static int decode_tns(AACContext * ac, TemporalNoiseShaping * tns,

        GetBitContext * gb, const IndividualChannelStream * ics) {

    int w, filt, i, coef_len, coef_res, coef_compress;

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

    const int tns_max_order = is8 ? 7 : ac->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;

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

        tns->n_filt[w] = get_bits(gb, 2 - is8);



        if (tns->n_filt[w])

            coef_res = get_bits1(gb);



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

            int tmp2_idx;

            tns->length[w][filt] = get_bits(gb, 6 - 2*is8);



            if ((tns->order[w][filt] = get_bits(gb, 5 - 2*is8)) > tns_max_order) {

                av_log(ac->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.",

                       tns->order[w][filt], tns_max_order);

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

                return -1;

            }

            tns->direction[w][filt] = get_bits1(gb);

            coef_compress = get_bits1(gb);

            coef_len = coef_res + 3 - coef_compress;

            tmp2_idx = 2*coef_compress + coef_res;



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

                tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];

        }

    }

    return 0;

}

static int decode_tns(AACContext * ac, TemporalNoiseShaping * tns,

        GetBitContext * gb, const IndividualChannelStream * ics) {

    int w, filt, i, coef_len, coef_res, coef_compress;

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

    const int tns_max_order = is8 ? 7 : ac->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;

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

        tns->n_filt[w] = get_bits(gb, 2 - is8);



        if (tns->n_filt[w])

            coef_res = get_bits1(gb);



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

            int tmp2_idx;

            tns->length[w][filt] = get_bits(gb, 6 - 2*is8);



            if ((tns->order[w][filt] = get_bits(gb, 5 - 2*is8)) > tns_max_order) {

                av_log(ac->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.",

                       tns->order[w][filt], tns_max_order);

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

                return -1;

            }

            tns->direction[w][filt] = get_bits1(gb);

            coef_compress = get_bits1(gb);

            coef_len = coef_res + 3 - coef_compress;

            tmp2_idx = 2*coef_compress + coef_res;



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

                tns->coef[w][filt][i] = tns_tmp2_map[tmp2_idx][get_bits(gb, coef_len)];

        }

    }

    return 0;

}

        tns->n_filt[w] = get_bits(gb, 2 - is8);         if (tns->n_filt[w])
static int FUNC_0(AACContext * VAR_0, TemporalNoiseShaping * VAR_1,

        GetBitContext * VAR_2, const IndividualChannelStream * VAR_3) {

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;

    const int VAR_10 = VAR_3->window_sequence[0] == EIGHT_SHORT_SEQUENCE;

    const int VAR_11 = VAR_10 ? 7 : VAR_0->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12;

    for (VAR_4 = 0; VAR_4 < VAR_3->num_windows; VAR_4++) {

        VAR_1->n_filt[VAR_4] = get_bits(VAR_2, 2 - VAR_10);



        if (VAR_1->n_filt[VAR_4])

            VAR_8 = get_bits1(VAR_2);



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

            int tmp2_idx;

            VAR_1->length[VAR_4][VAR_5] = get_bits(VAR_2, 6 - 2*VAR_10);



            if ((VAR_1->order[VAR_4][VAR_5] = get_bits(VAR_2, 5 - 2*VAR_10)) > VAR_11) {

                av_log(VAR_0->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.",

                       VAR_1->order[VAR_4][VAR_5], VAR_11);

                VAR_1->order[VAR_4][VAR_5] = 0;

                return -1;

            }

            VAR_1->direction[VAR_4][VAR_5] = get_bits1(VAR_2);

            VAR_9 = get_bits1(VAR_2);

            VAR_7 = VAR_8 + 3 - VAR_9;

            tmp2_idx = 2*VAR_9 + VAR_8;



            for (VAR_6 = 0; VAR_6 < VAR_1->order[VAR_4][VAR_5]; VAR_6++)

                VAR_1->coef[VAR_4][VAR_5][VAR_6] = tns_tmp2_map[tmp2_idx][get_bits(VAR_2, VAR_7)];

        }

    }

    return 0;

}

static int FUNC_0(AACContext * VAR_0, TemporalNoiseShaping * VAR_1,
GetBitContext * VAR_2, const IndividualChannelStream * VAR_3) { int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; const int VAR_10 = VAR_3->window_sequence[0] == EIGHT_SHORT_SEQUENCE; const int VAR_11 = VAR_10 ? 7 : VAR_0->m4ac.object_type == AOT_AAC_MAIN ? 20 : 12; for (VAR_4 = 0; VAR_4 < VAR_3->num_windows; VAR_4++) { VAR_1->n_filt[VAR_4] = get_bits(VAR_2, 2 - VAR_10); if (VAR_1->n_filt[VAR_4])
VAR_8 = get_bits1(VAR_2); for (VAR_5 = 0; VAR_5 < VAR_1->n_filt[VAR_4]; VAR_5++) { int tmp2_idx; VAR_1->length[VAR_4][VAR_5] = get_bits(VAR_2, 6 - 2*VAR_10); if ((VAR_1->order[VAR_4][VAR_5] = get_bits(VAR_2, 5 - 2*VAR_10)) > VAR_11) { av_log(VAR_0->avccontext, AV_LOG_ERROR, "TNS filter order %d is greater than maximum %d.",
VAR_1->order[VAR_4][VAR_5], VAR_11); VAR_1->order[VAR_4][VAR_5] = 0; return -1; } VAR_1->direction[VAR_4][VAR_5] = get_bits1(VAR_2); VAR_9 = get_bits1(VAR_2); VAR_7 = VAR_8 + 3 - VAR_9; tmp2_idx = 2*VAR_9 + VAR_8; for (VAR_6 = 0; VAR_6 < VAR_1->order[VAR_4][VAR_5]; VAR_6++) VAR_1->coef[VAR_4][VAR_5][VAR_6] = tns_tmp2_map[tmp2_idx][get_bits(VAR_2, VAR_7)]; } } return 0; }