[x265] [PATCH] RD merge: refine merge costs with estimated merge mode bits

deepthi at multicorewareinc.com deepthi at multicorewareinc.com
Thu Nov 28 10:55:07 CET 2013


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1385632492 -19800
# Node ID 42892f4f4cc209a224a646f439a4bb4eba4389b3
# Parent  2ba6c26c9febdc8c57d3014c0cf98d4897d3992d
RD merge: refine merge costs with estimated merge mode bits.

diff -r 2ba6c26c9feb -r 42892f4f4cc2 source/encoder/compress.cpp
--- a/source/encoder/compress.cpp	Thu Nov 28 15:04:04 2013 +0530
+++ b/source/encoder/compress.cpp	Thu Nov 28 15:24:52 2013 +0530
@@ -244,7 +244,9 @@
     outBestCU->setPartSizeSubParts(SIZE_2Nx2N, 0, depth);
     outBestCU->setMergeFlagSubParts(true, 0, 0, depth);
 
+    int part = g_convertToBit[outTempCU->getWidth(0)];
     int bestMergeCand = 0;
+    uint32_t bitsCand = 0;
     for (int mergeCand = 0; mergeCand < numValidMergeCand; ++mergeCand)
     {
         // set MC parameters, interprets depth relative to LCU level
@@ -255,10 +257,16 @@
 
         // do MC only for Luma part
         m_search->motionCompensation(outTempCU, m_tmpPredYuv[depth], REF_PIC_LIST_X, -1, true, false);
-        int part = g_convertToBit[outTempCU->getWidth(0)];
+        bitsCand = mergeCand + 1;
+        if (mergeCand == (int)m_cfg->param.maxNumMergeCand - 1)
+        {
+            bitsCand--;
+        }
+        outTempCU->m_totalBits = bitsCand;
+        outTempCU->m_totalDistortion = primitives.sa8d[part](m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(),
+                                                         m_tmpPredYuv[depth]->getLumaAddr(), m_tmpPredYuv[depth]->getStride());
+        outTempCU->m_totalCost = m_rdCost->calcRdSADCost(outTempCU->m_totalDistortion, outTempCU->m_totalBits);
 
-        outTempCU->m_totalCost = primitives.sa8d[part](m_origYuv[depth]->getLumaAddr(), m_origYuv[depth]->getStride(),
-                                                         m_tmpPredYuv[depth]->getLumaAddr(), m_tmpPredYuv[depth]->getStride());
         if (outTempCU->m_totalCost < outBestCU->m_totalCost)
         {
             bestMergeCand = mergeCand;


More information about the x265-devel mailing list