Coverage Report

Created: 2026-10-31 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/decoder/ixheaacd_mps_temp_process.c
Line
Count
Source
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 <math.h>
21
#include "ixheaac_type_def.h"
22
#include "ixheaac_constants.h"
23
#include "ixheaacd_bitbuffer.h"
24
#include "ixheaacd_common_rom.h"
25
#include "ixheaacd_sbrdecsettings.h"
26
#include "ixheaacd_sbr_scale.h"
27
#include "ixheaacd_env_extr_part.h"
28
#include "ixheaacd_sbr_rom.h"
29
#include "ixheaacd_config.h"
30
#include "ixheaacd_hybrid.h"
31
#include "ixheaacd_ps_dec.h"
32
#include "ixheaacd_qmf_dec.h"
33
#include "ixheaacd_mps_polyphase.h"
34
#include "ixheaacd_mps_struct_def.h"
35
#include "ixheaacd_mps_res_rom.h"
36
#include "ixheaacd_mps_aac_struct.h"
37
#include "ixheaacd_mps_dec.h"
38
#include "ixheaacd_mps_process.h"
39
#include "ixheaacd_lpp_tran.h"
40
#include "ixheaacd_env_extr.h"
41
#include "ixheaacd_env_calc.h"
42
#include "ixheaac_sbr_const.h"
43
#include "ixheaacd_pvc_dec.h"
44
#include "ixheaacd_sbr_dec.h"
45
#include "ixheaacd_audioobjtypes.h"
46
#include "ixheaac_basic_ops32.h"
47
#include "ixheaac_basic_ops40.h"
48
#include "ixheaacd_mps_bitdec.h"
49
#include "ixheaacd_mps_macro_def.h"
50
#include "ixheaacd_mps_get_index.h"
51
#include "ixheaacd_mps_basic_op.h"
52
#include "ixheaacd_mps_tp_process.h"
53
#include "ixheaacd_error_codes.h"
54
12.1M
#define HP_SIZE (9)
55
56
5.54M
#define STP_LPF_COEFF1 (0.950f)
57
3.69M
#define STP_LPF_COEFF2 (0.450f)
58
1.21M
#define STP_UPDATE_ENERGY_RATE (32)
59
#define STP_SCALE_LIMIT (2.82f)
60
3.69M
#define STP_DAMP (0.1f)
61
62
static const FLOAT32 ixheaacd_bp[BP_SIZE] = {
63
  0.0000f, 0.0005f, 0.0092f, 0.0587f, 0.2580f, 0.7392f, 0.9791f,
64
  0.9993f, 1.0000f, 1.0000f, 1.0000f, 1.0000f, 0.9999f, 0.9984f,
65
  0.9908f, 0.9639f, 0.8952f, 0.7711f, 0.6127f, 0.4609f, 0.3391f,
66
  0.2493f, 0.1848f, 0.1387f, 0.1053f};
67
68
static const FLOAT32 ixheaacd_gf[BP_SIZE] = {
69
  0.f,     0.f,     0.f,     0.f,     0.f,
70
  0.f,     1e-008f,   8.1e-007f,   3.61e-006f,  8.41e-006f,
71
  1.6e-005f,   2.704e-005f, 3.969e-005f, 5.625e-005f, 7.396e-005f,
72
  9.801e-005f, 0.00012321f, 0.00015625f, 0.00019881f, 0.00024964f,
73
  0.00032041f, 0.00041209f, 0.00053824f, 0.00070756f, 0.00094249f};
74
75
extern const WORD32 ixheaacd_mps_gain_set_indx[29];
76
77
static VOID ixheaacd_mps_temp_process_scale_calc(ia_mps_dec_state_struct* self,
78
923k
                                                 WORD32 ts, FLOAT32* scale) {
79
923k
  FLOAT32 dir_energy;
80
923k
  FLOAT32 diff_energy[2];
81
923k
  FLOAT32 temp;
82
83
923k
  WORD32 ch, n;
84
923k
  WORD32 left_ch = 0, right_ch = 1;
85
86
923k
  if (self->subband_var.init_flag == 0) {
87
2.40k
    for (ch = 0; ch < 2; ch++) {
88
1.60k
      self->subband_var.tp_scale_last[ch] = 1.0f;
89
1.60k
      self->subband_var.nrg_diff_prev[ch] = 32768 * 32768;
90
1.60k
    }
91
92
803
    self->subband_var.nrg_dir_prev = 32768 * 32768;
93
803
    self->subband_var.init_flag = 1;
94
803
  }
95
96
923k
  if (self->subband_var.update_old_ener == STP_UPDATE_ENERGY_RATE) {
97
28.1k
    self->subband_var.update_old_ener = 1;
98
28.1k
    self->subband_var.nrg_dir_prev = self->subband_var.nrg_dir;
99
84.5k
    for (ch = 0; ch < self->out_ch_count; ch++)
100
56.3k
      self->subband_var.nrg_diff_prev[ch] = self->subband_var.nrg_diff[ch];
101
28.1k
  } else
102
895k
    self->subband_var.update_old_ener++;
103
104
923k
  dir_energy = 0;
105
106
18.4M
  for (n = 6; n < BP_SIZE; n++) {
107
17.5M
    FLOAT32 dir_left_re = self->hyb_dir_out[left_ch][ts][n + 7].re;
108
17.5M
    FLOAT32 dir_right_re = self->hyb_dir_out[right_ch][ts][n + 7].re;
109
17.5M
    FLOAT32 dir_left_im = self->hyb_dir_out[left_ch][ts][n + 7].im;
110
17.5M
    FLOAT32 dir_right_im = self->hyb_dir_out[right_ch][ts][n + 7].im;
111
112
17.5M
    temp = ((dir_left_re + dir_right_re) * (dir_left_re + dir_right_re)) +
113
17.5M
           ((dir_left_im + dir_right_im) * (dir_left_im + dir_right_im));
114
17.5M
    dir_energy += temp * ixheaacd_bp[n] * ixheaacd_bp[n] * ixheaacd_gf[n] *
115
17.5M
                  ixheaacd_gf[n];
116
17.5M
  }
117
118
923k
  self->subband_var.nrg_dir =
119
923k
      (FLOAT32)(STP_LPF_COEFF1 * self->subband_var.nrg_dir +
120
923k
                (1.0 - STP_LPF_COEFF1) * dir_energy);
121
122
923k
  dir_energy /= (self->subband_var.nrg_dir_prev + ABS_THR);
123
124
2.77M
  for (ch = 0; ch < self->out_ch_count; ch++) {
125
1.84M
    diff_energy[ch] = 0;
126
36.9M
    for (n = 6; n < BP_SIZE; n++) {
127
35.1M
      FLOAT32 diff_re = self->hyb_diff_out[ch][ts][n + 7].re;
128
35.1M
      FLOAT32 diff_im = self->hyb_diff_out[ch][ts][n + 7].im;
129
130
35.1M
      temp = (diff_re * diff_re) + (diff_im * diff_im);
131
35.1M
      diff_energy[ch] += temp * ixheaacd_bp[n] * ixheaacd_bp[n] *
132
35.1M
                         ixheaacd_gf[n] * ixheaacd_gf[n];
133
35.1M
    }
134
135
1.84M
    self->subband_var.nrg_diff[ch] =
136
1.84M
        (FLOAT32)(STP_LPF_COEFF1 * self->subband_var.nrg_diff[ch] +
137
1.84M
                  (1.0 - STP_LPF_COEFF1) * diff_energy[ch]);
138
1.84M
    diff_energy[ch] /= (self->subband_var.nrg_diff_prev[ch] + ABS_THR);
139
1.84M
  }
140
141
923k
  scale[left_ch] = (FLOAT32)sqrt((dir_energy) / (diff_energy[left_ch] + 1e-9));
142
923k
  scale[right_ch] =
143
923k
      (FLOAT32)sqrt((dir_energy) / (diff_energy[right_ch] + 1e-9));
144
145
2.77M
  for (ch = 0; ch < self->out_ch_count; ch++) {
146
1.84M
    scale[ch] = STP_DAMP + (1 - STP_DAMP) * scale[ch];
147
1.84M
  }
148
149
2.77M
  for (ch = 0; ch < self->out_ch_count; ch++) {
150
1.84M
    scale[ch] =
151
1.84M
        min(max(scale[ch], (FLOAT32)(1.0 / STP_SCALE_LIMIT)), STP_SCALE_LIMIT);
152
1.84M
  }
153
154
2.77M
  for (ch = 0; ch < self->out_ch_count; ch++) {
155
1.84M
    scale[ch] =
156
1.84M
        (FLOAT32)(STP_LPF_COEFF2 * scale[ch] +
157
1.84M
                  (1.0 - STP_LPF_COEFF2) * self->subband_var.tp_scale_last[ch]);
158
1.84M
    self->subband_var.tp_scale_last[ch] = scale[ch];
159
1.84M
  }
160
923k
}
161
162
923k
static VOID ixheaacd_mps_subbandtp(ia_mps_dec_state_struct* self, WORD32 ts) {
163
923k
  FLOAT32 scale[2];
164
923k
  WORD32 ch, n;
165
923k
  WORD32 no_scaling;
166
923k
  FLOAT32 temp;
167
923k
  const WORD32 ixheaacd_hybrid_to_qmf_map[] = {0, 0, 0, 0, 0, 0, 1, 1, 2, 2};
168
923k
  const WORD32 ixheaacd_hybrid_to_qmf_map_ldmps[] = {0, 1, 2};
169
923k
  const WORD32* ptr_ixheaacd_hybrid_to_qmf_map;
170
923k
  WORD32 loop_counter = 0;
171
172
923k
  if (self->ldmps_config.ldmps_present_flag) {
173
20.6k
    ptr_ixheaacd_hybrid_to_qmf_map = ixheaacd_hybrid_to_qmf_map_ldmps;
174
20.6k
    loop_counter = 3;
175
903k
  } else {
176
903k
    ptr_ixheaacd_hybrid_to_qmf_map = ixheaacd_hybrid_to_qmf_map;
177
903k
    loop_counter = 10;
178
903k
  }
179
180
923k
  ixheaacd_mps_temp_process_scale_calc(self, ts, scale);
181
182
2.77M
  for (ch = 0; ch < self->out_ch_count; ch++) {
183
1.84M
    no_scaling = 1;
184
185
1.84M
    if ((self->config->bs_temp_shape_config == 1) ||
186
0
        (self->config->bs_temp_shape_config == 2))
187
1.84M
      no_scaling = !self->temp_shape_enable_ch_stp[ch];
188
189
1.84M
    if (no_scaling == 1) {
190
112M
      for (n = 0; n < self->hyb_band_count_max; n++) {
191
110M
        self->hyb_dir_out[ch][ts][n].re += self->hyb_diff_out[ch][ts][n].re;
192
110M
        self->hyb_dir_out[ch][ts][n].im += self->hyb_diff_out[ch][ts][n].im;
193
110M
      }
194
1.74M
    } else {
195
98.2k
      if (self->ldmps_config.ldmps_present_flag) {
196
34.7k
        for (n = 0; n < 3; n++) {
197
26.0k
          temp = (FLOAT32)(scale[ch] *
198
26.0k
                           ixheaacd_bp[ptr_ixheaacd_hybrid_to_qmf_map[n]]);
199
26.0k
          self->hyb_dir_out[ch][ts][n].re +=
200
26.0k
              (self->hyb_diff_out[ch][ts][n].re * temp);
201
26.0k
          self->hyb_dir_out[ch][ts][n].im +=
202
26.0k
              (self->hyb_diff_out[ch][ts][n].im * temp);
203
26.0k
        }
204
89.6k
      } else {
205
985k
        for (n = 0; n < loop_counter; n++) {
206
896k
          temp = (FLOAT32)(scale[ch] *
207
896k
                           ixheaacd_bp[ptr_ixheaacd_hybrid_to_qmf_map[n]]);
208
896k
          self->hyb_dir_out[ch][ts][n].re +=
209
896k
              (self->hyb_diff_out[ch][ts][n].re * temp);
210
896k
          self->hyb_dir_out[ch][ts][n].im +=
211
896k
              (self->hyb_diff_out[ch][ts][n].im * temp);
212
896k
        }
213
89.6k
      }
214
982k
      for (n = 7; n < HP_SIZE - 3 + 10; n++) {
215
884k
        temp = (FLOAT32)(scale[ch] * ixheaacd_bp[n + 3 - 10]);
216
884k
        self->hyb_dir_out[ch][ts][n].re +=
217
884k
            (self->hyb_diff_out[ch][ts][n].re * temp);
218
884k
        self->hyb_dir_out[ch][ts][n].im +=
219
884k
            (self->hyb_diff_out[ch][ts][n].im * temp);
220
884k
      }
221
4.56M
      for (; n < self->hyb_band_count_max; n++) {
222
4.46M
        temp = (FLOAT32)(scale[ch]);
223
4.46M
        self->hyb_dir_out[ch][ts][n].re +=
224
4.46M
            (self->hyb_diff_out[ch][ts][n].re * temp);
225
4.46M
        self->hyb_dir_out[ch][ts][n].im +=
226
4.46M
            (self->hyb_diff_out[ch][ts][n].im * temp);
227
4.46M
      }
228
98.2k
    }
229
1.84M
  }
230
923k
}
231
232
123k
WORD32 ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) {
233
123k
  WORD32 ch, ts, hyb;
234
123k
  WORD32 err = 0;
235
123k
  ia_sbr_frame_info_data_struct* ptr_frame_data =
236
123k
      (ia_sbr_frame_info_data_struct*)self->p_sbr_frame[0];
237
123k
  if (self->res_bands != 28) {
238
105k
    if (self->config->bs_temp_shape_config == 1) {
239
30.2k
      WORD32 dif_s = ((self->res_bands == 0)
240
30.2k
                          ? 0
241
30.2k
                          : ixheaacd_mps_gain_set_indx[self->res_bands]);
242
90.6k
      for (ch = 0; ch < self->out_ch_count; ch++) {
243
1.90M
        for (ts = 0; ts < self->time_slots; ts++) {
244
16.3M
          for (hyb = dif_s; hyb < HYBRID_BAND_BORDER; hyb++) {
245
14.5M
            self->hyb_dir_out[ch][ts][hyb].re +=
246
14.5M
                self->hyb_diff_out[ch][ts][hyb].re;
247
14.5M
            self->hyb_dir_out[ch][ts][hyb].im +=
248
14.5M
                self->hyb_diff_out[ch][ts][hyb].im;
249
14.5M
            self->hyb_diff_out[ch][ts][hyb].re = 0;
250
14.5M
            self->hyb_diff_out[ch][ts][hyb].im = 0;
251
14.5M
          }
252
1.84M
        }
253
60.4k
      }
254
255
954k
      for (ts = 0; ts < self->time_slots; ts++)
256
923k
        ixheaacd_mps_subbandtp(self, ts);
257
258
75.0k
    } else {
259
75.0k
      WORD32 dif_s = ((self->res_bands == 0)
260
75.0k
                          ? 0
261
75.0k
                          : ixheaacd_mps_gain_set_indx[self->res_bands]);
262
225k
      for (ch = 0; ch < self->out_ch_count; ch++) {
263
6.62M
        for (ts = 0; ts < self->time_slots; ts++) {
264
205M
          for (hyb = dif_s; hyb < self->hyb_band_count_max; hyb++) {
265
199M
            self->hyb_dir_out[ch][ts][hyb].re +=
266
199M
                self->hyb_diff_out[ch][ts][hyb].re;
267
199M
            self->hyb_dir_out[ch][ts][hyb].im +=
268
199M
                self->hyb_diff_out[ch][ts][hyb].im;
269
199M
          }
270
6.47M
        }
271
150k
      }
272
75.0k
    }
273
105k
  }
274
275
123k
  ixheaacd_mps_qmf_hyb_synthesis(self);
276
277
123k
  if (self->ldmps_config.ldmps_present_flag != 1) {
278
356k
    for (ch = 0; ch < self->out_ch_count; ch++) {
279
237k
      err =
280
237k
          ixheaacd_sbr_dec_from_mps(&self->qmf_out_dir[ch][0][0].re, self->p_sbr_dec[ch],
281
237k
                                    self->p_sbr_frame[ch], self->p_sbr_header[ch], self->ec_flag);
282
237k
      if (err) return err;
283
237k
    }
284
118k
  }
285
286
123k
  if (self->object_type == AOT_ER_AAC_ELD || self->object_type == AOT_ER_AAC_LD)
287
4.57k
    self->synth_count = self->hyb_band_count[0];
288
118k
  else
289
118k
  {
290
118k
    if (ptr_frame_data->mps_sbr_flag) {
291
58.4k
      self->synth_count =
292
58.4k
        ptr_frame_data->pstr_sbr_header->pstr_freq_band_data->sub_band_end;
293
58.4k
    }
294
60.4k
    else {
295
60.4k
      self->synth_count = self->band_count[0];
296
60.4k
    }
297
118k
  }
298
299
123k
  ixheaacd_mps_synt_calc(self);
300
123k
  return err;
301
123k
}
302
303
290k
static VOID ixheaacd_subband_tp(ia_heaac_mps_state_struct *pstr_mps_state, WORD32 ts) {
304
290k
  ia_mps_dec_tp_process_tables_struct *tp_process_table_ptr =
305
290k
      pstr_mps_state->ia_mps_dec_mps_table.tp_process_table_ptr;
306
290k
  const WORD32 *sqrt_tab =
307
290k
      pstr_mps_state->ia_mps_dec_mps_table.common_table_ptr->sqrt_tab;
308
290k
  ia_mps_dec_subband_tp_params_struct *sub_band_tp =
309
290k
      pstr_mps_state->mps_persistent_mem.sub_band_params;
310
290k
  ia_mps_dec_reuse_array_struct *p_array_struct = pstr_mps_state->array_struct;
311
312
290k
  WORD32 temp_1, temp_2;
313
290k
  WORD16 qtemp1, qtemp2;
314
290k
  WORD32 *qmf_output_real_dry;
315
290k
  WORD32 *qmf_output_imag_dry;
316
290k
  WORD32 *qmf_output_real_wet;
317
290k
  WORD32 *qmf_output_imag_wet;
318
319
290k
  WORD32 *dmx_real;
320
290k
  WORD32 *dmx_imag;
321
290k
  WORD32 *dry_ener;
322
290k
  WORD32 *wet_ener;
323
290k
  WORD16 *q_dry_ener;
324
290k
  WORD16 *q_wet_ener;
325
326
290k
  WORD32 *p_buffer_real, *p_buffer_imag, *p_buffer_re, *p_buffer_im;
327
290k
  WORD32 *p_buf_real, *p_buf_imag, *p_buf_re, *p_buf_im;
328
290k
  WORD32 *scale;
329
290k
  WORD16 *q_scale;
330
290k
  WORD32 damp, one_minus_damp;
331
290k
  WORD32 temp;
332
333
290k
  WORD32 *prev_tp_scale = sub_band_tp->prev_tp_scale;
334
335
290k
  WORD32 *old_wet_ener = sub_band_tp->old_wet_ener;
336
290k
  WORD16 *q_old_wet_ener = sub_band_tp->q_old_wet_ener;
337
338
290k
  WORD32 *run_wet_ener = sub_band_tp->run_wet_ener;
339
290k
  WORD16 *q_run_wet_ener = sub_band_tp->q_run_wet_ener;
340
341
290k
  WORD32 *old_dry_ener = sub_band_tp->old_dry_ener;
342
290k
  WORD16 *q_old_dry_ener = sub_band_tp->q_old_dry_ener;
343
344
290k
  WORD32 *run_dry_ener = sub_band_tp->run_dry_ener;
345
290k
  WORD16 *q_run_dry_ener = sub_band_tp->q_run_dry_ener;
346
347
290k
  WORD32 *hyb_output_real_dry, *hyb_output_imag_dry;
348
349
290k
  WORD32 *p_hyb_out_dry_real, *p_hyb_out_dry_imag;
350
351
290k
  WORD32 ch, n, no_scaling, i, k = 0, offset;
352
290k
  WORD32 i_lf = 0, i_rf = 0, i_c = 0, i_lfe = 0, i_ls = 0, i_rs = 0, i_al = 0, i_ar = 0;
353
354
290k
  WORD32 loop_counter = 0;
355
356
290k
  WORD32 num_input_channels = pstr_mps_state->num_input_channels;
357
290k
  WORD32 num_output_channels = pstr_mps_state->num_output_channels;
358
290k
  WORD32 hybrid_bands = pstr_mps_state->hybrid_bands;
359
360
290k
  WORD32 tree_config = pstr_mps_state->tree_config;
361
290k
  WORD64 dmx_real64 = 0;
362
290k
  WORD64 dmx_imag64 = 0;
363
364
290k
  dry_ener = pstr_mps_state->mps_scratch_mem_v;
365
290k
  q_dry_ener = (WORD16 *)pstr_mps_state->mps_scratch_mem_v +
366
290k
               IXHEAAC_GET_SIZE_ALIGNED_TYPE(INPUT_CHX2, sizeof(*q_dry_ener), BYTE_ALIGN_8);
367
368
290k
  wet_ener =
369
290k
      dry_ener + IXHEAAC_GET_SIZE_ALIGNED_TYPE(INPUT_CHX1_5, sizeof(*wet_ener), BYTE_ALIGN_8);
370
290k
  q_wet_ener = q_dry_ener +
371
290k
               IXHEAAC_GET_SIZE_ALIGNED_TYPE(IN_CH_2XOUT_CH, sizeof(*q_wet_ener), BYTE_ALIGN_8);
372
373
290k
  scale = wet_ener + IXHEAAC_GET_SIZE_ALIGNED_TYPE(OUTPUT_CHX1_5, sizeof(*scale), BYTE_ALIGN_8);
374
290k
  q_scale =
375
290k
      q_wet_ener + IXHEAAC_GET_SIZE_ALIGNED_TYPE(OUTPUT_CHX3, sizeof(*q_scale), BYTE_ALIGN_8);
376
377
290k
  dmx_real =
378
290k
      scale + IXHEAAC_GET_SIZE_ALIGNED_TYPE(OUTPUT_CHX1_5, sizeof(*dmx_real), BYTE_ALIGN_8);
379
290k
  dmx_imag =
380
290k
      dmx_real + IXHEAAC_GET_SIZE_ALIGNED_TYPE(IN_CHXBP_SIZE, sizeof(*dmx_imag), BYTE_ALIGN_8);
381
382
290k
  qmf_output_real_dry = dmx_imag + IXHEAAC_GET_SIZE_ALIGNED_TYPE(
383
290k
                                       IN_CHXBP_SIZE, sizeof(*qmf_output_real_dry), BYTE_ALIGN_8);
384
385
290k
  qmf_output_imag_dry =
386
290k
      qmf_output_real_dry +
387
290k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(OUT_CHXQB, sizeof(*qmf_output_imag_dry), BYTE_ALIGN_8);
388
389
290k
  qmf_output_real_wet =
390
290k
      qmf_output_imag_dry +
391
290k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(OUT_CHXQB, sizeof(*qmf_output_real_wet), BYTE_ALIGN_8);
392
393
290k
  qmf_output_imag_wet =
394
290k
      qmf_output_real_wet +
395
290k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(OUT_CHXQB, sizeof(*qmf_output_imag_wet), BYTE_ALIGN_8);
396
397
290k
  if (sub_band_tp->update_old_ener == STP_UPDATE_ENERGY_RATE) {
398
7.03k
    sub_band_tp->update_old_ener = 1;
399
45.7k
    for (ch = 0; ch < num_input_channels; ch++) {
400
38.7k
      old_dry_ener[ch] = run_dry_ener[ch];
401
38.7k
      q_old_dry_ener[ch] = q_run_dry_ener[ch];
402
38.7k
    }
403
62.4k
    for (ch = 0; ch < num_output_channels; ch++) {
404
55.3k
      old_wet_ener[ch] = run_wet_ener[ch];
405
55.3k
      q_old_wet_ener[ch] = q_run_wet_ener[ch];
406
55.3k
    }
407
7.03k
  } else
408
283k
    sub_band_tp->update_old_ener++;
409
410
2.61M
  for (ch = 0; ch < MAX_OUTPUT_CHANNELS_MPS; ch++) {
411
2.32M
    scale[ch] = ONE_IN_Q15;
412
2.32M
    q_scale[ch] = 15;
413
2.32M
  }
414
415
290k
  switch (tree_config) {
416
14.4k
    case TREE_5151:
417
14.4k
      i_lf = 0;
418
14.4k
      i_rf = 1;
419
14.4k
      i_c = 2;
420
14.4k
      i_lfe = 3;
421
14.4k
      i_ls = 4;
422
14.4k
      i_rs = 5;
423
14.4k
      loop_counter = 6;
424
14.4k
      break;
425
13.1k
    case TREE_5152:
426
13.1k
      i_lf = 0;
427
13.1k
      i_rf = 2;
428
13.1k
      i_c = 4;
429
13.1k
      i_lfe = 5;
430
13.1k
      i_ls = 1;
431
13.1k
      i_rs = 3;
432
13.1k
      loop_counter = 5;
433
13.1k
      break;
434
14.8k
    case TREE_525:
435
14.8k
      i_lf = 0;
436
14.8k
      i_rf = 2;
437
14.8k
      i_c = 4;
438
14.8k
      i_lfe = 5;
439
14.8k
      i_ls = 1;
440
14.8k
      i_rs = 3;
441
14.8k
      loop_counter = 4;
442
14.8k
      break;
443
18.5k
    case TREE_7271:
444
24.4k
    case TREE_7272:
445
155k
    case TREE_7572:
446
155k
      i_lf = 0;
447
155k
      i_rf = 3;
448
155k
      i_c = 6;
449
155k
      i_lfe = 7;
450
155k
      i_ls = 2;
451
155k
      i_rs = 5;
452
155k
      i_al = 1;
453
155k
      i_ar = 4;
454
155k
      loop_counter = 6;
455
155k
      break;
456
92.6k
    case TREE_7571:
457
92.6k
      i_lf = 0;
458
92.6k
      i_rf = 3;
459
92.6k
      i_c = 6;
460
92.6k
      i_lfe = 7;
461
92.6k
      i_ls = 2;
462
92.6k
      i_rs = 5;
463
92.6k
      i_al = 1;
464
92.6k
      i_ar = 4;
465
92.6k
      loop_counter = 5;
466
92.6k
      break;
467
0
    default:
468
0
      break;
469
290k
  }
470
471
290k
  offset = ts * MAX_HYBRID_BANDS;
472
290k
  p_buffer_real = p_array_struct->buf_real + offset + HYBRID_BAND_BORDER;
473
290k
  p_buffer_imag = p_array_struct->buf_imag + offset + HYBRID_BAND_BORDER;
474
475
2.52M
  for (ch = 0; ch < num_output_channels; ch++) {
476
2.23M
    p_buffer_re = p_buffer_real;
477
2.23M
    p_buffer_im = p_buffer_imag;
478
479
46.9M
    for (i = QMF_OUT_START_IDX; i < BP_SIZE; i++) {
480
44.7M
      *qmf_output_real_wet++ = *p_buffer_re++;
481
44.7M
      *qmf_output_imag_wet++ = *p_buffer_im++;
482
44.7M
    }
483
2.23M
    p_buffer_real += TSXHB;
484
2.23M
    p_buffer_imag += TSXHB;
485
2.23M
  }
486
290k
  i = QMF_OUT_OFFSET * num_output_channels;
487
290k
  qmf_output_real_wet -= i;
488
290k
  qmf_output_imag_wet -= i;
489
490
290k
  p_buffer_re = qmf_output_real_dry;
491
290k
  p_buffer_im = qmf_output_imag_dry;
492
493
290k
  hyb_output_real_dry =
494
290k
      p_array_struct->hyb_output_real_dry + ts * MAX_HYBRID_BANDS + 6;
495
290k
  hyb_output_imag_dry =
496
290k
      p_array_struct->hyb_output_imag_dry + ts * MAX_HYBRID_BANDS + 6;
497
498
1.89M
  for (ch = 0; ch < loop_counter; ch++) {
499
1.60M
    *p_buffer_re++ = ixheaac_add32_sat(hyb_output_real_dry[0], hyb_output_real_dry[1]);
500
1.60M
    *p_buffer_im++ = ixheaac_add32_sat(hyb_output_imag_dry[0], hyb_output_imag_dry[1]);
501
502
1.60M
    hyb_output_real_dry += TSXHB;
503
1.60M
    hyb_output_imag_dry += TSXHB;
504
1.60M
  }
505
506
290k
  hyb_output_real_dry =
507
290k
      p_array_struct->hyb_output_real_dry + ts * MAX_HYBRID_BANDS + 8;
508
290k
  hyb_output_imag_dry =
509
290k
      p_array_struct->hyb_output_imag_dry + ts * MAX_HYBRID_BANDS + 8;
510
511
1.89M
  for (ch = 0; ch < loop_counter; ch++) {
512
1.60M
    *p_buffer_re++ = ixheaac_add32_sat(hyb_output_real_dry[0], hyb_output_real_dry[1]);
513
1.60M
    *p_buffer_im++ = ixheaac_add32_sat(hyb_output_imag_dry[0], hyb_output_imag_dry[1]);
514
515
1.60M
    hyb_output_real_dry += TSXHB;
516
1.60M
    hyb_output_imag_dry += TSXHB;
517
1.60M
  }
518
519
290k
  p_hyb_out_dry_real =
520
290k
      p_array_struct->hyb_output_real_dry + ts * MAX_HYBRID_BANDS + 10;
521
290k
  p_hyb_out_dry_imag =
522
290k
      p_array_struct->hyb_output_imag_dry + ts * MAX_HYBRID_BANDS + 10;
523
524
6.67M
  for (i = 3; i < BP_SIZE; i++) {
525
6.38M
    hyb_output_real_dry = p_hyb_out_dry_real;
526
6.38M
    hyb_output_imag_dry = p_hyb_out_dry_imag;
527
528
41.7M
    for (ch = 0; ch < loop_counter; ch++) {
529
35.3M
      *p_buffer_re++ = *hyb_output_real_dry;
530
35.3M
      *p_buffer_im++ = *hyb_output_imag_dry;
531
532
35.3M
      hyb_output_real_dry += TSXHB;
533
35.3M
      hyb_output_imag_dry += TSXHB;
534
35.3M
    }
535
6.38M
    p_hyb_out_dry_real++;
536
6.38M
    p_hyb_out_dry_imag++;
537
6.38M
  }
538
539
7.25M
  for (n = 1; n < BP_SIZE; n++) {
540
6.96M
    switch (tree_config) {
541
346k
      case TREE_5151:
542
346k
        dmx_real64 =
543
346k
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
544
346k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
545
346k
                                          tp_process_table_ptr->bpxgf[n]);
546
346k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
547
346k
                                          tp_process_table_ptr->bpxgf[n]);      
548
346k
        qmf_output_real_dry++;
549
346k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
550
346k
                                          tp_process_table_ptr->bpxgf[n]);
