From bbc6fea61ff3becd414c2abc783a4818d662f7b2 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 13 Feb 2025 14:02:03 -0500 Subject: [PATCH] fixes to overflow in preprocessing --- lib_com/options.h | 1 + lib_enc/ivas_stereo_classifier.c | 4 ++++ lib_enc/speech_music_classif_fx.c | 11 +++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 974237f4c..2d359665c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -168,4 +168,5 @@ #define FIX_1072_SPEEDUP_gainpanning /* FhG: Minor WMOPS tuning, nonbe */ #define FIX_1072_SPEEDUP_COMPUTEDIFUSENESS /* FhG: Minor WMOPS tuning, nonbe */ #define FIX_1320_LOWRATE_ACELP +#define FIX_1297_OVERFLOW /* VA: fixes issue with overflows in pre-processing */ #endif diff --git a/lib_enc/ivas_stereo_classifier.c b/lib_enc/ivas_stereo_classifier.c index c84fd73f1..4913f2545 100644 --- a/lib_enc/ivas_stereo_classifier.c +++ b/lib_enc/ivas_stereo_classifier.c @@ -1647,7 +1647,11 @@ static void edge_detect_fx( } } +#ifndef FIX_1297_OVERFLOW *edge_str = extract_l( L_shr( edge_min, 10 ) ); // Q15 +#else + *edge_str = extract_h( L_shl_sat( edge_min, 16 - 10 ) ); // Q15 +#endif move16(); *edge_type = et; // Q0 move16(); diff --git a/lib_enc/speech_music_classif_fx.c b/lib_enc/speech_music_classif_fx.c index 32b521ef4..295cff8a1 100644 --- a/lib_enc/speech_music_classif_fx.c +++ b/lib_enc/speech_music_classif_fx.c @@ -2303,14 +2303,21 @@ Word16 ivas_smc_gmm_fx( *high_lpn_flag = 1; move32(); } - +#ifndef FIX_1297_OVERFLOW hSpMusClas->lpm_fx = extract_l( L_shr( lpm_fx, 11 ) ); // Q7 move16(); hSpMusClas->lps_fx = extract_l( L_shr( lps_fx, 11 ) ); // Q7 move16(); hSpMusClas->lpn_fx = extract_l( L_shr( lpn_fx, 11 ) ); // Q7 move16(); - +#else + hSpMusClas->lpm_fx = extract_h( L_shl_sat( lpm_fx, 16 - 11 ) ); // Q7 + move16(); + hSpMusClas->lps_fx = extract_h( L_shl_sat( lps_fx, 16 - 11 ) ); // Q7 + move16(); + hSpMusClas->lpn_fx = extract_h( L_shl_sat( lpn_fx, 16 - 11 ) ); // Q7 + move16(); +#endif /* determine HQ Generic speech class */ IF( st->hHQ_core != NULL ) { -- GitLab