]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/nvenc: Add support for 2pass rc in vbr mode
authorTimo Rothenpieler <timo@rothenpieler.org>
Tue, 4 Aug 2015 17:57:10 +0000 (19:57 +0200)
committerTimo Rothenpieler <timo@rothenpieler.org>
Tue, 4 Aug 2015 19:38:10 +0000 (21:38 +0200)
Thanks to WereCatf for pointing out this now exists.

Github: Closes #143

libavcodec/nvenc.c

index d9dcf964f5c6c7dc4fcb5fb60f68f3bd389cd2f4..54906526eb59798187636d2faf1d406eed7abcf1 100644 (file)
@@ -791,7 +791,16 @@ static av_cold int nvenc_encode_init(AVCodecContext *avctx)
         avctx->qmin = -1;
         avctx->qmax = -1;
     } else if (avctx->qmin >= 0 && avctx->qmax >= 0) {
-        ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;
+        if (ctx->twopass == 1) {
+            ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_VBR;
+
+            if (avctx->codec->id == AV_CODEC_ID_H264) {
+                ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE;
+                ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE;
+            }
+        } else {
+            ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;
+        }
 
         ctx->encode_config.rcParams.enableMinQP = 1;
         ctx->encode_config.rcParams.enableMaxQP = 1;