[FFmpeg-cvslog] avcodec/nvenc: zero avg and max bitrate in CQ mode

Roman Arzumanyan git at videolan.org
Mon Jun 1 21:02:03 EEST 2020


ffmpeg | branch: release/4.2 | Roman Arzumanyan <rarzumanyan at nvidia.com> | Mon Apr 20 13:53:36 2020 +0300| [e3883657540d4e99f0f77a3337aa37db4464eda3] | committer: Timo Rothenpieler

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

Signed-off-by: Timo Rothenpieler <timo at rothenpieler.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3883657540d4e99f0f77a3337aa37db4464eda3
---

 libavcodec/nvenc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 5fa44b1819..8298aec671 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -912,12 +912,17 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
     if (ctx->zerolatency)
         ctx->encode_config.rcParams.zeroReorderDelay = 1;
 
-    if (ctx->quality)
-    {
+    if (ctx->quality) {
         //convert from float to fixed point 8.8
         int tmp_quality = (int)(ctx->quality * 256.0f);
         ctx->encode_config.rcParams.targetQuality = (uint8_t)(tmp_quality >> 8);
         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;
     }
 }
 



More information about the ffmpeg-cvslog mailing list