static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,

                      IndividualChannelStream *ics, int decode)

{

    const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);

    int w, filt, m, i;

    int bottom, top, order, start, end, size, inc;

    float lpc[TNS_MAX_ORDER];

    float tmp[TNS_MAX_ORDER];



    for (w = 0; w < ics->num_windows; w++) {

        bottom = ics->num_swb;

        for (filt = 0; filt < tns->n_filt[w]; filt++) {

            top    = bottom;

            bottom = FFMAX(0, top - tns->length[w][filt]);

            order  = tns->order[w][filt];

            if (order == 0)

                continue;



            // tns_decode_coef

            compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);



            start = ics->swb_offset[FFMIN(bottom, mmm)];

            end   = ics->swb_offset[FFMIN(   top, mmm)];

            if ((size = end - start) <= 0)

                continue;

            if (tns->direction[w][filt]) {

                inc = -1;

                start = end - 1;

            } else {

                inc = 1;

            }

            start += w * 128;



            if (decode) {

                // ar filter

                for (m = 0; m < size; m++, start += inc)

                    for (i = 1; i <= FFMIN(m, order); i++)

                        coef[start] -= coef[start - i * inc] * lpc[i - 1];

            } else {

                // ma filter

                for (m = 0; m < size; m++, start += inc) {

                    tmp[0] = coef[start];

                    for (i = 1; i <= FFMIN(m, order); i++)

                        coef[start] += tmp[i] * lpc[i - 1];

                    for (i = order; i > 0; i--)

                        tmp[i] = tmp[i - 1];

                }

            }

        }

    }

}

static void apply_tns(float coef[1024], TemporalNoiseShaping *tns,

                      IndividualChannelStream *ics, int decode)

{

    const int mmm = FFMIN(ics->tns_max_bands, ics->max_sfb);

    int w, filt, m, i;

    int bottom, top, order, start, end, size, inc;

    float lpc[TNS_MAX_ORDER];

    float tmp[TNS_MAX_ORDER];



    for (w = 0; w < ics->num_windows; w++) {

        bottom = ics->num_swb;

        for (filt = 0; filt < tns->n_filt[w]; filt++) {

            top    = bottom;

            bottom = FFMAX(0, top - tns->length[w][filt]);

            order  = tns->order[w][filt];

            if (order == 0)

                continue;



            

            compute_lpc_coefs(tns->coef[w][filt], order, lpc, 0, 0, 0);



            start = ics->swb_offset[FFMIN(bottom, mmm)];

            end   = ics->swb_offset[FFMIN(   top, mmm)];

            if ((size = end - start) <= 0)

                continue;

            if (tns->direction[w][filt]) {

                inc = -1;

                start = end - 1;

            } else {

                inc = 1;

            }

            start += w * 128;



            if (decode) {

                

                for (m = 0; m < size; m++, start += inc)

                    for (i = 1; i <= FFMIN(m, order); i++)

                        coef[start] -= coef[start - i * inc] * lpc[i - 1];

            } else {

                

                for (m = 0; m < size; m++, start += inc) {

                    tmp[0] = coef[start];

                    for (i = 1; i <= FFMIN(m, order); i++)

                        coef[start] += tmp[i] * lpc[i - 1];

                    for (i = order; i > 0; i--)

                        tmp[i] = tmp[i - 1];

                }

            }

        }

    }

}

static void FUNC_0(float VAR_0[1024], TemporalNoiseShaping *VAR_1,

                      IndividualChannelStream *VAR_2, int VAR_3)

