[FFmpeg-cvslog] avcodec/nvenc: support SDK 12.2 bit depth API
Timo Rothenpieler
git at videolan.org
Sun Mar 31 22:36:51 EEST 2024
ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Sun Mar 31 18:39:49 2024 +0200| [06c2a2c425f22e7dba5cad909737a631cc676e3f] | committer: Timo Rothenpieler
avcodec/nvenc: support SDK 12.2 bit depth API
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=06c2a2c425f22e7dba5cad909737a631cc676e3f
---
libavcodec/nvenc.c | 15 +++++++++++++++
libavcodec/nvenc.h | 5 +++++
2 files changed, 20 insertions(+)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 0cb3b87c67..8327496937 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1255,6 +1255,11 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx)
h264->level = ctx->level;
+#ifdef NVENC_HAVE_NEW_BIT_DEPTH_API
+ h264->inputBitDepth = h264->outputBitDepth =
+ IS_10BIT(ctx->data_pix_fmt) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8;
+#endif
+
if (ctx->coder >= 0)
h264->entropyCodingMode = ctx->coder;
@@ -1370,7 +1375,12 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx)
hevc->chromaFormatIDC = IS_YUV444(ctx->data_pix_fmt) ? 3 : 1;
+#ifdef NVENC_HAVE_NEW_BIT_DEPTH_API
+ hevc->inputBitDepth = hevc->outputBitDepth =
+ IS_10BIT(ctx->data_pix_fmt) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8;
+#else
hevc->pixelBitDepthMinus8 = IS_10BIT(ctx->data_pix_fmt) ? 2 : 0;
+#endif
hevc->level = ctx->level;
@@ -1455,8 +1465,13 @@ static av_cold int nvenc_setup_av1_config(AVCodecContext *avctx)
av1->chromaFormatIDC = IS_YUV444(ctx->data_pix_fmt) ? 3 : 1;
+#ifdef NVENC_HAVE_NEW_BIT_DEPTH_API
+ av1->inputBitDepth = IS_10BIT(ctx->data_pix_fmt) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8;
+ av1->outputBitDepth = (IS_10BIT(ctx->data_pix_fmt) || ctx->highbitdepth) ? NV_ENC_BIT_DEPTH_10 : NV_ENC_BIT_DEPTH_8;
+#else
av1->inputPixelBitDepthMinus8 = IS_10BIT(ctx->data_pix_fmt) ? 2 : 0;
av1->pixelBitDepthMinus8 = (IS_10BIT(ctx->data_pix_fmt) || ctx->highbitdepth) ? 2 : 0;
+#endif
if (ctx->b_ref_mode >= 0)
av1->useBFramesAsRef = ctx->b_ref_mode;
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index 48cdfc58aa..d99d8a0d76 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -83,6 +83,11 @@ typedef void ID3D11Device;
#define NVENC_NO_DEPRECATED_RC
#endif
+// SDK 12.2 compile time feature checks
+#if NVENCAPI_CHECK_VERSION(12, 2)
+#define NVENC_HAVE_NEW_BIT_DEPTH_API
+#endif
+
typedef struct NvencSurface
{
NV_ENC_INPUT_PTR input_surface;
More information about the ffmpeg-cvslog
mailing list