Commit 3675b229 authored by Yunqing Wang's avatar Yunqing Wang
Browse files

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
parent cf7c4732
......@@ -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);
......
......@@ -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;
......
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