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

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
1696 if (ctx->weighted_pred == 1)1696 if (ctx->weighted_pred == 1)
1697 ctx->init_encode_params.enableWeightedPrediction = 1;1697 ctx->init_encode_params.enableWeightedPrediction = 1;
1698 1698
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
1699 if (ctx->bluray_compat) {1708 if (ctx->bluray_compat) {
1700 ctx->aud = 1;1709 ctx->aud = 1;
1701 ctx->dpb_size = FFMIN(FFMAX(avctx->refs, 0), 6);1710 ctx->dpb_size = FFMIN(FFMAX(avctx->refs, 0), 6);
libavcodec/nvenc.h+2−0
@@ -81,6 +81,7 @@ typedef void ID3D11Device; · 80 unmodified lines
81// SDK 12.1 compile time feature checks81// SDK 12.1 compile time feature checks
82#if NVENCAPI_CHECK_VERSION(12, 1)82#if NVENCAPI_CHECK_VERSION(12, 1)
83#define NVENC_NO_DEPRECATED_RC83#define NVENC_NO_DEPRECATED_RC
84#define NVENC_HAVE_SPLIT_FRAME_ENCODING
84#endif85#endif
85 86
86// SDK 12.2 compile time feature checks87// SDK 12.2 compile time feature checks
@@ -280,6 +281,7 @@ typedef struct NvencContext · 193 unmodified lines
280 int tf_level;281 int tf_level;
281 int lookahead_level;282 int lookahead_level;
282 int unidir_b;283 int unidir_b;
284 int split_encode_mode;
283} NvencContext;285} NvencContext;
284 286
285int ff_nvenc_encode_init(AVCodecContext *avctx);287int ff_nvenc_encode_init(AVCodecContext *avctx);
libavcodec/nvenc_av1.c+8−0
@@ -157,6 +157,14 @@ static const AVOption options[] = { · 156 unmodified lines
157 { "1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_1 }, 0, 0, VE, .unit = "lookahead_level" },157 { "1", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_1 }, 0, 0, VE, .unit = "lookahead_level" },
158 { "2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_2 }, 0, 0, VE, .unit = "lookahead_level" },158 { "2", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_2 }, 0, 0, VE, .unit = "lookahead_level" },
159 { "3", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_LOOKAHEAD_LEVEL_3 }, 0, 0, VE, .unit = "lookahead_level" },159 { "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" },
160#endif168#endif
161 { NULL }169 { NULL }
162};170};
libavcodec/nvenc_hevc.c+8−0
@@ -216,6 +216,14 @@ static const AVOption options[] = { · 215 unmodified lines
216#endif216#endif
217#ifdef NVENC_HAVE_UNIDIR_B217#ifdef NVENC_HAVE_UNIDIR_B
218 { "unidir_b", "Enable use of unidirectional B-Frames.", OFFSET(unidir_b), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },218 { "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" },
219#endif227#endif
220 { NULL }228 { NULL }
221};229};
libavcodec/version.h+1−1
@@ -30,7 +30,7 @@ · 29 unmodified lines
30#include "version_major.h"30#include "version_major.h"
31 31
32#define LIBAVCODEC_VERSION_MINOR 532#define LIBAVCODEC_VERSION_MINOR 5
33#define LIBAVCODEC_VERSION_MICRO 10233#define LIBAVCODEC_VERSION_MICRO 103
34 34
35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \35#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
36 LIBAVCODEC_VERSION_MINOR, \36 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