]> granicus.if.org Git - libvpx/commitdiff
Inlining vp9_get_pred_probs_switchable_interp function.
authorDmitry Kovalev <dkovalev@google.com>
Tue, 6 Aug 2013 18:04:31 +0000 (11:04 -0700)
committerDmitry Kovalev <dkovalev@google.com>
Tue, 6 Aug 2013 18:04:31 +0000 (11:04 -0700)
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
vp9/decoder/vp9_decodemv.c
vp9/encoder/vp9_bitstream.c
vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_rdopt.c

index 238290b41e93167798083b35ab5ee45683a27e7c..a09558fa43fa72e18df58b89ffa6426e23ff3cf5 100644 (file)
@@ -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,
index 2d9be6a2d482991c5980ab85b7be430d2d4fd450..074b3e9ac6c8315c9dcb4d88684caf32f331b72f 100644 (file)
@@ -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;
 }
index e79bc8113efbcface65eae2ae4f336dbf9a5f7e1..6a50c80d431b7db667b740d4762cd58da13499d2 100644 (file)
@@ -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) {
index 8bd35008f30996b20f085833b0c93ecafb1878f0..82859c5d7f2fbeb7d312df8251ef4899000dc21a 100644 (file)
@@ -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];
-    }
   }
 }
 
index fd6713391786ffa2a662ce73620e98cb0120bde4..8a5ae44767ce83a2d3c756b99511b5bd3502d028 100644 (file)
@@ -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,