Don't recalculate mv_ref costs for each block/partition.
Changes cost_mv_ref() into doing a LUT into pre-calculated cost arrays instead. Encode time of first 50 frames of bus (speed 0) @ 1500kbps goes from 2min11.6 to 2min10.9, i.e. 0.5% faster overall. Change-Id: If186e92c34c201b29cbbc058785a15c9c09e433a
This commit is contained in:
parent
5a73254918
commit
8fde07a3ae
@ -115,6 +115,7 @@ struct macroblock {
|
||||
int **mvsadcost;
|
||||
|
||||
int mbmode_cost[MB_MODE_COUNT];
|
||||
unsigned inter_mode_cost[INTER_MODE_CONTEXTS][MB_MODE_COUNT - NEARESTMV];
|
||||
int intra_uv_mode_cost[2][MB_MODE_COUNT];
|
||||
int y_mode_costs[VP9_INTRA_MODES][VP9_INTRA_MODES][VP9_INTRA_MODES];
|
||||
int switchable_interp_costs[VP9_SWITCHABLE_FILTERS + 1]
|
||||
|
@ -276,6 +276,16 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int qindex) {
|
||||
cpi->mb.nmvcost_hp : cpi->mb.nmvcost,
|
||||
&cpi->common.fc.nmvc,
|
||||
cpi->mb.e_mbd.allow_high_precision_mv, 1, 1);
|
||||
|
||||
for (i = 0; i < INTER_MODE_CONTEXTS; i++) {
|
||||
MB_PREDICTION_MODE m;
|
||||
|
||||
for (m = NEARESTMV; m < MB_MODE_COUNT; m++)
|
||||
cpi->mb.inter_mode_cost[i][m - NEARESTMV] =
|
||||
cost_token(vp9_sb_mv_ref_tree,
|
||||
cpi->common.fc.inter_mode_probs[i],
|
||||
vp9_sb_mv_ref_encoding_array - NEARESTMV + m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1518,19 +1528,17 @@ static int64_t rd_pick_intra_sbuv_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
return best_rd;
|
||||
}
|
||||
|
||||
int vp9_cost_mv_ref(VP9_COMP *cpi,
|
||||
MB_PREDICTION_MODE m,
|
||||
const int mode_context) {
|
||||
MACROBLOCKD *xd = &cpi->mb.e_mbd;
|
||||
static int cost_mv_ref(VP9_COMP *cpi,
|
||||
MB_PREDICTION_MODE m,
|
||||
const int mode_context) {
|
||||
MACROBLOCK *const x = &cpi->mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
int segment_id = xd->mode_info_context->mbmi.segment_id;
|
||||
|
||||
// Dont account for mode here if segment skip is enabled.
|
||||
if (!vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP)) {
|
||||
VP9_COMMON *pc = &cpi->common;
|
||||
assert(NEARESTMV <= m && m <= NEWMV);
|
||||
return cost_token(vp9_sb_mv_ref_tree,
|
||||
pc->fc.inter_mode_probs[mode_context],
|
||||
vp9_sb_mv_ref_encoding_array - NEARESTMV + m);
|
||||
return x->inter_mode_cost[mode_context][m - NEARESTMV];
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
@ -1607,8 +1615,8 @@ static int labels2mode(MACROBLOCK *x, int i,
|
||||
break;
|
||||
}
|
||||
|
||||
cost = vp9_cost_mv_ref(cpi, this_mode,
|
||||
mbmi->mb_mode_context[mbmi->ref_frame[0]]);
|
||||
cost = cost_mv_ref(cpi, this_mode,
|
||||
mbmi->mb_mode_context[mbmi->ref_frame[0]]);
|
||||
|
||||
mic->bmi[i].as_mv[0].as_int = this_mv->as_int;
|
||||
if (mbmi->ref_frame[1] > 0)
|
||||
@ -2647,8 +2655,8 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
|
||||
* are only three options: Last/Golden, ARF/Last or Golden/ARF, or in other
|
||||
* words if you present them in that order, the second one is always known
|
||||
* if the first is known */
|
||||
*rate2 += vp9_cost_mv_ref(cpi, this_mode,
|
||||
mbmi->mb_mode_context[mbmi->ref_frame[0]]);
|
||||
*rate2 += cost_mv_ref(cpi, this_mode,
|
||||
mbmi->mb_mode_context[mbmi->ref_frame[0]]);
|
||||
|
||||
pred_exists = 0;
|
||||
interpolating_intpel_seen = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user