static void postfilter(EVRCContext *e, float *in, const float *coeff,

                       float *out, int idx, const struct PfCoeff *pfc,

                       int length)

{

    float wcoef1[FILTER_ORDER], wcoef2[FILTER_ORDER],

          scratch[SUBFRAME_SIZE], temp[SUBFRAME_SIZE],

          mem[SUBFRAME_SIZE];

    float sum1 = 0.0, sum2 = 0.0, gamma, gain;

    float tilt = pfc->tilt;

    int i, n, best;



    bandwidth_expansion(wcoef1, coeff, pfc->p1);

    bandwidth_expansion(wcoef2, coeff, pfc->p2);



    /* Tilt compensation filter, TIA/IS-127 5.9.1 */

    for (i = 0; i < length - 1; i++)

        sum2 += in[i] * in[i + 1];

    if (sum2 < 0.0)

        tilt = 0.0;



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

        scratch[i] = in[i] - tilt * e->last;

        e->last = in[i];

    }



    /* Short term residual filter, TIA/IS-127 5.9.2 */

    residual_filter(&e->postfilter_residual[ACB_SIZE], scratch, wcoef1, e->postfilter_fir, length);



    /* Long term postfilter */

    best = idx;

    for (i = FFMIN(MIN_DELAY, idx - 3); i <= FFMAX(MAX_DELAY, idx + 3); i++) {

        for (n = ACB_SIZE, sum2 = 0; n < ACB_SIZE + length; n++)

            sum2 += e->postfilter_residual[n] * e->postfilter_residual[n - i];

        if (sum2 > sum1) {

            sum1 = sum2;

            best = i;

        }

    }



    for (i = ACB_SIZE, sum1 = 0; i < ACB_SIZE + length; i++)

        sum1 += e->postfilter_residual[i - best] * e->postfilter_residual[i - best];

    for (i = ACB_SIZE, sum2 = 0; i < ACB_SIZE + length; i++)

        sum2 += e->postfilter_residual[i] * e->postfilter_residual[i - best];



    if (sum2 * sum1 == 0 || e->bitrate == RATE_QUANT) {

        memcpy(temp, e->postfilter_residual + ACB_SIZE, length * sizeof(float));

    } else {

        gamma = sum2 / sum1;

        if (gamma < 0.5)

            memcpy(temp, e->postfilter_residual + ACB_SIZE, length * sizeof(float));

        else {

            gamma = FFMIN(gamma, 1.0);



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

                temp[i] = e->postfilter_residual[ACB_SIZE + i] + gamma *

                    pfc->ltgain * e->postfilter_residual[ACB_SIZE + i - best];

            }

        }

    }



    memcpy(scratch, temp, length * sizeof(float));

    memcpy(mem, e->postfilter_iir, FILTER_ORDER * sizeof(float));

    synthesis_filter(scratch, wcoef2, mem, length, scratch);



    /* Gain computation, TIA/IS-127 5.9.4-2 */

    for (i = 0, sum1 = 0, sum2 = 0; i < length; i++) {

        sum1 += in[i] * in[i];

        sum2 += scratch[i] * scratch[i];

    }

    gain = sum2 ? sqrt(sum1 / sum2) : 1.0;



    for (i = 0; i < length; i++)

        temp[i] *= gain;



    /* Short term postfilter */

    synthesis_filter(temp, wcoef2, e->postfilter_iir, length, out);



    memcpy(e->postfilter_residual,

           e->postfilter_residual + length, ACB_SIZE * sizeof(float));

}

static void postfilter(EVRCContext *e, float *in, const float *coeff,

                       float *out, int idx, const struct PfCoeff *pfc,

                       int length)

