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

1、源代码:

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

  21. // 构造候选列表
  22. Int mergeCandBuffer[MRG_MAX_NUM_CANDS];
  23. for( UInt ui = ; ui < numValidMergeCand; ++ui )
  24. {
  25. mergeCandBuffer[ui] = ;
  26. }
  27.  
  28. Bool bestIsSkip = false;
  29.  
  30. UInt iteration;
    // 默认为false,iteration = 2
  31. if ( rpcTempCU->isLosslessCoded())
  32. {
  33. iteration = ;
  34. }
  35. else
  36. {
  37. iteration = ;
  38. }
  39. DEBUG_STRING_NEW(bestStr)

//代码结构分析

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

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

  1. // 遍历两次:第一次无残差编码,第二次对残差编码
  2. for( UInt uiNoResidual = ; uiNoResidual < iteration; ++uiNoResidual )
  3. {
    // 遍历所有Merge候选成员
  4. for( UInt uiMergeCand = ; uiMergeCand < numValidMergeCand; ++uiMergeCand )
  5. {
  6. if(!(uiNoResidual== && mergeCandBuffer[uiMergeCand]==))
  7. {
  8. if( !(bestIsSkip && uiNoResidual == ) )
  9. {
  10. DEBUG_STRING_NEW(tmpStr)
  11. // set MC parameters 设置运动补偿参数
  12. rpcTempCU->setPredModeSubParts( MODE_INTER, , uhDepth ); // interprets depth relative to LCU level
  13. rpcTempCU->setCUTransquantBypassSubParts( bTransquantBypassFlag, , uhDepth );
  14. rpcTempCU->setChromaQpAdjSubParts( bTransquantBypassFlag ? : m_ChromaQpAdjIdc, , uhDepth );
  15. rpcTempCU->setPartSizeSubParts( SIZE_2Nx2N, , uhDepth ); // interprets depth relative to LCU level
  16. rpcTempCU->setMergeFlagSubParts( true, , , uhDepth ); // interprets depth relative to LCU level
  17. rpcTempCU->setMergeIndexSubParts( uiMergeCand, , , uhDepth ); // interprets depth relative to LCU level
  18. rpcTempCU->setInterDirSubParts( uhInterDirNeighbours[uiMergeCand], , , uhDepth ); // interprets depth relative to LCU level
  19. rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[ + *uiMergeCand], SIZE_2Nx2N, , ); // interprets depth relative to rpcTempCU level
  20. rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[ + *uiMergeCand], SIZE_2Nx2N, , ); // interprets depth relative to rpcTempCU level
  21.  
  22. // do MC 进行运动补偿
  23. m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] );
  24. // estimate residual and encode everything 计算残差和RDCost,并进行编码
  25. m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU,
  26. m_ppcOrigYuv [uhDepth],
  27. m_ppcPredYuvTemp[uhDepth],
  28. m_ppcResiYuvTemp[uhDepth],
  29. m_ppcResiYuvBest[uhDepth],
  30. m_ppcRecoYuvTemp[uhDepth],
  31. (uiNoResidual != ) DEBUG_STRING_PASS_INTO(tmpStr) );
  32.  
  33. #ifdef DEBUG_STRING
  34. DebugInterPredResiReco(tmpStr, *(m_ppcPredYuvTemp[uhDepth]), *(m_ppcResiYuvBest[uhDepth]), *(m_ppcRecoYuvTemp[uhDepth]), DebugStringGetPredModeMask(rpcTempCU->getPredictionMode()));
  35. #endif
  36. // 第一次迭代时进行
  37. if ((uiNoResidual == ) && (rpcTempCU->getQtRootCbf() == ))
  38. {
  39. // If no residual when allowing for one, then set mark to not try case where residual is forced to 0
  40. mergeCandBuffer[uiMergeCand] = ;
  41. }
  42.  
  43. rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf() == , , uhDepth );
  44. Int orgQP = rpcTempCU->getQP( );
  45. xCheckDQP( rpcTempCU );
    // 更新最优模式
  46. xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth DEBUG_STRING_PASS_INTO(bestStr) DEBUG_STRING_PASS_INTO(tmpStr));
  47. // 重新初始化预测参数,为下一次预测做准备
  48. rpcTempCU->initEstData( uhDepth, orgQP, bTransquantBypassFlag );
  49.  
  50. if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip )
  51. {
  52. bestIsSkip = rpcBestCU->getQtRootCbf() == ;
  53. }
  54. }
  55. }
  56. }

  57. // 如果开启earlyDetectionSkip时,第一次迭代执行
  58. if(uiNoResidual == && m_pcEncCfg->getUseEarlySkipDetection())
  59. {
  60. if(rpcBestCU->getQtRootCbf( ) == )
  61. {
  62. if( rpcBestCU->getMergeFlag( ))
  63. {
  64. *earlyDetectionSkipMode = true;
  65. }
  66. else if(m_pcEncCfg->getFastSearch() != SELECTIVE)
  67. {
  68. Int absoulte_MV=;
  69. for ( UInt uiRefListIdx = ; uiRefListIdx < ; uiRefListIdx++ )
  70. {
  71. if ( rpcBestCU->getSlice()->getNumRefIdx( RefPicList( uiRefListIdx ) ) > )
  72. {
  73. TComCUMvField* pcCUMvField = rpcBestCU->getCUMvField(RefPicList( uiRefListIdx ));
  74. Int iHor = pcCUMvField->getMvd( ).getAbsHor();
  75. Int iVer = pcCUMvField->getMvd( ).getAbsVer();
  76. absoulte_MV+=iHor+iVer;
  77. }
  78. }
  79.  
  80. if(absoulte_MV == )
  81. {
  82. *earlyDetectionSkipMode = true;
  83. }
  84. }
  85. }
  86. }
  87. }
  88. DEBUG_STRING_APPEND(sDebug, bestStr)
  89. }

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. spring boot 项目连接数据库查询数据过程

    spring boot 项目搭建 pom.xml <?xml version="1.0" encoding="UTF-8"?> <projec ...

  2. Day01_mongoDB入门

    学于黑马和传智播客联合做的教学项目 感谢 黑马官网:http://www.itheima.com 传智播客官网:http://www.itcast.cn 微信搜索"艺术行者",关注 ...

  3. 判断js中数组是否包含某值

    可以用数组的includes函数判断数组中是否存在某个值.

  4. 重置spyder 解决 gbk 编码不能读取问题

    重置spyder 解决 gbk 编码不能读取问题 2020-06-18

  5. 从包含10个无符号数的字节数组array中选出最小的一个数存于变量MIN中,并将该数以十进制形式显示出来。

    问题 从包含10个无符号数的字节数组array中选出最小的一个数存于变量MIN中,并将该数以十进制形式显示出来. 代码 data segment arrey db 0,1,2,4,6,5,7,9,8, ...

  6. PHP imageaffinematrixget - 获取矩阵

    imageaffinematrixget — 获取矩阵.高佣联盟 www.cgewang.com 语法 array imageaffinematrixget ( int $type [, mixed ...

  7. Android运行时注入浅析与使用

    背景 最近接触新项目,项目中引入了Android Annotation(AA)依赖注入开源框架,代码中大片的注解代码,对于没用过注解框架(或者说没有如此大面积的使用)的我来说确实看得很费力,于是花时间 ...

  8. 账本APP开发

    服务端开发 好好学习,天天向上 本文已收录至我的Github仓库DayDayUP:github.com/RobodLee/DayDayUP,欢迎Star,更多文章请前往:目录导航 前言 我平时喜欢用账 ...

  9. 简单的vector--- 2

    如何重载operator[]   及其相关细节 如何使用 const_cast<>(  )  和 static_cast<>( ) 模板类 如何内部声明,外部定义友元函数 使用 ...

  10. tracebace用法

    介绍一下traceback 平时看到的程序的错误信息也就是traceback信息 举个简单例子: import traceback try: s = [1, 2, 3] print s[5] exce ...