Commit efc115f4 authored by Jingning Han's avatar Jingning Han
Browse files

Store the predicted motion vectors

Change-Id: I860ebd612cac998e143ac5bcbf06e3954a62b047
parent 6a720986
...@@ -52,6 +52,9 @@ static INLINE int is_inter_mode(PREDICTION_MODE mode) { ...@@ -52,6 +52,9 @@ static INLINE int is_inter_mode(PREDICTION_MODE mode) {
typedef struct { typedef struct {
PREDICTION_MODE as_mode; PREDICTION_MODE as_mode;
int_mv as_mv[2]; // first, second inter predictor motion vectors int_mv as_mv[2]; // first, second inter predictor motion vectors
#if CONFIG_REF_MV
int_mv pred_mv[2];
#endif
} b_mode_info; } b_mode_info;
// Note that the rate-distortion optimization loop, bit-stream writer, and // Note that the rate-distortion optimization loop, bit-stream writer, and
...@@ -94,6 +97,7 @@ typedef struct { ...@@ -94,6 +97,7 @@ typedef struct {
TX_TYPE tx_type; TX_TYPE tx_type;
#if CONFIG_REF_MV #if CONFIG_REF_MV
int_mv pred_mv[2];
uint8_t ref_mv_idx; uint8_t ref_mv_idx;
#endif #endif
// TODO(slavarnway): Delete and use bmi[3].as_mv[] instead. // TODO(slavarnway): Delete and use bmi[3].as_mv[] instead.
......
...@@ -39,6 +39,7 @@ typedef struct mv32 { ...@@ -39,6 +39,7 @@ typedef struct mv32 {
typedef struct candidate_mv { typedef struct candidate_mv {
int_mv this_mv; int_mv this_mv;
int_mv comp_mv; int_mv comp_mv;
int_mv pred_mv;
int weight; int weight;
} CANDIDATE_MV; } CANDIDATE_MV;
#endif #endif
......
...@@ -40,6 +40,8 @@ static uint8_t add_ref_mv_candidate(const MACROBLOCKD *xd, ...@@ -40,6 +40,8 @@ static uint8_t add_ref_mv_candidate(const MACROBLOCKD *xd,
// Add a new item to the list. // Add a new item to the list.
if (index == *refmv_count) { if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv; 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 * len; ref_mv_stack[index].weight = 2 * len;
++(*refmv_count); ++(*refmv_count);
...@@ -64,6 +66,8 @@ static uint8_t add_ref_mv_candidate(const MACROBLOCKD *xd, ...@@ -64,6 +66,8 @@ static uint8_t add_ref_mv_candidate(const MACROBLOCKD *xd,
// Add a new item to the list. // Add a new item to the list.
if (index == *refmv_count) { if (index == *refmv_count) {
ref_mv_stack[index].this_mv = this_refmv; 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 = len; ref_mv_stack[index].weight = len;
++(*refmv_count); ++(*refmv_count);
......
...@@ -240,6 +240,17 @@ static INLINE int_mv get_sub_block_mv(const MODE_INFO *candidate, int which_mv, ...@@ -240,6 +240,17 @@ static INLINE int_mv get_sub_block_mv(const MODE_INFO *candidate, int which_mv,
: candidate->mbmi.mv[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. // Performs mv sign inversion if indicated by the reference frame combination.
static INLINE int_mv scale_mv(const MB_MODE_INFO *mbmi, int ref, static INLINE int_mv scale_mv(const MB_MODE_INFO *mbmi, int ref,
const MV_REFERENCE_FRAME this_ref_frame, const MV_REFERENCE_FRAME this_ref_frame,
......
...@@ -537,13 +537,22 @@ static INLINE int is_mv_valid(const MV *mv) { ...@@ -537,13 +537,22 @@ static INLINE int is_mv_valid(const MV *mv) {
} }
static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
PREDICTION_MODE mode, int_mv mv[2], PREDICTION_MODE mode, int block, int_mv mv[2],
int_mv ref_mv[2], int_mv nearest_mv[2], int_mv ref_mv[2], int_mv nearest_mv[2],
int_mv near_mv[2], int is_compound, int allow_hp, int_mv near_mv[2], int is_compound, int allow_hp,
aom_reader *r) { aom_reader *r) {
int i; int i;
int ret = 1; 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;
#else
(void)block;
#endif
switch (mode) { switch (mode) {
case NEWMV: { case NEWMV: {
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
...@@ -552,22 +561,40 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd, ...@@ -552,22 +561,40 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc, mv_counts, read_mv(r, &mv[i].as_mv, &ref_mv[i].as_mv, &cm->fc->nmvc, mv_counts,
allow_hp); allow_hp);
ret = ret && is_mv_valid(&mv[i].as_mv); 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; break;
} }
case NEARESTMV: { case NEARESTMV: {
mv[0].as_int = nearest_mv[0].as_int; mv[0].as_int = nearest_mv[0].as_int;
if (is_compound) mv[1].as_int = nearest_mv[1].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; break;
} }
case NEARMV: { case NEARMV: {
mv[0].as_int = near_mv[0].as_int; mv[0].as_int = near_mv[0].as_int;
if (is_compound) mv[1].as_int = near_mv[1].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; break;
} }
case ZEROMV: { case ZEROMV: {
mv[0].as_int = 0; mv[0].as_int = 0;
if (is_compound) mv[1].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; break;
} }
default: { return 0; } default: { return 0; }
...@@ -730,7 +757,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, ...@@ -730,7 +757,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
&near_sub8x8[ref]); &near_sub8x8[ref]);
} }
if (!assign_mv(cm, xd, b_mode, block, nearestmv, nearest_sub8x8, if (!assign_mv(cm, xd, b_mode, j, block, nearestmv, nearest_sub8x8,
near_sub8x8, is_compound, allow_hp, r)) { near_sub8x8, is_compound, allow_hp, r)) {
xd->corrupted |= 1; xd->corrupted |= 1;
break; break;
...@@ -749,7 +776,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi, ...@@ -749,7 +776,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int; 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; mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
} else { } else {
xd->corrupted |= !assign_mv(cm, xd, mbmi->mode, mbmi->mv, nearestmv, xd->corrupted |= !assign_mv(cm, xd, mbmi->mode, 0, mbmi->mv, nearestmv,
nearestmv, nearmv, is_compound, allow_hp, r); nearestmv, nearmv, is_compound, allow_hp, r);
} }
} }
......
...@@ -1330,6 +1330,20 @@ static int set_and_cost_bmi_mvs(AV1_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd, ...@@ -1330,6 +1330,20 @@ static int set_and_cost_bmi_mvs(AV1_COMP *cpi, MACROBLOCK *x, MACROBLOCKD *xd,
mic->bmi[i].as_mode = mode; 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 (idy = 0; idy < num_4x4_blocks_high; ++idy)
for (idx = 0; idx < num_4x4_blocks_wide; ++idx) for (idx = 0; idx < num_4x4_blocks_wide; ++idx)
memmove(&mic->bmi[i + idy * 2 + idx], &mic->bmi[i], sizeof(mic->bmi[i])); memmove(&mic->bmi[i + idy * 2 + idx], &mic->bmi[i], sizeof(mic->bmi[i]));
...@@ -2457,6 +2471,13 @@ static int64_t handle_inter_mode( ...@@ -2457,6 +2471,13 @@ static int64_t handle_inter_mode(
if (mv_check_bounds(x, &cur_mv[i].as_mv)) return INT64_MAX; if (mv_check_bounds(x, &cur_mv[i].as_mv)) return INT64_MAX;
mbmi->mv[i].as_int = cur_mv[i].as_int; 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 #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