FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libswresample/x86/audio_convert_init.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 45 104 43.3%
Functions: 1 1 100.0%
Branches: 95 276 34.4%

Line Branch Exec Source
1 /*
2 * Copyright (C) 2012 Michael Niedermayer (michaelni@gmx.at)
3 *
4 * This file is part of libswresample
5 *
6 * libswresample 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 * libswresample 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 libswresample; 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 "libavutil/x86/cpu.h"
23 #include "libswresample/swresample_internal.h"
24 #include "libswresample/audioconvert.h"
25
26 #define PROTO(pre, in, out, cap) void ff ## pre ## in## _to_ ##out## _a_ ##cap(uint8_t **dst, const uint8_t **src, int len);
27 #define PROTO2(pre, out, cap) PROTO(pre, int16, out, cap) PROTO(pre, int32, out, cap) PROTO(pre, float, out, cap)
28 #define PROTO3(pre, cap) PROTO2(pre, int16, cap) PROTO2(pre, int32, cap) PROTO2(pre, float, cap)
29 #define PROTO4(pre) PROTO3(pre, sse) PROTO3(pre, sse2) PROTO3(pre, ssse3) PROTO3(pre, sse4) PROTO3(pre, avx) PROTO3(pre, avx2)
30 PROTO4(_)
31 PROTO4(_pack_2ch_)
32 PROTO4(_pack_6ch_)
33 PROTO4(_pack_8ch_)
34 PROTO4(_unpack_2ch_)
35 PROTO4(_unpack_6ch_)
36
37 2235 av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
38 enum AVSampleFormat out_fmt,
39 enum AVSampleFormat in_fmt,
40 int channels){
41 2235 int mm_flags = av_get_cpu_flags();
42
43 2235 ac->simd_f= NULL;
44
45 //FIXME add memcpy case
46
47 #define MULTI_CAPS_FUNC(flag, cap) \
48 if (EXTERNAL_##flag(mm_flags)) {\
49 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
50 ac->simd_f = ff_int16_to_int32_a_ ## cap;\
51 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
52 ac->simd_f = ff_int32_to_int16_a_ ## cap;\
53 }
54
55
8/18
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2205 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 30 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 30 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 12 times.
✓ Branch 15 taken 18 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 12 times.
2235 MULTI_CAPS_FUNC(SSE2, sse2)
56
57
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2205 times.
2235 if(EXTERNAL_SSE(mm_flags)) {
58
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(channels == 6) {
59 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
60 ac->simd_f = ff_pack_6ch_float_to_float_a_sse;
61
62 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
63 ac->simd_f = ff_unpack_6ch_float_to_float_a_sse;
64 }
65 }
66
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2205 times.
2235 if(EXTERNAL_SSE2(mm_flags)) {
67
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 27 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
30 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
68 ac->simd_f = ff_int32_to_float_a_sse2;
69
8/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 26 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 2 times.
30 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
70 2 ac->simd_f = ff_int16_to_float_a_sse2;
71
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
30 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
72 ac->simd_f = ff_float_to_int32_a_sse2;
73
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 18 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
30 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
74 ac->simd_f = ff_float_to_int16_a_sse2;
75
76
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 25 times.
30 if(channels == 2) {
77
5/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
78 1 ac->simd_f = ff_pack_2ch_int32_to_int32_a_sse2;
79
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S16P)
80 ac->simd_f = ff_pack_2ch_int16_to_int16_a_sse2;
81
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S16P)
82 ac->simd_f = ff_pack_2ch_int16_to_int32_a_sse2;
83
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_S32P)
84 ac->simd_f = ff_pack_2ch_int32_to_int16_a_sse2;
85
86
4/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
87 ac->simd_f = ff_unpack_2ch_int32_to_int32_a_sse2;
88
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
89 ac->simd_f = ff_unpack_2ch_int16_to_int16_a_sse2;
90
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
91 ac->simd_f = ff_unpack_2ch_int16_to_int32_a_sse2;
92
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32)
93 ac->simd_f = ff_unpack_2ch_int32_to_int16_a_sse2;
94
95
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
5 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
96 ac->simd_f = ff_pack_2ch_int32_to_float_a_sse2;
97
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
98 ac->simd_f = ff_pack_2ch_float_to_int32_a_sse2;
99
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
5 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S16P)
100 ac->simd_f = ff_pack_2ch_int16_to_float_a_sse2;
101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S16 && in_fmt == AV_SAMPLE_FMT_FLTP)
102 ac->simd_f = ff_pack_2ch_float_to_int16_a_sse2;
103
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
5 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
104 ac->simd_f = ff_unpack_2ch_int32_to_float_a_sse2;
105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
106 ac->simd_f = ff_unpack_2ch_float_to_int32_a_sse2;
107
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
5 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
108 ac->simd_f = ff_unpack_2ch_int16_to_float_a_sse2;
109
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLT)
110 ac->simd_f = ff_unpack_2ch_float_to_int16_a_sse2;
111 }
112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(channels == 6) {
113 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
114 ac->simd_f = ff_pack_6ch_int32_to_float_a_sse2;
115 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
116 ac->simd_f = ff_pack_6ch_float_to_int32_a_sse2;
117
118 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
119 ac->simd_f = ff_unpack_6ch_int32_to_float_a_sse2;
120 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
121 ac->simd_f = ff_unpack_6ch_float_to_int32_a_sse2;
122 }
123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(channels == 8) {
124 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
125 ac->simd_f = ff_pack_8ch_float_to_float_a_sse2;
126 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
127 ac->simd_f = ff_pack_8ch_int32_to_float_a_sse2;
128 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
129 ac->simd_f = ff_pack_8ch_float_to_int32_a_sse2;
130 }
131 }
132
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2205 times.
2235 if(EXTERNAL_SSSE3(mm_flags)) {
133
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 25 times.
30 if(channels == 2) {
134
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S16)
135 ac->simd_f = ff_unpack_2ch_int16_to_int16_a_ssse3;
136
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16)
137 ac->simd_f = ff_unpack_2ch_int16_to_int32_a_ssse3;
138
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
5 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16)
139 ac->simd_f = ff_unpack_2ch_int16_to_float_a_ssse3;
140 }
141 }
142
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2205 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
2235 if(EXTERNAL_AVX_FAST(mm_flags)) {
143
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 27 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
30 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
144 ac->simd_f = ff_int32_to_float_a_avx;
145 }
146
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2205 times.
2235 if(EXTERNAL_AVX(mm_flags)) {
147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(channels == 6) {
148 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
149 ac->simd_f = ff_pack_6ch_float_to_float_a_avx;
150 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
151 ac->simd_f = ff_pack_6ch_int32_to_float_a_avx;
152 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
153 ac->simd_f = ff_pack_6ch_float_to_int32_a_avx;
154
155 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
156 ac->simd_f = ff_unpack_6ch_float_to_float_a_avx;
157 if( out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32)
158 ac->simd_f = ff_unpack_6ch_int32_to_float_a_avx;
159 if( out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLT)
160 ac->simd_f = ff_unpack_6ch_float_to_int32_a_avx;
161 }
162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if(channels == 8) {
163 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
164 ac->simd_f = ff_pack_8ch_float_to_float_a_avx;
165 if( out_fmt == AV_SAMPLE_FMT_FLT && in_fmt == AV_SAMPLE_FMT_S32P)
166 ac->simd_f = ff_pack_8ch_int32_to_float_a_avx;
167 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLTP)
168 ac->simd_f = ff_pack_8ch_float_to_int32_a_avx;
169 }
170 }
171
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 2205 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
2235 if(EXTERNAL_AVX2_FAST(mm_flags)) {
172
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 30 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
30 if( out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
173 ac->simd_f = ff_float_to_int32_a_avx2;
174 }
175 2235 }
176