From 09572a648a2a06ff71a4bfd0bbe7776a5285dc6e Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 28 Aug 2025 16:04:38 -0400 Subject: [PATCH 1/2] possible fix for 1984 --- lib_com/options.h | 1 + lib_com/tcx_utils_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 8ec901855..a68b80119 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -90,6 +90,7 @@ #define FIX_1319_STACK_SBA_DECODER /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */ #define FIX_1320_STACK_CPE_DECODER /* VA: issue 1320: Optimize the stack memory consumption in the CPE decoder */ +#define FIX_1984_SAT_IN_PSYCHAD /* VA: Issue 1984: proposal to fix an assert */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index fa0f7a9df..7480b4657 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*/ +#ifdef FIX_1984_SAT_IN_PSYCHAD + L_tmp = L_shl_sat( L_mult_sat( tmp, max_val ), add( tmp_e, max_e ) ); /* Q31 */ +#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 From 9b703fea0040ba4a495aa2d099f9ac3d65912588 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 28 Aug 2025 16:11:17 -0400 Subject: [PATCH 2/2] fix clang --- lib_com/tcx_utils_fx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/tcx_utils_fx.c b/lib_com/tcx_utils_fx.c index 7480b4657..326ec6221 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1445,15 +1445,15 @@ void PsychAdaptLowFreqDeemph( /* fac = tmp = (float)pow(max_val / min, 0.0078125f); */ tmp_e = min_e; move16(); - tmp = Inv16( min, &tmp_e ); /*Q15 - tmp_e*/ + tmp = Inv16( min, &tmp_e ); /*Q15 - tmp_e*/ #ifdef FIX_1984_SAT_IN_PSYCHAD L_tmp = L_shl_sat( L_mult_sat( tmp, max_val ), add( tmp_e, max_e ) ); /* Q31 */ #else - L_tmp = L_shl( L_mult( tmp, max_val ), add( tmp_e, max_e ) ); /* Q31 */ + 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 */ + 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 */ #ifdef ISSUE_1836_replace_overflow_libcom tmp = round_fx_sat( L_tmp ); /* Q15 */ #else -- GitLab