basic_prediction.c
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:5k
- #include "basic_prediction.h"
- void CopyBlock(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy;
- #ifdef BIG_ENDIAN
- char *lpSrc = (char *) Src;
- char *lpDst = (char *) Dst;
- int lpStride = Stride;
- for (dy = 0; dy < 8; dy++) {
- lpDst[0] = lpSrc[0];
- lpDst[1] = lpSrc[1];
- lpDst[2] = lpSrc[2];
- lpDst[3] = lpSrc[3];
- lpDst[4] = lpSrc[4];
- lpDst[5] = lpSrc[5];
- lpDst[6] = lpSrc[6];
- lpDst[7] = lpSrc[7];
- lpSrc += lpStride;
- lpDst += lpStride;
- }
- #else
- long *lpSrc = (long *) Src;
- long *lpDst = (long *) Dst;
- int lpStride = Stride >> 2;
- for (dy = 0; dy < 8; dy++) {
- lpDst[0] = lpSrc[0];
- lpDst[1] = lpSrc[1];
- lpSrc += lpStride;
- lpDst += lpStride;
- }
- #endif
- }
- /**/
- void CopyBlockHor(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 8; dy++) {
- for (dx = 0; dx < 8; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1]+1) >> 1;
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyBlockVer(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 8; dy++) {
- for (dx = 0; dx < 8; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+Stride] +1) >> 1;
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyBlockHorVer(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 8; dy++) {
- for (dx = 0; dx < 8; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1] +
- Src[dx+Stride] + Src[dx+Stride+1] +2) >> 2;
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyBlockHorRound(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 8; dy++) {
- for (dx = 0; dx < 8; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1]) >> 1; // hor interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyBlockVerRound(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 8; dy++) {
- for (dx = 0; dx < 8; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+Stride]) >> 1; // ver interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyBlockHorVerRound(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 8; dy++) {
- for (dx = 0; dx < 8; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1] +
- Src[dx+Stride] + Src[dx+Stride+1] +1) >> 2; // horver interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /** *** **/
- void CopyMBlock(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy;
- #ifdef BIG_ENDIAN
- char *lpSrc = (char *) Src;
- char *lpDst = (char *) Dst;
- int lpStride = Stride;
- for (dy = 0; dy < 16; dy++) {
- lpDst[0] = lpSrc[0];
- lpDst[1] = lpSrc[1];
- lpDst[2] = lpSrc[2];
- lpDst[3] = lpSrc[3];
- lpDst[4] = lpSrc[4];
- lpDst[5] = lpSrc[5];
- lpDst[6] = lpSrc[6];
- lpDst[7] = lpSrc[7];
- lpDst[8] = lpSrc[8];
- lpDst[9] = lpSrc[9];
- lpDst[10] = lpSrc[10];
- lpDst[11] = lpSrc[11];
- lpDst[12] = lpSrc[12];
- lpDst[13] = lpSrc[13];
- lpDst[14] = lpSrc[14];
- lpDst[15] = lpSrc[15];
- lpSrc += lpStride;
- lpDst += lpStride;
- }
- #else
- long *lpSrc = (long *) Src;
- long *lpDst = (long *) Dst;
- int lpStride = Stride >> 2;
- for (dy = 0; dy < 16; dy++) {
- lpDst[0] = lpSrc[0];
- lpDst[1] = lpSrc[1];
- lpDst[2] = lpSrc[2];
- lpDst[3] = lpSrc[3];
- lpSrc += lpStride;
- lpDst += lpStride;
- }
- #endif
- }
- /**/
- void CopyMBlockHor(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 16; dy++) {
- for (dx = 0; dx < 16; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1]+1) >> 1; // hor interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyMBlockVer(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 16; dy++) {
- for (dx = 0; dx < 16; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+Stride] +1) >> 1; // ver interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyMBlockHorVer(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 16; dy++) {
- for (dx = 0; dx < 16; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1] +
- Src[dx+Stride] + Src[dx+Stride+1] +2) >> 2; // horver interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyMBlockHorRound(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 16; dy++) {
- for (dx = 0; dx < 16; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1]) >> 1; // hor interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyMBlockVerRound(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 16; dy++) {
- for (dx = 0; dx < 16; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+Stride]) >> 1; // ver interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }
- /**/
- void CopyMBlockHorVerRound(unsigned char * Src, unsigned char * Dst, int Stride)
- {
- int dy, dx;
- for (dy = 0; dy < 16; dy++) {
- for (dx = 0; dx < 16; dx++) {
- Dst[dx] = (Src[dx] + Src[dx+1] +
- Src[dx+Stride] + Src[dx+Stride+1] +1) >> 2; // horver interpolation with rounding
- }
- Src += Stride;
- Dst += Stride;
- }
- }