FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/flacdsp_init.c
Date: 2024-04-19 07:31:02
Exec Total Coverage
Lines: 45 46 97.8%
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_32_sse4(int32_t *samples, const int coeffs[32], int order,
27 int qlevel, int len);
28 void ff_flac_lpc_32_xop(int32_t *samples, const int coeffs[32], int order,
29 int qlevel, int len);
30
31 #define DECORRELATE_FUNCS(fmt, opt) \
32 void ff_flac_decorrelate_ls_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
33 int len, int shift); \
34 void ff_flac_decorrelate_rs_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
35 int len, int shift); \
36 void ff_flac_decorrelate_ms_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
37 int len, int shift)
38
39 #define DECORRELATE_IFUNCS(fmt, opt) \
40 void ff_flac_decorrelate_indep2_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
41 int len, int shift); \
42 void ff_flac_decorrelate_indep4_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
43 int len, int shift); \
44 void ff_flac_decorrelate_indep6_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
45 int len, int shift); \
46 void ff_flac_decorrelate_indep8_##fmt##_##opt(uint8_t **out, int32_t **in, int channels, \
47 int len, int shift)
48
49 DECORRELATE_FUNCS(16, sse2);
50 DECORRELATE_FUNCS(16, avx);
51 DECORRELATE_FUNCS(32, sse2);
52 DECORRELATE_FUNCS(32, avx);
53 DECORRELATE_IFUNCS(16, ssse3);
54 DECORRELATE_IFUNCS(16, avx);
55 DECORRELATE_IFUNCS(32, ssse3);
56 DECORRELATE_IFUNCS(32, avx);
57
58 6427 av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels)
59 {
60 #if HAVE_X86ASM
61 6427 int cpu_flags = av_get_cpu_flags();
62
63
2/2
✓ Branch 0 taken 3712 times.
✓ Branch 1 taken 2715 times.
6427 if (EXTERNAL_SSE2(cpu_flags)) {
64
2/2
✓ Branch 0 taken 3364 times.
✓ Branch 1 taken 348 times.
3712 if (fmt == AV_SAMPLE_FMT_S16) {
65 3364 c->decorrelate[1] = ff_flac_decorrelate_ls_16_sse2;
66 3364 c->decorrelate[2] = ff_flac_decorrelate_rs_16_sse2;
67 3364 c->decorrelate[3] = ff_flac_decorrelate_ms_16_sse2;
68
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 } else if (fmt == AV_SAMPLE_FMT_S32) {
69 348 c->decorrelate[1] = ff_flac_decorrelate_ls_32_sse2;
70 348 c->decorrelate[2] = ff_flac_decorrelate_rs_32_sse2;
71 348 c->decorrelate[3] = ff_flac_decorrelate_ms_32_sse2;
72 }
73 }
74
2/2
✓ Branch 0 taken 3692 times.
✓ Branch 1 taken 2735 times.
6427 if (EXTERNAL_SSSE3(cpu_flags)) {
75
2/2
✓ Branch 0 taken 3354 times.
✓ Branch 1 taken 338 times.
3692 if (fmt == AV_SAMPLE_FMT_S16) {
76
2/2
✓ Branch 0 taken 1691 times.
✓ Branch 1 taken 1663 times.
3354 if (channels == 2)
77 1691 c->decorrelate[0] = ff_flac_decorrelate_indep2_16_ssse3;
78
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1656 times.
1663 else if (channels == 4)
79 7 c->decorrelate[0] = ff_flac_decorrelate_indep4_16_ssse3;
80
2/2
✓ Branch 0 taken 807 times.
✓ Branch 1 taken 849 times.
1656 else if (channels == 6)
81 807 c->decorrelate[0] = ff_flac_decorrelate_indep6_16_ssse3;
82
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 842 times.
849 else if (ARCH_X86_64 && channels == 8)
83 7 c->decorrelate[0] = ff_flac_decorrelate_indep8_16_ssse3;
84
1/2
✓ Branch 0 taken 338 times.
✗ Branch 1 not taken.
338 } else if (fmt == AV_SAMPLE_FMT_S32) {
85
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 21 times.
338 if (channels == 2)
86 317 c->decorrelate[0] = ff_flac_decorrelate_indep2_32_ssse3;
87
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14 times.
21 else if (channels == 4)
88 7 c->decorrelate[0] = ff_flac_decorrelate_indep4_32_ssse3;
89
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
14 else if (channels == 6)
90 7 c->decorrelate[0] = ff_flac_decorrelate_indep6_32_ssse3;
91
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 else if (ARCH_X86_64 && channels == 8)
92 7 c->decorrelate[0] = ff_flac_decorrelate_indep8_32_ssse3;
93 }
94 }
95
2/2
✓ Branch 0 taken 3682 times.
✓ Branch 1 taken 2745 times.
6427 if (EXTERNAL_SSE4(cpu_flags)) {
96 3682 c->lpc32 = ff_flac_lpc_32_sse4;
97 }
98
2/2
✓ Branch 0 taken 3652 times.
✓ Branch 1 taken 2775 times.
6427 if (EXTERNAL_AVX(cpu_flags)) {
99
2/2
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 318 times.
3652 if (fmt == AV_SAMPLE_FMT_S16) {
100
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3331 times.
3334 if (ARCH_X86_64 && channels == 8)
101 3 c->decorrelate[0] = ff_flac_decorrelate_indep8_16_avx;
102
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 } else if (fmt == AV_SAMPLE_FMT_S32) {
103
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 315 times.
318 if (channels == 4)
104 3 c->decorrelate[0] = ff_flac_decorrelate_indep4_32_avx;
105
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 312 times.
315 else if (channels == 6)
106 3 c->decorrelate[0] = ff_flac_decorrelate_indep6_32_avx;
107
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 309 times.
312 else if (ARCH_X86_64 && channels == 8)
108 3 c->decorrelate[0] = ff_flac_decorrelate_indep8_32_avx;
109 }
110 }
111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6427 times.
6427 if (EXTERNAL_XOP(cpu_flags)) {
112 c->lpc32 = ff_flac_lpc_32_xop;
113 }
114 #endif /* HAVE_X86ASM */
115 6427 }
116