diff --git a/lib_com/ari_hm.c b/lib_com/ari_hm.c index 28a41093362144f32aa5d535f93bd5f3164aa4b0..e858a9ff2e15ee8a7ce1c3e4878b7d5b2bd46513 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( - const int16_t lag, /* i : pitch lag */ +#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 c2fc60a11ba78937bb7009b033136ecf7fd38d2c..e4c1de494d3cc1bf3bb5f1758d8668cabc0d82c1 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -224,6 +224,7 @@ #define FIX_699_FILE_READER_JBM_TSM /* VA: issue 699: complement FileReader_getFilePath() logic for TSM and JBM */ #define FIX_997_REMOVE_SPAR_DEC_UPMIXER /* VA: issue 997: remove obsolete function ivas_spar_dec_upmixer() */ #define FIX_1003_PARAMISM_BINAURAL_RECONFIG_USAN /* FhG: fix for #1003: fix USAN caused by ParamISM reconfig */ +#define FIX_1001_ARI_HM_OVERFLOW /* FhG: fix for undef behaviour in in the harmonic TCX model arithmetic coder */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_com/prot.h b/lib_com/prot.h index e79530df0f74df103f6f73cef5661b87fe40770b..f02db62888de05704a6c10b89cf825057433eb05 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7833,14 +7833,22 @@ int16_t DecodeIndex( #define GET_ADJ2( T, L, F ) ( ( ( L ) << ( F ) ) - ( T ) ) int16_t tcx_hm_render( - const int16_t lag, /* i : pitch lag */ +#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 a1e43ae97c978da56369be9c6a7ff05813ac459c..67be41d6e7df0ed83af4108a4cc35e9428ea6b25 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 56722df065eddebd846f3625ac4cd9fb00d92d74..cbbc1d9763cbcd8c2c328c05b8705ef26f256090 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 );