Enable dynamic ref motion vector mode for compound inter block

This commit enables the dynamic reference motion vector coding mode
for the compound inter blocks.

Change-Id: I3d6edea7cf241cbb108709b57aeb54f811029237
This commit is contained in:
Jingning Han 2016-04-04 09:37:04 -07:00
Родитель 9fdd1124d0
Коммит c443f820b7
3 изменённых файлов: 37 добавлений и 22 удалений

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

@ -613,11 +613,12 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
if (bsize >= BLOCK_8X8) {
mbmi->mode = read_inter_mode(cm, xd, r, mode_ctx);
#if CONFIG_REF_MV
if (mbmi->mode == NEARMV && !is_compound) {
if (xd->ref_mv_count[mbmi->ref_frame[0]] > 2) {
if (mbmi->mode == NEARMV) {
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
if (xd->ref_mv_count[ref_frame_type] > 2) {
if (aom_read_bit(r)) {
mbmi->ref_mv_idx = 1;
if (xd->ref_mv_count[mbmi->ref_frame[0]] > 3)
if (xd->ref_mv_count[ref_frame_type] > 3)
if (aom_read_bit(r))
mbmi->ref_mv_idx = 2;
}
@ -651,18 +652,19 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
nearestmv[0] = xd->ref_mv_stack[ref_frame_type][0].this_mv;
nearestmv[1] = xd->ref_mv_stack[ref_frame_type][0].comp_mv;
for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i)
for (i = 0; i < 2; ++i)
lower_mv_precision(&nearestmv[i].as_mv, allow_hp);
}
if (xd->ref_mv_count[ref_frame_type] > 1) {
int i;
const int ref_mv_idx = 1 + mbmi->ref_mv_idx;
nearestmv[0] = xd->ref_mv_stack[ref_frame_type][0].this_mv;
nearestmv[1] = xd->ref_mv_stack[ref_frame_type][0].comp_mv;
nearmv[0] = xd->ref_mv_stack[ref_frame_type][1].this_mv;
nearmv[1] = xd->ref_mv_stack[ref_frame_type][1].comp_mv;
nearmv[0] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
nearmv[1] = xd->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
for (i = 0; i < 2; ++i) {
lower_mv_precision(&nearestmv[i].as_mv, allow_hp);
lower_mv_precision(&nearmv[i].as_mv, allow_hp);
}

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

@ -444,10 +444,11 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
if (bsize >= BLOCK_8X8) {
write_inter_mode(cm, w, mode, mode_ctx);
#if CONFIG_REF_MV
if (mode == NEARMV && mbmi->ref_frame[1] == NONE) {
if (mbmi_ext->ref_mv_count[mbmi->ref_frame[0]] > 2) {
if (mode == NEARMV) {
const uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
if (mbmi_ext->ref_mv_count[ref_frame_type] > 2) {
aom_write_bit(w, mbmi->ref_mv_idx != 0);
if (mbmi_ext->ref_mv_count[mbmi->ref_frame[0]] > 3 &&
if (mbmi_ext->ref_mv_count[ref_frame_type] > 3 &&
mbmi->ref_mv_idx > 0)
aom_write_bit(w, mbmi->ref_mv_idx != 1);
}

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

@ -2478,9 +2478,10 @@ static int64_t handle_inter_mode(
if (this_mode == NEARMV && is_comp_pred) {
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
const int ref_mv_idx = mbmi->ref_mv_idx + 1;
if (mbmi_ext->ref_mv_count[ref_frame_type] > 1) {
cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][1].this_mv;
cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][1].comp_mv;
cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].this_mv;
cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][ref_mv_idx].comp_mv;
for (i = 0; i < 2; ++i) {
lower_mv_precision(&cur_mv[i].as_mv, cm->allow_high_precision_mv);
@ -2927,7 +2928,7 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
MB_MODE_INFO best_mbmode;
#if CONFIG_REF_MV
uint8_t best_ref_mv_idx[MAX_REF_FRAMES] = { 0 };
uint8_t best_ref_mv_idx[MODE_CTX_REF_FRAMES] = { 0 };
int rate_skip0 = av1_cost_bit(av1_get_skip_prob(cm, xd), 0);
int rate_skip1 = av1_cost_bit(av1_get_skip_prob(cm, xd), 1);
#endif
@ -3104,6 +3105,9 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
int this_skip2 = 0;
int64_t total_sse = INT64_MAX;
int early_term = 0;
#if CONFIG_REF_MV
uint8_t ref_frame_type;
#endif
this_mode = av1_mode_order[mode_index].mode;
ref_frame = av1_mode_order[mode_index].ref_frame[0];
@ -3240,6 +3244,10 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
rate2 += intra_cost_penalty;
distortion2 = distortion_y + distortion_uv;
} else {
#if CONFIG_REF_MV
mbmi->ref_mv_idx = 0;
ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
#endif
this_rd = handle_inter_mode(
cpi, x, bsize, &rate2, &distortion2, &skippable, &rate_y, &rate_uv,
&disable_skip, frame_mv, mi_row, mi_col, single_newmv,
@ -3247,17 +3255,16 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
&mask_filter, filter_cache);
#if CONFIG_REF_MV
mbmi->ref_mv_idx = 0;
if (!comp_pred && mbmi->mode == NEARMV &&
mbmi_ext->ref_mv_count[ref_frame] > 2) {
mbmi_ext->ref_mv_count[ref_frame_type] > 2) {
int_mv backup_mv = frame_mv[NEARMV][ref_frame];
int_mv cur_mv = mbmi_ext->ref_mv_stack[ref_frame][2].this_mv;
MB_MODE_INFO backup_mbmi = *mbmi;
int64_t tmp_ref_rd = this_rd;
int ref_idx;
int ref_set = AOMMIN(2, mbmi_ext->ref_mv_count[ref_frame] - 2);
int ref_set = AOMMIN(2, mbmi_ext->ref_mv_count[ref_frame_type] - 2);
rate2 += av1_cost_bit(128, 0);
if (this_rd < INT64_MAX) {
@ -3290,6 +3297,8 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
int64_t dummy_mask_filter = 0;
int_mv dummy_single_newmv[MAX_REF_FRAMES] = { { 0 } };
mbmi->ref_mv_idx = 1 + ref_idx;
frame_mv[NEARMV][ref_frame] = cur_mv;
tmp_alt_rd = handle_inter_mode(cpi, x, bsize,
&tmp_rate, &tmp_dist, &tmp_skip,
@ -3305,7 +3314,7 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
}
tmp_rate += av1_cost_bit(128, 1);
if (mbmi_ext->ref_mv_count[ref_frame] > 3)
if (mbmi_ext->ref_mv_count[ref_frame_type] > 3)
tmp_rate += av1_cost_bit(128, ref_idx);
if (tmp_alt_rd < INT64_MAX) {
@ -3329,7 +3338,7 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
this_rd = tmp_alt_rd;
mbmi->ref_mv_idx = 1 + ref_idx;
// Indicator of the effective nearmv reference motion vector.
best_ref_mv_idx[ref_frame] = 1 + ref_idx;
best_ref_mv_idx[ref_frame_type] = 1 + ref_idx;
tmp_ref_rd = tmp_alt_rd;
backup_mbmi = *mbmi;
} else {
@ -3556,8 +3565,9 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
}
if (mbmi_ext->ref_mv_count[rf_type] > 1) {
nearmv[0] = mbmi_ext->ref_mv_stack[rf_type][1].this_mv;
nearmv[1] = mbmi_ext->ref_mv_stack[rf_type][1].comp_mv;
const int ref_mv_idx = best_ref_mv_idx[rf_type] + 1;
nearmv[0] = mbmi_ext->ref_mv_stack[rf_type][ref_mv_idx].this_mv;
nearmv[1] = mbmi_ext->ref_mv_stack[rf_type][ref_mv_idx].comp_mv;
}
for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) {
@ -3603,8 +3613,10 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
best_mbmode.mode = ZEROMV;
}
if (best_mbmode.mode == NEARMV && best_mbmode.ref_frame[1] == NONE)
best_mbmode.ref_mv_idx = best_ref_mv_idx[best_mbmode.ref_frame[0]];
if (best_mbmode.mode == NEARMV) {
uint8_t ref_frame_type = av1_ref_frame_type(best_mbmode.ref_frame);
best_mbmode.ref_mv_idx = best_ref_mv_idx[ref_frame_type];
}
#endif
if (best_mode_index < 0 || best_rd >= best_rd_so_far) {