History

avcodec/nvenc: Multi NVENC Split Frame Encoding in HEVC and AV1

When Split frame encoding is enabled, each input frame is partitioned into horizontal strips which are encoded independently and simultaneously by separate NVENCs, usually resulting in increased encoding speed compared to single NVENC encoding.

Diego Felix de Souza committed 2 years ago

Commit 1f265aa1 parent 1c451045 files · +28 −1Browse files

Showing the changes to libavcodec (5 of 5 files). Show all

Unified · Split

5 files
  1. libavcodec/nvenc.c +9 −0
  2. libavcodec/nvenc.h +2 −0
  3. libavcodec/nvenc_av1.c +8 −0
  4. libavcodec/nvenc_hevc.c +8 −0
  5. libavcodec/version.h +1 −1
libavcodec/nvenc.c+9−0
@@ -1696,6 +1696,15 @@ FF_ENABLE_DEPRECATION_WARNINGS · 1695 unmodified lines
16961696 if (ctx->weighted_pred == 1)
16971697 ctx->init_encode_params.enableWeightedPrediction = 1;
16981698
1699+#ifdef NVENC_HAVE_SPLIT_FRAME_ENCODING
1700+ ctx->init_encode_params.splitEncodeMode = ctx->split_encode_mode;
1701+
1702+ if (ctx->split_encode_mode != NV_ENC_SPLIT_DISABLE_MODE) {
1703+ if (avctx->codec->id == AV_CODEC_ID_HEVC && ctx->weighted_pred == 1)
1704+ av_log(avctx, AV_LOG_WARNING, "Split encoding not supported with weighted prediction enabled.\n");
1705+ }
1706+#endif
1707+
16991708 if (ctx->bluray_compat) {
17001709 ctx->aud = 1;
17011710 ctx->dpb_size = FFMIN(FFMAX(avctx->refs, 0), 6);
libavcodec/nvenc.h+2−0
@@ -81,6 +81,7 @@ typedef void ID3D11Device; · 80 unmodified lines
8181 // SDK 12.1 compile time feature checks
8282 #if NVENCAPI_CHECK_VERSION(12, 1)
8383 #define NVENC_NO_DEPRECATED_RC
84+#define NVENC_HAVE_SPLIT_FRAME_ENCODING
8485 #endif
8586
8687 // SDK 12.2 compile time feature checks
@@ -280,6 +281,7 @@ typedef struct NvencContext · 193 unmodified lines
280281 int tf_level;
281282 int lookahead_level;
282283 int unidir_b;
284+ int split_encode_mode;
283285 } NvencContext;
284286
285287 int ff_nvenc_encode_init(AVCodecContext *avctx);
libavcodec/nvenc_av1.c+8−0
@@ -157,6 +157,14 @@ static const AVOption options[] = { · 156 unmodified lines
157157 { "1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_1 }, 0, 0, VE, .unit = "lookahead_level" },
158158 { "2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_2 }, 0, 0, VE, .unit = "lookahead_level" },
159159 { "3", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_3 }, 0, 0, VE, .unit = "lookahead_level" },
160+#endif
161+#ifdef NVENC_HAVE_SPLIT_FRAME_ENCODING
162+ { "split_encode_mode", "Specifies the split encoding mode", OFFSET(split_encode_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, NV_ENC_SPLIT_DISABLE_MODE, VE, .unit = "split_encode_mode" },
163+ { "disabled", "Disabled for all configurations", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_DISABLE_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
164+ { "auto", "Enabled or disabled depending on the preset and tuning info", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
165+ { "forced", "Enabled with number of horizontal strips selected by the driver", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
166+ { "2", "Enabled with number of horizontal strips forced to 2 when number of NVENCs > 1", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_TWO_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
167+ { "3", "Enabled with number of horizontal strips forced to 3 when number of NVENCs > 2", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_THREE_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
160168 #endif
161169 { NULL }
162170 };
libavcodec/nvenc_hevc.c+8−0
@@ -216,6 +216,14 @@ static const AVOption options[] = { · 215 unmodified lines
216216 #endif
217217 #ifdef NVENC_HAVE_UNIDIR_B
218218 { "unidir_b", "Enable use of unidirectional B-Frames.", OFFSET(unidir_b), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
219+#endif
220+#ifdef NVENC_HAVE_SPLIT_FRAME_ENCODING
221+ { "split_encode_mode", "Specifies the split encoding mode", OFFSET(split_encode_mode), AV_OPT_TYPE_INT, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, NV_ENC_SPLIT_DISABLE_MODE, VE, .unit = "split_encode_mode" },
222+ { "disabled", "Disabled for all configurations", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_DISABLE_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
223+ { "auto", "Enabled or disabled depending on the preset and tuning info", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
224+ { "forced", "Enabled with number of horizontal strips selected by the driver", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_AUTO_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
225+ { "2", "Enabled with number of horizontal strips forced to 2 when number of NVENCs > 1", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_TWO_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
226+ { "3", "Enabled with number of horizontal strips forced to 3 when number of NVENCs > 2", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_SPLIT_THREE_FORCED_MODE }, 0, 0, VE, .unit = "split_encode_mode" },
219227 #endif
220228 { NULL }
221229 };
libavcodec/version.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
3030 #include "version_major.h"
3131
3232 #define LIBAVCODEC_VERSION_MINOR 5
33−#define LIBAVCODEC_VERSION_MICRO 102
33+#define LIBAVCODEC_VERSION_MICRO 103
3434
3535 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3636 LIBAVCODEC_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t