From 737e30acf8d7d5702c9a5a44c9b199e9415c4dc8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 21 Aug 2025 09:37:13 +0200 Subject: [PATCH 1/2] fix overflow in hq_lr_enc --- lib_com/options.h | 1 + lib_enc/hq_lr_enc.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 0000a66f49..e6081dee4f 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 FIX_1348_OVERFLOW /* FhG: fix BASOP overflow in hq_lr_dec(), brings floating-point code inline with FX */ +#define FIX_1369_HQ_LR_OVERFLOW /* FhG: fix BASOP overflow in hq_lr_enc(), brings floating-point code inline with FX */ /* #################### End BE switches ################################## */ diff --git a/lib_enc/hq_lr_enc.c b/lib_enc/hq_lr_enc.c index 65b5dd4ef5..ca71fbc307 100644 --- a/lib_enc/hq_lr_enc.c +++ b/lib_enc/hq_lr_enc.c @@ -336,7 +336,15 @@ void hq_lr_enc( frac1 = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ L_tmp = Pow2( 30, frac1 ); exp = sub( exp, 30 ); +#ifdef FIX_1369_HQ_LR_OVERFLOW +#ifdef BASOP_NOGLOB + 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, s_max( sub( exp, 6 ), -31 ) ); /* 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 46912cc8f9db0e70425a2b831495386a8f51c8cf Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 21 Aug 2025 09:39:10 +0200 Subject: [PATCH 2/2] formatting --- lib_enc/hq_lr_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/hq_lr_enc.c b/lib_enc/hq_lr_enc.c index ca71fbc307..be0a2254c5 100644 --- a/lib_enc/hq_lr_enc.c +++ b/lib_enc/hq_lr_enc.c @@ -343,7 +343,7 @@ void hq_lr_enc( 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 */ + Ep_fx[i] = L_shl( L_tmp, sub( exp, 6 ) ); /* Q -6 */ #endif Ep[i] = (float) ( Ep_fx[i] / pow( 2.0, -6 ) ); } -- GitLab