Set mv limits in a consistent way
Following the border consolidation, modified mv limits so
they are consistent within the encoder. More CLs will follow.
Speed 1 Borg test showed negligible impact:
avg_psnr: ovr_psnr: ssim:
hdres: -0.004 -0.006 0.010
midres: 0.042 0.047 0.063
lowres: -0.014 -0.011 0.007
STATS_CHANGED
Change-Id: I3fce1aa226cf28b72de7531d858f45c26785456e
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index db48529..bb829c7 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -406,11 +406,8 @@
// Set up limit values for MV components.
// Mv beyond the range do not produce new/different prediction block.
- x->mv_limits.row_min =
- -(((mi_row + mi_height) * MI_SIZE) + AOM_INTERP_EXTEND);
- x->mv_limits.col_min = -(((mi_col + mi_width) * MI_SIZE) + AOM_INTERP_EXTEND);
- x->mv_limits.row_max = (cm->mi_rows - mi_row) * MI_SIZE + AOM_INTERP_EXTEND;
- x->mv_limits.col_max = (cm->mi_cols - mi_col) * MI_SIZE + AOM_INTERP_EXTEND;
+ av1_set_mv_limits(cm, &x->mv_limits, mi_row, mi_col, mi_height, mi_width,
+ cpi->oxcf.border_in_pixels);
set_plane_n4(xd, mi_width, mi_height, num_planes);
diff --git a/av1/encoder/mcomp.h b/av1/encoder/mcomp.h
index 79450bf..efca00d 100644
--- a/av1/encoder/mcomp.h
+++ b/av1/encoder/mcomp.h
@@ -102,6 +102,20 @@
// Sets up configs for all other types of motion search
void av1_init3smotion_compensation(search_site_config *cfg, int stride);
+// Set up limit values for MV components.
+// Mv beyond the range do not produce new/different prediction block.
+static INLINE void av1_set_mv_limits(const AV1_COMMON *const cm,
+ FullMvLimits *mv_limits, int mi_row,
+ int mi_col, int mi_height, int mi_width,
+ int border) {
+ mv_limits->row_min = -(mi_row * MI_SIZE + border - 2 * AOM_INTERP_EXTEND);
+ mv_limits->col_min = -(mi_col * MI_SIZE + border - 2 * AOM_INTERP_EXTEND);
+ mv_limits->row_max = (cm->mi_rows - mi_row - mi_height) * MI_SIZE + border -
+ 2 * AOM_INTERP_EXTEND;
+ mv_limits->col_max = (cm->mi_cols - mi_col - mi_width) * MI_SIZE + border -
+ 2 * AOM_INTERP_EXTEND;
+}
+
void av1_set_mv_search_range(FullMvLimits *mv_limits, const MV *mv);
int av1_init_search_range(int size);
diff --git a/av1/encoder/partition_strategy.h b/av1/encoder/partition_strategy.h
index 4a4cbf7..5275432 100644
--- a/av1/encoder/partition_strategy.h
+++ b/av1/encoder/partition_strategy.h
@@ -153,11 +153,8 @@
// Set up limit values for MV components.
// Mv beyond the range do not produce new/different prediction block.
- x->mv_limits.row_min =
- -(((mi_row + mi_height) * MI_SIZE) + AOM_INTERP_EXTEND);
- x->mv_limits.col_min = -(((mi_col + mi_width) * MI_SIZE) + AOM_INTERP_EXTEND);
- x->mv_limits.row_max = (cm->mi_rows - mi_row) * MI_SIZE + AOM_INTERP_EXTEND;
- x->mv_limits.col_max = (cm->mi_cols - mi_col) * MI_SIZE + AOM_INTERP_EXTEND;
+ av1_set_mv_limits(cm, &x->mv_limits, mi_row, mi_col, mi_height, mi_width,
+ cpi->oxcf.border_in_pixels);
set_plane_n4(xd, mi_width, mi_height, num_planes);