551
346k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
552
346k
                                          tp_process_table_ptr->bpxgf[n]);
553
346k
        *dmx_real = (WORD32)(dmx_real64 >> 30);
554
346k
        dmx_real++;
555
346k
        dmx_real++;
556
557
346k
        break;
558
316k
      case TREE_5152:
559
316k
        dmx_real64 =
560
316k
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
561
316k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
562
316k
                                          tp_process_table_ptr->bpxgf[n]);
563
316k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
564
316k
                                          tp_process_table_ptr->bpxgf[n]);
565
316k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
566
316k
                                          tp_process_table_ptr->bpxgf[n]);
567
316k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
568
316k
                                          tp_process_table_ptr->bpxgf[n]);
569
316k
        *dmx_real = (WORD32)(dmx_real64 >> 30);
570
316k
        dmx_real++;
571
316k
        dmx_real++;
572
573
316k
        break;
574
355k
      case TREE_525:
575
355k
        dmx_real64 =
576
355k
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
577
355k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
578
355k
                                          tp_process_table_ptr->bpxgf[n]);
579
355k
        *dmx_real = (WORD32)(dmx_real64 >> 30);
580
355k
        dmx_real++;
581
582
355k
        dmx_real64 =
583
355k
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
584
355k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
585
355k
                                          tp_process_table_ptr->bpxgf[n]);
