Commit efbbe700 authored by Fergus Simpson's avatar Fergus Simpson

handle_inter_mode: loop mv rate calculation

In two cases the bit cost of a movement vector was calculated twice
and summed when there were mutliple refs. The first result was
assigned and the second was added. Now they are both added in a loop
to reduce duplication.

Change-Id: Iadcaec1dc4c2583fbb5cfd07bea6480756692a01
parent 4470af19
......@@ -8034,18 +8034,15 @@ static int64_t handle_inter_mode(
joint_motion_search(cpi, x, bsize, frame_mv, mi_row, mi_col, NULL,
single_newmv, &rate_mv, 0);
} else {
rate_mv = 0;
for (i = 0; i < 2; ++i) {
#if CONFIG_REF_MV
av1_set_mvcost(x, mbmi->ref_frame[0], 0, mbmi->ref_mv_idx);
#endif // CONFIG_REF_MV
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);
#if CONFIG_REF_MV
av1_set_mvcost(x, mbmi->ref_frame[1], 1, mbmi->ref_mv_idx);
av1_set_mvcost(x, mbmi->ref_frame[i], i, mbmi->ref_mv_idx);
#endif // CONFIG_REF_MV
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);
rate_mv += av1_mv_bit_cost(
&frame_mv[refs[i]].as_mv, &mbmi_ext->ref_mvs[refs[i]][0].as_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
}
}
} else if (this_mode == NEAREST_NEWMV || this_mode == NEAR_NEWMV) {
frame_mv[refs[1]].as_int = single_newmv[refs[1]].as_int;
......@@ -8067,18 +8064,15 @@ static int64_t handle_inter_mode(
joint_motion_search(cpi, x, bsize, frame_mv, mi_row, mi_col,
single_newmv, &rate_mv, 0);
} else {
rate_mv = 0;
for (i = 0; i < 2; ++i) {
#if CONFIG_REF_MV
av1_set_mvcost(x, mbmi->ref_frame[0], 0, mbmi->ref_mv_idx);
#endif // CONFIG_REF_MV
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);
#if CONFIG_REF_MV
av1_set_mvcost(x, mbmi->ref_frame[1], 1, mbmi->ref_mv_idx);
av1_set_mvcost(x, mbmi->ref_frame[i], i, mbmi->ref_mv_idx);
#endif // CONFIG_REF_MV
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);
rate_mv += av1_mv_bit_cost(
&frame_mv[refs[i]].as_mv, &mbmi_ext->ref_mvs[refs[i]][0].as_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
}
}
#endif // CONFIG_EXT_INTER
} else {
......
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