From dbaa1e12460384c395885fd07b5b0d512dd15226 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 4 Dec 2025 09:35:48 -0500 Subject: [PATCH 1/4] Fix assert in EVS path --- lib_com/options.h | 2 +- lib_enc/enc_acelpx_fx.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 1a7b596d5..6cbfe7e97 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -85,6 +85,7 @@ #define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */ #define NONBE_1122_KEEP_EVS_MODE_UNCHANGED /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR. */ #define FIX_1435_MOVE_STEREO_PANNING /* VA: issue 1435: do the EVS stereo panning in the renderer */ +#define FIX_2248_EVS_ASSERT /* VA: Include _sat in an EVS related part of the code */ /* #################### End BE switches ################################## */ @@ -97,7 +98,6 @@ #define FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH /* VA: Fix Issue 2253 where the encoder and decoder could get out of sync */ #define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ - /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 95104c76c..5c3ac2f69 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -293,8 +293,11 @@ static void E_ACELP_1pulse_searchx_fx( ps0 = *ps; /* Qdn */ move16(); alp0 = L_deposit_h( *alp ); /* Q22 */ +#ifndef FIX_2248_EVS_ASSERT alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ - +#else + alp0 = L_mac_sat( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ +#endif /* Ensure that in the loop below s > 0 in the first iteration, the actual values do not matter. */ move16(); move16(); -- GitLab From 1f0ed6f47dedcea16f441427cd1cb47d6da7d362 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 4 Dec 2025 09:58:59 -0500 Subject: [PATCH 2/4] Fix clang --- lib_enc/enc_acelpx_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/enc_acelpx_fx.c b/lib_enc/enc_acelpx_fx.c index 5c3ac2f69..089c3bbb4 100644 --- a/lib_enc/enc_acelpx_fx.c +++ b/lib_enc/enc_acelpx_fx.c @@ -292,7 +292,7 @@ static void E_ACELP_1pulse_searchx_fx( /*alp0 = *alp + R[0]; INDIRECT(1);*/ ps0 = *ps; /* Qdn */ move16(); - alp0 = L_deposit_h( *alp ); /* Q22 */ + alp0 = L_deposit_h( *alp ); /* Q22 */ #ifndef FIX_2248_EVS_ASSERT alp0 = L_mac( alp0, R[0], sign_val_1 ); /* Qalp = (Q_R=Q_cor)*Q_signval */ #else -- GitLab From 8d30cdc16b622acdc14c994f8e3ef6442a1fe4b6 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 14:31:29 -0500 Subject: [PATCH 3/4] Fix proposal for 2264, out-of-bound access in log2 --- lib_com/log2.c | 7 +++++-- lib_com/options.h | 2 +- lib_enc/swb_pre_proc_fx.c | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 70e6b93c0..8fa3a7120 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -57,10 +57,13 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val { Word16 i, a; Word16 y; - +#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); - +#else + assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ + L_x = L_max( L_x, 0x40000000 ); +#endif L_x = L_shr( L_x, 9 ); a = extract_l( L_x ); /* Extract b10-b24 of fraction */ a = lshr( a, 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index 1b4f59296..b84e1a499 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define FIX_2015_PREMPH_SAT_ALT_PART2 /* VA: Add missing scaling factor to be passed to AVQ_cod() */ #define FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH /* VA: Fix Issue 2253 where the encoder and decoder could get out of sync */ #define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ - +#define FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC /* VA: Fix issue 2264 by adding a proper safeguard in log2 and by adding a missing normalization in swb_pre_proc_ivas_fx()*/ /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a966f70cc..a2ade8d3b 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,6 +1125,9 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } +#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC + exp = norm_l( CldfbHB_fx ); +#endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); -- GitLab From 1f525044637dca0073042c4fb7e4f6a7e6354ac4 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Fri, 5 Dec 2025 14:39:03 -0500 Subject: [PATCH 4/4] Revert "Fix proposal for 2264, out-of-bound access in log2" This reverts commit 8d30cdc16b622acdc14c994f8e3ef6442a1fe4b6. --- lib_com/log2.c | 7 ++----- lib_com/options.h | 2 +- lib_enc/swb_pre_proc_fx.c | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib_com/log2.c b/lib_com/log2.c index 8fa3a7120..70e6b93c0 100644 --- a/lib_com/log2.c +++ b/lib_com/log2.c @@ -57,13 +57,10 @@ Word16 Log2_norm_lc( /* (o) : Fractional part of Log2. (range: 0<=val { Word16 i, a; Word16 y; -#ifndef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC + if ( L_x <= 0 ) L_x = L_deposit_h( 0x4000 ); -#else - assert( L_x >= 0x40000000 ); /* If assert fail, means input is not normalized as it should be */ - L_x = L_max( L_x, 0x40000000 ); -#endif + L_x = L_shr( L_x, 9 ); a = extract_l( L_x ); /* Extract b10-b24 of fraction */ a = lshr( a, 1 ); diff --git a/lib_com/options.h b/lib_com/options.h index b84e1a499..1b4f59296 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,7 @@ #define FIX_2015_PREMPH_SAT_ALT_PART2 /* VA: Add missing scaling factor to be passed to AVQ_cod() */ #define FIX_2253_CORRECT_GSC_MINIMUM_PIT_SEARCH /* VA: Fix Issue 2253 where the encoder and decoder could get out of sync */ #define NONBE_FIX_1967_SBA_DECODER_MONO_OUT_BIG_DIFFERENCES /* Dolby: Fix basop issue 1967 */ -#define FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC /* VA: Fix issue 2264 by adding a proper safeguard in log2 and by adding a missing normalization in swb_pre_proc_ivas_fx()*/ + /* ##################### End NON-BE switches ########################### */ /* ################## End MAINTENANCE switches ######################### */ diff --git a/lib_enc/swb_pre_proc_fx.c b/lib_enc/swb_pre_proc_fx.c index a2ade8d3b..a966f70cc 100644 --- a/lib_enc/swb_pre_proc_fx.c +++ b/lib_enc/swb_pre_proc_fx.c @@ -1125,9 +1125,6 @@ void swb_pre_proc_ivas_fx( CldfbHB_fx = EPSILON_FX; move32(); } -#ifdef FIX_2264_OUT_OF_BOUND_READING_IN_LOG2_NORM_LC - exp = norm_l( CldfbHB_fx ); -#endif CldfbHB_fx = L_shl( CldfbHB_fx, exp ); /* CldfbHB_ener = CldfbHB_fl*2^(exp) */ Cldfbtemp1 = Log2_norm_lc( CldfbHB_fx ); /* Log2_norm_lc(t) = 2^15*(log2(t/2^30)) */ Cldfbtemp1 = sub( shr( Cldfbtemp1, 6 ), shl( add( sub( Q31 - Q30, CldfbHB_fx_e ), exp ), 9 ) ); -- GitLab