ref: a7aca1b5affedad769df671bff63f0999cda0e62
parent: 0b06f95d2a9c08819838aaf7f63d95c8a7c4a959
author: Angie Chiang <angiebird@google.com>
date: Tue Sep 25 11:26:33 EDT 2018
Add vp9_full_pixel_diamond_new This function will call vp9_diaomond_search_sad_new / vp9_refining_search_sad_new accordingly. Change-Id: If96a8a1c9c06b6b4ed3aac6d59bdb03f20c96df9
--- a/vp9/encoder/vp9_mcomp.c
+++ b/vp9/encoder/vp9_mcomp.c
@@ -1578,8 +1578,6 @@
}
#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;
@@ -2077,6 +2075,61 @@
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
--- a/vp9/encoder/vp9_mcomp.h
+++ b/vp9/encoder/vp9_mcomp.h
@@ -119,6 +119,19 @@
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