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

James Almer jamrial at gmail.com
Tue Sep 15 16:24:24 EEST 2020


This allows the decoder context to be initialized with all stream parameters
before a packet is parsed.

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

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;
 }
 
-- 
2.27.0



More information about the ffmpeg-devel mailing list