Commit 0fa0f42c authored by Alex Converse's avatar Alex Converse

Refactor mv limits.

cherry pick of libvpx commit 6554333b59cf773983c7cacbd832d754f75139e8

BUG=aomedia:443

Change-Id: Ifebdc9ef37850508eb4b8e572fd0f6026ab04987
parent f323f015
......@@ -88,6 +88,13 @@ typedef struct {
#endif
} MB_MODE_INFO_EXT;
typedef struct {
int col_min;
int col_max;
int row_min;
int row_max;
} MvLimits;
#if CONFIG_PALETTE
typedef struct {
uint8_t best_palette_color_map[MAX_SB_SQUARE];
......@@ -163,10 +170,7 @@ struct macroblock {
// These define limits to motion vector components to prevent them
// from extending outside the UMV borders
int mv_col_min;
int mv_col_max;
int mv_row_min;
int mv_row_max;
MvLimits mv_limits;
#if CONFIG_VAR_TX
uint8_t blk_skip[MAX_MB_PLANE][MAX_MIB_SIZE * MAX_MIB_SIZE * 8];
......
......@@ -289,10 +289,11 @@ static void set_offsets_without_segment_id(const AV1_COMP *const cpi,
// Set up limit values for MV components.
// Mv beyond the range do not produce new/different prediction block.
x->mv_row_min = -(((mi_row + mi_height) * MI_SIZE) + AOM_INTERP_EXTEND);
x->mv_col_min = -(((mi_col + mi_width) * MI_SIZE) + AOM_INTERP_EXTEND);
x->mv_row_max = (cm->mi_rows - mi_row) * MI_SIZE + AOM_INTERP_EXTEND;
x->mv_col_max = (cm->mi_cols - mi_col) * MI_SIZE + AOM_INTERP_EXTEND;
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;
set_plane_n4(xd, mi_width, mi_height);
......@@ -389,10 +390,14 @@ static void set_offsets_extend(const AV1_COMP *const cpi, ThreadData *td,
// Set up limit values for MV components.
// Mv beyond the range do not produce new/different prediction block.
x->mv_row_min = -(((mi_row_pred + mi_height) * MI_SIZE) + AOM_INTERP_EXTEND);
x->mv_col_min = -(((mi_col_pred + mi_width) * MI_SIZE) + AOM_INTERP_EXTEND);
x->mv_row_max = (cm->mi_rows - mi_row_pred) * MI_SIZE + AOM_INTERP_EXTEND;
x->mv_col_max = (cm->mi_cols - mi_col_pred) * MI_SIZE + AOM_INTERP_EXTEND;
x->mv_limits.row_min =
-(((mi_row_pred + mi_height) * MI_SIZE) + AOM_INTERP_EXTEND);
x->mv_limits.col_min =
-(((mi_col_pred + mi_width) * MI_SIZE) + AOM_INTERP_EXTEND);
x->mv_limits.row_max =
(cm->mi_rows - mi_row_pred) * MI_SIZE + AOM_INTERP_EXTEND;
x->mv_limits.col_max =
(cm->mi_cols - mi_col_pred) * MI_SIZE + AOM_INTERP_EXTEND;
// Set up distance of MB to edge of frame in 1/8th pel units.
#if !CONFIG_CB4X4
......
......@@ -615,8 +615,9 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
// Set up limit values for motion vectors to prevent them extending
// outside the UMV borders.
x->mv_row_min = -((mb_row * 16) + BORDER_MV_PIXELS_B16);
x->mv_row_max = ((cm->mb_rows - 1 - mb_row) * 16) + BORDER_MV_PIXELS_B16;
x->mv_limits.row_min = -((mb_row * 16) + BORDER_MV_PIXELS_B16);
x->mv_limits.row_max =
((cm->mb_rows - 1 - mb_row) * 16) + BORDER_MV_PIXELS_B16;
for (mb_col = 0; mb_col < cm->mb_cols; ++mb_col) {
int this_error;
......@@ -728,8 +729,9 @@ void av1_first_pass(AV1_COMP *cpi, const struct lookahead_entry *source) {
// Set up limit values for motion vectors to prevent them extending
// outside the UMV borders.
x->mv_col_min = -((mb_col * 16) + BORDER_MV_PIXELS_B16);
x->mv_col_max = ((cm->mb_cols - 1 - mb_col) * 16) + BORDER_MV_PIXELS_B16;
x->mv_limits.col_min = -((mb_col * 16) + BORDER_MV_PIXELS_B16);
x->mv_limits.col_max =
((cm->mb_cols - 1 - mb_col) * 16) + BORDER_MV_PIXELS_B16;
if (!frame_is_intra_only(cm)) { // Do a motion search
int tmp_err, motion_error, raw_motion_error;
......
......@@ -30,10 +30,7 @@ static unsigned int do_16x16_motion_iteration(AV1_COMP *cpi, const MV *ref_mv,
const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv;
const aom_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
const int tmp_col_min = x->mv_col_min;
const int tmp_col_max = x->mv_col_max;
const int tmp_row_min = x->mv_row_min;
const int tmp_row_max = x->mv_row_max;
const MvLimits tmp_mv_limits = x->mv_limits;
MV ref_full;
int cost_list[5];
......@@ -41,7 +38,7 @@ static unsigned int do_16x16_motion_iteration(AV1_COMP *cpi, const MV *ref_mv,
int step_param = mv_sf->reduce_first_step_size;
step_param = AOMMIN(step_param, MAX_MVSEARCH_STEPS - 2);
av1_set_mv_search_range(x, ref_mv);
av1_set_mv_search_range(&x->mv_limits, ref_mv);
ref_full.col = ref_mv->col >> 3;
ref_full.row = ref_mv->row >> 3;
......@@ -77,10 +74,7 @@ static unsigned int do_16x16_motion_iteration(AV1_COMP *cpi, const MV *ref_mv,
av1_build_inter_predictors_sby(xd, mb_row, mb_col, NULL, BLOCK_16X16);
/* restore UMV window */
x->mv_col_min = tmp_col_min;
x->mv_col_max = tmp_col_max;
x->mv_row_min = tmp_row_min;
x->mv_row_max = tmp_row_max;
x->mv_limits = tmp_mv_limits;
return aom_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride,
xd->plane[0].dst.buf, xd->plane[0].dst.stride);
......@@ -237,8 +231,8 @@ static void update_mbgraph_frame_stats(AV1_COMP *cpi,
av1_zero(mi_local);
// Set up limit values for motion vectors to prevent them extending outside
// the UMV borders.
x->mv_row_min = -BORDER_MV_PIXELS_B16;
x->mv_row_max = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16;
x->mv_limits.row_min = -BORDER_MV_PIXELS_B16;
x->mv_limits.row_max = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16;
xd->up_available = 0;
xd->plane[0].dst.stride = buf->y_stride;
xd->plane[0].pre[0].stride = buf->y_stride;
......@@ -256,8 +250,8 @@ static void update_mbgraph_frame_stats(AV1_COMP *cpi,
// Set up limit values for motion vectors to prevent them extending outside
// the UMV borders.
x->mv_col_min = -BORDER_MV_PIXELS_B16;
x->mv_col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16;
x->mv_limits.col_min = -BORDER_MV_PIXELS_B16;
x->mv_limits.col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16;
xd->left_available = 0;
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
......@@ -273,15 +267,15 @@ static void update_mbgraph_frame_stats(AV1_COMP *cpi,
mb_y_in_offset += 16;
gld_y_in_offset += 16;
arf_y_in_offset += 16;
x->mv_col_min -= 16;
x->mv_col_max -= 16;
x->mv_limits.col_min -= 16;
x->mv_limits.col_max -= 16;
}
xd->up_available = 1;
mb_y_offset += buf->y_stride * 16;
gld_y_offset += golden_ref->y_stride * 16;
if (alt_ref) arf_y_offset += alt_ref->y_stride * 16;
x->mv_row_min -= 16;
x->mv_row_max -= 16;
x->mv_limits.row_min -= 16;
x->mv_limits.row_max -= 16;
offset += cm->mb_cols;
}
}
......
This diff is collapsed.
......@@ -46,8 +46,8 @@ typedef struct search_site_config {
void av1_init_dsmotion_compensation(search_site_config *cfg, int stride);
void av1_init3smotion_compensation(search_site_config *cfg, int stride);
void av1_set_mv_search_range(MACROBLOCK *x, const MV *mv);
void av1_set_subpel_mv_search_range(const MACROBLOCK *x, int *col_min,
void av1_set_mv_search_range(MvLimits *mv_limits, const MV *mv);
void av1_set_subpel_mv_search_range(const MvLimits *mv_limits, int *col_min,
int *col_max, int *row_min, int *row_max,
const MV *ref_mv);
......
This diff is collapsed.
......@@ -258,10 +258,7 @@ static int temporal_filter_find_matching_mb_c(AV1_COMP *cpi,
int distortion;
unsigned int sse;
int cost_list[5];
int tmp_col_min = x->mv_col_min;
int tmp_col_max = x->mv_col_max;
int tmp_row_min = x->mv_row_min;
int tmp_row_max = x->mv_row_max;
MvLimits tmp_mv_limits = x->mv_limits;
MV best_ref_mv1 = { 0, 0 };
MV best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */
......@@ -282,7 +279,7 @@ static int temporal_filter_find_matching_mb_c(AV1_COMP *cpi,
step_param = mv_sf->reduce_first_step_size;
step_param = AOMMIN(step_param, MAX_MVSEARCH_STEPS - 2);
av1_set_mv_search_range(x, &best_ref_mv1);
av1_set_mv_search_range(&x->mv_limits, &best_ref_mv1);
#if CONFIG_REF_MV
x->mvcost = x->mv_cost_stack[0];
......@@ -296,10 +293,7 @@ static int temporal_filter_find_matching_mb_c(AV1_COMP *cpi,
cond_cost_list(cpi, cost_list), &cpi->fn_ptr[BLOCK_16X16], 0,
&best_ref_mv1);
x->mv_col_min = tmp_col_min;
x->mv_col_max = tmp_col_max;
x->mv_row_min = tmp_row_min;
x->mv_row_max = tmp_row_max;
x->mv_limits = tmp_mv_limits;
// Ignore mv costing by sending NULL pointer instead of cost array
bestsme = cpi->find_fractional_mv_step(
......@@ -370,8 +364,9 @@ static void temporal_filter_iterate_c(AV1_COMP *cpi,
// 8 - AOM_INTERP_EXTEND.
// To keep the mv in play for both Y and UV planes the max that it
// can be on a border is therefore 16 - (2*AOM_INTERP_EXTEND+1).
cpi->td.mb.mv_row_min = -((mb_row * 16) + (17 - 2 * AOM_INTERP_EXTEND));
cpi->td.mb.mv_row_max =
cpi->td.mb.mv_limits.row_min =
-((mb_row * 16) + (17 - 2 * AOM_INTERP_EXTEND));
cpi->td.mb.mv_limits.row_max =
((mb_rows - 1 - mb_row) * 16) + (17 - 2 * AOM_INTERP_EXTEND);
for (mb_col = 0; mb_col < mb_cols; mb_col++) {
......@@ -381,8 +376,9 @@ static void temporal_filter_iterate_c(AV1_COMP *cpi,
memset(accumulator, 0, 16 * 16 * 3 * sizeof(accumulator[0]));
memset(count, 0, 16 * 16 * 3 * sizeof(count[0]));
cpi->td.mb.mv_col_min = -((mb_col * 16) + (17 - 2 * AOM_INTERP_EXTEND));
cpi->td.mb.mv_col_max =
cpi->td.mb.mv_limits.col_min =
-((mb_col * 16) + (17 - 2 * AOM_INTERP_EXTEND));
cpi->td.mb.mv_limits.col_max =
((mb_cols - 1 - mb_col) * 16) + (17 - 2 * AOM_INTERP_EXTEND);
for (frame = 0; frame < frame_count; frame++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment