[x265] [PATCH] slicetype: select best mvp using neighbor mv's satd cost for Lowres ME

gopu at multicorewareinc.com gopu at multicorewareinc.com
Tue Apr 21 10:27:17 CEST 2015


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1429603596 -19800
#      Tue Apr 21 13:36:36 2015 +0530
# Node ID 2f5c607a5608a0aed7ea226dee8580846225c45d
# Parent  5c3443546cccea47316d59dbc4f892e1b6f8b1b5
slicetype: select best mvp using neighbor mv's satd cost for Lowres ME

This patch [CHANGES OUTPUT], modified the lowres mvp selection logic, the Lowres
mvp selected based on the four neighbor mv's satd cost insted of the medien
operation

diff -r 5c3443546ccc -r 2f5c607a5608 source/encoder/motion.h
--- a/source/encoder/motion.h	Sat Apr 18 10:02:19 2015 -0700
+++ b/source/encoder/motion.h	Tue Apr 21 13:36:36 2015 +0530
@@ -37,8 +37,6 @@
 {
 protected:
 
-    intptr_t blockOffset;
-    
     int ctuAddr;
     int absPartIdx;  // part index of PU, including CU offset within CTU
 
@@ -48,18 +46,19 @@
     int blockwidth;
     int blockheight;
 
+    MotionEstimate& operator =(const MotionEstimate&);
+
+public:
+
+    static const int COST_MAX = 1 << 28;
+
     pixelcmp_t sad;
     pixelcmp_x3_t sad_x3;
     pixelcmp_x4_t sad_x4;
     pixelcmp_t satd;
     pixelcmp_t chromaSatd;
 
-    MotionEstimate& operator =(const MotionEstimate&);
-
-public:
-
-    static const int COST_MAX = 1 << 28;
-
+    intptr_t blockOffset;
     Yuv fencPUYuv;
     int partEnum;
     bool bChromaSATD;
diff -r 5c3443546ccc -r 2f5c607a5608 source/encoder/slicetype.cpp
--- a/source/encoder/slicetype.cpp	Sat Apr 18 10:02:19 2015 -0700
+++ b/source/encoder/slicetype.cpp	Tue Apr 21 13:36:36 2015 +0530
@@ -44,23 +44,6 @@
 
 namespace {
 
-inline int16_t median(int16_t a, int16_t b, int16_t c)
-{
-    int16_t t = (a - b) & ((a - b) >> 31);
-
-    a -= t;
-    b += t;
-    b -= (b - c) & ((b - c) >> 31);
-    b += (a - b) & ((a - b) >> 31);
-    return b;
-}
-
-inline void median_mv(MV &dst, MV a, MV b, MV c)
-{
-    dst.x = median(a.x, b.x, c.x);
-    dst.y = median(a.y, b.y, c.y);
-}
-
 /* Compute variance to derive AC energy of each block */
 inline uint32_t acEnergyVar(Frame *curFrame, uint64_t sum_ssd, int shift, int plane)
 {
@@ -85,6 +68,22 @@
         return acEnergyVar(curFrame, primitives.cu[BLOCK_16x16].var(src, srcStride), 8, plane);
 }
 
+inline void mergeCostEstimate(ReferencePlanes *ref, MV &dst, MV *src, intptr_t blockOffset, Yuv fencPUYuv, pixelcmp_t satd)
+{
+    int bcost = MAX_UINT;
+    pixel* fenc = fencPUYuv.m_buf[0];
+
+    for (int16_t i = 0; i < 4; i++)
+    {
+        int cost = ref->lowresQPelCost(fenc, blockOffset, src[i], satd);
+        if (cost < bcost)
+        {
+            dst = src[i];
+            bcost = cost;
+        }
+    }
+}
+
 } // end anonymous namespace
 
 /* Find the total AC energy of each block in all planes */
@@ -2034,7 +2033,9 @@
 
         /* Reverse-order MV prediction */
         mvc[0] = 0;
+        mvc[1] = 0;
         mvc[2] = 0;
+        mvc[3] = 0;
 #define MVC(mv) mvc[numc++] = mv;
         if (cuX < widthInCU - 1)
             MVC(fencMV[1]);
@@ -2050,7 +2051,7 @@
         if (numc <= 1)
             mvp = mvc[0];
         else
-            median_mv(mvp, mvc[0], mvc[1], mvc[2]);
+            mergeCostEstimate(i ? fref1 : wfref0, mvp, mvc, tld.me.blockOffset, tld.me.fencPUYuv, tld.me.satd);
 
         fencCost = tld.me.motionEstimate(i ? fref1 : wfref0, mvmin, mvmax, mvp, numc, mvc, s_merange, *fencMV);
         COPY2_IF_LT(bcost, fencCost, listused, i + 1);


More information about the x265-devel mailing list