static int decode_cce(AACContext * ac, GetBitContext * gb, ChannelElement * che) {

    int num_gain = 0;

    int c, g, sfb, ret, idx = 0;

    int sign;

    float scale;

    SingleChannelElement * sce = &che->ch[0];

    ChannelCoupling * coup     = &che->coup;



    coup->coupling_point = 2*get_bits1(gb);

    coup->num_coupled = get_bits(gb, 3);

    for (c = 0; c <= coup->num_coupled; c++) {

        num_gain++;

        coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;

        coup->id_select[c] = get_bits(gb, 4);

        if (coup->type[c] == TYPE_CPE) {

            coup->ch_select[c] = get_bits(gb, 2);

            if (coup->ch_select[c] == 3)

                num_gain++;

        } else

            coup->ch_select[c] = 1;

    }

    coup->coupling_point += get_bits1(gb);



    if (coup->coupling_point == 2) {

        av_log(ac->avccontext, AV_LOG_ERROR,

            "Independently switched CCE with 'invalid' domain signalled.\n");

        memset(coup, 0, sizeof(ChannelCoupling));

        return -1;

    }



    sign = get_bits(gb, 1);

    scale = pow(2., pow(2., (int)get_bits(gb, 2) - 3));



    if ((ret = decode_ics(ac, sce, gb, 0, 0)))

        return ret;



    for (c = 0; c < num_gain; c++) {

        int cge = 1;

        int gain = 0;

        float gain_cache = 1.;

        if (c) {

            cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);

            gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;

            gain_cache = pow(scale, gain);

        }

        for (g = 0; g < sce->ics.num_window_groups; g++) {

            for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {

                if (sce->band_type[idx] != ZERO_BT) {

                    if (!cge) {

                        int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;

                        if (t) {

                            int s = 1;

                            if (sign) {

                                s  -= 2 * (t & 0x1);

                                t >>= 1;

                            }

                            gain += t;

                            gain_cache = pow(scale, gain) * s;

                        }

                    }

                    coup->gain[c][idx] = gain_cache;

                }

            }

        }

    }

    return 0;

}

static int decode_cce(AACContext * ac, GetBitContext * gb, ChannelElement * che) {

    int num_gain = 0;

    int c, g, sfb, ret, idx = 0;

    int sign;

    float scale;

    SingleChannelElement * sce = &che->ch[0];

    ChannelCoupling * coup     = &che->coup;



    coup->coupling_point = 2*get_bits1(gb);

    coup->num_coupled = get_bits(gb, 3);

    for (c = 0; c <= coup->num_coupled; c++) {

        num_gain++;

        coup->type[c] = get_bits1(gb) ? TYPE_CPE : TYPE_SCE;

        coup->id_select[c] = get_bits(gb, 4);

        if (coup->type[c] == TYPE_CPE) {

            coup->ch_select[c] = get_bits(gb, 2);

            if (coup->ch_select[c] == 3)

                num_gain++;

        } else

            coup->ch_select[c] = 1;

    }

    coup->coupling_point += get_bits1(gb);



    if (coup->coupling_point == 2) {

        av_log(ac->avccontext, AV_LOG_ERROR,

            "Independently switched CCE with 'invalid' domain signalled.\n");

        memset(coup, 0, sizeof(ChannelCoupling));

        return -1;

    }



    sign = get_bits(gb, 1);

    scale = pow(2., pow(2., (int)get_bits(gb, 2) - 3));



    if ((ret = decode_ics(ac, sce, gb, 0, 0)))

        return ret;



    for (c = 0; c < num_gain; c++) {

        int cge = 1;

        int gain = 0;

        float gain_cache = 1.;

        if (c) {

            cge = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(gb);

            gain = cge ? get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60: 0;

            gain_cache = pow(scale, gain);

        }

        for (g = 0; g < sce->ics.num_window_groups; g++) {

            for (sfb = 0; sfb < sce->ics.max_sfb; sfb++, idx++) {

                if (sce->band_type[idx] != ZERO_BT) {

                    if (!cge) {

                        int t = get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60;

                        if (t) {

                            int s = 1;

                            if (sign) {

                                s  -= 2 * (t & 0x1);

                                t >>= 1;

                            }

                            gain += t;

                            gain_cache = pow(scale, gain) * s;

                        }

                    }

                    coup->gain[c][idx] = gain_cache;

                }

            }

        }

    }

    return 0;

}

