[x265] [PATCH 3 of 4] rdlevel: compare Merge-skip(merge2Nx2N with no residue) to best among inter/intra/merge in rdlevel 2

deepthidevaki at multicorewareinc.com deepthidevaki at multicorewareinc.com
Wed Dec 4 08:37:48 CET 2013


# HG changeset patch
# User Deepthi Devaki <deepthidevaki at multicorewareinc.com>
# Date 1386142577 -19800
# Node ID bd58942f9dd2f717f51081183cdf301d20dc1d56
# Parent  71d40e349b4062df2ac12b54cd6eded9cdfa70a2
rdlevel: compare Merge-skip(merge2Nx2N with no residue) to best among inter/intra/merge in rdlevel 2

diff -r 71d40e349b40 -r bd58942f9dd2 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Wed Dec 04 13:05:54 2013 +0530
+++ b/source/encoder/compress.cpp	Wed Dec 04 13:06:17 2013 +0530
@@ -286,6 +286,10 @@
         }
     }
 
+    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);
     if (m_cfg->param.rdLevel > 2)
     {
         //calculate the motion compensation for chroma for the best mode selected
@@ -298,11 +302,6 @@
         TComDataCU* tmp;
         TComYuv *yuv;
 
-        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);
         xCheckDQP(outTempCU);
@@ -437,7 +436,8 @@
 
             /* Compute  Merge Cost */
             xComputeCostMerge2Nx2N(m_bestMergeCU[depth], m_mergeCU[depth], m_modePredYuv[3][depth], m_bestMergeRecoYuv[depth]);
-
+            TComYuv* bestMergePred;
+            bestMergePred = m_modePredYuv[3][depth];
             if (!(m_cfg->param.bEnableEarlySkip && m_bestMergeCU[depth]->isSkipped(0)))
             {
                 /*Compute 2Nx2N mode costs*/
@@ -567,6 +567,30 @@
                 {
                     xEncodeIntraInInter(outBestCU, m_origYuv[depth], m_bestPredYuv[depth], m_tmpResiYuv[depth],  m_bestRecoYuv[depth]);
                 }
+                //Check Merge-skip
+                if (!(outBestCU->getPredictionMode(0) == MODE_INTER && outBestCU->getPartitionSize(0) == SIZE_2Nx2N && outBestCU->getMergeFlag(0)))
+                {
+                    int numPart = m_mergeCU[depth]->getNumPartInter();
+                    for (int partIdx = 0; partIdx < numPart; partIdx++)
+                    {
+                        m_search->motionCompensation(m_mergeCU[depth], bestMergePred, REF_PIC_LIST_X, partIdx, false, true);
+                    }
+                }
+
+                m_search->encodeResAndCalcRdInterCU(m_mergeCU[depth], m_origYuv[depth], bestMergePred, m_tmpResiYuv[depth],
+                                                    m_bestResiYuv[depth], m_tmpRecoYuv[depth], true);
+
+                if (m_mergeCU[depth]->m_totalCost < outBestCU->m_totalCost)
+                {
+                    outBestCU = m_mergeCU[depth];
+                    tempYuv = m_bestRecoYuv[depth];
+                    m_bestRecoYuv[depth] = m_tmpRecoYuv[depth];
+                    m_tmpRecoYuv[depth] = tempYuv;
+                    if (bestMergePred != m_bestPredYuv[depth])
+                    {
+                        bestMergePred->copyPartToPartYuv(m_bestPredYuv[depth], 0, outBestCU->getWidth(0), outBestCU->getHeight(0));
+                    }
+                }
             }
             /* Disable recursive analysis for whole CUs temporarily */
             if ((outBestCU != 0) && (outBestCU->isSkipped(0)))


More information about the x265-devel mailing list