diff --git a/lib_com/options.h b/lib_com/options.h index 4abd6c6ccd97341e59d097fbe0e7108108209d99..5bba8b46a03edae4e48a387eb7d32d36d7b683a7 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define NONE_BE_FIX_816_LFE_PLC_FLOAT /* DLB: issue 816: reduce required precision to float for LFE-PLC*/ #define FIX_844_Q_SYN_INIT /* VA : proposed fix to 844, initializing q_old_synth when switching to MDCT*/ #define FIX_839_FB_CONTENT_SOMETIME_MISSING /* VA : Fix scaling error for FB TB BWE */ +#define FIX_846_TILT_BWE /* VA : Proposed fix to 846, to solve saturation */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index 399106de3d169e21efa89c76671726fe9aeca287..181bc2e1ad0826e4c18549a2456b96467347e6de 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -765,7 +765,7 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ ptr = sp; L_ener_tot = L_deposit_l( 1 ); - +#ifndef FIX_846_TILT_BWE /* Divide Frame Length by 32 */ FOR( j = shr( N, 5 ); j > 0; j-- ) { @@ -781,6 +781,21 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ L_ener_tot = L_add( L_ener_tot, L_ener ); } +#else + /* Divide Frame Length by 32 */ + Word64 W_ener; + W_ener = Mpy_32_32( *ptr, *ptr ); + ptr++; + FOR( j = 1; j < N; j++ ) + { + /* With the shift by 4 and the L_mult0, no overflow possible for 32 samples */ + W_ener = W_mac_32_32( W_ener, *ptr, *ptr ); + ptr++; + } + L_ener_tot = W_round64_L( W_ener ); + L_ener_tot = L_max( L_ener_tot, 1 ); /* L_ener_tot is energy, it is always positive, but have to be > 0 for the following division */ + +#endif L_ener = L_abs( L_sub( sp[1], sp[0] ) ); FOR( i = 2; i < N; i++ )