Unified · Split
| @@ -594,6 +594,14 @@ static int nvenc_check_capabilities(AVCodecContext *avctx) · 593 unmodified lines | |||
| 594 | return AVERROR(ENOSYS); | 594 | return AVERROR(ENOSYS); |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | #ifdef NVENC_HAVE_TEMPORAL_FILTER | ||
| 598 | ret = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_TEMPORAL_FILTER); | ||
| 599 | if(ctx->tf_level > 0 && ret <= 0) { | ||
| 600 | av_log(avctx, AV_LOG_WARNING, "Temporal filtering not supported by the device\n"); | ||
| 601 | return AVERROR(ENOSYS); | ||
| 602 | } | ||
| 603 | #endif | ||
| 604 | |||
| 597 | ctx->support_dyn_bitrate = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE); | 605 | ctx->support_dyn_bitrate = nvenc_check_cap(avctx, NV_ENC_CAPS_SUPPORT_DYN_BITRATE_CHANGE); |
| 598 | 606 | ||
| 599 | return 0; | 607 | return 0; |
| @@ -1396,6 +1404,25 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) · 796 unmodified lines | |||
| 1396 | hevc->numRefL1 = avctx->refs; | 1404 | hevc->numRefL1 = avctx->refs; |
| 1397 | #endif | 1405 | #endif |
| 1398 | 1406 | ||
| 1407 | #ifdef NVENC_HAVE_TEMPORAL_FILTER | ||
| 1408 | if (ctx->tf_level >= 0) { | ||
| 1409 | hevc->tfLevel = ctx->tf_level; | ||
| 1410 | |||
| 1411 | switch (ctx->tf_level) | ||
| 1412 | { | ||
| 1413 | case NV_ENC_TEMPORAL_FILTER_LEVEL_0: | ||
| 1414 | case NV_ENC_TEMPORAL_FILTER_LEVEL_4: | ||
| 1415 | break; | ||
| 1416 | default: | ||
| 1417 | av_log(avctx, AV_LOG_ERROR, "Invalid temporal filtering level.\n"); | ||
| 1418 | return AVERROR(EINVAL); | ||
| 1419 | } | ||
| 1420 | |||
| 1421 | if (ctx->encode_config.frameIntervalP < 5) | ||
| 1422 | av_log(avctx, AV_LOG_WARNING, "Temporal filtering needs at least 4 B-Frames (-bf 4).\n"); | ||
| 1423 | } | ||
| 1424 | #endif | ||
| 1425 | |||
| 1399 | return 0; | 1426 | return 0; |
| 1400 | } | 1427 | } |
| 1401 | 1428 | ||
| @@ -86,6 +86,7 @@ typedef void ID3D11Device; · 85 unmodified lines | |||
| 86 | // SDK 12.2 compile time feature checks | 86 | // SDK 12.2 compile time feature checks |
| 87 | #if NVENCAPI_CHECK_VERSION(12, 2) | 87 | #if NVENCAPI_CHECK_VERSION(12, 2) |
| 88 | #define NVENC_HAVE_NEW_BIT_DEPTH_API | 88 | #define NVENC_HAVE_NEW_BIT_DEPTH_API |
| 89 | #define NVENC_HAVE_TEMPORAL_FILTER | ||
| 89 | #endif | 90 | #endif |
| 90 | 91 | ||
| 91 | typedef struct NvencSurface | 92 | typedef struct NvencSurface |
| @@ -271,6 +272,7 @@ typedef struct NvencContext · 179 unmodified lines | |||
| 271 | int highbitdepth; | 272 | int highbitdepth; |
| 272 | int max_slice_size; | 273 | int max_slice_size; |
| 273 | int rgb_mode; | 274 | int rgb_mode; |
| 275 | int tf_level; | ||
| 274 | } NvencContext; | 276 | } NvencContext; |
| 275 | 277 | ||
| 276 | int ff_nvenc_encode_init(AVCodecContext *avctx); | 278 | int ff_nvenc_encode_init(AVCodecContext *avctx); |
| @@ -196,6 +196,12 @@ static const AVOption options[] = { · 195 unmodified lines | |||
| 196 | OFFSET(max_slice_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, | 196 | OFFSET(max_slice_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, |
| 197 | { "constrained-encoding", "Enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices", | 197 | { "constrained-encoding", "Enable constrainedFrame encoding where each slice in the constrained picture is independent of other slices", |
| 198 | OFFSET(constrained_encoding), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, | 198 | OFFSET(constrained_encoding), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE }, |
| 199 | #ifdef NVENC_HAVE_TEMPORAL_FILTER | ||
| 200 | { "tf_level", "Specifies the strength of the temporal filtering", | ||
| 201 | OFFSET(tf_level), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VE, .unit = "tf_level" }, | ||
| 202 | { "0", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_TEMPORAL_FILTER_LEVEL_0 }, 0, 0, VE, .unit = "tf_level" }, | ||
| 203 | { "4", "", 0, AV_OPT_TYPE_CONST, { .i64 = NV_ENC_TEMPORAL_FILTER_LEVEL_4 }, 0, 0, VE, .unit = "tf_level" }, | ||
| 204 | #endif | ||
| 199 | { NULL } | 205 | { NULL } |
| 200 | }; | 206 | }; |
| 201 | 207 | ||