shithub: libvpx

Download patch

ref: aab2aff9aa264d573852f4dce34bea47708cf1be
parent: a0b2ff6644a237db1c558e87437864bb2332a4fc
parent: 763c9e08dd9fd7aa3acca3bf3a89a7c36d640050
author: Hui Su <huisu@google.com>
date: Tue Aug 7 19:38:37 EDT 2018

Merge "Add enhanced_full_pixel_motion_search feature"

--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2409,6 +2409,31 @@
       cpi, x, bsize, &mvp_full, step_param, cpi->sf.mv.search_method, sadpb,
       cond_cost_list(cpi, cost_list), &ref_mv, &tmp_mv->as_mv, INT_MAX, 1);
 
+  if (cpi->sf.enhanced_full_pixel_motion_search) {
+    if (x->mv_best_ref_index[ref] == 2) {
+      const int diff_row = ((int)pred_mv[0].row - pred_mv[2].row) >> 3;
+      const int diff_col = ((int)pred_mv[0].col - pred_mv[2].col) >> 3;
+      const int diff_sse = diff_row * diff_row + diff_col * diff_col;
+      // If pred_mv[0] and pred_mv[2] are very different, also search around
+      // pred_mv[0].
+      if (diff_sse > 10) {
+        int this_me;
+        MV this_mv;
+        mvp_full = pred_mv[0];
+        mvp_full.col >>= 3;
+        mvp_full.row >>= 3;
+        this_me = vp9_full_pixel_search(cpi, x, bsize, &mvp_full, step_param,
+                                        cpi->sf.mv.search_method, sadpb,
+                                        cond_cost_list(cpi, cost_list), &ref_mv,
+                                        &this_mv, INT_MAX, 1);
+        if (this_me < bestsme) {
+          tmp_mv->as_mv = this_mv;
+          bestsme = this_me;
+        }
+      }
+    }
+  }
+
   x->mv_limits = tmp_mv_limits;
 
   if (bestsme < INT_MAX) {
--- a/vp9/encoder/vp9_speed_features.c
+++ b/vp9/encoder/vp9_speed_features.c
@@ -277,6 +277,7 @@
     sf->auto_min_max_partition_size = RELAXED_NEIGHBORING_MIN_MAX;
     sf->recode_tolerance_low = 15;
     sf->recode_tolerance_high = 45;
+    sf->enhanced_full_pixel_motion_search = 0;
 
     if (cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) {
       for (i = 0; i < MAX_MESH_STEP; ++i) {
@@ -408,6 +409,7 @@
   sf->disable_16x16part_nonkey = 0;
   sf->disable_golden_ref = 0;
   sf->enable_tpl_model = 0;
+  sf->enhanced_full_pixel_motion_search = 0;
 
   if (speed >= 1) {
     sf->allow_txfm_domain_distortion = 1;
@@ -817,6 +819,7 @@
   sf->tx_size_search_method = USE_FULL_RD;
   sf->use_lp32x32fdct = 0;
   sf->adaptive_motion_search = 0;
+  sf->enhanced_full_pixel_motion_search = 1;
   sf->adaptive_pred_interp_filter = 0;
   sf->adaptive_mode_search = 0;
   sf->cb_pred_filter_search = 0;
--- a/vp9/encoder/vp9_speed_features.h
+++ b/vp9/encoder/vp9_speed_features.h
@@ -353,6 +353,9 @@
   // point for this motion search and limits the search range around it.
   int adaptive_motion_search;
 
+  // Do extra full pixel motion search to obtain better motion vector.
+  int enhanced_full_pixel_motion_search;
+
   // Threshold for allowing exhaistive motion search.
   int exhaustive_searches_thresh;