{

    float wcoef1[FILTER_ORDER], wcoef2[FILTER_ORDER],

          scratch[SUBFRAME_SIZE], temp[SUBFRAME_SIZE],

          mem[SUBFRAME_SIZE];

    float sum1 = 0.0, sum2 = 0.0, gamma, gain;

    float tilt = pfc->tilt;

    int i, n, best;



    bandwidth_expansion(wcoef1, coeff, pfc->p1);

    bandwidth_expansion(wcoef2, coeff, pfc->p2);



    

    for (i = 0; i < length - 1; i++)

        sum2 += in[i] * in[i + 1];

    if (sum2 < 0.0)

        tilt = 0.0;



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

        scratch[i] = in[i] - tilt * e->last;

        e->last = in[i];

    }



    

    residual_filter(&e->postfilter_residual[ACB_SIZE], scratch, wcoef1, e->postfilter_fir, length);



    

    best = idx;

    for (i = FFMIN(MIN_DELAY, idx - 3); i <= FFMAX(MAX_DELAY, idx + 3); i++) {

        for (n = ACB_SIZE, sum2 = 0; n < ACB_SIZE + length; n++)

            sum2 += e->postfilter_residual[n] * e->postfilter_residual[n - i];

        if (sum2 > sum1) {

            sum1 = sum2;

            best = i;

        }

    }



    for (i = ACB_SIZE, sum1 = 0; i < ACB_SIZE + length; i++)

        sum1 += e->postfilter_residual[i - best] * e->postfilter_residual[i - best];

    for (i = ACB_SIZE, sum2 = 0; i < ACB_SIZE + length; i++)

        sum2 += e->postfilter_residual[i] * e->postfilter_residual[i - best];



    if (sum2 * sum1 == 0 || e->bitrate == RATE_QUANT) {

        memcpy(temp, e->postfilter_residual + ACB_SIZE, length * sizeof(float));

    } else {

        gamma = sum2 / sum1;

        if (gamma < 0.5)

            memcpy(temp, e->postfilter_residual + ACB_SIZE, length * sizeof(float));

        else {

            gamma = FFMIN(gamma, 1.0);



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

                temp[i] = e->postfilter_residual[ACB_SIZE + i] + gamma *

                    pfc->ltgain * e->postfilter_residual[ACB_SIZE + i - best];

            }

        }

    }



    memcpy(scratch, temp, length * sizeof(float));

    memcpy(mem, e->postfilter_iir, FILTER_ORDER * sizeof(float));

    synthesis_filter(scratch, wcoef2, mem, length, scratch);



    

    for (i = 0, sum1 = 0, sum2 = 0; i < length; i++) {

        sum1 += in[i] * in[i];

        sum2 += scratch[i] * scratch[i];

    }

    gain = sum2 ? sqrt(sum1 / sum2) : 1.0;



    for (i = 0; i < length; i++)

        temp[i] *= gain;



    

    synthesis_filter(temp, wcoef2, e->postfilter_iir, length, out);



    memcpy(e->postfilter_residual,

           e->postfilter_residual + length, ACB_SIZE * sizeof(float));

}

static void FUNC_0(EVRCContext *VAR_0, float *VAR_1, const float *VAR_2,

                       float *VAR_3, int VAR_4, const struct PfCoeff *VAR_5,

                       int VAR_6)

