shithub: libvpx

Download patch

ref: 335b1d360bbf39ea44d87e97efcd54a61fb34913
parent: 13eed79c776477f0bc3ed5e70c2fce69165cb77e
author: Dmitry Kovalev <[email protected]>
date: Thu Aug 22 11:45:56 EDT 2013

check_bsize_coverage cleanup.

Change-Id: Ib7803857b35c00e317c9deb8630e777e25eb278f

--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -255,25 +255,20 @@
   xd->left_seg_context = cm->left_seg_context + (mi_row & MI_MASK);
 }
 
-static int check_bsize_coverage(VP9_COMMON *cm, int mi_row, int mi_col,
-                                BLOCK_SIZE_TYPE bsize) {
-  int bsl = mi_width_log2(bsize), bs = 1 << bsl;
-  int ms = bs / 2;
+// return the node index in the prob tree for binary coding
+static int check_bsize_coverage(int bs, int mi_rows, int mi_cols,
+                                int mi_row, int mi_col) {
+  const int r = (mi_row + bs < mi_rows);
+  const int c = (mi_col + bs < mi_cols);
 
-  if ((mi_row + ms < cm->mi_rows) && (mi_col + ms < cm->mi_cols))
+  if (r && c)
     return 0;
 
-  // frame width/height are multiples of 8, hence 8x8 block should always
-  // pass the above check
-  assert(bsize > BLOCK_8X8);
+  if (c && !r)
+    return 1;  // only allow horizontal/split partition types
 
-  // return the node index in the prob tree for binary coding
-  // only allow horizontal/split partition types
-  if ((mi_col + ms < cm->mi_cols) && (mi_row + ms >= cm->mi_rows))
-    return 1;
-  // only allow vertical/split partition types
-  if ((mi_row + ms < cm->mi_rows) && (mi_col + ms >= cm->mi_cols))
-    return 2;
+  if (r && !c)
+    return 2;  // only allow vertical/split partition types
 
   return -1;
 }
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -264,7 +264,7 @@
                             vp9_reader* r, BLOCK_SIZE_TYPE bsize) {
   VP9_COMMON *const pc = &pbi->common;
   MACROBLOCKD *const xd = &pbi->mb;
-  int bs = (1 << mi_width_log2(bsize)) / 2, n;
+  const int bs = (1 << mi_width_log2(bsize)) / 2;
   PARTITION_TYPE partition = PARTITION_NONE;
   BLOCK_SIZE_TYPE subsize;
 
@@ -276,7 +276,8 @@
       return;
   } else {
     int pl;
-    const int idx = check_bsize_coverage(pc, mi_row, mi_col, bsize);
+    const int idx = check_bsize_coverage(bs, pc->mi_rows, pc->mi_cols,
+                                         mi_row, mi_col);
     set_partition_seg_context(pc, xd, mi_row, mi_col);
     pl = partition_plane_context(xd, bsize);
 
@@ -311,13 +312,14 @@
       if (mi_col + bs < pc->mi_cols)
         decode_modes_b(pbi, mi_row, mi_col + bs, r, subsize);
       break;
-    case PARTITION_SPLIT:
+    case PARTITION_SPLIT: {
+      int n;
       for (n = 0; n < 4; n++) {
-        int j = n >> 1, i = n & 0x01;
+        const int j = n >> 1, i = n & 1;
         *(get_sb_index(xd, subsize)) = n;
         decode_modes_sb(pbi, mi_row + j * bs, mi_col + i * bs, r, subsize);
       }
-      break;
+    } break;
     default:
       assert(!"Invalid partition type");
   }
--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -628,7 +628,8 @@
 
   if (bsize >= BLOCK_8X8) {
     int pl;
-    const int idx = check_bsize_coverage(cm, mi_row, mi_col, bsize);
+    const int idx = check_bsize_coverage(bs, cm->mi_rows, cm->mi_cols,
+                                         mi_row, mi_col);
     set_partition_seg_context(cm, xd, mi_row, mi_col);
     pl = partition_plane_context(xd, bsize);
     // encode the partition information