diff --git a/lib_com/options.h b/lib_com/options.h index a92e40a71b77704ec1c23f036a2c9248d2d856fe..92ad8525f960416b1bfb5821d1124f5e8ae63e5a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -91,6 +91,7 @@ //de-activate FIX_1320_STACK_CPE_DECODER due to sanitizer issues in #1986; also review needed for patch within FIX_1946_CRASH_JBM_PROCESSING, which gets partially disabled //#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 fa0f7a9dfd6435395904b7f68dc310ee2fa6fb36..326ec622160e3281067d2dc8c507261401dfd77a 100644 --- a/lib_com/tcx_utils_fx.c +++ b/lib_com/tcx_utils_fx.c @@ -1445,11 +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*/ - L_tmp = L_shl( L_mult( tmp, max_val ), add( tmp_e, max_e ) ); /* 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 */ + 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 */ #ifdef ISSUE_1836_replace_overflow_libcom tmp = round_fx_sat( L_tmp ); /* Q15 */ #else