FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/flacdsp_init.c
Date: 2026-04-24 19:58:39
Exec Total Coverage
Lines: 48 49 98.0%
Functions: 1 1 100.0%
Branches: 41 46 89.1%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2014 James Almer
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "libavutil/attributes.h"
22 #include "libavcodec/flacdsp.h"
23 #include "libavutil/x86/cpu.h"
24 #include "config.h"
25
26 void ff_flac_lpc_16_sse4(int32_t *samples, const int coeffs[32], int order,
27 int qlevel, int len);
28 void ff_flac_lpc_32_sse4(int32_t *samples, const int coeffs[32], int order,
29 int qlevel, int len);
30 void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
31 int qlevel, int len);
32
33 void ff_flac_wasted_32_sse2(int32_t *decoded, int wasted, int len);
34 void ff_flac_wasted_33_sse4(int64_t *decoded, const int32_t *residual, int wasted, int len);
35
36 #define DECORRELATE_FUNCS(fmt, opt) \
37 void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
38 int len, int shift); \
39 void ff_flac_decorrelate_rs_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
40 int len, int shift); \
41 void ff_flac_decorrelate_ms_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
42 int len, int shift)
43
44 #define DECORRELATE_IFUNCS(fmt, opt) \
45 void ff_flac_decorrelate_indep2_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
46 int len, int shift); \
47 void ff_flac_decorrelate_indep4_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
48 int len, int shift); \
49 void ff_flac_decorrelate_indep6_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
50 int len, int shift); \
51 void ff_flac_decorrelate_indep8_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
52 int len, int shift)
53
54 DECORRELATE_FUNCS(16, sse2);
55 DECORRELATE_FUNCS(16, avx);
56 DECORRELATE_FUNCS(32, sse2);
57 DECORRELATE_FUNCS(32, avx);
58 DECORRELATE_IFUNCS(16, ssse3);
59 DECORRELATE_IFUNCS(16, avx);
60 DECORRELATE_IFUNCS(32, ssse3);
61 DECORRELATE_IFUNCS(32, avx);
62
63 6567 av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels)
64 {
65 6567 int cpu_flags = av_get_cpu_flags();
66
67
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 2777 times.
6567 if (EXTERNAL_SSE2(cpu_flags)) {
68 3790 c->wasted32 = ff_flac_wasted_32_sse2;
69
2/2
✓ Branch 0 taken 3434 times.
✓ Branch 1 taken 356 times.
3790 if (fmt == AV_SAMPLE_FMT_S16) {
70 3434 c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2;
71 3434 c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2;
72 3434 c->decorrelate[3] = ff_flac_decorrelate_ms_16_sse2;
73
1/2
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
356 } else if (fmt == AV_SAMPLE_FMT_S32) {
74 356 c->decorrelate[1] = ff_flac_decorrelate_ls_32_sse2;
75 356 c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2;
76 356 c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2;
77 }
78 }
79
2/2
✓ Branch 0 taken 3770 times.
✓ Branch 1 taken 2797 times.
6567 if (EXTERNAL_SSSE3(cpu_flags)) {
80
2/2
✓ Branch 0 taken 3424 times.
✓ Branch 1 taken 346 times.
3770 if (fmt == AV_SAMPLE_FMT_S16) {
81
2/2
✓ Branch 0 taken 1724 times.
✓ Branch 1 taken 1700 times.
3424 if (channels == 2)
82 1724 c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3;
83
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1692 times.
1700 else if (channels == 4)
84 8 c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3;
85
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 884 times.
1692 else if (channels == 6)
86 808 c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3;
87 #if ARCH_X86_64
88
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 876 times.
884 else if (channels == 8)
89 8 c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3;
90 #endif
91
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 } else if (fmt == AV_SAMPLE_FMT_S32) {
92
2/2
✓ Branch 0 taken 319 times.
✓ Branch 1 taken 27 times.
346 if (channels == 2)
93 319 c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3;
94
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 19 times.
27 else if (channels == 4)
95 8 c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3;
96
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 8 times.
19 else if (channels == 6)
97 11 c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3;
98 #if ARCH_X86_64
99
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 else if (channels == 8)
100 8 c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3;
101 #endif
102 }
103 }
104
2/2
✓ Branch 0 taken 3760 times.
✓ Branch 1 taken 2807 times.
6567 if (EXTERNAL_SSE4(cpu_flags)) {
105 3760 c->lpc16 = ff_flac_lpc_16_sse4;
106 3760 c->lpc32 = ff_flac_lpc_32_sse4;
107 3760 c->wasted33 = ff_flac_wasted_33_sse4;
108 }
109
2/2
✓ Branch 0 taken 3720 times.
✓ Branch 1 taken 2847 times.
6567 if (EXTERNAL_AVX(cpu_flags)) {
110
2/2
✓ Branch 0 taken 3399 times.
✓ Branch 1 taken 321 times.
3720 if (fmt == AV_SAMPLE_FMT_S16) {
111 #if ARCH_X86_64
112
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3396 times.
3399 if (channels == 8)
113 3 c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx;
114 #endif
115
1/2
✓ Branch 0 taken 321 times.
✗ Branch 1 not taken.
321 } else if (fmt == AV_SAMPLE_FMT_S32) {
116
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 318 times.
321 if (channels == 4)
117 3 c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx;
118
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 312 times.
318 else if (channels == 6)
119 6 c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx;
120 #if ARCH_X86_64
121
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 309 times.
312 else if (channels == 8)
122 3 c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx;
123 #endif
124 }
125 }
126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6567 times.
6567 if (EXTERNAL_XOP(cpu_flags)) {
127 c->lpc32 = ff_flac_lpc_32_xop;
128 }
129 6567 }
130