[x265] [PATCH] search: use selectMVP() helper function for --pme

Steve Borho steve at borho.org
Fri May 1 20:00:53 CEST 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1430501649 18000
#      Fri May 01 12:34:09 2015 -0500
# Node ID 67dac0db55e73909c8d670298705de53de563608
# Parent  3ded3f46b20791dab6322f359827d47b9e5237b1
search: use selectMVP() helper function for --pme

addresses an oversight in acf4ede2ca53

diff -r 3ded3f46b207 -r 67dac0db55e7 source/encoder/search.cpp
--- a/source/encoder/search.cpp	Wed Apr 29 19:40:08 2015 -0700
+++ b/source/encoder/search.cpp	Fri May 01 12:34:09 2015 -0500
@@ -1901,9 +1901,9 @@
     do
     {
         if (meId < m_slice->m_numRefIdx[0])
-            slave.singleMotionEstimation(*this, pme.mode, pme.cuGeom, pme.pu, pme.puIdx, 0, meId);
+            slave.singleMotionEstimation(*this, pme.mode, pme.pu, pme.puIdx, 0, meId);
         else
-            slave.singleMotionEstimation(*this, pme.mode, pme.cuGeom, pme.pu, pme.puIdx, 1, meId - m_slice->m_numRefIdx[0]);
+            slave.singleMotionEstimation(*this, pme.mode, pme.pu, pme.puIdx, 1, meId - m_slice->m_numRefIdx[0]);
 
         meId = -1;
         pme.m_lock.acquire();
@@ -1914,49 +1914,23 @@
     while (meId >= 0);
 }
 
-void Search::singleMotionEstimation(Search& master, Mode& interMode, const CUGeom& cuGeom, const PredictionUnit& pu,
-                                    int part, int list, int ref)
+void Search::singleMotionEstimation(Search& master, Mode& interMode, const PredictionUnit& pu, int part, int list, int ref)
 {
     uint32_t bits = master.m_listSelBits[list] + MVP_IDX_BITS;
     bits += getTUBits(ref, m_slice->m_numRefIdx[list]);
 
-    MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 1];
+    MotionData* bestME = interMode.bestME[part];
+
+    MV  mvc[(MD_ABOVE_LEFT + 1) * 2 + 1];
     int numMvc = interMode.cu.getPMV(interMode.interNeighbours, list, ref, interMode.amvpCand[list][ref], mvc);
 
-    int merange = m_param->searchRange;
-    MotionData* bestME = interMode.bestME[part];
     const MV* amvp = interMode.amvpCand[list][ref];
-    int mvpIdx = 0;
-
-    if (amvp[0] != amvp[1])
-    {
-        uint32_t bestCost = MAX_INT;
-        for (int i = 0; i < AMVP_NUM_CANDS; i++)
-        {
-            MV mvCand = amvp[i];
-
-            // NOTE: skip mvCand if Y is > merange and -FN>1
-            if (m_bFrameParallel && (mvCand.y >= (merange + 1) * 4))
-                continue;
-
-            interMode.cu.clipMv(mvCand);
-
-            Yuv& tmpPredYuv = m_rqt[cuGeom.depth].tmpPredYuv;
-            predInterLumaPixel(pu, tmpPredYuv, *m_slice->m_refPicList[list][ref]->m_reconPic, mvCand);
-            uint32_t cost = m_me.bufSAD(tmpPredYuv.getLumaAddr(pu.puAbsPartIdx), tmpPredYuv.m_size);
-
-            if (bestCost > cost)
-            {
-                bestCost = cost;
-                mvpIdx = i;
-            }
-        }
-    }
-
+    int mvpIdx = selectMVP(interMode.cu, pu, amvp, list, ref);
     MV mvmin, mvmax, outmv, mvp = amvp[mvpIdx];
-    setSearchRange(interMode.cu, mvp, merange, mvmin, mvmax);
-
-    int satdCost = m_me.motionEstimate(&m_slice->m_mref[list][ref], mvmin, mvmax, mvp, numMvc, mvc, merange, outmv);
+
+    setSearchRange(interMode.cu, mvp, m_param->searchRange, mvmin, mvmax);
+
+    int satdCost = m_me.motionEstimate(&m_slice->m_mref[list][ref], mvmin, mvmax, mvp, numMvc, mvc, m_param->searchRange, outmv);
 
     /* Get total cost of partition, but only include MV bit cost once */
     bits += m_me.bitcost(outmv);
@@ -2093,7 +2067,7 @@
             {
                 processPME(pme, *this);
 
-                singleMotionEstimation(*this, interMode, cuGeom, pu, puIdx, 0, 0); /* L0-0 */
+                singleMotionEstimation(*this, interMode, pu, puIdx, 0, 0); /* L0-0 */
 
                 bDoUnidir = false;
 
diff -r 3ded3f46b207 -r 67dac0db55e7 source/encoder/search.h
--- a/source/encoder/search.h	Wed Apr 29 19:40:08 2015 -0700
+++ b/source/encoder/search.h	Fri May 01 12:34:09 2015 -0500
@@ -339,7 +339,7 @@
     };
 
     void     processPME(PME& pme, Search& slave);
-    void     singleMotionEstimation(Search& master, Mode& interMode, const CUGeom& cuGeom, const PredictionUnit& pu, int part, int list, int ref);
+    void     singleMotionEstimation(Search& master, Mode& interMode, const PredictionUnit& pu, int part, int list, int ref);
 
 protected:
 


More information about the x265-devel mailing list