static int decode_motion_vector (bit_buffer_t *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) {

  uint32_t    bit_cache;

  vlc_code_t *vlc;

  int	      diff, sign;

  int	      i;



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



    /* get motion code */

    bit_cache = get_bit_cache (bitbuf);



    if (!(bit_cache & 0xFFE00000))

      return -1;	/* invalid vlc code */



    if (bit_cache & 0x80000000) {

      diff = 0;



      /* flush bit */

      skip_bits(bitbuf,1);



    } else {

      if (bit_cache >= 0x06000000) {

        vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];

      } else {

        vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];

      }



      /* decode motion vector differential */

      sign = (int) (bit_cache << (vlc->length - 1)) >> 31;

      diff = (vlc->value ^ sign) - sign;



      /* flush bits */

      skip_bits(bitbuf,vlc->length);

    }



    /* add median of motion vector predictors and clip result */

    if (i == 1)

      mv->y = ((diff + MEDIAN(pmv[0]->y, pmv[1]->y, pmv[2]->y)) << 26) >> 26;

    else

      mv->x = ((diff + MEDIAN(pmv[0]->x, pmv[1]->x, pmv[2]->x)) << 26) >> 26;

  }



  return 0;

}

static int decode_motion_vector (bit_buffer_t *bitbuf, svq1_pmv_t *mv, svq1_pmv_t **pmv) {

  uint32_t    bit_cache;

  vlc_code_t *vlc;

  int	      diff, sign;

  int	      i;



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



    

    bit_cache = get_bit_cache (bitbuf);



    if (!(bit_cache & 0xFFE00000))

      return -1;	



    if (bit_cache & 0x80000000) {

      diff = 0;



      

      skip_bits(bitbuf,1);



    } else {

      if (bit_cache >= 0x06000000) {

        vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];

      } else {

        vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];

      }



      

      sign = (int) (bit_cache << (vlc->length - 1)) >> 31;

      diff = (vlc->value ^ sign) - sign;



      

      skip_bits(bitbuf,vlc->length);

    }



    

    if (i == 1)

      mv->y = ((diff + MEDIAN(pmv[0]->y, pmv[1]->y, pmv[2]->y)) << 26) >> 26;

    else

      mv->x = ((diff + MEDIAN(pmv[0]->x, pmv[1]->x, pmv[2]->x)) << 26) >> 26;

  }



  return 0;

}

static int FUNC_0 (bit_buffer_t *VAR_0, svq1_pmv_t *VAR_1, svq1_pmv_t **VAR_2) {

  uint32_t    bit_cache;

  vlc_code_t *vlc;

  int	      VAR_3, VAR_4;

  int	      VAR_5;



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



    

    bit_cache = get_bit_cache (VAR_0);



    if (!(bit_cache & 0xFFE00000))

      return -1;	



    if (bit_cache & 0x80000000) {

      VAR_3 = 0;



      

      skip_bits(VAR_0,1);



    } else {

      if (bit_cache >= 0x06000000) {

        vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3];

      } else {

        vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2];

      }



      

      VAR_4 = (int) (bit_cache << (vlc->length - 1)) >> 31;

      VAR_3 = (vlc->value ^ VAR_4) - VAR_4;



      

      skip_bits(VAR_0,vlc->length);

    }



    

    if (VAR_5 == 1)

      VAR_1->y = ((VAR_3 + MEDIAN(VAR_2[0]->y, VAR_2[1]->y, VAR_2[2]->y)) << 26) >> 26;

    else

      VAR_1->x = ((VAR_3 + MEDIAN(VAR_2[0]->x, VAR_2[1]->x, VAR_2[2]->x)) << 26) >> 26;

  }



  return 0;

}

static int FUNC_0 (bit_buffer_t *VAR_0, svq1_pmv_t *VAR_1, svq1_pmv_t **VAR_2) { uint32_t    bit_cache; vlc_code_t *vlc; int	      VAR_3, VAR_4; int	      VAR_5; for (VAR_5=0; VAR_5 < 2; VAR_5++) { bit_cache = get_bit_cache (VAR_0); if (!(bit_cache & 0xFFE00000))
return -1; if (bit_cache & 0x80000000) { VAR_3 = 0; skip_bits(VAR_0,1); } else { if (bit_cache >= 0x06000000) { vlc = &motion_table_0[(bit_cache >> (32 - 7)) - 3]; } else { vlc = &motion_table_1[(bit_cache >> (32 - 12)) - 2]; } VAR_4 = (int) (bit_cache << (vlc->length - 1)) >> 31; VAR_3 = (vlc->value ^ VAR_4) - VAR_4; skip_bits(VAR_0,vlc->length); } if (VAR_5 == 1)
VAR_1->y = ((VAR_3 + MEDIAN(VAR_2[0]->y, VAR_2[1]->y, VAR_2[2]->y)) << 26) >> 26; else
VAR_1->x = ((VAR_3 + MEDIAN(VAR_2[0]->x, VAR_2[1]->x, VAR_2[2]->x)) << 26) >> 26; } return 0; }