From 0c80065694924cafd55a0fd2ded298eecb8b2015 Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Tue, 6 Aug 2013 11:04:31 -0700 Subject: [PATCH] Inlining vp9_get_pred_probs_switchable_interp function. There was no benefit having this function. For example, inside read_switchable_filter_type switchable filter context was calculated twice. Change-Id: I79cd5bf95cbc0f6d8bf91a2e32289e01b18dcff1 --- vp9/common/vp9_pred_common.h | 6 ------ vp9/decoder/vp9_decodemv.c | 4 ++-- vp9/encoder/vp9_bitstream.c | 7 ++++--- vp9/encoder/vp9_encodeframe.c | 34 +++++++++++++++------------------- vp9/encoder/vp9_rdopt.c | 13 ++++++------- 5 files changed, 27 insertions(+), 37 deletions(-) diff --git a/vp9/common/vp9_pred_common.h b/vp9/common/vp9_pred_common.h index 238290b41..a09558fa4 100644 --- a/vp9/common/vp9_pred_common.h +++ b/vp9/common/vp9_pred_common.h @@ -57,12 +57,6 @@ void vp9_set_pred_flag_mbskip(VP9_COMMON *cm, BLOCK_SIZE_TYPE bsize, unsigned char vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd); -static INLINE const vp9_prob *vp9_get_pred_probs_switchable_interp( - const VP9_COMMON *cm, const MACROBLOCKD *xd) { - const int pred_context = vp9_get_pred_context_switchable_interp(xd); - return &cm->fc.switchable_interp_prob[pred_context][0]; -} - unsigned char vp9_get_pred_context_intra_inter(const MACROBLOCKD *xd); static INLINE vp9_prob vp9_get_pred_prob_intra_inter(const VP9_COMMON *cm, diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c index 2d9be6a2d..074b3e9ac 100644 --- a/vp9/decoder/vp9_decodemv.c +++ b/vp9/decoder/vp9_decodemv.c @@ -370,9 +370,9 @@ static INLINE INTERPOLATIONFILTERTYPE read_switchable_filter_type( VP9D_COMP *pbi, vp9_reader *r) { VP9_COMMON *const cm = &pbi->common; MACROBLOCKD *const xd = &pbi->mb; - const vp9_prob *probs = vp9_get_pred_probs_switchable_interp(cm, xd); - const int type = treed_read(r, vp9_switchable_interp_tree, probs); const int ctx = vp9_get_pred_context_switchable_interp(xd); + const int type = treed_read(r, vp9_switchable_interp_tree, + cm->fc.switchable_interp_prob[ctx]); ++cm->counts.switchable_interp[ctx][type]; return type; } diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index e79bc8113..6a50c80d4 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -477,12 +477,13 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc) { } } - if (cpi->common.mcomp_filter_type == SWITCHABLE) { + if (pc->mcomp_filter_type == SWITCHABLE) { + const int ctx = vp9_get_pred_context_switchable_interp(xd); write_token(bc, vp9_switchable_interp_tree, - vp9_get_pred_probs_switchable_interp(&cpi->common, xd), + pc->fc.switchable_interp_prob[ctx], &vp9_switchable_interp_encodings[mi->interp_filter]); } else { - assert(mi->interp_filter == cpi->common.mcomp_filter_type); + assert(mi->interp_filter == pc->mcomp_filter_type); } if (bsize < BLOCK_8X8) { diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 8bd35008f..82859c5d7 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -333,13 +333,14 @@ void vp9_activity_masking(VP9_COMP *cpi, MACROBLOCK *x) { static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, BLOCK_SIZE_TYPE bsize, int output_enabled) { int i, x_idx, y; - MACROBLOCK * const x = &cpi->mb; - MACROBLOCKD * const xd = &x->e_mbd; + VP9_COMMON *const cm = &cpi->common; + MACROBLOCK *const x = &cpi->mb; + MACROBLOCKD *const xd = &x->e_mbd; MODE_INFO *mi = &ctx->mic; - MB_MODE_INFO * const mbmi = &xd->mode_info_context->mbmi; + MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; int mb_mode_index = ctx->best_mode_index; - const int mis = cpi->common.mode_info_stride; + const int mis = cm->mode_info_stride; const int mi_width = num_8x8_blocks_wide_lookup[bsize]; const int mi_height = num_8x8_blocks_high_lookup[bsize]; @@ -351,15 +352,12 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, // Restore the coding context of the MB to that that was in place // when the mode was picked for it - for (y = 0; y < mi_height; y++) { - for (x_idx = 0; x_idx < mi_width; x_idx++) { + for (y = 0; y < mi_height; y++) + for (x_idx = 0; x_idx < mi_width; x_idx++) if ((xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)) + mi_width > x_idx - && (xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)) + mi_height > y) { - MODE_INFO *mi_addr = xd->mode_info_context + x_idx + y * mis; - *mi_addr = *mi; - } - } - } + && (xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)) + mi_height > y) + xd->mode_info_context[x_idx + y * mis] = *mi; + // FIXME(rbultje) I'm pretty sure this should go to the end of this block // (i.e. after the output_enabled) if (bsize < BLOCK_32X32) { @@ -383,7 +381,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, cpi->rd_tx_select_diff[i] += ctx->tx_rd_diff[i]; } - if (cpi->common.frame_type == KEY_FRAME) { + if (cm->frame_type == KEY_FRAME) { // Restore the coding modes to that held in the coding context // if (mb_mode == I4X4_PRED) // for (i = 0; i < 16; i++) @@ -436,19 +434,17 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, xd->mode_info_context[mis * j + i].mbmi = *mbmi; } - if (cpi->common.mcomp_filter_type == SWITCHABLE - && is_inter_mode(mbmi->mode)) { - ++cpi->common.counts.switchable_interp[ - vp9_get_pred_context_switchable_interp(xd)][mbmi->interp_filter]; + if (cm->mcomp_filter_type == SWITCHABLE && is_inter_mode(mbmi->mode)) { + const int ctx = vp9_get_pred_context_switchable_interp(xd); + ++cm->counts.switchable_interp[ctx][mbmi->interp_filter]; } cpi->rd_comp_pred_diff[SINGLE_PREDICTION_ONLY] += ctx->single_pred_diff; cpi->rd_comp_pred_diff[COMP_PREDICTION_ONLY] += ctx->comp_pred_diff; cpi->rd_comp_pred_diff[HYBRID_PREDICTION] += ctx->hybrid_pred_diff; - for (i = 0; i <= VP9_SWITCHABLE_FILTERS; i++) { + for (i = 0; i <= VP9_SWITCHABLE_FILTERS; i++) cpi->rd_filter_diff[i] += ctx->best_filter_diff[i]; - } } } diff --git a/vp9/encoder/vp9_rdopt.c b/vp9/encoder/vp9_rdopt.c index fd6713391..8a5ae4476 100644 --- a/vp9/encoder/vp9_rdopt.c +++ b/vp9/encoder/vp9_rdopt.c @@ -2412,13 +2412,12 @@ static YV12_BUFFER_CONFIG *get_scaled_ref_frame(VP9_COMP *cpi, int ref_frame) { return scaled_ref_frame; } -static INLINE int get_switchable_rate(MACROBLOCK *x) { - MACROBLOCKD *xd = &x->e_mbd; - MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; - - const int c = vp9_get_pred_context_switchable_interp(xd); - const int m = mbmi->interp_filter; - return SWITCHABLE_INTERP_RATE_FACTOR * x->switchable_interp_costs[c][m]; +static INLINE int get_switchable_rate(const MACROBLOCK *x) { + const MACROBLOCKD *const xd = &x->e_mbd; + const MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi; + const int ctx = vp9_get_pred_context_switchable_interp(xd); + return SWITCHABLE_INTERP_RATE_FACTOR * + x->switchable_interp_costs[ctx][mbmi->interp_filter]; } static void single_motion_search(VP9_COMP *cpi, MACROBLOCK *x, -- 2.40.0