shithub: libvpx

Download patch

ref: 03fe08ca3033d0386919211e66079894add2fea9
parent: b4148c3a03a1f91d3b6d931d22d9cd5c44879bfe
author: Jingning Han <jingning@google.com>
date: Mon Oct 7 07:20:50 EDT 2013

Deprecate the use of PARTITION_INFO from encoder

Use b_mode_info to store the inter prediction mode of sub8x8 block,
in replacement of the use of partition_info. Remove redundant buffer
update for partition_info. For bus_cif at 2000 kbps, this seem to make
speed 0 about 1% faster.

Change-Id: Id1b3be45e75a24fb4b42335ac480c23e440978f6

--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -406,8 +406,6 @@
   const BLOCK_SIZE bsize = mi->sb_type;
   const int allow_hp = xd->allow_high_precision_mv;
 
-  x->partition_info = x->pi + (m - cm->mi);
-
 #ifdef ENTROPY_STATS
   active_section = 9;
 #endif
@@ -489,7 +487,7 @@
       for (idy = 0; idy < 2; idy += num_4x4_blocks_high) {
         for (idx = 0; idx < 2; idx += num_4x4_blocks_wide) {
           const int j = idy * 2 + idx;
-          const MB_PREDICTION_MODE blockmode = x->partition_info->bmi[j].mode;
+          const MB_PREDICTION_MODE blockmode = m->bmi[j].as_mode;
           write_sb_mv_ref(bc, blockmode, mv_ref_p);
           ++cm->counts.inter_mode[mi->mode_context[rf]]
                                  [inter_mode_offset(blockmode)];
--- a/vp9/encoder/vp9_block.h
+++ b/vp9/encoder/vp9_block.h
@@ -23,16 +23,9 @@
   int offset;
 } search_site;
 
-typedef struct {
-  struct {
-    MB_PREDICTION_MODE mode;
-  } bmi[4];
-} PARTITION_INFO;
-
 // Structure to hold snapshot of coding context during the mode picking process
 typedef struct {
   MODE_INFO mic;
-  PARTITION_INFO partition_info;
   unsigned char zcoeff_blk[256];
   int skip;
   int_mv best_ref_mv;
@@ -87,9 +80,6 @@
 
   MACROBLOCKD e_mbd;
   int skip_block;
-  PARTITION_INFO *partition_info; /* work pointer */
-  PARTITION_INFO *pi;   /* Corresponds to upper left visible macroblock */
-  PARTITION_INFO *pip;  /* Base of allocated array */
 
   search_site *ss;
   int ss_count;
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -381,7 +381,6 @@
   }
 
   if (is_inter_block(mbmi) && mbmi->sb_type < BLOCK_8X8) {
-    *x->partition_info = ctx->partition_info;
     mbmi->mv[0].as_int = mi->bmi[3].as_mv[0].as_int;
     mbmi->mv[1].as_int = mi->bmi[3].as_mv[1].as_int;
   }
@@ -491,9 +490,6 @@
   // Activity map pointer
   x->mb_activity_ptr = &cpi->mb_activity_map[idx_map];
   x->active_ptr = cpi->active_map + idx_map;
-
-  /* pointers to mode info contexts */
-  x->partition_info = x->pi + idx_str;
 
   xd->mi_8x8 = cm->mi_grid_visible + idx_str;
   xd->prev_mi_8x8 = cm->prev_mi_grid_visible + idx_str;
--- a/vp9/encoder/vp9_encodemv.c
+++ b/vp9/encoder/vp9_encodemv.c
@@ -337,7 +337,7 @@
     for (idy = 0; idy < 2; idy += num_4x4_h) {
       for (idx = 0; idx < 2; idx += num_4x4_w) {
         const int i = idy * 2 + idx;
-        if (x->partition_info->bmi[i].mode == NEWMV)
+        if (mi->bmi[i].as_mode == NEWMV)
           inc_mvs(mi->bmi[i].as_mv, best_ref_mv, is_compound, &cpi->NMVcount);
       }
     }
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -515,7 +515,6 @@
   setup_pre_planes(xd, 0, lst_yv12, 0, 0, NULL);
   setup_dst_planes(xd, new_yv12, 0, 0);
 
-  x->partition_info = x->pi;
   xd->mi_8x8 = cm->mi_grid_visible;
   // required for vp9_frame_init_quantizer
   xd->this_mi =
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -309,9 +309,6 @@
   cpi->mb_activity_map = 0;
   vpx_free(cpi->mb_norm_activity_map);
   cpi->mb_norm_activity_map = 0;
-
-  vpx_free(cpi->mb.pip);
-  cpi->mb.pip = 0;
 }
 
 // Computes a q delta (in "q index" terms) to get from a starting q value
