int ff_h263_decode_mb(MpegEncContext *s,
                      int16_t block[6][64])
{
    int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
    int16_t *mot_val;
    const int xy= s->mb_x + s->mb_y * s->mb_stride;
    int cbpb = 0, pb_mv_count = 0;
    av_assert2(!s->h263_pred);
    if (s->pict_type == AV_PICTURE_TYPE_P) {
        do{
            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->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
                s->mv[0][0][0] = 0;
                s->mv[0][0][1] = 0;
                s->mb_skipped = !(s->obmc | s->loop_filter);
                goto end;
            cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
            if (cbpc < 0){
                av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
        }while(cbpc == 20);
        s->bdsp.clear_blocks(s->block[0]);
        dquant = cbpc & 8;
        s->mb_intra = ((cbpc & 4) != 0);
        if (s->mb_intra) goto intra;
        if(s->pb_frame && get_bits1(&s->gb))
            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
        cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
        if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
            cbpy ^= 0xF;
        cbp = (cbpc & 3) | (cbpy << 2);
        if (dquant) {
            h263_decode_dquant(s);
        s->mv_dir = MV_DIR_FORWARD;
        if ((cbpc & 16) == 0) {
            s->current_picture.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
            /* 16x16 motion prediction */
            s->mv_type = MV_TYPE_16X16;
            ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
            if (s->umvplus)
               mx = h263p_decode_umotion(s, pred_x);
            else
               mx = ff_h263_decode_motion(s, pred_x, 1);
            if (mx >= 0xffff)
            if (s->umvplus)
               my = h263p_decode_umotion(s, pred_y);
            else
               my = ff_h263_decode_motion(s, pred_y, 1);
            if (my >= 0xffff)
            s->mv[0][0][0] = mx;
            s->mv[0][0][1] = my;
            if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
               skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
        } else {
            s->current_picture.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
            s->mv_type = MV_TYPE_8X8;
            for(i=0;i<4;i++) {
                mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
                if (s->umvplus)
                    mx = h263p_decode_umotion(s, pred_x);
                else
                    mx = ff_h263_decode_motion(s, pred_x, 1);
                if (mx >= 0xffff)
                if (s->umvplus)
                    my = h263p_decode_umotion(s, pred_y);
                else
                    my = ff_h263_decode_motion(s, pred_y, 1);
                if (my >= 0xffff)
                s->mv[0][i][0] = mx;
                s->mv[0][i][1] = my;
                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
                  skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
                mot_val[0] = mx;
                mot_val[1] = my;
    } else if(s->pict_type==AV_PICTURE_TYPE_B) {
        int mb_type;
        const int stride= s->b8_stride;
        int16_t *mot_val0 = s->current_picture.motion_val[0][2 * (s->mb_x + s->mb_y * stride)];
        int16_t *mot_val1 = s->current_picture.motion_val[1][2 * (s->mb_x + s->mb_y * stride)];
//        const int mv_xy= s->mb_x + 1 + s->mb_y * s->mb_stride;
        //FIXME ugly
        mot_val0[0       ]= mot_val0[2       ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]=
        mot_val0[1       ]= mot_val0[3       ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]=
        mot_val1[0       ]= mot_val1[2       ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]=
        mot_val1[1       ]= mot_val1[3       ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
        do{
            mb_type= get_vlc2(&s->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2);
            if (mb_type < 0){
                av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y);
            mb_type= h263_mb_type_b_map[ mb_type ];
        }while(!mb_type);
        s->mb_intra = IS_INTRA(mb_type);
        if(HAS_CBP(mb_type)){
            s->bdsp.clear_blocks(s->block[0]);
            cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
            if(s->mb_intra){
                dquant = IS_QUANT(mb_type);
                goto intra;
            cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
            if (cbpy < 0){
                av_log(s->avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
            if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
                cbpy ^= 0xF;
            cbp = (cbpc & 3) | (cbpy << 2);
        }else
            cbp=0;
        av_assert2(!s->mb_intra);
        if(IS_QUANT(mb_type)){
            h263_decode_dquant(s);
        if(IS_DIRECT(mb_type)){
            s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
            mb_type |= set_direct_mv(s);
        }else{
            s->mv_dir = 0;
            s->mv_type= MV_TYPE_16X16;
//FIXME UMV
            if(USES_LIST(mb_type, 0)){
                int16_t *mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
                s->mv_dir = MV_DIR_FORWARD;
                if (s->umvplus)
                    mx = h263p_decode_umotion(s, pred_x);
                else
                    mx = ff_h263_decode_motion(s, pred_x, 1);
                if (mx >= 0xffff)
                if (s->umvplus)
                    my = h263p_decode_umotion(s, pred_y);
                else
                    my = ff_h263_decode_motion(s, pred_y, 1);
                if (my >= 0xffff)
                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
                    skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
                s->mv[0][0][0] = mx;
                s->mv[0][0][1] = my;
                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
            if(USES_LIST(mb_type, 1)){
                int16_t *mot_val= ff_h263_pred_motion(s, 0, 1, &pred_x, &pred_y);
                s->mv_dir |= MV_DIR_BACKWARD;
                if (s->umvplus)
                    mx = h263p_decode_umotion(s, pred_x);
                else
                    mx = ff_h263_decode_motion(s, pred_x, 1);
                if (mx >= 0xffff)
                if (s->umvplus)
                    my = h263p_decode_umotion(s, pred_y);
                else
                    my = ff_h263_decode_motion(s, pred_y, 1);
                if (my >= 0xffff)
                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
                    skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */
                s->mv[1][0][0] = mx;
                s->mv[1][0][1] = my;
                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
        s->current_picture.mb_type[xy] = mb_type;
    } else { /* I-Frame */
        do{
            cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
            if (cbpc < 0){
                av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
        }while(cbpc == 8);
        s->bdsp.clear_blocks(s->block[0]);
        dquant = cbpc & 4;
        s->mb_intra = 1;
intra:
        s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
        if (s->h263_aic) {
            s->ac_pred = get_bits1(&s->gb);
            if(s->ac_pred){
                s->current_picture.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
                s->h263_aic_dir = get_bits1(&s->gb);
        }else
            s->ac_pred = 0;
        if(s->pb_frame && get_bits1(&s->gb))
            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
        cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
        if(cbpy<0){
            av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
        cbp = (cbpc & 3) | (cbpy << 2);
        if (dquant) {
            h263_decode_dquant(s);
        pb_mv_count += !!s->pb_frame;
    while(pb_mv_count--){
        ff_h263_decode_motion(s, 0, 1);
        ff_h263_decode_motion(s, 0, 1);
    /* decode each block */
    for (i = 0; i < 6; i++) {
        if (h263_decode_block(s, block[i], i, cbp&32) < 0)
            return -1;
        cbp+=cbp;
    if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
        return -1;
    if(s->obmc && !s->mb_intra){
        if(s->pict_type == AV_PICTURE_TYPE_P && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
            preview_obmc(s);
end:
        /* per-MB end of slice check */
    {
        int v= show_bits(&s->gb, 16);
        if (get_bits_left(&s->gb) < 16) {
            v >>= 16 - get_bits_left(&s->gb);
        if(v==0)
            return SLICE_END;
    return SLICE_OK;
int ff_h263_decode_mb(MpegEncContext *s,
                      int16_t block[6][64])
{
    int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
    int16_t *mot_val;
    const int xy= s->mb_x + s->mb_y * s->mb_stride;
    int cbpb = 0, pb_mv_count = 0;
    av_assert2(!s->h263_pred);
    if (s->pict_type == AV_PICTURE_TYPE_P) {
        do{
            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->current_picture.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
                s->mv[0][0][0] = 0;
                s->mv[0][0][1] = 0;
                s->mb_skipped = !(s->obmc | s->loop_filter);
                goto end;
            cbpc = get_vlc2(&s->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
            if (cbpc < 0){
                av_log(s->avctx, AV_LOG_ERROR, "cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
        }while(cbpc == 20);
        s->bdsp.clear_blocks(s->block[0]);
        dquant = cbpc & 8;
        s->mb_intra = ((cbpc & 4) != 0);
        if (s->mb_intra) goto intra;
        if(s->pb_frame && get_bits1(&s->gb))
            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
        cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
        if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
            cbpy ^= 0xF;
        cbp = (cbpc & 3) | (cbpy << 2);
        if (dquant) {
            h263_decode_dquant(s);
        s->mv_dir = MV_DIR_FORWARD;
        if ((cbpc & 16) == 0) {
            s->current_picture.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_L0;
            
            s->mv_type = MV_TYPE_16X16;
            ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
            if (s->umvplus)
               mx = h263p_decode_umotion(s, pred_x);
            else
               mx = ff_h263_decode_motion(s, pred_x, 1);
            if (mx >= 0xffff)
            if (s->umvplus)
               my = h263p_decode_umotion(s, pred_y);
            else
               my = ff_h263_decode_motion(s, pred_y, 1);
            if (my >= 0xffff)
            s->mv[0][0][0] = mx;
            s->mv[0][0][1] = my;
            if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
               skip_bits1(&s->gb); 
        } else {
            s->current_picture.mb_type[xy] = MB_TYPE_8x8 | MB_TYPE_L0;
            s->mv_type = MV_TYPE_8X8;
            for(i=0;i<4;i++) {
                mot_val = ff_h263_pred_motion(s, i, 0, &pred_x, &pred_y);
                if (s->umvplus)
                    mx = h263p_decode_umotion(s, pred_x);
                else
                    mx = ff_h263_decode_motion(s, pred_x, 1);
                if (mx >= 0xffff)
                if (s->umvplus)
                    my = h263p_decode_umotion(s, pred_y);
                else
                    my = ff_h263_decode_motion(s, pred_y, 1);
                if (my >= 0xffff)
                s->mv[0][i][0] = mx;
                s->mv[0][i][1] = my;
                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
                  skip_bits1(&s->gb); 
                mot_val[0] = mx;
                mot_val[1] = my;
    } else if(s->pict_type==AV_PICTURE_TYPE_B) {
        int mb_type;
        const int stride= s->b8_stride;
        int16_t *mot_val0 = s->current_picture.motion_val[0][2 * (s->mb_x + s->mb_y * stride)];
        int16_t *mot_val1 = s->current_picture.motion_val[1][2 * (s->mb_x + s->mb_y * stride)];

        
        mot_val0[0       ]= mot_val0[2       ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]=
        mot_val0[1       ]= mot_val0[3       ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]=
        mot_val1[0       ]= mot_val1[2       ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]=
        mot_val1[1       ]= mot_val1[3       ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
        do{
            mb_type= get_vlc2(&s->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2);
            if (mb_type < 0){
                av_log(s->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", s->mb_x, s->mb_y);
            mb_type= h263_mb_type_b_map[ mb_type ];
        }while(!mb_type);
        s->mb_intra = IS_INTRA(mb_type);
        if(HAS_CBP(mb_type)){
            s->bdsp.clear_blocks(s->block[0]);
            cbpc = get_vlc2(&s->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
            if(s->mb_intra){
                dquant = IS_QUANT(mb_type);
                goto intra;
            cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
            if (cbpy < 0){
                av_log(s->avctx, AV_LOG_ERROR, "b cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
            if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
                cbpy ^= 0xF;
            cbp = (cbpc & 3) | (cbpy << 2);
        }else
            cbp=0;
        av_assert2(!s->mb_intra);
        if(IS_QUANT(mb_type)){
            h263_decode_dquant(s);
        if(IS_DIRECT(mb_type)){
            s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
            mb_type |= set_direct_mv(s);
        }else{
            s->mv_dir = 0;
            s->mv_type= MV_TYPE_16X16;

            if(USES_LIST(mb_type, 0)){
                int16_t *mot_val= ff_h263_pred_motion(s, 0, 0, &pred_x, &pred_y);
                s->mv_dir = MV_DIR_FORWARD;
                if (s->umvplus)
                    mx = h263p_decode_umotion(s, pred_x);
                else
                    mx = ff_h263_decode_motion(s, pred_x, 1);
                if (mx >= 0xffff)
                if (s->umvplus)
                    my = h263p_decode_umotion(s, pred_y);
                else
                    my = ff_h263_decode_motion(s, pred_y, 1);
                if (my >= 0xffff)
                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
                    skip_bits1(&s->gb); 
                s->mv[0][0][0] = mx;
                s->mv[0][0][1] = my;
                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
            if(USES_LIST(mb_type, 1)){
                int16_t *mot_val= ff_h263_pred_motion(s, 0, 1, &pred_x, &pred_y);
                s->mv_dir |= MV_DIR_BACKWARD;
                if (s->umvplus)
                    mx = h263p_decode_umotion(s, pred_x);
                else
                    mx = ff_h263_decode_motion(s, pred_x, 1);
                if (mx >= 0xffff)
                if (s->umvplus)
                    my = h263p_decode_umotion(s, pred_y);
                else
                    my = ff_h263_decode_motion(s, pred_y, 1);
                if (my >= 0xffff)
                if (s->umvplus && (mx - pred_x) == 1 && (my - pred_y) == 1)
                    skip_bits1(&s->gb); 
                s->mv[1][0][0] = mx;
                s->mv[1][0][1] = my;
                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= mx;
                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= my;
        s->current_picture.mb_type[xy] = mb_type;
    } else { 
        do{
            cbpc = get_vlc2(&s->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
            if (cbpc < 0){
                av_log(s->avctx, AV_LOG_ERROR, "I cbpc damaged at %d %d\n", s->mb_x, s->mb_y);
        }while(cbpc == 8);
        s->bdsp.clear_blocks(s->block[0]);
        dquant = cbpc & 4;
        s->mb_intra = 1;
intra:
        s->current_picture.mb_type[xy] = MB_TYPE_INTRA;
        if (s->h263_aic) {
            s->ac_pred = get_bits1(&s->gb);
            if(s->ac_pred){
                s->current_picture.mb_type[xy] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
                s->h263_aic_dir = get_bits1(&s->gb);
        }else
            s->ac_pred = 0;
        if(s->pb_frame && get_bits1(&s->gb))
            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
        cbpy = get_vlc2(&s->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
        if(cbpy<0){
            av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
        cbp = (cbpc & 3) | (cbpy << 2);
        if (dquant) {
            h263_decode_dquant(s);
        pb_mv_count += !!s->pb_frame;
    while(pb_mv_count--){
        ff_h263_decode_motion(s, 0, 1);
        ff_h263_decode_motion(s, 0, 1);
    
    for (i = 0; i < 6; i++) {
        if (h263_decode_block(s, block[i], i, cbp&32) < 0)
            return -1;
        cbp+=cbp;
    if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
        return -1;
    if(s->obmc && !s->mb_intra){
        if(s->pict_type == AV_PICTURE_TYPE_P && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
            preview_obmc(s);
end:
        
    {
        int v= show_bits(&s->gb, 16);
        if (get_bits_left(&s->gb) < 16) {
            v >>= 16 - get_bits_left(&s->gb);
        if(v==0)
            return SLICE_END;
    return SLICE_OK;
int FUNC_0(MpegEncContext *VAR_0,
                      int16_t VAR_1[6][64])
{
    int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
    int16_t *mot_val;
    const int VAR_11= VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride;
    int VAR_12 = 0, VAR_13 = 0;
    av_assert2(!VAR_0->h263_pred);
    if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {
        do{
            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->current_picture.mb_type[VAR_11] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0;
                VAR_0->mv[0][0][0] = 0;
                VAR_0->mv[0][0][1] = 0;
                VAR_0->mb_skipped = !(VAR_0->obmc | VAR_0->loop_filter);
                goto end;
            VAR_2 = get_vlc2(&VAR_0->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2);
            if (VAR_2 < 0){
                av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_2 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
        }while(VAR_2 == 20);
        VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);
        VAR_10 = VAR_2 & 8;
        VAR_0->mb_intra = ((VAR_2 & 4) != 0);
        if (VAR_0->mb_intra) goto intra;
        if(VAR_0->pb_frame && get_bits1(&VAR_0->gb))
            VAR_13 = h263_get_modb(&VAR_0->gb, VAR_0->pb_frame, &VAR_12);
        VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
        if(VAR_0->alt_inter_vlc==0 || (VAR_2 & 3)!=3)
            VAR_3 ^= 0xF;
        VAR_5 = (VAR_2 & 3) | (VAR_3 << 2);
        if (VAR_10) {
            h263_decode_dquant(VAR_0);
        VAR_0->mv_dir = MV_DIR_FORWARD;
        if ((VAR_2 & 16) == 0) {
            VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_16x16 | MB_TYPE_L0;
            
            VAR_0->mv_type = MV_TYPE_16X16;
            ff_h263_pred_motion(VAR_0, 0, 0, &VAR_6, &VAR_7);
            if (VAR_0->umvplus)
               VAR_8 = h263p_decode_umotion(VAR_0, VAR_6);
            else
               VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1);
            if (VAR_8 >= 0xffff)
            if (VAR_0->umvplus)
               VAR_9 = h263p_decode_umotion(VAR_0, VAR_7);
            else
               VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1);
            if (VAR_9 >= 0xffff)
            VAR_0->mv[0][0][0] = VAR_8;
            VAR_0->mv[0][0][1] = VAR_9;
            if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
               skip_bits1(&VAR_0->gb); 
        } else {
            VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_8x8 | MB_TYPE_L0;
            VAR_0->mv_type = MV_TYPE_8X8;
            for(VAR_4=0;VAR_4<4;VAR_4++) {
                mot_val = ff_h263_pred_motion(VAR_0, VAR_4, 0, &VAR_6, &VAR_7);
                if (VAR_0->umvplus)
                    VAR_8 = h263p_decode_umotion(VAR_0, VAR_6);
                else
                    VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1);
                if (VAR_8 >= 0xffff)
                if (VAR_0->umvplus)
                    VAR_9 = h263p_decode_umotion(VAR_0, VAR_7);
                else
                    VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1);
                if (VAR_9 >= 0xffff)
                VAR_0->mv[0][VAR_4][0] = VAR_8;
                VAR_0->mv[0][VAR_4][1] = VAR_9;
                if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
                  skip_bits1(&VAR_0->gb); 
                mot_val[0] = VAR_8;
                mot_val[1] = VAR_9;
    } else if(VAR_0->pict_type==AV_PICTURE_TYPE_B) {
        int mb_type;
        const int stride= VAR_0->b8_stride;
        int16_t *mot_val0 = VAR_0->current_picture.motion_val[0][2 * (VAR_0->mb_x + VAR_0->mb_y * stride)];
        int16_t *mot_val1 = VAR_0->current_picture.motion_val[1][2 * (VAR_0->mb_x + VAR_0->mb_y * stride)];

        
        mot_val0[0       ]= mot_val0[2       ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]=
        mot_val0[1       ]= mot_val0[3       ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]=
        mot_val1[0       ]= mot_val1[2       ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]=
        mot_val1[1       ]= mot_val1[3       ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0;
        do{
            mb_type= get_vlc2(&VAR_0->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2);
            if (mb_type < 0){
                av_log(VAR_0->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
            mb_type= h263_mb_type_b_map[ mb_type ];
        }while(!mb_type);
        VAR_0->mb_intra = IS_INTRA(mb_type);
        if(HAS_CBP(mb_type)){
            VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);
            VAR_2 = get_vlc2(&VAR_0->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1);
            if(VAR_0->mb_intra){
                VAR_10 = IS_QUANT(mb_type);
                goto intra;
            VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
            if (VAR_3 < 0){
                av_log(VAR_0->avctx, AV_LOG_ERROR, "b VAR_3 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
            if(VAR_0->alt_inter_vlc==0 || (VAR_2 & 3)!=3)
                VAR_3 ^= 0xF;
            VAR_5 = (VAR_2 & 3) | (VAR_3 << 2);
        }else
            VAR_5=0;
        av_assert2(!VAR_0->mb_intra);
        if(IS_QUANT(mb_type)){
            h263_decode_dquant(VAR_0);
        if(IS_DIRECT(mb_type)){
            VAR_0->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
            mb_type |= set_direct_mv(VAR_0);
        }else{
            VAR_0->mv_dir = 0;
            VAR_0->mv_type= MV_TYPE_16X16;

            if(USES_LIST(mb_type, 0)){
                int16_t *mot_val= ff_h263_pred_motion(VAR_0, 0, 0, &VAR_6, &VAR_7);
                VAR_0->mv_dir = MV_DIR_FORWARD;
                if (VAR_0->umvplus)
                    VAR_8 = h263p_decode_umotion(VAR_0, VAR_6);
                else
                    VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1);
                if (VAR_8 >= 0xffff)
                if (VAR_0->umvplus)
                    VAR_9 = h263p_decode_umotion(VAR_0, VAR_7);
                else
                    VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1);
                if (VAR_9 >= 0xffff)
                if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
                    skip_bits1(&VAR_0->gb); 
                VAR_0->mv[0][0][0] = VAR_8;
                VAR_0->mv[0][0][1] = VAR_9;
                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= VAR_8;
                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= VAR_9;
            if(USES_LIST(mb_type, 1)){
                int16_t *mot_val= ff_h263_pred_motion(VAR_0, 0, 1, &VAR_6, &VAR_7);
                VAR_0->mv_dir |= MV_DIR_BACKWARD;
                if (VAR_0->umvplus)
                    VAR_8 = h263p_decode_umotion(VAR_0, VAR_6);
                else
                    VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1);
                if (VAR_8 >= 0xffff)
                if (VAR_0->umvplus)
                    VAR_9 = h263p_decode_umotion(VAR_0, VAR_7);
                else
                    VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1);
                if (VAR_9 >= 0xffff)
                if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
                    skip_bits1(&VAR_0->gb); 
                VAR_0->mv[1][0][0] = VAR_8;
                VAR_0->mv[1][0][1] = VAR_9;
                mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= VAR_8;
                mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= VAR_9;
        VAR_0->current_picture.mb_type[VAR_11] = mb_type;
    } else { 
        do{
            VAR_2 = get_vlc2(&VAR_0->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
            if (VAR_2 < 0){
                av_log(VAR_0->avctx, AV_LOG_ERROR, "I VAR_2 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
        }while(VAR_2 == 8);
        VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]);
        VAR_10 = VAR_2 & 4;
        VAR_0->mb_intra = 1;
intra:
        VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_INTRA;
        if (VAR_0->h263_aic) {
            VAR_0->ac_pred = get_bits1(&VAR_0->gb);
            if(VAR_0->ac_pred){
                VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_INTRA | MB_TYPE_ACPRED;
                VAR_0->h263_aic_dir = get_bits1(&VAR_0->gb);
        }else
            VAR_0->ac_pred = 0;
        if(VAR_0->pb_frame && get_bits1(&VAR_0->gb))
            VAR_13 = h263_get_modb(&VAR_0->gb, VAR_0->pb_frame, &VAR_12);
        VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1);
        if(VAR_3<0){
            av_log(VAR_0->avctx, AV_LOG_ERROR, "I VAR_3 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y);
        VAR_5 = (VAR_2 & 3) | (VAR_3 << 2);
        if (VAR_10) {
            h263_decode_dquant(VAR_0);
        VAR_13 += !!VAR_0->pb_frame;
    while(VAR_13--){
        ff_h263_decode_motion(VAR_0, 0, 1);
        ff_h263_decode_motion(VAR_0, 0, 1);
    
    for (VAR_4 = 0; VAR_4 < 6; VAR_4++) {
        if (h263_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32) < 0)
            return -1;
        VAR_5+=VAR_5;
    if(VAR_0->pb_frame && h263_skip_b_part(VAR_0, VAR_12) < 0)
        return -1;
    if(VAR_0->obmc && !VAR_0->mb_intra){
        if(VAR_0->pict_type == AV_PICTURE_TYPE_P && VAR_0->mb_x+1<VAR_0->mb_width && VAR_0->mb_num_left != 1)
            preview_obmc(VAR_0);
end:
        
    {
        int v= show_bits(&VAR_0->gb, 16);
        if (get_bits_left(&VAR_0->gb) < 16) {
            v >>= 16 - get_bits_left(&VAR_0->gb);
        if(v==0)
            return SLICE_END;
    return SLICE_OK;
int FUNC_0(MpegEncContext *VAR_0,
int16_t VAR_1[6][64])
{ int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; int16_t *mot_val; const int VAR_11= VAR_0->mb_x + VAR_0->mb_y * VAR_0->mb_stride; int VAR_12 = 0, VAR_13 = 0; av_assert2(!VAR_0->h263_pred); if (VAR_0->pict_type == AV_PICTURE_TYPE_P) { do{ 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->current_picture.mb_type[VAR_11] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; VAR_0->mv[0][0][0] = 0; VAR_0->mv[0][0][1] = 0; VAR_0->mb_skipped = !(VAR_0->obmc | VAR_0->loop_filter); goto end; VAR_2 = get_vlc2(&VAR_0->gb, ff_h263_inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); if (VAR_2 < 0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "VAR_2 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y); }while(VAR_2 == 20); VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]); VAR_10 = VAR_2 & 8; VAR_0->mb_intra = ((VAR_2 & 4) != 0); if (VAR_0->mb_intra) goto intra; if(VAR_0->pb_frame && get_bits1(&VAR_0->gb))
VAR_13 = h263_get_modb(&VAR_0->gb, VAR_0->pb_frame, &VAR_12); VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if(VAR_0->alt_inter_vlc==0 || (VAR_2 & 3)!=3)
VAR_3 ^= 0xF; VAR_5 = (VAR_2 & 3) | (VAR_3 << 2); if (VAR_10) { h263_decode_dquant(VAR_0); VAR_0->mv_dir = MV_DIR_FORWARD; if ((VAR_2 & 16) == 0) { VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_16x16 | MB_TYPE_L0; VAR_0->mv_type = MV_TYPE_16X16; ff_h263_pred_motion(VAR_0, 0, 0, &VAR_6, &VAR_7); if (VAR_0->umvplus)
VAR_8 = h263p_decode_umotion(VAR_0, VAR_6); else
VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1); if (VAR_8 >= 0xffff)
if (VAR_0->umvplus)
VAR_9 = h263p_decode_umotion(VAR_0, VAR_7); else
VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1); if (VAR_9 >= 0xffff)
VAR_0->mv[0][0][0] = VAR_8; VAR_0->mv[0][0][1] = VAR_9; if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
skip_bits1(&VAR_0->gb); } else { VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_8x8 | MB_TYPE_L0; VAR_0->mv_type = MV_TYPE_8X8; for(VAR_4=0;VAR_4<4;VAR_4++) { mot_val = ff_h263_pred_motion(VAR_0, VAR_4, 0, &VAR_6, &VAR_7); if (VAR_0->umvplus)
VAR_8 = h263p_decode_umotion(VAR_0, VAR_6); else
VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1); if (VAR_8 >= 0xffff)
if (VAR_0->umvplus)
VAR_9 = h263p_decode_umotion(VAR_0, VAR_7); else
VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1); if (VAR_9 >= 0xffff)
VAR_0->mv[0][VAR_4][0] = VAR_8; VAR_0->mv[0][VAR_4][1] = VAR_9; if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
skip_bits1(&VAR_0->gb); mot_val[0] = VAR_8; mot_val[1] = VAR_9; } else if(VAR_0->pict_type==AV_PICTURE_TYPE_B) { int mb_type; const int stride= VAR_0->b8_stride; int16_t *mot_val0 = VAR_0->current_picture.motion_val[0][2 * (VAR_0->mb_x + VAR_0->mb_y * stride)]; int16_t *mot_val1 = VAR_0->current_picture.motion_val[1][2 * (VAR_0->mb_x + VAR_0->mb_y * stride)]; mot_val0[0       ]= mot_val0[2       ]= mot_val0[0+2*stride]= mot_val0[2+2*stride]=
mot_val0[1       ]= mot_val0[3       ]= mot_val0[1+2*stride]= mot_val0[3+2*stride]=
mot_val1[0       ]= mot_val1[2       ]= mot_val1[0+2*stride]= mot_val1[2+2*stride]=
mot_val1[1       ]= mot_val1[3       ]= mot_val1[1+2*stride]= mot_val1[3+2*stride]= 0; do{ mb_type= get_vlc2(&VAR_0->gb, h263_mbtype_b_vlc.table, H263_MBTYPE_B_VLC_BITS, 2); if (mb_type < 0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "b mb_type damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y); mb_type= h263_mb_type_b_map[ mb_type ]; }while(!mb_type); VAR_0->mb_intra = IS_INTRA(mb_type); if(HAS_CBP(mb_type)){ VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]); VAR_2 = get_vlc2(&VAR_0->gb, cbpc_b_vlc.table, CBPC_B_VLC_BITS, 1); if(VAR_0->mb_intra){ VAR_10 = IS_QUANT(mb_type); goto intra; VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if (VAR_3 < 0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "b VAR_3 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y); if(VAR_0->alt_inter_vlc==0 || (VAR_2 & 3)!=3)
VAR_3 ^= 0xF; VAR_5 = (VAR_2 & 3) | (VAR_3 << 2); }else VAR_5=0; av_assert2(!VAR_0->mb_intra); if(IS_QUANT(mb_type)){ h263_decode_dquant(VAR_0); if(IS_DIRECT(mb_type)){ VAR_0->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; mb_type |= set_direct_mv(VAR_0); }else{ VAR_0->mv_dir = 0; VAR_0->mv_type= MV_TYPE_16X16; if(USES_LIST(mb_type, 0)){ int16_t *mot_val= ff_h263_pred_motion(VAR_0, 0, 0, &VAR_6, &VAR_7); VAR_0->mv_dir = MV_DIR_FORWARD; if (VAR_0->umvplus)
VAR_8 = h263p_decode_umotion(VAR_0, VAR_6); else
VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1); if (VAR_8 >= 0xffff)
if (VAR_0->umvplus)
VAR_9 = h263p_decode_umotion(VAR_0, VAR_7); else
VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1); if (VAR_9 >= 0xffff)
if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
skip_bits1(&VAR_0->gb); VAR_0->mv[0][0][0] = VAR_8; VAR_0->mv[0][0][1] = VAR_9; mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= VAR_8; mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= VAR_9; if(USES_LIST(mb_type, 1)){ int16_t *mot_val= ff_h263_pred_motion(VAR_0, 0, 1, &VAR_6, &VAR_7); VAR_0->mv_dir |= MV_DIR_BACKWARD; if (VAR_0->umvplus)
VAR_8 = h263p_decode_umotion(VAR_0, VAR_6); else
VAR_8 = ff_h263_decode_motion(VAR_0, VAR_6, 1); if (VAR_8 >= 0xffff)
if (VAR_0->umvplus)
VAR_9 = h263p_decode_umotion(VAR_0, VAR_7); else
VAR_9 = ff_h263_decode_motion(VAR_0, VAR_7, 1); if (VAR_9 >= 0xffff)
if (VAR_0->umvplus && (VAR_8 - VAR_6) == 1 && (VAR_9 - VAR_7) == 1)
skip_bits1(&VAR_0->gb); VAR_0->mv[1][0][0] = VAR_8; VAR_0->mv[1][0][1] = VAR_9; mot_val[0       ]= mot_val[2       ]= mot_val[0+2*stride]= mot_val[2+2*stride]= VAR_8; mot_val[1       ]= mot_val[3       ]= mot_val[1+2*stride]= mot_val[3+2*stride]= VAR_9; VAR_0->current_picture.mb_type[VAR_11] = mb_type; } else { do{ VAR_2 = get_vlc2(&VAR_0->gb, ff_h263_intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2); if (VAR_2 < 0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "I VAR_2 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y); }while(VAR_2 == 8); VAR_0->bdsp.clear_blocks(VAR_0->VAR_1[0]); VAR_10 = VAR_2 & 4; VAR_0->mb_intra = 1; intra:
VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_INTRA; if (VAR_0->h263_aic) { VAR_0->ac_pred = get_bits1(&VAR_0->gb); if(VAR_0->ac_pred){ VAR_0->current_picture.mb_type[VAR_11] = MB_TYPE_INTRA | MB_TYPE_ACPRED; VAR_0->h263_aic_dir = get_bits1(&VAR_0->gb); }else VAR_0->ac_pred = 0; if(VAR_0->pb_frame && get_bits1(&VAR_0->gb))
VAR_13 = h263_get_modb(&VAR_0->gb, VAR_0->pb_frame, &VAR_12); VAR_3 = get_vlc2(&VAR_0->gb, ff_h263_cbpy_vlc.table, CBPY_VLC_BITS, 1); if(VAR_3<0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "I VAR_3 damaged at %d %d\n", VAR_0->mb_x, VAR_0->mb_y); VAR_5 = (VAR_2 & 3) | (VAR_3 << 2); if (VAR_10) { h263_decode_dquant(VAR_0); VAR_13 += !!VAR_0->pb_frame; while(VAR_13--){ ff_h263_decode_motion(VAR_0, 0, 1); ff_h263_decode_motion(VAR_0, 0, 1); for (VAR_4 = 0; VAR_4 < 6; VAR_4++) { if (h263_decode_block(VAR_0, VAR_1[VAR_4], VAR_4, VAR_5&32) < 0)
return -1; VAR_5+=VAR_5; if(VAR_0->pb_frame && h263_skip_b_part(VAR_0, VAR_12) < 0)
return -1; if(VAR_0->obmc && !VAR_0->mb_intra){ if(VAR_0->pict_type == AV_PICTURE_TYPE_P && VAR_0->mb_x+1<VAR_0->mb_width && VAR_0->mb_num_left != 1)
preview_obmc(VAR_0); end:
{ int v= show_bits(&VAR_0->gb, 16); if (get_bits_left(&VAR_0->gb) < 16) { v >>= 16 - get_bits_left(&VAR_0->gb); if(v==0)
return SLICE_END; return SLICE_OK;