static int decode_ics(AACContext *ac, SingleChannelElement *sce,

                      GetBitContext *gb, int common_window, int scale_flag)

{

    Pulse pulse;

    TemporalNoiseShaping    *tns = &sce->tns;

    IndividualChannelStream *ics = &sce->ics;

    INTFLOAT *out = sce->coeffs;

    int global_gain, eld_syntax, er_syntax, pulse_present = 0;

    int ret;



    eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD;

    er_syntax  = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC ||

                 ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP ||

                 ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD ||

                 ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD;



    /* This assignment is to silence a GCC warning about the variable being used

     * uninitialized when in fact it always is.

     */

    pulse.num_pulse = 0;



    global_gain = get_bits(gb, 8);



    if (!common_window && !scale_flag) {

        if (decode_ics_info(ac, ics, gb) < 0)

            return AVERROR_INVALIDDATA;

    }



    if ((ret = decode_band_types(ac, sce->band_type,

                                 sce->band_type_run_end, gb, ics)) < 0)

        return ret;

    if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics,

                                  sce->band_type, sce->band_type_run_end)) < 0)

        return ret;



    pulse_present = 0;

    if (!scale_flag) {

        if (!eld_syntax && (pulse_present = get_bits1(gb))) {

            if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {

                av_log(ac->avctx, AV_LOG_ERROR,

                       "Pulse tool not allowed in eight short sequence.\n");

                return AVERROR_INVALIDDATA;

            }

            if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {

                av_log(ac->avctx, AV_LOG_ERROR,

                       "Pulse data corrupt or invalid.\n");

                return AVERROR_INVALIDDATA;

            }

        }

        tns->present = get_bits1(gb);

        if (tns->present && !er_syntax)

            if (decode_tns(ac, tns, gb, ics) < 0)

                return AVERROR_INVALIDDATA;

        if (!eld_syntax && get_bits1(gb)) {

            avpriv_request_sample(ac->avctx, "SSR");

            return AVERROR_PATCHWELCOME;

        }

        // I see no textual basis in the spec for this occurring after SSR gain

        // control, but this is what both reference and real implmentations do

        if (tns->present && er_syntax)

            if (decode_tns(ac, tns, gb, ics) < 0)

                return AVERROR_INVALIDDATA;

    }



    if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present,

                                    &pulse, ics, sce->band_type) < 0)

        return AVERROR_INVALIDDATA;



    if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window)

        apply_prediction(ac, sce);



    return 0;

}

static int decode_ics(AACContext *ac, SingleChannelElement *sce,

                      GetBitContext *gb, int common_window, int scale_flag)

{

    Pulse pulse;

    TemporalNoiseShaping    *tns = &sce->tns;

    IndividualChannelStream *ics = &sce->ics;

    INTFLOAT *out = sce->coeffs;

    int global_gain, eld_syntax, er_syntax, pulse_present = 0;

    int ret;



    eld_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD;

    er_syntax  = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC ||

                 ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP ||

                 ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD ||

                 ac->oc[1].m4ac.object_type == AOT_ER_AAC_ELD;



    





    pulse.num_pulse = 0;



    global_gain = get_bits(gb, 8);



    if (!common_window && !scale_flag) {

        if (decode_ics_info(ac, ics, gb) < 0)

            return AVERROR_INVALIDDATA;

    }



    if ((ret = decode_band_types(ac, sce->band_type,

                                 sce->band_type_run_end, gb, ics)) < 0)

        return ret;

    if ((ret = decode_scalefactors(ac, sce->sf, gb, global_gain, ics,

                                  sce->band_type, sce->band_type_run_end)) < 0)

        return ret;



    pulse_present = 0;

    if (!scale_flag) {

        if (!eld_syntax && (pulse_present = get_bits1(gb))) {

            if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {

                av_log(ac->avctx, AV_LOG_ERROR,

                       "Pulse tool not allowed in eight short sequence.\n");

                return AVERROR_INVALIDDATA;

            }

            if (decode_pulses(&pulse, gb, ics->swb_offset, ics->num_swb)) {

                av_log(ac->avctx, AV_LOG_ERROR,

                       "Pulse data corrupt or invalid.\n");

                return AVERROR_INVALIDDATA;

            }

        }

        tns->present = get_bits1(gb);

        if (tns->present && !er_syntax)

            if (decode_tns(ac, tns, gb, ics) < 0)

                return AVERROR_INVALIDDATA;

        if (!eld_syntax && get_bits1(gb)) {

            avpriv_request_sample(ac->avctx, "SSR");

            return AVERROR_PATCHWELCOME;

        }

        

        

        if (tns->present && er_syntax)

            if (decode_tns(ac, tns, gb, ics) < 0)

                return AVERROR_INVALIDDATA;

    }



    if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present,

                                    &pulse, ics, sce->band_type) < 0)

        return AVERROR_INVALIDDATA;



    if (ac->oc[1].m4ac.object_type == AOT_AAC_MAIN && !common_window)

        apply_prediction(ac, sce);



    return 0;

}

        if (decode_ics_info(ac, ics, gb) < 0)             return AVERROR_INVALIDDATA;         return ret;         return ret;                 return AVERROR_INVALIDDATA;                 return AVERROR_INVALIDDATA;         if (tns->present && !er_syntax)             if (decode_tns(ac, tns, gb, ics) < 0)                 return AVERROR_INVALIDDATA;             return AVERROR_PATCHWELCOME;         if (tns->present && er_syntax)             if (decode_tns(ac, tns, gb, ics) < 0)                 return AVERROR_INVALIDDATA;     if (decode_spectrum_and_dequant(ac, out, gb, sce->sf, pulse_present,                                     &pulse, ics, sce->band_type) < 0)         return AVERROR_INVALIDDATA;
