Commit 0842fd2c authored by Roman Arzumanyan's avatar Roman Arzumanyan Committed by Timo Rothenpieler

avcodec/nvenc: zero avg and max bitrate in CQ mode

Signed-off-by: 's avatarTimo Rothenpieler <timo@rothenpieler.org>
parent 7f76f20f
...@@ -947,12 +947,17 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx) ...@@ -947,12 +947,17 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
if (ctx->zerolatency) if (ctx->zerolatency)
ctx->encode_config.rcParams.zeroReorderDelay = 1; ctx->encode_config.rcParams.zeroReorderDelay = 1;
if (ctx->quality) if (ctx->quality) {
{
//convert from float to fixed point 8.8 //convert from float to fixed point 8.8
int tmp_quality = (int)(ctx->quality * 256.0f); int tmp_quality = (int)(ctx->quality * 256.0f);
ctx->encode_config.rcParams.targetQuality = (uint8_t)(tmp_quality >> 8); ctx->encode_config.rcParams.targetQuality = (uint8_t)(tmp_quality >> 8);
ctx->encode_config.rcParams.targetQualityLSB = (uint8_t)(tmp_quality & 0xff); ctx->encode_config.rcParams.targetQualityLSB = (uint8_t)(tmp_quality & 0xff);
av_log(avctx, AV_LOG_VERBOSE, "CQ(%d) mode enabled.\n", tmp_quality);
//CQ mode shall discard max & avg bitrate;
avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate = 0;
avctx->rc_max_rate = ctx->encode_config.rcParams.maxBitRate = 0;
} }
} }
......
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