Coverage Report

Created: 2025-11-24 06:48

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libxaac/decoder/ixheaacd_mps_initfuncs.c
Line
Count
Source
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2023 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 "ixheaac_type_def.h"
22
#include "ixheaacd_mps_struct_def.h"
23
#include "ixheaacd_mps_res_rom.h"
24
#include "ixheaacd_mps_aac_struct.h"
25
#include "ixheaacd_sbr_common.h"
26
#include "ixheaac_constants.h"
27
#include "ixheaacd_bitbuffer.h"
28
#include "ixheaacd_aac_rom.h"
29
#include "ixheaacd_error_codes.h"
30
#include "ixheaacd_pulsedata.h"
31
#include "ixheaacd_pns.h"
32
#include "ixheaacd_drc_data_struct.h"
33
#include "ixheaacd_cnst.h"
34
#include "ixheaacd_ec_defines.h"
35
#include "ixheaacd_ec_struct_def.h"
36
#include "ixheaacd_channelinfo.h"
37
#include "ixheaacd_sbrdecoder.h"
38
#include "ixheaacd_common_rom.h"
39
#include "ixheaacd_sbrdecsettings.h"
40
#include "ixheaacd_sbr_scale.h"
41
#include "ixheaacd_env_extr_part.h"
42
#include "ixheaacd_sbr_rom.h"
43
#include "ixheaacd_lpp_tran.h"
44
#include "ixheaacd_hybrid.h"
45
#include "ixheaacd_ps_dec.h"
46
#include "ixheaacd_env_extr.h"
47
#include "ixheaacd_audioobjtypes.h"
48
#include "ixheaacd_memory_standards.h"
49
#include "ixheaacd_latmdemux.h"
50
#include "ixheaacd_aacdec.h"
51
#include "ixheaacd_mps_polyphase.h"
52
#include "ixheaacd_config.h"
53
#include "ixheaacd_qmf_dec.h"
54
#include "ixheaacd_mps_dec.h"
55
#include "ixheaacd_struct_def.h"
56
#include "ixheaacd_mps_decor.h"
57
#include "ixheaacd_mps_bitdec.h"
58
#include "ixheaacd_mps_mdct_2_qmf.h"
59
#include "ixheaacd_mps_tonality.h"
60
#include "ixheaacd_mps_reshape_bb_env.h"
61
#include "ixheaacd_mps_hybfilter.h"
62
#include "ixheaacd_mps_blind.h"
63
#include "ixheaacd_mps_macro_def.h"
64
#include "ixheaacd_mps_tables.h"
65
66
1.08M
#define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3)
67
68
#define ALIGN_SIZE32(x) ((((x) + 3) >> 2) << 2)
69
70
42.3k
WORD32 ixheaacd_getsize_mps_persistent() {
71
42.3k
  return (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_persistent_mem), BYTE_ALIGN_8));
72
42.3k
}
73
74
42.3k
static WORD32 ixheaacd_calc_decorr_size() {
75
42.3k
  WORD32 matrix_alloc_size, decorr_filter_size, num_den_size;
76
42.3k
  WORD32 fraction_alloc_size, ducker_create_size, decor_dec_size;
77
42.3k
  WORD32 state_alloc_size, alloc_size, dec_type = 0;
78
79
42.3k
  matrix_alloc_size =
80
42.3k
      MAX_NO_DECORR_CHANNELS * 2 *
81
42.3k
      (MAX_HYBRID_BANDS *
82
42.3k
           IXHEAAC_GET_SIZE_ALIGNED((MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY) * sizeof(WORD32),
83
42.3k
                                    BYTE_ALIGN_8) +
84
42.3k
       IXHEAAC_GET_SIZE_ALIGNED(MAX_HYBRID_BANDS * sizeof(WORD32 *), BYTE_ALIGN_8));
85
42.3k
  decorr_filter_size =
86
42.3k
      MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS *
87
42.3k
      IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_decorr_filter_instance_struct), BYTE_ALIGN_8);
88
42.3k
  num_den_size = MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS *
89
42.3k
                 IXHEAAC_GET_SIZE_ALIGNED(MAX_NUM_DEN_LENGTH * sizeof(WORD32), BYTE_ALIGN_8);
90
91
42.3k
  if (dec_type == 1)
92
0
    fraction_alloc_size = 4 * num_den_size;
93
42.3k
  else
94
42.3k
    fraction_alloc_size = 2 * num_den_size;
95
96
42.3k
  state_alloc_size = MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS * 2 *
97
42.3k
                     IXHEAAC_GET_SIZE_ALIGNED(MAX_NUM_DEN_LENGTH * sizeof(WORD32), BYTE_ALIGN_8);
98
99
42.3k
  ducker_create_size =
100
42.3k
      MAX_NO_DECORR_CHANNELS *
101
42.3k
      (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_ducker_interface), BYTE_ALIGN_8) +
102
42.3k
       IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_duck_instance_struct), BYTE_ALIGN_8));
103
42.3k
  decor_dec_size = MAX_NO_DECORR_CHANNELS *
104
42.3k
                   IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_decorr_dec_struct), BYTE_ALIGN_8);
105
106
42.3k
  alloc_size = matrix_alloc_size + decorr_filter_size + fraction_alloc_size + ducker_create_size +
107
42.3k
               decor_dec_size + state_alloc_size;
108
109
42.3k
  return (2 * alloc_size);
110
42.3k
}
111
112
21.1k
WORD32 ixheaacd_mps_persistent_buffer_sizes() {
113
21.1k
  WORD32 buffer_size;
114
115
21.1k
  buffer_size = ixheaacd_getsize_mps_persistent();
116
117
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(PREV_GAINAT, BYTE_ALIGN_8);
118
119
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(ARBDMX_ALPHA, BYTE_ALIGN_8);
120
121
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8);
122
123
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8);
124
125
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8);
126
127
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8);
128
129
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8);
130
131
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8);
132
133
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8);
134
135
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8);
136
137
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(ANA_BUF_SIZE, BYTE_ALIGN_8);
138
139
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(SYN_BUF_SIZE, BYTE_ALIGN_8);
140
141
21.1k
  buffer_size += ixheaacd_calc_decorr_size();
142
143
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(HYB_FILTER_STATE_SIZE, BYTE_ALIGN_8);
144
145
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(TONALITY_STATE_SIZE, BYTE_ALIGN_8);
146
147
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(SMOOTHING_STATE_SIZE, BYTE_ALIGN_8);
148
149
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(RESHAPE_STATE_SIZE, BYTE_ALIGN_8);
150
151
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(SUBBAND_TP_SIZE, BYTE_ALIGN_8);
152
153
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(BLIND_DECODER_SIZE, BYTE_ALIGN_8);
154
155
21.1k
  buffer_size +=
156
21.1k
      IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_spatial_bs_frame_struct), BYTE_ALIGN_8);
157
158
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(ARRAY_STRUCT_SIZE, BYTE_ALIGN_8);
159
160
  // Add buffer sizes for pstr_mps_state->array_struct
161
  // res_mdct
162
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(MDCT_RES_BUF_SIZE, BYTE_ALIGN_8);
163
  // qmf_residual_real
164
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_RES_BUF_SIZE, BYTE_ALIGN_8);
165
  // qmf_residual_imag
166
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_RES_BUF_SIZE, BYTE_ALIGN_8);
167
  // m_qmf_real
168
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_BUF_SIZE, BYTE_ALIGN_8);
169
  // m_qmf_imag
170
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_BUF_SIZE, BYTE_ALIGN_8);
171
  // buf_real
172
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(BUF_SIZE, BYTE_ALIGN_8);
173
  // buf_imag
174
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(BUF_SIZE, BYTE_ALIGN_8);
175
  // aux_struct
176
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_auxilary_struct), BYTE_ALIGN_8);
177
  // aux_struct->m2_param
178
21.1k
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_m2_param_struct), BYTE_ALIGN_8);
179
180
21.1k
  return buffer_size;
181
21.1k
}
182
183
VOID ixheaacd_set_mps_persistent_buffers(ia_heaac_mps_state_struct *pstr_mps_state,
184
                                         WORD32 *persistent_used, WORD32 num_channel,
185
21.1k
                                         VOID *persistent_mem) {
186
21.1k
  WORD32 used_persistent = *persistent_used;
187
188
21.1k
  struct ia_mps_persistent_mem *mps_persistent_mem = &(pstr_mps_state->mps_persistent_mem);
189
190
21.1k
  WORD32 decorr_size;
191
192
21.1k
  num_channel = max(2, num_channel);
193
194
21.1k
  mps_persistent_mem->prev_gain_at = (WORD32 *)((WORD8 *)persistent_mem);
195
196
21.1k
  memset(mps_persistent_mem->prev_gain_at, 0,
197
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(PREV_GAINAT, BYTE_ALIGN_8));
198
199
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(PREV_GAINAT, BYTE_ALIGN_8);
200
201
21.1k
  mps_persistent_mem->arbdmx_alpha_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
202
21.1k
  memset(mps_persistent_mem->arbdmx_alpha_prev, 0,
203
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(ARBDMX_ALPHA, BYTE_ALIGN_8));
204
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(ARBDMX_ALPHA, BYTE_ALIGN_8);
205
206
21.1k
  mps_persistent_mem->m1_param_real_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
207
21.1k
  memset(mps_persistent_mem->m1_param_real_prev, 0,
208
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8));
209
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8);
210
211
21.1k
  mps_persistent_mem->m1_param_imag_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
212
21.1k
  memset(mps_persistent_mem->m1_param_imag_prev, 0,
213
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8));
214
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8);
215
216
21.1k
  mps_persistent_mem->m2_decor_real_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
217
21.1k
  memset(mps_persistent_mem->m2_decor_real_prev, 0,
218
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8));
219
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8);
220
221
21.1k
  mps_persistent_mem->m2_decor_imag_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
222
21.1k
  memset(mps_persistent_mem->m2_decor_imag_prev, 0,
223
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8));
224
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8);
225
226
21.1k
  mps_persistent_mem->m2_resid_real_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
227
21.1k
  memset(mps_persistent_mem->m2_resid_real_prev, 0,
228
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8));
229
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8);
230
231
21.1k
  mps_persistent_mem->m2_resid_imag_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
232
21.1k
  memset(mps_persistent_mem->m2_resid_imag_prev, 0,
233
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8));
234
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8);
235
236
21.1k
  mps_persistent_mem->qmf_input_delay_real =
