Commit 758be457 authored by Agatha Hu's avatar Agatha Hu Committed by Timo Rothenpieler

avcodec/nvenc: clamp initial qp value to [1, 51]

Signed-off-by: 's avatarTimo Rothenpieler <timo@rothenpieler.org>
parent f1a88973
...@@ -843,10 +843,10 @@ static av_cold int nvenc_encode_init(AVCodecContext *avctx) ...@@ -843,10 +843,10 @@ static av_cold int nvenc_encode_init(AVCodecContext *avctx)
ctx->encode_config.rcParams.initialRCQP.qpInterP = qp_inter_p; ctx->encode_config.rcParams.initialRCQP.qpInterP = qp_inter_p;
if(avctx->i_quant_factor != 0.0 && avctx->b_quant_factor != 0.0) { if(avctx->i_quant_factor != 0.0 && avctx->b_quant_factor != 0.0) {
ctx->encode_config.rcParams.initialRCQP.qpIntra = qp_inter_p * fabs(avctx->i_quant_factor); ctx->encode_config.rcParams.initialRCQP.qpIntra = av_clip(
ctx->encode_config.rcParams.initialRCQP.qpIntra += avctx->i_quant_offset; qp_inter_p * fabs(avctx->i_quant_factor) + avctx->i_quant_offset, 0, 51);
ctx->encode_config.rcParams.initialRCQP.qpInterB = qp_inter_p * fabs(avctx->b_quant_factor); ctx->encode_config.rcParams.initialRCQP.qpInterB = av_clip(
ctx->encode_config.rcParams.initialRCQP.qpInterB += avctx->b_quant_offset; qp_inter_p * fabs(avctx->b_quant_factor) + avctx->b_quant_offset, 0, 51);
} else { } else {
ctx->encode_config.rcParams.initialRCQP.qpIntra = qp_inter_p; ctx->encode_config.rcParams.initialRCQP.qpIntra = qp_inter_p;
ctx->encode_config.rcParams.initialRCQP.qpInterB = qp_inter_p; ctx->encode_config.rcParams.initialRCQP.qpInterB = qp_inter_p;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment