FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/ac3dsp_init.c
Date: 2021-09-24 20:55:06
Exec Total Coverage
Lines: 25 27 92.6%
Branches: 37 90 41.1%

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/asm.h"
24 #include "libavutil/x86/cpu.h"
25 #include "libavcodec/ac3.h"
26 #include "libavcodec/ac3dsp.h"
27
28 void ff_ac3_exponent_min_mmx (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
29 void ff_ac3_exponent_min_mmxext(uint8_t *exp, int num_reuse_blocks, int nb_coefs);
30 void ff_ac3_exponent_min_sse2 (uint8_t *exp, int num_reuse_blocks, int nb_coefs);
31
32 void ff_float_to_fixed24_3dnow(int32_t *dst, const float *src, unsigned int len);
33 void ff_float_to_fixed24_sse (int32_t *dst, const float *src, unsigned int len);
34 void ff_float_to_fixed24_sse2 (int32_t *dst, const float *src, unsigned int len);
35
36 int ff_ac3_compute_mantissa_size_sse2(uint16_t mant_cnt[6][16]);
37
38 void ff_ac3_extract_exponents_sse2 (uint8_t *exp, int32_t *coef, int nb_coefs);
39 void ff_ac3_extract_exponents_ssse3(uint8_t *exp, int32_t *coef, int nb_coefs);
40
41 75 av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact)
42 {
43 75 int cpu_flags = av_get_cpu_flags();
44
45
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 55 times.
75 if (EXTERNAL_MMX(cpu_flags)) {
46 20 c->ac3_exponent_min = ff_ac3_exponent_min_mmx;
47 }
48
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if (EXTERNAL_AMD3DNOW(cpu_flags)) {
49 if (!bit_exact) {
50 c->float_to_fixed24 = ff_float_to_fixed24_3dnow;
51 }
52 }
53
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 55 times.
75 if (EXTERNAL_MMXEXT(cpu_flags)) {
54 20 c->ac3_exponent_min = ff_ac3_exponent_min_mmxext;
55 }
56
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 55 times.
75 if (EXTERNAL_SSE(cpu_flags)) {
57 20 c->float_to_fixed24 = ff_float_to_fixed24_sse;
58 }
59
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 55 times.
75 if (EXTERNAL_SSE2(cpu_flags)) {
60 20 c->ac3_exponent_min = ff_ac3_exponent_min_sse2;
61 20 c->float_to_fixed24 = ff_float_to_fixed24_sse2;
62 20 c->compute_mantissa_size = ff_ac3_compute_mantissa_size_sse2;
63 20 c->extract_exponents = ff_ac3_extract_exponents_sse2;
64 }
65
66
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 55 times.
75 if (EXTERNAL_SSSE3(cpu_flags)) {
67
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if (!(cpu_flags & AV_CPU_FLAG_ATOM))
68 20 c->extract_exponents = ff_ac3_extract_exponents_ssse3;
69 }
70 75 }
71
72 #define DOWNMIX_FUNC_OPT(ch, opt) \
73 void ff_ac3_downmix_ ## ch ## _to_1_ ## opt(float **samples, \
74 float **matrix, int len); \
75 void ff_ac3_downmix_ ## ch ## _to_2_ ## opt(float **samples, \
76 float **matrix, int len);
77
78 #define DOWNMIX_FUNCS(opt) \
79 DOWNMIX_FUNC_OPT(3, opt) \
80 DOWNMIX_FUNC_OPT(4, opt) \
81 DOWNMIX_FUNC_OPT(5, opt) \
82 DOWNMIX_FUNC_OPT(6, opt)
83
84 DOWNMIX_FUNCS(sse)
85 DOWNMIX_FUNCS(avx)
86 DOWNMIX_FUNCS(fma3)
87
88 11 void ff_ac3dsp_set_downmix_x86(AC3DSPContext *c)
89 {
90 11 int cpu_flags = av_get_cpu_flags();
91
92 #define SET_DOWNMIX(ch, suf, SUF) \
93 if (ch == c->in_channels) { \
94 if (EXTERNAL_ ## SUF (cpu_flags)) { \
95 if (c->out_channels == 1) \
96 c->downmix = ff_ac3_downmix_ ## ch ## _to_1_ ## suf; \
97 else \
98 c->downmix = ff_ac3_downmix_ ## ch ## _to_2_ ## suf; \
99 } \
100 }
101
102 #define SET_DOWNMIX_ALL(suf, SUF) \
103 SET_DOWNMIX(3, suf, SUF) \
104 SET_DOWNMIX(4, suf, SUF) \
105 SET_DOWNMIX(5, suf, SUF) \
106 SET_DOWNMIX(6, suf, SUF)
107
108
8/24
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 6 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 11 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
11 SET_DOWNMIX_ALL(sse, SSE)
109
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if (!(cpu_flags & AV_CPU_FLAG_AVXSLOW)) {
110
8/24
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 6 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 11 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
11 SET_DOWNMIX_ALL(avx, AVX)
111
8/24
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✓ Branch 13 taken 5 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 6 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 11 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
11 SET_DOWNMIX_ALL(fma3, FMA3)
112 }
113 11 }
114