Fix inter cost in bipred

The cost of coding MV ref indices and MV direction was added to bitcost
but not inter cost. Fixed by adding the extra bits to inter as well.
This commit is contained in:
Arttu Ylä-Outinen 2017-06-01 08:49:46 +03:00
parent edbe00763e
commit e9cf15465e

View file

@ -1579,14 +1579,16 @@ static void search_pu_inter(encoder_state_t * const state,
cost += calc_mvd(state, merge_cand[i].mv[0][0], merge_cand[i].mv[0][1], 0, mv_cand, merge_cand, 0, ref_idx, &bitcost[0]);
cost += calc_mvd(state, merge_cand[i].mv[1][0], merge_cand[i].mv[1][1], 0, mv_cand, merge_cand, 0, ref_idx, &bitcost[1]);
if (cost < *inter_cost) {
cur_cu->inter.mv_dir = 3;
uint8_t mv_ref_coded[2] = {
const uint8_t mv_ref_coded[2] = {
state->frame->refmap[merge_cand[i].ref[0]].idx,
state->frame->refmap[merge_cand[j].ref[1]].idx
};
const int extra_bits = mv_ref_coded[0] + mv_ref_coded[1] + 2 /* mv dir cost */;
cost += state->lambda_sqrt * extra_bits + 0.5;
if (cost < *inter_cost) {
cur_cu->inter.mv_dir = 3;
cur_cu->inter.mv_ref[0] = merge_cand[i].ref[0];
cur_cu->inter.mv_ref[1] = merge_cand[j].ref[1];
@ -1634,8 +1636,9 @@ static void search_pu_inter(encoder_state_t * const state,
}
CU_SET_MV_CAND(cur_cu, reflist, cu_mv_cand);
}
*inter_cost = cost;
*inter_bitcost = bitcost[0] + bitcost[1] + cur_cu->inter.mv_dir - 1 + mv_ref_coded[0] + mv_ref_coded[1];
*inter_bitcost = bitcost[0] + bitcost[1] + extra_bits;
}
}
}