{

    const int VAR_4 = FFMIN(VAR_2->tns_max_bands, VAR_2->max_sfb);

    int VAR_5, VAR_6, VAR_7, VAR_8;

    int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15;

    float VAR_16[TNS_MAX_ORDER];

    float VAR_17[TNS_MAX_ORDER];



    for (VAR_5 = 0; VAR_5 < VAR_2->num_windows; VAR_5++) {

        VAR_9 = VAR_2->num_swb;

        for (VAR_6 = 0; VAR_6 < VAR_1->n_filt[VAR_5]; VAR_6++) {

            VAR_10    = VAR_9;

            VAR_9 = FFMAX(0, VAR_10 - VAR_1->length[VAR_5][VAR_6]);

            VAR_11  = VAR_1->VAR_11[VAR_5][VAR_6];

            if (VAR_11 == 0)

                continue;



            

            compute_lpc_coefs(VAR_1->VAR_0[VAR_5][VAR_6], VAR_11, VAR_16, 0, 0, 0);



            VAR_12 = VAR_2->swb_offset[FFMIN(VAR_9, VAR_4)];

            VAR_13   = VAR_2->swb_offset[FFMIN(   VAR_10, VAR_4)];

            if ((VAR_14 = VAR_13 - VAR_12) <= 0)

                continue;

            if (VAR_1->direction[VAR_5][VAR_6]) {

                VAR_15 = -1;

                VAR_12 = VAR_13 - 1;

            } else {

                VAR_15 = 1;

            }

            VAR_12 += VAR_5 * 128;



            if (VAR_3) {

                

                for (VAR_7 = 0; VAR_7 < VAR_14; VAR_7++, VAR_12 += VAR_15)

                    for (VAR_8 = 1; VAR_8 <= FFMIN(VAR_7, VAR_11); VAR_8++)

                        VAR_0[VAR_12] -= VAR_0[VAR_12 - VAR_8 * VAR_15] * VAR_16[VAR_8 - 1];

            } else {

                

                for (VAR_7 = 0; VAR_7 < VAR_14; VAR_7++, VAR_12 += VAR_15) {

                    VAR_17[0] = VAR_0[VAR_12];

                    for (VAR_8 = 1; VAR_8 <= FFMIN(VAR_7, VAR_11); VAR_8++)

                        VAR_0[VAR_12] += VAR_17[VAR_8] * VAR_16[VAR_8 - 1];

                    for (VAR_8 = VAR_11; VAR_8 > 0; VAR_8--)

                        VAR_17[VAR_8] = VAR_17[VAR_8 - 1];

                }

            }

        }

    }

}

static void FUNC_0(float VAR_0[1024], TemporalNoiseShaping *VAR_1,
IndividualChannelStream *VAR_2, int VAR_3)
{ const int VAR_4 = FFMIN(VAR_2->tns_max_bands, VAR_2->max_sfb); int VAR_5, VAR_6, VAR_7, VAR_8; int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15; float VAR_16[TNS_MAX_ORDER]; float VAR_17[TNS_MAX_ORDER]; for (VAR_5 = 0; VAR_5 < VAR_2->num_windows; VAR_5++) { VAR_9 = VAR_2->num_swb; for (VAR_6 = 0; VAR_6 < VAR_1->n_filt[VAR_5]; VAR_6++) { VAR_10    = VAR_9; VAR_9 = FFMAX(0, VAR_10 - VAR_1->length[VAR_5][VAR_6]); VAR_11  = VAR_1->VAR_11[VAR_5][VAR_6]; if (VAR_11 == 0)
continue; compute_lpc_coefs(VAR_1->VAR_0[VAR_5][VAR_6], VAR_11, VAR_16, 0, 0, 0); VAR_12 = VAR_2->swb_offset[FFMIN(VAR_9, VAR_4)]; VAR_13   = VAR_2->swb_offset[FFMIN(   VAR_10, VAR_4)]; if ((VAR_14 = VAR_13 - VAR_12) <= 0)
continue; if (VAR_1->direction[VAR_5][VAR_6]) { VAR_15 = -1; VAR_12 = VAR_13 - 1; } else { VAR_15 = 1; } VAR_12 += VAR_5 * 128; if (VAR_3) { for (VAR_7 = 0; VAR_7 < VAR_14; VAR_7++, VAR_12 += VAR_15) for (VAR_8 = 1; VAR_8 <= FFMIN(VAR_7, VAR_11); VAR_8++) VAR_0[VAR_12] -= VAR_0[VAR_12 - VAR_8 * VAR_15] * VAR_16[VAR_8 - 1]; } else { for (VAR_7 = 0; VAR_7 < VAR_14; VAR_7++, VAR_12 += VAR_15) { VAR_17[0] = VAR_0[VAR_12]; for (VAR_8 = 1; VAR_8 <= FFMIN(VAR_7, VAR_11); VAR_8++) VAR_0[VAR_12] += VAR_17[VAR_8] * VAR_16[VAR_8 - 1]; for (VAR_8 = VAR_11; VAR_8 > 0; VAR_8--) VAR_17[VAR_8] = VAR_17[VAR_8 - 1]; } } } } }