From 630ac53c3b3acc51abc392656cf94ca196cb3751 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 28 Apr 2026 11:10:24 +0200 Subject: [PATCH 1/4] Added FIX_BASOP_2563_CRASH_HQ_GENERIC_DEC to resolve basop issue 2563 --- lib_com/options.h | 1 + lib_com/swb_bwe_com_fx.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 52de155d3..39d4daf2c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -107,6 +107,7 @@ #define FIX_BASOP_2555_FRAMELEN_CALC /* FhG: BASOP issue 2555: Simplify (sub-)framelength calculation in ivas_mdct_core_tns_ns_fx() */ #define FIX_BASOP_2095_REMOVE_TABLES_PT01 /* FhG: BASOP issue 2095: remove unused tables, part 01 */ #define FIX_2346_DUPLICATED_IGF_FUNCTIONS_2 /* FhG: part 2 of basop issue 2346: Review potentially duplicated IGF functions */ +#define FIX_BASOP_2563_CRASH_HQ_GENERIC_DEC /* Eri: BASOP issue 2563: Crash in hq_generic decoding. EVS code --> solve with _sat operator */ /* #################### End BE switches ################################## */ diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index bd1c35e3e..434dd6a80 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -2747,8 +2747,12 @@ void hq_generic_decoding_fx( exp2 = sub( norm_l( L_tmp2 ), 1 ); tmp1_fx = extract_h( L_shl( L_tmp1, exp1 ) ); tmp2_fx = extract_h( L_shl( L_tmp2, exp2 ) ); - tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ + tmp3_fx = div_s( tmp2_fx, tmp1_fx ); /*15 + exp2 + 15 - (exp1 + 15) */ +#ifdef FIX_BASOP_2563_CRASH_HQ_GENERIC_DEC + tmp3_fx = shr_sat( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */ +#else tmp3_fx = shr( tmp3_fx, add( 5, sub( exp2, exp1 ) ) ); /*10 */ +#endif if ( LT_16( tmp3_fx, 307 /*0.3 in Q10 */ ) ) { -- GitLab From dbe87b36a26f60f1a5af7f84ca4b64c1f3843858 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 28 Apr 2026 11:20:56 +0200 Subject: [PATCH 2/4] Fix to trigger assert instead of segfault for overflow in shr --- lib_basop/basop32.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib_basop/basop32.c b/lib_basop/basop32.c index 4f601911b..f46714baa 100644 --- a/lib_basop/basop32.c +++ b/lib_basop/basop32.c @@ -345,7 +345,7 @@ Flag Carry = 0; do \ { \ (void) 0; \ - } while ( 0 ) /* no-op */ + } while ( 0 ) /* no-op */ #define B_HELPER_GET_GLOBAL( global_flag ) 0 /* Default to 0 */ #endif @@ -896,7 +896,18 @@ Word16 shr_o( Word16 var1, Word16 var2, Flag *Overflow ) Word16 shr( Word16 var1, Word16 var2 ) { +#ifdef FIX_BASOP_2563_CRASH_HQ_GENERIC_DEC + Flag Overflow; + Word16 result; + result = shr_o( var1, var2, &Overflow ); + if ( Overflow ) + { + assert( 0 ); + } + return result; +#else return shr_o( var1, var2, NULL ); +#endif } Word16 shr_sat( Word16 var1, Word16 var2 ) { -- GitLab From 44dcb535933a515f3fda058551da42b2e5081f65 Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 28 Apr 2026 11:27:03 +0200 Subject: [PATCH 3/4] Clang format --- lib_basop/basop32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_basop/basop32.c b/lib_basop/basop32.c index f46714baa..526366604 100644 --- a/lib_basop/basop32.c +++ b/lib_basop/basop32.c @@ -345,7 +345,7 @@ Flag Carry = 0; do \ { \ (void) 0; \ - } while ( 0 ) /* no-op */ + } while ( 0 ) /* no-op */ #define B_HELPER_GET_GLOBAL( global_flag ) 0 /* Default to 0 */ #endif -- GitLab From fc3953ebe4b373b1f37f8b6bdb7fe09a397de90e Mon Sep 17 00:00:00 2001 From: Erik Norvell Date: Tue, 28 Apr 2026 14:09:33 +0200 Subject: [PATCH 4/4] Add init of Overflow in shr --- lib_basop/basop32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib_basop/basop32.c b/lib_basop/basop32.c index 526366604..1b9ef845d 100644 --- a/lib_basop/basop32.c +++ b/lib_basop/basop32.c @@ -899,6 +899,9 @@ Word16 shr( Word16 var1, Word16 var2 ) #ifdef FIX_BASOP_2563_CRASH_HQ_GENERIC_DEC Flag Overflow; Word16 result; + + Overflow = 0; + result = shr_o( var1, var2, &Overflow ); if ( Overflow ) { -- GitLab