static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)

{

    int i = 0;

    unsigned int ave_mean;

    s->transient[ch] = get_bits1(&s->gb);

    if (s->transient[ch]) {

        s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size));

        if (s->transient_pos[ch])

            s->transient[ch] = 0;

        s->channel[ch].transient_counter =

            FFMAX(s->channel[ch].transient_counter, s->samples_per_frame / 2);

    } else if (s->channel[ch].transient_counter)

        s->transient[ch] = 1;



    if (s->seekable_tile) {

        ave_mean = get_bits(&s->gb, s->bits_per_sample);

        s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1);

    }



    if (s->seekable_tile) {

        if (s->do_inter_ch_decorr)

            s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample + 1);

        else

            s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample);

        i++;

    }

    for (; i < tile_size; i++) {

        int quo = 0, rem, rem_bits, residue;

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

            quo++;

            if (get_bits_left(&s->gb) <= 0)

                return -1;

        }

        if (quo >= 32)

            quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1);



        ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1);

        if (ave_mean <= 1)

            residue = quo;

        else {

            rem_bits = av_ceil_log2(ave_mean);

            rem      = rem_bits ? get_bits(&s->gb, rem_bits) : 0;

            residue  = (quo << rem_bits) + rem;

        }



        s->ave_sum[ch] = residue + s->ave_sum[ch] -

                         (s->ave_sum[ch] >> s->movave_scaling);



        if (residue & 1)

            residue = -(residue >> 1) - 1;

        else

            residue = residue >> 1;

        s->channel_residues[ch][i] = residue;

    }



    return 0;



}

static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size)

{

    int i = 0;

    unsigned int ave_mean;

    s->transient[ch] = get_bits1(&s->gb);

    if (s->transient[ch]) {

        s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size));

        if (s->transient_pos[ch])

            s->transient[ch] = 0;

        s->channel[ch].transient_counter =

            FFMAX(s->channel[ch].transient_counter, s->samples_per_frame / 2);

    } else if (s->channel[ch].transient_counter)

        s->transient[ch] = 1;



    if (s->seekable_tile) {

        ave_mean = get_bits(&s->gb, s->bits_per_sample);

        s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1);

    }



    if (s->seekable_tile) {

        if (s->do_inter_ch_decorr)

            s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample + 1);

        else

            s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample);

        i++;

    }

    for (; i < tile_size; i++) {

        int quo = 0, rem, rem_bits, residue;

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

            quo++;

            if (get_bits_left(&s->gb) <= 0)

                return -1;

        }

        if (quo >= 32)

            quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1);



        ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1);

        if (ave_mean <= 1)

            residue = quo;

        else {

            rem_bits = av_ceil_log2(ave_mean);

            rem      = rem_bits ? get_bits(&s->gb, rem_bits) : 0;

            residue  = (quo << rem_bits) + rem;

        }



        s->ave_sum[ch] = residue + s->ave_sum[ch] -

                         (s->ave_sum[ch] >> s->movave_scaling);



        if (residue & 1)

            residue = -(residue >> 1) - 1;

        else

            residue = residue >> 1;

        s->channel_residues[ch][i] = residue;

    }



    return 0;



}

            rem      = rem_bits ? get_bits(&s->gb, rem_bits) : 0;
static int FUNC_0(WmallDecodeCtx *VAR_0, int VAR_1, int VAR_2)

