From f48af0d897c288c2e3b363df4449f2449ce63256 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 5 Feb 2024 11:52:17 +0100 Subject: [PATCH 1/5] store intermediate result in int32 variable --- lib_com/ari_hm.c | 8 ++++++++ lib_com/options.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 3995913c43..98fd749418 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -290,13 +290,21 @@ void tcx_hm_modify_envelope( while ( k <= L_frame + kTcxHmParabolaHalfWidth - 1 ) { +#ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI + int32_t tmp; +#endif for ( x = max( 0, k - kTcxHmParabolaHalfWidth ); x <= min( k + kTcxHmParabolaHalfWidth, L_frame - 1 ); ++x ) { 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 = (int16_t) (tmp >> fract_res); +#else k = ( h * lag ) >> fract_res; +#endif } return; diff --git a/lib_com/options.h b/lib_com/options.h index 8f7a89fcf0..dca95cc05a 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -158,6 +158,7 @@ #define FIX_955_FASTCONV_REND_IN_ISM /* VA: put FastConv rendering call under DEBUGGING */ #define FIX_969_USAN_IGF_ARITH /* FhG: issue 969: fix USAN error in igf_sce_dec; same issue as #962 */ #define FIX_959_MASA_LINEAR_REND /* VA: issue 959: remove unused calling of ivas_sba_linear_renderer() in MASA rendering */ +#define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ /* #################### End BE switches ################################## */ -- GitLab From c85fd4b9ad9111fde4403e277241549f0137c5b5 Mon Sep 17 00:00:00 2001 From: knj Date: Mon, 5 Feb 2024 13:43:10 +0100 Subject: [PATCH 2/5] fix clang-format --- lib_com/ari_hm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 98fd749418..8655cfd94f 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -301,7 +301,7 @@ void tcx_hm_modify_envelope( ++h; #ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI tmp = ( h * lag ); - k = (int16_t) (tmp >> fract_res); + k = (int16_t) ( tmp >> fract_res ); #else k = ( h * lag ) >> fract_res; #endif -- GitLab From e38fd5373b08555021b5c3d0e6f543bc9256dba9 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 8 Feb 2024 10:00:46 +0100 Subject: [PATCH 3/5] amend patch --- lib_com/ari_hm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 8655cfd94f..fe9f077290 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -272,7 +272,12 @@ void tcx_hm_modify_envelope( const int16_t L_frame /* i : number of spectral lines */ ) { +#ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI + int16_t h, x; + int32_t k; +#else int16_t k, h, x; +#endif Word16 inv_shape[2 * kTcxHmParabolaHalfWidth + 1]; /* Q15 */ if ( gain == 0 ) @@ -301,7 +306,7 @@ void tcx_hm_modify_envelope( ++h; #ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI tmp = ( h * lag ); - k = (int16_t) ( tmp >> fract_res ); + k = tmp >> fract_res ; #else k = ( h * lag ) >> fract_res; #endif -- GitLab From 9f335434993596d21f666ea60e8a313b6d5e5da6 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 8 Feb 2024 11:20:02 +0100 Subject: [PATCH 4/5] clang format --- lib_com/ari_hm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index fe9f077290..0ee33b042f 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -306,7 +306,7 @@ void tcx_hm_modify_envelope( ++h; #ifdef FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI tmp = ( h * lag ); - k = tmp >> fract_res ; + k = tmp >> fract_res; #else k = ( h * lag ) >> fract_res; #endif -- GitLab From e2d1b6921183a56138d0f56cdc8950d3224fa0e8 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 8 Feb 2024 11:27:15 +0100 Subject: [PATCH 5/5] fix warning under VS --- lib_com/ari_hm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 0ee33b042f..7060e6cd21 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -299,7 +299,11 @@ void tcx_hm_modify_envelope( int32_t tmp; #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 ) +#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] ); } -- GitLab