../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
20 / 20
100.0%
Branches:
33 / 84
39.3%
Functions:
2 / 2
100.0%

libavcodec/x86/ac3dsp_init.c
Line Branch Exec Source
1 /*
2 * x86-optimized AC-3 DSP functions
3 * Copyright (c) 2011 Justin Ruggles
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "libavutil/attributes.h"
23 #include "libavutil/x86/cpu.h"
24 #include "libavcodec/ac3dsp.h"
25
26 void ff_ac3_exponent_min_sse2 (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
27
28 void ff_float_to_fixed24_sse2 (int32_t *dst, const float *src, size_t len);
29 void ff_float_to_fixed24_avx (int32_t *dst, const float *src, size_t len);
30
31 int ff_ac3_compute_mantissa_size_sse2(const uint16_t mant_cnt[6][16]);
32
33 void ff_ac3_extract_exponents_sse2 (uint8_t *exp, const int32_t *coef, int nb_coefs);
34 void ff_ac3_extract_exponents_ssse3(uint8_t *exp, const int32_t *coef, int nb_coefs);
35
36 155 av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c)
37 {
38 155 int cpu_flags = av_get_cpu_flags();
39
40
2/2
✓ Branch 3 → 4 taken 43 times.
✓ Branch 3 → 5 taken 112 times.
155 if (EXTERNAL_SSE2(cpu_flags)) {
41 43 c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
42 43 c->float_to_fixed24 = ff_float_to_fixed24_sse2;
43 43 c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
44 43 c->extract_exponents = ff_ac3_extract_exponents_sse2;
45 }
46
47
2/2
✓ Branch 5 → 6 taken 41 times.
✓ Branch 5 → 8 taken 114 times.
155 if (EXTERNAL_SSSE3(cpu_flags)) {
48
1/2
✓ Branch 6 → 7 taken 41 times.
✗ Branch 6 → 8 not taken.
41 if (!(cpu_flags & AV_CPU_FLAG_ATOM))
49 41 c->extract_exponents = ff_ac3_extract_exponents_ssse3;
50 }
51
3/4
✓ Branch 8 → 9 taken 36 times.
✓ Branch 8 → 11 taken 119 times.
✓ Branch 9 → 10 taken 36 times.
✗ Branch 9 → 11 not taken.
155 if (EXTERNAL_AVX_FAST(cpu_flags)) {
52 36 c->float_to_fixed24 = ff_float_to_fixed24_avx;
53 }
54 155 }
55
56 #define DOWNMIX_FUNC_OPT(ch, opt) \
57 void ff_ac3_downmix_ ## ch ## _to_1_ ## opt(float **samples, \
58 float **matrix, int len); \
59 void ff_ac3_downmix_ ## ch ## _to_2_ ## opt(float **samples, \
60 float **matrix, int len);
61
62 #define DOWNMIX_FUNCS(opt) \
63 DOWNMIX_FUNC_OPT(3, opt) \
64 DOWNMIX_FUNC_OPT(4, opt) \
65 DOWNMIX_FUNC_OPT(5, opt) \
66 DOWNMIX_FUNC_OPT(6, opt)
67
68 DOWNMIX_FUNCS(sse)
69 DOWNMIX_FUNCS(avx)
70 DOWNMIX_FUNCS(fma3)
71
72 11 void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c)
73 {
74 11 int cpu_flags = av_get_cpu_flags();
75
76 #define SET_DOWNMIX(ch, suf, SUF) \
77 if (ch == c->in_channels) { \
78 if (EXTERNAL_ ## SUF (cpu_flags)) { \
79 if (c->out_channels == 1) \
80 c->downmix = ff_ac3_downmix_ ## ch ## _to_1_ ## suf; \
81 else \
82 c->downmix = ff_ac3_downmix_ ## ch ## _to_2_ ## suf; \
83 } \
84 }
85
86 #define SET_DOWNMIX_ALL(suf, SUF) \
87 SET_DOWNMIX(3, suf, SUF) \
88 SET_DOWNMIX(4, suf, SUF) \
89 SET_DOWNMIX(5, suf, SUF) \
90 SET_DOWNMIX(6, suf, SUF)
91
92
8/24
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 8 taken 11 times.
✗ Branch 4 → 5 not taken.
✗ Branch 4 → 8 not taken.
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
✓ Branch 8 → 9 taken 5 times.
✓ Branch 8 → 13 taken 6 times.
✗ Branch 9 → 10 not taken.
✓ Branch 9 → 13 taken 5 times.
✗ Branch 10 → 11 not taken.
✗ Branch 10 → 12 not taken.
✓ Branch 13 → 14 taken 6 times.
✓ Branch 13 → 18 taken 5 times.
✗ Branch 14 → 15 not taken.
✓ Branch 14 → 18 taken 6 times.
✗ Branch 15 → 16 not taken.
✗ Branch 15 → 17 not taken.
✗ Branch 18 → 19 not taken.
✓ Branch 18 → 23 taken 11 times.
✗ Branch 19 → 20 not taken.
✗ Branch 19 → 23 not taken.
✗ Branch 20 → 21 not taken.
✗ Branch 20 → 22 not taken.
11 SET_DOWNMIX_ALL(sse, SSE)
93
1/2
✓ Branch 23 → 24 taken 11 times.
✗ Branch 23 → 64 not taken.
11 if (!(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
94
8/24
✗ Branch 24 → 25 not taken.
✓ Branch 24 → 29 taken 11 times.
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 29 not taken.
✗ Branch 26 → 27 not taken.
✗ Branch 26 → 28 not taken.
✓ Branch 29 → 30 taken 5 times.
✓ Branch 29 → 34 taken 6 times.
✗ Branch 30 → 31 not taken.
✓ Branch 30 → 34 taken 5 times.
✗ Branch 31 → 32 not taken.
✗ Branch 31 → 33 not taken.
✓ Branch 34 → 35 taken 6 times.
✓ Branch 34 → 39 taken 5 times.
✗ Branch 35 → 36 not taken.
✓ Branch 35 → 39 taken 6 times.
✗ Branch 36 → 37 not taken.
✗ Branch 36 → 38 not taken.
✗ Branch 39 → 40 not taken.
✓ Branch 39 → 44 taken 11 times.
✗ Branch 40 → 41 not taken.
✗ Branch 40 → 44 not taken.
✗ Branch 41 → 42 not taken.
✗ Branch 41 → 43 not taken.
11 SET_DOWNMIX_ALL(avx, AVX)
95
8/24
✗ Branch 44 → 45 not taken.
✓ Branch 44 → 49 taken 11 times.
✗ Branch 45 → 46 not taken.
✗ Branch 45 → 49 not taken.
✗ Branch 46 → 47 not taken.
✗ Branch 46 → 48 not taken.
✓ Branch 49 → 50 taken 5 times.
✓ Branch 49 → 54 taken 6 times.
✗ Branch 50 → 51 not taken.
✓ Branch 50 → 54 taken 5 times.
✗ Branch 51 → 52 not taken.
✗ Branch 51 → 53 not taken.
✓ Branch 54 → 55 taken 6 times.
✓ Branch 54 → 59 taken 5 times.
✗ Branch 55 → 56 not taken.
✓ Branch 55 → 59 taken 6 times.
✗ Branch 56 → 57 not taken.
✗ Branch 56 → 58 not taken.
✗ Branch 59 → 60 not taken.
✓ Branch 59 → 64 taken 11 times.
✗ Branch 60 → 61 not taken.
✗ Branch 60 → 64 not taken.
✗ Branch 61 → 62 not taken.
✗ Branch 61 → 63 not taken.
11 SET_DOWNMIX_ALL(fma3, FMA3)
96 }
97 11 }
98