From d355b48bd45599c227d4d48945e1ec9e65986214 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Mon, 4 Nov 2024 15:21:58 +0530 Subject: [PATCH] Fix for 3GPP issue 984: Decoder crash for Stereo at 24.4 / 32 kbps JBM operation in Comp_and_apply_gain_ivas_fx() --- lib_com/gs_gains_fx.c | 14 +++++++------- lib_com/gs_noisefill_fx.c | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib_com/gs_gains_fx.c b/lib_com/gs_gains_fx.c index 8b3719e98..08c4d9f36 100644 --- a/lib_com/gs_gains_fx.c +++ b/lib_com/gs_gains_fx.c @@ -215,13 +215,13 @@ void Comp_and_apply_gain_ivas_fx( * y_gain = pow(10.0, (Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) * = pow(2, 3.321928*(Ener_per_bd_iQ[i_band]-Ener_per_bd_yQ[i_band])) *-----------------------------------------------------------------*/ - L16 = sub( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ - L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ - L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ - frac = L_Extract_lc( L32, &exp1 ); /* Extract exponent of gcode0 */ - y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ - /* output of Pow2() will be: */ - /* 16384 < Pow2() <= 32767 */ + L16 = sub_sat( Ener_per_bd_iQ[i_band], Ener_per_bd_yQ[i_band] ); /*Q12 */ + L32 = L_mult( L16, 27213 ); /* 3.321928 in Q13 -> Q26 */ + L32 = L_shr( L32, 10 ); /* From Q26 to Q16 */ + frac = L_Extract_lc( L32, &exp1 ); /* Extract exponent of gcode0 */ + y_gain = extract_l( Pow2( 14, frac ) ); /* Put 14 as exponent so that */ + /* output of Pow2() will be: */ + /* 16384 < Pow2() <= 32767 */ #ifdef BASOP_NOGLOB Ener_per_bd_yQ[i_band] = shl_o( y_gain, sub( exp1, 13 ), &Overflow ); /*Q13*/ #else /* BASOP_NOGLOB */ diff --git a/lib_com/gs_noisefill_fx.c b/lib_com/gs_noisefill_fx.c index d0f72936d..9f4ef9810 100644 --- a/lib_com/gs_noisefill_fx.c +++ b/lib_com/gs_noisefill_fx.c @@ -1338,9 +1338,9 @@ void highband_exc_dct_in_ivas_fx( { FOR( i = 0; i < last_bin; i++ ) { - Ener_per_bd_iQ[i] = s_min( Ener_per_bd_iQ[i], sub( add( lt_ener_per_band_fx[i], 1229 ), Ener_per_bd_yQ[i] ) ); + Ener_per_bd_iQ[i] = s_min( Ener_per_bd_iQ[i], sub_sat( add( lt_ener_per_band_fx[i], 1229 ), Ener_per_bd_yQ[i] ) ); move16(); - lt_ener_per_band_fx[i] = sub( lt_ener_per_band_fx[i], 77 ); + lt_ener_per_band_fx[i] = sub_sat( lt_ener_per_band_fx[i], 77 ); move16(); } FOR( ; i < MBANDS_GN; i++ ) -- GitLab