{

    int VAR_3 = 0;

    unsigned int VAR_4;

    VAR_0->transient[VAR_1] = get_bits1(&VAR_0->gb);

    if (VAR_0->transient[VAR_1]) {

        VAR_0->transient_pos[VAR_1] = get_bits(&VAR_0->gb, av_log2(VAR_2));

        if (VAR_0->transient_pos[VAR_1])

            VAR_0->transient[VAR_1] = 0;

        VAR_0->channel[VAR_1].transient_counter =

            FFMAX(VAR_0->channel[VAR_1].transient_counter, VAR_0->samples_per_frame / 2);

    } else if (VAR_0->channel[VAR_1].transient_counter)

        VAR_0->transient[VAR_1] = 1;



    if (VAR_0->seekable_tile) {

        VAR_4 = get_bits(&VAR_0->gb, VAR_0->bits_per_sample);

        VAR_0->ave_sum[VAR_1] = VAR_4 << (VAR_0->movave_scaling + 1);

    }



    if (VAR_0->seekable_tile) {

        if (VAR_0->do_inter_ch_decorr)

            VAR_0->channel_residues[VAR_1][0] = get_sbits(&VAR_0->gb, VAR_0->bits_per_sample + 1);

        else

            VAR_0->channel_residues[VAR_1][0] = get_sbits(&VAR_0->gb, VAR_0->bits_per_sample);

        VAR_3++;

    }

    for (; VAR_3 < VAR_2; VAR_3++) {

        int VAR_5 = 0, VAR_6, VAR_7, VAR_8;

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

            VAR_5++;

            if (get_bits_left(&VAR_0->gb) <= 0)

                return -1;

        }

        if (VAR_5 >= 32)

            VAR_5 += get_bits_long(&VAR_0->gb, get_bits(&VAR_0->gb, 5) + 1);



        VAR_4 = (VAR_0->ave_sum[VAR_1] + (1 << VAR_0->movave_scaling)) >> (VAR_0->movave_scaling + 1);

        if (VAR_4 <= 1)

            VAR_8 = VAR_5;

        else {

            VAR_7 = av_ceil_log2(VAR_4);

            VAR_6      = VAR_7 ? get_bits(&VAR_0->gb, VAR_7) : 0;

            VAR_8  = (VAR_5 << VAR_7) + VAR_6;

        }



        VAR_0->ave_sum[VAR_1] = VAR_8 + VAR_0->ave_sum[VAR_1] -

                         (VAR_0->ave_sum[VAR_1] >> VAR_0->movave_scaling);



        if (VAR_8 & 1)

            VAR_8 = -(VAR_8 >> 1) - 1;

        else

            VAR_8 = VAR_8 >> 1;

        VAR_0->channel_residues[VAR_1][VAR_3] = VAR_8;

    }



    return 0;



}

static int FUNC_0(WmallDecodeCtx *VAR_0, int VAR_1, int VAR_2)
{ int VAR_3 = 0; unsigned int VAR_4; VAR_0->transient[VAR_1] = get_bits1(&VAR_0->gb); if (VAR_0->transient[VAR_1]) { VAR_0->transient_pos[VAR_1] = get_bits(&VAR_0->gb, av_log2(VAR_2)); if (VAR_0->transient_pos[VAR_1])
VAR_0->transient[VAR_1] = 0; VAR_0->channel[VAR_1].transient_counter =
FFMAX(VAR_0->channel[VAR_1].transient_counter, VAR_0->samples_per_frame / 2); } else if (VAR_0->channel[VAR_1].transient_counter) VAR_0->transient[VAR_1] = 1; if (VAR_0->seekable_tile) { VAR_4 = get_bits(&VAR_0->gb, VAR_0->bits_per_sample); VAR_0->ave_sum[VAR_1] = VAR_4 << (VAR_0->movave_scaling + 1); } if (VAR_0->seekable_tile) { if (VAR_0->do_inter_ch_decorr)
VAR_0->channel_residues[VAR_1][0] = get_sbits(&VAR_0->gb, VAR_0->bits_per_sample + 1); else
VAR_0->channel_residues[VAR_1][0] = get_sbits(&VAR_0->gb, VAR_0->bits_per_sample); VAR_3++; } for (; VAR_3 < VAR_2; VAR_3++) { int VAR_5 = 0, VAR_6, VAR_7, VAR_8; while(get_bits1(&VAR_0->gb)) { VAR_5++; if (get_bits_left(&VAR_0->gb) <= 0)
return -1; } if (VAR_5 >= 32)
VAR_5 += get_bits_long(&VAR_0->gb, get_bits(&VAR_0->gb, 5) + 1); VAR_4 = (VAR_0->ave_sum[VAR_1] + (1 << VAR_0->movave_scaling)) >> (VAR_0->movave_scaling + 1); if (VAR_4 <= 1)
VAR_8 = VAR_5; else { VAR_7 = av_ceil_log2(VAR_4); VAR_6      = VAR_7 ? get_bits(&VAR_0->gb, VAR_7) : 0; VAR_8  = (VAR_5 << VAR_7) + VAR_6; } VAR_0->ave_sum[VAR_1] = VAR_8 + VAR_0->ave_sum[VAR_1] -
(VAR_0->ave_sum[VAR_1] >> VAR_0->movave_scaling); if (VAR_8 & 1)
VAR_8 = -(VAR_8 >> 1) - 1; else
VAR_8 = VAR_8 >> 1; VAR_0->channel_residues[VAR_1][VAR_3] = VAR_8; } return 0; }