From 2f9f657253c2634d5ab290ea89608cb345dc278f Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 4 Nov 2024 10:34:22 +0530 Subject: [PATCH] Fix for 3gpp issue 971: Waveform discrepency when transitioning from concealing a lost frame to decoding a received frame with SBA bitstream [x] Changed guard bits logic to avoid saturation --- lib_dec/FEC_scale_syn_fx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib_dec/FEC_scale_syn_fx.c b/lib_dec/FEC_scale_syn_fx.c index 1de166612..21a589c56 100644 --- a/lib_dec/FEC_scale_syn_fx.c +++ b/lib_dec/FEC_scale_syn_fx.c @@ -790,15 +790,16 @@ void FEC_scale_syn_ivas_fx( /*-----------------------------------------------------------------* * Find the energy/gain at the end of the frame *-----------------------------------------------------------------*/ - IF( LT_16( getScaleFactor16( synth, L_frame ), 2 ) ) + tmp = sub( 3, getScaleFactor16( synth, L_frame ) ); + IF( tmp > 0 ) { - Scale_sig( synth, L_frame, -1 ); - frame_ener_fx( L_frame, clas, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2 /*Q0*/, 1, sub( Q_syn, 1 ), 3, 0 ); - Scale_sig( synth, L_frame, 1 ); + Word16 synth_tmp[L_FRAME16k]; + Copy_Scale_sig( synth, synth_tmp, L_frame, -tmp ); // Q_synth - tmp + frame_ener_fx( L_frame, clas, synth_tmp, pitch[L_frame / L_SUBFR - 1], &L_enr2 /*Q0*/, 1, sub( Q_syn, tmp ), 3, 0 ); } ELSE { - frame_ener_fx( L_frame, clas, synth, pitch[sub( shr( L_frame, 6 ), 1 )], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 ); + frame_ener_fx( L_frame, clas, synth, pitch[L_frame / L_SUBFR - 1], &L_enr2 /*Q0*/, 1, Q_syn, 3, 0 ); } test(); -- GitLab