Change the interface of vp9_full_pixel_diamond_new
authorAngie Chiang <angiebird@google.com>
Thu, 29 Nov 2018 22:54:17 +0000 (14:54 -0800)
committerAngie Chiang <angiebird@google.com>
Fri, 30 Nov 2018 01:06:30 +0000 (17:06 -0800)
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

vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_mcomp.c
vp9/encoder/vp9_mcomp.h

index 41f9419..04d2524 100644 (file)
@@ -5660,10 +5660,10 @@ uint32_t motion_compensated_prediction(VP9_COMP *cpi, ThreadData *td,
   (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;
index a254303..235f034 100644 (file)
@@ -2240,24 +2240,18 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
               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 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
     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 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
 
       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 @@ double vp9_full_pixel_diamond_new(const VP9_COMP *cpi, MACROBLOCK *x,
   // 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;
index a159cb2..54f68ca 100644 (file)
@@ -130,10 +130,10 @@ double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
 
 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