Fix inconsistent use of ref_mv_idx.
"+ 1" has been added in a few locations to match the indices for the
context for the CDFs and the motion vectors.
Suggested fix (of removing +1s entirely) can then be implemented
without further affecting the overall behaviour of the encoder and
decoder.
BUG=aomedia:858
Change-Id: I650a618d3fda1d27bd3550d25ad1ac52e4365061
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 9bce3bf..8fff1dd 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -5980,7 +5980,9 @@
best_mv->col >>= 3;
best_mv->row >>= 3;
- av1_set_mvcost(x, refs[id], id, mbmi->ref_mv_idx);
+ av1_set_mvcost(
+ x, refs[id], id,
+ mbmi->ref_mv_idx + (have_nearmv_in_inter_mode(mbmi->mode) ? 1 : 0));
// Small-range full-pixel motion search.
bestsme = av1_refining_search_8p_c(x, sadpb, search_range,
@@ -6039,7 +6041,9 @@
xd->plane[i].pre[ref] = backup_yv12[ref][i];
}
- av1_set_mvcost(x, refs[ref], ref, mbmi->ref_mv_idx);
+ av1_set_mvcost(
+ x, refs[ref], ref,
+ mbmi->ref_mv_idx + (have_nearmv_in_inter_mode(mbmi->mode) ? 1 : 0));
*rate_mv += av1_mv_bit_cost(&frame_mv[refs[ref]].as_mv,
&x->mbmi_ext->ref_mvs[refs[ref]][0].as_mv,
@@ -6351,7 +6355,9 @@
av1_set_mv_search_range(&x->mv_limits, &ref_mv);
- av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
+ av1_set_mvcost(
+ x, ref, ref_idx,
+ mbmi->ref_mv_idx + (have_nearmv_in_inter_mode(mbmi->mode) ? 1 : 0));
// Work out the size of the first step in the mv step search.
// 0 here is maximum length first step. 1 is AOMMAX >> 1 etc.
@@ -6680,7 +6686,9 @@
best_mv->col >>= 3;
best_mv->row >>= 3;
- av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
+ av1_set_mvcost(
+ x, ref, ref_idx,
+ mbmi->ref_mv_idx + (have_nearmv_in_inter_mode(mbmi->mode) ? 1 : 0));
// Small-range full-pixel motion search.
bestsme = av1_refining_search_8p_c(x, sadpb, search_range,
@@ -6732,7 +6740,9 @@
xd->plane[i].pre[ref_idx] = backup_yv12[i];
}
- av1_set_mvcost(x, ref, ref_idx, mbmi->ref_mv_idx);
+ av1_set_mvcost(
+ x, ref, ref_idx,
+ mbmi->ref_mv_idx + (have_nearmv_in_inter_mode(mbmi->mode) ? 1 : 0));
*rate_mv += av1_mv_bit_cost(this_mv, &ref_mv.as_mv, x->nmvjointcost,
x->mvcost, MV_COST_WEIGHT);
}
@@ -7399,7 +7409,8 @@
compound_single_motion_search_interinter(
cpi, x, bsize, frame_mv, mi_row, mi_col, NULL, 0, rate_mv, 0, 1);
} else {
- av1_set_mvcost(x, refs[1], 1, mbmi->ref_mv_idx);
+ av1_set_mvcost(x, refs[1], 1,
+ mbmi->ref_mv_idx + (this_mode == NEAR_NEWMV ? 1 : 0));
*rate_mv = av1_mv_bit_cost(&frame_mv[refs[1]].as_mv,
&mbmi_ext->ref_mvs[refs[1]][0].as_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
@@ -7413,7 +7424,8 @@
compound_single_motion_search_interinter(
cpi, x, bsize, frame_mv, mi_row, mi_col, NULL, 0, rate_mv, 0, 0);
} else {
- av1_set_mvcost(x, refs[0], 0, mbmi->ref_mv_idx);
+ av1_set_mvcost(x, refs[0], 0,
+ mbmi->ref_mv_idx + (this_mode == NEW_NEARMV ? 1 : 0));
*rate_mv = av1_mv_bit_cost(&frame_mv[refs[0]].as_mv,
&mbmi_ext->ref_mvs[refs[0]][0].as_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);