586
355k
        *dmx_real = (WORD32)(dmx_real64 >> 30);
587
355k
        dmx_real++;
588
589
355k
        break;
590
445k
      case TREE_7271:
591
587k
      case TREE_7272:
592
587k
        dmx_real64 =
593
587k
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
594
587k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
595
587k
                                          tp_process_table_ptr->bpxgf[n]);
596
587k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
597
587k
                                          tp_process_table_ptr->bpxgf[n]);
598
587k
        *dmx_real = (WORD32)(dmx_real64 >> 30);
599
587k
        dmx_real++;
600
601
587k
        dmx_real64 =
602
587k
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
603
587k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
604
587k
                                          tp_process_table_ptr->bpxgf[n]);
605
587k
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
606
587k
                                          tp_process_table_ptr->bpxgf[n]);
607
587k
        *dmx_real = (WORD32)(dmx_real64 >> 30);
608
587k
        dmx_real++;
609
610
587k
        break;
611
2.22M
      case TREE_7571:
612
613
2.22M
        dmx_real64 =
614
2.22M
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
615
2.22M
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
616
2.22M
                                          tp_process_table_ptr->bpxgf[n]);
617
2.22M
        qmf_output_real_dry++;
618
2.22M
        *dmx_real = (WORD32)(dmx_real64 >> 30);
619
    
620
2.22M
        dmx_real++;
621
622
2.22M
        dmx_real64 =
623
2.22M
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
624
2.22M
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
625
2.22M
                                          tp_process_table_ptr->bpxgf[n]);
626
2.22M
        *dmx_real = (WORD32)(dmx_real64 >> 30);
627
2.22M
        dmx_real++;
628
629
2.22M
        break;
630
3.13M
      case TREE_7572:
631
3.13M
        qmf_output_real_dry++;
632
3.13M
        dmx_real64 =
633
3.13M
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
634
3.13M
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
635
3.13M
                                          tp_process_table_ptr->bpxgf[n]);
636
3.13M
        qmf_output_real_dry++;
637
3.13M
        *dmx_real = (WORD32)(dmx_real64 >> 30);
638
3.13M
        dmx_real++;
639
640
3.13M
        dmx_real64 =
641
3.13M
            ixheaac_mult32x32in64(*qmf_output_real_dry++, tp_process_table_ptr->bpxgf[n]);
642
3.13M
        dmx_real64 = ixheaac_mac32x32in64(dmx_real64, *qmf_output_real_dry++,
643
3.13M
                                          tp_process_table_ptr->bpxgf[n]);
644
3.13M
        *dmx_real = (WORD32)(dmx_real64 >> 30);
645
3.13M
        dmx_real++;
646
647
3.13M
        break;
648
0
      default:
649
0
        break;
650
6.96M
    }
651
6.96M
  }
652
290k
  dmx_real -= DMX_OFFSET;
653
654
7.25M
  for (n = 1; n < BP_SIZE; n++) {
655
6.96M
    switch (tree_config) {
656
346k
      case TREE_5151:
657
346k
        dmx_imag64 =
658
346k
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
659
346k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
660
346k
                                          tp_process_table_ptr->bpxgf[n]);
661
346k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
662
346k
                                          tp_process_table_ptr->bpxgf[n]);      
663
346k
        qmf_output_imag_dry++;
664
346k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
665
346k
                                          tp_process_table_ptr->bpxgf[n]);
666
346k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
667
346k
                                          tp_process_table_ptr->bpxgf[n]);
668
346k
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
669
346k
    dmx_imag++;
670
346k
    dmx_imag++;
671
672
346k
        break;
673
316k
      case TREE_5152:
674
675
316k
        dmx_imag64 =
676
316k
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
677
316k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
678
316k
                                          tp_process_table_ptr->bpxgf[n]);
679
316k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
680
316k
                                          tp_process_table_ptr->bpxgf[n]);
681
316k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
682
316k
                                          tp_process_table_ptr->bpxgf[n]);
683
316k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
684
316k
                                          tp_process_table_ptr->bpxgf[n]);
685
316k
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
686
316k
        dmx_imag++;
687
316k
        dmx_imag++;
688
    
689
316k
        break;
690
355k
      case TREE_525:
691
355k
        dmx_imag64 =
692
355k
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
693
355k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
694
355k
                                          tp_process_table_ptr->bpxgf[n]);
695
355k
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
696
355k
        dmx_imag++;
697
698
355k
        dmx_imag64 =
699
355k
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
700
355k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
701
355k
                                          tp_process_table_ptr->bpxgf[n]);
702
355k
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
703
355k
        dmx_imag++;
704
355k
        break;
705
445k
      case TREE_7271:
706
587k
      case TREE_7272:
707
587k
        dmx_imag64 =
708
587k
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
709
587k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
710
587k
                                          tp_process_table_ptr->bpxgf[n]);
711
587k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
712
587k
                                          tp_process_table_ptr->bpxgf[n]);
713
587k
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
714
587k
        dmx_imag++;
715
716
587k
        dmx_imag64 =
717
587k
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
718
587k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
719
587k
                                          tp_process_table_ptr->bpxgf[n]);
720
587k
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
721
587k
                                          tp_process_table_ptr->bpxgf[n]);
722
587k
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
723
587k
        dmx_imag++;
724
725
587k
        break;
726
2.22M
      case TREE_7571:
727
2.22M
        dmx_imag64 =
728
2.22M
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
729
2.22M
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
730
2.22M
                                          tp_process_table_ptr->bpxgf[n]);
731
2.22M
        qmf_output_imag_dry++;
732
2.22M
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
733
    
734
2.22M
        dmx_imag++;
735
736
2.22M
        dmx_imag64 =
737
2.22M
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
738
2.22M
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
739
2.22M
                                          tp_process_table_ptr->bpxgf[n]);
740
2.22M
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
741
2.22M
        dmx_imag++;
742
743
744
2.22M
        break;
745
3.13M
      case TREE_7572:
746
3.13M
        qmf_output_imag_dry++;
747
3.13M
        dmx_imag64 =
748
3.13M
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
749
3.13M
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
750
3.13M
                                          tp_process_table_ptr->bpxgf[n]);
751
3.13M
        qmf_output_imag_dry++;
752
3.13M
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
753
3.13M
        dmx_imag++;
754
755
3.13M
        dmx_imag64 =
756
3.13M
            ixheaac_mult32x32in64(*qmf_output_imag_dry++, tp_process_table_ptr->bpxgf[n]);
757
3.13M
        dmx_imag64 = ixheaac_mac32x32in64(dmx_imag64, *qmf_output_imag_dry++,
758
3.13M
                                          tp_process_table_ptr->bpxgf[n]);
759
3.13M
        *dmx_imag = (WORD32)(dmx_imag64 >> 30);
760
3.13M
        dmx_imag++;
761
762
3.13M
        break;
763
0
      default:
764
0
        break;
765
6.96M
    }
766
6.96M
  }
767
290k
  dmx_imag -= DMX_OFFSET;
768
769
843k
  for (ch = 0; ch < min(2, num_input_channels); ch++) {
770
552k
    dry_ener[ch] = 0;
771
552k
    q_dry_ener[ch] = 15;
772
773
13.8M
    for (n = 1; n < BP_SIZE; n++) {
774
13.2M
      qtemp1 = 10;
775
13.2M
      temp_1 = ixheaacd_mps_mult32(*dmx_real, *dmx_real, &qtemp1, qtemp1);
776
13.2M
      dmx_real += 2;
777
13.2M
      dry_ener[ch] =
778
13.2M
          ixheaacd_mps_add32(dry_ener[ch], temp_1, &q_dry_ener[ch], qtemp1);
779
780
13.2M
      qtemp1 = 10;
781
13.2M
      temp_1 = ixheaacd_mps_mult32(*dmx_imag, *dmx_imag, &qtemp1, qtemp1);
782
13.2M
      dmx_imag += 2;
783
13.2M
      dry_ener[ch] =
784
13.2M
          ixheaacd_mps_add32(dry_ener[ch], temp_1, &q_dry_ener[ch], qtemp1);
785
13.2M
    }
786
552k
    dmx_real -= DMX_OFFSET_MINUS_ONE;
787
552k
    dmx_imag -= DMX_OFFSET_MINUS_ONE;
788
789
552k
    temp_1 = ixheaacd_mps_mult32_shr_15(run_dry_ener[ch], STP_LPF_COEFF1_FIX);
790
791
552k
    temp_2 = ONE_IN_Q15 - STP_LPF_COEFF1_FIX;
792
552k
    temp_2 = ixheaacd_mps_mult32_shr_15(temp_2, dry_ener[ch]);
793
794
552k
    run_dry_ener[ch] = ixheaacd_mps_add32(temp_1, temp_2, &(q_run_dry_ener[ch]),
795
552k
                                          q_dry_ener[ch]);
796
797
552k
    qtemp1 = q_old_dry_ener[ch];
798
552k
    temp_1 = ixheaacd_mps_add32(old_dry_ener[ch], ABS_THR_FIX, &qtemp1, 15);
799
552k
    ;
800
801
552k
    dry_ener[ch] = ixheaacd_mps_div_32(dry_ener[ch], temp_1, &qtemp2);
802
552k
    q_dry_ener[ch] = qtemp2 + q_dry_ener[ch] - qtemp1;
803
552k
  }
