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

📄 mae_pass_thru.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* <LIC_AMD_STD> * Copyright (c) 2005 Advanced Micro Devices, Inc. *  * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. *  * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *  * The full GNU General Public License is included in this distribution in the * file called COPYING * </LIC_AMD_STD>  *//* <CTL_AMD_STD> * </CTL_AMD_STD>  *//* <DOC_AMD_STD>	Name	: mae_pass_thru.c	Author	: Prasad Padiyar	Desc	: Contains functions which act as pass-thru layer between ref code			  and C-Model * </DOC_AMD_STD>  */// ***************************************************************************//  pragmas// ***************************************************************************// ***************************************************************************//  includes// ***************************************************************************#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#if !defined(OS_Linux)//#include <header.h>#endif#include "swizzle.h"#include "mae_fe.h"#include "mae_fe_mcomp.h"#include "mae_vpi.h"#include "mae_pass_thru.h"#include "mae_interface.h"#include "filecache.h"// ***************************************************************************//  definitions// ***************************************************************************#define BLOCKS_FOR_420_FORMAT	6#define BLOCKS_FOR_422_FORMAT	8#define BLOCK_DATA_SIZE_32		(sizeof(int) * BLOCK_SQUARE_SIZE)#define BLOCK_DATA_SIZE_16		(sizeof(int16) * BLOCK_SQUARE_SIZE)#define WM_DATA_SIZE			(sizeof(uint8) * BLOCK_SQUARE_SIZE)#define PROGRESSIVE_SCAN		0#define INTERLACED_SCAN			1#define XFORMSIZE_8_8			0#define XFORMSIZE_8_4			1#define XFORMSIZE_4_8			2#define XFORMSIZE_4_4			3// ***************************************************************************//  types// ***************************************************************************// ***************************************************************************//  data// ***************************************************************************mae_fe_config MAE_CONFIG;int nFileUpdates = NO_DUMP_ALL; //flag to mask on/off file writesint nBldOpt	= USE_REF;		 //flag to toggle REF/MAE usage for video decodingunsigned char bSpecialDump = FALSE;extern struct GlobalCModelInfo gCM;// ***************************************************************************//  function prototypes// ***************************************************************************extern void fe_process_mb					(mae_fe_config*,											 mae_fe_mb*, 											 uint8*,											 uint8*,											 uint8*,											 uint32);// ***************************************************************************//  function implementations// ***************************************************************************// ***************************************************************************////  Function:       BuildFrameParamsForMAE//////  Parameters:     mae_cmodel_frame_params RefCode_Frame_Data //					All frame related data from the reference code that will //					hold good for all the MBs under this frame.////  Return Value:   VOID////  Notes:			This function needs to gets called only once per frame.//// ***************************************************************************void BuildFrameParamsForMAE(mae_cmodel_frame_params *pRefCode_Frame_Data, unsigned char bRefPointers){	// Lets fill out all the data for this frame	// ******************************************	MAE_CONFIG.bc = pRefCode_Frame_Data->blockcount; // 0 for 4:2:0 & 1 for 4:2:2	// Used only for Inter blocks & MAE only supports a value of 1 as of now	MAE_CONFIG.iqmul1 = 0; 	// not used!!	MAE_CONFIG.xfrmtyp = 0;	// Mismatch control	MAE_CONFIG.mis = pRefCode_Frame_Data->mis; //0 for MPEG4	// For WMV9 only	MAE_CONFIG.loopfilt = 0;	MAE_CONFIG.smooth	= 0;	// Saturation. Let MAE do its default handling on this!!	MAE_CONFIG.satiq = 1;	// height & width	MAE_CONFIG.height  = pRefCode_Frame_Data->iPicHeight;	MAE_CONFIG.linesiz = pRefCode_Frame_Data->iPicWidth;	// Intensity Comp related (WMV9 only)	MAE_CONFIG.icomp	= 0;	MAE_CONFIG.lumshift = 0;	MAE_CONFIG.lumscale = 0;	// Only for Inter frames	MAE_CONFIG.mcprec	= pRefCode_Frame_Data->mcprec;	MAE_CONFIG.mcprecuv = pRefCode_Frame_Data->mcprecuv;	// Forward references (YUV). Needed only for MC	MAE_CONFIG.fwd_y_top_ptr	= (unsigned int)pRefCode_Frame_Data->fwd_y_top_ptr;	MAE_CONFIG.fwd_cb_top_ptr	= (unsigned int)pRefCode_Frame_Data->fwd_cb_top_ptr;	MAE_CONFIG.fwd_cr_top_ptr	= (unsigned int)pRefCode_Frame_Data->fwd_cr_top_ptr;	// Backward references (YUV). Needed only for MC	MAE_CONFIG.bwd_y_top_ptr	= (unsigned int)pRefCode_Frame_Data->bwd_y_top_ptr;	MAE_CONFIG.bwd_cb_top_ptr	= (unsigned int)pRefCode_Frame_Data->bwd_cb_top_ptr;	MAE_CONFIG.bwd_cr_top_ptr	= (unsigned int)pRefCode_Frame_Data->bwd_cr_top_ptr;	// Needed if INTERLACING is ON	MAE_CONFIG.fwd_y_bot_ptr	= (unsigned int)pRefCode_Frame_Data->fwd_y_bot_ptr;	MAE_CONFIG.fwd_cr_bot_ptr	= (unsigned int)pRefCode_Frame_Data->fwd_cr_bot_ptr;	MAE_CONFIG.fwd_cb_bot_ptr	= (unsigned int)pRefCode_Frame_Data->fwd_cb_bot_ptr;	// Needed if INTERLACING is ON	MAE_CONFIG.bwd_y_bot_ptr	= (unsigned int)pRefCode_Frame_Data->bwd_y_bot_ptr;	MAE_CONFIG.bwd_cb_bot_ptr	= (unsigned int)pRefCode_Frame_Data->bwd_cb_bot_ptr;	MAE_CONFIG.bwd_cr_bot_ptr	= (unsigned int)pRefCode_Frame_Data->bwd_cr_bot_ptr;	// specific to DMV	gCM.dmv = pRefCode_Frame_Data->dmv;	// Physical addresses of the current frame (YUV)	MAE_CONFIG.cur_y_frame_ptr	= 0;	MAE_CONFIG.cur_cb_frame_ptr = 0;	MAE_CONFIG.cur_cr_frame_ptr = 0;}// ***************************************************************************////  Function:       BuildMBParamsForMAE//////  Parameters:     mae_cmodel_mb_params RefCode_MB_Data //					All MB related data from the reference code that will //					hold good for all the blocks under this frame.////  Return Value:   VOID////  Notes:			This function needs to gets called only once per MB (for all//					MBs in a particular frame).//// ***************************************************************************void BuildMBParamsForMAE(mae_cmodel_mb_params *pRefCode_MB_Data, unsigned char *pIdctOutput, unsigned char xScanType){	mae_fe_config		*pMAE_LOCAL_CONFIG;	mae_fe_mb			 MAE_MACRO_BLOCK;    static int           nPrevFrameNum = 1;	pMAE_LOCAL_CONFIG = &MAE_CONFIG;	// Lets fill out all the data for this MB	// **************************************	// MAE Header Word 0 Stuff	// ***********************	// Block mode Intra, Foward, Backward or BiDirectional (last 3 for Inter frames only)	// Set the MBMode for all blocks	if (pRefCode_MB_Data->mbmode == MBM_FORWARD)		MAE_MACRO_BLOCK.mbmode = MBMODE_FWD_ALL_422;//MBMODE_FWD_ALL_420;	else if (pRefCode_MB_Data->mbmode == MBM_BACKWARD)		MAE_MACRO_BLOCK.mbmode = MBMODE_BWD_ALL_422;//MBMODE_BWD_ALL_420;	else if (pRefCode_MB_Data->mbmode == MBM_BIDIRECTIONAL)		MAE_MACRO_BLOCK.mbmode = MBMODE_BID_ALL_422;//MBMODE_BID_ALL_420;	else if (pRefCode_MB_Data->mbmode == MBM_INTRA)		MAE_MACRO_BLOCK.mbmode = MBMODE_INTRA_ALL;	// Coded Block Paramter. All blocks that are coded in this MacroBlock	if (pRefCode_MB_Data->mbmode == MBM_INTRA)	{		MAE_MACRO_BLOCK.cbp = pRefCode_MB_Data->cbp;		// Weight Change Mask		MAE_MACRO_BLOCK.wtchgmsk = WM_INTRA_Y | WM_INTRA_C;		memcpy (MAE_MACRO_BLOCK.wm0, pRefCode_MB_Data->WM_FOR_INTRA_Y, WM_DATA_SIZE);		memcpy (MAE_MACRO_BLOCK.wm1, pRefCode_MB_Data->WM_FOR_INTRA_C, WM_DATA_SIZE);	}	else	{		MAE_MACRO_BLOCK.cbp = pRefCode_MB_Data->cbp;		// Weight Change Mask		MAE_MACRO_BLOCK.wtchgmsk = WM_INTER_Y | WM_INTER_C;		memcpy (MAE_MACRO_BLOCK.wm2, pRefCode_MB_Data->WM_FOR_INTER_Y, WM_DATA_SIZE);		memcpy (MAE_MACRO_BLOCK.wm3, pRefCode_MB_Data->WM_FOR_INTER_C, WM_DATA_SIZE);	}    // Au big blocks	MAE_MACRO_BLOCK.bblk = MAE_BIG_BLOCK_ON; // all co-effs are 16 bit wide	// DC Scaler values (only for Intra mode)	if (pRefCode_MB_Data->codec == CODEC_H263 || pRefCode_MB_Data->codec == CODEC_MPEG)	{		MAE_MACRO_BLOCK.dcluma   = pRefCode_MB_Data->iDcScalerY;		MAE_MACRO_BLOCK.dcchroma = pRefCode_MB_Data->iDcScalerC;	}	// MAE Header Word 1 Stuff	// ***********************	// MC rounding conrol	MAE_MACRO_BLOCK.rnd = 0;	// Picture structure	MAE_MACRO_BLOCK.ps = pRefCode_MB_Data->ps;	// Field prediction related parameters	MAE_MACRO_BLOCK.dctt = pRefCode_MB_Data->dctt;	MAE_MACRO_BLOCK.fp	 = pRefCode_MB_Data->fp;	MAE_MACRO_BLOCK.ft   = pRefCode_MB_Data->ft;	MAE_MACRO_BLOCK.fb   = pRefCode_MB_Data->fb;	MAE_MACRO_BLOCK.bt   = pRefCode_MB_Data->bt;	MAE_MACRO_BLOCK.bb   = pRefCode_MB_Data->bb;	// IQUANT values	MAE_MACRO_BLOCK.iqadd1 = pRefCode_MB_Data->iqadd1;	MAE_MACRO_BLOCK.iqadd2 = pRefCode_MB_Data->iqadd2;	MAE_MACRO_BLOCK.iqdiv3 = pRefCode_MB_Data->iqdiv3;	MAE_MACRO_BLOCK.iqmul2 = pRefCode_MB_Data->iqmul2;	// MAE Header Word 2 Stuff	// ***********************	// X & Y position of the current MB	// ********************************	MAE_MACRO_BLOCK.xpos = pRefCode_MB_Data->xpos;	MAE_MACRO_BLOCK.ypos = pRefCode_MB_Data->ypos;	// MAE Header Word 3 Stuff	// ***********************	// Transform size parameter mask (only for WMV9). Set default here	MAE_MACRO_BLOCK.xformsize = XFORMSIZE_8_8;	// MV data, 4 for forward ref & 4 for backward ref (lumas - Y)	// For MBT_16x16 & forward MC only, all of the first 4 MVs should point to 	// the same value	if(pRefCode_MB_Data->mbmode == MBM_BIDIRECTIONAL)	{		MAE_MACRO_BLOCK.mv[0] = pRefCode_MB_Data->luma_mv[0];		MAE_MACRO_BLOCK.mv[1] = pRefCode_MB_Data->luma_mv[1];		MAE_MACRO_BLOCK.mv[2] = pRefCode_MB_Data->luma_mv[2];		MAE_MACRO_BLOCK.mv[3] = pRefCode_MB_Data->luma_mv[3];		MAE_MACRO_BLOCK.mv[4] = pRefCode_MB_Data->luma_mv[4];		MAE_MACRO_BLOCK.mv[5] = pRefCode_MB_Data->luma_mv[5];		MAE_MACRO_BLOCK.mv[6] = pRefCode_MB_Data->luma_mv[6];		MAE_MACRO_BLOCK.mv[7] = pRefCode_MB_Data->luma_mv[7];//		if(pRefCode_MB_Data->mbtype == MBT_16x16 || pRefCode_MB_Data->mbtype == MBT_16x8)//		{//			MAE_MACRO_BLOCK.mv[4] = 0;//			MAE_MACRO_BLOCK.mv[5] = 0;//			MAE_MACRO_BLOCK.mv[6] = 0;//			MAE_MACRO_BLOCK.mv[7] = 0;//		}	}	else	{		MAE_MACRO_BLOCK.mv[0] = pRefCode_MB_Data->luma_mv[0];		MAE_MACRO_BLOCK.mv[1] = pRefCode_MB_Data->luma_mv[1];		MAE_MACRO_BLOCK.mv[2] = pRefCode_MB_Data->luma_mv[2];		MAE_MACRO_BLOCK.mv[3] = pRefCode_MB_Data->luma_mv[3];		MAE_MACRO_BLOCK.mv[4] = 0;		MAE_MACRO_BLOCK.mv[5] = 0;		MAE_MACRO_BLOCK.mv[6] = 0;		MAE_MACRO_BLOCK.mv[7] = 0;	}	// Used for MC (to determine number of MVs). This will be picked up 	// individually for each MB.	// For Ex: With only forward prediction using MBT_16x16 type, all 4 MVs 	// should have the same value. 	// *********************************************************************	MAE_MACRO_BLOCK.mbtype = pRefCode_MB_Data->mbtype;	// MV for the chroma pair (CbCr - UV)	// For MBT_16x16 & forward MC only, only the first value is used		MAE_MACRO_BLOCK.mv_uv[0] = pRefCode_MB_Data->chroma_mv[0];	MAE_MACRO_BLOCK.mv_uv[1] = pRefCode_MB_Data->chroma_mv[1];	MAE_MACRO_BLOCK.mv_uv1[0] = pRefCode_MB_Data->chroma_mv1[0];	MAE_MACRO_BLOCK.mv_uv1[1] = pRefCode_MB_Data->chroma_mv1[1];	// Block Data (only 6 used for 4:2:0 format)	memcpy (MAE_MACRO_BLOCK.blk_data0, pRefCode_MB_Data->blk_data0, BLOCK_DATA_SIZE_16);	memcpy (MAE_MACRO_BLOCK.blk_data1, pRefCode_MB_Data->blk_data1, BLOCK_DATA_SIZE_16);	memcpy (MAE_MACRO_BLOCK.blk_data2, pRefCode_MB_Data->blk_data2, BLOCK_DATA_SIZE_16);	memcpy (MAE_MACRO_BLOCK.blk_data3, pRefCode_MB_Data->blk_data3, BLOCK_DATA_SIZE_16);	memcpy (MAE_MACRO_BLOCK.blk_data4, pRefCode_MB_Data->blk_data4, BLOCK_DATA_SIZE_16);	memcpy (MAE_MACRO_BLOCK.blk_data5, pRefCode_MB_Data->blk_data5, BLOCK_DATA_SIZE_16);	// $PP	memcpy (MAE_MACRO_BLOCK.blk_data6, pRefCode_MB_Data->blk_data6, BLOCK_DATA_SIZE_16);	memcpy (MAE_MACRO_BLOCK.blk_data7, pRefCode_MB_Data->blk_data7, BLOCK_DATA_SIZE_16);	// Update codec info (MPEG4 or H.263)	// NOT REQUIRED AS OF NOW!!	//MAE_MACRO_BLOCK.codec = pRefCode_MB_Data->codec;		// picture_level_mbmode; set to 0	MAE_MACRO_BLOCK.picture_level_mbmode = 0;	// Reserved fields	MAE_MACRO_BLOCK.res6 = 0;	MAE_MACRO_BLOCK.res7 = 0;	// Send the CModel extra info	gCM.nFrameType = pRefCode_MB_Data->nFrameType;	gCM.nFrameNum  = pRefCode_MB_Data->nFrameNum;	gCM.bPureIntra = pRefCode_MB_Data->bPureIntra;	pMAE_LOCAL_CONFIG->cur_y_frame_ptr = (unsigned int)pRefCode_MB_Data->cur_y_frame;	pMAE_LOCAL_CONFIG->cur_cb_frame_ptr = (unsigned int)pRefCode_MB_Data->cur_cb_frame;	pMAE_LOCAL_CONFIG->cur_cr_frame_ptr = (unsigned int)pRefCode_MB_Data->cur_cr_frame;#if 0        if(nPrevFrameNum != pRefCode_MB_Data->nFrameNum)        {            nPrevFrameNum = pRefCode_MB_Data->nFrameNum;            WrapIndicateFrameDone();        }        WrapExtraInfo = (wrap_extra_info *)malloc(sizeof(wrap_extra_info));        memset(WrapExtraInfo,0,sizeof(wrap_extra_info));        WrapExtraInfo->mae_fe_cfg   = pMAE_LOCAL_CONFIG;        WrapExtraInfo->cur_y_frame  = pRefCode_MB_Data->cur_y_frame;        WrapExtraInfo->cur_cb_frame = pRefCode_MB_Data->cur_cb_frame;        WrapExtraInfo->cur_cr_frame = pRefCode_MB_Data->cur_cr_frame;        WrapExtraInfo->nMB          = pRefCode_MB_Data->nMB;        WrapExtraInfo->nForceSend   = SEND_BATCH;        // Let the CModel perform IQUANT, IDCT & MotionComp        WrapBuildMBParams(&MAE_MACRO_BLOCK, WrapExtraInfo);#else	    // Let the CModel do the IQUANT, IDCT & MotionComp	    if(pMAE_LOCAL_CONFIG)	    {		    fe_process_mb(pMAE_LOCAL_CONFIG, 					      &MAE_MACRO_BLOCK, 					      pRefCode_MB_Data->cur_y_frame,					      pRefCode_MB_Data->cur_cb_frame, 					      pRefCode_MB_Data->cur_cr_frame, 					      pRefCode_MB_Data->nMB);	    }#endif}// ***************************************************************************////  Function:       InterChecksOnBlock//////  Parameters:     pINTERMEDITATE_BLOCK_CHECKERS -- pointer to //					INTERMEDITATE_BLOCK_CHECKERS struct//					char *xFileName -- file name to write data into//////  Return Value:   VOID////  Notes:			This function needs to be called after doing either IQUANT or//					IDCT on a single block. So, this gets called 6 (or 8) times for //					each MB.//// ***************************************************************************void InterChecksOnBlock(pINTERMEDITATE_BLOCK_CHECKERS pCheckBlk, char *xFileName){

⌨️ 快捷键说明

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