diff --git a/lib_com/options.h b/lib_com/options.h index 3949dd4672616c6d0b27bf2d55067bfcad8cf124..fbfe61d36dd31f9b2d934c175675fd011eb6e1fc 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -82,6 +82,8 @@ #define FIX_ISSUE_1817_REPLACE_CARRY_OVERFLOW /* FhG: bit-exact, replace carry and overflow operations by 64-bit operations, MR 1931 */ #define NONBE_SVD_OPTIMIZATION /* FhG: reduce WMOPS of HouseHolderReduction() in ivas_svd_dec.c() by removing redundant mathematics and using 64 bit additions */ #define FIX_1766_TCX2ACELP_BWE_ISSUE /* VA : Fix rare BWE issue when switching from TCX to ACELP */ +#define FIX_1781_SPECTRAL_GAPS /* FhG: Change internal calculation of tcx_noise_factor_ivas_fx() to 32-bit*/ + /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_enc/tcx_utils_enc_fx.c b/lib_enc/tcx_utils_enc_fx.c index 0face2cf4eb254777bff6d0c03dd7a820e00bbb3..a6e0a3e8010af8eb43edf77efa003edd86bf9ec8 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 FIX_1781_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 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 */ +#endif /* inv_gain2 = 1.0f / ((float)(nTransWidth * nTransWidth) * gain_tcx); */ tmp32 = L_mult( imult1616( nTransWidth, nTransWidth ), gain_tcx ); /* 15Q16 */ +#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 FIX_1781_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 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 ); +#endif } i = add( i, 1 ); @@ -2639,7 +2660,11 @@ void tcx_noise_factor_ivas_fx( FOR( ; i < lowpassLine; i++ ) { +#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 ); +#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 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 ); move32(); +#endif exp_spQ[i] = add( x_orig_e, inv_gain2_e ); move16(); }