shithub: dav1d

Download patch

ref: ce258fa4003c1ccaecea45311ecc063e31a241ad
parent: bb1a9352b9f7bd8679646aa132e51e8c63775896
author: Ronald S. Bultje <rsbultje@gmail.com>
date: Sat Nov 17 06:05:45 EST 2018

Normatively allow invalid global motion parameters

--- a/src/decode.c
+++ b/src/decode.c
@@ -3071,6 +3071,9 @@
             } else {
                 f->svc[i][0].scale = 0;
             }
+            f->gmv_warp_allowed[i] = f->frame_hdr.gmv[i].type > WM_TYPE_TRANSLATION &&
+                                     !f->frame_hdr.force_integer_mv &&
+                                     !dav1d_get_shear_params(&f->frame_hdr.gmv[i]);
         }
     }
 
--- a/src/internal.h
+++ b/src/internal.h
@@ -132,6 +132,7 @@
     const uint8_t *prev_segmap;
     unsigned refpoc[7], refrefpoc[7][7];
     int ref_coded_width[7];
+    uint8_t gmv_warp_allowed[7];
     CdfThreadContext in_cdf, out_cdf;
     struct {
         Dav1dData data;
--- a/src/obu.c
+++ b/src/obu.c
@@ -41,7 +41,6 @@
 #include "src/levels.h"
 #include "src/obu.h"
 #include "src/ref.h"
-#include "src/warpmv.h"
 
 static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb,
                          Av1SequenceHeader *const hdr)
@@ -994,9 +993,6 @@
 
             mat[0] = dav1d_get_bits_subexp(gb, ref_mat[0] >> shift, bits) * (1 << shift);
             mat[1] = dav1d_get_bits_subexp(gb, ref_mat[1] >> shift, bits) * (1 << shift);
-
-            if (dav1d_get_shear_params(&hdr->gmv[i]))
-                goto error;
         }
     }
 #if DEBUG_FRAME_HDR
--- a/src/recon_tmpl.c
+++ b/src/recon_tmpl.c
@@ -1169,11 +1169,9 @@
         const Dav1dThreadPicture *const refp = &f->refp[b->ref[0]];
         const enum Filter2d filter_2d = b->filter2d;
 
-        if (imin(bw4, bh4) > 1 && !f->frame_hdr.force_integer_mv &&
-            ((b->inter_mode == GLOBALMV &&
-              f->frame_hdr.gmv[b->ref[0]].type > WM_TYPE_TRANSLATION) ||
-             (b->motion_mode == MM_WARP &&
-              t->warpmv.type > WM_TYPE_TRANSLATION)))
+        if (imin(bw4, bh4) > 1 &&
+            ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) ||
+             (b->motion_mode == MM_WARP && t->warpmv.type > WM_TYPE_TRANSLATION)))
         {
             res = warp_affine(t, dst, NULL, f->cur.stride[0], b_dim, 0, refp,
                               b->motion_mode == MM_WARP ? &t->warpmv :
@@ -1285,11 +1283,9 @@
                 if (res) return res;
             }
         } else {
-            if (imin(cbw4, cbh4) > 1 && !f->frame_hdr.force_integer_mv &&
-                ((b->inter_mode == GLOBALMV &&
-                  f->frame_hdr.gmv[b->ref[0]].type > WM_TYPE_TRANSLATION) ||
-                 (b->motion_mode == MM_WARP &&
-                  t->warpmv.type > WM_TYPE_TRANSLATION)))
+            if (imin(cbw4, cbh4) > 1 &&
+                ((b->inter_mode == GLOBALMV && f->gmv_warp_allowed[b->ref[0]]) ||
+                 (b->motion_mode == MM_WARP && t->warpmv.type > WM_TYPE_TRANSLATION)))
             {
                 for (int pl = 0; pl < 2; pl++) {
                     res = warp_affine(t, ((pixel *) f->cur.data[1 + pl]) + uvdstoff, NULL,
@@ -1368,9 +1364,7 @@
         for (int i = 0; i < 2; i++) {
             const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]];
 
-            if (b->inter_mode == GLOBALMV_GLOBALMV && !f->frame_hdr.force_integer_mv &&
-                f->frame_hdr.gmv[b->ref[i]].type > WM_TYPE_TRANSLATION)
-            {
+            if (b->inter_mode == GLOBALMV_GLOBALMV && f->gmv_warp_allowed[b->ref[i]]) {
                 res = warp_affine(t, NULL, tmp[i], bw4 * 4, b_dim, 0, refp,
                                   &f->frame_hdr.gmv[b->ref[i]]);
                 if (res) return res;
@@ -1413,8 +1407,7 @@
             for (int i = 0; i < 2; i++) {
                 const Dav1dThreadPicture *const refp = &f->refp[b->ref[i]];
                 if (b->inter_mode == GLOBALMV_GLOBALMV &&
-                    imin(cbw4, cbh4) > 1 && !f->frame_hdr.force_integer_mv &&
-                    f->frame_hdr.gmv[b->ref[i]].type > WM_TYPE_TRANSLATION)
+                    imin(cbw4, cbh4) > 1 && f->gmv_warp_allowed[b->ref[i]])
                 {
                     res = warp_affine(t, NULL, tmp[i], bw4 * 2, b_dim, 1 + pl,
                                       refp, &f->frame_hdr.gmv[b->ref[i]]);