shithub: libvpx

Download patch

ref: 4f5815290cbbdf001c98d26c3218a7e70a9aa3b1
parent: ced3c20165a06e70b546aca3c98a2a71a1f9387f
parent: deb7456058ef7f8fb7c352e3812409dd32f20d4c
author: Ronald S. Bultje <[email protected]>
date: Thu Jul 18 06:06:51 EDT 2013

Merge "Fix bug which skips zeromv even if near/nearest is not 0,0."

--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1875,15 +1875,28 @@
           int c3 = cost_mv_ref(cpi, ZEROMV, rfc);
 
           if (this_mode == NEARMV) {
-            if (c1 >= c2 || c1 > c3)
+            if (c1 > c3)
               continue;
           } else if (this_mode == NEARESTMV) {
-            if (c2 > c1 || c2 > c3)
+            if (c2 > c3)
               continue;
           } else {
             assert(this_mode == ZEROMV);
-            if (c3 >= c2 || c3 >= c1)
-              continue;
+            if (mbmi->ref_frame[1] <= 0) {
+              if ((c3 >= c2 &&
+                   frame_mv[NEARESTMV][mbmi->ref_frame[0]].as_int == 0) ||
+                  (c3 >= c1 &&
+                   frame_mv[NEARMV][mbmi->ref_frame[0]].as_int == 0))
+                continue;
+            } else {
+              if ((c3 >= c2 &&
+                   frame_mv[NEARESTMV][mbmi->ref_frame[0]].as_int == 0 &&
+                   frame_mv[NEARESTMV][mbmi->ref_frame[1]].as_int == 0) ||
+                  (c3 >= c1 &&
+                   frame_mv[NEARMV][mbmi->ref_frame[0]].as_int == 0 &&
+                   frame_mv[NEARMV][mbmi->ref_frame[1]].as_int == 0))
+                continue;
+            }
           }
         }
 
@@ -2719,15 +2732,28 @@
     int c3 = cost_mv_ref(cpi, ZEROMV, rfc);
 
     if (this_mode == NEARMV) {
-      if (c1 >= c2 || c1 > c3)
+      if (c1 > c3)
         return INT64_MAX;
     } else if (this_mode == NEARESTMV) {
-      if (c2 > c1 || c2 > c3)
+      if (c2 > c3)
         return INT64_MAX;
     } else {
       assert(this_mode == ZEROMV);
-      if (c3 >= c2 || c3 >= c1)
-        return INT64_MAX;
+      if (num_refs == 1) {
+        if ((c3 >= c2 &&
+             mode_mv[NEARESTMV][mbmi->ref_frame[0]].as_int == 0) ||
+            (c3 >= c1 &&
+             mode_mv[NEARMV][mbmi->ref_frame[0]].as_int == 0))
+          return INT64_MAX;
+      } else {
+        if ((c3 >= c2 &&
+             mode_mv[NEARESTMV][mbmi->ref_frame[0]].as_int == 0 &&
+             mode_mv[NEARESTMV][mbmi->ref_frame[1]].as_int == 0) ||
+            (c3 >= c1 &&
+             mode_mv[NEARMV][mbmi->ref_frame[0]].as_int == 0 &&
+             mode_mv[NEARMV][mbmi->ref_frame[1]].as_int == 0))
+          return INT64_MAX;
+      }
     }
   }