237
21.1k
      (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
238
21.1k
  memset(mps_persistent_mem->qmf_input_delay_real, 0,
239
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8));
240
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8);
241
242
21.1k
  mps_persistent_mem->qmf_input_delay_imag =
243
21.1k
      (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
244
21.1k
  memset(mps_persistent_mem->qmf_input_delay_imag, 0,
245
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8));
246
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8);
247
248
21.1k
  mps_persistent_mem->syn_qmf_states_buffer =
249
21.1k
      (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
250
21.1k
  memset(mps_persistent_mem->syn_qmf_states_buffer, 0,
251
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(SYN_BUF_SIZE, BYTE_ALIGN_8));
252
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(SYN_BUF_SIZE, BYTE_ALIGN_8);
253
254
21.1k
  mps_persistent_mem->ana_qmf_states_buffer =
255
21.1k
      (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
256
21.1k
  memset(mps_persistent_mem->ana_qmf_states_buffer, 0,
257
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(ANA_BUF_SIZE, BYTE_ALIGN_8));
258
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(ANA_BUF_SIZE, BYTE_ALIGN_8);
259
260
21.1k
  decorr_size = ixheaacd_calc_decorr_size();
261
262
21.1k
  mps_persistent_mem->decorr_ptr = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
263
21.1k
  memset(mps_persistent_mem->decorr_ptr, 0, decorr_size);
264
21.1k
  used_persistent += decorr_size;
265
266
21.1k
  mps_persistent_mem->hyb_filter_state =
267
21.1k
      (ia_mps_dec_thyb_filter_state_struct *)((WORD8 *)persistent_mem + used_persistent);
268
21.1k
  memset(mps_persistent_mem->hyb_filter_state, 0,
269
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(HYB_FILTER_STATE_SIZE, BYTE_ALIGN_8));
270
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(HYB_FILTER_STATE_SIZE, BYTE_ALIGN_8);
271
272
21.1k
  mps_persistent_mem->ton_state =
273
21.1k
      (ia_mps_dec_tonality_state_struct *)((WORD8 *)persistent_mem + used_persistent);
274
21.1k
  memset(mps_persistent_mem->ton_state, 0,
275
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(TONALITY_STATE_SIZE, BYTE_ALIGN_8));
276
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(TONALITY_STATE_SIZE, BYTE_ALIGN_8);
277
278
21.1k
  mps_persistent_mem->smooth_state =
279
21.1k
      (ia_mps_dec_smoothing_state_struct *)((WORD8 *)persistent_mem + used_persistent);
280
21.1k
  memset(mps_persistent_mem->smooth_state, 0,
281
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(SMOOTHING_STATE_SIZE, BYTE_ALIGN_8));
282
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(SMOOTHING_STATE_SIZE, BYTE_ALIGN_8);
283
284
21.1k
  mps_persistent_mem->reshape_bb_env_state =
285
21.1k
      (ia_mps_dec_reshape_bb_env_state_struct *)((WORD8 *)persistent_mem + used_persistent);
286
21.1k
  memset(mps_persistent_mem->reshape_bb_env_state, 0,
287
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(RESHAPE_STATE_SIZE, BYTE_ALIGN_8));
288
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(RESHAPE_STATE_SIZE, BYTE_ALIGN_8);
289
290
21.1k
  mps_persistent_mem->sub_band_params =
291
21.1k
      (ia_mps_dec_subband_tp_params_struct *)((WORD8 *)persistent_mem + used_persistent);
292
21.1k
  memset(mps_persistent_mem->sub_band_params, 0,
293
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(SUBBAND_TP_SIZE, BYTE_ALIGN_8));
294
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(SUBBAND_TP_SIZE, BYTE_ALIGN_8);
295
296
21.1k
  mps_persistent_mem->blind_decoder =
297
21.1k
      (ia_mps_dec_blind_decoder_struct *)((WORD8 *)persistent_mem + used_persistent);
298
21.1k
  memset(mps_persistent_mem->blind_decoder, 0,
299
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(BLIND_DECODER_SIZE, BYTE_ALIGN_8));
300
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(BLIND_DECODER_SIZE, BYTE_ALIGN_8);
301
302
21.1k
  mps_persistent_mem->p_bs_frame =
303
21.1k
      (ia_mps_dec_spatial_bs_frame_struct *)((WORD8 *)persistent_mem + used_persistent);
304
21.1k
  memset(mps_persistent_mem->p_bs_frame, 0,
305
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_spatial_bs_frame_struct), BYTE_ALIGN_8));
306
21.1k
  used_persistent +=
307
21.1k
      IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_spatial_bs_frame_struct), BYTE_ALIGN_8);
308
309
21.1k
  pstr_mps_state->array_struct =
310
21.1k
      (ia_mps_dec_reuse_array_struct *)((WORD8 *)persistent_mem + used_persistent);
311
21.1k
  memset(pstr_mps_state->array_struct, 0,
312
21.1k
         IXHEAAC_GET_SIZE_ALIGNED(ARRAY_STRUCT_SIZE, BYTE_ALIGN_8));
313
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(ARRAY_STRUCT_SIZE, BYTE_ALIGN_8);
314
315
  // Set buffers pointers of pstr_mps_state->array_struct
316
21.1k
  ia_mps_dec_reuse_array_struct *p_array_struct = pstr_mps_state->array_struct;
317
318
21.1k
  p_array_struct->res_mdct = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
319
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(MDCT_RES_BUF_SIZE, BYTE_ALIGN_8);
320
321
21.1k
  p_array_struct->qmf_residual_real = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
322
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_RES_BUF_SIZE, BYTE_ALIGN_8);
323
21.1k
  p_array_struct->qmf_residual_imag = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
324
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_RES_BUF_SIZE, BYTE_ALIGN_8);
325
326
21.1k
  p_array_struct->m_qmf_real = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
327
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_BUF_SIZE, BYTE_ALIGN_8);
328
21.1k
  p_array_struct->m_qmf_imag = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
329
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_BUF_SIZE, BYTE_ALIGN_8);
330
331
21.1k
  p_array_struct->buf_real = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
332
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(BUF_SIZE, BYTE_ALIGN_8);
333
21.1k
  p_array_struct->buf_imag = (WORD32 *)((WORD8 *)persistent_mem + used_persistent);
334
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(BUF_SIZE, BYTE_ALIGN_8);
335
336
21.1k
  p_array_struct->hyb_output_real_dry = p_array_struct->res_mdct;
337
21.1k
  p_array_struct->hyb_output_imag_dry =
338
21.1k
      p_array_struct->res_mdct +
339
21.1k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_OUTPUT_CHANNELS_AT_MPS * TSXHB,
340
21.1k
                                    sizeof(*p_array_struct->hyb_output_imag_dry), BYTE_ALIGN_8);
341
342
21.1k
  p_array_struct->x_real = p_array_struct->hyb_output_real_dry;
343
21.1k
  p_array_struct->x_imag = p_array_struct->hyb_output_imag_dry;
344
345
21.1k
  p_array_struct->time_out = p_array_struct->hyb_output_real_dry;
346
347
21.1k
  p_array_struct->w_dry_real = p_array_struct->m_qmf_real;
348
21.1k
  p_array_struct->w_dry_imag = p_array_struct->m_qmf_imag;
349
350
21.1k
  p_array_struct->env_dmx_0 =
351
21.1k
      p_array_struct->m_qmf_real +
352
21.1k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(TSXHBX5, sizeof(*p_array_struct->env_dmx_0), BYTE_ALIGN_8);
353
21.1k
  p_array_struct->env_dmx_1 =
354
21.1k
      p_array_struct->env_dmx_0 +
355
21.1k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(MAX_TIME_SLOTS, sizeof(*p_array_struct->env_dmx_1),
356
21.1k
                                    BYTE_ALIGN_8);
357
358
21.1k
  p_array_struct->qmf_residual_real_pre = p_array_struct->qmf_residual_real;
359
21.1k
  p_array_struct->qmf_residual_real_post =
360
21.1k
      p_array_struct->qmf_residual_real +
361
21.1k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(
362
21.1k
          RES_CHXQMFXTS, sizeof(*p_array_struct->qmf_residual_real_post), BYTE_ALIGN_8);
363
364
21.1k
  p_array_struct->qmf_residual_imag_pre = p_array_struct->qmf_residual_imag;
365
21.1k
  p_array_struct->qmf_residual_imag_post =
366
21.1k
      p_array_struct->qmf_residual_imag +
367
21.1k
      IXHEAAC_GET_SIZE_ALIGNED_TYPE(
368
21.1k
          RES_CHXQMFXTS, sizeof(*p_array_struct->qmf_residual_imag_post), BYTE_ALIGN_8);
369
370
21.1k
  p_array_struct->buffer_real = p_array_struct->qmf_residual_real_post;
371
21.1k
  p_array_struct->buffer_imag = p_array_struct->qmf_residual_imag_post;
372
373
21.1k
  p_array_struct->m1_param = (ia_mps_dec_m1_param_struct *)p_array_struct->buffer_real;
374
375
21.1k
  pstr_mps_state->aux_struct =
376
21.1k
      (ia_mps_dec_auxilary_struct *)((WORD8 *)persistent_mem + used_persistent);
377
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_auxilary_struct), BYTE_ALIGN_8);
378
379
21.1k
  pstr_mps_state->aux_struct->m2_param =
380
21.1k
      (ia_mps_dec_m2_param_struct *)((WORD8 *)persistent_mem + used_persistent);
381
21.1k
  used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_m2_param_struct), BYTE_ALIGN_8);
382
383
21.1k
  *persistent_used = used_persistent;
384
21.1k
}
385
386
0
WORD32 ixheaacd_scratch_buffer_sizes() {
387
0
  WORD32 buffer_size;
388
389
0
  buffer_size = IXHEAAC_GET_SIZE_ALIGNED(MDCT_RES_BUF_SIZE, BYTE_ALIGN_8);
390
391
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_RES_BUF_SIZE, BYTE_ALIGN_8);
392
393
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_RES_BUF_SIZE, BYTE_ALIGN_8);
394
395
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_BUF_SIZE, BYTE_ALIGN_8);
396
397
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_BUF_SIZE, BYTE_ALIGN_8);
398
399
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(BUF_SIZE, BYTE_ALIGN_8);
400
401
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(BUF_SIZE, BYTE_ALIGN_8);
402
403
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_auxilary_struct), BYTE_ALIGN_8);
404
405
0
  buffer_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_m2_param_struct), BYTE_ALIGN_8);
406
407
0
  return buffer_size;
