Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
philipl committed Jan 9, 2020
1 parent 94cdf82 commit 3ea7057
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions libavcodec/nvenc.c
Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions libavcodec/nvenc.h
Expand Up @@ -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 */
1 change: 1 addition & 0 deletions libavcodec/nvenc_h264.c
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions libavcodec/nvenc_hevc.c
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion libavcodec/version.h
Expand Up @@ -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, \
Expand Down

0 comments on commit 3ea7057

Please sign in to comment.