Commit 682dad0e authored by Jingning Han's avatar Jingning Han Committed by Gerrit Code Review

Merge "Store predicted motion vectors" into nextgenv2

parents 961668c9 876c8b03
......@@ -79,6 +79,9 @@ static INLINE int have_newmv_in_inter_mode(PREDICTION_MODE mode) {
typedef struct {
PREDICTION_MODE as_mode;
int_mv as_mv[2]; // first, second inter predictor motion vectors
#if CONFIG_REF_MV
int_mv pred_mv[2];
#endif
#if CONFIG_EXT_INTER
int_mv ref_mv[2];
#endif // CONFIG_EXT_INTER
......
......@@ -38,6 +38,7 @@ typedef struct mv32 {
typedef struct candidate_mv {
int_mv this_mv;
int_mv comp_mv;
int_mv pred_mv;
int weight;
} CANDIDATE_MV;
#endif
......
......@@ -38,6 +38,8 @@ static uint8_t add_ref_mv_candidate(const MODE_INFO *const candidate_mi,
// Add a new item to the list.
if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv;
ref_mv_stack[index].pred_mv =
get_sub_block_pred_mv(candidate_mi, ref, col, block);
ref_mv_stack[index].weight = 2 * weight;
++(*refmv_count);
......@@ -63,6 +65,8 @@ static uint8_t add_ref_mv_candidate(const MODE_INFO *const candidate_mi,
// Add a new item to the list.
if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv;
ref_mv_stack[index].pred_mv =
get_sub_block_pred_mv(candidate_mi, ref, col, alt_block);
ref_mv_stack[index].weight = weight;
++(*refmv_count);
......
......@@ -150,6 +150,16 @@ static INLINE int_mv get_sub_block_mv(const MODE_INFO *candidate, int which_mv,
: candidate->mbmi.mv[which_mv];
}
#if CONFIG_REF_MV
static INLINE int_mv get_sub_block_pred_mv(const MODE_INFO *candidate,
int which_mv,
int search_col, int block_idx) {
return block_idx >= 0 && candidate->mbmi.sb_type < BLOCK_8X8
? candidate->bmi[idx_n_column_to_subblock[block_idx][search_col == 0]]
.pred_mv[which_mv]
: candidate->mbmi.pred_mv[which_mv];
}
#endif
// Performs mv sign inversion if indicated by the reference frame combination.
static INLINE int_mv scale_mv(const MB_MODE_INFO *mbmi, int ref,
......
......@@ -891,11 +891,20 @@ static INLINE int is_mv_valid(const MV *mv) {
static INLINE int assign_mv(VP10_COMMON *cm, MACROBLOCKD *xd,
PREDICTION_MODE mode,
#if CONFIG_REF_MV
int block,
#endif
int_mv mv[2], int_mv ref_mv[2],
int_mv nearest_mv[2], int_mv near_mv[2],
int is_compound, int allow_hp, vpx_reader *r) {
int i;
int ret = 1;
#if CONFIG_REF_MV
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
BLOCK_SIZE bsize = mbmi->sb_type;
int_mv *pred_mv = (bsize >= BLOCK_8X8) ?
mbmi->pred_mv : xd->mi[0]->bmi[block].pred_mv;
#endif
switch (mode) {
#if CONFIG_EXT_INTER
......@@ -908,6 +917,10 @@ static INLINE int assign_mv(VP10_COMMON *cm, MACROBLOCKD *xd,
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc, mv_counts,
allow_hp);
ret = ret && is_mv_valid(&mv[i].as_mv);
#if CONFIG_REF_MV
pred_mv[i].as_int = ref_mv[i].as_int;
#endif
}
break;
}
......@@ -915,18 +928,36 @@ static INLINE int assign_mv(VP10_COMMON *cm, MACROBLOCKD *xd,
mv[0].as_int = nearest_mv[0].as_int;
if (is_compound)
mv[1].as_int = nearest_mv[1].as_int;
#if CONFIG_REF_MV
pred_mv[0].as_int = nearest_mv[0].as_int;
if (is_compound)
pred_mv[1].as_int = nearest_mv[1].as_int;
#endif
break;
}
case NEARMV: {
mv[0].as_int = near_mv[0].as_int;
if (is_compound)
mv[1].as_int = near_mv[1].as_int;
#if CONFIG_REF_MV
pred_mv[0].as_int = near_mv[0].as_int;
if (is_compound)
pred_mv[1].as_int = near_mv[1].as_int;
#endif
break;
}
case ZEROMV: {
mv[0].as_int = 0;
if (is_compound)
mv[1].as_int = 0;
#if CONFIG_REF_MV
pred_mv[0].as_int = 0;
if (is_compound)
pred_mv[1].as_int = 0;
#endif
break;
}
#if CONFIG_EXT_INTER
......@@ -1284,7 +1315,11 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
#endif // CONFIG_EXT_INTER
}
if (!assign_mv(cm, xd, b_mode, block,
if (!assign_mv(cm, xd, b_mode,
#if CONFIG_REF_MV
j,
#endif
block,
#if CONFIG_EXT_INTER
ref_mv[mv_idx],
#else
......@@ -1312,7 +1347,11 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi,
mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
} else {
xd->corrupted |= !assign_mv(cm, xd, mbmi->mode, mbmi->mv,
xd->corrupted |= !assign_mv(cm, xd, mbmi->mode,
#if CONFIG_REF_MV
0,
#endif
mbmi->mv,
#if CONFIG_EXT_INTER
mbmi->mode == NEWFROMNEARMV ?
nearmv : nearestmv,
......
......@@ -3554,6 +3554,20 @@ static int set_and_cost_bmi_mvs(VP10_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
mic->bmi[i].as_mode = mode;
#if CONFIG_REF_MV
if (mode == NEWMV) {
mic->bmi[i].pred_mv[0].as_int =
mbmi_ext->ref_mvs[mbmi->ref_frame[0]][0].as_int;
if (is_compound)
mic->bmi[i].pred_mv[1].as_int =
mbmi_ext->ref_mvs[mbmi->ref_frame[1]][0].as_int;
} else {
mic->bmi[i].pred_mv[0].as_int = this_mv[0].as_int;
if (is_compound)
mic->bmi[i].pred_mv[1].as_int = this_mv[1].as_int;
}
#endif
for (idy = 0; idy < num_4x4_blocks_high; ++idy)
for (idx = 0; idx < num_4x4_blocks_wide; ++idx)
memmove(&mic->bmi[i + idy * 2 + idx], &mic->bmi[i], sizeof(mic->bmi[i]));
......@@ -5305,6 +5319,13 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
if (mv_check_bounds(x, &cur_mv[i].as_mv))
return INT64_MAX;
mbmi->mv[i].as_int = cur_mv[i].as_int;
#if CONFIG_REF_MV
if (this_mode != NEWMV)
mbmi->pred_mv[i].as_int = mbmi->mv[i].as_int;
else
mbmi->pred_mv[i].as_int = mbmi_ext->ref_mvs[refs[i]][0].as_int;
#endif
}
#if CONFIG_REF_MV
......
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