408
0
}
409
410
21.1k
VOID ixheaacd_set_scratch_buffers(ia_heaac_mps_state_struct *pstr_mps_state, VOID *scratch_mem) {
411
21.1k
  WORD32 scratch_used = 0;
412
413
21.1k
  pstr_mps_state->mps_scratch_mem_v = (VOID *)((WORD8 *)scratch_mem + scratch_used);
414
21.1k
}
415
VOID ixheaacd_ana_filter_bank_init(ia_heaac_mps_state_struct *pstr_mps_state,
416
14.0k
                                   ia_mps_dec_qmf_ana_filter_bank *qmf_bank) {
417
14.0k
  memset(qmf_bank->qmf_states_buffer, 0,
418
14.0k
         QMF_FILTER_STATE_ANA_SIZE_MPS * sizeof(qmf_bank->qmf_states_buffer[0]));
419
14.0k
  qmf_bank->p_filter_ana =
420
14.0k
      pstr_mps_state->ia_mps_dec_mps_table.qmf_table_ptr->ia_mps_enc_qmf_64_640;
421
14.0k
  qmf_bank->flag = 0;
422
14.0k
  qmf_bank->offset = 0;
423
14.0k
  qmf_bank->ref_co_eff_ptr_l = qmf_bank->p_filter_ana + 10;
424
14.0k
  qmf_bank->ref_co_eff_ptr_r = qmf_bank->p_filter_ana + QMF_FILTER_STATE_ANA_SIZE_MPS;
425
14.0k
  qmf_bank->offset_l = 5;
426
14.0k
  qmf_bank->offset_r = 5;
427
14.0k
}
428
429
4.54k
VOID ixheaacd_syn_filter_bank_create(ia_heaac_mps_state_struct *pstr_mps_state) {
430
4.54k
  ia_mps_dec_qmf_syn_filter_bank *qmf_bank = &(pstr_mps_state->syn_qmf_bank);
431
432
4.54k
  memset(qmf_bank->sbr_qmf_states_synthesis, 0, SYN_BUFFER_SIZE);
433
4.54k
  qmf_bank->p_filter_syn =
434
4.54k
      pstr_mps_state->ia_mps_dec_mps_table.tp_process_table_ptr->ia_mps_dec_qmf_64_640;
435
4.54k
}
436
437
4.53k
static IA_ERRORCODE ixheaacd_set_m2_params(ia_heaac_mps_state_struct *pstr_mps_state) {
438
4.53k
  ia_heaac_mps_state_struct *curr_state = pstr_mps_state;
439
4.53k
  WORD32 up_mix_type = curr_state->up_mix_type;
440
441
4.53k
  switch (curr_state->tree_config) {
442
492
    case TREE_5151:
443
492
      if (up_mix_type == 2) {
444
0
        curr_state->m2_param_imag_present = 1;
445
446
0
        curr_state->m2_param_present[0][1] = 1;
447
0
        curr_state->m2_param_present[1][1] = 1;
448
0
        curr_state->m2_param_present[0][0] = 2;
449
0
        curr_state->m2_param_present[1][0] = 2;
450
451
0
        curr_state->m1_param_present[0][0] = 1;
452
0
        curr_state->m1_param_present[1][0] = 1;
453
492
      } else {
454
492
        if (up_mix_type == 3) {
455
0
          curr_state->m2_param_present[0][3] = 1;
456
0
          curr_state->m2_param_present[1][3] = 1;
457
0
          curr_state->m2_param_present[0][0] = 2;
458
0
          curr_state->m2_param_present[1][0] = 2;
459
460
0
          curr_state->m1_param_present[0][0] = 1;
461
0
          curr_state->m1_param_present[3][0] = 1;
462
492
        } else {
463
492
          curr_state->m2_param_present[0][0] = 3;
464
492
          curr_state->m2_param_present[0][1] = 3;
465
492
          curr_state->m2_param_present[0][2] = 3;
466
492
          curr_state->m2_param_present[0][3] = 3;
467
492
          curr_state->m2_param_present[1][0] = 3;
468
492
          curr_state->m2_param_present[1][1] = 3;
469
492
          curr_state->m2_param_present[1][2] = 3;
470
492
          curr_state->m2_param_present[1][3] = 3;
471
492
          curr_state->m2_param_present[2][0] = 3;
472
492
          curr_state->m2_param_present[2][1] = 3;
473
492
          curr_state->m2_param_present[2][2] = 3;
474
492
          curr_state->m2_param_present[3][0] = 3;
475
492
          curr_state->m2_param_present[4][0] = 3;
476
492
          curr_state->m2_param_present[4][1] = 3;
477
492
          curr_state->m2_param_present[4][4] = 3;
478
492
          curr_state->m2_param_present[5][0] = 3;
479
492
          curr_state->m2_param_present[5][1] = 3;
480
492
          curr_state->m2_param_present[5][4] = 3;
481
482
492
          curr_state->m1_param_present[0][0] = 1;
483
492
          curr_state->m1_param_present[1][0] = 1;
484
492
          curr_state->m1_param_present[2][0] = 1;
485
492
          curr_state->m1_param_present[3][0] = 1;
486
492
          curr_state->m1_param_present[4][0] = 1;
487
492
        }
488
492
      }
489
492
      break;
490
466
    case TREE_5152:
491
466
      if (up_mix_type == 2) {
492
0
        curr_state->m2_param_imag_present = 1;
493
494
0
        curr_state->m2_param_present[0][1] = 1;
495
0
        curr_state->m2_param_present[1][1] = 1;
496
0
        curr_state->m2_param_present[0][0] = 2;
497
0
        curr_state->m2_param_present[1][0] = 2;
498
499
0
        curr_state->m1_param_present[0][0] = 1;
500
0
        curr_state->m1_param_present[1][0] = 1;
501
466
      } else {
502
466
        if (up_mix_type == 3) {
503
0
          curr_state->m2_param_present[0][2] = 1;
504
0
          curr_state->m2_param_present[1][2] = 1;
505
0
          curr_state->m2_param_present[0][0] = 2;
506
0
          curr_state->m2_param_present[1][0] = 2;
507
508
0
          curr_state->m1_param_present[0][0] = 1;
509
0
          curr_state->m1_param_present[2][0] = 1;
510
466
        } else {
511
466
          curr_state->m2_param_present[0][0] = 3;
512
466
          curr_state->m2_param_present[0][1] = 3;
513
466
          curr_state->m2_param_present[0][2] = 3;
514
466
          curr_state->m2_param_present[0][3] = 3;
515
466
          curr_state->m2_param_present[1][0] = 3;
516
466
          curr_state->m2_param_present[1][1] = 3;
517
466
          curr_state->m2_param_present[1][2] = 3;
518
466
          curr_state->m2_param_present[1][3] = 3;
519
466
          curr_state->m2_param_present[2][0] = 3;
520
466
          curr_state->m2_param_present[2][1] = 3;
521
466
          curr_state->m2_param_present[2][2] = 3;
522
466
          curr_state->m2_param_present[2][4] = 3;
523
466
          curr_state->m2_param_present[3][0] = 3;
524
466
          curr_state->m2_param_present[3][1] = 3;
525
466
          curr_state->m2_param_present[3][2] = 3;
526
466
          curr_state->m2_param_present[3][4] = 3;
527
466
          curr_state->m2_param_present[4][0] = 3;
528
466
          curr_state->m2_param_present[4][1] = 3;
529
466
          curr_state->m2_param_present[5][0] = 3;
530
531
466
          curr_state->m1_param_present[0][0] = 1;
532
466
          curr_state->m1_param_present[1][0] = 1;
533
466
          curr_state->m1_param_present[2][0] = 1;
534
466
          curr_state->m1_param_present[3][0] = 1;
535
466
          curr_state->m1_param_present[4][0] = 1;
536
466
        }
537
466
      }
538
466
      break;
539
1.44k
    case TREE_525:
540
1.44k
      if (up_mix_type == 1) {
541
0
        curr_state->m2_param_present[0][3] = 1;
542
0
        curr_state->m2_param_present[1][3] = 1;
543
0
        curr_state->m2_param_present[2][4] = 1;
544
0
        curr_state->m2_param_present[3][4] = 1;
545
546
0
        curr_state->m2_param_present[0][0] = 2;
547
0
        curr_state->m2_param_present[1][0] = 2;
548
0
        curr_state->m2_param_present[2][1] = 2;
549
0
        curr_state->m2_param_present[3][1] = 2;
550
0
        curr_state->m2_param_present[4][2] = 2;
551
552
0
        curr_state->m1_param_present[0][0] = 1;
553
0
        curr_state->m1_param_present[0][1] = 1;
554
0
        curr_state->m1_param_present[0][2] = 1;
555
0
        curr_state->m1_param_present[1][0] = 1;
556
0
        curr_state->m1_param_present[1][1] = 1;
557
0
        curr_state->m1_param_present[1][2] = 1;
558
0
        curr_state->m1_param_present[2][0] = 1;
559
0
        curr_state->m1_param_present[2][1] = 1;
560
0
        curr_state->m1_param_present[2][2] = 1;
561
1.44k
      } else if (up_mix_type == 2) {
562
0
        if (curr_state->binaural_quality == 1) {
563
0
        } else {
564
0
          curr_state->m2_param_imag_present = 1;
565
566
0
          curr_state->m2_param_present[0][0] = 2;
567
0
          curr_state->m2_param_present[0][1] = 2;
568
0
          curr_state->m2_param_present[1][0] = 2;
569
0
          curr_state->m2_param_present[1][1] = 2;
570
0
          if (curr_state->arbitrary_downmix == 2) {
571
0
            curr_state->m2_param_present[0][2] = 2;
572
0
            curr_state->m2_param_present[0][3] = 2;
573
0
            curr_state->m2_param_present[1][2] = 2;
574
0
            curr_state->m2_param_present[1][3] = 2;
575
0
          }
576
577
0
          curr_state->m1_param_present[0][0] = 1;
578
0
          curr_state->m1_param_present[1][1] = 1;
579
0
          curr_state->m1_param_present[2][3] = 1;
580
0
          curr_state->m1_param_present[3][4] = 1;
581
0
        }
582
1.44k
      } else {
583
1.44k
        curr_state->m2_param_present[0][0] = 3;
584
1.44k
        curr_state->m2_param_present[0][3] = 3;
585
1.44k
        curr_state->m2_param_present[1][0] = 3;
586
1.44k
        curr_state->m2_param_present[1][3] = 3;
587
1.44k
        curr_state->m2_param_present[2][1] = 3;
588
1.44k
        curr_state->m2_param_present[2][4] = 3;
589
1.44k
        curr_state->m2_param_present[3][1] = 3;
590
1.44k
        curr_state->m2_param_present[3][4] = 3;
591
1.44k
        curr_state->m2_param_present[4][2] = 3;
592
1.44k
        curr_state->m2_param_present[5][2] = 3;
593
594
1.44k
        curr_state->m1_param_present[0][0] = 1;
595
1.44k
        curr_state->m1_param_present[0][1] = 1;
596
1.44k
        curr_state->m1_param_present[0][2] = 1;
597
1.44k
        curr_state->m1_param_present[0][3] = 1;
598
1.44k
        curr_state->m1_param_present[0][4] = 1;
599
1.44k
        curr_state->m1_param_present[1][0] = 1;
600
1.44k
        curr_state->m1_param_present[1][1] = 1;
601
1.44k
        curr_state->m1_param_present[1][2] = 1;
602
1.44k
        curr_state->m1_param_present[1][3] = 1;
603
1.44k
        curr_state->m1_param_present[1][4] = 1;
604
1.44k
        curr_state->m1_param_present[2][0] = 1;
605
1.44k
        curr_state->m1_param_present[2][1] = 1;
606
1.44k
        curr_state->m1_param_present[2][2] = 1;
607
1.44k
        curr_state->m1_param_present[2][3] = 1;
608
1.44k
        curr_state->m1_param_present[2][4] = 1;
609
1.44k
      }
610
1.44k
      break;
611
282
    case TREE_7271:
612
282
      if (up_mix_type == 0) {
613
282
        curr_state->m2_param_present[0][3] = 3;
614
282
        curr_state->m2_param_present[0][6] = 3;
615
282
        curr_state->m2_param_present[1][3] = 3;
616
282
        curr_state->m2_param_present[1][6] = 3;
617
282
        curr_state->m2_param_present[2][3] = 3;
618
282
        curr_state->m2_param_present[3][4] = 3;
619
282
        curr_state->m2_param_present[3][7] = 3;
620
282
        curr_state->m2_param_present[4][4] = 3;
621
282
        curr_state->m2_param_present[4][7] = 3;
622
282
        curr_state->m2_param_present[5][4] = 3;
623
624
282
        curr_state->m2_param_present[0][0] = 2;
625
282
        curr_state->m2_param_present[1][0] = 2;
626
282
        curr_state->m2_param_present[2][0] = 2;
627
282
        curr_state->m2_param_present[3][1] = 2;
628
282
        curr_state->m2_param_present[4][1] = 2;
629
282
        curr_state->m2_param_present[5][1] = 2;
630
282
        curr_state->m2_param_present[6][2] = 2;
631
282
        curr_state->m2_param_present[7][2] = 2;
632
633
282
        curr_state->m1_param_present[0][0] = 1;
634
282
        curr_state->m1_param_present[0][1] = 1;
635
282
        curr_state->m1_param_present[0][2] = 1;
636
282
        curr_state->m1_param_present[0][3] = 1;
637
282
        curr_state->m1_param_present[0][4] = 1;
638
282
        curr_state->m1_param_present[1][0] = 1;
639
282
        curr_state->m1_param_present[1][1] = 1;
640
282
        curr_state->m1_param_present[1][2] = 1;
641
282
        curr_state->m1_param_present[1][3] = 1;
642
282
        curr_state->m1_param_present[1][4] = 1;
643
282
        curr_state->m1_param_present[2][0] = 1;
644
282
        curr_state->m1_param_present[2][1] = 1;
645
282
        curr_state->m1_param_present[2][2] = 1;
646
282
        curr_state->m1_param_present[2][3] = 1;
647
282
        curr_state->m1_param_present[2][4] = 1;
648
282
      } else if (up_mix_type == 2) {
649
0
        if (curr_state->binaural_quality == 1) {
650
0
        } else {
651
0
          curr_state->m2_param_imag_present = 1;
652
653
0
          curr_state->m2_param_present[0][0] = 2;
654
0
          curr_state->m2_param_present[0][1] = 2;
655
0
          curr_state->m2_param_present[1][0] = 2;
656
0
          curr_state->m2_param_present[1][1] = 2;
657
0
          if (curr_state->arbitrary_downmix == 2) {
658
0
            curr_state->m2_param_present[0][2] = 2;
659
0
            curr_state->m2_param_present[0][3] = 2;
660
0
            curr_state->m2_param_present[1][2] = 2;
661
0
            curr_state->m2_param_present[1][3] = 2;
662
0
          }
663
664
0
          curr_state->m1_param_present[0][0] = 1;
665
0
          curr_state->m1_param_present[1][1] = 1;
666
0
          curr_state->m1_param_present[2][3] = 1;
667
0
          curr_state->m1_param_present[3][4] = 1;
668
0
        }
669
0
      }
670
282
      break;
671
357
    case TREE_7272:
672
357
      if (up_mix_type == 0) {
673
357
        curr_state->m2_param_present[0][3] = 3;
674
357
        curr_state->m2_param_present[1][3] = 3;
675
357
        curr_state->m2_param_present[1][6] = 3;
676
357
        curr_state->m2_param_present[2][3] = 3;
677
357
        curr_state->m2_param_present[2][6] = 3;
678
357
        curr_state->m2_param_present[3][4] = 3;
679
357
        curr_state->m2_param_present[4][4] = 3;
680
357
        curr_state->m2_param_present[4][7] = 3;
681
357
        curr_state->m2_param_present[5][4] = 3;
682
357
        curr_state->m2_param_present[5][7] = 3;
683
684
357
        curr_state->m2_param_present[0][0] = 2;
685
357
        curr_state->m2_param_present[1][0] = 2;
686
357
        curr_state->m2_param_present[2][0] = 2;
687
357
        curr_state->m2_param_present[3][1] = 2;
688
357
        curr_state->m2_param_present[4][1] = 2;
689
357
        curr_state->m2_param_present[5][1] = 2;
690
357
        curr_state->m2_param_present[6][2] = 2;
691
357
        curr_state->m2_param_present[7][2] = 2;
692
693
357
        curr_state->m1_param_present[0][0] = 1;
694
357
        curr_state->m1_param_present[0][1] = 1;
695
357
        curr_state->m1_param_present[0][2] = 1;
696
357
        curr_state->m1_param_present[0][3] = 1;
697
357
        curr_state->m1_param_present[0][4] = 1;
698
357
        curr_state->m1_param_present[1][0] = 1;
699
357
        curr_state->m1_param_present[1][1] = 1;
700
357
        curr_state->m1_param_present[1][2] = 1;
701
357
        curr_state->m1_param_present[1][3] = 1;
702
357
        curr_state->m1_param_present[1][4] = 1;
703
357
        curr_state->m1_param_present[2][0] = 1;
704
357
        curr_state->m1_param_present[2][1] = 1;
705
357
        curr_state->m1_param_present[2][2] = 1;
706
357
        curr_state->m1_param_present[2][3] = 1;
707
357
        curr_state->m1_param_present[2][4] = 1;
708
357
      } else if (up_mix_type == 2) {
709
0
        if (curr_state->binaural_quality == 1) {
710
0
        } else {
711
0
          curr_state->m2_param_imag_present = 1;
712
713
0
          curr_state->m2_param_present[0][0] = 2;
714
0
          curr_state->m2_param_present[0][1] = 2;
715
0
          curr_state->m2_param_present[1][0] = 2;
716
0
          curr_state->m2_param_present[1][1] = 2;
717
0
          if (curr_state->arbitrary_downmix == 2) {
718
0
            curr_state->m2_param_present[0][2] = 2;
719
0
            curr_state->m2_param_present[0][3] = 2;
720
0
            curr_state->m2_param_present[1][2] = 2;
721
0
            curr_state->m2_param_present[1][3] = 2;
722
0
          }
723
724
0
          curr_state->m1_param_present[0][0] = 1;
725
0
          curr_state->m1_param_present[1][1] = 1;
726
0
          curr_state->m1_param_present[2][3] = 1;
727
0
          curr_state->m1_param_present[3][4] = 1;
728
0
        }
729
0
      }
730
357
      break;
731
162
    case TREE_7571:
732
162
      curr_state->m2_param_present[0][6] = 3;
733
162
      curr_state->m2_param_present[1][6] = 3;
734
162
      curr_state->m2_param_present[3][7] = 3;
735
162
      curr_state->m2_param_present[4][7] = 3;
736
737
162
      curr_state->m2_param_present[0][0] = 2;
738
162
      curr_state->m2_param_present[1][0] = 2;
739
162
      curr_state->m2_param_present[2][4] = 2;
740
162
      curr_state->m2_param_present[3][1] = 2;
741
162
      curr_state->m2_param_present[4][1] = 2;
742
162
      curr_state->m2_param_present[5][5] = 2;
743
162
      curr_state->m2_param_present[6][2] = 2;
744
162
      curr_state->m2_param_present[7][3] = 2;
745
746
162
      curr_state->m1_param_present[0][0] = 1;
747
162
      curr_state->m1_param_present[1][1] = 1;
748
162
      curr_state->m1_param_present[2][2] = 1;
749
162
      curr_state->m1_param_present[3][3] = 1;
750
162
      curr_state->m1_param_present[4][4] = 1;
751
162
      curr_state->m1_param_present[5][5] = 1;
752
162
      curr_state->m1_param_present[6][0] = 1;
753
162
      curr_state->m1_param_present[7][1] = 1;
754
162
      break;
755
1.32k
    case TREE_7572:
756
1.32k
      curr_state->m2_param_present[1][6] = 3;
757
1.32k
      curr_state->m2_param_present[2][6] = 3;
758
1.32k
      curr_state->m2_param_present[4][7] = 3;
759
1.32k
      curr_state->m2_param_present[5][7] = 3;
760
761
1.32k
      curr_state->m2_param_present[0][0] = 2;
762
1.32k
      curr_state->m2_param_present[1][4] = 2;
763
1.32k
      curr_state->m2_param_present[2][4] = 2;
764
1.32k
      curr_state->m2_param_present[3][1] = 2;
765
1.32k
      curr_state->m2_param_present[4][5] = 2;
766
1.32k
      curr_state->m2_param_present[5][5] = 2;
767
1.32k
      curr_state->m2_param_present[6][2] = 2;
768
1.32k
      curr_state->m2_param_present[7][3] = 2;
769
770
1.32k
      curr_state->m1_param_present[0][0] = 1;
771
1.32k
      curr_state->m1_param_present[1][1] = 1;
772
1.32k
      curr_state->m1_param_present[2][2] = 1;
773
1.32k
      curr_state->m1_param_present[3][3] = 1;
774
1.32k
      curr_state->m1_param_present[4][4] = 1;
775
1.32k
      curr_state->m1_param_present[5][5] = 1;
776
1.32k
      curr_state->m1_param_present[6][4] = 1;
777
1.32k
      curr_state->m1_param_present[7][5] = 1;
778
1.32k
      break;
779
0
    default:
780
0
      return IA_XHEAAC_MPS_DEC_EXE_FATAL_UNSUPPRORTED_TREE_CONFIG;
781
0
      break;
782
4.53k
  };
783
784
4.53k
  return IA_NO_ERROR;
785
4.53k
}
786
787
2.13k
VOID ixheaacd_sb_tp_init(ia_heaac_mps_state_struct *pstr_mps_state) {
788
2.13k
  WORD32 ch;
789
2.13k
  ia_mps_dec_subband_tp_params_struct *sub_band_tp =
790
2.13k
      pstr_mps_state->mps_persistent_mem.sub_band_params;
791
2.13k
  WORD32 *prev_tp_scale = sub_band_tp->prev_tp_scale;
792
2.13k
  WORD16 *q_prev_tp_scale = sub_band_tp->q_prev_tp_scale;
793
794
2.13k
  WORD32 *old_wet_ener = sub_band_tp->old_wet_ener;
795
2.13k
  WORD16 *q_old_wet_ener = sub_band_tp->q_old_wet_ener;
796
797
2.13k
  WORD32 *run_wet_ener = sub_band_tp->run_wet_ener;
798
2.13k
  WORD16 *q_run_wet_ener = sub_band_tp->q_run_wet_ener;
799
800
19.1k
  for (ch = 0; ch < MAX_OUTPUT_CHANNELS_MPS; ch++) {
801
17.0k
    prev_tp_scale[ch] = ONE_IN_Q15;
802
17.0k
    q_prev_tp_scale[ch] = 15;
803
804
17.0k
    old_wet_ener[ch] = ONE_IN_Q30;
805
17.0k
    q_old_wet_ener[ch] = 0;
806
17.0k
    run_wet_ener[ch] = 0;
807
17.0k
    q_run_wet_ener[ch] = 0;
808
17.0k
  }
809
14.9k
  for (ch = 0; ch < MAX_INPUT_CHANNELS_MPS; ch++) {
810
12.7k
    sub_band_tp->old_dry_ener[ch] = ONE_IN_Q30;
811
12.7k
    sub_band_tp->q_old_dry_ener[ch] = 0;
812
12.7k
    sub_band_tp->run_dry_ener[ch] = 0;
813
12.7k
    sub_band_tp->q_run_dry_ener[ch] = 0;
814
12.7k
  }
815
2.13k
}
816
817
4.53k
VOID ixheaacd_decorr_init(ia_heaac_mps_state_struct *pstr_mps_state) {
818
4.53k
  VOID *decorr_persistent = pstr_mps_state->mps_persistent_mem.decorr_ptr;
819
4.53k
  WORD32 i, k;
820
4.53k
  WORD32 hybrid_bands = pstr_mps_state->hybrid_bands;
821
4.53k
  WORD32 dec_type = pstr_mps_state->dec_type;
822
823
27.1k
  for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
824
22.6k
    pstr_mps_state->ap_decor[k] = decorr_persistent;
825
22.6k
    decorr_persistent =
826
22.6k
        (WORD8 *)decorr_persistent +
827
22.6k
        IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_decorr_dec_struct), BYTE_ALIGN_8);
