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 "ixheaacd_sbr_common.h" 22 #include <ixheaacd_type_def.h> 23 24 #include "ixheaacd_constants.h" 25 #include <ixheaacd_basic_ops32.h> 26 #include <ixheaacd_basic_ops16.h> 27 #include <ixheaacd_basic_ops40.h> 28 #include "ixheaacd_basic_ops.h" 29 30 #include "ixheaacd_bitbuffer.h" 31 #include "ixheaacd_error_codes.h" 32 #include "ixheaacd_defines.h" 33 #include <ixheaacd_aac_rom.h> 34 #include "ixheaacd_pulsedata.h" 35 36 #include "ixheaacd_pns.h" 37 #include "ixheaacd_drc_data_struct.h" 38 39 #include "ixheaacd_lt_predict.h" 40 41 #include "ixheaacd_channelinfo.h" 42 #include "ixheaacd_cnst.h" 43 #include "ixheaacd_drc_dec.h" 44 #include "ixheaacd_sbrdecoder.h" 45 46 #include "ixheaacd_block.h" 47 #include "ixheaacd_channel.h" 48 49 #include "ixheaacd_common_rom.h" 50 #include "ixheaacd_basic_funcs.h" 51 #include <ixheaacd_basic_op.h> 52 #include "ixheaacd_intrinsics.h" 53 #include "ixheaacd_stereo.h" 54 55 #include "ixheaacd_tns.h" 56 57 #include "ixheaacd_audioobjtypes.h" 58 #include "ixheaacd_latmdemux.h" 59 60 #include "ixheaacd_aacdec.h" 61 #include "ixheaacd_definitions.h" 62 63 #include "ixheaacd_error_codes.h" 64 65 #include "ixheaacd_pulsedata.h" 66 67 #include "ixheaacd_sbrdecsettings.h" 68 #include "ixheaacd_sbr_scale.h" 69 #include "ixheaacd_env_extr_part.h" 70 #include <ixheaacd_sbr_rom.h> 71 #include "ixheaacd_audioobjtypes.h" 72 #include "ixheaacd_sbrdecoder.h" 73 #include "ixheaacd_memory_standards.h" 74 #include "ixheaacd_mps_polyphase.h" 75 #include "ixheaacd_config.h" 76 #include "ixheaacd_mps_dec.h" 77 #include "ixheaacd_struct_def.h" 78 #include "ixheaacd_adts_crc_check.h" 79 #include "ixheaacd_rvlc.h" 80 #include "ixheaacd_hcr.h" 81 #include "ixheaacd_function_selector.h" 82 83 #define SPEC(ptr, w, gl) ((ptr) + ((w) * (gl))) 84 85 #define _SWAP(a, b) \ 86 (b = (((WORD32)a[0] << 24) | ((WORD32)a[1] << 16) | ((WORD32)a[2] << 8) | \ 87 ((WORD32)a[3]))) 88 89 UWORD32 ixheaacd_aac_showbits_32(UWORD8 *ptr_read_next) { 90 UWORD8 *v = ptr_read_next; 91 UWORD32 b = 0; 92 93 _SWAP(v, b); 94 return b; 95 } 96 97 WORD16 *ixheaacd_getscalefactorbandoffsets( 98 ia_ics_info_struct *ptr_ics_info, 99 ia_aac_dec_tables_struct *ptr_aac_tables) { 100 if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { 101 return ptr_aac_tables->sfb_long_table; 102 } else { 103 return ptr_aac_tables->sfb_short_table; 104 } 105 } 106 107 WORD8 *ixheaacd_getscalefactorbandwidth( 108 ia_ics_info_struct *ptr_ics_info, 109 ia_aac_dec_tables_struct *ptr_aac_tables) { 110 if (ptr_ics_info->frame_length == 512) { 111 return ( 112 WORD8 *)(&ptr_aac_tables 113 ->scale_fac_bands_512[ptr_ics_info->sampling_rate_index] 114 [0]); 115 } else { 116 return ( 117 WORD8 *)(&ptr_aac_tables 118 ->scale_fac_bands_480[ptr_ics_info->sampling_rate_index] 119 [0]); 120 } 121 } 122 123 WORD32 ixheaacd_cblock_inv_quant_spect_data( 124 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, 125 ia_aac_dec_tables_struct *ptr_aac_tables); 126 127 void ixheaacd_cblock_scale_spect_data( 128 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, 129 ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, 130 WORD32 object_type, WORD32 aac_sf_data_resil_flag) { 131 int grp_win, group = 0; 132 WORD32 *ptr_spect_coeff = ptr_aac_dec_channel_info->ptr_spec_coeff; 133 WORD8 *ptr_sfb_width = (WORD8 *)(ixheaacd_getscalefactorbandwidth( 134 &(ptr_aac_dec_channel_info->str_ics_info), ptr_aac_tables)); 135 int max_band; 136 WORD16 *ptr_scale_fac = ptr_aac_dec_channel_info->ptr_scale_factor; 137 WORD tot_bands = ptr_aac_dec_channel_info->str_ics_info.max_sfb; 138 WORD tot_groups = ptr_aac_dec_channel_info->str_ics_info.num_window_groups; 139 WORD32 *scale_table_ptr = ptr_aac_tables->pstr_block_tables->scale_table; 140 141 max_band = ptr_aac_dec_channel_info->str_ics_info.max_sfb; 142 143 do { 144 grp_win = 145 ptr_aac_dec_channel_info->str_ics_info.window_group_length[group++]; 146 do { 147 (*ixheaacd_scale_factor_process)(&ptr_spect_coeff[0], &ptr_scale_fac[0], 148 tot_bands, (WORD8 *)ptr_sfb_width, 149 scale_table_ptr, total_channels, 150 object_type, aac_sf_data_resil_flag); 151 ptr_spect_coeff += 128; 152 grp_win--; 153 } while (grp_win != 0); 154 155 ptr_scale_fac += 16; 156 tot_groups--; 157 } while (tot_groups != 0); 158 } 159 160 WORD32 ixheaacd_read_pulse_data(ia_bit_buf_struct *it_bit_buff, 161 ia_pulse_info_struct *ptr_pulse_info, 162 ia_aac_dec_tables_struct *ptr_aac_tables) { 163 WORD32 i, total_offset; 164 WORD32 error_code = 0; 165 166 WORD32 value = ixheaacd_read_bits_buf(it_bit_buff, 8); 167 ptr_pulse_info->number_pulse = value >> 6; 168 ptr_pulse_info->pulse_start_band = value & 0x3F; 169 170 if (ptr_pulse_info->pulse_start_band >= 52) { 171 return (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_PULSEDATA_ERROR; 172 } 173 174 total_offset = ptr_aac_tables->str_aac_sfb_info[0] 175 .sfb_index[ptr_pulse_info->pulse_start_band]; 176 177 for (i = 0; i < ptr_pulse_info->number_pulse + 1; i++) { 178 WORD32 value = ixheaacd_read_bits_buf(it_bit_buff, 9); 179 ptr_pulse_info->pulse_offset[i] = value >> 4; 180 ptr_pulse_info->pulse_amp[i] = value & 0xF; 181 total_offset += ptr_pulse_info->pulse_offset[i]; 182 183 if (total_offset >= 1024) { 184 error_code = (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_PULSEDATA_ERROR; 185 } 186 } 187 188 return error_code; 189 } 190 191 static WORD16 ixheaacd_read_block_data( 192 ia_bit_buf_struct *it_bit_buff, 193 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, 194 ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, 195 WORD32 frame_size, WORD32 object_type, WORD32 aac_spect_data_resil_flag, 196 WORD32 aac_sect_data_resil_flag, WORD32 aac_sf_data_resil_flag, 197 WORD32 ele_type, ia_aac_dec_overlap_info *ptr_aac_dec_static_channel_info) 198 199 { 200 FLAG gain_control_data_present; 201 WORD16 error_code = AAC_DEC_OK; 202 203 if (ptr_aac_dec_channel_info->str_ics_info.window_sequence == 204 EIGHT_SHORT_SEQUENCE) { 205 memset(ptr_aac_dec_channel_info->ptr_scale_factor, 0, 206 MAX_WINDOWS * MAX_SCALE_FACTOR_BANDS_SHORT * 3); 207 } 208 209 error_code = ixheaacd_read_section_data( 210 it_bit_buff, ptr_aac_dec_channel_info, aac_spect_data_resil_flag, 211 aac_sect_data_resil_flag, ptr_aac_tables); 212 213 if (error_code) { 214 return error_code; 215 } 216 if (aac_sf_data_resil_flag && 217 ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD))) 218 ixheaacd_rvlc_read(it_bit_buff, ptr_aac_dec_channel_info); 219 else 220 ixheaacd_read_scale_factor_data(it_bit_buff, ptr_aac_dec_channel_info, 221 ptr_aac_tables, object_type); 222 223 error_code = 0; 224 if (object_type != AOT_ER_AAC_ELD) { 225 ptr_aac_dec_channel_info->str_pulse_info.pulse_data_present = 226 ixheaacd_read_bits_buf(it_bit_buff, 1); 227 if (ptr_aac_dec_channel_info->str_pulse_info.pulse_data_present) { 228 error_code = ixheaacd_read_pulse_data( 229 it_bit_buff, &ptr_aac_dec_channel_info->str_pulse_info, 230 ptr_aac_tables); 231 } 232 233 if (error_code) { 234 return error_code; 235 } 236 } 237 238 ptr_aac_dec_channel_info->str_tns_info.tns_data_present = 239 (FLAG)ixheaacd_read_bits_buf(it_bit_buff, 1); 240 241 if (object_type < ER_OBJECT_START) { 242 error_code = 0; 243 if (ptr_aac_dec_channel_info->str_tns_info.tns_data_present) { 244 error_code = 245 ixheaacd_read_tns_data(it_bit_buff, ptr_aac_dec_channel_info); 246 } 247 248 if (error_code) { 249 return error_code; 250 } 251 } 252 253 if (object_type != AOT_ER_AAC_ELD) { 254 gain_control_data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); 255 256 if (gain_control_data_present) { 257 return (WORD16)( 258 (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_GAIN_CONTROL_DATA_PRESENT); 259 } 260 } 261 262 if (object_type == AOT_ER_AAC_ELD) { 263 if (ptr_aac_dec_channel_info->str_tns_info.tns_data_present) 264 error_code = 265 ixheaacd_read_tns_data(it_bit_buff, ptr_aac_dec_channel_info); 266 } 267 268 if (aac_spect_data_resil_flag && 269 ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD))) 270 ixheaacd_hcr_read(it_bit_buff, ptr_aac_dec_channel_info, ele_type); 271 272 if (aac_sf_data_resil_flag && 273 ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD))) { 274 ixheaacd_rvlc_dec(ptr_aac_dec_channel_info, ptr_aac_dec_static_channel_info, 275 it_bit_buff); 276 277 it_bit_buff->bit_pos = 7 - it_bit_buff->bit_pos; 278 } 279 280 if (object_type == AOT_ER_AAC_LD) { 281 if (ptr_aac_dec_channel_info->str_tns_info.tns_data_present) 282 error_code = 283 ixheaacd_read_tns_data(it_bit_buff, ptr_aac_dec_channel_info); 284 } 285 286 { it_bit_buff->bit_pos = 7 - it_bit_buff->bit_pos; } 287 288 error_code |= ixheaacd_read_spectral_data( 289 it_bit_buff, ptr_aac_dec_channel_info, ptr_aac_tables, total_channels, 290 frame_size, object_type, aac_spect_data_resil_flag, 291 aac_sf_data_resil_flag); 292 293 it_bit_buff->bit_pos = (7 - it_bit_buff->bit_pos); 294 295 return error_code; 296 } 297 298 WORD16 ixheaacd_ltp_decode(ia_bit_buf_struct *it_bit_buff, 299 ia_ics_info_struct *ptr_ics_info, WORD32 object_type, 300 WORD32 frame_size, WORD32 ch) { 301 WORD32 retval = AAC_DEC_OK; 302 303 if (ptr_ics_info->predictor_data_present) { 304 if (ch == 0) { 305 ixheaacd_init_ltp_object(&(ptr_ics_info->ltp)); 306 ptr_ics_info->ltp.data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); 307 if (ptr_ics_info->ltp.data_present) { 308 if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, 309 &(ptr_ics_info->ltp), it_bit_buff, 310 frame_size)) > 0) { 311 return retval; 312 } 313 } 314 } else { 315 ixheaacd_init_ltp_object(&(ptr_ics_info->ltp2)); 316 ptr_ics_info->ltp2.data_present = ixheaacd_read_bits_buf(it_bit_buff, 1); 317 if (ptr_ics_info->ltp2.data_present) { 318 if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, 319 &(ptr_ics_info->ltp2), it_bit_buff, 320 frame_size)) > 0) { 321 return retval; 322 } 323 } 324 } 325 } 326 return retval; 327 } 328 WORD16 ixheaacd_ics_read(ia_bit_buf_struct *it_bit_buff, 329 ia_ics_info_struct *ptr_ics_info, 330 WORD8 num_swb_window[2], WORD32 object_type, 331 WORD32 common_window, WORD32 frame_size) { 332 WORD i; 333 WORD mask; 334 WORD value = 0; 335 336 if (object_type == AOT_ER_AAC_ELD) { 337 ptr_ics_info->window_sequence = 0; 338 ptr_ics_info->window_shape = 1; 339 } else { 340 if (object_type != AOT_ER_AAC_LD) { 341 ptr_ics_info->frame_length = 1024; 342 } 343 value = ixheaacd_read_bits_buf(it_bit_buff, 4); 344 ptr_ics_info->window_sequence = (WORD16)((value & 0x6) >> 1); 345 ptr_ics_info->window_shape = (WORD16)((value & 0x1)); 346 } 347 348 if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { 349 ptr_ics_info->num_swb_window = num_swb_window[0]; 350 351 ptr_ics_info->num_window_groups = 1; 352 ptr_ics_info->window_group_length[0] = 1; 353 354 if (object_type == AOT_ER_AAC_ELD) { 355 ptr_ics_info->max_sfb = ixheaacd_read_bits_buf(it_bit_buff, 6); 356 if (ptr_ics_info->max_sfb == 0) ptr_ics_info->num_swb_window = 0; 357 } else { 358 value = ixheaacd_read_bits_buf(it_bit_buff, 7); 359 ptr_ics_info->max_sfb = (value & 0x7E) >> 1; 360 } 361 362 if ((object_type != AOT_ER_AAC_LD) && (object_type != AOT_AAC_LTP)) { 363 if (value & 1) { 364 return (WORD16)( 365 (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_PREDICTION_DATA_PRESENT); 366 } 367 368 } else { 369 ptr_ics_info->predictor_data_present = value & 1; 370 371 if (ptr_ics_info->predictor_data_present) { 372 WORD32 retval = AAC_DEC_OK; 373 374 ixheaacd_init_ltp_object(&(ptr_ics_info->ltp)); 375 if (object_type < ER_OBJECT_START) { 376 if ((ptr_ics_info->ltp.data_present = 377 ixheaacd_read_bits_buf(it_bit_buff, 1)) & 378 1) { 379 if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, 380 &(ptr_ics_info->ltp), it_bit_buff, 381 frame_size)) > 0) { 382 return retval; 383 } 384 } 385 if (common_window) { 386 ixheaacd_init_ltp_object(&(ptr_ics_info->ltp2)); 387 if ((ptr_ics_info->ltp2.data_present = 388 ixheaacd_read_bits_buf(it_bit_buff, 1)) & 389 1) { 390 if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, 391 &(ptr_ics_info->ltp2), 392 it_bit_buff, frame_size)) > 0) { 393 return retval; 394 } 395 } 396 } 397 } 398 if ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD)) { 399 if (!common_window && (object_type >= ER_OBJECT_START)) { 400 if ((ptr_ics_info->ltp.data_present = 401 ixheaacd_read_bits_buf(it_bit_buff, 1)) & 402 1) { 403 if ((retval = ixheaacd_ltp_data(object_type, ptr_ics_info, 404 &(ptr_ics_info->ltp), it_bit_buff, 405 frame_size)) < 0) { 406 return retval; 407 } 408 } 409 } 410 } 411 } 412 } 413 414 } else { 415 WORD32 num_groups = 0, scale_factor_grouping; 416 ptr_ics_info->num_swb_window = num_swb_window[1]; 417 418 value = ixheaacd_read_bits_buf(it_bit_buff, 11); 419 ptr_ics_info->max_sfb = (value & 0x780) >> 7; 420 421 scale_factor_grouping = (value & 0x7F); 422 423 mask = 0x40; 424 for (i = 0; i < 7; i++) { 425 ptr_ics_info->window_group_length[i] = 1; 426 427 if (scale_factor_grouping & mask) { 428 ptr_ics_info->window_group_length[num_groups] = 429 ptr_ics_info->window_group_length[num_groups] + 1; 430 431 } else { 432 num_groups = num_groups + 1; 433 } 434 435 mask = mask >> 1; 436 } 437 438 ptr_ics_info->window_group_length[7] = 1; 439 ptr_ics_info->num_window_groups = num_groups + 1; 440 } 441 442 if (ptr_ics_info->max_sfb > ptr_ics_info->num_swb_window) { 443 return (WORD16)IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_SFB_TRANSMITTED; 444 } 445 446 return AAC_DEC_OK; 447 } 448 449 WORD16 ixheaacd_individual_ch_stream( 450 ia_bit_buf_struct *it_bit_buff, ia_aac_decoder_struct *aac_dec_handle, 451 WORD32 num_ch, WORD32 frame_size, WORD32 total_channels, WORD32 object_type, 452 ia_eld_specific_config_struct eld_specific_config, WORD32 ele_type) { 453 WORD16 error_code = AAC_DEC_OK; 454 WORD32 ch; 455 WORD32 crc_reg = 0; 456 457 for (ch = 0; ch < num_ch; ch++) { 458 ia_aac_dec_channel_info_struct *ptr_aac_dec_ch_info = 459 aac_dec_handle->pstr_aac_dec_ch_info[ch]; 460 ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_ch_info->str_ics_info; 461 462 if (ch == 1) { 463 if (it_bit_buff->pstr_adts_crc_info->crc_active == 1) { 464 crc_reg = 465 ixheaacd_adts_crc_start_reg(it_bit_buff->pstr_adts_crc_info, 466 it_bit_buff, CRC_ADTS_RAW_IIND_ICS); 467 } 468 } 469 ptr_aac_dec_ch_info->global_gain = 470 (WORD16)ixheaacd_read_bits_buf(it_bit_buff, 8); 471 472 if (!(aac_dec_handle->pstr_aac_dec_ch_info[LEFT]->common_window)) { 473 error_code = ixheaacd_ics_read( 474 it_bit_buff, ptr_ics_info, aac_dec_handle->num_swb_window, 475 object_type, 476 aac_dec_handle->pstr_aac_dec_ch_info[LEFT]->common_window, 477 aac_dec_handle->samples_per_frame); 478 if (ch == 1) 479 aac_dec_handle->pstr_aac_dec_ch_info[ch - 1]->str_ics_info.ltp2.lag = 480 ptr_ics_info->ltp.lag; 481 482 if (error_code) { 483 if (it_bit_buff->cnt_bits < 0) { 484 error_code = (WORD16)( 485 (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); 486 } 487 return error_code; 488 } 489 } 490 491 error_code = ixheaacd_read_block_data( 492 it_bit_buff, ptr_aac_dec_ch_info, aac_dec_handle->pstr_aac_tables, 493 total_channels, frame_size, object_type, 494 eld_specific_config.aac_spect_data_resil_flag, 495 eld_specific_config.aac_sect_data_resil_flag, 496 eld_specific_config.aac_sf_data_resil_flag, ele_type, 497 aac_dec_handle->pstr_aac_dec_overlap_info[ch]); 498 if (error_code) { 499 if (it_bit_buff->cnt_bits < 0) { 500 error_code = (WORD16)( 501 (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); 502 } 503 504 return error_code; 505 } 506 507 if (ch == 0) { 508 if ((object_type == AOT_ER_AAC_LD) && 509 (aac_dec_handle->pstr_aac_dec_ch_info[LEFT]->common_window) && 510 (ele_type == ID_CPE)) { 511 WORD16 temp = 512 ixheaacd_ltp_decode(it_bit_buff, ptr_ics_info, object_type, 513 aac_dec_handle->samples_per_frame, 1); 514 515 if (temp != 0) { 516 return temp; 517 } 518 aac_dec_handle->pstr_aac_dec_ch_info[ch + 1]->str_ics_info.ltp.lag = 519 ptr_ics_info->ltp2.lag; 520 } 521 } 522 if (ch == 1) { 523 if (it_bit_buff->pstr_adts_crc_info->crc_active == 1) { 524 ixheaacd_adts_crc_end_reg(it_bit_buff->pstr_adts_crc_info, it_bit_buff, 525 crc_reg); 526 } 527 } 528 } 529 530 return error_code; 531 } 532 533 VOID ixheaacd_read_ms_data( 534 ia_bit_buf_struct *it_bit_buff, 535 ia_aac_dec_channel_info_struct *ptr_aac_dec_ch_info) { 536 WORD32 num_win_group, sfb; 537 WORD32 ms_mask_present; 538 UWORD8 *ptr_ms_used = &ptr_aac_dec_ch_info->pstr_stereo_info->ms_used[0][0]; 539 WORD32 num_window_groups = 540 ptr_aac_dec_ch_info->str_ics_info.num_window_groups; 541 WORD16 max_sfb = ptr_aac_dec_ch_info->str_ics_info.max_sfb; 542 543 ms_mask_present = ixheaacd_read_bits_buf(it_bit_buff, 2); 544 545 if (ms_mask_present < 1) { 546 memset(ptr_ms_used, 0, 547 sizeof(UWORD8) * JOINT_STEREO_MAX_BANDS * JOINT_STEREO_MAX_GROUPS); 548 } 549 550 else if (ms_mask_present == 1) { 551 for (num_win_group = 0; num_win_group < num_window_groups; 552 num_win_group++) { 553 for (sfb = 0; sfb < max_sfb; sfb++) { 554 ptr_aac_dec_ch_info->pstr_stereo_info->ms_used[num_win_group][sfb] = 555 (UWORD8)ixheaacd_read_bits_buf(it_bit_buff, 1); 556 } 557 } 558 559 } else { 560 for (num_win_group = 0; num_win_group < num_window_groups; 561 num_win_group++) { 562 ptr_ms_used = 563 &ptr_aac_dec_ch_info->pstr_stereo_info->ms_used[num_win_group][0]; 564 memset(ptr_ms_used, 1, (max_sfb) * sizeof(UWORD8)); 565 } 566 } 567 } 568 569 VOID ixheaacd_channel_pair_process( 570 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[], WORD32 num_ch, 571 ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, 572 WORD32 object_type, WORD32 aac_spect_data_resil_flag, 573 WORD32 aac_sf_data_resil_flag, WORD32 *in_data, WORD32 *out_data, 574 void *self_ptr) { 575 WORD32 channel; 576 ia_aac_decoder_struct *self = self_ptr; 577 if (aac_spect_data_resil_flag) { 578 for (channel = 0; channel < num_ch; channel++) { 579 ixheaacd_cblock_inv_quant_spect_data(ptr_aac_dec_channel_info[channel], 580 ptr_aac_tables); 581 ixheaacd_cblock_scale_spect_data(ptr_aac_dec_channel_info[channel], 582 ptr_aac_tables, num_ch, object_type, 583 aac_sf_data_resil_flag); 584 } 585 } 586 587 if (num_ch > 1) { 588 if (ptr_aac_dec_channel_info[LEFT]->common_window) { 589 if (ptr_aac_dec_channel_info[LEFT]->str_pns_info.pns_active || 590 ptr_aac_dec_channel_info[RIGHT]->str_pns_info.pns_active) { 591 ixheaacd_map_ms_mask_pns(ptr_aac_dec_channel_info); 592 } 593 594 ixheaacd_ms_stereo_process(ptr_aac_dec_channel_info, ptr_aac_tables); 595 } 596 597 ixheaacd_intensity_stereo_process(ptr_aac_dec_channel_info, ptr_aac_tables, 598 object_type, aac_sf_data_resil_flag); 599 } 600 601 for (channel = 0; channel < num_ch; channel++) { 602 WORD32 *p_spectrum = ptr_aac_dec_channel_info[channel]->ptr_spec_coeff; 603 604 if (total_channels > 2) { 605 if (ptr_aac_dec_channel_info[channel]->str_ics_info.window_sequence != 606 EIGHT_SHORT_SEQUENCE) { 607 WORD16 *band_offsets = ptr_aac_tables->sfb_long_table; 608 WORD32 no_spec_coeff = band_offsets[ptr_aac_dec_channel_info[channel] 609 ->str_ics_info.max_sfb]; 610 ixheaacd_right_shift_block(p_spectrum, no_spec_coeff, 3); 611 } else { 612 ixheaacd_right_shift_block(p_spectrum, 1024, 3); 613 } 614 } 615 616 ixheaacd_pns_process(ptr_aac_dec_channel_info, channel, ptr_aac_tables); 617 618 if ((object_type == AOT_ER_AAC_LD) || (object_type == AOT_AAC_LTP)) { 619 { 620 if (channel == 0) { 621 ltp_info *ltp1 = 622 &(ptr_aac_dec_channel_info[channel]->str_ics_info.ltp); 623 ixheaacd_lt_prediction(ptr_aac_dec_channel_info[channel], ltp1, 624 p_spectrum, ptr_aac_tables, 625 self->ptr_aac_dec_static_channel_info[LEFT] 626 ->overlap_add_data.win_shape, 627 self->sampling_rate_index, object_type, 628 self->samples_per_frame, in_data, out_data); 629 630 } else { 631 ltp_info *ltp2 = 632 (self->pstr_aac_dec_ch_info[0]->common_window) 633 ? &(ptr_aac_dec_channel_info[0]->str_ics_info.ltp2) 634 : 635 636 &(ptr_aac_dec_channel_info[1]->str_ics_info.ltp); 637 ixheaacd_lt_prediction(ptr_aac_dec_channel_info[channel], ltp2, 638 p_spectrum, ptr_aac_tables, 639 self->ptr_aac_dec_static_channel_info[RIGHT] 640 ->overlap_add_data.win_shape, 641 self->sampling_rate_index, object_type, 642 self->samples_per_frame, in_data, out_data); 643 } 644 } 645 } 646 647 if (ptr_aac_dec_channel_info[channel]->str_tns_info.tns_data_present) { 648 ixheaacd_aac_tns_process(ptr_aac_dec_channel_info[channel], 649 total_channels, ptr_aac_tables, object_type, 1, 650 NULL); 651 } 652 } 653 } 654 655 VOID ixheaacd_set_corr_info( 656 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD16 pns_band) { 657 ia_pns_correlation_info_struct *ptr_corr_info = 658 ptr_aac_dec_channel_info->pstr_pns_corr_info; 659 ptr_corr_info->correlated[(pns_band >> PNS_BAND_FLAGS_SHIFT)] |= 660 (1 << (pns_band & PNS_BAND_FLAGS_MASK)); 661 } 662 663 VOID ixheaacd_map_ms_mask_pns( 664 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info[CHANNELS]) { 665 WORD32 num_win_group, sfb; 666 667 for (num_win_group = 0; 668 num_win_group < 669 ptr_aac_dec_channel_info[LEFT]->str_ics_info.num_window_groups; 670 num_win_group++) { 671 for (sfb = 0; sfb < ptr_aac_dec_channel_info[LEFT]->str_ics_info.max_sfb; 672 sfb++) { 673 if (ptr_aac_dec_channel_info[LEFT] 674 ->pstr_stereo_info->ms_used[num_win_group][sfb]) { 675 WORD16 pns_band = (num_win_group << 4) + sfb; 676 ixheaacd_set_corr_info(ptr_aac_dec_channel_info[LEFT], pns_band); 677 678 if (ptr_aac_dec_channel_info[LEFT]->str_pns_info.pns_used[pns_band] && 679 ptr_aac_dec_channel_info[RIGHT]->str_pns_info.pns_used[pns_band]) { 680 ptr_aac_dec_channel_info[LEFT] 681 ->pstr_stereo_info->ms_used[num_win_group][sfb] ^= 1; 682 } 683 } 684 } 685 } 686 } 687 688 VOID ixheaacd_pulse_data_apply(ia_pulse_info_struct *ptr_pulse_info, 689 WORD8 *pulse_scratch, 690 const WORD16 *ptr_swb_offset, WORD object_type) { 691 WORD i; 692 WORD32 k; 693 694 memset(pulse_scratch, 0, sizeof(WORD32) * 256); 695 696 if (object_type != AOT_ER_AAC_ELD) { 697 if (ptr_pulse_info->pulse_data_present) { 698 k = ptr_swb_offset[ptr_pulse_info->pulse_start_band]; 699 700 for (i = 0; i <= ptr_pulse_info->number_pulse; i++) { 701 k = k + ptr_pulse_info->pulse_offset[i]; 702 pulse_scratch[k] = ptr_pulse_info->pulse_amp[i]; 703 } 704 } 705 } else { 706 ptr_pulse_info->pulse_data_present = 0; 707 } 708 } 709 710 WORD16 ixheaacd_read_spectral_data( 711 ia_bit_buf_struct *it_bit_buff, 712 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, 713 ia_aac_dec_tables_struct *ptr_aac_tables, WORD32 total_channels, 714 WORD32 frame_size, WORD32 object_type, WORD32 aac_spect_data_resil_flag, 715 WORD32 aac_sf_data_resil_flag) { 716 WORD sfb, max_sfb; 717 WORD num_win_grp, group_len, grp_offset; 718 719 WORD index; 720 WORD8 *ptr_code_book, *ptr_code_book_no; 721 WORD16 *ptr_scale_factor; 722 WORD32 *ptr_spec_coef; 723 ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; 724 WORD16 *swb_offset; 725 726 WORD32 *ptr_spec_coef_out; 727 728 ptr_code_book = ptr_aac_dec_channel_info->ptr_code_book; 729 ptr_scale_factor = ptr_aac_dec_channel_info->ptr_scale_factor; 730 ptr_spec_coef = ptr_aac_dec_channel_info->ptr_spec_coeff; 731 max_sfb = ptr_ics_info->max_sfb; 732 733 swb_offset = 734 ptr_aac_tables->str_aac_sfb_info[ptr_ics_info->window_sequence].sfb_index; 735 736 if (!aac_spect_data_resil_flag) { 737 if (ptr_aac_dec_channel_info->str_ics_info.window_sequence != 738 EIGHT_SHORT_SEQUENCE) { 739 WORD8 *ptr_scratch; 740 741 if (object_type == AOT_ER_AAC_ELD) 742 ptr_scratch = (WORD8 *)ptr_aac_dec_channel_info->pulse_scratch; 743 else 744 ptr_scratch = (WORD8 *)ptr_aac_dec_channel_info->scratch_buf_ptr; 745 746 memset(ptr_spec_coef, 0, sizeof(WORD32) * 1024); 747 748 ixheaacd_pulse_data_apply(&ptr_aac_dec_channel_info->str_pulse_info, 749 ptr_scratch, swb_offset, object_type); 750 751 ptr_spec_coef_out = &ptr_spec_coef[0]; 752 for (sfb = 0; sfb < max_sfb;) { 753 WORD ret_val; 754 WORD32 sfb_width; 755 WORD32 sect_cb = ptr_code_book[sfb]; 756 WORD start = sfb; 757 if ((object_type == AOT_ER_AAC_ELD) || (object_type == AOT_ER_AAC_LD)) { 758 if ((sect_cb >= 16) && (sect_cb <= 31)) { 759 ptr_code_book[sfb] = sect_cb = 11; 760 } 761 } 762 for (; sfb < max_sfb && (ptr_code_book[sfb] == sect_cb); sfb++) 763 ; 764 765 sfb_width = swb_offset[sfb] - swb_offset[start]; 766 767 if (sect_cb > ZERO_HCB && (sect_cb < NOISE_HCB)) { 768 ret_val = ixheaacd_huffman_dec_word2(it_bit_buff, sect_cb, sfb_width, 769 ptr_aac_tables, 770 ptr_spec_coef_out, ptr_scratch); 771 772 if (ret_val != 0) { 773 return (WORD16)( 774 (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_MAX_HUFFDEC_VAL); 775 } 776 } 777 778 else { 779 if (ptr_aac_dec_channel_info->str_pulse_info.pulse_data_present) { 780 ixheaacd_inverse_quantize( 781 ptr_spec_coef_out, sfb_width, 782 (WORD32 *) 783 ptr_aac_tables->pstr_block_tables->ixheaacd_pow_table_Q13, 784 ptr_scratch); 785 } 786 787 else { 788 memset(ptr_spec_coef_out, 0, sizeof(WORD32) * sfb_width); 789 } 790 } 791 ptr_scratch += sfb_width; 792 ptr_spec_coef_out += sfb_width; 793 } 794 795 if ((object_type != AOT_ER_AAC_ELD) && (object_type != AOT_ER_AAC_LD)) 796 index = 1024 - swb_offset[max_sfb]; 797 else 798 index = frame_size - swb_offset[max_sfb]; 799 800 memset(ptr_spec_coef_out, 0, sizeof(WORD32) * index); 801 802 } else { 803 memset(ptr_spec_coef, 0, sizeof(WORD32) * 1024); 804 805 grp_offset = 0; 806 807 for (num_win_grp = 0; num_win_grp < ptr_ics_info->num_window_groups; 808 num_win_grp++) { 809 WORD grp_len = ptr_ics_info->window_group_length[num_win_grp]; 810 ptr_code_book_no = 811 &ptr_code_book[num_win_grp * MAX_SCALE_FACTOR_BANDS_SHORT]; 812 ptr_spec_coef_out = &ptr_spec_coef[grp_offset * MAX_BINS_SHORT]; 813 814 for (sfb = 0; sfb < max_sfb;) { 815 WORD sect_cb = *ptr_code_book_no; 816 WORD start = sfb; 817 WORD ret_val; 818 819 for (; sfb < max_sfb && (*ptr_code_book_no == sect_cb); 820 sfb++, ptr_code_book_no++) 821 ; 822 823 if (sect_cb > ZERO_HCB && (sect_cb < NOISE_HCB)) { 824 ret_val = ixheaacd_decode_huffman( 825 it_bit_buff, sect_cb, ptr_spec_coef_out, (WORD16 *)swb_offset, 826 start, sfb, grp_len, ptr_aac_tables); 827 828 if (ret_val != 0) { 829 return (WORD16)( 830 (WORD32) 831 IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_MAX_HUFFDEC_VAL); 832 } 833 } 834 } 835 grp_offset = (grp_offset + grp_len); 836 } 837 } 838 { 839 WORD32 *ptr_scale_table = ptr_aac_tables->pstr_block_tables->scale_table; 840 WORD8 *ptr_sfb_width = 841 ptr_aac_tables->str_aac_sfb_info[ptr_ics_info->window_sequence] 842 .sfb_width; 843 844 for (num_win_grp = 0; num_win_grp < ptr_ics_info->num_window_groups; 845 num_win_grp++) { 846 for (group_len = 0; 847 group_len < ptr_ics_info->window_group_length[num_win_grp]; 848 group_len++) { 849 (*ixheaacd_scale_factor_process)( 850 &ptr_spec_coef[0], &ptr_scale_factor[0], max_sfb, 851 (WORD8 *)ptr_sfb_width, ptr_scale_table, total_channels, 852 object_type, aac_sf_data_resil_flag); 853 854 ptr_spec_coef += MAX_BINS_SHORT; 855 } 856 857 ptr_scale_factor += MAX_SCALE_FACTOR_BANDS_SHORT; 858 } 859 } 860 } else { 861 ia_hcr_info_struct *pstr_hcr_info = &ptr_aac_dec_channel_info->str_hcr_info; 862 WORD32 error = 0; 863 864 memset(ptr_spec_coef, 0, sizeof(WORD32) * 1024); 865 866 if (ptr_aac_dec_channel_info->reorder_spect_data_len != 0) { 867 error = ixheaacd_huff_code_reorder_init( 868 pstr_hcr_info, ptr_aac_dec_channel_info, ptr_aac_tables, it_bit_buff); 869 870 if (error != 0) { 871 return IA_ENHAACPLUS_DEC_EXE_NONFATAL_DECODE_FRAME_ERROR; 872 } 873 error = ixheaacd_hcr_decoder(pstr_hcr_info, ptr_aac_dec_channel_info, 874 ptr_aac_tables, it_bit_buff); 875 876 if (error != 0) { 877 ixheaacd_huff_mute_erroneous_lines(pstr_hcr_info); 878 } 879 880 it_bit_buff->cnt_bits += 881 -ptr_aac_dec_channel_info->reorder_spect_data_len; 882 it_bit_buff->ptr_read_next = 883 it_bit_buff->ptr_bit_buf_base + 884 ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); 885 it_bit_buff->bit_pos = (it_bit_buff->size - it_bit_buff->cnt_bits) & 7; 886 887 } else { 888 it_bit_buff->ptr_read_next = 889 it_bit_buff->ptr_bit_buf_base + 890 ((it_bit_buff->size - it_bit_buff->cnt_bits) >> 3); 891 it_bit_buff->bit_pos = (it_bit_buff->size - it_bit_buff->cnt_bits) & 7; 892 } 893 } 894 895 return AAC_DEC_OK; 896 } 897 898 WORD16 ixheaacd_read_tns_data( 899 ia_bit_buf_struct *it_bit_buff, 900 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info) { 901 WORD win_size, window_per_frame; 902 WORD n_filt_bits, start_band_bits, order_bits; 903 WORD32 bottom; 904 905 ia_ics_info_struct *ptr_ics_info = &ptr_aac_dec_channel_info->str_ics_info; 906 ia_tns_info_aac_struct *ptr_tns_info = 907 &ptr_aac_dec_channel_info->str_tns_info; 908 909 if (ptr_ics_info->window_sequence != EIGHT_SHORT_SEQUENCE) { 910 n_filt_bits = 2; 911 start_band_bits = 6; 912 order_bits = 5; 913 window_per_frame = 1; 914 915 } else { 916 n_filt_bits = 1; 917 start_band_bits = 4; 918 order_bits = 3; 919 window_per_frame = 8; 920 } 921 922 bottom = ptr_ics_info->num_swb_window; 923 924 for (win_size = 0; win_size < window_per_frame; win_size++) { 925 WORD n_filt; 926 WORD start_band, coef_res; 927 ptr_tns_info->n_filt[win_size] = n_filt = 928 (WORD16)ixheaacd_read_bits_buf(it_bit_buff, n_filt_bits); 929 930 if (n_filt) { 931 WORD filt; 932 WORD top; 933 934 coef_res = ixheaacd_read_bits_buf(it_bit_buff, 1); 935 936 top = bottom; 937 for (filt = 0; filt < n_filt; filt++) { 938 WORD order; 939 ia_filter_info_struct *filter = 940 &ptr_tns_info->str_filter[win_size][filt]; 941 942 start_band = ixheaacd_read_bits_buf(it_bit_buff, start_band_bits); 943 944 if (top < start_band) { 945 top = start_band; 946 } 947 filter->start_band = top - start_band; 948 filter->stop_band = top; 949 950 top = filter->start_band; 951 952 if (filter->start_band < 0) { 953 filter->order = -1; 954 return (WORD16)((WORD32)IA_ENHAACPLUS_DEC_EXE_FATAL_TNS_RANGE_ERROR); 955 } 956 957 filter->order = order = ixheaacd_read_bits_buf(it_bit_buff, order_bits); 958 959 if ((order - MAX_ORDER_LONG) > 0) { 960 return (WORD16)( 961 (WORD32)IA_ENHAACPLUS_DEC_EXE_NONFATAL_TNS_ORDER_ERROR); 962 } 963 964 if (order) { 965 WORD i; 966 WORD32 coef, coef_compress; 967 WORD resolution, shift; 968 969 filter->direction = 970 (WORD8)(ixheaacd_read_bits_buf(it_bit_buff, 1) ? -1 : 1); 971 972 coef_compress = ixheaacd_read_bits_buf(it_bit_buff, 1); 973 974 filter->resolution = coef_res; 975 976 resolution = coef_res + 3 - coef_compress; 977 978 shift = 32 - resolution; 979 980 for (i = 0; i < order; i++) { 981 coef = ixheaacd_read_bits_buf(it_bit_buff, resolution); 982 coef = coef << shift; 983 filter->coef[i] = (WORD8)(coef >> shift); 984 } 985 } 986 } 987 } 988 } 989 return AAC_DEC_OK; 990 } 991 992 WORD32 ixheaacd_inv_quant(WORD32 *px_quant, WORD32 *ixheaacd_pow_table_Q13) 993 994 { 995 WORD32 q1; 996 WORD32 temp; 997 WORD32 q_abs; 998 WORD16 interp; 999 WORD32 shift; 1000 1001 q_abs = *px_quant; 1002 1003 if (q_abs > (8191 + 32)) 1004 return IA_ENHAACPLUS_DEC_EXE_NONFATAL_EXCEEDS_MAX_HUFFDEC_VAL; 1005 1006 if (q_abs < 1024) { 1007 shift = 3; 1008 } else { 1009 shift = 6; 1010 } 1011 1012 q1 = (q_abs) >> shift; 1013 1014 interp = q_abs - (q1 << shift); 1015 1016 temp = ixheaacd_pow_table_Q13[q1 + 1] - ixheaacd_pow_table_Q13[q1]; 1017 1018 temp = (WORD32)(temp * (WORD32)interp); 1019 1020 temp = temp + (ixheaacd_pow_table_Q13[q1] << shift); 1021 1022 if (shift == 3) 1023 temp = temp << 1; 1024 else 1025 temp = temp << 2; 1026 1027 *px_quant = temp; 1028 1029 return 0; 1030 } 1031 1032 void ixheaacd_scale_value_in_place(WORD32 *value, WORD32 scalefactor) { 1033 WORD32 newscale; 1034 1035 if ((newscale = (scalefactor)) >= 0) { 1036 *(value) <<= newscale; 1037 } else { 1038 *(value) >>= -newscale; 1039 } 1040 } 1041 1042 WORD32 ixheaacd_cblock_inv_quant_spect_data( 1043 ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, 1044 ia_aac_dec_tables_struct *ptr_aac_tables) { 1045 int window, group, grp_win, band; 1046 int sf_bands_transmitted = ptr_aac_dec_channel_info->str_ics_info.max_sfb; 1047 WORD8 *ptr_code_book = ptr_aac_dec_channel_info->ptr_code_book; 1048 const WORD16 *band_offsets = (WORD16 *)ixheaacd_getscalefactorbandoffsets( 1049 &(ptr_aac_dec_channel_info->str_ics_info), ptr_aac_tables); 1050 WORD32 *ptr_pow_table_Q13 = 1051 (WORD32 *)ptr_aac_tables->pstr_block_tables->ixheaacd_pow_table_Q13; 1052 1053 for (window = 0, group = 0; 1054 group < ptr_aac_dec_channel_info->str_ics_info.num_window_groups; 1055 group++) { 1056 for (grp_win = 0; 1057 grp_win < 1058 ptr_aac_dec_channel_info->str_ics_info.window_group_length[group]; 1059 grp_win++, window++) { 1060 for (band = 0; band < sf_bands_transmitted; band++) { 1061 WORD32 *ptr_spec_coef = 1062 SPEC(ptr_aac_dec_channel_info->ptr_spec_coeff, window, 1063 ptr_aac_dec_channel_info->granule_len) + 1064 band_offsets[band]; 1065 int num_lines = band_offsets[band + 1] - band_offsets[band]; 1066 int bnds = group * 16 + band; 1067 int i; 1068 1069 if ((ptr_code_book[bnds] == ZERO_HCB) || 1070 (ptr_code_book[bnds] == INTENSITY_HCB) || 1071 (ptr_code_book[bnds] == INTENSITY_HCB2)) 1072 continue; 1073 1074 if (ptr_code_book[bnds] == NOISE_HCB) { 1075 continue; 1076 } 1077 1078 for (i = 0; i < num_lines; i++) { 1079 WORD8 temp = 0; 1080 WORD32 out1 = ptr_spec_coef[i]; 1081 if (out1 <= 0) { 1082 out1 = sub_d(temp, out1); 1083 if (out1 > 127) { 1084 ixheaacd_inv_quant(&out1, ptr_pow_table_Q13); 1085 } else 1086 out1 = ptr_pow_table_Q13[out1]; 1087 ptr_spec_coef[i] = -out1; 1088 1089 } else { 1090 if (out1 > 127) { 1091 ixheaacd_inv_quant(&out1, ptr_pow_table_Q13); 1092 } else 1093 out1 = ptr_pow_table_Q13[out1]; 1094 1095 ptr_spec_coef[i] = out1; 1096 } 1097 } 1098 } 1099 } 1100 } 1101 1102 return AAC_DEC_OK; 1103 } 1104 1105 void ixheaacd_init_ltp_object(ltp_info *ltp) { 1106 ltp->data_present = 0; 1107 ltp->last_band = 0; 1108 1109 ltp->lag_update = 0; 1110 ltp->coef = 0; 1111 } 1112 1113 WORD32 ixheaacd_ltp_data(WORD32 object_type, ia_ics_info_struct *ics, 1114 ltp_info *ltp, ia_handle_bit_buf_struct bs, 1115 WORD32 frame_len) { 1116 UWORD8 sfb, w; 1117 1118 if (object_type == AOT_ER_AAC_LD) { 1119 ltp->lag_update = ixheaacd_read_bits_buf(bs, 1); 1120 1121 if (ltp->lag_update) { 1122 ltp->lag = (UWORD16)ixheaacd_read_bits_buf(bs, 10); 1123 } 1124 } else { 1125 ltp->lag = (UWORD16)ixheaacd_read_bits_buf(bs, 11); 1126 } 1127 1128 if (ltp->lag > (frame_len << 1)) return -1; 1129 1130 ltp->coef = (UWORD8)ixheaacd_read_bits_buf(bs, 3); 1131 1132 if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) { 1133 for (w = 0; w < 8; w++) { 1134 if ((ltp->short_used[w] = ixheaacd_read_bits_buf(bs, 1)) & 1) { 1135 ltp->short_lag_present[w] = ixheaacd_read_bits_buf(bs, 1); 1136 if (ltp->short_lag_present[w]) { 1137 ltp->short_lag[w] = (UWORD8)ixheaacd_read_bits_buf(bs, 4); 1138 } 1139 } 1140 } 1141 } else { 1142 ltp->last_band = (ics->max_sfb < MAX_LTP_SFB ? ics->max_sfb : MAX_LTP_SFB); 1143 1144 for (sfb = 0; sfb < ltp->last_band; sfb++) { 1145 ltp->long_used[sfb] = ixheaacd_read_bits_buf(bs, 1); 1146 } 1147 } 1148 1149 return 0; 1150 } 1151