static int mpc8_decode_frame(AVCodecContext * avctx, void *data,

                             int *got_frame_ptr, AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    MPCContext *c = avctx->priv_data;

    GetBitContext gb2, *gb = &gb2;

    int i, j, k, ch, cnt, res, t;

    Band *bands = c->bands;

    int off;

    int maxband, keyframe;

    int last[2];



    /* get output buffer */

    c->frame.nb_samples = MPC_FRAME_SIZE;

    if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return res;

    }



    keyframe = c->cur_frame == 0;



    if(keyframe){

        memset(c->Q, 0, sizeof(c->Q));

        c->last_bits_used = 0;

    }

    init_get_bits(gb, buf, buf_size * 8);

    skip_bits(gb, c->last_bits_used & 7);



    if(keyframe)

        maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1);

    else{

        maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);

        if(maxband > 32) maxband -= 33;

    }



    if(maxband > c->maxbands + 1 || maxband >= BANDS) {

        av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband);

        return AVERROR_INVALIDDATA;

    }

    c->last_max_band = maxband;



    /* read subband indexes */

    if(maxband){

        last[0] = last[1] = 0;

        for(i = maxband - 1; i >= 0; i--){

            for(ch = 0; ch < 2; ch++){

                last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];

                if(last[ch] > 15) last[ch] -= 17;

                bands[i].res[ch] = last[ch];

            }

        }

        if(c->MSS){

            int mask;



            cnt = 0;

            for(i = 0; i < maxband; i++)

                if(bands[i].res[0] || bands[i].res[1])

                    cnt++;

            t = mpc8_get_mod_golomb(gb, cnt);

            mask = mpc8_get_mask(gb, cnt, t);

            for(i = maxband - 1; i >= 0; i--)

                if(bands[i].res[0] || bands[i].res[1]){

                    bands[i].msf = mask & 1;

                    mask >>= 1;

                }

        }

    }

    for(i = maxband; i < c->maxbands; i++)

        bands[i].res[0] = bands[i].res[1] = 0;



    if(keyframe){

        for(i = 0; i < 32; i++)

            c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;

    }



    for(i = 0; i < maxband; i++){

        if(bands[i].res[0] || bands[i].res[1]){

            cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;

            if(cnt >= 0){

                t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);

                if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);

                if(bands[i].res[1]) bands[i].scfi[1] = t & 3;

            }

        }

    }



    for(i = 0; i < maxband; i++){

        for(ch = 0; ch < 2; ch++){

            if(!bands[i].res[ch]) continue;



            if(c->oldDSCF[ch][i]){

                bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6;

                c->oldDSCF[ch][i] = 0;

            }else{

                t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);

                if(t == 64)

                    t += get_bits(gb, 6);

                bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;

            }

            for(j = 0; j < 2; j++){

                if((bands[i].scfi[ch] << j) & 2)

                    bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];

                else{

                    t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);

                    if(t == 31)

                        t = 64 + get_bits(gb, 6);

                    bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;

                }

            }

        }

    }



    for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){

        for(ch = 0; ch < 2; ch++){

            res = bands[i].res[ch];

            switch(res){

            case -1:

                for(j = 0; j < SAMPLES_PER_BAND; j++)

                    c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;

                break;

            case 0:

                break;

            case 1:

                for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){

                    cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);

                    t = mpc8_get_mask(gb, 18, cnt);

                    for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)

                        c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;

                }

                break;

            case 2:

                cnt = 6;//2*mpc8_thres[res]

                for(j = 0; j < SAMPLES_PER_BAND; j += 3){

                    t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);

                    c->Q[ch][off + j + 0] = mpc8_idx50[t];

                    c->Q[ch][off + j + 1] = mpc8_idx51[t];

                    c->Q[ch][off + j + 2] = mpc8_idx52[t];

                    cnt = (cnt >> 1) + mpc8_huffq2[t];

                }

                break;

            case 3:

            case 4:

                for(j = 0; j < SAMPLES_PER_BAND; j += 2){

                    t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];

                    c->Q[ch][off + j + 1] = t >> 4;

                    c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);

                }

                break;

            case 5:

            case 6:

            case 7:

            case 8:

                cnt = 2 * mpc8_thres[res];

                for(j = 0; j < SAMPLES_PER_BAND; j++){

                    t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];

                    c->Q[ch][off + j] = t;

                    cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);

                }

                break;

            default:

                for(j = 0; j < SAMPLES_PER_BAND; j++){

                    c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);

                    if(res != 9){

                        c->Q[ch][off + j] <<= res - 9;

                        c->Q[ch][off + j] |= get_bits(gb, res - 9);

                    }

                    c->Q[ch][off + j] -= (1 << (res - 2)) - 1;

                }

            }

        }

    }



    ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0],

                                avctx->channels);



    c->cur_frame++;



    c->last_bits_used = get_bits_count(gb);

    if(c->cur_frame >= c->frames)

        c->cur_frame = 0;



    *got_frame_ptr   = 1;

    *(AVFrame *)data = c->frame;



    return c->cur_frame ? c->last_bits_used >> 3 : buf_size;

}

