From 2b3f042e6d7b6b90f659110fd536782b047c76d2 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 16 Feb 2024 17:18:49 +0100 Subject: [PATCH 1/2] patch for issue 1001 --- lib_com/ari_hm.c | 8 ++++++++ lib_com/options.h | 2 +- lib_com/prot.h | 8 ++++++++ lib_dec/ari_hm_dec.c | 8 ++++++++ lib_enc/ari_hm_enc.c | 16 ++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 3e83529bbb..2e603fbaa1 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -205,7 +205,11 @@ int16_t CountIndexBits( *-------------------------------------------------------------------*/ int16_t tcx_hm_render( +#ifdef FIX_1001_ARI_HM_OVERFLOW + const int32_t lag, /* i : pitch lag */ +#else const int16_t lag, /* i : pitch lag */ +#endif const int16_t fract_res, /* i : fractional resolution of the lag */ Word16 p[] /* o : harmonic model (Q13) */ ) @@ -265,7 +269,11 @@ int16_t tcx_hm_render( void tcx_hm_modify_envelope( const Word16 gain, /* i : HM gain (Q11) */ +#ifdef FIX_1001_ARI_HM_OVERFLOW + const int32_t lag, +#else const int16_t lag, +#endif const int16_t fract_res, const Word16 p[], /* i : harmonic model (Q13) */ Word32 env[], /* i/o: envelope (Q16) */ diff --git a/lib_com/options.h b/lib_com/options.h index 48d7a6cb28..71d4b3ba5b 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -154,7 +154,7 @@ /*#define SPLIT_REND_WITH_HEAD_ROT */ /* Dlb,FhG: Split Rendering contributions 21 and 35 */ #define FIX_966_VAR_OVERFLOW_IN_HARM_MODEL_ARI /* FhG: fix and undef behaviour bug in the harmonic TCX model arithmetic coder */ - +#define FIX_1001_ARI_HM_OVERFLOW /* FhG: fix for undef behaviour in in the harmonic TCX model arithmetic coder */ diff --git a/lib_com/prot.h b/lib_com/prot.h index e60023602e..fb721e9369 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7832,14 +7832,22 @@ int16_t DecodeIndex( #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) int16_t tcx_hm_render( +#ifdef FIX_1001_ARI_HM_OVERFLOW + const int32_t lag, /* i : pitch lag */ +#else const int16_t lag, /* i : pitch lag */ +#endif const int16_t fract_res, /* i : fractional resolution of the lag */ Word16 p[] /* o : harmonic model (Q13) */ ); void tcx_hm_modify_envelope( const Word16 gain, /* i : HM gain (Q11) */ +#ifdef FIX_1001_ARI_HM_OVERFLOW + const int32_t lag, +#else const int16_t lag, +#endif const int16_t fract_res, const Word16 p[], /* i : harmonic model (Q13) */ Word32 env[], /* i/o: envelope (Q16) */ diff --git a/lib_dec/ari_hm_dec.c b/lib_dec/ari_hm_dec.c index 30889e741f..2a0e8bde04 100644 --- a/lib_dec/ari_hm_dec.c +++ b/lib_dec/ari_hm_dec.c @@ -120,7 +120,11 @@ void tcx_hm_decode( int16_t *hm_bits /* o : bit consumption */ ) { +#ifdef FIX_1001_ARI_HM_OVERFLOW + int32_t lag; +#else int16_t lag; +#endif int32_t tmpL; int16_t NumTargetBits, fract_res; Word16 p[2 * kTcxHmParabolaHalfWidth + 1], gain; @@ -144,7 +148,11 @@ void tcx_hm_decode( /* Convert the index to lag */ UnmapIndex( prm_hm[1], L_frame >= 256, LtpPitchLag, ( NumTargetBits <= kSmallerLagsTargetBitsThreshold ) || ( L_frame < 256 ), &fract_res, &tmpL ); +#ifdef FIX_1001_ARI_HM_OVERFLOW + lag = tmpL; +#else lag = (int16_t) tmpL; +#endif /* Render the harmonic model */ if ( tcx_hm_render( lag, fract_res, p ) ) diff --git a/lib_enc/ari_hm_enc.c b/lib_enc/ari_hm_enc.c index dd37682551..0a18a007ab 100644 --- a/lib_enc/ari_hm_enc.c +++ b/lib_enc/ari_hm_enc.c @@ -418,7 +418,11 @@ static void PeakFilter( static float tcx_hm_get_re( const float x[], /* i : absolute spectrum */ const Word16 gain, /* i : HM gain (Q11) */ +#ifdef FIX_1001_ARI_HM_OVERFLOW + const int32_t lag, +#else const int16_t lag, +#endif const int16_t fract_res, const Word16 p[], /* i : harmonic model (Q13) */ const Word32 env[], /* i : envelope (Q16) */ @@ -467,7 +471,11 @@ static float tcx_hm_get_re( static void tcx_hm_quantize_gain( const float x[], /* i : absolute spectrum */ const Word32 env[], /* i : envelope (Q16) */ +#ifdef FIX_1001_ARI_HM_OVERFLOW + const int32_t lag, +#else const int16_t lag, +#endif const int16_t fract_res, Word16 p[], /* i : harmonic model (Q13) */ const int16_t L_frame, /* i : number of spectral lines */ @@ -557,7 +565,11 @@ void tcx_hm_analyse( int16_t *hm_bits /* o : bit consumption */ ) { +#ifdef FIX_1001_ARI_HM_OVERFLOW + int32_t lag; +#else int16_t lag; +#endif int32_t tmpL; int16_t fract_res; float fspec[N_MAX_ARI], RelativeScore; @@ -583,7 +595,11 @@ void tcx_hm_analyse( /* Convert the index to lag */ UnmapIndex( prm_hm[1], L_frame >= 256, LtpPitchLag, ( targetBits - *hm_bits <= kSmallerLagsTargetBitsThreshold ) || ( L_frame < 256 ), &fract_res, &tmpL ); +#ifdef FIX_1001_ARI_HM_OVERFLOW + lag = tmpL; +#else lag = (int16_t) tmpL; +#endif /* Render harmonic model */ tcx_hm_render( lag, fract_res, p ); -- GitLab From 59b67412b92aad57e9cfc7df9cd27ed37fd45ce7 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Fri, 16 Feb 2024 17:21:39 +0100 Subject: [PATCH 2/2] formatting --- lib_com/ari_hm.c | 4 ++-- lib_com/prot.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 2e603fbaa1..0e9a18085c 100644 --- a/lib_com/ari_hm.c +++ b/lib_com/ari_hm.c @@ -206,9 +206,9 @@ int16_t CountIndexBits( int16_t tcx_hm_render( #ifdef FIX_1001_ARI_HM_OVERFLOW - const int32_t lag, /* i : pitch lag */ + const int32_t lag, /* i : pitch lag */ #else - const int16_t lag, /* i : pitch lag */ + const int16_t lag, /* i : pitch lag */ #endif const int16_t fract_res, /* i : fractional resolution of the lag */ Word16 p[] /* o : harmonic model (Q13) */ diff --git a/lib_com/prot.h b/lib_com/prot.h index fb721e9369..d55ffdfbc6 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7833,9 +7833,9 @@ int16_t DecodeIndex( int16_t tcx_hm_render( #ifdef FIX_1001_ARI_HM_OVERFLOW - const int32_t lag, /* i : pitch lag */ + const int32_t lag, /* i : pitch lag */ #else - const int16_t lag, /* i : pitch lag */ + const int16_t lag, /* i : pitch lag */ #endif const int16_t fract_res, /* i : fractional resolution of the lag */ Word16 p[] /* o : harmonic model (Q13) */ -- GitLab