static int vc1_decode_p_mb_intfr(VC1Context *v)

{

    MpegEncContext *s = &v->s;

    GetBitContext *gb = &s->gb;

    int i;

    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;

    int cbp = 0; /* cbp decoding stuff */

    int mqdiff, mquant; /* MB quantization */

    int ttmb = v->ttfrm; /* MB Transform type */



    int mb_has_coeffs = 1; /* last_flag */

    int dmv_x, dmv_y; /* Differential MV components */

    int val; /* temp value */

    int first_block = 1;

    int dst_idx, off;

    int skipped, fourmv = 0, twomv = 0;

    int block_cbp = 0, pat, block_tt = 0;

    int idx_mbmode = 0, mvbp;

    int stride_y, fieldtx;



    mquant = v->pq; /* Loosy initialization */



    if (v->skip_is_raw)

        skipped = get_bits1(gb);

    else

        skipped = v->s.mbskip_table[mb_pos];

    if (!skipped) {

        if (v->fourmvswitch)

            idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done

        else

            idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line

        switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) {

        /* store the motion vector type in a flag (useful later) */

        case MV_PMODE_INTFR_4MV:

            fourmv = 1;

            v->blk_mv_type[s->block_index[0]] = 0;

            v->blk_mv_type[s->block_index[1]] = 0;

            v->blk_mv_type[s->block_index[2]] = 0;

            v->blk_mv_type[s->block_index[3]] = 0;

            break;

        case MV_PMODE_INTFR_4MV_FIELD:

            fourmv = 1;

            v->blk_mv_type[s->block_index[0]] = 1;

            v->blk_mv_type[s->block_index[1]] = 1;

            v->blk_mv_type[s->block_index[2]] = 1;

            v->blk_mv_type[s->block_index[3]] = 1;

            break;

        case MV_PMODE_INTFR_2MV_FIELD:

            twomv = 1;

            v->blk_mv_type[s->block_index[0]] = 1;

            v->blk_mv_type[s->block_index[1]] = 1;

            v->blk_mv_type[s->block_index[2]] = 1;

            v->blk_mv_type[s->block_index[3]] = 1;

            break;

        case MV_PMODE_INTFR_1MV:

            v->blk_mv_type[s->block_index[0]] = 0;

            v->blk_mv_type[s->block_index[1]] = 0;

            v->blk_mv_type[s->block_index[2]] = 0;

            v->blk_mv_type[s->block_index[3]] = 0;

            break;

        }

        if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { // intra MB

            s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;

            s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;

            s->current_picture.f.mb_type[mb_pos]                     = MB_TYPE_INTRA;

            s->mb_intra = v->is_intra[s->mb_x] = 1;

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

                v->mb_type[0][s->block_index[i]] = 1;

            fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);

            mb_has_coeffs = get_bits1(gb);

            if (mb_has_coeffs)

                cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);

            v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);

            GET_MQUANT();

            s->current_picture.f.qscale_table[mb_pos] = mquant;

            /* Set DC scale - y and c use the same (not sure if necessary here) */

            s->y_dc_scale = s->y_dc_scale_table[mquant];

            s->c_dc_scale = s->c_dc_scale_table[mquant];

            dst_idx = 0;

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

                s->dc_val[0][s->block_index[i]] = 0;

                dst_idx += i >> 2;

                val = ((cbp >> (5 - i)) & 1);

                v->mb_type[0][s->block_index[i]] = s->mb_intra;

                v->a_avail = v->c_avail = 0;

                if (i == 2 || i == 3 || !s->first_slice_line)

                    v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];

                if (i == 1 || i == 3 || s->mb_x)

                    v->c_avail = v->mb_type[0][s->block_index[i] - 1];



                vc1_decode_intra_block(v, s->block[i], i, val, mquant,

                                       (i & 4) ? v->codingset2 : v->codingset);

                if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;

                v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);

                if (i < 4) {

                    stride_y = s->linesize << fieldtx;

                    off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;

                } else {

                    stride_y = s->uvlinesize;

                    off = 0;

                }

                s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);

                //TODO: loop filter

            }



        } else { // inter MB

            mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];

            if (mb_has_coeffs)

                cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);

            if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {

                v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);

            } else {

                if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV)

                    || (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) {

                    v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);

                }

            }

            s->mb_intra = v->is_intra[s->mb_x] = 0;

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

                v->mb_type[0][s->block_index[i]] = 0;

            fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1];

            /* for all motion vector read MVDATA and motion compensate each block */

            dst_idx = 0;

            if (fourmv) {

                mvbp = v->fourmvbp;

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

                    if (i < 4) {


                        val   = ((mvbp >> (3 - i)) & 1);

                        if (val) {

                            get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                        }

                        vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);

                        vc1_mc_4mv_luma(v, i, 0);

                    } else if (i == 4) {

                        vc1_mc_4mv_chroma4(v);

                    }

                }

            } else if (twomv) {

                mvbp  = v->twomvbp;


                if (mvbp & 2) {

                    get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                }

                vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);

                vc1_mc_4mv_luma(v, 0, 0);

                vc1_mc_4mv_luma(v, 1, 0);


                if (mvbp & 1) {

                    get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                }

                vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);

                vc1_mc_4mv_luma(v, 2, 0);

                vc1_mc_4mv_luma(v, 3, 0);

                vc1_mc_4mv_chroma4(v);

            } else {

                mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];


                if (mvbp) {

                    get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                }

                vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);

                vc1_mc_1mv(v, 0);

            }

            if (cbp)

                GET_MQUANT();  // p. 227

            s->current_picture.f.qscale_table[mb_pos] = mquant;

            if (!v->ttmbf && cbp)

                ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);

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

                s->dc_val[0][s->block_index[i]] = 0;

                dst_idx += i >> 2;

                val = ((cbp >> (5 - i)) & 1);

                if (!fieldtx)

                    off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);

                else

                    off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));

                if (val) {

                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,

                                             first_block, s->dest[dst_idx] + off,

                                             (i & 4) ? s->uvlinesize : (s->linesize << fieldtx),

                                             (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);

                    block_cbp |= pat << (i << 2);

                    if (!v->ttmbf && ttmb < 8)

                        ttmb = -1;

                    first_block = 0;

                }

            }

        }

    } else { // skipped

        s->mb_intra = v->is_intra[s->mb_x] = 0;

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

            v->mb_type[0][s->block_index[i]] = 0;

            s->dc_val[0][s->block_index[i]] = 0;

        }

        s->current_picture.f.mb_type[mb_pos]      = MB_TYPE_SKIP;

        s->current_picture.f.qscale_table[mb_pos] = 0;

        v->blk_mv_type[s->block_index[0]] = 0;

        v->blk_mv_type[s->block_index[1]] = 0;

        v->blk_mv_type[s->block_index[2]] = 0;

        v->blk_mv_type[s->block_index[3]] = 0;

        vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);

        vc1_mc_1mv(v, 0);

    }

    if (s->mb_x == s->mb_width - 1)

        memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride);

    return 0;

}
static int vc1_decode_p_mb_intfr(VC1Context *v)

