shithub: libvpx

Download patch

ref: ff3f93639c147fa9b8dcf6d014b3c80bf3b7c8ef
parent: acfc5981c3d53c998f6c1e94a173999087912b85
author: John Koleszar <jkoleszar@google.com>
date: Fri Apr 12 10:12:05 EDT 2013

Use BLOCK_SIZE_TYPE in foreach_ walker

Change-Id: I655305c9e22bdd9abc893d3c40d4bc6616aa1d35

--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -801,16 +801,18 @@
 }
 
 typedef void (*foreach_transformed_block_visitor)(int plane, int block,
-                                                  int block_size_b,
+                                                  BLOCK_SIZE_TYPE bsize,
                                                   int ss_txfrm_size,
                                                   void *arg);
 static INLINE void foreach_transformed_block_in_plane(
-    const MACROBLOCKD* const xd, int block_size, int plane,
+    const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize, int plane,
     int is_split, foreach_transformed_block_visitor visit, void *arg) {
+  const int bw = b_width_log2(bsize), bh = b_height_log2(bsize);
+
   // block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
   // 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
   const TX_SIZE tx_size = xd->mode_info_context->mbmi.txfm_size;
-  const int block_size_b = block_size;
+  const int block_size_b = bw + bh;
   const int txfrm_size_b = tx_size * 2;
 
   // subsampled size of the block
@@ -825,20 +827,19 @@
   const int ss_txfrm_size = txfrm_size_b > ss_block_size || is_split
                                 ? txfrm_size_b - ss_max * 2
                                 : txfrm_size_b;
+  const int step = 1 << ss_txfrm_size;
 
-  // TODO(jkoleszar): 1 may not be correct here with larger chroma planes.
-  const int inc = is_split ? 1 : (1 << ss_txfrm_size);
   int i;
 
   assert(txfrm_size_b <= block_size_b);
   assert(ss_txfrm_size <= ss_block_size);
-  for (i = 0; i < (1 << ss_block_size); i += inc) {
-    visit(plane, i, block_size_b, ss_txfrm_size, arg);
+  for (i = 0; i < (1 << ss_block_size); i += step) {
+    visit(plane, i, bsize, ss_txfrm_size, arg);
   }
 }
 
 static INLINE void foreach_transformed_block(
-    const MACROBLOCKD* const xd, int block_size,
+    const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
     foreach_transformed_block_visitor visit, void *arg) {
   const MB_PREDICTION_MODE mode = xd->mode_info_context->mbmi.mode;
   const int is_split =
@@ -850,13 +851,13 @@
     const int is_split_chroma = is_split &&
          xd->plane[plane].plane_type == PLANE_TYPE_UV;
 
-    foreach_transformed_block_in_plane(xd, block_size, plane, is_split_chroma,
+    foreach_transformed_block_in_plane(xd, bsize, plane, is_split_chroma,
                                        visit, arg);
   }
 }
 
 static INLINE void foreach_transformed_block_uv(
-    const MACROBLOCKD* const xd, int block_size,
+    const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
     foreach_transformed_block_visitor visit, void *arg) {
   const MB_PREDICTION_MODE mode = xd->mode_info_context->mbmi.mode;
   const int is_split =
@@ -865,7 +866,7 @@
   int plane;
 
   for (plane = 1; plane < MAX_MB_PLANE; plane++) {
-    foreach_transformed_block_in_plane(xd, block_size, plane, is_split,
+    foreach_transformed_block_in_plane(xd, bsize, plane, is_split,
                                        visit, arg);
   }
 }
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -402,11 +402,12 @@
   int *eobtotal;
 };
 static void decode_block(int plane, int block,
-                         int block_size_b,
+                         BLOCK_SIZE_TYPE bsize,
                          int ss_txfrm_size,
                          void *argv) {
   const struct decode_block_args* const arg = argv;
-  const int old_block_idx = old_block_idx_4x4(arg->xd, block_size_b,
+  const int bw = b_width_log2(bsize), bh = b_height_log2(bsize);
+  const int old_block_idx = old_block_idx_4x4(arg->xd, bw + bh,
                                               plane, block);
 
   // find the maximum eob for this transform size, adjusted by segment
@@ -428,10 +429,9 @@
                          MACROBLOCKD* const xd,
                          BOOL_DECODER* const bc,
                          BLOCK_SIZE_TYPE bsize) {
-  const int bwl = mb_width_log2(bsize) + 2, bhl = mb_height_log2(bsize) + 2;
   int eobtotal = 0;
   struct decode_block_args args = {pbi, xd, bc, &eobtotal};
-  foreach_transformed_block(xd, bwl + bhl, decode_block, &args);
+  foreach_transformed_block(xd, bsize, decode_block, &args);
   return eobtotal;
 }
 
--- a/vp9/encoder/vp9_tokenize.c
+++ b/vp9/encoder/vp9_tokenize.c
@@ -381,32 +381,29 @@
   int *skippable;
 };
 static void is_skippable(int plane, int block,
-                         int block_size_b, int ss_txfrm_size, void *argv) {
+                         BLOCK_SIZE_TYPE bsize, int ss_txfrm_size, void *argv) {
   struct is_skippable_args *args = argv;
   args->skippable[0] &= (!args->xd->plane[plane].eobs[block]);
 }
 
 int vp9_sb_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) {
-  const int bwl = mb_width_log2(bsize) + 2, bhl = mb_height_log2(bsize) + 2;
   int result = 1;
   struct is_skippable_args args = {xd, &result};
-  foreach_transformed_block(xd, bwl + bhl, is_skippable, &args);
+  foreach_transformed_block(xd, bsize, is_skippable, &args);
   return result;
 }
 
 int vp9_sby_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) {
-  const int bwl = mb_width_log2(bsize) + 2, bhl = mb_height_log2(bsize) + 2;
   int result = 1;
   struct is_skippable_args args = {xd, &result};
-  foreach_transformed_block_in_plane(xd, bwl + bhl, 0, 0, is_skippable, &args);
+  foreach_transformed_block_in_plane(xd, bsize, 0, 0, is_skippable, &args);
   return result;
 }
 
 int vp9_sbuv_is_skippable(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize) {
-  const int bwl = mb_width_log2(bsize) + 2, bhl = mb_height_log2(bsize) + 2;
   int result = 1;
   struct is_skippable_args args = {xd, &result};
-  foreach_transformed_block_uv(xd, bwl + bhl, is_skippable, &args);
+  foreach_transformed_block_uv(xd, bsize, is_skippable, &args);
   return result;
 }
 
--