From 92ef31396246ae221769f23ef1640c8fe557c1f4 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 28 Aug 2025 18:23:06 +0200 Subject: [PATCH] Add one bit of headroom in e_fx calculation in FdCng_encodeSID_ivas_fx() --- lib_com/options.h | 1 + lib_enc/fd_cng_enc_fx.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8ec901855..3769c0fda 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -81,6 +81,7 @@ #define FIX_1979_SAT_MISSING_IN_LSF_ENC /* VA: Proposal to fix 1979, saturation in lsf_enc, NOkia to review */ #define FIX_1946_CRASH_JBM_PROCESSING /* FhG: Increased guard bits of DFT_fx */ +#define FIX_1980_CRASH_FDCNG_ENCODESID /* FhG: Add one bit of headroom in e_fx calculation in FdCng_encodeSID_ivas_fx() */ /* #################### Start BASOP porting switches ############################ */ #define NONBE_1244_FIX_SWB_BWE_MEMORY /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */ diff --git a/lib_enc/fd_cng_enc_fx.c b/lib_enc/fd_cng_enc_fx.c index 9298c8634..587016e5f 100644 --- a/lib_enc/fd_cng_enc_fx.c +++ b/lib_enc/fd_cng_enc_fx.c @@ -2469,7 +2469,11 @@ void FdCng_encodeSID_ivas_fx( v_fx[i] = Mpy_32_32( 671088640 /*10 in Q26*/, BASOP_Util_Log10( E_fx[i], hFdCngEnc->msNoiseEst_fx_exp ) ); // Q20 = 26+25-31 move32(); } - e_fx = L_add( e_fx, v_fx[i] ); // Q20 +#ifdef FIX_1980_CRASH_FDCNG_ENCODESID + e_fx = L_add( e_fx, L_shr( v_fx[i], 1 ) ); // Q19, add one bit headroom +#else + e_fx = L_add( e_fx, v_fx[i] ); // Q20 +#endif } /* Normalize MSVQ input */ @@ -2538,8 +2542,11 @@ void FdCng_encodeSID_ivas_fx( { gain_fx = L_add( gain_fx, v_fx[i] ); // Q = 31 - v_e } - - e_fx = L_shl( e_fx, sub( 11, v_e ) ); // Q = 31 - v_e +#ifdef FIX_1980_CRASH_FDCNG_ENCODESID + e_fx = L_shl( e_fx, sub( 12, v_e ) ); // Q = 31 - v_e +#else + e_fx = L_shl( e_fx, sub( 11, v_e ) ); // Q = 31 - v_e +#endif gain_fx = Mpy_32_16_1( L_sub( e_fx, gain_fx ), div_s( 1, N ) ); // Q = 31 - v_e gain_fx = L_shl( gain_fx, sub( v_e, 8 ) ); // Q23 -- GitLab