diff options
author | Yogender Gupta <ygupta@nvidia.com> | 2016-09-24 17:55:00 +0200 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2016-09-28 16:48:43 +0200 |
commit | facc19ef06a753515a3fa604269dd1aa412dc08f (patch) | |
tree | ae073a0fa586ea5edafe604156576ffeb7ee585d /libavcodec/nvenc.c | |
parent | 033f98c902f5b556a01be27d2cb5cff93bda92f3 (diff) | |
download | ffmpeg-facc19ef06a753515a3fa604269dd1aa412dc08f.tar.gz |
avcodec/nvenc: Extended rate-control support as provided by SDK 7
Merged from libav commit by Yogender Gupta:
https://git.libav.org/?p=libav.git;a=commitdiff;h=70de2ea4261f860457a04e3d0c58c5543f403325
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r-- | libavcodec/nvenc.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 421ea79c62..f6f756fe00 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -724,10 +724,50 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx) ctx->encode_config.rcParams.vbvBufferSize = 2 * ctx->encode_config.rcParams.averageBitRate; } - if (ctx->rc_lookahead > 0) { - ctx->encode_config.rcParams.enableLookahead = 1; - ctx->encode_config.rcParams.lookaheadDepth = FFMIN(ctx->rc_lookahead, 32); + if (ctx->aq) { + ctx->encode_config.rcParams.enableAQ = 1; + ctx->encode_config.rcParams.aqStrength = ctx->aq_strength; + av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n"); } + + if (ctx->temporal_aq) { + ctx->encode_config.rcParams.enableTemporalAQ = 1; + av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n"); + } + + if (ctx->rc_lookahead) { + int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) - + ctx->encode_config.frameIntervalP - 4; + + if (lkd_bound < 0) { + av_log(avctx, AV_LOG_WARNING, + "Lookahead not enabled. Increase buffer delay (-delay).\n"); + } else { + ctx->encode_config.rcParams.enableLookahead = 1; + ctx->encode_config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound); + ctx->encode_config.rcParams.disableIadapt = ctx->no_scenecut; + ctx->encode_config.rcParams.disableBadapt = !ctx->b_adapt; + av_log(avctx, AV_LOG_VERBOSE, + "Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n", + ctx->encode_config.rcParams.lookaheadDepth, + ctx->encode_config.rcParams.disableIadapt ? "disabled" : "enabled", + ctx->encode_config.rcParams.disableBadapt ? "disabled" : "enabled"); + } + } + + if (ctx->strict_gop) { + ctx->encode_config.rcParams.strictGOPTarget = 1; + av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n"); + } + + if (ctx->nonref_p) + ctx->encode_config.rcParams.enableNonRefP = 1; + + if (ctx->zerolatency) + ctx->encode_config.rcParams.zeroReorderDelay = 1; + + if (ctx->quality) + ctx->encode_config.rcParams.targetQuality = ctx->quality; } static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) |