Commit e721745e authored by Fabian Bauer's avatar Fabian Bauer
Browse files

cleanup a bit

parent f7943249
Loading
Loading
Loading
Loading
Loading
+2 −94
Original line number Diff line number Diff line
@@ -1748,7 +1748,6 @@ void minimum_statistics_fx(
    Word16 msPeriodogSum16;
    Word16 msNoiseFloor16_scalar;

#ifdef FIX_2485_HARMONIZE_minimum_statistics
    Word32 *msNoiseFloor_buffer32 = (Word32 *) msNoiseFloor_buffer;
    Word16 *msNoiseFloor_buffer16 = (Word16 *) msNoiseFloor_buffer;
    Word32 *msNoiseEst_buffer32 = (Word32 *) msNoiseEst_buffer;
@@ -1759,7 +1758,6 @@ void minimum_statistics_fx(
    {
        (void) enc_dec;
    }
#endif

    len2 = i_mult( MSNUMSUBFR, len );

@@ -1779,7 +1777,6 @@ void minimum_statistics_fx(
    /* No minimum statistics at initialization */
    IF( LT_16( hFdCngCom->msFrCnt_init_counter, hFdCngCom->msFrCnt_init_thresh ) )
    {
#ifdef FIX_2485_HARMONIZE_minimum_statistics
        Copy( msPeriodog, msPsd, len );            /* 6Q9 */
        Copy( msPeriodog, msPsdFirstMoment, len ); /* 6Q9 */
        IF( isIVAS == 0 )
@@ -1793,12 +1790,6 @@ void minimum_statistics_fx(
            Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseFloor_buffer32, len, Q16 ); /* Q25 */
            Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseEst_buffer32, len, Q16 );   /* Q25 */
        }
#else
        Copy( msPeriodog, msPsd, len );                                           /* 6Q9 */
        Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseFloor_buffer, len, Q16 ); /* Q25 */
        Copy_Scale_sig_16_32_no_sat( msPeriodog, msNoiseEst_buffer, len, Q16 );   /* Q25 */
        Copy( msPeriodog, msPsdFirstMoment, len );                                /* 6Q9 */
#endif

        set32_fx( msPsdSecondMoment, 0l /*0.0 Q31*/, len );
        msPeriodogSum[0] = dotp_s_fx( msPeriodog, psize, lenFFT, CNG_HS );
@@ -1860,11 +1851,7 @@ void minimum_statistics_fx(
            {
                /* calculate scalar with normalized msPeriodogSum[cnt], exponent -2*s1 */
                s1 = norm_l( msPeriodogSum[cnt] );
#ifdef FIX_2485_HARMONIZE_minimum_statistics
                msPeriodogSum16 = round_fx_sat( L_shl_sat( msPeriodogSum[cnt], s1 ) );
#else
                msPeriodogSum16 = round_fx_sat( L_shl( msPeriodogSum[cnt], s1 ) );
#endif
                scalar = L_mult( msPeriodogSum16, msPeriodogSum16 );

                /* calculate difference, both elements in 16Q15 format, use absolute value
@@ -1905,13 +1892,8 @@ void minimum_statistics_fx(
                scalar16 = shl( scalar16, s3 );
                scalar16 = s_max( scalar16, MSALPHACORMAX );

#ifdef FIX_2485_HARMONIZE_minimum_statistics
                hFdCngCom->msAlphaCor[cnt] = L_add( Mpy_32_16_1( hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha ),
                                                    L_mult( scalar16, msAlphaCorAlpha2 ) );
#else
                hFdCngCom->msAlphaCor[cnt] = Madd_32_16( L_mult( scalar16, msAlphaCorAlpha2 ), hFdCngCom->msAlphaCor[cnt], msAlphaCorAlpha );
#endif

                move32();
            }

@@ -1919,7 +1901,6 @@ void minimum_statistics_fx(

            /* msPeriodogSum[cnt] with format 16Q15 */
            Word16 msNoiseFloor16tmp[NPART_SHAPING];
#ifdef FIX_2485_HARMONIZE_minimum_statistics
            IF( isIVAS == 0 )
            {
                snr = dotp_s_fx( msNoiseFloor_buffer16 + start, psize + start, current_len, CNG_HS );
@@ -1936,17 +1917,6 @@ void minimum_statistics_fx(
                }
                snr = dotp_s_fx( &msNoiseFloor16tmp[start], psize + start, current_len, CNG_HS );
            }
#else
            IF( enc_dec == ENC )
            {
                Copy_Scale_sig32_16( msNoiseFloor_buffer, msNoiseFloor16tmp, NPART, 0 );
            }
            ELSE
            {
                Copy_Scale_sig32_16( msNoiseFloor_buffer, msNoiseFloor16tmp, NPART_SHAPING, 0 );
            }
            snr = dotp_s_fx( &msNoiseFloor16tmp[start], psize + start, current_len, CNG_HS );
#endif

            IF( GT_32( L_shr( Mpy_32_16_1( msPsdSum[cnt], 18431 /*0.56246299817 Q15*/ ), 13 ), snr ) )
            {
@@ -1967,14 +1937,10 @@ void minimum_statistics_fx(
            {
                /* Compute optimal smoothing parameter for PSD estimation */
                test();
#ifdef FIX_2485_HARMONIZE_minimum_statistics
                test();
                test();
                test();
                IF( ( scalar == 0 ) || ( ( isIVAS == 0 ) ? ( msNoiseFloor_buffer16[j] == 0 ) : ( msNoiseFloor_buffer32[j] == 0 ) ) )
#else
                IF( ( scalar == 0 ) || ( msNoiseFloor_buffer[j] == 0 ) )
#endif
                {
                    msAlpha[j] = msAlphaHatMin2;
                    move32();
@@ -1984,7 +1950,7 @@ void minimum_statistics_fx(
                    /* calculate scalar2 with normalized msNoiseFloor[j], exponent -2*s1 */
                    s1 = WORD16_BITS - 1;
                    move16();
#ifdef FIX_2485_HARMONIZE_minimum_statistics

                    IF( isIVAS == 0 )
                    {
                        if ( msNoiseFloor_buffer16[j] != 0 )
@@ -2011,18 +1977,7 @@ void minimum_statistics_fx(
                           to avoid -1.0 x -1.0 multiplications later */
                        scalar316 = abs_s( sub( msPsd[j], msNoiseFloor16tmp[j] ) );
                    }
#else
                    if ( msNoiseFloor16tmp[j] != 0 )
                    {
                        s1 = norm_s( msNoiseFloor16tmp[j] );
                    }
                    msNoiseFloor16_scalar = shl( msNoiseFloor16tmp[j], s1 );
                    scalar2 = L_mult( msNoiseFloor16_scalar, msNoiseFloor16_scalar );

                    /* calculate difference, both elements in 6Q9 format, use absolute value
                       to avoid -1.0 x -1.0 multiplications later */
                    scalar316 = abs_s( sub( msPsd[j], msNoiseFloor16tmp[j] ) );
#endif
                    s2 = WORD16_BITS - 1;
                    move16();
                    if ( scalar316 != 0 )
@@ -2060,13 +2015,8 @@ void minimum_statistics_fx(
                }

                /* Compute the PSD (smoothed periodogram) in each band */
#ifdef FIX_2485_HARMONIZE_minimum_statistics
                msPsd[j] = round_fx( L_add( Mpy_32_16_1( msAlpha[j], msPsd[j] ),
                                            Mpy_32_16_1( L_sub( 2147483647l, msAlpha[j] ), msPeriodog[j] ) ) );
#else
                msPsd[j] = round_fx( Madd_32_16( Mpy_32_16_1( msAlpha[j], msPsd[j] ), L_sub( 2147483647l /*1.0 Q31*/, msAlpha[j] ), msPeriodog[j] ) );
#endif

                move16();
            }
            msPsdSum[cnt] = dotp_s_fx( msPsd + start, psize + start, current_len, CNG_HS );
@@ -2124,15 +2074,10 @@ void minimum_statistics_fx(
                /* Compute inverse of amount of degrees of freedom */
                QeqInv = MSQEQINVMAX;
                move16();
#ifdef FIX_2485_HARMONIZE_minimum_statistics
                test();
                test();
                IF( ( isIVAS == 0 ) ? ( msNoiseFloor_buffer16[j] != 0 ) : ( msNoiseFloor_buffer32[j] != 0 ) )
#else
                IF( msNoiseFloor_buffer[j] != 0 /*0.0 Q15*/ )
#endif
                {
#ifdef FIX_2485_HARMONIZE_minimum_statistics
                    IF( isIVAS == 0 )
                    {
                        tmp = L_mult( msNoiseFloor_buffer16[j], msNoiseFloor_buffer16[j] );
@@ -2141,9 +2086,7 @@ void minimum_statistics_fx(
                    {
                        tmp = Mpy_32_32( msNoiseFloor_buffer32[j], msNoiseFloor_buffer32[j] );
                    }
#else
                    tmp = Mpy_32_32( msNoiseFloor_buffer[j], msNoiseFloor_buffer[j] );
#endif

                    tmp16 = BASOP_Util_Divide3232_uu_1616_Scale( msPsdSecondMoment[j], tmp, &s );
                    /* consider factor of 2 */
                    s = s_min( s_max( sub( s, 1 ), -( WORD16_BITS - 1 ) ), ( WORD16_BITS - 1 ) );
@@ -2254,7 +2197,6 @@ void minimum_statistics_fx(
                }
            }
            /* Get the current noise floor */
#ifdef FIX_2485_HARMONIZE_minimum_statistics
            IF( isIVAS == 0 )
            {
                Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor_buffer16, len, -16 );
@@ -2263,9 +2205,6 @@ void minimum_statistics_fx(
            {
                Copy32( msCurrentMinOut, msNoiseFloor_buffer32, len );
            }
#else
            Copy32( msCurrentMinOut, msNoiseFloor_buffer, len );
#endif
        }
        ELSE /* sub window complete */
        {
@@ -2323,7 +2262,6 @@ void minimum_statistics_fx(
                set32_fx( msCurrentMin, 2147483647l /*1.0 Q31*/, len );

                /* Get the current noise floor */
#ifdef FIX_2485_HARMONIZE_minimum_statistics
                IF( isIVAS == 0 )
                {
                    Copy_Scale_sig_32_16( msCurrentMinOut, msNoiseFloor_buffer16, len, -16 );
@@ -2332,9 +2270,6 @@ void minimum_statistics_fx(
                {
                    Copy32( msCurrentMinOut, msNoiseFloor_buffer32, len );
                }
#else
                Copy32( msCurrentMinOut, msNoiseFloor_buffer, len );
#endif
            }
        }

@@ -2393,7 +2328,6 @@ void minimum_statistics_fx(
        }

        /* Smooth noise estimate during CNG phases */
#ifdef FIX_2485_HARMONIZE_minimum_statistics
        IF( isIVAS == 0 )
        {
            FOR( j = 0; j < len; j++ )
@@ -2412,18 +2346,8 @@ void minimum_statistics_fx(
                move32();
            }
        }
#else
        Word64 tmp64;
        FOR( j = 0; j < len; j++ )
        {
            tmp64 = W_add( W_mult_32_16( msNoiseEst_buffer[j], 31130 /*0.95 Q15*/ ), W_mult_32_16( msNoiseFloor_buffer[j], 1638 /*0.05 Q15*/ ) );
            msNoiseEst_buffer[j] = W_extract_h( W_shl( tmp64, 16 ) ); // Q25
            move32();
        }
#endif
    }

#ifdef FIX_2485_HARMONIZE_minimum_statistics
    IF( isIVAS > 0 )
    {
        IF( EQ_16( enc_dec, DEC ) && EQ_16( element_mode, IVAS_CPE_TD ) )
@@ -2432,13 +2356,6 @@ void minimum_statistics_fx(
            v_multc_att32( msNoiseEst_buffer32, 23142, msNoiseEst_buffer32, NPART_SHAPING );
        }
    }
#else
    IF( EQ_16( enc_dec, DEC ) && EQ_16( element_mode, IVAS_CPE_TD ) )
    {
        // v_multc(msNoiseEst, 1.4125f, msNoiseEst, NPART_SHAPING);
        v_multc_att32( msNoiseEst_buffer, 23142, msNoiseEst_buffer, NPART_SHAPING );
    }
#endif
    /* Collect buffers */
    Copy( msPeriodog, msPeriodogBuf + len * ( *msPeriodogBufPtr ), len );

@@ -2459,7 +2376,6 @@ void minimum_statistics_fx(
        {
            scalar = L_mac( scalar, msPeriodogBuf[i], 6554 /*1.0/MSBUFLEN Q15*/ );
        }
#ifdef FIX_2485_HARMONIZE_minimum_statistics
        IF( isIVAS == 0 )
        {
            scalar16 = round_fx( scalar );
@@ -2478,14 +2394,6 @@ void minimum_statistics_fx(
            }
        }
        assert( ( ( isIVAS == 0 ) ? ( msNoiseEst_buffer16[j] >= 0 ) : ( msNoiseEst_buffer32[j] >= 0 ) ) );
#else
        if ( GT_32( msNoiseEst_buffer[j], scalar ) /*0.0 Q15*/ )
        {
            msNoiseEst_buffer[j] = scalar;
            move32();
        }
        assert( msNoiseEst[j] >= 0 );
#endif
    }
}