ref: 0c80065694924cafd55a0fd2ded298eecb8b2015
parent: 3e51acafec730e118edc2660a8c0a94f04c327e8
author: Dmitry Kovalev <[email protected]>
date: Tue Aug 6 07:04:31 EDT 2013
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
--- a/vp9/common/vp9_pred_common.h
+++ b/vp9/common/vp9_pred_common.h
@@ -57,12 +57,6 @@
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,
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -370,9 +370,9 @@
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;
}
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -477,12 +477,13 @@
}
}
- 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) {
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -333,13 +333,14 @@
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 @@
// 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 @@
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,10 +434,9 @@
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;
@@ -446,9 +443,8 @@
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];
- }
}
}
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -2412,13 +2412,12 @@
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,