From 3675b2291cac15e6bc5a9bde9a0da7e00f919aaa Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Mon, 10 Jan 2011 16:16:59 -0500 Subject: [PATCH] Fix bug in motion search The maximum possible MV in 1/8 pel units is (1<<11), which could cause mvcost out of its range that is 1023. Change maximum possible MV in 1/8 pel units to (1<<11)-8 will fix this problem. Change-Id: I5788ed1de773f66658c14f225fb4ab5b1679b74b --- vp8/encoder/mcomp.h | 1 - vp8/encoder/rdopt.c | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/vp8/encoder/mcomp.h b/vp8/encoder/mcomp.h index 122debc..7600f87 100644 --- a/vp8/encoder/mcomp.h +++ b/vp8/encoder/mcomp.h @@ -24,7 +24,6 @@ extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]); #define MAX_MVSEARCH_STEPS 8 // The maximum number of steps in a step search given the largest allowed initial step #define MAX_FULL_PEL_VAL ((1 << (MAX_MVSEARCH_STEPS+3)) - 8) // Max full pel mv specified in 1/8 pel units #define MAX_FIRST_STEP (1 << (MAX_MVSEARCH_STEPS-1)) // Maximum size of the first step in full pel units -#define MAX_POSSIBLE_MV (1 << 11) // Maximum MV in 1/8 pel units extern void print_mode_context(void); extern int vp8_mv_bit_cost(MV *mv, MV *ref, int *mvcost[2], int Weight); diff --git a/vp8/encoder/rdopt.c b/vp8/encoder/rdopt.c index d694d39..366b875 100644 --- a/vp8/encoder/rdopt.c +++ b/vp8/encoder/rdopt.c @@ -1325,10 +1325,10 @@ static int vp8_rd_pick_best_mbsegmentation(VP8_COMP *cpi, MACROBLOCK *x, if (bsi.segment_rd < best_rd) { - int col_min = (best_ref_mv->col - MAX_POSSIBLE_MV) >>3; - int col_max = (best_ref_mv->col + MAX_POSSIBLE_MV) >>3; - int row_min = (best_ref_mv->row - MAX_POSSIBLE_MV) >>3; - int row_max = (best_ref_mv->row + MAX_POSSIBLE_MV) >>3; + int col_min = (best_ref_mv->col - MAX_FULL_PEL_VAL) >>3; + int col_max = (best_ref_mv->col + MAX_FULL_PEL_VAL) >>3; + int row_min = (best_ref_mv->row - MAX_FULL_PEL_VAL) >>3; + int row_max = (best_ref_mv->row + MAX_FULL_PEL_VAL) >>3; int tmp_col_min = x->mv_col_min; int tmp_col_max = x->mv_col_max; @@ -1927,14 +1927,14 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int x->e_mbd.mode_info_context->mbmi.ref_frame, cpi->common.ref_frame_sign_bias, &sr, &near_sadidx[0]); /* adjust mvp to make sure it is within MV range */ - if(mvp.row > best_ref_mv.row + MAX_POSSIBLE_MV) - mvp.row = best_ref_mv.row + MAX_POSSIBLE_MV; - else if(mvp.row < best_ref_mv.row - MAX_POSSIBLE_MV) - mvp.row = best_ref_mv.row - MAX_POSSIBLE_MV; - if(mvp.col > best_ref_mv.col + MAX_POSSIBLE_MV) - mvp.col = best_ref_mv.col + MAX_POSSIBLE_MV; - else if(mvp.col < best_ref_mv.col - MAX_POSSIBLE_MV) - mvp.col = best_ref_mv.col - MAX_POSSIBLE_MV; + if(mvp.row > best_ref_mv.row + MAX_FULL_PEL_VAL) + mvp.row = best_ref_mv.row + MAX_FULL_PEL_VAL; + else if(mvp.row < best_ref_mv.row - MAX_FULL_PEL_VAL) + mvp.row = best_ref_mv.row - MAX_FULL_PEL_VAL; + if(mvp.col > best_ref_mv.col + MAX_FULL_PEL_VAL) + mvp.col = best_ref_mv.col + MAX_FULL_PEL_VAL; + else if(mvp.col < best_ref_mv.col - MAX_FULL_PEL_VAL) + mvp.col = best_ref_mv.col - MAX_FULL_PEL_VAL; } // Check to see if the testing frequency for this mode is at its max @@ -2066,10 +2066,10 @@ int vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, int int further_steps; int n; - int col_min = (best_ref_mv.col - MAX_POSSIBLE_MV) >>3; - int col_max = (best_ref_mv.col + MAX_POSSIBLE_MV) >>3; - int row_min = (best_ref_mv.row - MAX_POSSIBLE_MV) >>3; - int row_max = (best_ref_mv.row + MAX_POSSIBLE_MV) >>3; + int col_min = (best_ref_mv.col - MAX_FULL_PEL_VAL) >>3; + int col_max = (best_ref_mv.col + MAX_FULL_PEL_VAL) >>3; + int row_min = (best_ref_mv.row - MAX_FULL_PEL_VAL) >>3; + int row_max = (best_ref_mv.row + MAX_FULL_PEL_VAL) >>3; int tmp_col_min = x->mv_col_min; int tmp_col_max = x->mv_col_max; -- 2.7.4