/src/libxaac/decoder/ixheaacd_api.c
Line | Count | Source (jump to first uncovered line) |
1 | | /****************************************************************************** |
2 | | * * |
3 | | * Copyright (C) 2018 The Android Open Source Project |
4 | | * |
5 | | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | * you may not use this file except in compliance with the License. |
7 | | * You may obtain a copy of the License at: |
8 | | * |
9 | | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | * |
11 | | * Unless required by applicable law or agreed to in writing, software |
12 | | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | * See the License for the specific language governing permissions and |
15 | | * limitations under the License. |
16 | | * |
17 | | ***************************************************************************** |
18 | | * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore |
19 | | */ |
20 | | #include <string.h> |
21 | | #include <stdio.h> |
22 | | #include <stdlib.h> |
23 | | #include "ixheaacd_sbr_common.h" |
24 | | #include "ixheaac_type_def.h" |
25 | | #include "ixheaacd_memory_standards.h" |
26 | | #include "ixheaacd_mps_struct_def.h" |
27 | | #include "ixheaacd_mps_res_rom.h" |
28 | | #include "ixheaacd_mps_aac_struct.h" |
29 | | #include "ixheaac_constants.h" |
30 | | #include "ixheaac_basic_ops32.h" |
31 | | #include "ixheaac_basic_ops16.h" |
32 | | #include "ixheaac_basic_ops40.h" |
33 | | #include "ixheaac_basic_ops.h" |
34 | | |
35 | | #include "ixheaac_error_standards.h" |
36 | | #include "ixheaacd_apicmd_standards.h" |
37 | | #include "ixheaacd_aac_config.h" |
38 | | #include "ixheaacd_api_defs.h" |
39 | | |
40 | | #include "ixheaacd_definitions.h" |
41 | | #include "ixheaacd_error_codes.h" |
42 | | #include "ixheaacd_bitbuffer.h" |
43 | | |
44 | | #include "ixheaacd_audioobjtypes.h" |
45 | | #include "ixheaacd_sbrdecsettings.h" |
46 | | #include "ixheaacd_memory_standards.h" |
47 | | |
48 | | #include "ixheaacd_bitbuffer.h" |
49 | | #include "ixheaacd_adts.h" |
50 | | #include "ixheaacd_defines.h" |
51 | | #include "ixheaacd_cnst.h" |
52 | | #include "ixheaacd_aac_rom.h" |
53 | | #include "ixheaacd_ec_defines.h" |
54 | | #include "ixheaacd_ec_struct_def.h" |
55 | | |
56 | | #include "ixheaacd_sbr_scale.h" |
57 | | #include "ixheaacd_lpp_tran.h" |
58 | | #include "ixheaacd_env_extr_part.h" |
59 | | #include "ixheaacd_sbr_rom.h" |
60 | | |
61 | | #include "ixheaacd_hybrid.h" |
62 | | #include "ixheaacd_ps_dec.h" |
63 | | #include "ixheaacd_ps_bitdec.h" |
64 | | |
65 | | #include "ixheaacd_pulsedata.h" |
66 | | |
67 | | #include "ixheaacd_pns.h" |
68 | | #include "ixheaacd_drc_data_struct.h" |
69 | | |
70 | | #include "ixheaacd_lt_predict.h" |
71 | | |
72 | | #include "ixheaacd_channelinfo.h" |
73 | | #include "ixheaacd_drc_dec.h" |
74 | | #include "ixheaac_sbr_const.h" |
75 | | #include "ixheaacd_sbrdecoder.h" |
76 | | #include "ixheaacd_env_extr.h" |
77 | | #include "ixheaacd_common_rom.h" |
78 | | #include "ixheaacd_freq_sca.h" |
79 | | #include "ixheaacd_qmf_dec.h" |
80 | | #include "ixheaacd_env_calc.h" |
81 | | |
82 | | #include "ixheaacd_pvc_dec.h" |
83 | | #include "ixheaacd_sbr_dec.h" |
84 | | #include "ixheaacd_block.h" |
85 | | #include "ixheaacd_channel.h" |
86 | | |
87 | | #include "ixheaacd_audioobjtypes.h" |
88 | | #include "ixheaacd_latmdemux.h" |
89 | | |
90 | | #include "ixheaacd_aacdec.h" |
91 | | #include "ixheaacd_mps_polyphase.h" |
92 | | #include "ixheaacd_config.h" |
93 | | #include "ixheaacd_mps_dec.h" |
94 | | #include "ixheaacd_struct_def.h" |
95 | | #include "ixheaacd_headerdecode.h" |
96 | | #include "ixheaacd_adts_crc_check.h" |
97 | | |
98 | | #include "ixheaacd_multichannel.h" |
99 | | #include "ixheaacd_ver_number.h" |
100 | | |
101 | | #include "ixheaacd_interface.h" |
102 | | #include "ixheaacd_info.h" |
103 | | |
104 | | #include "ixheaacd_config.h" |
105 | | |
106 | | #include "ixheaacd_struct.h" |
107 | | #include "ixheaacd_mps_polyphase.h" |
108 | | #include "ixheaacd_tns_usac.h" |
109 | | #include "ixheaacd_acelp_info.h" |
110 | | |
111 | | #include "ixheaacd_main.h" |
112 | | #include "ixheaacd_arith_dec.h" |
113 | | #include "ixheaacd_create.h" |
114 | | #include "ixheaacd_function_selector.h" |
115 | | #include "ixheaacd_ld_mps_dec.h" |
116 | | #include "ixheaacd_mps_tables.h" |
117 | | #define MAX_TRACKS_PER_LAYER 50 |
118 | | |
119 | | #define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) |
120 | | |
121 | 448k | #define IA_ENHAACPDEC_NUM_MEMTABS (4) |
122 | | |
123 | 0 | #define NUM_AAC_TABLES 8 |
124 | | |
125 | 953k | #define LD_OBJ -2 |
126 | | |
127 | | #define SCR_BASE_SCR_8K_SIZE \ |
128 | 298k | (IXHEAAC_GET_SIZE_ALIGNED((2 * CHANNELS * MAX_BINS_LONG * sizeof(WORD32)), BYTE_ALIGN_8)) |
129 | | #define SCR_EXTRA_SCR_4K_0_SIZE \ |
130 | 465k | (2 * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_channel_info_struct), sizeof(WORD32)) + \ |
131 | 465k | 2 * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_sfb_code_book_struct), sizeof(WORD32)) + \ |
132 | 465k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_pns_stereo_data_struct), sizeof(WORD32))) |
133 | | #define SCR_EXTRA_SCR_4K_2_SIZE \ |
134 | 465k | (IXHEAAC_GET_SIZE_ALIGNED((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * sizeof(WORD32)), BYTE_ALIGN_8)) |
135 | | #define SCR_EXTRA_SCR_4K_3_SIZE \ |
136 | 167k | (IXHEAAC_GET_SIZE_ALIGNED((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * sizeof(WORD32)), BYTE_ALIGN_8)) |
137 | | #define SCR_OUT_DATA_SIZE \ |
138 | 117k | (IXHEAAC_GET_SIZE_ALIGNED((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * sizeof(WORD32)), BYTE_ALIGN_8)) |
139 | | #define SCR_IN_DATA_SIZE \ |
140 | 117k | (2 * IXHEAAC_GET_SIZE_ALIGNED((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * sizeof(WORD32)), \ |
141 | 117k | BYTE_ALIGN_8)) |
142 | | #define SCR_INTER_SCR_SIZE \ |
143 | 274k | (MAX_CHANNEL_COUNT * \ |
144 | 274k | IXHEAAC_GET_SIZE_ALIGNED((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * sizeof(WORD16)), \ |
145 | 274k | BYTE_ALIGN_8)) |
146 | | #define SCR_COUP_CH_OUT_SIZE \ |
147 | 261k | (MAX_CHANNEL_COUNT * \ |
148 | 261k | IXHEAAC_GET_SIZE_ALIGNED((IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * sizeof(WORD16)), \ |
149 | 261k | BYTE_ALIGN_8)) |
150 | | |
151 | | #define P_IND_CH_INFO_OFFSET \ |
152 | 268 | (SCR_BASE_SCR_8K_SIZE + SCR_EXTRA_SCR_4K_0_SIZE + SCR_EXTRA_SCR_4K_2_SIZE) |
153 | | |
154 | | #define HEAACV2_MAX_SIZE \ |
155 | | (max(SCR_BASE_SCR_8K_SIZE + SCR_EXTRA_SCR_4K_0_SIZE + SCR_EXTRA_SCR_4K_2_SIZE + \ |
156 | | SCR_INTER_SCR_SIZE + SCR_COUP_CH_OUT_SIZE, \ |
157 | | MPS_SCRATCH_MEM_SIZE)) |
158 | | #define ELDV2_MAX_SIZE \ |
159 | | (max(SCR_BASE_SCR_8K_SIZE + SCR_EXTRA_SCR_4K_0_SIZE + SCR_EXTRA_SCR_4K_2_SIZE + \ |
160 | | SCR_EXTRA_SCR_4K_3_SIZE + SCR_INTER_SCR_SIZE + SCR_COUP_CH_OUT_SIZE, \ |
161 | | MPS_SCRATCH_MEM_SIZE)) |
162 | | #define LD_MAX_SIZE \ |
163 | | (max(SCR_BASE_SCR_8K_SIZE + SCR_EXTRA_SCR_4K_0_SIZE + SCR_EXTRA_SCR_4K_2_SIZE + \ |
164 | | SCR_OUT_DATA_SIZE + SCR_IN_DATA_SIZE + SCR_INTER_SCR_SIZE + SCR_COUP_CH_OUT_SIZE, \ |
165 | | MPS_SCRATCH_MEM_SIZE)) |
166 | | |
167 | 297k | #define MAX_SCR_SIZE (max(max(HEAACV2_MAX_SIZE, ELDV2_MAX_SIZE), LD_MAX_SIZE)) |
168 | | |
169 | | IA_ERRORCODE ixheaacd_dec_mem_api(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, |
170 | 377k | WORD32 i_cmd, WORD32 i_idx, VOID *pv_value) { |
171 | 377k | pUWORD32 pui_value = pv_value; |
172 | | |
173 | 377k | if (i_idx < 0 || i_idx >= IA_ENHAACPDEC_NUM_MEMTABS) { |
174 | 0 | return IA_XHEAAC_DEC_API_FATAL_INVALID_MEMTAB_INDEX; |
175 | 0 | } |
176 | | |
177 | 377k | if (i_cmd == IA_API_CMD_SET_MEM_PTR) { |
178 | 94.4k | if (pv_value == 0) { |
179 | 0 | return (IA_XHEAAC_DEC_API_FATAL_MEM_ALLOC); |
180 | 0 | } |
181 | 94.4k | if (((SIZE_T)pv_value % |
182 | 94.4k | p_obj_exhaacplus_dec->p_mem_info_aac[i_idx].ui_alignment) != 0) { |
183 | 0 | return (IA_XHEAAC_DEC_API_FATAL_MEM_ALIGN); |
184 | 0 | } |
185 | 94.4k | p_obj_exhaacplus_dec->pp_mem_aac[i_idx] = pv_value; |
186 | 94.4k | memset(p_obj_exhaacplus_dec->pp_mem_aac[i_idx], 0, |
187 | 94.4k | p_obj_exhaacplus_dec->p_mem_info_aac[i_idx].ui_size); |
188 | | |
189 | 94.4k | if (i_idx == IA_ENHAACPLUS_DEC_PERSIST_IDX) { |
190 | 23.6k | pUWORD8 p_temp = pv_value; |
191 | 23.6k | UWORD32 *meminfo = |
192 | 23.6k | (UWORD32 *)p_obj_exhaacplus_dec->p_mem_info_aac + i_idx; |
193 | 23.6k | UWORD32 pers_size = meminfo[0]; |
194 | 23.6k | p_temp = p_temp + pers_size - |
195 | 23.6k | (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + |
196 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8) + |
197 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(MAX_HEADER_BUF_SIZE, BYTE_ALIGN_8)); |
198 | 23.6k | p_obj_exhaacplus_dec->p_state_aac = pv_value; |
199 | 23.6k | memset(p_obj_exhaacplus_dec->p_state_aac, 0, |
200 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8)); |
201 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data = p_temp; |
202 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = |
203 | 23.6k | p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8); |
204 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->header_ptr = |
205 | 23.6k | p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + |
206 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8); |
207 | 23.6k | } |
208 | | |
209 | 283k | } else { |
210 | 283k | UWORD32 *meminfo = |
211 | 283k | (UWORD32 *)(p_obj_exhaacplus_dec->p_mem_info_aac + i_idx); |
212 | 283k | *pui_value = *(meminfo + (i_cmd - IA_API_CMD_GET_MEM_INFO_SIZE)); |
213 | 283k | } |
214 | | |
215 | 377k | return IA_NO_ERROR; |
216 | 377k | } |
217 | | |
218 | | static PLATFORM_INLINE VOID |
219 | 23.6k | ixheaacd_init_sbr_tables(ia_sbr_tables_struct *ptr_sbr_tables) { |
220 | 23.6k | ptr_sbr_tables->env_calc_tables_ptr = |
221 | 23.6k | (ia_env_calc_tables_struct *)&ixheaacd_aac_dec_env_calc_tables; |
222 | 23.6k | ptr_sbr_tables->qmf_dec_tables_ptr = |
223 | 23.6k | (ia_qmf_dec_tables_struct *)&ixheaacd_aac_qmf_dec_tables; |
224 | 23.6k | ptr_sbr_tables->env_extr_tables_ptr = |
225 | 23.6k | (ia_env_extr_tables_struct *)&ixheaacd_aac_dec_env_extr_tables; |
226 | 23.6k | ptr_sbr_tables->ps_tables_ptr = |
227 | 23.6k | (ia_ps_tables_struct *)&ixheaacd_aac_dec_ps_tables; |
228 | 23.6k | } |
229 | | |
230 | | VOID ixheaacd_updatebytesconsumed( |
231 | | ia_aac_dec_state_struct *p_state_enhaacplus_dec, |
232 | 264k | struct ia_bit_buf_struct *it_bit_buff) { |
233 | 264k | p_state_enhaacplus_dec->i_bytes_consumed = |
234 | 264k | (WORD32)(it_bit_buff->ptr_read_next - it_bit_buff->ptr_bit_buf_base); |
235 | 264k | if ((p_state_enhaacplus_dec->i_bytes_consumed == 0) && |
236 | 264k | (it_bit_buff->cnt_bits == 0)) { |
237 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = |
238 | 0 | p_state_enhaacplus_dec->ui_in_bytes; |
239 | 0 | } |
240 | 264k | if (it_bit_buff->cnt_bits < 0) { |
241 | 162 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
242 | 162 | p_state_enhaacplus_dec->ui_out_bytes = 0; |
243 | 162 | p_state_enhaacplus_dec->ui_mps_out_bytes = 0; |
244 | 162 | p_state_enhaacplus_dec->b_n_raw_data_blk = 0; |
245 | 162 | } |
246 | 264k | } |
247 | | |
248 | | static VOID copy_qmf_to_ldmps(ia_mps_dec_state_struct *mps_dec_handle, |
249 | 13.2k | VOID *sbr_persistent_mem_v) { |
250 | 13.2k | ia_sbr_pers_struct *sbr_persistent_mem = |
251 | 13.2k | (ia_sbr_pers_struct *)sbr_persistent_mem_v; |
252 | 13.2k | memcpy(&mps_dec_handle->str_mps_qmf_bank, |
253 | 13.2k | &sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[0] |
254 | 13.2k | ->str_sbr_dec.str_codec_qmf_bank, |
255 | 13.2k | sizeof(ia_sbr_qmf_filter_bank_struct)); |
256 | | |
257 | 13.2k | mps_dec_handle->sbr_tables_ptr = |
258 | 13.2k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables; |
259 | 13.2k | mps_dec_handle->qmf_dec_tables_ptr = |
260 | 13.2k | sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_tables->qmf_dec_tables_ptr; |
261 | 13.2k | mps_dec_handle->str_sbr_scale_fact = |
262 | 13.2k | &sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_channel[0] |
263 | 13.2k | ->str_sbr_dec.str_sbr_scale_fact; |
264 | 13.2k | } |
265 | | |
266 | | WORD32 ixheaacd_readifadts(ia_aac_dec_state_struct *p_state_enhaacplus_dec, |
267 | | struct ia_bit_buf_struct *it_bit_buff, |
268 | 49.3k | ia_adts_header_struct *adts) { |
269 | 49.3k | WORD error; |
270 | | |
271 | 49.3k | if ((error = ixheaacd_find_syncword(adts, it_bit_buff)) != 0) { |
272 | 1.29k | ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); |
273 | 1.29k | return IA_XHEAAC_DEC_EXE_NONFATAL_ADTS_SYNC_LOST; |
274 | 1.29k | } |
275 | 48.0k | if ((error = ixheaacd_check_if_adts( |
276 | 48.0k | adts, it_bit_buff, |
277 | 48.0k | p_state_enhaacplus_dec->p_config->ui_max_channels)) != 0) { |
278 | 494 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
279 | | |
280 | 494 | if (it_bit_buff->cnt_bits < 0) { |
281 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
282 | 0 | p_state_enhaacplus_dec->ui_out_bytes = 0; |
283 | 0 | p_state_enhaacplus_dec->ui_mps_out_bytes = 0; |
284 | 0 | error = IA_XHEAAC_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; |
285 | 0 | return error; |
286 | 0 | } |
287 | 494 | return IA_XHEAAC_DEC_EXE_NONFATAL_ADTS_SYNC_LOST; |
288 | 494 | } |
289 | 47.5k | p_state_enhaacplus_dec->b_n_raw_data_blk = |
290 | 47.5k | (WORD8)(adts->no_raw_data_blocks + 1); |
291 | 47.5k | return 0; |
292 | 48.0k | } |
293 | | |
294 | | static VOID ixheaacd_allocate_aac_scr( |
295 | | ia_aac_dec_scratch_struct *aac_scratch_struct, VOID *base_scratch_ptr, |
296 | | VOID *output_ptr, WORD channel, WORD max_channel, |
297 | 298k | WORD32 audio_object_type) { |
298 | 298k | WORD32 scratch_used = 0; |
299 | 298k | aac_scratch_struct->base_scr_8k = base_scratch_ptr; |
300 | 298k | aac_scratch_struct->extra_scr_4k[1] = (WORD8 *)base_scratch_ptr; |
301 | 298k | scratch_used += SCR_BASE_SCR_8K_SIZE; |
302 | 298k | if (channel == 1) { |
303 | 240k | aac_scratch_struct->extra_scr_4k[0] = (WORD8 *)base_scratch_ptr + scratch_used; |
304 | 240k | scratch_used += SCR_EXTRA_SCR_4K_0_SIZE; |
305 | 240k | aac_scratch_struct->extra_scr_4k[2] = (WORD8 *)base_scratch_ptr + scratch_used; |
306 | 240k | scratch_used += SCR_EXTRA_SCR_4K_2_SIZE; |
307 | 240k | } else { |
308 | 57.4k | aac_scratch_struct->extra_scr_4k[0] = output_ptr; |
309 | | |
310 | 57.4k | if (max_channel > 2) { |
311 | 57.4k | aac_scratch_struct->extra_scr_4k[0] = (WORD8 *)base_scratch_ptr + scratch_used; |
312 | 57.4k | scratch_used += SCR_EXTRA_SCR_4K_0_SIZE; |
313 | 57.4k | } |
314 | 57.4k | aac_scratch_struct->extra_scr_4k[2] = (WORD8 *)base_scratch_ptr + scratch_used; |
315 | 57.4k | scratch_used += SCR_EXTRA_SCR_4K_2_SIZE; |
316 | 57.4k | } |
317 | | |
318 | 298k | if (audio_object_type == AOT_ER_AAC_ELD || audio_object_type == AOT_ER_AAC_LD) { |
319 | 167k | aac_scratch_struct->extra_scr_4k[0] = (WORD8 *)base_scratch_ptr + scratch_used; |
320 | 167k | scratch_used += SCR_EXTRA_SCR_4K_0_SIZE; |
321 | | |
322 | 167k | aac_scratch_struct->extra_scr_4k[2] = (WORD8 *)base_scratch_ptr + scratch_used; |
323 | 167k | scratch_used += SCR_EXTRA_SCR_4K_2_SIZE; |
324 | | |
325 | 167k | aac_scratch_struct->extra_scr_4k[3] = (WORD8 *)base_scratch_ptr + scratch_used; |
326 | 167k | scratch_used += SCR_EXTRA_SCR_4K_3_SIZE; |
327 | 167k | } |
328 | 298k | if ((audio_object_type == AOT_ER_AAC_LD) || (audio_object_type == AOT_AAC_LTP)) { |
329 | 117k | aac_scratch_struct->out_data = (WORD32 *)((WORD8 *)base_scratch_ptr + scratch_used); |
330 | 117k | scratch_used += SCR_OUT_DATA_SIZE; |
331 | | |
332 | 117k | aac_scratch_struct->in_data = (WORD32 *)((WORD8 *)base_scratch_ptr + scratch_used); |
333 | 117k | scratch_used += SCR_IN_DATA_SIZE; |
334 | 117k | } |
335 | 298k | } |
336 | | |
337 | | VOID ixheaacd_allocate_sbr_scr(ia_sbr_scr_struct *sbr_scratch_struct, VOID *base_scratch_ptr, |
338 | | VOID *output_ptr, WORD32 total_channels, WORD8 *p_qshift_arr, |
339 | 309k | UWORD8 slot_pos, UWORD8 num_ch) { |
340 | 309k | WORD32 j, i; |
341 | 309k | sbr_scratch_struct->ptr_work_buf_core = base_scratch_ptr; |
342 | | |
343 | 309k | if (p_qshift_arr != NULL && *p_qshift_arr != LD_OBJ) { |
344 | 43.0k | WORD32 *tmp_buf = (WORD32 *)output_ptr; |
345 | | |
346 | 63.3k | for (j = 1; j < num_ch; j++) { |
347 | 20.2k | if ((*p_qshift_arr + j) == 0) |
348 | 0 | *(p_qshift_arr + j) = *(p_qshift_arr + j - 1); |
349 | 20.2k | } |
350 | | |
351 | 43.0k | if (total_channels > 2) { |
352 | 297 | for (j = 0; j < num_ch; j++) { |
353 | 168k | for (i = 0; i < 1024; i++) { |
354 | 167k | *((WORD16 *)tmp_buf + slot_pos + total_channels * i + j) = |
355 | 167k | ixheaac_round16(ixheaac_shl32_sat( |
356 | 167k | *(tmp_buf + slot_pos + total_channels * i + j), |
357 | 167k | *(p_qshift_arr + j))); |
358 | 167k | } |
359 | 164 | } |
360 | 42.9k | } else { |
361 | 106k | for (j = 0; j < num_ch; j++) { |
362 | 64.7M | for (i = 0; i < 1024; i++) { |
363 | 64.7M | *((WORD16 *)tmp_buf + total_channels * i + j) = |
364 | 64.7M | ixheaac_round16(ixheaac_shl32_sat( |
365 | 64.7M | *(tmp_buf + total_channels * i + j), *(p_qshift_arr + j))); |
366 | 64.7M | } |
367 | 63.1k | } |
368 | 42.9k | } |
369 | 43.0k | } |
370 | 309k | } |
371 | | |
372 | 0 | VOID ixheaacd_get_lib_id_strings(pVOID pv_output) { |
373 | 0 | ia_lib_info_struct *pstr_lib_info = (ia_lib_info_struct *)pv_output; |
374 | |
|
375 | 0 | pstr_lib_info->p_lib_name = (WORD8 *)LIBNAME; |
376 | 0 | pstr_lib_info->p_version_num = (WORD8 *)xHE_AAC_DEC_ITTIAM_VER; |
377 | |
|
378 | 0 | return; |
379 | 0 | } |
380 | | |
381 | | IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_xheaac_dec_obj, WORD32 i_cmd, |
382 | 4.93M | WORD32 i_idx, pVOID pv_value) { |
383 | 4.93M | ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec = p_ia_xheaac_dec_obj; |
384 | 4.93M | pUWORD32 pui_value = pv_value; |
385 | 4.93M | pWORD32 pui_value_signed = pv_value; |
386 | 4.93M | pWORD8 pb_value = pv_value; |
387 | 4.93M | pVOID *pp_value = (pVOID *)pv_value; |
388 | 4.93M | float *pf_value = pv_value; |
389 | | |
390 | 4.93M | if ((i_cmd != IA_API_CMD_GET_API_SIZE) && |
391 | 4.93M | (i_cmd != IA_API_CMD_GET_LIB_ID_STRINGS)) { |
392 | 4.90M | if (p_ia_xheaac_dec_obj == 0) { |
393 | 0 | return (IA_XHEAAC_DEC_API_FATAL_MEM_ALLOC); |
394 | 0 | } |
395 | 4.90M | if (((SIZE_T)p_ia_xheaac_dec_obj & 3) != 0) { |
396 | 0 | return (IA_XHEAAC_DEC_API_FATAL_MEM_ALIGN); |
397 | 0 | } |
398 | 4.90M | } |
399 | | |
400 | 4.93M | switch (i_cmd) { |
401 | 94.4k | case IA_API_CMD_GET_MEM_INFO_SIZE: |
402 | 188k | case IA_API_CMD_GET_MEM_INFO_ALIGNMENT: |
403 | 283k | case IA_API_CMD_GET_MEM_INFO_TYPE: |
404 | 377k | case IA_API_CMD_SET_MEM_PTR: { |
405 | 377k | return ixheaacd_dec_mem_api(p_ia_xheaac_dec_obj, i_cmd, i_idx, |
406 | 377k | pv_value); |
407 | 283k | } |
408 | | |
409 | 0 | case IA_API_CMD_GET_TABLE_INFO_SIZE: |
410 | 0 | case IA_API_CMD_GET_TABLE_INFO_ALIGNMENT: |
411 | 0 | case IA_API_CMD_SET_TABLE_PTR: |
412 | 0 | case IA_API_CMD_GET_TABLE_PTR: { |
413 | 0 | return ixheaacd_dec_table_api(p_ia_xheaac_dec_obj, i_cmd, i_idx, |
414 | 0 | pv_value); |
415 | 0 | } |
416 | 4.93M | }; |
417 | | |
418 | 4.55M | switch (i_cmd) { |
419 | 0 | case IA_API_CMD_GET_LIB_ID_STRINGS: { |
420 | 0 | WORD8 *i1_ver; |
421 | 0 | WORD8 ver_char; |
422 | |
|
423 | 0 | if (i_idx == IA_CMD_TYPE_LIB_NAME) |
424 | 0 | i1_ver = (WORD8 *)LIBNAME; |
425 | 0 | else if (i_idx == IA_CMD_TYPE_LIB_VERSION) |
426 | 0 | i1_ver = (WORD8 *)xHE_AAC_DEC_ITTIAM_VER; |
427 | 0 | else |
428 | 0 | return IA_XHEAAC_DEC_API_FATAL_INVALID_LIB_ID_STRINGS_IDX; |
429 | | |
430 | 0 | ver_char = *i1_ver++; |
431 | |
|
432 | 0 | for (; ver_char != '\0';) { |
433 | 0 | if (ver_char != '$') { |
434 | 0 | *pb_value++ = ver_char; |
435 | 0 | } |
436 | 0 | ver_char = *i1_ver++; |
437 | 0 | } |
438 | 0 | *pb_value = ver_char; |
439 | |
|
440 | 0 | break; |
441 | 0 | } |
442 | 23.6k | case IA_API_CMD_GET_API_SIZE: { |
443 | 23.6k | *pui_value = sizeof(ia_exhaacplus_dec_api_struct); |
444 | 23.6k | break; |
445 | 0 | } |
446 | 123k | case IA_API_CMD_INIT: { |
447 | 123k | switch (i_idx) { |
448 | 23.6k | case IA_CMD_TYPE_INIT_API_PRE_CONFIG_PARAMS: { |
449 | 23.6k | memset(p_obj_exhaacplus_dec, 0, sizeof(*p_obj_exhaacplus_dec)); |
450 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; |
451 | 23.6k | p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; |
452 | 23.6k | p_obj_exhaacplus_dec->aac_config.flag_08khz_out = 0; |
453 | 23.6k | p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; |
454 | 23.6k | p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 0; |
455 | 23.6k | p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; |
456 | 23.6k | p_obj_exhaacplus_dec->aac_config.header_dec_done = 0; |
457 | 23.6k | p_obj_exhaacplus_dec->aac_config.frame_status = 1; |
458 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 0; |
459 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; |
460 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 1; |
461 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_samp_freq = 0; |
462 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_frame_size = 0; |
463 | | |
464 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = 2; |
465 | 23.6k | p_obj_exhaacplus_dec->aac_config.i_channel_mask = 3; |
466 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 3; |
467 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 0; |
468 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_effect_type = 0; |
469 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_target_loudness = -24; |
470 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_loud_norm_flag = 0; |
471 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_hq_esbr = 0; |
472 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr = 1; |
473 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr_ps = 0; |
474 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr = 0; |
475 | 23.6k | p_obj_exhaacplus_dec->aac_config.loas_present = 0; |
476 | 23.6k | p_obj_exhaacplus_dec->aac_config.ld_decoder = 0; |
477 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 100; |
478 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 100; |
479 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_cut = 0; |
480 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_boost = 0; |
481 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; |
482 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_set = 0; |
483 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 0; |
484 | 23.6k | p_obj_exhaacplus_dec->aac_config.output_level = -1; |
485 | 23.6k | #ifdef LOUDNESS_LEVELING_SUPPORT |
486 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_loudness_leveling_flag = 1; |
487 | 23.6k | #endif |
488 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_max_channels = 6; |
489 | | |
490 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 0; |
491 | 23.6k | p_obj_exhaacplus_dec->aac_config.downmix = 0; |
492 | | |
493 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_err_conceal = 0; |
494 | | |
495 | 23.6k | { |
496 | 23.6k | ia_aac_dec_tables_struct *pstr_aac_tables = |
497 | 23.6k | &p_obj_exhaacplus_dec->aac_tables; |
498 | 23.6k | pstr_aac_tables->pstr_huffmann_tables = |
499 | 23.6k | (ia_aac_dec_huffman_tables_struct |
500 | 23.6k | *)&ixheaacd_aac_huffmann_tables; |
501 | 23.6k | pstr_aac_tables->pstr_block_tables = |
502 | 23.6k | (ia_aac_dec_block_tables_struct *)&ixheaacd_aac_block_tables; |
503 | 23.6k | pstr_aac_tables->pstr_imdct_tables = |
504 | 23.6k | (ia_aac_dec_imdct_tables_struct *)&ixheaacd_imdct_tables; |
505 | | |
506 | 23.6k | ixheaacd_huff_tables_create(pstr_aac_tables); |
507 | 23.6k | } |
508 | 23.6k | ixheaacd_init_sbr_tables(&p_obj_exhaacplus_dec->str_sbr_tables); |
509 | 23.6k | p_obj_exhaacplus_dec->common_tables = |
510 | 23.6k | (ixheaacd_misc_tables *)&ixheaacd_str_fft_n_transcendent_tables; |
511 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_qmf_bands = 64; |
512 | | |
513 | 23.6k | break; |
514 | 0 | } |
515 | 23.6k | case IA_CMD_TYPE_INIT_API_POST_CONFIG_PARAMS: { |
516 | 23.6k | ixheaacd_fill_aac_mem_tables(p_obj_exhaacplus_dec); |
517 | 23.6k | break; |
518 | 0 | } |
519 | 37.9k | case IA_CMD_TYPE_INIT_PROCESS: { |
520 | 37.9k | WORD32 err_code = 0; |
521 | 37.9k | if (p_obj_exhaacplus_dec->p_state_aac->fatal_err_present) { |
522 | 555 | err_code = IA_FATAL_ERROR; |
523 | 37.4k | } else { |
524 | 37.4k | err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); |
525 | 37.4k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal && err_code) { |
526 | 0 | if (err_code & IA_FATAL_ERROR) { |
527 | 0 | err_code = IA_XHEAAC_DEC_INIT_FATAL_EC_INIT_FAIL; |
528 | 0 | } else { |
529 | 0 | err_code = IA_XHEAAC_DEC_INIT_NONFATAL_EC_INIT_FAIL; |
530 | 0 | } |
531 | 0 | } |
532 | 37.4k | } |
533 | 37.9k | if (err_code != 0) { |
534 | 2.12k | if (err_code < 0) |
535 | 1.38k | p_obj_exhaacplus_dec->p_state_aac->fatal_err_present = 1; |
536 | 2.12k | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
537 | 2.12k | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; |
538 | 2.12k | } |
539 | 37.9k | return err_code; |
540 | 0 | break; |
541 | 0 | } |
542 | 37.9k | case IA_CMD_TYPE_INIT_DONE_QUERY: { |
543 | 37.9k | if (p_obj_exhaacplus_dec->p_state_aac->ui_init_done == 1) { |
544 | 19.9k | *pui_value = 1; |
545 | 19.9k | } else { |
546 | 17.9k | *pui_value = 0; |
547 | 17.9k | } |
548 | 37.9k | break; |
549 | 0 | } |
550 | | |
551 | 0 | case IA_CMD_TYPE_GA_HDR: { |
552 | 0 | return ixheaacd_decoder_2_ga_hdr(p_obj_exhaacplus_dec); |
553 | 0 | break; |
554 | 0 | } |
555 | | |
556 | 0 | case IA_CMD_TYPE_FLUSH_MEM: { |
557 | 0 | return ixheaacd_decoder_flush_api(p_obj_exhaacplus_dec); |
558 | 0 | break; |
559 | 0 | } |
560 | | |
561 | 0 | default: { |
562 | 0 | return IA_XHEAAC_DEC_API_NONFATAL_CMD_TYPE_NOT_SUPPORTED; |
563 | 0 | } |
564 | 123k | }; |
565 | 85.2k | break; |
566 | 123k | } |
567 | 188k | case IA_API_CMD_SET_CONFIG_PARAM: { |
568 | 188k | switch (i_idx) { |
569 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_SAMP_FREQ: { |
570 | 0 | if ((*pui_value < 8000) || (*pui_value > 96000)) { |
571 | 0 | return (IA_XHEAAC_DEC_CONFIG_FATAL_INVALID_SAMPLE_RATE); |
572 | 0 | } |
573 | 0 | p_obj_exhaacplus_dec->aac_config.ui_samp_freq = *pui_value; |
574 | 0 | break; |
575 | 0 | } |
576 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_FRAMELENGTH_FLAG: { |
577 | 0 | if ((*pui_value != 1) && (*pui_value != 0)) { |
578 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_FRAMELENGTHFLAG); |
579 | 0 | } |
580 | 0 | p_obj_exhaacplus_dec->aac_config.ui_frame_size = *pui_value; |
581 | 0 | break; |
582 | 0 | } |
583 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_PCM_WDSZ: { |
584 | 0 | if ((*pui_value != 16) && (*pui_value != 24)) { |
585 | 0 | p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; |
586 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_PCM_WDSZ); |
587 | 0 | } |
588 | 0 | p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = *pui_value; |
589 | 0 | break; |
590 | 0 | } |
591 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_DOWNMIX: { |
592 | 0 | if ((*pui_value != 1) && (*pui_value != 0)) { |
593 | 0 | p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; |
594 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_DOWNMIX); |
595 | 0 | } |
596 | 0 | p_obj_exhaacplus_dec->aac_config.flag_downmix = *pui_value; |
597 | 0 | p_obj_exhaacplus_dec->aac_config.downmix = *pui_value; |
598 | 0 | break; |
599 | 0 | } |
600 | | |
601 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_TOSTEREO: { |
602 | 0 | if ((*pui_value != 1) && (*pui_value != 0)) { |
603 | 0 | p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 1; |
604 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_TOSTEREO); |
605 | 0 | } |
606 | 0 | p_obj_exhaacplus_dec->aac_config.flag_to_stereo = *pui_value; |
607 | 0 | break; |
608 | 0 | } |
609 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_DSAMPLE: { |
610 | 0 | if ((*pui_value != 1) && (*pui_value != 0)) { |
611 | 0 | p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; |
612 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_DSAMPLE); |
613 | 0 | } |
614 | 0 | p_obj_exhaacplus_dec->aac_config.down_sample_flag = *pui_value; |
615 | 0 | break; |
616 | 0 | } |
617 | | |
618 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_MP4FLAG: { |
619 | 23.6k | if ((*pui_value != 1) && (*pui_value != 0)) { |
620 | 0 | p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 0; |
621 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_MP4FLAG); |
622 | 0 | } |
623 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = *pui_value; |
624 | 23.6k | break; |
625 | 23.6k | } |
626 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_DRC_CUT: { |
627 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; |
628 | 23.6k | if (*pf_value > 1 || *pf_value < 0) { |
629 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; |
630 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_DRC_CUT); |
631 | 0 | } |
632 | | |
633 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_cut = 1; |
634 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_cut = |
635 | 23.6k | (WORD32)((*pf_value) * 100); |
636 | 23.6k | break; |
637 | 23.6k | } |
638 | | |
639 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_DRC_BOOST: { |
640 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; |
641 | 23.6k | if (*pf_value > 1 || *pf_value < 0) { |
642 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; |
643 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_DRC_BOOST); |
644 | 0 | } |
645 | | |
646 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_boost = 1; |
647 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_boost = |
648 | 23.6k | (WORD32)((*pf_value) * 100); |
649 | 23.6k | break; |
650 | 23.6k | } |
651 | | |
652 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_DRC_TARGET_LEVEL: { |
653 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; |
654 | 23.6k | p_obj_exhaacplus_dec->aac_config.i_loud_ref_level = *pui_value_signed; |
655 | 23.6k | if (*pui_value > 127) { |
656 | 9.01k | p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; |
657 | 9.01k | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_DRC_TARGET); |
658 | 9.01k | } |
659 | 14.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = *pui_value; |
660 | 14.6k | break; |
661 | 23.6k | } |
662 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_DRC_HEAVY_COMP: { |
663 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_drc_set = 1; |
664 | 23.6k | if ((*pui_value != 1) && (*pui_value != 0)) { |
665 | 17.7k | p_obj_exhaacplus_dec->aac_config.ui_drc_heavy_comp = 0; |
666 | 17.7k | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_DRCFLAG); |
667 | 17.7k | } |
668 | 5.90k | p_obj_exhaacplus_dec->aac_config.ui_drc_heavy_comp = *pui_value; |
669 | 5.90k | break; |
670 | 23.6k | } |
671 | 0 | case IA_XHEAAC_DEC_CONFIG_DISABLE_SYNC: { |
672 | 0 | if ((*pui_value != 1) && (*pui_value != 0)) { |
673 | 0 | p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; |
674 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_SYNCFLAG); |
675 | 0 | } |
676 | 0 | p_obj_exhaacplus_dec->aac_config.ui_disable_sync = *pui_value; |
677 | 0 | break; |
678 | 0 | } |
679 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_AUTO_SBR_UPSAMPLE: { |
680 | 0 | if ((*pui_value != 1) && (*pui_value != 0)) { |
681 | 0 | p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 0; |
682 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_SBRUPFLAG); |
683 | 0 | } |
684 | 0 | p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = *pui_value; |
685 | 0 | break; |
686 | 0 | } |
687 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_MAX_CHANNEL: { |
688 | 0 | if (*pui_value > 8) { |
689 | 0 | p_obj_exhaacplus_dec->aac_config.ui_max_channels = 8; |
690 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_MAX_CHANNEL); |
691 | 0 | } |
692 | 0 | if (*pui_value < 2) { |
693 | 0 | p_obj_exhaacplus_dec->aac_config.ui_max_channels = 2; |
694 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_MAX_CHANNEL); |
695 | 0 | } |
696 | 0 | p_obj_exhaacplus_dec->aac_config.ui_max_channels = *pui_value; |
697 | 0 | break; |
698 | 0 | } |
699 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_FRAMESIZE: { |
700 | 0 | if (*pui_value == 1) { |
701 | 0 | p_obj_exhaacplus_dec->aac_config.framesize_480 = 1; |
702 | 0 | } else if (*pui_value == 0) { |
703 | 0 | p_obj_exhaacplus_dec->aac_config.framesize_480 = 0; |
704 | 0 | } else { |
705 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_FRAMSZ); |
706 | 0 | } |
707 | 0 | break; |
708 | 0 | } |
709 | | |
710 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_LD_TESTING: { |
711 | 0 | if (*pui_value == 1) { |
712 | 0 | p_obj_exhaacplus_dec->aac_config.ld_decoder = 1; |
713 | 0 | } else if (*pui_value == 0) { |
714 | 0 | p_obj_exhaacplus_dec->aac_config.ld_decoder = 0; |
715 | 0 | } else { |
716 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_LD_CONFIG); |
717 | 0 | } |
718 | 0 | break; |
719 | 0 | } |
720 | | |
721 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_COUP_CHANNEL: { |
722 | 0 | if (*pui_value > 16) { |
723 | 0 | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 1; |
724 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_COUP_CHANNEL); |
725 | 0 | } |
726 | 0 | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = *pui_value; |
727 | 0 | break; |
728 | 0 | } |
729 | | |
730 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_DOWNMIX_STEREO: { |
731 | 0 | if ((*pui_value != 1) && (*pui_value != 0)) { |
732 | 0 | p_obj_exhaacplus_dec->aac_config.downmix = 0; |
733 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_DOWNMIX_STEREO); |
734 | 0 | } |
735 | 0 | p_obj_exhaacplus_dec->aac_config.downmix = *pui_value; |
736 | 0 | break; |
737 | 0 | } |
738 | | |
739 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_DRC_EFFECT_TYPE: { |
740 | 23.6k | if (((*pui_value_signed) > 8) || ((*pui_value_signed) < -1)) { |
741 | 18.8k | p_obj_exhaacplus_dec->aac_config.ui_effect_type = -1; |
742 | 18.8k | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_EFFECT_TYPE); |
743 | 18.8k | } |
744 | 4.78k | p_obj_exhaacplus_dec->aac_config.ui_effect_type = *pui_value_signed; |
745 | 4.78k | break; |
746 | 23.6k | } |
747 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_DRC_TARGET_LOUDNESS: { |
748 | 23.6k | if (*pui_value_signed >= 0) { |
749 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_loud_norm_flag = 1; |
750 | 23.6k | } |
751 | 23.6k | *pui_value_signed = -(*pui_value_signed >> 2); |
752 | 23.6k | if (((*pui_value_signed) > 0) || ((*pui_value_signed) < -63)) { |
753 | 0 | p_obj_exhaacplus_dec->aac_config.ui_target_loudness = 0; |
754 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_TARGET_LOUDNESS); |
755 | 0 | } |
756 | 23.6k | p_obj_exhaacplus_dec->aac_config.ui_target_loudness = |
757 | 23.6k | *pui_value_signed; |
758 | 23.6k | break; |
759 | 23.6k | } |
760 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_HQ_ESBR: { |
761 | 0 | if (((*pui_value_signed) != 0) && ((*pui_value_signed) != 1)) { |
762 | 0 | p_obj_exhaacplus_dec->aac_config.ui_hq_esbr = 0; |
763 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_ESBR_HQ_FLAG); |
764 | 0 | } |
765 | 0 | p_obj_exhaacplus_dec->aac_config.ui_hq_esbr = *pui_value_signed; |
766 | 0 | break; |
767 | 0 | } |
768 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_PS_ENABLE: { |
769 | 0 | if (((*pui_value_signed) != 0) && ((*pui_value_signed) != 1)) { |
770 | 0 | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr_ps = 0; |
771 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_ESBR_PS_FLAG); |
772 | 0 | } |
773 | 0 | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr_ps = *pui_value_signed; |
774 | 0 | break; |
775 | 0 | } |
776 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_PEAK_LIMITER: { |
777 | 0 | if (((*pui_value_signed) != 0) && ((*pui_value_signed) != 1)) { |
778 | 0 | p_obj_exhaacplus_dec->aac_config.peak_limiter_off = 0; |
779 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_PEAK_LIM_FLAG_TYPE); |
780 | 0 | } |
781 | 0 | p_obj_exhaacplus_dec->aac_config.peak_limiter_off = *pui_value_signed; |
782 | 0 | break; |
783 | 0 | } |
784 | 0 | case IA_XHEAAC_DEC_CONFIG_ERROR_CONCEALMENT: { |
785 | 0 | if (((*pui_value_signed) != 0) && ((*pui_value_signed) != 1)) { |
786 | 0 | p_obj_exhaacplus_dec->aac_config.ui_err_conceal = 0; |
787 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_ERR_CONCEAL_FLAG_TYPE); |
788 | 0 | } |
789 | 0 | p_obj_exhaacplus_dec->aac_config.ui_err_conceal = *pui_value_signed; |
790 | 0 | break; |
791 | 0 | } |
792 | 0 | case IA_XHEAAC_DEC_CONFIG_PARAM_ESBR: { |
793 | 0 | if (((*pui_value_signed) != 0) && ((*pui_value_signed) != 1)) { |
794 | 0 | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr = 1; |
795 | 0 | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_ESBR_FLAG); |
796 | 0 | } |
797 | 0 | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr = *pui_value_signed; |
798 | 0 | break; |
799 | 0 | } |
800 | 0 | #ifdef LOUDNESS_LEVELING_SUPPORT |
801 | 23.6k | case IA_XHEAAC_DEC_CONFIG_PARAM_DRC_LOUDNESS_LEVELING: { |
802 | 23.6k | if (((*pui_value_signed) != 0) && ((*pui_value_signed) != 1)) { |
803 | 19.4k | p_obj_exhaacplus_dec->aac_config.ui_loudness_leveling_flag = 1; |
804 | 19.4k | return (IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_LOUDNESS_LEVELING_FLAG); |
805 | 19.4k | } |
806 | 4.19k | p_obj_exhaacplus_dec->aac_config.ui_loudness_leveling_flag = *pui_value_signed; |
807 | 4.19k | break; |
808 | 23.6k | } |
809 | 0 | #endif |
810 | 0 | default: { return IA_XHEAAC_DEC_API_FATAL_INVALID_CONFIG_PARAM; } |
811 | 188k | } |
812 | 123k | break; |
813 | 188k | } |
814 | | |
815 | 1.36M | case IA_API_CMD_GET_CONFIG_PARAM: { |
816 | 1.36M | UWORD32 i; |
817 | 1.36M | WORD32 *pvalue = |
818 | 1.36M | (WORD32 *)(&p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz); |
819 | 1.36M | if (IA_XHEAAC_DEC_CONFIG_PARAM_NUM_CHANNELS == i_idx) { |
820 | 19.9k | if (p_obj_exhaacplus_dec->p_state_aac != NULL && |
821 | 19.9k | p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle |
822 | 19.9k | .heaac_mps_present == 1) { |
823 | 4.27k | *pui_value = p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle |
824 | 4.27k | .num_output_channels_at; |
825 | 15.7k | } else { |
826 | 15.7k | *pui_value = pvalue[i_idx]; |
827 | 15.7k | } |
828 | 1.34M | } else if (IA_XHEAAC_DEC_CONFIG_PARAM_CHANNEL_MASK == i_idx) { |
829 | 19.9k | if (p_obj_exhaacplus_dec->p_state_aac != NULL && |
830 | 19.9k | p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle |
831 | 19.9k | .heaac_mps_present == 1) { |
832 | 4.27k | *pui_value = p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle |
833 | 4.27k | .bs_config.ui_channel_mask; |
834 | 15.7k | } else { |
835 | 15.7k | *pui_value = pvalue[i_idx]; |
836 | 15.7k | } |
837 | 19.9k | } else |
838 | 1.32M | if (i_idx >= 0 && i_idx <= 8) { |
839 | 159k | *pui_value = pvalue[i_idx]; |
840 | 1.16M | } else if (IA_ENHAACPLUS_DEC_CONFIG_GET_NUM_PRE_ROLL_FRAMES == i_idx) { |
841 | 0 | WORD32 *ptri_value = (WORD32 *)pv_value; |
842 | 0 | ia_audio_specific_config_struct *ptr_audio_specific_config = |
843 | 0 | ((ia_audio_specific_config_struct *) |
844 | 0 | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
845 | |
|
846 | 0 | for (i = 0; i < MAX_AUDIO_PREROLLS + 1; i++) { |
847 | 0 | if (ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
848 | 0 | .preroll_bytes[i] == 0) { |
849 | 0 | break; |
850 | 0 | } |
851 | 0 | } |
852 | |
|
853 | 0 | *ptri_value = i; |
854 | 1.16M | } else if (IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR == i_idx) { |
855 | 19.9k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
856 | 19.9k | ((ia_audio_specific_config_struct *) |
857 | 19.9k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
858 | | |
859 | 29.8k | for (i = 0; i < ptr_audio_specific_config->str_usac_config |
860 | 29.8k | .str_usac_dec_config.num_config_extensions; |
861 | 19.9k | i++) { |
862 | 9.90k | pp_value[i] = ptr_audio_specific_config->str_usac_config |
863 | 9.90k | .str_usac_dec_config.usac_cfg_ext_info_buf[i]; |
864 | 9.90k | } |
865 | | |
866 | 38.6k | for (i = 0; i < ptr_audio_specific_config->str_usac_config |
867 | 38.6k | .str_usac_dec_config.num_elements; |
868 | 19.9k | i++) { |
869 | 18.7k | if (ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
870 | 18.7k | .usac_ext_ele_payload_present[i]) { |
871 | 1.68k | pp_value[i + 16] = |
872 | 1.68k | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
873 | 1.68k | .usac_ext_ele_payload_buf[i]; |
874 | 1.68k | } |
875 | 18.7k | } |
876 | 1.14M | } else if (IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_BUF_SIZES == i_idx) { |
877 | 19.9k | WORD32 *ptri_value = (WORD32 *)pv_value; |
878 | 19.9k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
879 | 19.9k | ((ia_audio_specific_config_struct *) |
880 | 19.9k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
881 | 29.8k | for (i = 0; i < ptr_audio_specific_config->str_usac_config |
882 | 29.8k | .str_usac_dec_config.num_config_extensions; |
883 | 19.9k | i++) { |
884 | 9.90k | ptri_value[i] = ptr_audio_specific_config->str_usac_config |
885 | 9.90k | .str_usac_dec_config.usac_cfg_ext_info_len[i]; |
886 | 9.90k | } |
887 | 38.6k | for (i = 0; i < ptr_audio_specific_config->str_usac_config |
888 | 38.6k | .str_usac_dec_config.num_elements; |
889 | 19.9k | i++) { |
890 | 18.7k | ptri_value[i + 16] = |
891 | 18.7k | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
892 | 18.7k | .usac_ext_ele_payload_len[i]; |
893 | 18.7k | } |
894 | | |
895 | 1.12M | } else if (IA_ENHAACPLUS_DEC_DRC_IS_CONFIG_CHANGED == i_idx) { |
896 | 0 | *pui_value = p_obj_exhaacplus_dec->p_state_aac->drc_config_changed; |
897 | 1.12M | } else if (IA_ENHAACPLUS_DEC_DRC_APPLY_CROSSFADE == i_idx) { |
898 | 0 | *pui_value = p_obj_exhaacplus_dec->p_state_aac->apply_crossfade; |
899 | 1.12M | } else if (IA_ENHAACPLUS_DEC_CONFIG_NUM_ELE == i_idx) { |
900 | 19.9k | UWORD32 *ptri_value = (UWORD32 *)pv_value; |
901 | 19.9k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
902 | 19.9k | ((ia_audio_specific_config_struct *) |
903 | 19.9k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
904 | 19.9k | *ptri_value = ptr_audio_specific_config->str_usac_config |
905 | 19.9k | .str_usac_dec_config.num_elements; |
906 | | |
907 | 1.10M | } else if (IA_ENHAACPLUS_DEC_CONFIG_NUM_CONFIG_EXT == i_idx) { |
908 | 19.9k | UWORD32 *ptri_value = (UWORD32 *)pv_value; |
909 | 19.9k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
910 | 19.9k | ((ia_audio_specific_config_struct *) |
911 | 19.9k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
912 | 19.9k | *ptri_value = ptr_audio_specific_config->str_usac_config |
913 | 19.9k | .str_usac_dec_config.num_config_extensions; |
914 | 1.08M | } else if (IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_LEN == i_idx) { |
915 | 541k | UWORD32 *ptri_value = (UWORD32 *)pv_value; |
916 | 541k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
917 | 541k | ((ia_audio_specific_config_struct *) |
918 | 541k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
919 | 541k | WORD32 preroll_counter = ptr_audio_specific_config->str_usac_config |
920 | 541k | .str_usac_dec_config.preroll_counter; |
921 | 541k | *ptri_value = |
922 | 541k | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
923 | 541k | .usac_ext_gain_payload_len[preroll_counter]; |
924 | 541k | } else if (IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF == i_idx) { |
925 | 541k | WORD32 payload_buffer_offeset = 0; |
926 | 541k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
927 | 541k | ((ia_audio_specific_config_struct *) |
928 | 541k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
929 | 541k | WORD32 preroll_counter = ptr_audio_specific_config->str_usac_config |
930 | 541k | .str_usac_dec_config.preroll_counter; |
931 | 544k | for (i = 0; i < (UWORD32)preroll_counter; i++) |
932 | 2.25k | payload_buffer_offeset += |
933 | 2.25k | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
934 | 2.25k | .usac_ext_gain_payload_len[i] * |
935 | 2.25k | sizeof(WORD8); |
936 | 541k | *pp_value = ptr_audio_specific_config->str_usac_config |
937 | 541k | .str_usac_dec_config.usac_ext_gain_payload_buf + |
938 | 541k | payload_buffer_offeset; |
939 | 541k | } else if (IA_XHEAAC_DEC_CONFIG_PARAM_AOT == i_idx) { |
940 | 0 | if (p_obj_exhaacplus_dec->p_state_aac != NULL) { |
941 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_mp4_flag == 1) { |
942 | 0 | ia_audio_specific_config_struct *ptr_audio_specific_config = |
943 | 0 | ((ia_audio_specific_config_struct *) |
944 | 0 | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
945 | 0 | *pui_value = ptr_audio_specific_config->audio_object_type; |
946 | 0 | } else { |
947 | 0 | *pui_value = p_obj_exhaacplus_dec->p_state_aac->audio_object_type; |
948 | 0 | } |
949 | 0 | } else { |
950 | 0 | *pui_value = AOT_AAC_LC; |
951 | 0 | } |
952 | 0 | } |
953 | 0 | #ifdef LOUDNESS_LEVELING_SUPPORT |
954 | 0 | else if (IA_XHEAAC_DEC_CONFIG_PARAM_DRC_LOUDNESS_LEVELING == i_idx) { |
955 | 0 | WORD32 *ui_value = |
956 | 0 | (WORD32 *)(&p_obj_exhaacplus_dec->aac_config.ui_loudness_leveling_flag); |
957 | 0 | *pui_value = *ui_value; |
958 | 0 | } |
959 | 0 | #endif |
960 | 0 | else if (IA_XHEAAC_DEC_CONFIG_PARAM_DRC_CUT == i_idx) { |
961 | 0 | UWORD32 *ui_value = (UWORD32 *)(&p_obj_exhaacplus_dec->aac_config.ui_drc_cut); |
962 | 0 | *pui_value = *ui_value; |
963 | 0 | } else if (IA_XHEAAC_DEC_CONFIG_PARAM_DRC_BOOST == i_idx) { |
964 | 0 | UWORD32 *ui_value = (UWORD32 *)(&p_obj_exhaacplus_dec->aac_config.ui_drc_boost); |
965 | 0 | *pui_value = *ui_value; |
966 | 0 | } else if (IA_XHEAAC_DEC_CONFIG_PARAM_DRC_MODE_CUT == i_idx) { |
967 | 0 | UWORD8 *ui_value = (&p_obj_exhaacplus_dec->aac_config.ui_drc_mode_cut); |
968 | 0 | *pb_value = *ui_value; |
969 | 0 | } else if (IA_XHEAAC_DEC_CONFIG_PARAM_DRC_MODE_BOOST == i_idx) { |
970 | 0 | UWORD8 *ui_value = (&p_obj_exhaacplus_dec->aac_config.ui_drc_mode_boost); |
971 | 0 | *pb_value = *ui_value; |
972 | 0 | } |
973 | 0 | else { |
974 | 0 | return IA_XHEAAC_DEC_API_FATAL_INVALID_CONFIG_PARAM; |
975 | 0 | } |
976 | 1.36M | break; |
977 | 1.36M | } |
978 | | |
979 | 1.36M | case IA_API_CMD_GET_MEMTABS_SIZE: { |
980 | 23.6k | *pui_value = (sizeof(ia_mem_info_struct) + sizeof(pVOID *)) * |
981 | 23.6k | (IA_ENHAACPDEC_NUM_MEMTABS); |
982 | 23.6k | break; |
983 | 1.36M | } |
984 | 0 | case IA_API_CMD_GET_LOUDNESS_VAL: { |
985 | 0 | *pui_value = p_obj_exhaacplus_dec->aac_config.output_level; |
986 | 0 | break; |
987 | 1.36M | } |
988 | 23.6k | case IA_API_CMD_SET_MEMTABS_PTR: { |
989 | 23.6k | if (pv_value == NULL) return IA_XHEAAC_DEC_API_FATAL_MEM_ALLOC; |
990 | 23.6k | memset(pv_value, 0, (sizeof(ia_mem_info_struct) + sizeof(pVOID *)) * |
991 | 23.6k | (IA_ENHAACPDEC_NUM_MEMTABS)); |
992 | | |
993 | 23.6k | p_obj_exhaacplus_dec->p_mem_info_aac = pv_value; |
994 | 23.6k | p_obj_exhaacplus_dec->pp_mem_aac = |
995 | 23.6k | (pVOID *)((WORD8 *)pv_value + |
996 | 23.6k | sizeof(ia_mem_info_struct) * IA_ENHAACPDEC_NUM_MEMTABS); |
997 | | |
998 | 23.6k | break; |
999 | 23.6k | } |
1000 | 0 | case IA_API_CMD_GET_N_MEMTABS: { |
1001 | 0 | *pui_value = IA_ENHAACPDEC_NUM_MEMTABS; |
1002 | 0 | break; |
1003 | 23.6k | } |
1004 | | |
1005 | 0 | case IA_API_CMD_GET_N_TABLES: { |
1006 | 0 | *pui_value = NUM_AAC_TABLES + NUM_MPS_TABLES; |
1007 | 0 | break; |
1008 | 23.6k | } |
1009 | 1.08M | case IA_API_CMD_EXECUTE: { |
1010 | 1.08M | switch (i_idx) { |
1011 | 541k | case IA_CMD_TYPE_DO_EXECUTE: { |
1012 | 541k | WORD32 err_code = 0; |
1013 | 541k | if (!p_obj_exhaacplus_dec->p_state_aac->ui_init_done || |
1014 | 541k | p_obj_exhaacplus_dec->p_state_aac->fatal_err_present) { |
1015 | 3.75k | err_code = IA_FATAL_ERROR; |
1016 | 538k | } else { |
1017 | 538k | memset(p_obj_exhaacplus_dec->p_state_aac->qshift_adj, 0, |
1018 | 538k | sizeof(p_obj_exhaacplus_dec->p_state_aac->qshift_adj)); |
1019 | 538k | p_obj_exhaacplus_dec->p_state_aac->qshift_cnt = 0; |
1020 | 538k | err_code = ixheaacd_dec_execute(p_obj_exhaacplus_dec); |
1021 | 538k | } |
1022 | 541k | if (err_code != IA_NO_ERROR) { |
1023 | 21.0k | if (err_code < 0) { |
1024 | 7.31k | p_obj_exhaacplus_dec->p_state_aac->fatal_err_present = 1; |
1025 | 7.31k | } |
1026 | 21.0k | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
1027 | 21.0k | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; |
1028 | 21.0k | } |
1029 | 541k | return err_code; |
1030 | 0 | break; |
1031 | 0 | } |
1032 | 541k | case IA_CMD_TYPE_DONE_QUERY: { |
1033 | 541k | if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 1) { |
1034 | 0 | *pui_value = 1; |
1035 | 541k | } else { |
1036 | 541k | *pui_value = 0; |
1037 | 541k | } |
1038 | | |
1039 | 541k | break; |
1040 | 0 | } |
1041 | 0 | default: { return IA_XHEAAC_DEC_API_FATAL_INVALID_EXECUTE_TYPE; } |
1042 | 1.08M | }; |
1043 | 541k | break; |
1044 | 1.08M | } |
1045 | 579k | case IA_API_CMD_GET_CURIDX_INPUT_BUF: { |
1046 | 579k | *pui_value = p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed; |
1047 | 579k | break; |
1048 | 1.08M | } |
1049 | 579k | case IA_API_CMD_SET_INPUT_BYTES: { |
1050 | 579k | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes = *pui_value; |
1051 | 579k | break; |
1052 | 1.08M | } |
1053 | 541k | case IA_API_CMD_GET_OUTPUT_BYTES: { |
1054 | 541k | if (1 == i_idx) { |
1055 | 0 | *pui_value = p_obj_exhaacplus_dec->p_state_aac->ui_mps_out_bytes; |
1056 | 541k | } else { |
1057 | 541k | *pui_value = p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes; |
1058 | 541k | } |
1059 | 541k | if (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == AOT_USAC) { |
1060 | 265k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
1061 | 265k | ((ia_audio_specific_config_struct *) |
1062 | 265k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
1063 | | |
1064 | 265k | WORD32 preroll_counter = ptr_audio_specific_config->str_usac_config |
1065 | 265k | .str_usac_dec_config.preroll_counter; |
1066 | | |
1067 | 265k | *pui_value = ptr_audio_specific_config->str_usac_config |
1068 | 265k | .str_usac_dec_config.preroll_bytes[preroll_counter]; |
1069 | | |
1070 | 265k | preroll_counter++; |
1071 | 265k | if (preroll_counter > (MAX_AUDIO_PREROLLS + 1)) return IA_FATAL_ERROR; |
1072 | 265k | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
1073 | 265k | .preroll_counter = preroll_counter; |
1074 | 265k | } |
1075 | 541k | break; |
1076 | 541k | } |
1077 | 541k | case IA_API_CMD_INPUT_OVER: { |
1078 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->ui_input_over = 1; |
1079 | 23.6k | break; |
1080 | 541k | } |
1081 | 0 | default: { return IA_XHEAAC_DEC_API_FATAL_INVALID_CMD; } |
1082 | 4.55M | }; |
1083 | 3.90M | return IA_NO_ERROR; |
1084 | 4.55M | } |
1085 | | |
1086 | 0 | IA_ERRORCODE ixheaacd_decoder_2_ga_hdr(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { |
1087 | 0 | IA_ERRORCODE err_code = IA_NO_ERROR; |
1088 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { |
1089 | 0 | p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; |
1090 | 0 | p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; |
1091 | 0 | p_obj_exhaacplus_dec->aac_config.flag_08khz_out = 0; |
1092 | 0 | p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; |
1093 | 0 | p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 0; |
1094 | 0 | p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; |
1095 | 0 | p_obj_exhaacplus_dec->aac_config.header_dec_done = 0; |
1096 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 1; |
1097 | 0 | p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 1; |
1098 | 0 | p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; |
1099 | 0 | p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 1; |
1100 | 0 | p_obj_exhaacplus_dec->aac_config.ui_samp_freq = 0; |
1101 | 0 | p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 3; |
1102 | 0 | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 2; |
1103 | 0 | p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr = 0; |
1104 | 0 | p_obj_exhaacplus_dec->aac_config.loas_present = 0; |
1105 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; |
1106 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; |
1107 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_cut = 0; |
1108 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_boost = 0; |
1109 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; |
1110 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_set = 0; |
1111 | 0 | p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 1; |
1112 | |
|
1113 | 0 | p_obj_exhaacplus_dec->aac_config.ui_max_channels = 6; |
1114 | |
|
1115 | 0 | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 0; |
1116 | 0 | p_obj_exhaacplus_dec->aac_config.downmix = 0; |
1117 | |
|
1118 | 0 | { |
1119 | 0 | ia_aac_dec_tables_struct *pstr_aac_tables = |
1120 | 0 | &p_obj_exhaacplus_dec->aac_tables; |
1121 | 0 | pstr_aac_tables->pstr_huffmann_tables = |
1122 | 0 | (ia_aac_dec_huffman_tables_struct *)&ixheaacd_aac_huffmann_tables; |
1123 | 0 | pstr_aac_tables->pstr_block_tables = |
1124 | 0 | (ia_aac_dec_block_tables_struct *)&ixheaacd_aac_block_tables; |
1125 | 0 | pstr_aac_tables->pstr_imdct_tables = |
1126 | 0 | (ia_aac_dec_imdct_tables_struct *)&ixheaacd_imdct_tables; |
1127 | |
|
1128 | 0 | ixheaacd_huff_tables_create(pstr_aac_tables); |
1129 | 0 | } |
1130 | 0 | ixheaacd_init_sbr_tables(&p_obj_exhaacplus_dec->str_sbr_tables); |
1131 | 0 | p_obj_exhaacplus_dec->common_tables = |
1132 | 0 | (ixheaacd_misc_tables *)&ixheaacd_str_fft_n_transcendent_tables; |
1133 | 0 | p_obj_exhaacplus_dec->aac_config.ui_qmf_bands = 64; |
1134 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_init_done = 0; |
1135 | |
|
1136 | 0 | err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); |
1137 | 0 | } else { |
1138 | 0 | p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 0; |
1139 | 0 | err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); |
1140 | 0 | } |
1141 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal && err_code) { |
1142 | 0 | if (err_code & IA_FATAL_ERROR) { |
1143 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_EC_INIT_FAIL; |
1144 | 0 | } else { |
1145 | 0 | return IA_XHEAAC_DEC_INIT_NONFATAL_EC_INIT_FAIL; |
1146 | 0 | } |
1147 | 0 | } else { |
1148 | 0 | return err_code; |
1149 | 0 | } |
1150 | 0 | } |
1151 | | |
1152 | 0 | IA_ERRORCODE ixheaacd_decoder_flush_api(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { |
1153 | 0 | IA_ERRORCODE err_code = IA_NO_ERROR; |
1154 | 0 | UWORD8 *header_temp_ptr; |
1155 | 0 | WORD32 header_length; |
1156 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { |
1157 | 0 | header_temp_ptr = p_obj_exhaacplus_dec->p_state_aac->header_ptr; |
1158 | 0 | header_length = p_obj_exhaacplus_dec->p_state_aac->header_length; |
1159 | 0 | memset(p_obj_exhaacplus_dec->p_state_aac, 0, |
1160 | 0 | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8)); |
1161 | 0 | { |
1162 | 0 | pUWORD8 p_temp = (pUWORD8)p_obj_exhaacplus_dec->p_state_aac; |
1163 | 0 | UWORD32 *meminfo = (UWORD32 *)p_obj_exhaacplus_dec->p_mem_info_aac; |
1164 | 0 | UWORD32 pers_size = meminfo[0]; |
1165 | 0 | p_temp = p_temp + pers_size - |
1166 | 0 | (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + |
1167 | 0 | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8) + |
1168 | 0 | IXHEAAC_GET_SIZE_ALIGNED(MAX_HEADER_BUF_SIZE, BYTE_ALIGN_8)); |
1169 | |
|
1170 | 0 | p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data = p_temp; |
1171 | 0 | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = |
1172 | 0 | p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8); |
1173 | 0 | p_obj_exhaacplus_dec->p_state_aac->header_ptr = |
1174 | 0 | p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + |
1175 | 0 | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8); |
1176 | 0 | } |
1177 | 0 | memset(&(p_obj_exhaacplus_dec->aac_config), 0, |
1178 | 0 | sizeof(ia_aac_dec_config_struct)); |
1179 | |
|
1180 | 0 | p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz = 16; |
1181 | 0 | p_obj_exhaacplus_dec->aac_config.flag_downmix = 0; |
1182 | 0 | p_obj_exhaacplus_dec->aac_config.flag_08khz_out = 0; |
1183 | 0 | p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; |
1184 | 0 | p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 0; |
1185 | 0 | p_obj_exhaacplus_dec->aac_config.down_sample_flag = 0; |
1186 | 0 | p_obj_exhaacplus_dec->aac_config.header_dec_done = 0; |
1187 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 1; |
1188 | 0 | p_obj_exhaacplus_dec->aac_config.ui_mp4_flag = 1; |
1189 | 0 | p_obj_exhaacplus_dec->aac_config.ui_disable_sync = 0; |
1190 | 0 | p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample = 1; |
1191 | 0 | p_obj_exhaacplus_dec->aac_config.ui_samp_freq = 0; |
1192 | 0 | p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 3; |
1193 | 0 | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 2; |
1194 | 0 | p_obj_exhaacplus_dec->aac_config.ui_pce_found_in_hdr = 0; |
1195 | 0 | p_obj_exhaacplus_dec->aac_config.loas_present = 0; |
1196 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_boost = 0; |
1197 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_cut = 0; |
1198 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_cut = 0; |
1199 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_mode_boost = 0; |
1200 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_target_level = 108; |
1201 | 0 | p_obj_exhaacplus_dec->aac_config.ui_drc_set = 0; |
1202 | 0 | p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 1; |
1203 | |
|
1204 | 0 | p_obj_exhaacplus_dec->aac_config.ui_max_channels = 6; |
1205 | |
|
1206 | 0 | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel = 0; |
1207 | 0 | p_obj_exhaacplus_dec->aac_config.downmix = 0; |
1208 | 0 | p_obj_exhaacplus_dec->p_state_aac->peak_lim_init = 0; |
1209 | |
|
1210 | 0 | { |
1211 | 0 | ia_aac_dec_tables_struct *pstr_aac_tables = |
1212 | 0 | &p_obj_exhaacplus_dec->aac_tables; |
1213 | 0 | pstr_aac_tables->pstr_huffmann_tables = |
1214 | 0 | (ia_aac_dec_huffman_tables_struct *)&ixheaacd_aac_huffmann_tables; |
1215 | 0 | pstr_aac_tables->pstr_block_tables = |
1216 | 0 | (ia_aac_dec_block_tables_struct *)&ixheaacd_aac_block_tables; |
1217 | 0 | pstr_aac_tables->pstr_imdct_tables = |
1218 | 0 | (ia_aac_dec_imdct_tables_struct *)&ixheaacd_imdct_tables; |
1219 | |
|
1220 | 0 | ixheaacd_huff_tables_create(pstr_aac_tables); |
1221 | 0 | } |
1222 | 0 | ixheaacd_init_sbr_tables(&p_obj_exhaacplus_dec->str_sbr_tables); |
1223 | 0 | p_obj_exhaacplus_dec->common_tables = |
1224 | 0 | (ixheaacd_misc_tables *)&ixheaacd_str_fft_n_transcendent_tables; |
1225 | 0 | p_obj_exhaacplus_dec->aac_config.ui_qmf_bands = 64; |
1226 | 0 | p_obj_exhaacplus_dec->p_state_aac->header_ptr = header_temp_ptr; |
1227 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes = header_length; |
1228 | 0 | p_obj_exhaacplus_dec->p_state_aac->header_length = header_length; |
1229 | |
|
1230 | 0 | err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); |
1231 | 0 | } else { |
1232 | 0 | p_obj_exhaacplus_dec->aac_config.ui_flush_cmd = 0; |
1233 | 0 | err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); |
1234 | 0 | } |
1235 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal && err_code) { |
1236 | 0 | if (err_code & IA_FATAL_ERROR) { |
1237 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_EC_INIT_FAIL; |
1238 | 0 | } else { |
1239 | 0 | return IA_XHEAAC_DEC_INIT_NONFATAL_EC_INIT_FAIL; |
1240 | 0 | } |
1241 | 0 | } else { |
1242 | 0 | return err_code; |
1243 | 0 | } |
1244 | 0 | } |
1245 | | |
1246 | | static PLATFORM_INLINE WORD32 |
1247 | 23.6k | ixheaacd_persistent_buffer_sizes(WORD32 num_channel) { |
1248 | 23.6k | WORD32 size_buffers = 0; |
1249 | | |
1250 | 23.6k | WORD32 temp; |
1251 | 23.6k | WORD32 max_channels; |
1252 | | |
1253 | 23.6k | size_buffers += IXHEAAC_GET_SIZE_ALIGNED(4 * 512 * num_channel * sizeof(WORD32), BYTE_ALIGN_8); |
1254 | | |
1255 | 23.6k | size_buffers += |
1256 | 23.6k | num_channel * IXHEAAC_GET_SIZE_ALIGNED(ltp_buffer_size * sizeof(WORD16), BYTE_ALIGN_8); |
1257 | | |
1258 | 23.6k | size_buffers += |
1259 | 23.6k | num_channel * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_channel_info), BYTE_ALIGN_8); |
1260 | | |
1261 | 23.6k | if (num_channel > 2) { |
1262 | 23.6k | max_channels = MAX_BS_ELEMENT; |
1263 | 23.6k | } else { |
1264 | 0 | max_channels = 2; |
1265 | 0 | } |
1266 | 23.6k | size_buffers += (max_channels)*2 * |
1267 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), BYTE_ALIGN_8); |
1268 | | |
1269 | 23.6k | size_buffers += |
1270 | 23.6k | num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAXSBRBYTES * sizeof(WORD8), BYTE_ALIGN_8); |
1271 | | |
1272 | 23.6k | size_buffers += |
1273 | 23.6k | num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAXSBRBYTES * sizeof(WORD8), BYTE_ALIGN_8); |
1274 | | |
1275 | 23.6k | size_buffers += |
1276 | 23.6k | 2 * num_channel * |
1277 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED( |
1278 | 23.6k | (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * sizeof(WORD16), BYTE_ALIGN_8); |
1279 | | |
1280 | 23.6k | size_buffers += |
1281 | 23.6k | 2 * num_channel * |
1282 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED( |
1283 | 23.6k | (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * sizeof(WORD32), BYTE_ALIGN_8); |
1284 | | |
1285 | 23.6k | size_buffers += |
1286 | 23.6k | 2 * num_channel * |
1287 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED( |
1288 | 23.6k | (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * sizeof(WORD16), BYTE_ALIGN_8); |
1289 | | |
1290 | 23.6k | size_buffers += |
1291 | 23.6k | 2 * num_channel * |
1292 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED( |
1293 | 23.6k | (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * sizeof(WORD32), BYTE_ALIGN_8); |
1294 | | |
1295 | 23.6k | size_buffers += num_channel * 2 * |
1296 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32), |
1297 | 23.6k | BYTE_ALIGN_8); |
1298 | | |
1299 | 23.6k | size_buffers += 2 * LPC_ORDER * num_channel * |
1300 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(NO_ANALYSIS_CHANNELS * sizeof(WORD32), BYTE_ALIGN_8); |
1301 | | |
1302 | 23.6k | size_buffers += 2 * IXHEAAC_GET_SIZE_ALIGNED(LPC_ORDER * sizeof(WORD32 *), BYTE_ALIGN_8); |
1303 | | |
1304 | 23.6k | size_buffers += 2 * LPC_ORDER * num_channel * |
1305 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(NO_ANALYSIS_CHANNELS * sizeof(WORD32), BYTE_ALIGN_8); |
1306 | | |
1307 | 23.6k | size_buffers += 2 * num_channel * 3 * |
1308 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(MAX_FREQ_COEFFS * sizeof(WORD16), BYTE_ALIGN_8); |
1309 | | |
1310 | 23.6k | temp = IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_freq_band_data_struct), BYTE_ALIGN_8) + |
1311 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_prev_frame_data_struct), BYTE_ALIGN_8) + |
1312 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_channel_struct), BYTE_ALIGN_8) + |
1313 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_header_data_struct), BYTE_ALIGN_8); |
1314 | 23.6k | size_buffers += 2 * num_channel * temp; |
1315 | | |
1316 | 23.6k | size_buffers += MAX_BS_ELEMENT * |
1317 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ixheaac_drc_bs_data_struct *), BYTE_ALIGN_8); |
1318 | | |
1319 | 23.6k | size_buffers += num_channel * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_ps_dec_struct), BYTE_ALIGN_8); |
1320 | | |
1321 | 23.6k | { |
1322 | 23.6k | WORD32 temp_size = 0; |
1323 | 23.6k | size_buffers += (num_channel * 2 * |
1324 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_frame_info_data_struct) + |
1325 | 23.6k | MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8, |
1326 | 23.6k | BYTE_ALIGN_8)); |
1327 | 23.6k | temp_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_pvc_data_struct), BYTE_ALIGN_8); |
1328 | 23.6k | temp_size += 2 * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8); |
1329 | 23.6k | temp_size += 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8); |
1330 | 23.6k | temp_size += |
1331 | 23.6k | 2 * 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_QMF_BUF_LEN * sizeof(FLOAT32 *), BYTE_ALIGN_8); |
1332 | 23.6k | temp_size += 2 * 2 * MAX_QMF_BUF_LEN * |
1333 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(MAX_QMF_BUF_LEN * sizeof(FLOAT32), BYTE_ALIGN_8); |
1334 | 23.6k | temp_size += 2 * 2 * MAX_ENV_COLS * |
1335 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(MAX_QMF_BUF_LEN * sizeof(WORD32), BYTE_ALIGN_8); |
1336 | 23.6k | size_buffers += num_channel * temp_size; |
1337 | 23.6k | } |
1338 | | |
1339 | 23.6k | return (size_buffers); |
1340 | 23.6k | } |
1341 | | |
1342 | | VOID ixheaacd_fill_aac_mem_tables( |
1343 | 23.6k | ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { |
1344 | 23.6k | ia_mem_info_struct *p_mem_info_aac; |
1345 | | |
1346 | 23.6k | WORD32 num_channels; |
1347 | 23.6k | WORD32 channels; |
1348 | 23.6k | WORD32 buffer_size; |
1349 | | |
1350 | 23.6k | if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { |
1351 | 23.6k | num_channels = (p_obj_exhaacplus_dec->aac_config.ui_max_channels + 1); |
1352 | 23.6k | } else |
1353 | | |
1354 | 0 | { |
1355 | 0 | num_channels = p_obj_exhaacplus_dec->aac_config.ui_max_channels; |
1356 | 0 | } |
1357 | | |
1358 | 23.6k | channels = num_channels; |
1359 | 23.6k | buffer_size = ixheaacd_persistent_buffer_sizes(num_channels); |
1360 | | |
1361 | 23.6k | { |
1362 | 23.6k | p_mem_info_aac = |
1363 | 23.6k | &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX]; |
1364 | 23.6k | p_mem_info_aac->ui_size = |
1365 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8) + |
1366 | 23.6k | channels * |
1367 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_aac_persistent_struct), BYTE_ALIGN_8) + |
1368 | 23.6k | buffer_size + channels * ixheaacd_getsize_sbr_persistent() + channels * 16 + |
1369 | 23.6k | ixheaacd_mps_persistent_buffer_sizes(); |
1370 | 23.6k | p_mem_info_aac->ui_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8); |
1371 | 23.6k | p_mem_info_aac->ui_size += |
1372 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8); |
1373 | 23.6k | p_mem_info_aac->ui_size += IXHEAAC_GET_SIZE_ALIGNED(MAX_HEADER_BUF_SIZE, BYTE_ALIGN_8); |
1374 | 23.6k | p_mem_info_aac->ui_alignment = 16; |
1375 | 23.6k | p_mem_info_aac->ui_type = IA_MEMTYPE_PERSIST; |
1376 | 23.6k | } |
1377 | | |
1378 | 23.6k | { |
1379 | 23.6k | p_mem_info_aac = |
1380 | 23.6k | &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_SCRATCH_IDX]; |
1381 | | |
1382 | 23.6k | p_mem_info_aac->ui_size = MAX_SCR_SIZE; |
1383 | | |
1384 | 23.6k | p_mem_info_aac->ui_alignment = 8; |
1385 | 23.6k | p_mem_info_aac->ui_type = IA_MEMTYPE_SCRATCH; |
1386 | 23.6k | } |
1387 | 23.6k | { |
1388 | 23.6k | p_mem_info_aac = |
1389 | 23.6k | &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; |
1390 | | |
1391 | 23.6k | p_mem_info_aac->ui_size = IA_MAX_INP_BUFFER_SIZE; |
1392 | | |
1393 | 23.6k | p_mem_info_aac->ui_alignment = 8; |
1394 | 23.6k | p_mem_info_aac->ui_type = IA_MEMTYPE_INPUT; |
1395 | 23.6k | } |
1396 | 23.6k | { |
1397 | 23.6k | p_mem_info_aac = |
1398 | 23.6k | &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]; |
1399 | 23.6k | p_mem_info_aac->ui_size = IA_ENHAACPLUS_DEC_OUT_BUF_SIZE; |
1400 | 23.6k | p_mem_info_aac->ui_alignment = 8; |
1401 | 23.6k | p_mem_info_aac->ui_type = IA_MEMTYPE_OUTPUT; |
1402 | 23.6k | } |
1403 | 23.6k | return; |
1404 | 23.6k | } |
1405 | | |
1406 | | IA_ERRORCODE ixheaacd_dec_table_api( |
1407 | | ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec, WORD32 i_cmd, |
1408 | 0 | WORD32 i_idx, pVOID pv_value) { |
1409 | 0 | ia_heaac_mps_state_struct *pstr_mps_state = |
1410 | 0 | &p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle; |
1411 | 0 | pUWORD32 pui_value = pv_value; |
1412 | 0 | pUWORD32 *p_pui_value = pv_value; |
1413 | 0 | SIZE_T ui_get_vals[5]; |
1414 | |
|
1415 | 0 | pVOID *table_ptrs[8 + NUM_MPS_TABLES]; |
1416 | 0 | UWORD32 table_sizes[8 + NUM_MPS_TABLES] = { |
1417 | 0 | sizeof(ixheaacd_aac_huffmann_tables), |
1418 | 0 | sizeof(ixheaacd_aac_block_tables), |
1419 | 0 | sizeof(ixheaacd_imdct_tables), |
1420 | 0 | sizeof(ixheaacd_str_fft_n_transcendent_tables), |
1421 | 0 | sizeof(ixheaacd_aac_dec_env_calc_tables), |
1422 | 0 | sizeof(ixheaacd_aac_qmf_dec_tables), |
1423 | 0 | sizeof(ixheaacd_aac_dec_env_extr_tables), |
1424 | 0 | sizeof(ixheaacd_aac_dec_ps_tables), |
1425 | 0 | sizeof(ixheaacd_mps_dec_qmf_tables), |
1426 | 0 | sizeof(ixheaacd_mps_dec_common_tables), |
1427 | 0 | sizeof(ixheaacd_mps_dec_hybrid_tables), |
1428 | 0 | sizeof(ixheaacd_mps_dec_m1_m2_tables), |
1429 | 0 | sizeof(ixheaacd_mps_dec_decorr_tables), |
1430 | 0 | sizeof(ixheaacd_mps_dec_tp_process_tables), |
1431 | 0 | sizeof(ixheaacd_mps_dec_mdct2qmf_table), |
1432 | 0 | sizeof(ixheaacd_mps_dec_tonality_tables), |
1433 | 0 | sizeof(ixheaacd_mps_dec_bitdec_tables), |
1434 | 0 | sizeof(ixheaacd_mps_dec_blind_tables), |
1435 | 0 | sizeof(ixheaacd_mps_dec_mdct2qmf_tables), |
1436 | 0 | sizeof(ia_mps_dec_mdct2qmf_cos_table_struct), |
1437 | 0 | sizeof(ia_mps_dec_residual_aac_tables_struct)}; |
1438 | 0 | table_ptrs[0] = |
1439 | 0 | (pVOID *)&(p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables); |
1440 | 0 | table_ptrs[1] = |
1441 | 0 | (pVOID *)&(p_obj_exhaacplus_dec->aac_tables.pstr_block_tables); |
1442 | 0 | table_ptrs[2] = |
1443 | 0 | (pVOID *)&(p_obj_exhaacplus_dec->aac_tables.pstr_imdct_tables); |
1444 | 0 | table_ptrs[3] = (pVOID *)&(p_obj_exhaacplus_dec->common_tables); |
1445 | 0 | table_ptrs[4] = |
1446 | 0 | (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.env_calc_tables_ptr; |
1447 | 0 | table_ptrs[5] = |
1448 | 0 | (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.qmf_dec_tables_ptr; |
1449 | 0 | table_ptrs[6] = |
1450 | 0 | (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.env_extr_tables_ptr; |
1451 | 0 | table_ptrs[7] = (pVOID *)&p_obj_exhaacplus_dec->str_sbr_tables.ps_tables_ptr; |
1452 | 0 | table_ptrs[8] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.qmf_table_ptr); |
1453 | 0 | table_ptrs[9] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.common_table_ptr); |
1454 | 0 | table_ptrs[10] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.hybrid_table_ptr); |
1455 | 0 | table_ptrs[11] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.m1_m2_table_ptr); |
1456 | 0 | table_ptrs[12] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.decor_table_ptr); |
1457 | 0 | table_ptrs[13] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.tp_process_table_ptr); |
1458 | 0 | table_ptrs[14] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.mdct2qmf_table_ptr); |
1459 | 0 | table_ptrs[15] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.tonality_table_ptr); |
1460 | 0 | table_ptrs[16] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.bitdec_table_ptr); |
1461 | 0 | table_ptrs[17] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.blind_table_ptr); |
1462 | 0 | table_ptrs[18] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.mdct2qmfcos_table_ptr); |
1463 | 0 | table_ptrs[19] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.mdct2qmfcos_tab_ptr); |
1464 | 0 | table_ptrs[20] = (pVOID *)&(pstr_mps_state->ia_mps_dec_mps_table.aac_tab); |
1465 | |
|
1466 | 0 | if (i_idx < 0 || i_idx >= (NUM_AAC_TABLES + NUM_MPS_TABLES)) { |
1467 | 0 | return IA_XHEAAC_DEC_API_FATAL_INVALID_MEMTAB_INDEX; |
1468 | 0 | } |
1469 | | |
1470 | 0 | ui_get_vals[0] = table_sizes[i_idx]; |
1471 | 0 | ui_get_vals[1] = 4; |
1472 | 0 | ui_get_vals[4] = (SIZE_T)(*table_ptrs[i_idx]); |
1473 | |
|
1474 | 0 | if (i_cmd == IA_API_CMD_SET_TABLE_PTR) { |
1475 | 0 | if (pv_value == 0) { |
1476 | 0 | return (IA_XHEAAC_DEC_API_FATAL_MEM_ALLOC); |
1477 | 0 | } |
1478 | 0 | if (((SIZE_T)pv_value) & 3) { |
1479 | 0 | return IA_XHEAAC_DEC_API_FATAL_MEM_ALIGN; |
1480 | 0 | } |
1481 | | |
1482 | 0 | *table_ptrs[i_idx] = pv_value; |
1483 | |
|
1484 | 0 | if (i_idx == 0) { |
1485 | 0 | ixheaacd_huff_tables_create(&p_obj_exhaacplus_dec->aac_tables); |
1486 | 0 | } |
1487 | |
|
1488 | 0 | } |
1489 | | |
1490 | 0 | else if (i_cmd == IA_API_CMD_GET_TABLE_PTR) { |
1491 | 0 | *p_pui_value = (UWORD32 *)((SIZE_T)( |
1492 | 0 | ui_get_vals[i_cmd - IA_API_CMD_GET_TABLE_INFO_SIZE])); |
1493 | 0 | } else { |
1494 | 0 | *pui_value = (WORD32)(ui_get_vals[i_cmd - IA_API_CMD_GET_TABLE_INFO_SIZE]); |
1495 | 0 | } |
1496 | | |
1497 | 0 | return IA_NO_ERROR; |
1498 | 0 | } |
1499 | | |
1500 | | VOID ixheaacd_mps_payload(ia_handle_sbr_dec_inst_struct self, |
1501 | 5.66k | ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { |
1502 | 5.66k | struct ia_bit_buf_struct local_bit_buff; |
1503 | 5.66k | struct ia_bit_buf_struct *it_bit_buff; |
1504 | 5.66k | if (self->ptr_mps_data != NULL) { |
1505 | 3.73k | ixheaacd_create_init_bit_buf(&local_bit_buff, (UWORD8 *)self->ptr_mps_data, |
1506 | 3.73k | (self->left_mps_bits >> 3) + 1); |
1507 | 3.73k | } |
1508 | | |
1509 | 5.66k | local_bit_buff.xaac_jmp_buf = |
1510 | 5.66k | &p_obj_exhaacplus_dec->p_state_aac->xaac_jmp_buf; |
1511 | | |
1512 | 5.66k | it_bit_buff = &local_bit_buff; |
1513 | | |
1514 | 5.66k | it_bit_buff->bit_pos = self->mps_bits_pos; |
1515 | 5.66k | it_bit_buff->cnt_bits = self->left_mps_bits; |
1516 | | |
1517 | 12.5k | while (self->left_mps_bits >= 8) { |
1518 | 6.89k | ixheaacd_extension_payload( |
1519 | 6.89k | it_bit_buff, &self->left_mps_bits, |
1520 | 6.89k | &p_obj_exhaacplus_dec->p_state_aac->mps_dec_handle); |
1521 | 6.89k | } |
1522 | 5.66k | } |
1523 | | |
1524 | | IA_ERRORCODE ixheaacd_dec_init( |
1525 | 37.4k | ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { |
1526 | 37.4k | FLAG frame_status = 1; |
1527 | 37.4k | WORD32 frame_size_1; |
1528 | 37.4k | WORD32 sample_rate_1; |
1529 | 37.4k | WORD16 num_channels_1; |
1530 | 37.4k | WORD32 ps_detected = 0; |
1531 | 37.4k | UWORD8 *in_buffer; |
1532 | 37.4k | WORD16 *time_data; |
1533 | 37.4k | WORD ch_idx; |
1534 | 37.4k | WORD sbr_present_flag = 0; |
1535 | 37.4k | UWORD8 *mps_buffer; |
1536 | 37.4k | ia_aac_dec_state_struct *p_state_enhaacplus_dec; |
1537 | | |
1538 | 37.4k | WORD32 error_code = IA_NO_ERROR; |
1539 | 37.4k | WORD32 persistent_used = 0; |
1540 | 37.4k | IA_ERRORCODE err_code = IA_NO_ERROR; |
1541 | 37.4k | struct ia_aac_persistent_struct *aac_persistent_mem; |
1542 | 37.4k | struct ia_sbr_pers_struct *sbr_persistent_mem; |
1543 | 37.4k | WORD32 ret_val; |
1544 | | |
1545 | 37.4k | p_obj_exhaacplus_dec->p_state_aac = |
1546 | 37.4k | p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX]; |
1547 | | |
1548 | 37.4k | if (p_obj_exhaacplus_dec->p_state_aac->ui_init_done) |
1549 | 0 | { |
1550 | 0 | return IA_NO_ERROR; |
1551 | 0 | } |
1552 | | |
1553 | 37.4k | p_obj_exhaacplus_dec->p_state_aac->preroll_config_present = 0; |
1554 | | |
1555 | 37.4k | if (p_obj_exhaacplus_dec->p_state_aac != NULL) { |
1556 | 37.4k | ret_val = setjmp(p_obj_exhaacplus_dec->p_state_aac->xaac_jmp_buf); |
1557 | 37.4k | if (ret_val != 0) { |
1558 | 1.99k | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
1559 | 1.99k | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; |
1560 | 1.99k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = 0; |
1561 | 1.99k | return IA_NO_ERROR; |
1562 | 1.99k | } |
1563 | 37.4k | } |
1564 | | |
1565 | 35.4k | time_data = (WORD16 *)(p_obj_exhaacplus_dec |
1566 | 35.4k | ->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]); |
1567 | | |
1568 | 37.4k | if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { |
1569 | 37.4k | in_buffer = p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; |
1570 | 18.4E | } else { |
1571 | 18.4E | in_buffer = p_obj_exhaacplus_dec->p_state_aac->header_ptr; |
1572 | 18.4E | } |
1573 | | |
1574 | 35.4k | p_state_enhaacplus_dec = p_obj_exhaacplus_dec->p_state_aac; |
1575 | | |
1576 | 35.4k | p_state_enhaacplus_dec->aac_scratch_mem_v = |
1577 | 35.4k | p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_SCRATCH_IDX]; |
1578 | 35.4k | p_obj_exhaacplus_dec->p_state_aac->huffman_code_book_scl = |
1579 | 35.4k | p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables |
1580 | 35.4k | ->huffman_code_book_scl; |
1581 | 35.4k | mps_buffer = p_obj_exhaacplus_dec->p_state_aac->mps_buffer; |
1582 | 35.4k | p_state_enhaacplus_dec->mps_header = -1; |
1583 | 35.4k | p_obj_exhaacplus_dec->p_state_aac->huffman_code_book_scl_index = |
1584 | 35.4k | p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables |
1585 | 35.4k | ->huffman_code_book_scl_index; |
1586 | | |
1587 | 35.4k | p_state_enhaacplus_dec->pstr_aac_tables = &p_obj_exhaacplus_dec->aac_tables; |
1588 | 35.4k | if (p_obj_exhaacplus_dec->p_state_aac->header_dec_done == 0) |
1589 | 23.6k | { |
1590 | 23.6k | p_obj_exhaacplus_dec->aac_config.header_dec_done = 0; |
1591 | 23.6k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config.ldmps_present_flag = 0; |
1592 | 23.6k | } |
1593 | 35.4k | if (p_obj_exhaacplus_dec->aac_config.header_dec_done == 0) { |
1594 | 23.6k | WORD32 channels; |
1595 | 23.6k | UWORD32 total_persistent_used = 0; |
1596 | | |
1597 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->p_config = |
1598 | 23.6k | &p_obj_exhaacplus_dec->aac_config; |
1599 | | |
1600 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr = |
1601 | 23.6k | (pVOID)((pWORD8)p_obj_exhaacplus_dec->p_state_aac + |
1602 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8)); |
1603 | 23.6k | if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { |
1604 | 23.6k | p_state_enhaacplus_dec->aac_persistent_mem_v = |
1605 | 23.6k | (pVOID)((pWORD8)p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr + |
1606 | 23.6k | (MAX_BS_ELEMENT)*2 * |
1607 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), |
1608 | 23.6k | BYTE_ALIGN_8)); |
1609 | | |
1610 | 23.6k | memset(p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr, 0, |
1611 | 23.6k | (MAX_BS_ELEMENT)*2 * |
1612 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), BYTE_ALIGN_8)); |
1613 | 23.6k | } else { |
1614 | 0 | p_state_enhaacplus_dec->aac_persistent_mem_v = |
1615 | 0 | (pVOID)((pWORD8)p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr + |
1616 | 0 | (2) * 2 * |
1617 | 0 | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), |
1618 | 0 | BYTE_ALIGN_8)); |
1619 | |
|
1620 | 0 | memset(p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr, 0, |
1621 | 0 | (2) * 2 * |
1622 | 0 | IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), BYTE_ALIGN_8)); |
1623 | 0 | } |
1624 | 23.6k | if (1 == p_obj_exhaacplus_dec->aac_config.ui_max_channels) |
1625 | 0 | channels = 1; |
1626 | 23.6k | else |
1627 | 23.6k | channels = 2; |
1628 | | |
1629 | 23.6k | persistent_used = ixheaacd_set_aac_persistent_buffers( |
1630 | 23.6k | p_state_enhaacplus_dec->aac_persistent_mem_v, channels); |
1631 | | |
1632 | 23.6k | p_state_enhaacplus_dec->sbr_persistent_mem_v = |
1633 | 23.6k | (pVOID)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + |
1634 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8)); |
1635 | 23.6k | total_persistent_used += IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8); |
1636 | | |
1637 | 23.6k | persistent_used = ixheaacd_getsize_sbr_persistent(); |
1638 | 23.6k | ixheaacd_set_sbr_persistent_buffers( |
1639 | 23.6k | p_state_enhaacplus_dec->sbr_persistent_mem_v, &persistent_used, |
1640 | 23.6k | channels, 1); |
1641 | | |
1642 | 23.6k | p_state_enhaacplus_dec->heaac_mps_handle.mps_persistent_mem_v = |
1643 | 23.6k | (pVOID)((pWORD8)p_state_enhaacplus_dec->sbr_persistent_mem_v + |
1644 | 23.6k | IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8)); |
1645 | 23.6k | total_persistent_used += IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8); |
1646 | | |
1647 | 23.6k | persistent_used = ixheaacd_getsize_mps_persistent(); |
1648 | | |
1649 | 23.6k | ixheaacd_set_mps_persistent_buffers( |
1650 | 23.6k | &p_state_enhaacplus_dec->heaac_mps_handle, &persistent_used, channels, |
1651 | 23.6k | p_state_enhaacplus_dec->heaac_mps_handle.mps_persistent_mem_v); |
1652 | 23.6k | total_persistent_used += IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8); |
1653 | | |
1654 | 23.6k | if (total_persistent_used > |
1655 | 23.6k | p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX].ui_size) { |
1656 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_DEC_INIT_FAIL; |
1657 | 0 | } |
1658 | | |
1659 | 23.6k | aac_persistent_mem = (struct ia_aac_persistent_struct *) |
1660 | 23.6k | p_state_enhaacplus_dec->aac_persistent_mem_v; |
1661 | 23.6k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || |
1662 | 23.6k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) |
1663 | 2 | p_state_enhaacplus_dec->frame_len_flag = |
1664 | 2 | p_obj_exhaacplus_dec->aac_config.framesize_480; |
1665 | | |
1666 | 23.6k | p_state_enhaacplus_dec->ptr_overlap_buf = |
1667 | 23.6k | aac_persistent_mem->overlap_buffer; |
1668 | | |
1669 | 23.6k | p_state_enhaacplus_dec->bit_count = 0; |
1670 | 23.6k | p_state_enhaacplus_dec->ec_enable = p_obj_exhaacplus_dec->aac_config.ui_err_conceal; |
1671 | 23.6k | p_state_enhaacplus_dec->sync_status = 0; |
1672 | 23.6k | p_state_enhaacplus_dec->bs_format = ADTS_BSFORMAT; |
1673 | 23.6k | p_state_enhaacplus_dec->latm_initialized = 0; |
1674 | 23.6k | p_state_enhaacplus_dec->frame_size = 0; |
1675 | 23.6k | memset(&p_state_enhaacplus_dec->latm_struct_element, 0, |
1676 | 23.6k | sizeof(ixheaacd_latm_struct)); |
1677 | 23.6k | memset(&p_state_enhaacplus_dec->b_n_raw_data_blk, 0, |
1678 | 23.6k | sizeof(WORD32) * (9 + MAX_BS_ELEMENT)); |
1679 | | |
1680 | 23.6k | p_state_enhaacplus_dec->sbr_present_flag = 0; |
1681 | | |
1682 | 260k | for (ch_idx = 0; ch_idx < MAX_BS_ELEMENT; ch_idx++) { |
1683 | 236k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; |
1684 | 236k | } |
1685 | | |
1686 | 23.6k | memset(&p_state_enhaacplus_dec->ind_cc_info, 0, |
1687 | 23.6k | sizeof(ia_enhaacplus_dec_ind_cc)); |
1688 | | |
1689 | 23.6k | p_state_enhaacplus_dec->last_frame_ok = 1; |
1690 | 23.6k | p_obj_exhaacplus_dec->aac_config.header_dec_done = 1; |
1691 | | |
1692 | 23.6k | aac_persistent_mem->str_aac_decoder.pstr_aac_tables = |
1693 | 23.6k | &p_obj_exhaacplus_dec->aac_tables; |
1694 | 23.6k | aac_persistent_mem->str_aac_decoder.pstr_common_tables = |
1695 | 23.6k | p_obj_exhaacplus_dec->common_tables; |
1696 | | |
1697 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->sbr_persistent_mem_u = |
1698 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->sbr_persistent_mem_v; |
1699 | | |
1700 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->sbr_scratch_mem_u = |
1701 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->aac_scratch_mem_v; |
1702 | | |
1703 | 23.6k | ixheaacd_set_sbr_persistent_table_pointer( |
1704 | 23.6k | p_obj_exhaacplus_dec->p_state_aac->sbr_persistent_mem_v, |
1705 | 23.6k | &p_obj_exhaacplus_dec->str_sbr_tables, |
1706 | 23.6k | p_obj_exhaacplus_dec->common_tables); |
1707 | 23.6k | ixheaacd_set_scratch_buffers( |
1708 | 23.6k | &p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle, |
1709 | 23.6k | p_state_enhaacplus_dec->aac_scratch_mem_v); |
1710 | 23.6k | } |
1711 | | |
1712 | 35.4k | if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 1) { |
1713 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_EO_INPUT_REACHED; |
1714 | 0 | } |
1715 | | |
1716 | 35.4k | if (p_obj_exhaacplus_dec->p_state_aac->header_dec_done == 0) { |
1717 | 23.6k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || |
1718 | 23.6k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) |
1719 | 2 | p_state_enhaacplus_dec->frame_len_flag = |
1720 | 2 | p_obj_exhaacplus_dec->aac_config.framesize_480; |
1721 | | |
1722 | 23.6k | aac_persistent_mem = (struct ia_aac_persistent_struct *) |
1723 | 23.6k | p_state_enhaacplus_dec->aac_persistent_mem_v; |
1724 | 23.6k | sbr_persistent_mem = (struct ia_sbr_pers_struct *) |
1725 | 23.6k | p_state_enhaacplus_dec->sbr_persistent_mem_v; |
1726 | 23.6k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
1727 | 0 | p_obj_exhaacplus_dec->p_state_aac->first_frame = 1; |
1728 | 0 | } |
1729 | | |
1730 | 23.6k | if (p_obj_exhaacplus_dec->aac_config.ui_samp_freq == 0) { |
1731 | 23.6k | WORD32 header_bytes_consumed, return_val; |
1732 | | |
1733 | 23.6k | if (p_state_enhaacplus_dec->ui_in_bytes == 0) { |
1734 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
1735 | 0 | return IA_NO_ERROR; |
1736 | 0 | } |
1737 | | |
1738 | 23.6k | if (1 == p_obj_exhaacplus_dec->aac_config.ui_frame_size) { |
1739 | 0 | p_state_enhaacplus_dec->frame_len_flag = 1; |
1740 | 0 | p_state_enhaacplus_dec->frame_length = 960; |
1741 | 23.6k | } else { |
1742 | 23.6k | p_state_enhaacplus_dec->frame_len_flag = 0; |
1743 | 23.6k | p_state_enhaacplus_dec->frame_length = 1024; |
1744 | 23.6k | } |
1745 | | |
1746 | 23.6k | p_state_enhaacplus_dec->ui_init_done = 0; |
1747 | 23.6k | memset(&(p_state_enhaacplus_dec->eld_specific_config), 0, |
1748 | 23.6k | sizeof(ia_eld_specific_config_struct)); |
1749 | 23.6k | return_val = ixheaacd_aac_headerdecode( |
1750 | 23.6k | p_obj_exhaacplus_dec, (UWORD8 *)in_buffer, &header_bytes_consumed, |
1751 | 23.6k | aac_persistent_mem->str_aac_decoder.pstr_aac_tables |
1752 | 23.6k | ->pstr_huffmann_tables); |
1753 | 23.6k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || |
1754 | 23.6k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD || |
1755 | 23.6k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LC) { |
1756 | 6.26k | *sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[0] = |
1757 | 6.26k | p_obj_exhaacplus_dec->p_state_aac->str_sbr_config; |
1758 | 6.26k | *sbr_persistent_mem->str_sbr_dec_inst.pstr_sbr_header[1] = |
1759 | 6.26k | p_obj_exhaacplus_dec->p_state_aac->str_sbr_config; |
1760 | 17.3k | } else { |
1761 | 17.3k | memset(&(p_state_enhaacplus_dec->eld_specific_config), 0, |
1762 | 17.3k | sizeof(ia_eld_specific_config_struct)); |
1763 | 17.3k | } |
1764 | | |
1765 | 23.6k | if (return_val < 0) { |
1766 | 658 | if (return_val == |
1767 | 658 | (WORD32)IA_XHEAAC_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX) { |
1768 | 12 | p_state_enhaacplus_dec->i_bytes_consumed = header_bytes_consumed; |
1769 | 12 | return return_val; |
1770 | 12 | } |
1771 | 646 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
1772 | | |
1773 | 646 | return return_val; |
1774 | 658 | } |
1775 | | |
1776 | 22.9k | if (return_val == |
1777 | 22.9k | IA_XHEAAC_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES) { |
1778 | 26 | p_state_enhaacplus_dec->i_bytes_consumed = header_bytes_consumed; |
1779 | 26 | return return_val; |
1780 | 26 | } |
1781 | | |
1782 | 22.9k | p_state_enhaacplus_dec->i_bytes_consumed = header_bytes_consumed; |
1783 | | |
1784 | 22.9k | if ((return_val == 0) && |
1785 | 22.9k | (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == AOT_USAC)) { |
1786 | 8.46k | { |
1787 | 8.46k | WORD32 pcm_size = p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz; |
1788 | 8.46k | WORD8 *inbuffer = |
1789 | 8.46k | p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; |
1790 | 8.46k | WORD8 *outbuffer = |
1791 | 8.46k | p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]; |
1792 | 8.46k | WORD32 out_bytes = 0; |
1793 | 8.46k | WORD32 frames_done = p_obj_exhaacplus_dec->p_state_aac->frame_counter; |
1794 | 8.46k | p_obj_exhaacplus_dec->p_state_aac->decode_create_done = 0; |
1795 | | |
1796 | 8.46k | if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 0) { |
1797 | 8.46k | error_code = ixheaacd_dec_main( |
1798 | 8.46k | p_obj_exhaacplus_dec, inbuffer, outbuffer, &out_bytes, |
1799 | 8.46k | frames_done, pcm_size, |
1800 | 8.46k | &p_obj_exhaacplus_dec->p_state_aac->num_of_output_ch); |
1801 | 8.46k | if (error_code) return error_code; |
1802 | 8.44k | p_obj_exhaacplus_dec->p_state_aac->frame_counter++; |
1803 | 8.44k | } else { |
1804 | 0 | out_bytes = 0; |
1805 | 0 | } |
1806 | | |
1807 | 8.44k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = |
1808 | 8.44k | p_obj_exhaacplus_dec->p_state_aac->num_of_output_ch; |
1809 | 8.44k | } |
1810 | 8.44k | if (return_val == 0) |
1811 | 8.44k | p_obj_exhaacplus_dec->p_state_aac->ui_init_done = 1; |
1812 | 8.44k | return return_val; |
1813 | 8.46k | } |
1814 | | |
1815 | 14.4k | if (return_val == 0) { |
1816 | 13.8k | p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 1; |
1817 | 13.8k | if (p_obj_exhaacplus_dec->aac_config.ui_flush_cmd == 0) { |
1818 | 13.8k | memcpy(p_state_enhaacplus_dec->header_ptr, in_buffer, |
1819 | 13.8k | header_bytes_consumed * sizeof(UWORD8)); |
1820 | 13.8k | p_state_enhaacplus_dec->header_length = header_bytes_consumed; |
1821 | 13.8k | } |
1822 | 13.8k | } |
1823 | | |
1824 | 14.4k | if (p_obj_exhaacplus_dec->p_state_aac->header_dec_done != 1) |
1825 | 18 | return IA_XHEAAC_DEC_INIT_NONFATAL_HEADER_NOT_AT_START; |
1826 | | |
1827 | 14.4k | if (p_state_enhaacplus_dec->dwnsmp_signal == 1 && |
1828 | 14.4k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) |
1829 | 1.92k | p_obj_exhaacplus_dec->aac_config.down_sample_flag = 1; |
1830 | | |
1831 | 14.4k | if (p_state_enhaacplus_dec->sampling_rate == |
1832 | 14.4k | p_state_enhaacplus_dec->extension_samp_rate) { |
1833 | 5 | p_obj_exhaacplus_dec->aac_config.down_sample_flag = 1; |
1834 | 5 | } |
1835 | | |
1836 | 14.4k | } else { |
1837 | 4 | p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 1; |
1838 | 4 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
1839 | | |
1840 | 4 | p_state_enhaacplus_dec->sampling_rate = |
1841 | 4 | p_obj_exhaacplus_dec->aac_config.ui_samp_freq; |
1842 | | |
1843 | 4 | if (1 == p_obj_exhaacplus_dec->aac_config.ui_frame_size) { |
1844 | 0 | p_state_enhaacplus_dec->frame_len_flag = 1; |
1845 | 0 | p_state_enhaacplus_dec->frame_length = 960; |
1846 | 4 | } else { |
1847 | 4 | p_state_enhaacplus_dec->frame_len_flag = 0; |
1848 | 4 | p_state_enhaacplus_dec->frame_length = 1024; |
1849 | 4 | } |
1850 | 4 | } |
1851 | | |
1852 | 14.4k | p_state_enhaacplus_dec->pstr_bit_buf = ixheaacd_create_bit_buf( |
1853 | 14.4k | &p_state_enhaacplus_dec->str_bit_buf, (UWORD8 *)in_buffer, |
1854 | 14.4k | p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_INPUT_IDX] |
1855 | 14.4k | .ui_size); |
1856 | 14.4k | p_state_enhaacplus_dec->pstr_bit_buf->xaac_jmp_buf = |
1857 | 14.4k | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
1858 | | |
1859 | 14.4k | p_state_enhaacplus_dec->ptr_bit_stream = |
1860 | 14.4k | p_state_enhaacplus_dec->pstr_bit_buf; |
1861 | | |
1862 | 14.4k | if (p_state_enhaacplus_dec->s_adts_hdr_present) { |
1863 | 7.15k | if (p_obj_exhaacplus_dec->aac_config.ld_decoder == 1) |
1864 | 0 | p_state_enhaacplus_dec->audio_object_type = 23; |
1865 | 7.15k | } |
1866 | | |
1867 | 14.4k | if ((p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) || |
1868 | 14.4k | (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD)) |
1869 | 4.95k | if (p_state_enhaacplus_dec->s_adts_hdr_present) { |
1870 | 0 | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { |
1871 | 0 | p_state_enhaacplus_dec->eld_specific_config.ld_sbr_samp_rate = 1; |
1872 | 0 | p_state_enhaacplus_dec->eld_specific_config.ld_sbr_crc_flag = 0; |
1873 | 0 | p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present = 0; |
1874 | |
|
1875 | 0 | if (p_obj_exhaacplus_dec->aac_config.eld_sbr_present == 1) { |
1876 | 0 | p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present = 1; |
1877 | 0 | } |
1878 | 0 | } |
1879 | 0 | if (p_obj_exhaacplus_dec->aac_config.framesize_480) |
1880 | 0 | p_state_enhaacplus_dec->frame_length = 480; |
1881 | 0 | else |
1882 | 0 | p_state_enhaacplus_dec->frame_length = 512; |
1883 | 0 | } |
1884 | | |
1885 | 14.4k | { |
1886 | 153k | for (ch_idx = 0; ch_idx < MAX_BS_ELEMENT; ch_idx++) { |
1887 | 138k | WORD32 channels; |
1888 | 138k | channels = 2; |
1889 | | |
1890 | 138k | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = |
1891 | 138k | ixheaacd_aac_decoder_init( |
1892 | 138k | p_state_enhaacplus_dec, |
1893 | | |
1894 | 138k | p_state_enhaacplus_dec->pstr_stream_sbr[0], channels, |
1895 | 138k | p_state_enhaacplus_dec->aac_persistent_mem_v, |
1896 | 138k | p_state_enhaacplus_dec->frame_length); |
1897 | | |
1898 | 138k | if (!p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]) { |
1899 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
1900 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_DEC_INIT_FAIL; |
1901 | 0 | } |
1902 | 138k | } |
1903 | | |
1904 | 14.4k | { |
1905 | 14.4k | p_state_enhaacplus_dec->pstr_drc_dec = |
1906 | 14.4k | &p_state_enhaacplus_dec->str_drc_dec_info; |
1907 | 14.4k | ixheaacd_drc_dec_create(p_state_enhaacplus_dec->pstr_drc_dec, 127, 127); |
1908 | 14.4k | } |
1909 | 14.4k | p_state_enhaacplus_dec->pstr_drc_dec->cut_factor = |
1910 | 14.4k | p_obj_exhaacplus_dec->aac_config.ui_drc_cut; |
1911 | 14.4k | p_state_enhaacplus_dec->pstr_drc_dec->boost_factor = |
1912 | 14.4k | p_obj_exhaacplus_dec->aac_config.ui_drc_boost; |
1913 | 14.4k | p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level = |
1914 | 14.4k | p_obj_exhaacplus_dec->aac_config.ui_drc_target_level; |
1915 | 14.4k | p_state_enhaacplus_dec->pstr_drc_dec->prog_ref_level = |
1916 | 14.4k | p_obj_exhaacplus_dec->aac_config.ui_drc_target_level; |
1917 | | |
1918 | 14.4k | if (1 == p_obj_exhaacplus_dec->aac_config.ui_drc_set) { |
1919 | 13.8k | if (p_obj_exhaacplus_dec->aac_config.ui_drc_heavy_comp == 1) { |
1920 | 442 | p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 1; |
1921 | 442 | p_state_enhaacplus_dec->pstr_drc_dec->heavy_mode = 1; |
1922 | 13.4k | } else { |
1923 | 13.4k | p_state_enhaacplus_dec->pstr_drc_dec->heavy_mode = 0; |
1924 | 13.4k | if (p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level > 127) |
1925 | 0 | p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level = 127; |
1926 | 13.4k | if (p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level < 0) { |
1927 | 0 | if (p_state_enhaacplus_dec->pstr_drc_dec->cut_factor > 0 || |
1928 | 0 | p_state_enhaacplus_dec->pstr_drc_dec->boost_factor > 0) |
1929 | 0 | p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 1; |
1930 | 0 | else |
1931 | 0 | p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 0; |
1932 | 0 | p_state_enhaacplus_dec->pstr_drc_dec->drc_dig_norm = 0; |
1933 | 0 | p_state_enhaacplus_dec->pstr_drc_dec->target_ref_level = 108; |
1934 | 13.4k | } else { |
1935 | 13.4k | p_state_enhaacplus_dec->pstr_drc_dec->drc_on = 1; |
1936 | 13.4k | p_state_enhaacplus_dec->pstr_drc_dec->drc_dig_norm = 1; |
1937 | 13.4k | } |
1938 | 13.4k | } |
1939 | 13.8k | } |
1940 | 14.4k | } |
1941 | 14.4k | } else { |
1942 | 11.7k | struct ia_bit_buf_struct temp_bit_buff = {0}; |
1943 | 11.7k | ia_adts_header_struct adts; |
1944 | 11.7k | struct ia_bit_buf_struct *it_bit_buff; |
1945 | | |
1946 | 11.7k | WORD16 frame_size_2 = 0; |
1947 | 11.7k | WORD32 sample_rate_2 = 0; |
1948 | 11.7k | WORD32 sample_rate = 0; |
1949 | 11.7k | WORD type, i; |
1950 | 11.7k | WORD elements_number; |
1951 | | |
1952 | 11.7k | if (p_state_enhaacplus_dec->audio_object_type == AOT_USAC) |
1953 | 0 | return IA_FATAL_ERROR; |
1954 | | |
1955 | 11.7k | memset(&adts, 0, sizeof(ia_adts_header_struct)); |
1956 | | |
1957 | 163k | for (i = 0; i < MAX_BS_ELEMENT + 1; i++) { |
1958 | 151k | p_obj_exhaacplus_dec->aac_config.element_type[i] = -1; |
1959 | 151k | } |
1960 | | |
1961 | 11.7k | it_bit_buff = p_state_enhaacplus_dec->pstr_bit_buf; |
1962 | | |
1963 | 11.7k | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 0; |
1964 | 11.7k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = 0; |
1965 | 11.7k | p_state_enhaacplus_dec->ui_mps_out_bytes = 0; |
1966 | 11.7k | if (p_state_enhaacplus_dec->ui_in_bytes == 0) { |
1967 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
1968 | 0 | return IA_NO_ERROR; |
1969 | 0 | } |
1970 | | |
1971 | 11.7k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || |
1972 | 11.8k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { |
1973 | 4.91k | if (p_obj_exhaacplus_dec->aac_config.ui_mp4_flag) |
1974 | 45 | p_state_enhaacplus_dec->frame_size = |
1975 | 45 | p_state_enhaacplus_dec->ui_in_bytes; |
1976 | 4.91k | } |
1977 | | |
1978 | 11.7k | ixheaacd_create_init_bit_buf(it_bit_buff, in_buffer, |
1979 | 11.7k | p_state_enhaacplus_dec->ui_in_bytes); |
1980 | 11.7k | p_state_enhaacplus_dec->pstr_bit_buf->xaac_jmp_buf = |
1981 | 11.7k | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
1982 | | |
1983 | 11.7k | it_bit_buff->adts_header_present = |
1984 | 11.7k | p_state_enhaacplus_dec->s_adts_hdr_present; |
1985 | 11.7k | it_bit_buff->no_raw_data_blocks = |
1986 | 11.7k | (WORD8)p_state_enhaacplus_dec->b_n_raw_data_blk; |
1987 | 11.7k | it_bit_buff->protection_absent = p_state_enhaacplus_dec->protection_absent; |
1988 | | |
1989 | 11.7k | memcpy(&temp_bit_buff, it_bit_buff, sizeof(struct ia_bit_buf_struct)); |
1990 | | |
1991 | 11.7k | if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) |
1992 | 13.7k | elements_number = MAX_BS_ELEMENT; |
1993 | 18.4E | else |
1994 | 18.4E | elements_number = 2; |
1995 | | |
1996 | 149k | for (i = 0; i < elements_number; i++) |
1997 | 137k | p_state_enhaacplus_dec->pstr_stream_sbr[i][0].no_elements = 0; |
1998 | | |
1999 | 11.7k | { it_bit_buff->initial_cnt_bits = it_bit_buff->cnt_bits; } |
2000 | | |
2001 | 11.7k | ixheaacd_byte_align( |
2002 | 11.7k | p_state_enhaacplus_dec->ptr_bit_stream, |
2003 | 11.7k | &p_state_enhaacplus_dec->pstr_aac_dec_info[0]->byte_align_bits); |
2004 | | |
2005 | 11.7k | if (p_state_enhaacplus_dec->s_adts_hdr_present) { |
2006 | 7.15k | WORD32 error; |
2007 | | |
2008 | 7.15k | if (p_state_enhaacplus_dec->b_n_raw_data_blk == 0) { |
2009 | 7.15k | error = ixheaacd_readifadts(p_state_enhaacplus_dec, it_bit_buff, &adts); |
2010 | | |
2011 | 7.15k | if (error) return error; |
2012 | | |
2013 | 7.15k | p_state_enhaacplus_dec->protection_absent = adts.protection_absent; |
2014 | | |
2015 | 7.15k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || |
2016 | 7.15k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { |
2017 | 0 | p_state_enhaacplus_dec->frame_size = adts.aac_frame_length; |
2018 | 0 | if (p_obj_exhaacplus_dec->aac_config.framesize_480) |
2019 | 0 | p_state_enhaacplus_dec->frame_length = 480; |
2020 | 0 | else |
2021 | 0 | p_state_enhaacplus_dec->frame_length = 512; |
2022 | 0 | } |
2023 | 7.15k | } |
2024 | 7.15k | } |
2025 | | |
2026 | 11.7k | if (p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) { |
2027 | 6.49k | WORD32 result; |
2028 | 6.49k | WORD32 sync; |
2029 | 6.49k | WORD32 cnt_bits; |
2030 | | |
2031 | 6.49k | sync = ixheaacd_read_bits_buf(it_bit_buff, 11); |
2032 | 6.49k | cnt_bits = it_bit_buff->cnt_bits; |
2033 | 6.49k | if (it_bit_buff->cnt_bits <= 24) { |
2034 | 0 | return IA_XHEAAC_DEC_INIT_NONFATAL_INSUFFICIENT_INPUT_BYTES; |
2035 | 0 | } |
2036 | | |
2037 | 6.50k | while (sync != 0x2b7) { |
2038 | 2 | sync = ((sync & 0x3ff) << 1) | ixheaacd_read_bits_buf(it_bit_buff, 1); |
2039 | 2 | if (it_bit_buff->cnt_bits < 11) { |
2040 | 0 | ixheaacd_read_bidirection(it_bit_buff, -11); |
2041 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = |
2042 | 0 | (cnt_bits - it_bit_buff->cnt_bits) / 8; |
2043 | 0 | return (IA_XHEAAC_DEC_INIT_NONFATAL_HEADER_NOT_AT_START); |
2044 | 0 | } |
2045 | 2 | } |
2046 | | |
2047 | 6.49k | it_bit_buff->audio_mux_align = it_bit_buff->cnt_bits - 13; |
2048 | | |
2049 | 6.49k | if (sync == 0x2b7) { |
2050 | 6.49k | result = ixheaacd_latm_audio_mux_element( |
2051 | 6.49k | it_bit_buff, &p_state_enhaacplus_dec->latm_struct_element, |
2052 | 6.49k | p_state_enhaacplus_dec, |
2053 | 6.49k | (ia_sampling_rate_info_struct *)&p_obj_exhaacplus_dec->aac_tables |
2054 | 6.49k | .pstr_huffmann_tables->str_sample_rate_info[0]); |
2055 | 6.49k | if (result < 0) { |
2056 | 3 | return result; |
2057 | 3 | } |
2058 | 6.49k | } |
2059 | 6.49k | } |
2060 | | |
2061 | 11.7k | p_state_enhaacplus_dec->pstr_aac_dec_info[0]->byte_align_bits = |
2062 | 11.7k | it_bit_buff->cnt_bits; |
2063 | | |
2064 | 11.7k | type = -1; |
2065 | 11.7k | ch_idx = 0; |
2066 | | |
2067 | 22.6k | while ((type != 7)) { |
2068 | 17.2k | ia_aac_dec_scratch_struct aac_scratch_struct; |
2069 | 17.2k | memset(&aac_scratch_struct, 0, sizeof(aac_scratch_struct)); |
2070 | | |
2071 | 17.2k | if (ch_idx >= elements_number) { |
2072 | 13 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2073 | | |
2074 | 13 | return IA_XHEAAC_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX; |
2075 | 13 | } |
2076 | | |
2077 | 17.2k | ixheaacd_allocate_aac_scr( |
2078 | 17.2k | &aac_scratch_struct, p_state_enhaacplus_dec->aac_scratch_mem_v, |
2079 | 17.2k | time_data, 1, p_obj_exhaacplus_dec->aac_config.ui_max_channels, |
2080 | 17.2k | p_state_enhaacplus_dec->audio_object_type); |
2081 | | |
2082 | 17.2k | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->p_ind_channel_info = |
2083 | 17.2k | &p_state_enhaacplus_dec->ind_cc_info; |
2084 | 17.2k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2085 | 0 | p_obj_exhaacplus_dec->aac_config.first_frame = 1; |
2086 | 0 | } |
2087 | | |
2088 | 17.2k | error_code = ixheaacd_aacdec_decodeframe( |
2089 | 17.2k | p_obj_exhaacplus_dec, &aac_scratch_struct, time_data, frame_status, &type, &ch_idx, 1, |
2090 | 17.2k | 2, p_obj_exhaacplus_dec->aac_config.element_instance_order, 0, 1, 0, |
2091 | 17.2k | p_obj_exhaacplus_dec->aac_config.ui_max_channels, 2, |
2092 | 17.2k | p_obj_exhaacplus_dec->p_state_aac->frame_length, |
2093 | 17.2k | p_obj_exhaacplus_dec->p_state_aac->frame_size, p_state_enhaacplus_dec->pstr_drc_dec, |
2094 | 17.2k | p_state_enhaacplus_dec->audio_object_type, p_state_enhaacplus_dec->ch_config, |
2095 | 17.2k | p_state_enhaacplus_dec->eld_specific_config, p_state_enhaacplus_dec->s_adts_hdr_present, |
2096 | 17.2k | &p_state_enhaacplus_dec->drc_dummy, p_state_enhaacplus_dec->ldmps_present, |
2097 | 17.2k | &p_state_enhaacplus_dec->slot_pos, mps_buffer, &p_state_enhaacplus_dec->mps_header, |
2098 | 17.2k | &p_state_enhaacplus_dec->ui_mps_out_bytes, 1, |
2099 | 17.2k | p_obj_exhaacplus_dec->aac_config.first_frame); |
2100 | | |
2101 | 17.2k | if (p_state_enhaacplus_dec->pstr_drc_dec->drc_element_found == 1) { |
2102 | 459 | if (p_obj_exhaacplus_dec->aac_config.i_loud_ref_level < 0) { |
2103 | 0 | p_obj_exhaacplus_dec->aac_config.output_level = |
2104 | 0 | p_state_enhaacplus_dec->pstr_drc_dec->prog_ref_level; |
2105 | 459 | } else { |
2106 | 459 | p_obj_exhaacplus_dec->aac_config.output_level = |
2107 | 459 | p_obj_exhaacplus_dec->aac_config.i_loud_ref_level; |
2108 | 459 | } |
2109 | 459 | } |
2110 | | |
2111 | 17.2k | memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] |
2112 | 17.2k | ->pstr_aac_dec_ch_info[0] |
2113 | 17.2k | ->str_ics_info.ltp), |
2114 | 17.2k | 0, sizeof(ltp_info)); |
2115 | 17.2k | memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] |
2116 | 17.2k | ->pstr_aac_dec_ch_info[0] |
2117 | 17.2k | ->str_ics_info.ltp2), |
2118 | 17.2k | 0, sizeof(ltp_info)); |
2119 | 17.2k | memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] |
2120 | 17.2k | ->pstr_aac_dec_ch_info[1] |
2121 | 17.2k | ->str_ics_info.ltp), |
2122 | 17.2k | 0, sizeof(ltp_info)); |
2123 | 17.2k | memset(&(p_obj_exhaacplus_dec->p_state_aac->pstr_aac_dec_info[ch_idx] |
2124 | 17.2k | ->pstr_aac_dec_ch_info[1] |
2125 | 17.2k | ->str_ics_info.ltp2), |
2126 | 17.2k | 0, sizeof(ltp_info)); |
2127 | | |
2128 | 17.2k | { |
2129 | | |
2130 | 17.2k | frame_size_1 = p_state_enhaacplus_dec->frame_length; |
2131 | 17.2k | sample_rate_1 = |
2132 | 17.2k | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->sampling_rate; |
2133 | 17.2k | num_channels_1 = |
2134 | 17.2k | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->channels; |
2135 | 17.2k | } |
2136 | | |
2137 | 17.2k | if ((p_obj_exhaacplus_dec->aac_config.ui_max_channels <= 2) && |
2138 | 17.2k | (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 2)) { |
2139 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2140 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_UNIMPLEMENTED_CCE; |
2141 | 0 | } |
2142 | | |
2143 | 17.2k | if (p_state_enhaacplus_dec->pstr_stream_sbr[0][0].no_elements) { |
2144 | 3.00k | sbr_present_flag = 1; |
2145 | 3.00k | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 1; |
2146 | 3.00k | } |
2147 | | |
2148 | 17.2k | if (error_code) { |
2149 | 626 | if (p_state_enhaacplus_dec->ui_input_over) { |
2150 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_EO_INPUT_REACHED; |
2151 | 0 | } |
2152 | | |
2153 | 626 | ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); |
2154 | 626 | return error_code; |
2155 | 626 | } |
2156 | | |
2157 | 16.5k | if (p_state_enhaacplus_dec->s_adts_hdr_present) { |
2158 | 7.99k | if (adts.no_raw_data_blocks != 0) { |
2159 | 4.09k | if (adts.protection_absent == 0 && it_bit_buff->cnt_bits >= 16) { |
2160 | 81 | adts.crc_check = ixheaacd_read_bits_buf(it_bit_buff, 16); |
2161 | 81 | } |
2162 | 4.09k | } |
2163 | 7.99k | p_state_enhaacplus_dec->b_n_raw_data_blk--; |
2164 | 7.99k | } |
2165 | | |
2166 | 16.5k | sample_rate_2 = sample_rate_1; |
2167 | 16.5k | frame_size_2 = frame_size_1; |
2168 | | |
2169 | 16.5k | if (!p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] && |
2170 | 16.5k | p_state_enhaacplus_dec->pstr_stream_sbr[0][0].no_elements) { |
2171 | 3.00k | WORD32 harmonic_sbr_flag = 0; |
2172 | 3.00k | if ((p_obj_exhaacplus_dec->aac_config.flag_16khz_out == 1) && |
2173 | 3.00k | (sample_rate_1 == 8000)) { |
2174 | 0 | p_obj_exhaacplus_dec->aac_config.flag_16khz_out = 0; |
2175 | 0 | } |
2176 | | |
2177 | 3.00k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = ixheaacd_init_sbr( |
2178 | 3.00k | sample_rate_1, frame_size_1, |
2179 | 3.00k | (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, |
2180 | 3.00k | p_state_enhaacplus_dec->sbr_persistent_mem_v, |
2181 | 3.00k | p_state_enhaacplus_dec->ptr_overlap_buf, MAXNRSBRCHANNELS, (WORD)1, |
2182 | 3.00k | 1, frame_size_1 * 2, &harmonic_sbr_flag, NULL, |
2183 | 3.00k | p_state_enhaacplus_dec->str_sbr_config, |
2184 | 3.00k | p_state_enhaacplus_dec->audio_object_type, |
2185 | 3.00k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
2186 | 3.00k | .ldmps_present_flag, |
2187 | 3.00k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
2188 | 3.00k | .no_ldsbr_present); |
2189 | 3.00k | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
2190 | 2.99k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->xaac_jmp_buf = |
2191 | 2.99k | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
2192 | 2.99k | } |
2193 | 13.5k | } else { |
2194 | 13.5k | } |
2195 | | |
2196 | 16.5k | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] && |
2197 | 16.5k | p_state_enhaacplus_dec->pstr_stream_sbr[0][0].no_elements) { |
2198 | 2.99k | ia_sbr_scr_struct sbr_scratch_struct; |
2199 | 2.99k | WORD16 num_channels_1_t = num_channels_1; |
2200 | 2.99k | ixheaacd_allocate_sbr_scr(&sbr_scratch_struct, p_state_enhaacplus_dec->aac_scratch_mem_v, |
2201 | 2.99k | time_data, 0, NULL, 0, 0); |
2202 | 2.99k | { |
2203 | 2.99k | WORD32 audio_object_type = p_state_enhaacplus_dec->audio_object_type; |
2204 | | |
2205 | 2.99k | if (audio_object_type != AOT_ER_AAC_ELD && audio_object_type != AOT_ER_AAC_LD) { |
2206 | 593 | WORD32 i = 0; |
2207 | 593 | ia_dec_data_struct *pstr_dec_data = |
2208 | 593 | (ia_dec_data_struct *)p_state_enhaacplus_dec->pstr_dec_data; |
2209 | 593 | if (num_channels_1 == 1) { |
2210 | 561k | for (; i < 1024; i++) { |
2211 | 561k | pstr_dec_data->str_usac_data.time_sample_vector[0][i] = |
2212 | 561k | ((FLOAT32)time_data[i]); |
2213 | 561k | } |
2214 | 548 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[0] = |
2215 | 548 | &pstr_dec_data->str_usac_data.time_sample_vector[0][0]; |
2216 | | |
2217 | 548 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[1] = |
2218 | 548 | &pstr_dec_data->str_usac_data.time_sample_vector[1][0]; |
2219 | 548 | } else if (num_channels_1 == 2) { |
2220 | 46.1k | for (; i < 1024; i++) { |
2221 | 46.0k | pstr_dec_data->str_usac_data.time_sample_vector[0][i] = |
2222 | 46.0k | ((FLOAT32)time_data[2 * i + 0]); |
2223 | 46.0k | pstr_dec_data->str_usac_data.time_sample_vector[1][i] = |
2224 | 46.0k | ((FLOAT32)time_data[2 * i + 1]); |
2225 | 46.0k | } |
2226 | 45 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[0] = |
2227 | 45 | &pstr_dec_data->str_usac_data.time_sample_vector[0][0]; |
2228 | | |
2229 | 45 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[1] = |
2230 | 45 | &pstr_dec_data->str_usac_data.time_sample_vector[1][0]; |
2231 | 45 | } |
2232 | 593 | } |
2233 | 2.99k | } |
2234 | 2.99k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->ec_flag = |
2235 | 2.99k | p_obj_exhaacplus_dec->aac_config.ui_err_conceal; |
2236 | 2.99k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->esbr_hq = |
2237 | 2.99k | p_obj_exhaacplus_dec->aac_config.ui_hq_esbr; |
2238 | 2.99k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->enh_sbr = |
2239 | 2.99k | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr; |
2240 | 2.99k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->enh_sbr_ps = |
2241 | 2.99k | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr_ps; |
2242 | | |
2243 | 2.99k | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
2244 | 2.99k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->xaac_jmp_buf = |
2245 | 2.99k | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
2246 | 2.99k | } |
2247 | | |
2248 | 2.99k | if (ixheaacd_applysbr(p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx], |
2249 | 2.99k | &p_state_enhaacplus_dec->pstr_stream_sbr[0][0], time_data, |
2250 | 2.99k | &num_channels_1, frame_status, |
2251 | 2.99k | p_obj_exhaacplus_dec->aac_config.down_sample_flag, 0, |
2252 | 2.99k | &sbr_scratch_struct, 1, 1, 0, NULL, NULL, |
2253 | 2.99k | p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present, |
2254 | 2.99k | p_state_enhaacplus_dec->audio_object_type, 1, |
2255 | 2.99k | p_state_enhaacplus_dec->ldmps_present, frame_size_1, |
2256 | 2.99k | p_state_enhaacplus_dec->heaac_mps_handle.heaac_mps_present, |
2257 | 2.99k | p_obj_exhaacplus_dec->aac_config.ui_err_conceal, |
2258 | 2.99k | p_obj_exhaacplus_dec->aac_config.first_frame) != SBRDEC_OK) { |
2259 | 23 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; |
2260 | 23 | return -1; |
2261 | 2.96k | } else { |
2262 | 2.96k | if (!p_obj_exhaacplus_dec->aac_config.down_sample_flag) { |
2263 | 1.29k | sample_rate_1 *= 2; |
2264 | 1.29k | } |
2265 | 2.96k | if (p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present == 1) { |
2266 | 2.32k | p_obj_exhaacplus_dec->p_state_aac->mps_dec_handle.pre_mix_req = 1; |
2267 | 2.32k | ixheaacd_mps_payload( |
2268 | 2.32k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx], |
2269 | 2.32k | p_obj_exhaacplus_dec); |
2270 | 2.32k | } |
2271 | 2.96k | } |
2272 | 2.96k | { |
2273 | 2.96k | WORD32 audio_object_type = p_state_enhaacplus_dec->audio_object_type; |
2274 | | |
2275 | 2.96k | if (audio_object_type != AOT_ER_AAC_ELD && audio_object_type != AOT_ER_AAC_LD) { |
2276 | 593 | WORD32 out_bytes = 0; |
2277 | 593 | ia_dec_data_struct *pstr_dec_data = |
2278 | 593 | (ia_dec_data_struct *)p_state_enhaacplus_dec->pstr_dec_data; |
2279 | 593 | ixheaacd_samples_sat((WORD8 *)time_data, 2048, 16, |
2280 | 593 | pstr_dec_data->str_usac_data.time_sample_vector, &out_bytes, 1); |
2281 | 593 | } |
2282 | 2.96k | } |
2283 | 2.96k | if (p_obj_exhaacplus_dec->aac_config.flag_downmix) { |
2284 | 0 | num_channels_1 = 1; |
2285 | 0 | } |
2286 | 2.96k | if (num_channels_1_t == 1 && num_channels_1 == 2) ps_detected = 1; |
2287 | 13.5k | } else { |
2288 | 13.5k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config.no_ldsbr_present = 1; |
2289 | 13.5k | } |
2290 | | |
2291 | 16.5k | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
2292 | 16.5k | p_state_enhaacplus_dec->pstr_bit_buf = it_bit_buff; |
2293 | | |
2294 | 16.5k | { |
2295 | 16.5k | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = |
2296 | 16.5k | ixheaacd_aac_decoder_init( |
2297 | 16.5k | p_state_enhaacplus_dec, |
2298 | 16.5k | p_state_enhaacplus_dec->pstr_stream_sbr[0], 2, |
2299 | 16.5k | p_state_enhaacplus_dec->aac_persistent_mem_v, |
2300 | 16.5k | p_state_enhaacplus_dec->frame_length); |
2301 | | |
2302 | 16.5k | if (!p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]) { |
2303 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2304 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_DEC_INIT_FAIL; |
2305 | 0 | } |
2306 | | |
2307 | 16.5k | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
2308 | 2.88k | WORD32 harmonic_sbr_flag = 0; |
2309 | 2.88k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = ixheaacd_init_sbr( |
2310 | 2.88k | sample_rate_2, frame_size_2, |
2311 | 2.88k | (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, |
2312 | 2.88k | p_state_enhaacplus_dec->sbr_persistent_mem_v, |
2313 | 2.88k | p_state_enhaacplus_dec->ptr_overlap_buf, MAXNRSBRCHANNELS, 1, 1, |
2314 | 2.88k | frame_size_2 * 2, &harmonic_sbr_flag, NULL, |
2315 | 2.88k | p_state_enhaacplus_dec->str_sbr_config, |
2316 | 2.88k | p_state_enhaacplus_dec->audio_object_type, |
2317 | 2.88k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
2318 | 2.88k | .ldmps_present_flag, |
2319 | 2.88k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
2320 | 2.88k | .no_ldsbr_present); |
2321 | 2.88k | } |
2322 | 16.5k | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
2323 | 2.88k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->xaac_jmp_buf = |
2324 | 2.88k | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
2325 | 2.88k | } |
2326 | 16.5k | } |
2327 | | |
2328 | 16.5k | if (sample_rate < sample_rate_1) sample_rate = sample_rate_1; |
2329 | | |
2330 | 16.5k | ch_idx++; |
2331 | | |
2332 | 16.5k | if (p_state_enhaacplus_dec->audio_object_type >= ER_OBJECT_START && |
2333 | 16.5k | (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD || |
2334 | 5.75k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || |
2335 | 5.75k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LC)) |
2336 | 5.71k | break; |
2337 | 16.5k | } |
2338 | | |
2339 | 11.1k | { |
2340 | 11.1k | ia_adts_crc_info_struct *ptr_adts_crc_info = |
2341 | 11.1k | p_state_enhaacplus_dec->ptr_bit_stream->pstr_adts_crc_info; |
2342 | 11.1k | if (ptr_adts_crc_info->crc_active == 1) { |
2343 | 89 | if ((error_code = ixheaacd_adts_crc_check_crc(ptr_adts_crc_info))) { |
2344 | 88 | return error_code; |
2345 | 88 | } |
2346 | 89 | } |
2347 | 11.1k | } |
2348 | | |
2349 | 11.0k | { |
2350 | 11.0k | VOID *temp; |
2351 | 11.0k | WORD prev_persistent_used_t; |
2352 | 11.0k | WORD prev_sbrpersistent_used_t; |
2353 | 11.0k | WORD ps_enable; |
2354 | 11.0k | WORD ch_idx_err = 0; |
2355 | 11.0k | WORD persistent_used_t = 0; |
2356 | 11.0k | WORD channel_check = 0; |
2357 | 11.0k | WORD cc_channel_check = 0; |
2358 | 11.0k | WORD max_ch_num = p_obj_exhaacplus_dec->aac_config.ui_max_channels; |
2359 | 11.0k | WORD32 harmonic_sbr_flag = 0; |
2360 | 11.0k | i = 0; |
2361 | | |
2362 | 11.0k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = ch_idx; |
2363 | 24.5k | while (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx_err] <= 3 && |
2364 | 25.1k | p_obj_exhaacplus_dec->aac_config.element_type[ch_idx_err] >= 0) { |
2365 | 13.4k | ch_idx_err++; |
2366 | 13.4k | } |
2367 | | |
2368 | 11.0k | if (ch_idx_err == 0) { |
2369 | 23 | p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 0; |
2370 | 23 | p_state_enhaacplus_dec->i_bytes_consumed = (WORD32)( |
2371 | 23 | it_bit_buff->ptr_read_next - it_bit_buff->ptr_bit_buf_base); |
2372 | 23 | return IA_XHEAAC_DEC_INIT_NONFATAL_DECODE_FRAME_ERROR; |
2373 | 23 | } |
2374 | | |
2375 | 11.0k | if (ch_idx_err == 1) |
2376 | 10.9k | ps_enable = 1; |
2377 | 100 | else |
2378 | 100 | ps_enable = 0; |
2379 | | |
2380 | 20.0k | while (p_obj_exhaacplus_dec->aac_config.element_type[i] >= 0 && |
2381 | 20.0k | p_obj_exhaacplus_dec->aac_config.element_type[i] <= 3) { |
2382 | 13.4k | WORD32 channel = 0; |
2383 | 13.4k | switch (p_obj_exhaacplus_dec->aac_config.element_type[i]) { |
2384 | 8.87k | case 0: |
2385 | 10.6k | case 3: |
2386 | 10.6k | channel = 1; |
2387 | 10.6k | break; |
2388 | 2.44k | case 1: |
2389 | 2.44k | channel = 2; |
2390 | 2.44k | break; |
2391 | 368 | case 2: |
2392 | 368 | if (max_ch_num > 2) { |
2393 | 368 | if (p_obj_exhaacplus_dec->aac_config.element_instance_order[i] != |
2394 | 368 | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel) { |
2395 | 230 | i++; |
2396 | 230 | continue; |
2397 | 230 | } |
2398 | 138 | channel = 1; |
2399 | 138 | } else { |
2400 | 0 | i++; |
2401 | 0 | continue; |
2402 | 0 | } |
2403 | 138 | cc_channel_check++; |
2404 | 138 | break; |
2405 | 0 | default: |
2406 | 0 | return -1; |
2407 | 13.4k | } |
2408 | | |
2409 | 13.2k | if (cc_channel_check > MAX_CC_CHANNEL_NUM) |
2410 | 1 | return IA_XHEAAC_DEC_EXE_FATAL_UNIMPLEMENTED_CCE; |
2411 | 13.2k | if (ps_enable == 1) { |
2412 | 10.8k | channel = 2; |
2413 | 10.8k | } |
2414 | | |
2415 | 13.2k | if (p_obj_exhaacplus_dec->aac_config.element_type[i] != 2) { |
2416 | 13.0k | channel_check += channel; |
2417 | 13.0k | } |
2418 | | |
2419 | 13.2k | if (channel_check > max_ch_num) { |
2420 | 4 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2421 | 4 | return IA_XHEAAC_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX; |
2422 | 4 | } |
2423 | | |
2424 | 13.2k | temp = p_state_enhaacplus_dec->aac_persistent_mem_v; |
2425 | | |
2426 | 13.2k | prev_persistent_used_t = persistent_used_t; |
2427 | | |
2428 | 13.2k | ixheaacd_allocate_mem_persistent( |
2429 | 13.2k | p_obj_exhaacplus_dec, p_state_enhaacplus_dec, channel, |
2430 | 13.2k | &persistent_used_t, &prev_sbrpersistent_used_t, ps_enable); |
2431 | | |
2432 | 13.2k | p_state_enhaacplus_dec->aac_persistent_mem_v = temp; |
2433 | 13.2k | p_state_enhaacplus_dec->last_frame_ok = 1; |
2434 | | |
2435 | 13.2k | p_state_enhaacplus_dec->num_channel_last = 0; |
2436 | 13.2k | p_state_enhaacplus_dec->ui_init_done = 0; |
2437 | 13.2k | p_state_enhaacplus_dec->ui_input_over = 0; |
2438 | 13.2k | p_state_enhaacplus_dec->ptr_bit_stream = |
2439 | 13.2k | p_state_enhaacplus_dec->pstr_bit_buf; |
2440 | | |
2441 | 13.2k | p_state_enhaacplus_dec->pstr_aac_dec_info[i] = 0; |
2442 | | |
2443 | 13.2k | p_state_enhaacplus_dec->pstr_aac_dec_info[i] = |
2444 | 13.2k | ixheaacd_aac_decoder_init( |
2445 | 13.2k | p_state_enhaacplus_dec, |
2446 | 13.2k | p_state_enhaacplus_dec->pstr_stream_sbr[i], channel, |
2447 | 13.2k | (WORD8 *)p_state_enhaacplus_dec->aac_persistent_mem_v + |
2448 | 13.2k | prev_persistent_used_t, |
2449 | 13.2k | p_state_enhaacplus_dec->frame_length); |
2450 | | |
2451 | 13.2k | if (!p_state_enhaacplus_dec->pstr_aac_dec_info[i]) { |
2452 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2453 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_DEC_INIT_FAIL; |
2454 | 0 | } |
2455 | | |
2456 | 13.2k | p_state_enhaacplus_dec->str_sbr_dec_info[i] = ixheaacd_init_sbr( |
2457 | 13.2k | sample_rate_2, frame_size_2, |
2458 | 13.2k | (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, |
2459 | 13.2k | p_state_enhaacplus_dec->sbr_persistent_mem_v, |
2460 | 13.2k | p_state_enhaacplus_dec->ptr_overlap_buf, channel, ps_enable, 1, |
2461 | 13.2k | frame_size_2 * 2, &harmonic_sbr_flag, NULL, |
2462 | 13.2k | p_state_enhaacplus_dec->str_sbr_config, |
2463 | 13.2k | p_state_enhaacplus_dec->audio_object_type, |
2464 | 13.2k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
2465 | 13.2k | .ldmps_present_flag, |
2466 | 13.2k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
2467 | 13.2k | .no_ldsbr_present); |
2468 | 13.2k | if (p_state_enhaacplus_dec->str_sbr_dec_info[i]) { |
2469 | 13.1k | p_state_enhaacplus_dec->str_sbr_dec_info[i]->xaac_jmp_buf = |
2470 | 13.1k | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
2471 | 13.1k | } |
2472 | 13.2k | if ((sbr_present_flag && |
2473 | 13.2k | ((p_obj_exhaacplus_dec->p_state_aac->audio_object_type == |
2474 | 2.90k | AOT_AAC_LC) || |
2475 | 2.90k | (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == |
2476 | 2.32k | AOT_SBR) || |
2477 | 2.90k | (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == |
2478 | 2.32k | AOT_PS))) || |
2479 | 13.2k | ((p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
2480 | 12.6k | .ldmps_present_flag == 1) && |
2481 | 12.6k | (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == |
2482 | 367 | AOT_ER_AAC_ELD))) |
2483 | 945 | p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 1; |
2484 | 13.2k | copy_qmf_to_ldmps(&p_obj_exhaacplus_dec->p_state_aac->mps_dec_handle, |
2485 | 13.2k | p_state_enhaacplus_dec->sbr_persistent_mem_v); |
2486 | 13.2k | if (p_state_enhaacplus_dec->audio_object_type == AOT_AAC_LC && |
2487 | 13.2k | p_state_enhaacplus_dec->ui_mps_out_bytes != 0) { |
2488 | 4.38k | p_state_enhaacplus_dec->heaac_mps_handle.heaac_mps_present = 1; |
2489 | 4.38k | if (p_state_enhaacplus_dec->pstr_stream_sbr[0][0].no_elements) { |
2490 | 0 | p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle.mps_with_sbr = 1; |
2491 | 0 | } |
2492 | 4.38k | error_code = |
2493 | 4.38k | ixheaacd_aac_mps_init(p_obj_exhaacplus_dec, mps_buffer, |
2494 | 4.38k | p_state_enhaacplus_dec->ui_mps_out_bytes, sample_rate_1); |
2495 | 4.38k | if (error_code) return error_code; |
2496 | 4.32k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = |
2497 | 4.32k | p_state_enhaacplus_dec->heaac_mps_handle.num_output_channels_at; |
2498 | 4.32k | if (p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle.mps_with_sbr == 1) { |
2499 | 0 | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 1; |
2500 | 0 | } |
2501 | 4.32k | if (p_obj_exhaacplus_dec->aac_config.element_type[i + 1] >= 0 && |
2502 | 4.32k | p_obj_exhaacplus_dec->aac_config.element_type[i + 1] <= 3) { |
2503 | 2 | return IA_FATAL_ERROR; |
2504 | 2 | } |
2505 | 4.32k | break; |
2506 | 4.32k | } |
2507 | 8.82k | i++; |
2508 | 8.82k | } |
2509 | 10.9k | p_state_enhaacplus_dec->pers_mem_ptr = |
2510 | 10.9k | (WORD8 *)p_state_enhaacplus_dec->aac_persistent_mem_v + |
2511 | 10.9k | persistent_used_t; |
2512 | | |
2513 | 10.9k | p_obj_exhaacplus_dec->aac_config.i_channel_mask = |
2514 | 10.9k | ixheaacd_get_channel_mask(p_obj_exhaacplus_dec); |
2515 | | |
2516 | 10.9k | { |
2517 | 10.9k | num_channels_1 = 0; |
2518 | 10.9k | ch_idx = 0; |
2519 | 24.2k | while (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] >= 0 && |
2520 | 24.2k | p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] <= 3) { |
2521 | 13.3k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 0 || |
2522 | 13.3k | p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 3) |
2523 | 10.4k | num_channels_1 += 1; |
2524 | 13.3k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 1) |
2525 | 2.43k | num_channels_1 += 2; |
2526 | 13.3k | ch_idx++; |
2527 | 13.3k | } |
2528 | | |
2529 | 10.9k | if (ch_idx == 2 && num_channels_1 == 2) { |
2530 | 184 | p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 2; |
2531 | 184 | } |
2532 | 10.9k | if (ch_idx == 1) { |
2533 | 10.8k | if (num_channels_1 == 1) |
2534 | 8.60k | p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 0; |
2535 | 10.8k | if (num_channels_1 == 2) |
2536 | 2.15k | p_obj_exhaacplus_dec->aac_config.ui_channel_mode = 1; |
2537 | 10.8k | } |
2538 | | |
2539 | 10.9k | if (ps_detected == 1 && num_channels_1 == 1) num_channels_1 = 2; |
2540 | 10.9k | } |
2541 | 10.9k | } |
2542 | 10.9k | if (1 == p_obj_exhaacplus_dec->aac_config.downmix) num_channels_1 = 2; |
2543 | | |
2544 | 10.9k | if (p_obj_exhaacplus_dec->aac_config.flag_downmix == 1) { |
2545 | 0 | num_channels_1 = 1; |
2546 | 0 | } |
2547 | | |
2548 | 10.9k | if ((p_obj_exhaacplus_dec->aac_config.flag_to_stereo == 1) && |
2549 | 10.9k | (ch_idx == 1 || num_channels_1 <= 2)) { |
2550 | 797 | num_channels_1 = 2; |
2551 | 797 | } |
2552 | | |
2553 | 10.9k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = num_channels_1; |
2554 | 10.9k | p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; |
2555 | 10.9k | p_state_enhaacplus_dec->ui_init_done = 1; |
2556 | | |
2557 | 10.9k | memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); |
2558 | | |
2559 | 10.9k | p_state_enhaacplus_dec->b_n_raw_data_blk = 0; |
2560 | | |
2561 | 11.5k | if (p_obj_exhaacplus_dec->p_state_aac->header_dec_done == 1) { |
2562 | 11.5k | p_obj_exhaacplus_dec->p_state_aac->header_dec_done = 0; |
2563 | 11.5k | } |
2564 | 10.9k | } |
2565 | 25.4k | return err_code; |
2566 | 35.4k | } |
2567 | | |
2568 | | VOID ixheaacd_fill_slot_order(ia_aac_dec_state_struct *p_state_enhaacplus_dec, |
2569 | | WORD32 ch, WORD8 *ptr_is_cpe, |
2570 | 11.2k | WORD8 *ptr_tag_select, WORD32 *ptr_idx_no) { |
2571 | 11.2k | WORD32 i; |
2572 | 11.2k | WORD32 idx_no = *ptr_idx_no; |
2573 | 11.2k | WORD *p_slot_element = p_state_enhaacplus_dec->p_config->slot_element; |
2574 | 11.2k | WORD *p_element_type = p_state_enhaacplus_dec->p_config->element_type; |
2575 | 11.2k | WORD *p_element_instance_order = |
2576 | 11.2k | p_state_enhaacplus_dec->p_config->element_instance_order; |
2577 | | |
2578 | 12.5k | for (i = 0; i < ch; i++) { |
2579 | 1.25k | if (ptr_is_cpe[i] == 0) { |
2580 | 1.08k | *p_slot_element++ = idx_no++; |
2581 | 1.08k | *p_element_type++ = 0; |
2582 | 1.08k | *p_element_instance_order++ = ptr_tag_select[i]; |
2583 | 1.08k | } |
2584 | 1.25k | } |
2585 | 11.2k | *ptr_idx_no = idx_no; |
2586 | 11.2k | } |
2587 | | |
2588 | | VOID ixheaacd_fill_prog_config_slots( |
2589 | 3.75k | ia_aac_dec_state_struct *p_state_enhaacplus_dec) { |
2590 | 3.75k | WORD32 idx_no = 0; |
2591 | | |
2592 | 3.75k | ixheaacd_fill_slot_order( |
2593 | 3.75k | p_state_enhaacplus_dec, p_state_enhaacplus_dec->p_config->str_prog_config |
2594 | 3.75k | .num_front_channel_elements, |
2595 | 3.75k | p_state_enhaacplus_dec->p_config->str_prog_config.front_element_is_cpe, |
2596 | 3.75k | p_state_enhaacplus_dec->p_config->str_prog_config |
2597 | 3.75k | .front_element_tag_select, |
2598 | 3.75k | &idx_no); |
2599 | | |
2600 | 3.75k | ixheaacd_fill_slot_order( |
2601 | 3.75k | p_state_enhaacplus_dec, p_state_enhaacplus_dec->p_config->str_prog_config |
2602 | 3.75k | .num_side_channel_elements, |
2603 | 3.75k | p_state_enhaacplus_dec->p_config->str_prog_config.side_element_is_cpe, |
2604 | 3.75k | p_state_enhaacplus_dec->p_config->str_prog_config.side_element_tag_select, |
2605 | 3.75k | &idx_no); |
2606 | | |
2607 | 3.75k | ixheaacd_fill_slot_order( |
2608 | 3.75k | p_state_enhaacplus_dec, p_state_enhaacplus_dec->p_config->str_prog_config |
2609 | 3.75k | .num_back_channel_elements, |
2610 | 3.75k | p_state_enhaacplus_dec->p_config->str_prog_config.back_element_is_cpe, |
2611 | 3.75k | p_state_enhaacplus_dec->p_config->str_prog_config.back_element_tag_select, |
2612 | 3.75k | &idx_no); |
2613 | 3.75k | } |
2614 | | |
2615 | | IA_ERRORCODE ixheaacd_dec_execute( |
2616 | 538k | ia_exhaacplus_dec_api_struct *p_obj_exhaacplus_dec) { |
2617 | 538k | ia_adts_header_struct adts = {0}; |
2618 | 538k | ia_aac_dec_state_struct *p_state_enhaacplus_dec; |
2619 | | |
2620 | 538k | UWORD8 *in_buffer; |
2621 | 538k | WORD16 *time_data; |
2622 | 538k | WORD16 num_of_out_samples = 0; |
2623 | 538k | WORD16 frame_size = 0; |
2624 | 538k | WORD32 sample_rate_dec = 0; |
2625 | 538k | WORD32 sample_rate = 0; |
2626 | 538k | WORD16 num_ch = 0; |
2627 | 538k | struct ia_bit_buf_struct *it_bit_buff; |
2628 | 538k | UWORD8 *mps_buffer; |
2629 | 538k | WORD32 error_code = IA_NO_ERROR; |
2630 | 538k | WORD ch_idx1; |
2631 | 538k | WORD type; |
2632 | 538k | WORD total_channels = 0; |
2633 | 538k | WORD total_elements = 0; |
2634 | 538k | WORD16 *actual_out_buffer = NULL; |
2635 | 538k | WORD ps_enable; |
2636 | 538k | WORD esbr_mono_downmix = 0; |
2637 | 538k | WORD8 element_used[MAX_BS_ELEMENT]; |
2638 | 538k | WORD32 channel_coupling_flag = 0; |
2639 | | |
2640 | 538k | SIZE_T bytes_for_sync; |
2641 | 538k | WORD32 audio_mux_length_bytes_last = 0; |
2642 | 538k | WORD32 ret_val; |
2643 | 538k | WORD32 mps_out_samples; |
2644 | | |
2645 | 538k | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 0; |
2646 | 538k | p_obj_exhaacplus_dec->aac_config.frame_status = 1; |
2647 | | |
2648 | 538k | if (p_obj_exhaacplus_dec->p_state_aac != NULL) { |
2649 | 538k | ret_val = setjmp(p_obj_exhaacplus_dec->p_state_aac->xaac_jmp_buf); |
2650 | 538k | if (ret_val != 0) { |
2651 | 5.98k | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
2652 | 5.98k | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; |
2653 | 5.98k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = 0; |
2654 | 5.98k | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2655 | 5.98k | return IA_NO_ERROR; |
2656 | 5.98k | } |
2657 | 538k | } |
2658 | | |
2659 | 532k | time_data = (WORD16 *)(p_obj_exhaacplus_dec |
2660 | 532k | ->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]); |
2661 | 532k | in_buffer = p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]; |
2662 | 532k | p_state_enhaacplus_dec = p_obj_exhaacplus_dec->p_state_aac; |
2663 | 532k | p_state_enhaacplus_dec->aac_scratch_mem_v = |
2664 | 532k | p_obj_exhaacplus_dec->pp_mem_aac[IA_ENHAACPLUS_DEC_SCRATCH_IDX]; |
2665 | 532k | p_state_enhaacplus_dec->mps_header = -1; |
2666 | 532k | mps_buffer = p_state_enhaacplus_dec->mps_buffer; |
2667 | 532k | it_bit_buff = p_state_enhaacplus_dec->pstr_bit_buf; |
2668 | | |
2669 | 532k | ch_idx1 = 0; |
2670 | 532k | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
2671 | | |
2672 | 532k | if (p_state_enhaacplus_dec->audio_object_type == AOT_USAC) { |
2673 | 264k | WORD32 pcm_size = p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz; |
2674 | 264k | WORD8 *inbuffer = (WORD8 *)(p_obj_exhaacplus_dec |
2675 | 264k | ->pp_mem_aac[IA_ENHAACPLUS_DEC_INPUT_IDX]); |
2676 | 264k | WORD8 *outbuffer = |
2677 | 264k | (WORD8 *)(p_obj_exhaacplus_dec |
2678 | 264k | ->pp_mem_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]); |
2679 | 264k | WORD32 out_bytes = 0; |
2680 | | |
2681 | 264k | WORD32 frames_done = p_obj_exhaacplus_dec->p_state_aac->frame_counter; |
2682 | | |
2683 | 264k | ia_dec_data_struct *pstr_dec_data = |
2684 | 264k | (ia_dec_data_struct *)(p_obj_exhaacplus_dec->p_state_aac |
2685 | 264k | ->pstr_dec_data); |
2686 | | |
2687 | 264k | if (pstr_dec_data->str_usac_data.down_samp_sbr != 0) return IA_FATAL_ERROR; |
2688 | | |
2689 | 264k | if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 0) { |
2690 | 264k | ia_audio_specific_config_struct *ptr_audio_specific_config = |
2691 | 264k | ((ia_audio_specific_config_struct *) |
2692 | 264k | p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); |
2693 | | |
2694 | 264k | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
2695 | 264k | .preroll_counter = 0; |
2696 | 264k | { |
2697 | 264k | WORD32 iii = 0; |
2698 | 1.32M | for (iii = 0; iii < (MAX_AUDIO_PREROLLS + 1); iii++) { |
2699 | 1.05M | ((ia_dec_data_struct *)(p_obj_exhaacplus_dec->p_state_aac |
2700 | 1.05M | ->pstr_dec_data)) |
2701 | 1.05M | ->str_frame_data.str_audio_specific_config.str_usac_config |
2702 | 1.05M | .str_usac_dec_config.usac_ext_gain_payload_len[iii] = 0; |
2703 | 1.05M | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
2704 | 1.05M | .usac_ext_gain_payload_len[iii] = |
2705 | 1.05M | 0; // reinitilize the payload len buff |
2706 | 1.05M | ptr_audio_specific_config->str_usac_config.str_usac_dec_config |
2707 | 1.05M | .preroll_bytes[iii] = 0; |
2708 | 1.05M | } |
2709 | 264k | } |
2710 | | |
2711 | 264k | ((ia_dec_data_struct *)(p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data)) |
2712 | 264k | ->str_frame_data.str_audio_specific_config.str_usac_config |
2713 | 264k | .str_usac_dec_config.preroll_counter = 0; |
2714 | 264k | error_code = ixheaacd_dec_main( |
2715 | 264k | p_obj_exhaacplus_dec, inbuffer, outbuffer, &out_bytes, frames_done, |
2716 | 264k | pcm_size, &p_obj_exhaacplus_dec->p_state_aac->num_of_output_ch); |
2717 | 264k | if (error_code) { |
2718 | 1.74k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2719 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2720 | 1.74k | } else { |
2721 | 1.74k | return error_code; |
2722 | 1.74k | } |
2723 | 1.74k | } |
2724 | 263k | p_obj_exhaacplus_dec->p_state_aac->frame_counter++; |
2725 | 263k | } else { |
2726 | 0 | out_bytes = 0; |
2727 | 0 | } |
2728 | | |
2729 | 263k | if (pstr_dec_data->str_usac_data.ec_flag == 0) { |
2730 | 259k | if (p_state_enhaacplus_dec->bs_format != LOAS_BSFORMAT) { |
2731 | 1.96k | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
2732 | 1.96k | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; |
2733 | 1.96k | } |
2734 | 259k | } else { |
2735 | 3.14k | if (p_state_enhaacplus_dec->bs_format != LOAS_BSFORMAT) { |
2736 | 0 | if (pstr_dec_data->str_usac_data.frame_ok == 0) { |
2737 | 0 | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
2738 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; |
2739 | 0 | pstr_dec_data->dec_bit_buf.cnt_bits = 0; |
2740 | 0 | } else { |
2741 | 0 | ia_dec_data_struct *pstr_dec_data = |
2742 | 0 | (ia_dec_data_struct *)p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data; |
2743 | |
|
2744 | 0 | if (pstr_dec_data->dec_bit_buf.cnt_bits & 7) { |
2745 | 0 | pstr_dec_data->dec_bit_buf.cnt_bits -= (pstr_dec_data->dec_bit_buf.cnt_bits & 7); |
2746 | 0 | } |
2747 | 0 | if (pstr_dec_data->dec_bit_buf.cnt_bits == 0) { |
2748 | 0 | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
2749 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; |
2750 | 0 | } else { |
2751 | 0 | p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = |
2752 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes - |
2753 | 0 | (pstr_dec_data->dec_bit_buf.cnt_bits >> 3); |
2754 | 0 | } |
2755 | 0 | } |
2756 | 0 | } |
2757 | 3.14k | } |
2758 | | |
2759 | 263k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = out_bytes; |
2760 | 263k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = |
2761 | 263k | p_obj_exhaacplus_dec->p_state_aac->num_of_output_ch; |
2762 | 263k | pstr_dec_data->str_usac_data.sbr_parse_err_flag = 0; |
2763 | | |
2764 | 263k | return 0; |
2765 | 264k | } |
2766 | | |
2767 | 565k | while (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] <= 3 && |
2768 | 571k | p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] >= 0) { |
2769 | 298k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 0 || |
2770 | 298k | p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 3) { |
2771 | 235k | total_channels += 1; |
2772 | 235k | total_elements += 1; |
2773 | 235k | } |
2774 | 298k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 1) { |
2775 | 61.3k | total_elements += 1; |
2776 | 61.3k | total_channels += 2; |
2777 | 61.3k | } |
2778 | 298k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx1] == 2) { |
2779 | 1.70k | total_elements += 1; |
2780 | 1.70k | } |
2781 | | |
2782 | 298k | ch_idx1++; |
2783 | 298k | if (ch_idx1 > MAX_BS_ELEMENT) { |
2784 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) |
2785 | 0 | break; |
2786 | 0 | else |
2787 | 0 | return IA_FATAL_ERROR; |
2788 | 0 | } |
2789 | 298k | } |
2790 | | |
2791 | 267k | if (ch_idx1 != 1) { |
2792 | 12.5k | ps_enable = 0; |
2793 | 12.5k | if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { |
2794 | 12.5k | WORD32 scratch_pointer; |
2795 | | |
2796 | 12.5k | scratch_pointer = (MAX_SCR_SIZE - SCR_INTER_SCR_SIZE); |
2797 | | |
2798 | 12.5k | p_state_enhaacplus_dec->coup_ch_output = |
2799 | 12.5k | (WORD32 *)((WORD8 *) |
2800 | 12.5k | p_obj_exhaacplus_dec->p_state_aac->aac_scratch_mem_v + |
2801 | 12.5k | scratch_pointer); |
2802 | 12.5k | } |
2803 | | |
2804 | 12.5k | } |
2805 | | |
2806 | 254k | else { |
2807 | 254k | if (total_channels < (WORD)p_obj_exhaacplus_dec->aac_config.ui_n_channels) |
2808 | 23.6k | total_channels = p_obj_exhaacplus_dec->aac_config.ui_n_channels; |
2809 | 254k | ps_enable = 1; |
2810 | 254k | } |
2811 | | |
2812 | 267k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = 0; |
2813 | 267k | p_obj_exhaacplus_dec->p_state_aac->ui_mps_out_bytes = 0; |
2814 | 267k | if (p_state_enhaacplus_dec->ui_in_bytes == 0) { |
2815 | 0 | UWORD32 i; |
2816 | 0 | WORD32 j; |
2817 | 0 | if (p_state_enhaacplus_dec->peak_lim_init == 1) { |
2818 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = |
2819 | 0 | (p_state_enhaacplus_dec->peak_limiter.attack_time_samples) * |
2820 | 0 | total_channels * sizeof(WORD16); |
2821 | |
|
2822 | 0 | for (j = 0; j < total_channels; j++) { |
2823 | 0 | for (i = 0; |
2824 | 0 | i < (p_state_enhaacplus_dec->peak_limiter.attack_time_samples - |
2825 | 0 | p_state_enhaacplus_dec->peak_limiter.delayed_input_index); |
2826 | 0 | i++) { |
2827 | 0 | *(time_data + total_channels * i + j) = ixheaac_round16( |
2828 | 0 | (WORD32)*(p_state_enhaacplus_dec->peak_limiter.delayed_input + |
2829 | 0 | (p_state_enhaacplus_dec->peak_limiter.delayed_input_index) * |
2830 | 0 | total_channels + |
2831 | 0 | total_channels * i + j)); |
2832 | 0 | } |
2833 | 0 | } |
2834 | |
|
2835 | 0 | for (j = 0; j < total_channels; j++) { |
2836 | 0 | for (i = 0; |
2837 | 0 | i < p_state_enhaacplus_dec->peak_limiter.delayed_input_index; |
2838 | 0 | i++) { |
2839 | 0 | *(time_data + |
2840 | 0 | (p_state_enhaacplus_dec->peak_limiter.attack_time_samples - |
2841 | 0 | p_state_enhaacplus_dec->peak_limiter.delayed_input_index) * |
2842 | 0 | total_channels + |
2843 | 0 | total_channels * i + j) = |
2844 | 0 | ixheaac_round16( |
2845 | 0 | (WORD32)*(p_state_enhaacplus_dec->peak_limiter.delayed_input + |
2846 | 0 | total_channels * i + j)); |
2847 | 0 | } |
2848 | 0 | } |
2849 | |
|
2850 | 0 | if (p_obj_exhaacplus_dec->aac_config.dup_stereo_flag) { |
2851 | 0 | for (i = 0; |
2852 | 0 | i < (p_state_enhaacplus_dec->peak_limiter.attack_time_samples); |
2853 | 0 | i++) { |
2854 | 0 | time_data[2 * i + 1] = time_data[2 * i + 0]; |
2855 | 0 | } |
2856 | 0 | } |
2857 | 0 | } else { |
2858 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = 0; |
2859 | 0 | } |
2860 | |
|
2861 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
2862 | 0 | return IA_NO_ERROR; |
2863 | 0 | } |
2864 | | |
2865 | 267k | if (ch_idx1 == 0) { |
2866 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2867 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2868 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2869 | 0 | } else { |
2870 | 0 | return IA_XHEAAC_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; |
2871 | 0 | } |
2872 | 0 | } |
2873 | 267k | if (total_channels > (WORD)p_obj_exhaacplus_dec->aac_config.ui_max_channels) { |
2874 | 130 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2875 | 130 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2876 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2877 | 130 | } else { |
2878 | 130 | return IA_XHEAAC_DEC_CONFIG_NONFATAL_INVALID_MAX_CHANNEL; |
2879 | 130 | } |
2880 | 130 | } |
2881 | | |
2882 | 267k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD || |
2883 | 267k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD) { |
2884 | 165k | if (p_obj_exhaacplus_dec->aac_config.ui_mp4_flag) |
2885 | 1.31k | p_state_enhaacplus_dec->frame_size = p_state_enhaacplus_dec->ui_in_bytes; |
2886 | 165k | } |
2887 | | |
2888 | 267k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LC) { |
2889 | 52.3k | if (p_obj_exhaacplus_dec->aac_config.ui_mp4_flag) |
2890 | 122 | p_state_enhaacplus_dec->frame_size = 1024; |
2891 | 52.3k | } |
2892 | | |
2893 | 267k | { |
2894 | 267k | ixheaacd_create_init_bit_buf(it_bit_buff, in_buffer, |
2895 | 267k | p_state_enhaacplus_dec->ui_in_bytes); |
2896 | 267k | it_bit_buff->xaac_jmp_buf = &(p_state_enhaacplus_dec->xaac_jmp_buf); |
2897 | | |
2898 | 267k | it_bit_buff->adts_header_present = |
2899 | 267k | p_state_enhaacplus_dec->s_adts_hdr_present; |
2900 | 267k | it_bit_buff->no_raw_data_blocks = |
2901 | 267k | (WORD8)p_state_enhaacplus_dec->b_n_raw_data_blk; |
2902 | 267k | it_bit_buff->protection_absent = p_state_enhaacplus_dec->protection_absent; |
2903 | | |
2904 | 267k | if (p_state_enhaacplus_dec->s_adts_hdr_present) { |
2905 | 44.0k | if (p_state_enhaacplus_dec->b_n_raw_data_blk == 0) { |
2906 | 42.2k | WORD32 error; |
2907 | | |
2908 | 42.2k | error = ixheaacd_readifadts(p_state_enhaacplus_dec, it_bit_buff, &adts); |
2909 | 42.2k | if (error) { |
2910 | 1.78k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2911 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2912 | 0 | if (adts.samp_freq_index > 11) { |
2913 | 0 | adts.samp_freq_index = 11; |
2914 | 0 | } |
2915 | 1.78k | } else { |
2916 | 1.78k | return error; |
2917 | 1.78k | } |
2918 | 1.78k | } |
2919 | | |
2920 | 40.4k | if ((WORD32)p_state_enhaacplus_dec->sampling_rate != |
2921 | 40.4k | (WORD32)((p_obj_exhaacplus_dec->aac_tables.pstr_huffmann_tables |
2922 | 40.4k | ->str_sample_rate_info[adts.samp_freq_index] |
2923 | 40.4k | .sampling_frequency))) { |
2924 | 20 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
2925 | 20 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2926 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2927 | 20 | } else { |
2928 | 20 | return IA_XHEAAC_DEC_EXE_NONFATAL_CHANGED_ADTS_SF; |
2929 | 20 | } |
2930 | 20 | } |
2931 | 40.4k | } |
2932 | 44.0k | } |
2933 | | |
2934 | 265k | bytes_for_sync = (SIZE_T)it_bit_buff->ptr_read_next; |
2935 | | |
2936 | 265k | if (p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) { |
2937 | 225k | WORD32 result, audio_mux_len_bytes_last; |
2938 | 225k | WORD32 cnt_bits = it_bit_buff->cnt_bits; |
2939 | 225k | WORD32 sync = ixheaacd_read_bits_buf(it_bit_buff, 11); |
2940 | 225k | UWORD32 curr_samp_rate = 0; |
2941 | | |
2942 | 225k | if (p_state_enhaacplus_dec->latm_initialized) |
2943 | 219k | curr_samp_rate = |
2944 | 219k | p_state_enhaacplus_dec->latm_struct_element.layer_info[0][0] |
2945 | 219k | .asc.sampling_freq; |
2946 | | |
2947 | 144M | while (sync != 0x2b7) { |
2948 | 144M | sync = ((sync & 0x3ff) << 1) | ixheaacd_read_bits_buf(it_bit_buff, 1); |
2949 | 144M | if (it_bit_buff->cnt_bits < 13) { |
2950 | 1.72k | ixheaacd_read_bidirection(it_bit_buff, -11); |
2951 | 1.72k | p_state_enhaacplus_dec->i_bytes_consumed = |
2952 | 1.72k | (cnt_bits - it_bit_buff->cnt_bits) / 8; |
2953 | | |
2954 | 1.72k | if (p_state_enhaacplus_dec->i_bytes_consumed == 0) |
2955 | 62 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
2956 | 1.72k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2957 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2958 | 1.72k | } else { |
2959 | 1.72k | return (IA_XHEAAC_DEC_INIT_NONFATAL_HEADER_NOT_AT_START); |
2960 | 1.72k | } |
2961 | 1.72k | } |
2962 | 144M | } |
2963 | | |
2964 | 224k | it_bit_buff->audio_mux_align = it_bit_buff->cnt_bits - 13; |
2965 | | |
2966 | 224k | audio_mux_len_bytes_last = ixheaacd_read_bits_buf(it_bit_buff, 13); |
2967 | | |
2968 | 224k | audio_mux_length_bytes_last = audio_mux_len_bytes_last; |
2969 | | |
2970 | 224k | bytes_for_sync = (SIZE_T)it_bit_buff->ptr_read_next - bytes_for_sync; |
2971 | | |
2972 | 224k | if (it_bit_buff->cnt_bits < (audio_mux_len_bytes_last << 3)) { |
2973 | 1.13k | ixheaacd_read_bidirection(it_bit_buff, -(13 + 11)); |
2974 | 1.13k | p_state_enhaacplus_dec->i_bytes_consumed = (cnt_bits - it_bit_buff->cnt_bits) / 8; |
2975 | 1.13k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2976 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2977 | 1.13k | } else { |
2978 | 1.13k | return IA_XHEAAC_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES; |
2979 | 1.13k | } |
2980 | 222k | } else { |
2981 | 222k | ixheaacd_read_bidirection(it_bit_buff, -(13)); |
2982 | 222k | } |
2983 | | |
2984 | 222k | if (sync == 0x2b7) { |
2985 | 222k | result = ixheaacd_latm_audio_mux_element( |
2986 | 222k | it_bit_buff, &p_state_enhaacplus_dec->latm_struct_element, |
2987 | 222k | p_state_enhaacplus_dec, |
2988 | 222k | (ia_sampling_rate_info_struct *)&p_obj_exhaacplus_dec->aac_tables |
2989 | 222k | .pstr_huffmann_tables->str_sample_rate_info[0]); |
2990 | 222k | if (result < 0) { |
2991 | 613 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
2992 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
2993 | 613 | } else { |
2994 | 613 | return result; |
2995 | 613 | } |
2996 | 613 | } |
2997 | 222k | if (!p_state_enhaacplus_dec->latm_initialized) { |
2998 | 5.89k | p_state_enhaacplus_dec->sampling_rate = |
2999 | 5.89k | p_state_enhaacplus_dec->latm_struct_element.layer_info[0][0].asc.sampling_freq; |
3000 | 5.89k | p_state_enhaacplus_dec->latm_initialized = 1; |
3001 | 216k | } else { |
3002 | 216k | if (p_state_enhaacplus_dec->sampling_rate != curr_samp_rate) { |
3003 | 110 | p_state_enhaacplus_dec->i_bytes_consumed = 0; |
3004 | 110 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3005 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3006 | 110 | } else { |
3007 | 110 | return IA_XHEAAC_DEC_EXE_NONFATAL_CHANGED_ADTS_SF; |
3008 | 110 | } |
3009 | 110 | } |
3010 | 216k | } |
3011 | 222k | } |
3012 | 222k | } |
3013 | 265k | } |
3014 | | |
3015 | 261k | if (total_elements == 2 && total_channels == 2 && |
3016 | 261k | (p_state_enhaacplus_dec->p_config->ui_pce_found_in_hdr == 1 || |
3017 | 5.31k | p_state_enhaacplus_dec->p_config->ui_pce_found_in_hdr == 3)) { |
3018 | 3.15k | ixheaacd_fill_prog_config_slots(p_state_enhaacplus_dec); |
3019 | 3.15k | } |
3020 | | |
3021 | 261k | memset(element_used, 0, sizeof(WORD8) * MAX_BS_ELEMENT); |
3022 | | |
3023 | 261k | if (it_bit_buff->cnt_bits <= 0) { |
3024 | 4 | it_bit_buff->cnt_bits = -1; |
3025 | 4 | ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); |
3026 | 4 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3027 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3028 | 4 | } else { |
3029 | 4 | return (WORD16)((WORD32)IA_XHEAAC_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); |
3030 | 4 | } |
3031 | 4 | } |
3032 | | |
3033 | 261k | { it_bit_buff->initial_cnt_bits = it_bit_buff->cnt_bits; } |
3034 | | |
3035 | 261k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD) { |
3036 | 88.9k | if (p_state_enhaacplus_dec->s_adts_hdr_present) |
3037 | 0 | p_state_enhaacplus_dec->frame_size = adts.aac_frame_length; |
3038 | 88.9k | } |
3039 | | |
3040 | 261k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LC) { |
3041 | 51.7k | if (p_state_enhaacplus_dec->s_adts_hdr_present) |
3042 | 0 | p_state_enhaacplus_dec->frame_size = 1024; |
3043 | 51.7k | } |
3044 | | |
3045 | 267k | if (p_state_enhaacplus_dec->pstr_drc_dec) { |
3046 | 267k | p_state_enhaacplus_dec->pstr_drc_dec->num_drc_elements = 0; |
3047 | | |
3048 | 267k | p_state_enhaacplus_dec->pstr_drc_dec->state = 1; |
3049 | 267k | } |
3050 | 261k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3051 | 0 | if (total_elements > MAX_BS_ELEMENT) { |
3052 | 0 | total_elements = MAX_BS_ELEMENT; |
3053 | 0 | } |
3054 | 0 | } |
3055 | | |
3056 | 261k | WORD16 *intermediate_scr = (WORD16 *)(WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + |
3057 | 261k | (MAX_SCR_SIZE - SCR_INTER_SCR_SIZE - SCR_COUP_CH_OUT_SIZE); |
3058 | | |
3059 | 536k | for (ch_idx1 = 0; ch_idx1 < total_elements; ch_idx1++) { |
3060 | 284k | WORD32 skip_full_decode = 0; |
3061 | 284k | WORD32 ch_idx = ch_idx1; |
3062 | 284k | WORD32 channel = 0; |
3063 | 284k | WORD ch_fac, slot_ele; |
3064 | | |
3065 | 284k | if (p_state_enhaacplus_dec->audio_object_type < ER_OBJECT_START || |
3066 | 284k | (p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_LD && |
3067 | 213k | p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_ELD && |
3068 | 213k | p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_LC)) { |
3069 | 70.4k | jmp_buf local; |
3070 | | |
3071 | 70.4k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal == 1) { |
3072 | 0 | ret_val = setjmp(local); |
3073 | 0 | } |
3074 | 70.4k | if (ret_val == 0) { |
3075 | 70.4k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal == 1) { |
3076 | 0 | p_obj_exhaacplus_dec->p_state_aac->ptr_bit_stream->xaac_jmp_buf = &local; |
3077 | 0 | } |
3078 | 70.4k | error_code = ixheaacd_get_element_index_tag( |
3079 | 70.4k | p_obj_exhaacplus_dec, ch_idx1, &ch_idx, &channel, |
3080 | 70.4k | p_obj_exhaacplus_dec->aac_config.element_instance_order, total_elements, element_used, |
3081 | 70.4k | total_channels, p_state_enhaacplus_dec->pstr_drc_dec, |
3082 | 70.4k | &p_state_enhaacplus_dec->drc_dummy, mps_buffer, &p_state_enhaacplus_dec->mps_header, |
3083 | 70.4k | &p_state_enhaacplus_dec->ui_mps_out_bytes); |
3084 | 70.4k | } |
3085 | | |
3086 | 70.4k | if (error_code || ret_val) { |
3087 | 3.08k | ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); |
3088 | 3.08k | if (it_bit_buff->cnt_bits < 0) { |
3089 | 9 | p_state_enhaacplus_dec->ui_out_bytes = 0; |
3090 | 9 | p_state_enhaacplus_dec->ui_mps_out_bytes = 0; |
3091 | 9 | p_state_enhaacplus_dec->b_n_raw_data_blk = 0; |
3092 | 9 | } |
3093 | 3.08k | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
3094 | 3.08k | p_state_enhaacplus_dec->b_n_raw_data_blk = 0; |
3095 | 3.08k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3096 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3097 | 3.08k | } else { |
3098 | 3.08k | return error_code; |
3099 | 3.08k | } |
3100 | 3.08k | } |
3101 | 67.3k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == ID_CPE) |
3102 | 2.07k | { |
3103 | 2.07k | if (channel != 2) |
3104 | 0 | { |
3105 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) |
3106 | 0 | { |
3107 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3108 | 0 | channel = 2; |
3109 | 0 | } |
3110 | 0 | else |
3111 | 0 | { |
3112 | 0 | return IA_FATAL_ERROR; |
3113 | 0 | } |
3114 | 0 | } |
3115 | 2.07k | } |
3116 | 65.3k | else |
3117 | 65.3k | { |
3118 | 65.3k | if (channel != 1) |
3119 | 0 | { |
3120 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) |
3121 | 0 | { |
3122 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3123 | 0 | channel = 1; |
3124 | 0 | } |
3125 | 0 | else |
3126 | 0 | { |
3127 | 0 | return IA_FATAL_ERROR; |
3128 | 0 | } |
3129 | 0 | } |
3130 | 65.3k | } |
3131 | 213k | } else { |
3132 | 213k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == ID_SCE) |
3133 | 158k | channel = 1; |
3134 | 55.3k | else |
3135 | 55.3k | channel = 2; |
3136 | 213k | } |
3137 | | |
3138 | 281k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal && (error_code || ret_val)) { |
3139 | 0 | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 0 || |
3140 | 0 | p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 3) { |
3141 | 0 | if (channel > 1) { |
3142 | 0 | channel = 1; |
3143 | 0 | } |
3144 | 0 | } |
3145 | 0 | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 1) { |
3146 | 0 | if (channel > 2) { |
3147 | 0 | channel = 2; |
3148 | 0 | } |
3149 | 0 | } |
3150 | 0 | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 2) { |
3151 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { |
3152 | 0 | if (!(p_obj_exhaacplus_dec->aac_config.element_instance_order[ch_idx] != |
3153 | 0 | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel)) { |
3154 | 0 | if (channel > 1) { |
3155 | 0 | channel = 1; |
3156 | 0 | } |
3157 | 0 | } |
3158 | 0 | } |
3159 | 0 | } |
3160 | 0 | if (ps_enable == 1) { |
3161 | 0 | if (channel > 2) { |
3162 | 0 | channel = 2; |
3163 | 0 | } |
3164 | 0 | } |
3165 | 0 | } |
3166 | | |
3167 | 281k | ch_fac = total_channels; |
3168 | 281k | slot_ele = p_obj_exhaacplus_dec->aac_config.slot_element[ch_idx]; |
3169 | 281k | actual_out_buffer = time_data; |
3170 | 281k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] == 2) { |
3171 | 777 | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->p_ind_channel_info = |
3172 | 777 | &p_state_enhaacplus_dec->ind_cc_info; |
3173 | 777 | if (p_obj_exhaacplus_dec->aac_config.element_instance_order[ch_idx] != |
3174 | 777 | p_obj_exhaacplus_dec->aac_config.ui_coupling_channel) { |
3175 | 268 | skip_full_decode = 1; |
3176 | 268 | ixheaacd_set_aac_persistent_buffers( |
3177 | 268 | p_state_enhaacplus_dec->pers_mem_ptr, channel); |
3178 | | |
3179 | 268 | { |
3180 | 268 | struct ia_aac_persistent_struct *aac_persistent_mem = |
3181 | 268 | (struct ia_aac_persistent_struct *) |
3182 | 268 | p_state_enhaacplus_dec->pers_mem_ptr; |
3183 | 268 | aac_persistent_mem->str_aac_decoder.pstr_aac_tables = |
3184 | 268 | &p_obj_exhaacplus_dec->aac_tables; |
3185 | 268 | aac_persistent_mem->str_aac_decoder.pstr_common_tables = |
3186 | 268 | p_obj_exhaacplus_dec->common_tables; |
3187 | 268 | } |
3188 | | |
3189 | 268 | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = 0; |
3190 | | |
3191 | 268 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; |
3192 | | |
3193 | 268 | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx] = |
3194 | 268 | ixheaacd_aac_decoder_init( |
3195 | 268 | p_state_enhaacplus_dec, |
3196 | | |
3197 | 268 | p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx], |
3198 | | |
3199 | 268 | channel, p_state_enhaacplus_dec->pers_mem_ptr, |
3200 | 268 | p_state_enhaacplus_dec->frame_length |
3201 | | |
3202 | 268 | ); |
3203 | 268 | if (!p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]) { |
3204 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = 1; |
3205 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3206 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3207 | 0 | } else { |
3208 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_DEC_INIT_FAIL; |
3209 | 0 | } |
3210 | 0 | } |
3211 | 268 | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->p_ind_channel_info = |
3212 | 268 | (WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + (P_IND_CH_INFO_OFFSET); |
3213 | 268 | } |
3214 | 777 | if (p_obj_exhaacplus_dec->aac_config.element_type[1] < 3 && |
3215 | 777 | p_obj_exhaacplus_dec->aac_config.element_type[1] > 0 && |
3216 | 777 | p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { |
3217 | 98 | actual_out_buffer = |
3218 | 98 | (WORD16 *)(VOID *)p_state_enhaacplus_dec->coup_ch_output; |
3219 | 98 | } |
3220 | 777 | ch_fac = 1; |
3221 | 777 | slot_ele = 0; |
3222 | 777 | } |
3223 | | |
3224 | 281k | type = -1; |
3225 | 281k | p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements = 0; |
3226 | | |
3227 | 281k | { |
3228 | 281k | WORD element_index_order1[MAX_BS_ELEMENT]; |
3229 | 281k | ia_aac_dec_scratch_struct aac_scratch_struct; |
3230 | 281k | memset(&aac_scratch_struct, 0, sizeof(aac_scratch_struct)); |
3231 | | |
3232 | 281k | ixheaacd_allocate_aac_scr( |
3233 | 281k | &aac_scratch_struct, p_state_enhaacplus_dec->aac_scratch_mem_v, |
3234 | 281k | time_data, channel, p_obj_exhaacplus_dec->aac_config.ui_max_channels, |
3235 | 281k | p_state_enhaacplus_dec->audio_object_type); |
3236 | | |
3237 | 281k | if (p_state_enhaacplus_dec->ch_config == 2 && channel == 1) { |
3238 | 92 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3239 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3240 | 92 | } else { |
3241 | 92 | return IA_XHEAAC_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; |
3242 | 92 | } |
3243 | 92 | } |
3244 | | |
3245 | 281k | error_code = ixheaacd_aacdec_decodeframe( |
3246 | 281k | p_obj_exhaacplus_dec, &aac_scratch_struct, actual_out_buffer, |
3247 | 281k | p_obj_exhaacplus_dec->aac_config.frame_status, &type, &ch_idx, 0, channel, |
3248 | 281k | element_index_order1, skip_full_decode, ch_fac, slot_ele, |
3249 | 281k | p_obj_exhaacplus_dec->aac_config.ui_max_channels, total_channels, |
3250 | 281k | p_obj_exhaacplus_dec->p_state_aac->frame_length, |
3251 | 281k | p_obj_exhaacplus_dec->p_state_aac->frame_size, p_state_enhaacplus_dec->pstr_drc_dec, |
3252 | 281k | p_state_enhaacplus_dec->audio_object_type, p_state_enhaacplus_dec->ch_config, |
3253 | 281k | p_state_enhaacplus_dec->eld_specific_config, p_state_enhaacplus_dec->s_adts_hdr_present, |
3254 | 281k | &p_state_enhaacplus_dec->drc_dummy, p_state_enhaacplus_dec->ldmps_present, |
3255 | 281k | &p_state_enhaacplus_dec->slot_pos, mps_buffer, &p_state_enhaacplus_dec->mps_header, |
3256 | 281k | &p_state_enhaacplus_dec->ui_mps_out_bytes, 0, |
3257 | 281k | p_obj_exhaacplus_dec->aac_config.first_frame); |
3258 | | |
3259 | 281k | p_state_enhaacplus_dec->slot_pos -= (channel - 1); |
3260 | 281k | p_state_enhaacplus_dec->sbr_present = 0; |
3261 | | |
3262 | 281k | if (p_obj_exhaacplus_dec->p_state_aac->qshift_adj[0] != LD_OBJ && |
3263 | 281k | p_state_enhaacplus_dec->frame_counter == 0) { |
3264 | 9.89k | ixheaacd_peak_limiter_init( |
3265 | 9.89k | &p_state_enhaacplus_dec->peak_limiter, total_channels, |
3266 | 9.89k | p_obj_exhaacplus_dec->p_state_aac->p_config->ui_samp_freq, |
3267 | 9.89k | &p_state_enhaacplus_dec->peak_limiter.buffer[0], |
3268 | 9.89k | &p_obj_exhaacplus_dec->p_state_aac->delay_in_samples); |
3269 | 9.89k | p_obj_exhaacplus_dec->p_state_aac->peak_lim_init = 1; |
3270 | 9.89k | } |
3271 | | |
3272 | 281k | if (p_state_enhaacplus_dec->audio_object_type < ER_OBJECT_START || |
3273 | 281k | (p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_LD && |
3274 | 212k | p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_ELD && |
3275 | 212k | p_state_enhaacplus_dec->audio_object_type != AOT_ER_AAC_LC)) { |
3276 | 66.9k | if ((error_code == 0) && ((ch_idx1 + 1) == total_elements) && |
3277 | 66.9k | (type != ID_END)) { |
3278 | 1.14k | { |
3279 | 1.14k | p_state_enhaacplus_dec->i_bytes_consumed = (WORD32)( |
3280 | 1.14k | it_bit_buff->ptr_read_next - it_bit_buff->ptr_bit_buf_base); |
3281 | 1.14k | p_state_enhaacplus_dec->b_n_raw_data_blk = 0; |
3282 | 1.14k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3283 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3284 | 1.14k | } else { |
3285 | 1.14k | return IA_XHEAAC_DEC_EXE_NONFATAL_ELE_INSTANCE_TAG_NOT_FOUND; |
3286 | 1.14k | } |
3287 | 1.14k | } |
3288 | 1.14k | } |
3289 | 66.9k | } |
3290 | | |
3291 | 280k | num_ch = p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->channels; |
3292 | 280k | if (skip_full_decode == 0) { |
3293 | 278k | if (p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_ELD || |
3294 | 278k | p_state_enhaacplus_dec->audio_object_type == AOT_ER_AAC_LD) |
3295 | 161k | frame_size = p_state_enhaacplus_dec->frame_length; |
3296 | 116k | else { |
3297 | 116k | frame_size = p_state_enhaacplus_dec->frame_length; |
3298 | 116k | } |
3299 | | |
3300 | 278k | sample_rate_dec = |
3301 | 278k | p_state_enhaacplus_dec->pstr_aac_dec_info[ch_idx]->sampling_rate; |
3302 | 278k | } |
3303 | 280k | } |
3304 | | |
3305 | 280k | if (skip_full_decode == 1) { |
3306 | 263 | p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements = 0; |
3307 | 263 | } |
3308 | | |
3309 | 280k | if (p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements != 0) { |
3310 | 56.1k | p_obj_exhaacplus_dec->aac_config.ui_sbr_mode = 1; |
3311 | 56.1k | } |
3312 | | |
3313 | 280k | if (error_code) { |
3314 | 4.54k | if (p_state_enhaacplus_dec->ui_input_over) { |
3315 | 0 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3316 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3317 | 0 | } else { |
3318 | 0 | return IA_XHEAAC_DEC_INIT_FATAL_EO_INPUT_REACHED; |
3319 | 0 | } |
3320 | 0 | } |
3321 | 4.54k | ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); |
3322 | 4.54k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes += |
3323 | 4.54k | p_state_enhaacplus_dec->num_of_out_samples * num_ch * sizeof(WORD16); |
3324 | 4.54k | if (error_code) { |
3325 | 4.54k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3326 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3327 | 4.54k | } else { |
3328 | 4.54k | return error_code; |
3329 | 4.54k | } |
3330 | 4.54k | } |
3331 | 4.54k | } |
3332 | | |
3333 | 275k | error_code = IA_NO_ERROR; |
3334 | | |
3335 | 275k | if (p_obj_exhaacplus_dec->aac_config.ui_auto_sbr_upsample == 0) { |
3336 | 0 | if (p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements == 0 && |
3337 | 0 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
3338 | 0 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; |
3339 | 0 | error_code = IA_XHEAAC_DEC_EXE_NONFATAL_SBR_TURNED_OFF; |
3340 | 0 | } |
3341 | 0 | } |
3342 | 275k | if ((!p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) && |
3343 | 275k | p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0].no_elements) { |
3344 | 32 | WORD32 harmonic_sbr_flag = 0; |
3345 | 32 | error_code = IA_XHEAAC_DEC_EXE_NONFATAL_SBR_TURNED_ON; |
3346 | 32 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = ixheaacd_init_sbr( |
3347 | 32 | sample_rate_dec, frame_size, |
3348 | 32 | (FLAG *)&p_obj_exhaacplus_dec->aac_config.down_sample_flag, |
3349 | 32 | p_state_enhaacplus_dec->sbr_persistent_mem_v, |
3350 | 32 | p_state_enhaacplus_dec->ptr_overlap_buf, ps_enable ? 2 : channel, |
3351 | 32 | ps_enable, 1, frame_size * 2, &harmonic_sbr_flag, NULL, |
3352 | 32 | p_state_enhaacplus_dec->str_sbr_config, |
3353 | 32 | p_state_enhaacplus_dec->audio_object_type, |
3354 | 32 | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
3355 | 32 | .ldmps_present_flag, |
3356 | 32 | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config.no_ldsbr_present); |
3357 | 32 | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
3358 | 5 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->xaac_jmp_buf = |
3359 | 5 | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
3360 | 5 | } |
3361 | 32 | } |
3362 | | |
3363 | 275k | { |
3364 | 275k | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] && |
3365 | 275k | p_state_enhaacplus_dec->pstr_stream_sbr[0][0].no_elements) { |
3366 | 56.0k | ia_sbr_scr_struct sbr_scratch_struct; |
3367 | 56.0k | ixheaacd_allocate_sbr_scr(&sbr_scratch_struct, p_state_enhaacplus_dec->aac_scratch_mem_v, |
3368 | 56.0k | time_data, total_channels, |
3369 | 56.0k | p_obj_exhaacplus_dec->p_state_aac->qshift_adj, |
3370 | 56.0k | p_state_enhaacplus_dec->slot_pos, channel); |
3371 | | |
3372 | 56.0k | p_state_enhaacplus_dec->sbr_present = 1; |
3373 | 56.0k | p_state_enhaacplus_dec->peak_lim_init = 0; |
3374 | | |
3375 | 56.0k | if (p_obj_exhaacplus_dec->aac_config.ui_enh_sbr) |
3376 | 56.0k | { |
3377 | 56.0k | WORD32 audio_object_type = p_state_enhaacplus_dec->audio_object_type; |
3378 | | |
3379 | 56.0k | if (audio_object_type != AOT_ER_AAC_ELD && audio_object_type != AOT_ER_AAC_LD) { |
3380 | 22.9k | WORD32 i = 0; |
3381 | 22.9k | ia_dec_data_struct* pstr_dec_data = |
3382 | 22.9k | (ia_dec_data_struct*)p_state_enhaacplus_dec->pstr_dec_data; |
3383 | 22.9k | if (ch_fac == 1) { |
3384 | 1.88M | for (; i < 1024; i++) { |
3385 | 1.88M | pstr_dec_data->str_usac_data.time_sample_vector[0][i] = |
3386 | 1.88M | (FLOAT32)time_data[i]; |
3387 | 1.88M | } |
3388 | 1.83k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[0] = |
3389 | 1.83k | &pstr_dec_data->str_usac_data.time_sample_vector[0][0]; |
3390 | | |
3391 | 1.83k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[1] = |
3392 | 1.83k | &pstr_dec_data->str_usac_data.time_sample_vector[1][0]; |
3393 | 21.0k | } else if (ch_fac == 2) { |
3394 | 21.4M | for (; i < 1024; i++) { |
3395 | 21.4M | pstr_dec_data->str_usac_data.time_sample_vector[0][i] = |
3396 | 21.4M | (FLOAT32)time_data[2 * i + 0]; |
3397 | 21.4M | pstr_dec_data->str_usac_data.time_sample_vector[1][i] = |
3398 | 21.4M | (FLOAT32)time_data[2 * i + 1]; |
3399 | 21.4M | } |
3400 | 20.9k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[0] = |
3401 | 20.9k | &pstr_dec_data->str_usac_data.time_sample_vector[0][0]; |
3402 | | |
3403 | 20.9k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[1] = |
3404 | 20.9k | &pstr_dec_data->str_usac_data.time_sample_vector[1][0]; |
3405 | 20.9k | } else if (ch_fac > 2) { |
3406 | 132 | if (channel == 1) { |
3407 | 103k | for (; i < 1024; i++) { |
3408 | 103k | pstr_dec_data->str_usac_data.time_sample_vector[0][i] = |
3409 | 103k | (FLOAT32)(time_data + slot_ele)[i* ch_fac]; |
3410 | 103k | } |
3411 | 101 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[0] = |
3412 | 101 | &pstr_dec_data->str_usac_data.time_sample_vector[0][0]; |
3413 | 101 | } else if (channel == 2) { |
3414 | 31.7k | for (; i < 1024; i++) { |
3415 | 31.7k | pstr_dec_data->str_usac_data.time_sample_vector[0][i] = |
3416 | 31.7k | (FLOAT32)(time_data + slot_ele)[ch_fac * i + 0]; |
3417 | 31.7k | pstr_dec_data->str_usac_data.time_sample_vector[1][i] = |
3418 | 31.7k | (FLOAT32)(time_data + slot_ele)[ch_fac * i + 1]; |
3419 | 31.7k | } |
3420 | 31 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[0] = |
3421 | 31 | &pstr_dec_data->str_usac_data.time_sample_vector[0][0]; |
3422 | | |
3423 | 31 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->time_sample_buf[1] = |
3424 | 31 | &pstr_dec_data->str_usac_data.time_sample_vector[1][0]; |
3425 | 31 | } |
3426 | 132 | } |
3427 | 22.9k | } |
3428 | 56.0k | } |
3429 | 56.0k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->esbr_hq = |
3430 | 56.0k | p_obj_exhaacplus_dec->aac_config.ui_hq_esbr; |
3431 | 56.0k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->enh_sbr = |
3432 | 56.0k | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr; |
3433 | 56.0k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->enh_sbr_ps = |
3434 | 56.0k | p_obj_exhaacplus_dec->aac_config.ui_enh_sbr_ps; |
3435 | | |
3436 | 56.0k | if (p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
3437 | 56.0k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]->xaac_jmp_buf = |
3438 | 56.0k | &(p_state_enhaacplus_dec->xaac_jmp_buf); |
3439 | 56.0k | } |
3440 | | |
3441 | 56.0k | if (ixheaacd_applysbr(p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx], |
3442 | 56.0k | &p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx][0], |
3443 | 56.0k | actual_out_buffer, &num_ch, |
3444 | 56.0k | p_obj_exhaacplus_dec->aac_config.frame_status, |
3445 | 56.0k | p_obj_exhaacplus_dec->aac_config.down_sample_flag, |
3446 | 56.0k | esbr_mono_downmix, &sbr_scratch_struct, ps_enable, ch_fac, slot_ele, |
3447 | 56.0k | NULL, &p_state_enhaacplus_dec->str_drc_dec_info, |
3448 | 56.0k | p_state_enhaacplus_dec->eld_specific_config.ld_sbr_flag_present, |
3449 | 56.0k | p_state_enhaacplus_dec->audio_object_type, 0, |
3450 | 56.0k | p_state_enhaacplus_dec->ldmps_present, frame_size, |
3451 | 56.0k | p_state_enhaacplus_dec->heaac_mps_handle.heaac_mps_present, |
3452 | 56.0k | p_obj_exhaacplus_dec->aac_config.ui_err_conceal, |
3453 | 56.0k | p_obj_exhaacplus_dec->aac_config.first_frame) != SBRDEC_OK) { |
3454 | 237 | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] = 0; |
3455 | 237 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3456 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3457 | 237 | } else { |
3458 | 237 | return -1; |
3459 | 237 | } |
3460 | 55.7k | } else { |
3461 | 55.7k | if (!p_obj_exhaacplus_dec->aac_config.down_sample_flag) { |
3462 | 34.2k | frame_size = (WORD16)(frame_size * 2); |
3463 | 34.2k | sample_rate_dec *= 2; |
3464 | 34.2k | } |
3465 | 55.7k | if (p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
3466 | 55.7k | .ldmps_present_flag == 1) { |
3467 | 3.33k | ixheaacd_mps_payload( |
3468 | 3.33k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx], |
3469 | 3.33k | p_obj_exhaacplus_dec); |
3470 | 3.33k | } |
3471 | 55.7k | } |
3472 | | |
3473 | 55.7k | if (p_obj_exhaacplus_dec->aac_config.ui_enh_sbr) |
3474 | 55.2k | { |
3475 | 55.2k | WORD32 audio_object_type = p_state_enhaacplus_dec->audio_object_type; |
3476 | | |
3477 | 55.2k | if (audio_object_type != AOT_ER_AAC_ELD && audio_object_type != AOT_ER_AAC_LD) { |
3478 | 22.8k | WORD32 out_bytes = 0; |
3479 | 22.8k | ia_dec_data_struct *pstr_dec_data = |
3480 | 22.8k | (ia_dec_data_struct *)p_state_enhaacplus_dec->pstr_dec_data; |
3481 | 22.8k | if (ch_fac <= 2) { |
3482 | 22.7k | ixheaacd_samples_sat((WORD8*)time_data, 2048, 16, |
3483 | 22.7k | pstr_dec_data->str_usac_data.time_sample_vector, |
3484 | 22.7k | &out_bytes, ch_fac); |
3485 | 22.7k | } else { |
3486 | 131 | ixheaacd_samples_sat_mc((WORD8*)(time_data + slot_ele), 2048, |
3487 | 131 | pstr_dec_data->str_usac_data.time_sample_vector, |
3488 | 131 | &out_bytes, channel, ch_fac); |
3489 | 131 | } |
3490 | 22.8k | } |
3491 | 55.2k | } |
3492 | 55.7k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config.no_ldsbr_present = |
3493 | 55.7k | 0; |
3494 | 55.7k | if (p_state_enhaacplus_dec->ui_mps_out_bytes > 0) { |
3495 | 151 | p_state_enhaacplus_dec->heaac_mps_handle.heaac_mps_present = 1; |
3496 | 151 | } |
3497 | 219k | } else { |
3498 | 219k | p_state_enhaacplus_dec->mps_dec_handle.ldmps_config.no_ldsbr_present = 1; |
3499 | 219k | } |
3500 | 275k | } |
3501 | | |
3502 | 275k | if (p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
3503 | 275k | .ldmps_present_flag == 1 && |
3504 | 275k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx] && |
3505 | 275k | p_state_enhaacplus_dec->mps_dec_handle.mps_init_done == 1) { |
3506 | 3.36k | if (p_state_enhaacplus_dec->ec_enable) { |
3507 | 0 | if (!p_obj_exhaacplus_dec->aac_config.first_frame) { |
3508 | 0 | error_code = ixheaacd_ld_mps_apply(p_obj_exhaacplus_dec, actual_out_buffer); |
3509 | 0 | if (error_code) p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3510 | 0 | } |
3511 | 3.36k | } else { |
3512 | 3.36k | error_code = ixheaacd_ld_mps_apply(p_obj_exhaacplus_dec, actual_out_buffer); |
3513 | | |
3514 | 3.36k | if (error_code) |
3515 | 72 | return error_code; |
3516 | 3.36k | } |
3517 | 3.36k | } |
3518 | 275k | if (sample_rate < sample_rate_dec) { |
3519 | 257k | sample_rate = sample_rate_dec; |
3520 | 257k | } |
3521 | | |
3522 | 275k | if (p_state_enhaacplus_dec->sbr_present || |
3523 | 275k | p_obj_exhaacplus_dec->p_state_aac->qshift_adj[0] == LD_OBJ) { |
3524 | 114k | num_of_out_samples = frame_size; |
3525 | | |
3526 | 160k | } else { |
3527 | 160k | num_of_out_samples = |
3528 | 160k | frame_size - |
3529 | 160k | MIN((WORD16)p_obj_exhaacplus_dec->p_state_aac->delay_in_samples, frame_size); |
3530 | 160k | } |
3531 | | |
3532 | 275k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal && |
3533 | 275k | p_obj_exhaacplus_dec->aac_config.first_frame && |
3534 | 275k | (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == AOT_ER_AAC_ELD || |
3535 | 0 | p_obj_exhaacplus_dec->p_state_aac->audio_object_type == AOT_ER_AAC_LD)) { |
3536 | 0 | num_of_out_samples = frame_size; |
3537 | 0 | } |
3538 | | |
3539 | 275k | p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; |
3540 | | |
3541 | 275k | p_state_enhaacplus_dec->num_channel_last = num_ch; |
3542 | 275k | p_state_enhaacplus_dec->num_of_out_samples = num_of_out_samples; |
3543 | | |
3544 | 275k | if (p_state_enhaacplus_dec->mps_dec_handle.ldmps_config |
3545 | 275k | .ldmps_present_flag == 1 && |
3546 | 275k | p_state_enhaacplus_dec->mps_dec_handle.mps_init_done == 1 && |
3547 | 275k | p_state_enhaacplus_dec->str_sbr_dec_info[ch_idx]) { |
3548 | 3.29k | if (p_obj_exhaacplus_dec->p_state_aac->mps_dec_handle.output_buffer) { |
3549 | 3.29k | ixheaacd_samples_sat((WORD8 *)actual_out_buffer, num_of_out_samples, |
3550 | 3.29k | p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz, |
3551 | 3.29k | p_obj_exhaacplus_dec->p_state_aac->mps_dec_handle.output_buffer, |
3552 | 3.29k | &mps_out_samples, 2); |
3553 | 3.29k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = mps_out_samples; |
3554 | 3.29k | } |
3555 | 3.29k | num_ch = p_obj_exhaacplus_dec->p_state_aac->mps_dec_handle.out_ch_count; |
3556 | 3.29k | if (p_state_enhaacplus_dec->ec_enable) { |
3557 | 0 | if (p_obj_exhaacplus_dec->aac_config.first_frame) { |
3558 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = |
3559 | 0 | p_state_enhaacplus_dec->num_of_out_samples * num_ch * sizeof(WORD16); |
3560 | 0 | } |
3561 | 0 | } |
3562 | 271k | } else { |
3563 | 271k | if (p_obj_exhaacplus_dec->aac_config.element_type[ch_idx] != 2) { |
3564 | 269k | if (p_obj_exhaacplus_dec->aac_config.flag_to_stereo == 1 && |
3565 | 269k | channel == 1 && total_elements == 1 && num_ch == 1) { |
3566 | 5.71k | num_ch = 2; |
3567 | 5.71k | p_obj_exhaacplus_dec->aac_config.dup_stereo_flag = 1; |
3568 | | |
3569 | 263k | } else { |
3570 | 263k | p_obj_exhaacplus_dec->aac_config.dup_stereo_flag = 0; |
3571 | 263k | } |
3572 | | |
3573 | 269k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = 2; |
3574 | | |
3575 | 269k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes += |
3576 | 269k | p_state_enhaacplus_dec->num_of_out_samples * num_ch * sizeof(WORD16); |
3577 | | |
3578 | 269k | } else { |
3579 | 2.66k | channel_coupling_flag = 1; |
3580 | 2.66k | } |
3581 | 271k | } |
3582 | | |
3583 | 275k | if (p_state_enhaacplus_dec->sbr_present && total_channels > 2) { |
3584 | 295 | for (WORD32 j = 0; j < channel; j++) { |
3585 | 253k | for (WORD32 i = 0; i < frame_size; i++) { |
3586 | 253k | intermediate_scr[total_channels * i + j + |
3587 | 253k | p_state_enhaacplus_dec->slot_pos] = |
3588 | 253k | actual_out_buffer[total_channels * i + j + |
3589 | 253k | p_state_enhaacplus_dec->slot_pos]; |
3590 | 253k | } |
3591 | 163 | } |
3592 | 132 | } |
3593 | 275k | } |
3594 | | |
3595 | 252k | if (p_state_enhaacplus_dec->sbr_present && total_channels > 2) { |
3596 | 43 | memcpy(time_data, intermediate_scr, |
3597 | 43 | sizeof(WORD16) * frame_size * total_channels); |
3598 | 43 | } |
3599 | | |
3600 | 252k | { |
3601 | 252k | ia_adts_crc_info_struct *ptr_adts_crc_info = |
3602 | 252k | p_state_enhaacplus_dec->ptr_bit_stream->pstr_adts_crc_info; |
3603 | 252k | if (ptr_adts_crc_info->crc_active == 1) { |
3604 | 1 | if ((error_code = ixheaacd_adts_crc_check_crc(ptr_adts_crc_info))) { |
3605 | 1 | if (error_code) { |
3606 | 1 | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3607 | 0 | p_obj_exhaacplus_dec->aac_config.frame_status = 0; |
3608 | 1 | } else { |
3609 | 1 | return error_code; |
3610 | 1 | } |
3611 | 1 | } |
3612 | 1 | } |
3613 | 1 | } |
3614 | 252k | } |
3615 | | |
3616 | 252k | p_obj_exhaacplus_dec->aac_config.ui_n_channels = total_channels; |
3617 | | |
3618 | 252k | p_state_enhaacplus_dec->frame_counter++; |
3619 | | |
3620 | 252k | WORD32 i, j; |
3621 | | |
3622 | 252k | if (channel_coupling_flag) { |
3623 | 482 | error_code = ixheaacd_dec_ind_coupling(p_obj_exhaacplus_dec, |
3624 | 482 | p_state_enhaacplus_dec->coup_ch_output, |
3625 | 482 | num_of_out_samples, total_channels, time_data); |
3626 | 482 | if (error_code) |
3627 | 25 | return error_code; |
3628 | 482 | } |
3629 | | |
3630 | 599k | for (i = 0; i < total_channels; i++) { |
3631 | 346k | if (p_obj_exhaacplus_dec->p_state_aac->qshift_adj[i + 1] == 0) |
3632 | 307k | p_obj_exhaacplus_dec->p_state_aac->qshift_adj[i + 1] = |
3633 | 307k | p_obj_exhaacplus_dec->p_state_aac->qshift_adj[0]; |
3634 | 346k | } |
3635 | | |
3636 | 252k | if (p_obj_exhaacplus_dec->aac_config.flag_to_stereo == 1 && |
3637 | 252k | total_elements == 1 && num_ch == 2 && |
3638 | 252k | p_obj_exhaacplus_dec->aac_config.dup_stereo_flag == 1) { |
3639 | 5.71k | WORD i; |
3640 | | |
3641 | 5.71k | if (!p_state_enhaacplus_dec->sbr_present && |
3642 | 5.71k | p_obj_exhaacplus_dec->p_state_aac->qshift_adj[0] != LD_OBJ) { |
3643 | 249k | for (i = 0; i < frame_size; i++) { |
3644 | 248k | *((WORD32 *)actual_out_buffer + 2 * i + 1) = |
3645 | 248k | *((WORD32 *)actual_out_buffer + 2 * i); |
3646 | 248k | } |
3647 | 5.46k | } else { |
3648 | 11.1M | for (i = 0; i < frame_size; i++) { |
3649 | 11.1M | *(actual_out_buffer + 2 * i + 1) = *(actual_out_buffer + 2 * i); |
3650 | 11.1M | } |
3651 | 5.46k | } |
3652 | 5.71k | } |
3653 | | |
3654 | 252k | if (!p_state_enhaacplus_dec->sbr_present && |
3655 | 252k | p_obj_exhaacplus_dec->p_state_aac->peak_lim_init == 1 && |
3656 | 252k | p_obj_exhaacplus_dec->p_state_aac->qshift_adj[0] != LD_OBJ) { |
3657 | 109k | if (!p_obj_exhaacplus_dec->aac_config.peak_limiter_off) { |
3658 | 109k | ixheaacd_peak_limiter_process( |
3659 | 109k | &p_state_enhaacplus_dec->peak_limiter, time_data, frame_size, |
3660 | 109k | p_obj_exhaacplus_dec->p_state_aac->qshift_adj); |
3661 | 109k | } else { |
3662 | 0 | ixheaacd_scale_adjust(time_data, frame_size, |
3663 | 0 | p_obj_exhaacplus_dec->p_state_aac->qshift_adj, |
3664 | 0 | total_channels); |
3665 | 0 | } |
3666 | | |
3667 | 188M | for (i = 0; i < frame_size * 2; i++) { |
3668 | 415M | for (j = 0; j < total_channels; j++) { |
3669 | 226M | *((WORD16 *)time_data + total_channels * i + j) = |
3670 | 226M | ixheaac_round16(*((WORD32 *)time_data + total_channels * i + j)); |
3671 | 226M | } |
3672 | 188M | } |
3673 | | |
3674 | 109k | memmove( |
3675 | 109k | time_data, |
3676 | 109k | (time_data + |
3677 | 109k | total_channels * p_obj_exhaacplus_dec->p_state_aac->delay_in_samples), |
3678 | 109k | sizeof(WORD16) * num_of_out_samples * total_channels); |
3679 | | |
3680 | 109k | p_obj_exhaacplus_dec->p_state_aac->delay_in_samples = |
3681 | 109k | p_obj_exhaacplus_dec->p_state_aac->delay_in_samples - |
3682 | 109k | MIN(p_obj_exhaacplus_dec->p_state_aac->delay_in_samples, (UWORD16)frame_size); |
3683 | 109k | } |
3684 | 252k | if (p_state_enhaacplus_dec->heaac_mps_handle.heaac_mps_present == 1) { |
3685 | 16.5k | ia_heaac_mps_state_struct *pstr_mps_state = |
3686 | 16.5k | &p_state_enhaacplus_dec->heaac_mps_handle; |
3687 | 16.5k | if (p_state_enhaacplus_dec->sbr_present == 0) { |
3688 | 16.1k | p_state_enhaacplus_dec->heaac_mps_handle.mps_decode = 1; |
3689 | 16.1k | } else { |
3690 | 337 | p_state_enhaacplus_dec->heaac_mps_handle.mps_with_sbr = 1; |
3691 | 337 | } |
3692 | 16.5k | if (!p_obj_exhaacplus_dec->aac_config.ui_enh_sbr) |
3693 | 0 | { |
3694 | 0 | p_state_enhaacplus_dec->heaac_mps_handle.mps_decode = 1; |
3695 | 0 | } |
3696 | 16.5k | if (p_state_enhaacplus_dec->heaac_mps_handle.mps_init_done == 1) { |
3697 | 16.4k | p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle.frame_ok = |
3698 | 16.4k | p_obj_exhaacplus_dec->aac_config.frame_status; |
3699 | 16.4k | p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle.ec_flag = |
3700 | 16.4k | p_obj_exhaacplus_dec->aac_config.ui_err_conceal; |
3701 | | |
3702 | 16.4k | error_code = ixheaacd_heaac_mps_apply(p_obj_exhaacplus_dec, actual_out_buffer, mps_buffer, |
3703 | 16.4k | p_state_enhaacplus_dec->ui_mps_out_bytes); |
3704 | | |
3705 | 16.4k | if (error_code != IA_NO_ERROR) { |
3706 | 827 | return error_code; |
3707 | 827 | } |
3708 | | |
3709 | 15.6k | p_state_enhaacplus_dec->heaac_mps_handle.mps_decode = 1; |
3710 | 15.6k | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = |
3711 | 15.6k | (pstr_mps_state->num_output_channels_at * |
3712 | 15.6k | pstr_mps_state->frame_length * |
3713 | 15.6k | (p_obj_exhaacplus_dec->aac_config.ui_pcm_wdsz >> 3)); |
3714 | 15.6k | p_obj_exhaacplus_dec->p_state_aac->heaac_mps_handle.first_frame = 0; |
3715 | 15.6k | } |
3716 | 16.5k | } |
3717 | 251k | if ((total_channels > 2) && (1 == p_obj_exhaacplus_dec->aac_config.downmix)) { |
3718 | 0 | ixheaacd_dec_downmix_to_stereo(p_obj_exhaacplus_dec, num_of_out_samples, |
3719 | 0 | total_elements, time_data, total_channels); |
3720 | |
|
3721 | 0 | total_channels = 2; |
3722 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = |
3723 | 0 | p_state_enhaacplus_dec->num_of_out_samples * 2 * sizeof(WORD16); |
3724 | 0 | } |
3725 | | |
3726 | 251k | if (p_obj_exhaacplus_dec->aac_config.flag_downmix && total_channels == 2) { |
3727 | 0 | WORD32 out_ch = 1; |
3728 | 0 | WORD i; |
3729 | 0 | if (p_obj_exhaacplus_dec->aac_config.flag_to_stereo == 1) { |
3730 | 0 | out_ch = 2; |
3731 | 0 | } |
3732 | |
|
3733 | 0 | p_obj_exhaacplus_dec->aac_config.ui_n_channels = out_ch; |
3734 | 0 | p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes = |
3735 | 0 | p_state_enhaacplus_dec->num_of_out_samples * out_ch * sizeof(WORD16); |
3736 | |
|
3737 | 0 | for (i = 0; i < num_of_out_samples; i++) { |
3738 | 0 | WORD16 temp; |
3739 | |
|
3740 | 0 | temp = (time_data[2 * i + 0] >> 1) + (time_data[2 * i + 1] >> 1); |
3741 | |
|
3742 | 0 | if (out_ch == 2) { |
3743 | 0 | time_data[2 * i + 0] = temp; |
3744 | 0 | time_data[2 * i + 1] = time_data[2 * i + 0]; |
3745 | 0 | } else { |
3746 | 0 | time_data[i] = temp; |
3747 | 0 | } |
3748 | 0 | } |
3749 | 0 | } |
3750 | | |
3751 | 251k | if (p_state_enhaacplus_dec->s_adts_hdr_present) { |
3752 | 38.6k | if (adts.no_raw_data_blocks != 0) { |
3753 | 2.17k | if (adts.protection_absent == 0 && it_bit_buff->cnt_bits >= 16) { |
3754 | 0 | adts.crc_check = ixheaacd_read_bits_buf(it_bit_buff, 16); |
3755 | 0 | } |
3756 | 2.17k | } |
3757 | 38.6k | p_state_enhaacplus_dec->b_n_raw_data_blk--; |
3758 | 38.6k | } |
3759 | | |
3760 | 251k | ixheaacd_updatebytesconsumed(p_state_enhaacplus_dec, it_bit_buff); |
3761 | | |
3762 | 251k | if (p_state_enhaacplus_dec->bs_format == LOAS_BSFORMAT) |
3763 | 215k | p_state_enhaacplus_dec->i_bytes_consumed = |
3764 | 215k | (WORD32)(audio_mux_length_bytes_last + bytes_for_sync); |
3765 | | |
3766 | 251k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal && |
3767 | 251k | p_obj_exhaacplus_dec->aac_config.first_frame) { |
3768 | 0 | p_obj_exhaacplus_dec->aac_config.first_frame = 0; |
3769 | 0 | } |
3770 | | |
3771 | 251k | if (p_obj_exhaacplus_dec->aac_config.ui_err_conceal) { |
3772 | 0 | if (p_obj_exhaacplus_dec->aac_config.frame_status != 1) { |
3773 | 0 | p_state_enhaacplus_dec->i_bytes_consumed = p_state_enhaacplus_dec->ui_in_bytes; |
3774 | 0 | } |
3775 | 0 | return IA_NO_ERROR; |
3776 | 251k | } else { |
3777 | 251k | return error_code; |
3778 | 251k | } |
3779 | 251k | } |