64 lines
2.4 KiB
Diff
64 lines
2.4 KiB
Diff
|
From 8e5fec4c7765b1c43d40f652b46d034340877a31 Mon Sep 17 00:00:00 2001
|
||
|
From: Ryan Foster <ryan@obsproject.com>
|
||
|
Date: Fri, 14 Apr 2023 12:05:59 -0400
|
||
|
Subject: [PATCH 1/2] obs-ffmpeg: Use 2x2 tiles in NVENC AV1 for 4K+
|
||
|
|
||
|
When resolution is 4K or higher, use 2x2 uniform tiles for NVENC AV1.
|
||
|
---
|
||
|
plugins/obs-ffmpeg/jim-nvenc.c | 11 +++++++++++
|
||
|
1 file changed, 11 insertions(+)
|
||
|
|
||
|
diff --git a/plugins/obs-ffmpeg/jim-nvenc.c b/plugins/obs-ffmpeg/jim-nvenc.c
|
||
|
index 10a7dd18549b9..c1e8bee154770 100644
|
||
|
--- a/plugins/obs-ffmpeg/jim-nvenc.c
|
||
|
+++ b/plugins/obs-ffmpeg/jim-nvenc.c
|
||
|
@@ -922,6 +922,17 @@ static bool init_encoder_av1(struct nvenc_data *enc, obs_data_t *settings,
|
||
|
if (config->rcParams.rateControlMode == NV_ENC_PARAMS_RC_CBR)
|
||
|
av1_config->enableBitstreamPadding = 1;
|
||
|
|
||
|
+#define FOUR_K_CX 3840
|
||
|
+#define FOUR_K_CY 2160
|
||
|
+#define PIXELCOUNT_4K (FOUR_K_CX * FOUR_K_CY)
|
||
|
+
|
||
|
+ /* If 4K+, set tiles to 2x2 uniform tiles. */
|
||
|
+ if ((voi->width * voi->height) >= PIXELCOUNT_4K) {
|
||
|
+ av1_config->enableCustomTileConfig = 0;
|
||
|
+ av1_config->numTileColumns = 2;
|
||
|
+ av1_config->numTileRows = 2;
|
||
|
+ }
|
||
|
+
|
||
|
switch (voi->colorspace) {
|
||
|
case VIDEO_CS_601:
|
||
|
av1_config->colorPrimaries = 6;
|
||
|
|
||
|
From 872f0353e68191d69bcc4678a2d195144fdcabeb Mon Sep 17 00:00:00 2001
|
||
|
From: Ryan Foster <ryan@obsproject.com>
|
||
|
Date: Fri, 14 Apr 2023 12:07:50 -0400
|
||
|
Subject: [PATCH 2/2] obs-ffmpeg: Use 2 tiles per frame in AMF AV1 for 4K+
|
||
|
|
||
|
When resolution is 4K or higher, use 2 tiles per frame in AMF AV1.
|
||
|
---
|
||
|
plugins/obs-ffmpeg/texture-amf.cpp | 9 +++++++++
|
||
|
1 file changed, 9 insertions(+)
|
||
|
|
||
|
diff --git a/plugins/obs-ffmpeg/texture-amf.cpp b/plugins/obs-ffmpeg/texture-amf.cpp
|
||
|
index 88914a027f699..5979b903385ad 100644
|
||
|
--- a/plugins/obs-ffmpeg/texture-amf.cpp
|
||
|
+++ b/plugins/obs-ffmpeg/texture-amf.cpp
|
||
|
@@ -2018,6 +2018,15 @@ static void amf_av1_create_internal(amf_base *enc, obs_data_t *settings)
|
||
|
const bool is10bit = enc->amf_format == AMF_SURFACE_P010;
|
||
|
const char *preset = obs_data_get_string(settings, "preset");
|
||
|
|
||
|
+ constexpr uint32_t four_k_cx = 3840;
|
||
|
+ constexpr uint32_t four_k_cy = 2160;
|
||
|
+ constexpr uint32_t pixelcount_4k = four_k_cx * four_k_cy;
|
||
|
+
|
||
|
+ /* If 4K+, set tiles per frame to 2. */
|
||
|
+ if ((enc->cx * enc->cy) >= pixelcount_4k) {
|
||
|
+ set_av1_property(enc, TILES_PER_FRAME, 2);
|
||
|
+ }
|
||
|
+
|
||
|
set_av1_property(enc, FRAMESIZE, AMFConstructSize(enc->cx, enc->cy));
|
||
|
set_av1_property(enc, USAGE, AMF_VIDEO_ENCODER_USAGE_TRANSCODING);
|
||
|
set_av1_property(enc, ALIGNMENT_MODE,
|