804
805
2.52M
  for (ch = 0; ch < num_output_channels; ch++) {
806
2.23M
    if (ch == i_lfe) continue;
807
1.94M
    if ((tree_config >= TREE_525) && (ch == i_c)) continue;
808
1.68M
    if ((tree_config == TREE_7571) && ((ch == i_ls) || (ch == i_rs))) continue;
809
1.49M
    if ((tree_config == TREE_7572) && ((ch == i_lf) || (ch == i_rf))) continue;
810
811
1.23M
    wet_ener[ch] = 0;
812
1.23M
    q_wet_ener[ch] = 15;
813
814
1.23M
    wet_ener[ch] = 0;
815
1.23M
    q_wet_ener[ch] = 15;
816
25.9M
    for (n = FIVE; n < BP_SIZE; n++) {
817
24.7M
      qtemp1 = 10;
818
24.7M
      temp_1 = ixheaacd_mps_mult32(*qmf_output_real_wet, *qmf_output_real_wet,
819
24.7M
                                   &qtemp1, qtemp1);
820
24.7M
      qmf_output_real_wet++;
821
822
24.7M
      qtemp2 = 10;
823
24.7M
      temp_2 = ixheaacd_mps_mult32(*qmf_output_imag_wet, *qmf_output_imag_wet,
824
24.7M
                                   &qtemp2, qtemp2);
825
24.7M
      qmf_output_imag_wet++;
826
827
24.7M
      temp_1 = ixheaacd_mps_add32(temp_1, temp_2, &qtemp1, qtemp2);
828
829
24.7M
      temp_1 = ixheaacd_mps_mult32(temp_1, tp_process_table_ptr->bp2xgf2[n],
830
24.7M
                                   &qtemp1, 57);
831
832
24.7M
      wet_ener[ch] =
833
24.7M
          ixheaacd_mps_add32(wet_ener[ch], temp_1, &q_wet_ener[ch], qtemp1);
834
24.7M
    }
835
1.23M
    temp_1 = ixheaacd_mps_mult32_shr_15(run_wet_ener[ch], STP_LPF_COEFF1_FIX);
836
837
1.23M
    temp_2 = ONE_IN_Q15 - STP_LPF_COEFF1_FIX;
838
839
1.23M
    temp_2 = ixheaacd_mps_mult32_shr_15(temp_2, wet_ener[ch]);
840
841
1.23M
    run_wet_ener[ch] =
842
1.23M
        ixheaacd_mps_add32(temp_1, temp_2, &q_run_wet_ener[ch], q_wet_ener[ch]);
843
844
1.23M
    qtemp1 = q_old_wet_ener[ch];
845
1.23M
    temp_1 = ixheaacd_mps_add32(old_wet_ener[ch], ABS_THR_FIX, &qtemp1, 15);
846
847
1.23M
    wet_ener[ch] = ixheaacd_mps_div_32(wet_ener[ch], temp_1, &qtemp2);
848
1.23M
    q_wet_ener[ch] = qtemp2 + q_wet_ener[ch] - qtemp1;
849
1.23M
  }
850
851
290k
  damp = POINT_ONE_Q15;
852
290k
  one_minus_damp = POINT_NINE_Q15;
853
290k
  switch (tree_config) {
854
14.4k
    case TREE_5151:
855
27.6k
    case TREE_5152:
856
27.6k
      if (wet_ener[i_lf] != 0) {
857
14.2k
        scale[i_lf] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_lf], &qtemp2);
858
14.2k
        q_scale[i_lf] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_lf];
859
14.2k
      } else {
860
13.3k
        temp_1 = ixheaac_norm32(dry_ener[0]);
861
13.3k
        scale[i_lf] = dry_ener[0] << temp_1;
862
13.3k
        q_scale[i_lf] = q_dry_ener[0] + temp_1 - 30;
863
13.3k
      }
864
27.6k
      scale[i_lf] = ixheaacd_mps_sqrt(scale[i_lf], &(q_scale[i_lf]), sqrt_tab);
865
866
27.6k
      if (wet_ener[i_rf] != 0) {
867
14.2k
        scale[i_rf] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_rf], &qtemp2);
868
14.2k
        q_scale[i_rf] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_rf];
869
14.2k
      } else {
870
13.3k
        temp_1 = ixheaac_norm32(dry_ener[0]);
871
13.3k
        scale[i_rf] = dry_ener[0] << temp_1;
872
13.3k
        q_scale[i_rf] = q_dry_ener[0] + temp_1 - 30;
873
13.3k
      }
874
27.6k
      scale[i_rf] = ixheaacd_mps_sqrt(scale[i_rf], &(q_scale[i_rf]), sqrt_tab);
875
876
27.6k
      if (wet_ener[i_c] != 0) {
877
10.3k
        scale[i_c] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_c], &qtemp2);
878
10.3k
        q_scale[i_c] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_c];
879
17.2k
      } else {
880
17.2k
        temp_1 = ixheaac_norm32(dry_ener[0]);
881
17.2k
        scale[i_c] = dry_ener[0] << temp_1;
882
17.2k
        q_scale[i_c] = q_dry_ener[0] + temp_1 - 30;
883
17.2k
      }
884
27.6k
      scale[i_c] = ixheaacd_mps_sqrt(scale[i_c], &(q_scale[i_c]), sqrt_tab);
885
886
27.6k
      if (wet_ener[i_ls] != 0) {
887
3.99k
        scale[i_ls] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_ls], &qtemp2);
888
3.99k
        q_scale[i_ls] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_ls];
889
23.6k
      } else {
890
23.6k
        temp_1 = ixheaac_norm32(dry_ener[0]);
891
23.6k
        scale[i_ls] = dry_ener[0] << temp_1;
892
23.6k
        q_scale[i_ls] = q_dry_ener[0] + temp_1 - 30;
893
23.6k
      }
894
27.6k
      scale[i_ls] = ixheaacd_mps_sqrt(scale[i_ls], &(q_scale[i_ls]), sqrt_tab);
895
896
27.6k
      if (wet_ener[i_rs] != 0) {
897
11.1k
        scale[i_rs] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_rs], &qtemp2);
898
11.1k
        q_scale[i_rs] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_rs];
899
16.5k
      } else {
900
16.5k
        temp_1 = ixheaac_norm32(dry_ener[0]);
901
16.5k
        scale[i_rs] = dry_ener[0] << temp_1;
902
16.5k
        q_scale[i_rs] = q_dry_ener[0] + temp_1 - 30;
903
16.5k
      }
904
27.6k
      scale[i_rs] = ixheaacd_mps_sqrt(scale[i_rs], &(q_scale[i_rs]), sqrt_tab);
905
906
193k
      for (ch = 0; ch < 6; ch++) {
907
165k
        if (ch == 3 && tree_config == 0) continue;
908
151k
        temp_1 = ixheaacd_mps_mult32_shr_15(scale[ch], one_minus_damp);
909
151k
        scale[ch] = ixheaacd_mps_add32(temp_1, damp, &(q_scale[ch]), 15);
910
151k
        scale[ch] = ixheaacd_mps_convert_to_qn(scale[ch], q_scale[ch], 15);
911
151k
        if (scale[ch] > STP_SCALE_LIMIT_FIX) scale[ch] = STP_SCALE_LIMIT_FIX;
912
151k
        if (scale[ch] < ONE_BY_STP_SCALE_LIMIT)
913
56.8k
          scale[ch] = ONE_BY_STP_SCALE_LIMIT;
914
151k
      }
915
916
27.6k
      break;
917
14.8k
    case TREE_525:
918
14.8k
      if (wet_ener[i_lf] != 0) {
919
1.17k
        scale[i_lf] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_lf], &qtemp2);
920
1.17k
        q_scale[i_lf] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_lf];
921
13.6k
      } else {
922
13.6k
        temp_1 = ixheaac_norm32(dry_ener[0]);
923
13.6k
        scale[i_lf] = dry_ener[0] << temp_1;
924
13.6k
        q_scale[i_lf] = q_dry_ener[0] + temp_1 - 30;
925
13.6k
      }
926
14.8k
      scale[i_lf] = ixheaacd_mps_sqrt(scale[i_lf], &(q_scale[i_lf]), sqrt_tab);
927
928
14.8k
      if (wet_ener[i_rf] != 0) {
929
1.56k
        scale[i_rf] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_rf], &qtemp2);
930
1.56k
        q_scale[i_rf] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_rf];
931
13.2k
      } else {
932
13.2k
        temp_1 = ixheaac_norm32(dry_ener[1]);
933
13.2k
        scale[i_rf] = dry_ener[1] << temp_1;
934
13.2k
        q_scale[i_rf] = q_dry_ener[1] + temp_1 - 30;
935
13.2k
      }
936
14.8k
      scale[i_rf] = ixheaacd_mps_sqrt(scale[i_rf], &(q_scale[i_rf]), sqrt_tab);
937
938
14.8k
      if (wet_ener[i_ls] != 0) {
939
1.04k
        scale[i_ls] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_ls], &qtemp2);
940
1.04k
        q_scale[i_ls] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_ls];
941
13.7k
      } else {
942
13.7k
        temp_1 = ixheaac_norm32(dry_ener[0]);
943
13.7k
        scale[i_ls] = dry_ener[0] << temp_1;
944
13.7k
        q_scale[i_ls] = q_dry_ener[0] + temp_1 - 30;
945
13.7k
      }
946
14.8k
      scale[i_ls] = ixheaacd_mps_sqrt(scale[i_ls], &(q_scale[i_ls]), sqrt_tab);
947
948
14.8k
      if (wet_ener[i_rs] != 0) {
949
1.44k
        scale[i_rs] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_rs], &qtemp2);
950
1.44k
        q_scale[i_rs] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_rs];
951
13.3k
      } else {
952
13.3k
        temp_1 = ixheaac_norm32(dry_ener[1]);
953
13.3k
        scale[i_rs] = dry_ener[1] << temp_1;
954
13.3k
        q_scale[i_rs] = q_dry_ener[1] + temp_1 - 30;
955
13.3k
      }
956
14.8k
      scale[i_rs] = ixheaacd_mps_sqrt(scale[i_rs], &(q_scale[i_rs]), sqrt_tab);
957
958
74.1k
      for (ch = 0; ch < 4; ch++) {
959
59.2k
        temp_1 = ixheaacd_mps_mult32_shr_15(scale[ch], one_minus_damp);
960
59.2k
        scale[ch] = ixheaacd_mps_add32(temp_1, damp, &(q_scale[ch]), 15);
961
59.2k
        scale[ch] = ixheaacd_mps_convert_to_qn(scale[ch], q_scale[ch], 15);
962
59.2k
        if (scale[ch] > STP_SCALE_LIMIT_FIX) scale[ch] = STP_SCALE_LIMIT_FIX;
963
59.2k
        if (scale[ch] < ONE_BY_STP_SCALE_LIMIT)
964
36.5k
          scale[ch] = ONE_BY_STP_SCALE_LIMIT;
965
59.2k
      }
966
14.8k
      break;
967
18.5k
    case TREE_7271:
968
24.4k
    case TREE_7272:
969
24.4k
      if (wet_ener[i_lf] != 0) {
970
2.06k
        scale[i_lf] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_lf], &qtemp2);
971
2.06k
        q_scale[i_lf] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_lf];
