void ff_aac_encode_tns_info(AACEncContext *s, SingleChannelElement *sce)

{

    int i, w, filt, coef_len, coef_compress;

    const int coef_res = MAX_LPC_PRECISION == 4 ? 1 : 0;

    const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE;



    put_bits(&s->pb, 1, !!sce->tns.present);



    if (!sce->tns.present)

        return;



    for (i = 0; i < sce->ics.num_windows; i++) {

        put_bits(&s->pb, 2 - is8, sce->tns.n_filt[i]);

        if (sce->tns.n_filt[i]) {

            put_bits(&s->pb, 1, !!coef_res);

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

                put_bits(&s->pb, 6 - 2 * is8, sce->tns.length[i][filt]);

                put_bits(&s->pb, 5 - 2 * is8, sce->tns.order[i][filt]);

                if (sce->tns.order[i][filt]) {

                    coef_compress = compress_coef(sce->tns.coef_idx[i][filt],

                                                  sce->tns.order[i][filt]);

                    put_bits(&s->pb, 1, !!sce->tns.direction[i][filt]);

                    put_bits(&s->pb, 1, !!coef_compress);

                    coef_len = coef_res + 3 - coef_compress;

                    for (w = 0; w < sce->tns.order[i][filt]; w++)

                        put_bits(&s->pb, coef_len, sce->tns.coef_idx[i][filt][w]);

                }

            }

        }

    }

}

void ff_aac_encode_tns_info(AACEncContext *s, SingleChannelElement *sce)

{

    int i, w, filt, coef_len, coef_compress;

    const int coef_res = MAX_LPC_PRECISION == 4 ? 1 : 0;

    const int is8 = sce->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE;



    put_bits(&s->pb, 1, !!sce->tns.present);



    if (!sce->tns.present)

        return;



    for (i = 0; i < sce->ics.num_windows; i++) {

        put_bits(&s->pb, 2 - is8, sce->tns.n_filt[i]);

        if (sce->tns.n_filt[i]) {

            put_bits(&s->pb, 1, !!coef_res);

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

                put_bits(&s->pb, 6 - 2 * is8, sce->tns.length[i][filt]);

                put_bits(&s->pb, 5 - 2 * is8, sce->tns.order[i][filt]);

                if (sce->tns.order[i][filt]) {

                    coef_compress = compress_coef(sce->tns.coef_idx[i][filt],

                                                  sce->tns.order[i][filt]);

                    put_bits(&s->pb, 1, !!sce->tns.direction[i][filt]);

                    put_bits(&s->pb, 1, !!coef_compress);

                    coef_len = coef_res + 3 - coef_compress;

                    for (w = 0; w < sce->tns.order[i][filt]; w++)

                        put_bits(&s->pb, coef_len, sce->tns.coef_idx[i][filt][w]);

                }

            }

        }

    }

}

void FUNC_0(AACEncContext *VAR_0, SingleChannelElement *VAR_1)

{

    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6;

    const int VAR_7 = MAX_LPC_PRECISION == 4 ? 1 : 0;

    const int VAR_8 = VAR_1->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE;



    put_bits(&VAR_0->pb, 1, !!VAR_1->tns.present);



    if (!VAR_1->tns.present)

        return;



    for (VAR_2 = 0; VAR_2 < VAR_1->ics.num_windows; VAR_2++) {

        put_bits(&VAR_0->pb, 2 - VAR_8, VAR_1->tns.n_filt[VAR_2]);

        if (VAR_1->tns.n_filt[VAR_2]) {

            put_bits(&VAR_0->pb, 1, !!VAR_7);

            for (VAR_4 = 0; VAR_4 < VAR_1->tns.n_filt[VAR_2]; VAR_4++) {

                put_bits(&VAR_0->pb, 6 - 2 * VAR_8, VAR_1->tns.length[VAR_2][VAR_4]);

                put_bits(&VAR_0->pb, 5 - 2 * VAR_8, VAR_1->tns.order[VAR_2][VAR_4]);

                if (VAR_1->tns.order[VAR_2][VAR_4]) {

                    VAR_6 = compress_coef(VAR_1->tns.coef_idx[VAR_2][VAR_4],

                                                  VAR_1->tns.order[VAR_2][VAR_4]);

                    put_bits(&VAR_0->pb, 1, !!VAR_1->tns.direction[VAR_2][VAR_4]);

                    put_bits(&VAR_0->pb, 1, !!VAR_6);

                    VAR_5 = VAR_7 + 3 - VAR_6;

                    for (VAR_3 = 0; VAR_3 < VAR_1->tns.order[VAR_2][VAR_4]; VAR_3++)

                        put_bits(&VAR_0->pb, VAR_5, VAR_1->tns.coef_idx[VAR_2][VAR_4][VAR_3]);

                }

            }

        }

    }

}

void FUNC_0(AACEncContext *VAR_0, SingleChannelElement *VAR_1)
{ int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6; const int VAR_7 = MAX_LPC_PRECISION == 4 ? 1 : 0; const int VAR_8 = VAR_1->ics.window_sequence[0] == EIGHT_SHORT_SEQUENCE; put_bits(&VAR_0->pb, 1, !!VAR_1->tns.present); if (!VAR_1->tns.present)
return; for (VAR_2 = 0; VAR_2 < VAR_1->ics.num_windows; VAR_2++) { put_bits(&VAR_0->pb, 2 - VAR_8, VAR_1->tns.n_filt[VAR_2]); if (VAR_1->tns.n_filt[VAR_2]) { put_bits(&VAR_0->pb, 1, !!VAR_7); for (VAR_4 = 0; VAR_4 < VAR_1->tns.n_filt[VAR_2]; VAR_4++) { put_bits(&VAR_0->pb, 6 - 2 * VAR_8, VAR_1->tns.length[VAR_2][VAR_4]); put_bits(&VAR_0->pb, 5 - 2 * VAR_8, VAR_1->tns.order[VAR_2][VAR_4]); if (VAR_1->tns.order[VAR_2][VAR_4]) { VAR_6 = compress_coef(VAR_1->tns.coef_idx[VAR_2][VAR_4],
VAR_1->tns.order[VAR_2][VAR_4]); put_bits(&VAR_0->pb, 1, !!VAR_1->tns.direction[VAR_2][VAR_4]); put_bits(&VAR_0->pb, 1, !!VAR_6); VAR_5 = VAR_7 + 3 - VAR_6; for (VAR_3 = 0; VAR_3 < VAR_1->tns.order[VAR_2][VAR_4]; VAR_3++) put_bits(&VAR_0->pb, VAR_5, VAR_1->tns.coef_idx[VAR_2][VAR_4][VAR_3]); } } } } }