From b496715c1992fa7c7601d04b91a5ff9149ecc6bc Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 18 Aug 2025 15:54:42 +0200 Subject: [PATCH 1/2] fix for overflow; brings float inline with BASOP --- lib_com/options.h | 1 + lib_dec/hq_lr_dec.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index e6e5cea86a..8267482f97 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -164,6 +164,7 @@ /*#define FIX_I4_OL_PITCH*/ /* fix open-loop pitch used for EVS core switching */ #define TMP_FIX_1119_SPLIT_RENDERING_VOIP /* FhG: Add error check for unsupported config: split rendering with VoIP mode */ #define CODE_IMPROVEMENTS /* FhG: Small code improvements that do not change the functionality */ +#define FIX_1348_OVERFLOW /* FhG: fix BASOP overflow in hq_lr_dec(), brings floating-point code inline with FX */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c index f9ab923be7..2b2377400f 100644 --- a/lib_dec/hq_lr_dec.c +++ b/lib_dec/hq_lr_dec.c @@ -262,7 +262,15 @@ void hq_lr_dec( frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ L_tmp = Pow2( 30, frac1 ); exp = sub( exp, 30 ); +#ifdef FIX_1348_OVERFLOW +#ifdef BASOP_NOGLOB + Ep_fx[i] = L_shl_o( L_tmp, sub( exp, 6 ), &Overflow ); /* Q -6 */ +#else Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ +#endif +#else + Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ +#endif Ep[i] = (float) ( Ep_fx[i] / pow( 2.0, -6 ) ); } -- GitLab From fbfe16f594be13171fb3d32dcced29b584df2b46 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Mon, 18 Aug 2025 16:46:13 +0200 Subject: [PATCH 2/2] extend patch --- lib_dec/hq_lr_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/hq_lr_dec.c b/lib_dec/hq_lr_dec.c index 2b2377400f..b2febc4956 100644 --- a/lib_dec/hq_lr_dec.c +++ b/lib_dec/hq_lr_dec.c @@ -264,9 +264,9 @@ void hq_lr_dec( exp = sub( exp, 30 ); #ifdef FIX_1348_OVERFLOW #ifdef BASOP_NOGLOB - Ep_fx[i] = L_shl_o( L_tmp, sub( exp, 6 ), &Overflow ); /* Q -6 */ + Ep_fx[i] = L_shl_o( L_tmp, s_max( sub( exp, 6 ), -31 ), &Overflow ); /* Q -6 */ #else - Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ + Ep_fx[i] = L_shl( L_tmp, s_max( sub( exp, 6 ), -31 ) ); /* Q -6 */ #endif #else Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ -- GitLab