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 <stdarg.h>
23 #include <assert.h>
24
25 #include <ixheaacd_type_def.h>
26
27 #include "ixheaacd_bitbuffer.h"
28
29 #include "ixheaacd_defines.h"
30 #include "ixheaacd_memory_standards.h"
31 #include "ixheaacd_sbrdecsettings.h"
32 #include "ixheaacd_env_extr_part.h"
33 #include "ixheaacd_aac_rom.h"
34 #include "ixheaacd_common_rom.h"
35 #include <ixheaacd_sbr_rom.h>
36 #include "ixheaacd_pulsedata.h"
37 #include "ixheaacd_pns.h"
38
39 #include "ixheaacd_sbr_common.h"
40 #include "ixheaacd_drc_data_struct.h"
41 #include "ixheaacd_drc_dec.h"
42
43 #include "ixheaacd_lt_predict.h"
44
45 #include "ixheaacd_channelinfo.h"
46 #include "ixheaacd_channel.h"
47 #include "ixheaacd_channelinfo.h"
48 #include "ixheaacd_sbrdecoder.h"
49 #include "ixheaacd_audioobjtypes.h"
50 #include "ixheaacd_latmdemux.h"
51 #include "ixheaacd_aacdec.h"
52 #include "ixheaacd_sbr_common.h"
53
54 #include "ixheaacd_mps_polyphase.h"
55 #include "ixheaacd_config.h"
56 #include "ixheaacd_mps_dec.h"
57
58 #include "ixheaacd_struct_def.h"
59
60 #include "ixheaacd_config.h"
61 #include "ixheaacd_interface.h"
62 #include "ixheaacd_info.h"
63 #include "ixheaacd_struct.h"
64 #include "ixheaacd_constants.h"
65
66 #include "ixheaacd_error_codes.h"
67
ixheaacd_sbr_ratio(UWORD32 core_sbr_framelength_idx)68 UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_framelength_idx) {
69 UWORD32 sbr_ratio_index = 0x0FF;
70
71 switch (core_sbr_framelength_idx) {
72 case 0:
73 case 1:
74 sbr_ratio_index = USAC_SBR_RATIO_NO_SBR;
75 break;
76 case 2:
77 sbr_ratio_index = USAC_SBR_RATIO_INDEX_8_3;
78 break;
79 case 3:
80 sbr_ratio_index = USAC_SBR_RATIO_INDEX_2_1;
81 break;
82 case 4:
83 sbr_ratio_index = USAC_SBR_RATIO_INDEX_4_1;
84 break;
85 }
86
87 return sbr_ratio_index;
88 }
89
ixheaacd_get_sample_freq_indx(WORD32 sampling_freq)90 WORD32 ixheaacd_get_sample_freq_indx(WORD32 sampling_freq) {
91 WORD32 sampling_rate_tbl[] = {96000, 88200, 64000, 48000, 44100, 32000,
92 24000, 22050, 16000, 12000, 11025, 8000,
93 7350, 0, 0, 0};
94
95 WORD32 index;
96 WORD32 tbl_size = sizeof(sampling_rate_tbl) / sizeof(WORD32) - 1;
97
98 for (index = 0; index < tbl_size; index++) {
99 if (sampling_rate_tbl[index] == sampling_freq) break;
100 }
101
102 if (index > tbl_size) {
103 return tbl_size - 1;
104 }
105
106 return index;
107 }
ixheaacd_sbr_params(UWORD32 core_sbr_framelength_idx,WORD32 * output_framelength,WORD32 * block_size,WORD32 * output_samples,WORD32 * sample_rate_layer,UWORD32 * sample_freq_indx)108 UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_framelength_idx,
109 WORD32 *output_framelength, WORD32 *block_size,
110 WORD32 *output_samples, WORD32 *sample_rate_layer,
111 UWORD32 *sample_freq_indx) {
112 UWORD32 sbr_ratio_index = 0x0FF;
113
114 *output_framelength = -1;
115
116 switch (core_sbr_framelength_idx) {
117 case 0:
118 sbr_ratio_index = USAC_SBR_RATIO_NO_SBR;
119 *output_framelength = USAC_OUT_FRAMELENGTH_768;
120 *block_size = 768;
121 *output_samples = *block_size;
122 break;
123 case 1:
124 sbr_ratio_index = USAC_SBR_RATIO_NO_SBR;
125 *output_framelength = USAC_OUT_FRAMELENGTH_1024;
126 *block_size = 1024;
127 *output_samples = *block_size;
128 break;
129 case 2:
130 sbr_ratio_index = USAC_SBR_RATIO_INDEX_8_3;
131 *output_framelength = USAC_OUT_FRAMELENGTH_2048;
132 *block_size = 768;
133 *output_samples = (*block_size * 8) / 3;
134 *sample_rate_layer = (*sample_rate_layer * 3) >> 3;
135 break;
136 case 3:
137 sbr_ratio_index = USAC_SBR_RATIO_INDEX_2_1;
138 *output_framelength = USAC_OUT_FRAMELENGTH_2048;
139 *block_size = 1024;
140 *output_samples = *block_size * 2;
141 *sample_rate_layer = *sample_rate_layer >> 1;
142 break;
143 case 4:
144 sbr_ratio_index = USAC_SBR_RATIO_INDEX_4_1;
145 *output_framelength = USAC_OUT_FRAMELENGTH_4096;
146 *block_size = 1024;
147 *output_samples = *block_size * 4;
148 *sample_rate_layer = *sample_rate_layer >> 2;
149 break;
150 }
151
152 *sample_freq_indx = ixheaacd_get_sample_freq_indx(*sample_rate_layer);
153
154 return sbr_ratio_index;
155 }
156
ixheaacd_read_escape_value(ia_bit_buf_struct * it_bit_buff,UWORD32 * ext_ele_value,UWORD32 no_bits1,UWORD32 no_bits2,UWORD32 no_bits3)157 VOID ixheaacd_read_escape_value(ia_bit_buf_struct *it_bit_buff,
158 UWORD32 *ext_ele_value, UWORD32 no_bits1,
159 UWORD32 no_bits2, UWORD32 no_bits3) {
160 UWORD32 value = 0;
161 UWORD32 val_add = 0;
162 UWORD32 max_val1 = (1 << no_bits1) - 1;
163 UWORD32 max_val2 = (1 << no_bits2) - 1;
164
165 value = ixheaacd_read_bits_buf(it_bit_buff, no_bits1);
166
167 if (value == max_val1) {
168 val_add = ixheaacd_read_bits_buf(it_bit_buff, no_bits2);
169
170 value += val_add;
171
172 if (val_add == max_val2) {
173 val_add = ixheaacd_read_bits_buf(it_bit_buff, no_bits3);
174
175 value += val_add;
176 }
177 }
178
179 *ext_ele_value = value;
180 }
181
ixheaacd_get_usac_chan_conf(ia_usac_config_struct * pstr_usac_config,UWORD32 ch_config_index)182 static VOID ixheaacd_get_usac_chan_conf(ia_usac_config_struct *pstr_usac_config,
183 UWORD32 ch_config_index) {
184 switch (ch_config_index) {
185 case 1:
186 pstr_usac_config->num_out_channels = 1;
187 pstr_usac_config->output_channel_pos[0] = BS_OUTPUT_CHANNEL_POS_C;
188 break;
189 case 2:
190 pstr_usac_config->num_out_channels = 2;
191 pstr_usac_config->output_channel_pos[0] = BS_OUTPUT_CHANNEL_POS_L;
192 pstr_usac_config->output_channel_pos[1] = BS_OUTPUT_CHANNEL_POS_R;
193 break;
194
195 default:
196 assert(0);
197 break;
198 }
199 }
200
ixheaacd_sbr_config(ia_bit_buf_struct * it_bit_buff,ia_usac_dec_sbr_config_struct * pstr_usac_sbr_config)201 VOID ixheaacd_sbr_config(ia_bit_buf_struct *it_bit_buff,
202 ia_usac_dec_sbr_config_struct *pstr_usac_sbr_config) {
203 pstr_usac_sbr_config->harmonic_sbr = ixheaacd_read_bits_buf(it_bit_buff, 1);
204 pstr_usac_sbr_config->bs_inter_tes = ixheaacd_read_bits_buf(it_bit_buff, 1);
205 pstr_usac_sbr_config->bs_pvc = ixheaacd_read_bits_buf(it_bit_buff, 1);
206 pstr_usac_sbr_config->dflt_start_freq =
207 ixheaacd_read_bits_buf(it_bit_buff, 4);
208
209 pstr_usac_sbr_config->dflt_stop_freq = ixheaacd_read_bits_buf(it_bit_buff, 4);
210 pstr_usac_sbr_config->dflt_header_extra1 =
211 ixheaacd_read_bits_buf(it_bit_buff, 1);
212 pstr_usac_sbr_config->dflt_header_extra2 =
213 ixheaacd_read_bits_buf(it_bit_buff, 1);
214
215 if (pstr_usac_sbr_config->dflt_header_extra1) {
216 pstr_usac_sbr_config->dflt_freq_scale =
217 ixheaacd_read_bits_buf(it_bit_buff, 2);
218 pstr_usac_sbr_config->dflt_alter_scale =
219 ixheaacd_read_bits_buf(it_bit_buff, 1);
220 pstr_usac_sbr_config->dflt_noise_bands =
221 ixheaacd_read_bits_buf(it_bit_buff, 2);
222 }
223
224 if (pstr_usac_sbr_config->dflt_header_extra2) {
225 pstr_usac_sbr_config->dflt_limiter_bands =
226 ixheaacd_read_bits_buf(it_bit_buff, 2);
227 pstr_usac_sbr_config->dflt_limiter_gains =
228 ixheaacd_read_bits_buf(it_bit_buff, 2);
229 pstr_usac_sbr_config->dflt_interpol_freq =
230 ixheaacd_read_bits_buf(it_bit_buff, 1);
231 pstr_usac_sbr_config->dflt_smoothing_mode =
232 ixheaacd_read_bits_buf(it_bit_buff, 1);
233 }
234 }
235
ixheaacd_ext_element_config(ia_bit_buf_struct * it_bit_buff,ia_usac_dec_element_config_struct * pstr_usac_element_config,UWORD8 * ptr_usac_ext_ele_payload,WORD32 * ptr_usac_ext_ele_payload_len,WORD32 * preroll_flag)236 WORD32 ixheaacd_ext_element_config(
237 ia_bit_buf_struct *it_bit_buff,
238 ia_usac_dec_element_config_struct *pstr_usac_element_config,
239 UWORD8 *ptr_usac_ext_ele_payload, WORD32 *ptr_usac_ext_ele_payload_len,
240 WORD32 *preroll_flag) {
241 UWORD32 usac_ext_element_type, usac_ext_element_config_length, flag;
242
243 UWORD32 i;
244
245 ixheaacd_read_escape_value(it_bit_buff, &(usac_ext_element_type), 4, 8, 16);
246
247 ixheaacd_read_escape_value(it_bit_buff, &(usac_ext_element_config_length), 4,
248 8, 16);
249 if (usac_ext_element_config_length >= 768) return -1;
250
251 flag = ixheaacd_read_bits_buf(it_bit_buff, 1);
252
253 *ptr_usac_ext_ele_payload_len = 0;
254
255 if (flag) {
256 ixheaacd_read_escape_value(
257 it_bit_buff,
258 (UWORD32 *)(&(pstr_usac_element_config->usac_ext_eleme_def_len)), 8, 16,
259 0);
260 pstr_usac_element_config->usac_ext_eleme_def_len += 1;
261
262 } else {
263 pstr_usac_element_config->usac_ext_eleme_def_len = 0;
264 }
265
266 pstr_usac_element_config->usac_ext_elem_pld_frag =
267 ixheaacd_read_bits_buf(it_bit_buff, 1);
268
269 switch (usac_ext_element_type) {
270 case ID_EXT_ELE_FILL:
271 break;
272 case ID_EXT_ELE_AUDIOPREROLL:
273 *preroll_flag = 1;
274 break;
275 case ID_EXT_ELE_UNI_DRC:
276 for (i = 0; i < usac_ext_element_config_length; i++) {
277 ptr_usac_ext_ele_payload[i] = ixheaacd_read_bits_buf(it_bit_buff, 8);
278 }
279 *ptr_usac_ext_ele_payload_len = usac_ext_element_config_length;
280 break;
281
282 default:
283 if ((it_bit_buff->cnt_bits >> 3) < (WORD32)usac_ext_element_config_length)
284 return -1;
285 it_bit_buff->ptr_read_next += usac_ext_element_config_length;
286 it_bit_buff->cnt_bits -= (usac_ext_element_config_length << 3);
287
288 break;
289 }
290
291 return 0;
292 }
293
ixheaacd_mps212_config(ia_bit_buf_struct * it_bit_buff,ia_usac_dec_mps_config_struct * pstr_usac_mps212_config,WORD32 stereo_config_index)294 VOID ixheaacd_mps212_config(
295 ia_bit_buf_struct *it_bit_buff,
296 ia_usac_dec_mps_config_struct *pstr_usac_mps212_config,
297 WORD32 stereo_config_index) {
298 pstr_usac_mps212_config->bs_freq_res = ixheaacd_read_bits_buf(it_bit_buff, 3);
299
300 pstr_usac_mps212_config->bs_fixed_gain_dmx =
301 ixheaacd_read_bits_buf(it_bit_buff, 3);
302
303 pstr_usac_mps212_config->bs_temp_shape_config =
304 ixheaacd_read_bits_buf(it_bit_buff, 2);
305
306 pstr_usac_mps212_config->bs_decorr_config =
307 ixheaacd_read_bits_buf(it_bit_buff, 2);
308
309 pstr_usac_mps212_config->bs_high_rate_mode =
310 ixheaacd_read_bits_buf(it_bit_buff, 1);
311
312 pstr_usac_mps212_config->bs_phase_coding =
313 ixheaacd_read_bits_buf(it_bit_buff, 1);
314
315 pstr_usac_mps212_config->bs_ott_bands_phase_present =
316 ixheaacd_read_bits_buf(it_bit_buff, 1);
317
318 if (pstr_usac_mps212_config->bs_ott_bands_phase_present) {
319 pstr_usac_mps212_config->bs_ott_bands_phase =
320 ixheaacd_read_bits_buf(it_bit_buff, 5);
321 }
322
323 if (stereo_config_index > 1) {
324 pstr_usac_mps212_config->bs_residual_bands =
325 ixheaacd_read_bits_buf(it_bit_buff, 5);
326
327 pstr_usac_mps212_config->bs_ott_bands_phase =
328 max(pstr_usac_mps212_config->bs_ott_bands_phase,
329 pstr_usac_mps212_config->bs_residual_bands);
330
331 pstr_usac_mps212_config->bs_pseudo_lr =
332 ixheaacd_read_bits_buf(it_bit_buff, 1);
333 }
334
335 if (pstr_usac_mps212_config->bs_temp_shape_config == 2)
336 pstr_usac_mps212_config->bs_env_quant_mode =
337 ixheaacd_read_bits_buf(it_bit_buff, 1);
338 }
339
ixheaacd_cpe_config(ia_bit_buf_struct * it_bit_buff,ia_usac_dec_element_config_struct * pstr_usac_element_config,WORD32 sbr_ratio_index)340 VOID ixheaacd_cpe_config(
341 ia_bit_buf_struct *it_bit_buff,
342 ia_usac_dec_element_config_struct *pstr_usac_element_config,
343 WORD32 sbr_ratio_index) {
344 pstr_usac_element_config->tw_mdct = ixheaacd_read_bits_buf(it_bit_buff, 1);
345 pstr_usac_element_config->noise_filling =
346 ixheaacd_read_bits_buf(it_bit_buff, 1);
347
348 if (sbr_ratio_index > 0) {
349 ixheaacd_sbr_config(it_bit_buff,
350 &(pstr_usac_element_config->str_usac_sbr_config));
351 pstr_usac_element_config->stereo_config_index =
352 ixheaacd_read_bits_buf(it_bit_buff, 2);
353
354 } else {
355 pstr_usac_element_config->stereo_config_index = 0;
356 }
357
358 if (pstr_usac_element_config->stereo_config_index > 0)
359 ixheaacd_mps212_config(it_bit_buff,
360 &(pstr_usac_element_config->str_usac_mps212_config),
361 pstr_usac_element_config->stereo_config_index);
362 }
363
ixheaacd_decoder_config(ia_bit_buf_struct * it_bit_buff,ia_usac_decoder_config_struct * pstr_usac_decoder_config,WORD32 sbr_ratio_index,UINT32 * chan)364 WORD32 ixheaacd_decoder_config(
365 ia_bit_buf_struct *it_bit_buff,
366 ia_usac_decoder_config_struct *pstr_usac_decoder_config,
367 WORD32 sbr_ratio_index, UINT32 *chan) {
368 UWORD32 elem_idx = 0;
369 UWORD32 err = 0;
370
371 ixheaacd_read_escape_value(
372 it_bit_buff, &(pstr_usac_decoder_config->num_elements), 4, 8, 16);
373 pstr_usac_decoder_config->num_elements += 1;
374 pstr_usac_decoder_config->preroll_flag = 0;
375
376 if (pstr_usac_decoder_config->num_elements > USAC_MAX_ELEMENTS) {
377 return -1;
378 }
379
380 for (elem_idx = 0; elem_idx < pstr_usac_decoder_config->num_elements;
381 elem_idx++) {
382 ia_usac_dec_element_config_struct *pstr_usac_element_config =
383 &(pstr_usac_decoder_config->str_usac_element_config[elem_idx]);
384
385 pstr_usac_decoder_config->usac_element_type[elem_idx] =
386 ixheaacd_read_bits_buf(it_bit_buff, 2);
387
388 switch (pstr_usac_decoder_config->usac_element_type[elem_idx]) {
389 case ID_USAC_SCE:
390
391 pstr_usac_element_config->tw_mdct =
392 ixheaacd_read_bits_buf(it_bit_buff, 1);
393 pstr_usac_element_config->noise_filling =
394 ixheaacd_read_bits_buf(it_bit_buff, 1);
395
396 if (sbr_ratio_index > 0)
397 ixheaacd_sbr_config(it_bit_buff,
398 &(pstr_usac_element_config->str_usac_sbr_config));
399
400 break;
401
402 case ID_USAC_CPE:
403 ixheaacd_cpe_config(it_bit_buff, pstr_usac_element_config,
404 sbr_ratio_index);
405 if (pstr_usac_element_config->stereo_config_index > 1 && *chan < 2)
406 return -1;
407
408 break;
409
410 case ID_USAC_LFE:
411
412 pstr_usac_element_config->tw_mdct = 0;
413 pstr_usac_element_config->noise_filling = 0;
414 break;
415
416 case ID_USAC_EXT:
417 err = ixheaacd_ext_element_config(
418 it_bit_buff, pstr_usac_element_config,
419 &pstr_usac_decoder_config->usac_ext_ele_payload_buf[elem_idx][0],
420 &pstr_usac_decoder_config->usac_ext_ele_payload_len[elem_idx],
421 &(pstr_usac_decoder_config->preroll_flag));
422
423 if (pstr_usac_decoder_config->usac_ext_ele_payload_len[elem_idx] > 0) {
424 pstr_usac_decoder_config->usac_ext_ele_payload_present[elem_idx] = 1;
425 } else {
426 pstr_usac_decoder_config->usac_ext_ele_payload_present[elem_idx] = 0;
427 }
428 if (err != 0) return -1;
429 break;
430 default:
431 return -1;
432 break;
433 }
434 }
435 return err;
436 }
437
ixheaacd_config_extension(ia_bit_buf_struct * it_bit_buff,ia_usac_decoder_config_struct * pstr_usac_decoder_config)438 WORD32 ixheaacd_config_extension(
439 ia_bit_buf_struct *it_bit_buff,
440 ia_usac_decoder_config_struct *pstr_usac_decoder_config) {
441 UWORD32 i, j;
442 UWORD32 num_config_extensions;
443 UWORD32 usac_config_ext_type, usac_config_ext_len;
444
445 ixheaacd_read_escape_value(it_bit_buff, &(num_config_extensions), 2, 4, 8);
446 num_config_extensions += 1;
447 if (USAC_MAX_CONFIG_EXTENSIONS < num_config_extensions) {
448 return -1;
449 }
450
451 pstr_usac_decoder_config->num_config_extensions = num_config_extensions;
452 memset(pstr_usac_decoder_config->usac_cfg_ext_info_len, 0,
453 USAC_MAX_CONFIG_EXTENSIONS * sizeof(WORD32));
454 memset(pstr_usac_decoder_config->usac_cfg_ext_info_present, 0,
455 USAC_MAX_CONFIG_EXTENSIONS * sizeof(WORD32));
456
457 for (j = 0; j < num_config_extensions; j++) {
458 UWORD32 tmp;
459 UWORD32 fill_byte_val = 0xa5;
460
461 ixheaacd_read_escape_value(it_bit_buff, &(usac_config_ext_type), 4, 8, 16);
462 ixheaacd_read_escape_value(it_bit_buff, &(usac_config_ext_len), 4, 8, 16);
463
464 switch (usac_config_ext_type) {
465 case ID_CONFIG_EXT_FILL:
466 for (i = 0; i < usac_config_ext_len; i++) {
467 fill_byte_val = ixheaacd_read_bits_buf(it_bit_buff, 8);
468 if (fill_byte_val != 0xa5) return -1;
469 }
470 break;
471 default:
472 if ((WORD32)usac_config_ext_len > (it_bit_buff->cnt_bits >> 3)) {
473 return -1;
474 }
475 if (ID_CONFIG_EXT_LOUDNESS_INFO == usac_config_ext_type) {
476 for (i = 0; i < usac_config_ext_len; i++) {
477 UWORD8 byte_val = ixheaacd_read_bits_buf(it_bit_buff, 8);
478 pstr_usac_decoder_config->usac_cfg_ext_info_buf[j][i] = byte_val;
479 }
480 pstr_usac_decoder_config->usac_cfg_ext_info_len[j] =
481 usac_config_ext_len;
482 pstr_usac_decoder_config->usac_cfg_ext_info_present[j] = 1;
483 } else {
484 for (i = 0; i < usac_config_ext_len; i++)
485 tmp = ixheaacd_read_bits_buf(it_bit_buff, 8);
486 }
487 break;
488 }
489 }
490
491 return 0;
492 }
493
ixheaacd_config(ia_bit_buf_struct * it_bit_buff,ia_usac_config_struct * pstr_usac_conf,UINT32 * chan)494 WORD32 ixheaacd_config(ia_bit_buf_struct *it_bit_buff,
495 ia_usac_config_struct *pstr_usac_conf, UINT32 *chan) {
496 WORD32 tmp, err;
497 err = 0;
498
499 pstr_usac_conf->usac_sampling_frequency_index =
500 ixheaacd_read_bits_buf(it_bit_buff, 5);
501
502 if (pstr_usac_conf->usac_sampling_frequency_index == 0x1f)
503 pstr_usac_conf->usac_sampling_frequency =
504 ixheaacd_read_bits_buf(it_bit_buff, 24);
505
506 pstr_usac_conf->core_sbr_framelength_index =
507 ixheaacd_read_bits_buf(it_bit_buff, 3);
508
509 if (pstr_usac_conf->core_sbr_framelength_index > 4) return -1;
510
511 pstr_usac_conf->channel_configuration_index =
512 ixheaacd_read_bits_buf(it_bit_buff, 5);
513 if (pstr_usac_conf->channel_configuration_index >= 3) return -1;
514
515 if (pstr_usac_conf->channel_configuration_index == 0) {
516 UWORD32 i;
517
518 ixheaacd_read_escape_value(it_bit_buff,
519 (UWORD32 *)(&(pstr_usac_conf->num_out_channels)),
520 5, 8, 16);
521 if (BS_MAX_NUM_OUT_CHANNELS < pstr_usac_conf->num_out_channels) {
522 return IA_ENHAACPLUS_DEC_INIT_FATAL_STREAM_CHAN_GT_MAX;
523 }
524 for (i = 0; i < pstr_usac_conf->num_out_channels; i++)
525 pstr_usac_conf->output_channel_pos[i] =
526 ixheaacd_read_bits_buf(it_bit_buff, 5);
527
528 } else {
529 ixheaacd_get_usac_chan_conf(pstr_usac_conf,
530 pstr_usac_conf->channel_configuration_index);
531 }
532
533 err = ixheaacd_decoder_config(
534 it_bit_buff, &(pstr_usac_conf->str_usac_dec_config),
535 ixheaacd_sbr_ratio(pstr_usac_conf->core_sbr_framelength_index), chan);
536 if (err != 0) return -1;
537
538 tmp = ixheaacd_read_bits_buf(it_bit_buff, 1);
539
540 if (tmp) {
541 err = ixheaacd_config_extension(it_bit_buff,
542 &pstr_usac_conf->str_usac_dec_config);
543 if (err != 0) return -1;
544 }
545
546 return err;
547 }
548
ixheaacd_conf_default(ia_usac_config_struct * pstr_usac_conf)549 VOID ixheaacd_conf_default(ia_usac_config_struct *pstr_usac_conf) {
550 WORD32 i;
551
552 pstr_usac_conf->num_out_channels = 0;
553
554 for (i = 0; i < BS_MAX_NUM_OUT_CHANNELS; i++)
555 pstr_usac_conf->output_channel_pos[i] = BS_OUTPUT_CHANNEL_POS_NA;
556
557 pstr_usac_conf->str_usac_dec_config.num_elements = 0;
558
559 for (i = 0; i < USAC_MAX_ELEMENTS; i++)
560 pstr_usac_conf->str_usac_dec_config.usac_element_type[i] = ID_USAC_INVALID;
561
562 return;
563 }
564