summaryrefslogtreecommitdiff
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-01-08 12:29:38 +0100
committerAnton Khirnov <anton@khirnov.net>2016-01-12 09:23:38 +0100
commitaac7d6b284c3976eb0c48d61f342f008fb6e4103 (patch)
tree71698b15e8bfb790223c34e6fbe441e5521e04b2 /libavcodec/nvenc.c
parentee359c72ef8735122929da96006565e1558f1e55 (diff)
nvenc: flush the encoder before closing it, as required by the docs
Otherwise, closing the encoder can crash.
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 02cb8b4225..c151ad5055 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -825,6 +825,14 @@ av_cold int ff_nvenc_encode_close(AVCodecContext *avctx)
NV_ENCODE_API_FUNCTION_LIST *nv = &ctx->nvel.nvenc_funcs;
int i;
+ /* the encoder has to be flushed before it can be closed */
+ if (ctx->nvenc_ctx) {
+ NV_ENC_PIC_PARAMS params = { .version = NV_ENC_PIC_PARAMS_VER,
+ .encodePicFlags = NV_ENC_PIC_FLAG_EOS };
+
+ nv->nvEncEncodePicture(ctx->nvenc_ctx, &params);
+ }
+
av_fifo_free(ctx->timestamps);
av_fifo_free(ctx->pending);
av_fifo_free(ctx->ready);