/src/ffmpeg/libavcodec/aac/aacdec_proc_template.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * AAC decoder |
3 | | * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org ) |
4 | | * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com ) |
5 | | * Copyright (c) 2008-2013 Alex Converse <alex.converse@gmail.com> |
6 | | * |
7 | | * AAC LATM decoder |
8 | | * Copyright (c) 2008-2010 Paul Kendall <paul@kcbbs.gen.nz> |
9 | | * Copyright (c) 2010 Janne Grunau <janne-libav@jannau.net> |
10 | | * |
11 | | * AAC decoder fixed-point implementation |
12 | | * Copyright (c) 2013 |
13 | | * MIPS Technologies, Inc., California. |
14 | | * |
15 | | * This file is part of FFmpeg. |
16 | | * |
17 | | * FFmpeg is free software; you can redistribute it and/or |
18 | | * modify it under the terms of the GNU Lesser General Public |
19 | | * License as published by the Free Software Foundation; either |
20 | | * version 2.1 of the License, or (at your option) any later version. |
21 | | * |
22 | | * FFmpeg is distributed in the hope that it will be useful, |
23 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
25 | | * Lesser General Public License for more details. |
26 | | * |
27 | | * You should have received a copy of the GNU Lesser General Public |
28 | | * License along with FFmpeg; if not, write to the Free Software |
29 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
30 | | */ |
31 | | |
32 | | /** |
33 | | * linear congruential pseudorandom number generator |
34 | | * |
35 | | * @param previous_val pointer to the current state of the generator |
36 | | * |
37 | | * @return Returns a 32-bit pseudorandom integer |
38 | | */ |
39 | | static av_always_inline int lcg_random(unsigned previous_val) |
40 | 34.1M | { |
41 | 34.1M | union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; |
42 | 34.1M | return v.s; |
43 | 34.1M | } aacdec_fixed.c:lcg_random Line | Count | Source | 40 | 32.4M | { | 41 | 32.4M | union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; | 42 | 32.4M | return v.s; | 43 | 32.4M | } |
aacdec_float.c:lcg_random Line | Count | Source | 40 | 1.70M | { | 41 | 1.70M | union { unsigned u; int s; } v = { previous_val * 1664525u + 1013904223 }; | 42 | 1.70M | return v.s; | 43 | 1.70M | } |
|
44 | | |
45 | | /** |
46 | | * Decode spectral data; reference: table 4.50. |
47 | | * Dequantize and scale spectral data; reference: 4.6.3.3. |
48 | | * |
49 | | * @param coef array of dequantized, scaled spectral data |
50 | | * @param sf array of scalefactors or intensity stereo positions |
51 | | * @param pulse_present set if pulses are present |
52 | | * @param pulse pointer to pulse data struct |
53 | | * @param band_type array of the used band type |
54 | | * |
55 | | * @return Returns error status. 0 - OK, !0 - error |
56 | | */ |
57 | | static int AAC_RENAME(decode_spectrum_and_dequant)(AACDecContext *ac, |
58 | | GetBitContext *gb, |
59 | | const Pulse *pulse, |
60 | | SingleChannelElement *sce) |
61 | 1.31M | { |
62 | 1.31M | int i, k, g, idx = 0; |
63 | 1.31M | INTFLOAT *coef = sce->AAC_RENAME(coeffs); |
64 | 1.31M | IndividualChannelStream *ics = &sce->ics; |
65 | 1.31M | const int c = 1024 / ics->num_windows; |
66 | 1.31M | const uint16_t *offsets = ics->swb_offset; |
67 | 1.31M | const INTFLOAT *sf = sce->AAC_RENAME(sf); |
68 | 1.31M | const enum BandType *band_type = sce->band_type; |
69 | 1.31M | INTFLOAT *coef_base = coef; |
70 | | |
71 | 3.50M | for (g = 0; g < ics->num_windows; g++) |
72 | 2.19M | memset(coef + g * 128 + offsets[ics->max_sfb], 0, |
73 | 2.19M | sizeof(INTFLOAT) * (c - offsets[ics->max_sfb])); |
74 | | |
75 | 2.89M | for (g = 0; g < ics->num_window_groups; g++) { |
76 | 1.58M | unsigned g_len = ics->group_len[g]; |
77 | | |
78 | 5.38M | for (i = 0; i < ics->max_sfb; i++, idx++) { |
79 | 3.80M | const unsigned cbt_m1 = band_type[idx] - 1; |
80 | 3.80M | INTFLOAT *cfo = coef + offsets[i]; |
81 | 3.80M | int off_len = offsets[i + 1] - offsets[i]; |
82 | 3.80M | int group; |
83 | | |
84 | 3.80M | if (cbt_m1 >= INTENSITY_BT2 - 1) { |
85 | 4.00M | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { |
86 | 3.02M | memset(cfo, 0, off_len * sizeof(*cfo)); |
87 | 3.02M | } |
88 | 2.82M | } else if (cbt_m1 == NOISE_BT - 1) { |
89 | 5.47M | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { |
90 | 3.63M | INTFLOAT band_energy; |
91 | | #if USE_FIXED |
92 | 35.9M | for (k = 0; k < off_len; k++) { |
93 | 32.4M | ac->random_state = lcg_random(ac->random_state); |
94 | 32.4M | cfo[k] = ac->random_state >> 3; |
95 | 32.4M | } |
96 | | |
97 | 3.53M | band_energy = ac->fdsp->scalarproduct_fixed(cfo, cfo, off_len); |
98 | | band_energy = fixed_sqrt(band_energy, 31); |
99 | | noise_scale(cfo, sf[idx], band_energy, off_len); |
100 | | #else |
101 | | float scale; |
102 | | |
103 | 1.79M | for (k = 0; k < off_len; k++) { |
104 | 1.70M | ac->random_state = lcg_random(ac->random_state); |
105 | 1.70M | cfo[k] = ac->random_state; |
106 | 1.70M | } |
107 | | |
108 | | band_energy = ac->fdsp->scalarproduct_float(cfo, cfo, off_len); |
109 | | scale = sf[idx] / sqrtf(band_energy); |
110 | | ac->fdsp->vector_fmul_scalar(cfo, cfo, scale, off_len); |
111 | | #endif /* USE_FIXED */ |
112 | 3.63M | } |
113 | 1.84M | } else { |
114 | | #if !USE_FIXED |
115 | | const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; |
116 | | #endif /* !USE_FIXED */ |
117 | 982k | const VLCElem *vlc_tab = ff_vlc_spectral[cbt_m1]; |
118 | 982k | OPEN_READER(re, gb); |
119 | | |
120 | 982k | switch (cbt_m1 >> 1) { |
121 | 78.8k | case 0: |
122 | 189k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { |
123 | 110k | INTFLOAT *cf = cfo; |
124 | 110k | int len = off_len; |
125 | | |
126 | 272k | do { |
127 | 272k | int code; |
128 | 272k | unsigned cb_idx; |
129 | | |
130 | 272k | UPDATE_CACHE(re, gb); |
131 | 272k | GET_VLC(code, re, gb, vlc_tab, 8, 2); |
132 | 272k | cb_idx = code; |
133 | | #if USE_FIXED |
134 | | cf = DEC_SQUAD(cf, cb_idx); |
135 | | #else |
136 | | cf = VMUL4(cf, vq, cb_idx, sf + idx); |
137 | | #endif /* USE_FIXED */ |
138 | 272k | } while (len -= 4); |
139 | 110k | } |
140 | 78.8k | break; |
141 | | |
142 | 143k | case 1: |
143 | 305k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { |
144 | 162k | INTFLOAT *cf = cfo; |
145 | 162k | int len = off_len; |
146 | | |
147 | 797k | do { |
148 | 797k | int code; |
149 | 797k | unsigned nnz; |
150 | 797k | unsigned cb_idx; |
151 | 797k | uint32_t bits; |
152 | | |
153 | 797k | UPDATE_CACHE(re, gb); |
154 | 797k | GET_VLC(code, re, gb, vlc_tab, 8, 2); |
155 | 797k | cb_idx = code; |
156 | 797k | nnz = cb_idx >> 8 & 15; |
157 | 797k | bits = nnz ? GET_CACHE(re, gb) : 0; |
158 | 797k | LAST_SKIP_BITS(re, gb, nnz); |
159 | | #if USE_FIXED |
160 | | cf = DEC_UQUAD(cf, cb_idx, bits); |
161 | | #else |
162 | | cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); |
163 | | #endif /* USE_FIXED */ |
164 | 797k | } while (len -= 4); |
165 | 162k | } |
166 | 143k | break; |
167 | | |
168 | 43.9k | case 2: |
169 | 110k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { |
170 | 66.8k | INTFLOAT *cf = cfo; |
171 | 66.8k | int len = off_len; |
172 | | |
173 | 313k | do { |
174 | 313k | int code; |
175 | 313k | unsigned cb_idx; |
176 | | |
177 | 313k | UPDATE_CACHE(re, gb); |
178 | 313k | GET_VLC(code, re, gb, vlc_tab, 8, 2); |
179 | 313k | cb_idx = code; |
180 | | #if USE_FIXED |
181 | | cf = DEC_SPAIR(cf, cb_idx); |
182 | | #else |
183 | | cf = VMUL2(cf, vq, cb_idx, sf + idx); |
184 | | #endif /* USE_FIXED */ |
185 | 313k | } while (len -= 2); |
186 | 66.8k | } |
187 | 43.9k | break; |
188 | | |
189 | 279k | case 3: |
190 | 677k | case 4: |
191 | 3.17M | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { |
192 | 2.49M | INTFLOAT *cf = cfo; |
193 | 2.49M | int len = off_len; |
194 | | |
195 | 7.25M | do { |
196 | 7.25M | int code; |
197 | 7.25M | unsigned nnz; |
198 | 7.25M | unsigned cb_idx; |
199 | 7.25M | unsigned sign; |
200 | | |
201 | 7.25M | UPDATE_CACHE(re, gb); |
202 | 7.25M | GET_VLC(code, re, gb, vlc_tab, 8, 2); |
203 | 7.25M | cb_idx = code; |
204 | 7.25M | nnz = cb_idx >> 8 & 15; |
205 | 7.25M | sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; |
206 | 7.25M | LAST_SKIP_BITS(re, gb, nnz); |
207 | | #if USE_FIXED |
208 | | cf = DEC_UPAIR(cf, cb_idx, sign); |
209 | | #else |
210 | | cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); |
211 | | #endif /* USE_FIXED */ |
212 | 7.25M | } while (len -= 2); |
213 | 2.49M | } |
214 | 677k | break; |
215 | | |
216 | 38.5k | default: |
217 | 91.0k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { |
218 | | #if USE_FIXED |
219 | | int *icf = cfo; |
220 | | int v; |
221 | | #else |
222 | | float *cf = cfo; |
223 | | uint32_t *icf = (uint32_t *) cf; |
224 | | #endif /* USE_FIXED */ |
225 | 53.1k | int len = off_len; |
226 | | |
227 | 256k | do { |
228 | 256k | int code; |
229 | 256k | unsigned nzt, nnz; |
230 | 256k | unsigned cb_idx; |
231 | 256k | uint32_t bits; |
232 | 256k | int j; |
233 | | |
234 | 256k | UPDATE_CACHE(re, gb); |
235 | 256k | GET_VLC(code, re, gb, vlc_tab, 8, 2); |
236 | 256k | cb_idx = code; |
237 | | |
238 | 256k | if (cb_idx == 0x0000) { |
239 | 180k | *icf++ = 0; |
240 | 180k | *icf++ = 0; |
241 | 180k | continue; |
242 | 180k | } |
243 | | |
244 | 75.3k | nnz = cb_idx >> 12; |
245 | 75.3k | nzt = cb_idx >> 8; |
246 | 75.3k | bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); |
247 | 75.3k | LAST_SKIP_BITS(re, gb, nnz); |
248 | | |
249 | 225k | for (j = 0; j < 2; j++) { |
250 | 150k | if (nzt & 1<<j) { |
251 | 23.9k | uint32_t b; |
252 | 23.9k | int n; |
253 | | /* The total length of escape_sequence must be < 22 bits according |
254 | | to the specification (i.e. max is 111111110xxxxxxxxxxxx). */ |
255 | 23.9k | UPDATE_CACHE(re, gb); |
256 | 23.9k | b = GET_CACHE(re, gb); |
257 | 23.9k | b = 31 - av_log2(~b); |
258 | | |
259 | 23.9k | if (b > 8) { |
260 | 610 | av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); |
261 | 610 | return AVERROR_INVALIDDATA; |
262 | 610 | } |
263 | | |
264 | 23.3k | SKIP_BITS(re, gb, b + 1); |
265 | 23.3k | b += 4; |
266 | 23.3k | n = (1 << b) + SHOW_UBITS(re, gb, b); |
267 | 23.3k | LAST_SKIP_BITS(re, gb, b); |
268 | | #if USE_FIXED |
269 | | v = n; |
270 | 13.1k | if (bits & 1U<<31) |
271 | 5.36k | v = -v; |
272 | | *icf++ = v; |
273 | | #else |
274 | | *icf++ = ff_cbrt_tab[n] | (bits & 1U<<31); |
275 | | #endif /* USE_FIXED */ |
276 | 23.3k | bits <<= 1; |
277 | 126k | } else { |
278 | | #if USE_FIXED |
279 | | v = cb_idx & 15; |
280 | 51.3k | if (bits & 1U<<31) |
281 | 23.3k | v = -v; |
282 | | *icf++ = v; |
283 | | #else |
284 | | unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; |
285 | | *icf++ = (bits & 1U<<31) | v; |
286 | | #endif /* USE_FIXED */ |
287 | 126k | bits <<= !!v; |
288 | 126k | } |
289 | 149k | cb_idx >>= 4; |
290 | 149k | } |
291 | 255k | } while (len -= 2); |
292 | | #if !USE_FIXED |
293 | 27.2k | ac->fdsp->vector_fmul_scalar(cfo, cfo, sf[idx], off_len); |
294 | 27.2k | #endif /* !USE_FIXED */ |
295 | 27.2k | } |
296 | 982k | } |
297 | | |
298 | 982k | CLOSE_READER(re, gb); |
299 | 982k | } |
300 | 3.80M | } |
301 | 1.58M | coef += g_len << 7; |
302 | 1.58M | } |
303 | | |
304 | 1.31M | if (pulse) { |
305 | 99.5k | idx = 0; |
306 | 349k | for (i = 0; i < pulse->num_pulse; i++) { |
307 | 250k | INTFLOAT co = coef_base[ pulse->pos[i] ]; |
308 | 1.64M | while (offsets[idx + 1] <= pulse->pos[i]) |
309 | 1.39M | idx++; |
310 | 250k | if (band_type[idx] != NOISE_BT && sf[idx]) { |
311 | 29.4k | INTFLOAT ico = -pulse->amp[i]; |
312 | | #if USE_FIXED |
313 | 22.3k | if (co) { |
314 | 8.85k | ico = co + (co > 0 ? -ico : ico); |
315 | 8.85k | } |
316 | | coef_base[ pulse->pos[i] ] = ico; |
317 | | #else |
318 | 7.13k | if (co) { |
319 | 3.14k | co /= sf[idx]; |
320 | 3.14k | ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); |
321 | 3.14k | } |
322 | | coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; |
323 | | #endif /* USE_FIXED */ |
324 | 29.4k | } |
325 | 250k | } |
326 | 99.5k | } |
327 | | #if USE_FIXED |
328 | | coef = coef_base; |
329 | | idx = 0; |
330 | 1.53M | for (g = 0; g < ics->num_window_groups; g++) { |
331 | 778k | unsigned g_len = ics->group_len[g]; |
332 | | |
333 | 4.22M | for (i = 0; i < ics->max_sfb; i++, idx++) { |
334 | 3.44M | const unsigned cbt_m1 = band_type[idx] - 1; |
335 | 3.44M | int *cfo = coef + offsets[i]; |
336 | 3.44M | int off_len = offsets[i + 1] - offsets[i]; |
337 | 3.44M | int group; |
338 | | |
339 | 3.44M | if (cbt_m1 < NOISE_BT - 1) { |
340 | 3.54M | for (group = 0; group < (int)g_len; group++, cfo+=128) { |
341 | 2.71M | vector_pow43(cfo, off_len); |
342 | 2.71M | subband_scale(cfo, cfo, sf[idx], 34, off_len, ac->avctx); |
343 | 2.71M | } |
344 | 825k | } |
345 | 3.44M | } |
346 | 778k | coef += g_len << 7; |
347 | 778k | } |
348 | | #endif /* USE_FIXED */ |
349 | 1.31M | return 0; |
350 | 1.31M | } aacdec_fixed.c:decode_spectrum_and_dequant_fixed Line | Count | Source | 61 | 752k | { | 62 | 752k | int i, k, g, idx = 0; | 63 | 752k | INTFLOAT *coef = sce->AAC_RENAME(coeffs); | 64 | 752k | IndividualChannelStream *ics = &sce->ics; | 65 | 752k | const int c = 1024 / ics->num_windows; | 66 | 752k | const uint16_t *offsets = ics->swb_offset; | 67 | 752k | const INTFLOAT *sf = sce->AAC_RENAME(sf); | 68 | 752k | const enum BandType *band_type = sce->band_type; | 69 | 752k | INTFLOAT *coef_base = coef; | 70 | | | 71 | 2.02M | for (g = 0; g < ics->num_windows; g++) | 72 | 1.27M | memset(coef + g * 128 + offsets[ics->max_sfb], 0, | 73 | 1.27M | sizeof(INTFLOAT) * (c - offsets[ics->max_sfb])); | 74 | | | 75 | 1.53M | for (g = 0; g < ics->num_window_groups; g++) { | 76 | 779k | unsigned g_len = ics->group_len[g]; | 77 | | | 78 | 4.22M | for (i = 0; i < ics->max_sfb; i++, idx++) { | 79 | 3.44M | const unsigned cbt_m1 = band_type[idx] - 1; | 80 | 3.44M | INTFLOAT *cfo = coef + offsets[i]; | 81 | 3.44M | int off_len = offsets[i + 1] - offsets[i]; | 82 | 3.44M | int group; | 83 | | | 84 | 3.44M | if (cbt_m1 >= INTENSITY_BT2 - 1) { | 85 | 3.72M | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 86 | 2.85M | memset(cfo, 0, off_len * sizeof(*cfo)); | 87 | 2.85M | } | 88 | 2.57M | } else if (cbt_m1 == NOISE_BT - 1) { | 89 | 5.28M | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 90 | 3.53M | INTFLOAT band_energy; | 91 | 3.53M | #if USE_FIXED | 92 | 35.9M | for (k = 0; k < off_len; k++) { | 93 | 32.4M | ac->random_state = lcg_random(ac->random_state); | 94 | 32.4M | cfo[k] = ac->random_state >> 3; | 95 | 32.4M | } | 96 | | | 97 | 3.53M | band_energy = ac->fdsp->scalarproduct_fixed(cfo, cfo, off_len); | 98 | 3.53M | band_energy = fixed_sqrt(band_energy, 31); | 99 | 3.53M | noise_scale(cfo, sf[idx], band_energy, off_len); | 100 | | #else | 101 | | float scale; | 102 | | | 103 | | for (k = 0; k < off_len; k++) { | 104 | | ac->random_state = lcg_random(ac->random_state); | 105 | | cfo[k] = ac->random_state; | 106 | | } | 107 | | | 108 | | band_energy = ac->fdsp->scalarproduct_float(cfo, cfo, off_len); | 109 | | scale = sf[idx] / sqrtf(band_energy); | 110 | | ac->fdsp->vector_fmul_scalar(cfo, cfo, scale, off_len); | 111 | | #endif /* USE_FIXED */ | 112 | 3.53M | } | 113 | 1.74M | } else { | 114 | | #if !USE_FIXED | 115 | | const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; | 116 | | #endif /* !USE_FIXED */ | 117 | 825k | const VLCElem *vlc_tab = ff_vlc_spectral[cbt_m1]; | 118 | 825k | OPEN_READER(re, gb); | 119 | | | 120 | 825k | switch (cbt_m1 >> 1) { | 121 | 53.1k | case 0: | 122 | 133k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 123 | 80.2k | INTFLOAT *cf = cfo; | 124 | 80.2k | int len = off_len; | 125 | | | 126 | 195k | do { | 127 | 195k | int code; | 128 | 195k | unsigned cb_idx; | 129 | | | 130 | 195k | UPDATE_CACHE(re, gb); | 131 | 195k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 132 | 195k | cb_idx = code; | 133 | 195k | #if USE_FIXED | 134 | 195k | cf = DEC_SQUAD(cf, cb_idx); | 135 | | #else | 136 | | cf = VMUL4(cf, vq, cb_idx, sf + idx); | 137 | | #endif /* USE_FIXED */ | 138 | 195k | } while (len -= 4); | 139 | 80.2k | } | 140 | 53.1k | break; | 141 | | | 142 | 86.4k | case 1: | 143 | 186k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 144 | 100k | INTFLOAT *cf = cfo; | 145 | 100k | int len = off_len; | 146 | | | 147 | 609k | do { | 148 | 609k | int code; | 149 | 609k | unsigned nnz; | 150 | 609k | unsigned cb_idx; | 151 | 609k | uint32_t bits; | 152 | | | 153 | 609k | UPDATE_CACHE(re, gb); | 154 | 609k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 155 | 609k | cb_idx = code; | 156 | 609k | nnz = cb_idx >> 8 & 15; | 157 | 609k | bits = nnz ? GET_CACHE(re, gb) : 0; | 158 | 609k | LAST_SKIP_BITS(re, gb, nnz); | 159 | 609k | #if USE_FIXED | 160 | 609k | cf = DEC_UQUAD(cf, cb_idx, bits); | 161 | | #else | 162 | | cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); | 163 | | #endif /* USE_FIXED */ | 164 | 609k | } while (len -= 4); | 165 | 100k | } | 166 | 86.4k | break; | 167 | | | 168 | 28.3k | case 2: | 169 | 75.1k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 170 | 46.8k | INTFLOAT *cf = cfo; | 171 | 46.8k | int len = off_len; | 172 | | | 173 | 209k | do { | 174 | 209k | int code; | 175 | 209k | unsigned cb_idx; | 176 | | | 177 | 209k | UPDATE_CACHE(re, gb); | 178 | 209k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 179 | 209k | cb_idx = code; | 180 | 209k | #if USE_FIXED | 181 | 209k | cf = DEC_SPAIR(cf, cb_idx); | 182 | | #else | 183 | | cf = VMUL2(cf, vq, cb_idx, sf + idx); | 184 | | #endif /* USE_FIXED */ | 185 | 209k | } while (len -= 2); | 186 | 46.8k | } | 187 | 28.3k | break; | 188 | | | 189 | 270k | case 3: | 190 | 646k | case 4: | 191 | 3.10M | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 192 | 2.46M | INTFLOAT *cf = cfo; | 193 | 2.46M | int len = off_len; | 194 | | | 195 | 7.02M | do { | 196 | 7.02M | int code; | 197 | 7.02M | unsigned nnz; | 198 | 7.02M | unsigned cb_idx; | 199 | 7.02M | unsigned sign; | 200 | | | 201 | 7.02M | UPDATE_CACHE(re, gb); | 202 | 7.02M | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 203 | 7.02M | cb_idx = code; | 204 | 7.02M | nnz = cb_idx >> 8 & 15; | 205 | 7.02M | sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; | 206 | 7.02M | LAST_SKIP_BITS(re, gb, nnz); | 207 | 7.02M | #if USE_FIXED | 208 | 7.02M | cf = DEC_UPAIR(cf, cb_idx, sign); | 209 | | #else | 210 | | cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); | 211 | | #endif /* USE_FIXED */ | 212 | 7.02M | } while (len -= 2); | 213 | 2.46M | } | 214 | 646k | break; | 215 | | | 216 | 11.5k | default: | 217 | 36.7k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 218 | 25.5k | #if USE_FIXED | 219 | 25.5k | int *icf = cfo; | 220 | 25.5k | int v; | 221 | | #else | 222 | | float *cf = cfo; | 223 | | uint32_t *icf = (uint32_t *) cf; | 224 | | #endif /* USE_FIXED */ | 225 | 25.5k | int len = off_len; | 226 | | | 227 | 91.2k | do { | 228 | 91.2k | int code; | 229 | 91.2k | unsigned nzt, nnz; | 230 | 91.2k | unsigned cb_idx; | 231 | 91.2k | uint32_t bits; | 232 | 91.2k | int j; | 233 | | | 234 | 91.2k | UPDATE_CACHE(re, gb); | 235 | 91.2k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 236 | 91.2k | cb_idx = code; | 237 | | | 238 | 91.2k | if (cb_idx == 0x0000) { | 239 | 58.8k | *icf++ = 0; | 240 | 58.8k | *icf++ = 0; | 241 | 58.8k | continue; | 242 | 58.8k | } | 243 | | | 244 | 32.4k | nnz = cb_idx >> 12; | 245 | 32.4k | nzt = cb_idx >> 8; | 246 | 32.4k | bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); | 247 | 32.4k | LAST_SKIP_BITS(re, gb, nnz); | 248 | | | 249 | 96.9k | for (j = 0; j < 2; j++) { | 250 | 64.8k | if (nzt & 1<<j) { | 251 | 13.4k | uint32_t b; | 252 | 13.4k | int n; | 253 | | /* The total length of escape_sequence must be < 22 bits according | 254 | | to the specification (i.e. max is 111111110xxxxxxxxxxxx). */ | 255 | 13.4k | UPDATE_CACHE(re, gb); | 256 | 13.4k | b = GET_CACHE(re, gb); | 257 | 13.4k | b = 31 - av_log2(~b); | 258 | | | 259 | 13.4k | if (b > 8) { | 260 | 326 | av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); | 261 | 326 | return AVERROR_INVALIDDATA; | 262 | 326 | } | 263 | | | 264 | 13.1k | SKIP_BITS(re, gb, b + 1); | 265 | 13.1k | b += 4; | 266 | 13.1k | n = (1 << b) + SHOW_UBITS(re, gb, b); | 267 | 13.1k | LAST_SKIP_BITS(re, gb, b); | 268 | 13.1k | #if USE_FIXED | 269 | 13.1k | v = n; | 270 | 13.1k | if (bits & 1U<<31) | 271 | 5.36k | v = -v; | 272 | 13.1k | *icf++ = v; | 273 | | #else | 274 | | *icf++ = ff_cbrt_tab[n] | (bits & 1U<<31); | 275 | | #endif /* USE_FIXED */ | 276 | 13.1k | bits <<= 1; | 277 | 51.3k | } else { | 278 | 51.3k | #if USE_FIXED | 279 | 51.3k | v = cb_idx & 15; | 280 | 51.3k | if (bits & 1U<<31) | 281 | 23.3k | v = -v; | 282 | 51.3k | *icf++ = v; | 283 | | #else | 284 | | unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; | 285 | | *icf++ = (bits & 1U<<31) | v; | 286 | | #endif /* USE_FIXED */ | 287 | 51.3k | bits <<= !!v; | 288 | 51.3k | } | 289 | 64.4k | cb_idx >>= 4; | 290 | 64.4k | } | 291 | 90.8k | } while (len -= 2); | 292 | | #if !USE_FIXED | 293 | | ac->fdsp->vector_fmul_scalar(cfo, cfo, sf[idx], off_len); | 294 | | #endif /* !USE_FIXED */ | 295 | 25.5k | } | 296 | 825k | } | 297 | | | 298 | 825k | CLOSE_READER(re, gb); | 299 | 825k | } | 300 | 3.44M | } | 301 | 778k | coef += g_len << 7; | 302 | 778k | } | 303 | | | 304 | 752k | if (pulse) { | 305 | 78.0k | idx = 0; | 306 | 266k | for (i = 0; i < pulse->num_pulse; i++) { | 307 | 188k | INTFLOAT co = coef_base[ pulse->pos[i] ]; | 308 | 1.22M | while (offsets[idx + 1] <= pulse->pos[i]) | 309 | 1.03M | idx++; | 310 | 188k | if (band_type[idx] != NOISE_BT && sf[idx]) { | 311 | 22.3k | INTFLOAT ico = -pulse->amp[i]; | 312 | 22.3k | #if USE_FIXED | 313 | 22.3k | if (co) { | 314 | 8.85k | ico = co + (co > 0 ? -ico : ico); | 315 | 8.85k | } | 316 | 22.3k | coef_base[ pulse->pos[i] ] = ico; | 317 | | #else | 318 | | if (co) { | 319 | | co /= sf[idx]; | 320 | | ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); | 321 | | } | 322 | | coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; | 323 | | #endif /* USE_FIXED */ | 324 | 22.3k | } | 325 | 188k | } | 326 | 78.0k | } | 327 | 752k | #if USE_FIXED | 328 | 752k | coef = coef_base; | 329 | 752k | idx = 0; | 330 | 1.53M | for (g = 0; g < ics->num_window_groups; g++) { | 331 | 778k | unsigned g_len = ics->group_len[g]; | 332 | | | 333 | 4.22M | for (i = 0; i < ics->max_sfb; i++, idx++) { | 334 | 3.44M | const unsigned cbt_m1 = band_type[idx] - 1; | 335 | 3.44M | int *cfo = coef + offsets[i]; | 336 | 3.44M | int off_len = offsets[i + 1] - offsets[i]; | 337 | 3.44M | int group; | 338 | | | 339 | 3.44M | if (cbt_m1 < NOISE_BT - 1) { | 340 | 3.54M | for (group = 0; group < (int)g_len; group++, cfo+=128) { | 341 | 2.71M | vector_pow43(cfo, off_len); | 342 | 2.71M | subband_scale(cfo, cfo, sf[idx], 34, off_len, ac->avctx); | 343 | 2.71M | } | 344 | 825k | } | 345 | 3.44M | } | 346 | 778k | coef += g_len << 7; | 347 | 778k | } | 348 | 752k | #endif /* USE_FIXED */ | 349 | 752k | return 0; | 350 | 752k | } |
aacdec_float.c:decode_spectrum_and_dequant Line | Count | Source | 61 | 562k | { | 62 | 562k | int i, k, g, idx = 0; | 63 | 562k | INTFLOAT *coef = sce->AAC_RENAME(coeffs); | 64 | 562k | IndividualChannelStream *ics = &sce->ics; | 65 | 562k | const int c = 1024 / ics->num_windows; | 66 | 562k | const uint16_t *offsets = ics->swb_offset; | 67 | 562k | const INTFLOAT *sf = sce->AAC_RENAME(sf); | 68 | 562k | const enum BandType *band_type = sce->band_type; | 69 | 562k | INTFLOAT *coef_base = coef; | 70 | | | 71 | 1.47M | for (g = 0; g < ics->num_windows; g++) | 72 | 915k | memset(coef + g * 128 + offsets[ics->max_sfb], 0, | 73 | 915k | sizeof(INTFLOAT) * (c - offsets[ics->max_sfb])); | 74 | | | 75 | 1.36M | for (g = 0; g < ics->num_window_groups; g++) { | 76 | 804k | unsigned g_len = ics->group_len[g]; | 77 | | | 78 | 1.16M | for (i = 0; i < ics->max_sfb; i++, idx++) { | 79 | 355k | const unsigned cbt_m1 = band_type[idx] - 1; | 80 | 355k | INTFLOAT *cfo = coef + offsets[i]; | 81 | 355k | int off_len = offsets[i + 1] - offsets[i]; | 82 | 355k | int group; | 83 | | | 84 | 355k | if (cbt_m1 >= INTENSITY_BT2 - 1) { | 85 | 273k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 86 | 167k | memset(cfo, 0, off_len * sizeof(*cfo)); | 87 | 167k | } | 88 | 249k | } else if (cbt_m1 == NOISE_BT - 1) { | 89 | 187k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 90 | 94.6k | INTFLOAT band_energy; | 91 | | #if USE_FIXED | 92 | | for (k = 0; k < off_len; k++) { | 93 | | ac->random_state = lcg_random(ac->random_state); | 94 | | cfo[k] = ac->random_state >> 3; | 95 | | } | 96 | | | 97 | | band_energy = ac->fdsp->scalarproduct_fixed(cfo, cfo, off_len); | 98 | | band_energy = fixed_sqrt(band_energy, 31); | 99 | | noise_scale(cfo, sf[idx], band_energy, off_len); | 100 | | #else | 101 | 94.6k | float scale; | 102 | | | 103 | 1.79M | for (k = 0; k < off_len; k++) { | 104 | 1.70M | ac->random_state = lcg_random(ac->random_state); | 105 | 1.70M | cfo[k] = ac->random_state; | 106 | 1.70M | } | 107 | | | 108 | 94.6k | band_energy = ac->fdsp->scalarproduct_float(cfo, cfo, off_len); | 109 | 94.6k | scale = sf[idx] / sqrtf(band_energy); | 110 | 94.6k | ac->fdsp->vector_fmul_scalar(cfo, cfo, scale, off_len); | 111 | 94.6k | #endif /* USE_FIXED */ | 112 | 94.6k | } | 113 | 157k | } else { | 114 | 157k | #if !USE_FIXED | 115 | 157k | const float *vq = ff_aac_codebook_vector_vals[cbt_m1]; | 116 | 157k | #endif /* !USE_FIXED */ | 117 | 157k | const VLCElem *vlc_tab = ff_vlc_spectral[cbt_m1]; | 118 | 157k | OPEN_READER(re, gb); | 119 | | | 120 | 157k | switch (cbt_m1 >> 1) { | 121 | 25.7k | case 0: | 122 | 56.0k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 123 | 30.3k | INTFLOAT *cf = cfo; | 124 | 30.3k | int len = off_len; | 125 | | | 126 | 77.0k | do { | 127 | 77.0k | int code; | 128 | 77.0k | unsigned cb_idx; | 129 | | | 130 | 77.0k | UPDATE_CACHE(re, gb); | 131 | 77.0k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 132 | 77.0k | cb_idx = code; | 133 | | #if USE_FIXED | 134 | | cf = DEC_SQUAD(cf, cb_idx); | 135 | | #else | 136 | 77.0k | cf = VMUL4(cf, vq, cb_idx, sf + idx); | 137 | 77.0k | #endif /* USE_FIXED */ | 138 | 77.0k | } while (len -= 4); | 139 | 30.3k | } | 140 | 25.7k | break; | 141 | | | 142 | 57.0k | case 1: | 143 | 119k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 144 | 62.2k | INTFLOAT *cf = cfo; | 145 | 62.2k | int len = off_len; | 146 | | | 147 | 187k | do { | 148 | 187k | int code; | 149 | 187k | unsigned nnz; | 150 | 187k | unsigned cb_idx; | 151 | 187k | uint32_t bits; | 152 | | | 153 | 187k | UPDATE_CACHE(re, gb); | 154 | 187k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 155 | 187k | cb_idx = code; | 156 | 187k | nnz = cb_idx >> 8 & 15; | 157 | 187k | bits = nnz ? GET_CACHE(re, gb) : 0; | 158 | 187k | LAST_SKIP_BITS(re, gb, nnz); | 159 | | #if USE_FIXED | 160 | | cf = DEC_UQUAD(cf, cb_idx, bits); | 161 | | #else | 162 | 187k | cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); | 163 | 187k | #endif /* USE_FIXED */ | 164 | 187k | } while (len -= 4); | 165 | 62.2k | } | 166 | 57.0k | break; | 167 | | | 168 | 15.6k | case 2: | 169 | 35.7k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 170 | 20.0k | INTFLOAT *cf = cfo; | 171 | 20.0k | int len = off_len; | 172 | | | 173 | 104k | do { | 174 | 104k | int code; | 175 | 104k | unsigned cb_idx; | 176 | | | 177 | 104k | UPDATE_CACHE(re, gb); | 178 | 104k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 179 | 104k | cb_idx = code; | 180 | | #if USE_FIXED | 181 | | cf = DEC_SPAIR(cf, cb_idx); | 182 | | #else | 183 | 104k | cf = VMUL2(cf, vq, cb_idx, sf + idx); | 184 | 104k | #endif /* USE_FIXED */ | 185 | 104k | } while (len -= 2); | 186 | 20.0k | } | 187 | 15.6k | break; | 188 | | | 189 | 8.86k | case 3: | 190 | 31.5k | case 4: | 191 | 67.3k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 192 | 35.7k | INTFLOAT *cf = cfo; | 193 | 35.7k | int len = off_len; | 194 | | | 195 | 230k | do { | 196 | 230k | int code; | 197 | 230k | unsigned nnz; | 198 | 230k | unsigned cb_idx; | 199 | 230k | unsigned sign; | 200 | | | 201 | 230k | UPDATE_CACHE(re, gb); | 202 | 230k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 203 | 230k | cb_idx = code; | 204 | 230k | nnz = cb_idx >> 8 & 15; | 205 | 230k | sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; | 206 | 230k | LAST_SKIP_BITS(re, gb, nnz); | 207 | | #if USE_FIXED | 208 | | cf = DEC_UPAIR(cf, cb_idx, sign); | 209 | | #else | 210 | 230k | cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); | 211 | 230k | #endif /* USE_FIXED */ | 212 | 230k | } while (len -= 2); | 213 | 35.7k | } | 214 | 31.5k | break; | 215 | | | 216 | 27.0k | default: | 217 | 54.3k | for (group = 0; group < (AAC_SIGNE)g_len; group++, cfo+=128) { | 218 | | #if USE_FIXED | 219 | | int *icf = cfo; | 220 | | int v; | 221 | | #else | 222 | 27.5k | float *cf = cfo; | 223 | 27.5k | uint32_t *icf = (uint32_t *) cf; | 224 | 27.5k | #endif /* USE_FIXED */ | 225 | 27.5k | int len = off_len; | 226 | | | 227 | 164k | do { | 228 | 164k | int code; | 229 | 164k | unsigned nzt, nnz; | 230 | 164k | unsigned cb_idx; | 231 | 164k | uint32_t bits; | 232 | 164k | int j; | 233 | | | 234 | 164k | UPDATE_CACHE(re, gb); | 235 | 164k | GET_VLC(code, re, gb, vlc_tab, 8, 2); | 236 | 164k | cb_idx = code; | 237 | | | 238 | 164k | if (cb_idx == 0x0000) { | 239 | 121k | *icf++ = 0; | 240 | 121k | *icf++ = 0; | 241 | 121k | continue; | 242 | 121k | } | 243 | | | 244 | 42.9k | nnz = cb_idx >> 12; | 245 | 42.9k | nzt = cb_idx >> 8; | 246 | 42.9k | bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); | 247 | 42.9k | LAST_SKIP_BITS(re, gb, nnz); | 248 | | | 249 | 128k | for (j = 0; j < 2; j++) { | 250 | 85.6k | if (nzt & 1<<j) { | 251 | 10.5k | uint32_t b; | 252 | 10.5k | int n; | 253 | | /* The total length of escape_sequence must be < 22 bits according | 254 | | to the specification (i.e. max is 111111110xxxxxxxxxxxx). */ | 255 | 10.5k | UPDATE_CACHE(re, gb); | 256 | 10.5k | b = GET_CACHE(re, gb); | 257 | 10.5k | b = 31 - av_log2(~b); | 258 | | | 259 | 10.5k | if (b > 8) { | 260 | 284 | av_log(ac->avctx, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); | 261 | 284 | return AVERROR_INVALIDDATA; | 262 | 284 | } | 263 | | | 264 | 10.2k | SKIP_BITS(re, gb, b + 1); | 265 | 10.2k | b += 4; | 266 | 10.2k | n = (1 << b) + SHOW_UBITS(re, gb, b); | 267 | 10.2k | LAST_SKIP_BITS(re, gb, b); | 268 | | #if USE_FIXED | 269 | | v = n; | 270 | | if (bits & 1U<<31) | 271 | | v = -v; | 272 | | *icf++ = v; | 273 | | #else | 274 | 10.2k | *icf++ = ff_cbrt_tab[n] | (bits & 1U<<31); | 275 | 10.2k | #endif /* USE_FIXED */ | 276 | 10.2k | bits <<= 1; | 277 | 75.1k | } else { | 278 | | #if USE_FIXED | 279 | | v = cb_idx & 15; | 280 | | if (bits & 1U<<31) | 281 | | v = -v; | 282 | | *icf++ = v; | 283 | | #else | 284 | 75.1k | unsigned v = ((const uint32_t*)vq)[cb_idx & 15]; | 285 | 75.1k | *icf++ = (bits & 1U<<31) | v; | 286 | 75.1k | #endif /* USE_FIXED */ | 287 | 75.1k | bits <<= !!v; | 288 | 75.1k | } | 289 | 85.3k | cb_idx >>= 4; | 290 | 85.3k | } | 291 | 164k | } while (len -= 2); | 292 | 27.2k | #if !USE_FIXED | 293 | 27.2k | ac->fdsp->vector_fmul_scalar(cfo, cfo, sf[idx], off_len); | 294 | 27.2k | #endif /* !USE_FIXED */ | 295 | 27.2k | } | 296 | 157k | } | 297 | | | 298 | 156k | CLOSE_READER(re, gb); | 299 | 156k | } | 300 | 355k | } | 301 | 804k | coef += g_len << 7; | 302 | 804k | } | 303 | | | 304 | 562k | if (pulse) { | 305 | 21.4k | idx = 0; | 306 | 83.7k | for (i = 0; i < pulse->num_pulse; i++) { | 307 | 62.2k | INTFLOAT co = coef_base[ pulse->pos[i] ]; | 308 | 421k | while (offsets[idx + 1] <= pulse->pos[i]) | 309 | 358k | idx++; | 310 | 62.2k | if (band_type[idx] != NOISE_BT && sf[idx]) { | 311 | 7.13k | INTFLOAT ico = -pulse->amp[i]; | 312 | | #if USE_FIXED | 313 | | if (co) { | 314 | | ico = co + (co > 0 ? -ico : ico); | 315 | | } | 316 | | coef_base[ pulse->pos[i] ] = ico; | 317 | | #else | 318 | 7.13k | if (co) { | 319 | 3.14k | co /= sf[idx]; | 320 | 3.14k | ico = co / sqrtf(sqrtf(fabsf(co))) + (co > 0 ? -ico : ico); | 321 | 3.14k | } | 322 | 7.13k | coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico * sf[idx]; | 323 | 7.13k | #endif /* USE_FIXED */ | 324 | 7.13k | } | 325 | 62.2k | } | 326 | 21.4k | } | 327 | | #if USE_FIXED | 328 | | coef = coef_base; | 329 | | idx = 0; | 330 | | for (g = 0; g < ics->num_window_groups; g++) { | 331 | | unsigned g_len = ics->group_len[g]; | 332 | | | 333 | | for (i = 0; i < ics->max_sfb; i++, idx++) { | 334 | | const unsigned cbt_m1 = band_type[idx] - 1; | 335 | | int *cfo = coef + offsets[i]; | 336 | | int off_len = offsets[i + 1] - offsets[i]; | 337 | | int group; | 338 | | | 339 | | if (cbt_m1 < NOISE_BT - 1) { | 340 | | for (group = 0; group < (int)g_len; group++, cfo+=128) { | 341 | | vector_pow43(cfo, off_len); | 342 | | subband_scale(cfo, cfo, sf[idx], 34, off_len, ac->avctx); | 343 | | } | 344 | | } | 345 | | } | 346 | | coef += g_len << 7; | 347 | | } | 348 | | #endif /* USE_FIXED */ | 349 | 562k | return 0; | 350 | 562k | } |
|
351 | | |
352 | | /** |
353 | | * Decode coupling_channel_element; reference: table 4.8. |
354 | | * |
355 | | * @return Returns error status. 0 - OK, !0 - error |
356 | | */ |
357 | | static int AAC_RENAME(decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelElement *che) |
358 | 32.8k | { |
359 | 32.8k | int num_gain = 0; |
360 | 32.8k | int c, g, sfb, ret; |
361 | 32.8k | int sign; |
362 | 32.8k | INTFLOAT scale; |
363 | 32.8k | SingleChannelElement *sce = &che->ch[0]; |
364 | 32.8k | ChannelCoupling *coup = &che->coup; |
365 | | |
366 | 32.8k | coup->coupling_point = 2 * get_bits1(gb); |
367 | 32.8k | coup->num_coupled = get_bits(gb, 3); |
368 | 143k | for (c = 0; c <= coup->num_coupled; c++) { |
369 | 110k | num_gain++; |
370 | 110k | coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; |
371 | 110k | coup->id_select[c] = get_bits(gb, 4); |
372 | 110k | if (coup->type[c] == TYPE_CPE) { |
373 | 34.2k | coup->ch_select[c] = get_bits(gb, 2); |
374 | 34.2k | if (coup->ch_select[c] == 3) |
375 | 10.6k | num_gain++; |
376 | 34.2k | } else |
377 | 76.6k | coup->ch_select[c] = 2; |
378 | 110k | } |
379 | 32.8k | coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); |
380 | | |
381 | 32.8k | sign = get_bits(gb, 1); |
382 | | #if USE_FIXED |
383 | | scale = get_bits(gb, 2); |
384 | | #else |
385 | | scale = cce_scale[get_bits(gb, 2)]; |
386 | | #endif |
387 | | |
388 | 32.8k | if ((ret = ff_aac_decode_ics(ac, sce, gb, 0, 0))) |
389 | 14.1k | return ret; |
390 | | |
391 | 88.9k | for (c = 0; c < num_gain; c++) { |
392 | 70.4k | int idx = 0; |
393 | 70.4k | int cge = 1; |
394 | 70.4k | int gain = 0; |
395 | 70.4k | INTFLOAT gain_cache = FIXR10(1.); |
396 | 70.4k | if (c) { |
397 | 51.6k | cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); |
398 | 51.6k | gain = cge ? get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - 60: 0; |
399 | 51.6k | gain_cache = GET_GAIN(scale, gain); |
400 | | #if USE_FIXED |
401 | 19.9k | if ((abs(gain_cache)-1024) >> 3 > 30) |
402 | 80 | return AVERROR(ERANGE); |
403 | | #endif |
404 | 51.6k | } |
405 | 70.3k | if (coup->coupling_point == AFTER_IMDCT) { |
406 | 16.7k | coup->gain[c][0] = gain_cache; |
407 | 53.5k | } else { |
408 | 111k | for (g = 0; g < sce->ics.num_window_groups; g++) { |
409 | 308k | for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { |
410 | 251k | if (sce->band_type[idx] != ZERO_BT) { |
411 | 246k | if (!cge) { |
412 | 122k | int t = get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - 60; |
413 | 122k | if (t) { |
414 | 31.8k | int s = 1; |
415 | 31.8k | t = gain += t; |
416 | 31.8k | if (sign) { |
417 | 28.1k | s -= 2 * (t & 0x1); |
418 | 28.1k | t >>= 1; |
419 | 28.1k | } |
420 | 31.8k | gain_cache = GET_GAIN(scale, t) * s; |
421 | | #if USE_FIXED |
422 | 24.9k | if ((abs(gain_cache)-1024) >> 3 > 30) |
423 | 95 | return AVERROR(ERANGE); |
424 | | #endif |
425 | 31.8k | } |
426 | 122k | } |
427 | 141k | coup->gain[c][idx] = gain_cache; |
428 | 141k | } |
429 | 251k | } |
430 | 57.6k | } |
431 | 53.5k | } |
432 | 24.1k | } |
433 | 4.07k | return 0; |
434 | 4.24k | } aacdec_fixed.c:decode_cce_fixed Line | Count | Source | 358 | 6.54k | { | 359 | 6.54k | int num_gain = 0; | 360 | 6.54k | int c, g, sfb, ret; | 361 | 6.54k | int sign; | 362 | 6.54k | INTFLOAT scale; | 363 | 6.54k | SingleChannelElement *sce = &che->ch[0]; | 364 | 6.54k | ChannelCoupling *coup = &che->coup; | 365 | | | 366 | 6.54k | coup->coupling_point = 2 * get_bits1(gb); | 367 | 6.54k | coup->num_coupled = get_bits(gb, 3); | 368 | 35.9k | for (c = 0; c <= coup->num_coupled; c++) { | 369 | 29.4k | num_gain++; | 370 | 29.4k | coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; | 371 | 29.4k | coup->id_select[c] = get_bits(gb, 4); | 372 | 29.4k | if (coup->type[c] == TYPE_CPE) { | 373 | 10.5k | coup->ch_select[c] = get_bits(gb, 2); | 374 | 10.5k | if (coup->ch_select[c] == 3) | 375 | 4.59k | num_gain++; | 376 | 10.5k | } else | 377 | 18.8k | coup->ch_select[c] = 2; | 378 | 29.4k | } | 379 | 6.54k | coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); | 380 | | | 381 | 6.54k | sign = get_bits(gb, 1); | 382 | 6.54k | #if USE_FIXED | 383 | 6.54k | scale = get_bits(gb, 2); | 384 | | #else | 385 | | scale = cce_scale[get_bits(gb, 2)]; | 386 | | #endif | 387 | | | 388 | 6.54k | if ((ret = ff_aac_decode_ics(ac, sce, gb, 0, 0))) | 389 | 2.29k | return ret; | 390 | | | 391 | 28.3k | for (c = 0; c < num_gain; c++) { | 392 | 24.2k | int idx = 0; | 393 | 24.2k | int cge = 1; | 394 | 24.2k | int gain = 0; | 395 | 24.2k | INTFLOAT gain_cache = FIXR10(1.); | 396 | 24.2k | if (c) { | 397 | 19.9k | cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); | 398 | 19.9k | gain = cge ? get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - 60: 0; | 399 | 19.9k | gain_cache = GET_GAIN(scale, gain); | 400 | 19.9k | #if USE_FIXED | 401 | 19.9k | if ((abs(gain_cache)-1024) >> 3 > 30) | 402 | 80 | return AVERROR(ERANGE); | 403 | 19.9k | #endif | 404 | 19.9k | } | 405 | 24.1k | if (coup->coupling_point == AFTER_IMDCT) { | 406 | 5.47k | coup->gain[c][0] = gain_cache; | 407 | 18.6k | } else { | 408 | 38.0k | for (g = 0; g < sce->ics.num_window_groups; g++) { | 409 | 163k | for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { | 410 | 144k | if (sce->band_type[idx] != ZERO_BT) { | 411 | 141k | if (!cge) { | 412 | 83.2k | int t = get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - 60; | 413 | 83.2k | if (t) { | 414 | 24.9k | int s = 1; | 415 | 24.9k | t = gain += t; | 416 | 24.9k | if (sign) { | 417 | 23.4k | s -= 2 * (t & 0x1); | 418 | 23.4k | t >>= 1; | 419 | 23.4k | } | 420 | 24.9k | gain_cache = GET_GAIN(scale, t) * s; | 421 | 24.9k | #if USE_FIXED | 422 | 24.9k | if ((abs(gain_cache)-1024) >> 3 > 30) | 423 | 95 | return AVERROR(ERANGE); | 424 | 24.9k | #endif | 425 | 24.9k | } | 426 | 83.2k | } | 427 | 141k | coup->gain[c][idx] = gain_cache; | 428 | 141k | } | 429 | 144k | } | 430 | 19.5k | } | 431 | 18.6k | } | 432 | 24.1k | } | 433 | 4.07k | return 0; | 434 | 4.24k | } |
aacdec_float.c:decode_cce Line | Count | Source | 358 | 26.2k | { | 359 | 26.2k | int num_gain = 0; | 360 | 26.2k | int c, g, sfb, ret; | 361 | 26.2k | int sign; | 362 | 26.2k | INTFLOAT scale; | 363 | 26.2k | SingleChannelElement *sce = &che->ch[0]; | 364 | 26.2k | ChannelCoupling *coup = &che->coup; | 365 | | | 366 | 26.2k | coup->coupling_point = 2 * get_bits1(gb); | 367 | 26.2k | coup->num_coupled = get_bits(gb, 3); | 368 | 107k | for (c = 0; c <= coup->num_coupled; c++) { | 369 | 81.5k | num_gain++; | 370 | 81.5k | coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE; | 371 | 81.5k | coup->id_select[c] = get_bits(gb, 4); | 372 | 81.5k | if (coup->type[c] == TYPE_CPE) { | 373 | 23.7k | coup->ch_select[c] = get_bits(gb, 2); | 374 | 23.7k | if (coup->ch_select[c] == 3) | 375 | 6.03k | num_gain++; | 376 | 23.7k | } else | 377 | 57.7k | coup->ch_select[c] = 2; | 378 | 81.5k | } | 379 | 26.2k | coup->coupling_point += get_bits1(gb) || (coup->coupling_point >> 1); | 380 | | | 381 | 26.2k | sign = get_bits(gb, 1); | 382 | | #if USE_FIXED | 383 | | scale = get_bits(gb, 2); | 384 | | #else | 385 | 26.2k | scale = cce_scale[get_bits(gb, 2)]; | 386 | 26.2k | #endif | 387 | | | 388 | 26.2k | if ((ret = ff_aac_decode_ics(ac, sce, gb, 0, 0))) | 389 | 11.8k | return ret; | 390 | | | 391 | 60.6k | for (c = 0; c < num_gain; c++) { | 392 | 46.1k | int idx = 0; | 393 | 46.1k | int cge = 1; | 394 | 46.1k | int gain = 0; | 395 | 46.1k | INTFLOAT gain_cache = FIXR10(1.); | 396 | 46.1k | if (c) { | 397 | 31.7k | cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb); | 398 | 31.7k | gain = cge ? get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - 60: 0; | 399 | 31.7k | gain_cache = GET_GAIN(scale, gain); | 400 | | #if USE_FIXED | 401 | | if ((abs(gain_cache)-1024) >> 3 > 30) | 402 | | return AVERROR(ERANGE); | 403 | | #endif | 404 | 31.7k | } | 405 | 46.1k | if (coup->coupling_point == AFTER_IMDCT) { | 406 | 11.2k | coup->gain[c][0] = gain_cache; | 407 | 34.8k | } else { | 408 | 73.0k | for (g = 0; g < sce->ics.num_window_groups; g++) { | 409 | 144k | for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) { | 410 | 106k | if (sce->band_type[idx] != ZERO_BT) { | 411 | 105k | if (!cge) { | 412 | 39.2k | int t = get_vlc2(gb, ff_vlc_scalefactors, 7, 3) - 60; | 413 | 39.2k | if (t) { | 414 | 6.94k | int s = 1; | 415 | 6.94k | t = gain += t; | 416 | 6.94k | if (sign) { | 417 | 4.65k | s -= 2 * (t & 0x1); | 418 | 4.65k | t >>= 1; | 419 | 4.65k | } | 420 | 6.94k | gain_cache = GET_GAIN(scale, t) * s; | 421 | | #if USE_FIXED | 422 | | if ((abs(gain_cache)-1024) >> 3 > 30) | 423 | | return AVERROR(ERANGE); | 424 | | #endif | 425 | 6.94k | } | 426 | 39.2k | } | 427 | 105k | coup->gain[c][idx] = gain_cache; | 428 | 105k | } | 429 | 106k | } | 430 | 38.1k | } | 431 | 34.8k | } | 432 | 46.1k | } | 433 | 14.4k | return 0; | 434 | 26.2k | } |
|
435 | | |
436 | | static av_cold void AAC_RENAME(aac_proc_init)(AACDecProc *aac_proc) |
437 | 25.5k | { |
438 | 51.1k | #define SET(member) aac_proc->member = AAC_RENAME(member) |
439 | 25.5k | SET(decode_spectrum_and_dequant); |
440 | 25.5k | SET(decode_cce); |
441 | 25.5k | #undef SET |
442 | 102k | #define SET(member) aac_proc->member = AV_JOIN(ff_aac_, AAC_RENAME(member)); |
443 | 25.5k | SET(sbr_ctx_alloc_init); |
444 | 25.5k | SET(sbr_decode_extension); |
445 | 25.5k | SET(sbr_apply); |
446 | 25.5k | SET(sbr_ctx_close); |
447 | 25.5k | #undef SET |
448 | 25.5k | } aacdec_fixed.c:aac_proc_init_fixed Line | Count | Source | 437 | 5.88k | { | 438 | 5.88k | #define SET(member) aac_proc->member = AAC_RENAME(member) | 439 | 5.88k | SET(decode_spectrum_and_dequant); | 440 | 5.88k | SET(decode_cce); | 441 | 5.88k | #undef SET | 442 | 5.88k | #define SET(member) aac_proc->member = AV_JOIN(ff_aac_, AAC_RENAME(member)); | 443 | 5.88k | SET(sbr_ctx_alloc_init); | 444 | 5.88k | SET(sbr_decode_extension); | 445 | 5.88k | SET(sbr_apply); | 446 | 5.88k | SET(sbr_ctx_close); | 447 | 5.88k | #undef SET | 448 | 5.88k | } |
aacdec_float.c:aac_proc_init Line | Count | Source | 437 | 19.6k | { | 438 | 19.6k | #define SET(member) aac_proc->member = AAC_RENAME(member) | 439 | 19.6k | SET(decode_spectrum_and_dequant); | 440 | 19.6k | SET(decode_cce); | 441 | 19.6k | #undef SET | 442 | 19.6k | #define SET(member) aac_proc->member = AV_JOIN(ff_aac_, AAC_RENAME(member)); | 443 | 19.6k | SET(sbr_ctx_alloc_init); | 444 | 19.6k | SET(sbr_decode_extension); | 445 | 19.6k | SET(sbr_apply); | 446 | 19.6k | SET(sbr_ctx_close); | 447 | 19.6k | #undef SET | 448 | 19.6k | } |
|