From 3944cfb14db2ceb2836a718a2144e9edd7d3c54c Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Wed, 13 Jan 2016 09:03:15 -0800 Subject: [PATCH] Handle single ref mv pair in the candidate list for compound mode This commit considers the case where a single reference motion vector pair is found in the candidate list. It treats this pair as the effective motion vector for nearestmv mode. This improves the coding performance by 0.06% for stdhd sets. Change-Id: I9ce12f456b52912933e05c18c3841a78c26155d2 --- vp10/decoder/decodemv.c | 9 +++++++ vp10/encoder/rdopt.c | 52 ++++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c index 997c19e67..df0ec057b 100644 --- a/vp10/decoder/decodemv.c +++ b/vp10/decoder/decodemv.c @@ -886,6 +886,15 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi, mbmi->mode != ZEROMV) { uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); + if (xd->ref_mv_count[ref_frame_type] == 1 && mbmi->mode == NEARESTMV) { + int i; + 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) + lower_mv_precision(&nearestmv[i].as_mv, allow_hp); + } + if (xd->ref_mv_count[ref_frame_type] > 1) { int i; nearestmv[0] = xd->ref_mv_stack[ref_frame_type][0].this_mv; diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index f98382595..753bd8e7e 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -4464,7 +4464,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x, #if CONFIG_REF_MV if (this_mode == NEARESTMV && is_comp_pred) { uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); - if (mbmi_ext->ref_mv_count[ref_frame_type] > 1) { + if (mbmi_ext->ref_mv_count[ref_frame_type] > 0) { cur_mv[0] = mbmi_ext->ref_mv_stack[ref_frame_type][0].this_mv; cur_mv[1] = mbmi_ext->ref_mv_stack[ref_frame_type][0].comp_mv; @@ -5684,39 +5684,37 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi, best_mbmode.mode = ZEROMV; } else { uint8_t rf_type = vp10_ref_frame_type(best_mbmode.ref_frame); - if (mbmi_ext->ref_mv_count[rf_type] > 1) { - int i; - int_mv nearestmv[2], nearmv[2]; - const int allow_hp = cm->allow_high_precision_mv; + int i; + const int allow_hp = cm->allow_high_precision_mv; + int_mv nearestmv[2] = { frame_mv[NEARESTMV][refs[0]], + frame_mv[NEARESTMV][refs[1]] }; + + int_mv nearmv[2] = { frame_mv[NEARMV][refs[0]], + frame_mv[NEARMV][refs[1]] }; + if (mbmi_ext->ref_mv_count[rf_type] >= 1) { nearestmv[0] = mbmi_ext->ref_mv_stack[rf_type][0].this_mv; nearestmv[1] = mbmi_ext->ref_mv_stack[rf_type][0].comp_mv; + } + + 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; + } - for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { - lower_mv_precision(&nearestmv[i].as_mv, allow_hp); - lower_mv_precision(&nearmv[i].as_mv, allow_hp); - } - - if (nearestmv[0].as_int == best_mbmode.mv[0].as_int && - nearestmv[1].as_int == best_mbmode.mv[1].as_int) - best_mbmode.mode = NEARESTMV; - else if (nearmv[0].as_int == best_mbmode.mv[0].as_int && - nearmv[1].as_int == best_mbmode.mv[1].as_int) - best_mbmode.mode = NEARMV; - else if (best_mbmode.mv[0].as_int == 0 && best_mbmode.mv[1].as_int == 0) - best_mbmode.mode = ZEROMV; - } else { - if (frame_mv[NEARESTMV][refs[0]].as_int == best_mbmode.mv[0].as_int && - (frame_mv[NEARESTMV][refs[1]].as_int == best_mbmode.mv[1].as_int)) - best_mbmode.mode = NEARESTMV; - else if (frame_mv[NEARMV][refs[0]].as_int == best_mbmode.mv[0].as_int && - (frame_mv[NEARMV][refs[1]].as_int == best_mbmode.mv[1].as_int)) - best_mbmode.mode = NEARMV; - else if (best_mbmode.mv[0].as_int == 0 && best_mbmode.mv[1].as_int == 0) - best_mbmode.mode = ZEROMV; + for (i = 0; i < MAX_MV_REF_CANDIDATES; ++i) { + lower_mv_precision(&nearestmv[i].as_mv, allow_hp); + lower_mv_precision(&nearmv[i].as_mv, allow_hp); } + + if (nearestmv[0].as_int == best_mbmode.mv[0].as_int && + nearestmv[1].as_int == best_mbmode.mv[1].as_int) + best_mbmode.mode = NEARESTMV; + else if (nearmv[0].as_int == best_mbmode.mv[0].as_int && + nearmv[1].as_int == best_mbmode.mv[1].as_int) + best_mbmode.mode = NEARMV; + else if (best_mbmode.mv[0].as_int == 0 && best_mbmode.mv[1].as_int == 0) + best_mbmode.mode = ZEROMV; } #else if (frame_mv[NEARESTMV][refs[0]].as_int == best_mbmode.mv[0].as_int && -- 2.40.0