[x265] [PATCH] no-rdo: add no-residue candidate in merge2Nx2N

deepthidevaki at multicorewareinc.com deepthidevaki at multicorewareinc.com
Tue Oct 29 07:10:56 CET 2013


# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1383026581 -19800
# Node ID 8c38f0da2ae93bf19e780bf96be95bf201ed8f94
# Parent  8846f5cf6d8d1b06496055a1bc756ed4dd3fa1c5
no-rdo: add no-residue candidate in merge2Nx2N

diff -r 8846f5cf6d8d -r 8c38f0da2ae9 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Tue Oct 29 01:05:47 2013 -0500
+++ b/source/encoder/compress.cpp	Tue Oct 29 11:33:01 2013 +0530
@@ -245,6 +245,7 @@
     outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
     outTempCU->getInterMergeCandidates(0, 0, mvFieldNeighbours, interDirNeighbours, numValidMergeCand);
 
+    int bestMergeCand = 0;
     for (int mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand)
     {
         // set MC parameters, interprets depth relative to LCU level
@@ -268,6 +269,7 @@
 
         if (outTempCU->m_totalCost < outBestCU->m_totalCost)
         {
+            bestMergeCand = mergeCand;
             TComDataCU* tmp = outTempCU;
             outTempCU = outBestCU;
             outBestCU = tmp;
@@ -286,7 +288,44 @@
     {
         m_search->motionCompensation(outBestCU, bestPredYuv, REF_PIC_LIST_X, partIdx, false, true);
     }
-    m_search->encodeResAndCalcRdInterCU(outBestCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], yuvReconBest, false);
+
+    TComDataCU* tmp;
+    TComYuv *yuv;
+
+    outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
+    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
+    outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth);
+    outTempCU->setMergeFlagSubParts(true, 0, 0, depth);
+    outTempCU->setMergeIndexSubParts(bestMergeCand, 0, 0, depth);
+    outTempCU->setInterDirSubParts(interDirNeighbours[bestMergeCand], 0, 0, depth);
+    outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(mvFieldNeighbours[0 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);
+    outTempCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField(mvFieldNeighbours[1 + 2 * bestMergeCand], SIZE_2Nx2N, 0, 0);
+
+    //No-residue mode
+    m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], true);
+
+    tmp = outTempCU;
+    outTempCU = outBestCU;
+    outBestCU = tmp;
+
+    yuv = yuvReconBest;
+    yuvReconBest = m_tmpRecoYuv[depth];
+    m_tmpRecoYuv[depth] = yuv;
+
+    //Encode with residue
+    m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], false);
+
+    if (outTempCU->m_totalCost < outBestCU->m_totalCost)    //Choose best from no-residue mode and residue mode
+    {
+        tmp = outTempCU;
+        outTempCU = outBestCU;
+        outBestCU = tmp;
+
+        yuv = yuvReconBest;
+        yuvReconBest = m_tmpRecoYuv[depth];
+        m_tmpRecoYuv[depth] = yuv;
+    }
+
     if (m_cfg->param.bEnableEarlySkip)
     {
         if (outBestCU->getQtRootCbf(0) == 0)


More information about the x265-devel mailing list