static int process_tns_coeffs(TemporalNoiseShaping *tns, float *tns_coefs_raw,

                              int order, int w, int filt)

{

    int i, j;

    int *idx = tns->coef_idx[w][filt];

    float *lpc = tns->coef[w][filt];

    const int iqfac_p = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0);

    const int iqfac_m = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0);

    float temp[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f};



    /* Quantization */

    for (i = 0; i < order; i++) {

        idx[i] = ceilf(asin(tns_coefs_raw[i])*((tns_coefs_raw[i] >= 0) ? iqfac_p : iqfac_m));

        lpc[i] = 2*sin(idx[i]/((idx[i] >= 0) ? iqfac_p : iqfac_m));

    }



    /* Trim any coeff less than 0.1f from the end */

    for (i = order; i > -1; i--) {

        lpc[i] = (fabs(lpc[i]) > 0.1f) ? lpc[i] : 0.0f;

        if (lpc[i] != 0.0 ) {

            order = i;

            break;

        }

    }



    if (!order)

        return 0;



    /* Step up procedure, convert to LPC coeffs */

    out[0] = 1.0f;

    for (i = 1; i <= order; i++) {

        for (j = 1; j < i; j++) {

            temp[j] = out[j] + lpc[i]*out[i-j];

        }

        for (j = 1; j <= i; j++) {

            out[j] = temp[j];

        }

        out[i] = lpc[i-1];

    }

    memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float));



    return order;

}

static int process_tns_coeffs(TemporalNoiseShaping *tns, float *tns_coefs_raw,

                              int order, int w, int filt)

{

    int i, j;

    int *idx = tns->coef_idx[w][filt];

    float *lpc = tns->coef[w][filt];

    const int iqfac_p = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0);

    const int iqfac_m = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0);

    float temp[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f};



    

    for (i = 0; i < order; i++) {

        idx[i] = ceilf(asin(tns_coefs_raw[i])*((tns_coefs_raw[i] >= 0) ? iqfac_p : iqfac_m));

        lpc[i] = 2*sin(idx[i]/((idx[i] >= 0) ? iqfac_p : iqfac_m));

    }



    

    for (i = order; i > -1; i--) {

        lpc[i] = (fabs(lpc[i]) > 0.1f) ? lpc[i] : 0.0f;

        if (lpc[i] != 0.0 ) {

            order = i;

            break;

        }

    }



    if (!order)

        return 0;



    

    out[0] = 1.0f;

    for (i = 1; i <= order; i++) {

        for (j = 1; j < i; j++) {

            temp[j] = out[j] + lpc[i]*out[i-j];

        }

        for (j = 1; j <= i; j++) {

            out[j] = temp[j];

        }

        out[i] = lpc[i-1];

    }

    memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float));



    return order;

}

static int FUNC_0(TemporalNoiseShaping *VAR_0, float *VAR_1,

                              int VAR_2, int VAR_3, int VAR_4)

{

    int VAR_5, VAR_6;

    int *VAR_7 = VAR_0->coef_idx[VAR_3][VAR_4];

    float *VAR_8 = VAR_0->coef[VAR_3][VAR_4];

    const int VAR_9 = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0);

    const int VAR_10 = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0);

    float VAR_11[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f};



    

    for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) {

        VAR_7[VAR_5] = ceilf(asin(VAR_1[VAR_5])*((VAR_1[VAR_5] >= 0) ? VAR_9 : VAR_10));

        VAR_8[VAR_5] = 2*sin(VAR_7[VAR_5]/((VAR_7[VAR_5] >= 0) ? VAR_9 : VAR_10));

    }



    

    for (VAR_5 = VAR_2; VAR_5 > -1; VAR_5--) {

        VAR_8[VAR_5] = (fabs(VAR_8[VAR_5]) > 0.1f) ? VAR_8[VAR_5] : 0.0f;

        if (VAR_8[VAR_5] != 0.0 ) {

            VAR_2 = VAR_5;

            break;

        }

    }



    if (!VAR_2)

        return 0;



    

    out[0] = 1.0f;

    for (VAR_5 = 1; VAR_5 <= VAR_2; VAR_5++) {

        for (VAR_6 = 1; VAR_6 < VAR_5; VAR_6++) {

            VAR_11[VAR_6] = out[VAR_6] + VAR_8[VAR_5]*out[VAR_5-VAR_6];

        }

        for (VAR_6 = 1; VAR_6 <= VAR_5; VAR_6++) {

            out[VAR_6] = VAR_11[VAR_6];

        }

        out[VAR_5] = VAR_8[VAR_5-1];

    }

    memcpy(VAR_8, out, TNS_MAX_ORDER*sizeof(float));



    return VAR_2;

}

static int FUNC_0(TemporalNoiseShaping *VAR_0, float *VAR_1,
int VAR_2, int VAR_3, int VAR_4)
{ int VAR_5, VAR_6; int *VAR_7 = VAR_0->coef_idx[VAR_3][VAR_4]; float *VAR_8 = VAR_0->coef[VAR_3][VAR_4]; const int VAR_9 = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0); const int VAR_10 = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0); float VAR_11[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f}; for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) { VAR_7[VAR_5] = ceilf(asin(VAR_1[VAR_5])*((VAR_1[VAR_5] >= 0) ? VAR_9 : VAR_10)); VAR_8[VAR_5] = 2*sin(VAR_7[VAR_5]/((VAR_7[VAR_5] >= 0) ? VAR_9 : VAR_10)); } for (VAR_5 = VAR_2; VAR_5 > -1; VAR_5--) { VAR_8[VAR_5] = (fabs(VAR_8[VAR_5]) > 0.1f) ? VAR_8[VAR_5] : 0.0f; if (VAR_8[VAR_5] != 0.0 ) { VAR_2 = VAR_5; break; } } if (!VAR_2)
return 0; out[0] = 1.0f; for (VAR_5 = 1; VAR_5 <= VAR_2; VAR_5++) { for (VAR_6 = 1; VAR_6 < VAR_5; VAR_6++) { VAR_11[VAR_6] = out[VAR_6] + VAR_8[VAR_5]*out[VAR_5-VAR_6]; } for (VAR_6 = 1; VAR_6 <= VAR_5; VAR_6++) { out[VAR_6] = VAR_11[VAR_6]; } out[VAR_5] = VAR_8[VAR_5-1]; } memcpy(VAR_8, out, TNS_MAX_ORDER*sizeof(float)); return VAR_2; }