From: Yunqing Wang Date: Thu, 2 Jun 2011 21:33:17 +0000 (-0400) Subject: Adjust bounds checking for hex search in real-time mode X-Git-Tag: v0.9.7~117 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e5c236c21011c668c6b521dc4e554dbf91a161fe;p=libvpx 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 --- diff --git a/vp8/encoder/pickinter.c b/vp8/encoder/pickinter.c index 77e188e30..f4bcabe79 100644 --- a/vp8/encoder/pickinter.c +++ b/vp8/encoder/pickinter.c @@ -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,