828
22.6k
  }
829
27.1k
  for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
830
22.6k
    pstr_mps_state->ap_decor[k]->ducker = decorr_persistent;
831
22.6k
    decorr_persistent =
832
22.6k
        (WORD8 *)decorr_persistent +
833
22.6k
        IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_ducker_interface), BYTE_ALIGN_8) +
834
22.6k
        IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_duck_instance_struct), BYTE_ALIGN_8);
835
22.6k
  }
836
837
27.1k
  for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
838
1.08M
    for (i = 0; i < hybrid_bands; i++) {
839
1.05M
      pstr_mps_state->ap_decor[k]->filter[i] = decorr_persistent;
840
1.05M
      decorr_persistent = (WORD8 *)decorr_persistent +
841
1.05M
                          IXHEAAC_GET_SIZE_ALIGNED(
842
1.05M
                              sizeof(ia_mps_dec_decorr_filter_instance_struct), BYTE_ALIGN_8);
843
1.05M
    }
844
22.6k
  }
845
846
4.53k
  if (dec_type == 1) {
847
0
    for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
848
0
      for (i = 0; i < hybrid_bands; i++) {
849
0
        pstr_mps_state->ap_decor[k]->filter[i]->numerator_real = decorr_persistent;
850
0
        decorr_persistent =
851
0
            (WORD8 *)decorr_persistent +
852
0
            IXHEAAC_GET_SIZE_ALIGNED(
853
0
                MAX_NUM_DEN_LENGTH *
854
0
                    sizeof(pstr_mps_state->ap_decor[k]->filter[i]->numerator_real[0]),
855
0
                BYTE_ALIGN_8);
856
0
        pstr_mps_state->ap_decor[k]->filter[i]->denominator_real = decorr_persistent;
857
0
        decorr_persistent =
858
0
            (WORD8 *)decorr_persistent +
859
0
            IXHEAAC_GET_SIZE_ALIGNED(
860
0
                MAX_NUM_DEN_LENGTH *
861
0
                    sizeof(pstr_mps_state->ap_decor[k]->filter[i]->denominator_real[0]),
862
0
                BYTE_ALIGN_8);
863
0
        pstr_mps_state->ap_decor[k]->filter[i]->numerator_imag = decorr_persistent;
864
0
        decorr_persistent =
865
0
            (WORD8 *)decorr_persistent +
866
0
            IXHEAAC_GET_SIZE_ALIGNED(
867
0
                MAX_NUM_DEN_LENGTH *
868
0
                    sizeof(pstr_mps_state->ap_decor[k]->filter[i]->numerator_imag[0]),
869
0
                BYTE_ALIGN_8);
870
0
        pstr_mps_state->ap_decor[k]->filter[i]->denominator_imag = decorr_persistent;
871
0
        decorr_persistent =
872
0
            (WORD8 *)decorr_persistent +
873
0
            IXHEAAC_GET_SIZE_ALIGNED(
874
0
                MAX_NUM_DEN_LENGTH *
875
0
                    sizeof(pstr_mps_state->ap_decor[k]->filter[i]->denominator_imag[0]),
876
0
                BYTE_ALIGN_8);
877
0
      }
878
0
    }
