1 /******************************************************************************
2 * *
3 * Copyright (C) 2018 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *****************************************************************************
18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19 */
20 #include <string.h>
21
22 #include "ixheaacd_sbr_common.h"
23 #include "ixheaacd_type_def.h"
24
25 #include "ixheaacd_constants.h"
26 #include "ixheaacd_basic_ops32.h"
27 #include "ixheaacd_basic_ops16.h"
28 #include "ixheaacd_basic_ops40.h"
29 #include "ixheaacd_basic_ops.h"
30
31 #include "ixheaacd_intrinsics.h"
32 #include "ixheaacd_common_rom.h"
33 #include "ixheaacd_bitbuffer.h"
34 #include "ixheaacd_sbrdecsettings.h"
35 #include "ixheaacd_sbr_scale.h"
36 #include "ixheaacd_lpp_tran.h"
37 #include "ixheaacd_env_extr_part.h"
38 #include "ixheaacd_sbr_rom.h"
39 #include "ixheaacd_hybrid.h"
40 #include "ixheaacd_ps_dec.h"
41 #include "ixheaacd_env_extr.h"
42 #include "ixheaacd_qmf_dec.h"
43
44 #include "ixheaacd_basic_op.h"
45 #include "ixheaacd_env_calc.h"
46
47 #include "ixheaacd_interface.h"
48
49 #include "ixheaacd_function_selector.h"
50 #include "ixheaacd_audioobjtypes.h"
51
52 #define DCT3_LEN (32)
53 #define DCT2_LEN (64)
54
55 #define LP_SHIFT_VAL 7
56 #define HQ_SHIFT_64 4
57 #define RADIXSHIFT 1
58 #define ROUNDING_SPECTRA 1
59 #define HQ_SHIFT_VAL 4
60
ixheaacd_mult32x32in32_shift25(WORD32 a,WORD32 b)61 static PLATFORM_INLINE WORD32 ixheaacd_mult32x32in32_shift25(WORD32 a,
62 WORD32 b) {
63 WORD32 result;
64 WORD64 temp_result;
65
66 temp_result = (WORD64)a * (WORD64)b;
67
68 result = (WORD32)(temp_result >> 25);
69
70 return (result);
71 }
72
ixheaacd_pretwdct2(WORD32 * inp,WORD32 * out_fwd)73 VOID ixheaacd_pretwdct2(WORD32 *inp, WORD32 *out_fwd) {
74 WORD32 n;
75 WORD32 *out_rev = out_fwd + DCT2_LEN - 1;
76
77 for (n = 0; n < DCT2_LEN / 2; n++) {
78 *out_fwd = *inp;
79 inp++;
80 *out_rev = *inp;
81 out_fwd++;
82
83 out_rev--;
84 inp++;
85 }
86
87 return;
88 }
89
ixheaacd_pretwdct2_32(WORD32 * inp,WORD32 * out_fwd,int dct2_len)90 static PLATFORM_INLINE VOID ixheaacd_pretwdct2_32(WORD32 *inp, WORD32 *out_fwd,
91 int dct2_len) {
92 WORD32 n;
93
94 WORD32 *out_rev = out_fwd + dct2_len - 1;
95 for (n = dct2_len / 2 - 1; n >= 0; n--) {
96 *out_fwd = *inp;
97 inp++;
98 *out_rev = *inp;
99 out_fwd++;
100
101 out_rev--;
102 inp++;
103 }
104
105 return;
106 }
107
ixheaacd_fftposttw(WORD32 * out,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)108 VOID ixheaacd_fftposttw(WORD32 *out,
109 ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
110 int k;
111 WORD32 *p_out_fwd, *ptr_out_rev;
112 const WORD16 *twidle_fwd, *twidle_rev;
113 WORD32 in1, in2, val1, val2;
114
115 twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 1;
116 twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 15;
117
118 p_out_fwd = out;
119 ptr_out_rev = out + DCT2_LEN - 1;
120
121 in1 = ((*p_out_fwd++) << 1);
122 val1 = ((*p_out_fwd--) << 1);
123
124 *p_out_fwd++ = in1;
125 *p_out_fwd++ = val1;
126
127 for (k = 1; k <= DCT2_LEN / 4; k++) {
128 WORD32 temp[4];
129 WORD16 twid_re, twid_im;
130
131 temp[0] = *p_out_fwd++;
132 temp[1] = *p_out_fwd--;
133 temp[3] = *ptr_out_rev--;
134 temp[2] = *ptr_out_rev++;
135
136 in2 = ixheaacd_sub32_sat(temp[3], temp[1]);
137 in1 = ixheaacd_add32_sat(temp[3], temp[1]);
138
139 temp[1] = ixheaacd_sub32_sat(temp[0], temp[2]);
140 temp[3] = ixheaacd_add32_sat(temp[0], temp[2]);
141
142 twid_re = *twidle_fwd++;
143 twid_im = *twidle_rev--;
144 val1 = ixheaacd_mult32x16in32(in1, twid_re) -
145 ixheaacd_mult32x16in32(temp[1], twid_im);
146 val2 = ixheaacd_mult32x16in32(temp[1], twid_re) +
147 ixheaacd_mult32x16in32(in1, twid_im);
148 val1 = val1 << 1;
149 val2 = val2 << 1;
150
151 *p_out_fwd++ = ixheaacd_add32_sat(temp[3], val1);
152 *p_out_fwd++ = ixheaacd_add32_sat(in2, val2);
153
154 *ptr_out_rev-- = ixheaacd_sub32_sat(val2, in2);
155 *ptr_out_rev-- = ixheaacd_sub32_sat(temp[3], val1);
156 }
157
158 return;
159 }
160
ixheaacd_posttwdct2(WORD32 * inp,WORD16 * out_fwd,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)161 VOID ixheaacd_posttwdct2(WORD32 *inp, WORD16 *out_fwd,
162 ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
163 WORD32 k;
164 WORD32 inp_re, inp_im, out_re, out_im, last_val, out_re1;
165 WORD16 *out_fwd2, *out_rev2, *out_rev;
166 WORD16 twid_re, twid_im;
167 const WORD16 *twidle_fwd;
168 WORD16 re1, im1, im2;
169
170 out_rev = out_fwd + DCT2_LEN - 1;
171 out_rev2 = out_fwd - 1;
172 out_fwd2 = out_fwd + 65;
173 out_re = *inp++;
174 out_im = *inp++;
175 out_re1 =
176 ixheaacd_sat64_32(ixheaacd_add64((WORD64)out_re, (WORD64)out_im) >> 1);
177 re1 = ixheaacd_round16(ixheaacd_shl32(out_re1, (5 - 1)));
178
179 *out_fwd++ = re1;
180
181 last_val = ixheaacd_sub32_sat(out_re, out_im);
182
183 twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 2;
184 for (k = DCT2_LEN / 2 - 2; k >= 0; k--) {
185 inp_re = *inp++;
186 inp_im = *inp++;
187
188 twid_re = *twidle_fwd++;
189 twid_im = *twidle_fwd++;
190 out_re = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(inp_re, twid_re),
191 ixheaacd_mult32x16in32(inp_im, twid_im));
192 out_im = ixheaacd_add32_sat(ixheaacd_mult32x16in32(inp_im, twid_re),
193 ixheaacd_mult32x16in32(inp_re, twid_im));
194 re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1)));
195 im1 = ixheaacd_round16(ixheaacd_shl32(out_im, (5 - 1)));
196 im2 = ixheaacd_negate16(im1);
197
198 *out_fwd++ = re1;
199 *out_rev2-- = re1;
200 *out_rev-- = im1;
201 *out_fwd2++ = im2;
202 }
203 twid_re = *twidle_fwd++;
204
205 out_re = ixheaacd_mult32x16in32(last_val, twid_re);
206 re1 = ixheaacd_round16(ixheaacd_shl32(out_re, (5 - 1)));
207
208 *out_fwd++ = re1;
209 *out_rev2-- = re1;
210
211 return;
212 }
213
ixheaacd_fftposttw_32(WORD32 * out,int dct2_len,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)214 static PLATFORM_INLINE VOID ixheaacd_fftposttw_32(
215 WORD32 *out, int dct2_len, ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
216 int k;
217 WORD32 *ptr_out_fwd, *ptr_out_rev;
218 const WORD16 *twidle_fwd, *twidle_rev;
219 WORD32 in1, in2, val1, val2;
220
221 twidle_fwd = qmf_dec_tables_ptr->post_fft_tbl + 2;
222 twidle_rev = qmf_dec_tables_ptr->post_fft_tbl + 14;
223
224 ptr_out_fwd = out;
225 ptr_out_rev = out + dct2_len - 1;
226
227 in1 = ((*ptr_out_fwd++) << 1);
228 val1 = ((*ptr_out_fwd--) << 1);
229
230 *ptr_out_fwd++ = in1;
231 *ptr_out_fwd++ = val1;
232
233 for (k = dct2_len / 4 - 1; k >= 0; k--) {
234 WORD32 temp0, temp1, temp2, temp3;
235 WORD16 twid_re, twid_im;
236
237 temp0 = *ptr_out_fwd++;
238 temp1 = *ptr_out_fwd--;
239 temp3 = *ptr_out_rev--;
240 temp2 = *ptr_out_rev++;
241
242 in1 = ixheaacd_add32_sat(temp1, temp3);
243 in2 = ixheaacd_sub32_sat(temp3, temp1);
244
245 temp1 = ixheaacd_sub32_sat(temp0, temp2);
246 temp3 = ixheaacd_add32_sat(temp0, temp2);
247
248 twid_re = *twidle_fwd;
249 twidle_fwd += 2;
250
251 twid_im = *twidle_rev;
252 twidle_rev -= 2;
253
254 val1 = ixheaacd_mult32x16in32(in1, twid_re) -
255 ixheaacd_mult32x16in32(temp1, twid_im);
256 val2 = ixheaacd_mult32x16in32(temp1, twid_re) +
257 ixheaacd_mult32x16in32(in1, twid_im);
258
259 val1 = val1 << 1;
260 val2 = val2 << 1;
261
262 *ptr_out_fwd++ = ixheaacd_add32_sat(temp3, val1);
263 *ptr_out_fwd++ = ixheaacd_add32_sat(in2, val2);
264
265 *ptr_out_rev-- = ixheaacd_sub32_sat(val2, in2);
266 *ptr_out_rev-- = ixheaacd_sub32_sat(temp3, val1);
267 }
268
269 return;
270 }
271
272 static PLATFORM_INLINE VOID
ixheaacd_posttwdct2_32(WORD32 * inp,WORD16 * out_fwd,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)273 ixheaacd_posttwdct2_32(WORD32 *inp, WORD16 *out_fwd,
274 ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
275 int k;
276 WORD32 inp_re, out_re, out_im, last_val, out_re1;
277 WORD16 *out_rev, *out_rev2, *out_fwd2;
278 WORD16 twid_re, twid_im;
279 const WORD16 *twidle_fwd;
280 WORD16 re1, im1, im2;
281 WORD32 rounding_fac = 0x8000;
282
283 out_rev = out_fwd + 32 - 1;
284 out_rev2 = out_fwd - 1;
285 out_fwd2 = out_fwd + 32 + 1;
286 out_fwd[32] = 0;
287
288 out_re = *inp++;
289 out_im = *inp++;
290
291 out_re1 =
292 ixheaacd_sat64_32(ixheaacd_add64((WORD64)out_re, (WORD64)out_im) >> 1);
293 re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re1, (5 - 1)));
294 *out_fwd++ = re1;
295 last_val = ixheaacd_sub32_sat(out_re, out_im);
296
297 twidle_fwd = qmf_dec_tables_ptr->dct23_tw + 4;
298 for (k = 14; k >= 0; k--) {
299 WORD32 temp1, temp2;
300 inp_re = *inp++;
301 twid_re = *twidle_fwd++;
302 twid_im = *twidle_fwd;
303 twidle_fwd += 3;
304
305 temp1 = ixheaacd_mult32x16in32(inp_re, twid_re);
306 temp2 = ixheaacd_mult32x16in32(inp_re, twid_im);
307
308 inp_re = *inp++;
309
310 out_re = ixheaacd_sub32_sat(temp1, ixheaacd_mult32x16in32(inp_re, twid_im));
311 out_im = ixheaacd_add32_sat(ixheaacd_mult32x16in32(inp_re, twid_re), temp2);
312
313 out_re = ixheaacd_add32_sat(out_re, out_re);
314 out_im = ixheaacd_add32_sat(out_im, out_im);
315 out_re = ixheaacd_add32_sat(out_re, out_re);
316 out_im = ixheaacd_add32_sat(out_im, out_im);
317 out_re = ixheaacd_add32_sat(out_re, out_re);
318 out_im = ixheaacd_add32_sat(out_im, out_im);
319 out_re = ixheaacd_add32_sat(out_re, out_re);
320 out_im = ixheaacd_add32_sat(out_im, out_im);
321 out_re = ixheaacd_add32_sat(out_re, rounding_fac);
322 out_im = ixheaacd_add32_sat(out_im, rounding_fac);
323 re1 = (out_re >> 16);
324 im1 = (out_im >> 16);
325 im2 = ixheaacd_negate16(im1);
326
327 *out_fwd++ = re1;
328 *out_rev2-- = re1;
329 *out_rev-- = im1;
330 *out_fwd2++ = im2;
331 }
332 twid_re = *twidle_fwd++;
333
334 out_re = ixheaacd_mult32x16in32(last_val, twid_re);
335 re1 = ixheaacd_round16(ixheaacd_shl32_sat(out_re, (5 - 1)));
336 *out_fwd++ = re1;
337 *out_rev2-- = re1;
338
339 return;
340 }
341
ixheaacd_dct2_32(WORD32 * inp,WORD32 * out,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr,WORD16 * filter_states)342 VOID ixheaacd_dct2_32(WORD32 *inp, WORD32 *out,
343 ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
344 WORD16 *filter_states) {
345 WORD32 *output;
346
347 output = out + 16;
348 filter_states = filter_states + 16;
349 ixheaacd_pretwdct2_32(inp, output, 32);
350
351 ixheaacd_radix4bfly(qmf_dec_tables_ptr->w_16, output, 1, 4);
352 ixheaacd_postradixcompute4(inp, output, qmf_dec_tables_ptr->dig_rev_table4_16,
353 16);
354 ixheaacd_fftposttw_32(inp, 32, qmf_dec_tables_ptr);
355
356 ixheaacd_posttwdct2_32(inp, filter_states, qmf_dec_tables_ptr);
357
358 return;
359 }
360
ixheaacd_sbr_qmfanal32_winadd_eld(WORD16 * inp1,WORD16 * inp2,WORD16 * p_qmf1,WORD16 * p_qmf2,WORD32 * p_out)361 VOID ixheaacd_sbr_qmfanal32_winadd_eld(WORD16 *inp1, WORD16 *inp2,
362 WORD16 *p_qmf1, WORD16 *p_qmf2,
363 WORD32 *p_out) {
364 WORD32 n;
365
366 for (n = 0; n < 32; n += 2) {
367 WORD32 accu;
368 accu = ixheaacd_mult16x16in32(inp1[n + 0], p_qmf1[(n + 0)]);
369 accu = ixheaacd_add32(
370 accu, ixheaacd_mult16x16in32(inp1[n + 64], p_qmf1[(n + 64)]));
371 accu = ixheaacd_add32(
372 accu, ixheaacd_mult16x16in32(inp1[n + 128], p_qmf1[(n + 128)]));
373 accu = ixheaacd_add32(
374 accu, ixheaacd_mult16x16in32(inp1[n + 192], p_qmf1[(n + 192)]));
375 accu = ixheaacd_add32(
376 accu, ixheaacd_mult16x16in32(inp1[n + 256], p_qmf1[(n + 256)]));
377 p_out[n] = accu;
378
379 accu = ixheaacd_mult16x16in32(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]);
380 accu = ixheaacd_add32_sat(
381 accu, ixheaacd_mult16x16in32(inp1[n + 1 + 64], p_qmf1[(n + 1 + 64)]));
382 accu = ixheaacd_add32_sat(
383 accu, ixheaacd_mult16x16in32(inp1[n + 1 + 128], p_qmf1[(n + 1 + 128)]));
384 accu = ixheaacd_add32_sat(
385 accu, ixheaacd_mult16x16in32(inp1[n + 1 + 192], p_qmf1[(n + 1 + 192)]));
386 accu = ixheaacd_add32_sat(
387 accu, ixheaacd_mult16x16in32(inp1[n + 1 + 256], p_qmf1[(n + 1 + 256)]));
388 p_out[n + 1] = accu;
389
390 accu = ixheaacd_mult16x16in32(inp2[n + 0], p_qmf2[(n + 0)]);
391 accu = ixheaacd_add32(
392 accu, ixheaacd_mult16x16in32(inp2[n + 64], p_qmf2[(n + 64)]));
393 accu = ixheaacd_add32(
394 accu, ixheaacd_mult16x16in32(inp2[n + 128], p_qmf2[(n + 128)]));
395 accu = ixheaacd_add32(
396 accu, ixheaacd_mult16x16in32(inp2[n + 192], p_qmf2[(n + 192)]));
397 accu = ixheaacd_add32(
398 accu, ixheaacd_mult16x16in32(inp2[n + 256], p_qmf2[(n + 256)]));
399 p_out[n + 32] = accu;
400
401 accu = ixheaacd_mult16x16in32(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]);
402 accu = ixheaacd_add32_sat(
403 accu, ixheaacd_mult16x16in32(inp2[n + 1 + 64], p_qmf2[(n + 1 + 64)]));
404 accu = ixheaacd_add32_sat(
405 accu, ixheaacd_mult16x16in32(inp2[n + 1 + 128], p_qmf2[(n + 1 + 128)]));
406 accu = ixheaacd_add32_sat(
407 accu, ixheaacd_mult16x16in32(inp2[n + 1 + 192], p_qmf2[(n + 1 + 192)]));
408 accu = ixheaacd_add32_sat(
409 accu, ixheaacd_mult16x16in32(inp2[n + 1 + 256], p_qmf2[(n + 1 + 256)]));
410 p_out[n + 1 + 32] = accu;
411 }
412 }
413
ixheaacd_esbr_qmfanal32_winadd(WORD32 * inp1,WORD32 * inp2,WORD32 * p_qmf1,WORD32 * p_qmf2,WORD32 * p_out,WORD32 num_band_anal_qmf)414 VOID ixheaacd_esbr_qmfanal32_winadd(WORD32 *inp1, WORD32 *inp2, WORD32 *p_qmf1,
415 WORD32 *p_qmf2, WORD32 *p_out,
416 WORD32 num_band_anal_qmf) {
417 WORD32 n;
418 WORD64 accu;
419
420 if (num_band_anal_qmf == 32) {
421 for (n = 0; n < num_band_anal_qmf; n += 2) {
422 accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[2 * (n + 0)]);
423 accu = ixheaacd_add64(
424 accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf],
425 p_qmf1[2 * (n + 2 * num_band_anal_qmf)]));
426 accu = ixheaacd_add64(
427 accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf],
428 p_qmf1[2 * (n + 4 * num_band_anal_qmf)]));
429 accu = ixheaacd_add64(
430 accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf],
431 p_qmf1[2 * (n + 6 * num_band_anal_qmf)]));
432 accu = ixheaacd_add64(
433 accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf],
434 p_qmf1[2 * (n + 8 * num_band_anal_qmf)]));
435 p_out[n] = (WORD32)(accu >> 31);
436
437 accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[2 * (n + 1 + 0)]);
438 accu = ixheaacd_add64(
439 accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf],
440 p_qmf1[2 * (n + 1 + 2 * num_band_anal_qmf)]));
441 accu = ixheaacd_add64(
442 accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf],
443 p_qmf1[2 * (n + 1 + 4 * num_band_anal_qmf)]));
444 accu = ixheaacd_add64(
445 accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf],
446 p_qmf1[2 * (n + 1 + 6 * num_band_anal_qmf)]));
447 accu = ixheaacd_add64(
448 accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf],
449 p_qmf1[2 * (n + 1 + 8 * num_band_anal_qmf)]));
450 p_out[n + 1] = (WORD32)(accu >> 31);
451
452 accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[2 * (n + 0)]);
453 accu = ixheaacd_add64(
454 accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf],
455 p_qmf2[2 * (n + 2 * num_band_anal_qmf)]));
456 accu = ixheaacd_add64(
457 accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf],
458 p_qmf2[2 * (n + 4 * num_band_anal_qmf)]));
459 accu = ixheaacd_add64(
460 accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf],
461 p_qmf2[2 * (n + 6 * num_band_anal_qmf)]));
462 accu = ixheaacd_add64(
463 accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf],
464 p_qmf2[2 * (n + 8 * num_band_anal_qmf)]));
465 p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31);
466
467 accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[2 * (n + 1 + 0)]);
468 accu = ixheaacd_add64(
469 accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf],
470 p_qmf2[2 * (n + 1 + 2 * num_band_anal_qmf)]));
471 accu = ixheaacd_add64(
472 accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf],
473 p_qmf2[2 * (n + 1 + 4 * num_band_anal_qmf)]));
474 accu = ixheaacd_add64(
475 accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf],
476 p_qmf2[2 * (n + 1 + 6 * num_band_anal_qmf)]));
477 accu = ixheaacd_add64(
478 accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf],
479 p_qmf2[2 * (n + 1 + 8 * num_band_anal_qmf)]));
480 p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31);
481 }
482 } else if (num_band_anal_qmf == 24) {
483 for (n = 0; n < num_band_anal_qmf; n += 2) {
484 accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[(n + 0)]);
485 accu = ixheaacd_add64(
486 accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf],
487 p_qmf1[(n + 2 * num_band_anal_qmf)]));
488 accu = ixheaacd_add64(
489 accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf],
490 p_qmf1[(n + 4 * num_band_anal_qmf)]));
491 accu = ixheaacd_add64(
492 accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf],
493 p_qmf1[(n + 6 * num_band_anal_qmf)]));
494 accu = ixheaacd_add64(
495 accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf],
496 p_qmf1[(n + 8 * num_band_anal_qmf)]));
497 p_out[n] = (WORD32)(accu >> 31);
498
499 accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[(n + 1 + 0)]);
500 accu = ixheaacd_add64(
501 accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf],
502 p_qmf1[(n + 1 + 2 * num_band_anal_qmf)]));
503 accu = ixheaacd_add64(
504 accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf],
505 p_qmf1[(n + 1 + 4 * num_band_anal_qmf)]));
506 accu = ixheaacd_add64(
507 accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf],
508 p_qmf1[(n + 1 + 6 * num_band_anal_qmf)]));
509 accu = ixheaacd_add64(
510 accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf],
511 p_qmf1[(n + 1 + 8 * num_band_anal_qmf)]));
512 p_out[n + 1] = (WORD32)(accu >> 31);
513
514 accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[(n + 0)]);
515 accu = ixheaacd_add64(
516 accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf],
517 p_qmf2[(n + 2 * num_band_anal_qmf)]));
518 accu = ixheaacd_add64(
519 accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf],
520 p_qmf2[(n + 4 * num_band_anal_qmf)]));
521 accu = ixheaacd_add64(
522 accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf],
523 p_qmf2[(n + 6 * num_band_anal_qmf)]));
524 accu = ixheaacd_add64(
525 accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf],
526 p_qmf2[(n + 8 * num_band_anal_qmf)]));
527 p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31);
528
529 accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[(n + 1 + 0)]);
530 accu = ixheaacd_add64(
531 accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf],
532 p_qmf2[(n + 1 + 2 * num_band_anal_qmf)]));
533 accu = ixheaacd_add64(
534 accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf],
535 p_qmf2[(n + 1 + 4 * num_band_anal_qmf)]));
536 accu = ixheaacd_add64(
537 accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf],
538 p_qmf2[(n + 1 + 6 * num_band_anal_qmf)]));
539 accu = ixheaacd_add64(
540 accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf],
541 p_qmf2[(n + 1 + 8 * num_band_anal_qmf)]));
542 p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31);
543 }
544
545 } else {
546 for (n = 0; n < num_band_anal_qmf; n += 2) {
547 accu = ixheaacd_mult64(inp1[n + 0], p_qmf1[4 * (n + 0)]);
548 accu = ixheaacd_add64(
549 accu, ixheaacd_mult64(inp1[n + 2 * num_band_anal_qmf],
550 p_qmf1[4 * (n + 2 * num_band_anal_qmf)]));
551 accu = ixheaacd_add64(
552 accu, ixheaacd_mult64(inp1[n + 4 * num_band_anal_qmf],
553 p_qmf1[4 * (n + 4 * num_band_anal_qmf)]));
554 accu = ixheaacd_add64(
555 accu, ixheaacd_mult64(inp1[n + 6 * num_band_anal_qmf],
556 p_qmf1[4 * (n + 6 * num_band_anal_qmf)]));
557 accu = ixheaacd_add64(
558 accu, ixheaacd_mult64(inp1[n + 8 * num_band_anal_qmf],
559 p_qmf1[4 * (n + 8 * num_band_anal_qmf)]));
560 p_out[n] = (WORD32)(accu >> 31);
561
562 accu = ixheaacd_mult64(inp1[n + 1 + 0], p_qmf1[4 * (n + 1 + 0)]);
563 accu = ixheaacd_add64(
564 accu, ixheaacd_mult64(inp1[n + 1 + 2 * num_band_anal_qmf],
565 p_qmf1[4 * (n + 1 + 2 * num_band_anal_qmf)]));
566 accu = ixheaacd_add64(
567 accu, ixheaacd_mult64(inp1[n + 1 + 4 * num_band_anal_qmf],
568 p_qmf1[4 * (n + 1 + 4 * num_band_anal_qmf)]));
569 accu = ixheaacd_add64(
570 accu, ixheaacd_mult64(inp1[n + 1 + 6 * num_band_anal_qmf],
571 p_qmf1[4 * (n + 1 + 6 * num_band_anal_qmf)]));
572 accu = ixheaacd_add64(
573 accu, ixheaacd_mult64(inp1[n + 1 + 8 * num_band_anal_qmf],
574 p_qmf1[4 * (n + 1 + 8 * num_band_anal_qmf)]));
575 p_out[n + 1] = (WORD32)(accu >> 31);
576
577 accu = ixheaacd_mult64(inp2[n + 0], p_qmf2[4 * (n + 0)]);
578 accu = ixheaacd_add64(
579 accu, ixheaacd_mult64(inp2[n + 2 * num_band_anal_qmf],
580 p_qmf2[4 * (n + 2 * num_band_anal_qmf)]));
581 accu = ixheaacd_add64(
582 accu, ixheaacd_mult64(inp2[n + 4 * num_band_anal_qmf],
583 p_qmf2[4 * (n + 4 * num_band_anal_qmf)]));
584 accu = ixheaacd_add64(
585 accu, ixheaacd_mult64(inp2[n + 6 * num_band_anal_qmf],
586 p_qmf2[4 * (n + 6 * num_band_anal_qmf)]));
587 accu = ixheaacd_add64(
588 accu, ixheaacd_mult64(inp2[n + 8 * num_band_anal_qmf],
589 p_qmf2[4 * (n + 8 * num_band_anal_qmf)]));
590 p_out[n + num_band_anal_qmf] = (WORD32)(accu >> 31);
591
592 accu = ixheaacd_mult64(inp2[n + 1 + 0], p_qmf2[4 * (n + 1 + 0)]);
593 accu = ixheaacd_add64(
594 accu, ixheaacd_mult64(inp2[n + 1 + 2 * num_band_anal_qmf],
595 p_qmf2[4 * (n + 1 + 2 * num_band_anal_qmf)]));
596 accu = ixheaacd_add64(
597 accu, ixheaacd_mult64(inp2[n + 1 + 4 * num_band_anal_qmf],
598 p_qmf2[4 * (n + 1 + 4 * num_band_anal_qmf)]));
599 accu = ixheaacd_add64(
600 accu, ixheaacd_mult64(inp2[n + 1 + 6 * num_band_anal_qmf],
601 p_qmf2[4 * (n + 1 + 6 * num_band_anal_qmf)]));
602 accu = ixheaacd_add64(
603 accu, ixheaacd_mult64(inp2[n + 1 + 8 * num_band_anal_qmf],
604 p_qmf2[4 * (n + 1 + 8 * num_band_anal_qmf)]));
605 p_out[n + 1 + num_band_anal_qmf] = (WORD32)(accu >> 31);
606 }
607 }
608 }
609
ixheaacd_esbr_inv_modulation(WORD32 * qmf_real,ia_sbr_qmf_filter_bank_struct * syn_qmf,ia_qmf_dec_tables_struct * qmf_dec_tables_ptr)610 VOID ixheaacd_esbr_inv_modulation(
611 WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf,
612 ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
613 ixheaacd_esbr_cos_sin_mod(qmf_real, syn_qmf, qmf_dec_tables_ptr->esbr_w_32,
614 qmf_dec_tables_ptr->dig_rev_table2_32);
615 }
616
ixheaacd_sbr_qmfsyn32_winadd(WORD16 * tmp1,WORD16 * tmp2,WORD16 * inp1,WORD16 * sample_buffer,FLAG shift,WORD32 ch_fac)617 VOID ixheaacd_sbr_qmfsyn32_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1,
618 WORD16 *sample_buffer, FLAG shift,
619 WORD32 ch_fac) {
620 WORD32 k;
621 WORD32 rounding_fac = 0x8000;
622 rounding_fac = rounding_fac >> shift;
623
624 for (k = 0; k < 32; k++) {
625 WORD32 syn_out = rounding_fac;
626
627 syn_out = ixheaacd_add32(
628 syn_out, ixheaacd_mult16x16in32(tmp1[0 + k], inp1[2 * (k + 0)]));
629 syn_out = ixheaacd_add32(
630 syn_out, ixheaacd_mult16x16in32(tmp1[128 + k], inp1[2 * (k + 64)]));
631 syn_out = ixheaacd_add32(
632 syn_out, ixheaacd_mult16x16in32(tmp1[256 + k], inp1[2 * (k + 128)]));
633 syn_out = ixheaacd_add32(
634 syn_out, ixheaacd_mult16x16in32(tmp1[384 + k], inp1[2 * (k + 192)]));
635 syn_out = ixheaacd_add32(
636 syn_out, ixheaacd_mult16x16in32(tmp1[512 + k], inp1[2 * (k + 256)]));
637
638 syn_out = ixheaacd_add32(
639 syn_out, ixheaacd_mult16x16in32(tmp2[64 + k], inp1[2 * (k + 32)]));
640 syn_out = ixheaacd_add32(
641 syn_out, ixheaacd_mult16x16in32(tmp2[192 + k], inp1[2 * (k + 96)]));
642 syn_out = ixheaacd_add32(
643 syn_out, ixheaacd_mult16x16in32(tmp2[320 + k], inp1[2 * (k + 160)]));
644 syn_out = ixheaacd_add32(
645 syn_out, ixheaacd_mult16x16in32(tmp2[448 + k], inp1[2 * (k + 224)]));
646 syn_out = ixheaacd_add32(
647 syn_out, ixheaacd_mult16x16in32(tmp2[576 + k], inp1[2 * (k + 288)]));
648 syn_out = ixheaacd_add32_sat(syn_out, syn_out);
649 if (shift == 2) {
650 syn_out = ixheaacd_add32_sat(syn_out, syn_out);
651 }
652 sample_buffer[ch_fac * k] = (syn_out >> 16);
653 }
654 }
655
ixheaacd_sbr_pre_twiddle(WORD32 * p_xre,WORD32 * p_xim,WORD16 * p_twiddles)656 void ixheaacd_sbr_pre_twiddle(WORD32 *p_xre, WORD32 *p_xim,
657 WORD16 *p_twiddles) {
658 int k;
659
660 for (k = 62; k >= 0; k--) {
661 WORD32 x_re = *p_xre;
662 WORD32 x_im = *p_xim;
663
664 WORD16 ixheaacd_cosine = *p_twiddles++;
665 WORD16 ixheaacd_sine = *p_twiddles++;
666
667 WORD32 re, im;
668
669 re = ixheaacd_mac32x16in32_shl_sat(
670 ixheaacd_mult32x16in32_shl(x_re, ixheaacd_cosine), x_im, ixheaacd_sine);
671 im = ixheaacd_sub32_sat(ixheaacd_mult32x16in32_shl(x_im, ixheaacd_cosine),
672 ixheaacd_mult32x16in32_shl(x_re, ixheaacd_sine));
673
674 *p_xre++ = re;
675 *p_xim++ = im;
676 }
677 }
678
ixheaacd_cplx_synt_qmffilt(WORD32 ** qmf_real,WORD32 ** qmf_imag,WORD32 split,ia_sbr_scale_fact_struct * sbr_scale_factor,WORD16 * time_out,ia_sbr_qmf_filter_bank_struct * qmf_bank,ia_ps_dec_struct * ptr_ps_dec,FLAG active,FLAG low_pow_flag,ia_sbr_tables_struct * sbr_tables_ptr,ixheaacd_misc_tables * pstr_common_tables,WORD32 ch_fac,FLAG drc_on,WORD32 drc_sbr_factors[][64],WORD32 audio_object_type)679 VOID ixheaacd_cplx_synt_qmffilt(
680 WORD32 **qmf_real, WORD32 **qmf_imag, WORD32 split,
681 ia_sbr_scale_fact_struct *sbr_scale_factor, WORD16 *time_out,
682 ia_sbr_qmf_filter_bank_struct *qmf_bank, ia_ps_dec_struct *ptr_ps_dec,
683 FLAG active, FLAG low_pow_flag, ia_sbr_tables_struct *sbr_tables_ptr,
684 ixheaacd_misc_tables *pstr_common_tables, WORD32 ch_fac, FLAG drc_on,
685 WORD32 drc_sbr_factors[][64], WORD32 audio_object_type) {
686 WORD32 i;
687
688 WORD32 code_scale_factor;
689 WORD32 scale_factor;
690 WORD32 out_scale_factor;
691 WORD32 low_band_scale_factor;
692 WORD32 high_band_scale_factor;
693 WORD16 *filter_states = qmf_bank->filter_states;
694 WORD32 **ptr_qmf_imag_temp;
695 WORD32 qmf_real2[2 * NO_SYNTHESIS_CHANNELS];
696
697 WORD32 no_synthesis_channels = qmf_bank->no_channels;
698 WORD32 p1;
699
700 WORD16 *fp1;
701 WORD16 *fp2;
702
703 WORD32 sixty4 = NO_SYNTHESIS_CHANNELS;
704 WORD32 thirty2 = qmf_bank->no_channels;
705
706 WORD16 *filter_coeff;
707 WORD32 num_time_slots = qmf_bank->num_time_slots;
708 WORD32 ixheaacd_drc_offset;
709 WORD32 ov_lb_scale = sbr_scale_factor->ov_lb_scale;
710 WORD32 lb_scale = sbr_scale_factor->lb_scale;
711 WORD32 st_syn_scale = sbr_scale_factor->st_syn_scale;
712 WORD32 ov_lb_shift, lb_shift, hb_shift;
713
714 WORD32 *qmf_real_tmp = qmf_real2;
715 WORD32 *qmf_imag_tmp = &qmf_real2[NO_SYNTHESIS_CHANNELS];
716 WORD32 env = 0;
717
718 WORD32 common_shift;
719
720 if (no_synthesis_channels == 32) {
721 qmf_bank->cos_twiddle =
722 (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32;
723 qmf_bank->alt_sin_twiddle =
724 (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32;
725 qmf_bank->t_cos =
726 (WORD16 *)
727 sbr_tables_ptr->qmf_dec_tables_ptr->sbr_cos_sin_twiddle_ds_l32;
728 } else {
729 qmf_bank->cos_twiddle =
730 (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l64;
731 qmf_bank->alt_sin_twiddle =
732 (WORD16 *)sbr_tables_ptr->qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l64;
733 }
734 if (audio_object_type != AOT_ER_AAC_ELD &&
735 audio_object_type != AOT_ER_AAC_LD) {
736 qmf_bank->filter_pos_syn +=
737 (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c - qmf_bank->p_filter);
738 qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c;
739 } else {
740 qmf_bank->filter_pos_syn +=
741 (sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld - qmf_bank->p_filter);
742 qmf_bank->p_filter = sbr_tables_ptr->qmf_dec_tables_ptr->qmf_c_eld;
743 }
744
745 fp1 = &filter_states[0];
746 fp2 = fp1 + no_synthesis_channels;
747
748 if (audio_object_type == AOT_ER_AAC_ELD ||
749 audio_object_type == AOT_ER_AAC_LD) {
750 fp1 = qmf_bank->fp1_syn;
751 fp2 = qmf_bank->fp2_syn;
752 sixty4 = qmf_bank->sixty4;
753 }
754
755 filter_coeff = qmf_bank->filter_pos_syn;
756
757 if (active) {
758 code_scale_factor = scale_factor = sbr_scale_factor->ps_scale;
759 } else {
760 code_scale_factor = ixheaacd_min32(lb_scale, ov_lb_scale);
761 scale_factor = sbr_scale_factor->hb_scale;
762 }
763
764 low_band_scale_factor = (st_syn_scale - code_scale_factor);
765 high_band_scale_factor = (st_syn_scale - scale_factor);
766
767 p1 = 0;
768
769 if (low_pow_flag)
770
771 {
772 ov_lb_shift = (st_syn_scale - ov_lb_scale) - 4;
773 lb_shift = (st_syn_scale - lb_scale) - 4;
774 hb_shift = high_band_scale_factor - 4;
775 out_scale_factor = -((sbr_scale_factor->st_syn_scale - 1));
776 ptr_qmf_imag_temp = 0;
777
778 }
779
780 else {
781 out_scale_factor = -((sbr_scale_factor->st_syn_scale - 3));
782 if (active) {
783 ov_lb_shift = (sbr_scale_factor->ps_scale - ov_lb_scale);
784 lb_shift = (sbr_scale_factor->ps_scale - lb_scale);
785 hb_shift = (sbr_scale_factor->ps_scale - sbr_scale_factor->hb_scale);
786 common_shift = low_band_scale_factor - 8;
787
788 } else {
789 if (audio_object_type != AOT_ER_AAC_ELD &&
790 audio_object_type != AOT_ER_AAC_LD) {
791 ov_lb_shift = (st_syn_scale - ov_lb_scale) - 8;
792 lb_shift = (st_syn_scale - lb_scale) - 8;
793 hb_shift = high_band_scale_factor - 8;
794 } else {
795 ov_lb_shift = (st_syn_scale - ov_lb_scale) - 7;
796 lb_shift = (st_syn_scale - lb_scale) - 7;
797 hb_shift = high_band_scale_factor - 7;
798 }
799 common_shift = 0;
800 }
801 ptr_qmf_imag_temp = qmf_imag;
802 }
803
804 {
805 if (ov_lb_shift == lb_shift) {
806 (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0,
807 num_time_slots, ov_lb_shift, low_pow_flag);
808
809 } else {
810 (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb, 0,
811 split, ov_lb_shift, low_pow_flag);
812
813 (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, 0, qmf_bank->lsb,
814 split, num_time_slots, lb_shift, low_pow_flag);
815 }
816
817 (*ixheaacd_adjust_scale)(qmf_real, ptr_qmf_imag_temp, qmf_bank->lsb,
818 qmf_bank->usb, 0, num_time_slots, hb_shift,
819 low_pow_flag);
820 }
821
822 ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset;
823
824 if (1 == drc_on) {
825 for (i = 0; i < num_time_slots; i++) {
826 WORD32 loop_val;
827 for (loop_val = 0; loop_val < 64; loop_val++) {
828 qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25(
829 qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]);
830 }
831 }
832 }
833
834 if (low_pow_flag)
835
836 {
837 WORD16 *fptemp;
838
839 VOID(*sbr_qmf_syn_winadd)
840 (WORD16 *, WORD16 *, WORD16 *, WORD16 *, FLAG, WORD32);
841 ia_qmf_dec_tables_struct *qmf_tab_ptr = sbr_tables_ptr->qmf_dec_tables_ptr;
842
843 if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED)
844 sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn32_winadd;
845 else
846 sbr_qmf_syn_winadd = ixheaacd_sbr_qmfsyn64_winadd;
847
848 for (i = 0; i < num_time_slots; i++) {
849 ixheaacd_inv_modulation_lp(qmf_real[i],
850 &filter_states[ixheaacd_drc_offset], qmf_bank,
851 qmf_tab_ptr);
852
853 sbr_qmf_syn_winadd(fp1, fp2, filter_coeff, &time_out[ch_fac * p1], 2,
854 ch_fac);
855
856 ixheaacd_drc_offset -= no_synthesis_channels << 1;
857
858 if (ixheaacd_drc_offset < 0)
859 ixheaacd_drc_offset += ((no_synthesis_channels << 1) * 10);
860
861 fptemp = fp1;
862 fp1 = fp2;
863 fp2 = fptemp;
864
865 filter_coeff += 64;
866
867 if (filter_coeff == qmf_bank->p_filter + 640)
868 filter_coeff = (WORD16 *)qmf_bank->p_filter;
869
870 p1 += no_synthesis_channels;
871 }
872
873 } else {
874 for (i = 0; i < num_time_slots; i++) {
875 WORD32 *t_qmf_imag;
876 t_qmf_imag = qmf_imag[i];
877
878 if (active) {
879 if (i == ptr_ps_dec->border_position[env]) {
880 ixheaacd_init_rot_env(ptr_ps_dec, (WORD16)env, qmf_bank->usb,
881 sbr_tables_ptr, pstr_common_tables->trig_data);
882 env++;
883 }
884
885 ixheaacd_apply_ps(ptr_ps_dec, &qmf_real[i], &qmf_imag[i], qmf_real_tmp,
886 qmf_imag_tmp, sbr_scale_factor, (WORD16)i,
887 sbr_tables_ptr);
888 }
889 if (1 == drc_on) {
890 WORD32 loop_val;
891 for (loop_val = 0; loop_val < 64; loop_val++) {
892 qmf_real[i][loop_val] = ixheaacd_mult32x32in32_shift25(
893 qmf_real[i][loop_val], drc_sbr_factors[6 + i][loop_val]);
894 }
895 }
896
897 if (active) {
898 if (common_shift)
899 ixheaacd_shiftrountine(qmf_real[i], t_qmf_imag, no_synthesis_channels,
900 common_shift);
901 }
902
903 if (audio_object_type == AOT_ER_AAC_ELD ||
904 audio_object_type == AOT_ER_AAC_LD)
905 ixheaacd_sbr_pre_twiddle(
906 qmf_real[i], t_qmf_imag,
907 sbr_tables_ptr->qmf_dec_tables_ptr->ixheaacd_sbr_synth_cos_sin_l32);
908
909 ixheaacd_inv_emodulation(qmf_real[i], qmf_bank,
910 sbr_tables_ptr->qmf_dec_tables_ptr);
911
912 {
913 WORD32 temp_out_scale_fac = out_scale_factor + 1;
914 if (audio_object_type == AOT_ER_AAC_LD ||
915 audio_object_type == AOT_ER_AAC_ELD) {
916 temp_out_scale_fac = temp_out_scale_fac - 1;
917
918 ixheaacd_shiftrountine_with_rnd_eld(
919 qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset],
920 no_synthesis_channels, temp_out_scale_fac);
921
922 }
923
924 else {
925 ixheaacd_shiftrountine_with_rnd(
926 qmf_real[i], t_qmf_imag, &filter_states[ixheaacd_drc_offset],
927 no_synthesis_channels, temp_out_scale_fac);
928 }
929 }
930
931 if (no_synthesis_channels == NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED) {
932 WORD32 temp = 1;
933 if (audio_object_type == AOT_ER_AAC_LD ||
934 audio_object_type == AOT_ER_AAC_ELD) {
935 temp = 2;
936 }
937 ixheaacd_sbr_qmfsyn32_winadd(fp1, fp2, filter_coeff,
938 &time_out[ch_fac * p1], temp, ch_fac);
939
940 fp1 += thirty2;
941 fp2 -= thirty2;
942 thirty2 = -thirty2;
943
944 ixheaacd_drc_offset -= 64;
945
946 if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 640;
947
948 } else {
949 WORD32 temp = 1;
950 if (audio_object_type == AOT_ER_AAC_LD ||
951 audio_object_type == AOT_ER_AAC_ELD) {
952 temp = 2;
953 }
954 ixheaacd_sbr_qmfsyn64_winadd(fp1, fp2, filter_coeff,
955 &time_out[ch_fac * p1], temp, ch_fac);
956
957 fp1 += sixty4;
958 fp2 -= sixty4;
959 sixty4 = -sixty4;
960 ixheaacd_drc_offset -= 128;
961
962 if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280;
963 }
964
965 filter_coeff += 64;
966
967 if (filter_coeff == qmf_bank->p_filter + 640)
968 filter_coeff = (WORD16 *)qmf_bank->p_filter;
969
970 p1 += no_synthesis_channels;
971
972 if (active)
973 memcpy(qmf_real[i], qmf_real_tmp,
974 2 * no_synthesis_channels * sizeof(WORD32));
975 }
976 }
977
978 if (audio_object_type == AOT_ER_AAC_LD ||
979 audio_object_type == AOT_ER_AAC_ELD) {
980 qmf_bank->fp1_syn = fp1;
981 qmf_bank->fp2_syn = fp2;
982 qmf_bank->sixty4 = sixty4;
983 }
984
985 qmf_bank->filter_pos_syn = filter_coeff;
986 qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset;
987 }
988