diff --git a/lib_com/options.h b/lib_com/options.h index a92e40a71b77704ec1c23f036a2c9248d2d856fe..05902cbcbf639feba213f7cb150f560057fca5ea 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 9298c863481ba068e9933d1d90336774fe3d47c6..587016e5f3558b5bf2b1f4969420bf40313fc119 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