From cddcc89fc1d4295f6abfc66e23df2fb06b028041 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 20 Aug 2025 11:43:12 -0400 Subject: [PATCH 1/2] porting MR2133 --- lib_com/options.h | 2 ++ lib_com/swb_tbe_com_fx.c | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 031644459..614e3f3e5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -139,6 +139,8 @@ #define FIX_1101_CLEANING_JBM_CALL /* VA: issue 1101: remove obsolete call of ivas_jbm_dec_tc_buffer_open() */ #define NONBE_FIX_1337_MISSING_DIRECTIVITY_DISTATT_EXTREND /* Eri: issue 1337: Missing directivity setting and distance attenuation in external renderer IVAS_rend */ +#define NONBE_1328_FIX_NON_LINEARITY /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328 */ + /* #################### End BASOP porting switches ############################ */ #endif diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 8e773ffd9..4de20bb99 100755 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6061,7 +6061,9 @@ void non_linearity_ivas_fx( move32(); #endif #endif - +#ifdef NONBE_1328_FIX_NON_LINEARITY + Word16 sc_factor; +#endif IF( EQ_16( L_frame, L_FRAME16k ) ) { @@ -6121,9 +6123,17 @@ void non_linearity_ivas_fx( scale = 1438814044; move32(); /* Q31; 0.67 in Q31 */ } +#ifdef NONBE_1328_FIX_NON_LINEARITY + /* sc_factor = 32; */ /* Here we divise prev_scale, so 32 == 2 << (15-10) 1024.0 corresponds to 10 bits and 32 to 5 bits */ + /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ + sc_factor = shl_sat( 1, sub( 15, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ + sc_factor = s_min( sc_factor, 16384 ); + IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) +#else test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 64 ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) +#endif { scale_step = 16384; move16(); /* Q14 */ @@ -6209,7 +6219,16 @@ void non_linearity_ivas_fx( } test(); +#ifdef NONBE_1328_FIX_NON_LINEARITY + /* sc_factor = 32; */ /* Here we divise prev_scale, so 32 == 2 << (15-10) 1024.0 corresponds to 10 bits and 32 to 5 bits */ + /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ + sc_factor = shl_sat( 1, sub( 15, max( 12 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ + sc_factor = s_min( sc_factor, 16384 ); + + IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) +#else IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, 64 ), scale ) ) +#endif { scale_step = 16384; move16(); /*Q14 */ -- GitLab From f87d806f69f937340839133faed5dbab8dc297a9 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Wed, 20 Aug 2025 11:52:27 -0400 Subject: [PATCH 2/2] fix clang --- lib_com/swb_tbe_com_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 4de20bb99..0931e418b 100755 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6124,8 +6124,8 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } #ifdef NONBE_1328_FIX_NON_LINEARITY - /* sc_factor = 32; */ /* Here we divise prev_scale, so 32 == 2 << (15-10) 1024.0 corresponds to 10 bits and 32 to 5 bits */ - /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ + /* sc_factor = 32; */ /* Here we divise prev_scale, so 32 == 2 << (15-10) 1024.0 corresponds to 10 bits and 32 to 5 bits */ + /* if ( element_mode > EVS_MONO ) */ /* element mode is not needed because the function is duplicated for IVAS */ sc_factor = shl_sat( 1, sub( 15, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ sc_factor = s_min( sc_factor, 16384 ); @@ -6172,7 +6172,7 @@ void non_linearity_ivas_fx( #ifdef ISSUE_1836_replace_overflow_libcom L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ //??sat #else - L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ + L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /* Q(16+29-exp+1-16+exp-14)->Q16 */ #endif frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ @@ -6181,7 +6181,7 @@ void non_linearity_ivas_fx( #ifdef ISSUE_1836_replace_overflow_libcom scale_step = shl_sat( tmp, exp ); /* Q14 */ //??sat #else - scale_step = shl_o( tmp, exp, &Overflow ); /* Q14 */ + scale_step = shl_o( tmp, exp, &Overflow ); /* Q14 */ #endif } } @@ -6209,7 +6209,7 @@ void non_linearity_ivas_fx( #ifdef ISSUE_1836_replace_overflow_libcom scale = L_shl_sat( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ) ); /* Q31 */ //??sat #else - scale = L_shl_o( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ), &Overflow ); /* Q31 */ + scale = L_shl_o( L_mult( 21955, tmp ), add( exp, sub( Q_inp, 14 ) ), &Overflow ); /* Q31 */ #endif } ELSE @@ -6271,7 +6271,7 @@ void non_linearity_ivas_fx( #ifdef ISSUE_1836_replace_overflow_libcom L_tmp = L_shl_sat( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ) ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ //??sat #else - L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ + L_tmp = L_shl_o( Mult_32_16( L_tmp, tmp ), sub( exp, 14 ), &Overflow ); /*Q(16+29-exp+1-16+exp-14)->Q16 */ #endif frac = L_Extract_lc( L_tmp, &exp ); /* Extract exponent of L_tmp */ @@ -6280,7 +6280,7 @@ void non_linearity_ivas_fx( #ifdef ISSUE_1836_replace_overflow_libcom scale_step = shl_sat( tmp, exp ); /*Q14 */ //??sat #else - scale_step = shl_o( tmp, exp, &Overflow ); /*Q14 */ + scale_step = shl_o( tmp, exp, &Overflow ); /*Q14 */ #endif } } -- GitLab