]> git.sesse.net Git - ffmpeg/commitdiff
libx265: Write global extradata when requested
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 14 Mar 2014 03:26:24 +0000 (04:26 +0100)
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>
Mon, 24 Mar 2014 15:27:41 +0000 (15:27 +0000)
Matroska, MP4, and other containers require it.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
libavcodec/libx265.c

index a6e4193f7f1d1ef75f3ff1c9ba8708896593f1b4..b779c373c550e193dda33e60ade39fa3495ba768 100644 (file)
@@ -190,7 +190,7 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
     for (i = 0; i < nnal; i++)
         ctx->header_size += nal[i].sizeBytes;
 
-    ctx->header = av_malloc(ctx->header_size);
+    ctx->header = av_malloc(ctx->header_size + FF_INPUT_BUFFER_PADDING_SIZE);
     if (!ctx->header) {
         av_log(avctx, AV_LOG_ERROR,
                "Cannot allocate HEVC header of size %d.\n", ctx->header_size);
@@ -204,6 +204,14 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
         buf += nal[i].sizeBytes;
     }
 
+    if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
+        avctx->extradata_size = ctx->header_size;
+        avctx->extradata      = ctx->header;
+
+        ctx->header_size = 0;
+        ctx->header      = NULL;
+    }
+
     return 0;
 }