879
4.53k
  } else {
880
27.1k
    for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
881
1.08M
      for (i = 0; i < hybrid_bands; i++) {
882
1.05M
        pstr_mps_state->ap_decor[k]->filter[i]->numerator_real = decorr_persistent;
883
1.05M
        decorr_persistent =
884
1.05M
            (WORD8 *)decorr_persistent +
885
1.05M
            IXHEAAC_GET_SIZE_ALIGNED(
886
1.05M
                MAX_NUM_DEN_LENGTH *
887
1.05M
                    sizeof(pstr_mps_state->ap_decor[k]->filter[i]->numerator_real[0]),
888
1.05M
                BYTE_ALIGN_8);
889
1.05M
        pstr_mps_state->ap_decor[k]->filter[i]->denominator_real = decorr_persistent;
890
1.05M
        decorr_persistent =
891
1.05M
            (WORD8 *)decorr_persistent +
892
1.05M
            IXHEAAC_GET_SIZE_ALIGNED(
893
1.05M
                MAX_NUM_DEN_LENGTH *
894
1.05M
                    sizeof(pstr_mps_state->ap_decor[k]->filter[i]->denominator_real[0]),
895
1.05M
                BYTE_ALIGN_8);
896
1.05M
      }
897
22.6k
    }
898
4.53k
  }
899
900
27.1k
  for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
901
1.08M
    for (i = 0; i < hybrid_bands; i++) {
902
1.05M
      pstr_mps_state->ap_decor[k]->filter[i]->state_real = decorr_persistent;
903
1.05M
      decorr_persistent =
904
1.05M
          (WORD8 *)decorr_persistent +
905
1.05M
          IXHEAAC_GET_SIZE_ALIGNED(
906
1.05M
              MAX_NUM_DEN_LENGTH * sizeof(pstr_mps_state->ap_decor[k]->filter[i]->state_real[0]),
907
1.05M
              BYTE_ALIGN_8);
908
1.05M
      pstr_mps_state->ap_decor[k]->filter[i]->state_imag = decorr_persistent;
909
1.05M
      decorr_persistent =
910
1.05M
          (WORD8 *)decorr_persistent +
911
1.05M
          IXHEAAC_GET_SIZE_ALIGNED(
912
1.05M
              MAX_NUM_DEN_LENGTH * sizeof(pstr_mps_state->ap_decor[k]->filter[i]->state_imag[0]),
913
1.05M
              BYTE_ALIGN_8);
914
1.05M
    }
915
22.6k
  }
916
917
27.1k
  for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
918
22.6k
    pstr_mps_state->ap_decor[k]->delay_buffer_real = (WORD32 **)decorr_persistent;
919
22.6k
    decorr_persistent =
920
22.6k
        (WORD8 *)decorr_persistent +
921
22.6k
        IXHEAAC_GET_SIZE_ALIGNED(
922
22.6k
            hybrid_bands * sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_real[0]),
923
22.6k
            BYTE_ALIGN_8);
924
1.08M
    for (i = 0; i < hybrid_bands; i++) {
925
1.05M
      pstr_mps_state->ap_decor[k]->delay_buffer_real[i] = (WORD32 *)decorr_persistent;
926
927
1.05M
      decorr_persistent = (WORD8 *)decorr_persistent +
928
1.05M
                          IXHEAAC_GET_SIZE_ALIGNED(
929
1.05M
                              (MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY) *
930
1.05M
                                  sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_real[i][0]),
931
1.05M
                              BYTE_ALIGN_8);
932
1.05M
    }
933
934
22.6k
    pstr_mps_state->ap_decor[k]->delay_buffer_imag =
935
22.6k
        (WORD32 **)ALIGN_SIZE64((SIZE_T)(decorr_persistent));
