Adjust bounds checking for hex search in real-time mode

Currently, hex search couldn't guarantee the motion vector(MV)
found is within the limit of maximum MV. Therefore, very large
motion vectors resulted from big motion in the video could cause
encoding artifacts. This change adjusted hex search bounds
checking to make sure the resulted motion vector won't go out
of the range. James Berry, thank you for finding the bug.

Change-Id: If2c55edd9019e72444ad9b4b8688969eef610c55
This commit is contained in:
Yunqing Wang 2011-06-02 17:33:17 -04:00
parent 4ce6928d5b
commit e5c236c210

View File

@ -736,26 +736,26 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
//adjust search range according to sr from mv prediction
if(sr > step_param)
step_param = sr;
col_min = (best_ref_mv.as_mv.col - MAX_FULL_PEL_VAL) >>3;
col_max = (best_ref_mv.as_mv.col + MAX_FULL_PEL_VAL) >>3;
row_min = (best_ref_mv.as_mv.row - MAX_FULL_PEL_VAL) >>3;
row_max = (best_ref_mv.as_mv.row + MAX_FULL_PEL_VAL) >>3;
// Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
if (x->mv_col_min < col_min )
x->mv_col_min = col_min;
if (x->mv_col_max > col_max )
x->mv_col_max = col_max;
if (x->mv_row_min < row_min )
x->mv_row_min = row_min;
if (x->mv_row_max > row_max )
x->mv_row_max = row_max;
}else
{
mvp.as_int = best_ref_mv.as_int;
}
col_min = (best_ref_mv.as_mv.col - MAX_FULL_PEL_VAL) >>3;
col_max = (best_ref_mv.as_mv.col + MAX_FULL_PEL_VAL) >>3;
row_min = (best_ref_mv.as_mv.row - MAX_FULL_PEL_VAL) >>3;
row_max = (best_ref_mv.as_mv.row + MAX_FULL_PEL_VAL) >>3;
// Get intersection of UMV window and valid MV window to reduce # of checks in diamond search.
if (x->mv_col_min < col_min )
x->mv_col_min = col_min;
if (x->mv_col_max > col_max )
x->mv_col_max = col_max;
if (x->mv_row_min < row_min )
x->mv_row_min = row_min;
if (x->mv_row_max > row_max )
x->mv_row_max = row_max;
further_steps = (cpi->Speed >= 8)? 0: (cpi->sf.max_step_search_steps - 1 - step_param);
if (cpi->sf.search_method == HEX)
@ -808,13 +808,10 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
}
}
if(cpi->sf.improved_mv_pred)
{
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_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;
if (bestsme < INT_MAX)
cpi->find_fractional_mv_step(x, b, d, &d->bmi.mv, &best_ref_mv,