From c1bc360e1a52aabb76bed461237922621837f6cb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Tue, 9 Jul 2024 12:19:19 +0530 Subject: [PATCH] LTV crash and high MLD fixes [x] High MLD fix for the test case - ltv-Multi-channel 7_1_4 at 160 kbps, 48kHz in, 48kHz out, BINAURAL out, bandwidth switching, HR. MLD decreased from 37.302719 to 15.416886 [x] Fix for ltv-crash SBA FOA bitrate switching from 13.2 kbps to 192 kbps, 32kHz in, 32kHz out, DTX on, BINAURAL out [x] Fix for LTV-Crash [ltv-OMASA 1Dir1TC 4ISM at 48 kbps, 48kHz in, 48kHz out, BINAURAL_ROOM_REVERB out] --- lib_com/fd_cng_com_fx.c | 16 +++++++++++++++- lib_dec/dec_tcx.c | 10 ++++++++-- lib_dec/fd_cng_dec_fx.c | 17 ++++++++++++++++- lib_dec/ivas_spar_md_dec.c | 10 +++++++++- lib_dec/ivas_stereo_dft_dec_fx.c | 2 +- 5 files changed, 49 insertions(+), 6 deletions(-) diff --git a/lib_com/fd_cng_com_fx.c b/lib_com/fd_cng_com_fx.c index b024df61d..7ba5cf7c6 100644 --- a/lib_com/fd_cng_com_fx.c +++ b/lib_com/fd_cng_com_fx.c @@ -2227,7 +2227,21 @@ void scalebands_fx( move32(); FOR( ; i <= part[stopPartM1]; i++ ) { - val = L_shl( Mpy_32_16_1( val, delta ), s1 ); + test(); + IF( val != 0 && delta != 0 ) + { + val = L_shl( Mpy_32_16_1( val, delta ), s1 ); + IF( val == 0 ) + { + val = 1; + move32(); + } + } + ELSE + { + val = 0; + move32(); + } bandpow[i] = val; move32(); } diff --git a/lib_dec/dec_tcx.c b/lib_dec/dec_tcx.c index 17ce5672d..06c9bc5ba 100644 --- a/lib_dec/dec_tcx.c +++ b/lib_dec/dec_tcx.c @@ -1571,7 +1571,7 @@ void decoder_tcx_tns_fx( const Word16 whitenedDomain, Word16 *length ) { - Word16 index, isTCX5, L; + Word16 index, isTCX5, L, tmp; TCX_CONFIG_HANDLE hTcxCfg = st->hTcxCfg; index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */ @@ -1581,6 +1581,8 @@ void decoder_tcx_tns_fx( move16(); L = L_frameTCX; move16(); + tmp = L; + move16(); test(); IF( EQ_16( L_frame, shr( st->L_frame, 1 ) ) && NE_16( st->tcxonly, 0 ) ) @@ -1601,6 +1603,8 @@ void decoder_tcx_tns_fx( { L = L_spec; move16(); + tmp = L; + move16(); } test(); @@ -1652,6 +1656,8 @@ void decoder_tcx_tns_fx( IF( EQ_16( st->element_mode, EVS_MONO ) || LT_16( L_spec, L_frameTCX ) ) /* todo: this is temporary to maintain EVS BE, this is a bug and should be fixed also for EVS (see issue 13) */ { tcx5TnsUngrouping_fx( shr( L_frameTCX, 1 ), shr( hTcxCfg->tnsConfig[0][0].iFilterBorders[0], 1 ), x_fx, DEC ); + tmp = L_frameTCX; + move16(); } ELSE { @@ -1679,7 +1685,7 @@ void decoder_tcx_tns_fx( if ( length != NULL ) { - *length = L; + *length = tmp; move16(); } diff --git a/lib_dec/fd_cng_dec_fx.c b/lib_dec/fd_cng_dec_fx.c index 4c0e5b1d7..f4cf173f5 100644 --- a/lib_dec/fd_cng_dec_fx.c +++ b/lib_dec/fd_cng_dec_fx.c @@ -2907,7 +2907,22 @@ void perform_noise_estimation_dec_ivas_fx( } /* IIR smoothing */ - *ptr_per = Mpy_32_16_1( ( *ptr_per ), alpha ); + test(); + IF( *ptr_per != 0 && alpha != 0 ) + { + *ptr_per = Mpy_32_16_1( ( *ptr_per ), alpha ); + move32(); + IF( *ptr_per == 0 ) + { + *ptr_per = 1; + move32(); + } + } + ELSE + { + *ptr_per = 0; + move32(); + } *ptr_per = L_add( ( *ptr_per ), Mpy_32_16_1( temp, sub( MAX_16, alpha ) ) ); ptr_per++; } diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 48cbad61d..1a894ce10 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -4469,7 +4469,15 @@ static void ivas_parse_parameter_bitstream_dtx( value = get_next_indice( st0, pr_pd_bits ); - pr = idiv1616( value, pd_q_lvls ); + IF( value != 0 ) + { + pr = idiv1616( value, pd_q_lvls ); + } + ELSE + { + pr = 0; + move16(); + } pd = extract_l( L_sub( value, i_mult( pr, pd_q_lvls ) ) ); val_fx = dtx_pd_real_min_max_fx[0]; move32(); diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 87831a269..1808c5384 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -2153,7 +2153,7 @@ void stereo_dft_dec_fx( move16(); } l_gamma = L_deposit_l( gamma ); - op1 = L_add( l_gamma, L_shr( L_deposit_l( sub( MAX_16, mult( g, g ) ) ), q_gamma ) ); + op1 = L_add( l_gamma, L_shr( L_deposit_l( sub( MAX_16, mult_sat( g, g ) ) ), q_gamma ) ); /*The mult_sat function is needed because -0.999979973 is being mapped to -32768. This value, when multiplied by -32768, is causing a crash.*/ q_loc2 = add( Q16, q_gamma ); q_loc1 = q_loc2; move16(); -- GitLab