From ed402def6cdc15d0677209c43be8e1216f958b3b Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Thu, 25 Jul 2024 19:21:22 +0530 Subject: [PATCH] Fix for 3GPP issue 790 [x] [3GPP-Issue #790] Fixes improper output with floating point IVAS decoder for 10dB test_sba_plc_system[1-32-PLperc40mblen50-stvFOA-0-32000] test case [x] Corresponding float changes taken through MR!453: https://forge.3gpp.org/rep/sa4/audio/ivas-basop/-/merge_requests/453 --- lib_com/options.h | 1 + lib_dec/swb_tbe_dec.c | 18 ++++++++++++++++ lib_dec/swb_tbe_dec_fx.c | 44 ++++++++++++++++++++++++++++++++++++++++ lib_enc/swb_tbe_enc.c | 18 ++++++++++++++++ lib_enc/swb_tbe_enc_fx.c | 24 +++++++++++++++++++++- 5 files changed, 104 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index c40293951..d56b99de4 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -78,6 +78,7 @@ #define NONBE_FIX_1096_NAN_VALUES_IN_DIRAC_TO_STEREO /* FhG: avoid sidegain DFT-Stereo param to be larger than 1 when converting from Dirac parameters */ #define NON_BE_1055_RESET_LP_MEMORIES /* VA: issue 1055: Correctly reset LP filter MA and AR memories in bitrate switching */ #define NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /* VA: Add fix point bit allocation for special GSC mode such that float and fixed point have the same final bit allocation */ +#define NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE /* VA: issue 1132: prevent division by extremely low energy value in SWB TBE */ /* #################### End FIXES switches ############################ */ diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 870b656fa..bf05a9b2b 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -337,6 +337,15 @@ void wb_tbe_dec( prev_pow = sum2_f( shaped_wb_excitation, L_SHB_LAHEAD / 4 ); curr_pow = sum2_f( shaped_wb_excitation + L_SHB_LAHEAD / 4, L_SHB_LAHEAD / 4 ); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + if ( st->element_mode > EVS_MONO ) + { + /* prevent too low values of energy */ + prev_pow = max( 0.00001f, prev_pow ); + curr_pow = max( 0.00001f, curr_pow ); + } +#endif + if ( voice_factors[0] > 0.75f ) { curr_pow *= 0.25; @@ -3448,6 +3457,15 @@ void swb_tbe_dec( prev_pow = sum2_f( shaped_shb_excitation, L_SHB_LAHEAD + 10 ); curr_pow = sum2_f( shaped_shb_excitation + L_SHB_LAHEAD + 10, L_SHB_LAHEAD + 10 ); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + if ( st->element_mode > EVS_MONO ) + { + /* prevent too low values of energy */ + prev_pow = max( 0.00001f, prev_pow ); + curr_pow = max( 0.00001f, curr_pow ); + } +#endif + if ( voice_factors[0] > 0.75f ) { curr_pow *= 0.25; diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 330156ce0..b986d136b 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -908,6 +908,17 @@ void ivas_wb_tbe_dec_fx( prev_pow = 0; move32(); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + IF( st_fx->element_mode > EVS_MONO ) + { + tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); +#ifdef BASOP_NOGLOB + prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#else + prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#endif + } +#endif FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ @@ -933,6 +944,17 @@ void ivas_wb_tbe_dec_fx( curr_pow = 0; move32(); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + IF( st_fx->element_mode > EVS_MONO ) + { + tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 ); +#ifdef BASOP_NOGLOB + curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/ +#else + curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */ +#endif + } +#endif FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ @@ -1554,6 +1576,17 @@ void wb_tbe_dec_fx( prev_pow = 0; move32(); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + IF( st_fx->element_mode > EVS_MONO ) + { + tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); +#ifdef BASOP_NOGLOB + prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#else + prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#endif + } +#endif FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { #ifdef BASOP_NOGLOB @@ -1588,6 +1621,17 @@ void wb_tbe_dec_fx( curr_pow = 0; move32(); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + IF( st_fx->element_mode > EVS_MONO ) + { + tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 ); +#ifdef BASOP_NOGLOB + curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/ +#else + curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */ +#endif + } +#endif FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { #ifdef BASOP_NOGLOB diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 943fe458b..608d96d19 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -373,6 +373,15 @@ void wb_tbe_enc( prev_pow = sum2_f( shaped_wb_excitation, L_SHB_LAHEAD / 4 ); curr_pow = sum2_f( shaped_wb_excitation + L_SHB_LAHEAD / 4, L_SHB_LAHEAD / 4 ); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + if ( st->element_mode > EVS_MONO ) + { + /* prevent too low values of energy */ + prev_pow = max( 0.00001f, prev_pow ); + curr_pow = max( 0.00001f, curr_pow ); + } +#endif + if ( voice_factors[0] > 0.75f ) { curr_pow = (float) ( curr_pow * 0.25 ); @@ -1050,6 +1059,15 @@ void swb_tbe_enc( prev_pow = sum2_f( shaped_shb_excitation, L_SHB_LAHEAD + 10 ); curr_pow = sum2_f( shaped_shb_excitation + L_SHB_LAHEAD + 10, L_SHB_LAHEAD + 10 ); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + if ( st->element_mode > EVS_MONO ) + { + /* prevent too low values of energy */ + prev_pow = max( 0.00001f, prev_pow ); + curr_pow = max( 0.00001f, curr_pow ); + } +#endif + if ( voice_factors[0] > 0.75f ) { curr_pow = (float) ( curr_pow * 0.25 ); diff --git a/lib_enc/swb_tbe_enc_fx.c b/lib_enc/swb_tbe_enc_fx.c index c86d5c97c..5eb1d275a 100644 --- a/lib_enc/swb_tbe_enc_fx.c +++ b/lib_enc/swb_tbe_enc_fx.c @@ -843,7 +843,18 @@ void wb_tbe_enc_fx( } prev_pow = 0; - move16(); + move32(); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + IF( st_fx->element_mode > EVS_MONO ) + { + tmp = sub( shl( sub( st_fx->prev_Q_bwe_exc, 16 ), 1 ), 31 + 16 ); +#ifdef BASOP_NOGLOB + prev_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#else + prev_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(st_fx->prev_Q_bwe_exc-16))*/ +#endif + } +#endif FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { prev_pow = L_mac0( prev_pow, hBWE_TD->state_syn_shbexc_fx[i], hBWE_TD->state_syn_shbexc_fx[i] ); /* Q(2*st_fx->prev_Q_bwe_exc) */ @@ -871,6 +882,17 @@ void wb_tbe_enc_fx( curr_pow = 0; move16(); +#ifdef NONBE_FIX_1132_THRESHOLD_POW_IN_SWB_TBE + IF( st_fx->element_mode > EVS_MONO ) + { + tmp = sub( shl( Q_bwe_exc_ext, 1 ), 31 + 16 ); +#ifdef BASOP_NOGLOB + curr_pow = L_shl_sat( 1407374848l /*0.00001f Q47*/, tmp ); /*Q(2*(Q_bwe_exc_ext))*/ +#else + curr_pow = L_shl( 1407374848l /*0.00001f Q47*/, tmp ); /* 2*(Q_bwe_exc_ext) */ +#endif + } +#endif FOR( i = 0; i < L_SHB_LAHEAD / 4; i++ ) { curr_pow = L_mac0( curr_pow, shaped_wb_excitation[i + L_SHB_LAHEAD / 4], shaped_wb_excitation[i + L_SHB_LAHEAD / 4] ); /* Q(2*Q_bwe_exc_ext) */ -- GitLab