📄 mcomp.c
字号:
dest[3] = (7 * dest[3] + p[3] + 4) >> 3; // Second row dest += hdim, p += hdim; dest[0] = (3 * dest[0] + p[0] + 2) >> 2; dest[1] = (3 * dest[1] + p[1] + 2) >> 2; dest[2] = (7 * dest[2] + p[2] + 4) >> 3; dest[3] = (7 * dest[3] + p[3] + 4) >> 3; // Third row (identical to second row) dest += hdim, p += hdim; dest[0] = (3 * dest[0] + p[0] + 2) >> 2; dest[1] = (3 * dest[1] + p[1] + 2) >> 2; dest[2] = (7 * dest[2] + p[2] + 4) >> 3; dest[3] = (7 * dest[3] + p[3] + 4) >> 3; // Fourth row (identical to third row) dest += hdim, p += hdim; dest[0] = (3 * dest[0] + p[0] + 2) >> 2; dest[1] = (3 * dest[1] + p[1] + 2) >> 2; dest[2] = (7 * dest[2] + p[2] + 4) >> 3; dest[3] = (7 * dest[3] + p[3] + 4) >> 3; return;}// weighRight_Vert - Derived from weighLeft_Vert by reversing indices// This means that the assembler routine can be easily derived from the otherstatic void weighRight_Vert( PIXEL *dest, // Non-overlapped MC; overlapped by this routine PIXEL const *p, // p: MC using right motion vector // &p[TOP_OFFSET]: MC using top/bottom MV int hdim ) // Line offset{ // First row dest[3] = (2 * dest[3] + p[3] + p[TOP_OFFSET + 3] + 2) >> 2; dest[2] = (5 * dest[2] + p[2] + 2 * p[TOP_OFFSET + 2] + 4) >> 3; dest[1] = (5 * dest[1] + p[1] + 2 * p[TOP_OFFSET + 1] + 4) >> 3; dest[0] = (5 * dest[0] + p[0] + 2 * p[TOP_OFFSET + 0] + 4) >> 3; // Second row dest += hdim, p += hdim; dest[3] = (5 * dest[3] + 2 * p[3] + p[TOP_OFFSET + 3] + 4) >> 3; dest[2] = (5 * dest[2] + 2 * p[2] + p[TOP_OFFSET + 2] + 4) >> 3; dest[1] = (5 * dest[1] + p[1] + 2 * p[TOP_OFFSET + 1] + 4) >> 3; dest[0] = (5 * dest[0] + p[0] + 2 * p[TOP_OFFSET + 0] + 4) >> 3; // Third row dest += hdim, p += hdim; dest[3] = (5 * dest[3] + 2 * p[3] + p[TOP_OFFSET + 3] + 4) >> 3; dest[2] = (5 * dest[2] + 2 * p[2] + p[TOP_OFFSET + 2] + 4) >> 3; dest[1] = (6 * dest[1] + p[1] + p[TOP_OFFSET + 1] + 4) >> 3; dest[0] = (6 * dest[0] + p[0] + p[TOP_OFFSET + 0] + 4) >> 3; // Fourth row (identical to third row) dest += hdim, p += hdim; dest[3] = (5 * dest[3] + 2 * p[3] + p[TOP_OFFSET + 3] + 4) >> 3; dest[2] = (5 * dest[2] + 2 * p[2] + p[TOP_OFFSET + 2] + 4) >> 3; dest[1] = (6 * dest[1] + p[1] + p[TOP_OFFSET + 1] + 4) >> 3; dest[0] = (6 * dest[0] + p[0] + p[TOP_OFFSET + 0] + 4) >> 3; return;}// weighNoRight_Vert - Derived from weighNoLeft_Vert by reversing indices// This means that the assembler routine can be easily derived from the otherstatic void weighNoRight_Vert( PIXEL *dest, PIXEL const *p, int hdim ){ // First row dest[3] = (3 * dest[3] + p[TOP_OFFSET + 3] + 2) >> 2; dest[2] = (3 * dest[2] + p[TOP_OFFSET + 2] + 2) >> 2; dest[1] = (3 * dest[1] + p[TOP_OFFSET + 1] + 2) >> 2; dest[0] = (3 * dest[0] + p[TOP_OFFSET + 0] + 2) >> 2; // Second row dest += hdim, p += hdim; dest[3] = (7 * dest[3] + p[TOP_OFFSET + 3] + 4) >> 3; dest[2] = (7 * dest[2] + p[TOP_OFFSET + 2] + 4) >> 3; dest[1] = (3 * dest[1] + p[TOP_OFFSET + 1] + 2) >> 2; dest[0] = (3 * dest[0] + p[TOP_OFFSET + 0] + 2) >> 2; // Third row dest += hdim, p += hdim; dest[3] = (7 * dest[3] + p[TOP_OFFSET + 3] + 4) >> 3; dest[2] = (7 * dest[2] + p[TOP_OFFSET + 2] + 4) >> 3; dest[1] = (7 * dest[1] + p[TOP_OFFSET + 1] + 4) >> 3; dest[0] = (7 * dest[0] + p[TOP_OFFSET + 0] + 4) >> 3; // Fourth row (identical to third row) dest += hdim, p += hdim; dest[3] = (7 * dest[3] + p[TOP_OFFSET + 3] + 4) >> 3; dest[2] = (7 * dest[2] + p[TOP_OFFSET + 2] + 4) >> 3; dest[1] = (7 * dest[1] + p[TOP_OFFSET + 1] + 4) >> 3; dest[0] = (7 * dest[0] + p[TOP_OFFSET + 0] + 4) >> 3; return;}// weighRight - Derived from weighLeft by reversing indices// This means that the assembler routine can be easily derived from the otherstatic void weighRight( PIXEL *dest, PIXEL const *p, int hdim ){ // First row dest[3] = (3 * dest[3] + p[3] + 2) >> 2; dest[2] = (7 * dest[2] + p[2] + 4) >> 3; dest[1] = (7 * dest[1] + p[1] + 4) >> 3; dest[0] = (7 * dest[0] + p[0] + 4) >> 3; // Second row dest += hdim, p += hdim; dest[3] = (3 * dest[3] + p[3] + 2) >> 2; dest[2] = (3 * dest[2] + p[2] + 2) >> 2; dest[1] = (7 * dest[1] + p[1] + 4) >> 3; dest[0] = (7 * dest[0] + p[0] + 4) >> 3; // Third row (identical to second row) dest += hdim, p += hdim; dest[3] = (3 * dest[3] + p[3] + 2) >> 2; dest[2] = (3 * dest[2] + p[2] + 2) >> 2; dest[1] = (7 * dest[1] + p[1] + 4) >> 3; dest[0] = (7 * dest[0] + p[0] + 4) >> 3; // Fourth row (identical to third row) dest += hdim, p += hdim; dest[3] = (3 * dest[3] + p[3] + 2) >> 2; dest[2] = (3 * dest[2] + p[2] + 2) >> 2; dest[1] = (7 * dest[1] + p[1] + 4) >> 3; dest[0] = (7 * dest[0] + p[0] + 4) >> 3; return;}static void mc16pelsNoInterpol( PIXEL *in, PIXEL *out, int hdim, int vSize ){#ifndef FOR_UNIX union { // Copy words to speed up routine PIXEL *pix; U32 *word; } pIn, pOut; pIn.pix = in; pOut.pix = out; while (vSize > 0) { *(pOut.word + 0) = *(pIn.word + 0); *(pOut.word + 1) = *(pIn.word + 1); *(pOut.word + 2) = *(pIn.word + 2); *(pOut.word + 3) = *(pIn.word + 3); pIn.pix += hdim; pOut.pix += hdim; --vSize; } return;#else union { // PIXELs are not always word-aligned! Gotta copy bytes in UNIX PIXEL *pix; BYTE *byte; } pIn, pOut; BYTE *pInbyte; BYTE *pOutbyte; int i; pIn.pix = in; pOut.pix = out; while (vSize > 0) { pInbyte = pIn.byte; pOutbyte = pOut.byte; for (i=0; i<16; i++) *(pOutbyte++) = *(pInbyte++); pIn.pix += hdim; pOut.pix += hdim; --vSize; } return;#endif}static void mc8pelsNoInterpol( PIXEL *in, PIXEL *out, int hdim, int vSize ){#ifndef FOR_UNIX union { // Copy words to speed up routine PIXEL *pix; U32 *word; } pIn, pOut; pIn.pix = in; pOut.pix = out; while (vSize > 0) { *(pOut.word + 0) = *(pIn.word + 0); *(pOut.word + 1) = *(pIn.word + 1); pIn.pix += hdim; pOut.pix += hdim; --vSize; } return;#else union { // PIXELs are not always word-aligned! Gotta copy bytes in UNIX PIXEL *pix; BYTE *byte; } pIn, pOut; pIn.pix = in; pOut.pix = out; while (vSize > 0) { *(pOut.byte + 0) = *(pIn.byte + 0); *(pOut.byte + 1) = *(pIn.byte + 1); *(pOut.byte + 2) = *(pIn.byte + 2); *(pOut.byte + 3) = *(pIn.byte + 3); *(pOut.byte + 4) = *(pIn.byte + 4); *(pOut.byte + 5) = *(pIn.byte + 5); *(pOut.byte + 6) = *(pIn.byte + 6); *(pOut.byte + 7) = *(pIn.byte + 7); pIn.pix += hdim; pOut.pix += hdim; --vSize; } return;#endif}static void mc4pelsNoInterpol( PIXEL *in, PIXEL *out, int hdim, int vSize ){#ifndef FOR_UNIX union { // Copy words to speed up routine PIXEL *pix; U32 *word; } pIn, pOut; pIn.pix = in; pOut.pix = out; while (vSize > 0) { *(pOut.word + 0) = *(pIn.word + 0); pIn.pix += hdim; pOut.pix += hdim; --vSize; } return;#else union { // PIXELs are not always word-aligned! Gotta copy bytes in UNIX PIXEL *pix; BYTE *byte; } pIn, pOut; pIn.pix = in; pOut.pix = out; while (vSize > 0) { *(pOut.byte + 0) = *(pIn.byte + 0); *(pOut.byte + 1) = *(pIn.byte + 1); *(pOut.byte + 2) = *(pIn.byte + 2); *(pOut.byte + 3) = *(pIn.byte + 3); pIn.pix += hdim; pOut.pix += hdim; --vSize; } return;#endif}static void mc16pelsHorInterpol( PIXEL const *in, PIXEL *out, int hdim, int vSize ){ while (vSize > 0) { out[0] = (in[0] + in[1] + 1) >> 1; out[1] = (in[1] + in[2] + 1) >> 1; out[2] = (in[2] + in[3] + 1) >> 1; out[3] = (in[3] + in[4] + 1) >> 1; out[4] = (in[4] + in[5] + 1) >> 1; out[5] = (in[5] + in[6] + 1) >> 1; out[6] = (in[6] + in[7] + 1) >> 1; out[7] = (in[7] + in[8] + 1) >> 1; out[8] = (in[8] + in[9] + 1) >> 1; out[9] = (in[9] + in[10] + 1) >> 1; out[10] = (in[10] + in[11] + 1) >> 1; out[11] = (in[11] + in[12] + 1) >> 1; out[12] = (in[12] + in[13] + 1) >> 1; out[13] = (in[13] + in[14] + 1) >> 1; out[14] = (in[14] + in[15] + 1) >> 1; out[15] = (in[15] + in[16] + 1) >> 1; in += hdim; out += hdim; --vSize; } return;}static void mc8pelsHorInterpol( PIXEL const *in, PIXEL *out, int hdim, int vSize ){ while (vSize > 0) { out[0] = (in[0] + in[1] + 1) >> 1; out[1] = (in[1] + in[2] + 1) >> 1; out[2] = (in[2] + in[3] + 1) >> 1; out[3] = (in[3] + in[4] + 1) >> 1; out[4] = (in[4] + in[5] + 1) >> 1; out[5] = (in[5] + in[6] + 1) >> 1; out[6] = (in[6] + in[7] + 1) >> 1; out[7] = (in[7] + in[8] + 1) >> 1; in += hdim; out += hdim; --vSize; } return;}static void mc4pelsHorInterpol( PIXEL const *in, PIXEL *out, int hdim, int vSize ){ while (vSize > 0) { out[0] = (in[0] + in[1] + 1) >> 1; out[1] = (in[1] + in[2] + 1) >> 1; out[2] = (in[2] + in[3] + 1) >> 1; out[3] = (in[3] + in[4] + 1) >> 1; in += hdim; out += hdim; --vSize; } return;}static void mc16pelsVertInterpol( PIXEL const *in, PIXEL *out, int hdim, int vSize ){ while (vSize > 0) { out[0] = (in[0] + in[hdim+0] + 1) >> 1; out[1] = (in[1] + in[hdim+1] + 1) >> 1; out[2] = (in[2] + in[hdim+2] + 1) >> 1; out[3] = (in[3] + in[hdim+3] + 1) >> 1; out[4] = (in[4] + in[hdim+4] + 1) >> 1; out[5] = (in[5] + in[hdim+5] + 1) >> 1; out[6] = (in[6] + in[hdim+6] + 1) >> 1; out[7] = (in[7] + in[hdim+7] + 1) >> 1; out[8] = (in[8] + in[hdim+8] + 1) >> 1; out[9] = (in[9] + in[hdim+9] + 1) >> 1; out[10] = (in[10] + in[hdim+10] + 1) >> 1; out[11] = (in[11] + in[hdim+11] + 1) >> 1; out[12] = (in[12] + in[hdim+12] + 1) >> 1; out[13] = (in[13] + in[hdim+13] + 1) >> 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -