commit 20ba5b1c2c75084fd16e89c82e2736c6aebda9ea
Author: Leigh Scott <leigh123linux(a)gmail.com>
Date: Sat Apr 6 16:07:21 2024 +0100
Fix nvenc build issue
5b637ae04773b417c9e6b47ba015abf458a9c151.patch | 163 +++++++++++++++++++++++++
avidemux.spec | 1 +
2 files changed, 164 insertions(+)
---
diff --git a/5b637ae04773b417c9e6b47ba015abf458a9c151.patch
b/5b637ae04773b417c9e6b47ba015abf458a9c151.patch
new file mode 100644
index 0000000..7c58232
--- /dev/null
+++ b/5b637ae04773b417c9e6b47ba015abf458a9c151.patch
@@ -0,0 +1,163 @@
+From 5b637ae04773b417c9e6b47ba015abf458a9c151 Mon Sep 17 00:00:00 2001
+From: eumagga0x2a <eumagga0x2a(a)users.noreply.github.com>
+Date: Tue, 31 Oct 2023 20:00:05 +0100
+Subject: [PATCH] [ffmpeg/patches] Add upstream patch to fix build with latest
+ nv-codec-headers
+
+---
+ ...nvenc-stop-using-deprecated-rc-modes.patch | 146 ++++++++++++++++++
+ 1 file changed, 146 insertions(+)
+ create mode 100644
avidemux_core/ffmpeg_package/patches/upstream/nvenc-stop-using-deprecated-rc-modes.patch
+
+diff --git
a/avidemux_core/ffmpeg_package/patches/upstream/nvenc-stop-using-deprecated-rc-modes.patch
b/avidemux_core/ffmpeg_package/patches/upstream/nvenc-stop-using-deprecated-rc-modes.patch
+new file mode 100644
+index 000000000..6c1c1d099
+--- /dev/null
++++
b/avidemux_core/ffmpeg_package/patches/upstream/nvenc-stop-using-deprecated-rc-modes.patch
+@@ -0,0 +1,146 @@
++From d2b46c1ef768bc31ba9180f6d469d5b8be677500 Mon Sep 17 00:00:00 2001
++From: Timo Rothenpieler <timo(a)rothenpieler.org>
++Date: Thu, 1 Jun 2023 23:46:46 +0200
++Subject: [PATCH] avcodec/nvenc: stop using deprecated rc modes with SDK 12.1
++
++---
++ libavcodec/nvenc.c | 11 +++++++++++
++ libavcodec/nvenc.h | 5 +++++
++ libavcodec/nvenc_h264.c | 12 ++++++++++++
++ libavcodec/nvenc_hevc.c | 12 ++++++++++++
++ 4 files changed, 40 insertions(+)
++
++diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
++index c1798ce564b7f..50371d63366de 100644
++--- a/libavcodec/nvenc.c
+++++ b/libavcodec/nvenc.c
++@@ -44,9 +44,14 @@
++ #define CHECK_CU(x) FF_CUDA_CHECK_DL(avctx, dl_fn->cuda_dl, x)
++
++ #define NVENC_CAP 0x30
+++
+++#ifndef NVENC_NO_DEPRECATED_RC
++ #define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR || \
++ rc == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ || \
++ rc == NV_ENC_PARAMS_RC_CBR_HQ)
+++#else
+++#define IS_CBR(rc) (rc == NV_ENC_PARAMS_RC_CBR)
+++#endif
++
++ const enum AVPixelFormat ff_nvenc_pix_fmts[] = {
++ AV_PIX_FMT_YUV420P,
++@@ -926,6 +931,7 @@ static void nvenc_override_rate_control(AVCodecContext *avctx)
++ case NV_ENC_PARAMS_RC_CONSTQP:
++ set_constqp(avctx);
++ return;
+++#ifndef NVENC_NO_DEPRECATED_RC
++ case NV_ENC_PARAMS_RC_VBR_MINQP:
++ if (avctx->qmin < 0) {
++ av_log(avctx, AV_LOG_WARNING,
++@@ -936,12 +942,15 @@ static void nvenc_override_rate_control(AVCodecContext *avctx)
++ }
++ /* fall through */
++ case NV_ENC_PARAMS_RC_VBR_HQ:
+++#endif
++ case NV_ENC_PARAMS_RC_VBR:
++ set_vbr(avctx);
++ break;
++ case NV_ENC_PARAMS_RC_CBR:
+++#ifndef NVENC_NO_DEPRECATED_RC
++ case NV_ENC_PARAMS_RC_CBR_HQ:
++ case NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ:
+++#endif
++ break;
++ }
++
++@@ -1211,12 +1220,14 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext
*avctx)
++
++ h264->outputPictureTimingSEI = 1;
++
+++#ifndef NVENC_NO_DEPRECATED_RC
++ if (cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ ||
++ cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR_HQ ||
++ cc->rcParams.rateControlMode == NV_ENC_PARAMS_RC_VBR_HQ) {
++ h264->adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE;
++ h264->fmoMode = NV_ENC_H264_FMO_DISABLE;
++ }
+++#endif
++
++ if (ctx->flags & NVENC_LOSSLESS) {
++ h264->qpPrimeYZeroTransformBypassFlag = 1;
++diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
++index 411c83aa94387..97aad80cd0657 100644
++--- a/libavcodec/nvenc.h
+++++ b/libavcodec/nvenc.h
++@@ -77,6 +77,11 @@ typedef void ID3D11Device;
++ #define NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH
++ #endif
++
+++// SDK 12.1 compile time feature checks
+++#if NVENCAPI_CHECK_VERSION(12, 1)
+++#define NVENC_NO_DEPRECATED_RC
+++#endif
+++
++ typedef struct NvencSurface
++ {
++ NV_ENC_INPUT_PTR input_surface;
++diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c
++index 5dc2961c3bcf3..698615855bf57 100644
++--- a/libavcodec/nvenc_h264.c
+++++ b/libavcodec/nvenc_h264.c
++@@ -100,6 +100,7 @@ static const AVOption options[] = {
++ { "constqp", "Constant QP mode", 0,
AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0,
0, VE, "rc" },
++ { "vbr", "Variable bitrate mode", 0,
AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0,
0, VE, "rc" },
++ { "cbr", "Constant bitrate mode", 0,
AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0,
0, VE, "rc" },
+++#ifndef NVENC_NO_DEPRECATED_RC
++ { "vbr_minqp", "Variable bitrate mode with MinQP
(deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_MINQP)
}, 0, 0, VE, "rc" },
++ { "ll_2pass_quality", "Multi-pass optimized for image quality
(deprecated)",
++ 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_2_PASS_QUALITY) }, 0, 0, VE,
"rc" },
++@@ -109,6 +110,17 @@ static const AVOption options[] = {
++ { "cbr_ld_hq", "Constant bitrate low delay high quality
mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ)
}, 0, 0, VE, "rc" },
++ { "cbr_hq", "Constant bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_HQ) }, 0,
0, VE, "rc" },
++ { "vbr_hq", "Variable bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_HQ) }, 0,
0, VE, "rc" },
+++#else
+++ { "vbr_minqp", "Variable bitrate mode with MinQP
(deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) },
0, 0, VE, "rc" },
+++ { "ll_2pass_quality", "Multi-pass optimized for image quality
(deprecated)",
+++ 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE,
"rc" },
+++ { "ll_2pass_size", "Multi-pass optimized for constant frame size
(deprecated)",
+++ 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE,
"rc" },
+++ { "vbr_2pass", "Multi-pass variable bitrate mode
(deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) },
0, 0, VE, "rc" },
+++ { "cbr_ld_hq", "Constant bitrate low delay high quality
mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) },
0, 0, VE, "rc" },
+++ { "cbr_hq", "Constant bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0,
0, VE, "rc" },
+++ { "vbr_hq", "Variable bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0,
0, VE, "rc" },
+++#endif
++ { "rc-lookahead", "Number of frames to look ahead for
rate-control",
++ OFFSET(rc_lookahead),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
++ { "surfaces", "Number of concurrent surfaces",
OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_REGISTERED_FRAMES, VE },
++diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
++index 1362a927c8e46..d99077f17055f 100644
++--- a/libavcodec/nvenc_hevc.c
+++++ b/libavcodec/nvenc_hevc.c
++@@ -89,6 +89,7 @@ static const AVOption options[] = {
++ { "constqp", "Constant QP mode", 0,
AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CONSTQP }, 0,
0, VE, "rc" },
++ { "vbr", "Variable bitrate mode", 0,
AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_VBR }, 0,
0, VE, "rc" },
++ { "cbr", "Constant bitrate mode", 0,
AV_OPT_TYPE_CONST, { .i64 = NV_ENC_PARAMS_RC_CBR }, 0,
0, VE, "rc" },
+++#ifndef NVENC_NO_DEPRECATED_RC
++ { "vbr_minqp", "Variable bitrate mode with MinQP
(deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_MINQP)
}, 0, 0, VE, "rc" },
++ { "ll_2pass_quality", "Multi-pass optimized for image quality
(deprecated)",
++ 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_2_PASS_QUALITY) }, 0, 0, VE,
"rc" },
++@@ -98,6 +99,17 @@ static const AVOption options[] = {
++ { "cbr_ld_hq", "Constant bitrate low delay high quality
mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_LOWDELAY_HQ)
}, 0, 0, VE, "rc" },
++ { "cbr_hq", "Constant bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR_HQ) }, 0,
0, VE, "rc" },
++ { "vbr_hq", "Variable bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR_HQ) }, 0,
0, VE, "rc" },
+++#else
+++ { "vbr_minqp", "Variable bitrate mode with MinQP
(deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) },
0, 0, VE, "rc" },
+++ { "ll_2pass_quality", "Multi-pass optimized for image quality
(deprecated)",
+++ 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0, 0, VE,
"rc" },
+++ { "ll_2pass_size", "Multi-pass optimized for constant frame size
(deprecated)",
+++ 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0, 0, VE,
"rc" },
+++ { "vbr_2pass", "Multi-pass variable bitrate mode
(deprecated)", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) },
0, 0, VE, "rc" },
+++ { "cbr_ld_hq", "Constant bitrate low delay high quality
mode", 0, AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) },
0, 0, VE, "rc" },
+++ { "cbr_hq", "Constant bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_CBR) }, 0,
0, VE, "rc" },
+++ { "vbr_hq", "Variable bitrate high quality mode", 0,
AV_OPT_TYPE_CONST, { .i64 = RCD(NV_ENC_PARAMS_RC_VBR) }, 0,
0, VE, "rc" },
+++#endif
++ { "rc-lookahead", "Number of frames to look ahead for
rate-control",
++ OFFSET(rc_lookahead),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
++ { "surfaces", "Number of concurrent surfaces",
OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_REGISTERED_FRAMES, VE },
diff --git a/avidemux.spec b/avidemux.spec
index 4f9ffd5..c8c4c35 100644
--- a/avidemux.spec
+++ b/avidemux.spec
@@ -19,6 +19,7 @@ Source0:
http://downloads.sourceforge.net/%{name}/%{name}_%{version}.tar.
Patch0: avidemux-disable_mp4v2.patch
Patch1: ffmpeg_buildfix.patch
+Patch2: 5b637ae04773b417c9e6b47ba015abf458a9c151.patch
# Don't try to build on arm, aarch64 or ppc
ExclusiveArch: i686 x86_64