shithub: dav1d

Download patch

ref: 37a03fc77223a6d60554876fae4596734bbea79b
parent: 2c1467b4d22259192dfaa55484689e321919518a
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Wed Aug 28 15:17:05 EDT 2019

Check absolute tile positions in sb-to-tile_idx table generation

Otherwise the table can get out of sync when the frame size and tile
count stays the same, but the tile coordinates change. Fixes #266.

--- a/src/decode.c
+++ b/src/decode.c
@@ -2595,8 +2595,10 @@
             f->tile_thread.titsati_sz = titsati_sz;
         }
         if (f->tile_thread.titsati_init[0] != f->frame_hdr->tiling.cols ||
-            f->tile_thread.titsati_init[1] != f->sbh ||
-            f->tile_thread.titsati_init[2] != f->frame_hdr->tiling.rows)
+            f->tile_thread.titsati_init[1] != f->frame_hdr->tiling.rows ||
+            memcmp(f->frame_hdr->tiling.row_start_sb, f->tile_thread.titsati_index_rows,
+                   sizeof(*f->tile_thread.titsati_index_rows) *
+                       (f->frame_hdr->tiling.rows + 1)))
         {
             for (int tile_row = 0, tile_idx = 0;
                  tile_row < f->frame_hdr->tiling.rows; tile_row++)
@@ -2614,8 +2616,10 @@
                 }
             }
             f->tile_thread.titsati_init[0] = f->frame_hdr->tiling.cols;
-            f->tile_thread.titsati_init[1] = f->sbh;
-            f->tile_thread.titsati_init[2] = f->frame_hdr->tiling.rows;
+            f->tile_thread.titsati_init[1] = f->frame_hdr->tiling.rows;
+            memcpy(f->tile_thread.titsati_index_rows, f->frame_hdr->tiling.row_start_sb,
+                   sizeof(*f->tile_thread.titsati_index_rows) *
+                       (f->frame_hdr->tiling.rows + 1));
         }
     }
 
--- a/src/internal.h
+++ b/src/internal.h
@@ -235,7 +235,8 @@
         pthread_cond_t cond, icond;
         int tasks_left, num_tasks;
         int (*task_idx_to_sby_and_tile_idx)[2];
-        int titsati_sz, titsati_init[3];
+        int titsati_sz, titsati_init[2];
+        uint16_t titsati_index_rows[1 + DAV1D_MAX_TILE_ROWS];
         int inited;
     } tile_thread;
 };