static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])

{

    int cbp, code, i;

    uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];



    if (s->pict_type == AV_PICTURE_TYPE_P) {

        if (s->use_skip_mb_code) {

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

                /* skip mb */

                s->mb_intra = 0;

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

                    s->block_last_index[i] = -1;

                s->mv_dir = MV_DIR_FORWARD;

                s->mv_type = MV_TYPE_16X16;

                s->mv[0][0][0] = 0;

                s->mv[0][0][1] = 0;

                s->mb_skipped = 1;

                *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;

                return 0;

            }

        }



        if(s->msmpeg4_version==2)

            code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);

        else

            code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);

        if(code<0 || code>7){

            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);

            return -1;

        }



        s->mb_intra = code >>2;



        cbp = code & 0x3;

    } else {

        s->mb_intra = 1;

        if(s->msmpeg4_version==2)

            cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);

        else

            cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);

        if(cbp<0 || cbp>3){

            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);

            return -1;

        }

    }



    if (!s->mb_intra) {

        int mx, my, cbpy;



        cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);

        if(cbpy<0){

            av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);

            return -1;

        }



        cbp|= cbpy<<2;

        if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;



        ff_h263_pred_motion(s, 0, 0, &mx, &my);

        mx= msmpeg4v2_decode_motion(s, mx, 1);

        my= msmpeg4v2_decode_motion(s, my, 1);



        s->mv_dir = MV_DIR_FORWARD;

        s->mv_type = MV_TYPE_16X16;

        s->mv[0][0][0] = mx;

        s->mv[0][0][1] = my;

        *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;

    } else {

        if(s->msmpeg4_version==2){

            s->ac_pred = get_bits1(&s->gb);

            cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors

        } else{

            s->ac_pred = 0;

            cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; //FIXME check errors

            if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;

        }

        *mb_type_ptr = MB_TYPE_INTRA;

    }



    s->bdsp.clear_blocks(s->block[0]);

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

        if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)

        {

             av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);

             return -1;

        }

    }

    return 0;

}

static int msmpeg4v12_decode_mb(MpegEncContext *s, int16_t block[6][64])

{

    int cbp, code, i;

    uint32_t * const mb_type_ptr = &s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride];



    if (s->pict_type == AV_PICTURE_TYPE_P) {

        if (s->use_skip_mb_code) {

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

                

                s->mb_intra = 0;

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

                    s->block_last_index[i] = -1;

                s->mv_dir = MV_DIR_FORWARD;

                s->mv_type = MV_TYPE_16X16;

                s->mv[0][0][0] = 0;

                s->mv[0][0][1] = 0;

                s->mb_skipped = 1;

                *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;

                return 0;

            }

        }



        if(s->msmpeg4_version==2)

            code = get_vlc2(&s->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);

        else

            code = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);

        if(code<0 || code>7){

            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", code, s->mb_x, s->mb_y);

            return -1;

        }



        s->mb_intra = code >>2;



        cbp = code & 0x3;

    } else {

        s->mb_intra = 1;

        if(s->msmpeg4_version==2)

            cbp= get_vlc2(&s->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);

        else

            cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);

        if(cbp<0 || cbp>3){

            av_log(s->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);

            return -1;

        }

    }



    if (!s->mb_intra) {

        int mx, my, cbpy;



        cbpy= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);

        if(cbpy<0){

            av_log(s->avctx, AV_LOG_ERROR, "cbpy %d invalid at %d %d\n", cbp, s->mb_x, s->mb_y);

            return -1;

        }



        cbp|= cbpy<<2;

        if(s->msmpeg4_version==1 || (cbp&3) != 3) cbp^= 0x3C;



        ff_h263_pred_motion(s, 0, 0, &mx, &my);

        mx= msmpeg4v2_decode_motion(s, mx, 1);

        my= msmpeg4v2_decode_motion(s, my, 1);



        s->mv_dir = MV_DIR_FORWARD;

        s->mv_type = MV_TYPE_16X16;

        s->mv[0][0][0] = mx;

        s->mv[0][0][1] = my;

        *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;

    } else {

        if(s->msmpeg4_version==2){

            s->ac_pred = get_bits1(&s->gb);

            cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; 

        } else{

            s->ac_pred = 0;

            cbp|= get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; 

            if(s->pict_type==AV_PICTURE_TYPE_P) cbp^=0x3C;

        }

        *mb_type_ptr = MB_TYPE_INTRA;

    }



    s->bdsp.clear_blocks(s->block[0]);

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

        if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0)

        {

             av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i);

             return -1;

        }

    }

    return 0;

}

            cbp= get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);
