From c8103a53d8ef569f4059585d10a03da0005e3ac4 Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 29 Aug 2025 11:16:02 +0200 Subject: [PATCH] Replace L_shl with L_shl_sat to clamp small rounding error that push value above 1.0 in PsychAdaptLowFreqDeemph() --- lib_com/options.h | 1 + lib_com/tcx_utils_fx.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 8ec901855..bb39f2b34 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_1984_CRASH_ENC_ISM4 /* FhG: Replace L_shl with L_shl_sat to clamp small rounding error that push value above 1.0 */ /* #################### 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_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index fa0f7a9df..18f62299f 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1446,7 +1446,11 @@ void PsychAdaptLowFreqDeemph( tmp_e = min_e; move16(); tmp = Inv16( min, &tmp_e ); /*Q15 - tmp_e*/ - L_tmp = L_shl( L_mult( tmp, max_val ), add( tmp_e, max_e ) ); /* Q31 */ +#ifdef FIX_1984_CRASH_ENC_ISM4 + L_tmp = L_shl_sat( L_mult( tmp, max_val ), add( tmp_e, max_e ) ); /* Q31, use L_shl_sat() to clamp small error that push L_tmp above 1.0 */ +#else + L_tmp = L_shl( L_mult( tmp, max_val ), add( tmp_e, max_e ) ); /* Q31 */ +#endif L_tmp = BASOP_Util_Log2( L_tmp ); /* Q25 */ L_tmp = L_shr( L_tmp, 7 ); /* 0.0078125f = 1.f/(1<<7) */ L_tmp = BASOP_Util_InvLog2( L_tmp ); /* Q31 */ -- GitLab