]> git.sesse.net Git - ffmpeg/commitdiff
nvenc: implement flush to help allow an encoder to be re-used
authorPhilip Langdale <philipl@overt.org>
Fri, 20 Dec 2019 23:34:33 +0000 (15:34 -0800)
committerPhilip Langdale <philipl@overt.org>
Thu, 9 Jan 2020 03:20:36 +0000 (19:20 -0800)
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.

libavcodec/nvenc.c
libavcodec/nvenc.h
libavcodec/nvenc_h264.c
libavcodec/nvenc_hevc.c
libavcodec/version.h

index 310e30805ddceea9b2275e9254c572c85804408e..9a96bf2bbafe5d0100a5c468742a46f76425ad8b 100644 (file)
@@ -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);
+}
index a269bd97bbab1602392be0ac7d74e8cf975da1cd..c44c81e67596d43e70ca815b748663e3b5a08c77 100644 (file)
@@ -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 */
index d5c7370aaa7aebab44281467e69d0ed31b0b8b7c..479155fe1528c53bfb1cbc4afdd7429948375660 100644 (file)
@@ -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,
index c668b97f86441a76dadb6b149e6c19b725ac5b62..7c9b3848f1f588d599aed4c23dcbb0d6e7381bff 100644 (file)
@@ -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,
index 77da913df0520b2303a6fff672d386ac0d797cbc..1a884324609305153b31dde41d76d0ad8e6a8a28 100644 (file)
@@ -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, \