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