From 4f1ae877cba0089f2e05267e4d25c518668e3684 Mon Sep 17 00:00:00 2001 From: Leigh Scott Date: Sat, 23 Nov 2024 17:10:01 +0000 Subject: [PATCH] Fix nvenc build issue --- compat-ffmpeg4.spec | 6 ++- nvenc-support-SDK-12.2-bit-depth-API.patch | 61 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 nvenc-support-SDK-12.2-bit-depth-API.patch diff --git a/compat-ffmpeg4.spec b/compat-ffmpeg4.spec index eb7767d..8c584d7 100644 --- a/compat-ffmpeg4.spec +++ b/compat-ffmpeg4.spec @@ -43,7 +43,7 @@ Summary: Digital VCR and streaming server Name: compat-ffmpeg4 Version: 4.4.5 -Release: 1%{?dist} +Release: 2%{?dist} License: %{ffmpeg_license} URL: https://ffmpeg.org/ Source0: %{url}/releases/ffmpeg-%{version}.tar.xz @@ -51,6 +51,7 @@ Source1: %{url}/releases/ffmpeg-%{version}.tar.xz.asc Source2: %{url}/ffmpeg-devel.asc Patch0: configure-fix-nvenc-detection.patch Patch1: nvenc-stop-using-deprecated-rc-modes.patch +Patch2: nvenc-support-SDK-12.2-bit-depth-API.patch BuildRequires: gcc BuildRequires: alsa-lib-devel @@ -333,6 +334,9 @@ rm -rf %{buildroot}/%{_datadir}/compat-ffmpeg4/ %changelog +* Sat Nov 23 2024 Leigh Scott - 4.4.5-2 +- Rebuild for new x265 + * Sun Aug 04 2024 Leigh Scott - 4.4.5-1 - Update to 4.4.5 diff --git a/nvenc-support-SDK-12.2-bit-depth-API.patch b/nvenc-support-SDK-12.2-bit-depth-API.patch new file mode 100644 index 0000000..5ca6f29 --- /dev/null +++ b/nvenc-support-SDK-12.2-bit-depth-API.patch @@ -0,0 +1,61 @@ +diff -uNrp a/libavcodec/nvenc.c b/libavcodec/nvenc.c +--- a/libavcodec/nvenc.c 2024-07-28 23:54:46.000000000 +0100 ++++ b/libavcodec/nvenc.c 2024-11-23 16:57:00.759959963 +0000 +@@ -1114,6 +1114,11 @@ static av_cold int nvenc_setup_h264_conf + + 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; + +@@ -1200,7 +1205,12 @@ static av_cold int nvenc_setup_hevc_conf + + 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; + +@@ -1405,14 +1415,14 @@ static NV_ENC_BUFFER_FORMAT nvenc_map_bu + { + switch (pix_fmt) { + case AV_PIX_FMT_YUV420P: +- return NV_ENC_BUFFER_FORMAT_YV12_PL; ++ return NV_ENC_BUFFER_FORMAT_YV12; + case AV_PIX_FMT_NV12: +- return NV_ENC_BUFFER_FORMAT_NV12_PL; ++ return NV_ENC_BUFFER_FORMAT_NV12; + case AV_PIX_FMT_P010: + case AV_PIX_FMT_P016: + return NV_ENC_BUFFER_FORMAT_YUV420_10BIT; + case AV_PIX_FMT_YUV444P: +- return NV_ENC_BUFFER_FORMAT_YUV444_PL; ++ return NV_ENC_BUFFER_FORMAT_YUV444; + case AV_PIX_FMT_YUV444P16: + return NV_ENC_BUFFER_FORMAT_YUV444_10BIT; + case AV_PIX_FMT_0RGB32: +diff -uNrp a/libavcodec/nvenc.h b/libavcodec/nvenc.h +--- a/libavcodec/nvenc.h 2024-11-23 17:00:50.338016687 +0000 ++++ b/libavcodec/nvenc.h 2024-11-23 16:57:00.760959981 +0000 +@@ -75,6 +75,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;