summaryrefslogtreecommitdiff
path: root/libavcodec/libx265.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-03-14 04:26:24 +0100
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2014-03-24 15:27:41 +0000
commit60728e8bab8d2a5f6bbb4baa7d53142dbc6047ed (patch)
tree2b3b35845faad2e0e009bf311587c05dbc7c77f3 /libavcodec/libx265.c
parent8ef33497a6a3ed05d2f931809c074ef3d1878834 (diff)
libx265: Write global extradata when requested
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>
Diffstat (limited to 'libavcodec/libx265.c')
-rw-r--r--libavcodec/libx265.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index a6e4193f7f..b779c373c5 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -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;
}