@@ -983,20 +980,6 @@
                        "Failed to allocate altref buffer");
 }
 
-static int alloc_partition_data(VP9_COMP *cpi) {
-  vpx_free(cpi->mb.pip);
-
-  cpi->mb.pip = vpx_calloc(cpi->common.mode_info_stride *
-                           (cpi->common.mi_rows + MI_BLOCK_SIZE),
-                           sizeof(PARTITION_INFO));
-  if (!cpi->mb.pip)
-    return 1;
-
-  cpi->mb.pi = cpi->mb.pip + cpi->common.mode_info_stride + 1;
-
-  return 0;
-}
-
 void vp9_alloc_compressor_data(VP9_COMP *cpi) {
   VP9_COMMON *cm = &cpi->common;
 
@@ -1003,10 +986,6 @@
   if (vp9_alloc_frame_buffers(cm, cm->width, cm->height))
     vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
                        "Failed to allocate frame buffers");
-
-  if (alloc_partition_data(cpi))
-    vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
-                       "Failed to allocate partition data");
 
   if (vp9_alloc_frame_buffer(&cpi->last_frame_uf,
                              cm->width, cm->height,
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -1499,7 +1499,8 @@
   if (has_second_rf)
     mic->bmi[i].as_mv[1].as_int = this_second_mv->as_int;
 
-  x->partition_info->bmi[i].mode = m;
+  mic->bmi[i].as_mode = m;
+
   for (idy = 0; idy < num_4x4_blocks_high; ++idy)
     for (idx = 0; idx < num_4x4_blocks_wide; ++idx)
       vpx_memcpy(&mic->bmi[i + idy * 2 + idx],
@@ -1646,7 +1647,7 @@
                                     BEST_SEG_INFO *bsi_buf, int filter_idx,
                                     int_mv seg_mvs[4][MAX_REF_FRAMES],
                                     int mi_row, int mi_col) {
-  int i, j, br = 0, idx, idy;
+  int i, br = 0, idx, idy;
   int64_t bd = 0, block_sse = 0;
   MB_PREDICTION_MODE this_mode;
   MODE_INFO *mi = x->e_mbd.mi_8x8[0];
@@ -2008,15 +2009,6 @@
         bsi->segment_rd = INT64_MAX;
         return;
       }
-
-      for (j = 1; j < num_4x4_blocks_high; ++j)
-        vpx_memcpy(&x->partition_info->bmi[i + j * 2],
-                   &x->partition_info->bmi[i],
-                   sizeof(x->partition_info->bmi[i]));
-      for (j = 1; j < num_4x4_blocks_wide; ++j)
-        vpx_memcpy(&x->partition_info->bmi[i + j],
-                   &x->partition_info->bmi[i],
-                   sizeof(x->partition_info->bmi[i]));
     }
   } /* for each label */
 
@@ -2028,7 +2020,7 @@
 
   // update the coding decisions
   for (i = 0; i < 4; ++i)
