summaryrefslogtreecommitdiff
path: root/libavformat/apngenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2016-11-18 12:21:54 -0300
committerJames Almer <jamrial@gmail.com>2016-11-18 12:26:44 -0300
commit50e0e96f3f8ed57443707289a621446cef0fe367 (patch)
tree0d2f28a093630810f4a4fa2c1646ae6447414df0 /libavformat/apngenc.c
parent16c429166ddf1736972b6ccce84bd3509ec16a34 (diff)
avformat/apngenc: use the stream parameters extradata if available
Fixes remuxing apng streams coming from the apng demuxer, which sends extradata during init. Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/apngenc.c')
-rw-r--r--libavformat/apngenc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c
index e5e8aa998f..0c40be297f 100644
--- a/libavformat/apngenc.c
+++ b/libavformat/apngenc.c
@@ -81,6 +81,7 @@ static void apng_write_chunk(AVIOContext *io_context, uint32_t tag,
static int apng_write_header(AVFormatContext *format_context)
{
APNGMuxContext *apng = format_context->priv_data;
+ AVCodecParameters *par = format_context->streams[0]->codecpar;
if (format_context->nb_streams != 1 ||
format_context->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
@@ -101,6 +102,14 @@ static int apng_write_header(AVFormatContext *format_context)
avio_wb64(format_context->pb, PNGSIG);
// Remaining headers are written when they are copied from the encoder
+ if (par->extradata_size) {
+ apng->extra_data = av_mallocz(par->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
+ if (!apng->extra_data)
+ return AVERROR(ENOMEM);
+ apng->extra_data_size = par->extradata_size;
+ memcpy(apng->extra_data, par->extradata, par->extradata_size);
+ }
+
return 0;
}