{

    float VAR_7[FILTER_ORDER], wcoef2[FILTER_ORDER],

          scratch[SUBFRAME_SIZE], temp[SUBFRAME_SIZE],

          mem[SUBFRAME_SIZE];

    float VAR_8 = 0.0, VAR_9 = 0.0, VAR_10, VAR_11;

    float VAR_12 = VAR_5->VAR_12;

    int VAR_13, VAR_14, VAR_15;



    bandwidth_expansion(VAR_7, VAR_2, VAR_5->p1);

    bandwidth_expansion(wcoef2, VAR_2, VAR_5->p2);



    

    for (VAR_13 = 0; VAR_13 < VAR_6 - 1; VAR_13++)

        VAR_9 += VAR_1[VAR_13] * VAR_1[VAR_13 + 1];

    if (VAR_9 < 0.0)

        VAR_12 = 0.0;



    for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++) {

        scratch[VAR_13] = VAR_1[VAR_13] - VAR_12 * VAR_0->last;

        VAR_0->last = VAR_1[VAR_13];

    }



    

    residual_filter(&VAR_0->postfilter_residual[ACB_SIZE], scratch, VAR_7, VAR_0->postfilter_fir, VAR_6);



    

    VAR_15 = VAR_4;

    for (VAR_13 = FFMIN(MIN_DELAY, VAR_4 - 3); VAR_13 <= FFMAX(MAX_DELAY, VAR_4 + 3); VAR_13++) {

        for (VAR_14 = ACB_SIZE, VAR_9 = 0; VAR_14 < ACB_SIZE + VAR_6; VAR_14++)

            VAR_9 += VAR_0->postfilter_residual[VAR_14] * VAR_0->postfilter_residual[VAR_14 - VAR_13];

        if (VAR_9 > VAR_8) {

            VAR_8 = VAR_9;

            VAR_15 = VAR_13;

        }

    }



    for (VAR_13 = ACB_SIZE, VAR_8 = 0; VAR_13 < ACB_SIZE + VAR_6; VAR_13++)

        VAR_8 += VAR_0->postfilter_residual[VAR_13 - VAR_15] * VAR_0->postfilter_residual[VAR_13 - VAR_15];

    for (VAR_13 = ACB_SIZE, VAR_9 = 0; VAR_13 < ACB_SIZE + VAR_6; VAR_13++)

        VAR_9 += VAR_0->postfilter_residual[VAR_13] * VAR_0->postfilter_residual[VAR_13 - VAR_15];



    if (VAR_9 * VAR_8 == 0 || VAR_0->bitrate == RATE_QUANT) {

        memcpy(temp, VAR_0->postfilter_residual + ACB_SIZE, VAR_6 * sizeof(float));

    } else {

        VAR_10 = VAR_9 / VAR_8;

        if (VAR_10 < 0.5)

            memcpy(temp, VAR_0->postfilter_residual + ACB_SIZE, VAR_6 * sizeof(float));

        else {

            VAR_10 = FFMIN(VAR_10, 1.0);



            for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++) {

                temp[VAR_13] = VAR_0->postfilter_residual[ACB_SIZE + VAR_13] + VAR_10 *

                    VAR_5->ltgain * VAR_0->postfilter_residual[ACB_SIZE + VAR_13 - VAR_15];

            }

        }

    }



    memcpy(scratch, temp, VAR_6 * sizeof(float));

    memcpy(mem, VAR_0->postfilter_iir, FILTER_ORDER * sizeof(float));

    synthesis_filter(scratch, wcoef2, mem, VAR_6, scratch);



    

    for (VAR_13 = 0, VAR_8 = 0, VAR_9 = 0; VAR_13 < VAR_6; VAR_13++) {

        VAR_8 += VAR_1[VAR_13] * VAR_1[VAR_13];

        VAR_9 += scratch[VAR_13] * scratch[VAR_13];

    }

    VAR_11 = VAR_9 ? sqrt(VAR_8 / VAR_9) : 1.0;



    for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++)

        temp[VAR_13] *= VAR_11;



    

    synthesis_filter(temp, wcoef2, VAR_0->postfilter_iir, VAR_6, VAR_3);



    memcpy(VAR_0->postfilter_residual,

           VAR_0->postfilter_residual + VAR_6, ACB_SIZE * sizeof(float));

}

