Commit 8a1759ad authored by Paul B Mahol's avatar Paul B Mahol

avcodec/exr: export writer info into frame metadata

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent 546e29d1
...@@ -1303,8 +1303,9 @@ static int check_header_variable(EXRContext *s, ...@@ -1303,8 +1303,9 @@ static int check_header_variable(EXRContext *s,
return var_size; 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 magic_number, version, i, flags, sar = 0;
int layer_match = 0; int layer_match = 0;
...@@ -1576,6 +1577,14 @@ static int decode_header(EXRContext *s) ...@@ -1576,6 +1577,14 @@ static int decode_header(EXRContext *s)
return AVERROR_PATCHWELCOME; return AVERROR_PATCHWELCOME;
} }
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; continue;
} }
...@@ -1612,6 +1621,8 @@ static int decode_header(EXRContext *s) ...@@ -1612,6 +1621,8 @@ static int decode_header(EXRContext *s)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
av_frame_set_metadata(frame, metadata);
// aaand we are done // aaand we are done
bytestream2_skip(&s->gb, 1); bytestream2_skip(&s->gb, 1);
return 0; return 0;
...@@ -1631,7 +1642,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, ...@@ -1631,7 +1642,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
bytestream2_init(&s->gb, avpkt->data, avpkt->size); bytestream2_init(&s->gb, avpkt->data, avpkt->size);
if ((ret = decode_header(s)) < 0) if ((ret = decode_header(s, picture)) < 0)
return ret; return ret;
switch (s->pixel_type) { switch (s->pixel_type) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment