aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Arzumanyan <rarzumanyan@nvidia.com>2019-09-27 17:56:11 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2019-09-27 20:00:59 +0200
commit567b5e33d9d77919ee920c091f4273c5b38fc821 (patch)
tree6279b5ee480849fd3a51eb9d3bb97ace6add4333
parente929b2f248a9c49761475e07d1a089e05912d1c6 (diff)
downloadffmpeg-567b5e33d9d77919ee920c091f4273c5b38fc821.tar.gz
avcodec/nvenc: add multiple reference frames support
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
-rw-r--r--libavcodec/nvenc.c23
-rw-r--r--libavcodec/nvenc.h5
-rw-r--r--libavcodec/version.h2
3 files changed, 29 insertions, 1 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 158e304a0c..8a7347b84e 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -403,6 +403,19 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
}
#endif
+#ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES
+ ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES);
+ if(avctx->refs != NV_ENC_NUM_REF_FRAMES_AUTOSELECT && ret <= 0) {
+ av_log(avctx, AV_LOG_VERBOSE, "Multiple reference frames are not supported\n");
+ return AVERROR(ENOSYS);
+ }
+#else
+ if(avctx->refs != 0) {
+ av_log(avctx, AV_LOG_VERBOSE, "Multiple reference frames need SDK 9.1 at build time\n");
+ return AVERROR(ENOSYS);
+ }
+#endif
+
ctx->support_dyn_bitrate = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE);
return 0;
@@ -1010,6 +1023,11 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
h264->useBFramesAsRef = ctx->b_ref_mode;
#endif
+#ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES
+ h264->numRefL0 = avctx->refs;
+ h264->numRefL1 = avctx->refs;
+#endif
+
return 0;
}
@@ -1094,6 +1112,11 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
hevc->useBFramesAsRef = ctx->b_ref_mode;
#endif
+#ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES
+ hevc->numRefL0 = avctx->refs;
+ hevc->numRefL1 = avctx->refs;
+#endif
+
return 0;
}
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index 892a001f69..46ad7972bc 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -54,6 +54,11 @@ typedef void ID3D11Device;
#define NVENC_HAVE_HEVC_BFRAME_REF_MODE
#endif
+// SDK 9.1 compile time feature checks
+#if NVENCAPI_CHECK_VERSION(9, 1)
+#define NVENC_HAVE_MULTIPLE_REF_FRAMES
+#endif
+
typedef struct NvencSurface
{
NV_ENC_INPUT_PTR input_surface;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 67f2a90739..04b210371e 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 59
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \