From 00b579890d866f0dd2f34bcb8aceb890ab29f582 Mon Sep 17 00:00:00 2001 From: Timo Rothenpieler Date: Mon, 9 Aug 2021 15:16:58 +0200 Subject: [PATCH] avcodec/nvenc: always set qp cr/cb offsets --- libavcodec/nvenc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index df8e472e73..815b9429b3 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -749,15 +749,6 @@ static av_cold void set_constqp(AVCodecContext *avctx) rc->constQP.qpIntra = av_clip(ctx->cqp * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51); } -#ifdef NVENC_HAVE_QP_CHROMA_OFFSETS - rc->cbQPIndexOffset = ctx->qp_cb_offset; - rc->crQPIndexOffset = ctx->qp_cr_offset; -#else - if (ctx->qp_cb_offset || ctx->qp_cr_offset) { - av_log(avctx, AV_LOG_WARNING, "Failed setting QP CB/CR offsets, SDK 11.1 or greater required at compile time.\n"); - } -#endif - avctx->qmin = -1; avctx->qmax = -1; } @@ -977,6 +968,14 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx) ctx->rc &= ~RC_MODE_DEPRECATED; } +#ifdef NVENC_HAVE_QP_CHROMA_OFFSETS + ctx->encode_config.rcParams.cbQPIndexOffset = ctx->qp_cb_offset; + ctx->encode_config.rcParams.crQPIndexOffset = ctx->qp_cr_offset; +#else + if (ctx->qp_cb_offset || ctx->qp_cr_offset) + av_log(avctx, AV_LOG_WARNING, "Failed setting QP CB/CR offsets, SDK 11.1 or greater required at compile time.\n"); +#endif + #ifdef NVENC_HAVE_LDKFS if (ctx->ldkfs) ctx->encode_config.rcParams.lowDelayKeyFrameScale = ctx->ldkfs;