diff options
author | Ricardo Monteiro <rmonteiro@nvidia.com> | 2023-06-22 12:18:19 +0200 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2023-06-22 19:33:09 +0200 |
commit | 99dfdb45a89955916651eeaeac77d938e9a4217a (patch) | |
tree | 23feaa25b6ffe918ace3976dde0f74b09c57b9f8 /libavcodec/nvenc.c | |
parent | 997d8a7e73a9b9f00e4bc32ed3b41b30d2e39cf8 (diff) | |
download | ffmpeg-99dfdb45a89955916651eeaeac77d938e9a4217a.tar.gz |
avcodec/nvenc: let preset decide default gop size
Default GOP size is now set by preset and tuning info. This GOP size is only overwriten if -g value is provided.
Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r-- | libavcodec/nvenc.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index d56ebc68e2..06579a502b 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -1171,8 +1171,8 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) if (ctx->intra_refresh) { h264->enableIntraRefresh = 1; - h264->intraRefreshPeriod = avctx->gop_size; - h264->intraRefreshCnt = avctx->gop_size - 1; + h264->intraRefreshPeriod = cc->gopLength; + h264->intraRefreshCnt = cc->gopLength - 1; #ifdef NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH h264->singleSliceIntraRefresh = ctx->single_slice_intra_refresh; #endif @@ -1192,8 +1192,8 @@ static av_cold int nvenc_setup_h264_config(AVCodecContext *avctx) if (ctx->intra_refresh) { h264->idrPeriod = NVENC_INFINITE_GOPLENGTH; - } else if (avctx->gop_size >= 0) { - h264->idrPeriod = avctx->gop_size; + } else if (cc->gopLength > 0) { + h264->idrPeriod = cc->gopLength; } if (IS_CBR(cc->rcParams.rateControlMode)) { @@ -1295,8 +1295,8 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) if (ctx->intra_refresh) { hevc->enableIntraRefresh = 1; - hevc->intraRefreshPeriod = avctx->gop_size; - hevc->intraRefreshCnt = avctx->gop_size - 1; + hevc->intraRefreshPeriod = cc->gopLength; + hevc->intraRefreshCnt = cc->gopLength - 1; #ifdef NVENC_HAVE_SINGLE_SLICE_INTRA_REFRESH hevc->singleSliceIntraRefresh = ctx->single_slice_intra_refresh; #endif @@ -1318,8 +1318,8 @@ static av_cold int nvenc_setup_hevc_config(AVCodecContext *avctx) if (ctx->intra_refresh) { hevc->idrPeriod = NVENC_INFINITE_GOPLENGTH; - } else if (avctx->gop_size >= 0) { - hevc->idrPeriod = avctx->gop_size; + } else if (cc->gopLength > 0) { + hevc->idrPeriod = cc->gopLength; } if (IS_CBR(cc->rcParams.rateControlMode)) { @@ -1413,12 +1413,12 @@ static av_cold int nvenc_setup_av1_config(AVCodecContext *avctx) if (ctx->intra_refresh) { av1->enableIntraRefresh = 1; - av1->intraRefreshPeriod = avctx->gop_size; - av1->intraRefreshCnt = avctx->gop_size - 1; + av1->intraRefreshPeriod = cc->gopLength; + av1->intraRefreshCnt = cc->gopLength - 1; av1->idrPeriod = NVENC_INFINITE_GOPLENGTH; - } else if (avctx->gop_size >= 0) { - av1->idrPeriod = avctx->gop_size; + } else if (cc->gopLength > 0) { + av1->idrPeriod = cc->gopLength; } if (IS_CBR(cc->rcParams.rateControlMode)) { @@ -1603,17 +1603,18 @@ FF_ENABLE_DEPRECATION_WARNINGS } if (avctx->gop_size > 0) { - if (avctx->max_b_frames >= 0) { - /* 0 is intra-only, 1 is I/P only, 2 is one B-Frame, 3 two B-frames, and so on. */ - ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; - } - + // only overwrite preset if a GOP size was selected as input ctx->encode_config.gopLength = avctx->gop_size; } else if (avctx->gop_size == 0) { ctx->encode_config.frameIntervalP = 0; ctx->encode_config.gopLength = 1; } + if (avctx->max_b_frames >= 0 && ctx->encode_config.gopLength > 1) { + /* 0 is intra-only, 1 is I/P only, 2 is one B-Frame, 3 two B-frames, and so on. */ + ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; + } + /* force to enable intra refresh */ if(ctx->single_slice_intra_refresh) ctx->intra_refresh = 1; |