aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2024-03-31 21:26:15 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2024-03-31 21:32:55 +0200
commit21b4708969415b9ec6d212fb35c12e4d1c28d066 (patch)
tree37c07650a8c841c1fa05035b25d2ddc4078fb8b7
parenta27096611835f1e46b0c842ad4fffe42b36bad41 (diff)
downloadffmpeg-21b4708969415b9ec6d212fb35c12e4d1c28d066.tar.gz
avcodec/nvenc: add support for unidirectional b-frames
-rw-r--r--libavcodec/nvenc.c12
-rw-r--r--libavcodec/nvenc.h2
-rw-r--r--libavcodec/nvenc_hevc.c3
-rw-r--r--libavcodec/version.h2
4 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 7f938a519f..d121442957 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -613,6 +613,14 @@ static int nvenc_check_capabilities(AVCodecContext *avctx)
}
#endif
+#ifdef NVENC_HAVE_UNIDIR_B
+ ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_UNIDIRECTIONAL_B);
+ if(ctx->unidir_b && ret <= 0) {
+ av_log(avctx, AV_LOG_WARNING, "Unidirectional B-Frames not supported by the device\n");
+ return AVERROR(ENOSYS);
+ }
+#endif
+
ctx->support_dyn_bitrate = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE);
return 0;
@@ -1658,6 +1666,10 @@ FF_DISABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS
}
+#ifdef NVENC_HAVE_UNIDIR_B
+ ctx->init_encode_params.enableUniDirectionalB = ctx->unidir_b;
+#endif
+
ctx->init_encode_params.enableEncodeAsync = 0;
ctx->init_encode_params.enablePTD = 1;
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index 3e207b1877..45860de722 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -89,6 +89,7 @@ typedef void ID3D11Device;
#define NVENC_HAVE_TEMPORAL_FILTER
#define NVENC_HAVE_LOOKAHEAD_LEVEL
#define NVENC_HAVE_UHQ_TUNING
+#define NVENC_HAVE_UNIDIR_B
#endif
typedef struct NvencSurface
@@ -276,6 +277,7 @@ typedef struct NvencContext
int rgb_mode;
int tf_level;
int lookahead_level;
+ int unidir_b;
} NvencContext;
int ff_nvenc_encode_init(AVCodecContext *avctx);
diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
index e0d16e82c7..bd8b6153f3 100644
--- a/libavcodec/nvenc_hevc.c
+++ b/libavcodec/nvenc_hevc.c
@@ -214,6 +214,9 @@ static const AVOption options[] = {
{ "2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_2 }, 0, 0, VE, .unit = "lookahead_level" },
{ "3", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_3 }, 0, 0, VE, .unit = "lookahead_level" },
#endif
+#ifdef NVENC_HAVE_UNIDIR_B
+ { "unidir_b", "Enable use of unidirectional B-Frames.", OFFSET(unidir_b), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
+#endif
{ NULL }
};
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 06631ffa8c..7aa95fc3f1 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 4
+#define LIBAVCODEC_VERSION_MINOR 5
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \