[x265] [PATCH] Changes in merge mode in no-rdo path for better psnr improvement and time performance

sumalatha at multicorewareinc.com sumalatha at multicorewareinc.com
Mon Jul 15 10:58:11 CEST 2013


# HG changeset patch
# User sumalatha
# Date 1373878676 -19800
# Node ID 59e44237a9fce7a2c7ac6f3887e34f1b3144fc28
# Parent  9e689682ffb144709c5351ca3b2828c507b19b26
Changes in merge mode in no-rdo path for better psnr improvement and time performance

diff -r 9e689682ffb1 -r 59e44237a9fc source/Lib/TLibEncoder/TEncCu.h
--- a/source/Lib/TLibEncoder/TEncCu.h	Fri Jul 12 23:22:40 2013 -0500
+++ b/source/Lib/TLibEncoder/TEncCu.h	Mon Jul 15 14:27:56 2013 +0530
@@ -149,6 +149,7 @@
 
     Void xCheckRDCostMerge2Nx2N(TComDataCU*& outBestCU, TComDataCU*& outTempCU, Bool *earlyDetectionSkipMode,
                                 TComYuv*& outBestPredYuv, TComYuv*& rpcYuvReconBest);
+    Void xComputeCostMerge2Nx2N(TComDataCU*& outBestCU, TComDataCU*& outTempCU, Bool* earlyDetectionSkip, TComYuv*& bestPredYuv, TComYuv*& tmpPredYuv);
     Void xComputeCostIntraInInter(TComDataCU*& outTempCU, PartSize partSize);
     Void xCheckRDCostInter(TComDataCU*& outBestCU, TComDataCU*& outTempCU, PartSize partSize, Bool bUseMRG = false);
     Void xComputeCostInter(TComDataCU* outTempCU, PartSize partSize, UInt Index, Bool bUseMRG = false);
diff -r 9e689682ffb1 -r 59e44237a9fc source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Fri Jul 12 23:22:40 2013 -0500
+++ b/source/encoder/compress.cpp	Mon Jul 15 14:27:56 2013 +0530
@@ -218,6 +218,95 @@
  * \param outTempCU
  * \returns Void
  */
+Void TEncCu::xComputeCostMerge2Nx2N(TComDataCU*& outBestCU, TComDataCU*& outTempCU, Bool* earlyDetectionSkip, TComYuv*& bestPredYuv, TComYuv*& tmpPredYuv)
+{
+    assert(rpcTempCU->getSlice()->getSliceType() != I_SLICE);
+    TComMvField  cMvFieldNeighbours[MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists
+    UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS];
+    Int numValidMergeCand = 0;
+
+    for (UInt ui = 0; ui < outTempCU->getSlice()->getMaxNumMergeCand(); ++ui)
+    {
+        uhInterDirNeighbours[ui] = 0;
+    }
+
+    UChar depth = outTempCU->getDepth(0);
+    outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth); // interprets depth relative to LCU level
+    outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(), 0, depth);
+    outTempCU->getInterMergeCandidates(0, 0, cMvFieldNeighbours, uhInterDirNeighbours, numValidMergeCand);
+
+    x265::MotionEstimate me_merge; // TODO: use m_pcPredSearch->m_me here
+    me_merge.setSourcePlane((pixel*)m_origYuv[depth]->getLumaAddr(),
+                            m_origYuv[depth]->getStride());
+
+    for (Int uiMergeCand = 0; uiMergeCand < numValidMergeCand; ++uiMergeCand)
+    {
+        // set MC parameters
+        outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);             // interprets depth relative to LCU level
+        outTempCU->setCUTransquantBypassSubParts(m_cfg->getCUTransquantBypassFlagValue(),     0, depth);
+        outTempCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth);             // interprets depth relative to LCU level
+        outTempCU->setMergeFlagSubParts(true, 0, 0, depth);             // interprets depth relative to LCU level
+        outTempCU->setMergeIndexSubParts(uiMergeCand, 0, 0, depth);             // interprets depth relative to LCU level
+        outTempCU->setInterDirSubParts(uhInterDirNeighbours[uiMergeCand], 0, 0, depth);             // interprets depth relative to LCU level
+        outTempCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField(cMvFieldNeighbours[0 + 2 * uiMergeCand], SIZE_2Nx2N, 0, 0);             // interprets depth relative to rpcTempCU level
+        outTempCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField(cMvFieldNeighbours[1 + 2 * uiMergeCand], SIZE_2Nx2N, 0, 0);             // interprets depth relative to rpcTempCU level
+
+        // do MC
+        m_search->motionCompensation(outTempCU,tmpPredYuv);
+
+         outTempCU->getTotalCost() = primitives.sse_pp[PartitionFromSizes(outTempCU->getWidth(0), outTempCU->getHeight(0))]((pixel*)m_origYuv[depth]->getLumaAddr(), (intptr_t)m_origYuv[depth]->getStride(), (pixel*)tmpPredYuv->getLumaAddr(), tmpPredYuv->getStride());
+
+        Int orgQP = outTempCU->getQP(0);
+
+        if (outTempCU->getTotalCost() < outBestCU->getTotalCost())
+        {
+            TComDataCU* tmp = outTempCU;
+            outTempCU = outBestCU;
+            outBestCU = tmp;
+            // Change Prediction data
+            TComYuv* pcYuv = NULL;
+            pcYuv = bestPredYuv;
+            bestPredYuv  = tmpPredYuv;
+            tmpPredYuv = pcYuv;
+           
+        }
+
+        outTempCU->initEstData(depth, orgQP);
+    }
+      m_search->encodeResAndCalcRdInterCU(outBestCU, m_origYuv[depth], bestPredYuv, m_tmpResiYuv[depth], m_bestResiYuv[depth], m_bestMergeRecoYuv[depth], false);
+       if ( m_cfg->getUseEarlySkipDetection())
+        {
+            if (outBestCU->getQtRootCbf(0) == 0)
+            {
+                if (outBestCU->getMergeFlag(0))
+                {
+                    *earlyDetectionSkip = true;
+                }
+                else
+                {
+                    Int absoulte_MV = 0;
+                    for (UInt uiRefListIdx = 0; uiRefListIdx < 2; uiRefListIdx++)
+                    {
+                        if (outBestCU->getSlice()->getNumRefIdx(RefPicList(uiRefListIdx)) > 0)
+                        {
+                            TComCUMvField* pcCUMvField = outBestCU->getCUMvField(RefPicList(uiRefListIdx));
+                            Int iHor = abs(pcCUMvField->getMvd(0).x);
+                            Int iVer = abs(pcCUMvField->getMvd(0).y);
+                            absoulte_MV += iHor + iVer;
+                        }
+                    }
+
+                    if (absoulte_MV == 0)
+                    {
+                        *earlyDetectionSkip = true;
+                    }
+                }
+            }
+        }
+
+      m_tmpResiYuv[depth]->clear();
+    x265_emms();
+}
 Void TEncCu::xComputeCostInter(TComDataCU* outTempCU, PartSize partSize, UInt index, Bool bUseMRG)
 {
     UChar depth = outTempCU->getDepth(0);
@@ -233,6 +322,7 @@
     m_tmpResiYuv[depth]->clear();
 
     m_search->predInterSearch(outTempCU, m_origYuv[depth], m_modePredYuv[index][depth], bUseMRG);
+    outTempCU->getTotalCost() = primitives.sse_pp[PartitionFromSizes(outTempCU->getWidth(0), outTempCU->getHeight(0))]((pixel*)m_origYuv[depth]->getLumaAddr(), (intptr_t)m_origYuv[depth]->getStride(), (pixel*)m_modePredYuv[index][depth]->getLumaAddr(),  m_modePredYuv[index][depth]->getStride());
 }
 
 Void TEncCu::xCompressInterCU(TComDataCU*& outBestCU, TComDataCU*& outTempCU, TComDataCU*& cu, UInt depth, UInt PartitionIndex)
@@ -294,7 +384,7 @@
 
         /* Compute  Merge Cost */
         Bool earlyDetectionSkip = false;
-        xCheckRDCostMerge2Nx2N(m_bestMergeCU[depth], m_mergeCU[depth], &earlyDetectionSkip, m_modePredYuv[3][depth], m_bestMergeRecoYuv[depth]);
+        xComputeCostMerge2Nx2N(m_bestMergeCU[depth], m_mergeCU[depth], &earlyDetectionSkip, m_modePredYuv[3][depth], m_modePredYuv[4][depth]);
 
         if (!earlyDetectionSkip)
         {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: july_15.patch
Type: text/x-patch
Size: 7059 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130715/db90e341/attachment-0001.bin>


More information about the x265-devel mailing list