[FFmpeg-cvslog] avcodec/nvenc: add b_as_ref support for HEVC
Roman Arzumanyan
git at videolan.org
Thu Feb 14 14:39:24 EET 2019
ffmpeg | branch: master | Roman Arzumanyan <rarzumanyan at nvidia.com> | Thu Feb 14 13:20:25 2019 +0100| [f1f66df6a204fdc08b8763004de2df3e20bab8f3] | committer: Timo Rothenpieler
avcodec/nvenc: add b_as_ref support for HEVC
Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f1f66df6a204fdc08b8763004de2df3e20bab8f3
---
libavcodec/nvenc.c | 4 ++++
libavcodec/nvenc.h | 5 +++++
libavcodec/nvenc_hevc.c | 11 +++++++++++
libavcodec/version.h | 2 +-
4 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 97497be0bc..304a684e0c 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1070,6 +1070,10 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
hevc->tier = ctx->tier;
+#ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE
+ hevc->useBFramesAsRef = ctx->b_ref_mode;
+#endif
+
return 0;
}
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index ebb7a80fc3..ddd6168409 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -49,6 +49,11 @@ typedef void ID3D11Device;
#define NVENC_HAVE_QP_MAP_MODE
#endif
+// SDK 9.0 compile time feature checks
+#if NVENCAPI_CHECK_VERSION(9, 0)
+#define NVENC_HAVE_HEVC_BFRAME_REF_MODE
+#endif
+
typedef struct NvencSurface
{
NV_ENC_INPUT_PTR input_surface;
diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
index 0df7eab8cd..d567d960ba 100644
--- a/libavcodec/nvenc_hevc.c
+++ b/libavcodec/nvenc_hevc.c
@@ -116,6 +116,17 @@ static const AVOption options[] = {
OFFSET(cqp), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 51, VE },
{ "weighted_pred","Set 1 to enable weighted prediction",
OFFSET(weighted_pred),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+#ifdef NVENC_HAVE_HEVC_BFRAME_REF_MODE
+ { "b_ref_mode", "Use B frames as references", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_BFRAME_REF_MODE_DISABLED }, NV_ENC_BFRAME_REF_MODE_DISABLED, NV_ENC_BFRAME_REF_MODE_MIDDLE, VE, "b_ref_mode" },
+ { "disabled", "B frames will not be used for reference", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_DISABLED }, 0, 0, VE, "b_ref_mode" },
+ { "each", "Each B frame will be used for reference", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_EACH }, 0, 0, VE, "b_ref_mode" },
+ { "middle", "Only (number of B frames)/2 will be used for reference", 0,AV_OPT_TYPE_CONST, { .i64 = NV_ENC_BFRAME_REF_MODE_MIDDLE }, 0, 0, VE, "b_ref_mode" },
+#else
+ { "b_ref_mode", "(not supported)", OFFSET(b_ref_mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE, "b_ref_mode" },
+ { "disabled", "", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "b_ref_mode" },
+ { "each", "", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "b_ref_mode" },
+ { "middle", "", 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, 0, 0, VE, "b_ref_mode" },
+#endif
{ NULL }
};
diff --git a/libavcodec/version.h b/libavcodec/version.h
index c6eb7028f0..f2f188ea7c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 47
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list