936
22.6k
    decorr_persistent =
937
22.6k
        (WORD8 *)decorr_persistent +
938
22.6k
        IXHEAAC_GET_SIZE_ALIGNED(
939
22.6k
            hybrid_bands * sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_imag[0]),
940
22.6k
            BYTE_ALIGN_8);
941
942
1.08M
    for (i = 0; i < hybrid_bands; i++) {
943
1.05M
      pstr_mps_state->ap_decor[k]->delay_buffer_imag[i] =
944
1.05M
          (WORD32 *)ALIGN_SIZE64((SIZE_T)(decorr_persistent));
945
946
1.05M
      decorr_persistent = (WORD8 *)decorr_persistent +
947
1.05M
                          IXHEAAC_GET_SIZE_ALIGNED(
948
1.05M
                              (MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY) *
949
1.05M
                                  sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_imag[i][0]),
950
1.05M
                              BYTE_ALIGN_8);
951
1.05M
    }
952
22.6k
  }
953
4.53k
}
954
955
4.53k
VOID ixheaacd_bs_frame_init(ia_heaac_mps_state_struct *pstr_mps_state) {
956
4.53k
  ia_mps_dec_spatial_bs_frame_struct *bs_frame = pstr_mps_state->bs_frame;
957
958
4.53k
  memset(bs_frame->ott_cld_idx_prev, 0,
959
4.53k
         MAX_NUM_OTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->ott_cld_idx_prev[0][0]));
960
4.53k
  memset(bs_frame->ott_icc_idx_prev, 0,
961
4.53k
         MAX_NUM_OTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->ott_icc_idx_prev[0][0]));
962
4.53k
  memset(bs_frame->cmp_ott_cld_idx_prev, 0,
963
4.53k
         MAX_NUM_OTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->cmp_ott_cld_idx_prev[0][0]));
964
4.53k
  memset(bs_frame->cmp_ott_icc_idx_prev, 0,
965
4.53k
         MAX_NUM_OTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->cmp_ott_icc_idx_prev[0][0]));
966
967
4.53k
  memset(bs_frame->ttt_cpc_1_idx_prev, 0,
968
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->ttt_cpc_1_idx_prev[0][0]));
969
4.53k
  memset(bs_frame->ttt_cpc_2_idx_prev, 0,
970
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->ttt_cpc_2_idx_prev[0][0]));
971
4.53k
  memset(bs_frame->ttt_cld_1_idx_prev, 0,
972
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->ttt_cld_1_idx_prev[0][0]));
973
4.53k
  memset(bs_frame->ttt_cld_2_idx_prev, 0,
974
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->ttt_cld_2_idx_prev[0][0]));
975
4.53k
  memset(bs_frame->ttt_icc_idx_prev, 0,
976
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->ttt_icc_idx_prev[0][0]));
977
4.53k
  memset(bs_frame->cmp_ttt_cpc_1_idx_prev, 0,
978
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->cmp_ttt_cpc_1_idx_prev[0][0]));
979
4.53k
  memset(bs_frame->cmp_ttt_cpc_2_idx_prev, 0,
980
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->cmp_ttt_cpc_2_idx_prev[0][0]));
981
4.53k
  memset(bs_frame->cmp_ttt_cld_1_idx_prev, 0,
982
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->cmp_ttt_cld_1_idx_prev[0][0]));
983
4.53k
  memset(bs_frame->cmp_ttt_cld_2_idx_prev, 0,
984
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->cmp_ttt_cld_2_idx_prev[0][0]));
985
4.53k
  memset(bs_frame->cmp_ttt_icc_idx_prev, 0,
986
4.53k
         MAX_NUM_TTT * MAX_PARAMETER_BANDS * sizeof(bs_frame->cmp_ttt_icc_idx_prev[0][0]));
987
988
4.53k
  memset(bs_frame->arbdmx_gain_idx_prev, 0,
989
4.53k
         MAX_INPUT_CHANNELS_MPS * MAX_PARAMETER_BANDS *
990
4.53k
             sizeof(bs_frame->arbdmx_gain_idx_prev[0][0]));
991
4.53k
  memset(bs_frame->cmp_arbdmx_gain_idx_prev, 0,
992
4.53k
         MAX_INPUT_CHANNELS_MPS * MAX_PARAMETER_BANDS *
993
4.53k
             sizeof(bs_frame->cmp_arbdmx_gain_idx_prev[0][0]));
994
4.53k
}
995
996
4.53k
IA_ERRORCODE ixheaacd_modules_init(ia_heaac_mps_state_struct *pstr_mps_state) {
997
4.53k
  IA_ERRORCODE err_code = IA_NO_ERROR;
998
4.53k
  ia_mps_dec_thyb_filter_state_struct *hyb_filter_state =
999
4.53k
      pstr_mps_state->mps_persistent_mem.hyb_filter_state;
1000
4.53k
  WORD32 up_mix_type = pstr_mps_state->up_mix_type;
1001
4.53k
  WORD32 in_channels = pstr_mps_state->num_input_channels;
1002
4.53k
  WORD32 n_ch;
1003
4.53k
  if (pstr_mps_state->smooth_config) ixheaacd_init_tonality(pstr_mps_state);
1004
1005
4.53k
  if (up_mix_type != 2) {
1006
4.53k
    if (pstr_mps_state->temp_shape_config == 2) {
1007
1.55k
      ixheaacd_init_bb_env(pstr_mps_state);
1008
1.55k
    }
1009
4.53k
  }
1010
1011
4.53k
  if (pstr_mps_state->scaling_enable == 1) ixheaacd_sb_tp_init(pstr_mps_state);
1012
1013
4.53k
  err_code = ixheaacd_syn_filt_bank_init(pstr_mps_state->syn, pstr_mps_state->qmf_bands);
1014
1015
4.53k
  if (err_code != IA_NO_ERROR) return err_code;
1016
1017
18.5k
  for (n_ch = 0; n_ch < in_channels; n_ch++) {
1018
14.0k
    ixheaacd_init_ana_hyb_filt_bank(&hyb_filter_state[n_ch]);
1019
14.0k
  }
1020
1021
18.5k
  for (n_ch = 0; n_ch < in_channels; n_ch++) {
1022
14.0k
    pstr_mps_state->aux_struct->arbdmx_alpha[n_ch] = 0;
1023
14.0k
  }
1024
1025
4.53k
  memset(&pstr_mps_state->aux_struct->ttt_cld_1[0], 0, 8 * 28 * sizeof(WORD32));
1026
1027
4.53k
  if (pstr_mps_state->residual_coding) {
1028
751
    WORD32 offset = in_channels;
1029
3.88k
    for (n_ch = 0; n_ch < pstr_mps_state->num_ott_boxes + pstr_mps_state->num_ttt_boxes; n_ch++) {
1030
3.13k
      if (pstr_mps_state->res_bands[n_ch] > 0) {
1031
1.01k
        ixheaacd_init_ana_hyb_filt_bank(&hyb_filter_state[offset + n_ch]);
1032
1.01k
      }
1033
3.13k
    }
1034
751
  }
1035
1036
4.53k
  if (pstr_mps_state->arbitrary_downmix == 2) {
1037
319
    WORD32 offset = in_channels + pstr_mps_state->num_ott_boxes + pstr_mps_state->num_ttt_boxes;
1038
767
    for (n_ch = 0; n_ch < in_channels; n_ch++) {
1039
448
      ixheaacd_init_ana_hyb_filt_bank(&hyb_filter_state[offset + n_ch]);
1040
448
    }
1041
319
  }
1042
4.53k
  if (up_mix_type == 1) {
1043
0
    ixheaacd_init_blind(pstr_mps_state);
1044
0
  }
1045
1046
4.53k
  pstr_mps_state->parse_next_bitstream_frame = 1;
1047
1048
4.53k
  ixheaacd_bs_frame_init(pstr_mps_state);
1049
1050
4.53k
  return err_code;
1051
4.53k
}
1052
1053
4.63k
IA_ERRORCODE ixheaacd_header_parse(ia_heaac_mps_state_struct *pstr_mps_state) {
1054
4.63k
  IA_ERRORCODE err_code = IA_NO_ERROR;
1055
4.63k
  WORD32 up_mix_type = pstr_mps_state->up_mix_type;
1056
4.63k
  WORD32 sac_header_len, alignment_bits = 0;
1057
4.63k
  ia_bit_buf_struct *mps_bit_buf = pstr_mps_state->ptr_mps_bit_buff;
1058
1059
4.63k
  if (up_mix_type != 1) {
1060
4.63k
    pstr_mps_state->sac_time_align_flag = ixheaacd_read_bits_buf(mps_bit_buf, 1);
1061
1062
4.63k
    sac_header_len = ixheaacd_read_bits_buf(mps_bit_buf, 7);
1063
4.63k
    if (sac_header_len == 127) {
1064
11
      sac_header_len += ixheaacd_read_bits_buf(mps_bit_buf, 16);
1065
11
    }
1066
1067
4.63k
    err_code = ixheaacd_parse_specific_config(pstr_mps_state, sac_header_len);
1068
4.63k
    if (err_code != IA_NO_ERROR) return err_code;
1069
1070
4.58k
    if (pstr_mps_state->bs_config.bs_temp_shape_config == 1) pstr_mps_state->scaling_enable = 1;
1071
1072
4.58k
    ixheaacd_byte_align(mps_bit_buf, &alignment_bits);
1073
4.58k
  } else {
1074
0
    err_code = ixheaacd_default_specific_config(pstr_mps_state, pstr_mps_state->sampling_freq);
1075
0
    if (err_code != IA_NO_ERROR) return err_code;
1076
0
  }
1077
4.58k
  return err_code;
1078
4.63k
}
1079
1080
4.54k
IA_ERRORCODE ixheaacd_aac_mps_create(ia_heaac_mps_state_struct *pstr_mps_state) {
1081
4.54k
  WORD32 i, j, k;
1082
4.54k
  WORD32 *prev_gain_at = pstr_mps_state->mps_persistent_mem.prev_gain_at;
1083
4.54k
  IA_ERRORCODE err_code = IA_NO_ERROR;
1084
4.54k
  WORD32 dec_type = pstr_mps_state->dec_type;
1085
4.54k
  WORD32 up_mix_type = pstr_mps_state->up_mix_type;
1086
4.54k
  WORD32 in_channels = pstr_mps_state->num_input_channels;
1087
1088
4.54k
  if (pstr_mps_state == 0) return IA_XHEAAC_DEC_INIT_FATAL_DEC_INIT_FAIL;
1089
1090
4.54k
  pstr_mps_state->num_parameter_sets = 1;
1091
1092
40.8k
  for (i = 0; i < MAX_OUTPUT_CHANNELS_AT_MPS; i++) {
1093
1.05M
    for (j = 0; j < MAX_PARAMETER_BANDS; j++) {
1094
1.01M
      *prev_gain_at++ = ONE_IN_Q15;
1095
1.01M
    }
1096
36.3k
  }
1097
1098
18.6k
  for (i = 0; i < in_channels; i++) {
1099
14.0k
    ixheaacd_ana_filter_bank_init(pstr_mps_state, &(pstr_mps_state->qmf_bank[i]));
1100
14.0k
  }
1101
1102
4.54k
  ixheaacd_syn_filter_bank_create(pstr_mps_state);
1103
1104
4.54k
  err_code = ixheaacd_set_current_state_parameters(pstr_mps_state);
1105
4.54k
  if (err_code != IA_NO_ERROR) return err_code;
1106
1107
4.53k
  err_code = ixheaacd_set_m2_params(pstr_mps_state);
1108
4.53k
  if (err_code != IA_NO_ERROR) return err_code;
1109
1110
4.53k
  err_code = ixheaacd_mdct2qmf_create(pstr_mps_state);
1111
4.53k
  if (err_code != IA_NO_ERROR) return err_code;
1112
1113
4.53k
  ixheaacd_decorr_init(pstr_mps_state);
1114
1115
27.1k
  for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) {
1116
22.6k
    WORD32 idec;
1117
1118
22.6k
    if (up_mix_type == 3) {
1119
0
      idec = 0;
1120
22.6k
    } else {
1121
22.6k
      idec = k;
1122
22.6k
    }
1123
1124
22.6k
    err_code = ixheaacd_decorr_create((pstr_mps_state->ap_decor[k]), pstr_mps_state->hybrid_bands,
1125
22.6k
                                      idec, dec_type, pstr_mps_state->decorr_config,
1126
22.6k
                                      &(pstr_mps_state->ia_mps_dec_mps_table));
1127
22.6k
    if (err_code != IA_NO_ERROR) return err_code;
1128
22.6k
  }
