From bad7de3e2f3480b124b9600e61c0368f00ddc128 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 27 Aug 2025 17:11:12 +0200 Subject: [PATCH 1/4] fix within NONBE_1328_FIX_NON_LINEARITY --- lib_com/swb_tbe_com_fx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index b128e02ad..e58914aa1 100755 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6123,12 +6123,14 @@ 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 */ + /* sc_factor = 32; */ /* Here we divide 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 ); + sc_factor = shl_sat( 1, sub( 16, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ + sc_factor = s_min( sc_factor, 32768 ); + test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) #else test(); @@ -6218,13 +6220,13 @@ void non_linearity_ivas_fx( move32(); /* Q31; 0.67 in Q31 */ } - 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 */ + /* sc_factor = 32; */ /* Here we divide 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 ); + sc_factor = shl_sat( 1, sub( 16, max( 12 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ + sc_factor = s_min( sc_factor, 32768 ); + test(); 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 ) ) -- GitLab From 21e183efb6a06c0116a4088f25e2de50ab6e6785 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 27 Aug 2025 17:36:43 +0200 Subject: [PATCH 2/4] fix --- lib_com/swb_tbe_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index e58914aa1..0b859bd18 100755 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6128,7 +6128,7 @@ void non_linearity_ivas_fx( /* sc_factor = 32; */ /* Here we divide 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( 16, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_min( sc_factor, 32768 ); + sc_factor = s_min( sc_factor, 2 * 32 ); test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) @@ -6224,7 +6224,7 @@ void non_linearity_ivas_fx( /* sc_factor = 32; */ /* Here we divide 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( 16, max( 12 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_min( sc_factor, 32768 ); + sc_factor = s_min( sc_factor, 2 * 32 ); test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) -- GitLab From 70dd727a5faa22d6d9effea133cd37c38ad02231 Mon Sep 17 00:00:00 2001 From: Tommy Vaillancourt Date: Thu, 28 Aug 2025 07:12:29 -0400 Subject: [PATCH 3/4] corretion to threshold --- lib_com/swb_tbe_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index 0b859bd18..c1646e4fc 100755 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6128,7 +6128,7 @@ void non_linearity_ivas_fx( /* sc_factor = 32; */ /* Here we divide 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( 16, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_min( sc_factor, 2 * 32 ); + sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 ); test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) @@ -6224,7 +6224,7 @@ void non_linearity_ivas_fx( /* sc_factor = 32; */ /* Here we divide 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( 16, max( 12 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_min( sc_factor, 2 * 32 ); + sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 ); test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) -- GitLab From 33ba909e4f6594c67bb23c45300cc4a43b69bd26 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 4 Sep 2025 13:02:30 +0200 Subject: [PATCH 4/4] add comment about the thresholds being different between float and BASOP --- lib_com/swb_tbe_com_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/swb_tbe_com_fx.c b/lib_com/swb_tbe_com_fx.c index c1646e4fc..6f5d2a4f0 100755 --- a/lib_com/swb_tbe_com_fx.c +++ b/lib_com/swb_tbe_com_fx.c @@ -6128,7 +6128,7 @@ void non_linearity_ivas_fx( /* sc_factor = 32; */ /* Here we divide 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( 16, max( 13 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 ); + sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 ); /* note: The thresholding is purposely different between float and BASOP implementations. */ test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) @@ -6224,7 +6224,7 @@ void non_linearity_ivas_fx( /* sc_factor = 32; */ /* Here we divide 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( 16, max( 12 - norm_s( add( j, 1 ) ), 0 ) ) ); /* Adapt the scaling factor allowed depending of max position */ - sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 ); + sc_factor = s_max( s_min( sc_factor, 16384 ), 2 * 32 ); /* note: The thresholding is purposely different between float and BASOP implementations. */ test(); IF( prev_scale <= 0 || GT_32( Mult_32_16( prev_scale, sc_factor ) /*Q30 -> Q31*/, scale /*Q31*/ ) ) -- GitLab