]> granicus.if.org Git - libvpx/commitdiff
Add vp9_full_pixel_diamond_new
authorAngie Chiang <angiebird@google.com>
Tue, 25 Sep 2018 22:26:33 +0000 (15:26 -0700)
committerAngie Chiang <angiebird@google.com>
Wed, 26 Sep 2018 00:05:06 +0000 (17:05 -0700)
This function will call vp9_diaomond_search_sad_new /
vp9_refining_search_sad_new accordingly.

Change-Id: If96a8a1c9c06b6b4ed3aac6d59bdb03f20c96df9

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

index c7ec149d3e1dd93626cddf3898850bd30237cb7f..97ec5e06ebda11350feb16e9ba8ccb46586788f5 100644 (file)
@@ -1578,8 +1578,6 @@ static int exhuastive_mesh_search(const MACROBLOCK *x, MV *ref_mv, MV *best_mv,
 }
 
 #if CONFIG_NON_GREEDY_MV
-#define NB_MVS_NUM 4
-
 static double nb_mvs_inconsistency(const MV *mv, const int_mv *nb_mvs,
                                    double lambda) {
   int i;
@@ -2078,6 +2076,61 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
   return best_sad;
 }
 
+#if CONFIG_NON_GREEDY_MV
+// Runs sequence of diamond searches in smaller steps for RD.
+/* do_refine: If last step (1-away) of n-step search doesn't pick the center
+              point as the best match, we will do a final 1-away diamond
+              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,
+                                  const vp9_variance_fn_ptr_t *fn_ptr,
+                                  const int_mv *nb_full_mvs, MV *dst_mv) {
+  MV temp_mv;
+  int n, num00 = 0;
+  double thissme;
+  double bestsme =
+      vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
+                                 step_param, lambda, &n, fn_ptr, nb_full_mvs);
+  *dst_mv = temp_mv;
+
+  // If there won't be more n-step search, check to see if refining search is
+  // needed.
+  if (n > further_steps) do_refine = 0;
+
+  while (n < further_steps) {
+    ++n;
+    if (num00) {
+      num00--;
+    } else {
+      thissme = vp9_diamond_search_sad_new(x, &cpi->ss_cfg, mvp_full, &temp_mv,
+                                           step_param + n, lambda, &num00,
+                                           fn_ptr, nb_full_mvs);
+      // check to see if refining search is needed.
+      if (num00 > further_steps - n) do_refine = 0;
+
+      if (thissme < bestsme) {
+        bestsme = thissme;
+        *dst_mv = temp_mv;
+      }
+    }
+  }
+
+  // final 1-away diamond refining search
+  if (do_refine) {
+    const int search_range = 8;
+    MV best_mv = *dst_mv;
+    thissme = vp9_refining_search_sad_new(x, &best_mv, lambda, search_range,
+                                          fn_ptr, nb_full_mvs);
+    if (thissme < bestsme) {
+      bestsme = thissme;
+      *dst_mv = best_mv;
+    }
+  }
+  return bestsme;
+}
+#endif  // CONFIG_NON_GREEDY_MV
+
 // Runs sequence of diamond searches in smaller steps for RD.
 /* do_refine: If last step (1-away) of n-step search doesn't pick the center
               point as the best match, we will do a final 1-away diamond
index 348db061944829e3bd07caba9689ea9a87d6e37a..46dd551298c2ac1f082af297b6afcb3f75e0ec43 100644 (file)
@@ -119,6 +119,19 @@ void vp9_set_subpel_mv_search_range(MvLimits *subpel_mv_limits,
                                     const MvLimits *umv_window_limits,
                                     const MV *ref_mv);
 
+#if CONFIG_NON_GREEDY_MV
+#define NB_MVS_NUM 4
+double vp9_refining_search_sad_new(const MACROBLOCK *x, MV *best_full_mv,
+                                   double lambda, int search_range,
+                                   const vp9_variance_fn_ptr_t *fn_ptr,
+                                   const int_mv *nb_full_mvs);
+
+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,
+                                  const vp9_variance_fn_ptr_t *fn_ptr,
+                                  const int_mv *nb_full_mvs, MV *dst_mv);
+#endif  // CONFIG_NON_GREEDY_MV
 #ifdef __cplusplus
 }  // extern "C"
 #endif