From 08fd41ccd70214c58aa436add4c955ad7c0af58c Mon Sep 17 00:00:00 2001
From: Dmitry Kovalev <dkovalev@google.com>
Date: Tue, 23 Jul 2013 17:57:15 -0700
Subject: [PATCH] Adding lookup table for size group.

Change-Id: Ia6144d77ebed66e0739b62e4d673e26a95aa9550
---
 vp9/common/vp9_common_data.c | 5 +++++
 vp9/common/vp9_common_data.h | 5 +++--
 vp9/decoder/vp9_decodemv.c   | 5 ++---
 vp9/encoder/vp9_bitstream.c  | 4 +---
 4 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/vp9/common/vp9_common_data.c b/vp9/common/vp9_common_data.c
index dee44ec637..7cd302a304 100644
--- a/vp9/common/vp9_common_data.c
+++ b/vp9/common/vp9_common_data.c
@@ -31,6 +31,11 @@ const int mi_height_log2_lookup[BLOCK_SIZE_TYPES] =
 const int num_8x8_blocks_high_lookup[BLOCK_SIZE_TYPES] =
   {1, 1, 1, 1, 2, 1, 2, 4, 2, 4, 8, 4, 8};
 
+// MIN(3, MIN(b_width_log2(bsize), b_height_log2(bsize)))
+const int size_group_lookup[BLOCK_SIZE_TYPES] =
+  {0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3};
+
+
 const PARTITION_TYPE partition_lookup[][BLOCK_SIZE_TYPES] = {
   {  // 4X4
     // 4X4, 4X8,8X4,8X8,8X16,16X8,16X16,16X32,32X16,32X32,32X64,64X32,64X64
diff --git a/vp9/common/vp9_common_data.h b/vp9/common/vp9_common_data.h
index 8b0f8a5007..44ec7ae752 100644
--- a/vp9/common/vp9_common_data.h
+++ b/vp9/common/vp9_common_data.h
@@ -21,8 +21,9 @@ extern const int num_8x8_blocks_wide_lookup[BLOCK_SIZE_TYPES];
 extern const int num_8x8_blocks_high_lookup[BLOCK_SIZE_TYPES];
 extern const int num_4x4_blocks_high_lookup[BLOCK_SIZE_TYPES];
 extern const int num_4x4_blocks_wide_lookup[BLOCK_SIZE_TYPES];
-extern const PARTITION_TYPE
-  partition_lookup[][BLOCK_SIZE_TYPES];
+extern const int size_group_lookup[BLOCK_SIZE_TYPES];
+
+extern const PARTITION_TYPE partition_lookup[][BLOCK_SIZE_TYPES];
 
 
 extern const BLOCK_SIZE_TYPE subsize_lookup[PARTITION_TYPES][BLOCK_SIZE_TYPES];
diff --git a/vp9/decoder/vp9_decodemv.c b/vp9/decoder/vp9_decodemv.c
index 6f0044a4a1..24e0fd4a0b 100644
--- a/vp9/decoder/vp9_decodemv.c
+++ b/vp9/decoder/vp9_decodemv.c
@@ -385,15 +385,14 @@ static void read_intra_block_modes(VP9D_COMP *pbi, MODE_INFO *mi,
   VP9_COMMON *const cm = &pbi->common;
   MB_MODE_INFO *const mbmi = &mi->mbmi;
   const BLOCK_SIZE_TYPE bsize = mi->mbmi.sb_type;
-  const int bwl = b_width_log2(bsize), bhl = b_height_log2(bsize);
 
   if (bsize >= BLOCK_SIZE_SB8X8) {
-    const int size_group = MIN(3, MIN(bwl, bhl));
+    const int size_group = size_group_lookup[bsize];
     mbmi->mode = read_intra_mode(r, cm->fc.y_mode_prob[size_group]);
     cm->counts.y_mode[size_group][mbmi->mode]++;
   } else {
      // Only 4x4, 4x8, 8x4 blocks
-     const int bw = 1 << bwl, bh = 1 << bhl;
+     const int bw = 1 << b_width_log2(bsize), bh = 1 << b_height_log2(bsize);
      int idx, idy;
 
      for (idy = 0; idy < 2; idy += bh) {
diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c
index ad0f6c5318..c33d9c85fa 100644
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -443,9 +443,7 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m,
 #endif
 
     if (bsize >= BLOCK_SIZE_SB8X8) {
-      const int bwl = b_width_log2(bsize), bhl = b_height_log2(bsize);
-      const int bsl = MIN(bwl, bhl);
-      write_intra_mode(bc, mode, pc->fc.y_mode_prob[MIN(3, bsl)]);
+      write_intra_mode(bc, mode, pc->fc.y_mode_prob[size_group_lookup[bsize]]);
     } else {
       int idx, idy;
       int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup[bsize];
-- 
GitLab