参考:https://blog.csdn.net/nb_vol_1/article/details/51163625

1、源代码:

/** check RD costs for a CU block encoded with merge
* \param rpcBestCU
* \param rpcTempCU
* \returns Void
*/
Void TEncCu::xCheckRDCostMerge2Nx2N( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU DEBUG_STRING_FN_DECLARE(sDebug), Bool *earlyDetectionSkipMode )
{
assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); // 确定该片是P Slice或者B Slice
TComMvField cMvFieldNeighbours[ * MRG_MAX_NUM_CANDS]; // double length for mv of both lists
UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
Int numValidMergeCand = ;
const Bool bTransquantBypassFlag = rpcTempCU->getCUTransquantBypass(); for( UInt ui = ; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )
{
uhInterDirNeighbours[ui] = ;
}
UChar uhDepth = rpcTempCU->getDepth( ); // 获取当前深度
// 给PU中相应的partition写入分割模式
rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, , uhDepth ); // interprets depth relative to LCU level
// 取出Merge候选列表
rpcTempCU->getInterMergeCandidates( , , cMvFieldNeighbours,uhInterDirNeighbours, numValidMergeCand );

// 构造候选列表
Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
for( UInt ui = ; ui < numValidMergeCand; ++ui )
{
mergeCandBuffer[ui] = ;
} Bool bestIsSkip = false; UInt iteration;
// 默认为false,iteration = 2
if ( rpcTempCU->isLosslessCoded())
{
iteration = ;
}
else
{
iteration = ;
}
DEBUG_STRING_NEW(bestStr)

//代码结构分析

//第一次不理skip模式,bestIsSkip的初始值为false;

//第二次不处理mergeCandBuffer[uiMergeCand]为1的情况.

  // 遍历两次:第一次无残差编码,第二次对残差编码
for( UInt uiNoResidual = ; uiNoResidual < iteration; ++uiNoResidual )
{
// 遍历所有Merge候选成员
for( UInt uiMergeCand = ; uiMergeCand < numValidMergeCand; ++uiMergeCand )
{
if(!(uiNoResidual== && mergeCandBuffer[uiMergeCand]==))
{
if( !(bestIsSkip && uiNoResidual == ) )
{
DEBUG_STRING_NEW(tmpStr)
// set MC parameters 设置运动补偿参数
rpcTempCU->setPredModeSubParts( MODE_INTER, , uhDepth ); // interprets depth relative to LCU level
rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, , uhDepth );
rpcTempCU->setChromaQpAdjSubParts( bTransquantBypassFlag ? : m_ChromaQpAdjIdc, , uhDepth );
rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, , uhDepth ); // interprets depth relative to LCU level
rpcTempCU->setMergeFlagSubParts( true, , , uhDepth ); // interprets depth relative to LCU level
rpcTempCU->setMergeIndexSubParts( uiMergeCand, , , uhDepth ); // interprets depth relative to LCU level
rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], , , uhDepth ); // interprets depth relative to LCU level
rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[ + *uiMergeCand], SIZE_2Nx2N, , ); // interprets depth relative to rpcTempCU level
rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[ + *uiMergeCand], SIZE_2Nx2N, , ); // interprets depth relative to rpcTempCU level // do MC 进行运动补偿
m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
// estimate residual and encode everything 计算残差和RDCost,并进行编码
m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
m_ppcOrigYuv [uhDepth],
m_ppcPredYuvTemp[uhDepth],
m_ppcResiYuvTemp[uhDepth],
m_ppcResiYuvBest[uhDepth],
m_ppcRecoYuvTemp[uhDepth],
(uiNoResidual != ) DEBUG_STRING_PASS_INTO(tmpStr) ); #ifdef DEBUG_STRING
DebugInterPredResiReco(tmpStr, *(m_ppcPredYuvTemp[uhDepth]), *(m_ppcResiYuvBest[uhDepth]), *(m_ppcRecoYuvTemp[uhDepth]), DebugStringGetPredModeMask(rpcTempCU->getPredictionMode()));
#endif
// 第一次迭代时进行
if ((uiNoResidual == ) && (rpcTempCU->getQtRootCbf() == ))
{
// If no residual when allowing for one, then set mark to not try case where residual is forced to 0
mergeCandBuffer[uiMergeCand] = ;
} rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf() == , , uhDepth );
Int orgQP = rpcTempCU->getQP( );
xCheckDQP( rpcTempCU );
// 更新最优模式
xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(bestStr) DEBUG_STRING_PASS_INTO(tmpStr));
// 重新初始化预测参数,为下一次预测做准备
rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag ); if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
{
bestIsSkip = rpcBestCU->getQtRootCbf() == ;
}
}
}
}

// 如果开启earlyDetectionSkip时,第一次迭代执行
if(uiNoResidual == && m_pcEncCfg->getUseEarlySkipDetection())
{
if(rpcBestCU->getQtRootCbf( ) == )
{
if( rpcBestCU->getMergeFlag( ))
{
*earlyDetectionSkipMode = true;
}
else if(m_pcEncCfg->getFastSearch() != SELECTIVE)
{
Int absoulte_MV=;
for ( UInt uiRefListIdx = ; uiRefListIdx < ; uiRefListIdx++ )
{
if ( rpcBestCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > )
{
TComCUMvField* pcCUMvField = rpcBestCU->getCUMvField(RefPicList( uiRefListIdx ));
Int iHor = pcCUMvField->getMvd( ).getAbsHor();
Int iVer = pcCUMvField->getMvd( ).getAbsVer();
absoulte_MV+=iHor+iVer;
}
} if(absoulte_MV == )
{
*earlyDetectionSkipMode = true;
}
}
}
}
}
DEBUG_STRING_APPEND(sDebug, bestStr)
}

