• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <math.h>
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_arr.h"
30 #include "ixheaacd_basic_ops.h"
31 
32 #include "ixheaacd_defines.h"
33 #include "ixheaacd_basic_op.h"
34 #include "ixheaacd_intrinsics.h"
35 #include "ixheaacd_common_rom.h"
36 #include "ixheaacd_basic_funcs.h"
37 #include "ixheaacd_bitbuffer.h"
38 #include "ixheaacd_sbrdecsettings.h"
39 #include "ixheaacd_defines.h"
40 
41 #include "ixheaacd_pns.h"
42 
43 #include "ixheaacd_aac_rom.h"
44 #include "ixheaacd_pulsedata.h"
45 
46 #include "ixheaacd_drc_data_struct.h"
47 #include "ixheaacd_lt_predict.h"
48 #include "ixheaacd_cnst.h"
49 #include "ixheaacd_ec_defines.h"
50 #include "ixheaacd_ec_struct_def.h"
51 #include "ixheaacd_channelinfo.h"
52 #include "ixheaacd_drc_dec.h"
53 
54 #include "ixheaacd_sbrdecoder.h"
55 #include "ixheaacd_sbr_scale.h"
56 #include "ixheaacd_lpp_tran.h"
57 #include "ixheaacd_env_extr_part.h"
58 #include "ixheaacd_sbr_rom.h"
59 
60 #include "ixheaacd_hybrid.h"
61 #include "ixheaacd_ps_dec.h"
62 
63 #include "ixheaacd_env_extr.h"
64 
65 #include "ixheaacd_ps_dec.h"
66 
67 #include "ixheaacd_qmf_dec.h"
68 #include "ixheaacd_env_calc.h"
69 #include "ixheaacd_sbr_const.h"
70 
71 #include "ixheaacd_pvc_dec.h"
72 #include "ixheaacd_sbr_dec.h"
73 #include "ixheaacd_function_selector.h"
74 
ixheaacd_k_chan_filt(const FLOAT32 * ptr_qmf_re,const FLOAT32 * ptr_qmf_im,FLOAT32 (* ptr_tmp_hyb_re)[MAX_NUM_QMF_CHANNELS],FLOAT32 (* ptr_tmp_hyb_im)[MAX_NUM_QMF_CHANNELS],WORD32 nSamples,WORD32 k,WORD32 bCplx,const FLOAT32 * p,FLOAT32 * cos_sin_mod_tbl)75 VOID ixheaacd_k_chan_filt(const FLOAT32 *ptr_qmf_re, const FLOAT32 *ptr_qmf_im,
76                           FLOAT32 (*ptr_tmp_hyb_re)[MAX_NUM_QMF_CHANNELS],
77                           FLOAT32 (*ptr_tmp_hyb_im)[MAX_NUM_QMF_CHANNELS], WORD32 nSamples,
78                           WORD32 k, WORD32 bCplx, const FLOAT32 *p,
79                           FLOAT32 *cos_sin_mod_tbl) {
80   WORD32 i, n, q;
81   FLOAT32 real, imag;
82   FLOAT32 cos_val, sin_val;
83   FLOAT32 *p_real_imag = cos_sin_mod_tbl;
84 
85   if (bCplx) {
86     for (i = 0; i < nSamples; i++) {
87       for (q = 0; q < k; q++) {
88         real = 0;
89         imag = 0;
90         for (n = 0; n < 13; n++) {
91           cos_val = *p_real_imag++;
92           sin_val = *p_real_imag++;
93           real += p[n] * (ptr_qmf_re[n + i] * cos_val - ptr_qmf_im[n + i] * sin_val);
94           imag += p[n] * (ptr_qmf_im[n + i] * cos_val + ptr_qmf_re[n + i] * sin_val);
95         }
96         ptr_tmp_hyb_re[i][q] = real;
97         ptr_tmp_hyb_im[i][q] = imag;
98       }
99       p_real_imag -= (13 * k * 2);
100     }
101   } else {
102     for (i = 0; i < nSamples; i++) {
103       for (q = 0; q < k; q++) {
104         real = 0;
105         imag = 0;
106         for (n = 0; n < 13; n++) {
107           cos_val = *p_real_imag++;
108           real += p[n] * (ptr_qmf_re[n + i] * cos_val);
109           imag += p[n] * (ptr_qmf_im[n + i] * cos_val);
110         }
111         ptr_tmp_hyb_re[i][q] = real;
112         ptr_tmp_hyb_im[i][q] = imag;
113       }
114       p_real_imag -= (13 * k);
115     }
116   }
117 }
118 
ixheaacd_hyb_anal(const FLOAT32 ** ptr_qmf_re,const FLOAT32 ** ptr_qmf_im,ia_ps_dec_struct * ptr_ps_dec,ia_ps_tables_struct * ptr_ps_tables,WORD32 use_34_st_bands)119 VOID ixheaacd_hyb_anal(const FLOAT32 **ptr_qmf_re, const FLOAT32 **ptr_qmf_im,
120                        ia_ps_dec_struct *ptr_ps_dec, ia_ps_tables_struct *ptr_ps_tables,
121                        WORD32 use_34_st_bands) {
122   WORD32 k, n, band;
123   WORD32 band_res;
124   WORD32 frame_size;
125   WORD32 ch_offset = 0;
126   FLOAT32(*ptr_tmp_hyb_re)[MAX_NUM_COLUMNS];
127   FLOAT32(*ptr_tmp_hyb_im)[MAX_NUM_COLUMNS];
128   ia_hybrid_flt_struct *ptr_hybrid;
129   if (!use_34_st_bands) {
130     ptr_tmp_hyb_re = ptr_ps_dec->hyb_left_re;
131     ptr_tmp_hyb_im = ptr_ps_dec->hyb_left_im;
132     ptr_hybrid = &ptr_ps_dec->str_flt_hybrid20;
133   } else {
134     ptr_tmp_hyb_re = NULL;
135     ptr_tmp_hyb_im = ptr_ps_dec->hyb_left_im;
136     ptr_hybrid = &ptr_ps_dec->str_flt_hybrid34;
137   }
138   frame_size = ptr_hybrid->frame_size;
139   for (band = 0; band < ptr_hybrid->num_qmf_bands; band++) {
140     band_res = ptr_hybrid->ptr_resol[band];
141 
142     memcpy(ptr_hybrid->ptr_work_re, ptr_hybrid->ptr_qmf_buf_re[band],
143            (HYBRID_FILTER_LENGTH - 1) * sizeof(ptr_hybrid->ptr_work_re[0]));
144     memcpy(ptr_hybrid->ptr_work_im, ptr_hybrid->ptr_qmf_buf_im[band],
145            (HYBRID_FILTER_LENGTH - 1) * sizeof(ptr_hybrid->ptr_work_im[0]));
146 
147     for (n = 0; n < frame_size; n++) {
148       ptr_hybrid->ptr_work_re[(HYBRID_FILTER_LENGTH - 1) + n] =
149           ptr_qmf_re[n + HYBRID_FILTER_DELAY][band];
150       ptr_hybrid->ptr_work_im[(HYBRID_FILTER_LENGTH - 1) + n] =
151           ptr_qmf_im[n + HYBRID_FILTER_DELAY][band];
152     }
153 
154     memcpy(ptr_hybrid->ptr_qmf_buf_re[band], ptr_hybrid->ptr_work_re + frame_size,
155            (HYBRID_FILTER_LENGTH - 1) * sizeof(ptr_hybrid->ptr_qmf_buf_re[band][0]));
156     memcpy(ptr_hybrid->ptr_qmf_buf_im[band], ptr_hybrid->ptr_work_im + frame_size,
157            (HYBRID_FILTER_LENGTH - 1) * sizeof(ptr_hybrid->ptr_qmf_buf_im[band][0]));
158 
159     if (ptr_tmp_hyb_re) {
160       switch (band_res) {
161         case NO_HYBRID_CHANNELS_2:
162           ixheaacd_k_chan_filt(
163               ptr_hybrid->ptr_work_re, ptr_hybrid->ptr_work_im, ptr_hybrid->ptr_temp_re,
164               ptr_hybrid->ptr_temp_im, frame_size, NO_HYBRID_CHANNELS_2, REAL,
165               ptr_ps_tables->p2_13_20,
166               &ptr_ps_tables->cos_mod_2channel[0][0]);
167           break;
168         case NO_HYBRID_CHANNELS_4:
169           ixheaacd_k_chan_filt(
170               ptr_hybrid->ptr_work_re, ptr_hybrid->ptr_work_im, ptr_hybrid->ptr_temp_re,
171               ptr_hybrid->ptr_temp_im, frame_size, NO_HYBRID_CHANNELS_4, CPLX,
172               ptr_ps_tables->p4_13_34,
173               &ptr_ps_tables->cos_sin_mod_4channel[0][0]);
174           break;
175         case NO_HYBRID_CHANNELS_8:
176           ixheaacd_k_chan_filt(
177               ptr_hybrid->ptr_work_re, ptr_hybrid->ptr_work_im, ptr_hybrid->ptr_temp_re,
178               ptr_hybrid->ptr_temp_im, frame_size, NO_HYBRID_CHANNELS_8, CPLX,
179               use_34_st_bands ? ptr_ps_tables->p8_13_34 : ptr_ps_tables->p8_13_20,
180               &ptr_ps_tables->cos_sin_mod_8channel[0][0]);
181           break;
182         case NO_HYBRID_CHANNELS_12:
183           ixheaacd_k_chan_filt(ptr_hybrid->ptr_work_re, ptr_hybrid->ptr_work_im,
184                                ptr_hybrid->ptr_temp_re, ptr_hybrid->ptr_temp_im, frame_size,
185                                NO_HYBRID_CHANNELS_12, CPLX, ptr_ps_tables->p12_13_34,
186                                &ptr_ps_tables->cos_sin_mod_12channel[0][0]);
187           break;
188         default:
189           break;
190       }
191 
192       for (n = 0; n < frame_size; n++) {
193         for (k = 0; k < (WORD32)band_res; k++) {
194           ptr_tmp_hyb_re[n][ch_offset + k] = ptr_hybrid->ptr_temp_re[n][k];
195           ptr_tmp_hyb_im[n][ch_offset + k] = ptr_hybrid->ptr_temp_im[n][k];
196         }
197       }
198       ch_offset += band_res;
199     }
200   }
201 }
202 
ixheaacd_hyb_synth(FLOAT32 (* ptr_tmp_hyb_re)[MAX_NUM_COLUMNS],FLOAT32 (* ptr_tmp_hyb_im)[MAX_NUM_COLUMNS],FLOAT32 ** ptr_qmf_re,FLOAT32 ** ptr_qmf_im,ia_hybrid_flt_struct * ptr_hybrid)203 VOID ixheaacd_hyb_synth(
204     FLOAT32 (*ptr_tmp_hyb_re)[MAX_NUM_COLUMNS],
205     FLOAT32 (*ptr_tmp_hyb_im)[MAX_NUM_COLUMNS],
206     FLOAT32 **ptr_qmf_re,
207     FLOAT32 **ptr_qmf_im,
208     ia_hybrid_flt_struct *ptr_hybrid) {
209   WORD32 k, n, band;
210   WORD16 band_res;
211   WORD32 frame_size = ptr_hybrid->frame_size;
212   WORD32 ch_offset = 0;
213 
214   for (band = 0; band < ptr_hybrid->num_qmf_bands; band++) {
215     band_res = ptr_hybrid->ptr_resol[band];
216 
217     for (n = 0; n < frame_size; n++) {
218       ptr_qmf_re[n][band] = ptr_qmf_im[n][band] = 0;
219 
220       for (k = 0; k < (WORD32)band_res; k++) {
221         ptr_qmf_re[n][band] += ptr_tmp_hyb_re[n][ch_offset + k];
222         ptr_qmf_im[n][band] += ptr_tmp_hyb_im[n][ch_offset + k];
223       }
224     }
225     ch_offset += band_res;
226   }
227 }
228 
ixheaacd_map_34_float_to_20(FLOAT32 * ptr_index)229 VOID ixheaacd_map_34_float_to_20(FLOAT32 *ptr_index) {
230   ptr_index[0] = (2 * ptr_index[0] + ptr_index[1]) / 3.0f;
231   ptr_index[1] = (ptr_index[1] + 2 * ptr_index[2]) / 3.0f;
232   ptr_index[2] = (2 * ptr_index[3] + ptr_index[4]) / 3.0f;
233   ptr_index[3] = (ptr_index[4] + 2 * ptr_index[5]) / 3.0f;
234   ptr_index[4] = (ptr_index[6] + ptr_index[7]) / 2.0f;
235   ptr_index[5] = (ptr_index[8] + ptr_index[9]) / 2.0f;
236   ptr_index[6] = ptr_index[10];
237   ptr_index[7] = ptr_index[11];
238   ptr_index[8] = (ptr_index[12] + ptr_index[13]) / 2.0f;
239   ptr_index[9] = (ptr_index[14] + ptr_index[15]) / 2.0f;
240   ptr_index[10] = ptr_index[16];
241   ptr_index[11] = ptr_index[17];
242   ptr_index[12] = ptr_index[18];
243   ptr_index[13] = ptr_index[19];
244   ptr_index[14] = (ptr_index[20] + ptr_index[21]) / 2.0f;
245   ptr_index[15] = (ptr_index[22] + ptr_index[23]) / 2.0f;
246   ptr_index[16] = (ptr_index[24] + ptr_index[25]) / 2.0f;
247   ptr_index[17] = (ptr_index[26] + ptr_index[27]) / 2.0f;
248   ptr_index[18] = (ptr_index[28] + ptr_index[29] + ptr_index[30] + ptr_index[31]) / 4.0f;
249   ptr_index[19] = (ptr_index[32] + ptr_index[33]) / 2.0f;
250 }
251 
ixheaacd_map_20_float_to_34(FLOAT32 * ptr_index)252 VOID ixheaacd_map_20_float_to_34(FLOAT32 *ptr_index) {
253   FLOAT32 arr_temp[NUM_HI_RES_BINS];
254   WORD32 i;
255 
256   arr_temp[0] = ptr_index[0];
257   arr_temp[1] = (ptr_index[0] + ptr_index[1]) / 2.0f;
258   arr_temp[2] = ptr_index[1];
259   arr_temp[3] = ptr_index[2];
260   arr_temp[4] = (ptr_index[2] + ptr_index[3]) / 2.0f;
261   arr_temp[5] = ptr_index[3];
262   arr_temp[6] = ptr_index[4];
263   arr_temp[7] = ptr_index[4];
264   arr_temp[8] = ptr_index[5];
265   arr_temp[9] = ptr_index[5];
266   arr_temp[10] = ptr_index[6];
267   arr_temp[11] = ptr_index[7];
268   arr_temp[12] = ptr_index[8];
269   arr_temp[13] = ptr_index[8];
270   arr_temp[14] = ptr_index[9];
271   arr_temp[15] = ptr_index[9];
272   arr_temp[16] = ptr_index[10];
273   arr_temp[17] = ptr_index[11];
274   arr_temp[18] = ptr_index[12];
275   arr_temp[19] = ptr_index[13];
276   arr_temp[20] = ptr_index[14];
277   arr_temp[21] = ptr_index[14];
278   arr_temp[22] = ptr_index[15];
279   arr_temp[23] = ptr_index[15];
280   arr_temp[24] = ptr_index[16];
281   arr_temp[25] = ptr_index[16];
282   arr_temp[26] = ptr_index[17];
283   arr_temp[27] = ptr_index[17];
284   arr_temp[28] = ptr_index[18];
285   arr_temp[29] = ptr_index[18];
286   arr_temp[30] = ptr_index[18];
287   arr_temp[31] = ptr_index[18];
288   arr_temp[32] = ptr_index[19];
289   arr_temp[33] = ptr_index[19];
290 
291   for (i = 0; i < 34; i++) {
292     ptr_index[i] = arr_temp[i];
293   }
294 }
295 
ixheaacd_create_ps_esbr_dec(ia_ps_dec_struct * ptr_ps_dec_struct,ia_ps_tables_struct * ptr_ps_tables,UWORD32 noQmfChans,UWORD32 num_sub_samples,WORD32 ps_mode)296 WORD32 ixheaacd_create_ps_esbr_dec(ia_ps_dec_struct *ptr_ps_dec_struct,
297                                    ia_ps_tables_struct *ptr_ps_tables, UWORD32 noQmfChans,
298                                    UWORD32 num_sub_samples, WORD32 ps_mode) {
299   UWORD32 i;
300   ia_ps_dec_struct *ptr_ps_dec = ptr_ps_dec_struct;
301 
302   ptr_ps_dec = ptr_ps_dec_struct;
303 
304   ptr_ps_dec->num_sub_samples = num_sub_samples;
305   ptr_ps_dec->num_chans = noQmfChans;
306   ptr_ps_dec->ps_mode = ps_mode;
307 
308   ptr_ps_dec->ps_data_present = 0;
309   ptr_ps_dec->enable_iid = 0;
310   ptr_ps_dec->iid_mode = 0;
311   ptr_ps_dec->enable_icc = 0;
312   ptr_ps_dec->icc_mode = 0;
313   ptr_ps_dec->enable_ext = 0;
314 
315   ptr_ps_dec->use_pca_rot_flg = 0;
316   ptr_ps_dec->freq_res_ipd = 0;
317   ptr_ps_dec->use_34_st_bands = 0;
318   ptr_ps_dec->use_34_st_bands_prev = 0;
319 
320   ptr_ps_dec->str_flt_hybrid20.frame_size = ptr_ps_dec->num_sub_samples;
321   ptr_ps_dec->str_flt_hybrid20.num_qmf_bands = NUM_QMF_BANDS_IN_HYBRID20;
322   ptr_ps_dec->str_flt_hybrid20.ptr_resol = (WORD16 *)&ptr_ps_tables->band_res_hyb20[0];
323   ptr_ps_dec->str_flt_hybrid20.ptr_work_re = &ptr_ps_dec->hyb_work_re_20[0];
324   ptr_ps_dec->str_flt_hybrid20.ptr_work_im = &ptr_ps_dec->hyb_work_im_20[0];
325   ptr_ps_dec->str_flt_hybrid20.ptr_qmf_buf_re = ptr_ps_dec->hyb_qmf_buf_re_20;
326   ptr_ps_dec->str_flt_hybrid20.ptr_qmf_buf_im = ptr_ps_dec->hyb_qmf_buf_im_20;
327   ptr_ps_dec->str_flt_hybrid20.ptr_temp_re = ptr_ps_dec->hyb_temp_re_20;
328   ptr_ps_dec->str_flt_hybrid20.ptr_temp_im = ptr_ps_dec->hyb_temp_im_20;
329 
330   ptr_ps_dec->str_flt_hybrid34.frame_size = ptr_ps_dec->num_sub_samples;
331   ptr_ps_dec->str_flt_hybrid34.num_qmf_bands = NUM_QMF_BANDS_IN_HYBRID34;
332   ptr_ps_dec->str_flt_hybrid34.ptr_resol = (WORD16 *)&ptr_ps_tables->band_res_hyb34[0];
333   ptr_ps_dec->str_flt_hybrid34.ptr_work_re = &ptr_ps_dec->hyb_work_re_34[0];
334   ptr_ps_dec->str_flt_hybrid34.ptr_work_im = &ptr_ps_dec->hyb_work_im_34[0];
335   ptr_ps_dec->str_flt_hybrid34.ptr_qmf_buf_re = ptr_ps_dec->hyb_qmf_buf_re_34;
336   ptr_ps_dec->str_flt_hybrid34.ptr_qmf_buf_im = ptr_ps_dec->hyb_qmf_buf_im_34;
337   ptr_ps_dec->str_flt_hybrid34.ptr_temp_re = ptr_ps_dec->hyb_temp_re_34;
338   ptr_ps_dec->str_flt_hybrid34.ptr_temp_im = ptr_ps_dec->hyb_temp_im_34;
339 
340   ptr_ps_dec->delay_buf_idx = 0;
341 
342   for (i = 0; i < NUM_OF_QUAD_MIRROR_FILTER_CHNLS; i++) {
343     ptr_ps_dec->delay_qmf_delay_buf_idx[i] = 0;
344     ptr_ps_dec->delay_qmf_delay_num_samp[i] = ptr_ps_tables->qmf_delay_idx_tbl[i];
345   }
346 
347   for (i = 0; i < NUM_HI_RES_BINS; i++) {
348     ptr_ps_dec->h11_re_prev[i] = 1.0f;
349     ptr_ps_dec->h12_re_prev[i] = 1.0f;
350   }
351 
352   memset(ptr_ps_dec->h11_im_prev, 0, sizeof(ptr_ps_dec->h11_im_prev));
353   memset(ptr_ps_dec->h12_im_prev, 0, sizeof(ptr_ps_dec->h12_im_prev));
354   memset(ptr_ps_dec->h21_re_prev, 0, sizeof(ptr_ps_dec->h21_re_prev));
355   memset(ptr_ps_dec->h22_re_prev, 0, sizeof(ptr_ps_dec->h22_re_prev));
356   memset(ptr_ps_dec->h21_im_prev, 0, sizeof(ptr_ps_dec->h21_im_prev));
357   memset(ptr_ps_dec->h22_im_prev, 0, sizeof(ptr_ps_dec->h22_im_prev));
358 
359   memset(ptr_ps_dec->ipd_idx_map_1, 0, sizeof(ptr_ps_dec->ipd_idx_map_1));
360   memset(ptr_ps_dec->opd_idx_map_1, 0, sizeof(ptr_ps_dec->opd_idx_map_1));
361   memset(ptr_ps_dec->ipd_idx_map_2, 0, sizeof(ptr_ps_dec->ipd_idx_map_2));
362   memset(ptr_ps_dec->opd_idx_map_2, 0, sizeof(ptr_ps_dec->opd_idx_map_2));
363 
364   for (i = 0; i < NUM_HI_RES_BINS; i++) {
365     ptr_ps_dec->peak_decay_fast_bin[i] = 0.0f;
366     ptr_ps_dec->prev_nrg_bin[i] = 0.0f;
367     ptr_ps_dec->prev_peak_diff_bin[i] = 0.0f;
368   }
369 
370   memset(ptr_ps_dec->qmf_delay_buf_re, 0, sizeof(ptr_ps_dec->qmf_delay_buf_re));
371   memset(ptr_ps_dec->qmf_delay_buf_im, 0, sizeof(ptr_ps_dec->qmf_delay_buf_im));
372   memset(ptr_ps_dec->sub_qmf_delay_buf_re, 0, sizeof(ptr_ps_dec->sub_qmf_delay_buf_re));
373   memset(ptr_ps_dec->sub_qmf_delay_buf_im, 0, sizeof(ptr_ps_dec->sub_qmf_delay_buf_im));
374 
375   for (i = 0; i < NUM_SER_AP_LINKS; i++) {
376     memset(&ptr_ps_dec->ser_qmf_delay_buf_re[i][0][0], 0,
377            sizeof(ptr_ps_dec->ser_qmf_delay_buf_re[i]));
378     memset(&ptr_ps_dec->ser_qmf_delay_buf_im[i][0][0], 0,
379            sizeof(ptr_ps_dec->ser_qmf_delay_buf_im[i]));
380     memset(&ptr_ps_dec->ser_sub_qmf_dealy_buf_re[i][0][0], 0,
381            sizeof(ptr_ps_dec->ser_sub_qmf_dealy_buf_re[i]));
382     memset(&ptr_ps_dec->ser_sub_qmf_dealy_buf_im[i][0][0], 0,
383            sizeof(ptr_ps_dec->ser_sub_qmf_dealy_buf_im[i]));
384   }
385 
386   return 0;
387 }
388 
ixheaacd_esbr_apply_ps(ia_ps_dec_struct * ptr_ps_dec,FLOAT32 ** pp_qmf_buf_re_left,FLOAT32 ** pp_qmf_buf_im_left,FLOAT32 ** pp_qmf_buf_re_right,FLOAT32 ** pp_qmf_buf_im_right,WORD32 usb,ia_ps_tables_struct * ptr_ps_tables,WORD32 num_time_slot)389 VOID ixheaacd_esbr_apply_ps(ia_ps_dec_struct *ptr_ps_dec,
390                             FLOAT32 **pp_qmf_buf_re_left,
391                             FLOAT32 **pp_qmf_buf_im_left,
392                             FLOAT32 **pp_qmf_buf_re_right,
393                             FLOAT32 **pp_qmf_buf_im_right,
394                             WORD32 usb, ia_ps_tables_struct *ptr_ps_tables,
395                             WORD32 num_time_slot) {
396   WORD32 sb;
397   WORD32 i, k;
398 
399   WORD32 max_num_column;
400 
401   if (num_time_slot == 15)
402     max_num_column = MAX_NUM_COLUMNS_960;
403   else
404     max_num_column = MAX_NUM_COLUMNS;
405 
406   if (ptr_ps_dec->use_34_st_bands) {
407     ptr_ps_dec->ptr_group_borders = (WORD32 *)&ptr_ps_tables->group_borders_34_tbl[0];
408     ptr_ps_dec->ptr_bins_group_map = (WORD32 *)&ptr_ps_tables->bin_group_map_34[0];
409     ptr_ps_dec->ptr_hybrid = &ptr_ps_dec->str_flt_hybrid34;
410     ptr_ps_dec->num_groups = NUM_IID_GROUPS_HI_RES;
411     ptr_ps_dec->num_sub_qmf_groups = SUBQMF_GROUPS_HI_RES;
412     ptr_ps_dec->num_bins = NUM_HI_RES_BINS;
413     ptr_ps_dec->first_delay_gr = SUBQMF_GROUPS_HI_RES;
414   } else {
415     ptr_ps_dec->ptr_group_borders = (WORD32 *)&ptr_ps_tables->group_borders_20_tbl[0];
416     ptr_ps_dec->ptr_bins_group_map = (WORD32 *)&ptr_ps_tables->bin_group_map_20[0];
417     ptr_ps_dec->ptr_hybrid = &ptr_ps_dec->str_flt_hybrid20;
418     ptr_ps_dec->num_groups = NUM_IID_GROUPS;
419     ptr_ps_dec->num_sub_qmf_groups = SUBQMF_GROUPS;
420     ptr_ps_dec->num_bins = NUM_MID_RES_BINS;
421     ptr_ps_dec->first_delay_gr = SUBQMF_GROUPS;
422   }
423 
424   for (sb = usb; sb < ptr_ps_dec->num_chans; sb++) {
425     for (i = 0; i < NUM_SER_AP_LINKS; i++) {
426       for (k = 0; k < ptr_ps_dec->delay_sample_ser[i]; k++) {
427         ptr_ps_dec->ser_qmf_delay_buf_re[i][k][sb] = 0;
428         ptr_ps_dec->ser_qmf_delay_buf_im[i][k][sb] = 0;
429       }
430     }
431     for (k = 0; k < HIGH_DEL; k++) {
432       ptr_ps_dec->qmf_delay_buf_re[k][sb] = 0;
433       ptr_ps_dec->qmf_delay_buf_im[k][sb] = 0;
434     }
435   }
436   ixheaacd_hyb_anal((const FLOAT32 **)pp_qmf_buf_re_left,
437                     (const FLOAT32 **)pp_qmf_buf_im_left,
438                     ptr_ps_dec, ptr_ps_tables, 0);
439   ixheaacd_hyb_anal((const FLOAT32 **)pp_qmf_buf_re_left,
440                     (const FLOAT32 **)pp_qmf_buf_im_left,
441                     ptr_ps_dec, ptr_ps_tables, 1);
442 
443   if (!ptr_ps_dec->use_34_st_bands) {
444     WORD32 k;
445     for (k = 0; k < (WORD32)ptr_ps_dec->num_sub_samples; k++) {
446       ptr_ps_dec->hyb_left_re[k][3] += ptr_ps_dec->hyb_left_re[k][4];
447       ptr_ps_dec->hyb_left_im[k][3] += ptr_ps_dec->hyb_left_im[k][4];
448       ptr_ps_dec->hyb_left_re[k][4] = 0.;
449       ptr_ps_dec->hyb_left_im[k][4] = 0.;
450 
451       ptr_ps_dec->hyb_left_re[k][2] += ptr_ps_dec->hyb_left_re[k][5];
452       ptr_ps_dec->hyb_left_im[k][2] += ptr_ps_dec->hyb_left_im[k][5];
453       ptr_ps_dec->hyb_left_re[k][5] = 0.;
454       ptr_ps_dec->hyb_left_im[k][5] = 0.;
455     }
456   }
457 
458   if (ptr_ps_dec->ps_mode & 0x0080) {
459     WORD32 i, j;
460     for (i = 0; i < max_num_column; i++) {
461       for (j = 0; j < NUM_OF_QUAD_MIRROR_FILTER_CHNLS; j++) {
462         pp_qmf_buf_im_right[i][j] = pp_qmf_buf_im_left[i][j];
463         pp_qmf_buf_re_right[i][j] = pp_qmf_buf_re_left[i][j];
464       }
465     }
466     for (i = 0; i < max_num_column; i++) {
467       for (j = 0; j < NUM_SUB_QMF_CHANNELS_HI_RES; j++) {
468         ptr_ps_dec->hyb_right_re[i][j] = ptr_ps_dec->hyb_left_re[i][j];
469         ptr_ps_dec->hyb_right_im[i][j] = ptr_ps_dec->hyb_left_im[i][j];
470       }
471     }
472   } else {
473     if (ptr_ps_dec->ps_mode & 0x0002) {
474       WORD32 i, j;
475       for (i = 0; i < max_num_column; i++) {
476         for (j = 0; j < NUM_OF_QUAD_MIRROR_FILTER_CHNLS; j++) {
477           pp_qmf_buf_im_right[i][j] = 0.;
478           pp_qmf_buf_re_right[i][j] = 0.;
479         }
480       }
481       for (i = 0; i < max_num_column; i++) {
482         for (j = 0; j < NUM_SUB_QMF_CHANNELS_HI_RES; j++) {
483           ptr_ps_dec->hyb_right_re[i][j] = 0.;
484           ptr_ps_dec->hyb_right_im[i][j] = 0.;
485         }
486       }
487     } else {
488       ixheaacd_esbr_ps_de_correlate(ptr_ps_dec, pp_qmf_buf_re_left, pp_qmf_buf_im_left,
489                                     pp_qmf_buf_re_right, pp_qmf_buf_im_right,
490                                     ptr_ps_tables);
491     }
492 
493     if (!(ptr_ps_dec->ps_mode & 0x0040)) {
494       ixheaacd_esbr_ps_apply_rotation(ptr_ps_dec, pp_qmf_buf_re_left, pp_qmf_buf_im_left,
495                                       pp_qmf_buf_re_right, pp_qmf_buf_im_right,
496                                       ptr_ps_tables);
497     }
498   }
499 
500   ixheaacd_hyb_synth(ptr_ps_dec->hyb_left_re, ptr_ps_dec->hyb_left_im,
501                      pp_qmf_buf_re_left, pp_qmf_buf_im_left, ptr_ps_dec->ptr_hybrid);
502 
503   ixheaacd_hyb_synth(ptr_ps_dec->hyb_right_re, ptr_ps_dec->hyb_right_im,
504                      pp_qmf_buf_re_right, pp_qmf_buf_im_right, ptr_ps_dec->ptr_hybrid);
505 
506   ptr_ps_dec->use_34_st_bands_prev = ptr_ps_dec->use_34_st_bands;
507 
508 }
509 
ixheaacd_esbr_ps_de_correlate(ia_ps_dec_struct * ptr_ps_dec,FLOAT32 ** pp_qmf_buf_re_left,FLOAT32 ** pp_qmf_buf_im_left,FLOAT32 ** pp_qmf_buf_re_right,FLOAT32 ** pp_qmf_buf_im_right,ia_ps_tables_struct * ptr_ps_tables)510 VOID ixheaacd_esbr_ps_de_correlate(
511     ia_ps_dec_struct *ptr_ps_dec,
512     FLOAT32 **pp_qmf_buf_re_left,
513     FLOAT32 **pp_qmf_buf_im_left,
514     FLOAT32 **pp_qmf_buf_re_right,
515     FLOAT32 **pp_qmf_buf_im_right,
516     ia_ps_tables_struct *ptr_ps_tables) {
517   WORD32 sb, maxsb, gr, k;
518   WORD32 m;
519   WORD32 l_delay = 0;
520   WORD32 l_ser_delay_arr[NUM_SER_AP_LINKS] = {0};
521   FLOAT32 re_left;
522   FLOAT32 im_left;
523   FLOAT32 peak_diff, nrg, trans_ratio;
524 
525   FLOAT32(*pp_hyb_left_re)[MAX_NUM_COLUMNS];
526   FLOAT32(*pp_hyb_left_im)[MAX_NUM_COLUMNS];
527   FLOAT32(*pp_hyb_right_re)[MAX_NUM_COLUMNS];
528   FLOAT32(*pp_hyb_right_im)[MAX_NUM_COLUMNS];
529 
530   FLOAT32(*ppp_ser_sub_qmf_dealy_buf_re)[5][NUM_OF_QUAD_MIRROR_FILTER_CHNLS];
531   FLOAT32(*ppp_ser_sub_qmf_dealy_buf_im)[5][NUM_OF_QUAD_MIRROR_FILTER_CHNLS];
532   FLOAT32(*pp_sub_qmf_delay_buf_re)[NUM_OF_QUAD_MIRROR_FILTER_CHNLS];
533   FLOAT32(*pp_sub_qmf_delay_buf_im)[NUM_OF_QUAD_MIRROR_FILTER_CHNLS];
534 
535   FLOAT32 *pp_frac_delay_phase_fac_re;
536   FLOAT32 *pp_frac_delay_phase_fac_im;
537   FLOAT32(*pp_frac_delay_phase_fac_ser_re)[NUM_SER_AP_LINKS];
538   FLOAT32(*pp_frac_delay_phase_fac_ser_im)[NUM_SER_AP_LINKS];
539 
540   WORD32 *p_delay_qmf_delay_num_samp = NULL;
541   WORD32 *p_delay_qmf_delay_buf_idx = NULL;
542 
543   FLOAT32 pow_arr[32][NUM_HI_RES_BINS];
544   FLOAT32 trans_ratio_arr[32][NUM_HI_RES_BINS];
545   WORD32 bin;
546   FLOAT32 decay_cutoff;
547 
548   pp_hyb_left_re = ptr_ps_dec->hyb_left_re;
549   pp_hyb_left_im = ptr_ps_dec->hyb_left_im;
550   pp_hyb_right_re = ptr_ps_dec->hyb_right_re;
551   pp_hyb_right_im = ptr_ps_dec->hyb_right_im;
552 
553   ppp_ser_sub_qmf_dealy_buf_re = ptr_ps_dec->ser_sub_qmf_dealy_buf_re;
554   ppp_ser_sub_qmf_dealy_buf_im = ptr_ps_dec->ser_sub_qmf_dealy_buf_im;
555 
556   pp_sub_qmf_delay_buf_re = ptr_ps_dec->sub_qmf_delay_buf_re;
557   pp_sub_qmf_delay_buf_im = ptr_ps_dec->sub_qmf_delay_buf_im;
558 
559   if (ptr_ps_dec->use_34_st_bands != ptr_ps_dec->use_34_st_bands_prev) {
560     if (ptr_ps_dec->use_34_st_bands) {
561       WORD32 i;
562       for (i = 0; i < NUM_SER_AP_LINKS; i++) {
563         memset(&ptr_ps_dec->ser_qmf_delay_buf_re[i][0][0], 0,
564                sizeof(ptr_ps_dec->ser_qmf_delay_buf_re[i]));
565         memset(&ptr_ps_dec->ser_qmf_delay_buf_im[i][0][0], 0,
566                sizeof(ptr_ps_dec->ser_qmf_delay_buf_im[i]));
567         memset(&ptr_ps_dec->ser_sub_qmf_dealy_buf_re[i][0][0], 0,
568                sizeof(ptr_ps_dec->ser_sub_qmf_dealy_buf_re[i]));
569         memset(&ptr_ps_dec->ser_sub_qmf_dealy_buf_im[i][0][0], 0,
570                sizeof(ptr_ps_dec->ser_sub_qmf_dealy_buf_im[i]));
571       }
572       return;
573     } else {
574       WORD32 i;
575       for (i = 0; i < NUM_SER_AP_LINKS; i++) {
576         memset(&ptr_ps_dec->ser_qmf_delay_buf_re[i][0][0], 0,
577                sizeof(ptr_ps_dec->ser_qmf_delay_buf_re[i]));
578         memset(&ptr_ps_dec->ser_qmf_delay_buf_im[i][0][0], 0,
579                sizeof(ptr_ps_dec->ser_qmf_delay_buf_im[i]));
580         memset(&ptr_ps_dec->ser_sub_qmf_dealy_buf_re[i][0][0], 0,
581                sizeof(ptr_ps_dec->ser_sub_qmf_dealy_buf_re[i]));
582         memset(&ptr_ps_dec->ser_sub_qmf_dealy_buf_im[i][0][0], 0,
583                sizeof(ptr_ps_dec->ser_sub_qmf_dealy_buf_im[i]));
584       }
585 
586       return;
587     }
588   }
589 
590   if (ptr_ps_dec->use_34_st_bands) {
591     pp_frac_delay_phase_fac_re = ptr_ps_tables->frac_delay_phase_fac_qmf_sub_re_34;
592     pp_frac_delay_phase_fac_im = ptr_ps_tables->frac_delay_phase_fac_qmf_sub_im_34;
593     pp_frac_delay_phase_fac_ser_re = ptr_ps_tables->frac_delay_phase_fac_ser_qmf_sub_re_34;
594     pp_frac_delay_phase_fac_ser_im = ptr_ps_tables->frac_delay_phase_fac_ser_qmf_sub_im_34;
595   } else {
596     pp_frac_delay_phase_fac_re = ptr_ps_tables->frac_delay_phase_fac_qmf_sub_re_20;
597     pp_frac_delay_phase_fac_im = ptr_ps_tables->frac_delay_phase_fac_qmf_sub_im_20;
598     pp_frac_delay_phase_fac_ser_re = ptr_ps_tables->frac_delay_phase_fac_ser_qmf_sub_re_20;
599     pp_frac_delay_phase_fac_ser_im = ptr_ps_tables->frac_delay_phase_fac_ser_qmf_sub_im_20;
600   }
601 
602   for (k = 0; k < 32; k++) {
603     for (bin = 0; bin < NUM_HI_RES_BINS; bin++) {
604       pow_arr[k][bin] = 0;
605     }
606   }
607 
608   for (gr = 0; gr < ptr_ps_dec->num_sub_qmf_groups; gr++) {
609     bin = (~NEGATE_IPD_MASK) & ptr_ps_dec->ptr_bins_group_map[gr];
610     maxsb = ptr_ps_dec->ptr_group_borders[gr] + 1;
611     for (sb = ptr_ps_dec->ptr_group_borders[gr]; sb < maxsb; sb++) {
612       for (k = ptr_ps_dec->border_position[0];
613            k < ptr_ps_dec->border_position[ptr_ps_dec->num_env]; k++) {
614         im_left = pp_hyb_left_re[k][sb];
615         re_left = pp_hyb_left_im[k][sb];
616         pow_arr[k][bin] += im_left * im_left + re_left * re_left;
617       }
618     }
619   }
620   for (; gr < ptr_ps_dec->num_groups; gr++) {
621     bin = (~NEGATE_IPD_MASK) & ptr_ps_dec->ptr_bins_group_map[gr];
622     maxsb = ptr_ps_dec->ptr_group_borders[gr + 1];
623     for (sb = ptr_ps_dec->ptr_group_borders[gr]; sb < maxsb; sb++) {
624       for (k = ptr_ps_dec->border_position[0];
625            k < ptr_ps_dec->border_position[ptr_ps_dec->num_env]; k++) {
626         im_left = pp_qmf_buf_re_left[k][sb];
627         re_left = pp_qmf_buf_im_left[k][sb];
628         pow_arr[k][bin] += im_left * im_left + re_left * re_left;
629       }
630     }
631   }
632 
633   for (bin = 0; bin < ptr_ps_dec->num_bins; bin++) {
634     for (k = ptr_ps_dec->border_position[0];
635          k < ptr_ps_dec->border_position[ptr_ps_dec->num_env]; k++) {
636       FLOAT32 q = 1.5f;
637 
638       ptr_ps_dec->peak_decay_fast_bin[bin] *= PEAK_DECAY_FACTOR_FAST;
639       if (ptr_ps_dec->peak_decay_fast_bin[bin] < pow_arr[k][bin])
640         ptr_ps_dec->peak_decay_fast_bin[bin] = pow_arr[k][bin];
641 
642       peak_diff = ptr_ps_dec->prev_peak_diff_bin[bin];
643       peak_diff += INIT_FILT_COEFF * (ptr_ps_dec->peak_decay_fast_bin[bin] -
644                                       pow_arr[k][bin] -
645                                       ptr_ps_dec->prev_peak_diff_bin[bin]);
646       ptr_ps_dec->prev_peak_diff_bin[bin] = peak_diff;
647 
648       nrg = ptr_ps_dec->prev_nrg_bin[bin];
649       nrg += INIT_FILT_COEFF * (pow_arr[k][bin] - ptr_ps_dec->prev_nrg_bin[bin]);
650       ptr_ps_dec->prev_nrg_bin[bin] = nrg;
651       if (q * peak_diff <= nrg) {
652         trans_ratio_arr[k][bin] = 1.0f;
653       } else {
654         trans_ratio_arr[k][bin] = nrg / (q * peak_diff);
655       }
656     }
657   }
658 
659   if (ptr_ps_dec->use_34_st_bands) {
660     decay_cutoff = DECAY_CUTOFF_HI_RES;
661   } else {
662     decay_cutoff = DECAY_CUTOFF;
663   }
664 
665   for (gr = 0; gr < ptr_ps_dec->num_sub_qmf_groups; gr++) {
666     maxsb = ptr_ps_dec->ptr_group_borders[gr] + 1;
667 
668     for (sb = ptr_ps_dec->ptr_group_borders[gr]; sb < maxsb; sb++) {
669       FLOAT32 decay_scale_factor;
670 
671       decay_scale_factor = 1.0f;
672 
673       decay_scale_factor = max(decay_scale_factor, 0.0f);
674 
675       l_delay = ptr_ps_dec->delay_buf_idx;
676       for (k = 0; k < NUM_SER_AP_LINKS; k++)
677         l_ser_delay_arr[k] = ptr_ps_dec->delay_buf_idx_ser[k];
678 
679       for (k = ptr_ps_dec->border_position[0];
680            k < ptr_ps_dec->border_position[ptr_ps_dec->num_env]; k++) {
681         FLOAT32 real, imag, real0, imag0, r_r0, i_r0;
682 
683         im_left = pp_hyb_left_re[k][sb];
684         re_left = pp_hyb_left_im[k][sb];
685 
686         {
687           real0 = pp_sub_qmf_delay_buf_re[l_delay][sb];
688           imag0 = pp_sub_qmf_delay_buf_im[l_delay][sb];
689           pp_sub_qmf_delay_buf_re[l_delay][sb] = im_left;
690           pp_sub_qmf_delay_buf_im[l_delay][sb] = re_left;
691 
692           real = real0 * pp_frac_delay_phase_fac_re[sb] - imag0 *
693                  pp_frac_delay_phase_fac_im[sb];
694           imag = real0 * pp_frac_delay_phase_fac_im[sb] + imag0 *
695                  pp_frac_delay_phase_fac_re[sb];
696 
697           r_r0 = real;
698           i_r0 = imag;
699           for (m = 0; m < NUM_SER_AP_LINKS; m++) {
700             real0 = ppp_ser_sub_qmf_dealy_buf_re[m][l_ser_delay_arr[m]][sb];
701             imag0 = ppp_ser_sub_qmf_dealy_buf_im[m][l_ser_delay_arr[m]][sb];
702             real = real0 * pp_frac_delay_phase_fac_ser_re[sb][m] -
703                    imag0 * pp_frac_delay_phase_fac_ser_im[sb][m];
704             imag = real0 * pp_frac_delay_phase_fac_ser_im[sb][m] +
705                    imag0 * pp_frac_delay_phase_fac_ser_re[sb][m];
706 
707             real += -decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * r_r0;
708             imag += -decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * i_r0;
709             ppp_ser_sub_qmf_dealy_buf_re[m][l_ser_delay_arr[m]][sb] =
710                 r_r0 + decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * real;
711             ppp_ser_sub_qmf_dealy_buf_im[m][l_ser_delay_arr[m]][sb] =
712                 i_r0 + decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * imag;
713             r_r0 = real;
714             i_r0 = imag;
715           }
716         }
717 
718         bin = (~NEGATE_IPD_MASK) & ptr_ps_dec->ptr_bins_group_map[gr];
719         trans_ratio = trans_ratio_arr[k][bin];
720 
721         pp_hyb_right_re[k][sb] = trans_ratio * r_r0;
722         pp_hyb_right_im[k][sb] = trans_ratio * i_r0;
723 
724         if (++l_delay >= DEL_ALL_PASS) l_delay = 0;
725 
726         for (m = 0; m < NUM_SER_AP_LINKS; m++) {
727           if (++l_ser_delay_arr[m] >= ptr_ps_dec->delay_sample_ser[m]) {
728             l_ser_delay_arr[m] = 0;
729           }
730         }
731       }
732     }
733   }
734   {
735     ppp_ser_sub_qmf_dealy_buf_re = ptr_ps_dec->ser_qmf_delay_buf_re;
736     ppp_ser_sub_qmf_dealy_buf_im = ptr_ps_dec->ser_qmf_delay_buf_im;
737 
738     pp_sub_qmf_delay_buf_re = ptr_ps_dec->qmf_delay_buf_re;
739     pp_sub_qmf_delay_buf_im = ptr_ps_dec->qmf_delay_buf_im;
740 
741     pp_frac_delay_phase_fac_re = ptr_ps_tables->qmf_fract_delay_phase_factor_re;
742     pp_frac_delay_phase_fac_im = ptr_ps_tables->qmf_fract_delay_phase_factor_im;
743 
744     pp_frac_delay_phase_fac_ser_re = ptr_ps_tables->qmf_ser_fract_delay_phase_factor_re;
745     pp_frac_delay_phase_fac_ser_im = ptr_ps_tables->qmf_ser_fract_delay_phase_factor_im;
746 
747     p_delay_qmf_delay_buf_idx = ptr_ps_dec->delay_qmf_delay_buf_idx;
748     p_delay_qmf_delay_num_samp = ptr_ps_dec->delay_qmf_delay_num_samp;
749   }
750   for (; gr < ptr_ps_dec->num_groups; gr++) {
751     maxsb = ptr_ps_dec->ptr_group_borders[gr + 1];
752 
753     for (sb = ptr_ps_dec->ptr_group_borders[gr]; sb < maxsb; sb++) {
754       FLOAT32 decay_scale_factor;
755       if (sb <= decay_cutoff)
756         decay_scale_factor = 1.0f;
757       else
758         decay_scale_factor = 1.0f + decay_cutoff * DECAY_SLOPE - DECAY_SLOPE * sb;
759 
760       decay_scale_factor = max(decay_scale_factor, 0.0f);
761 
762       l_delay = ptr_ps_dec->delay_buf_idx;
763       for (k = 0; k < NUM_SER_AP_LINKS; k++)
764         l_ser_delay_arr[k] = ptr_ps_dec->delay_buf_idx_ser[k];
765 
766       for (k = ptr_ps_dec->border_position[0];
767            k < ptr_ps_dec->border_position[ptr_ps_dec->num_env]; k++) {
768         FLOAT32 real, imag, real0, imag0, r_r0, i_r0;
769 
770         im_left = pp_qmf_buf_re_left[k][sb];
771         re_left = pp_qmf_buf_im_left[k][sb];
772 
773         if (gr >= ptr_ps_dec->first_delay_gr && sb >= NUM_OF_ALL_PASS_CHNLS) {
774           real = pp_sub_qmf_delay_buf_re[p_delay_qmf_delay_buf_idx[sb]][sb];
775           imag = pp_sub_qmf_delay_buf_im[p_delay_qmf_delay_buf_idx[sb]][sb];
776           r_r0 = real;
777           i_r0 = imag;
778           pp_sub_qmf_delay_buf_re[p_delay_qmf_delay_buf_idx[sb]][sb] = im_left;
779           pp_sub_qmf_delay_buf_im[p_delay_qmf_delay_buf_idx[sb]][sb] = re_left;
780         } else {
781           real0 = pp_sub_qmf_delay_buf_re[l_delay][sb];
782           imag0 = pp_sub_qmf_delay_buf_im[l_delay][sb];
783           pp_sub_qmf_delay_buf_re[l_delay][sb] = im_left;
784           pp_sub_qmf_delay_buf_im[l_delay][sb] = re_left;
785 
786           real = real0 * pp_frac_delay_phase_fac_re[sb] - imag0 *
787                  pp_frac_delay_phase_fac_im[sb];
788           imag = real0 * pp_frac_delay_phase_fac_im[sb] + imag0 *
789                  pp_frac_delay_phase_fac_re[sb];
790 
791           r_r0 = real;
792           i_r0 = imag;
793           for (m = 0; m < NUM_SER_AP_LINKS; m++) {
794             real0 = ppp_ser_sub_qmf_dealy_buf_re[m][l_ser_delay_arr[m]][sb];
795             imag0 = ppp_ser_sub_qmf_dealy_buf_im[m][l_ser_delay_arr[m]][sb];
796             real = real0 * pp_frac_delay_phase_fac_ser_re[sb][m] -
797                    imag0 * pp_frac_delay_phase_fac_ser_im[sb][m];
798             imag = real0 * pp_frac_delay_phase_fac_ser_im[sb][m] +
799                    imag0 * pp_frac_delay_phase_fac_ser_re[sb][m];
800 
801             real += -decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * r_r0;
802             imag += -decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * i_r0;
803             ppp_ser_sub_qmf_dealy_buf_re[m][l_ser_delay_arr[m]][sb] =
804                 r_r0 + decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * real;
805             ppp_ser_sub_qmf_dealy_buf_im[m][l_ser_delay_arr[m]][sb] =
806                 i_r0 + decay_scale_factor * ptr_ps_tables->all_pass_link_decay_ser[m] * imag;
807             r_r0 = real;
808             i_r0 = imag;
809           }
810         }
811 
812         bin = (~NEGATE_IPD_MASK) & ptr_ps_dec->ptr_bins_group_map[gr];
813         trans_ratio = trans_ratio_arr[k][bin];
814 
815         pp_qmf_buf_re_right[k][sb] = trans_ratio * r_r0;
816         pp_qmf_buf_im_right[k][sb] = trans_ratio * i_r0;
817 
818         if (++l_delay >= DEL_ALL_PASS) l_delay = 0;
819 
820         if (gr >= ptr_ps_dec->first_delay_gr && sb >= NUM_OF_ALL_PASS_CHNLS) {
821           if (++p_delay_qmf_delay_buf_idx[sb] >= p_delay_qmf_delay_num_samp[sb]) {
822             p_delay_qmf_delay_buf_idx[sb] = 0;
823           }
824         }
825 
826         for (m = 0; m < NUM_SER_AP_LINKS; m++) {
827           if (++l_ser_delay_arr[m] >= ptr_ps_dec->delay_sample_ser[m]) {
828             l_ser_delay_arr[m] = 0;
829           }
830         }
831       }
832     }
833   }
834 
835   ptr_ps_dec->delay_buf_idx = l_delay;
836   for (m = 0; m < NUM_SER_AP_LINKS; m++) {
837     ptr_ps_dec->delay_buf_idx_ser[m] = l_ser_delay_arr[m];
838   }
839 }
840 
ixheaacd_esbr_ps_apply_rotation(ia_ps_dec_struct * ptr_ps_dec,FLOAT32 ** pp_qmf_buf_re_left,FLOAT32 ** pp_qmf_buf_im_left,FLOAT32 ** pp_qmf_buf_re_right,FLOAT32 ** pp_qmf_buf_im_right,ia_ps_tables_struct * ptr_ps_tables)841 VOID ixheaacd_esbr_ps_apply_rotation(
842     ia_ps_dec_struct *ptr_ps_dec,
843     FLOAT32 **pp_qmf_buf_re_left,
844     FLOAT32 **pp_qmf_buf_im_left,
845     FLOAT32 **pp_qmf_buf_re_right,
846     FLOAT32 **pp_qmf_buf_im_right,
847     ia_ps_tables_struct *ptr_ps_tables) {
848   WORD32 i;
849   WORD32 group;
850   WORD32 bin = 0;
851   WORD32 subband, max_subband;
852   WORD32 env;
853   FLOAT32(*p_hyb_left_re)[MAX_NUM_COLUMNS];
854   FLOAT32(*p_hyb_left_im)[MAX_NUM_COLUMNS];
855   FLOAT32(*p_hyb_rigth_re)[MAX_NUM_COLUMNS];
856   FLOAT32(*p_hyb_rigth_im)[MAX_NUM_COLUMNS];
857   FLOAT32 scale_fac_l, scale_fac_r;
858   FLOAT32 alpha, beta;
859   FLOAT32 ipd, opd;
860   FLOAT32 ipd1, opd1;
861   FLOAT32 ipd2, opd2;
862 
863   FLOAT32 h11r, h12r, h21r, h22r;
864   FLOAT32 h11i, h12i, h21i, h22i;
865   FLOAT32 H11r, H12r, H21r, H22r;
866   FLOAT32 H11i, H12i, H21i, H22i;
867   FLOAT32 deltaH11r, deltaH12r, deltaH21r, deltaH22r;
868   FLOAT32 deltaH11i, deltaH12i, deltaH21i, deltaH22i;
869   FLOAT32 l_left_re, l_left_im;
870   FLOAT32 l_right_re, l_right_im;
871 
872   WORD32 L;
873   FLOAT32 *ptr_scale_factors;
874   const WORD32 *ptr_quantized_iids;
875   WORD32 num_iid_steps;
876 
877   if (ptr_ps_dec->iid_quant) {
878     num_iid_steps = NUM_IID_STEPS_FINE;
879     ptr_scale_factors = ptr_ps_tables->scale_factors_fine_flt;
880     ptr_quantized_iids = ptr_ps_tables->quantized_iids_fine;
881   } else {
882     num_iid_steps = NUM_IID_STEPS;
883     ptr_scale_factors = ptr_ps_tables->scale_factors_flt;
884     ptr_quantized_iids = ptr_ps_tables->quantized_iids;
885   }
886 
887   if (ptr_ps_dec->use_34_st_bands != ptr_ps_dec->use_34_st_bands_prev) {
888     if (ptr_ps_dec->use_34_st_bands) {
889       ixheaacd_map_20_float_to_34(ptr_ps_dec->h11_re_prev);
890       ixheaacd_map_20_float_to_34(ptr_ps_dec->h12_re_prev);
891       ixheaacd_map_20_float_to_34(ptr_ps_dec->h21_re_prev);
892       ixheaacd_map_20_float_to_34(ptr_ps_dec->h22_re_prev);
893 
894       ixheaacd_map_20_float_to_34(ptr_ps_dec->h11_im_prev);
895       ixheaacd_map_20_float_to_34(ptr_ps_dec->h12_im_prev);
896       ixheaacd_map_20_float_to_34(ptr_ps_dec->h21_im_prev);
897       ixheaacd_map_20_float_to_34(ptr_ps_dec->h22_im_prev);
898 
899       memset(ptr_ps_dec->ipd_idx_map_1, 0, sizeof(ptr_ps_dec->ipd_idx_map_1));
900       memset(ptr_ps_dec->opd_idx_map_1, 0, sizeof(ptr_ps_dec->opd_idx_map_1));
901       memset(ptr_ps_dec->ipd_idx_map_2, 0, sizeof(ptr_ps_dec->ipd_idx_map_2));
902       memset(ptr_ps_dec->opd_idx_map_2, 0, sizeof(ptr_ps_dec->opd_idx_map_2));
903     } else {
904       ixheaacd_map_34_float_to_20(ptr_ps_dec->h11_re_prev);
905       ixheaacd_map_34_float_to_20(ptr_ps_dec->h12_re_prev);
906       ixheaacd_map_34_float_to_20(ptr_ps_dec->h21_re_prev);
907       ixheaacd_map_34_float_to_20(ptr_ps_dec->h22_re_prev);
908 
909       ixheaacd_map_34_float_to_20(ptr_ps_dec->h11_im_prev);
910       ixheaacd_map_34_float_to_20(ptr_ps_dec->h12_im_prev);
911       ixheaacd_map_34_float_to_20(ptr_ps_dec->h21_im_prev);
912       ixheaacd_map_34_float_to_20(ptr_ps_dec->h22_im_prev);
913 
914       memset(ptr_ps_dec->ipd_idx_map_1, 0, sizeof(ptr_ps_dec->ipd_idx_map_1));
915       memset(ptr_ps_dec->opd_idx_map_1, 0, sizeof(ptr_ps_dec->opd_idx_map_1));
916       memset(ptr_ps_dec->ipd_idx_map_2, 0, sizeof(ptr_ps_dec->ipd_idx_map_2));
917       memset(ptr_ps_dec->opd_idx_map_2, 0, sizeof(ptr_ps_dec->opd_idx_map_2));
918     }
919   }
920 
921   for (env = 0; env < ptr_ps_dec->num_env; env++) {
922     for (bin = 0; bin < ptr_ps_dec->num_bins; bin++) {
923       if (!ptr_ps_dec->use_pca_rot_flg) {
924         scale_fac_r = ptr_scale_factors[num_iid_steps +
925                       ptr_ps_dec->iid_par_table[env][bin]];
926         scale_fac_l = ptr_scale_factors[num_iid_steps -
927                       ptr_ps_dec->iid_par_table[env][bin]];
928 
929         alpha = ptr_ps_tables->alphas[ptr_ps_dec->icc_par_table[env][bin]];
930 
931         beta = alpha * (scale_fac_r - scale_fac_l) / PSC_SQRT2F;
932 
933         h11r = (FLOAT32)(scale_fac_l * cos(beta + alpha));
934         h12r = (FLOAT32)(scale_fac_r * cos(beta - alpha));
935         h21r = (FLOAT32)(scale_fac_l * sin(beta + alpha));
936         h22r = (FLOAT32)(scale_fac_r * sin(beta - alpha));
937       } else {
938         FLOAT32 c, rho, mu, alpha, gamma;
939         WORD32 i;
940 
941         i = ptr_ps_dec->iid_par_table[env][bin];
942         c = (FLOAT32)pow(
943             10.0,
944             ((i) ? (((i > 0) ? 1 : -1) * ptr_quantized_iids[((i > 0) ? i : -i) - 1]) : 0.) /
945                 20.0);
946         rho = ptr_ps_tables->quantized_rhos[ptr_ps_dec->icc_par_table[env][bin]];
947         rho = max(rho, 0.05f);
948 
949         if (rho == 0.0f && c == 1.) {
950           alpha = (FLOAT32)PI / 4.0f;
951         } else {
952           if (rho <= 0.05f) {
953             rho = 0.05f;
954           }
955           alpha = 0.5f * (FLOAT32)atan((2.0f * c * rho) / (c * c - 1.0f));
956 
957           if (alpha < 0.) {
958             alpha += (FLOAT32)PI / 2.0f;
959           }
960         }
961         mu = c + 1.0f / c;
962         mu = 1 + (4.0f * rho * rho - 4.0f) / (mu * mu);
963         gamma = (FLOAT32)atan(sqrt((1.0f - sqrt(mu)) / (1.0f + sqrt(mu))));
964 
965         h11r = (FLOAT32)(sqrt(2.) * cos(alpha) * cos(gamma));
966         h12r = (FLOAT32)(sqrt(2.) * sin(alpha) * cos(gamma));
967         h21r = (FLOAT32)(sqrt(2.) * -sin(alpha) * sin(gamma));
968         h22r = (FLOAT32)(sqrt(2.) * cos(alpha) * sin(gamma));
969       }
970 
971       if (bin >= ptr_ps_tables->ipd_bins_tbl[ptr_ps_dec->freq_res_ipd]) {
972         h11i = h12i = h21i = h22i = 0.0f;
973       } else {
974         ipd = (IPD_SCALE_FACTOR * 2.0f) * ptr_ps_dec->ipd_idx_map[env][bin];
975         opd = (OPD_SCALE_FACTOR * 2.0f) * ptr_ps_dec->opd_idx_map[env][bin];
976         ipd1 = (IPD_SCALE_FACTOR * 2.0f) * ptr_ps_dec->ipd_idx_map_1[bin];
977         opd1 = (OPD_SCALE_FACTOR * 2.0f) * ptr_ps_dec->opd_idx_map_1[bin];
978         ipd2 = (IPD_SCALE_FACTOR * 2.0f) * ptr_ps_dec->ipd_idx_map_2[bin];
979         opd2 = (OPD_SCALE_FACTOR * 2.0f) * ptr_ps_dec->opd_idx_map_2[bin];
980 
981         l_left_re = (FLOAT32)cos(ipd);
982         l_left_im = (FLOAT32)sin(ipd);
983         l_right_re = (FLOAT32)cos(opd);
984         l_right_im = (FLOAT32)sin(opd);
985 
986         l_left_re += PHASE_SMOOTH_HIST1 * (FLOAT32)cos(ipd1);
987         l_left_im += PHASE_SMOOTH_HIST1 * (FLOAT32)sin(ipd1);
988         l_right_re += PHASE_SMOOTH_HIST1 * (FLOAT32)cos(opd1);
989         l_right_im += PHASE_SMOOTH_HIST1 * (FLOAT32)sin(opd1);
990 
991         l_left_re += PHASE_SMOOTH_HIST2 * (FLOAT32)cos(ipd2);
992         l_left_im += PHASE_SMOOTH_HIST2 * (FLOAT32)sin(ipd2);
993         l_right_re += PHASE_SMOOTH_HIST2 * (FLOAT32)cos(opd2);
994         l_right_im += PHASE_SMOOTH_HIST2 * (FLOAT32)sin(opd2);
995 
996         ipd = (FLOAT32)atan2(l_left_im, l_left_re);
997         opd = (FLOAT32)atan2(l_right_im, l_right_re);
998 
999         l_left_re = (FLOAT32)cos(opd);
1000         l_left_im = (FLOAT32)sin(opd);
1001         opd -= ipd;
1002         l_right_re = (FLOAT32)cos(opd);
1003         l_right_im = (FLOAT32)sin(opd);
1004 
1005         h11i = h11r * l_left_im;
1006         h12i = h12r * l_right_im;
1007         h21i = h21r * l_left_im;
1008         h22i = h22r * l_right_im;
1009 
1010         h11r *= l_left_re;
1011         h12r *= l_right_re;
1012         h21r *= l_left_re;
1013         h22r *= l_right_re;
1014       }
1015 
1016       ptr_ps_dec->h11_re_vec[bin] = h11r;
1017       ptr_ps_dec->h12_re_vec[bin] = h12r;
1018       ptr_ps_dec->h21_re_vec[bin] = h21r;
1019       ptr_ps_dec->h22_re_vec[bin] = h22r;
1020       ptr_ps_dec->h11_im_vec[bin] = h11i;
1021       ptr_ps_dec->h12_im_vec[bin] = h12i;
1022       ptr_ps_dec->h21_im_vec[bin] = h21i;
1023       ptr_ps_dec->h22_im_vec[bin] = h22i;
1024 
1025     }
1026 
1027     p_hyb_left_re = ptr_ps_dec->hyb_left_re;
1028     p_hyb_left_im = ptr_ps_dec->hyb_left_im;
1029     p_hyb_rigth_re = ptr_ps_dec->hyb_right_re;
1030     p_hyb_rigth_im = ptr_ps_dec->hyb_right_im;
1031 
1032     for (group = 0; group < ptr_ps_dec->num_sub_qmf_groups; group++) {
1033       bin = (~NEGATE_IPD_MASK) & ptr_ps_dec->ptr_bins_group_map[group];
1034 
1035       max_subband = ptr_ps_dec->ptr_group_borders[group] + 1;
1036 
1037       L = ptr_ps_dec->border_position[env + 1] - ptr_ps_dec->border_position[env];
1038 
1039       H11r = ptr_ps_dec->h11_re_prev[bin];
1040       H12r = ptr_ps_dec->h12_re_prev[bin];
1041       H21r = ptr_ps_dec->h21_re_prev[bin];
1042       H22r = ptr_ps_dec->h22_re_prev[bin];
1043       if ((NEGATE_IPD_MASK & ptr_ps_dec->ptr_bins_group_map[group]) != 0) {
1044         H11i = -ptr_ps_dec->h11_im_prev[bin];
1045         H12i = -ptr_ps_dec->h12_im_prev[bin];
1046         H21i = -ptr_ps_dec->h21_im_prev[bin];
1047         H22i = -ptr_ps_dec->h22_im_prev[bin];
1048       } else {
1049         H11i = ptr_ps_dec->h11_im_prev[bin];
1050         H12i = ptr_ps_dec->h12_im_prev[bin];
1051         H21i = ptr_ps_dec->h21_im_prev[bin];
1052         H22i = ptr_ps_dec->h22_im_prev[bin];
1053       }
1054 
1055       h11r = ptr_ps_dec->h11_re_vec[bin];
1056       h12r = ptr_ps_dec->h12_re_vec[bin];
1057       h21r = ptr_ps_dec->h21_re_vec[bin];
1058       h22r = ptr_ps_dec->h22_re_vec[bin];
1059       if ((NEGATE_IPD_MASK & ptr_ps_dec->ptr_bins_group_map[group]) != 0) {
1060         h11i = -ptr_ps_dec->h11_im_vec[bin];
1061         h12i = -ptr_ps_dec->h12_im_vec[bin];
1062         h21i = -ptr_ps_dec->h21_im_vec[bin];
1063         h22i = -ptr_ps_dec->h22_im_vec[bin];
1064       } else {
1065         h11i = ptr_ps_dec->h11_im_vec[bin];
1066         h12i = ptr_ps_dec->h12_im_vec[bin];
1067         h21i = ptr_ps_dec->h21_im_vec[bin];
1068         h22i = ptr_ps_dec->h22_im_vec[bin];
1069       }
1070 
1071       deltaH11r = (h11r - H11r) / L;
1072       deltaH12r = (h12r - H12r) / L;
1073       deltaH21r = (h21r - H21r) / L;
1074       deltaH22r = (h22r - H22r) / L;
1075 
1076       deltaH11i = (h11i - H11i) / L;
1077       deltaH12i = (h12i - H12i) / L;
1078       deltaH21i = (h21i - H21i) / L;
1079       deltaH22i = (h22i - H22i) / L;
1080 
1081       for (i = ptr_ps_dec->border_position[env]; i < ptr_ps_dec->border_position[env + 1];
1082            i++) {
1083         H11r += deltaH11r;
1084         H12r += deltaH12r;
1085         H21r += deltaH21r;
1086         H22r += deltaH22r;
1087 
1088         H11i += deltaH11i;
1089         H12i += deltaH12i;
1090         H21i += deltaH21i;
1091         H22i += deltaH22i;
1092 
1093         for (subband = ptr_ps_dec->ptr_group_borders[group]; subband < max_subband;
1094              subband++) {
1095           l_left_re = H11r * p_hyb_left_re[i][subband] - H11i * p_hyb_left_im[i][subband] +
1096                       H21r * p_hyb_rigth_re[i][subband] - H21i * p_hyb_rigth_im[i][subband];
1097 
1098           l_left_im = H11i * p_hyb_left_re[i][subband] + H11r * p_hyb_left_im[i][subband] +
1099                       H21i * p_hyb_rigth_re[i][subband] + H21r * p_hyb_rigth_im[i][subband];
1100 
1101           l_right_re = H12r * p_hyb_left_re[i][subband] - H12i * p_hyb_left_im[i][subband] +
1102                        H22r * p_hyb_rigth_re[i][subband] - H22i * p_hyb_rigth_im[i][subband];
1103 
1104           l_right_im = H12i * p_hyb_left_re[i][subband] + H12r * p_hyb_left_im[i][subband] +
1105                        H22i * p_hyb_rigth_re[i][subband] + H22r * p_hyb_rigth_im[i][subband];
1106 
1107           p_hyb_left_re[i][subband] = l_left_re;
1108           p_hyb_left_im[i][subband] = l_left_im;
1109           p_hyb_rigth_re[i][subband] = l_right_re;
1110           p_hyb_rigth_im[i][subband] = l_right_im;
1111         }
1112       }
1113     }
1114 
1115     for (; group < ptr_ps_dec->num_groups; group++) {
1116       bin = (~NEGATE_IPD_MASK) & ptr_ps_dec->ptr_bins_group_map[group];
1117 
1118       max_subband = ptr_ps_dec->ptr_group_borders[group + 1];
1119 
1120       L = ptr_ps_dec->border_position[env + 1] - ptr_ps_dec->border_position[env];
1121 
1122       H11r = ptr_ps_dec->h11_re_prev[bin];
1123       H12r = ptr_ps_dec->h12_re_prev[bin];
1124       H21r = ptr_ps_dec->h21_re_prev[bin];
1125       H22r = ptr_ps_dec->h22_re_prev[bin];
1126       if ((NEGATE_IPD_MASK & ptr_ps_dec->ptr_bins_group_map[group]) != 0) {
1127         H11i = -ptr_ps_dec->h11_im_prev[bin];
1128         H12i = -ptr_ps_dec->h12_im_prev[bin];
1129         H21i = -ptr_ps_dec->h21_im_prev[bin];
1130         H22i = -ptr_ps_dec->h22_im_prev[bin];
1131       } else {
1132         H11i = ptr_ps_dec->h11_im_prev[bin];
1133         H12i = ptr_ps_dec->h12_im_prev[bin];
1134         H21i = ptr_ps_dec->h21_im_prev[bin];
1135         H22i = ptr_ps_dec->h22_im_prev[bin];
1136       }
1137 
1138       h11r = ptr_ps_dec->h11_re_vec[bin];
1139       h12r = ptr_ps_dec->h12_re_vec[bin];
1140       h21r = ptr_ps_dec->h21_re_vec[bin];
1141       h22r = ptr_ps_dec->h22_re_vec[bin];
1142       if ((NEGATE_IPD_MASK & ptr_ps_dec->ptr_bins_group_map[group]) != 0) {
1143         h11i = -ptr_ps_dec->h11_im_vec[bin];
1144         h12i = -ptr_ps_dec->h12_im_vec[bin];
1145         h21i = -ptr_ps_dec->h21_im_vec[bin];
1146         h22i = -ptr_ps_dec->h22_im_vec[bin];
1147       } else {
1148         h11i = ptr_ps_dec->h11_im_vec[bin];
1149         h12i = ptr_ps_dec->h12_im_vec[bin];
1150         h21i = ptr_ps_dec->h21_im_vec[bin];
1151         h22i = ptr_ps_dec->h22_im_vec[bin];
1152       }
1153 
1154       deltaH11r = (h11r - H11r) / L;
1155       deltaH12r = (h12r - H12r) / L;
1156       deltaH21r = (h21r - H21r) / L;
1157       deltaH22r = (h22r - H22r) / L;
1158 
1159       deltaH11i = (h11i - H11i) / L;
1160       deltaH12i = (h12i - H12i) / L;
1161       deltaH21i = (h21i - H21i) / L;
1162       deltaH22i = (h22i - H22i) / L;
1163 
1164       for (i = ptr_ps_dec->border_position[env]; i < ptr_ps_dec->border_position[env + 1];
1165            i++) {
1166         H11r += deltaH11r;
1167         H12r += deltaH12r;
1168         H21r += deltaH21r;
1169         H22r += deltaH22r;
1170 
1171         H11i += deltaH11i;
1172         H12i += deltaH12i;
1173         H21i += deltaH21i;
1174         H22i += deltaH22i;
1175 
1176         for (subband = ptr_ps_dec->ptr_group_borders[group]; subband < max_subband;
1177              subband++) {
1178           l_left_re = H11r * pp_qmf_buf_re_left[i][subband] - H11i *
1179                       pp_qmf_buf_im_left[i][subband] +
1180                       H21r * pp_qmf_buf_re_right[i][subband] - H21i *
1181                       pp_qmf_buf_im_right[i][subband];
1182 
1183           l_left_im = H11i * pp_qmf_buf_re_left[i][subband] + H11r *
1184                       pp_qmf_buf_im_left[i][subband] +
1185                       H21i * pp_qmf_buf_re_right[i][subband] + H21r *
1186                       pp_qmf_buf_im_right[i][subband];
1187 
1188           l_right_re = H12r * pp_qmf_buf_re_left[i][subband] - H12i *
1189                        pp_qmf_buf_im_left[i][subband] +
1190                        H22r * pp_qmf_buf_re_right[i][subband] - H22i *
1191                        pp_qmf_buf_im_right[i][subband];
1192 
1193           l_right_im = H12i * pp_qmf_buf_re_left[i][subband] + H12r *
1194                        pp_qmf_buf_im_left[i][subband] +
1195                        H22i * pp_qmf_buf_re_right[i][subband] + H22r *
1196                        pp_qmf_buf_im_right[i][subband];
1197 
1198           pp_qmf_buf_re_left[i][subband] = l_left_re;
1199           pp_qmf_buf_im_left[i][subband] = l_left_im;
1200           pp_qmf_buf_re_right[i][subband] = l_right_re;
1201           pp_qmf_buf_im_right[i][subband] = l_right_im;
1202         }
1203       }
1204     }
1205     for (bin = 0; bin < ptr_ps_dec->num_bins; bin++) {
1206       ptr_ps_dec->h11_re_prev[bin] = ptr_ps_dec->h11_re_vec[bin];
1207       ptr_ps_dec->h12_re_prev[bin] = ptr_ps_dec->h12_re_vec[bin];
1208       ptr_ps_dec->h21_re_prev[bin] = ptr_ps_dec->h21_re_vec[bin];
1209       ptr_ps_dec->h22_re_prev[bin] = ptr_ps_dec->h22_re_vec[bin];
1210 
1211       ptr_ps_dec->h11_im_prev[bin] = ptr_ps_dec->h11_im_vec[bin];
1212       ptr_ps_dec->h12_im_prev[bin] = ptr_ps_dec->h12_im_vec[bin];
1213       ptr_ps_dec->h21_im_prev[bin] = ptr_ps_dec->h21_im_vec[bin];
1214       ptr_ps_dec->h22_im_prev[bin] = ptr_ps_dec->h22_im_vec[bin];
1215     }
1216 
1217     for (bin = 0; bin < ptr_ps_tables->ipd_bins_tbl[ptr_ps_dec->freq_res_ipd]; bin++) {
1218       ptr_ps_dec->ipd_idx_map_2[bin] = ptr_ps_dec->ipd_idx_map_1[bin];
1219       ptr_ps_dec->opd_idx_map_2[bin] = ptr_ps_dec->opd_idx_map_1[bin];
1220       ptr_ps_dec->ipd_idx_map_1[bin] = ptr_ps_dec->ipd_idx_map[env][bin];
1221       ptr_ps_dec->opd_idx_map_1[bin] = ptr_ps_dec->opd_idx_map[env][bin];
1222     }
1223   }
1224 }
1225