shithub: dav1d

Download patch

ref: 6622002197992ffd2789e07e39e1f9df8cbf0d0c
parent: 9075f0ee5799fabea9cc0460a261470cf1fafaf9
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Mon Sep 24 13:47:25 EDT 2018

Use picture, not block, boundaries for edge extension conditions.

--- a/src/lf_apply.c
+++ b/src/lf_apply.c
@@ -220,12 +220,14 @@
                                     int sby, const int start_of_tile_row)
 {
     int x, have_left;
+    // Don't filter outside the frame
+    const int hy4 = (f->cur.p.p.h + 3) >> 2;
     const int have_top = sby > 0;
     const int is_sb64 = !f->seq_hdr.sb128;
     const int starty4 = (sby & is_sb64) << 4;
     const int sbsz = 32 >> is_sb64;
     const int sbl2 = 5 - is_sb64;
-    const int endy4 = starty4 + imin(f->bh - sby * f->sb_step, sbsz);
+    const int endy4 = starty4 + imin(hy4 - sby * f->sb_step, sbsz);
     const int halign = (f->bh + 31) & ~31;
     const int ss_ver = f->cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420;
     const int ss_hor = f->cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444;
--- a/src/lr_apply.c
+++ b/src/lr_apply.c
@@ -284,8 +284,8 @@
         ((f->frame_hdr.restoration.type[2] != RESTORATION_NONE) << 2);
 
     if (restore_planes & LR_RESTORE_Y) {
-        const int h = f->bh << 2;
-        const int w = f->bw << 2;
+        const int h = f->cur.p.p.h;
+        const int w = f->cur.p.p.w;
         const int row_h = imin((sby + 1) << (6 + f->seq_hdr.sb128), h);
         const int y_stripe = (sby << (6 + f->seq_hdr.sb128)) - offset_y;
         lr_sbrow(f, dst[0] - offset_y * PXSTRIDE(dst_stride[0]), y_stripe, w,
@@ -294,8 +294,8 @@
     if (restore_planes & (LR_RESTORE_U | LR_RESTORE_V)) {
         const int ss_ver = f->cur.p.p.layout == DAV1D_PIXEL_LAYOUT_I420;
         const int ss_hor = f->cur.p.p.layout != DAV1D_PIXEL_LAYOUT_I444;
-        const int h = f->bh << (2 - ss_ver);
-        const int w = f->bw << (2 - ss_hor);
+        const int h = (f->cur.p.p.h + ss_ver) >> ss_ver;
+        const int w = (f->cur.p.p.w + ss_hor) >> ss_hor;
         const int row_h = imin((sby + 1) << ((6 - ss_ver) + f->seq_hdr.sb128), h);
         const ptrdiff_t offset_uv = offset_y >> ss_ver;
         const int y_stripe =
--- a/src/recon.c
+++ b/src/recon.c
@@ -521,11 +521,13 @@
     if (refp != &f->cur) // i.e. not for intrabc
         dav1d_thread_picture_wait(refp, dy + bh4 * v_mul + !!my * 4,
                                   PLANE_TYPE_Y + !!pl);
-    if (dx < 3 || dx + bw4 * h_mul + 4 > f->bw * h_mul ||
-        dy < 3 || dy + bh4 * v_mul + 4 > f->bh * v_mul)
+    if (dx < 3 || dx + bw4 * h_mul + 4 > ((f->cur.p.p.w + ss_hor) >> ss_hor) ||
+        dy < 3 || dy + bh4 * v_mul + 4 > ((f->cur.p.p.h + ss_ver) >> ss_ver))
     {
         emu_edge(t->emu_edge, 160 * sizeof(pixel), refp->p.data[pl], ref_stride,
-                 bw4 * h_mul + 7, bh4 * v_mul + 7, f->bw * h_mul, f->bh * v_mul,
+                 bw4 * h_mul + 7, bh4 * v_mul + 7,
+                 (f->cur.p.p.w + ss_hor) >> ss_hor,
+                 (f->cur.p.p.h + ss_ver) >> ss_ver,
                  dx - 3, dy - 3);
         ref = &t->emu_edge[160 * 3 + 3];
         ref_stride = 160 * sizeof(pixel);
@@ -632,7 +634,8 @@
     const int h_mul = 4 >> ss_hor, v_mul = 4 >> ss_ver;
     assert(!((b_dim[0] * h_mul) & 7) && !((b_dim[1] * v_mul) & 7));
     const int32_t *const mat = wmp->matrix;
-    const int width = f->bw * h_mul, height = f->bh * v_mul;
+    const int width = (f->cur.p.p.w + ss_hor) >> ss_hor;
+    const int height = (f->cur.p.p.h + ss_ver) >> ss_ver;
 
     for (int y = 0; y < b_dim[1] * v_mul; y += 8) {
         for (int x = 0; x < b_dim[0] * h_mul; x += 8) {