[FFmpeg-devel] [PATCH 2/2] avcodec/exr: export writer info into frame metadata

Paul B Mahol onemda at gmail.com
Mon Jan 16 14:09:17 EET 2017


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/exr.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libavcodec/exr.c b/libavcodec/exr.c
index 0c2e5d2..034920f 100644
--- a/libavcodec/exr.c
+++ b/libavcodec/exr.c
@@ -1303,8 +1303,9 @@ static int check_header_variable(EXRContext *s,
     return var_size;
 }
 
-static int decode_header(EXRContext *s)
+static int decode_header(EXRContext *s, AVFrame *frame)
 {
+    AVDictionary *metadata = NULL;
     int magic_number, version, i, flags, sar = 0;
     int layer_match = 0;
 
@@ -1577,6 +1578,14 @@ static int decode_header(EXRContext *s)
             }
 
             continue;
+        } else if ((var_size = check_header_variable(s, "writer",
+                                                     "string", 1)) >= 0) {
+            uint8_t key[256] = { 0 };
+
+            bytestream2_get_buffer(&s->gb, key, FFMIN(sizeof(key) - 1, var_size));
+            av_dict_set(&metadata, "writer", key, 0);
+
+            continue;
         }
 
         // Check if there are enough bytes for a header
@@ -1612,6 +1621,8 @@ static int decode_header(EXRContext *s)
         return AVERROR_INVALIDDATA;
     }
 
+    av_frame_set_metadata(frame, metadata);
+
     // aaand we are done
     bytestream2_skip(&s->gb, 1);
     return 0;
@@ -1631,7 +1642,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 
     bytestream2_init(&s->gb, avpkt->data, avpkt->size);
 
-    if ((ret = decode_header(s)) < 0)
+    if ((ret = decode_header(s, picture)) < 0)
         return ret;
 
     switch (s->pixel_type) {
-- 
2.9.3



More information about the ffmpeg-devel mailing list