{

    MpegEncContext *s = &v->s;

    GetBitContext *gb = &s->gb;

    int i;

    int mb_pos = s->mb_x + s->mb_y * s->mb_stride;

    int cbp = 0; 

    int mqdiff, mquant; 

    int ttmb = v->ttfrm; 



    int mb_has_coeffs = 1; 

    int dmv_x, dmv_y; 

    int val; 

    int first_block = 1;

    int dst_idx, off;

    int skipped, fourmv = 0, twomv = 0;

    int block_cbp = 0, pat, block_tt = 0;

    int idx_mbmode = 0, mvbp;

    int stride_y, fieldtx;



    mquant = v->pq; 



    if (v->skip_is_raw)

        skipped = get_bits1(gb);

    else

        skipped = v->s.mbskip_table[mb_pos];

    if (!skipped) {

        if (v->fourmvswitch)

            idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); 

        else

            idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); 

        switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) {

        

        case MV_PMODE_INTFR_4MV:

            fourmv = 1;

            v->blk_mv_type[s->block_index[0]] = 0;

            v->blk_mv_type[s->block_index[1]] = 0;

            v->blk_mv_type[s->block_index[2]] = 0;

            v->blk_mv_type[s->block_index[3]] = 0;

            break;

        case MV_PMODE_INTFR_4MV_FIELD:

            fourmv = 1;

            v->blk_mv_type[s->block_index[0]] = 1;

            v->blk_mv_type[s->block_index[1]] = 1;

            v->blk_mv_type[s->block_index[2]] = 1;

            v->blk_mv_type[s->block_index[3]] = 1;

            break;

        case MV_PMODE_INTFR_2MV_FIELD:

            twomv = 1;

            v->blk_mv_type[s->block_index[0]] = 1;

            v->blk_mv_type[s->block_index[1]] = 1;

            v->blk_mv_type[s->block_index[2]] = 1;

            v->blk_mv_type[s->block_index[3]] = 1;

            break;

        case MV_PMODE_INTFR_1MV:

            v->blk_mv_type[s->block_index[0]] = 0;

            v->blk_mv_type[s->block_index[1]] = 0;

            v->blk_mv_type[s->block_index[2]] = 0;

            v->blk_mv_type[s->block_index[3]] = 0;

            break;

        }

        if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { 

            s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;

            s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;

            s->current_picture.f.mb_type[mb_pos]                     = MB_TYPE_INTRA;

            s->mb_intra = v->is_intra[s->mb_x] = 1;

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

                v->mb_type[0][s->block_index[i]] = 1;

            fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);

            mb_has_coeffs = get_bits1(gb);

            if (mb_has_coeffs)

                cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);

            v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);

            GET_MQUANT();

            s->current_picture.f.qscale_table[mb_pos] = mquant;

            

            s->y_dc_scale = s->y_dc_scale_table[mquant];

            s->c_dc_scale = s->c_dc_scale_table[mquant];

            dst_idx = 0;

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

                s->dc_val[0][s->block_index[i]] = 0;

                dst_idx += i >> 2;

                val = ((cbp >> (5 - i)) & 1);

                v->mb_type[0][s->block_index[i]] = s->mb_intra;

                v->a_avail = v->c_avail = 0;

                if (i == 2 || i == 3 || !s->first_slice_line)

                    v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];

                if (i == 1 || i == 3 || s->mb_x)

                    v->c_avail = v->mb_type[0][s->block_index[i] - 1];



                vc1_decode_intra_block(v, s->block[i], i, val, mquant,

                                       (i & 4) ? v->codingset2 : v->codingset);

                if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue;

                v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);

                if (i < 4) {

                    stride_y = s->linesize << fieldtx;

                    off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;

                } else {

                    stride_y = s->uvlinesize;

                    off = 0;

                }

                s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y);

                

            }



        } else { 

            mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];

            if (mb_has_coeffs)

                cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);

            if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {

                v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);

            } else {

                if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV)

                    || (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) {

                    v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);

                }

            }

            s->mb_intra = v->is_intra[s->mb_x] = 0;

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

                v->mb_type[0][s->block_index[i]] = 0;

            fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1];

            

            dst_idx = 0;

            if (fourmv) {

                mvbp = v->fourmvbp;

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

                    if (i < 4) {


                        val   = ((mvbp >> (3 - i)) & 1);

                        if (val) {

                            get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                        }

                        vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]);

                        vc1_mc_4mv_luma(v, i, 0);

                    } else if (i == 4) {

                        vc1_mc_4mv_chroma4(v);

                    }

                }

            } else if (twomv) {

                mvbp  = v->twomvbp;


                if (mvbp & 2) {

                    get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                }

                vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);

                vc1_mc_4mv_luma(v, 0, 0);

                vc1_mc_4mv_luma(v, 1, 0);


                if (mvbp & 1) {

                    get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                }

                vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]);

                vc1_mc_4mv_luma(v, 2, 0);

                vc1_mc_4mv_luma(v, 3, 0);

                vc1_mc_4mv_chroma4(v);

            } else {

                mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];


                if (mvbp) {

                    get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);

                }

                vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]);

                vc1_mc_1mv(v, 0);

            }

            if (cbp)

                GET_MQUANT();  

            s->current_picture.f.qscale_table[mb_pos] = mquant;

            if (!v->ttmbf && cbp)

                ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);

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

                s->dc_val[0][s->block_index[i]] = 0;

                dst_idx += i >> 2;

                val = ((cbp >> (5 - i)) & 1);

                if (!fieldtx)

                    off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);

                else

                    off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));

                if (val) {

                    pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,

                                             first_block, s->dest[dst_idx] + off,

                                             (i & 4) ? s->uvlinesize : (s->linesize << fieldtx),

                                             (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt);

                    block_cbp |= pat << (i << 2);

                    if (!v->ttmbf && ttmb < 8)

                        ttmb = -1;

                    first_block = 0;

                }

            }

        }

    } else { 

        s->mb_intra = v->is_intra[s->mb_x] = 0;

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

            v->mb_type[0][s->block_index[i]] = 0;

            s->dc_val[0][s->block_index[i]] = 0;

        }

        s->current_picture.f.mb_type[mb_pos]      = MB_TYPE_SKIP;

        s->current_picture.f.qscale_table[mb_pos] = 0;

        v->blk_mv_type[s->block_index[0]] = 0;

        v->blk_mv_type[s->block_index[1]] = 0;

        v->blk_mv_type[s->block_index[2]] = 0;

        v->blk_mv_type[s->block_index[3]] = 0;

        vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]);

        vc1_mc_1mv(v, 0);

    }

    if (s->mb_x == s->mb_width - 1)

        memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride);

    return 0;

}
static int FUNC_0(VC1Context *VAR_0)

