Commit d9fafc14 authored by Jiaquan Huo's avatar Jiaquan Huo
Browse files

fix bug

parent 1e92c06d
Loading
Loading
Loading
Loading
+1 −54
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@
#define EPS_STOP          1e-5
#endif

#if 0
#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT
/*------------------------------------------------------------------------------------------*
 * Static function declarations
@@ -182,33 +181,11 @@ static int16_t d_lev_dur(
    const int16_t m, /* i  : order of LP filter           */
    double epsP[]    /* o  : prediction error energy      */
)
#else
/*---------------------------------------------------------------------*
 * lfeplc_lev_dur()
 *
 * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations
 * of input signal
 *---------------------------------------------------------------------*/

/*! r: stability flag */
static int16_t lfeplc_lev_dur(
    float *a_out,   /* o  : LP coefficients (a[0] = 1.0) */
    const float *r, /* i  : vector of autocorrelations   */
    const int16_t m /* i  : order of LP filter           */
)
#endif
{
    int16_t i, j, l;
#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT
    double buf[TCXLTP_LTP_ORDER];
    double *rc; /* reflection coefficients  0,...,m-1 */
    double s, at, err;
#else
    float buf[TCXLTP_LTP_ORDER];
    float *rc; /* reflection coefficients  0,...,m-1 */
    float s, at, err;
    float a[LFE_PLC_LPCORD + 1];
#endif
    int16_t flag = 0;

    rc = &buf[0];
@@ -217,24 +194,15 @@ static int16_t lfeplc_lev_dur(
    a[1] = rc[0];
    err = r[0] + r[1] * rc[0];

#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT
    set_f( a_out, 0.f, LFE_PLC_LPCORD + 1 );
    set_f( a + 2, 0.f, LFE_PLC_LPCORD + 1 - 2 );
#else
    if ( epsP != NULL )
    {
        epsP[0] = r[0];
        epsP[1] = err;
    }
#endif

    for ( i = 2; i <= m; i++ )
    {
#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT
        s = 0.0;
#else
        s = 0.0f;
#endif
        for ( j = 0; j < i; j++ )
        {
            s += r[i - j] * a[j];
@@ -242,26 +210,10 @@ static int16_t lfeplc_lev_dur(

        rc[i - 1] = ( -s ) / err;

#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT
        if ( fabs( rc[i - 1] ) > 0.99945f )
#else
        if ( fabsf( rc[i - 1] ) > 0.99945f )
#endif
        {
            flag = 1; /* Test for unstable filter. If unstable keep old A(z) */
#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT
        }
#else
            return flag;
        }
        else
        {
            for ( j = 0; j <= m; j++ )
            {
                a_out[j] = a[j];
            }
        }
#endif

        for ( j = 1; j <= i / 2; j++ )
        {
@@ -279,13 +231,11 @@ static int16_t lfeplc_lev_dur(
        {
            err = 0.01f;
        }
#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT

        if ( epsP != NULL )
        {
            epsP[i] = err;
        }
#endif
    }

    return ( flag );
@@ -320,11 +270,8 @@ static int16_t lfeplc_lev_dur(
    s = r[1];
    a[1] = rc[0];
    a_out[1] = a[1];
    err += rc[0] * s;
    s += r[2] * a[1];
    rc[1] = ( -s ) / err;

    i = 2;
    i = 1;
    while ( i < m )
    {
        for ( j = 1; j <= i / 2; j++ )