shithub: dav1d

Download patch

ref: c0451c8abc802694e24e55c8214f2f8782e23aae
parent: bb505b3e7bbd23e67531ce82059845b2d83cdbe9
author: James Almer <jamrial@gmail.com>
date: Thu Oct 4 21:00:01 EDT 2018

fix skipping ref_order_hint in frame headers

Fixes parsing of some error_resilient_mode files.

--- a/src/obu.c
+++ b/src/obu.c
@@ -375,17 +375,19 @@
 
     if (hdr->frame_type == DAV1D_FRAME_TYPE_KEY) {
         hdr->refresh_frame_flags = hdr->show_frame ? 0xff : dav1d_get_bits(gb, 8);
+        if (hdr->refresh_frame_flags != 0xff && hdr->error_resilient_mode && seqhdr->order_hint)
+            for (int i = 0; i < 8; i++)
+                dav1d_get_bits(gb, seqhdr->order_hint_n_bits);
         if ((res = read_frame_size(c, gb, 0)) < 0) goto error;
         hdr->allow_intrabc = hdr->allow_screen_content_tools &&
                              /* FIXME: no superres scaling && */ dav1d_get_bits(gb, 1);
         hdr->use_ref_frame_mvs = 0;
     } else {
-        if (hdr->error_resilient_mode && seqhdr->order_hint)
-            for (int i = 0; i < 8; i++)
-                dav1d_get_bits(gb, seqhdr->order_hint_n_bits);
-
         if (hdr->frame_type == DAV1D_FRAME_TYPE_INTRA) {
             hdr->refresh_frame_flags = dav1d_get_bits(gb, 8);
+            if (hdr->refresh_frame_flags != 0xff && hdr->error_resilient_mode && seqhdr->order_hint)
+                for (int i = 0; i < 8; i++)
+                    dav1d_get_bits(gb, seqhdr->order_hint_n_bits);
             if ((res = read_frame_size(c, gb, 0)) < 0) goto error;
             hdr->allow_intrabc = hdr->allow_screen_content_tools &&
                              /* FIXME: no superres scaling && */ dav1d_get_bits(gb, 1);
@@ -393,6 +395,9 @@
             hdr->allow_intrabc = 0;
             hdr->refresh_frame_flags = hdr->frame_type == DAV1D_FRAME_TYPE_SWITCH ? 0xff :
                                        dav1d_get_bits(gb, 8);
+            if (hdr->error_resilient_mode && seqhdr->order_hint)
+                for (int i = 0; i < 8; i++)
+                    dav1d_get_bits(gb, seqhdr->order_hint_n_bits);
             hdr->frame_ref_short_signaling =
                 seqhdr->order_hint && dav1d_get_bits(gb, 1);
             if (hdr->frame_ref_short_signaling) goto error; // FIXME