Coverage Report

Created: 2025-07-18 06:38

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