shithub: libvpx

Download patch

ref: 30e7f9d856eb1cc6df895f6d9562493e04f6116d
parent: 1a363a8cae8539e82f44028548bb8c1a4ae6bd60
author: Angie Chiang <angiebird@google.com>
date: Tue Jun 25 11:43:43 EDT 2019

Remove mv_dist/mv_cost from new mv search funcs

The functions are
diamond_search_sad_new()
vp9_full_pixel_diamond_new()
vp9_refining_search_sad_new()

Change-Id: Ied6fe98b8a1401c95f0488faf781c5cd5e8e0db6

--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -5895,8 +5895,6 @@
   // TODO(angiebird): Figure out lambda's proper value.
   const int lambda = cpi->tpl_stats[frame_idx].lambda;
   int_mv nb_full_mvs[NB_MVS_NUM];
-  double mv_dist;
-  double mv_cost;
 #endif
 
   MV best_ref_mv1 = { 0, 0 };
@@ -5922,8 +5920,7 @@
   vp9_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, 1,
-                             &cpi->fn_ptr[bsize], nb_full_mvs, NB_MVS_NUM, mv,
-                             &mv_dist, &mv_cost);
+                             &cpi->fn_ptr[bsize], nb_full_mvs, NB_MVS_NUM, mv);
 #else
   (void)frame_idx;
   (void)mi_row;
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -2076,7 +2076,6 @@
 static double diamond_search_sad_new(const MACROBLOCK *x,
                                      const search_site_config *cfg,
                                      const MV *init_full_mv, MV *best_full_mv,
-                                     double *best_mv_dist, double *best_mv_cost,
                                      int search_param, int lambda, int *num00,
                                      const vp9_variance_fn_ptr_t *fn_ptr,
                                      const int_mv *nb_full_mvs,
@@ -2116,11 +2115,14 @@
   best_address = in_what;
 
   // Check the starting position
-  *best_mv_dist = fn_ptr->sdf(what, what_stride, in_what, in_what_stride);
-  *best_mv_cost =
-      vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num) /
-      (double)(1 << LOG2_PRECISION);
-  bestsad = (*best_mv_dist) + lambda * (*best_mv_cost);
+  {
+    const double mv_dist =
+        fn_ptr->sdf(what, what_stride, in_what, in_what_stride);
+    const double mv_cost =
+        vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num) /
+        (double)(1 << LOG2_PRECISION);
+    bestsad = mv_dist + lambda * mv_cost;
+  }
 
   i = 0;
 
@@ -2159,8 +2161,6 @@
             double thissad = mv_dist + lambda * mv_cost;
             if (thissad < bestsad) {
               bestsad = thissad;
-              *best_mv_dist = mv_dist;
-              *best_mv_cost = mv_cost;
               best_site = i;
             }
           }
@@ -2183,8 +2183,6 @@
             double thissad = mv_dist + lambda * mv_cost;
             if (thissad < bestsad) {
               bestsad = thissad;
-              *best_mv_dist = mv_dist;
-              *best_mv_cost = mv_cost;
               best_site = i;
             }
           }
@@ -2597,8 +2595,7 @@
                                   int do_refine,
                                   const vp9_variance_fn_ptr_t *fn_ptr,
                                   const int_mv *nb_full_mvs, int full_mv_num,
-                                  MV *best_mv, double *best_mv_dist,
-                                  double *best_mv_cost) {
+                                  MV *best_mv) {
   int n, num00 = 0;
   double thissme;
   double bestsme;
@@ -2605,9 +2602,9 @@
   const int further_steps = MAX_MVSEARCH_STEPS - 1 - step_param;
   const MV center_mv = { 0, 0 };
   vpx_clear_system_state();
-  bestsme = 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, full_mv_num);
+  bestsme =
+      diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, best_mv, step_param,
+                             lambda, &n, fn_ptr, nb_full_mvs, full_mv_num);
 
   bestsme = vp9_get_mvpred_var(x, best_mv, &center_mv, fn_ptr, 0);
 
@@ -2621,11 +2618,9 @@
       num00--;
     } else {
       MV temp_mv;
-      double mv_dist;
-      double mv_cost;
-      thissme = 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, full_mv_num);
+      thissme = diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
+                                       step_param + n, lambda, &num00, fn_ptr,
+                                       nb_full_mvs, full_mv_num);
       thissme = vp9_get_mvpred_var(x, &temp_mv, &center_mv, fn_ptr, 0);
       // check to see if refining search is needed.
       if (num00 > further_steps - n) do_refine = 0;
@@ -2633,8 +2628,6 @@
       if (thissme < bestsme) {
         bestsme = thissme;
         *best_mv = temp_mv;
-        *best_mv_dist = mv_dist;
-        *best_mv_cost = mv_cost;
       }
     }
   }
