Commit 3e182c04 authored by Nishant S Kulgod's avatar Nishant S Kulgod
Browse files

commit 1

parent c521a983
Loading
Loading
Loading
Loading
Loading
+114 −92

File changed.

Preview size limit exceeded, changes collapsed.

+180 −144

File changed.

Preview size limit exceeded, changes collapsed.

+10 −10
Original line number Diff line number Diff line
@@ -37,17 +37,18 @@ Word16 Damping_fact_fx( /* o : damping factor
    Word32 gain32;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif


    IF( core == ACELP_CORE )
    IF( EQ_16( core, ACELP_CORE ) )
    {
        alpha = mult_r( _ALPHA_VT_FX, 16384 ); /* rapid convergence to 0 */ /*Q14*/
        test();
        test();
        test(); /*ELSEIF*/
        test();
        test();                                                               /*ELSEIF*/
        test();
        test();
        IF( ( EQ_16( coder_type, UNVOICED ) ) && ( LE_16( nbLostCmpt, 3 ) ) ) /* Clear unvoiced last good frame   */
        {
            alpha = mult_r( _ALPHA_UU_FX, 16384 ); /*Q14*/
@@ -78,15 +79,15 @@ Word16 Damping_fact_fx( /* o : damping factor
        {
            alpha = 13107 /*0.8f Q14*/; /*Q14*/
        }
        ELSE if ( ( ( EQ_16( last_good, VOICED_CLAS ) ) || ( EQ_16( last_good, ONSET ) ) ) && ( LE_16( nbLostCmpt, 3 ) ) )
        ELSE IF( ( ( EQ_16( last_good, VOICED_CLAS ) ) || ( EQ_16( last_good, ONSET ) ) ) && ( LE_16( nbLostCmpt, 3 ) ) )
        {
            alpha = mult_r( _ALPHA_V_FX, 16384 ); /* constant for the first 3 erased frames */
        }

        IF( GE_16( last_good, VOICED_CLAS ) )
        {
            move16();
            lp_tmp = *lp_gainp;
            move32();

            IF( EQ_16( nbLostCmpt, 1 ) ) /* if first erased frame in a block, reset harmonic gain */
            {
@@ -95,7 +96,6 @@ Word16 Damping_fact_fx( /* o : damping factor
                /*gain = (float)sqrt( *lp_gainp );*/ /* move pitch gain towards 1 for voiced to remove energy fluctuations */
                /*BASOP_Util_Sqrt_MantExp(lp_gainp,&lp_gainp_E);*/
                s_gainp = 31 - 29;
                move16();
                gain32 = Sqrt32( lp_tmp, &s_gainp );

#ifdef BASOP_NOGLOB
@@ -114,22 +114,22 @@ Word16 Damping_fact_fx( /* o : damping factor
            }
            ELSE
            {
                /*0.7 + 0.2*stab_fac*/ move16();
                /*0.7 + 0.2*stab_fac*/
                lp_tmp = Mpy_32_16_1( lp_tmp, mac_r( 1503238528l /*0.7f Q31*/, 6554 /*0.2f Q15*/, stab_fac ) ); /*2Q29*/
                alpha = round_fx( L_shl( lp_tmp, 1 ) );                                                         /*1Q14*/
            }
            move16();
            *lp_gainp = lp_tmp; /*store*/
            move32();
        }
    }
    ELSE
    {
        alpha = mac_r( 375809632l /*0.35f Q30*/, 6554 /*0.4f Q14*/, stab_fac ); /*Q14*/
        if ( LT_16( nbLostCmpt, 2 ) )
        IF( LT_16( nbLostCmpt, 2 ) )
        {
            alpha = mac_r( 751619264l /*0.70f Q30*/, 4915 /*0.3f Q14*/, stab_fac ); /*Q14*/
        }
        if ( EQ_16( nbLostCmpt, 2 ) )
        IF( EQ_16( nbLostCmpt, 2 ) )
        {
            alpha = mac_r( 483183808l /*0.45f Q30*/, 6554 /*0.4f Q14*/, stab_fac ); /*Q14*/
        }
+1 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@
#include "cnst.h"
#include "wmc_auto.h"

#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * Local constants
 *--------------------------------------------------------------------*/
@@ -56,7 +57,6 @@
 *--------------------------------------------------------------------*/

/*! r: Index of the position of the minimum energy, that is the position i where filter(x[i-filterLength/2],...,x[i+(filterLength-filterLength/2)-1]) is at maximum. */
#ifndef IVAS_FLOAT_FIXED
static int16_t GetMinimumPosition(
    const float *x,       /* i  : input signal                                                */
    const int16_t length, /* i  : length of the filter length used for the energy calculation */
+43 −41
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ static Word16 GetMinimumPosition_fx(
    Word32 energy, energy_old, tmptest;
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move16();
#endif

    filterLength = s_min( filterLength, length );
@@ -41,7 +42,7 @@ static Word16 GetMinimumPosition_fx(
    iMinEnergyPos = center;
    move16();

    IF( filterLength > 0 )
    IF( GT_16( filterLength, 0 ) )
    {
        center = add( center, 1 );
        energy = L_deposit_l( 0 );
@@ -59,7 +60,7 @@ static Word16 GetMinimumPosition_fx(
#else
            energy = L_msu( energy_old, tmp16, tmp16 );
#endif
            tmp16 = shr( x[i + filterLength], tmp_e );
            tmp16 = shr( x[add( i, filterLength )], tmp_e );
            BASOP_SATURATE_WARNING_OFF_EVS /*Saturation will be handled*/
#ifdef BASOP_NOGLOB
                energy = L_mac_sat( energy, tmp16, tmp16 );
@@ -76,17 +77,17 @@ static Word16 GetMinimumPosition_fx(
                tmptest = L_sub( energy, MAXVAL_WORD32 );
#endif
            BASOP_SATURATE_WARNING_ON_EVS
            IF( tmptest == 0 )
            IF( EQ_32( tmptest, 0 ) )
            {
                tmp_e = add( tmp_e, 1 );
                energy = L_shr( energy_old, 2 );
                tmp16 = shr( x[i], tmp_e );
                energy = L_msu( energy, tmp16, tmp16 );
                tmp16 = shr( x[i + filterLength], tmp_e );
                tmp16 = shr( x[add( i, filterLength )], tmp_e );
                energy = L_mac( energy, tmp16, tmp16 );
            }

            IF( energy < 0 )
            IF( LT_32( energy, 0 ) )
            {
                iMinEnergyPos = add( i, center );
                tmp_e = 0;
@@ -118,10 +119,10 @@ static Word16 FindMaxPeak_fx(
    move16();
    FOR( i = 1; i < length; i++ )
    {
        if ( GT_16( abs_s( x[i] ), abs_s( x[iMax] ) ) )
        IF( GT_16( abs_s( x[i] ), abs_s( x[iMax] ) ) )
        {
            move16();
            iMax = i;
            move16();
        }
    }

@@ -144,16 +145,14 @@ static void AddSamples_fx(
    Word16 ftmp;

    pt_dest = new_exc;
    move16();
    pt_src = old_exc;
    move16();
    last_min_pos = 0;
    move16();

    FOR( i = 0; i < nb_min; i++ )
    {
        /* Copy section */
        FOR( j = min_pos[i] - last_min_pos; j > 0; j-- )
        FOR( j = sub( min_pos[i], last_min_pos ); j > 0; j-- )
        {
            *pt_dest++ = *pt_src++;
            move16();
@@ -253,7 +252,7 @@ void PulseResynchronization_fx(
    test();
    test();
    test();
    IF( ( LT_32( L_deposit_h( nFrameLength ), pitchStart ) ) || ( pitchStart <= 0 ) || ( pitchEnd <= 0 ) || ( LT_16( nSubframes, 1 ) ) || ( GT_16( nSubframes, 5 ) ) || ( LE_32( Mpy_32_16_1( pitchEnd, add( nSubframes, 1 ) ), Mpy_32_16_1( pitchStart, sub( nSubframes, 1 ) ) ) ) || ( src_exc - dst_exc >= 0 ) )
    IF( ( LT_32( L_deposit_h( nFrameLength ), pitchStart ) ) || LE_32( pitchStart, 0 ) || LE_32( pitchEnd, 0 ) || ( LT_16( nSubframes, 1 ) ) || ( GT_16( nSubframes, 5 ) ) || ( LE_32( Mpy_32_16_1( pitchEnd, add( nSubframes, 1 ) ), Mpy_32_16_1( pitchStart, sub( nSubframes, 1 ) ) ) ) || ( src_exc - dst_exc >= 0 ) )
    {
        /* This is error handling and recovery that should never occur. */
        test();
@@ -275,7 +274,7 @@ void PulseResynchronization_fx(
    /*samplesDelta = 0.5f*pitchDelta*nFrameLength*(nSubframes+1)*freqStart;*/
    /* pitchDelta*freqStart = ((pitchEnd - pitchStart)/roundedPitchStart)/nSubframes  */
    tmp16 = shl( roundedPitchStart, 2 ); /*Q0*/
    if ( EQ_16( nSubframes, 5 ) )
    IF( EQ_16( nSubframes, 5 ) )
    {
        tmp16 = add( tmp16, roundedPitchStart ); /*Q0*/ /*tmp16=roundedPitchStart*nSubframes*/
    }
@@ -307,6 +306,7 @@ void PulseResynchronization_fx(
    tmp2_e = add( tmp2_e, 31 - 16 );                   /* tmp32_a is now regarded as Q31 with scaling tmp2_e */

    tmp3_e = tmp2_e;
    move16();
    tmp32_a = L_negate( tmp32_a );
#ifdef BASOP_NOGLOB
    tmp32_a = L_add( L_shl_o( 1, sub( 31, tmp3_e ), &Overflow ), tmp32_a ); /*Q31,tmp3_e*/ /*tmp32_a= 1.0f-pitchStart*freqStart*/
@@ -332,7 +332,7 @@ void PulseResynchronization_fx(
    tmp32 = L_add( tmp32, 65536l /*1.f Q16*/ );
    k = extract_h( tmp32 );
    test();
    IF( ( k >= 0 ) && LE_16( add( k, 1 ), NB_PULSES_MAX ) )
    IF( GE_16( k, 0 ) && LE_16( add( k, 1 ), NB_PULSES_MAX ) )
    {
        absPitchDiff = L_abs( L_sub( L_deposit_h( roundedPitchStart ), pitchEnd ) ); /*Q16*/

@@ -361,7 +361,7 @@ void PulseResynchronization_fx(

        /* Calculate the integer number of samples to be added/removed in each pitch cycle */
        /*cycleDelta = max(0, (absPitchDiff-(k+1)*perCycleDeltaDelta)*T0*freqStart); */
        tmp_e = norm_s( k + 1 );
        tmp_e = norm_s( add( k, 1 ) );
        tmp32 = L_mult( perCycleDeltaDelta /*Q15,perCycleDeltaDelta_e*/, shl( add( k, 1 ), tmp_e ) /*Q0, tmp_e*/ ) /*Q0+16, perCycleDeltaDelta_e-tmp_e*/;
        tmp32 = BASOP_Util_Add_Mant32Exp( absPitchDiff /*Q16*/, 31 - 16, L_negate( tmp32 ), add( sub( perCycleDeltaDelta_e, tmp_e ), 31 - 16 ), &tmp_e ); /*Q31,tmp_e*/
        tmp32 = Mpy_32_16_1( tmp32, T0 /*Q0*/ );                                                                                                          /*Q16,tmp_e*/
@@ -370,7 +370,7 @@ void PulseResynchronization_fx(
        cycleDelta_e = add( tmp_e, freqStart_e );
        tmp32_a = L_shl( tmp32, cycleDelta_e );
        roundedCycleDelta = extract_h( L_abs( tmp32_a ) );
        if ( tmp32 < 0 )
        IF( LT_32( tmp32, 0 ) )
        {
            roundedCycleDelta = negate( roundedCycleDelta );
        }
@@ -383,19 +383,19 @@ void PulseResynchronization_fx(
#else
        cycleDelta = round_fx( tmp32 );                                       /*Q15, cycleDelta_e*/
#endif
        if ( cycleDelta == 0 )
        IF( EQ_16( cycleDelta, 0 ) )
        {
            move16();
            cycleDelta_e = 0;
            move16();
        }

        /*roundedCycleDelta = (int)(cycleDelta); */ /*done above*/
        move16();
        iDeltaSamples[0] = roundedCycleDelta;       /*Q0*/
        move16();
        /*fractionalLeft = cycleDelta-roundedCycleDelta;*/                   /*done above*/
        nSamplesDeltaRemain = sub( nSamplesDeltaRemain, roundedCycleDelta ); /*Q0*/

        tmp_e = ( s_max( 2, k ) );
        tmp_e = s_max( 2, k );
        tmp_e = norm_s( tmp_e ); /*maximum norming factor for following loop*/


@@ -415,7 +415,7 @@ void PulseResynchronization_fx(
                iDeltaSamples[i] = roundedCycleDelta;
                move16();
                roundedCycleDelta = extract_h( cycleDelta32 ); /* cycleDelta32 should never be < 0 here */
                iDeltaSamples[i - 1] = roundedCycleDelta;
                iDeltaSamples[sub( i, 1 )] = roundedCycleDelta;
                move16();
            }
            ELSE
@@ -428,9 +428,9 @@ void PulseResynchronization_fx(
            fractionalLeft = lshr( extract_l( cycleDelta32 ), 1 ); /*Q15*/ /* cycleDelta32 should never be < 0 here */
            nSamplesDeltaRemain = sub( nSamplesDeltaRemain, roundedCycleDelta );
        }
        iDeltaSamples[k + 1] = s_max( 0, nSamplesDeltaRemain );
        iDeltaSamples[add( k, 1 )] = s_max( 0, nSamplesDeltaRemain );
        move16();
        maxDeltaSamples = s_max( iDeltaSamples[k], iDeltaSamples[k + 1] ); /*Q0*/
        maxDeltaSamples = s_max( iDeltaSamples[k], iDeltaSamples[add( k, 1 )] ); /*Q0*/

        /* Find the location of the minimum energy between the first two pulses */

@@ -449,7 +449,7 @@ void PulseResynchronization_fx(
        iMinPos1 = add( iMinPos1, T0 );


        IF( nSamplesDelta < 0 )
        IF( LT_16( nSamplesDelta, 0 ) )
        {
            /* Find the location of the minimum energy before the first pulse */

@@ -460,43 +460,45 @@ void PulseResynchronization_fx(
            }
            ELSE
            {
                move16();
                iMinPos[0] = sub( GetMinimumPosition_fx( src_exc, T0, iDeltaSamples[0] ), shr( iDeltaSamples[0], 1 ) );
                move16();
            }

            /* Find the location of the minimum energy between the pulses */
            FOR( i = 1; i <= k; i++ )
            {
                move16();
                iMinPos[i] = add( iMinPos1, sub( imult1616( sub( i, 1 ), roundedPitchStart ), shr( iDeltaSamples[i], 1 ) ) );
                move16();
            }
            /* Find the location of the minimum energy after the last pulse */

            IF( LT_16( add( iMinPos1, add( imult1616( k, roundedPitchStart ), sub( iDeltaSamples[k + 1], shr( iDeltaSamples[k + 1], 1 ) ) ) ), sub( nFrameLength, nSamplesDelta ) ) )
            IF( LT_16( add( iMinPos1, add( imult1616( k, roundedPitchStart ), sub( iDeltaSamples[add( k, 1 )], shr( iDeltaSamples[add( k, 1 )], 1 ) ) ) ), sub( nFrameLength, nSamplesDelta ) ) )
            {
                iMinPos[add( k, 1 )] = add( iMinPos1, sub( imult1616( k, roundedPitchStart ), shr( iDeltaSamples[add( k, 1 )], 1 ) ) );
                move16();
                iMinPos[k + 1] = add( iMinPos1, sub( imult1616( k, roundedPitchStart ), shr( iDeltaSamples[k + 1], 1 ) ) );
            }
            ELSE
            {
                /*iMinPos[k+1] = T0+k*roundedPitchStart
                               + GetMinimumPosition_fx(src_exc+T0+k*roundedPitchStart, nFrameLength-nSamplesDelta-(T0+k*roundedPitchStart), iDeltaSamples[k+1])
                               - iDeltaSamples[k+1]/2;                                                 */
                tmp16 = GetMinimumPosition_fx( src_exc + T0 + k * roundedPitchStart, sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[k + 1] );
                tmp16 = GetMinimumPosition_fx( src_exc + add( T0, imult1616( k, roundedPitchStart ) ), sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[add( k, 1 )] );
                tmp16 = add( add( T0, imult1616( k, roundedPitchStart ) ), tmp16 );
                tmp16 = sub( tmp16, shr( iDeltaSamples[k + 1], 1 ) );
                iMinPos[k + 1] = tmp16;
                tmp16 = sub( tmp16, shr( iDeltaSamples[add( k, 1 )], 1 ) );
                iMinPos[add( k, 1 )] = tmp16;
                move16();
            }

            IF( GT_16( add( iMinPos[k + 1], iDeltaSamples[k + 1] ), sub( nFrameLength, nSamplesDelta ) ) )
            IF( GT_16( add( iMinPos[add( k, 1 )], iDeltaSamples[add( k, 1 )] ), sub( nFrameLength, nSamplesDelta ) ) )
            {
                iDeltaSamples[k] += add( iMinPos[k + 1], sub( iDeltaSamples[k + 1], sub( nFrameLength, nSamplesDelta ) ) );
                iDeltaSamples[k + 1] = sub( nFrameLength, add( nSamplesDelta, iMinPos[k + 1] ) );
                iDeltaSamples[k] = add( iDeltaSamples[k], add( iMinPos[add( k, 1 )], sub( iDeltaSamples[add( k, 1 )], sub( nFrameLength, nSamplesDelta ) ) ) );
                move16();
                iDeltaSamples[add( k, 1 )] = sub( nFrameLength, add( nSamplesDelta, iMinPos[add( k, 1 )] ) );
                move16();
            }

            /* Remove samples at the given positions */
            RemoveSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, k + 2 );
            RemoveSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, add( k, 2 ) );
        }
        ELSE
        {
@@ -523,27 +525,27 @@ void PulseResynchronization_fx(
            /* Find the location of the minimum energy after the last pulse */
            IF( LT_16( iMinPos1, sub( nFrameLength, nSamplesDelta ) ) )
            {
                iMinPos[k + 1] = iMinPos1;
                iMinPos[add( k, 1 )] = iMinPos1;
                move16();
            }
            ELSE
            {

                tmp16 = GetMinimumPosition_fx( src_exc + T0 + k * roundedPitchStart, sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[k + 1] );
                tmp16 = GetMinimumPosition_fx( src_exc + add( T0, imult1616( k, roundedPitchStart ) ), sub( nFrameLength, add( nSamplesDelta, add( T0, imult1616( k, roundedPitchStart ) ) ) ), iDeltaSamples[add( k, 1 )] );
                tmp16 = add( add( tmp16, T0 ), imult1616( k, roundedPitchStart ) );
                iMinPos[k + 1] = tmp16;
                iMinPos[add( k, 1 )] = tmp16;
                move16();
            }

            IF( GT_16( add( iMinPos[k + 1], iDeltaSamples[k + 1] ), sub( nFrameLength, nSamplesDelta ) ) )
            IF( GT_16( add( iMinPos[add( k, 1 )], iDeltaSamples[add( k, 1 )] ), sub( nFrameLength, nSamplesDelta ) ) )
            {
                iDeltaSamples[k] = add( iDeltaSamples[k], add( iMinPos[add( k, 1 )], sub( iDeltaSamples[add( k, 1 )], sub( nFrameLength, nSamplesDelta ) ) ) );
                move16();
                iDeltaSamples[add( k, 1 )] = sub( sub( nFrameLength, nSamplesDelta ), iMinPos[add( k, 1 )] );
                move16();
                iDeltaSamples[k] = add( iDeltaSamples[k], add( iMinPos[k + 1], sub( iDeltaSamples[k + 1], sub( nFrameLength, nSamplesDelta ) ) ) );
                iDeltaSamples[k + 1] = sub( sub( nFrameLength, nSamplesDelta ), iMinPos[k + 1] );
            }
            /* Add samples at the given positions */
            AddSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, k + 2 );
            AddSamples_fx( src_exc, dst_exc, nFrameLength, nSamplesDelta, iMinPos, iDeltaSamples, add( k, 2 ) );
        }
    }
}
Loading