[FFmpeg-cvslog] avcodec/nvenc: use alias to provide deprecated profiles

Timo Rothenpieler git at videolan.org
Wed Oct 21 19:52:43 EEST 2020


ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Wed Oct 21 17:52:43 2020 +0200| [11a8e93681dfe51c75683ac5a13b72d4bed7ac1f] | committer: Timo Rothenpieler

avcodec/nvenc: use alias to provide deprecated profiles

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

 libavcodec/nvenc.c | 33 +++++++++++++++++++++++++--------
 libavcodec/nvenc.h |  2 ++
 2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 1aae6c00e5..63fbe17810 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -657,6 +657,28 @@ typedef struct GUIDTuple {
 static void nvenc_map_preset(NvencContext *ctx)
 {
     GUIDTuple presets[] = {
+#ifdef NVENC_HAVE_NEW_PRESETS
+        PRESET(P1),
+        PRESET(P2),
+        PRESET(P3),
+        PRESET(P4),
+        PRESET(P5),
+        PRESET(P6),
+        PRESET(P7),
+        PRESET_ALIAS(SLOW,   P7, NVENC_TWO_PASSES),
+        PRESET_ALIAS(MEDIUM, P4, NVENC_ONE_PASS),
+        PRESET_ALIAS(FAST,   P1, NVENC_ONE_PASS),
+        // Compat aliases
+        PRESET_ALIAS(DEFAULT,             P4, NVENC_DEPRECATED_PRESET),
+        PRESET_ALIAS(HP,                  P1, NVENC_DEPRECATED_PRESET),
+        PRESET_ALIAS(HQ,                  P7, NVENC_DEPRECATED_PRESET),
+        PRESET_ALIAS(BD,                  P5, NVENC_DEPRECATED_PRESET),
+        PRESET_ALIAS(LOW_LATENCY_DEFAULT, P4, NVENC_DEPRECATED_PRESET | NVENC_LOWLATENCY),
+        PRESET_ALIAS(LOW_LATENCY_HP,      P1, NVENC_DEPRECATED_PRESET | NVENC_LOWLATENCY),
+        PRESET_ALIAS(LOW_LATENCY_HQ,      P7, NVENC_DEPRECATED_PRESET | NVENC_LOWLATENCY),
+        PRESET_ALIAS(LOSSLESS_DEFAULT,    P4, NVENC_DEPRECATED_PRESET | NVENC_LOSSLESS),
+        PRESET_ALIAS(LOSSLESS_HP,         P1, NVENC_DEPRECATED_PRESET | NVENC_LOSSLESS),
+#else
         PRESET(DEFAULT),
         PRESET(HP),
         PRESET(HQ),
@@ -669,14 +691,6 @@ static void nvenc_map_preset(NvencContext *ctx)
         PRESET(LOW_LATENCY_HQ,      NVENC_LOWLATENCY),
         PRESET(LOSSLESS_DEFAULT,    NVENC_LOSSLESS),
         PRESET(LOSSLESS_HP,         NVENC_LOSSLESS),
-#ifdef NVENC_HAVE_NEW_PRESETS
-        PRESET(P1),
-        PRESET(P2),
-        PRESET(P3),
-        PRESET(P4),
-        PRESET(P5),
-        PRESET(P6),
-        PRESET(P7),
 #endif
     };
 
@@ -1238,6 +1252,9 @@ static av_cold int nvenc_setup_encoder(AVCodecContext *avctx)
 
     nvenc_map_preset(ctx);
 
+    if (ctx->flags & NVENC_DEPRECATED_PRESET)
+        av_log(avctx, AV_LOG_WARNING, "The selected preset is deprecated. Use p1 to p7 + -tune or fast/medium/slow.\n");
+
     preset_config.version = NV_ENC_PRESET_CONFIG_VER;
     preset_config.presetCfg.version = NV_ENC_CONFIG_VER;
 
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index fb3820f7cf..07e0ae1769 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -135,6 +135,8 @@ enum {
     NVENC_LOSSLESS   = 2,
     NVENC_ONE_PASS   = 4,
     NVENC_TWO_PASSES = 8,
+
+    NVENC_DEPRECATED_PRESET = 0x8000,
 };
 
 enum {



More information about the ffmpeg-cvslog mailing list