static int FUNC_0(AACContext * VAR_0, GetBitContext * VAR_1, ChannelElement * VAR_2) {

    int VAR_3 = 0;

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0;

    int VAR_9;

    float VAR_10;

    SingleChannelElement * sce = &VAR_2->ch[0];

    ChannelCoupling * coup     = &VAR_2->coup;



    coup->coupling_point = 2*get_bits1(VAR_1);

    coup->num_coupled = get_bits(VAR_1, 3);

    for (VAR_4 = 0; VAR_4 <= coup->num_coupled; VAR_4++) {

        VAR_3++;

        coup->type[VAR_4] = get_bits1(VAR_1) ? TYPE_CPE : TYPE_SCE;

        coup->id_select[VAR_4] = get_bits(VAR_1, 4);

        if (coup->type[VAR_4] == TYPE_CPE) {

            coup->ch_select[VAR_4] = get_bits(VAR_1, 2);

            if (coup->ch_select[VAR_4] == 3)

                VAR_3++;

        } else

            coup->ch_select[VAR_4] = 1;

    }

    coup->coupling_point += get_bits1(VAR_1);



    if (coup->coupling_point == 2) {

        av_log(VAR_0->avccontext, AV_LOG_ERROR,

            "Independently switched CCE with 'invalid' domain signalled.\n");

        memset(coup, 0, sizeof(ChannelCoupling));

        return -1;

    }



    VAR_9 = get_bits(VAR_1, 1);

    VAR_10 = pow(2., pow(2., (int)get_bits(VAR_1, 2) - 3));



    if ((VAR_7 = decode_ics(VAR_0, sce, VAR_1, 0, 0)))

        return VAR_7;



    for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) {

        int VAR_11 = 1;

        int VAR_12 = 0;

        float VAR_13 = 1.;

        if (VAR_4) {

            VAR_11 = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(VAR_1);

            VAR_12 = VAR_11 ? get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60: 0;

            VAR_13 = pow(VAR_10, VAR_12);

        }

        for (VAR_5 = 0; VAR_5 < sce->ics.num_window_groups; VAR_5++) {

            for (VAR_6 = 0; VAR_6 < sce->ics.max_sfb; VAR_6++, VAR_8++) {

                if (sce->band_type[VAR_8] != ZERO_BT) {

                    if (!VAR_11) {

                        int t = get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60;

                        if (t) {

                            int s = 1;

                            if (VAR_9) {

                                s  -= 2 * (t & 0x1);

                                t >>= 1;

                            }

                            VAR_12 += t;

                            VAR_13 = pow(VAR_10, VAR_12) * s;

                        }

                    }

                    coup->VAR_12[VAR_4][VAR_8] = VAR_13;

                }

            }

        }

    }

    return 0;

}

static int FUNC_0(AACContext * VAR_0, GetBitContext * VAR_1, ChannelElement * VAR_2) { int VAR_3 = 0; int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8 = 0; int VAR_9; float VAR_10; SingleChannelElement * sce = &VAR_2->ch[0]; ChannelCoupling * coup     = &VAR_2->coup; coup->coupling_point = 2*get_bits1(VAR_1); coup->num_coupled = get_bits(VAR_1, 3); for (VAR_4 = 0; VAR_4 <= coup->num_coupled; VAR_4++) { VAR_3++; coup->type[VAR_4] = get_bits1(VAR_1) ? TYPE_CPE : TYPE_SCE; coup->id_select[VAR_4] = get_bits(VAR_1, 4); if (coup->type[VAR_4] == TYPE_CPE) { coup->ch_select[VAR_4] = get_bits(VAR_1, 2); if (coup->ch_select[VAR_4] == 3)
VAR_3++; } else coup->ch_select[VAR_4] = 1; } coup->coupling_point += get_bits1(VAR_1); if (coup->coupling_point == 2) { av_log(VAR_0->avccontext, AV_LOG_ERROR,
"Independently switched CCE with 'invalid' domain signalled.\n"); memset(coup, 0, sizeof(ChannelCoupling)); return -1; } VAR_9 = get_bits(VAR_1, 1); VAR_10 = pow(2., pow(2., (int)get_bits(VAR_1, 2) - 3)); if ((VAR_7 = decode_ics(VAR_0, sce, VAR_1, 0, 0)))
return VAR_7; for (VAR_4 = 0; VAR_4 < VAR_3; VAR_4++) { int VAR_11 = 1; int VAR_12 = 0; float VAR_13 = 1.; if (VAR_4) { VAR_11 = coup->coupling_point == AFTER_IMDCT ? 1 : get_bits1(VAR_1); VAR_12 = VAR_11 ? get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60: 0; VAR_13 = pow(VAR_10, VAR_12); } for (VAR_5 = 0; VAR_5 < sce->ics.num_window_groups; VAR_5++) { for (VAR_6 = 0; VAR_6 < sce->ics.max_sfb; VAR_6++, VAR_8++) { if (sce->band_type[VAR_8] != ZERO_BT) { if (!VAR_11) { int t = get_vlc2(VAR_1, vlc_scalefactors.table, 7, 3) - 60; if (t) { int s = 1; if (VAR_9) { s  -= 2 * (t & 0x1); t >>= 1; } VAR_12 += t; VAR_13 = pow(VAR_10, VAR_12) * s; } } coup->VAR_12[VAR_4][VAR_8] = VAR_13; } } } } return 0; }