]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/nvenc: Deprecate usage of global_quality, introducing qp
authorTimo Rothenpieler <timo@rothenpieler.org>
Thu, 23 Mar 2017 16:01:40 +0000 (17:01 +0100)
committerTimo Rothenpieler <timo@rothenpieler.org>
Thu, 23 Mar 2017 16:10:52 +0000 (17:10 +0100)
libavcodec/nvenc.c
libavcodec/nvenc.h
libavcodec/nvenc_h264.c
libavcodec/nvenc_hevc.c
libavcodec/version.h

index 0abada0ff02b37dc97ccac8aae20d85bfe99b66b..49f32228bcc07de3c73c04780fe26a73dc7856a0 100644 (file)
@@ -522,10 +522,10 @@ static av_cold void set_constqp(AVCodecContext *avctx)
             rc->constQP.qpIntra = rc->constQP.qpInterP;
             rc->constQP.qpInterB = rc->constQP.qpInterP;
         }
-    } else if (avctx->global_quality > 0) {
-        rc->constQP.qpInterP = avctx->global_quality;
-        rc->constQP.qpInterB = avctx->global_quality;
-        rc->constQP.qpIntra = avctx->global_quality;
+    } else if (ctx->cqp >= 0) {
+        rc->constQP.qpInterP = ctx->cqp;
+        rc->constQP.qpInterB = ctx->cqp;
+        rc->constQP.qpIntra = ctx->cqp;
     }
 
     avctx->qmin = -1;
@@ -664,6 +664,12 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
 {
     NvencContext *ctx = avctx->priv_data;
 
+    if (avctx->global_quality > 0)
+        av_log(avctx, AV_LOG_WARNING, "Using global_quality with nvenc is deprecated. Use qp instead.\n");
+
+    if (ctx->cqp < 0 && avctx->global_quality > 0)
+        ctx->cqp = avctx->global_quality;
+
     if (avctx->bit_rate > 0) {
         ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate;
     } else if (ctx->encode_config.rcParams.averageBitRate > 0) {
@@ -688,7 +694,7 @@ static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
             } else {
                 ctx->rc = NV_ENC_PARAMS_RC_CBR;
             }
-        } else if (avctx->global_quality > 0) {
+        } else if (ctx->cqp >= 0) {
             ctx->rc = NV_ENC_PARAMS_RC_CONSTQP;
         } else if (ctx->twopass) {
             ctx->rc = NV_ENC_PARAMS_RC_2_PASS_VBR;
index cfca2efcc5647b102260aca82539aae12dccdadd..7dec5cc68517c4f92d1725d93be0283c37927e82 100644 (file)
@@ -158,6 +158,7 @@ typedef struct NvencContext
     int init_qp_p;
     int init_qp_b;
     int init_qp_i;
+    int cqp;
 } NvencContext;
 
 int ff_nvenc_encode_init(AVCodecContext *avctx);
index b7d4004fd36c931bfb8fc287db351acc6200f9db..2c55b607893bf4776b82e1926a20024dfb56eb8d 100644 (file)
@@ -112,6 +112,8 @@ static const AVOption options[] = {
     { "init_qpP",     "Initial QP value for P frame",       OFFSET(init_qp_p),    AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
     { "init_qpB",     "Initial QP value for B frame",       OFFSET(init_qp_b),    AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
     { "init_qpI",     "Initial QP value for I frame",       OFFSET(init_qp_i),    AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
+    { "qp",           "Constant quantization parameter rate control method",
+                                                            OFFSET(cqp),          AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
     { NULL }
 };
 
index 2804d7df5aef54a3e3d96f5559e7a1ddecab3e0e..c32ba4220bf7785514bb2b8b97c81114e7280600 100644 (file)
@@ -109,6 +109,8 @@ static const AVOption options[] = {
     { "init_qpP",     "Initial QP value for P frame",       OFFSET(init_qp_p),    AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
     { "init_qpB",     "Initial QP value for B frame",       OFFSET(init_qp_b),    AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
     { "init_qpI",     "Initial QP value for I frame",       OFFSET(init_qp_i),    AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
+    { "qp",           "Constant quantization parameter rate control method",
+                                                            OFFSET(cqp),          AV_OPT_TYPE_INT,   { .i64 = -1 }, -1, 51, VE },
     { NULL }
 };
 
index a545464bbc5cdeb59a78fd51ff49a0a2ea11cf70..5ca008fcb5d26698ab2253981fe1170db44e0765 100644 (file)
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  57
 #define LIBAVCODEC_VERSION_MINOR  85
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \