[FFmpeg-devel] [PATCH] lavc/nvenc: enable nvenc encoder instance reuse after draining

Pavel Koshevoy pkoshevoy at gmail.com
Thu Jun 7 07:38:28 EEST 2018


---
 libavcodec/nvenc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index b4186c0bec..8928eacc70 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2181,6 +2181,12 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
 
         av_fifo_generic_write(ctx->unused_surface_queue, &tmp_out_surf, sizeof(tmp_out_surf), NULL);
     } else if (ctx->encoder_flushing) {
+        /* reset to initial state so the encoder can be re-used */
+        ctx->encoder_flushing = 0;
+        ctx->first_packet_output = 0;
+        ctx->initial_pts[0] = AV_NOPTS_VALUE;
+        ctx->initial_pts[1] = AV_NOPTS_VALUE;
+        av_fifo_reset(ctx->timestamp_list);
         return AVERROR_EOF;
     } else {
         return AVERROR(EAGAIN);
-- 
2.16.4



More information about the ffmpeg-devel mailing list