shithub: libvpx

Download patch

ref: 8a0808a1457a9e426d029637856b3d8f44c6f29b
parent: 03b412d0449146ecd7e3398448cfa91c2acca05e
author: Ronald S. Bultje <[email protected]>
date: Wed Jun 12 06:30:06 EDT 2013

Fix row tiling.

Change-Id: I57be4eeaea6e4402f6a0cc04f5c6b7a5d9aedf9b

--- a/vp9/encoder/vp9_bitstream.c
+++ b/vp9/encoder/vp9_bitstream.c
@@ -967,8 +967,6 @@
   int mi_row, mi_col;
 
   m_ptr += c->cur_tile_mi_col_start + c->cur_tile_mi_row_start * mis;
-  vpx_memset(c->above_seg_context, 0, sizeof(PARTITION_CONTEXT) *
-             mi_cols_aligned_to_sb(c));
 
   for (mi_row = c->cur_tile_mi_row_start;
        mi_row < c->cur_tile_mi_row_end;
@@ -1728,24 +1726,34 @@
   {
     int tile_row, tile_col, total_size = 0;
     unsigned char *data_ptr = cx_data + header_bc.pos;
-    TOKENEXTRA *tok[1 << 6], *tok_end;
+    TOKENEXTRA *tok[4][1 << 6], *tok_end;
 
-    tok[0] = cpi->tok;
-    for (tile_col = 1; tile_col < pc->tile_columns; tile_col++)
-      tok[tile_col] = tok[tile_col - 1] + cpi->tok_count[tile_col - 1];
+    vpx_memset(cpi->common.above_seg_context, 0, sizeof(PARTITION_CONTEXT) *
+               mi_cols_aligned_to_sb(&cpi->common));
+    tok[0][0] = cpi->tok;
+    for (tile_row = 0; tile_row < pc->tile_rows; tile_row++) {
+      if (tile_row) {
+        tok[tile_row][0] = tok[tile_row - 1][pc->tile_columns - 1] +
+                           cpi->tok_count[tile_row - 1][pc->tile_columns - 1];
+      }
+      for (tile_col = 1; tile_col < pc->tile_columns; tile_col++) {
+        tok[tile_row][tile_col] = tok[tile_row][tile_col - 1] +
+                                  cpi->tok_count[tile_row][tile_col - 1];
+      }
+    }
 
     for (tile_row = 0; tile_row < pc->tile_rows; tile_row++) {
       vp9_get_tile_row_offsets(pc, tile_row);
-      tok_end = cpi->tok + cpi->tok_count[0];
-      for (tile_col = 0; tile_col < pc->tile_columns;
-           tile_col++, tok_end += cpi->tok_count[tile_col]) {
+      for (tile_col = 0; tile_col < pc->tile_columns; tile_col++) {
         vp9_get_tile_col_offsets(pc, tile_col);
+        tok_end = tok[tile_row][tile_col] + cpi->tok_count[tile_row][tile_col];
 
         if (tile_col < pc->tile_columns - 1 || tile_row < pc->tile_rows - 1)
           vp9_start_encode(&residual_bc, data_ptr + total_size + 4);
         else
           vp9_start_encode(&residual_bc, data_ptr + total_size);
-        write_modes(cpi, &residual_bc, &tok[tile_col], tok_end);
+        write_modes(cpi, &residual_bc, &tok[tile_row][tile_col], tok_end);
+        assert(tok[tile_row][tile_col] == tok_end);
         vp9_stop_encode(&residual_bc);
         if (tile_col < pc->tile_columns - 1 || tile_row < pc->tile_rows - 1) {
           // size of this tile
@@ -1756,11 +1764,6 @@
         total_size += residual_bc.pos;
       }
     }
-
-    assert((unsigned int)(tok[0] - cpi->tok) == cpi->tok_count[0]);
-    for (tile_col = 1; tile_col < pc->tile_columns; tile_col++)
-      assert((unsigned int)(tok[tile_col] - tok[tile_col - 1]) ==
-                  cpi->tok_count[tile_col]);
 
     *size += total_size;
   }
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -1572,7 +1572,7 @@
                mi_row < cm->cur_tile_mi_row_end;
                mi_row += 8)
             encode_sb_row(cpi, mi_row, &tp, &totalrate);
-          cpi->tok_count[tile_col] = (unsigned int)(tp - tp_old);
+          cpi->tok_count[tile_row][tile_col] = (unsigned int)(tp - tp_old);
           assert(tp - cpi->tok <=
                  get_token_alloc(cm->mb_rows, cm->mb_cols));
         }
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -296,7 +296,7 @@
   YV12_BUFFER_CONFIG last_frame_uf;
 
   TOKENEXTRA *tok;
-  unsigned int tok_count[1 << 6];
+  unsigned int tok_count[4][1 << 6];
 
 
   unsigned int frames_since_key;