diff mbox series

[FFmpeg-devel,2/2] avcodec/libdav1d: parse sequence headers in extradata if available

Message ID 20200915132425.5527-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] avcodec/libdav1d: use ff_decode_frame_props() to fill frame properties
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

James Almer Sept. 15, 2020, 1:24 p.m. UTC
This allows the decoder context to be initialized with all stream parameters
before a packet is parsed.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/libdav1d.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 1b9289824f..13673ae2dc 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -191,6 +191,17 @@  static av_cold int libdav1d_init(AVCodecContext *c)
     if (res < 0)
         return AVERROR(ENOMEM);
 
+    if (c->extradata && c->extradata_size) {
+        res = dav1d_parse_sequence_header(&seq, c->extradata, c->extradata_size);
+        if (res < 0)
+            return AVERROR_INVALIDDATA;
+
+        libdav1d_init_params(c, &seq);
+        res = ff_set_dimensions(c, seq.max_width, seq.max_height);
+        if (res < 0)
+            return res;
+    }
+
     return 0;
 }