From 16035d34daa9f1abf5885d12c4354bdad1636cbb Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 22 Aug 2024 20:18:28 +0530 Subject: [PATCH] Fix for 3gpp issue 832: Differences between BASOP and float decoder for clipped inputs --- lib_dec/core_switching_dec_fx.c | 21 ++++++++++++++++----- lib_dec/lib_dec_fx.c | 1 - 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 3f6bb58e4..f2c94e09d 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1694,12 +1694,24 @@ ivas_error core_switching_post_dec_ivas_fx( } /* delay HQ synthesis to synchronize with ACELP synthesis */ /* rescaling to the min exp of the 2 */ - IF( hHQ_core->Q_old_postdec ) + Word16 NonZero = 1; + move16(); + FOR( i = 0; i < delay_comp; i++ ) + { + IF( st_fx->delay_buf_out_fx[i] != 0 ) + { + NonZero = 0; + move16(); + break; + } + } + test(); + IF( hHQ_core->Q_old_postdec >= 0 || EQ_16( NonZero, 1 ) ) { Scale_sig( st_fx->delay_buf_out_fx, delay_comp, negate( hHQ_core->Q_old_postdec ) ); + hHQ_core->Q_old_postdec = 0; + move16(); } - - hHQ_core->Q_old_postdec = 0; move16(); Qtmp = s_min( *Qsynth, hHQ_core->Q_old_postdec ); Scale_sig( synth, output_frame, sub( Qtmp, *Qsynth ) ); @@ -1711,8 +1723,7 @@ ivas_error core_switching_post_dec_ivas_fx( Word16 temp_buffer[L_FRAME48k]; Copy( st_fx->delay_buf_out_fx, temp_buffer, delay_comp ); - Copy_Scale_sig( synth + sub( output_frame, delay_comp ), st_fx->delay_buf_out_fx, delay_comp, negate( hHQ_core->Q_old_postdec ) ); - hHQ_core->Q_old_postdec = 0; + Copy( synth + sub( output_frame, delay_comp ), st_fx->delay_buf_out_fx, delay_comp ); move16(); Copy( synth, synth + delay_comp, sub( output_frame, delay_comp ) ); Copy( temp_buffer, synth, delay_comp ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index db77f15fc..1c6e084a4 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1402,7 +1402,6 @@ static ivas_error IVAS_DEC_GetTcSamples( /*core_switching_post_dec*/ IF( hCPE->hCoreCoder[n]->hHQ_core != NULL ) { - hCPE->hCoreCoder[n]->hHQ_core->Q_old_postdec = 0; hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda = 0; } } -- GitLab