-    bsi->modes[i] = x->partition_info->bmi[i].mode;
+    bsi->modes[i] = mi->bmi[i].as_mode;
 }
 
 static int64_t rd_pick_best_mbsegmentation(VP9_COMP *cpi, MACROBLOCK *x,
@@ -2073,7 +2065,7 @@
     if (has_second_ref(mbmi))
       mi->bmi[i].as_mv[1].as_int = bsi->rdstat[i][mode_idx].mvs[1].as_int;
     xd->plane[0].eobs[i] = bsi->rdstat[i][mode_idx].eobs;
-    x->partition_info->bmi[i].mode = bsi->modes[i];
+    mi->bmi[i].as_mode = bsi->modes[i];
   }
 
   /*
@@ -2206,7 +2198,6 @@
 
 static void store_coding_context(MACROBLOCK *x, PICK_MODE_CONTEXT *ctx,
                          int mode_index,
-                         PARTITION_INFO *partition,
                          int_mv *ref_mv,
                          int_mv *second_ref_mv,
                          int64_t comp_pred_diff[NB_PREDICTION_TYPES],
@@ -2220,9 +2211,6 @@
   ctx->best_mode_index = mode_index;
   ctx->mic = *xd->this_mi;
 
-  if (partition)
-    ctx->partition_info = *partition;
-
   ctx->best_ref_mv.as_int = ref_mv->as_int;
   ctx->second_best_ref_mv.as_int = second_ref_mv->as_int;
 
@@ -3780,7 +3768,6 @@
   set_scale_factors(xd, mbmi->ref_frame[0], mbmi->ref_frame[1],
                     scale_factor);
   store_coding_context(x, ctx, best_mode_index,
-                       NULL,
                        &mbmi->ref_mvs[mbmi->ref_frame[0]][0],
                        &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 :
                                       mbmi->ref_frame[1]][0],
@@ -3839,7 +3826,6 @@
                                              cpi->common.y_dc_delta_q);
   int_mv seg_mvs[4][MAX_REF_FRAMES];
   b_mode_info best_bmodes[4];
-  PARTITION_INFO best_partition;
   int best_skip2 = 0;
   unsigned char best_zcoeff_blk[256] = { 0 };
 
@@ -4055,7 +4041,6 @@
                              &mbmi->ref_mvs[second_ref_frame][0] : NULL;
       b_mode_info tmp_best_bmodes[16];
       MB_MODE_INFO tmp_best_mbmode;
-      PARTITION_INFO tmp_best_partition;
       BEST_SEG_INFO bsi[SWITCHABLE_FILTERS];
       int pred_exists = 0;
       int uv_skippable;
@@ -4119,7 +4104,6 @@
               tmp_best_sse = total_sse;
               tmp_best_skippable = skippable;
               tmp_best_mbmode = *mbmi;
-              tmp_best_partition = *x->partition_info;
               for (i = 0; i < 4; i++)
                 tmp_best_bmodes[i] = xd->this_mi->bmi[i];
               pred_exists = 1;
@@ -4171,7 +4155,6 @@
         distortion = tmp_best_distortion;
         skippable = tmp_best_skippable;
         *mbmi = tmp_best_mbmode;
-        *x->partition_info = tmp_best_partition;
         for (i = 0; i < 4; i++)
           xd->this_mi->bmi[i] = tmp_best_bmodes[i];
       }
@@ -4299,7 +4282,6 @@
                    RDCOST(x->rdmult, x->rddiv, rate_uv, distortion_uv);
         best_mbmode = *mbmi;
         best_skip2 = this_skip2;
-        best_partition = *x->partition_info;
         vpx_memcpy(best_zcoeff_blk, x->zcoeff_blk[mbmi->tx_size],
                    sizeof(best_zcoeff_blk));
 
@@ -4457,16 +4439,9 @@
     for (i = 0; i < 4; i++)
       xd->this_mi->bmi[i].as_mode = best_bmodes[i].as_mode;
   } else {
-    for (i = 0; i < 4; i++)
-      xd->this_mi->bmi[i].as_mv[0].as_int =
-          best_bmodes[i].as_mv[0].as_int;
+    for (i = 0; i < 4; ++i)
+      vpx_memcpy(&xd->this_mi->bmi[i], &best_bmodes[i], sizeof(b_mode_info));
 
-    if (has_second_ref(mbmi))
-      for (i = 0; i < 4; i++)
-        xd->this_mi->bmi[i].as_mv[1].as_int = best_bmodes[i].as_mv[1].as_int;
-
-    *x->partition_info = best_partition;
-
     mbmi->mv[0].as_int = xd->this_mi->bmi[3].as_mv[0].as_int;
     mbmi->mv[1].as_int = xd->this_mi->bmi[3].as_mv[1].as_int;
   }
@@ -4508,7 +4483,6 @@
   set_scale_factors(xd, mbmi->ref_frame[0], mbmi->ref_frame[1],
                     scale_factor);
   store_coding_context(x, ctx, best_mode_index,
-                       &best_partition,
                        &mbmi->ref_mvs[mbmi->ref_frame[0]][0],
                        &mbmi->ref_mvs[mbmi->ref_frame[1] < 0 ? 0 :
                                       mbmi->ref_frame[1]][0],