From ab426b4ab98d126e8234b647aacc0d390b0a54e0 Mon Sep 17 00:00:00 2001 From: Tapani Pihlajakuja Date: Tue, 16 Jun 2026 13:53:52 +0300 Subject: [PATCH] Fix BASOP issue 2640 by saturating the shifts on extreme cases. --- lib_com/options.h | 1 + lib_rend/ivas_dirac_output_synthesis_dec_fx.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index fca9b4b0f..affdd07ed 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -102,6 +102,7 @@ #define FIX_FLOAT_1600_OMASA_WRONG_RENDER_PATH /* Nokia: float issue 1600: fix initialization condition of stereo type detection for OMASA */ #define FIX_BASOP_1765_MASA1TC_CNG_MISMATCH /* Nokia: BASOP issue 1765: Improve accuracy of FD CNG noise estimation */ #define FIX_BASOP_2627_PARAM_MC_ILD_REMAP_EXP /* FhG: BASOP #2627: accumulate 10^(ILD/10) using a dynamic exponent */ +#define FIX_BASOP_2640_MASA_STEREO_TYPE_ASSERT /* Nokia: BASOP issue 2640: Fix assert by saturating shift when exponent difference is very large. */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c index 27a95190f..cf995220e 100644 --- a/lib_rend/ivas_dirac_output_synthesis_dec_fx.c +++ b/lib_rend/ivas_dirac_output_synthesis_dec_fx.c @@ -2063,13 +2063,21 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( subtract_target_ratio = L_sub( BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ), BASOP_Util_Log2( masa_stereo_type_detect->target_power_y_smooth_fx ) ); // Q25 exp = sub( masa_stereo_type_detect->q_subtract_power_y_smooth, masa_stereo_type_detect->q_target_power_y_smooth ); +#ifdef FIX_BASOP_2640_MASA_STEREO_TYPE_ASSERT + L_tmp = Mpy_32_32( L_sub( subtract_target_ratio, L_shl_sat( exp, 25 ) ), LOG10_2_Q31 ); // Q25 +#else L_tmp = Mpy_32_32( L_sub( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ); // Q25 +#endif } ELSE { subtract_target_ratio = BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ); // Q25 exp = sub( 31, masa_stereo_type_detect->q_subtract_power_y_smooth ); +#ifdef FIX_BASOP_2640_MASA_STEREO_TYPE_ASSERT + L_tmp = L_sub( Mpy_32_32( L_add( subtract_target_ratio, L_shl_sat( exp, 25 ) ), LOG10_2_Q31 ), -503316480 /* L_shl( -15, 25 ) */ /*log(EPSILON)*/ ); // Q25 +#else L_tmp = L_sub( Mpy_32_32( L_add( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ), -503316480 /* L_shl( -15, 25 ) */ /*log(EPSILON)*/ ); // Q25 +#endif } subtract_target_ratio_db = Mpy_32_32( 1342177280 /* 10.0f * in Q27*/, L_tmp ); // (Q27, (Q25, Q31)) -> (Q27, Q25) -> Q21 -- GitLab