static int mpc8_decode_frame(AVCodecContext * avctx, void *data,

                             int *got_frame_ptr, AVPacket *avpkt)

{

    const uint8_t *buf = avpkt->data;

    int buf_size = avpkt->size;

    MPCContext *c = avctx->priv_data;

    GetBitContext gb2, *gb = &gb2;

    int i, j, k, ch, cnt, res, t;

    Band *bands = c->bands;

    int off;

    int maxband, keyframe;

    int last[2];



    

    c->frame.nb_samples = MPC_FRAME_SIZE;

    if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) {

        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");

        return res;

    }



    keyframe = c->cur_frame == 0;



    if(keyframe){

        memset(c->Q, 0, sizeof(c->Q));

        c->last_bits_used = 0;

    }

    init_get_bits(gb, buf, buf_size * 8);

    skip_bits(gb, c->last_bits_used & 7);



    if(keyframe)

        maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1);

    else{

        maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);

        if(maxband > 32) maxband -= 33;

    }



    if(maxband > c->maxbands + 1 || maxband >= BANDS) {

        av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband);

        return AVERROR_INVALIDDATA;

    }

    c->last_max_band = maxband;



    

    if(maxband){

        last[0] = last[1] = 0;

        for(i = maxband - 1; i >= 0; i--){

            for(ch = 0; ch < 2; ch++){

                last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch];

                if(last[ch] > 15) last[ch] -= 17;

                bands[i].res[ch] = last[ch];

            }

        }

        if(c->MSS){

            int mask;



            cnt = 0;

            for(i = 0; i < maxband; i++)

                if(bands[i].res[0] || bands[i].res[1])

                    cnt++;

            t = mpc8_get_mod_golomb(gb, cnt);

            mask = mpc8_get_mask(gb, cnt, t);

            for(i = maxband - 1; i >= 0; i--)

                if(bands[i].res[0] || bands[i].res[1]){

                    bands[i].msf = mask & 1;

                    mask >>= 1;

                }

        }

    }

    for(i = maxband; i < c->maxbands; i++)

        bands[i].res[0] = bands[i].res[1] = 0;



    if(keyframe){

        for(i = 0; i < 32; i++)

            c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1;

    }



    for(i = 0; i < maxband; i++){

        if(bands[i].res[0] || bands[i].res[1]){

            cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1;

            if(cnt >= 0){

                t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1);

                if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt);

                if(bands[i].res[1]) bands[i].scfi[1] = t & 3;

            }

        }

    }



    for(i = 0; i < maxband; i++){

        for(ch = 0; ch < 2; ch++){

            if(!bands[i].res[ch]) continue;



            if(c->oldDSCF[ch][i]){

                bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6;

                c->oldDSCF[ch][i] = 0;

            }else{

                t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);

                if(t == 64)

                    t += get_bits(gb, 6);

                bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6;

            }

            for(j = 0; j < 2; j++){

                if((bands[i].scfi[ch] << j) & 2)

                    bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];

                else{

                    t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);

                    if(t == 31)

                        t = 64 + get_bits(gb, 6);

                    bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6;

                }

            }

        }

    }



    for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){

        for(ch = 0; ch < 2; ch++){

            res = bands[i].res[ch];

            switch(res){

            case -1:

                for(j = 0; j < SAMPLES_PER_BAND; j++)

                    c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;

                break;

            case 0:

                break;

            case 1:

                for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){

                    cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);

                    t = mpc8_get_mask(gb, 18, cnt);

                    for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1)

                        c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;

                }

                break;

            case 2:

                cnt = 6;

                for(j = 0; j < SAMPLES_PER_BAND; j += 3){

                    t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2);

                    c->Q[ch][off + j + 0] = mpc8_idx50[t];

                    c->Q[ch][off + j + 1] = mpc8_idx51[t];

                    c->Q[ch][off + j + 2] = mpc8_idx52[t];

                    cnt = (cnt >> 1) + mpc8_huffq2[t];

                }

                break;

            case 3:

            case 4:

                for(j = 0; j < SAMPLES_PER_BAND; j += 2){

                    t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3];

                    c->Q[ch][off + j + 1] = t >> 4;

                    c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF);

                }

                break;

            case 5:

            case 6:

            case 7:

            case 8:

                cnt = 2 * mpc8_thres[res];

                for(j = 0; j < SAMPLES_PER_BAND; j++){

                    t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5];

                    c->Q[ch][off + j] = t;

                    cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]);

                }

                break;

            default:

                for(j = 0; j < SAMPLES_PER_BAND; j++){

                    c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);

                    if(res != 9){

                        c->Q[ch][off + j] <<= res - 9;

                        c->Q[ch][off + j] |= get_bits(gb, res - 9);

                    }

                    c->Q[ch][off + j] -= (1 << (res - 2)) - 1;

                }

            }

        }

    }



    ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0],

                                avctx->channels);



    c->cur_frame++;



    c->last_bits_used = get_bits_count(gb);

    if(c->cur_frame >= c->frames)

        c->cur_frame = 0;



    *got_frame_ptr   = 1;

    *(AVFrame *)data = c->frame;



    return c->cur_frame ? c->last_bits_used >> 3 : buf_size;

}

