Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2018-11-15 17:58:40 +0300
committerJames Almer <jamrial@gmail.com>2018-11-15 18:37:33 +0300
commit4149c72b5fd580858f5629d304688e36b27b4b33 (patch)
tree2d356b4dd6a90482f8cad0618eff560827b1af63
parent6c27b662f9ab99125294b50257f7a660684e990d (diff)
obu: add support for OBUs with no size field
-rw-r--r--src/obu.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/obu.c b/src/obu.c
index 92c4f93..d114ce7 100644
--- a/src/obu.c
+++ b/src/obu.c
@@ -1042,7 +1042,6 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
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 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
// 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);