[x265] [PATCH 4 of 5] search: prune temp members from MergeData, there was no caching

Steve Borho steve at borho.org
Wed Feb 25 03:17:44 CET 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1424804799 21600
#      Tue Feb 24 13:06:39 2015 -0600
# Node ID ad0de20884e0188c3634c4338e2afa5489963a65
# Parent  1880722d4edde648f753cd83ff597d8254e8df59
search: prune temp members from MergeData, there was no caching

Each PU had to generate its own list of merge candidates, so they might as well
be declared on the stack

diff -r 1880722d4edd -r ad0de20884e0 source/encoder/search.cpp
--- a/source/encoder/search.cpp	Tue Feb 24 12:57:26 2015 -0600
+++ b/source/encoder/search.cpp	Tue Feb 24 13:06:39 2015 -0600
@@ -1811,17 +1811,19 @@
 {
     X265_CHECK(cu.m_partSize[0] != SIZE_2Nx2N, "mergeEstimation() called for 2Nx2N\n");
 
-    m.maxNumMergeCand = cu.getInterMergeCandidates(pu.puAbsPartIdx, puIdx, m.mvFieldNeighbours, m.interDirNeighbours);
+    MVField  candMvField[MRG_MAX_NUM_CANDS][2];
+    uint8_t  candDir[MRG_MAX_NUM_CANDS];
+    uint32_t maxNumMergeCand = cu.getInterMergeCandidates(pu.puAbsPartIdx, puIdx, candMvField, candDir);
 
     if (cu.isBipredRestriction())
     {
         /* do not allow bidir merge candidates if PU is smaller than 8x8, drop L1 reference */
-        for (uint32_t mergeCand = 0; mergeCand < m.maxNumMergeCand; ++mergeCand)
+        for (uint32_t mergeCand = 0; mergeCand < maxNumMergeCand; ++mergeCand)
         {
-            if (m.interDirNeighbours[mergeCand] == 3)
+            if (candDir[mergeCand] == 3)
             {
-                m.interDirNeighbours[mergeCand] = 1;
-                m.mvFieldNeighbours[mergeCand][1].refIdx = REF_NOT_VALID;
+                candDir[mergeCand] = 1;
+                candMvField[mergeCand][1].refIdx = REF_NOT_VALID;
             }
         }
     }
@@ -1829,18 +1831,18 @@
     Yuv& tempYuv = m_rqt[cuGeom.depth].tmpPredYuv;
 
     uint32_t outCost = MAX_UINT;
-    for (uint32_t mergeCand = 0; mergeCand < m.maxNumMergeCand; ++mergeCand)
+    for (uint32_t mergeCand = 0; mergeCand < maxNumMergeCand; ++mergeCand)
     {
         /* Prevent TMVP candidates from using unavailable reference pixels */
         if (m_bFrameParallel &&
-            (m.mvFieldNeighbours[mergeCand][0].mv.y >= (m_param->searchRange + 1) * 4 ||
-             m.mvFieldNeighbours[mergeCand][1].mv.y >= (m_param->searchRange + 1) * 4))
+            (candMvField[mergeCand][0].mv.y >= (m_param->searchRange + 1) * 4 ||
+             candMvField[mergeCand][1].mv.y >= (m_param->searchRange + 1) * 4))
             continue;
 
-        cu.m_mv[0][pu.puAbsPartIdx] = m.mvFieldNeighbours[mergeCand][0].mv;
-        cu.m_refIdx[0][pu.puAbsPartIdx] = (int8_t)m.mvFieldNeighbours[mergeCand][0].refIdx;
-        cu.m_mv[1][pu.puAbsPartIdx] = m.mvFieldNeighbours[mergeCand][1].mv;
-        cu.m_refIdx[1][pu.puAbsPartIdx] = (int8_t)m.mvFieldNeighbours[mergeCand][1].refIdx;
+        cu.m_mv[0][pu.puAbsPartIdx] = candMvField[mergeCand][0].mv;
+        cu.m_refIdx[0][pu.puAbsPartIdx] = (int8_t)candMvField[mergeCand][0].refIdx;
+        cu.m_mv[1][pu.puAbsPartIdx] = candMvField[mergeCand][1].mv;
+        cu.m_refIdx[1][pu.puAbsPartIdx] = (int8_t)candMvField[mergeCand][1].refIdx;
 
         motionCompensation(cu, pu, tempYuv, true, m_me.bChromaSATD);
 
@@ -1848,7 +1850,7 @@
         if (m_me.bChromaSATD)
             costCand += m_me.bufChromaSATD(tempYuv, pu.puAbsPartIdx);
 
-        uint32_t bitsCand = getTUBits(mergeCand, m.maxNumMergeCand);
+        uint32_t bitsCand = getTUBits(mergeCand, maxNumMergeCand);
         costCand = costCand + m_rdCost.getCost(bitsCand);
         if (costCand < outCost)
         {
@@ -1858,9 +1860,9 @@
         }
     }
 
-    m.mvField[0] = m.mvFieldNeighbours[m.index][0];
-    m.mvField[1] = m.mvFieldNeighbours[m.index][1];
-    m.interDir = m.interDirNeighbours[m.index];
+    m.mvField[0] = candMvField[m.index][0];
+    m.mvField[1] = candMvField[m.index][1];
+    m.interDir = candDir[m.index];
 
     return outCost;
 }
diff -r 1880722d4edd -r ad0de20884e0 source/encoder/search.h
--- a/source/encoder/search.h	Tue Feb 24 12:57:26 2015 -0600
+++ b/source/encoder/search.h	Tue Feb 24 13:06:39 2015 -0600
@@ -350,11 +350,6 @@
 
     struct MergeData
     {
-        /* merge candidate data, cached between calls to mergeEstimation */
-        MVField  mvFieldNeighbours[MRG_MAX_NUM_CANDS][2];
-        uint8_t  interDirNeighbours[MRG_MAX_NUM_CANDS];
-        uint32_t maxNumMergeCand;
-
         /* outputs */
         MVField  mvField[2];
         uint32_t interDir;


More information about the x265-devel mailing list