static int FUNC_0(AACContext *VAR_0, SingleChannelElement *VAR_1,

                      GetBitContext *VAR_2, int VAR_3, int VAR_4)

{

    Pulse pulse;

    TemporalNoiseShaping    *tns = &VAR_1->tns;

    IndividualChannelStream *ics = &VAR_1->ics;

    INTFLOAT *out = VAR_1->coeffs;

    int VAR_5, VAR_6, VAR_7, VAR_8 = 0;

    int VAR_9;



    VAR_6 = VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_ELD;

    VAR_7  = VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_LC ||

                 VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_LTP ||

                 VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_LD ||

                 VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_ELD;



    





    pulse.num_pulse = 0;



    VAR_5 = get_bits(VAR_2, 8);



    if (!VAR_3 && !VAR_4) {

        if (decode_ics_info(VAR_0, ics, VAR_2) < 0)

            return AVERROR_INVALIDDATA;

    }



    if ((VAR_9 = decode_band_types(VAR_0, VAR_1->band_type,

                                 VAR_1->band_type_run_end, VAR_2, ics)) < 0)

        return VAR_9;

    if ((VAR_9 = decode_scalefactors(VAR_0, VAR_1->sf, VAR_2, VAR_5, ics,

                                  VAR_1->band_type, VAR_1->band_type_run_end)) < 0)

        return VAR_9;



    VAR_8 = 0;

    if (!VAR_4) {

        if (!VAR_6 && (VAR_8 = get_bits1(VAR_2))) {

            if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {

                av_log(VAR_0->avctx, AV_LOG_ERROR,

                       "Pulse tool not allowed in eight short sequence.\n");

                return AVERROR_INVALIDDATA;

            }

            if (decode_pulses(&pulse, VAR_2, ics->swb_offset, ics->num_swb)) {

                av_log(VAR_0->avctx, AV_LOG_ERROR,

                       "Pulse data corrupt or invalid.\n");

                return AVERROR_INVALIDDATA;

            }

        }

        tns->present = get_bits1(VAR_2);

        if (tns->present && !VAR_7)

            if (decode_tns(VAR_0, tns, VAR_2, ics) < 0)

                return AVERROR_INVALIDDATA;

        if (!VAR_6 && get_bits1(VAR_2)) {

            avpriv_request_sample(VAR_0->avctx, "SSR");

            return AVERROR_PATCHWELCOME;

        }

        

        

        if (tns->present && VAR_7)

            if (decode_tns(VAR_0, tns, VAR_2, ics) < 0)

                return AVERROR_INVALIDDATA;

    }



    if (decode_spectrum_and_dequant(VAR_0, out, VAR_2, VAR_1->sf, VAR_8,

                                    &pulse, ics, VAR_1->band_type) < 0)

        return AVERROR_INVALIDDATA;



    if (VAR_0->oc[1].m4ac.object_type == AOT_AAC_MAIN && !VAR_3)

        apply_prediction(VAR_0, VAR_1);



    return 0;

}

static int FUNC_0(AACContext *VAR_0, SingleChannelElement *VAR_1,
GetBitContext *VAR_2, int VAR_3, int VAR_4)
{ Pulse pulse; TemporalNoiseShaping    *tns = &VAR_1->tns; IndividualChannelStream *ics = &VAR_1->ics; INTFLOAT *out = VAR_1->coeffs; int VAR_5, VAR_6, VAR_7, VAR_8 = 0; int VAR_9; VAR_6 = VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; VAR_7  = VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_LC ||
VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_LTP ||
VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_LD ||
VAR_0->oc[1].m4ac.object_type == AOT_ER_AAC_ELD; pulse.num_pulse = 0; VAR_5 = get_bits(VAR_2, 8); if (!VAR_3 && !VAR_4) { if (decode_ics_info(VAR_0, ics, VAR_2) < 0)
return AVERROR_INVALIDDATA; } if ((VAR_9 = decode_band_types(VAR_0, VAR_1->band_type,
VAR_1->band_type_run_end, VAR_2, ics)) < 0)
return VAR_9; if ((VAR_9 = decode_scalefactors(VAR_0, VAR_1->sf, VAR_2, VAR_5, ics,
VAR_1->band_type, VAR_1->band_type_run_end)) < 0)
return VAR_9; VAR_8 = 0; if (!VAR_4) { if (!VAR_6 && (VAR_8 = get_bits1(VAR_2))) { if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Pulse tool not allowed in eight short sequence.\n"); return AVERROR_INVALIDDATA; } if (decode_pulses(&pulse, VAR_2, ics->swb_offset, ics->num_swb)) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Pulse data corrupt or invalid.\n"); return AVERROR_INVALIDDATA; } } tns->present = get_bits1(VAR_2); if (tns->present && !VAR_7)
if (decode_tns(VAR_0, tns, VAR_2, ics) < 0)
return AVERROR_INVALIDDATA; if (!VAR_6 && get_bits1(VAR_2)) { avpriv_request_sample(VAR_0->avctx, "SSR"); return AVERROR_PATCHWELCOME; } if (tns->present && VAR_7)
if (decode_tns(VAR_0, tns, VAR_2, ics) < 0)
return AVERROR_INVALIDDATA; } if (decode_spectrum_and_dequant(VAR_0, out, VAR_2, VAR_1->sf, VAR_8,
&pulse, ics, VAR_1->band_type) < 0)
return AVERROR_INVALIDDATA; if (VAR_0->oc[1].m4ac.object_type == AOT_AAC_MAIN && !VAR_3)
apply_prediction(VAR_0, VAR_1); return 0; }