📄 video.c
字号:
/* Set dest to Cr plane of current pict image. */ dest = vid_stream->current->Cr; /* Establish row size. */ row_size = vid_stream->mb_width * 8; /* Calculate row,col for upper left pixel of block. */ row = mb_row * 8; col = mb_col * 8; } /* Otherwise block is Cb block, and ... */ else { /* Set dest to Cb plane of current pict image. */ dest = vid_stream->current->Cb; /* Establish row size. */ row_size = vid_stream->mb_width * 8; /* Calculate row,col for upper left pixel value of block. */ row = mb_row * 8; col = mb_col * 8; } /* * For each pixel in block, set to cropped reconstructed value from inverse * dct. */ { short *sp = &vid_stream->block.dct_recon[0][0]; unsigned char *cm = cropTbl + MAX_NEG_CROP; dest += row * row_size + col; for (rr = 0; rr < 4; rr++, sp += 16, dest += row_size) { dest[0] = cm[sp[0]]; assertCrop(sp[0]); dest[1] = cm[sp[1]]; assertCrop(sp[1]); dest[2] = cm[sp[2]]; assertCrop(sp[2]); dest[3] = cm[sp[3]]; assertCrop(sp[3]); dest[4] = cm[sp[4]]; assertCrop(sp[4]); dest[5] = cm[sp[5]]; assertCrop(sp[5]); dest[6] = cm[sp[6]]; assertCrop(sp[6]); dest[7] = cm[sp[7]]; assertCrop(sp[7]); dest += row_size; dest[0] = cm[sp[8]]; assertCrop(sp[8]); dest[1] = cm[sp[9]]; assertCrop(sp[9]); dest[2] = cm[sp[10]]; assertCrop(sp[10]); dest[3] = cm[sp[11]]; assertCrop(sp[11]); dest[4] = cm[sp[12]]; assertCrop(sp[12]); dest[5] = cm[sp[13]]; assertCrop(sp[13]); dest[6] = cm[sp[14]]; assertCrop(sp[14]); dest[7] = cm[sp[15]]; assertCrop(sp[15]); } }}/* *-------------------------------------------------------------- * * ReconPMBlock -- * * Reconstructs forward predicted macroblocks. * * Results: * None. * * Side effects: * None. * *-------------------------------------------------------------- */static voidReconPMBlock(vid_stream, bnum, recon_right_for, recon_down_for, zflag) VidStream *vid_stream; int bnum, recon_right_for, recon_down_for, zflag;{ int mb_row, mb_col, row, col, row_size, rr; unsigned char *dest, *past; static int right_for, down_for, right_half_for, down_half_for; unsigned char *rindex1, *rindex2; unsigned char *index; short int *blockvals;#ifdef LOOSE_MPEG int maxx, maxy; int illegalBlock = 0; int row_start, row_end, rfirst, rlast, col_start, col_end, cfirst, clast;#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 (bnum < 4) { /* Calculate right_for, down_for 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; /* Set dest to luminance plane of current pict image. */ dest = vid_stream->current->luminance; if (vid_stream->picture.code_type == B_TYPE) { if (vid_stream->past != NULL) past = vid_stream->past->luminance; } else { /* Set predicitive frame to current future frame. */ if (vid_stream->future != NULL) past = 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_for + 7 > maxy) illegalBlock |= 0x4; else if (row + down_for < 0) illegalBlock |= 0x1; if (col + right_for + 7 > maxx) illegalBlock |= 0x2; else if (col + right_for < 0) illegalBlock |= 0x8;#endif } /* Otherwise, block is NOT luminance block, ... */ else { /* Construct motion vectors. */ recon_right_for /= 2; recon_down_for /= 2; 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; /* 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_for + 7 > maxy) illegalBlock |= 0x4; else if (row + down_for < 0) illegalBlock |= 0x1; if (col + right_for + 7 > maxx) illegalBlock |= 0x2; else if (col + right_for < 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 (vid_stream->picture.code_type == B_TYPE) { if (vid_stream->past != NULL) past = vid_stream->past->Cr; } else { if (vid_stream->future != NULL) past = 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 (vid_stream->picture.code_type == B_TYPE) { if (vid_stream->past != NULL) past = vid_stream->past->Cb; } else { if (vid_stream->future != NULL) past = vid_stream->future->Cb; } } } /* For each pixel in block... */#ifdef LOOSE_MPEG if (illegalBlock) { if (illegalBlock & 0x1) { row_start = 0; row_end = row+down_for+8; rfirst = rlast = 8 - row_end; } else if (illegalBlock & 0x4) { row_start = row + down_for; row_end = maxy+1; rlast = row_end - row_start - 1; rfirst = 0; } else { row_start = row+down_for; row_end = row_start+8; rfirst = 0; } if (illegalBlock & 0x8) { col_start = 0; col_end = col + right_for + 8; cfirst = clast = 8 - col_end; } else if (illegalBlock & 0x2) { col_start = col + right_for; col_end = maxx + 1; clast = col_end - col_start - 1; cfirst = 0; } else { col_start = col + right_for; col_end = col_start + 8; cfirst = 0; } for (rr = row_start; rr < row_end; rr++) { rindex1 = past + (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 = past + (row + down_for) * row_size + col + right_for; blockvals = &(vid_stream->block.dct_recon[0][0]); /* * Calculate predictive pixel value based on motion vectors and copy to * dest plane. */ if ((!down_half_for) && (!right_half_for)) { 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_for & 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_for & 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_for + (down_half_for * 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -