From e2ec095f562c706e72331902ab362bcf37106642 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 12 Aug 2024 09:47:45 -0400 Subject: [PATCH 1/2] propsed fix to 846 --- lib_com/options.h | 1 + lib_com/swb_bwe_com_fx.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 4abd6c6cc..5bba8b46a 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 399106de3..c6c2debdd 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++ ) -- GitLab From 8c66d656d6ec3b8f5102c644a795d2159b5c47a1 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Mon, 12 Aug 2024 09:53:23 -0400 Subject: [PATCH 2/2] fix clang_format and linux compiler warning --- lib_com/swb_bwe_com_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_com/swb_bwe_com_fx.c b/lib_com/swb_bwe_com_fx.c index c6c2debdd..181bc2e1a 100644 --- a/lib_com/swb_bwe_com_fx.c +++ b/lib_com/swb_bwe_com_fx.c @@ -783,14 +783,14 @@ Word16 ivas_calc_tilt_bwe_fx( /* o : Tilt in Q24 */ } #else /* Divide Frame Length by 32 */ - Word64 W_ener; + Word64 W_ener; W_ener = Mpy_32_32( *ptr, *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++; + 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 */ -- GitLab