HM16.0之帧间Merge模式——xCheckRDCostMerge2Nx2N的更多相关文章

  1. HM16.0之帧间预测——xCheckRDCostInter()函数

    参考:https://blog.csdn.net/nb_vol_1/article/category/6179825/1? 1.源代码: #if AMP_MRG Void TEncCu::xCheck ...

  2. HM16.0之帧内模式——xCheckRDCostIntra()函数

    参考:https://blog.csdn.net/nb_vol_1/article/category/6179825/1? 1.源代码: Void TEncCu::xCheckRDCostIntra( ...

  3. HM16.0 TAppEncoder

    参考:  https://www.cnblogs.com/tiansha/p/6458573.html https://blog.csdn.net/liangjiubujiu/article/deta ...

  4. x264源代码简单分析:宏块分析(Analysis)部分-帧间宏块(Inter)

    ===================================================== H.264源代码分析文章列表: [编码 - x264] x264源代码简单分析:概述 x26 ...

  5. Paper | 帧间相关性 + 压缩视频质量增强(MFQE)

    目录 1. ABSTRACT 2. INTRODUCTION 3. RELATED WORKS 3.1. Quality Enhancement 3.2. Multi-frame Super-reso ...

  6. x264代码剖析(十三):核心算法之帧间预測函数x264_mb_analyse_inter_*()

    x264代码剖析(十三):核心算法之帧间预測函数x264_mb_analyse_inter_*() 帧间预測是指利用视频时间域相关性,使用临近已编码图像像素预測当前图像的像素,以达到有效去除视频时域冗 ...

  7. 【HEVC帧间预测论文】P1.7 Content Based Hierarchical Fast Coding Unit Decision Algorithm

    Content Based Hierarchical Fast Coding Unit Decision Algorithm For HEVC <HEVC标准介绍.HEVC帧间预测论文笔记> ...

  8. 【HEVC帧间预测论文】P1.4 Motion Vectors Merging: Low Complexity Prediction Unit Decision

    Motion Vectors Merging: Low Complexity Prediction Unit Decision Heuristic for the inter-Prediction o ...

  9. 【HEVC帧间预测论文】P1.3 Fast Inter-Frame Prediction Algorithm of HEVC Based on Graphic Information

    基于图形信息的HEVC帧间预测快速算法/Fast Inter-Frame Prediction Algorithm of HEVC Based on Graphic Information <H ...

随机推荐

  1. IO—》递归

    递归的概述 递归,指在当前方法内调用自己的这种现象 public void method(){ System.out.println(“递归的演示”); //在当前方法内调用自己 method(); ...

  2. ES6 class继承的简单应用

    class的好处就是让继承的实现更加简单,语法简单,理解起来也不复杂,但是现在只能做测试使用,项目中需要用Babel工具. <!DOCTYPE html> <html> < ...

  3. luogu P3829 [SHOI2012]信用卡凸包 凸包 点的旋转

    LINK:信用卡凸包 当 R==0的时候显然是一个点的旋转 之后再求凸包即可. 这里先说点如何旋转 如果是根据原点旋转的话 经过一个繁杂的推导可以得到一个矩阵. [cosw,-sinw] [sinw, ...

  4. 5.22 noip模拟赛

    本来我是不想写的,无奈不会写.蒟蒻 考场就是想不出来 今天得到了100分额外水过了100分我是真的失败.还有一个根本不会check 感觉自己非常之菜. 这道题是这样的 还行吧比较有意思 首先确立一个真 ...

  5. 4.2 省选模拟赛 旅行路线 广义SAM

    \(n\leq 100000\) 题目上求出 多少条本质不同的路线. 首先定义了 相似的城市为度数相同的城市. 还定义了两条路线相同当且仅当长度相同 且对应位置的城市都是相似的. 考虑这张图的形态 n ...

  6. 【FZYZOJ】数论课堂 题解(约数个数定理)

    前言:想了两个小时orz,最后才想到要用约数个数定理…… ------------- 题目大意: 给定$n,q,A[1],A[2],A[3]$ 现有$A[i]=(A[i-1]+A[i-2]+A[i-3 ...

  7. 你不是说你会Aop吗?

    一大早,小王就急匆匆的跑过来找我,说:周哥,那个记录日志的功能我想请教一下. 因为公司某个项目要跟别的平台做对接,我们这边需要给他们提供一套接口.昨天,我就将记录接口日志的工作安排给了小王. 下面是我 ...

  8. map,reduce和filter函数

    numArray = [1, 2, 3, 4, 5] def ercifang(x): return x ** 2 def map_test(func, numArray): li = [] for ...

  9. 不能错过的分布式ID生成器(Leaf ),好用的一批!

    本文收录在个人博客:www.chengxy-nds.top,技术资料共享,同进步 不了解分布式ID的同学,先行去看<一口气说出 9种 分布式ID生成方式,面试官有点懵了>温习一下基础知识, ...

  10. SQL Server中的集合运算: UNION, EXCEPT和INTERSECT

    SQL Server中的集合运算包括UNION(合并),EXCEPT(差集)和INTERSECT(相交)三种. 集合运算的基本使用 1.UNION(合并两个查询结果集,隐式DINSTINCT,删除重复 ...