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 #include "ixheaacd_sbr_common.h"
22 #include "ixheaacd_type_def.h"
23
24 #include "ixheaacd_constants.h"
25 #include "ixheaacd_basic_ops32.h"
26 #include "ixheaacd_basic_ops16.h"
27 #include "ixheaacd_basic_ops40.h"
28 #include "ixheaacd_basic_ops_arr.h"
29 #include "ixheaacd_basic_ops.h"
30
31 #include "ixheaacd_defines.h"
32 #include "ixheaacd_basic_op.h"
33 #include "ixheaacd_intrinsics.h"
34 #include "ixheaacd_common_rom.h"
35 #include "ixheaacd_basic_funcs.h"
36 #include "ixheaacd_bitbuffer.h"
37 #include "ixheaacd_sbrdecsettings.h"
38 #include "ixheaacd_defines.h"
39
40 #include "ixheaacd_pns.h"
41
42 #include "ixheaacd_aac_rom.h"
43 #include "ixheaacd_pulsedata.h"
44
45 #include "ixheaacd_drc_data_struct.h"
46 #include "ixheaacd_lt_predict.h"
47 #include "ixheaacd_cnst.h"
48 #include "ixheaacd_ec_defines.h"
49 #include "ixheaacd_ec_struct_def.h"
50 #include "ixheaacd_channelinfo.h"
51 #include "ixheaacd_drc_dec.h"
52
53 #include "ixheaacd_sbrdecoder.h"
54 #include "ixheaacd_sbr_scale.h"
55 #include "ixheaacd_lpp_tran.h"
56 #include "ixheaacd_env_extr_part.h"
57 #include "ixheaacd_sbr_rom.h"
58
59 #include "ixheaacd_hybrid.h"
60 #include "ixheaacd_ps_dec.h"
61
62 #include "ixheaacd_env_extr.h"
63
64 #include "ixheaacd_ps_dec.h"
65
66 #include "ixheaacd_qmf_dec.h"
67 #include "ixheaacd_env_calc.h"
68 #include "ixheaacd_sbr_const.h"
69
70 #include "ixheaacd_pvc_dec.h"
71 #include "ixheaacd_sbr_dec.h"
72 #include "ixheaacd_function_selector.h"
73
ixheaacd_shl16_saturate(WORD16 op1,WORD16 shift)74 static PLATFORM_INLINE WORD16 ixheaacd_shl16_saturate(WORD16 op1,
75 WORD16 shift) {
76 WORD16 var_out;
77 WORD32 temp;
78
79 temp = (WORD32)(op1 << shift);
80 var_out = ixheaacd_sat16(temp);
81 return (var_out);
82 }
83
ixheaacd_shl16_arr_saturate(WORD16 * word16_arr,WORD16 shift,WORD n)84 static PLATFORM_INLINE VOID ixheaacd_shl16_arr_saturate(WORD16 *word16_arr,
85 WORD16 shift, WORD n) {
86 WORD i;
87
88 for (i = n - 1; i >= 0; i--) {
89 *word16_arr = ixheaacd_shl16_saturate(*word16_arr, shift);
90 word16_arr++;
91 }
92
93 return;
94 }
95
ixheaacd_scale_short_vec_left(WORD16 * word16_arr,WORD32 n,WORD16 shift)96 VOID ixheaacd_scale_short_vec_left(WORD16 *word16_arr, WORD32 n, WORD16 shift) {
97 ixheaacd_shl16_arr_saturate(word16_arr, shift, n);
98 }
99
ixheaacd_scale_int_vec_left(WORD32 * word32_arr,WORD32 n,WORD16 shift)100 VOID ixheaacd_scale_int_vec_left(WORD32 *word32_arr, WORD32 n, WORD16 shift) {
101 ixheaacd_shl32_arr_sat(word32_arr, shift, n);
102 }
103
ixheaacd_scale_int_vec_right(WORD32 * word32_arr,WORD32 n,WORD16 shift)104 VOID ixheaacd_scale_int_vec_right(WORD32 *word32_arr, WORD32 n, WORD16 shift) {
105 ixheaacd_shr32_arr(word32_arr, shift, n);
106 }
107
ixheaacd_scale_short_vec_right(WORD16 * word16_arr,WORD32 n,WORD16 shift)108 VOID ixheaacd_scale_short_vec_right(WORD16 *word16_arr, WORD32 n,
109 WORD16 shift) {
110 ixheaacd_shr16_arr(word16_arr, shift, n);
111 }
112
ixheaacd_calc_max(WORD16 * array,WORD32 size)113 WORD32 ixheaacd_calc_max(WORD16 *array, WORD32 size) {
114 WORD n;
115 WORD32 max_val = 0;
116 WORD16 temp1, temp2;
117
118 for (n = size; n != 0; n--) {
119 temp1 = *array++;
120 temp2 = *array++;
121
122 max_val = max_val | ixheaacd_abs32_nrm(temp1);
123 max_val = max_val | ixheaacd_abs32_nrm(temp2);
124 }
125
126 return max_val;
127 }
128
ixheaacd_get_ps_scale(ia_ps_dec_struct * ptr_ps_dec)129 static WORD ixheaacd_get_ps_scale(ia_ps_dec_struct *ptr_ps_dec) {
130 WORD i, m, n, len;
131 WORD32 max_val = 0;
132 WORD16 *ptr_re;
133 WORD32 *ptr_re_temp, *ptr_im;
134
135 for (m = 0; m < 2; m++) {
136 ptr_re = &ptr_ps_dec->delay_buf_qmf_ap_re_im[m][2 * 3];
137 max_val |=
138 ixheaacd_calc_max(ptr_re, NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS);
139 }
140
141 ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_ld_re_im;
142
143 max_val |= ixheaacd_calc_max(ptr_re, HIGH_DEL * SMALL_DEL_STRT);
144
145 ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_sd_re_im;
146
147 max_val |= ixheaacd_calc_max(
148 ptr_re, (SMALL_DEL *
149 (NUM_OF_QUAD_MIRROR_FILTER_ICC_CHNLS -
150 (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT))));
151
152 ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_sub_re_im;
153
154 max_val |= ixheaacd_calc_max(ptr_re, 16 * DEL_ALL_PASS);
155
156 for (i = 0; i < NUM_SER_AP_LINKS; i++) {
157 for (m = 0; m < ptr_ps_dec->delay_sample_ser[i]; m++) {
158 ptr_re = &ptr_ps_dec->delay_buf_qmf_ser_re_im[m][i][2 * 3];
159
160 max_val |=
161 ixheaacd_calc_max(ptr_re, NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS);
162 }
163 }
164
165 ptr_re = (WORD16 *)ptr_ps_dec->delay_buf_qmf_sub_ser_re_im;
166 max_val |= ixheaacd_calc_max(ptr_re, NUM_SER_AP_LINKS * 5 * 16);
167
168 max_val = max_val << 16;
169
170 len = ptr_ps_dec->str_hybrid.ptr_qmf_buf;
171
172 for (i = 0; i < NO_QMF_CHANNELS_IN_HYBRID; i++) {
173 ptr_re_temp = &ptr_ps_dec->str_hybrid.ptr_qmf_buf_re[i][0];
174 ptr_im = &ptr_ps_dec->str_hybrid.ptr_qmf_buf_im[i][0];
175
176 for (n = len; n != 0; n--) {
177 WORD32 temp3 = *ptr_re_temp++;
178 WORD32 temp4 = *ptr_im++;
179
180 max_val = max_val | ixheaacd_abs32_nrm(temp3);
181 max_val = max_val | ixheaacd_abs32_nrm(temp4);
182 }
183 }
184
185 return ixheaacd_pnorm32(max_val);
186 }
187
ixheaacd_init_ps_scale(ia_ps_dec_struct * ptr_ps_dec,ia_sbr_scale_fact_struct * sbr_scale_factor)188 VOID ixheaacd_init_ps_scale(ia_ps_dec_struct *ptr_ps_dec,
189 ia_sbr_scale_fact_struct *sbr_scale_factor)
190
191 {
192 WORD32 reserve, change;
193 WORD16 temp;
194
195 reserve = ixheaacd_get_ps_scale(ptr_ps_dec);
196
197 ptr_ps_dec->delay_buffer_scale = (ptr_ps_dec->delay_buffer_scale + reserve);
198 temp =
199 ixheaacd_min16(sbr_scale_factor->lb_scale, sbr_scale_factor->ov_lb_scale);
200 temp = ixheaacd_min16(temp, sbr_scale_factor->hb_scale);
201 temp = ixheaacd_min16(temp, ptr_ps_dec->delay_buffer_scale);
202 sbr_scale_factor->ps_scale = (temp - 1);
203
204 change = (sbr_scale_factor->ps_scale - ptr_ps_dec->delay_buffer_scale);
205 change = (change + reserve);
206
207 ixheaacd_scale_ps_states(ptr_ps_dec, (WORD16)change);
208
209 ptr_ps_dec->delay_buffer_scale = sbr_scale_factor->ps_scale;
210 }
211
ixheaacd_divide16_pos_dec(WORD32 op1,WORD32 op2)212 WORD32 ixheaacd_divide16_pos_dec(WORD32 op1, WORD32 op2) {
213 UWORD32 v;
214 UWORD32 u;
215 WORD k, nrm;
216
217 nrm = ixheaacd_norm32(op2);
218 u = (op1 << nrm);
219 v = (op2 << nrm);
220 u = (u & 0xffff0000);
221 v = (v & 0xffff0000);
222
223 if (u != 0) {
224 for (k = 16; k > 0; k--) {
225 if (u >= (UWORD32)v) {
226 u = ((u - v) << 1) + 1;
227 } else {
228 u = (u << 1);
229 }
230 }
231 }
232
233 return (u);
234 }
235
ixheaacd_decorr_filter1_dec(ia_ps_dec_struct * ptr_ps_dec,ia_ps_tables_struct * ps_tables_ptr,WORD16 * transient_ratio)236 VOID ixheaacd_decorr_filter1_dec(ia_ps_dec_struct *ptr_ps_dec,
237 ia_ps_tables_struct *ps_tables_ptr,
238 WORD16 *transient_ratio) {
239 WORD sb;
240 WORD m;
241
242 WORD16 delay_buf_idx;
243 WORD16 *p_delay_buf_sub_re_im;
244 WORD16 *p_frac_delay_phase_fac_ser_re_im, *p_frac_delay_phase_fac_ser_re_im1;
245
246 const WORD16 *p_frac_delay_phase_fac_re_im;
247 REVERB_BUFFERS_CH_RI *p_delay_buf_ser_sub_re_im;
248
249 WORD32 *p_left_real;
250 WORD32 *p_left_imag;
251 WORD32 *p_right_real;
252 WORD32 *p_right_imag;
253
254 p_frac_delay_phase_fac_re_im =
255 &ps_tables_ptr->frac_delay_phase_fac_qmf_sub_re_im[0];
256 p_delay_buf_ser_sub_re_im = &ptr_ps_dec->delay_buf_qmf_sub_ser_re_im;
257 p_frac_delay_phase_fac_ser_re_im =
258 &ps_tables_ptr->frac_delay_phase_fac_qmf_sub_ser_re_im[0][0];
259
260 p_left_real = ptr_ps_dec->ptr_hyb_left_re;
261 p_left_imag = ptr_ps_dec->ptr_hyb_left_im;
262 p_right_real = ptr_ps_dec->ptr_hyb_right_re;
263 p_right_imag = ptr_ps_dec->ptr_hyb_right_im;
264
265 delay_buf_idx = ptr_ps_dec->delay_buf_idx;
266 p_delay_buf_sub_re_im =
267 &ptr_ps_dec->delay_buf_qmf_sub_re_im[delay_buf_idx][0];
268 for (sb = 0; sb < SUBQMF_GROUPS; sb++) {
269 WORD16 real_tmp, imag_tmp, real_tmp0, imag_tmp0, real_in, imag_in, bin;
270
271 real_tmp0 = p_delay_buf_sub_re_im[0];
272 imag_tmp0 = p_delay_buf_sub_re_im[1];
273
274 real_in = (WORD16)(
275 ixheaacd_sub32_sat(
276 ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[0]),
277 ixheaacd_mult16x16in32(imag_tmp0,
278 p_frac_delay_phase_fac_re_im[1])) >>
279 15);
280 imag_in = (WORD16)(
281 ixheaacd_add32_sat(
282 ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[1]),
283 ixheaacd_mult16x16in32(imag_tmp0,
284 p_frac_delay_phase_fac_re_im[0])) >>
285 15);
286 *p_delay_buf_sub_re_im++ = ixheaacd_round16(p_left_real[sb]);
287 *p_delay_buf_sub_re_im++ = ixheaacd_round16(p_left_imag[sb]);
288 p_frac_delay_phase_fac_re_im += 2;
289
290 p_frac_delay_phase_fac_ser_re_im1 = p_frac_delay_phase_fac_ser_re_im;
291 p_frac_delay_phase_fac_ser_re_im += 2;
292
293 for (m = 0; m < NUM_SER_AP_LINKS; m++) {
294 WORD16 decay;
295 WORD16 delay_buf_idx_ser;
296 delay_buf_idx_ser = ptr_ps_dec->delay_buf_idx_ser[m];
297 real_tmp0 = (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][2 * sb];
298 imag_tmp0 =
299 (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][2 * sb + 1];
300
301 real_tmp =
302 (WORD16)(ixheaacd_sub32_sat(
303 ixheaacd_mult16x16in32(
304 real_tmp0, p_frac_delay_phase_fac_ser_re_im1[0]),
305 ixheaacd_mult16x16in32(
306 imag_tmp0, p_frac_delay_phase_fac_ser_re_im1[1])) >>
307 15);
308 imag_tmp =
309 (WORD16)(ixheaacd_add32_sat(
310 ixheaacd_mult16x16in32(
311 real_tmp0, p_frac_delay_phase_fac_ser_re_im1[1]),
312 ixheaacd_mult16x16in32(
313 imag_tmp0, p_frac_delay_phase_fac_ser_re_im1[0])) >>
314 15);
315
316 decay = ps_tables_ptr->rev_link_decay_ser[m];
317
318 real_tmp = ixheaacd_sub16(real_tmp, ixheaacd_mult16_shl(real_in, decay));
319 imag_tmp = ixheaacd_sub16(imag_tmp, ixheaacd_mult16_shl(imag_in, decay));
320
321 (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][sb * 2] =
322 ixheaacd_add16(real_in, ixheaacd_mult16_shl(real_tmp, decay));
323 (*p_delay_buf_ser_sub_re_im)[delay_buf_idx_ser][m][sb * 2 + 1] =
324 ixheaacd_add16(imag_in, ixheaacd_mult16_shl(imag_tmp, decay));
325
326 real_in = real_tmp;
327 imag_in = imag_tmp;
328 p_frac_delay_phase_fac_ser_re_im1 += 32;
329 }
330
331 bin = ps_tables_ptr->hybrid_to_bin[sb];
332 p_right_real[sb] =
333 ixheaacd_mult16x16in32_shl(real_in, transient_ratio[bin]);
334 p_right_imag[sb] =
335 ixheaacd_mult16x16in32_shl(imag_in, transient_ratio[bin]);
336 }
337 }
338
ixheaacd_decorr_filter2_dec(ia_ps_dec_struct * ptr_ps_dec,WORD32 * p_buf_left_real,WORD32 * p_buf_left_imag,WORD32 * p_buf_right_real,WORD32 * p_buf_right_imag,ia_ps_tables_struct * ps_tables_ptr,WORD16 * transient_ratio)339 VOID ixheaacd_decorr_filter2_dec(
340 ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_buf_left_real,
341 WORD32 *p_buf_left_imag, WORD32 *p_buf_right_real, WORD32 *p_buf_right_imag,
342 ia_ps_tables_struct *ps_tables_ptr, WORD16 *transient_ratio) {
343 WORD sb, di, sb_delay;
344 WORD m, bin;
345 WORD32 *p_left_real;
346 WORD32 *p_left_imag;
347 WORD32 *p_right_real;
348 WORD32 *p_right_imag;
349 WORD16 delay_buf_idx;
350 REVERB_BUFFERS_RI *p_delay_buf_ser_re_im;
351 WORD16 *p_delay_buf_ap_re_im;
352 const WORD16 *p_frac_delay_phase_fac_re_im;
353 WORD16 *p_frac_delay_phase_fac_ser_ap_re_im,
354 *p_frac_delay_phase_fac_ser_ap_re_im_temp;
355
356 p_left_real = p_buf_left_real;
357 p_left_imag = p_buf_left_imag;
358 p_right_real = p_buf_right_real;
359 p_right_imag = p_buf_right_imag;
360
361 p_delay_buf_ser_re_im = &ptr_ps_dec->delay_buf_qmf_ser_re_im;
362 p_frac_delay_phase_fac_re_im = ps_tables_ptr->frac_delay_phase_fac_qmf_re_im;
363 p_frac_delay_phase_fac_ser_ap_re_im =
364 &ps_tables_ptr->frac_delay_phase_fac_qmf_ser_re_im[0][0];
365
366 delay_buf_idx = ptr_ps_dec->delay_buf_idx;
367
368 p_delay_buf_ap_re_im = &ptr_ps_dec->delay_buf_qmf_ap_re_im[delay_buf_idx][0];
369 p_frac_delay_phase_fac_re_im += 6;
370 p_frac_delay_phase_fac_ser_ap_re_im += 6;
371 p_delay_buf_ap_re_im += 6;
372
373 for (sb = 3, di = 9; sb < 23; sb++) {
374 WORD16 real_tmp, imag_tmp, real_tmp0, imag_tmp0, real_in, imag_in;
375
376 sb_delay = sb;
377
378 real_tmp0 = p_delay_buf_ap_re_im[0];
379 imag_tmp0 = p_delay_buf_ap_re_im[1];
380
381 real_in = (WORD16)(
382 ixheaacd_sub32_sat(
383 ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[0]),
384 ixheaacd_mult16x16in32(imag_tmp0,
385 p_frac_delay_phase_fac_re_im[1])) >>
386 15);
387 imag_in = (WORD16)(
388 ixheaacd_add32_sat(
389 ixheaacd_mult16x16in32(real_tmp0, p_frac_delay_phase_fac_re_im[1]),
390 ixheaacd_mult16x16in32(imag_tmp0,
391 p_frac_delay_phase_fac_re_im[0])) >>
392 15);
393
394 *p_delay_buf_ap_re_im++ = ixheaacd_round16(p_left_real[sb]);
395 *p_delay_buf_ap_re_im++ = ixheaacd_round16(p_left_imag[sb]);
396
397 p_frac_delay_phase_fac_re_im += 2;
398
399 p_frac_delay_phase_fac_ser_ap_re_im_temp =
400 p_frac_delay_phase_fac_ser_ap_re_im;
401 p_frac_delay_phase_fac_ser_ap_re_im += 2;
402
403 for (m = 0; m < NUM_SER_AP_LINKS; m++, di++) {
404 WORD16 decay;
405 WORD16 delay_buf_idx_ser;
406 delay_buf_idx_ser = ptr_ps_dec->delay_buf_idx_ser[m];
407
408 real_tmp0 = (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2];
409 imag_tmp0 =
410 (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2 + 1];
411
412 real_tmp = (WORD16)(
413 ixheaacd_sub32_sat(
414 ixheaacd_mult16x16in32(
415 real_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[0]),
416 ixheaacd_mult16x16in32(
417 imag_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[1])) >>
418 15);
419 imag_tmp = (WORD16)(
420 ixheaacd_add32_sat(
421 ixheaacd_mult16x16in32(
422 real_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[1]),
423 ixheaacd_mult16x16in32(
424 imag_tmp0, p_frac_delay_phase_fac_ser_ap_re_im_temp[0])) >>
425 15);
426
427 decay = ps_tables_ptr->decay_scale_factor[di];
428
429 real_tmp = ixheaacd_sub16(real_tmp, ixheaacd_mult16_shl(real_in, decay));
430 imag_tmp = ixheaacd_sub16(imag_tmp, ixheaacd_mult16_shl(imag_in, decay));
431
432 (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2] =
433 ixheaacd_add16(real_in, ixheaacd_mult16_shl(real_tmp, decay));
434 (*p_delay_buf_ser_re_im)[delay_buf_idx_ser][m][sb_delay * 2 + 1] =
435 ixheaacd_add16(imag_in, ixheaacd_mult16_shl(imag_tmp, decay));
436
437 real_in = real_tmp;
438 imag_in = imag_tmp;
439 p_frac_delay_phase_fac_ser_ap_re_im_temp += 64;
440 }
441
442 bin = ps_tables_ptr->delay_to_bin[sb_delay];
443 p_right_real[sb] =
444 ixheaacd_mult16x16in32_shl(real_in, transient_ratio[bin]);
445 p_right_imag[sb] =
446 ixheaacd_mult16x16in32_shl(imag_in, transient_ratio[bin]);
447 }
448 }
449
ixheaacd_decorrelation_dec(ia_ps_dec_struct * ptr_ps_dec,WORD32 * p_buf_left_real,WORD32 * p_buf_left_imag,WORD32 * p_buf_right_real,WORD32 * p_buf_right_imag,ia_ps_tables_struct * ps_tables_ptr)450 VOID ixheaacd_decorrelation_dec(ia_ps_dec_struct *ptr_ps_dec,
451 WORD32 *p_buf_left_real,
452 WORD32 *p_buf_left_imag,
453 WORD32 *p_buf_right_real,
454 WORD32 *p_buf_right_imag,
455 ia_ps_tables_struct *ps_tables_ptr) {
456 WORD sb;
457
458 WORD gr, bin, sband, maxsband;
459
460 WORD32 peak_diff, nrg;
461 WORD32 power_buf[NUM_OF_BINS];
462 WORD16 transient_ratio[NUM_OF_BINS + 1];
463
464 WORD32 *p_left_real;
465 WORD32 *p_left_imag;
466 WORD32 *p_right_real;
467 WORD32 *p_right_imag;
468
469 WORD16 *p_delay_buf_re_im_ld;
470 WORD16 *p_delay_buf_re_im_sd;
471
472 WORD usb = ptr_ps_dec->usb;
473 WORD16 delay_buf_idx;
474
475 p_left_real = ptr_ps_dec->ptr_hyb_left_re;
476 p_left_imag = ptr_ps_dec->ptr_hyb_left_im;
477 p_right_real = ptr_ps_dec->ptr_hyb_right_re;
478 p_right_imag = ptr_ps_dec->ptr_hyb_right_im;
479
480 {
481 WORD32 re0, im0, re1, im1;
482
483 re0 = (p_left_real[0]);
484 im0 = (p_left_imag[0]);
485 re1 = (p_left_real[5]);
486 im1 = (p_left_imag[5]);
487
488 power_buf[0] = ixheaacd_mult32x16in32(re0, (WORD16)(re0 >> 16));
489 power_buf[0] = ixheaacd_add32_sat(
490 power_buf[0], ixheaacd_mult32x16in32(im0, (WORD16)(im0 >> 16)));
491 power_buf[0] = ixheaacd_add32_sat(
492 power_buf[0], ixheaacd_mult32x16in32(re1, (WORD16)(re1 >> 16)));
493 power_buf[0] = ixheaacd_add32_sat(
494 power_buf[0], ixheaacd_mult32x16in32(im1, (WORD16)(im1 >> 16)));
495
496 re0 = (p_left_real[4]);
497 im0 = (p_left_imag[4]);
498 re1 = (p_left_real[1]);
499 im1 = (p_left_imag[1]);
500
501 power_buf[1] = ixheaacd_mult32x16in32(re0, (WORD16)(re0 >> 16));
502 power_buf[1] = ixheaacd_add32_sat(
503 power_buf[1], ixheaacd_mult32x16in32(im0, (WORD16)(im0 >> 16)));
504 power_buf[1] = ixheaacd_add32_sat(
505 power_buf[1], ixheaacd_mult32x16in32(re1, (WORD16)(re1 >> 16)));
506 power_buf[1] = ixheaacd_add32_sat(
507 power_buf[1], ixheaacd_mult32x16in32(im1, (WORD16)(im1 >> 16)));
508 }
509
510 bin = 4 - 2;
511 for (gr = 4; gr < SUBQMF_GROUPS; gr++) {
512 WORD32 re, im;
513 sb = ps_tables_ptr->borders_group[gr];
514 re = (p_left_real[sb]);
515 im = (p_left_imag[sb]);
516 power_buf[bin] = ixheaacd_mult32x16in32(re, (WORD16)(re >> 16));
517 power_buf[bin] = ixheaacd_add32_sat(
518 power_buf[bin], ixheaacd_mult32x16in32(im, (WORD16)(im >> 16)));
519 bin++;
520 }
521
522 p_left_real = p_buf_left_real;
523 p_left_imag = p_buf_left_imag;
524
525 bin = NO_QMF_CHANNELS_IN_HYBRID + 5;
526 for (sband = NO_QMF_CHANNELS_IN_HYBRID; sband < NO_QMF_CHANNELS_IN_HYBRID + 6;
527 sband++) {
528 WORD32 re = (p_left_real[sband]);
529 WORD32 im = (p_left_imag[sband]);
530 power_buf[bin] = ixheaacd_mult32x16in32(re, (WORD16)(re >> 16));
531 power_buf[bin] = ixheaacd_add32_sat(
532 power_buf[bin], ixheaacd_mult32x16in32(im, (WORD16)(im >> 16)));
533 bin++;
534 }
535
536 bin = 16 - 2;
537 for (gr = 16; gr < NO_IID_GROUPS; gr++) {
538 WORD32 accu = 0, tmp;
539 WORD32 re, im;
540
541 maxsband = ixheaacd_min32(usb, ps_tables_ptr->borders_group[gr + 1]);
542
543 for (sband = ps_tables_ptr->borders_group[gr]; sband < maxsband; sband++) {
544 re = (p_left_real[sband]);
545 im = (p_left_imag[sband]);
546
547 tmp = ixheaacd_mult32x16in32(re, (WORD16)(re >> 16));
548 tmp = ixheaacd_add32_sat(tmp,
549 ixheaacd_mult32x16in32(im, (WORD16)(im >> 16)));
550 tmp = (tmp >> ps_tables_ptr->group_shift[gr - (SUBQMF_GROUPS + 6)]);
551
552 accu = ixheaacd_add32_sat(accu, tmp);
553 }
554 power_buf[bin] = accu;
555 bin++;
556 }
557
558 p_left_real = ptr_ps_dec->ptr_hyb_left_re;
559 p_left_imag = ptr_ps_dec->ptr_hyb_left_im;
560
561 for (bin = 0; bin < NUM_OF_BINS; bin++) {
562 power_buf[bin] = ixheaacd_shl32(power_buf[bin], 1);
563
564 power_buf[bin] = ixheaacd_max32(0, power_buf[bin]);
565
566 ptr_ps_dec->peak_decay_diff[bin] = ixheaacd_mult32x16in32_shl(
567 ptr_ps_dec->peak_decay_diff[bin], PEAK_DECAYING_FACT);
568
569 ptr_ps_dec->peak_decay_diff[bin] =
570 ixheaacd_max32(ptr_ps_dec->peak_decay_diff[bin], power_buf[bin]);
571
572 peak_diff = ixheaacd_add32_sat(
573 ixheaacd_mult32x16in32_shl(ptr_ps_dec->peak_decay_diff_prev[bin],
574 0x6000),
575 ((ixheaacd_sub32_sat(ptr_ps_dec->peak_decay_diff[bin],
576 power_buf[bin]) >>
577 2)));
578
579 ptr_ps_dec->peak_decay_diff_prev[bin] = peak_diff;
580
581 nrg = ixheaacd_add32_sat(
582 ixheaacd_mult32x16in32_shl(ptr_ps_dec->energy_prev[bin], 0x6000),
583 (power_buf[bin] >> 2));
584 ptr_ps_dec->energy_prev[bin] = nrg;
585
586 peak_diff = ixheaacd_add32_sat(peak_diff, (peak_diff >> 1));
587
588 if (peak_diff <= nrg) {
589 transient_ratio[bin] = 0x7fff;
590 } else {
591 transient_ratio[bin] =
592 ixheaacd_extract16l((*ixheaacd_divide16_pos)(nrg, peak_diff));
593 }
594 }
595
596 (*ixheaacd_decorr_filter1)(ptr_ps_dec, ps_tables_ptr, transient_ratio);
597
598 transient_ratio[20] = 0;
599
600 (*ixheaacd_decorr_filter2)(ptr_ps_dec, p_buf_left_real, p_buf_left_imag,
601 p_buf_right_real, p_buf_right_imag, ps_tables_ptr,
602 transient_ratio);
603
604 {
605 WORD16 trans_ratio = transient_ratio[18];
606
607 p_left_real = p_buf_left_real;
608 p_left_imag = p_buf_left_imag;
609 p_right_real = p_buf_right_real;
610 p_right_imag = p_buf_right_imag;
611
612 maxsband = ixheaacd_min32((WORD16)usb, ps_tables_ptr->borders_group[21]);
613 delay_buf_idx = ptr_ps_dec->delay_buf_idx_long;
614 p_delay_buf_re_im_ld =
615 &ptr_ps_dec->delay_buf_qmf_ld_re_im[delay_buf_idx][0];
616
617 for (sband = ps_tables_ptr->borders_group[20]; sband < maxsband; sband++) {
618 WORD16 real_in, imag_in;
619
620 real_in = p_delay_buf_re_im_ld[0];
621 imag_in = p_delay_buf_re_im_ld[1];
622 *p_delay_buf_re_im_ld++ = ixheaacd_round16(p_left_real[sband]);
623 *p_delay_buf_re_im_ld++ = ixheaacd_round16(p_left_imag[sband]);
624
625 p_right_real[sband] = ixheaacd_mult16x16in32_shl(real_in, trans_ratio);
626 p_right_imag[sband] = ixheaacd_mult16x16in32_shl(imag_in, trans_ratio);
627 }
628
629 ptr_ps_dec->delay_buf_idx_long =
630 ixheaacd_add16(ptr_ps_dec->delay_buf_idx_long, 1);
631
632 if (ptr_ps_dec->delay_buf_idx_long >= 14) {
633 ptr_ps_dec->delay_buf_idx_long = 0;
634 }
635
636 p_delay_buf_re_im_sd = &ptr_ps_dec->delay_buf_qmf_sd_re_im[0][0];
637
638 trans_ratio = transient_ratio[19];
639 maxsband = ixheaacd_min32((WORD16)usb, ps_tables_ptr->borders_group[22]);
640 for (sband = ps_tables_ptr->borders_group[21]; sband < maxsband; sband++) {
641 WORD16 real_in, imag_in;
642
643 real_in = p_delay_buf_re_im_sd[0];
644 imag_in = p_delay_buf_re_im_sd[1];
645 *p_delay_buf_re_im_sd++ = ixheaacd_round16(p_left_real[sband]);
646 *p_delay_buf_re_im_sd++ = ixheaacd_round16(p_left_imag[sband]);
647
648 p_right_real[sband] = ixheaacd_mult16x16in32_shl(real_in, trans_ratio);
649 p_right_imag[sband] = ixheaacd_mult16x16in32_shl(imag_in, trans_ratio);
650 }
651 }
652
653 for (sband = usb; sband < NO_SYNTHESIS_CHANNELS; sband++) {
654 p_right_real[sband] = 0;
655 p_right_imag[sband] = 0;
656 }
657
658 ptr_ps_dec->delay_buf_idx = (WORD16)(ptr_ps_dec->delay_buf_idx + 1);
659 if (ptr_ps_dec->delay_buf_idx >= DEL_ALL_PASS) {
660 ptr_ps_dec->delay_buf_idx = 0;
661 }
662
663 {
664 WORD delay_m;
665
666 for (delay_m = 0; delay_m < NUM_SER_AP_LINKS; delay_m++) {
667 ptr_ps_dec->delay_buf_idx_ser[delay_m] =
668 (ptr_ps_dec->delay_buf_idx_ser[delay_m] + 1);
669 if (ptr_ps_dec->delay_buf_idx_ser[delay_m] >=
670 ptr_ps_dec->delay_sample_ser[delay_m]) {
671 ptr_ps_dec->delay_buf_idx_ser[delay_m] = 0;
672 }
673 }
674 }
675 }
676
ixheaacd_cos512(WORD phi_by_4,const WORD16 * cos_sin_lookup_tab)677 static WORD16 ixheaacd_cos512(WORD phi_by_4, const WORD16 *cos_sin_lookup_tab) {
678 WORD index;
679 index = ixheaacd_round16(ixheaacd_abs32_sat(phi_by_4));
680
681 index = (index & 0x3FF);
682
683 if (index < 512) {
684 return cos_sin_lookup_tab[512 - index];
685 } else {
686 return (WORD16)(-(cos_sin_lookup_tab[index - 512]));
687 }
688 }
689
ixheaacd_sin512(WORD phi_by_4,const WORD16 * cos_sin_lookup_tab)690 static WORD16 ixheaacd_sin512(WORD phi_by_4, const WORD16 *cos_sin_lookup_tab) {
691 WORD index;
692
693 index = ixheaacd_round16(phi_by_4);
694
695 if (index < 0) {
696 index = (-(index)&0x3FF);
697
698 if (index < 512) {
699 return (WORD16)(-cos_sin_lookup_tab[index]);
700 } else {
701 return (WORD16)(-cos_sin_lookup_tab[1024 - index]);
702 }
703 } else {
704 index = (index & 0x3FF);
705
706 if (index < 512) {
707 return cos_sin_lookup_tab[index];
708 } else {
709 return cos_sin_lookup_tab[1024 - index];
710 }
711 }
712 }
713
ixheaacd_init_rot_env(ia_ps_dec_struct * ptr_ps_dec,WORD16 env,WORD16 usb,ia_sbr_tables_struct * sbr_tables_ptr,const WORD16 * cos_sin_lookup_tab)714 VOID ixheaacd_init_rot_env(ia_ps_dec_struct *ptr_ps_dec, WORD16 env, WORD16 usb,
715 ia_sbr_tables_struct *sbr_tables_ptr,
716 const WORD16 *cos_sin_lookup_tab) {
717 WORD group, bin, num_iid_steps;
718 WORD16 c2, c1;
719 WORD32 alpha, beta;
720 WORD16 h11, h12, h21, h22;
721 WORD16 inv_env_len;
722 const WORD16 *p_scale_factors;
723 WORD16 *p_iid_idx;
724 WORD indexplusa, indexminusa;
725
726 const WORD32 rescale = (0x0517cc1b << 1);
727
728 if (env == 0) {
729 WORD usb_prev = ptr_ps_dec->usb;
730 WORD16 *ptr_tmp;
731 ptr_ps_dec->usb = usb;
732
733 if ((usb > usb_prev) && usb_prev) {
734 WORD i, j, delay, offset1;
735 WORD ixheaacd_drc_offset =
736 (usb < NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS
737 ? usb
738 : NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS);
739
740 if (ixheaacd_drc_offset > usb_prev) {
741 for (i = 0; i < NUM_SER_AP_LINKS; i++) {
742 for (j = 0; j < ptr_ps_dec->delay_sample_ser[i]; j++) {
743 ptr_tmp = &ptr_ps_dec->delay_buf_qmf_ser_re_im[j][i][usb_prev * 2];
744
745 memset(ptr_tmp, 0,
746 sizeof(WORD16) * (ixheaacd_drc_offset - usb_prev) * 2);
747 }
748 }
749 }
750
751 offset1 =
752 (usb < (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT)
753 ? usb
754 : (NUM_OF_QUAD_MIRROR_FILTER_ALL_PASS_CHNLS + SMALL_DEL_STRT));
755 delay = HIGH_DEL;
756
757 if ((offset1 >= ixheaacd_drc_offset) && (offset1 <= SMALL_DEL_STRT)) {
758 for (i = 0; i < delay; i++) {
759 ptr_tmp =
760 &ptr_ps_dec->delay_buf_qmf_ld_re_im[i][ixheaacd_drc_offset * 2];
761
762 memset(ptr_tmp, 0,
763 sizeof(WORD16) * 2 * (offset1 - ixheaacd_drc_offset));
764 }
765 }
766
767 delay = SMALL_DEL;
768
769 if ((usb >= offset1) && (usb <= 16)) {
770 for (i = 0; i < delay; i++) {
771 ptr_tmp = &ptr_ps_dec->delay_buf_qmf_sd_re_im[i][offset1 * 2];
772
773 memset(ptr_tmp, 0, sizeof(WORD16) * 2 * (usb - offset1));
774 }
775 }
776 }
777 }
778
779 if (ptr_ps_dec->iid_quant) {
780 num_iid_steps = NUM_IID_LEVELS_FINE;
781 p_scale_factors = sbr_tables_ptr->ps_tables_ptr->scale_factors_fine;
782 } else {
783 num_iid_steps = NUM_IID_LEVELS;
784 p_scale_factors = sbr_tables_ptr->ps_tables_ptr->scale_factors;
785 }
786
787 inv_env_len =
788 sbr_tables_ptr->env_calc_tables_ptr->sbr_inv_int_table[ixheaacd_abs16(
789 ixheaacd_sub16_sat(ptr_ps_dec->border_position[env + 1],
790 ptr_ps_dec->border_position[env]))];
791
792 p_iid_idx = &ptr_ps_dec->iid_par_table[env][0];
793
794 for (group = 0; group < NO_IID_GROUPS; group++) {
795 WORD16 bplusa, bminusa;
796 WORD num_iid_idx, num_icc_idx;
797
798 bin = sbr_tables_ptr->ps_tables_ptr->group_to_bin[group];
799
800 num_iid_idx = p_iid_idx[bin];
801 num_icc_idx = p_iid_idx[bin + 238];
802
803 c1 = p_scale_factors[(num_iid_steps + num_iid_idx)];
804 c2 = p_scale_factors[(num_iid_steps - num_iid_idx)];
805
806 beta = ixheaacd_mult32x16in32_shl(
807 ixheaacd_mult16x16in32_shl(
808 sbr_tables_ptr->ps_tables_ptr->alpha_values[num_icc_idx],
809 ixheaacd_sub16(c1, c2)),
810 PSC_SQRT05F);
811 alpha = ixheaacd_shr32_dir_sat_limit(
812 ixheaacd_deposit16h_in32(
813 sbr_tables_ptr->ps_tables_ptr->alpha_values[num_icc_idx]),
814 1);
815
816 bplusa = ixheaacd_round16(ixheaacd_add32_sat(beta, alpha));
817 bminusa = ixheaacd_round16(ixheaacd_sub32_sat(beta, alpha));
818
819 indexplusa = ixheaacd_mult32x16in32(rescale, bplusa);
820 indexminusa = ixheaacd_mult32x16in32(rescale, bminusa);
821
822 h11 = ixheaacd_mult16_shl(ixheaacd_cos512(indexplusa, cos_sin_lookup_tab),
823 c2);
824 h12 = ixheaacd_mult16_shl(ixheaacd_cos512(indexminusa, cos_sin_lookup_tab),
825 c1);
826 h21 = ixheaacd_mult16_shl(ixheaacd_sin512(indexplusa, cos_sin_lookup_tab),
827 c2);
828 h22 = ixheaacd_mult16_shl(ixheaacd_sin512(indexminusa, cos_sin_lookup_tab),
829 c1);
830
831 ptr_ps_dec->delta_h11_h12[2 * group + 0] = ixheaacd_mult16_shl(
832 inv_env_len,
833 ixheaacd_sub16(h11, ptr_ps_dec->h11_h12_vec[2 * group + 0]));
834 ptr_ps_dec->delta_h11_h12[2 * group + 1] = ixheaacd_mult16_shl(
835 inv_env_len,
836 ixheaacd_sub16(h12, ptr_ps_dec->h11_h12_vec[2 * group + 1]));
837 ptr_ps_dec->delta_h21_h22[2 * group + 0] = ixheaacd_mult16_shl(
838 inv_env_len,
839 ixheaacd_sub16(h21, ptr_ps_dec->h21_h22_vec[2 * group + 0]));
840 ptr_ps_dec->delta_h21_h22[2 * group + 1] = ixheaacd_mult16_shl(
841 inv_env_len,
842 ixheaacd_sub16(h22, ptr_ps_dec->h21_h22_vec[2 * group + 1]));
843
844 ptr_ps_dec->H11_H12[2 * group + 0] = ptr_ps_dec->h11_h12_vec[2 * group + 0];
845 ptr_ps_dec->H11_H12[2 * group + 1] = ptr_ps_dec->h11_h12_vec[2 * group + 1];
846 ptr_ps_dec->H21_H22[2 * group + 0] = ptr_ps_dec->h21_h22_vec[2 * group + 0];
847 ptr_ps_dec->H21_H22[2 * group + 1] = ptr_ps_dec->h21_h22_vec[2 * group + 1];
848
849 ptr_ps_dec->h11_h12_vec[2 * group + 0] = h11;
850 ptr_ps_dec->h11_h12_vec[2 * group + 1] = h12;
851 ptr_ps_dec->h21_h22_vec[2 * group + 0] = h21;
852 ptr_ps_dec->h21_h22_vec[2 * group + 1] = h22;
853 }
854 }
855
ixheaacd_apply_rot_dec(ia_ps_dec_struct * ptr_ps_dec,WORD32 * p_qmf_left_re,WORD32 * p_qmf_left_im,WORD32 * p_qmf_right_re,WORD32 * p_qmf_right_im,ia_sbr_tables_struct * sbr_tables_ptr,const WORD16 * ptr_res)856 VOID ixheaacd_apply_rot_dec(ia_ps_dec_struct *ptr_ps_dec, WORD32 *p_qmf_left_re,
857 WORD32 *p_qmf_left_im, WORD32 *p_qmf_right_re,
858 WORD32 *p_qmf_right_im,
859 ia_sbr_tables_struct *sbr_tables_ptr,
860 const WORD16 *ptr_res) {
861 WORD group, subband, max_subband, usb, k;
862 WORD32 *p_hyb_left_re, *p_hyb_left_re1;
863 WORD32 *p_hyb_left_im, *p_hyb_left_im1;
864 WORD32 *p_hyb_right_re, *p_hyb_right_re1;
865 WORD32 *p_hyb_right_im, *p_hyb_right_im1;
866 WORD32 temp_left_real, temp_left_imag;
867 WORD32 temp_right_real, temp_right_imag;
868 WORD16 hybrid_resol;
869 WORD32 tmp_real, tmp_img;
870 WORD32 tmp_real1, tmp_img1;
871 WORD16 H11_H12[128 * 2] = {0};
872
873 usb = ptr_ps_dec->usb;
874
875 p_hyb_left_re1 = ptr_ps_dec->ptr_hyb_left_re;
876 p_hyb_left_im1 = ptr_ps_dec->ptr_hyb_left_im;
877 p_hyb_right_re1 = ptr_ps_dec->ptr_hyb_right_re;
878 p_hyb_right_im1 = ptr_ps_dec->ptr_hyb_right_im;
879
880 for (group = 0; group < NO_IID_GROUPS; group++) {
881 ptr_ps_dec->H11_H12[2 * group + 0] =
882 ixheaacd_add16(ptr_ps_dec->H11_H12[2 * group + 0],
883 ptr_ps_dec->delta_h11_h12[2 * group + 0]);
884 ptr_ps_dec->H11_H12[2 * group + 1] =
885 ixheaacd_add16(ptr_ps_dec->H11_H12[2 * group + 1],
886 ptr_ps_dec->delta_h11_h12[2 * group + 1]);
887
888 ptr_ps_dec->H21_H22[2 * group + 0] =
889 ixheaacd_add16(ptr_ps_dec->H21_H22[2 * group + 0],
890 ptr_ps_dec->delta_h21_h22[2 * group + 0]);
891 ptr_ps_dec->H21_H22[2 * group + 1] =
892 ixheaacd_add16(ptr_ps_dec->H21_H22[2 * group + 1],
893 ptr_ps_dec->delta_h21_h22[2 * group + 1]);
894 }
895
896 for (subband = 0; subband < SUBQMF_GROUPS; subband++) {
897 temp_left_real = ixheaacd_add32_sat(
898 ixheaacd_mult32x16in32(p_hyb_left_re1[subband],
899 ptr_ps_dec->H11_H12[2 * subband + 0]),
900 ixheaacd_mult32x16in32(p_hyb_right_re1[subband],
901 ptr_ps_dec->H21_H22[2 * subband + 0]));
902 temp_left_imag = ixheaacd_add32_sat(
903 ixheaacd_mult32x16in32(p_hyb_left_im1[subband],
904 ptr_ps_dec->H11_H12[2 * subband + 0]),
905 ixheaacd_mult32x16in32(p_hyb_right_im1[subband],
906 ptr_ps_dec->H21_H22[2 * subband + 0]));
907 temp_right_real = ixheaacd_add32_sat(
908 ixheaacd_mult32x16in32(p_hyb_left_re1[subband],
909 ptr_ps_dec->H11_H12[2 * subband + 1]),
910 ixheaacd_mult32x16in32(p_hyb_right_re1[subband],
911 ptr_ps_dec->H21_H22[2 * subband + 1]));
912 temp_right_imag = ixheaacd_add32_sat(
913 ixheaacd_mult32x16in32(p_hyb_left_im1[subband],
914 ptr_ps_dec->H11_H12[2 * subband + 1]),
915 ixheaacd_mult32x16in32(p_hyb_right_im1[subband],
916 ptr_ps_dec->H21_H22[2 * subband + 1]));
917 p_hyb_left_re1[subband] = ixheaacd_shl32(temp_left_real, 2);
918 p_hyb_left_im1[subband] = ixheaacd_shl32(temp_left_imag, 2);
919 p_hyb_right_re1[subband] = ixheaacd_shl32(temp_right_real, 2);
920 p_hyb_right_im1[subband] = ixheaacd_shl32(temp_right_imag, 2);
921 }
922
923 p_hyb_left_re = p_qmf_left_re;
924 p_hyb_left_im = p_qmf_left_im;
925 p_hyb_right_re = p_qmf_right_re;
926 p_hyb_right_im = p_qmf_right_im;
927
928 {
929 WORD32 *h11_h12_src = (WORD32 *)ptr_ps_dec->H11_H12;
930 WORD32 *h21_h22_src = (WORD32 *)ptr_ps_dec->H21_H22;
931 WORD32 *h11_h12_dst = (WORD32 *)H11_H12;
932
933 for (group = SUBQMF_GROUPS; group < NO_IID_GROUPS; group++) {
934 max_subband = ixheaacd_min32(
935 usb, sbr_tables_ptr->ps_tables_ptr->borders_group[group + 1]);
936 for (subband = sbr_tables_ptr->ps_tables_ptr->borders_group[group];
937 subband < max_subband; subband++) {
938 h11_h12_dst[2 * subband] = h11_h12_src[group];
939 h11_h12_dst[2 * subband + 1] = h21_h22_src[group];
940 }
941 }
942 }
943
944 for (subband = 0; subband < NO_QMF_CHANNELS_IN_HYBRID; subband++) {
945 tmp_real = *p_hyb_left_re1++;
946 tmp_img = *p_hyb_left_im1++;
947 tmp_real1 = *p_hyb_right_re1++;
948 tmp_img1 = *p_hyb_right_im1++;
949
950 hybrid_resol = ixheaacd_min16(*ptr_res++, 6);
951
952 for (k = hybrid_resol - 2; k >= 0; k--) {
953 tmp_real = ixheaacd_add32_sat(tmp_real, *p_hyb_left_re1++);
954 tmp_img = ixheaacd_add32_sat(tmp_img, *p_hyb_left_im1++);
955 tmp_real1 = ixheaacd_add32_sat(tmp_real1, *p_hyb_right_re1++);
956 tmp_img1 = ixheaacd_add32_sat(tmp_img1, *p_hyb_right_im1++);
957 }
958
959 p_hyb_left_re[subband] = tmp_real;
960 p_hyb_left_im[subband] = tmp_img;
961 p_hyb_right_re[subband] = tmp_real1;
962 p_hyb_right_im[subband] = tmp_img1;
963 }
964
965 for (; subband < usb; subband++) {
966 temp_left_real =
967 ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_re[subband],
968 H11_H12[4 * subband + 0]),
969 ixheaacd_mult32x16in32(p_hyb_right_re[subband],
970 H11_H12[4 * subband + 2]));
971 temp_left_imag =
972 ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_im[subband],
973 H11_H12[4 * subband + 0]),
974 ixheaacd_mult32x16in32(p_hyb_right_im[subband],
975 H11_H12[4 * subband + 2]));
976 temp_right_real =
977 ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_re[subband],
978 H11_H12[4 * subband + 1]),
979 ixheaacd_mult32x16in32(p_hyb_right_re[subband],
980 H11_H12[4 * subband + 3]));
981 temp_right_imag =
982 ixheaacd_add32_sat(ixheaacd_mult32x16in32(p_hyb_left_im[subband],
983 H11_H12[4 * subband + 1]),
984 ixheaacd_mult32x16in32(p_hyb_right_im[subband],
985 H11_H12[4 * subband + 3]));
986 p_hyb_left_re[subband] = ixheaacd_shl32(temp_left_real, 2);
987 p_hyb_left_im[subband] = ixheaacd_shl32(temp_left_imag, 2);
988 p_hyb_right_re[subband] = ixheaacd_shl32(temp_right_real, 2);
989 p_hyb_right_im[subband] = ixheaacd_shl32(temp_right_imag, 2);
990 }
991 }
992