]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/libx265.c
Merge commit '0e083d7e43805db1a978cb57bfa25fda62e8ff18'
[ffmpeg] / libavcodec / libx265.c
index 698ade216880ace32be4de7edeb219d5c4640287..2aceac796da45c4ec9c47dacec2db0f8b0bcf15c 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,13 @@ 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;
 }