diff --git a/lib_com/options.h b/lib_com/options.h index 76b6649a1f3663ff781241abc3594e0da1224cd9..12a2924643a2f3740388df2358cc9ab663171f23 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,7 +172,8 @@ /* all switches in this category should start with "NONBE_" */ #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 NON-BE switches ########################### */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index cfa34da4a8cf92c607e44a12d65d14d6c33d084d..5f2978157d26f560b47f708c2094955f313b359a 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -328,6 +328,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; @@ -341,6 +350,7 @@ void wb_tbe_dec( { scale = (float) sqrt( curr_pow / prev_pow ); } + for ( i = 0; i < L_SHB_LAHEAD / 4 - 1; i++ ) { shaped_wb_excitation[i] *= scale; @@ -1059,9 +1069,19 @@ void swb_tbe_dec( } mvr2r( shaped_shb_excitationTemp, &shaped_shb_excitation[L_SHB_LAHEAD], L_FRAME16k ); + 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_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 89d31b2be86ae8766709b6812a67656329cdbdcb..8f93f4241e343d21389cba63a053aa9e0ff72bed 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -383,6 +383,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 ); @@ -1060,6 +1069,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 );