void h263_encode_mb(MpegEncContext * s,

		    DCTELEM block[6][64],

		    int motion_x, int motion_y)

{

    int cbpc, cbpy, i, cbp, pred_x, pred_y;



    //    printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);

   if (!s->mb_intra) {

	   /* compute cbp */

	   cbp = 0;

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

	      if (s->block_last_index[i] >= 0)

		   cbp |= 1 << (5 - i);

	   }

	   if ((cbp | motion_x | motion_y) == 0) {

	      /* skip macroblock */

	      put_bits(&s->pb, 1, 1);

	      return;

	   }

	   put_bits(&s->pb, 1, 0);	/* mb coded */

	   cbpc = cbp & 3;

	   put_bits(&s->pb,

		inter_MCBPC_bits[cbpc],

		inter_MCBPC_code[cbpc]);

	   cbpy = cbp >> 2;

	   cbpy ^= 0xf;

	   put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);



	   /* motion vectors: 16x16 mode only now */

      h263_pred_motion(s, 0, &pred_x, &pred_y);

      

      if (!umvplus) {  

         h263_encode_motion(s, motion_x - pred_x);

         h263_encode_motion(s, motion_y - pred_y);

      }

      else {

         h263p_encode_umotion(s, motion_x - pred_x);

         h263p_encode_umotion(s, motion_y - pred_y);

         if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))

            /* To prevent Start Code emulation */

            put_bits(&s->pb,1,1);

      }

   } else {

	/* compute cbp */

	cbp = 0;

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

	    if (s->block_last_index[i] >= 1)

		cbp |= 1 << (5 - i);

	}



	cbpc = cbp & 3;

	if (s->pict_type == I_TYPE) {

	    put_bits(&s->pb,

		     intra_MCBPC_bits[cbpc],

		     intra_MCBPC_code[cbpc]);

	} else {

	    put_bits(&s->pb, 1, 0);	/* mb coded */

	    put_bits(&s->pb,

		     inter_MCBPC_bits[cbpc + 4],

		     inter_MCBPC_code[cbpc + 4]);

	}

	if (s->h263_pred) {

	    /* XXX: currently, we do not try to use ac prediction */

	    put_bits(&s->pb, 1, 0);	/* no ac prediction */

	}

	cbpy = cbp >> 2;

	put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);

    }



    /* encode each block */

    if (s->h263_pred) {

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

	    mpeg4_encode_block(s, block[i], i);

	}

    } else {

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

	    h263_encode_block(s, block[i], i);

	}

    }

}

void h263_encode_mb(MpegEncContext * s,

		    DCTELEM block[6][64],

		    int motion_x, int motion_y)

{

    int cbpc, cbpy, i, cbp, pred_x, pred_y;



    

   if (!s->mb_intra) {

	   

	   cbp = 0;

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

	      if (s->block_last_index[i] >= 0)

		   cbp |= 1 << (5 - i);

	   }

	   if ((cbp | motion_x | motion_y) == 0) {

	      

	      put_bits(&s->pb, 1, 1);

	      return;

	   }

	   put_bits(&s->pb, 1, 0);	

	   cbpc = cbp & 3;

	   put_bits(&s->pb,

		inter_MCBPC_bits[cbpc],

		inter_MCBPC_code[cbpc]);

	   cbpy = cbp >> 2;

	   cbpy ^= 0xf;

	   put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);



	   

      h263_pred_motion(s, 0, &pred_x, &pred_y);

      

      if (!umvplus) {  

         h263_encode_motion(s, motion_x - pred_x);

         h263_encode_motion(s, motion_y - pred_y);

      }

      else {

         h263p_encode_umotion(s, motion_x - pred_x);

         h263p_encode_umotion(s, motion_y - pred_y);

         if (((motion_x - pred_x) == 1) && ((motion_y - pred_y) == 1))

            

            put_bits(&s->pb,1,1);

      }

   } else {

	

	cbp = 0;

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

	    if (s->block_last_index[i] >= 1)

		cbp |= 1 << (5 - i);

	}



	cbpc = cbp & 3;

	if (s->pict_type == I_TYPE) {

	    put_bits(&s->pb,

		     intra_MCBPC_bits[cbpc],

		     intra_MCBPC_code[cbpc]);

	} else {

	    put_bits(&s->pb, 1, 0);	

	    put_bits(&s->pb,

		     inter_MCBPC_bits[cbpc + 4],

		     inter_MCBPC_code[cbpc + 4]);

	}

	if (s->h263_pred) {

	    

	    put_bits(&s->pb, 1, 0);	

	}

	cbpy = cbp >> 2;

	put_bits(&s->pb, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);

    }



    

    if (s->h263_pred) {

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

	    mpeg4_encode_block(s, block[i], i);

	}

    } else {

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

	    h263_encode_block(s, block[i], i);

	}

    }

}

      if (!umvplus) {  
void FUNC_0(MpegEncContext * VAR_0,

		    DCTELEM VAR_1[6][64],

		    int VAR_2, int VAR_3)

{

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;



    

   if (!VAR_0->mb_intra) {

	   

	   VAR_7 = 0;

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

	      if (VAR_0->block_last_index[VAR_6] >= 0)

		   VAR_7 |= 1 << (5 - VAR_6);

	   }

	   if ((VAR_7 | VAR_2 | VAR_3) == 0) {

	      

	      put_bits(&VAR_0->pb, 1, 1);

	      return;

	   }

	   put_bits(&VAR_0->pb, 1, 0);	

	   VAR_4 = VAR_7 & 3;

	   put_bits(&VAR_0->pb,

		inter_MCBPC_bits[VAR_4],

		inter_MCBPC_code[VAR_4]);

	   VAR_5 = VAR_7 >> 2;

	   VAR_5 ^= 0xf;

	   put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]);



	   

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

      

      if (!umvplus) {  

         h263_encode_motion(VAR_0, VAR_2 - VAR_8);

         h263_encode_motion(VAR_0, VAR_3 - VAR_9);

      }

      else {

         h263p_encode_umotion(VAR_0, VAR_2 - VAR_8);

         h263p_encode_umotion(VAR_0, VAR_3 - VAR_9);

         if (((VAR_2 - VAR_8) == 1) && ((VAR_3 - VAR_9) == 1))

            

            put_bits(&VAR_0->pb,1,1);

      }

   } else {

	

	VAR_7 = 0;

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

	    if (VAR_0->block_last_index[VAR_6] >= 1)

		VAR_7 |= 1 << (5 - VAR_6);

	}



	VAR_4 = VAR_7 & 3;

	if (VAR_0->pict_type == I_TYPE) {

	    put_bits(&VAR_0->pb,

		     intra_MCBPC_bits[VAR_4],

		     intra_MCBPC_code[VAR_4]);

	} else {

	    put_bits(&VAR_0->pb, 1, 0);	

	    put_bits(&VAR_0->pb,

		     inter_MCBPC_bits[VAR_4 + 4],

		     inter_MCBPC_code[VAR_4 + 4]);

	}

	if (VAR_0->h263_pred) {

	    

	    put_bits(&VAR_0->pb, 1, 0);	

	}

	VAR_5 = VAR_7 >> 2;

	put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]);

    }



    

    if (VAR_0->h263_pred) {

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

	    mpeg4_encode_block(VAR_0, VAR_1[VAR_6], VAR_6);

	}

    } else {

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

	    h263_encode_block(VAR_0, VAR_1[VAR_6], VAR_6);

	}

    }

}

