shithub: dav1d

Download patch

ref: 4149c72b5fd580858f5629d304688e36b27b4b33
parent: 6c27b662f9ab99125294b50257f7a660684e990d
author: James Almer <[email protected]>
date: Thu Nov 15 06:58:40 EST 2018

obu: add support for OBUs with no size field

--- a/src/obu.c
+++ b/src/obu.c
@@ -1042,7 +1042,6 @@
     const enum ObuType type = dav1d_get_bits(&gb, 4);
     const int has_extension = dav1d_get_bits(&gb, 1);
     const int has_length_field = dav1d_get_bits(&gb, 1);
-    if (!has_length_field) goto error;
     dav1d_get_bits(&gb, 1); // reserved
     if (has_extension) {
         dav1d_get_bits(&gb, 3); // temporal_layer_id
@@ -1052,15 +1051,18 @@
 
     // obu length field
     unsigned len = 0, more, i = 0;
-    do {
-        more = dav1d_get_bits(&gb, 1);
-        unsigned bits = dav1d_get_bits(&gb, 7);
-        if (i <= 3 || (i == 4 && bits < (1 << 4)))
-            len |= bits << (i * 7);
-        else if (bits)
-            goto error;
-        if (more && ++i == 8) goto error;
-    } while (more);
+    if (has_length_field)
+        do {
+            more = dav1d_get_bits(&gb, 1);
+            unsigned bits = dav1d_get_bits(&gb, 7);
+            if (i <= 3 || (i == 4 && bits < (1 << 4)))
+                len |= bits << (i * 7);
+            else if (bits)
+                goto error;
+            if (more && ++i == 8) goto error;
+        } while (more);
+    else
+        len = in->sz - 1 - has_extension;
     if (gb.error) goto error;
 
     const unsigned init_bit_pos = dav1d_get_bits_pos(&gb);