MbEncoder::encodeMacroblock( MbDataAccess& rcMbDataAccess,
IntFrame* pcFrame,
IntFrame* pcOrgFrame,//lufeng
RefFrameList& rcList0,
RefFrameList& rcList1,
UInt uiNumMaxIter,
UInt uiIterSearchRange,
Double dLambda,
Double& rdCost,//lufeng
Bool bSkipModeAllowed
)
{
ROF( m_bInitDone );
UInt uiQp = rcMbDataAccess.getMbData().getQp();
RNOK( m_pcRateDistortionIf->setMbQpLambda( rcMbDataAccess, uiQp, dLambda ) );
m_pcIntMbBestIntraChroma = NULL;
m_pcIntMbBestData ->init( rcMbDataAccess );
m_pcIntMbTempData ->init( rcMbDataAccess );
m_pcIntMbBest8x8Data->init( rcMbDataAccess );
m_pcIntMbTemp8x8Data->init( rcMbDataAccess );
m_pcIntPicBuffer = pcFrame->getFullPelYuvBuffer();
// m_pcXDistortion->loadOrgMbPelData( m_pcIntPicBuffer, m_pcIntOrgMbPelData );
m_pcXDistortion->loadOrgMbPelData( pcOrgFrame->getFullPelYuvBuffer(), m_pcIntOrgMbPelData );//lufeng: bug fixed for org pic lost in mbaff coding
m_pcTransform->setQp( rcMbDataAccess, rcMbDataAccess.getSH().getKeyPictureFlag() );
//====== evaluate macroblock modes ======
if( rcMbDataAccess.getSH().isInterP() && bSkipModeAllowed )
{
RNOK( xEstimateMbSkip ( m_pcIntMbTempData, m_pcIntMbBestData, rcList0, rcList1 ) );
}
if( rcMbDataAccess.getSH().isInterB() )
{
RNOK( xEstimateMbDirect ( m_pcIntMbTempData, m_pcIntMbBestData, rcList0, rcList1, NULL, false,bSkipModeAllowed ) );
}
if( rcMbDataAccess.getSH().isInterP() || rcMbDataAccess.getSH().isInterB() )
{
RNOK( xEstimateMb16x16 ( m_pcIntMbTempData, m_pcIntMbBestData, rcList0, rcList1, false, uiNumMaxIter, uiIterSearchRange, false, NULL, false ) );
RNOK( xEstimateMb16x8 ( m_pcIntMbTempData, m_pcIntMbBestData, rcList0, rcList1, false, uiNumMaxIter, uiIterSearchRange, false, NULL, false ) );
RNOK( xEstimateMb8x16 ( m_pcIntMbTempData, m_pcIntMbBestData, rcList0, rcList1, false, uiNumMaxIter, uiIterSearchRange, false, NULL, false ) );
RNOK( xEstimateMb8x8 ( m_pcIntMbTempData, m_pcIntMbBestData, rcList0, rcList1, false, uiNumMaxIter, uiIterSearchRange, false, NULL, false ) );
RNOK( xEstimateMb8x8Frext ( m_pcIntMbTempData, m_pcIntMbBestData, rcList0, rcList1, false, uiNumMaxIter, uiIterSearchRange, false, NULL, false ) );
}
RNOK( xEstimateMbIntra16 ( m_pcIntMbTempData, m_pcIntMbBestData, rcMbDataAccess.getSH().isInterB() ) );
RNOK( xEstimateMbIntra8 ( m_pcIntMbTempData, m_pcIntMbBestData, rcMbDataAccess.getSH().isInterB() ) );
RNOK( xEstimateMbIntra4 ( m_pcIntMbTempData, m_pcIntMbBestData, rcMbDataAccess.getSH().isInterB() ) );
RNOK( xEstimateMbPCM ( m_pcIntMbTempData, m_pcIntMbBestData, rcMbDataAccess.getSH().isInterB() ) );
//===== fix estimation =====
RNOK( m_pcRateDistortionIf->fixMacroblockQP( *m_pcIntMbBestData ) );
xStoreEstimation( rcMbDataAccess, *m_pcIntMbBestData, NULL, NULL, false, NULL );
rdCost = m_pcIntMbBestData->rdCost();//lufeng
static int count0=0;
static int count1=0;
static int count2=0;
static int count3=0;
static int count4=0;
static int count5=0;
static int count6=0;
int count=0;
//============统计各个宏块模式所占的比例2012.11.28===================
if(( rcMbDataAccess.getSH().isInterP() )||( rcMbDataAccess.getSH().isInterB() ))//判断当前编码宏块属于P帧还是B帧,一帧是一幅图像,一幅图像含有多个宏块
{
if(m_pcIntMbBestData->m_eMbMode==MODE_SKIP) count0++;
else if(m_pcIntMbBestData->m_eMbMode==MODE_16x16) count1++;
else if(m_pcIntMbBestData->m_eMbMode==MODE_16x8) count2++;
else if(m_pcIntMbBestData->m_eMbMode==MODE_8x16) count3++;
else if(m_pcIntMbBestData->m_eMbMode==MODE_8x8) count4++;
else if(m_pcIntMbBestData->m_eMbMode==MODE_8x8ref0) count5++;
else count6++;
// XPel *MbAddress=m_pcIntPicBuffer-> getMbLumAddr();
// XPel *MaxMbAddress = rcSH.getMbInPic()
static int Mbnum=0;//统计宏块总数
Mbnum+=1;
if (Mbnum==1200)//如果宏块总数为1200,即一帧结束,则进行统计宏块模式数据处理
//这里编码ballroom_0.yuv,分辨率640*480,故宏块总数为(640*480)/16*16=1200
/* if(Mbnum==((t_uiLumPicWidth*t_uiLumPicHeight)/256))*/ //这个是我自己对作者源程序的修改,这样就不用手动修改Mbnum的值了
//这样处理的前提,需要在ReadYuvFile.cpp文件里面相应位置添加extern UInt t_uiLumPicWidth=0; extern UInt t_uiLumPicHeight=0;
//t_uiLumPicWidth = uiLumPicWidth; t_uiLumPicHeight= uiLumPicHeight;
//同时,在MbEncoder.cpp文件里面相应位置添加extern UInt t_uiLumPicWidth;extern UInt t_uiLumPicHeight;
{
count=count0+count1+count2+count3+count4+count5+count6;
float percent0=(float)count0*100/count;
float percent1=(float)count1*100/count;
float percent2=(float)count2*100/count;
float percent3=(float)count3*100/count;
float percent4=(float)count4*100/count;
float percent5=(float)count5*100/count;
float percent6=(float)count6*100/count;
printf("count0=%d,count1=%d,count2=%d,count3=%d,count4=%d,count5=%d,count6=%d,count=%d\n",count0,count1,count2,count3,count4,count5,count6,count);
printf("percent0=%f,percent1=%f,percent2=%f,percent3=%f,percent4=%f,percent5=%f,percent6=f\n\n",percent0,percent1,percent2,percent3,percent4,percent5,percent6);
// count=0,count0=0,count1=0,count2=0,count3=0,count4=0,count5=0;
}
}
//===== uninit =====
m_pcIntMbBestData ->uninit();
m_pcIntMbTempData ->uninit();
m_pcIntMbBest8x8Data->uninit();
m_pcIntMbTemp8x8Data->uninit();
return Err::m_nOK;
}
统计宏块各个模式所占的比例
转载
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
JM8.5中的7种宏块模式问题
<br />JM8.5中的7种宏块模式问题 收藏 <br />Outline:1、 CFG文件中有关可变尺寸宏块模式的相关选项<br />2、 7种宏块模式对应的数值常量3、 7种宏块模式被分成宏块和亚宏块4、 如何对宏块和亚宏块的运动估计,采用一个共同的函数来处理5、 遗留问题 <br /> 1、CFG文件中有关可变尺寸宏块模式的相关选项###############################################################################<
search lambda reference table 运动估计