From 99b4c3e373cd9336fc478e5321e126a8e0db79fb Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 27 Oct 2025 11:48:51 +0100 Subject: [PATCH 1/2] L_add -> L_add_sat in get_envelope function --- lib_dec/TonalComponentDetection_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index 409b975f5..84d5ec063 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -454,7 +454,7 @@ static void getEnvelope( FOR( i = 0; i < n2; i++ ) { - sum = L_add( sum, powerSpec[i] ); /*powerSpec_exp*/ + sum = L_add_sat( sum, powerSpec[i] ); /*powerSpec_exp*/ } /* No need for PTR_INIT for powerSpec[i+n2] as we continue from the previous loop */ FOR( i = 0; i < n1; i++ ) -- GitLab From 342b58e46c42dd0c7882f4faba6da448732c67cf Mon Sep 17 00:00:00 2001 From: Jan Kiene Date: Mon, 27 Oct 2025 13:43:28 +0100 Subject: [PATCH 2/2] add preprocessor switch for fix --- lib_com/options.h | 1 + lib_dec/TonalComponentDetection_fx.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index f9fec417b..486b8582a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -80,6 +80,7 @@ #define FIX_2084_FLOATING_POINT_LEFTOVERS /* FhG: convert floating-point leftovers in IVAS_ENC_FeedObjectMetadata() */ #define FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING /* FhG: Replace L_shl with L_shl_sat to prevent overflow when calculating scale factors for very small numbers in the logarithmic domain */ #define FIX_APA_EXECS_SCALING /* VA: fix scaling of JBM APA buffer */ +#define FIX_BASOP_ASSERT_IN_TONAL_MDCT_PLC /* FhG: fix for issue 2165 - using saturating addition in tonal MDCT PLC function */ /* ################### End FIXES switches ########################### */ diff --git a/lib_dec/TonalComponentDetection_fx.c b/lib_dec/TonalComponentDetection_fx.c index 84d5ec063..bfb0b0428 100644 --- a/lib_dec/TonalComponentDetection_fx.c +++ b/lib_dec/TonalComponentDetection_fx.c @@ -454,7 +454,11 @@ static void getEnvelope( FOR( i = 0; i < n2; i++ ) { +#ifdef FIX_BASOP_ASSERT_IN_TONAL_MDCT_PLC sum = L_add_sat( sum, powerSpec[i] ); /*powerSpec_exp*/ +#else + sum = L_add( sum, powerSpec[i] ); /*powerSpec_exp*/ +#endif } /* No need for PTR_INIT for powerSpec[i+n2] as we continue from the previous loop */ FOR( i = 0; i < n1; i++ ) -- GitLab