Store the predicted motion vectors

Change-Id: I860ebd612cac998e143ac5bcbf06e3954a62b047
This commit is contained in:
Jingning Han 2016-04-04 15:00:22 -07:00
Родитель 6a720986ac
Коммит efc115f481
6 изменённых файлов: 71 добавлений и 3 удалений

Просмотреть файл

@ -52,6 +52,9 @@ static INLINE int is_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
} b_mode_info;
// Note that the rate-distortion optimization loop, bit-stream writer, and
@ -94,6 +97,7 @@ typedef struct {
TX_TYPE tx_type;
#if CONFIG_REF_MV
int_mv pred_mv[2];
uint8_t ref_mv_idx;
#endif
// TODO(slavarnway): Delete and use bmi[3].as_mv[] instead.

Просмотреть файл

@ -39,6 +39,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

Просмотреть файл

@ -40,6 +40,8 @@ static uint8_t add_ref_mv_candidate(const MACROBLOCKD *xd,
// 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 * len;
++(*refmv_count);
@ -64,6 +66,8 @@ static uint8_t add_ref_mv_candidate(const MACROBLOCKD *xd,
// 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 = len;
++(*refmv_count);

Просмотреть файл

@ -240,6 +240,17 @@ 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,
const MV_REFERENCE_FRAME this_ref_frame,

Просмотреть файл

@ -537,13 +537,22 @@ static INLINE int is_mv_valid(const MV *mv) {
}
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 near_mv[2], int is_compound, int allow_hp,
aom_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;
#else
(void)block;
#endif
switch (mode) {
case NEWMV: {
FRAME_COUNTS *counts = xd->counts;
@ -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,
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;
}
case NEARESTMV: {
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;
}
default: { return 0; }
@ -730,7 +757,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
&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)) {
xd->corrupted |= 1;
break;
@ -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[1].as_int = mi->bmi[3].as_mv[1].as_int;
} 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);
}
}

Просмотреть файл

@ -1330,6 +1330,20 @@ static int set_and_cost_bmi_mvs(AV1_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]));
@ -2457,6 +2471,13 @@ static int64_t handle_inter_mode(
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