972
22.4k
      } else {
973
22.4k
        temp_1 = ixheaac_norm32(dry_ener[0]);
974
22.4k
        scale[i_lf] = dry_ener[0] << temp_1;
975
22.4k
        q_scale[i_lf] = q_dry_ener[0] + temp_1 - 30;
976
22.4k
      }
977
24.4k
      scale[i_lf] = ixheaacd_mps_sqrt(scale[i_lf], &(q_scale[i_lf]), sqrt_tab);
978
979
24.4k
      if (wet_ener[i_rf] != 0) {
980
1.90k
        scale[i_rf] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_rf], &qtemp2);
981
1.90k
        q_scale[i_rf] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_rf];
982
22.5k
      } else {
983
22.5k
        temp_1 = ixheaac_norm32(dry_ener[1]);
984
22.5k
        scale[i_rf] = dry_ener[1] << temp_1;
985
22.5k
        q_scale[i_rf] = q_dry_ener[1] + temp_1 - 30;
986
22.5k
      }
987
24.4k
      scale[i_rf] = ixheaacd_mps_sqrt(scale[i_rf], &(q_scale[i_rf]), sqrt_tab);
988
989
24.4k
      if (wet_ener[i_ls] != 0) {
990
1.01k
        scale[i_ls] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_ls], &qtemp2);
991
1.01k
        q_scale[i_ls] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_ls];
992
23.4k
      } else {
993
23.4k
        temp_1 = ixheaac_norm32(dry_ener[0]);
994
23.4k
        scale[i_ls] = dry_ener[0] << temp_1;
995
23.4k
        q_scale[i_ls] = q_dry_ener[0] + temp_1 - 30;
996
23.4k
      }
997
24.4k
      scale[i_ls] = ixheaacd_mps_sqrt(scale[i_ls], &(q_scale[i_ls]), sqrt_tab);
998
999
24.4k
      if (wet_ener[i_rs] != 0) {
1000
1.29k
        scale[i_rs] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_rs], &qtemp2);
1001
1.29k
        q_scale[i_rs] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_rs];
1002
23.2k
      } else {
1003
23.2k
        temp_1 = ixheaac_norm32(dry_ener[1]);
1004
23.2k
        scale[i_rs] = dry_ener[1] << temp_1;
1005
23.2k
        q_scale[i_rs] = q_dry_ener[1] + temp_1 - 30;
1006
23.2k
      }
1007
24.4k
      scale[i_rs] = ixheaacd_mps_sqrt(scale[i_rs], &(q_scale[i_rs]), sqrt_tab);
1008
1009
24.4k
      if (wet_ener[i_al] != 0) {
1010
1.62k
        scale[i_al] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_al], &qtemp2);
1011
1.62k
        q_scale[i_al] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_al];
1012
22.8k
      } else {
1013
22.8k
        temp_1 = ixheaac_norm32(dry_ener[0]);
1014
22.8k
        scale[i_al] = dry_ener[0] << temp_1;
1015
22.8k
        q_scale[i_al] = q_dry_ener[0] + temp_1 - 30;
1016
22.8k
      }
1017
24.4k
      scale[i_al] = ixheaacd_mps_sqrt(scale[i_al], &(q_scale[i_al]), sqrt_tab);
1018
1019
24.4k
      if (wet_ener[i_ar] != 0) {
1020
1.14k
        scale[i_ar] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_ar], &qtemp2);
1021
1.14k
        q_scale[i_ar] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_ar];
1022
23.3k
      } else {
1023
23.3k
        temp_1 = ixheaac_norm32(dry_ener[1]);
1024
23.3k
        scale[i_ar] = dry_ener[1] << temp_1;
1025
23.3k
        q_scale[i_ar] = q_dry_ener[1] + temp_1 - 30;
1026
23.3k
      }
1027
24.4k
      scale[i_ar] = ixheaacd_mps_sqrt(scale[i_ar], &(q_scale[i_ar]), sqrt_tab);
1028
1029
171k
      for (ch = 0; ch < 6; ch++) {
1030
146k
        temp_1 = ixheaacd_mps_mult32_shr_15(scale[ch], one_minus_damp);
1031
146k
        scale[ch] = ixheaacd_mps_add32(temp_1, damp, &(q_scale[ch]), 15);
1032
146k
        scale[ch] = ixheaacd_mps_convert_to_qn(scale[ch], q_scale[ch], 15);
1033
146k
        if (scale[ch] > STP_SCALE_LIMIT_FIX) scale[ch] = STP_SCALE_LIMIT_FIX;
1034
146k
        if (scale[ch] < ONE_BY_STP_SCALE_LIMIT)
1035
81.8k
          scale[ch] = ONE_BY_STP_SCALE_LIMIT;
1036
146k
      }
1037
1038
24.4k
      break;
1039
92.6k
    case TREE_7571:
1040
92.6k
      if (wet_ener[i_lf] != 0) {
1041
1.84k
        scale[i_lf] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_lf], &qtemp2);
1042
1.84k
        q_scale[i_lf] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_lf];
1043
90.7k
      } else {
1044
90.7k
        temp_1 = ixheaac_norm32(dry_ener[0]);
1045
90.7k
        scale[i_lf] = dry_ener[0] << temp_1;
1046
90.7k
        q_scale[i_lf] = q_dry_ener[0] + temp_1 - 30;
1047
90.7k
      }
1048
92.6k
      scale[i_lf] = ixheaacd_mps_sqrt(scale[i_lf], &(q_scale[i_lf]), sqrt_tab);
1049
1050
92.6k
      if (wet_ener[i_rf] != 0) {
1051
0
        scale[i_rf] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_rf], &qtemp2);
1052
0
        q_scale[i_rf] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_rf];
1053
92.6k
      } else {
1054
92.6k
        temp_1 = ixheaac_norm32(dry_ener[1]);
1055
92.6k
        scale[i_rf] = dry_ener[1] << temp_1;
1056
92.6k
        q_scale[i_rf] = q_dry_ener[1] + temp_1 - 30;
1057
92.6k
      }
1058
92.6k
      scale[i_rf] = ixheaacd_mps_sqrt(scale[i_rf], &(q_scale[i_rf]), sqrt_tab);
1059
1060
92.6k
      if (wet_ener[i_al] != 0) {
1061
1.81k
        scale[i_al] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_al], &qtemp2);
1062
1.81k
        q_scale[i_al] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_al];
1063
90.8k
      } else {
1064
90.8k
        temp_1 = ixheaac_norm32(dry_ener[0]);
1065
90.8k
        scale[i_al] = dry_ener[0] << temp_1;
1066
90.8k
        q_scale[i_al] = q_dry_ener[0] + temp_1 - 30;
1067
90.8k
      }
1068
92.6k
      scale[i_al] = ixheaacd_mps_sqrt(scale[i_al], &(q_scale[i_al]), sqrt_tab);
1069
1070
92.6k
      if (wet_ener[i_ar] != 0) {
1071
2.20k
        scale[i_ar] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_ar], &qtemp2);
1072
2.20k
        q_scale[i_ar] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_ar];
1073
90.4k
      } else {
1074
90.4k
        temp_1 = ixheaac_norm32(dry_ener[1]);
1075
90.4k
        scale[i_ar] = dry_ener[1] << temp_1;
1076
90.4k
        q_scale[i_ar] = q_dry_ener[1] + temp_1 - 30;
1077
90.4k
      }
1078
92.6k
      scale[i_ar] = ixheaacd_mps_sqrt(scale[i_ar], &(q_scale[i_ar]), sqrt_tab);
1079
555k
      for (ch = 0; ch < FIVE; ch++) {
1080
463k
        if (ch == 2) continue;
1081
370k
        temp_1 = ixheaacd_mps_mult32_shr_15(scale[ch], one_minus_damp);
1082
370k
        scale[ch] = ixheaacd_mps_add32(temp_1, damp, &(q_scale[ch]), 15);
1083
370k
        scale[ch] = ixheaacd_mps_convert_to_qn(scale[ch], q_scale[ch], 15);
1084
370k
        if (scale[ch] > STP_SCALE_LIMIT_FIX) scale[ch] = STP_SCALE_LIMIT_FIX;
1085
370k
        if (scale[ch] < ONE_BY_STP_SCALE_LIMIT)
1086
43.6k
          scale[ch] = ONE_BY_STP_SCALE_LIMIT;
1087
370k
      }
1088
1089
92.6k
      break;
1090
130k
    case TREE_7572:
1091
130k
      if (wet_ener[i_ls] != 0) {
1092
5.75k
        scale[i_ls] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_ls], &qtemp2);
1093
5.75k
        q_scale[i_ls] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_ls];
1094
124k
      } else {
1095
124k
        temp_1 = ixheaac_norm32(dry_ener[0]);
1096
124k
        scale[i_ls] = dry_ener[0] << temp_1;
1097
124k
        q_scale[i_ls] = q_dry_ener[0] + temp_1 - 30;
1098
124k
      }
1099
130k
      scale[i_ls] = ixheaacd_mps_sqrt(scale[i_ls], &(q_scale[i_ls]), sqrt_tab);
1100
1101
130k
      if (wet_ener[i_rs] != 0) {
1102
0
        scale[i_rs] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_rs], &qtemp2);
1103
0
        q_scale[i_rs] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_rs];
1104
130k
      } else {
1105
130k
        temp_1 = ixheaac_norm32(dry_ener[1]);
1106
130k
        scale[i_rs] = dry_ener[1] << temp_1;
1107
130k
        q_scale[i_rs] = q_dry_ener[1] + temp_1 - 30;
1108
130k
      }
1109
130k
      scale[i_rs] = ixheaacd_mps_sqrt(scale[i_rs], &(q_scale[i_rs]), sqrt_tab);
1110
1111
130k
      if (wet_ener[i_al] != 0) {
1112
0
        scale[i_al] = ixheaacd_mps_div_32(dry_ener[0], wet_ener[i_al], &qtemp2);
1113
0
        q_scale[i_al] = qtemp2 + q_dry_ener[0] - q_wet_ener[i_al];
1114
130k
      } else {
1115
130k
        temp_1 = ixheaac_norm32(dry_ener[0]);
1116
130k
        scale[i_al] = dry_ener[0] << temp_1;
1117
130k
        q_scale[i_al] = q_dry_ener[0] + temp_1 - 30;
1118
130k
      }
1119
130k
      scale[i_al] = ixheaacd_mps_sqrt(scale[i_al], &(q_scale[i_al]), sqrt_tab);