static void FUNC_0(EVRCContext *VAR_0, float *VAR_1, const float *VAR_2,
float *VAR_3, int VAR_4, const struct PfCoeff *VAR_5,
int VAR_6)
{ float VAR_7[FILTER_ORDER], wcoef2[FILTER_ORDER],
scratch[SUBFRAME_SIZE], temp[SUBFRAME_SIZE],
mem[SUBFRAME_SIZE]; float VAR_8 = 0.0, VAR_9 = 0.0, VAR_10, VAR_11; float VAR_12 = VAR_5->VAR_12; int VAR_13, VAR_14, VAR_15; bandwidth_expansion(VAR_7, VAR_2, VAR_5->p1); bandwidth_expansion(wcoef2, VAR_2, VAR_5->p2); for (VAR_13 = 0; VAR_13 < VAR_6 - 1; VAR_13++) VAR_9 += VAR_1[VAR_13] * VAR_1[VAR_13 + 1]; if (VAR_9 < 0.0)
VAR_12 = 0.0; for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++) { scratch[VAR_13] = VAR_1[VAR_13] - VAR_12 * VAR_0->last; VAR_0->last = VAR_1[VAR_13]; } residual_filter(&VAR_0->postfilter_residual[ACB_SIZE], scratch, VAR_7, VAR_0->postfilter_fir, VAR_6); VAR_15 = VAR_4; for (VAR_13 = FFMIN(MIN_DELAY, VAR_4 - 3); VAR_13 <= FFMAX(MAX_DELAY, VAR_4 + 3); VAR_13++) { for (VAR_14 = ACB_SIZE, VAR_9 = 0; VAR_14 < ACB_SIZE + VAR_6; VAR_14++) VAR_9 += VAR_0->postfilter_residual[VAR_14] * VAR_0->postfilter_residual[VAR_14 - VAR_13]; if (VAR_9 > VAR_8) { VAR_8 = VAR_9; VAR_15 = VAR_13; } } for (VAR_13 = ACB_SIZE, VAR_8 = 0; VAR_13 < ACB_SIZE + VAR_6; VAR_13++) VAR_8 += VAR_0->postfilter_residual[VAR_13 - VAR_15] * VAR_0->postfilter_residual[VAR_13 - VAR_15]; for (VAR_13 = ACB_SIZE, VAR_9 = 0; VAR_13 < ACB_SIZE + VAR_6; VAR_13++) VAR_9 += VAR_0->postfilter_residual[VAR_13] * VAR_0->postfilter_residual[VAR_13 - VAR_15]; if (VAR_9 * VAR_8 == 0 || VAR_0->bitrate == RATE_QUANT) { memcpy(temp, VAR_0->postfilter_residual + ACB_SIZE, VAR_6 * sizeof(float)); } else { VAR_10 = VAR_9 / VAR_8; if (VAR_10 < 0.5)
memcpy(temp, VAR_0->postfilter_residual + ACB_SIZE, VAR_6 * sizeof(float)); else { VAR_10 = FFMIN(VAR_10, 1.0); for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++) { temp[VAR_13] = VAR_0->postfilter_residual[ACB_SIZE + VAR_13] + VAR_10 *
VAR_5->ltgain * VAR_0->postfilter_residual[ACB_SIZE + VAR_13 - VAR_15]; } } } memcpy(scratch, temp, VAR_6 * sizeof(float)); memcpy(mem, VAR_0->postfilter_iir, FILTER_ORDER * sizeof(float)); synthesis_filter(scratch, wcoef2, mem, VAR_6, scratch); for (VAR_13 = 0, VAR_8 = 0, VAR_9 = 0; VAR_13 < VAR_6; VAR_13++) { VAR_8 += VAR_1[VAR_13] * VAR_1[VAR_13]; VAR_9 += scratch[VAR_13] * scratch[VAR_13]; } VAR_11 = VAR_9 ? sqrt(VAR_8 / VAR_9) : 1.0; for (VAR_13 = 0; VAR_13 < VAR_6; VAR_13++) temp[VAR_13] *= VAR_11; synthesis_filter(temp, wcoef2, VAR_0->postfilter_iir, VAR_6, VAR_3); memcpy(VAR_0->postfilter_residual,
VAR_0->postfilter_residual + VAR_6, ACB_SIZE * sizeof(float)); }