shithub: libvpx

Download patch

ref: 430bd0c94a1352ddee807757449296e4ef3944e9
parent: c86b18894e22042e9c4e670a5a12b00a65d2c2e6
parent: 5a21de84183c10ade28a2692295fbe86dce22d44
author: Dmitry Kovalev <dkovalev@google.com>
date: Wed Jul 3 10:16:02 EDT 2013

Merge "Replacing 64 / MI_SIZE with MI_BLOCK_SIZE."

--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -11,6 +11,7 @@
 
 #include "./vpx_config.h"
 #include "vpx_mem/vpx_mem.h"
+
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_entropymode.h"
 #include "vp9/common/vp9_entropymv.h"
@@ -62,9 +63,9 @@
   vpx_free(oci->above_context[0]);
   for (i = 0; i < MAX_MB_PLANE; i++)
     oci->above_context[i] = 0;
-  oci->mip = 0;
-  oci->prev_mip = 0;
-  oci->above_seg_context = 0;
+  oci->mip = NULL;
+  oci->prev_mip = NULL;
+  oci->above_seg_context = NULL;
 }
 
 static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) {
@@ -74,7 +75,7 @@
 
   cm->mi_cols = aligned_width >> LOG2_MI_SIZE;
   cm->mi_rows = aligned_height >> LOG2_MI_SIZE;
-  cm->mode_info_stride = cm->mi_cols + 64 / MI_SIZE;
+  cm->mode_info_stride = cm->mi_cols + MI_BLOCK_SIZE;
 }
 
 static void setup_mi(VP9_COMMON *cm) {
@@ -99,6 +100,7 @@
   const int aligned_height = multiple8(height);
   const int ss_x = oci->subsampling_x;
   const int ss_y = oci->subsampling_y;
+  int mi_size;
 
   vp9_free_frame_buffers(oci);
 
@@ -131,14 +133,13 @@
   set_mb_mi(oci, aligned_width, aligned_height);
 
   // Allocation
-  oci->mip = vpx_calloc(oci->mode_info_stride * (oci->mi_rows + 64 / MI_SIZE),
-                        sizeof(MODE_INFO));
+  mi_size = oci->mode_info_stride * (oci->mi_rows + MI_BLOCK_SIZE);
+
+  oci->mip = vpx_calloc(mi_size, sizeof(MODE_INFO));
   if (!oci->mip)
     goto fail;
 
-  oci->prev_mip = vpx_calloc(oci->mode_info_stride *
-                             (oci->mi_rows + 64 / MI_SIZE),
-                             sizeof(MODE_INFO));
+  oci->prev_mip = vpx_calloc(mi_size, sizeof(MODE_INFO));
   if (!oci->prev_mip)
     goto fail;
 
--- a/vp9/common/vp9_enums.h
+++ b/vp9/common/vp9_enums.h
@@ -17,6 +17,7 @@
 
 #define MI_SIZE (1 << LOG2_MI_SIZE)
 #define MI_MASK ((64 >> LOG2_MI_SIZE) - 1)
+#define MI_BLOCK_SIZE (64 / MI_SIZE)
 
 typedef enum BLOCK_SIZE_TYPE {
   BLOCK_SIZE_AB4X4,
--- a/vp9/common/vp9_loopfilter.c
+++ b/vp9/common/vp9_loopfilter.c
@@ -268,16 +268,16 @@
   const int col_step = 1 << xd->plane[plane].subsampling_x;
   struct buf_2d * const dst = &xd->plane[plane].dst;
   uint8_t* const dst0 = dst->buf;
-  unsigned int mask_16x16[64 / MI_SIZE] = {0};
-  unsigned int mask_8x8[64 / MI_SIZE] = {0};
-  unsigned int mask_4x4[64 / MI_SIZE] = {0};
-  unsigned int mask_4x4_int[64 / MI_SIZE] = {0};
-  struct loop_filter_info lfi[64 / MI_SIZE][64 / MI_SIZE];
+  unsigned int mask_16x16[MI_BLOCK_SIZE] = {0};
+  unsigned int mask_8x8[MI_BLOCK_SIZE] = {0};
+  unsigned int mask_4x4[MI_BLOCK_SIZE] = {0};
+  unsigned int mask_4x4_int[MI_BLOCK_SIZE] = {0};
+  struct loop_filter_info lfi[MI_BLOCK_SIZE][MI_BLOCK_SIZE];
   int r, c;
   MODE_INFO *mi = xd->mode_info_context;
   int row_step_stride = cm->mode_info_stride * row_step;
 
-  for (r = 0; r < 64 / MI_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
+  for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
     unsigned int mask_16x16_c = 0;
     unsigned int mask_8x8_c = 0;
     unsigned int mask_4x4_c = 0;
@@ -284,7 +284,7 @@
     unsigned int border_mask;
 
     // Determine the vertical edges that need filtering
-    for (c = 0; c < 64 / MI_SIZE && mi_col + c < cm->mi_cols; c += col_step) {
+    for (c = 0; c < MI_BLOCK_SIZE && mi_col + c < cm->mi_cols; c += col_step) {
       const int skip_this = mi[c].mbmi.mb_skip_coeff
                             && mi[c].mbmi.ref_frame[0] != INTRA_FRAME;
       // left edge of current unit is block/partition edge -> no skip
@@ -366,7 +366,7 @@
 
   // Now do horizontal pass
   dst->buf = dst0;
-  for (r = 0; r < 64 / MI_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
+  for (r = 0; r < MI_BLOCK_SIZE && mi_row + r < cm->mi_rows; r += row_step) {
     const int skip_border_4x4_r = ss_y && mi_row + r == cm->mi_rows - 1;
     const unsigned int mask_4x4_int_r = skip_border_4x4_r ? 0 : mask_4x4_int[r];
 
@@ -379,19 +379,17 @@
   }
 }
 
-void vp9_loop_filter_frame(VP9_COMMON *cm,
-                           MACROBLOCKD *xd,
-                           int frame_filter_level,
-                           int y_only) {
+void vp9_loop_filter_frame(VP9_COMMON *cm, MACROBLOCKD *xd,
+                           int frame_filter_level, int y_only) {
   int mi_row, mi_col;
 
   // Initialize the loop filter for this frame.
   vp9_loop_filter_frame_init(cm, xd, frame_filter_level);
 
-  for (mi_row = 0; mi_row < cm->mi_rows; mi_row += 64 / MI_SIZE) {
+  for (mi_row = 0; mi_row < cm->mi_rows; mi_row += MI_BLOCK_SIZE) {
     MODE_INFO* const mi = cm->mi + mi_row * cm->mode_info_stride;
 
-    for (mi_col = 0; mi_col < cm->mi_cols; mi_col += 64 / MI_SIZE) {
+    for (mi_col = 0; mi_col < cm->mi_cols; mi_col += MI_BLOCK_SIZE) {
       int plane;
 
       setup_dst_planes(xd, cm->frame_to_show, mi_row, mi_col);
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -657,13 +657,13 @@
   VP9_COMMON *const pc = &pbi->common;
   int mi_row, mi_col;
 
-  for (mi_row = pc->cur_tile_mi_row_start;
-       mi_row < pc->cur_tile_mi_row_end; mi_row += 64 / MI_SIZE) {
+  for (mi_row = pc->cur_tile_mi_row_start; mi_row < pc->cur_tile_mi_row_end;
+       mi_row += MI_BLOCK_SIZE) {
     // For a SB there are 2 left contexts, each pertaining to a MB row within
     vpx_memset(&pc->left_context, 0, sizeof(pc->left_context));
     vpx_memset(pc->left_seg_context, 0, sizeof(pc->left_seg_context));
-    for (mi_col = pc->cur_tile_mi_col_start;
-         mi_col < pc->cur_tile_mi_col_end; mi_col += 64 / MI_SIZE)
+    for (mi_col = pc->cur_tile_mi_col_start; mi_col < pc->cur_tile_mi_col_end;
+         mi_col += MI_BLOCK_SIZE)
       decode_modes_sb(pbi, mi_row, mi_col, r, BLOCK_SIZE_SB64X64);
   }
 }
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -718,14 +718,12 @@
 
   m_ptr += c->cur_tile_mi_col_start + c->cur_tile_mi_row_start * mis;
 
-  for (mi_row = c->cur_tile_mi_row_start;
-       mi_row < c->cur_tile_mi_row_end;
+  for (mi_row = c->cur_tile_mi_row_start; mi_row < c->cur_tile_mi_row_end;
        mi_row += 8, m_ptr += 8 * mis) {
     m = m_ptr;
     vpx_memset(c->left_seg_context, 0, sizeof(c->left_seg_context));
-    for (mi_col = c->cur_tile_mi_col_start;
-         mi_col < c->cur_tile_mi_col_end;
-         mi_col += 64 / MI_SIZE, m += 64 / MI_SIZE)
+    for (mi_col = c->cur_tile_mi_col_start; mi_col < c->cur_tile_mi_col_end;
+         mi_col += MI_BLOCK_SIZE, m += MI_BLOCK_SIZE)
       write_modes_sb(cpi, m, bc, tok, tok_end, mi_row, mi_col,
                      BLOCK_SIZE_SB64X64);
   }
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1636,7 +1636,7 @@
 
   // Code each SB in the row
   for (mi_col = cm->cur_tile_mi_col_start; mi_col < cm->cur_tile_mi_col_end;
-      mi_col += 64 / MI_SIZE) {
+       mi_col += MI_BLOCK_SIZE) {
     int dummy_rate;
     int64_t dummy_dist;
 
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -879,8 +879,8 @@
 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 + 64 / MI_SIZE),
+  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;
@@ -3458,11 +3458,11 @@
 
   if (cm->show_frame) {
     vpx_memcpy(cm->prev_mip, cm->mip,
-               cm->mode_info_stride * (cm->mi_rows + 64 / MI_SIZE) *
+               cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE) *
                sizeof(MODE_INFO));
   } else {
     vpx_memset(cm->prev_mip, 0,
-               cm->mode_info_stride * (cm->mi_rows + 64 / MI_SIZE) *
+               cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE) *
                sizeof(MODE_INFO));
   }
   // restore prev_mi