1120
1121
130k
      if (wet_ener[i_ar] != 0) {
1122
5.76k
        scale[i_ar] = ixheaacd_mps_div_32(dry_ener[1], wet_ener[i_ar], &qtemp2);
1123
5.76k
        q_scale[i_ar] = qtemp2 + q_dry_ener[1] - q_wet_ener[i_ar];
1124
124k
      } else {
1125
124k
        temp_1 = ixheaac_norm32(dry_ener[1]);
1126
124k
        scale[i_ar] = dry_ener[1] << temp_1;
1127
124k
        q_scale[i_ar] = q_dry_ener[1] + temp_1 - 30;
1128
124k
      }
1129
130k
      scale[i_ar] = ixheaacd_mps_sqrt(scale[i_ar], &(q_scale[i_ar]), sqrt_tab);
1130
914k
      for (ch = 0; ch < 6; ch++) {
1131
783k
        if (ch == 3 || ch == 0) continue;
1132
522k
        temp_1 = ixheaacd_mps_mult32_shr_15(scale[ch], one_minus_damp);
1133
522k
        scale[ch] = ixheaacd_mps_add32(temp_1, damp, &(q_scale[ch]), 15);
1134
522k
        scale[ch] = ixheaacd_mps_convert_to_qn(scale[ch], q_scale[ch], 15);
1135
522k
        if (scale[ch] > STP_SCALE_LIMIT_FIX) scale[ch] = STP_SCALE_LIMIT_FIX;
1136
522k
        if (scale[ch] < ONE_BY_STP_SCALE_LIMIT)
1137
64.0k
          scale[ch] = ONE_BY_STP_SCALE_LIMIT;
1138
522k
      }
1139
1140
130k
      break;
1141
0
    default:
1142
0
      break;
1143
290k
  }
1144
1145
2.52M
  for (ch = 0; ch < num_output_channels; ch++) {
1146
2.23M
    temp_1 = ixheaacd_mps_mult32_shr_15(STP_LPF_COEFF2_FIX, scale[ch]);
1147
2.23M
    temp_2 =
1148
2.23M
        ixheaacd_mps_mult32_shr_15(ONE_MINUS_STP_LPF_COEFF2, prev_tp_scale[ch]);
1149
2.23M
    scale[ch] = ixheaac_add32_sat(temp_1, temp_2);
1150
2.23M
    prev_tp_scale[ch] = scale[ch];
1151
2.23M
  }
1152
1153
290k
  offset = ts * MAX_HYBRID_BANDS;
1154
290k
  p_buffer_real = p_array_struct->buf_real + offset + HYBRID_BAND_BORDER;
1155
290k
  p_buffer_imag = p_array_struct->buf_imag + offset + HYBRID_BAND_BORDER;
1156
1157
290k
  p_buf_real = p_array_struct->buffer_real + offset + FIVE;
1158
290k
  p_buf_imag = p_array_struct->buffer_imag + offset + FIVE;
1159
1160
290k
  p_hyb_out_dry_real = p_array_struct->hyb_output_real_dry +
1161
290k
                       ts * MAX_HYBRID_BANDS + HYBRID_BAND_BORDER;
1162
290k
  p_hyb_out_dry_imag = p_array_struct->hyb_output_imag_dry +
1163
290k
                       ts * MAX_HYBRID_BANDS + HYBRID_BAND_BORDER;
1164
1165
2.52M
  for (ch = 0; ch < num_output_channels; ch++) {
1166
2.23M
    no_scaling = 1;
1167
1168
2.23M
    ixheaacd_get_ch_idx(pstr_mps_state, ch, &i);
1169
2.23M
    if (i != -1) {
1170
1.23M
      no_scaling = !pstr_mps_state->aux_struct->temp_shape_enable_channel_stp[i];
1171
1.23M
    }
1172
2.23M
    p_buffer_re = p_buffer_real;
1173
2.23M
    p_buffer_im = p_buffer_imag;
1174
1175
2.23M
    p_buf_re = p_buf_real;
1176
2.23M
    p_buf_im = p_buf_imag;
1177
1178
2.23M
    hyb_output_real_dry = p_hyb_out_dry_real;
1179
2.23M
    hyb_output_imag_dry = p_hyb_out_dry_imag;
1180
1181
2.23M
    if (no_scaling == 1) {
1182
10.6M
      for (n = HYBRID_BAND_BORDER; n < (HP_SIZE + QMF_TO_HYB_OFFSET); n++) {
1183
8.54M
        *p_buf_re++ = ixheaac_add32_sat(*hyb_output_real_dry++, *p_buffer_re++);
1184
1185
8.54M
        *p_buf_im++ = ixheaac_add32_sat(*hyb_output_imag_dry++, *p_buffer_im++);
1186
8.54M
      }
1187
1188
62.6M
      for (; n < hybrid_bands; n++, k++) {
1189
60.5M
        temp = (no_scaling ? ONE_IN_Q15 : scale[ch]);
1190
1191
60.5M
        *p_buf_re++ = ixheaac_add32_sat(*hyb_output_real_dry++, *p_buffer_re++);
1192
1193
60.5M
        *p_buf_im++ = ixheaac_add32_sat(*hyb_output_imag_dry++, *p_buffer_im++);
1194
60.5M
      }
1195
2.13M
    } else {
1196
502k
      for (n = HYBRID_BAND_BORDER; n < (HP_SIZE + QMF_TO_HYB_OFFSET); n++) {
1197
401k
        temp = ixheaacd_mps_mult32_shr_30(
1198
401k
            scale[ch], tp_process_table_ptr->bp[n - QMF_TO_HYB_OFFSET]);
1199
1200
401k
        *p_buf_re++ = ixheaac_add32_sat(*hyb_output_real_dry++, 
1201
401k
                  ixheaacd_mps_mult32_shr_15(temp, *p_buffer_re));
1202
401k
        p_buffer_re++;
1203
1204
401k
        *p_buf_im++ = ixheaac_add32_sat(*hyb_output_imag_dry++, 
1205
401k
                      ixheaacd_mps_mult32_shr_15(temp, *p_buffer_im));
1206
401k
        p_buffer_im++;
1207
401k
      }
1208
1209
2.73M
      for (; n < hybrid_bands; n++, k++) {
1210
2.63M
        temp = (no_scaling ? ONE_IN_Q15 : scale[ch]);
1211
1212
2.63M
        *p_buf_re++ = ixheaac_add32_sat(*hyb_output_real_dry++, 
1213
2.63M
                      ixheaacd_mps_mult32_shr_15(temp, *p_buffer_re));
1214
2.63M
        p_buffer_re++;
1215
1216
2.63M
        *p_buf_im++ = ixheaac_add32_sat(*hyb_output_imag_dry++, 
1217
2.63M
                      ixheaacd_mps_mult32_shr_15(temp, *p_buffer_im));
1218
2.63M
        p_buffer_im++;
1219
2.63M
      }
1220
100k
    }
1221
1222
2.23M
    p_buffer_real += TSXHB;
1223
2.23M
    p_buffer_imag += TSXHB;
1224
1225
2.23M
    p_buf_real += TSXHB;
1226
2.23M
    p_buf_imag += TSXHB;
1227
1228
2.23M
    p_hyb_out_dry_real += TSXHB;
1229
2.23M
    p_hyb_out_dry_imag += TSXHB;
1230
2.23M
  }
1231
1232
290k
  return;
