static inline int decode_subframe(FLACContext *s, int channel)

{

    int32_t *decoded = s->decoded[channel];

    int type, wasted = 0;

    int bps = s->flac_stream_info.bps;

    int i, tmp, ret;



    if (channel == 0) {

        if (s->ch_mode == FLAC_CHMODE_RIGHT_SIDE)

            bps++;

    } else {

        if (s->ch_mode == FLAC_CHMODE_LEFT_SIDE || s->ch_mode == FLAC_CHMODE_MID_SIDE)

            bps++;

    }



    if (get_bits1(&s->gb)) {

        av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n");

        return AVERROR_INVALIDDATA;

    }

    type = get_bits(&s->gb, 6);



    if (get_bits1(&s->gb)) {

        int left = get_bits_left(&s->gb);

        if ( left <= 0 ||

            (left < bps && !show_bits_long(&s->gb, left)) ||

                           !show_bits_long(&s->gb, bps)) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Invalid number of wasted bits > available bits (%d) - left=%d\n",

                   bps, left);

            return AVERROR_INVALIDDATA;

        }

        wasted = 1 + get_unary(&s->gb, 1, get_bits_left(&s->gb));

        bps -= wasted;

    }

    if (bps > 32) {

        avpriv_report_missing_feature(s->avctx, "Decorrelated bit depth > 32");

        return AVERROR_PATCHWELCOME;

    }



//FIXME use av_log2 for types

    if (type == 0) {

        tmp = get_sbits_long(&s->gb, bps);

        for (i = 0; i < s->blocksize; i++)

            decoded[i] = tmp;

    } else if (type == 1) {

        for (i = 0; i < s->blocksize; i++)

            decoded[i] = get_sbits_long(&s->gb, bps);

    } else if ((type >= 8) && (type <= 12)) {

        if ((ret = decode_subframe_fixed(s, decoded, type & ~0x8, bps)) < 0)

            return ret;

    } else if (type >= 32) {

        if ((ret = decode_subframe_lpc(s, decoded, (type & ~0x20)+1, bps)) < 0)

            return ret;

    } else {

        av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n");

        return AVERROR_INVALIDDATA;

    }



    if (wasted) {

        int i;

        for (i = 0; i < s->blocksize; i++)

            decoded[i] <<= wasted;

    }



    return 0;

}

static inline int decode_subframe(FLACContext *s, int channel)

{

    int32_t *decoded = s->decoded[channel];

    int type, wasted = 0;

    int bps = s->flac_stream_info.bps;

    int i, tmp, ret;



    if (channel == 0) {

        if (s->ch_mode == FLAC_CHMODE_RIGHT_SIDE)

            bps++;

    } else {

        if (s->ch_mode == FLAC_CHMODE_LEFT_SIDE || s->ch_mode == FLAC_CHMODE_MID_SIDE)

            bps++;

    }



    if (get_bits1(&s->gb)) {

        av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n");

        return AVERROR_INVALIDDATA;

    }

    type = get_bits(&s->gb, 6);



    if (get_bits1(&s->gb)) {

        int left = get_bits_left(&s->gb);

        if ( left <= 0 ||

            (left < bps && !show_bits_long(&s->gb, left)) ||

                           !show_bits_long(&s->gb, bps)) {

            av_log(s->avctx, AV_LOG_ERROR,

                   "Invalid number of wasted bits > available bits (%d) - left=%d\n",

                   bps, left);

            return AVERROR_INVALIDDATA;

        }

        wasted = 1 + get_unary(&s->gb, 1, get_bits_left(&s->gb));

        bps -= wasted;

    }

    if (bps > 32) {

        avpriv_report_missing_feature(s->avctx, "Decorrelated bit depth > 32");

        return AVERROR_PATCHWELCOME;

    }





    if (type == 0) {

        tmp = get_sbits_long(&s->gb, bps);

        for (i = 0; i < s->blocksize; i++)

            decoded[i] = tmp;

    } else if (type == 1) {

        for (i = 0; i < s->blocksize; i++)

            decoded[i] = get_sbits_long(&s->gb, bps);

    } else if ((type >= 8) && (type <= 12)) {

        if ((ret = decode_subframe_fixed(s, decoded, type & ~0x8, bps)) < 0)

            return ret;

    } else if (type >= 32) {

        if ((ret = decode_subframe_lpc(s, decoded, (type & ~0x20)+1, bps)) < 0)

            return ret;

    } else {

        av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n");

        return AVERROR_INVALIDDATA;

    }



    if (wasted) {

        int i;

        for (i = 0; i < s->blocksize; i++)

            decoded[i] <<= wasted;

    }



    return 0;

}

            decoded[i] <<= wasted;
static inline int FUNC_0(FLACContext *VAR_0, int VAR_1)

