]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/nvenc: apply quantization factors to cqp
authorTimo Rothenpieler <timo@rothenpieler.org>
Thu, 23 Mar 2017 16:10:25 +0000 (17:10 +0100)
committerTimo Rothenpieler <timo@rothenpieler.org>
Thu, 23 Mar 2017 16:10:52 +0000 (17:10 +0100)
libavcodec/nvenc.c

index 49f32228bcc07de3c73c04780fe26a73dc7856a0..cf054550c1312fb85875c3d71aa2400ccf1cde44 100644 (file)
@@ -523,9 +523,11 @@ static av_cold void set_constqp(AVCodecContext *avctx)
             rc->constQP.qpInterB = rc->constQP.qpInterP;
         }
     } else if (ctx->cqp >= 0) {
-        rc->constQP.qpInterP = ctx->cqp;
-        rc->constQP.qpInterB = ctx->cqp;
-        rc->constQP.qpIntra = ctx->cqp;
+        rc->constQP.qpInterP = rc->constQP.qpInterB = rc->constQP.qpIntra = ctx->cqp;
+        if (avctx->b_quant_factor != 0.0)
+            rc->constQP.qpInterB = av_clip(ctx->cqp * fabs(avctx->b_quant_factor) + avctx->b_quant_offset + 0.5, 0, 51);
+        if (avctx->i_quant_factor != 0.0)
+            rc->constQP.qpIntra = av_clip(ctx->cqp * fabs(avctx->i_quant_factor) + avctx->i_quant_offset + 0.5, 0, 51);
     }
 
     avctx->qmin = -1;