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

📄 video.c

📁 mpeng Lib
💻 C
📖 第 1 页 / 共 5 页
字号:
	  rindex2 += row_size;	}    }#ifdef LOOSE_MPEG  }#endif}/* *-------------------------------------------------------------- * * ReconBMBlock -- * *	Reconstructs back predicted macroblocks. * * Results: *      None. * * Side effects: *      None. * *-------------------------------------------------------------- */static voidReconBMBlock(vid_stream, bnum, recon_right_back, recon_down_back, zflag)  VidStream *vid_stream;  int bnum, recon_right_back, recon_down_back, zflag;{  int mb_row, mb_col, row, col, row_size, rr;  unsigned char *dest, *future;  int right_back, down_back, right_half_back, down_half_back;  unsigned char *rindex1, *rindex2;  unsigned char *index;  short int *blockvals;#ifdef LOOSE_MPEG  int illegalBlock = 0;  int maxx, maxy;  int row_start, row_end, rlast, rfirst, col_start, col_end, clast, cfirst;#endif  /* Calculate macroblock row and column from address. */  mb_row = vid_stream->mblock.mb_address / vid_stream->mb_width;  mb_col = vid_stream->mblock.mb_address % vid_stream->mb_width;  /* If block is luminance block... */  if (bnum < 4) {    /* Calculate right_back, down_bakc motion vectors. */    right_back = recon_right_back >> 1;    down_back = recon_down_back >> 1;    right_half_back = recon_right_back & 0x1;    down_half_back = recon_down_back & 0x1;    /* Set dest to luminance plane of current pict image. */    dest = vid_stream->current->luminance;    /*     * If future frame exists, set future to luminance plane of future frame.     */    if (vid_stream->future != NULL)      future = vid_stream->future->luminance;    /* Establish row size. */    row_size = vid_stream->mb_width << 4;    /* Calculate row,col of upper left pixel in block. */    row = mb_row << 4;    col = mb_col << 4;    if (bnum > 1)      row += 8;    if (bnum % 2)      col += 8;#ifdef LOOSE_MPEG    /* Check for block illegality. */    maxx = lmaxx; maxy = lmaxy;    if (row + down_back + 7 > maxy) illegalBlock |= 0x4;    else if (row + down_back < 0)  illegalBlock |= 0x1;        if (col + right_back + 7 > maxx) illegalBlock |= 0x2;    else if (col + right_back < 0) illegalBlock |= 0x8;#endif  }  /* Otherwise, block is NOT luminance block, ... */  else {    /* Construct motion vectors. */    recon_right_back /= 2;    recon_down_back /= 2;    right_back = recon_right_back >> 1;    down_back = recon_down_back >> 1;    right_half_back = recon_right_back & 0x1;    down_half_back = recon_down_back & 0x1;    /* Establish row size. */    row_size = vid_stream->mb_width << 3;    /* Calculate row,col of upper left pixel in block. */    row = mb_row << 3;    col = mb_col << 3;#ifdef LOOSE_MPEG    /* Check for block illegality. */    maxx = cmaxx; maxy = cmaxy;    if (row + down_back + 7 > maxy) illegalBlock |= 0x4;    else if (row + down_back < 0) illegalBlock |= 0x1;    if (col + right_back + 7 > maxx) illegalBlock  |= 0x2;    else if (col + right_back < 0) illegalBlock |= 0x8;#endif    /* If block is Cr block... */    if (bnum == 4) {      /* Set dest to Cr plane of current pict image. */      dest = vid_stream->current->Cr;      /*       * If future frame exists, set future to Cr plane of future image.       */      if (vid_stream->future != NULL)	future = vid_stream->future->Cr;    }    /* Otherwise, block is Cb block... */    else {      /* Set dest to Cb plane of current pict image. */      dest = vid_stream->current->Cb;      /*       * If future frame exists, set future to Cb plane of future frame.       */      if (vid_stream->future != NULL)	future = vid_stream->future->Cb;    }  }  /* For each pixel in block do... */#ifdef LOOSE_MPEG  if (illegalBlock) {    if (illegalBlock & 0x1) {      row_start = 0;      row_end = row+down_back+8;      rfirst = rlast = 8 - row_end;    }    else if (illegalBlock & 0x4) {      row_start = row + down_back;      row_end = maxy+1;      rlast = row_end - row_start - 1;      rfirst = 0;    }    else {      row_start = row+down_back;      row_end = row_start+8;      rfirst = 0;    }    if (illegalBlock & 0x8) {      col_start = 0;      col_end = col + right_back + 8;      cfirst = clast = 8 - col_end;    }    else if (illegalBlock & 0x2) {      col_start = col + right_back;      col_end = maxx + 1;      clast = col_end - col_start - 1;      cfirst = 0;    }    else {      col_start = col + right_back;      col_end = col_start + 8;      cfirst = 0;    }    for (rr = row_start; rr < row_end; rr++) {      rindex1 = future + (rr * row_size) + col_start;      index = dest + ((row + rfirst) * row_size) + col + cfirst;      for (cc = col_start; cc < col_end; cc++) {	*index++ = *rindex1++;      }    }    if (illegalBlock & 0x1) {      for (rr = rlast -1; rr >=0; rr--) {	index = dest + ((row + rr) * row_size) + col;	rindex1 = dest + ((row + rlast) * row_size) + col;	for (cc = 0; cc < 8; cc ++) {	  *index++ = *rindex1++;	}      }    }    else if (illegalBlock & 0x4) {      for (rr = rlast+1; rr < 8; rr++) {	index = dest + ((row + rr) * row_size) + col;	rindex1 = dest + ((row + rlast) * row_size) + col;	for (cc = 0; cc < 8; cc ++) {	  *index++ = *rindex1++;	}      }    }    if (illegalBlock & 0x2) {      for (cc = clast+1; cc < 8; cc++) {	index = dest + (row * row_size) + (col + cc);	rindex1 = dest + (row * row_size) + (col + clast);	for (rr = 0; rr < 8; rr++) {	  *index = *rindex1;	  index += row_size;	  rindex1 += row_size;	}      }    }    else if (illegalBlock & 0x8) {      for (cc = clast-1; cc >= 0; cc--) {	index = dest + (row * row_size) + (col + cc);	rindex1 = dest + (row * row_size) + (col + clast);	for (rr = 0; rr < 8; rr++) {	  *index = *rindex1;	  index += row_size;	  rindex1 += row_size;	}      }    }    if (!zflag) {      for (rr = 0; rr < 8; rr++) {	index = dest + (row*row_size) + col;	blockvals = &(vid_stream->block.dct_recon[rr][0]);	index[0] += blockvals[0];	index[1] += blockvals[1];	index[2] += blockvals[2];	index[3] += blockvals[3];	index[4] += blockvals[4];	index[5] += blockvals[5];	index[6] += blockvals[6];	index[7] += blockvals[7];      }    }  }  else {#endif        index = dest + (row * row_size) + col;    rindex1 = future + (row + down_back) * row_size + col + right_back;    blockvals = &(vid_stream->block.dct_recon[0][0]);    if ((!right_half_back) && (!down_half_back)) {      unsigned char *cm = cropTbl + MAX_NEG_CROP;      if (!zflag)	for (rr = 0; rr < 4; rr++) {	  index[0] = cm[(int) rindex1[0] + (int) blockvals[0]];	  index[1] = cm[(int) rindex1[1] + (int) blockvals[1]];	  index[2] = cm[(int) rindex1[2] + (int) blockvals[2]];	  index[3] = cm[(int) rindex1[3] + (int) blockvals[3]];	  index[4] = cm[(int) rindex1[4] + (int) blockvals[4]];	  index[5] = cm[(int) rindex1[5] + (int) blockvals[5]];	  index[6] = cm[(int) rindex1[6] + (int) blockvals[6]];	  index[7] = cm[(int) rindex1[7] + (int) blockvals[7]];	  index += row_size;	  rindex1 += row_size;	  	  index[0] = cm[(int) rindex1[0] + (int) blockvals[8]];	  index[1] = cm[(int) rindex1[1] + (int) blockvals[9]];	  index[2] = cm[(int) rindex1[2] + (int) blockvals[10]];	  index[3] = cm[(int) rindex1[3] + (int) blockvals[11]];	  index[4] = cm[(int) rindex1[4] + (int) blockvals[12]];	  index[5] = cm[(int) rindex1[5] + (int) blockvals[13]];	  index[6] = cm[(int) rindex1[6] + (int) blockvals[14]];	  index[7] = cm[(int) rindex1[7] + (int) blockvals[15]];	  blockvals += 16;	  index += row_size;	  rindex1 += row_size;	}      else {	if (right_back & 0x1) {	  /* No alignment, use bye copy */	  for (rr = 0; rr < 4; rr++) {	    index[0] = rindex1[0];	    index[1] = rindex1[1];	    index[2] = rindex1[2];	    index[3] = rindex1[3];	    index[4] = rindex1[4];	    index[5] = rindex1[5];	    index[6] = rindex1[6];	    index[7] = rindex1[7];	    index += row_size;	    rindex1 += row_size;	    	    index[0] = rindex1[0];	    index[1] = rindex1[1];	    index[2] = rindex1[2];	    index[3] = rindex1[3];	    index[4] = rindex1[4];	    index[5] = rindex1[5];	    index[6] = rindex1[6];	    index[7] = rindex1[7];	    index += row_size;	    rindex1 += row_size;	  }	} else if (right_back & 0x2) {	  /* Half-word bit aligned, use 16 bit copy */	  short *src = (short *)rindex1;	  short *dest = (short *)index;	  row_size >>= 1;	  for (rr = 0; rr < 4; rr++) {	    dest[0] = src[0];	    dest[1] = src[1];	    dest[2] = src[2];	    dest[3] = src[3];	    dest += row_size;	    src += row_size;	    	    dest[0] = src[0];	    dest[1] = src[1];	    dest[2] = src[2];	    dest[3] = src[3];	    dest += row_size;	    src += row_size;	  }	} else {	  /* Word aligned, use 32 bit copy */	  int *src = (int *)rindex1;	  int *dest = (int *)index;	  row_size >>= 2;	  for (rr = 0; rr < 4; rr++) {	    dest[0] = src[0];	    dest[1] = src[1];	    dest += row_size;	    src += row_size;	    	    dest[0] = src[0];	    dest[1] = src[1];	    dest += row_size;	    src += row_size;	  }	}      }    } else {      unsigned char *cm = cropTbl + MAX_NEG_CROP;      rindex2 = rindex1 + right_half_back + (down_half_back * row_size);      if (!zflag)	for (rr = 0; rr < 4; rr++) {	  index[0] = cm[((int) (rindex1[0] + rindex2[0]) >> 1) + blockvals[0]];	  index[1] = cm[((int) (rindex1[1] + rindex2[1]) >> 1) + blockvals[1]];	  index[2] = cm[((int) (rindex1[2] + rindex2[2]) >> 1) + blockvals[2]];	  index[3] = cm[((int) (rindex1[3] + rindex2[3]) >> 1) + blockvals[3]];	  index[4] = cm[((int) (rindex1[4] + rindex2[4]) >> 1) + blockvals[4]];	  index[5] = cm[((int) (rindex1[5] + rindex2[5]) >> 1) + blockvals[5]];	  index[6] = cm[((int) (rindex1[6] + rindex2[6]) >> 1) + blockvals[6]];	  index[7] = cm[((int) (rindex1[7] + rindex2[7]) >> 1) + blockvals[7]];	  index += row_size;	  rindex1 += row_size;	  rindex2 += row_size;	  	  index[0] = cm[((int) (rindex1[0] + rindex2[0]) >> 1) + blockvals[8]];	  index[1] = cm[((int) (rindex1[1] + rindex2[1]) >> 1) + blockvals[9]];	  index[2] = cm[((int) (rindex1[2] + rindex2[2]) >> 1) + blockvals[10]];	  index[3] = cm[((int) (rindex1[3] + rindex2[3]) >> 1) + blockvals[11]];	  index[4] = cm[((int) (rindex1[4] + rindex2[4]) >> 1) + blockvals[12]];	  index[5] = cm[((int) (rindex1[5] + rindex2[5]) >> 1) + blockvals[13]];	  index[6] = cm[((int) (rindex1[6] + rindex2[6]) >> 1) + blockvals[14]];	  index[7] = cm[((int) (rindex1[7] + rindex2[7]) >> 1) + blockvals[15]];	  blockvals += 16;	  index += row_size;	  rindex1 += row_size;	  rindex2 += row_size;	}      else	for (rr = 0; rr < 4; rr++) {	  index[0] = (int) (rindex1[0] + rindex2[0]) >> 1;	  index[1] = (int) (rindex1[1] + rindex2[1]) >> 1;	  index[2] = (int) (rindex1[2] + rindex2[2]) >> 1;	  index[3] = (int) (rindex1[3] + rindex2[3]) >> 1;	  index[4] = (int) (rindex1[4] + rindex2[4]) >> 1;	  index[5] = (int) (rindex1[5] + rindex2[5]) >> 1;	  index[6] = (int) (rindex1[6] + rindex2[6]) >> 1;	  index[7] = (int) (rindex1[7] + rindex2[7]) >> 1;	  index += row_size;	  rindex1 += row_size;	  rindex2 += row_size;	  	  index[0] = (int) (rindex1[0] + rindex2[0]) >> 1;	  index[1] = (int) (rindex1[1] + rindex2[1]) >> 1;	  index[2] = (int) (rindex1[2] + rindex2[2]) >> 1;	  index[3] = (int) (rindex1[3] + rindex2[3]) >> 1;	  index[4] = (int) (rindex1[4] + rindex2[4]) >> 1;	  index[5] = (int) (rindex1[5] + rindex2[5]) >> 1;	  index[6] = (int) (rindex1[6] + rindex2[6]) >> 1;	  index[7] = (int) (rindex1[7] + rindex2[7]) >> 1;	  index += row_size;	  rindex1 += row_size;	  rindex2 += row_size;	}    }#ifdef LOOSE_MPEG  }#endif}/* *-------------------------------------------------------------- * * ReconBiMBlock -- * *	Reconstructs bidirectionally predicted macroblocks. * * Results: *      None. * * Side effects: *      None. * *-------------------------------------------------------------- */static voidReconBiMBlock(vid_stream, bnum, recon_right_for, recon_down_for,	      recon_right_back, recon_down_back, zflag)  VidStream *vid_stream;  int bnum, recon_right_for, recon_down_for, recon_right_back, recon_down_back;  int zflag;{  int mb_row, mb_col, row, col, row_size, rr;  unsigned char *dest, *past, *future;  int right_for, down_for, right_half_for, down_half_for;  int right_back, down_back, right_half_back, down_half_back;  unsigned char *index, *rindex1, *bindex1;  short int *blockvals;  int forw_row_start, back_row_start, forw_col_start, back_col_start;#ifdef LOOSE_MPEG  int illegal_forw = 0;  int illegal_back = 0;#endif  /* Calculate macroblock row and column from address. */  mb_row = vid_stream->mblock.mb_address / vid_stream->mb_width;  mb_col = vid_stream->mblock.mb_address % vid_stream->mb_width;  /* If block is luminance block... */  if (bnum < 4) {    /*     * Calculate right_for, down_for, right_half_for, down_half_for,     * right_back, down_bakc, right_half_back, and down_half_back, motion     * vectors.     */    right_for = recon_right_for >> 1;    down_for = recon_down_for >> 1;    right_half_for = recon_right_for & 0x1;    down_half_for = recon_down_for & 0x1;    right_back = recon_right_back >> 1;    down_back = recon_down_back >> 1;    right_half_back = recon_right_back & 0x1;    down_half_back = recon_down_back & 0x1;    /* Set dest to luminance plane of current pict image. */    dest = vid_stream->current->lumina

⌨️ 快捷键说明

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