static int FUNC_0(MpegEncContext *VAR_0, int16_t VAR_1[6][64])

{

    int VAR_2, VAR_3, VAR_4;

    uint32_t * const mb_type_ptr = &VAR_0->current_picture.mb_type[VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride];



    if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {

        if (VAR_0->use_skip_mb_code) {

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

                

                VAR_0->mb_intra = 0;

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

                    VAR_0->block_last_index[VAR_4] = -1;

                VAR_0->mv_dir = MV_DIR_FORWARD;

                VAR_0->mv_type = MV_TYPE_16X16;

                VAR_0->mv[0][0][0] = 0;

                VAR_0->mv[0][0][1] = 0;

                VAR_0->mb_skipped = 1;

                *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16;

                return 0;

            }

        }



        if(VAR_0->msmpeg4_version==2)

            VAR_3 = get_vlc2(&VAR_0->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1);

        else

            VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);

        if(VAR_3<0 || VAR_3>7){

            av_log(VAR_0->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", VAR_3, VAR_0->mb_x, VAR_0->mb_y);

            return -1;

        }



        VAR_0->mb_intra = VAR_3 >>2;



        VAR_2 = VAR_3 & 0x3;

    } else {

        VAR_0->mb_intra = 1;

        if(VAR_0->msmpeg4_version==2)

            VAR_2= get_vlc2(&VAR_0->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1);

        else

            VAR_2= get_vlc2(&VAR_0->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1);

        if(VAR_2<0 || VAR_2>3){

            av_log(VAR_0->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", VAR_2, VAR_0->mb_x, VAR_0->mb_y);

            return -1;

        }

    }



    if (!VAR_0->mb_intra) {

        int VAR_5, VAR_6, VAR_7;



        VAR_7= get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);

        if(VAR_7<0){

            av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_7 %d invalid at %d %d\n", VAR_2, VAR_0->mb_x, VAR_0->mb_y);

            return -1;

        }



        VAR_2|= VAR_7<<2;

        if(VAR_0->msmpeg4_version==1 || (VAR_2&3) != 3) VAR_2^= 0x3C;



        ff_h263_pred_motion(VAR_0, 0, 0, &VAR_5, &VAR_6);

        VAR_5= msmpeg4v2_decode_motion(VAR_0, VAR_5, 1);

        VAR_6= msmpeg4v2_decode_motion(VAR_0, VAR_6, 1);



        VAR_0->mv_dir = MV_DIR_FORWARD;

        VAR_0->mv_type = MV_TYPE_16X16;

        VAR_0->mv[0][0][0] = VAR_5;

        VAR_0->mv[0][0][1] = VAR_6;

        *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16;

    } else {

        if(VAR_0->msmpeg4_version==2){

            VAR_0->ac_pred = get_bits1(&VAR_0->gb);

            VAR_2|= get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; 

        } else{

            VAR_0->ac_pred = 0;

            VAR_2|= get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; 

            if(VAR_0->pict_type==AV_PICTURE_TYPE_P) VAR_2^=0x3C;

        }

        *mb_type_ptr = MB_TYPE_INTRA;

    }



    VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);

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

        if (ff_msmpeg4_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, (VAR_2 >> (5 - VAR_4)) & 1, NULL) < 0)

        {

             av_log(VAR_0->avctx, AV_LOG_ERROR, "\nerror while decoding VAR_1: %d x %d (%d)\n", VAR_0->mb_x, VAR_0->mb_y, VAR_4);

             return -1;

        }

    }

    return 0;

}

static int FUNC_0(MpegEncContext *VAR_0, int16_t VAR_1[6][64])
{ int VAR_2, VAR_3, VAR_4; uint32_t * const mb_type_ptr = &VAR_0->current_picture.mb_type[VAR_0->mb_x + VAR_0->mb_y*VAR_0->mb_stride]; if (VAR_0->pict_type == AV_PICTURE_TYPE_P) { if (VAR_0->use_skip_mb_code) { if (get_bits1(&VAR_0->gb)) { VAR_0->mb_intra = 0; for(VAR_4=0;VAR_4<6;VAR_4++) VAR_0->block_last_index[VAR_4] = -1; VAR_0->mv_dir = MV_DIR_FORWARD; VAR_0->mv_type = MV_TYPE_16X16; VAR_0->mv[0][0][0] = 0; VAR_0->mv[0][0][1] = 0; VAR_0->mb_skipped = 1; *mb_type_ptr = MB_TYPE_SKIP | MB_TYPE_L0 | MB_TYPE_16x16; return 0; } } if(VAR_0->msmpeg4_version==2)
VAR_3 = get_vlc2(&VAR_0->gb, v2_mb_type_vlc.table, V2_MB_TYPE_VLC_BITS, 1); else
VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); if(VAR_3<0 || VAR_3>7){ av_log(VAR_0->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", VAR_3, VAR_0->mb_x, VAR_0->mb_y); return -1; } VAR_0->mb_intra = VAR_3 >>2; VAR_2 = VAR_3 & 0x3; } else { VAR_0->mb_intra = 1; if(VAR_0->msmpeg4_version==2)
VAR_2= get_vlc2(&VAR_0->gb, v2_intra_cbpc_vlc.table, V2_INTRA_CBPC_VLC_BITS, 1); else
VAR_2= get_vlc2(&VAR_0->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1); if(VAR_2<0 || VAR_2>3){ av_log(VAR_0->avctx, AV_LOG_ERROR, "cbpc %d invalid at %d %d\n", VAR_2, VAR_0->mb_x, VAR_0->mb_y); return -1; } } if (!VAR_0->mb_intra) { int VAR_5, VAR_6, VAR_7; VAR_7= get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if(VAR_7<0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_7 %d invalid at %d %d\n", VAR_2, VAR_0->mb_x, VAR_0->mb_y); return -1; } VAR_2|= VAR_7<<2; if(VAR_0->msmpeg4_version==1 || (VAR_2&3) != 3) VAR_2^= 0x3C; ff_h263_pred_motion(VAR_0, 0, 0, &VAR_5, &VAR_6); VAR_5= msmpeg4v2_decode_motion(VAR_0, VAR_5, 1); VAR_6= msmpeg4v2_decode_motion(VAR_0, VAR_6, 1); VAR_0->mv_dir = MV_DIR_FORWARD; VAR_0->mv_type = MV_TYPE_16X16; VAR_0->mv[0][0][0] = VAR_5; VAR_0->mv[0][0][1] = VAR_6; *mb_type_ptr = MB_TYPE_L0 | MB_TYPE_16x16; } else { if(VAR_0->msmpeg4_version==2){ VAR_0->ac_pred = get_bits1(&VAR_0->gb); VAR_2|= get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; } else{ VAR_0->ac_pred = 0; VAR_2|= get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1)<<2; if(VAR_0->pict_type==AV_PICTURE_TYPE_P) VAR_2^=0x3C; } *mb_type_ptr = MB_TYPE_INTRA; } VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]); for (VAR_4 = 0; VAR_4 < 6; VAR_4++) { if (ff_msmpeg4_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, (VAR_2 >> (5 - VAR_4)) & 1, NULL) < 0)
{ av_log(VAR_0->avctx, AV_LOG_ERROR, "\nerror while decoding VAR_1: %d x %d (%d)\n", VAR_0->mb_x, VAR_0->mb_y, VAR_4); return -1; } } return 0; }