1129
1130
4.53k
  err_code = ixheaacd_modules_init(pstr_mps_state);
1131
1132
4.53k
  return err_code;
1133
4.53k
}
1134
1135
4.63k
VOID ixheaacd_wf_table_init(ia_heaac_mps_state_struct *pstr_mps_state) {
1136
4.63k
  WORD32 const **wf = pstr_mps_state->wf_tab.wf;
1137
4.63k
  ia_mps_dec_mps_tables_struct *mps_table_ptr = &pstr_mps_state->ia_mps_dec_mps_table;
1138
1139
4.63k
  wf[0] = NULL;
1140
4.63k
  wf[1] = ixheaacd_mps_dec_wf_tables.wf_02;
1141
4.63k
  wf[2] = ixheaacd_mps_dec_wf_tables.wf_03;
1142
4.63k
  wf[3] = ixheaacd_mps_dec_wf_tables.wf_04;
1143
4.63k
  wf[4] = NULL;
1144
4.63k
  wf[5] = NULL;
1145
4.63k
  wf[6] = NULL;
1146
4.63k
  wf[7] = NULL;
1147
4.63k
  wf[8] = NULL;
1148
4.63k
  wf[9] = NULL;
1149
4.63k
  wf[10] = NULL;
1150
4.63k
  wf[11] = NULL;
1151
4.63k
  wf[12] = NULL;
1152
4.63k
  wf[13] = NULL;
1153
4.63k
  wf[14] = ixheaacd_mps_dec_wf_tables.wf_15;
1154
4.63k
  wf[15] = ixheaacd_mps_dec_wf_tables.wf_16;
1155
4.63k
  wf[16] = NULL;
1156
4.63k
  wf[17] = ixheaacd_mps_dec_wf_tables.wf_18;
1157
4.63k
  wf[18] = NULL;
1158
4.63k
  wf[19] = NULL;
1159
4.63k
  wf[20] = NULL;
1160
4.63k
  wf[21] = NULL;
1161
4.63k
  wf[22] = NULL;
1162
4.63k
  wf[23] = ixheaacd_mps_dec_wf_tables.wf_24;
1163
4.63k
  wf[24] = NULL;
1164
4.63k
  wf[25] = NULL;
1165
4.63k
  wf[26] = NULL;
1166
4.63k
  wf[27] = NULL;
1167
4.63k
  wf[28] = NULL;
1168
4.63k
  wf[29] = ixheaacd_mps_dec_wf_tables.wf_30;
1169
4.63k
  wf[30] = NULL;
1170
4.63k
  wf[31] = ixheaacd_mps_dec_wf_tables.wf_32;
1171
1172
4.63k
  mps_table_ptr->wf_tab_ptr = &(pstr_mps_state->wf_tab);
1173
4.63k
}
1174
1175
4.63k
VOID ixheaacd_res_huff_tables_init(ia_mps_dec_residual_aac_tables_struct *aac_tables_ptr) {
1176
4.63k
  aac_tables_ptr->code_book[0] = 0;
1177
4.63k
  aac_tables_ptr->code_book[1] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_1;
1178
4.63k
  aac_tables_ptr->code_book[2] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_2;
1179
4.63k
  aac_tables_ptr->code_book[3] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_3;
1180
4.63k
  aac_tables_ptr->code_book[4] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_4;
1181
4.63k
  aac_tables_ptr->code_book[5] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_5;
1182
4.63k
  aac_tables_ptr->code_book[6] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_6;
1183
4.63k
  aac_tables_ptr->code_book[7] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_7;
1184
4.63k
  aac_tables_ptr->code_book[8] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_8;
1185
4.63k
  aac_tables_ptr->code_book[9] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_9;
1186
4.63k
  aac_tables_ptr->code_book[10] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_10;
1187
4.63k
  aac_tables_ptr->code_book[11] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_10;
1188
4.63k
  aac_tables_ptr->code_book[12] = aac_tables_ptr->res_huffmann_tables_ptr->huffman_code_book_10;
1189
1190
4.63k
  aac_tables_ptr->scale_factor_bands_short[0] =
1191
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_128;
1192
4.63k
  aac_tables_ptr->scale_factor_bands_short[1] =
1193
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_128;
1194
4.63k
  aac_tables_ptr->scale_factor_bands_short[2] =
1195
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_128;
1196
4.63k
  aac_tables_ptr->scale_factor_bands_short[3] =
1197
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_128;
1198
4.63k
  aac_tables_ptr->scale_factor_bands_short[4] =
1199
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_128;
1200
4.63k
  aac_tables_ptr->scale_factor_bands_short[5] =
1201
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_128;
1202
4.63k
  aac_tables_ptr->scale_factor_bands_short[6] =
1203
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_128;
1204
4.63k
  aac_tables_ptr->scale_factor_bands_short[7] =
1205
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_128;
1206
4.63k
  aac_tables_ptr->scale_factor_bands_short[8] =
1207
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_128;
1208
4.63k
  aac_tables_ptr->scale_factor_bands_short[9] =
1209
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_128;
1210
4.63k
  aac_tables_ptr->scale_factor_bands_short[10] =
1211
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_128;
1212
4.63k
  aac_tables_ptr->scale_factor_bands_short[11] =
1213
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_8_128;
1214
4.63k
  aac_tables_ptr->scale_factor_bands_short[12] =
1215
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_120;
1216
4.63k
  aac_tables_ptr->scale_factor_bands_short[13] =
1217
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_120;
1218
4.63k
  aac_tables_ptr->scale_factor_bands_short[14] =
1219
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_120;
1220
4.63k
  aac_tables_ptr->scale_factor_bands_short[15] =
1221
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_120;
1222
4.63k
  aac_tables_ptr->scale_factor_bands_short[16] =
1223
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_120;
1224
4.63k
  aac_tables_ptr->scale_factor_bands_short[17] =
1225
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_120;
1226
4.63k
  aac_tables_ptr->scale_factor_bands_short[18] =
1227
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_120;
1228
4.63k
  aac_tables_ptr->scale_factor_bands_short[19] =
1229
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_120;
1230
4.63k
  aac_tables_ptr->scale_factor_bands_short[20] =
1231
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_120;
1232
4.63k
  aac_tables_ptr->scale_factor_bands_short[21] =
1233
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_120;
1234
4.63k
  aac_tables_ptr->scale_factor_bands_short[22] =
1235
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_120;
1236
4.63k
  aac_tables_ptr->scale_factor_bands_short[23] =
1237
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_8_120;
1238
1239
4.63k
  aac_tables_ptr->scale_factor_bands_long[0] =
1240
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_1024;
1241
4.63k
  aac_tables_ptr->scale_factor_bands_long[1] =
1242
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_1024;
1243
4.63k
  aac_tables_ptr->scale_factor_bands_long[2] =
1244
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_64_1024;
1245
4.63k
  aac_tables_ptr->scale_factor_bands_long[3] =
1246
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_1024;
1247
4.63k
  aac_tables_ptr->scale_factor_bands_long[4] =
1248
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_1024;
1249
4.63k
  aac_tables_ptr->scale_factor_bands_long[5] =
1250
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_32_1024;
1251
4.63k
  aac_tables_ptr->scale_factor_bands_long[6] =
1252
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_1024;
1253
4.63k
  aac_tables_ptr->scale_factor_bands_long[7] =
1254
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_1024;
1255
4.63k
  aac_tables_ptr->scale_factor_bands_long[8] =
1256
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_1024;
1257
4.63k
  aac_tables_ptr->scale_factor_bands_long[9] =
1258
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_1024;
1259
4.63k
  aac_tables_ptr->scale_factor_bands_long[10] =
1260
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_1024;
1261
4.63k
  aac_tables_ptr->scale_factor_bands_long[11] =
1262
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_8_1024;
1263
4.63k
  aac_tables_ptr->scale_factor_bands_long[12] =
1264
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_960;
1265
4.63k
  aac_tables_ptr->scale_factor_bands_long[13] =
1266
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_96_960;
1267
4.63k
  aac_tables_ptr->scale_factor_bands_long[14] =
1268
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_64_960;
1269
4.63k
  aac_tables_ptr->scale_factor_bands_long[15] =
1270
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_960;
1271
4.63k
  aac_tables_ptr->scale_factor_bands_long[16] =
1272
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_960;
1273
4.63k
  aac_tables_ptr->scale_factor_bands_long[17] =
1274
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_48_960;
1275
4.63k
  aac_tables_ptr->scale_factor_bands_long[18] =
1276
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_960;
1277
4.63k
  aac_tables_ptr->scale_factor_bands_long[19] =
1278
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_24_960;
1279
4.63k
  aac_tables_ptr->scale_factor_bands_long[20] =
1280
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_960;
1281
4.63k
  aac_tables_ptr->scale_factor_bands_long[21] =
1282
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_960;
1283
4.63k
  aac_tables_ptr->scale_factor_bands_long[22] =
1284
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_16_960;
1285
4.63k
  aac_tables_ptr->scale_factor_bands_long[23] =
1286
4.63k
      aac_tables_ptr->res_huffmann_tables_ptr->sfb_8_960;
1287
4.63k
}
1288
1289
4.63k
static VOID ixheaacd_table_ptr_init(ia_heaac_mps_state_struct *pstr_mps_state) {
1290
4.63k
  ia_mps_dec_mps_tables_struct *mps_table_ptr = &pstr_mps_state->ia_mps_dec_mps_table;
1291
4.63k
  ia_mps_dec_residual_aac_tables_struct *aac_table_ptr = &pstr_mps_state->aac_table;
1292
1293
4.63k
  mps_table_ptr->qmf_table_ptr = (ia_mps_dec_qmf_tables_struct *)&ixheaacd_mps_dec_qmf_tables;
1294
4.63k
  mps_table_ptr->common_table_ptr =
1295
4.63k
      (ia_mps_dec_common_tables_struct *)&ixheaacd_mps_dec_common_tables;
1296
4.63k
  mps_table_ptr->hybrid_table_ptr =
1297
4.63k
      (ia_mps_dec_hybrid_tables_struct *)&ixheaacd_mps_dec_hybrid_tables;
1298
4.63k
  mps_table_ptr->m1_m2_table_ptr =
1299
4.63k
      (ia_mps_dec_m1_m2_tables_struct *)&ixheaacd_mps_dec_m1_m2_tables;
1300
4.63k
  mps_table_ptr->decor_table_ptr =
1301
4.63k
      (ia_mps_dec_decorr_tables_struct *)&ixheaacd_mps_dec_decorr_tables;
1302
4.63k
  mps_table_ptr->tp_process_table_ptr =
1303
4.63k
      (ia_mps_dec_tp_process_tables_struct *)&ixheaacd_mps_dec_tp_process_tables;
1304
1305
4.63k
  mps_table_ptr->mdct2qmf_table_ptr =
1306
4.63k
      (ia_mps_dec_mdct2qmf_table_struct *)&ixheaacd_mps_dec_mdct2qmf_table;
1307
1308
4.63k
  mps_table_ptr->tonality_table_ptr =
1309
4.63k
      (ia_mps_dec_tonality_tables_struct *)&ixheaacd_mps_dec_tonality_tables;
1310
1311
4.63k
  mps_table_ptr->bitdec_table_ptr =
1312
4.63k
      (ia_mps_dec_bitdec_tables_struct *)&ixheaacd_mps_dec_bitdec_tables;
1313
4.63k
  mps_table_ptr->blind_table_ptr =
1314
4.63k
      (ia_mps_dec_blind_tables_struct *)&ixheaacd_mps_dec_blind_tables;
1315
1316
4.63k
  mps_table_ptr->mdct2qmfcos_table_ptr =
1317
4.63k
      (ia_mps_dec_mdct2qmf_tables_struct *)&ixheaacd_mps_dec_mdct2qmf_tables;
1318
4.63k
  mps_table_ptr->mdct2qmfcos_tab_ptr =
1319
4.63k
      (ia_mps_dec_mdct2qmf_cos_table_struct *)&pstr_mps_state->ia_mps_dec_mdct2qmfcos_table;
1320
4.63k
  aac_table_ptr->res_huffmann_tables_ptr =
1321
4.63k
      (ia_mps_dec_res_huffmann_tables_struct *)&ixheaacd_mps_dec_res_huffmann_tables;
1322
4.63k
  aac_table_ptr->res_block_tables_ptr =
1323
4.63k
      (ia_mps_dec_res_block_tables_struct *)&ixheaacd_mps_dec_res_block_tables;
1324
1325
4.63k
  ixheaacd_res_huff_tables_init(aac_table_ptr);
1326
1327
4.63k
  mps_table_ptr->aac_tab = aac_table_ptr;
1328
1329
4.63k
  ixheaacd_wf_table_init(pstr_mps_state);
1330
4.63k
}
1331
1332
IA_ERRORCODE ixheaacd_aac_mps_init(ia_exhaacplus_dec_api_struct *p_obj_mps_dec, UWORD8 *databuf,
1333
4.63k
                                   WORD32 buffer_size, WORD32 sample_rate) {
1334
4.63k
  WORD32 i;
1335
1336
4.63k
  VOID *buf_ptr;
1337
4.63k
  ia_mps_persistent_mem *persistent_mem =
1338
4.63k
      &p_obj_mps_dec->p_state_aac->heaac_mps_handle.mps_persistent_mem;
1339
1340
4.63k
  IA_ERRORCODE err_code = IA_NO_ERROR;
1341
4.63k
  ia_heaac_mps_state_struct *curr_state = &p_obj_mps_dec->p_state_aac->heaac_mps_handle;
1342
4.63k
  ia_mps_spatial_bs_config_struct *p_bs_config = &curr_state->bs_config;
1343
4.63k
  curr_state->ec_flag = p_obj_mps_dec->p_state_aac->ec_enable;
1344
4.63k
  ixheaacd_table_ptr_init(curr_state);
1345
1346
4.63k
  curr_state->ptr_mps_bit_buff =
1347
4.63k
      ixheaacd_create_bit_buf(&curr_state->mps_bit_buf, (UWORD8 *)databuf, buffer_size);
1348
4.63k
  curr_state->ptr_mps_bit_buff->cnt_bits += (8 * buffer_size);
1349
1350
4.63k
  curr_state->ptr_mps_bit_buff->xaac_jmp_buf = &p_obj_mps_dec->p_state_aac->xaac_jmp_buf;
1351
1352
4.63k
  if (sample_rate < 27713) {
1353
3.52k
    curr_state->qmf_bands = 32;
1354
3.52k
  } else if (sample_rate >= 55426) {
1355
3
    curr_state->qmf_bands = 128;
1356
1.10k
  } else {
1357
1.10k
    curr_state->qmf_bands = 64;
1358
1.10k
  }
1359
1360
4.63k
  curr_state->sampling_freq = sample_rate;
1361
4.63k
  curr_state->num_input_channels = p_obj_mps_dec->p_state_aac->p_config->ui_n_channels;
1362
4.63k
  curr_state->bits_per_sample = p_obj_mps_dec->p_state_aac->p_config->ui_pcm_wdsz;
1363
4.63k
  curr_state->dec_type = p_bs_config->ui_dec_type;
1364
4.63k
  curr_state->up_mix_type = p_bs_config->ui_upmix_type;
1365
4.63k
  curr_state->binaural_quality = p_bs_config->ui_binaural_quality;
1366
4.63k
  curr_state->hrtf_model = p_bs_config->ui_hrtf_model;
1367
4.63k
  curr_state->is_buried_flag = p_bs_config->ui_bs_is_buried;
1368
1369
4.63k
  curr_state->bs_frame = persistent_mem->p_bs_frame;
1370
1371
4.63k
  buf_ptr = persistent_mem->syn_qmf_states_buffer;
1372
4.63k
  curr_state->syn = buf_ptr;
1373
1374
4.63k
  curr_state->syn_qmf_bank.sbr_qmf_states_synthesis =
1375
4.63k
      (WORD32 *)((WORD8 *)buf_ptr + sizeof(ia_mps_dec_synthesis_interface));
1376
1377
4.63k
  buf_ptr = persistent_mem->ana_qmf_states_buffer;
1378
1379
4.63k
  memset(curr_state->m2_param_present, 0,
1380
4.63k
         MAX_M2_OUTPUT * MAX_M2_INPUT * sizeof(curr_state->m2_param_present[0][0]));
1381
4.63k
  memset(&(curr_state->bs_config), 0, sizeof(ia_mps_spatial_bs_config_struct));
1382
4.63k
  memset(&(curr_state->res_block_type), 0,
1383
4.63k
         sizeof(WORD32) * MAX_RESIDUAL_CHANNELS_MPS * MAX_RESIDUAL_FRAMES);
1384
1385
4.63k
  curr_state->bs_config.ui_pcm_wdsz = 16;
1386
4.63k
  curr_state->bs_config.ui_samp_freq = 48000;
1387
4.63k
  curr_state->bs_config.ui_in_channels = 2;
1388
4.63k
  curr_state->bs_config.ui_qmf_bands = 64;
1389
1390
4.63k
  err_code = ixheaacd_header_parse(curr_state);
1391
4.63k
  if (err_code != IA_NO_ERROR) return err_code;
1392
1393
18.6k
  for (i = 0; i < curr_state->num_input_channels; i++) {
1394
14.0k
    curr_state->qmf_bank[i].qmf_states_buffer = buf_ptr;
1395
14.0k
    buf_ptr = (WORD8 *)buf_ptr + QMF_FILTER_STATE_ANA_SIZE_MPS * sizeof(WORD32);
1396
14.0k
  }
1397
1398
4.58k
  curr_state->i_bytes_consumed_mps = (WORD32)(curr_state->ptr_mps_bit_buff->ptr_read_next -
1399
4.58k
                                              curr_state->ptr_mps_bit_buff->ptr_bit_buf_base);
1400
1401
4.58k
  curr_state->bytes_remaining = buffer_size - curr_state->i_bytes_consumed_mps;
1402
1403
4.58k
  if (curr_state->bytes_remaining != 0) {
1404
163k
    for (WORD32 ii = 0; ii < curr_state->bytes_remaining; ii++) {
1405
158k
      curr_state->temp_buf[ii] = databuf[ii + curr_state->i_bytes_consumed_mps];
1406
158k
    }
1407
4.54k
  }
1408
1409
4.58k
  err_code = ixheaacd_aac_mps_create(curr_state);
1410
4.58k
  if (err_code != IA_NO_ERROR) return err_code;
1411
1412
4.57k
  curr_state->mps_init_done = 1;
1413
4.57k
  curr_state->first_frame = 1;
1414
1415
4.57k
  return err_code;
1416
4.58k
}