{

    int32_t *decoded = VAR_0->decoded[VAR_1];

    int VAR_2, VAR_3 = 0;

    int VAR_4 = VAR_0->flac_stream_info.VAR_4;

    int VAR_9, VAR_6, VAR_7;



    if (VAR_1 == 0) {

        if (VAR_0->ch_mode == FLAC_CHMODE_RIGHT_SIDE)

            VAR_4++;

    } else {

        if (VAR_0->ch_mode == FLAC_CHMODE_LEFT_SIDE || VAR_0->ch_mode == FLAC_CHMODE_MID_SIDE)

            VAR_4++;

    }



    if (get_bits1(&VAR_0->gb)) {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid subframe padding\n");

        return AVERROR_INVALIDDATA;

    }

    VAR_2 = get_bits(&VAR_0->gb, 6);



    if (get_bits1(&VAR_0->gb)) {

        int VAR_8 = get_bits_left(&VAR_0->gb);

        if ( VAR_8 <= 0 ||

            (VAR_8 < VAR_4 && !show_bits_long(&VAR_0->gb, VAR_8)) ||

                           !show_bits_long(&VAR_0->gb, VAR_4)) {

            av_log(VAR_0->avctx, AV_LOG_ERROR,

                   "Invalid number of VAR_3 bits > available bits (%d) - VAR_8=%d\n",

                   VAR_4, VAR_8);

            return AVERROR_INVALIDDATA;

        }

        VAR_3 = 1 + get_unary(&VAR_0->gb, 1, get_bits_left(&VAR_0->gb));

        VAR_4 -= VAR_3;

    }

    if (VAR_4 > 32) {

        avpriv_report_missing_feature(VAR_0->avctx, "Decorrelated bit depth > 32");

        return AVERROR_PATCHWELCOME;

    }





    if (VAR_2 == 0) {

        VAR_6 = get_sbits_long(&VAR_0->gb, VAR_4);

        for (VAR_9 = 0; VAR_9 < VAR_0->blocksize; VAR_9++)

            decoded[VAR_9] = VAR_6;

    } else if (VAR_2 == 1) {

        for (VAR_9 = 0; VAR_9 < VAR_0->blocksize; VAR_9++)

            decoded[VAR_9] = get_sbits_long(&VAR_0->gb, VAR_4);

    } else if ((VAR_2 >= 8) && (VAR_2 <= 12)) {

        if ((VAR_7 = decode_subframe_fixed(VAR_0, decoded, VAR_2 & ~0x8, VAR_4)) < 0)

            return VAR_7;

    } else if (VAR_2 >= 32) {

        if ((VAR_7 = decode_subframe_lpc(VAR_0, decoded, (VAR_2 & ~0x20)+1, VAR_4)) < 0)

            return VAR_7;

    } else {

        av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid coding VAR_2\n");

        return AVERROR_INVALIDDATA;

    }



    if (VAR_3) {

        int VAR_9;

        for (VAR_9 = 0; VAR_9 < VAR_0->blocksize; VAR_9++)

            decoded[VAR_9] <<= VAR_3;

    }



    return 0;

}

static inline int FUNC_0(FLACContext *VAR_0, int VAR_1)
{ int32_t *decoded = VAR_0->decoded[VAR_1]; int VAR_2, VAR_3 = 0; int VAR_4 = VAR_0->flac_stream_info.VAR_4; int VAR_9, VAR_6, VAR_7; if (VAR_1 == 0) { if (VAR_0->ch_mode == FLAC_CHMODE_RIGHT_SIDE)
VAR_4++; } else { if (VAR_0->ch_mode == FLAC_CHMODE_LEFT_SIDE || VAR_0->ch_mode == FLAC_CHMODE_MID_SIDE)
VAR_4++; } if (get_bits1(&VAR_0->gb)) { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid subframe padding\n"); return AVERROR_INVALIDDATA; } VAR_2 = get_bits(&VAR_0->gb, 6); if (get_bits1(&VAR_0->gb)) { int VAR_8 = get_bits_left(&VAR_0->gb); if ( VAR_8 <= 0 ||
(VAR_8 < VAR_4 && !show_bits_long(&VAR_0->gb, VAR_8)) ||
!show_bits_long(&VAR_0->gb, VAR_4)) { av_log(VAR_0->avctx, AV_LOG_ERROR,
"Invalid number of VAR_3 bits > available bits (%d) - VAR_8=%d\n",
VAR_4, VAR_8); return AVERROR_INVALIDDATA; } VAR_3 = 1 + get_unary(&VAR_0->gb, 1, get_bits_left(&VAR_0->gb)); VAR_4 -= VAR_3; } if (VAR_4 > 32) { avpriv_report_missing_feature(VAR_0->avctx, "Decorrelated bit depth > 32"); return AVERROR_PATCHWELCOME; } if (VAR_2 == 0) { VAR_6 = get_sbits_long(&VAR_0->gb, VAR_4); for (VAR_9 = 0; VAR_9 < VAR_0->blocksize; VAR_9++) decoded[VAR_9] = VAR_6; } else if (VAR_2 == 1) { for (VAR_9 = 0; VAR_9 < VAR_0->blocksize; VAR_9++) decoded[VAR_9] = get_sbits_long(&VAR_0->gb, VAR_4); } else if ((VAR_2 >= 8) && (VAR_2 <= 12)) { if ((VAR_7 = decode_subframe_fixed(VAR_0, decoded, VAR_2 & ~0x8, VAR_4)) < 0)
return VAR_7; } else if (VAR_2 >= 32) { if ((VAR_7 = decode_subframe_lpc(VAR_0, decoded, (VAR_2 & ~0x20)+1, VAR_4)) < 0)
return VAR_7; } else { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid coding VAR_2\n"); return AVERROR_INVALIDDATA; } if (VAR_3) { int VAR_9; for (VAR_9 = 0; VAR_9 < VAR_0->blocksize; VAR_9++) decoded[VAR_9] <<= VAR_3; } return 0; }