Commit 06ef2a6e authored by Mohammadreza Naghibzadeh's avatar Mohammadreza Naghibzadeh
Browse files

tcx_noise_factor_ivas_fx(): Change internal calculation to 32-bit

parent a90c34d3
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 */
+29 −0
Original line number Diff line number Diff line
@@ -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();
        }