[x265] [PATCH 1 of 3] improve motionEstimate() by bypass reduce MV Candidate

Min Chen chenm003 at 163.com
Thu Aug 27 02:13:08 CEST 2015


# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1440632250 25200
# Node ID be9fbc8bf0d5e57949367293035d047d6a7d9da8
# Parent  d8091487bc9749e702c468786b0cd9e663478a91
improve motionEstimate() by bypass reduce MV Candidate
---
 source/common/mv.h        |    2 ++
 source/encoder/motion.cpp |   11 ++++++++++-
 2 files changed, 12 insertions(+), 1 deletions(-)

diff -r d8091487bc97 -r be9fbc8bf0d5 source/common/mv.h
--- a/source/common/mv.h	Tue Aug 25 16:39:12 2015 -0700
+++ b/source/common/mv.h	Wed Aug 26 16:37:30 2015 -0700
@@ -79,6 +79,8 @@
 
     bool operator !() const                    { return !word; }
 
+    MV operator ~() const                    { return ~word; }
+
     // Scale down a QPEL mv to FPEL mv, rounding up by one HPEL offset
     MV roundToFPel() const                     { return MV((x + 2) >> 2, (y + 2) >> 2); }
 
diff -r d8091487bc97 -r be9fbc8bf0d5 source/encoder/motion.cpp
--- a/source/encoder/motion.cpp	Tue Aug 25 16:39:12 2015 -0700
+++ b/source/encoder/motion.cpp	Wed Aug 26 16:37:30 2015 -0700
@@ -621,10 +621,19 @@
         }
     }
 
-    X265_CHECK(!(ref->isLowres && numCandidates), "lowres motion candidates not allowed\n")
+    X265_CHECK(!(ref->isLowres && numCandidates), "lowres motion candidates not allowed\n");
+
     // measure SAD cost at each QPEL motion vector candidate
+    MV prevMV;
+    if (numCandidates)
+        prevMV = ~mvc[0];
     for (int i = 0; i < numCandidates; i++)
     {
+        // Bypass duplicated mvc, it isn't a good way but simplest. Prepare to sort input mvc list will give us less candidate
+        if (prevMV == mvc[i])
+            continue;
+        prevMV = mvc[i];
+
         MV m = mvc[i].clipped(qmvmin, qmvmax);
         if (m.notZero() & (m != pmv ? 1 : 0) & (m != bestpre ? 1 : 0)) // check already measured
         {



More information about the x265-devel mailing list