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

📄 mae_wrappers.cpp

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
{	INTERMEDITATE_MB_CHECKERS xFrameChecks;	char szFileName[MAX_FILE_SIZE], szFrameNum[MAX_FRAME_NUM_SIZE];	if(nFrameType == IFRAME)		xFrameChecks.nFrameWidthY = gMAEConfig.nFrameWidthY;	else		xFrameChecks.nFrameWidthY = 0;	// Initialize some stuff for the intermediate checkers 	// after IQUANT, IDCT & MC are done. However, we 	// need to do this only if none of the frame filters 	// (OverlappedSmoothing & Deblocking) are enabled	// ****************************************************	xFrameChecks.nMB		  = nCurMB; 	xFrameChecks.nWidthLuma   = gMAEConfig.nWidthLuma;	xFrameChecks.nWidthChroma = gMAEConfig.nWidthChroma;	xFrameChecks.cur_y_frame  = ppxliCodedY;	xFrameChecks.cur_cb_frame = ppxliCodedU;	xFrameChecks.cur_cr_frame = ppxliCodedV;	// Get the frame number in char* type	sprintf(szFrameNum, "%d", gMAEConfig.nFrameNum);	memset(szFileName, 0, MAX_FILE_SIZE);	if (nFrameType == IFRAME)		strcpy(szFileName, FILE_INTRA_FINAL);	else if (nFrameType == PFRAME)		strcpy(szFileName, FILE_INTER_P_FINAL);	else if (nFrameType == BFRAME)		strcpy(szFileName, FILE_INTER_B_FINAL);	strcat(szFileName, szFrameNum);	// MPEG4 Reference Code case	// ************************	if (nBldOpt == USE_REF)		strcat(szFileName, REF_FILE_EXTENSION);	// MAE(CModel) case	// ****************	else if (nBldOpt == USE_MAE)		strcat(szFileName, MAE_FILE_EXTENSION);	// Dump out the file now	if(nFrameType == IFRAME)		InterChecksOnIMB(&xFrameChecks, szFileName);	else		InterChecksOnPAndBMB(&xFrameChecks, szFileName);}#endif// ~HV For Travis// ***************************************************************************void C_MAEWrapper::LimitMVRangeToExtendedBBQuarterPel (int xpos, int ypos, 	int *x,int *y,int width, int height, bool isLuma, int index){	if (g_pHeader3->mbtype == MBT_16x16)	{		// LEFT		if ((4 * xpos + *x) < -64)		{			*x = -64 - (4*xpos);		}		// TOP		if ((4 * ypos + *y) < -64)		{			*y = -64 - (4*ypos);		}		// RIGHT		if ( ((4 * xpos + *x) >> 2) > (width - 1) )		{			*x = (width - 1)*4 - 4 * xpos;		}		// BOTTOM		if ( ((4 * ypos + *y) >> 2) > (height - 1) )		{			*y = (height - 1)*4 - 4 * ypos;		}	}	else if (g_pHeader3->mbtype == MBT_8x8)	{		int	lumaAdjustment;		// LEFT		lumaAdjustment = (index & 1) * 8;		if (((4 * xpos + *x) + (lumaAdjustment * 4)) < -32)		{			*x = -32 - (4 * xpos) - (4 * lumaAdjustment);		}		// TOP		lumaAdjustment = ((index >> 1) & 0x1) * 8;		if (((4 * ypos + *y) + (lumaAdjustment * 4)) < -32)		{			*y = -32 - (4 * ypos) - (4 * lumaAdjustment);		}		// RIGHT		lumaAdjustment = (index & 1) * 8;		if ((((4 * xpos + *x) >> 2) + lumaAdjustment) > width - 1)		{			*x = (width - 1 - lumaAdjustment)*4 - 4 * xpos;		}		// BOTTOM		lumaAdjustment = ((index >> 1) & 0x1) * 8;		if ((((4 * ypos + *y) >> 2) + lumaAdjustment) > height - 1)		{			*y = (height - 1 - lumaAdjustment)*4 - 4 * ypos;		}	}	else if (g_pHeader3->mbtype == MBT_16x8)	{		// LEFT		if ((4 * xpos + *x) < -64)		{			*x = -64 - (4*xpos);		}		// TOP		if ( ypos + (*y/8) < -8 )		{			*y = -64 - (8 * ypos);		}		// RIGHT		if ( ((4 * xpos + *x) >> 2) > (width - 1) )		{			*x = (width - 1)*4 - 4 * xpos;		}		// BOTTOM		if ( ypos + (*y/8) > height - 1 )		{			*y = (height - 1)*8 - 8 * ypos;		}	}}void C_MAEWrapper::LimitMVRangeToExtendedBBHalfPel (int xpos, int ypos, 	int *x,int *y,int width, int height, bool isLuma, int index){	if (g_pHeader3->mbtype == MBT_16x16)	{		if (isLuma)		{			// LEFT			if ((2 * xpos + *x) < -32)			{				*x = -32 - (2*xpos);			}			// TOP			if ((2 * ypos + *y) < -32)			{				*y = -32 - (2*ypos);			}			// RIGHT			if ( (2 * xpos + *x)/2 > width - 1 )			{				*x = (width - 1)*2 - 2 * xpos;			}			// BOTTOM			if ( (2 * ypos + *y)/2 > height - 1 )			{				*y = (height - 1)*2 - 2 * ypos;			}		}		else		{			// LEFT			if ((2 * xpos + *x) < -16)			{				*x = -16 - (2*xpos);			}			// TOP			if ((2 * ypos + *y) < -16)			{				*y = -16 - (2*ypos);			}			// RIGHT			if ( (2 * xpos + *x)/2 > width - 1 )			{				*x = (width - 1)*2 - 2 * xpos;			}			// BOTTOM			if ( (2 * ypos + *y)/2 > height - 1 )			{				*y = (height - 1)*2 - 2 * ypos;			}		}	}	else if (g_pHeader3->mbtype == MBT_8x8)	{		if (isLuma)		{			int	lumaAdjustment;			// LEFT			lumaAdjustment = (index & 1) * 8;			if (((2 * xpos + *x) + (lumaAdjustment * 2)) < -16)			{				*x = -16 - (2 * xpos) - (2 * lumaAdjustment);			}			// TOP			lumaAdjustment = ((index >> 1) & 0x1) * 8;			if (((2 * ypos + *y) + (lumaAdjustment * 2)) < -16)			{				*y = -16 - (2 * ypos) - (2 * lumaAdjustment);			}			// RIGHT			lumaAdjustment = (index & 1) * 8;			if ((((2 * xpos + *x) >> 1) + lumaAdjustment) > width - 1)			{				*x = (width - 1 - lumaAdjustment)*2 - 2 * xpos;			}			// BOTTOM			lumaAdjustment = ((index >> 1) & 0x1) * 8;			if ((((2 * ypos + *y) >> 1) + lumaAdjustment) > height - 1)			{				*y = (height - 1 - lumaAdjustment)*2 - 2 * ypos;			}		}		else		{			// LEFT			if ((2 * xpos + *x) < -16)			{				*x = -16 - (2*xpos);			}			// TOP			if ((2 * ypos + *y) < -16)			{				*y = -16 - (2*ypos);			}			// RIGHT			if ( (2 * xpos + *x)/2 > width - 1 )			{				*x = (width - 1)*2 - 2 * xpos;			}			// BOTTOM			if ( (2 * ypos + *y)/2 > height - 1 )			{				*y = (height - 1)*2 - 2 * ypos;			}		}	}	else if (g_pHeader3->mbtype == MBT_16x8)	{		if (isLuma)		{			// LEFT			if ((2 * xpos + *x) < -32)			{				*x = -32 - (2*xpos);			}			// TOP			if ( ypos + (*y/4) < -8 )			{				*y = -32 - (4 * ypos);			}			// RIGHT			if ( (2 * xpos + *x)/2 > width - 1 )			{				*x = (width - 1)*2 - 2 * xpos;			}			// BOTTOM			if ( ypos + (*y/4) > height - 1 )			{				*y = (height - 1)*4 - 4 * ypos;			}		}		else		{			// LEFT			if ((2 * xpos + *x) < -16)			{				*x = -16 - (2*xpos);			}			// TOP			if ( ypos + (*y/4) < -4)			{				*y = -16 - (4*ypos);			}			// RIGHT			if ( (2 * xpos + *x)/2 > width - 1 )			{				*x = (width - 1)*2 - 2 * xpos;			}			// BOTTOM			if ( ypos + (*y/4) > height - 1 )			{				*y = (height - 1)*4 - 4 * ypos;			}		}	}	return;}// ***************************************************************************voidC_MAEWrapper::SetLogFlags (uint32 inFlags){	m_nMAELogFlags = inFlags; 	return;}// ***************************************************************************////  Function:       UpdateIntraDestPointersForMPEG4//////  Parameters:     pmae_cmodel_mb_params -- pointer to this struct////  Return Value:   VOID////  Notes:			After the destination pointers are updated by MAE, we need //					to call this function to update the pointers in a way that //					the MPEG4 reference code understands.//// ***************************************************************************voidC_MAEWrapper::UpdateIntraDestPointersForMPEG4 (int nCurMB, unsigned char *xRefY,											   unsigned char *xRefU, unsigned char *xRefV){  int bn, nMultiplier, x, y;  uint8 *mae_y_frame  = (uint8 *)gMAEConfig.cur_y_frame_ptr;  uint8 *mae_cb_frame = (uint8 *)gMAEConfig.cur_cb_frame_ptr;  uint8 *mae_cr_frame = (uint8 *)gMAEConfig.cur_cr_frame_ptr;  uint8 *ref_y_frame  = xRefY;  uint8 *ref_cb_frame = xRefU;  uint8 *ref_cr_frame = xRefV;  int nWidthLuma      = gMAEConfig.nWidthLuma;  int nWidthChroma    = gMAEConfig.nWidthChroma;  int nFrameWidthY    = gMAEConfig.nFrameWidthY;  int linesiz	= pMAERegs->picture_size.linesiz;  int mb        = nCurMB;  int nMBPerRow = linesiz/MB_SIZE;  int rows      = mb / nMBPerRow;  int cols      = mb % nMBPerRow;  uint8 *dst_ptr, *dst_start, *mae_ptr;  mae_y_frame  += (rows * MB_SIZE	 * linesiz  ) + (cols *    MB_SIZE);  mae_cb_frame += (rows * BLOCK_SIZE * linesiz/2) + (cols * BLOCK_SIZE);  mae_cr_frame += (rows * BLOCK_SIZE * linesiz/2) + (cols * BLOCK_SIZE);  // Now, start storing the data in the Reference code's location   for(bn = 0; bn < V_CHROMA_BLOCK; bn++) {    switch (bn+1) {      // Store the original luma pointer      case Y1_LUMA_BLOCK:         dst_start = ref_y_frame;        mae_ptr = mae_y_frame;        break;      // Shift by BLOCK_SIZE(8)      case Y2_LUMA_BLOCK:         dst_start = ref_y_frame + BLOCK_SIZE;        mae_ptr = (mae_y_frame + BLOCK_SIZE);        break;      // Shift by big chunk to get to Y3 (the block below Y1)      case Y3_LUMA_BLOCK:         dst_start = ref_y_frame + nFrameWidthY;        mae_ptr = (mae_y_frame + (BLOCK_SIZE * linesiz));        break;      // Shift by BLOCK_SIZE(8) again from the Y3 pointer      case Y4_LUMA_BLOCK:         dst_start = ref_y_frame + nFrameWidthY + BLOCK_SIZE;        mae_ptr = (mae_y_frame + (BLOCK_SIZE * linesiz)) + BLOCK_SIZE;        break;    }    if (bn < 4) { // Luma      nMultiplier = nWidthLuma;    } else {      // Chroma      nMultiplier = nWidthChroma;      // Store the original Chroma destination(REF) pointers      dst_start = (bn == 4) ? ref_cb_frame : ref_cr_frame;      // Store the original Chroma source(MAE) pointers      mae_ptr  = (bn == 4) ? mae_cb_frame : mae_cr_frame;    }    for (y = 0; y < BLOCK_SIZE; y++) {        // Incrementing the destination(REF) pointer      dst_ptr = dst_start + (y * nMultiplier);      for (x = 0; x < BLOCK_SIZE; x++) {        *dst_ptr = *mae_ptr;        mae_ptr++;        dst_ptr++;      }      // Incrementing the source(MAE) pointer      if (bn < 4)        mae_ptr = mae_ptr + linesiz   - BLOCK_SIZE;      else        mae_ptr = mae_ptr + linesiz/2 - BLOCK_SIZE;    }  }  return;}// ***************************************************************************////  Function:       UpdateInterDestPointersForMPEG4//////  Parameters:     pmae_cmodel_mb_params -- pointer to this struct//////  Return Value:   VOID////  Notes:      After the destination pointers are updated by MAE, we need //          to call this function to update the pointers in a way that //          the MPEG4 reference code understands.//// ***************************************************************************voidC_MAEWrapper::UpdateInterDestPointersForMPEG4 (int nCurMB, unsigned char *xRefY,											   unsigned char *xRefU, unsigned char *xRefV){  int x, y, chroma;  uint8 *mae_y_frame  = (uint8 *)gMAEConfig.cur_y_frame_ptr;  uint8 *mae_cb_frame = (uint8 *)gMAEConfig.cur_cb_frame_ptr;  uint8 *mae_cr_frame = (uint8 *)gMAEConfig.cur_cr_frame_ptr;  uint8 *ref_y_frame  = xRefY;  uint8 *ref_cb_frame = xRefU;  uint8 *ref_cr_frame = xRefV;  int nWidthLuma      = gMAEConfig.nWidthLuma;  int nWidthChroma    = gMAEConfig.nWidthChroma;  int nFrameWidthY    = gMAEConfig.nFrameWidthY;  int linesiz	= pMAERegs->picture_size.linesiz;  int mb        = nCurMB;  int nMBPerRow = linesiz/MB_SIZE;  int rows      = mb / nMBPerRow;  int cols      = mb % nMBPerRow;  uint8 *dst_ptr, *mae_ptr;  mae_y_frame  += (rows * MB_SIZE	 * linesiz  ) + (cols *    MB_SIZE);  mae_cb_frame += (rows * BLOCK_SIZE * linesiz/2) + (cols * BLOCK_SIZE);

⌨️ 快捷键说明

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