shithub: libvpx

Download patch

ref: 06e4f825af0a2dfe799364a50c19dfa2654437ad
parent: 16f5607dfef1041e507a7f755a1f937b7cd52242
author: Jingning Han <jingning@google.com>
date: Tue Jan 7 04:53:38 EST 2014

Fix an issue in motion vector prediction stage

The previous implementation stops motion vector prediction test when
the zero motion vector appears for the second time. This commit fixes
it by simply skipping the second time check on zero mv and continuing
on to next mv candidate.

It slightly improves stdhd in speed 2 by 0.06% on average. Most static
sequences are not affected. A few hard ones, like jet, ped, and riverbed
were improved by 0.1 - 0.2%.

Change-Id: Ia8d4e2ffb7136669e8ad1fb24ea6e8fdd6b9a3c1

--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -585,7 +585,6 @@
                                  SPEED_FEATURES *sf,
                                  int speed) {
   sf->static_segmentation = 0;
-  sf->use_avoid_tested_higherror = 1;
   sf->adaptive_rd_thresh = 1;
   sf->recode_loop = (speed < 1);
   if (speed >= 1) {
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2119,16 +2119,20 @@
                      cpi->common.show_frame &&
                      block_size < cpi->sf.max_partition_size);
 
+  int_mv pred_mv[3] = {
+      mbmi->ref_mvs[ref_frame][0], mbmi->ref_mvs[ref_frame][1],
+      x->pred_mv[ref_frame]
+  };
+
   // Get the sad for each candidate reference mv
   for (i = 0; i < num_mv_refs; i++) {
-    this_mv.as_int = (i < MAX_MV_REF_CANDIDATES) ?
-        mbmi->ref_mvs[ref_frame][i].as_int : x->pred_mv[ref_frame].as_int;
+    this_mv.as_int = pred_mv[i].as_int;
 
     max_mv = MAX(max_mv,
                  MAX(abs(this_mv.as_mv.row), abs(this_mv.as_mv.col)) >> 3);
-    // The list is at an end if we see 0 for a second time.
+    // only need to check zero mv once
     if (!this_mv.as_int && zero_seen)
-      break;
+      continue;
     zero_seen = zero_seen || !this_mv.as_int;
 
     row_offset = this_mv.as_mv.row >> 3;
@@ -2346,6 +2350,10 @@
 
   YV12_BUFFER_CONFIG *scaled_ref_frame = get_scaled_ref_frame(cpi, ref);
 
+  int_mv pred_mv[3] = {
+      mbmi->ref_mvs[ref][0], mbmi->ref_mvs[ref][1], x->pred_mv[ref]
+  };
+
   if (scaled_ref_frame) {
     int i;
     // Swap out the reference frame for a version that's been scaled to
@@ -2410,9 +2418,7 @@
     }
   }
 
-  mvp_full = x->mv_best_ref_index[ref] < MAX_MV_REF_CANDIDATES
-      ? mbmi->ref_mvs[ref][x->mv_best_ref_index[ref]].as_mv
-      : x->pred_mv[ref].as_mv;
+  mvp_full = pred_mv[x->mv_best_ref_index[ref]].as_mv;
 
   mvp_full.col >>= 3;
   mvp_full.row >>= 3;
--