@@ -2643,17 +2636,12 @@
   if (do_refine) {
     const int search_range = 8;
     MV temp_mv = *best_mv;
-    double mv_dist;
-    double mv_cost;
-    thissme = vp9_refining_search_sad_new(x, &temp_mv, &mv_dist, &mv_cost,
-                                          lambda, search_range, fn_ptr,
-                                          nb_full_mvs, full_mv_num);
+    thissme = vp9_refining_search_sad_new(x, &temp_mv, lambda, search_range,
+                                          fn_ptr, nb_full_mvs, full_mv_num);
     thissme = vp9_get_mvpred_var(x, &temp_mv, &center_mv, fn_ptr, 0);
     if (thissme < bestsme) {
       bestsme = thissme;
       *best_mv = temp_mv;
-      *best_mv_dist = mv_dist;
-      *best_mv_cost = mv_cost;
     }
   }
 
@@ -2787,7 +2775,6 @@
 
 #if CONFIG_NON_GREEDY_MV
 double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
-                                   double *best_mv_dist, double *best_mv_cost,
                                    int lambda, int search_range,
                                    const vp9_variance_fn_ptr_t *fn_ptr,
                                    const int_mv *nb_full_mvs, int full_mv_num) {
@@ -2799,12 +2786,14 @@
   double best_sad;
   int i, j;
   vpx_clear_system_state();
-  *best_mv_dist =
-      fn_ptr->sdf(what->buf, what->stride, best_address, in_what->stride);
-  *best_mv_cost =
-      vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num) /
-      (double)(1 << LOG2_PRECISION);
-  best_sad = (*best_mv_dist) + lambda * (*best_mv_cost);
+  {
+    const double mv_dist =
+        fn_ptr->sdf(what->buf, what->stride, best_address, in_what->stride);
+    const double mv_cost =
+        vp9_nb_mvs_inconsistency(best_full_mv, nb_full_mvs, full_mv_num) /
+        (double)(1 << LOG2_PRECISION);
+    best_sad = mv_dist + lambda * mv_cost;
+  }
 
   for (i = 0; i < search_range; i++) {
     int best_site = -1;
@@ -2831,8 +2820,6 @@
         const double thissad = mv_dist + lambda * mv_cost;
         if (thissad < best_sad) {
           best_sad = thissad;
-          *best_mv_dist = mv_dist;
-          *best_mv_cost = mv_cost;
           best_site = j;
         }
       }
@@ -2851,8 +2838,6 @@
           const double thissad = mv_dist + lambda * mv_cost;
           if (thissad < best_sad) {
             best_sad = thissad;
-            *best_mv_dist = mv_dist;
-            *best_mv_cost = mv_cost;
             best_site = j;
           }
         }
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -129,7 +129,6 @@
 #define NB_MVS_NUM 4
 struct TplDepStats;
 double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
-                                   double *best_mv_dist, double *best_mv_cost,
                                    int lambda, int search_range,
                                    const vp9_variance_fn_ptr_t *fn_ptr,
                                    const int_mv *nb_full_mvs, int full_mv_num);
@@ -139,8 +138,7 @@
                                   int do_refine,
                                   const vp9_variance_fn_ptr_t *fn_ptr,
                                   const int_mv *nb_full_mvs, int full_mv_num,
-                                  MV *best_mv, double *best_mv_dist,
-                                  double *best_mv_cost);
+                                  MV *best_mv);
 
 int64_t vp9_nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
                                  int mv_num);
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2495,8 +2495,6 @@
   MV pred_mv[3];
 
 #if CONFIG_NON_GREEDY_MV
-  double mv_dist = 0;
-  double mv_cost = 0;
   double bestsme;
   int_mv nb_full_mvs[NB_MVS_NUM];
   const int nb_full_mv_num = NB_MVS_NUM;
@@ -2582,9 +2580,9 @@
   mvp_full.row >>= 3;
 
 #if CONFIG_NON_GREEDY_MV
-  bestsme = vp9_full_pixel_diamond_new(
-      cpi, x, &mvp_full, step_param, lambda, 1, &cpi->fn_ptr[bsize],
-      nb_full_mvs, nb_full_mv_num, &tmp_mv->as_mv, &mv_dist, &mv_cost);
+  bestsme = vp9_full_pixel_diamond_new(cpi, x, &mvp_full, step_param, lambda, 1,
+                                       &cpi->fn_ptr[bsize], nb_full_mvs,
+                                       nb_full_mv_num, &tmp_mv->as_mv);
 #else   // CONFIG_NON_GREEDY_MV
   bestsme = vp9_full_pixel_search(
       cpi, x, bsize, &mvp_full, step_param, cpi->sf.mv.search_method, sadpb,
@@ -2625,8 +2623,8 @@
 #if CONFIG_NON_GREEDY_MV
       this_me = vp9_full_pixel_diamond_new(
           cpi, x, &mvp_full, VPXMAX(step_param, MAX_MVSEARCH_STEPS - step),
-          lambda, 1, &cpi->fn_ptr[bsize], nb_full_mvs, nb_full_mv_num, &this_mv,
-          &mv_dist, &mv_cost);
+          lambda, 1, &cpi->fn_ptr[bsize], nb_full_mvs, nb_full_mv_num,
+          &this_mv);
 #else   // CONFIG_NON_GREEDY_MV
       this_me = vp9_full_pixel_search(
           cpi, x, bsize, &mvp_full,