1233
290k
}
1234
1235
21.7k
VOID ixheaacd_tp_process(ia_heaac_mps_state_struct *pstr_mps_state) {
1236
21.7k
  WORD32 ch, ts, hyb, n;
1237
21.7k
  WORD32 temp, temp_1, temp_2;
1238
21.7k
  ia_mps_dec_synthesis_interface *syn = pstr_mps_state->syn;
1239
21.7k
  WORD32 *hyb_output_real_wet, *hyb_output_imag_wet;
1240
21.7k
  WORD32 *hyb_output_real_dry, *hyb_output_imag_dry;
1241
1242
21.7k
  WORD32 *p_buffer_real, *p_buffer_imag, *p_buffer_re, *p_buffer_im;
1243
21.7k
  WORD32 *p_buf_real, *p_buf_imag, *p_buf_re, *p_buf_im;
1244
21.7k
  WORD32 *buf_real, *buf_imag;
1245
1246
21.7k
  WORD32 num_output_channels = pstr_mps_state->num_output_channels;
1247
21.7k
  WORD32 time_slots = pstr_mps_state->time_slots;
1248
21.7k
  WORD32 qmf_bands = pstr_mps_state->qmf_bands;
1249
21.7k
  WORD32 num_output_channels_at = pstr_mps_state->num_output_channels_at;
1250
21.7k
  WORD32 tree_config = pstr_mps_state->tree_config;
1251
21.7k
  WORD32 up_mix_type = pstr_mps_state->up_mix_type;
1252
21.7k
  WORD32 tp_hyb_band_border = pstr_mps_state->tp_hyb_band_border;
1253
1254
21.7k
  ia_mps_dec_reuse_array_struct *p_array_struct = pstr_mps_state->array_struct;
1255
21.7k
  WORD32 *p_hyb_out_dry_real = p_array_struct->hyb_output_real_dry;
1256
21.7k
  WORD32 *p_hyb_out_dry_imag = p_array_struct->hyb_output_imag_dry;
1257
21.7k
  WORD32 *p_hyb_out_dry_re, *p_hyb_out_dry_im;
1258
1259
21.7k
  WORD32 *p_time_out;
1260
1261
21.7k
  p_buffer_real = p_array_struct->buf_real;
1262
21.7k
  p_buffer_imag = p_array_struct->buf_imag;
1263
1264
21.7k
  p_buf_real = p_array_struct->buffer_real;
1265
21.7k
  p_buf_imag = p_array_struct->buffer_imag;
1266
1267
21.7k
  if (!pstr_mps_state->scaling_enable) {
1268
95.3k
    for (ch = 0; ch < num_output_channels; ch++) {
1269
84.5k
      p_buffer_re = p_buffer_real;
1270
84.5k
      p_buffer_im = p_buffer_imag;
1271
1272
84.5k
      p_buf_re = p_buf_real;
1273
84.5k
      p_buf_im = p_buf_imag;
1274
1275
84.5k
      p_hyb_out_dry_re = p_hyb_out_dry_real;
1276
84.5k
      p_hyb_out_dry_im = p_hyb_out_dry_imag;
1277
1278
2.39M
      for (ts = 0; ts < time_slots; ts++) {
1279
2.31M
        hyb_output_real_wet = p_buffer_re;
1280
2.31M
        hyb_output_imag_wet = p_buffer_im;
1281
2.31M
        hyb_output_real_dry = p_hyb_out_dry_re;
1282
2.31M
        hyb_output_imag_dry = p_hyb_out_dry_im;
1283
1284
2.31M
        buf_real = p_buf_re;
1285
2.31M
        buf_imag = p_buf_im;
1286
1287
2.31M
        temp_1 = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1288
2.31M
        temp_2 = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1289
13.8M
        for (n = 1; n < 6; n++) {
1290
11.5M
          temp_1 = ixheaac_add32_sat(temp_1, *hyb_output_real_dry++);
1291
11.5M
          temp_1 = ixheaac_add32_sat(temp_1, *hyb_output_real_wet++);
1292
11.5M
          temp_2 = ixheaac_add32_sat(temp_2, *hyb_output_imag_dry++);
1293
11.5M
          temp_2 = ixheaac_add32_sat(temp_2, *hyb_output_imag_wet++);
1294
11.5M
        }
1295
1296
2.31M
        *buf_real++ = temp_1;
1297
2.31M
        *buf_imag++ = temp_2;
1298
1299
2.31M
        temp = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1300
2.31M
        *buf_real = ixheaac_add32_sat(temp, *hyb_output_real_dry++);
1301
2.31M
        *buf_real = ixheaac_add32_sat(*buf_real, *hyb_output_real_wet++);
1302
2.31M
        temp = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1303
2.31M
        *buf_imag = ixheaac_add32_sat(temp, *hyb_output_imag_dry++);
1304
2.31M
        *buf_imag = ixheaac_add32_sat(*buf_imag, *hyb_output_imag_wet++);
1305
1306
2.31M
        buf_real++;
1307
2.31M
        buf_imag++;
1308
1309
2.31M
        temp = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1310
2.31M
        *buf_real = ixheaac_add32_sat(temp, *hyb_output_real_dry++);
1311
2.31M
        *buf_real = ixheaac_add32_sat(*buf_real, *hyb_output_real_wet++);
1312
2.31M
        temp = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1313
2.31M
        *buf_imag = ixheaac_add32_sat(temp, *hyb_output_imag_dry++);
1314
2.31M
        *buf_imag = ixheaac_add32_sat(*buf_imag, *hyb_output_imag_wet++);
1315
1316
2.31M
        buf_real++;
1317
2.31M
        buf_imag++;
1318
1319
142M
        for (n = 0; n < qmf_bands; n++) {
1320
140M
          *buf_real++ = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1321
140M
          *buf_imag++ = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1322
140M
        }
1323
1324
2.31M
        p_buffer_re += MAX_HYBRID_BANDS;
1325
2.31M
        p_buffer_im += MAX_HYBRID_BANDS;
1326
1327
2.31M
        p_buf_re += MAX_HYBRID_BANDS;
1328
2.31M
        p_buf_im += MAX_HYBRID_BANDS;
1329
1330
2.31M
        p_hyb_out_dry_re += MAX_HYBRID_BANDS;
1331
2.31M
        p_hyb_out_dry_im += MAX_HYBRID_BANDS;
1332
2.31M
      }
1333
84.5k
      p_buffer_real += TSXHB;
1334
84.5k
      p_buffer_imag += TSXHB;
1335
1336
84.5k
      p_buf_real += TSXHB;
1337
84.5k
      p_buf_imag += TSXHB;
1338
1339
84.5k
      p_hyb_out_dry_real += TSXHB;
1340
84.5k
      p_hyb_out_dry_imag += TSXHB;
1341
84.5k
    }
1342
10.9k
  } else {
1343
95.2k
    for (ch = 0; ch < num_output_channels; ch++) {
1344
84.2k
      p_buffer_re = p_buffer_real;
1345
84.2k
      p_buffer_im = p_buffer_imag;
1346
1347
84.2k
      p_buf_re = p_buf_real;
1348
84.2k
      p_buf_im = p_buf_imag;
1349
1350
84.2k
      p_hyb_out_dry_re = p_hyb_out_dry_real;
1351
84.2k
      p_hyb_out_dry_im = p_hyb_out_dry_imag;
1352
1353
2.32M
      for (ts = 0; ts < time_slots; ts++) {
1354
2.23M
        hyb_output_real_wet = p_buffer_re;
1355
2.23M
        hyb_output_imag_wet = p_buffer_im;
1356
2.23M
        hyb_output_real_dry = p_hyb_out_dry_re;
1357
2.23M
        hyb_output_imag_dry = p_hyb_out_dry_im;
1358
1359
2.23M
        buf_real = p_buf_re;
1360
2.23M
        buf_imag = p_buf_im;
1361
1362
2.23M
        temp_1 = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1363
2.23M
        temp_2 = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1364
13.4M
        for (n = 1; n < 6; n++) {
1365
11.1M
          temp_1 = ixheaac_add32_sat(temp_1, *hyb_output_real_dry++);
1366
11.1M
          temp_1 = ixheaac_add32_sat(temp_1, *hyb_output_real_wet++);
1367
11.1M
          temp_2 = ixheaac_add32_sat(temp_2, *hyb_output_imag_dry++);
1368
11.1M
          temp_2 = ixheaac_add32_sat(temp_2, *hyb_output_imag_wet++);
1369
11.1M
        }
1370
1371
2.23M
        *buf_real++ = temp_1;
1372
2.23M
        *buf_imag++ = temp_2;
1373
1374
2.23M
        *buf_real = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1375
2.23M
        *buf_real = ixheaac_add32_sat(*buf_real, *hyb_output_real_dry++);
1376
2.23M
        *buf_real = ixheaac_add32_sat(*buf_real, *hyb_output_real_wet++);
1377
1378
2.23M
        *buf_imag = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1379
2.23M
        *buf_imag = ixheaac_add32_sat(*buf_imag, *hyb_output_imag_dry++);
1380
2.23M
        *buf_imag = ixheaac_add32_sat(*buf_imag, *hyb_output_imag_wet++);
1381
1382
2.23M
        buf_real++;
1383
2.23M
        buf_imag++;
1384
1385
2.23M
        *buf_real = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1386
2.23M
        *buf_real = ixheaac_add32_sat(*buf_real, *hyb_output_real_dry++);
1387
2.23M
        *buf_real = ixheaac_add32_sat(*buf_real, *hyb_output_real_wet++);
1388
2.23M
        *buf_imag = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1389
2.23M
        *buf_imag = ixheaac_add32_sat(*buf_imag, *hyb_output_imag_dry++);
1390
2.23M
        *buf_imag = ixheaac_add32_sat(*buf_imag, *hyb_output_imag_wet++);
1391
1392
2.23M
        buf_real++;
1393
2.23M
        buf_imag++;
1394
1395
6.71M
        for (hyb = 3; hyb < tp_hyb_band_border - QMF_TO_HYB_OFFSET; hyb++) {
1396
4.47M
          *buf_real++ = ixheaac_add32_sat(*hyb_output_real_dry++, *hyb_output_real_wet++);
1397
4.47M
          *buf_imag++ = ixheaac_add32_sat(*hyb_output_imag_dry++, *hyb_output_imag_wet++);
1398
4.47M
        }
1399
2.23M
        p_buffer_re += MAX_HYBRID_BANDS;
1400
2.23M
        p_buffer_im += MAX_HYBRID_BANDS;
1401
1402
2.23M
        p_buf_re += MAX_HYBRID_BANDS;
1403
2.23M
        p_buf_im += MAX_HYBRID_BANDS;
1404
1405
2.23M
        p_hyb_out_dry_re += MAX_HYBRID_BANDS;
1406
2.23M
        p_hyb_out_dry_im += MAX_HYBRID_BANDS;
1407
2.23M
      }
1408
84.2k
      p_buffer_real += TSXHB;
1409
84.2k
      p_buffer_imag += TSXHB;
1410
1411
84.2k
      p_buf_real += TSXHB;
1412
84.2k
      p_buf_imag += TSXHB;
1413
1414
84.2k
      p_hyb_out_dry_real += TSXHB;
1415
84.2k
      p_hyb_out_dry_imag += TSXHB;
1416
84.2k
    }
1417
1418
301k
    for (ts = 0; ts < time_slots; ts++) {
1419
290k
      ixheaacd_subband_tp(pstr_mps_state, ts);
1420
290k
    }
1421
10.9k
  }
1422
1423
21.7k
  if ((!pstr_mps_state->bs_config.arbitrary_tree) &&
1424
21.7k
      ((up_mix_type != 2) && (up_mix_type != 3))) {
1425
21.7k
    WORD32 *time_out_5xxx =
1426
21.7k
        pstr_mps_state->ia_mps_dec_mps_table.tp_process_table_ptr->time_out_idx_5xxx;
1427
21.7k
    WORD32 *time_out_7xxx =
1428
21.7k
        pstr_mps_state->ia_mps_dec_mps_table.tp_process_table_ptr->time_out_idx_7xxx;
1429
1430
21.7k
    p_buf_real = p_array_struct->buffer_real;
1431
21.7k
    p_buf_imag = p_array_struct->buffer_imag;
1432
1433
190k
    for (ch = 0; ch < num_output_channels_at; ch++) {
1434
168k
      WORD32 tempch = 0;
1435
168k
      switch (tree_config) {
1436
4.12k
        case TREE_5151:
1437
4.12k
          tempch = ch;
1438
4.12k
          break;
1439
3.43k
        case TREE_5152:
1440
11.5k
        case TREE_525:
1441
11.5k
          tempch = time_out_5xxx[ch];
1442
11.5k
          break;
1443
10.4k
        case TREE_7271:
1444
13.2k
        case TREE_7272:
1445
44.3k
        case TREE_7571:
1446
153k
        case TREE_7572:
1447
153k
          tempch = time_out_7xxx[ch];
1448
153k
          break;
1449
0
        default:
1450
0
          break;
1451
168k
      }
1452
168k
      p_time_out = p_array_struct->time_out + tempch * QBXTS;
1453
168k
      syn->syn_filter_bank(&pstr_mps_state->syn_qmf_bank, p_buf_real, p_buf_imag,
1454
168k
                           p_time_out, ch, qmf_bands, time_slots,
1455
168k
                           pstr_mps_state->ia_mps_dec_mps_table.qmf_table_ptr);
1456
1457
168k
      p_buf_real += TSXHB;
1458
168k
      p_buf_imag += TSXHB;
1459
168k
    }
1460
21.7k
  } else {
1461
7
    p_time_out = p_array_struct->time_out;
1462
52
    for (ch = 0; ch < num_output_channels_at; ch++) {
1463
45
      syn->syn_filter_bank(&pstr_mps_state->syn_qmf_bank, p_buf_real, p_buf_imag,
1464
45
                           p_time_out, ch, qmf_bands, time_slots,
1465
45
                           pstr_mps_state->ia_mps_dec_mps_table.qmf_table_ptr);
1466
1467
45
      p_buf_real += TSXHB;
1468
45
      p_buf_imag += TSXHB;
1469
45
      p_time_out += QBXTS;
1470
45
    }
1471
7
  }
1472
1473
21.7k
  return;
1474
21.7k
}