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

📄 mc_interlaced.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 5 页
字号:
/*************************************************************************This software module was originally developed by 	Ming-Chieh Lee (mingcl@microsoft.com), Microsoft Corporation	Bruce Lin (blin@microsoft.com), Microsoft Corporation	Simon Winder (swinder@microsoft.com), Microsoft Corporation	(date: June, 1997)and edited by        Wei Wu (weiwu@stallion.risc.rockwell.com) Rockwell Science Centerand also edited by    Mathias Wien (wien@ient.rwth-aachen.de) RWTH Aachen / Robert BOSCH GmbHand also edited by	Yoshinori Suzuki (Hitachi, Ltd.)and also edited by	Hideaki Kimata (NTT)and also edited by    Fujitsu Laboratories Ltd. (contact: Eishi Morimatsu)    Sehoon Son (shson@unitel.co.kr) Samsung AITin the course of development of the MPEG-4 Video (ISO/IEC 14496-2). This software module is an implementation of a part of one or more MPEG-4 Video tools as specified by the MPEG-4 Video. ISO/IEC gives users of the MPEG-4 Video free license to this software module or modifications thereof for use in hardware or software products claiming conformance to the MPEG-4 Video. Those intending to use this software module in hardware or software products are advised that its use may infringe existing patents. The original developer of this software module and his/her company, the subsequent editors and their companies, and ISO/IEC have no liability for use of this software module or modifications thereof in an implementation. Copyright is not released for non MPEG-4 Video conforming products. Microsoft retains full right to use the code for his/her own purpose, assign or donate the code to a third party and to inhibit third parties from using the code for non <MPEG standard> conforming products. This copyright notice must be included in all copies or derivative works. Copyright (c) 1996, 1997.Module Name:	mc.cppAbstract:	Motion compensation routines (common for encoder and decoder).Revision History:    December 20, 1997   Interlaced tools added by NextLevel Systems (GI)                        X. Chen (xchen@nlvl.com) B. Eifrig (beifrig@nlvl.com)    Feb.16 1999         add Quarter Sample                         Mathias Wien (wien@ient.rwth-aachen.de)     Feb.23 1999         GMC added by Yoshinori Suzuki (Hitachi, Ltd.)	Aug.24, 1999 : NEWPRED added by Hideaki Kimata (NTT) 	Sep.06	1999 : RRV added by Eishi Morimatsu (Fujitsu Laboratories Ltd.) *************************************************************************/#include "typeapi.h"#include "codehead.h"#include "mode.hpp"#include "global.h"#include "entropy/bitstrm.h"#include "entropy/entropy.h"#include "entropy/huffman.h"#include "vopses.hpp"#include "vopsedec.hpp"#include "mae_pass_thru.h"#ifdef DUAL_MODEVoid motionComp (PixelC* ppxlcPred, // can be either Y or A                    PixelC* ppxlcRefLeftTop, // point to left-top of the frame                    Int iSize, // either MB or BLOCK size                    CoordI xRef, CoordI yRef, // x + mvX, in half pel unit                    Int iRoundingControl,                    CRct *prctMVLimit, // extended bounding box                    int nMBType,                    int nBlockNum,                    const CMotionVector* pmv,                    int nSkip){	CoordI ix, iy;	int nX, nY;	const PixelC* pSaveRef;	LIMITMVRANGETOEXTENDEDBBHALFPEL(&xRef,&yRef,prctMVLimit,iSize);	if (pmv)     {		nX = TRUEMVHALFPEL_X(pmv);		nY = TRUEMVHALFPEL_Y(pmv);	}	const PixelC* ppxlcRef = 		ppxlcRefLeftTop + 		((yRef >> 1) + EXPANDY_REF_FRAME) * m_iFrameWidthY + (xRef >> 1) + EXPANDY_REF_FRAME;	if(iSize==8 || iSize==16)	{		// optimisation		if (!(yRef & 1)) {			if (!(xRef & 1)) {				Int iSz = iSize * sizeof(PixelC);				for(iy = 0; iy < iSize; iy+=8)				{					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;					memcpy (ppxlcPred, ppxlcRef, iSz);					ppxlcRef += m_iFrameWidthY; ppxlcPred += MB_SIZE;				}			}			else {				PixelC pxlcT1,pxlcT2, *ppxlcDst;				const PixelC *ppxlcSrc;				Int iRndCtrl = 1 - iRoundingControl;				for (iy = 0; iy < iSize; iy++){					ppxlcDst = ppxlcPred;					ppxlcSrc = ppxlcRef;					for (ix = 0; ix < iSize; ix+=8) {						ppxlcDst [0] = (ppxlcSrc[0] + (pxlcT1=ppxlcSrc[1]) + iRndCtrl) >> 1;						ppxlcDst [1] = (pxlcT1 + (pxlcT2=ppxlcSrc[2]) + iRndCtrl) >> 1;						ppxlcDst [2] = (pxlcT2 + (pxlcT1=ppxlcSrc[3]) + iRndCtrl) >> 1;						ppxlcDst [3] = (pxlcT1 + (pxlcT2=ppxlcSrc[4]) + iRndCtrl) >> 1;						ppxlcDst [4] = (pxlcT2 + (pxlcT1=ppxlcSrc[5]) + iRndCtrl) >> 1;						ppxlcDst [5] = (pxlcT1 + (pxlcT2=ppxlcSrc[6]) + iRndCtrl) >> 1;						ppxlcDst [6] = (pxlcT2 + (pxlcT1=ppxlcSrc[7]) + iRndCtrl) >> 1;						ppxlcDst [7] = (pxlcT1 + ppxlcSrc[8] + iRndCtrl) >> 1;						ppxlcDst += 8;						ppxlcSrc += 8;					}					ppxlcRef += m_iFrameWidthY;					ppxlcPred += MB_SIZE;				}			}		}		else {			if (!(xRef & 1)) {				Int iRndCtrl = 1 - iRoundingControl;				const PixelC *ppxlcSrc, *ppxlcSrc2;				PixelC *ppxlcDst;				for (iy = 0; iy < iSize; iy++) {					ppxlcDst = ppxlcPred;					ppxlcSrc = ppxlcRef;					ppxlcSrc2 = ppxlcRef + m_iFrameWidthY;					for (ix = 0; ix < iSize; ix+=8) {						ppxlcDst [0] = (ppxlcSrc [0] + ppxlcSrc2 [0] + iRndCtrl) >> 1;						ppxlcDst [1] = (ppxlcSrc [1] + ppxlcSrc2 [1] + iRndCtrl) >> 1;						ppxlcDst [2] = (ppxlcSrc [2] + ppxlcSrc2 [2] + iRndCtrl) >> 1;						ppxlcDst [3] = (ppxlcSrc [3] + ppxlcSrc2 [3] + iRndCtrl) >> 1;						ppxlcDst [4] = (ppxlcSrc [4] + ppxlcSrc2 [4] + iRndCtrl) >> 1;						ppxlcDst [5] = (ppxlcSrc [5] + ppxlcSrc2 [5] + iRndCtrl) >> 1;						ppxlcDst [6] = (ppxlcSrc [6] + ppxlcSrc2 [6] + iRndCtrl) >> 1;						ppxlcDst [7] = (ppxlcSrc [7] + ppxlcSrc2 [7] + iRndCtrl) >> 1;						ppxlcDst += 8;						ppxlcSrc += 8;						ppxlcSrc2 += 8;					}					ppxlcRef += m_iFrameWidthY;					ppxlcPred += MB_SIZE;				}			}			else {				Int iRndCtrl = 2 - iRoundingControl;				PixelC pxlcT1, pxlcT2, pxlcT3, pxlcT4, *ppxlcDst;				const PixelC *ppxlcSrc, *ppxlcSrc2;				for (iy = 0; iy < iSize; iy++) {					ppxlcDst = ppxlcPred;					ppxlcSrc = ppxlcRef;					ppxlcSrc2 = ppxlcRef + m_iFrameWidthY;					for (ix = 0; ix < iSize; ix+=8) {						ppxlcDst [0] = (ppxlcSrc[0] + (pxlcT1=ppxlcSrc[1]) + ppxlcSrc2[0] + (pxlcT3=ppxlcSrc2[1]) + iRndCtrl) >> 2;						ppxlcDst [1] = (pxlcT1 + (pxlcT2=ppxlcSrc[2]) + pxlcT3 + (pxlcT4=ppxlcSrc2[2]) + iRndCtrl) >> 2;						ppxlcDst [2] = (pxlcT2 + (pxlcT1=ppxlcSrc[3]) + pxlcT4 + (pxlcT3=ppxlcSrc2[3]) + iRndCtrl) >> 2;						ppxlcDst [3] = (pxlcT1 + (pxlcT2=ppxlcSrc[4]) + pxlcT3 + (pxlcT4=ppxlcSrc2[4]) + iRndCtrl) >> 2;						ppxlcDst [4] = (pxlcT2 + (pxlcT1=ppxlcSrc[5]) + pxlcT4 + (pxlcT3=ppxlcSrc2[5]) + iRndCtrl) >> 2;						ppxlcDst [5] = (pxlcT1 + (pxlcT2=ppxlcSrc[6]) + pxlcT3 + (pxlcT4=ppxlcSrc2[6]) + iRndCtrl) >> 2;						ppxlcDst [6] = (pxlcT2 + (pxlcT1=ppxlcSrc[7]) + pxlcT4 + (pxlcT3=ppxlcSrc2[7]) + iRndCtrl) >> 2;						ppxlcDst [7] = (pxlcT1 + ppxlcSrc[8] + pxlcT3 + ppxlcSrc2[8] + iRndCtrl) >> 2;						ppxlcDst += 8;						ppxlcSrc += 8;						ppxlcSrc2 += 8;					}					ppxlcRef += m_iFrameWidthY;					ppxlcPred += MB_SIZE;				}			}		}	}	else {		if (!(yRef & 1)) {			if (!(xRef & 1)) {  //!bXSubPxl && !bYSubPxl				for (iy = 0; iy < iSize; iy++) {					memcpy (ppxlcPred, ppxlcRef, iSize*sizeof(PixelC));					ppxlcRef += m_iFrameWidthY;					ppxlcPred += MB_SIZE;				}			}			else {  //bXSubPxl && !bYSubPxl				for (iy = 0; iy < iSize; iy++){					for (ix = 0; ix < iSize; ix++)						ppxlcPred [ix] = (ppxlcRef [ix] + ppxlcRef [ix + 1] + 1 - iRoundingControl) >> 1;					ppxlcRef += m_iFrameWidthY;					ppxlcPred += MB_SIZE;				}			}		}		else {			const PixelC* ppxlcRefBot;			if (!(xRef & 1)) {  //!bXSubPxl&& bYSubPxl				for (iy = 0; iy < iSize; iy++) {					ppxlcRefBot = ppxlcRef + m_iFrameWidthY;		//UPln -> pixels (xInt,yInt+1);					for (ix = 0; ix < iSize; ix++) 						ppxlcPred [ix] = (ppxlcRef [ix] + ppxlcRefBot [ix] + 1 - iRoundingControl) >> 1;					ppxlcRef = ppxlcRefBot;					ppxlcPred += MB_SIZE;				}			}			else { // bXSubPxl && bYSubPxl				for (iy = 0; iy < iSize; iy++) {					ppxlcRefBot = ppxlcRef + m_iFrameWidthY;		//UPln -> pixels (xInt,yInt+1);					for (ix = 0; ix < iSize; ix++){						ppxlcPred [ix] = (							ppxlcRef [ix + 1] + ppxlcRef [ix] +							ppxlcRefBot [ix + 1] + ppxlcRefBot [ix] + 2 - iRoundingControl						) >> 2;					}					ppxlcRef = ppxlcRefBot;					ppxlcPred += MB_SIZE;				}			}		}	}}#endif#ifdef ENABLE_INTERLACING// QuarterSampleVoid CVideoObject::blkInterpolateY (	                 const PixelC* ppxlcRefLeftTop,                      // point to left-top of the frame					 Int blkSize, // Blocksize (0=16x8, 8=8x8, 16=16x16)					 Int xRef, Int yRef, // x + mvX in quarter pel unit					 U8* ppxlcblk, // Pointer to quarter sample interpolated block                     Int iRoundingControl  ) {  printf("==>blkInterpolateY\n");  Int maxVal = (1<<m_volmd.nBits)-1; // mwi  Int c[]={160, -48, 24, -8}; // Filter Coefficients  U8 refblk[MB_SIZE+7][MB_SIZE+7];  U8 tmpblk0[MB_SIZE+7][MB_SIZE+7];    U8 tmpblk1[MB_SIZE+1][MB_SIZE+1];  Int x_int, y_int, x_frac, y_frac;  Int blkSizeX, blkSizeY, iWidthY;    Int ix, iy, k;  Long u;  Int yTmp = yRef>>1;  // Field MV!  if (blkSize == 0) {    blkSizeX = 16;    blkSizeY = 8;    iWidthY  = 2*m_iFrameWidthY;        y_int  = yTmp/4;    if (yTmp < 0)      if (yTmp%4) y_int--;    y_frac = yTmp - (4*y_int);  }  else {    blkSizeX = blkSize;    blkSizeY = blkSize;    iWidthY  = m_iFrameWidthY;    y_int  = yRef/4;    if (yRef < 0)      if (yRef%4) y_int--;    y_frac = yRef - (4*y_int);  }  x_int  = xRef/4;  if (xRef < 0)    if (xRef%4) x_int--;  x_frac = xRef - (4*x_int);      // Initialization  const PixelC* ppxlcRef = ppxlcRefLeftTop + y_int * iWidthY + EXPANDY_REF_FRAME    * m_iFrameWidthY + x_int + EXPANDY_REF_FRAME;  for (iy=0; iy <= blkSizeY; iy++) {    for (ix=0; ix <= blkSizeX; ix++) {      refblk[iy+3][ix+3] = ppxlcRef[ix+iy*iWidthY];    }  }     // Horizontal Mirroring   for (iy=0; iy <= blkSizeY; iy++) {	 for (ix=0; ix <= 2; ix++) {	   refblk[iy+3][ix] = refblk[iy+3][5-ix];	   refblk[iy+3][blkSizeX+ix+4] = refblk[iy+3][blkSizeX-ix+3];	 }   }      switch (x_frac) {	      case 0 : // Full Pel Position       for (iy=0; iy <= blkSizeY; iy++) {	     for (ix=0; ix <= blkSizeX-1; ix++) {		   tmpblk0[iy+3][ix] = refblk[iy+3][ix+3];	     }	   }	 break;	      case 1 : // Quarter Pel Position       for (iy=0; iy <= blkSizeY; iy++) {	     for (ix=0; ix <= blkSizeX-1; ix++) {           u = 0;		   for (k=0; k<=3; k++) {			 u += c[k] * ( refblk[iy+3][ix+3-k] + refblk[iy+3][ix+4+k] );		   }		   u = (u+128-iRoundingControl)/256;		   u = max(0,min(maxVal,u));		   tmpblk1[iy][ix] = (U8)u; 

⌨️ 快捷键说明

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