static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1,

                             int *VAR_2, AVPacket *VAR_3)

{

    const uint8_t *VAR_4 = VAR_3->VAR_1;

    int VAR_5 = VAR_3->size;

    MPCContext *c = VAR_0->priv_data;

    GetBitContext gb2, *gb = &gb2;

    int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;

    Band *bands = c->bands;

    int VAR_13;

    int VAR_14, VAR_15;

    int VAR_16[2];



    

    c->frame.nb_samples = MPC_FRAME_SIZE;

    if ((VAR_11 = VAR_0->get_buffer(VAR_0, &c->frame)) < 0) {

        av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n");

        return VAR_11;

    }



    VAR_15 = c->cur_frame == 0;



    if(VAR_15){

        memset(c->Q, 0, sizeof(c->Q));

        c->last_bits_used = 0;

    }

    init_get_bits(gb, VAR_4, VAR_5 * 8);

    skip_bits(gb, c->last_bits_used & 7);



    if(VAR_15)

        VAR_14 = mpc8_get_mod_golomb(gb, c->maxbands + 1);

    else{

        VAR_14 = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2);

        if(VAR_14 > 32) VAR_14 -= 33;

    }



    if(VAR_14 > c->maxbands + 1 || VAR_14 >= BANDS) {

        av_log(VAR_0, AV_LOG_ERROR, "VAR_14 %d too large\n",VAR_14);

        return AVERROR_INVALIDDATA;

    }

    c->last_max_band = VAR_14;



    

    if(VAR_14){

        VAR_16[0] = VAR_16[1] = 0;

        for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--){

            for(VAR_9 = 0; VAR_9 < 2; VAR_9++){

                VAR_16[VAR_9] = get_vlc2(gb, res_vlc[VAR_16[VAR_9] > 2].table, MPC8_RES_BITS, 2) + VAR_16[VAR_9];

                if(VAR_16[VAR_9] > 15) VAR_16[VAR_9] -= 17;

                bands[VAR_6].VAR_11[VAR_9] = VAR_16[VAR_9];

            }

        }

        if(c->MSS){

            int VAR_17;



            VAR_10 = 0;

            for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++)

                if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1])

                    VAR_10++;

            VAR_12 = mpc8_get_mod_golomb(gb, VAR_10);

            VAR_17 = mpc8_get_mask(gb, VAR_10, VAR_12);

            for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--)

                if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){

                    bands[VAR_6].msf = VAR_17 & 1;

                    VAR_17 >>= 1;

                }

        }

    }

    for(VAR_6 = VAR_14; VAR_6 < c->maxbands; VAR_6++)

        bands[VAR_6].VAR_11[0] = bands[VAR_6].VAR_11[1] = 0;



    if(VAR_15){

        for(VAR_6 = 0; VAR_6 < 32; VAR_6++)

            c->oldDSCF[0][VAR_6] = c->oldDSCF[1][VAR_6] = 1;

    }



    for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){

        if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){

            VAR_10 = !!bands[VAR_6].VAR_11[0] + !!bands[VAR_6].VAR_11[1] - 1;

            if(VAR_10 >= 0){

                VAR_12 = get_vlc2(gb, scfi_vlc[VAR_10].table, scfi_vlc[VAR_10].bits, 1);

                if(bands[VAR_6].VAR_11[0]) bands[VAR_6].scfi[0] = VAR_12 >> (2 * VAR_10);

                if(bands[VAR_6].VAR_11[1]) bands[VAR_6].scfi[1] = VAR_12 & 3;

            }

        }

    }



    for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){

        for(VAR_9 = 0; VAR_9 < 2; VAR_9++){

            if(!bands[VAR_6].VAR_11[VAR_9]) continue;



            if(c->oldDSCF[VAR_9][VAR_6]){

                bands[VAR_6].scf_idx[VAR_9][0] = get_bits(gb, 7) - 6;

                c->oldDSCF[VAR_9][VAR_6] = 0;

            }else{

                VAR_12 = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2);

                if(VAR_12 == 64)

                    VAR_12 += get_bits(gb, 6);

                bands[VAR_6].scf_idx[VAR_9][0] = ((bands[VAR_6].scf_idx[VAR_9][2] + VAR_12 - 25) & 0x7F) - 6;

            }

            for(VAR_7 = 0; VAR_7 < 2; VAR_7++){

                if((bands[VAR_6].scfi[VAR_9] << VAR_7) & 2)

                    bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = bands[VAR_6].scf_idx[VAR_9][VAR_7];

                else{

                    VAR_12 = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2);

                    if(VAR_12 == 31)

                        VAR_12 = 64 + get_bits(gb, 6);

                    bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = ((bands[VAR_6].scf_idx[VAR_9][VAR_7] + VAR_12 - 25) & 0x7F) - 6;

                }

            }

        }

    }



    for(VAR_6 = 0, VAR_13 = 0; VAR_6 < VAR_14; VAR_6++, VAR_13 += SAMPLES_PER_BAND){

        for(VAR_9 = 0; VAR_9 < 2; VAR_9++){

            VAR_11 = bands[VAR_6].VAR_11[VAR_9];

            switch(VAR_11){

            case -1:

                for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++)

                    c->Q[VAR_9][VAR_13 + VAR_7] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;

                break;

            case 0:

                break;

            case 1:

                for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += SAMPLES_PER_BAND / 2){

                    VAR_10 = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2);

                    VAR_12 = mpc8_get_mask(gb, 18, VAR_10);

                    for(VAR_8 = 0; VAR_8 < SAMPLES_PER_BAND / 2; VAR_8++, VAR_12 <<= 1)

                        c->Q[VAR_9][VAR_13 + VAR_7 + VAR_8] = (VAR_12 & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0;

                }

                break;

            case 2:

                VAR_10 = 6;

                for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 3){

                    VAR_12 = get_vlc2(gb, q2_vlc[VAR_10 > 3].table, MPC8_Q2_BITS, 2);

                    c->Q[VAR_9][VAR_13 + VAR_7 + 0] = mpc8_idx50[VAR_12];

                    c->Q[VAR_9][VAR_13 + VAR_7 + 1] = mpc8_idx51[VAR_12];

                    c->Q[VAR_9][VAR_13 + VAR_7 + 2] = mpc8_idx52[VAR_12];

                    VAR_10 = (VAR_10 >> 1) + mpc8_huffq2[VAR_12];

                }

                break;

            case 3:

            case 4:

                for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 2){

                    VAR_12 = get_vlc2(gb, q3_vlc[VAR_11 - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[VAR_11 - 3];

                    c->Q[VAR_9][VAR_13 + VAR_7 + 1] = VAR_12 >> 4;

                    c->Q[VAR_9][VAR_13 + VAR_7 + 0] = (VAR_12 & 8) ? (VAR_12 & 0xF) - 16 : (VAR_12 & 0xF);

                }

                break;

            case 5:

            case 6:

            case 7:

            case 8:

                VAR_10 = 2 * mpc8_thres[VAR_11];

                for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){

                    VAR_12 = get_vlc2(gb, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].table, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].bits, 2) + quant_offsets[VAR_11 - 5];

                    c->Q[VAR_9][VAR_13 + VAR_7] = VAR_12;

                    VAR_10 = (VAR_10 >> 1) + FFABS(c->Q[VAR_9][VAR_13 + VAR_7]);

                }

                break;

            default:

                for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){

                    c->Q[VAR_9][VAR_13 + VAR_7] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2);

                    if(VAR_11 != 9){

                        c->Q[VAR_9][VAR_13 + VAR_7] <<= VAR_11 - 9;

                        c->Q[VAR_9][VAR_13 + VAR_7] |= get_bits(gb, VAR_11 - 9);

                    }

                    c->Q[VAR_9][VAR_13 + VAR_7] -= (1 << (VAR_11 - 2)) - 1;

                }

            }

        }

    }



    ff_mpc_dequantize_and_synth(c, VAR_14 - 1, c->frame.VAR_1[0],

                                VAR_0->channels);



    c->cur_frame++;



    c->last_bits_used = get_bits_count(gb);

    if(c->cur_frame >= c->frames)

        c->cur_frame = 0;



    *VAR_2   = 1;

    *(AVFrame *)VAR_1 = c->frame;



    return c->cur_frame ? c->last_bits_used >> 3 : VAR_5;

}

static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{ const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; MPCContext *c = VAR_0->priv_data; GetBitContext gb2, *gb = &gb2; int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12; Band *bands = c->bands; int VAR_13; int VAR_14, VAR_15; int VAR_16[2]; c->frame.nb_samples = MPC_FRAME_SIZE; if ((VAR_11 = VAR_0->get_buffer(VAR_0, &c->frame)) < 0) { av_log(VAR_0, AV_LOG_ERROR, "get_buffer() failed\n"); return VAR_11; } VAR_15 = c->cur_frame == 0; if(VAR_15){ memset(c->Q, 0, sizeof(c->Q)); c->last_bits_used = 0; } init_get_bits(gb, VAR_4, VAR_5 * 8); skip_bits(gb, c->last_bits_used & 7); if(VAR_15)
VAR_14 = mpc8_get_mod_golomb(gb, c->maxbands + 1); else{ VAR_14 = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2); if(VAR_14 > 32) VAR_14 -= 33; } if(VAR_14 > c->maxbands + 1 || VAR_14 >= BANDS) { av_log(VAR_0, AV_LOG_ERROR, "VAR_14 %d too large\n",VAR_14); return AVERROR_INVALIDDATA; } c->last_max_band = VAR_14; if(VAR_14){ VAR_16[0] = VAR_16[1] = 0; for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--){ for(VAR_9 = 0; VAR_9 < 2; VAR_9++){ VAR_16[VAR_9] = get_vlc2(gb, res_vlc[VAR_16[VAR_9] > 2].table, MPC8_RES_BITS, 2) + VAR_16[VAR_9]; if(VAR_16[VAR_9] > 15) VAR_16[VAR_9] -= 17; bands[VAR_6].VAR_11[VAR_9] = VAR_16[VAR_9]; } } if(c->MSS){ int VAR_17; VAR_10 = 0; for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++) if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1])
VAR_10++; VAR_12 = mpc8_get_mod_golomb(gb, VAR_10); VAR_17 = mpc8_get_mask(gb, VAR_10, VAR_12); for(VAR_6 = VAR_14 - 1; VAR_6 >= 0; VAR_6--) if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){ bands[VAR_6].msf = VAR_17 & 1; VAR_17 >>= 1; } } } for(VAR_6 = VAR_14; VAR_6 < c->maxbands; VAR_6++) bands[VAR_6].VAR_11[0] = bands[VAR_6].VAR_11[1] = 0; if(VAR_15){ for(VAR_6 = 0; VAR_6 < 32; VAR_6++) c->oldDSCF[0][VAR_6] = c->oldDSCF[1][VAR_6] = 1; } for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){ if(bands[VAR_6].VAR_11[0] || bands[VAR_6].VAR_11[1]){ VAR_10 = !!bands[VAR_6].VAR_11[0] + !!bands[VAR_6].VAR_11[1] - 1; if(VAR_10 >= 0){ VAR_12 = get_vlc2(gb, scfi_vlc[VAR_10].table, scfi_vlc[VAR_10].bits, 1); if(bands[VAR_6].VAR_11[0]) bands[VAR_6].scfi[0] = VAR_12 >> (2 * VAR_10); if(bands[VAR_6].VAR_11[1]) bands[VAR_6].scfi[1] = VAR_12 & 3; } } } for(VAR_6 = 0; VAR_6 < VAR_14; VAR_6++){ for(VAR_9 = 0; VAR_9 < 2; VAR_9++){ if(!bands[VAR_6].VAR_11[VAR_9]) continue; if(c->oldDSCF[VAR_9][VAR_6]){ bands[VAR_6].scf_idx[VAR_9][0] = get_bits(gb, 7) - 6; c->oldDSCF[VAR_9][VAR_6] = 0; }else{ VAR_12 = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2); if(VAR_12 == 64)
VAR_12 += get_bits(gb, 6); bands[VAR_6].scf_idx[VAR_9][0] = ((bands[VAR_6].scf_idx[VAR_9][2] + VAR_12 - 25) & 0x7F) - 6; } for(VAR_7 = 0; VAR_7 < 2; VAR_7++){ if((bands[VAR_6].scfi[VAR_9] << VAR_7) & 2)
bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = bands[VAR_6].scf_idx[VAR_9][VAR_7]; else{ VAR_12 = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2); if(VAR_12 == 31)
VAR_12 = 64 + get_bits(gb, 6); bands[VAR_6].scf_idx[VAR_9][VAR_7 + 1] = ((bands[VAR_6].scf_idx[VAR_9][VAR_7] + VAR_12 - 25) & 0x7F) - 6; } } } } for(VAR_6 = 0, VAR_13 = 0; VAR_6 < VAR_14; VAR_6++, VAR_13 += SAMPLES_PER_BAND){ for(VAR_9 = 0; VAR_9 < 2; VAR_9++){ VAR_11 = bands[VAR_6].VAR_11[VAR_9]; switch(VAR_11){ case -1:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++) c->Q[VAR_9][VAR_13 + VAR_7] = (av_lfg_get(&c->rnd) & 0x3FC) - 510; break; case 0:
break; case 1:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += SAMPLES_PER_BAND / 2){ VAR_10 = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2); VAR_12 = mpc8_get_mask(gb, 18, VAR_10); for(VAR_8 = 0; VAR_8 < SAMPLES_PER_BAND / 2; VAR_8++, VAR_12 <<= 1) c->Q[VAR_9][VAR_13 + VAR_7 + VAR_8] = (VAR_12 & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0; } break; case 2:
VAR_10 = 6; for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 3){ VAR_12 = get_vlc2(gb, q2_vlc[VAR_10 > 3].table, MPC8_Q2_BITS, 2); c->Q[VAR_9][VAR_13 + VAR_7 + 0] = mpc8_idx50[VAR_12]; c->Q[VAR_9][VAR_13 + VAR_7 + 1] = mpc8_idx51[VAR_12]; c->Q[VAR_9][VAR_13 + VAR_7 + 2] = mpc8_idx52[VAR_12]; VAR_10 = (VAR_10 >> 1) + mpc8_huffq2[VAR_12]; } break; case 3:
case 4:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7 += 2){ VAR_12 = get_vlc2(gb, q3_vlc[VAR_11 - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[VAR_11 - 3]; c->Q[VAR_9][VAR_13 + VAR_7 + 1] = VAR_12 >> 4; c->Q[VAR_9][VAR_13 + VAR_7 + 0] = (VAR_12 & 8) ? (VAR_12 & 0xF) - 16 : (VAR_12 & 0xF); } break; case 5:
case 6:
case 7:
case 8:
VAR_10 = 2 * mpc8_thres[VAR_11]; for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){ VAR_12 = get_vlc2(gb, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].table, quant_vlc[VAR_11 - 5][VAR_10 > mpc8_thres[VAR_11]].bits, 2) + quant_offsets[VAR_11 - 5]; c->Q[VAR_9][VAR_13 + VAR_7] = VAR_12; VAR_10 = (VAR_10 >> 1) + FFABS(c->Q[VAR_9][VAR_13 + VAR_7]); } break; default:
for(VAR_7 = 0; VAR_7 < SAMPLES_PER_BAND; VAR_7++){ c->Q[VAR_9][VAR_13 + VAR_7] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2); if(VAR_11 != 9){ c->Q[VAR_9][VAR_13 + VAR_7] <<= VAR_11 - 9; c->Q[VAR_9][VAR_13 + VAR_7] |= get_bits(gb, VAR_11 - 9); } c->Q[VAR_9][VAR_13 + VAR_7] -= (1 << (VAR_11 - 2)) - 1; } } } } ff_mpc_dequantize_and_synth(c, VAR_14 - 1, c->frame.VAR_1[0],
VAR_0->channels); c->cur_frame++; c->last_bits_used = get_bits_count(gb); if(c->cur_frame >= c->frames)
c->cur_frame = 0; *VAR_2   = 1; *(AVFrame *)VAR_1 = c->frame; return c->cur_frame ? c->last_bits_used >> 3 : VAR_5; }