Coverage Report

Created: 2025-07-11 06:38

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