From 06ef2a6ebe5f1aafea0d319622aeea41ce79ba45 Mon Sep 17 00:00:00 2001 From: naghibza Date: Thu, 14 Aug 2025 15:37:51 +0200 Subject: [PATCH 1/3] tcx_noise_factor_ivas_fx(): Change internal calculation to 32-bit --- lib_com/options.h | 2 +- lib_enc/tcx_utils_enc_fx.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 596d127d3..0b1ca22d3 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -140,7 +140,7 @@ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ - +#define NONBE_1781_FIX_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ /* #################### End BASOP porting switches ############################ */ #define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index bdf473aab..e7c1e594b 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2509,7 +2509,12 @@ void tcx_noise_factor_ivas_fx( Word16 i, k, win, segmentOffset, j; Word32 sqErrorNrg = 0, n; move32(); +#ifdef NONBE_1781_FIX_SPECTRAL_GAPS + Word32 inv_gain2, tilt_factor; + Word16 inv_gain2_e, nTransWidth_1, exp_sqErrorNrg = 0; +#else Word16 inv_gain2, inv_gain2_e, tilt_factor, nTransWidth_1, exp_sqErrorNrg = 0; +#endif move16(); Word32 accu1, accu2, tmp32; Word16 tmp1, tmp2, s; @@ -2539,13 +2544,25 @@ void tcx_noise_factor_ivas_fx( /* tilt_factor = 1.0f /(float)pow(max(0.375f, tiltCompFactor), 1.0f/(float)L_frame); */ tmp32 = BASOP_Util_Log2( L_deposit_h( s_max( 0x3000, tiltCompFactor ) ) ); /* 6Q25 */ tmp32 = L_shr( Mpy_32_16_1( tmp32, negate( tmp1 ) ), 6 ); +#ifdef NONBE_1781_FIX_SPECTRAL_GAPS + tilt_factor = BASOP_Util_InvLog2( L_sub( tmp32, 0x2000000 ) ); /* 1Q30 */ +#else tilt_factor = round_fx( BASOP_Util_InvLog2( L_sub( tmp32, 0x2000000 ) ) ); /* 1Q14 */ +#endif /* inv_gain2 = 1.0f / ((float)(nTransWidth * nTransWidth) * gain_tcx); */ tmp32 = L_mult( imult1616( nTransWidth, nTransWidth ), gain_tcx ); /* 15Q16 */ +#ifdef NONBE_1781_FIX_SPECTRAL_GAPS + inv_gain2 = BASOP_Util_Divide3232_Scale_newton( MAX_32, tmp32, &inv_gain2_e ); +#else inv_gain2 = BASOP_Util_Divide3232_Scale( MAX_32, tmp32, &inv_gain2_e ); +#endif inv_gain2_e = add( inv_gain2_e, sub( 0, add( 15, gain_tcx_e ) ) ); +#ifdef NONBE_1781_FIX_SPECTRAL_GAPS + inv_gain2 = L_shr( inv_gain2, 2 ); /* 2 bits headroom */ +#else inv_gain2 = shr( inv_gain2, 2 ); /* 2 bits headroom */ +#endif inv_gain2_e = add( inv_gain2_e, 2 ); /* find last nonzero line below iFirstLine, use it as start offset */ @@ -2571,7 +2588,11 @@ void tcx_noise_factor_ivas_fx( /* inv_gain2 *= (float)pow(tilt_factor, (float)i); */ FOR( k = 0; k < i; k++ ) { +#ifdef NONBE_1781_FIX_SPECTRAL_GAPS + inv_gain2 = L_shl( Mpy_32_32( inv_gain2, tilt_factor ), 1 ); +#else inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 ); +#endif } i = add( i, 1 ); @@ -2639,7 +2660,11 @@ void tcx_noise_factor_ivas_fx( FOR( ; i < lowpassLine; i++ ) { +#ifdef NONBE_1781_FIX_SPECTRAL_GAPS + inv_gain2 = L_shl( Mpy_32_32( inv_gain2, tilt_factor ), 1 ); +#else inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 ); +#endif IF( sqQ[i] != 0 ) /* current line is not zero, so reset pointers */ { @@ -2707,8 +2732,12 @@ void tcx_noise_factor_ivas_fx( win = add( win, 1 ); } /* update segment sum: magnitudes scaled by smoothing function */ +#ifdef NONBE_1781_FIX_SPECTRAL_GAPS + sqQ[i] = Mpy_32_32( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 ); +#else sqQ[i] = Mpy_32_16_1( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 ); move32(); +#endif exp_spQ[i] = add( x_orig_e, inv_gain2_e ); move16(); } -- GitLab From d8922680dd50454f32b84705ba8359b38522269d Mon Sep 17 00:00:00 2001 From: naghibza Date: Fri, 15 Aug 2025 12:02:13 +0200 Subject: [PATCH 2/3] Move patch macro within options.h and rename it. --- lib_com/options.h | 3 +-- lib_enc/tcx_utils_enc_fx.c | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 090d80aec..c2cbd71a5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -96,7 +96,7 @@ #define FIX_ISSUE_1764 /* NTT: update renorm and use abs */ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define FIX_1844_MISSING_FREE /* FhG: add missing free in ivas_binRenderer_convModuleClose_fx() */ - +#define FIX_1781_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ /* #################### Start BASOP porting switches ############################ */ #define FIX_1372_ISAR_POST_REND @@ -141,7 +141,6 @@ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ -#define NONBE_1781_FIX_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ /* #################### End BASOP porting switches ############################ */ #define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index e7c1e594b..90c8bc554 100644 --- a/lib_enc/tcx_utils_enc_fx.c +++ b/lib_enc/tcx_utils_enc_fx.c @@ -2509,7 +2509,7 @@ void tcx_noise_factor_ivas_fx( Word16 i, k, win, segmentOffset, j; Word32 sqErrorNrg = 0, n; move32(); -#ifdef NONBE_1781_FIX_SPECTRAL_GAPS +#ifdef FIX_1781_SPECTRAL_GAPS Word32 inv_gain2, tilt_factor; Word16 inv_gain2_e, nTransWidth_1, exp_sqErrorNrg = 0; #else @@ -2544,7 +2544,7 @@ void tcx_noise_factor_ivas_fx( /* tilt_factor = 1.0f /(float)pow(max(0.375f, tiltCompFactor), 1.0f/(float)L_frame); */ tmp32 = BASOP_Util_Log2( L_deposit_h( s_max( 0x3000, tiltCompFactor ) ) ); /* 6Q25 */ tmp32 = L_shr( Mpy_32_16_1( tmp32, negate( tmp1 ) ), 6 ); -#ifdef NONBE_1781_FIX_SPECTRAL_GAPS +#ifdef FIX_1781_SPECTRAL_GAPS tilt_factor = BASOP_Util_InvLog2( L_sub( tmp32, 0x2000000 ) ); /* 1Q30 */ #else tilt_factor = round_fx( BASOP_Util_InvLog2( L_sub( tmp32, 0x2000000 ) ) ); /* 1Q14 */ @@ -2552,13 +2552,13 @@ void tcx_noise_factor_ivas_fx( /* inv_gain2 = 1.0f / ((float)(nTransWidth * nTransWidth) * gain_tcx); */ tmp32 = L_mult( imult1616( nTransWidth, nTransWidth ), gain_tcx ); /* 15Q16 */ -#ifdef NONBE_1781_FIX_SPECTRAL_GAPS +#ifdef FIX_1781_SPECTRAL_GAPS inv_gain2 = BASOP_Util_Divide3232_Scale_newton( MAX_32, tmp32, &inv_gain2_e ); #else inv_gain2 = BASOP_Util_Divide3232_Scale( MAX_32, tmp32, &inv_gain2_e ); #endif inv_gain2_e = add( inv_gain2_e, sub( 0, add( 15, gain_tcx_e ) ) ); -#ifdef NONBE_1781_FIX_SPECTRAL_GAPS +#ifdef FIX_1781_SPECTRAL_GAPS inv_gain2 = L_shr( inv_gain2, 2 ); /* 2 bits headroom */ #else inv_gain2 = shr( inv_gain2, 2 ); /* 2 bits headroom */ @@ -2588,7 +2588,7 @@ void tcx_noise_factor_ivas_fx( /* inv_gain2 *= (float)pow(tilt_factor, (float)i); */ FOR( k = 0; k < i; k++ ) { -#ifdef NONBE_1781_FIX_SPECTRAL_GAPS +#ifdef FIX_1781_SPECTRAL_GAPS inv_gain2 = L_shl( Mpy_32_32( inv_gain2, tilt_factor ), 1 ); #else inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 ); @@ -2660,7 +2660,7 @@ void tcx_noise_factor_ivas_fx( FOR( ; i < lowpassLine; i++ ) { -#ifdef NONBE_1781_FIX_SPECTRAL_GAPS +#ifdef FIX_1781_SPECTRAL_GAPS inv_gain2 = L_shl( Mpy_32_32( inv_gain2, tilt_factor ), 1 ); #else inv_gain2 = shl( mult( inv_gain2, tilt_factor ), 1 ); @@ -2732,7 +2732,7 @@ void tcx_noise_factor_ivas_fx( win = add( win, 1 ); } /* update segment sum: magnitudes scaled by smoothing function */ -#ifdef NONBE_1781_FIX_SPECTRAL_GAPS +#ifdef FIX_1781_SPECTRAL_GAPS sqQ[i] = Mpy_32_32( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 ); #else sqQ[i] = Mpy_32_16_1( imult3216( L_abs( x_orig[i] ), win ), inv_gain2 ); -- GitLab From dd113bd95492df1a1097bc0880dfe61eeeeefad1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Tue, 19 Aug 2025 19:14:42 +0200 Subject: [PATCH 3/3] fix remaining merge conflict --- lib_com/options.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3873ae429..fbfe61d36 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -128,16 +128,12 @@ #define NONBE_FIX_1141_OSBA_ROOM_RENDERING /* FhG: Fix for issue 1141: render objects in OSBA decoder with room effect */ #define NONBE_1360_LFE_DELAY /* Dlb: LFE delay alignment when rendering in CLDFB domain*/ #define NONBE_1229_FIX_ISM1_DPID /* Eri: issue 1229: fix bug causing ISM 1 to use default -dpid instead of the specified one */ -<<<<<<< HEAD -#define NONBE_SVD_OPTIMIZATION -======= #define NONBE_SVD_OPTIMIZATION #define NONBE_FIX_1176_OSBA_REVERB_JBM_ASAN_ERROR /* Ericsson: Issue 1176, fix in TDREND_firfilt for subframes shorter than the filter length */ #define NONBE_1131_ACELP_OOB /* VA: issue 1131: fix division-by-zero in acelp gain decoding caused by wrong length of buffer update when switching from HQ core to ACELP core */ #define NONBE_1240_FIX_CORE_SELECTION_ISM_SW /* VA: issue 1240: Remove the forcing of the TCX core in ISM when switching from a high bitarte to a low one */ #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 */ ->>>>>>> main /* #################### End BASOP porting switches ############################ */ -- GitLab