⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 svq1.c

📁 Trolltech公司发布的图形界面操作系统。可在qt-embedded-2.3.7平台上编译为嵌入式图形界面操作系统。
💻 C
📖 第 1 页 / 共 4 页
字号:
  vlc_code_t *vlc;  uint8_t    *list[63];  uint32_t   *dst;  const uint32_t *codebook;  int	      entries[6];  int	      i, j, m, n;  int	      mean, stages;  unsigned    x, y, width, height, level;  uint32_t    n1, n2, n3, n4;  /* initialize list for breadth first processing of vectors */  list[0] = pixels;  /* recursively process vector */  for (i=0, m=1, n=1, level=5; i < n; i++) {    SVQ1_PROCESS_VECTOR();    /* destination address and vector size */    dst = (uint32_t *) list[i];    width = 1 << ((4 + level) /2);    height = 1 << ((3 + level) /2);    /* get number of stages (-1 skips vector, 0 for mean only) */    bit_cache = get_bit_cache (bitbuf);    vlc = &svq1_intra_vector_tables[level][bit_cache >> (32 - 7)];    /* flush bits */    stages	    = vlc->value;    skip_bits(bitbuf,vlc->length);    if (stages == -1) {	for (y=0; y < height; y++) {	  memset (&dst[y*(pitch / 4)], 0, width);	}      continue;		/* skip vector */    }    if ((stages > 0) && (level >= 4)) {#ifdef DEBUG_SVQ1    printf("Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",stages,level);#endif      return -1;	/* invalid vector */    }    /* get mean value for vector */    bit_cache = get_bit_cache (bitbuf);    if (bit_cache >= 0x25000000)	vlc = &svq1_intra_mean_table_0[(bit_cache >> (32 - 8)) - 37];    else if (bit_cache >= 0x03400000)	vlc = &svq1_intra_mean_table_1[(bit_cache >> (32 - 10)) - 13];    else if (bit_cache >= 0x00040000) 	vlc = &svq1_intra_mean_table_2[(bit_cache >> (32 - 14)) - 1];    else	vlc = &svq1_intra_mean_table_3[bit_cache >> (32 - 20)];    /* flush bits */    mean	    = vlc->value;    skip_bits(bitbuf,vlc->length);    if (stages == 0) {      for (y=0; y < height; y++) {	memset (&dst[y*(pitch / 4)], mean, width);      }    } else {      SVQ1_CALC_CODEBOOK_ENTRIES(svq1_intra_codebooks);      SVQ1_DO_CODEBOOK_INTRA()    }  }  return 0;}static int svq1_decode_block_non_intra (bit_buffer_t *bitbuf, uint8_t *pixels, int pitch ) {  uint32_t    bit_cache;  vlc_code_t *vlc;  uint8_t    *list[63];  uint32_t   *dst;  const uint32_t *codebook;  int	      entries[6];  int	      i, j, m, n;  int	      mean, stages;  int	      x, y, width, height, level;  uint32_t    n1, n2, n3, n4;  /* initialize list for breadth first processing of vectors */  list[0] = pixels;  /* recursively process vector */  for (i=0, m=1, n=1, level=5; i < n; i++) {    SVQ1_PROCESS_VECTOR();    /* destination address and vector size */    dst = (uint32_t *) list[i];    width = 1 << ((4 + level) /2);    height = 1 << ((3 + level) /2);    /* get number of stages (-1 skips vector, 0 for mean only) */    bit_cache = get_bit_cache (bitbuf);    vlc = &svq1_inter_vector_tables[level][bit_cache >> (32 - 6)];    /* flush bits */    stages	    = vlc->value;    skip_bits(bitbuf,vlc->length);    if (stages == -1) continue;	/* skip vector */    if ((stages > 0) && (level >= 4)) {#ifdef DEBUG_SVQ1    printf("Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",stages,level);#endif      return -1;	/* invalid vector */    }    /* get mean value for vector */    bit_cache = get_bit_cache (bitbuf);    if (bit_cache >= 0x0B000000)	vlc = &svq1_inter_mean_table_0[(bit_cache >> (32 - 8)) - 11];    else if (bit_cache >= 0x01200000)	vlc = &svq1_inter_mean_table_1[(bit_cache >> (32 - 12)) - 18];    else if (bit_cache >= 0x002E0000) 	vlc = &svq1_inter_mean_table_2[(bit_cache >> (32 - 15)) - 23];    else if (bit_cache >= 0x00094000)	vlc = &svq1_inter_mean_table_3[(bit_cache >> (32 - 18)) - 37];    else if (bit_cache >= 0x00049000)	vlc = &svq1_inter_mean_table_4[(bit_cache >> (32 - 20)) - 73];    else	vlc = &svq1_inter_mean_table_5[bit_cache >> (32 - 22)];    /* flush bits */    mean	    = vlc->value;    skip_bits(bitbuf,vlc->length);    SVQ1_CALC_CODEBOOK_ENTRIES(svq1_inter_codebooks);    SVQ1_DO_CODEBOOK_NONINTRA()  }  return 0;}static int svq1_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 = &svq1_motion_table_0[(bit_cache >> (32 - 7)) - 3];      } else {        vlc = &svq1_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 void svq1_skip_block (uint8_t *current, uint8_t *previous, int pitch, int x, int y) {  uint8_t *src;  uint8_t *dst;  int	   i;  src = &previous[x + y*pitch];  dst = current;  for (i=0; i < 16; i++) {    memcpy (dst, src, 16);    src += pitch;    dst += pitch;  }}static int svq1_motion_inter_block (MpegEncContext *s, bit_buffer_t *bitbuf,			       uint8_t *current, uint8_t *previous, int pitch,			       svq1_pmv_t *motion, int x, int y) {  uint8_t    *src;  uint8_t    *dst;  svq1_pmv_t  mv;  svq1_pmv_t *pmv[3];  int	      result;  /* predict and decode motion vector */  pmv[0] = &motion[0];  if (y == 0) {    pmv[1] =    pmv[2] = pmv[0];  }  else {    pmv[1] = &motion[(x / 8) + 2];    pmv[2] = &motion[(x / 8) + 4];  }  result = svq1_decode_motion_vector (bitbuf, &mv, pmv);  if (result != 0)    return result;  motion[0].x		=  motion[(x / 8) + 2].x	=  motion[(x / 8) + 3].x	= mv.x;  motion[0].y		=  motion[(x / 8) + 2].y	=  motion[(x / 8) + 3].y	= mv.y;  src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch];  dst = current;  s->dsp.put_pixels_tab[0][((mv.y & 1) << 1) | (mv.x & 1)](dst,src,pitch,16);  return 0;}static int svq1_motion_inter_4v_block (MpegEncContext *s, bit_buffer_t *bitbuf,				  uint8_t *current, uint8_t *previous, int pitch,				  svq1_pmv_t *motion,int x, int y) {  uint8_t    *src;  uint8_t    *dst;  svq1_pmv_t  mv;  svq1_pmv_t *pmv[4];  int	      i, result;  /* predict and decode motion vector (0) */  pmv[0] = &motion[0];  if (y == 0) {    pmv[1] =    pmv[2] = pmv[0];  }  else {    pmv[1] = &motion[(x / 8) + 2];    pmv[2] = &motion[(x / 8) + 4];  }  result = svq1_decode_motion_vector (bitbuf, &mv, pmv);  if (result != 0)    return result;  /* predict and decode motion vector (1) */  pmv[0] = &mv;  if (y == 0) {    pmv[1] =    pmv[2] = pmv[0];  }  else {    pmv[1] = &motion[(x / 8) + 3];  }  result = svq1_decode_motion_vector (bitbuf, &motion[0], pmv);  if (result != 0)    return result;  /* predict and decode motion vector (2) */  pmv[1] = &motion[0];  pmv[2] = &motion[(x / 8) + 1];  result = svq1_decode_motion_vector (bitbuf, &motion[(x / 8) + 2], pmv);  if (result != 0)    return result;  /* predict and decode motion vector (3) */  pmv[2] = &motion[(x / 8) + 2];  pmv[3] = &motion[(x / 8) + 3];  result = svq1_decode_motion_vector (bitbuf, pmv[3], pmv);  if (result != 0)    return result;  /* form predictions */  for (i=0; i < 4; i++) {    src = &previous[(x + (pmv[i]->x >> 1)) + (y + (pmv[i]->y >> 1))*pitch];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -