Skip to content

Commit

Permalink
Merge pull request #52 from ittiam-systems/decoder_bug_fixes
Browse files Browse the repository at this point in the history
Decoder bug fixes
  • Loading branch information
nikhil-bhavikatti authored Sep 11, 2023
2 parents ccdced7 + 632e575 commit 12867ea
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
14 changes: 14 additions & 0 deletions decoder/ixheaacd_bitbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ VOID ixheaacd_aac_read_byte_corr1(UWORD8 **ptr_read_next, WORD32 *ptr_bit_pos,
v++;
}
}

if (bits_consumed > (31 - temp_bit_count)) {
if ((p_bit_buf_end != NULL) && (p_bit_buf_end < v)) {
bits_consumed = 31 - temp_bit_count;
}
}

*ptr_bit_pos = bits_consumed + temp_bit_count;
*ptr_read_next = v;
return;
Expand All @@ -198,6 +205,13 @@ VOID ixheaacd_aac_read_byte_corr(UWORD8 **ptr_read_next, WORD32 *ptr_bit_pos,
} else {
bits_consumed += 8;
}

if (bits_consumed > 31) {
if (p_bit_buf_end < v) {
bits_consumed = 31;
}
}

*ptr_bit_pos = bits_consumed;
*ptr_read_next = v;
return;
Expand Down
3 changes: 3 additions & 0 deletions decoder/ixheaacd_imdct.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ static IA_ERRORCODE ixheaacd_fd_imdct_short(ia_usac_data_struct *usac_data,
ixheaacd_normalize(p_in_ibuffer, max_shift - 1, ixheaacd_drc_offset->n_long);
shiftp += max_shift - 1;

if ((shiftp - shift_olap) > 31) {
shiftp = 31 + shift_olap;
}
err_code = ixheaacd_calc_window(&window_short, ixheaacd_drc_offset->n_short,
window_select, usac_data->ec_flag);
if (err_code == -1) return err_code;
Expand Down
3 changes: 3 additions & 0 deletions decoder/ixheaacd_mps_decorr.c
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,9 @@ static VOID ixheaacd_ducker_apply_71(
if (ixheaacd_mps_comp(temp3, temp_1, &qtemp, qtemp1)) {
temp_2 = ixheaacd_mps_div_32(temp3, temp_1, &qtemp2);
qtemp2 = qtemp2 + qtemp - qtemp1;
if (temp_1 == 0) {
qtemp2 = qtemp;
}
temp3 = (qtemp2) > 28 ? MAX_32 : 4 << qtemp2;

if (temp_2 > temp3) {
Expand Down
3 changes: 3 additions & 0 deletions decoder/ixheaacd_pns_js_thumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ VOID ixheaacd_gen_rand_vec(WORD32 scale, WORD shift, WORD32 *ptr_spec_coef,

spec = ptr_spec_coef;

if (shift < -31) {
shift = -31;
}
for (sfb = 0; sfb <= sfb_width; sfb++) {
*spec = ixheaac_shr32_dir_sat_limit(ixheaac_mult32_shl_sat(*spec, scale),
shift);
Expand Down
4 changes: 3 additions & 1 deletion decoder/ixheaacd_sbrdecoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ IA_ERRORCODE ixheaacd_applysbr(
if (stereo) {
frame_status = ixheaacd_sbr_read_cpe(ptr_header_data[0], ptr_frame_data, it_bit_buff,
self->pstr_sbr_tables, audio_object_type);
if (usac_flag && (frame_status == 0)) return -1;
if (frame_status < 0) return frame_status;
} else {
if (ps_enable) {
Expand All @@ -630,6 +631,7 @@ IA_ERRORCODE ixheaacd_applysbr(
frame_status = ixheaacd_sbr_read_sce(
ptr_header_data[k], ptr_frame_data[k], self->pstr_ps_stereo_dec, it_bit_buff,
self->pstr_sbr_tables, audio_object_type, ec_flag);
if (usac_flag && (frame_status == 0)) return -1;
if (frame_status < 0) return frame_status;
if (ec_flag && self->pstr_ps_stereo_dec != NULL) {
ixheaacd_copy_prev_ps_params(self->pstr_ps_stereo_dec, &self->str_ps_config_prev,
Expand All @@ -644,7 +646,7 @@ IA_ERRORCODE ixheaacd_applysbr(
}
ptr_header_data[k]->enh_sbr_ps =
((self->enh_sbr_ps) | (ptr_header_data[0]->channel_mode == PS_STEREO));
if (audio_object_type != AOT_ER_AAC_ELD) {
if ((audio_object_type != AOT_ER_AAC_ELD) && (audio_object_type != AOT_USAC)) {
WORD32 total_bits_read;
total_bits_read = ixheaacd_no_bits_read(it_bit_buff);
if (total_bits_read > (ptr_bit_str_ele->size_payload << 3) ||
Expand Down

0 comments on commit 12867ea

Please sign in to comment.