[FFmpeg-cvslog] nvenc: implement flush to help allow an encoder to be re-used

Philip Langdale git at videolan.org
Thu Jan 9 05:21:16 EET 2020


ffmpeg | branch: master | Philip Langdale <philipl at overt.org> | Fri Dec 20 15:34:33 2019 -0800| [3ea705767720033754e8d85566460390191ae27d] | committer: Philip Langdale

nvenc: implement flush to help allow an encoder to be re-used

It can be useful to re-use an encoder instance when doing segmented
encodings, and this requires flushing the encoder at the start of
each segment.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ea705767720033754e8d85566460390191ae27d
---

 libavcodec/nvenc.c      | 5 +++++
 libavcodec/nvenc.h      | 2 ++
 libavcodec/nvenc_h264.c | 1 +
 libavcodec/nvenc_hevc.c | 1 +
 libavcodec/version.h    | 2 +-
 5 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 310e30805d..9a96bf2bba 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -2262,3 +2262,8 @@ int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     return 0;
 }
+
+av_cold void ff_nvenc_encode_flush(AVCodecContext *avctx)
+{
+    ff_nvenc_send_frame(avctx, NULL);
+}
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index a269bd97bb..c44c81e675 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -214,6 +214,8 @@ int ff_nvenc_receive_packet(AVCodecContext *avctx, AVPacket *pkt);
 int ff_nvenc_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
                           const AVFrame *frame, int *got_packet);
 
+void ff_nvenc_encode_flush(AVCodecContext *avctx);
+
 extern const enum AVPixelFormat ff_nvenc_pix_fmts[];
 
 #endif /* AVCODEC_NVENC_H */
diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c
index d5c7370aaa..479155fe15 100644
--- a/libavcodec/nvenc_h264.c
+++ b/libavcodec/nvenc_h264.c
@@ -240,6 +240,7 @@ AVCodec ff_h264_nvenc_encoder = {
     .receive_packet = ff_nvenc_receive_packet,
     .encode2        = ff_nvenc_encode_frame,
     .close          = ff_nvenc_encode_close,
+    .flush          = ff_nvenc_encode_flush,
     .priv_data_size = sizeof(NvencContext),
     .priv_class     = &h264_nvenc_class,
     .defaults       = defaults,
diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
index c668b97f86..7c9b3848f1 100644
--- a/libavcodec/nvenc_hevc.c
+++ b/libavcodec/nvenc_hevc.c
@@ -198,6 +198,7 @@ AVCodec ff_hevc_nvenc_encoder = {
     .receive_packet = ff_nvenc_receive_packet,
     .encode2        = ff_nvenc_encode_frame,
     .close          = ff_nvenc_encode_close,
+    .flush          = ff_nvenc_encode_flush,
     .priv_data_size = sizeof(NvencContext),
     .priv_class     = &hevc_nvenc_class,
     .defaults       = defaults,
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 77da913df0..1a88432460 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR  65
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MICRO 103
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list