shithub: dav1d

Download patch

ref: 1d36922f2538436d05213f5f4cddaff976a7559e
parent: 7aea6858ecd2e8e596dedc0be5396d8edb54eefc
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Sat Dec 28 10:04:05 EST 2019

av1: skip super-resolution upscaling if width < 16

This is consistent with libaom's av1_superres_scaled(). Fixes #322.

--- a/src/decode.c
+++ b/src/decode.c
@@ -2348,7 +2348,7 @@
 
     // Reference Restoration Unit (used for exp coding)
     int sb_idx, unit_idx;
-    if (f->frame_hdr->super_res.enabled) {
+    if (f->frame_hdr->width[0] != f->frame_hdr->width[1]) {
         // vertical components only
         sb_idx = (ts->tiling.row_start >> 5) * f->sr_sb128w;
         unit_idx = (ts->tiling.row_start & 16) >> 3;
@@ -2361,7 +2361,7 @@
         if (!((f->lf.restore_planes >> p) & 1U))
             continue;
 
-        if (f->frame_hdr->super_res.enabled) {
+        if (f->frame_hdr->width[0] != f->frame_hdr->width[1]) {
             const int ss_hor = p && f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444;
             const int d = f->frame_hdr->super_res.width_scale_denominator;
             const int unit_size_log2 = f->frame_hdr->restoration.unit_size[!!p];
@@ -2541,7 +2541,7 @@
 
             const enum Dav1dRestorationType frame_type = f->frame_hdr->restoration.type[p];
 
-            if (f->frame_hdr->super_res.enabled) {
+            if (f->frame_hdr->width[0] != f->frame_hdr->width[1]) {
                 const int w = (f->sr_cur.p.p.w + ss_hor) >> ss_hor;
                 const int n_units = imax(1, (w + half_unit) >> unit_size_log2);
 
@@ -3342,7 +3342,7 @@
     res = dav1d_thread_picture_alloc(c, f, bpc);
     if (res < 0) goto error;
 
-    if (f->frame_hdr->super_res.enabled) {
+    if (f->frame_hdr->width[0] != f->frame_hdr->width[1]) {
         res = dav1d_picture_alloc_copy(c, &f->cur, f->frame_hdr->width[0], &f->sr_cur.p);
         if (res < 0) goto error;
     } else {
@@ -3349,7 +3349,7 @@
         dav1d_picture_ref(&f->cur, &f->sr_cur.p);
     }
 
-    if (f->frame_hdr->super_res.enabled) {
+    if (f->frame_hdr->width[0] != f->frame_hdr->width[1]) {
         f->resize_step[0] = scale_fac(f->cur.p.w, f->sr_cur.p.p.w);
         const int ss_hor = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I444;
         const int in_cw = (f->cur.p.w + ss_hor) >> ss_hor;
--- a/src/recon_tmpl.c
+++ b/src/recon_tmpl.c
@@ -1993,7 +1993,7 @@
         bytefn(dav1d_cdef_brow)(f, f->lf.p, f->lf.mask_ptr, sby * sbsz,
                                 imin(sby * sbsz + n_blks, f->bh));
     }
-    if (f->frame_hdr->super_res.enabled) {
+    if (f->frame_hdr->width[0] != f->frame_hdr->width[1]) {
         const int has_chroma = f->cur.p.layout != DAV1D_PIXEL_LAYOUT_I400;
         for (int pl = 0; pl < 1 + 2 * has_chroma; pl++) {
             const int ss_ver = pl && f->cur.p.layout == DAV1D_PIXEL_LAYOUT_I420;