Deprecate refine search stage
With the new oct-diamond search pattern, the additional refinement
search that checks up to 24 motion vector points is no longer needed.
The compression performance change in speed 1 and 5 are both minor,
less than 0.03% gains in lowres, midres, and ugc360p.
On a single clip bus_cif at 1000 kbps tested in speed 5, the speed
is slightly up by 1.5%.
STATS_CHANGED
Change-Id: Ic14c8efd7113c326e98d0db5ab65876c09094eb5
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index 3c9abae..e246b4a 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -1798,8 +1798,7 @@
point as the best match, we will do a final 1-away diamond
refining search */
static int full_pixel_diamond(MACROBLOCK *x, MV *mvp_full, int step_param,
- int sadpb, int further_steps, int do_refine,
- int *cost_list,
+ int sadpb, int further_steps, int *cost_list,
const aom_variance_fn_ptr_t *fn_ptr,
const MV *ref_mv, const search_site_config *cfg,
uint8_t *second_pred, uint8_t *mask,
@@ -1815,8 +1814,6 @@
// 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;
@@ -1829,9 +1826,6 @@
if (thissme < INT_MAX)
thissme = av1_get_mvpred_var(x, &temp_mv, ref_mv, fn_ptr, 1);
- // check to see if refining search is needed.
- if (num00 > further_steps - n) do_refine = 0;
-
if (thissme < bestsme) {
bestsme = thissme;
x->best_mv.as_mv = temp_mv;
@@ -1839,20 +1833,6 @@
}
}
- // final 1-away diamond refining search
- if (do_refine) {
- const int search_range = 8;
- MV best_mv = x->best_mv.as_mv;
- thissme = av1_refining_search_sad(x, &best_mv, sadpb, search_range, fn_ptr,
- ref_mv);
- if (thissme < INT_MAX)
- thissme = av1_get_mvpred_var(x, &best_mv, ref_mv, fn_ptr, 1);
- if (thissme < bestsme) {
- bestsme = thissme;
- x->best_mv.as_mv = best_mv;
- }
- }
-
// Return cost list.
if (cost_list) {
calc_int_cost_list(x, ref_mv, sadpb, fn_ptr, &x->best_mv.as_mv, cost_list);
@@ -1921,80 +1901,6 @@
return bestsme;
}
-int av1_refining_search_sad(MACROBLOCK *x, MV *ref_mv, int error_per_bit,
- int search_range,
- const aom_variance_fn_ptr_t *fn_ptr,
- const MV *center_mv) {
- const MACROBLOCKD *const xd = &x->e_mbd;
- const MV neighbors[4] = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
- const struct buf_2d *const what = &x->plane[0].src;
- const struct buf_2d *const in_what = &xd->plane[0].pre[0];
- const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
- const uint8_t *best_address = get_buf_from_mv(in_what, ref_mv);
- unsigned int best_sad =
- fn_ptr->sdf(what->buf, what->stride, best_address, in_what->stride) +
- mvsad_err_cost(x, ref_mv, &fcenter_mv, error_per_bit);
- int i, j;
-
- for (i = 0; i < search_range; i++) {
- int best_site = -1;
- const int all_in = ((ref_mv->row - 1) > x->mv_limits.row_min) &
- ((ref_mv->row + 1) < x->mv_limits.row_max) &
- ((ref_mv->col - 1) > x->mv_limits.col_min) &
- ((ref_mv->col + 1) < x->mv_limits.col_max);
-
- if (all_in) {
- unsigned int sads[4];
- const uint8_t *const positions[4] = { best_address - in_what->stride,
- best_address - 1, best_address + 1,
- best_address + in_what->stride };
-
- fn_ptr->sdx4df(what->buf, what->stride, positions, in_what->stride, sads);
-
- for (j = 0; j < 4; ++j) {
- if (sads[j] < best_sad) {
- const MV mv = { ref_mv->row + neighbors[j].row,
- ref_mv->col + neighbors[j].col };
- sads[j] += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit);
- if (sads[j] < best_sad) {
- best_sad = sads[j];
- best_site = j;
- }
- }
- }
- } else {
- for (j = 0; j < 4; ++j) {
- const MV mv = { ref_mv->row + neighbors[j].row,
- ref_mv->col + neighbors[j].col };
-
- if (is_mv_in(&x->mv_limits, &mv)) {
- unsigned int sad =
- fn_ptr->sdf(what->buf, what->stride,
- get_buf_from_mv(in_what, &mv), in_what->stride);
- if (sad < best_sad) {
- sad += mvsad_err_cost(x, &mv, &fcenter_mv, error_per_bit);
- if (sad < best_sad) {
- best_sad = sad;
- best_site = j;
- }
- }
- }
- }
- }
-
- if (best_site == -1) {
- break;
- } else {
- x->second_best_mv.as_mv = *ref_mv;
- ref_mv->row += neighbors[best_site].row;
- ref_mv->col += neighbors[best_site].col;
- best_address = get_buf_from_mv(in_what, ref_mv);
- }
- }
-
- return best_sad;
-}
-
// This function is called when we do joint motion search in comp_inter_inter
// mode, or when searching for one component of an ext-inter compound mode.
int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
@@ -2355,10 +2261,9 @@
fn_ptr, 1, ref_mv);
break;
case NSTEP:
- var =
- full_pixel_diamond(x, mvp_full, step_param, error_per_bit,
- MAX_MVSEARCH_STEPS - 1 - step_param, 1, cost_list,
- fn_ptr, ref_mv, cfg, NULL, NULL, 0, 0);
+ var = full_pixel_diamond(x, mvp_full, step_param, error_per_bit,
+ MAX_MVSEARCH_STEPS - 1 - step_param, cost_list,
+ fn_ptr, ref_mv, cfg, NULL, NULL, 0, 0);
break;
default: assert(0 && "Invalid search method.");
}
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index 7a6f227..c19ecfa 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -84,10 +84,6 @@
int av1_init_search_range(int size);
-int av1_refining_search_sad(struct macroblock *x, MV *ref_mv, int sad_per_bit,
- int distance, const aom_variance_fn_ptr_t *fn_ptr,
- const MV *center_mv);
-
unsigned int av1_int_pro_motion_estimation(const struct AV1_COMP *cpi,
MACROBLOCK *x, BLOCK_SIZE bsize,
int mi_row, int mi_col,