From b3c125392f3116e433130582471db47342551822 Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 9 Feb 2024 14:05:44 +0100 Subject: [PATCH 1/2] instead of cast, use 32 bit var --- lib_com/ari_hm.c | 6 +++--- lib_com/options.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index afcdf52ad6..2a7718e843 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -273,8 +273,8 @@ void tcx_hm_modify_envelope( ) { #ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI - int16_t h, x; - int32_t k; + int16_t h; + int32_t x, k; #else int16_t k, h, x; #endif @@ -300,7 +300,7 @@ void tcx_hm_modify_envelope( #endif #ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI - for ( x = (int16_t) max( 0, k - kTcxHmParabolaHalfWidth ); x <= (int16_t) min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) + for ( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) #else for ( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) #endif diff --git a/lib_com/options.h b/lib_com/options.h index 865e54b2f7..8cd276584e 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,7 +154,7 @@ #define FIX_963_USAN_ERROR /* Eri: Issue 963: USAN error in Stereo CNG, division by zero */ #define FIX_971_LOG2_IDX_GAIN_0 /* VA: prevent -Inf due to log2(ratio==0) */ #define FIX_ACCESS_WITHIN_NULL_STRUCT_MC_BW_SWITCHING /* FhG: fix usan error in MCT with bw swicthing */ -// #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ +#define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ #define FIX_983_DISC_ISM_DIGEST_NUM_OBJS /* FhG: issue #983: the discrete ISM digest function uses the wrong number of objects */ /* #################### End BE switches ################################## */ -- GitLab From 32ba3bb67b364a0debe7b2e40f6c0b2ce219dfec Mon Sep 17 00:00:00 2001 From: knj Date: Fri, 9 Feb 2024 16:51:12 +0100 Subject: [PATCH 2/2] make everything 32 bit as done in EVS --- lib_com/ari_hm.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 2a7718e843..3e83529bbb 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -273,8 +273,7 @@ void tcx_hm_modify_envelope( ) { #ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI - int16_t h; - int32_t x, k; + int32_t h, x, k; #else int16_t k, h, x; #endif @@ -295,25 +294,12 @@ void tcx_hm_modify_envelope( while ( k <= L_frame + kTcxHmParabolaHalfWidth - 1 ) { -#ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI - int32_t tmp; -#endif - -#ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI - for ( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) -#else for ( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) -#endif { env[x] = Mpy_32_16( env[x], inv_shape[x - k + kTcxHmParabolaHalfWidth] ); } ++h; -#ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI - tmp = ( h * lag ); - k = tmp >> fract_res; -#else k = ( h * lag ) >> fract_res; -#endif } return; -- GitLab