void FUNC_0(MpegEncContext * VAR_0,
DCTELEM VAR_1[6][64],
int VAR_2, int VAR_3)
{ int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; if (!VAR_0->mb_intra) { VAR_7 = 0; for (VAR_6 = 0; VAR_6 < 6; VAR_6++) { if (VAR_0->block_last_index[VAR_6] >= 0)
VAR_7 |= 1 << (5 - VAR_6); } if ((VAR_7 | VAR_2 | VAR_3) == 0) { put_bits(&VAR_0->pb, 1, 1); return; } put_bits(&VAR_0->pb, 1, 0); VAR_4 = VAR_7 & 3; put_bits(&VAR_0->pb,
inter_MCBPC_bits[VAR_4],
inter_MCBPC_code[VAR_4]); VAR_5 = VAR_7 >> 2; VAR_5 ^= 0xf; put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]); h263_pred_motion(VAR_0, 0, &VAR_8, &VAR_9); if (!umvplus) { h263_encode_motion(VAR_0, VAR_2 - VAR_8); h263_encode_motion(VAR_0, VAR_3 - VAR_9); } else { h263p_encode_umotion(VAR_0, VAR_2 - VAR_8); h263p_encode_umotion(VAR_0, VAR_3 - VAR_9); if (((VAR_2 - VAR_8) == 1) && ((VAR_3 - VAR_9) == 1))
put_bits(&VAR_0->pb,1,1); } } else { VAR_7 = 0; for (VAR_6 = 0; VAR_6 < 6; VAR_6++) { if (VAR_0->block_last_index[VAR_6] >= 1)
VAR_7 |= 1 << (5 - VAR_6); } VAR_4 = VAR_7 & 3; if (VAR_0->pict_type == I_TYPE) { put_bits(&VAR_0->pb,
intra_MCBPC_bits[VAR_4],
intra_MCBPC_code[VAR_4]); } else { put_bits(&VAR_0->pb, 1, 0); put_bits(&VAR_0->pb,
inter_MCBPC_bits[VAR_4 + 4],
inter_MCBPC_code[VAR_4 + 4]); } if (VAR_0->h263_pred) { put_bits(&VAR_0->pb, 1, 0); } VAR_5 = VAR_7 >> 2; put_bits(&VAR_0->pb, cbpy_tab[VAR_5][1], cbpy_tab[VAR_5][0]); } if (VAR_0->h263_pred) { for (VAR_6 = 0; VAR_6 < 6; VAR_6++) { mpeg4_encode_block(VAR_0, VAR_1[VAR_6], VAR_6); } } else { for (VAR_6 = 0; VAR_6 < 6; VAR_6++) { h263_encode_block(VAR_0, VAR_1[VAR_6], VAR_6); } } }