shithub: libvpx

Download patch

ref: 5a0d53a031eff97f893c8d77e63b65008c22f37e
parent: 932f8fa04dc15f4adf16df37402556e8c4dc72e7
author: Angie Chiang <angiebird@google.com>
date: Thu Nov 29 09:54:17 EST 2018

Change the interface of vp9_full_pixel_diamond_new

Avoid passing in tpl_stats because this function will be called in
motion search, where tpl_stats should be fixed at the point.

Let further_steps becomes internal variable in the function.

Change-Id: Iebe380925eb1891c19e0b78163dab8e6bfafccdb

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5660,10 +5660,10 @@
   (void)sadpb;
   prepare_nb_full_mvs(&cpi->tpl_stats[frame_idx], mi_row, mi_col, rf_idx, bsize,
                       nb_full_mvs);
-  vp9_full_pixel_diamond_new(cpi, x, &best_ref_mv1_full, step_param, lambda,
-                             MAX_MVSEARCH_STEPS - 1 - step_param, 1,
-                             &cpi->fn_ptr[bsize], nb_full_mvs, tpl_stats,
-                             rf_idx);
+  vp9_full_pixel_diamond_new(
+      cpi, x, &best_ref_mv1_full, step_param, lambda, 1, &cpi->fn_ptr[bsize],
+      nb_full_mvs, &tpl_stats->mv_arr[rf_idx].as_mv,
+      &tpl_stats->mv_dist[rf_idx], &tpl_stats->mv_cost[rf_idx]);
 #else
   (void)frame_idx;
   (void)mi_row;
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -2240,24 +2240,18 @@
               refining search  */
 double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
                                   MV *mvp_full, int step_param, double lambda,
-                                  int further_steps, int do_refine,
+                                  int do_refine,
                                   const vp9_variance_fn_ptr_t *fn_ptr,
-                                  const int_mv *nb_full_mvs,
-                                  TplDepStats *tpl_stats, int rf_idx) {
-  MV *dst_mv = &tpl_stats->mv_arr[rf_idx].as_mv;
-  MV temp_mv;
+                                  const int_mv *nb_full_mvs, MV *best_mv,
+                                  double *best_mv_dist, double *best_mv_cost) {
   int n, num00 = 0;
   double thissme;
-  double mv_dist;
-  double mv_cost;
   double bestsme;
+  const int further_steps = MAX_MVSEARCH_STEPS - 1 - step_param;
   vpx_clear_system_state();
-  bestsme = vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
-                                       &mv_dist, &mv_cost, step_param, lambda,
-                                       &n, fn_ptr, nb_full_mvs);
-  *dst_mv = temp_mv;
-  tpl_stats->mv_dist[rf_idx] = mv_dist;
-  tpl_stats->mv_cost[rf_idx] = mv_cost;
+  bestsme = vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, best_mv,
+                                       best_mv_dist, best_mv_cost, step_param,
+                                       lambda, &n, fn_ptr, nb_full_mvs);
 
   // If there won't be more n-step search, check to see if refining search is
   // needed.
@@ -2268,6 +2262,9 @@
     if (num00) {
       num00--;
     } else {
+      MV temp_mv;
+      double mv_dist;
+      double mv_cost;
       thissme = vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
                                            &mv_dist, &mv_cost, step_param + n,
                                            lambda, &num00, fn_ptr, nb_full_mvs);
@@ -2276,9 +2273,9 @@
 
       if (thissme < bestsme) {
         bestsme = thissme;
-        *dst_mv = temp_mv;
-        tpl_stats->mv_dist[rf_idx] = mv_dist;
-        tpl_stats->mv_cost[rf_idx] = mv_cost;
+        *best_mv = temp_mv;
+        *best_mv_dist = mv_dist;
+        *best_mv_cost = mv_cost;
       }
     }
   }
@@ -2286,15 +2283,17 @@
   // final 1-away diamond refining search
   if (do_refine) {
     const int search_range = 8;
-    MV best_mv = *dst_mv;
+    MV temp_mv = *best_mv;
+    double mv_dist;
+    double mv_cost;
     thissme =
-        vp9_refining_search_sad_new(x, &best_mv, &mv_dist, &mv_cost, lambda,
+        vp9_refining_search_sad_new(x, &temp_mv, &mv_dist, &mv_cost, lambda,
                                     search_range, fn_ptr, nb_full_mvs);
     if (thissme < bestsme) {
       bestsme = thissme;
-      *dst_mv = best_mv;
-      tpl_stats->mv_dist[rf_idx] = mv_dist;
-      tpl_stats->mv_cost[rf_idx] = mv_cost;
+      *best_mv = temp_mv;
+      *best_mv_dist = mv_dist;
+      *best_mv_cost = mv_cost;
     }
   }
   return bestsme;
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -130,10 +130,10 @@
 
 double vp9_full_pixel_diamond_new(const struct VP9_COMP *cpi, MACROBLOCK *x,
                                   MV *mvp_full, int step_param, double lambda,
-                                  int further_steps, int do_refine,
+                                  int do_refine,
                                   const vp9_variance_fn_ptr_t *fn_ptr,
-                                  const int_mv *nb_full_mvs,
-                                  struct TplDepStats *tpl_stats, int rf_idx);
+                                  const int_mv *nb_full_mvs, MV *best_mv,
+                                  double *best_mv_dist, double *best_mv_cost);
 
 double av1_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs);
 #endif  // CONFIG_NON_GREEDY_MV