Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * MPEG-4 Parametric Stereo decoding functions | ||
3 | * Copyright (c) 2010 Alex Converse <alex.converse@gmail.com> | ||
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 | * Note: Rounding-to-nearest used unless otherwise stated | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #include <stdint.h> | ||
26 | #include "libavutil/common.h" | ||
27 | #include "libavutil/mathematics.h" | ||
28 | #include "libavutil/mem_internal.h" | ||
29 | #include "avcodec.h" | ||
30 | #include "aacps.h" | ||
31 | #if USE_FIXED | ||
32 | #include "aacps_fixed_tablegen.h" | ||
33 | #else | ||
34 | #include "libavutil/internal.h" | ||
35 | #include "aacps_tablegen.h" | ||
36 | #endif /* USE_FIXED */ | ||
37 | |||
38 | static const INTFLOAT g1_Q2[] = { | ||
39 | Q31(0.0f), Q31(0.01899487526049f), Q31(0.0f), Q31(-0.07293139167538f), | ||
40 | Q31(0.0f), Q31(0.30596630545168f), Q31(0.5f) | ||
41 | }; | ||
42 | |||
43 | 3 | static void ipdopd_reset(int8_t *ipd_hist, int8_t *opd_hist) | |
44 | { | ||
45 | int i; | ||
46 |
2/2✓ Branch 0 taken 51 times.
✓ Branch 1 taken 3 times.
|
54 | for (i = 0; i < PS_MAX_NR_IPDOPD; i++) { |
47 | 51 | opd_hist[i] = 0; | |
48 | 51 | ipd_hist[i] = 0; | |
49 | } | ||
50 | 3 | } | |
51 | |||
52 | /** Split one subband into 2 subsubbands with a symmetric real filter. | ||
53 | * The filter must have its non-center even coefficients equal to zero. */ | ||
54 | 3028 | static void hybrid2_re(INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], | |
55 | const INTFLOAT filter[7], int len, int reverse) | ||
56 | { | ||
57 | int i, j; | ||
58 |
2/2✓ Branch 0 taken 96896 times.
✓ Branch 1 taken 3028 times.
|
99924 | for (i = 0; i < len; i++, in++) { |
59 | 96896 | INT64FLOAT re_in = AAC_MUL31(filter[6], in[6][0]); //real inphase | |
60 | 96896 | INT64FLOAT re_op = 0.0f; //real out of phase | |
61 | 96896 | INT64FLOAT im_in = AAC_MUL31(filter[6], in[6][1]); //imag inphase | |
62 | 96896 | INT64FLOAT im_op = 0.0f; //imag out of phase | |
63 |
2/2✓ Branch 0 taken 290688 times.
✓ Branch 1 taken 96896 times.
|
387584 | for (j = 0; j < 6; j += 2) { |
64 | 290688 | re_op += (INT64FLOAT)filter[j+1] * (in[j+1][0] + in[12-j-1][0]); | |
65 | 290688 | im_op += (INT64FLOAT)filter[j+1] * (in[j+1][1] + in[12-j-1][1]); | |
66 | } | ||
67 | |||
68 | #if USE_FIXED | ||
69 | ✗ | re_op = (re_op + 0x40000000) >> 31; | |
70 | ✗ | im_op = (im_op + 0x40000000) >> 31; | |
71 | #endif /* USE_FIXED */ | ||
72 | |||
73 | 96896 | out[ reverse][i][0] = (INTFLOAT)(re_in + re_op); | |
74 | 96896 | out[ reverse][i][1] = (INTFLOAT)(im_in + im_op); | |
75 |
2/2✓ Branch 0 taken 48448 times.
✓ Branch 1 taken 48448 times.
|
96896 | out[!reverse][i][0] = (INTFLOAT)(re_in - re_op); |
76 |
2/2✓ Branch 0 taken 48448 times.
✓ Branch 1 taken 48448 times.
|
96896 | out[!reverse][i][1] = (INTFLOAT)(im_in - im_op); |
77 | } | ||
78 | 3028 | } | |
79 | |||
80 | /** Split one subband into 6 subsubbands with a complex filter */ | ||
81 | 1514 | static void hybrid6_cx(PSDSPContext *dsp, INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], | |
82 | TABLE_CONST INTFLOAT (*filter)[8][2], int len) | ||
83 | { | ||
84 | int i; | ||
85 | 1514 | int N = 8; | |
86 | 1514 | LOCAL_ALIGNED_16(INTFLOAT, temp, [8], [2]); | |
87 | |||
88 |
2/2✓ Branch 0 taken 48448 times.
✓ Branch 1 taken 1514 times.
|
49962 | for (i = 0; i < len; i++, in++) { |
89 | 48448 | dsp->hybrid_analysis(temp, in, (const INTFLOAT (*)[8][2]) filter, 1, N); | |
90 | 48448 | out[0][i][0] = temp[6][0]; | |
91 | 48448 | out[0][i][1] = temp[6][1]; | |
92 | 48448 | out[1][i][0] = temp[7][0]; | |
93 | 48448 | out[1][i][1] = temp[7][1]; | |
94 | 48448 | out[2][i][0] = temp[0][0]; | |
95 | 48448 | out[2][i][1] = temp[0][1]; | |
96 | 48448 | out[3][i][0] = temp[1][0]; | |
97 | 48448 | out[3][i][1] = temp[1][1]; | |
98 | 48448 | out[4][i][0] = temp[2][0] + temp[5][0]; | |
99 | 48448 | out[4][i][1] = temp[2][1] + temp[5][1]; | |
100 | 48448 | out[5][i][0] = temp[3][0] + temp[4][0]; | |
101 | 48448 | out[5][i][1] = temp[3][1] + temp[4][1]; | |
102 | } | ||
103 | 1514 | } | |
104 | |||
105 | 510 | static void hybrid4_8_12_cx(PSDSPContext *dsp, | |
106 | INTFLOAT (*in)[2], INTFLOAT (*out)[32][2], | ||
107 | TABLE_CONST INTFLOAT (*filter)[8][2], int N, int len) | ||
108 | { | ||
109 | int i; | ||
110 | |||
111 |
2/2✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 510 times.
|
16830 | for (i = 0; i < len; i++, in++) { |
112 | 16320 | dsp->hybrid_analysis(out[0] + i, in, (const INTFLOAT (*)[8][2]) filter, 32, N); | |
113 | } | ||
114 | 510 | } | |
115 | |||
116 | 1616 | static void hybrid_analysis(PSDSPContext *dsp, INTFLOAT out[91][32][2], | |
117 | INTFLOAT in[5][44][2], INTFLOAT L[2][38][64], | ||
118 | int is34, int len) | ||
119 | { | ||
120 | int i, j; | ||
121 |
2/2✓ Branch 0 taken 8080 times.
✓ Branch 1 taken 1616 times.
|
9696 | for (i = 0; i < 5; i++) { |
122 |
2/2✓ Branch 0 taken 307040 times.
✓ Branch 1 taken 8080 times.
|
315120 | for (j = 0; j < 38; j++) { |
123 | 307040 | in[i][j+6][0] = L[0][j][i]; | |
124 | 307040 | in[i][j+6][1] = L[1][j][i]; | |
125 | } | ||
126 | } | ||
127 |
2/2✓ Branch 0 taken 102 times.
✓ Branch 1 taken 1514 times.
|
1616 | if (is34) { |
128 | 102 | hybrid4_8_12_cx(dsp, in[0], out, f34_0_12, 12, len); | |
129 | 102 | hybrid4_8_12_cx(dsp, in[1], out+12, f34_1_8, 8, len); | |
130 | 102 | hybrid4_8_12_cx(dsp, in[2], out+20, f34_2_4, 4, len); | |
131 | 102 | hybrid4_8_12_cx(dsp, in[3], out+24, f34_2_4, 4, len); | |
132 | 102 | hybrid4_8_12_cx(dsp, in[4], out+28, f34_2_4, 4, len); | |
133 | 102 | dsp->hybrid_analysis_ileave(out + 27, L, 5, len); | |
134 | } else { | ||
135 | 1514 | hybrid6_cx(dsp, in[0], out, f20_0_8, len); | |
136 | 1514 | hybrid2_re(in[1], out+6, g1_Q2, len, 1); | |
137 | 1514 | hybrid2_re(in[2], out+8, g1_Q2, len, 0); | |
138 | 1514 | dsp->hybrid_analysis_ileave(out + 7, L, 3, len); | |
139 | } | ||
140 | //update in_buf | ||
141 |
2/2✓ Branch 0 taken 8080 times.
✓ Branch 1 taken 1616 times.
|
9696 | for (i = 0; i < 5; i++) { |
142 | 8080 | memcpy(in[i], in[i]+32, 6 * sizeof(in[i][0])); | |
143 | } | ||
144 | 1616 | } | |
145 | |||
146 | 3232 | static void hybrid_synthesis(PSDSPContext *dsp, INTFLOAT out[2][38][64], | |
147 | INTFLOAT in[91][32][2], int is34, int len) | ||
148 | { | ||
149 | int i, n; | ||
150 |
2/2✓ Branch 0 taken 204 times.
✓ Branch 1 taken 3028 times.
|
3232 | if (is34) { |
151 |
2/2✓ Branch 0 taken 6528 times.
✓ Branch 1 taken 204 times.
|
6732 | for (n = 0; n < len; n++) { |
152 | 6528 | memset(out[0][n], 0, 5*sizeof(out[0][n][0])); | |
153 | 6528 | memset(out[1][n], 0, 5*sizeof(out[1][n][0])); | |
154 |
2/2✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 6528 times.
|
84864 | for (i = 0; i < 12; i++) { |
155 | 78336 | out[0][n][0] += (UINTFLOAT)in[ i][n][0]; | |
156 | 78336 | out[1][n][0] += (UINTFLOAT)in[ i][n][1]; | |
157 | } | ||
158 |
2/2✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 6528 times.
|
58752 | for (i = 0; i < 8; i++) { |
159 | 52224 | out[0][n][1] += (UINTFLOAT)in[12+i][n][0]; | |
160 | 52224 | out[1][n][1] += (UINTFLOAT)in[12+i][n][1]; | |
161 | } | ||
162 |
2/2✓ Branch 0 taken 26112 times.
✓ Branch 1 taken 6528 times.
|
32640 | for (i = 0; i < 4; i++) { |
163 | 26112 | out[0][n][2] += (UINTFLOAT)in[20+i][n][0]; | |
164 | 26112 | out[1][n][2] += (UINTFLOAT)in[20+i][n][1]; | |
165 | 26112 | out[0][n][3] += (UINTFLOAT)in[24+i][n][0]; | |
166 | 26112 | out[1][n][3] += (UINTFLOAT)in[24+i][n][1]; | |
167 | 26112 | out[0][n][4] += (UINTFLOAT)in[28+i][n][0]; | |
168 | 26112 | out[1][n][4] += (UINTFLOAT)in[28+i][n][1]; | |
169 | } | ||
170 | } | ||
171 | 204 | dsp->hybrid_synthesis_deint(out, in + 27, 5, len); | |
172 | } else { | ||
173 |
2/2✓ Branch 0 taken 96896 times.
✓ Branch 1 taken 3028 times.
|
99924 | for (n = 0; n < len; n++) { |
174 | 96896 | out[0][n][0] = (UINTFLOAT)in[0][n][0] + in[1][n][0] + in[2][n][0] + | |
175 | 96896 | (UINTFLOAT)in[3][n][0] + in[4][n][0] + in[5][n][0]; | |
176 | 96896 | out[1][n][0] = (UINTFLOAT)in[0][n][1] + in[1][n][1] + in[2][n][1] + | |
177 | 96896 | (UINTFLOAT)in[3][n][1] + in[4][n][1] + in[5][n][1]; | |
178 | 96896 | out[0][n][1] = (UINTFLOAT)in[6][n][0] + in[7][n][0]; | |
179 | 96896 | out[1][n][1] = (UINTFLOAT)in[6][n][1] + in[7][n][1]; | |
180 | 96896 | out[0][n][2] = (UINTFLOAT)in[8][n][0] + in[9][n][0]; | |
181 | 96896 | out[1][n][2] = (UINTFLOAT)in[8][n][1] + in[9][n][1]; | |
182 | } | ||
183 | 3028 | dsp->hybrid_synthesis_deint(out, in + 7, 3, len); | |
184 | } | ||
185 | 3232 | } | |
186 | |||
187 | /// All-pass filter decay slope | ||
188 | #define DECAY_SLOPE Q30(0.05f) | ||
189 | /// Number of frequency bands that can be addressed by the parameter index, b(k) | ||
190 | static const int NR_PAR_BANDS[] = { 20, 34 }; | ||
191 | static const int NR_IPDOPD_BANDS[] = { 11, 17 }; | ||
192 | /// Number of frequency bands that can be addressed by the sub subband index, k | ||
193 | static const int NR_BANDS[] = { 71, 91 }; | ||
194 | /// Start frequency band for the all-pass filter decay slope | ||
195 | static const int DECAY_CUTOFF[] = { 10, 32 }; | ||
196 | /// Number of all-pass filer bands | ||
197 | static const int NR_ALLPASS_BANDS[] = { 30, 50 }; | ||
198 | /// First stereo band using the short one sample delay | ||
199 | static const int SHORT_DELAY_BAND[] = { 42, 62 }; | ||
200 | |||
201 | /** Table 8.46 */ | ||
202 | 1 | static void map_idx_10_to_20(int8_t *par_mapped, const int8_t *par, int full) | |
203 | { | ||
204 | int b; | ||
205 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (full) |
206 | 1 | b = 9; | |
207 | else { | ||
208 | ✗ | b = 4; | |
209 | ✗ | par_mapped[10] = 0; | |
210 | } | ||
211 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
|
11 | for (; b >= 0; b--) { |
212 | 10 | par_mapped[2*b+1] = par_mapped[2*b] = par[b]; | |
213 | } | ||
214 | 1 | } | |
215 | |||
216 | 1 | static void map_idx_34_to_20(int8_t *par_mapped, const int8_t *par, int full) | |
217 | { | ||
218 | 1 | par_mapped[ 0] = (2*par[ 0] + par[ 1]) / 3; | |
219 | 1 | par_mapped[ 1] = ( par[ 1] + 2*par[ 2]) / 3; | |
220 | 1 | par_mapped[ 2] = (2*par[ 3] + par[ 4]) / 3; | |
221 | 1 | par_mapped[ 3] = ( par[ 4] + 2*par[ 5]) / 3; | |
222 | 1 | par_mapped[ 4] = ( par[ 6] + par[ 7]) / 2; | |
223 | 1 | par_mapped[ 5] = ( par[ 8] + par[ 9]) / 2; | |
224 | 1 | par_mapped[ 6] = par[10]; | |
225 | 1 | par_mapped[ 7] = par[11]; | |
226 | 1 | par_mapped[ 8] = ( par[12] + par[13]) / 2; | |
227 | 1 | par_mapped[ 9] = ( par[14] + par[15]) / 2; | |
228 | 1 | par_mapped[10] = par[16]; | |
229 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (full) { |
230 | 1 | par_mapped[11] = par[17]; | |
231 | 1 | par_mapped[12] = par[18]; | |
232 | 1 | par_mapped[13] = par[19]; | |
233 | 1 | par_mapped[14] = ( par[20] + par[21]) / 2; | |
234 | 1 | par_mapped[15] = ( par[22] + par[23]) / 2; | |
235 | 1 | par_mapped[16] = ( par[24] + par[25]) / 2; | |
236 | 1 | par_mapped[17] = ( par[26] + par[27]) / 2; | |
237 | 1 | par_mapped[18] = ( par[28] + par[29] + par[30] + par[31]) / 4; | |
238 | 1 | par_mapped[19] = ( par[32] + par[33]) / 2; | |
239 | } | ||
240 | 1 | } | |
241 | |||
242 | 8 | static void map_val_34_to_20(INTFLOAT par[PS_MAX_NR_IIDICC]) | |
243 | { | ||
244 | #if USE_FIXED | ||
245 | ✗ | par[ 0] = (int)(((int64_t)(par[ 0] + (unsigned)(par[ 1]>>1)) * 1431655765 + \ | |
246 | ✗ | 0x40000000) >> 31); | |
247 | ✗ | par[ 1] = (int)(((int64_t)((par[ 1]>>1) + (unsigned)par[ 2]) * 1431655765 + \ | |
248 | ✗ | 0x40000000) >> 31); | |
249 | ✗ | par[ 2] = (int)(((int64_t)(par[ 3] + (unsigned)(par[ 4]>>1)) * 1431655765 + \ | |
250 | ✗ | 0x40000000) >> 31); | |
251 | ✗ | par[ 3] = (int)(((int64_t)((par[ 4]>>1) + (unsigned)par[ 5]) * 1431655765 + \ | |
252 | ✗ | 0x40000000) >> 31); | |
253 | #else | ||
254 | 8 | par[ 0] = (2*par[ 0] + par[ 1]) * 0.33333333f; | |
255 | 8 | par[ 1] = ( par[ 1] + 2*par[ 2]) * 0.33333333f; | |
256 | 8 | par[ 2] = (2*par[ 3] + par[ 4]) * 0.33333333f; | |
257 | 8 | par[ 3] = ( par[ 4] + 2*par[ 5]) * 0.33333333f; | |
258 | #endif /* USE_FIXED */ | ||
259 | 8 | par[ 4] = AAC_HALF_SUM(par[ 6], par[ 7]); | |
260 | 8 | par[ 5] = AAC_HALF_SUM(par[ 8], par[ 9]); | |
261 | 8 | par[ 6] = par[10]; | |
262 | 8 | par[ 7] = par[11]; | |
263 | 8 | par[ 8] = AAC_HALF_SUM(par[12], par[13]); | |
264 | 8 | par[ 9] = AAC_HALF_SUM(par[14], par[15]); | |
265 | 8 | par[10] = par[16]; | |
266 | 8 | par[11] = par[17]; | |
267 | 8 | par[12] = par[18]; | |
268 | 8 | par[13] = par[19]; | |
269 | 8 | par[14] = AAC_HALF_SUM(par[20], par[21]); | |
270 | 8 | par[15] = AAC_HALF_SUM(par[22], par[23]); | |
271 | 8 | par[16] = AAC_HALF_SUM(par[24], par[25]); | |
272 | 8 | par[17] = AAC_HALF_SUM(par[26], par[27]); | |
273 | #if USE_FIXED | ||
274 | ✗ | par[18] = (((par[28]+2)>>2) + ((par[29]+2)>>2) + ((par[30]+2)>>2) + ((par[31]+2)>>2)); | |
275 | #else | ||
276 | 8 | par[18] = ( par[28] + par[29] + par[30] + par[31]) * 0.25f; | |
277 | #endif /* USE_FIXED */ | ||
278 | 8 | par[19] = AAC_HALF_SUM(par[32], par[33]); | |
279 | 8 | } | |
280 | |||
281 | 204 | static void map_idx_10_to_34(int8_t *par_mapped, const int8_t *par, int full) | |
282 | { | ||
283 |
1/2✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
|
204 | if (full) { |
284 | 204 | par_mapped[33] = par[9]; | |
285 | 204 | par_mapped[32] = par[9]; | |
286 | 204 | par_mapped[31] = par[9]; | |
287 | 204 | par_mapped[30] = par[9]; | |
288 | 204 | par_mapped[29] = par[9]; | |
289 | 204 | par_mapped[28] = par[9]; | |
290 | 204 | par_mapped[27] = par[8]; | |
291 | 204 | par_mapped[26] = par[8]; | |
292 | 204 | par_mapped[25] = par[8]; | |
293 | 204 | par_mapped[24] = par[8]; | |
294 | 204 | par_mapped[23] = par[7]; | |
295 | 204 | par_mapped[22] = par[7]; | |
296 | 204 | par_mapped[21] = par[7]; | |
297 | 204 | par_mapped[20] = par[7]; | |
298 | 204 | par_mapped[19] = par[6]; | |
299 | 204 | par_mapped[18] = par[6]; | |
300 | 204 | par_mapped[17] = par[5]; | |
301 | 204 | par_mapped[16] = par[5]; | |
302 | } else { | ||
303 | ✗ | par_mapped[16] = 0; | |
304 | } | ||
305 | 204 | par_mapped[15] = par[4]; | |
306 | 204 | par_mapped[14] = par[4]; | |
307 | 204 | par_mapped[13] = par[4]; | |
308 | 204 | par_mapped[12] = par[4]; | |
309 | 204 | par_mapped[11] = par[3]; | |
310 | 204 | par_mapped[10] = par[3]; | |
311 | 204 | par_mapped[ 9] = par[2]; | |
312 | 204 | par_mapped[ 8] = par[2]; | |
313 | 204 | par_mapped[ 7] = par[2]; | |
314 | 204 | par_mapped[ 6] = par[2]; | |
315 | 204 | par_mapped[ 5] = par[1]; | |
316 | 204 | par_mapped[ 4] = par[1]; | |
317 | 204 | par_mapped[ 3] = par[1]; | |
318 | 204 | par_mapped[ 2] = par[0]; | |
319 | 204 | par_mapped[ 1] = par[0]; | |
320 | 204 | par_mapped[ 0] = par[0]; | |
321 | 204 | } | |
322 | |||
323 | ✗ | static void map_idx_20_to_34(int8_t *par_mapped, const int8_t *par, int full) | |
324 | { | ||
325 | ✗ | if (full) { | |
326 | ✗ | par_mapped[33] = par[19]; | |
327 | ✗ | par_mapped[32] = par[19]; | |
328 | ✗ | par_mapped[31] = par[18]; | |
329 | ✗ | par_mapped[30] = par[18]; | |
330 | ✗ | par_mapped[29] = par[18]; | |
331 | ✗ | par_mapped[28] = par[18]; | |
332 | ✗ | par_mapped[27] = par[17]; | |
333 | ✗ | par_mapped[26] = par[17]; | |
334 | ✗ | par_mapped[25] = par[16]; | |
335 | ✗ | par_mapped[24] = par[16]; | |
336 | ✗ | par_mapped[23] = par[15]; | |
337 | ✗ | par_mapped[22] = par[15]; | |
338 | ✗ | par_mapped[21] = par[14]; | |
339 | ✗ | par_mapped[20] = par[14]; | |
340 | ✗ | par_mapped[19] = par[13]; | |
341 | ✗ | par_mapped[18] = par[12]; | |
342 | ✗ | par_mapped[17] = par[11]; | |
343 | } | ||
344 | ✗ | par_mapped[16] = par[10]; | |
345 | ✗ | par_mapped[15] = par[ 9]; | |
346 | ✗ | par_mapped[14] = par[ 9]; | |
347 | ✗ | par_mapped[13] = par[ 8]; | |
348 | ✗ | par_mapped[12] = par[ 8]; | |
349 | ✗ | par_mapped[11] = par[ 7]; | |
350 | ✗ | par_mapped[10] = par[ 6]; | |
351 | ✗ | par_mapped[ 9] = par[ 5]; | |
352 | ✗ | par_mapped[ 8] = par[ 5]; | |
353 | ✗ | par_mapped[ 7] = par[ 4]; | |
354 | ✗ | par_mapped[ 6] = par[ 4]; | |
355 | ✗ | par_mapped[ 5] = par[ 3]; | |
356 | ✗ | par_mapped[ 4] = (par[ 2] + par[ 3]) / 2; | |
357 | ✗ | par_mapped[ 3] = par[ 2]; | |
358 | ✗ | par_mapped[ 2] = par[ 1]; | |
359 | ✗ | par_mapped[ 1] = (par[ 0] + par[ 1]) / 2; | |
360 | ✗ | par_mapped[ 0] = par[ 0]; | |
361 | } | ||
362 | |||
363 | 16 | static void map_val_20_to_34(INTFLOAT par[PS_MAX_NR_IIDICC]) | |
364 | { | ||
365 | 16 | par[33] = par[19]; | |
366 | 16 | par[32] = par[19]; | |
367 | 16 | par[31] = par[18]; | |
368 | 16 | par[30] = par[18]; | |
369 | 16 | par[29] = par[18]; | |
370 | 16 | par[28] = par[18]; | |
371 | 16 | par[27] = par[17]; | |
372 | 16 | par[26] = par[17]; | |
373 | 16 | par[25] = par[16]; | |
374 | 16 | par[24] = par[16]; | |
375 | 16 | par[23] = par[15]; | |
376 | 16 | par[22] = par[15]; | |
377 | 16 | par[21] = par[14]; | |
378 | 16 | par[20] = par[14]; | |
379 | 16 | par[19] = par[13]; | |
380 | 16 | par[18] = par[12]; | |
381 | 16 | par[17] = par[11]; | |
382 | 16 | par[16] = par[10]; | |
383 | 16 | par[15] = par[ 9]; | |
384 | 16 | par[14] = par[ 9]; | |
385 | 16 | par[13] = par[ 8]; | |
386 | 16 | par[12] = par[ 8]; | |
387 | 16 | par[11] = par[ 7]; | |
388 | 16 | par[10] = par[ 6]; | |
389 | 16 | par[ 9] = par[ 5]; | |
390 | 16 | par[ 8] = par[ 5]; | |
391 | 16 | par[ 7] = par[ 4]; | |
392 | 16 | par[ 6] = par[ 4]; | |
393 | 16 | par[ 5] = par[ 3]; | |
394 | 16 | par[ 4] = AAC_HALF_SUM(par[ 2], par[ 3]); | |
395 | 16 | par[ 3] = par[ 2]; | |
396 | 16 | par[ 2] = par[ 1]; | |
397 | 16 | par[ 1] = AAC_HALF_SUM(par[ 0], par[ 1]); | |
398 | 16 | } | |
399 | |||
400 | 1616 | static void decorrelation(PSContext *ps, INTFLOAT (*out)[32][2], const INTFLOAT (*s)[32][2], int is34) | |
401 | { | ||
402 | 1616 | LOCAL_ALIGNED_16(INTFLOAT, power, [34], [PS_QMF_TIME_SLOTS]); | |
403 | 1616 | LOCAL_ALIGNED_16(INTFLOAT, transient_gain, [34], [PS_QMF_TIME_SLOTS]); | |
404 | 1616 | INTFLOAT *peak_decay_nrg = ps->peak_decay_nrg; | |
405 | 1616 | INTFLOAT *power_smooth = ps->power_smooth; | |
406 | 1616 | INTFLOAT *peak_decay_diff_smooth = ps->peak_decay_diff_smooth; | |
407 | 1616 | INTFLOAT (*delay)[PS_QMF_TIME_SLOTS + PS_MAX_DELAY][2] = ps->delay; | |
408 | 1616 | INTFLOAT (*ap_delay)[PS_AP_LINKS][PS_QMF_TIME_SLOTS + PS_MAX_AP_DELAY][2] = ps->ap_delay; | |
409 | #if !USE_FIXED | ||
410 | 1616 | const float transient_impact = 1.5f; | |
411 | 1616 | const float a_smooth = 0.25f; ///< Smoothing coefficient | |
412 | #endif /* USE_FIXED */ | ||
413 |
2/2✓ Branch 0 taken 102 times.
✓ Branch 1 taken 1514 times.
|
1616 | const int8_t *const k_to_i = is34 ? ff_k_to_i_34 : ff_k_to_i_20; |
414 | int i, k, m, n; | ||
415 | 1616 | int n0 = 0, nL = 32; | |
416 | 1616 | const INTFLOAT peak_decay_factor = Q31(0.76592833836465f); | |
417 | |||
418 | 1616 | memset(power, 0, 34 * sizeof(*power)); | |
419 | |||
420 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1613 times.
|
1616 | if (is34 != ps->common.is34bands_old) { |
421 | 3 | memset(ps->peak_decay_nrg, 0, sizeof(ps->peak_decay_nrg)); | |
422 | 3 | memset(ps->power_smooth, 0, sizeof(ps->power_smooth)); | |
423 | 3 | memset(ps->peak_decay_diff_smooth, 0, sizeof(ps->peak_decay_diff_smooth)); | |
424 | 3 | memset(ps->delay, 0, sizeof(ps->delay)); | |
425 | 3 | memset(ps->ap_delay, 0, sizeof(ps->ap_delay)); | |
426 | } | ||
427 | |||
428 |
2/2✓ Branch 0 taken 116776 times.
✓ Branch 1 taken 1616 times.
|
118392 | for (k = 0; k < NR_BANDS[is34]; k++) { |
429 | 116776 | int i = k_to_i[k]; | |
430 | 116776 | ps->dsp.add_squares(power[i], s[k], nL - n0); | |
431 | } | ||
432 | |||
433 | //Transient detection | ||
434 | #if USE_FIXED | ||
435 | ✗ | for (i = 0; i < NR_PAR_BANDS[is34]; i++) { | |
436 | ✗ | for (n = n0; n < nL; n++) { | |
437 | int decayed_peak; | ||
438 | ✗ | decayed_peak = (int)(((int64_t)peak_decay_factor * \ | |
439 | ✗ | peak_decay_nrg[i] + 0x40000000) >> 31); | |
440 | ✗ | peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]); | |
441 | ✗ | power_smooth[i] += (power[i][n] + 2LL - power_smooth[i]) >> 2; | |
442 | ✗ | peak_decay_diff_smooth[i] += (peak_decay_nrg[i] + 2LL - power[i][n] - \ | |
443 | ✗ | peak_decay_diff_smooth[i]) >> 2; | |
444 | |||
445 | ✗ | if (peak_decay_diff_smooth[i]) { | |
446 | ✗ | transient_gain[i][n] = FFMIN(power_smooth[i]*43691LL / peak_decay_diff_smooth[i], 1<<16); | |
447 | } else | ||
448 | ✗ | transient_gain[i][n] = 1 << 16; | |
449 | } | ||
450 | } | ||
451 | #else | ||
452 |
2/2✓ Branch 0 taken 33748 times.
✓ Branch 1 taken 1616 times.
|
35364 | for (i = 0; i < NR_PAR_BANDS[is34]; i++) { |
453 |
2/2✓ Branch 0 taken 1079936 times.
✓ Branch 1 taken 33748 times.
|
1113684 | for (n = n0; n < nL; n++) { |
454 | 1079936 | float decayed_peak = peak_decay_factor * peak_decay_nrg[i]; | |
455 | float denom; | ||
456 |
2/2✓ Branch 0 taken 541112 times.
✓ Branch 1 taken 538824 times.
|
1079936 | peak_decay_nrg[i] = FFMAX(decayed_peak, power[i][n]); |
457 | 1079936 | power_smooth[i] += a_smooth * (power[i][n] - power_smooth[i]); | |
458 | 1079936 | peak_decay_diff_smooth[i] += a_smooth * (peak_decay_nrg[i] - power[i][n] - peak_decay_diff_smooth[i]); | |
459 | 1079936 | denom = transient_impact * peak_decay_diff_smooth[i]; | |
460 | 1079936 | transient_gain[i][n] = (denom > power_smooth[i]) ? | |
461 |
2/2✓ Branch 0 taken 211728 times.
✓ Branch 1 taken 868208 times.
|
1079936 | power_smooth[i] / denom : 1.0f; |
462 | } | ||
463 | } | ||
464 | |||
465 | #endif /* USE_FIXED */ | ||
466 | //Decorrelation and transient reduction | ||
467 | // PS_AP_LINKS - 1 | ||
468 | // ----- | ||
469 | // | | Q_fract_allpass[k][m]*z^-link_delay[m] - a[m]*g_decay_slope[k] | ||
470 | //H[k][z] = z^-2 * phi_fract[k] * | | ---------------------------------------------------------------- | ||
471 | // | | 1 - a[m]*g_decay_slope[k]*Q_fract_allpass[k][m]*z^-link_delay[m] | ||
472 | // m = 0 | ||
473 | //d[k][z] (out) = transient_gain_mapped[k][z] * H[k][z] * s[k][z] | ||
474 |
2/2✓ Branch 0 taken 50520 times.
✓ Branch 1 taken 1616 times.
|
52136 | for (k = 0; k < NR_ALLPASS_BANDS[is34]; k++) { |
475 | 50520 | int b = k_to_i[k]; | |
476 | #if USE_FIXED | ||
477 | int g_decay_slope; | ||
478 | |||
479 | ✗ | if (k - DECAY_CUTOFF[is34] <= 0) { | |
480 | ✗ | g_decay_slope = 1 << 30; | |
481 | } | ||
482 | ✗ | else if (k - DECAY_CUTOFF[is34] >= 20) { | |
483 | ✗ | g_decay_slope = 0; | |
484 | } | ||
485 | else { | ||
486 | ✗ | g_decay_slope = (1 << 30) - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); | |
487 | } | ||
488 | #else | ||
489 | 50520 | float g_decay_slope = 1.f - DECAY_SLOPE * (k - DECAY_CUTOFF[is34]); | |
490 | 50520 | g_decay_slope = av_clipf(g_decay_slope, 0.f, 1.f); | |
491 | #endif /* USE_FIXED */ | ||
492 | 50520 | memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); | |
493 | 50520 | memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); | |
494 |
2/2✓ Branch 0 taken 151560 times.
✓ Branch 1 taken 50520 times.
|
202080 | for (m = 0; m < PS_AP_LINKS; m++) { |
495 | 151560 | memcpy(ap_delay[k][m], ap_delay[k][m]+numQMFSlots, 5*sizeof(ap_delay[k][m][0])); | |
496 | } | ||
497 | 50520 | ps->dsp.decorrelate(out[k], delay[k] + PS_MAX_DELAY - 2, ap_delay[k], | |
498 | 50520 | phi_fract[is34][k], | |
499 | 50520 | (const INTFLOAT (*)[2]) Q_fract_allpass[is34][k], | |
500 | 50520 | transient_gain[b], g_decay_slope, nL - n0); | |
501 | } | ||
502 |
2/2✓ Branch 0 taken 19392 times.
✓ Branch 1 taken 1616 times.
|
21008 | for (; k < SHORT_DELAY_BAND[is34]; k++) { |
503 | 19392 | int i = k_to_i[k]; | |
504 | 19392 | memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); | |
505 | 19392 | memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); | |
506 | //H = delay 14 | ||
507 | 19392 | ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 14, | |
508 | 19392 | transient_gain[i], nL - n0); | |
509 | } | ||
510 |
2/2✓ Branch 0 taken 46864 times.
✓ Branch 1 taken 1616 times.
|
48480 | for (; k < NR_BANDS[is34]; k++) { |
511 | 46864 | int i = k_to_i[k]; | |
512 | 46864 | memcpy(delay[k], delay[k]+nL, PS_MAX_DELAY*sizeof(delay[k][0])); | |
513 | 46864 | memcpy(delay[k]+PS_MAX_DELAY, s[k], numQMFSlots*sizeof(delay[k][0])); | |
514 | //H = delay 1 | ||
515 | 46864 | ps->dsp.mul_pair_single(out[k], delay[k] + PS_MAX_DELAY - 1, | |
516 | 46864 | transient_gain[i], nL - n0); | |
517 | } | ||
518 | 1616 | } | |
519 | |||
520 | 204 | static void remap34(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], | |
521 | int8_t (*par)[PS_MAX_NR_IIDICC], | ||
522 | int num_par, int num_env, int full) | ||
523 | { | ||
524 | 204 | int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped; | |
525 | int e; | ||
526 |
2/4✓ Branch 0 taken 204 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 204 times.
|
204 | if (num_par == 20 || num_par == 11) { |
527 | ✗ | for (e = 0; e < num_env; e++) { | |
528 | ✗ | map_idx_20_to_34(par_mapped[e], par[e], full); | |
529 | } | ||
530 |
3/4✓ Branch 0 taken 102 times.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
|
204 | } else if (num_par == 10 || num_par == 5) { |
531 |
2/2✓ Branch 0 taken 204 times.
✓ Branch 1 taken 102 times.
|
306 | for (e = 0; e < num_env; e++) { |
532 | 204 | map_idx_10_to_34(par_mapped[e], par[e], full); | |
533 | } | ||
534 | } else { | ||
535 | 102 | *p_par_mapped = par; | |
536 | } | ||
537 | 204 | } | |
538 | |||
539 | 3134 | static void remap20(int8_t (**p_par_mapped)[PS_MAX_NR_IIDICC], | |
540 | int8_t (*par)[PS_MAX_NR_IIDICC], | ||
541 | int num_par, int num_env, int full) | ||
542 | { | ||
543 | 3134 | int8_t (*par_mapped)[PS_MAX_NR_IIDICC] = *p_par_mapped; | |
544 | int e; | ||
545 |
3/4✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3133 times.
|
3134 | if (num_par == 34 || num_par == 17) { |
546 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | for (e = 0; e < num_env; e++) { |
547 | 1 | map_idx_34_to_20(par_mapped[e], par[e], full); | |
548 | } | ||
549 |
3/4✓ Branch 0 taken 3132 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3132 times.
|
3133 | } else if (num_par == 10 || num_par == 5) { |
550 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | for (e = 0; e < num_env; e++) { |
551 | 1 | map_idx_10_to_20(par_mapped[e], par[e], full); | |
552 | } | ||
553 | } else { | ||
554 | 3132 | *p_par_mapped = par; | |
555 | } | ||
556 | 3134 | } | |
557 | |||
558 | 1616 | static void stereo_processing(PSContext *ps, INTFLOAT (*l)[32][2], INTFLOAT (*r)[32][2], int is34) | |
559 | { | ||
560 | int e, b, k; | ||
561 | |||
562 | 1616 | PSCommonContext *const ps2 = &ps->common; | |
563 | 1616 | INTFLOAT (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11; | |
564 | 1616 | INTFLOAT (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12; | |
565 | 1616 | INTFLOAT (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21; | |
566 | 1616 | INTFLOAT (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22; | |
567 | 1616 | int8_t *opd_hist = ps->opd_hist; | |
568 | 1616 | int8_t *ipd_hist = ps->ipd_hist; | |
569 | int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; | ||
570 | int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; | ||
571 | int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; | ||
572 | int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC]; | ||
573 | 1616 | int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf; | |
574 | 1616 | int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf; | |
575 | 1616 | int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf; | |
576 | 1616 | int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf; | |
577 |
2/2✓ Branch 0 taken 102 times.
✓ Branch 1 taken 1514 times.
|
1616 | const int8_t *const k_to_i = is34 ? ff_k_to_i_34 : ff_k_to_i_20; |
578 |
1/2✓ Branch 0 taken 1616 times.
✗ Branch 1 not taken.
|
1616 | TABLE_CONST INTFLOAT (*H_LUT)[8][4] = (PS_BASELINE || ps2->icc_mode < 3) ? HA : HB; |
579 | |||
580 | //Remapping | ||
581 |
2/2✓ Branch 0 taken 1590 times.
✓ Branch 1 taken 26 times.
|
1616 | if (ps2->num_env_old) { |
582 | 1590 | memcpy(H11[0][0], H11[0][ps2->num_env_old], sizeof(H11[0][0])); | |
583 | 1590 | memcpy(H11[1][0], H11[1][ps2->num_env_old], sizeof(H11[1][0])); | |
584 | 1590 | memcpy(H12[0][0], H12[0][ps2->num_env_old], sizeof(H12[0][0])); | |
585 | 1590 | memcpy(H12[1][0], H12[1][ps2->num_env_old], sizeof(H12[1][0])); | |
586 | 1590 | memcpy(H21[0][0], H21[0][ps2->num_env_old], sizeof(H21[0][0])); | |
587 | 1590 | memcpy(H21[1][0], H21[1][ps2->num_env_old], sizeof(H21[1][0])); | |
588 | 1590 | memcpy(H22[0][0], H22[0][ps2->num_env_old], sizeof(H22[0][0])); | |
589 | 1590 | memcpy(H22[1][0], H22[1][ps2->num_env_old], sizeof(H22[1][0])); | |
590 | } | ||
591 | |||
592 |
2/2✓ Branch 0 taken 102 times.
✓ Branch 1 taken 1514 times.
|
1616 | if (is34) { |
593 | 102 | remap34(&iid_mapped, ps2->iid_par, ps2->nr_iid_par, ps2->num_env, 1); | |
594 | 102 | remap34(&icc_mapped, ps2->icc_par, ps2->nr_icc_par, ps2->num_env, 1); | |
595 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
|
102 | if (ps2->enable_ipdopd) { |
596 | ✗ | remap34(&ipd_mapped, ps2->ipd_par, ps2->nr_ipdopd_par, ps2->num_env, 0); | |
597 | ✗ | remap34(&opd_mapped, ps2->opd_par, ps2->nr_ipdopd_par, ps2->num_env, 0); | |
598 | } | ||
599 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 100 times.
|
102 | if (!ps2->is34bands_old) { |
600 | 2 | map_val_20_to_34(H11[0][0]); | |
601 | 2 | map_val_20_to_34(H11[1][0]); | |
602 | 2 | map_val_20_to_34(H12[0][0]); | |
603 | 2 | map_val_20_to_34(H12[1][0]); | |
604 | 2 | map_val_20_to_34(H21[0][0]); | |
605 | 2 | map_val_20_to_34(H21[1][0]); | |
606 | 2 | map_val_20_to_34(H22[0][0]); | |
607 | 2 | map_val_20_to_34(H22[1][0]); | |
608 | 2 | ipdopd_reset(ipd_hist, opd_hist); | |
609 | } | ||
610 | } else { | ||
611 | 1514 | remap20(&iid_mapped, ps2->iid_par, ps2->nr_iid_par, ps2->num_env, 1); | |
612 | 1514 | remap20(&icc_mapped, ps2->icc_par, ps2->nr_icc_par, ps2->num_env, 1); | |
613 |
2/2✓ Branch 0 taken 53 times.
✓ Branch 1 taken 1461 times.
|
1514 | if (ps2->enable_ipdopd) { |
614 | 53 | remap20(&ipd_mapped, ps2->ipd_par, ps2->nr_ipdopd_par, ps2->num_env, 0); | |
615 | 53 | remap20(&opd_mapped, ps2->opd_par, ps2->nr_ipdopd_par, ps2->num_env, 0); | |
616 | } | ||
617 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1513 times.
|
1514 | if (ps2->is34bands_old) { |
618 | 1 | map_val_34_to_20(H11[0][0]); | |
619 | 1 | map_val_34_to_20(H11[1][0]); | |
620 | 1 | map_val_34_to_20(H12[0][0]); | |
621 | 1 | map_val_34_to_20(H12[1][0]); | |
622 | 1 | map_val_34_to_20(H21[0][0]); | |
623 | 1 | map_val_34_to_20(H21[1][0]); | |
624 | 1 | map_val_34_to_20(H22[0][0]); | |
625 | 1 | map_val_34_to_20(H22[1][0]); | |
626 | 1 | ipdopd_reset(ipd_hist, opd_hist); | |
627 | } | ||
628 | } | ||
629 | |||
630 | //Mixing | ||
631 |
2/2✓ Branch 0 taken 2033 times.
✓ Branch 1 taken 1616 times.
|
3649 | for (e = 0; e < ps2->num_env; e++) { |
632 |
2/2✓ Branch 0 taken 43516 times.
✓ Branch 1 taken 2033 times.
|
45549 | for (b = 0; b < NR_PAR_BANDS[is34]; b++) { |
633 | INTFLOAT h11, h12, h21, h22; | ||
634 | 43516 | h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][0]; | |
635 | 43516 | h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][1]; | |
636 | 43516 | h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][2]; | |
637 | 43516 | h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps2->iid_quant][icc_mapped[e][b]][3]; | |
638 | |||
639 |
4/4✓ Branch 0 taken 2080 times.
✓ Branch 1 taken 41436 times.
✓ Branch 2 taken 1144 times.
✓ Branch 3 taken 936 times.
|
43516 | if (!PS_BASELINE && ps2->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) { |
640 | //The spec say says to only run this smoother when enable_ipdopd | ||
641 | //is set but the reference decoder appears to run it constantly | ||
642 | INTFLOAT h11i, h12i, h21i, h22i; | ||
643 | INTFLOAT ipd_adj_re, ipd_adj_im; | ||
644 | 1144 | int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b]; | |
645 | 1144 | int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b]; | |
646 | 1144 | INTFLOAT opd_re = pd_re_smooth[opd_idx]; | |
647 | 1144 | INTFLOAT opd_im = pd_im_smooth[opd_idx]; | |
648 | 1144 | INTFLOAT ipd_re = pd_re_smooth[ipd_idx]; | |
649 | 1144 | INTFLOAT ipd_im = pd_im_smooth[ipd_idx]; | |
650 | 1144 | opd_hist[b] = opd_idx & 0x3F; | |
651 | 1144 | ipd_hist[b] = ipd_idx & 0x3F; | |
652 | |||
653 | 1144 | ipd_adj_re = AAC_MADD30(opd_re, ipd_re, opd_im, ipd_im); | |
654 | 1144 | ipd_adj_im = AAC_MSUB30(opd_im, ipd_re, opd_re, ipd_im); | |
655 | 1144 | h11i = AAC_MUL30(h11, opd_im); | |
656 | 1144 | h11 = AAC_MUL30(h11, opd_re); | |
657 | 1144 | h12i = AAC_MUL30(h12, ipd_adj_im); | |
658 | 1144 | h12 = AAC_MUL30(h12, ipd_adj_re); | |
659 | 1144 | h21i = AAC_MUL30(h21, opd_im); | |
660 | 1144 | h21 = AAC_MUL30(h21, opd_re); | |
661 | 1144 | h22i = AAC_MUL30(h22, ipd_adj_im); | |
662 | 1144 | h22 = AAC_MUL30(h22, ipd_adj_re); | |
663 | 1144 | H11[1][e+1][b] = h11i; | |
664 | 1144 | H12[1][e+1][b] = h12i; | |
665 | 1144 | H21[1][e+1][b] = h21i; | |
666 | 1144 | H22[1][e+1][b] = h22i; | |
667 | } | ||
668 | 43516 | H11[0][e+1][b] = h11; | |
669 | 43516 | H12[0][e+1][b] = h12; | |
670 | 43516 | H21[0][e+1][b] = h21; | |
671 | 43516 | H22[0][e+1][b] = h22; | |
672 | } | ||
673 |
2/2✓ Branch 0 taken 148423 times.
✓ Branch 1 taken 2033 times.
|
150456 | for (k = 0; k < NR_BANDS[is34]; k++) { |
674 | 148423 | LOCAL_ALIGNED_16(INTFLOAT, h, [2], [4]); | |
675 | 148423 | LOCAL_ALIGNED_16(INTFLOAT, h_step, [2], [4]); | |
676 | 148423 | int start = ps2->border_position[e]; | |
677 | 148423 | int stop = ps2->border_position[e+1]; | |
678 |
1/2✓ Branch 0 taken 148423 times.
✗ Branch 1 not taken.
|
148423 | INTFLOAT width = Q30(1.f) / ((stop - start) ? (stop - start) : 1); |
679 | #if USE_FIXED | ||
680 | ✗ | width = FFMIN(2U*width, INT_MAX); | |
681 | #endif | ||
682 | 148423 | b = k_to_i[k]; | |
683 | 148423 | h[0][0] = H11[0][e][b]; | |
684 | 148423 | h[0][1] = H12[0][e][b]; | |
685 | 148423 | h[0][2] = H21[0][e][b]; | |
686 | 148423 | h[0][3] = H22[0][e][b]; | |
687 |
2/2✓ Branch 0 taken 7384 times.
✓ Branch 1 taken 141039 times.
|
148423 | if (!PS_BASELINE && ps2->enable_ipdopd) { |
688 | //Is this necessary? ps_04_new seems unchanged | ||
689 |
4/10✗ Branch 0 not taken.
✓ Branch 1 taken 7384 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 7384 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 208 times.
✓ Branch 9 taken 7176 times.
|
7384 | if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) { |
690 | 208 | h[1][0] = -H11[1][e][b]; | |
691 | 208 | h[1][1] = -H12[1][e][b]; | |
692 | 208 | h[1][2] = -H21[1][e][b]; | |
693 | 208 | h[1][3] = -H22[1][e][b]; | |
694 | } else { | ||
695 | 7176 | h[1][0] = H11[1][e][b]; | |
696 | 7176 | h[1][1] = H12[1][e][b]; | |
697 | 7176 | h[1][2] = H21[1][e][b]; | |
698 | 7176 | h[1][3] = H22[1][e][b]; | |
699 | } | ||
700 | } | ||
701 | //Interpolation | ||
702 | 148423 | h_step[0][0] = AAC_MSUB31_V3(H11[0][e+1][b], h[0][0], width); | |
703 | 148423 | h_step[0][1] = AAC_MSUB31_V3(H12[0][e+1][b], h[0][1], width); | |
704 | 148423 | h_step[0][2] = AAC_MSUB31_V3(H21[0][e+1][b], h[0][2], width); | |
705 | 148423 | h_step[0][3] = AAC_MSUB31_V3(H22[0][e+1][b], h[0][3], width); | |
706 |
2/2✓ Branch 0 taken 7384 times.
✓ Branch 1 taken 141039 times.
|
148423 | if (!PS_BASELINE && ps2->enable_ipdopd) { |
707 | 7384 | h_step[1][0] = AAC_MSUB31_V3(H11[1][e+1][b], h[1][0], width); | |
708 | 7384 | h_step[1][1] = AAC_MSUB31_V3(H12[1][e+1][b], h[1][1], width); | |
709 | 7384 | h_step[1][2] = AAC_MSUB31_V3(H21[1][e+1][b], h[1][2], width); | |
710 | 7384 | h_step[1][3] = AAC_MSUB31_V3(H22[1][e+1][b], h[1][3], width); | |
711 | } | ||
712 |
1/2✓ Branch 0 taken 148423 times.
✗ Branch 1 not taken.
|
148423 | if (stop - start) |
713 | 148423 | ps->dsp.stereo_interpolate[!PS_BASELINE && ps2->enable_ipdopd]( | |
714 | 148423 | l[k] + 1 + start, r[k] + 1 + start, | |
715 | h, h_step, stop - start); | ||
716 | } | ||
717 | } | ||
718 | 1616 | } | |
719 | |||
720 | 1616 | int AAC_RENAME(ff_ps_apply)(AVCodecContext *avctx, PSContext *ps, INTFLOAT L[2][38][64], INTFLOAT R[2][38][64], int top) | |
721 | { | ||
722 | 1616 | INTFLOAT (*Lbuf)[32][2] = ps->Lbuf; | |
723 | 1616 | INTFLOAT (*Rbuf)[32][2] = ps->Rbuf; | |
724 | 1616 | const int len = 32; | |
725 | 1616 | int is34 = ps->common.is34bands; | |
726 | |||
727 | 1616 | top += NR_BANDS[is34] - 64; | |
728 | 1616 | memset(ps->delay+top, 0, (NR_BANDS[is34] - top)*sizeof(ps->delay[0])); | |
729 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1616 times.
|
1616 | if (top < NR_ALLPASS_BANDS[is34]) |
730 | ✗ | memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - top)*sizeof(ps->ap_delay[0])); | |
731 | |||
732 | 1616 | hybrid_analysis(&ps->dsp, Lbuf, ps->in_buf, L, is34, len); | |
733 | 1616 | decorrelation(ps, Rbuf, (const INTFLOAT (*)[32][2]) Lbuf, is34); | |
734 | 1616 | stereo_processing(ps, Lbuf, Rbuf, is34); | |
735 | 1616 | hybrid_synthesis(&ps->dsp, L, Lbuf, is34, len); | |
736 | 1616 | hybrid_synthesis(&ps->dsp, R, Rbuf, is34, len); | |
737 | |||
738 | 1616 | return 0; | |
739 | } | ||
740 | |||
741 | 176 | av_cold void AAC_RENAME(ff_ps_init)(void) { | |
742 | 176 | ps_tableinit(); | |
743 | 176 | ff_ps_init_common(); | |
744 | 176 | } | |
745 | |||
746 | 365 | av_cold void AAC_RENAME(ff_ps_ctx_init)(PSContext *ps) | |
747 | { | ||
748 | 365 | AAC_RENAME(ff_psdsp_init)(&ps->dsp); | |
749 | 365 | } | |
750 |