{

    MpegEncContext *s = &VAR_0->s;

    GetBitContext *gb = &s->gb;

    int VAR_1;

    int VAR_2 = s->mb_x + s->mb_y * s->mb_stride;

    int VAR_3 = 0; 

    int VAR_4, VAR_5; 

    int VAR_6 = VAR_0->ttfrm; 



    int VAR_7 = 1; 

    int VAR_8, VAR_9; 

    int VAR_10; 

    int VAR_11 = 1;

    int VAR_12, VAR_13;

    int VAR_14, VAR_15 = 0, VAR_16 = 0;

    int VAR_17 = 0, VAR_18, VAR_19 = 0;

    int VAR_20 = 0, VAR_21;

    int VAR_22, VAR_23;



    VAR_5 = VAR_0->pq; 



    if (VAR_0->skip_is_raw)

        VAR_14 = get_bits1(gb);

    else

        VAR_14 = VAR_0->s.mbskip_table[VAR_2];

    if (!VAR_14) {

        if (VAR_0->fourmvswitch)

            VAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); 

        else

            VAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); 

        switch (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0]) {

        

        case MV_PMODE_INTFR_4MV:

            VAR_15 = 1;

            VAR_0->blk_mv_type[s->block_index[0]] = 0;

            VAR_0->blk_mv_type[s->block_index[1]] = 0;

            VAR_0->blk_mv_type[s->block_index[2]] = 0;

            VAR_0->blk_mv_type[s->block_index[3]] = 0;

            break;

        case MV_PMODE_INTFR_4MV_FIELD:

            VAR_15 = 1;

            VAR_0->blk_mv_type[s->block_index[0]] = 1;

            VAR_0->blk_mv_type[s->block_index[1]] = 1;

            VAR_0->blk_mv_type[s->block_index[2]] = 1;

            VAR_0->blk_mv_type[s->block_index[3]] = 1;

            break;

        case MV_PMODE_INTFR_2MV_FIELD:

            VAR_16 = 1;

            VAR_0->blk_mv_type[s->block_index[0]] = 1;

            VAR_0->blk_mv_type[s->block_index[1]] = 1;

            VAR_0->blk_mv_type[s->block_index[2]] = 1;

            VAR_0->blk_mv_type[s->block_index[3]] = 1;

            break;

        case MV_PMODE_INTFR_1MV:

            VAR_0->blk_mv_type[s->block_index[0]] = 0;

            VAR_0->blk_mv_type[s->block_index[1]] = 0;

            VAR_0->blk_mv_type[s->block_index[2]] = 0;

            VAR_0->blk_mv_type[s->block_index[3]] = 0;

            break;

        }

        if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_INTRA) { 

            s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0;

            s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0;

            s->current_picture.f.mb_type[VAR_2]                     = MB_TYPE_INTRA;

            s->mb_intra = VAR_0->is_intra[s->mb_x] = 1;

            for (VAR_1 = 0; VAR_1 < 6; VAR_1++)

                VAR_0->mb_type[0][s->block_index[VAR_1]] = 1;

            VAR_23 = VAR_0->fieldtx_plane[VAR_2] = get_bits1(gb);

            VAR_7 = get_bits1(gb);

            if (VAR_7)

                VAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);

            VAR_0->s.ac_pred = VAR_0->acpred_plane[VAR_2] = get_bits1(gb);

            GET_MQUANT();

            s->current_picture.f.qscale_table[VAR_2] = VAR_5;

            

            s->y_dc_scale = s->y_dc_scale_table[VAR_5];

            s->c_dc_scale = s->c_dc_scale_table[VAR_5];

            VAR_12 = 0;

            for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {

                s->dc_val[0][s->block_index[VAR_1]] = 0;

                VAR_12 += VAR_1 >> 2;

                VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1);

                VAR_0->mb_type[0][s->block_index[VAR_1]] = s->mb_intra;

                VAR_0->a_avail = VAR_0->c_avail = 0;

                if (VAR_1 == 2 || VAR_1 == 3 || !s->first_slice_line)

                    VAR_0->a_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - s->block_wrap[VAR_1]];

                if (VAR_1 == 1 || VAR_1 == 3 || s->mb_x)

                    VAR_0->c_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - 1];



                vc1_decode_intra_block(VAR_0, s->block[VAR_1], VAR_1, VAR_10, VAR_5,

                                       (VAR_1 & 4) ? VAR_0->codingset2 : VAR_0->codingset);

                if ((VAR_1>3) && (s->flags & CODEC_FLAG_GRAY)) continue;

                VAR_0->vc1dsp.vc1_inv_trans_8x8(s->block[VAR_1]);

                if (VAR_1 < 4) {

                    VAR_22 = s->linesize << VAR_23;

                    VAR_13 = (VAR_23) ? ((VAR_1 & 1) * 8) + ((VAR_1 & 2) >> 1) * s->linesize : (VAR_1 & 1) * 8 + 4 * (VAR_1 & 2) * s->linesize;

                } else {

                    VAR_22 = s->uvlinesize;

                    VAR_13 = 0;

                }

                s->dsp.put_signed_pixels_clamped(s->block[VAR_1], s->dest[VAR_12] + VAR_13, VAR_22);

                

            }



        } else { 

            VAR_7 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][3];

            if (VAR_7)

                VAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);

            if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_2MV_FIELD) {

                VAR_0->twomvbp = get_vlc2(gb, VAR_0->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);

            } else {

                if ((ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV)

                    || (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV_FIELD)) {

                    VAR_0->fourmvbp = get_vlc2(gb, VAR_0->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);

                }

            }

            s->mb_intra = VAR_0->is_intra[s->mb_x] = 0;

            for (VAR_1 = 0; VAR_1 < 6; VAR_1++)

                VAR_0->mb_type[0][s->block_index[VAR_1]] = 0;

            VAR_23 = VAR_0->fieldtx_plane[VAR_2] = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][1];

            

            VAR_12 = 0;

            if (VAR_15) {

                VAR_21 = VAR_0->fourmvbp;

                for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {

                    if (VAR_1 < 4) {


                        VAR_10   = ((VAR_21 >> (3 - VAR_1)) & 1);

                        if (VAR_10) {

                            get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);

                        }

                        vc1_pred_mv_intfr(VAR_0, VAR_1, VAR_8, VAR_9, 0, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);

                        vc1_mc_4mv_luma(VAR_0, VAR_1, 0);

                    } else if (VAR_1 == 4) {

                        vc1_mc_4mv_chroma4(VAR_0);

                    }

                }

            } else if (VAR_16) {

                VAR_21  = VAR_0->twomvbp;


                if (VAR_21 & 2) {

                    get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);

                }

                vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);

                vc1_mc_4mv_luma(VAR_0, 0, 0);

                vc1_mc_4mv_luma(VAR_0, 1, 0);


                if (VAR_21 & 1) {

                    get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);

                }

                vc1_pred_mv_intfr(VAR_0, 2, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);

                vc1_mc_4mv_luma(VAR_0, 2, 0);

                vc1_mc_4mv_luma(VAR_0, 3, 0);

                vc1_mc_4mv_chroma4(VAR_0);

            } else {

                VAR_21 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][2];


                if (VAR_21) {

                    get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0);

                }

                vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);

                vc1_mc_1mv(VAR_0, 0);

            }

            if (VAR_3)

                GET_MQUANT();  

            s->current_picture.f.qscale_table[VAR_2] = VAR_5;

            if (!VAR_0->ttmbf && VAR_3)

                VAR_6 = get_vlc2(gb, ff_vc1_ttmb_vlc[VAR_0->tt_index].table, VC1_TTMB_VLC_BITS, 2);

            for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {

                s->dc_val[0][s->block_index[VAR_1]] = 0;

                VAR_12 += VAR_1 >> 2;

                VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1);

                if (!VAR_23)

                    VAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + (VAR_1 & 2) * 4 * s->linesize);

                else

                    VAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + ((VAR_1 > 1) * s->linesize));

                if (VAR_10) {

                    VAR_18 = vc1_decode_p_block(VAR_0, s->block[VAR_1], VAR_1, VAR_5, VAR_6,

                                             VAR_11, s->dest[VAR_12] + VAR_13,

                                             (VAR_1 & 4) ? s->uvlinesize : (s->linesize << VAR_23),

                                             (VAR_1 & 4) && (s->flags & CODEC_FLAG_GRAY), &VAR_19);

                    VAR_17 |= VAR_18 << (VAR_1 << 2);

                    if (!VAR_0->ttmbf && VAR_6 < 8)

                        VAR_6 = -1;

                    VAR_11 = 0;

                }

            }

        }

    } else { 

        s->mb_intra = VAR_0->is_intra[s->mb_x] = 0;

        for (VAR_1 = 0; VAR_1 < 6; VAR_1++) {

            VAR_0->mb_type[0][s->block_index[VAR_1]] = 0;

            s->dc_val[0][s->block_index[VAR_1]] = 0;

        }

        s->current_picture.f.mb_type[VAR_2]      = MB_TYPE_SKIP;

        s->current_picture.f.qscale_table[VAR_2] = 0;

        VAR_0->blk_mv_type[s->block_index[0]] = 0;

        VAR_0->blk_mv_type[s->block_index[1]] = 0;

        VAR_0->blk_mv_type[s->block_index[2]] = 0;

        VAR_0->blk_mv_type[s->block_index[3]] = 0;

        vc1_pred_mv_intfr(VAR_0, 0, 0, 0, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]);

        vc1_mc_1mv(VAR_0, 0);

    }

    if (s->mb_x == s->mb_width - 1)

        memmove(VAR_0->is_intra_base, VAR_0->is_intra, sizeof(VAR_0->is_intra_base[0])*s->mb_stride);

    return 0;

}
static int FUNC_0(VC1Context *VAR_0)
{ MpegEncContext *s = &VAR_0->s; GetBitContext *gb = &s->gb; int VAR_1; int VAR_2 = s->mb_x + s->mb_y * s->mb_stride; int VAR_3 = 0; int VAR_4, VAR_5; int VAR_6 = VAR_0->ttfrm; int VAR_7 = 1; int VAR_8, VAR_9; int VAR_10; int VAR_11 = 1; int VAR_12, VAR_13; int VAR_14, VAR_15 = 0, VAR_16 = 0; int VAR_17 = 0, VAR_18, VAR_19 = 0; int VAR_20 = 0, VAR_21; int VAR_22, VAR_23; VAR_5 = VAR_0->pq; if (VAR_0->skip_is_raw)
VAR_14 = get_bits1(gb); else
VAR_14 = VAR_0->s.mbskip_table[VAR_2]; if (!VAR_14) { if (VAR_0->fourmvswitch)
VAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); else
VAR_20 = get_vlc2(gb, VAR_0->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); switch (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0]) { case MV_PMODE_INTFR_4MV:
VAR_15 = 1; VAR_0->blk_mv_type[s->block_index[0]] = 0; VAR_0->blk_mv_type[s->block_index[1]] = 0; VAR_0->blk_mv_type[s->block_index[2]] = 0; VAR_0->blk_mv_type[s->block_index[3]] = 0; break; case MV_PMODE_INTFR_4MV_FIELD:
VAR_15 = 1; VAR_0->blk_mv_type[s->block_index[0]] = 1; VAR_0->blk_mv_type[s->block_index[1]] = 1; VAR_0->blk_mv_type[s->block_index[2]] = 1; VAR_0->blk_mv_type[s->block_index[3]] = 1; break; case MV_PMODE_INTFR_2MV_FIELD:
VAR_16 = 1; VAR_0->blk_mv_type[s->block_index[0]] = 1; VAR_0->blk_mv_type[s->block_index[1]] = 1; VAR_0->blk_mv_type[s->block_index[2]] = 1; VAR_0->blk_mv_type[s->block_index[3]] = 1; break; case MV_PMODE_INTFR_1MV:
VAR_0->blk_mv_type[s->block_index[0]] = 0; VAR_0->blk_mv_type[s->block_index[1]] = 0; VAR_0->blk_mv_type[s->block_index[2]] = 0; VAR_0->blk_mv_type[s->block_index[3]] = 0; break; } if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_INTRA) { s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; s->current_picture.f.mb_type[VAR_2]                     = MB_TYPE_INTRA; s->mb_intra = VAR_0->is_intra[s->mb_x] = 1; for (VAR_1 = 0; VAR_1 < 6; VAR_1++) VAR_0->mb_type[0][s->block_index[VAR_1]] = 1; VAR_23 = VAR_0->fieldtx_plane[VAR_2] = get_bits1(gb); VAR_7 = get_bits1(gb); if (VAR_7)
VAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); VAR_0->s.ac_pred = VAR_0->acpred_plane[VAR_2] = get_bits1(gb); GET_MQUANT(); s->current_picture.f.qscale_table[VAR_2] = VAR_5; s->y_dc_scale = s->y_dc_scale_table[VAR_5]; s->c_dc_scale = s->c_dc_scale_table[VAR_5]; VAR_12 = 0; for (VAR_1 = 0; VAR_1 < 6; VAR_1++) { s->dc_val[0][s->block_index[VAR_1]] = 0; VAR_12 += VAR_1 >> 2; VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1); VAR_0->mb_type[0][s->block_index[VAR_1]] = s->mb_intra; VAR_0->a_avail = VAR_0->c_avail = 0; if (VAR_1 == 2 || VAR_1 == 3 || !s->first_slice_line)
VAR_0->a_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - s->block_wrap[VAR_1]]; if (VAR_1 == 1 || VAR_1 == 3 || s->mb_x)
VAR_0->c_avail = VAR_0->mb_type[0][s->block_index[VAR_1] - 1]; vc1_decode_intra_block(VAR_0, s->block[VAR_1], VAR_1, VAR_10, VAR_5,
(VAR_1 & 4) ? VAR_0->codingset2 : VAR_0->codingset); if ((VAR_1>3) && (s->flags & CODEC_FLAG_GRAY)) continue; VAR_0->vc1dsp.vc1_inv_trans_8x8(s->block[VAR_1]); if (VAR_1 < 4) { VAR_22 = s->linesize << VAR_23; VAR_13 = (VAR_23) ? ((VAR_1 & 1) * 8) + ((VAR_1 & 2) >> 1) * s->linesize : (VAR_1 & 1) * 8 + 4 * (VAR_1 & 2) * s->linesize; } else { VAR_22 = s->uvlinesize; VAR_13 = 0; } s->dsp.put_signed_pixels_clamped(s->block[VAR_1], s->dest[VAR_12] + VAR_13, VAR_22); } } else { VAR_7 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][3]; if (VAR_7)
VAR_3 = 1 + get_vlc2(&VAR_0->s.gb, VAR_0->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); if (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_2MV_FIELD) { VAR_0->twomvbp = get_vlc2(gb, VAR_0->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1); } else { if ((ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV)
|| (ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][0] == MV_PMODE_INTFR_4MV_FIELD)) { VAR_0->fourmvbp = get_vlc2(gb, VAR_0->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); } } s->mb_intra = VAR_0->is_intra[s->mb_x] = 0; for (VAR_1 = 0; VAR_1 < 6; VAR_1++) VAR_0->mb_type[0][s->block_index[VAR_1]] = 0; VAR_23 = VAR_0->fieldtx_plane[VAR_2] = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][1]; VAR_12 = 0; if (VAR_15) { VAR_21 = VAR_0->fourmvbp; for (VAR_1 = 0; VAR_1 < 6; VAR_1++) { if (VAR_1 < 4) { VAR_10   = ((VAR_21 >> (3 - VAR_1)) & 1); if (VAR_10) { get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0); } vc1_pred_mv_intfr(VAR_0, VAR_1, VAR_8, VAR_9, 0, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]); vc1_mc_4mv_luma(VAR_0, VAR_1, 0); } else if (VAR_1 == 4) { vc1_mc_4mv_chroma4(VAR_0); } } } else if (VAR_16) { VAR_21  = VAR_0->twomvbp; if (VAR_21 & 2) { get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0); } vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]); vc1_mc_4mv_luma(VAR_0, 0, 0); vc1_mc_4mv_luma(VAR_0, 1, 0); if (VAR_21 & 1) { get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0); } vc1_pred_mv_intfr(VAR_0, 2, VAR_8, VAR_9, 2, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]); vc1_mc_4mv_luma(VAR_0, 2, 0); vc1_mc_4mv_luma(VAR_0, 3, 0); vc1_mc_4mv_chroma4(VAR_0); } else { VAR_21 = ff_vc1_mbmode_intfrp[VAR_0->fourmvswitch][VAR_20][2]; if (VAR_21) { get_mvdata_interlaced(VAR_0, &VAR_8, &VAR_9, 0); } vc1_pred_mv_intfr(VAR_0, 0, VAR_8, VAR_9, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]); vc1_mc_1mv(VAR_0, 0); } if (VAR_3)
GET_MQUANT(); s->current_picture.f.qscale_table[VAR_2] = VAR_5; if (!VAR_0->ttmbf && VAR_3)
VAR_6 = get_vlc2(gb, ff_vc1_ttmb_vlc[VAR_0->tt_index].table, VC1_TTMB_VLC_BITS, 2); for (VAR_1 = 0; VAR_1 < 6; VAR_1++) { s->dc_val[0][s->block_index[VAR_1]] = 0; VAR_12 += VAR_1 >> 2; VAR_10 = ((VAR_3 >> (5 - VAR_1)) & 1); if (!VAR_23)
VAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + (VAR_1 & 2) * 4 * s->linesize); else
VAR_13 = (VAR_1 & 4) ? 0 : ((VAR_1 & 1) * 8 + ((VAR_1 > 1) * s->linesize)); if (VAR_10) { VAR_18 = vc1_decode_p_block(VAR_0, s->block[VAR_1], VAR_1, VAR_5, VAR_6,
VAR_11, s->dest[VAR_12] + VAR_13,
(VAR_1 & 4) ? s->uvlinesize : (s->linesize << VAR_23),
(VAR_1 & 4) && (s->flags & CODEC_FLAG_GRAY), &VAR_19); VAR_17 |= VAR_18 << (VAR_1 << 2); if (!VAR_0->ttmbf && VAR_6 < 8)
VAR_6 = -1; VAR_11 = 0; } } } } else { s->mb_intra = VAR_0->is_intra[s->mb_x] = 0; for (VAR_1 = 0; VAR_1 < 6; VAR_1++) { VAR_0->mb_type[0][s->block_index[VAR_1]] = 0; s->dc_val[0][s->block_index[VAR_1]] = 0; } s->current_picture.f.mb_type[VAR_2]      = MB_TYPE_SKIP; s->current_picture.f.qscale_table[VAR_2] = 0; VAR_0->blk_mv_type[s->block_index[0]] = 0; VAR_0->blk_mv_type[s->block_index[1]] = 0; VAR_0->blk_mv_type[s->block_index[2]] = 0; VAR_0->blk_mv_type[s->block_index[3]] = 0; vc1_pred_mv_intfr(VAR_0, 0, 0, 0, 1, VAR_0->range_x, VAR_0->range_y, VAR_0->mb_type[0]); vc1_mc_1mv(VAR_0, 0); } if (s->mb_x == s->mb_width - 1)
memmove(VAR_0->is_intra_base, VAR_0->is_intra, sizeof(VAR_0->is_intra_base[0])*s->mb_stride); return 0; }