diff options
author | Ronald S. Bultje <rbultje@google.com> | 2013-07-03 10:54:36 -0700 |
---|---|---|
committer | Ronald S. Bultje <rbultje@google.com> | 2013-07-08 16:22:39 -0700 |
commit | 8fde07a3aeef421ed7b15c424e7fad2ede46f9bf (patch) | |
tree | 9311f4611f680ef043f4df070e01edcd6cd67721 /vp9/encoder | |
parent | 5a73254918b7f37582a606a6621a9eb0d05abb06 (diff) | |
download | libvpx-8fde07a3aeef421ed7b15c424e7fad2ede46f9bf.tar libvpx-8fde07a3aeef421ed7b15c424e7fad2ede46f9bf.tar.gz libvpx-8fde07a3aeef421ed7b15c424e7fad2ede46f9bf.tar.bz2 libvpx-8fde07a3aeef421ed7b15c424e7fad2ede46f9bf.zip |
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
Diffstat (limited to 'vp9/encoder')
-rw-r--r-- | vp9/encoder/vp9_block.h | 1 | ||||
-rw-r--r-- | vp9/encoder/vp9_rdopt.c | 32 |
2 files changed, 21 insertions, 12 deletions
diff --git a/vp9/encoder/vp9_block.h b/vp9/encoder/vp9_block.h index 7275e85d2..d575647ea 100644 --- a/vp9/encoder/vp9_block.h +++ b/vp9/encoder/vp9_block.h @@ -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] diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index d86483d95..b485ca45c 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -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; |