Commit 3b9fb3d1 authored by norvell's avatar norvell Committed by Sandesh Venkatesh
Browse files

Change FIX_732 to only address noise floor in msPeriodog calculation

parent 9460d05a
Loading
Loading
Loading
Loading
+29 −27
Original line number Diff line number Diff line
@@ -1117,11 +1117,7 @@ Word16 ApplyFdCng_fx(
                        *cngNoiseLevel_exp = hFdCngCom->sidNoiseEstExp;
                        move16();
                    }
#ifdef FIX_732
                    s2 = ( sub( WORD32_BITS, 1 ) );
#else
                    s2 = -( ( WORD32_BITS - 1 ) );
#endif
                    move16();
                    /* Shape the SID noise levels in each FFT bin */
                    j = 0;
@@ -1161,11 +1157,7 @@ Word16 ApplyFdCng_fx(
                            facTabExp[k] = -( ( WORD32_BITS - 1 ) );
                            move16();
                        }
#ifdef FIX_732
                        s2 = s_min( s2, facTabExp[k] );
#else
                        s2 = s_max( s2, facTabExp[k] );
#endif
                    }
                    if ( EQ_16( s2, -31 ) )
                    {
@@ -1178,11 +1170,7 @@ Word16 ApplyFdCng_fx(
                        s = s_max( s_min( s, ( WORD32_BITS - 1 ) ), -( ( WORD32_BITS - 1 ) ) );
                        FOR( ; j <= hFdCngCom->part[k]; j++ )
                        {
#ifdef FIX_732
                            cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#else
                            cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#endif
                            move32();
                        }
                    }
@@ -1220,11 +1208,7 @@ Word16 ApplyFdCng_fx(
            {
                IF( !( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) ) )
                {
#ifdef FIX_732
                    s2 = ( sub( WORD32_BITS, 1 ) );
#else
                    s2 = -( ( WORD32_BITS - 1 ) );
#endif
                    /* Shape the SID noise levels in each FFT bin */
                    j = 0;
                    move16();
@@ -1263,11 +1247,7 @@ Word16 ApplyFdCng_fx(
                            facTabExp[k] = -( WORD32_BITS - 1 );
                            move16();
                        }
#ifdef FIX_732
                        s2 = s_min( s2, facTabExp[k] );
#else
                        s2 = s_max( s2, facTabExp[k] );
#endif
                    }
                    IF( EQ_16( s2, -31 ) )
                    {
@@ -1280,11 +1260,7 @@ Word16 ApplyFdCng_fx(
                        s = s_max( s_min( s, sub( WORD32_BITS, 1 ) ), negate( sub( WORD32_BITS, 1 ) ) );
                        FOR( ; j <= hFdCngCom->part[k]; j++ )
                        {
#ifdef FIX_732
                            cngNoiseLevel[j] = L_shl_sat( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#else
                            cngNoiseLevel[j] = L_shl( Mpy_32_16_1( hFdCngDec->bandNoiseShape[j], facTab[k] ), s ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
#endif
                            move32();
                        }
                    }
@@ -1320,6 +1296,14 @@ Word16 ApplyFdCng_fx(
    }


    dbgwrite( hFdCngDec->bandNoiseShape, sizeof( Word32 ), 320, 1, "bandNoiseShape.int" );
    dbgwrite( &hFdCngDec->bandNoiseShape_exp, sizeof( short ), 1, 1, "bandNoiseShape_exp.short" );

    dbgwrite( cngNoiseLevel, sizeof( Word32 ), 340, 1, "cngNoiseLevel.int" );
    dbgwrite( cngNoiseLevel_exp, sizeof( short ), 1, 1, "cngNoiseLevel_exp.short" );
    dbgwrite( &frame, sizeof( int ), 1, 1, "frame.int" );


    return 0;
}

@@ -1523,6 +1507,9 @@ void perform_noise_estimation_dec_ivas_fx(
    Word32 enr, enr_tot, enr_tot0;
    Word16 enr_e, enr_ratio, alpha;
    Word32 *msPeriodog;
#ifdef FIX_732
    Word32 msPeriodog_floor;
#endif
    Word32 *msNoiseEst;
    Word32 *reIter;
    Word32 rescale_fac = 0;
@@ -1728,10 +1715,18 @@ void perform_noise_estimation_dec_ivas_fx(

                msPeriodog[p] = L_add( msPeriodog[p], L_tmp ); /*Q31 - hFdCngDec->msPeriodog_exp*/
                move32();

#ifdef FIX_732
                msPeriodog_floor = L_max( 1, L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) );
                IF( LT_32( msPeriodog[p], msPeriodog_floor ) )
#else
                IF( LT_32( msPeriodog[p], L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ) ) )
#endif
                {
#ifdef FIX_732
                    msPeriodog[p] = msPeriodog_floor;
#else
                    msPeriodog[p] = L_shr( 21474 /*Q31*/, hFdCngDec->msPeriodog_exp ); /*Q31 - hFdCngDec->msPeriodog_exp*/
#endif
                    move32();
                }
            }
@@ -2105,6 +2100,13 @@ void perform_noise_estimation_dec_ivas_fx(
        /* Expand partitions into bins of power spectrum */
        scalebands_fx( msNoiseEst, part, nFFTpart, hFdCngDec->midband_shaping, nFFTpart, sub( stopFFTbin, startBand ), hFdCngDec->bandNoiseShape, 1 );
        hFdCngDec->bandNoiseShape_exp = hFdCngDec->msNoiseEst_exp;

        dbgwrite( msNoiseEst, sizeof( int ), 62, 1, "msNoiseEst.int" );
        dbgwrite( &hFdCngDec->msNoiseEst_exp, sizeof( short ), 1, 1, "msNoiseEst_exp.short" );
        dbgwrite( msPeriodog, sizeof( int ), 62, 1, "msPeriodog.int" );
        dbgwrite( &hFdCngDec->msPeriodog_exp, sizeof( short ), 1, 1, "msPeriodog_exp.short" );


        move16();
        Copy32( hFdCngDec->bandNoiseShape, &hFdCngDec->smoothed_psd_fx[startBand], sub( stopFFTbin, startBand ) ); /*Q31 - hFdCngDec->bandNoiseShape_exp*/
        hFdCngDec->smoothed_psd_exp = hFdCngDec->bandNoiseShape_exp;