From: Angie Chiang Date: Tue, 25 Sep 2018 22:26:33 +0000 (-0700) Subject: Add vp9_full_pixel_diamond_new X-Git-Tag: v1.8.0~287^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7aca1b5affedad769df671bff63f0999cda0e62;p=libvpx Add vp9_full_pixel_diamond_new This function will call vp9_diaomond_search_sad_new / vp9_refining_search_sad_new accordingly. Change-Id: If96a8a1c9c06b6b4ed3aac6d59bdb03f20c96df9 --- diff --git a/vp9/encoder/vp9_mcomp.c b/vp9/encoder/vp9_mcomp.c index c7ec149d3..97ec5e06e 100644 --- a/vp9/encoder/vp9_mcomp.c +++ b/vp9/encoder/vp9_mcomp.c @@ -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 diff --git a/vp9/encoder/vp9_mcomp.h b/vp9/encoder/vp9_mcomp.h index 348db0619..46dd55129 100644 --- a/vp9/encoder/vp9_mcomp.h +++ b/vp9/encoder/vp9_mcomp.h @@ -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