summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYogender Gupta <ygupta@nvidia.com>2016-09-24 17:54:58 +0200
committerLuca Barbato <lu_zero@gentoo.org>2016-09-24 18:08:54 +0200
commite02e2515b24bfc37ede6ca1744696230be55e50b (patch)
tree0fd5a51c6e88f213466b5c63eef7bf908f2fb997
parent352741b5ead1543d775ccf6040f33023e4491186 (diff)
nvenc: Add some easier to understand presets that match x264 terminology
Signed-off-by: Luca Barbato <lu_zero@gentoo.org> Signed-off-by: Diego Biurrun <diego@biurrun.de> Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r--libavcodec/nvenc.c10
-rw-r--r--libavcodec/nvenc.h7
-rw-r--r--libavcodec/nvenc_h264.c5
-rw-r--r--libavcodec/nvenc_hevc.c5
4 files changed, 22 insertions, 5 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index 6db5b0d896..7f8737e0bf 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -459,8 +459,10 @@ typedef struct GUIDTuple {
int flags;
} GUIDTuple;
-#define PRESET(name, ...) \
- [PRESET_ ## name] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ }
+#define PRESET_ALIAS(alias, name, ...) \
+ [PRESET_ ## alias] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ }
+
+#define PRESET(name, ...) PRESET_ALIAS(name, name, __VA_ARGS__)
static int nvec_map_preset(NVENCContext *ctx)
{
@@ -474,6 +476,9 @@ static int nvec_map_preset(NVENCContext *ctx)
PRESET(LOW_LATENCY_HQ, NVENC_LOWLATENCY),
PRESET(LOSSLESS_DEFAULT, NVENC_LOSSLESS),
PRESET(LOSSLESS_HP, NVENC_LOSSLESS),
+ PRESET_ALIAS(SLOW, HQ, NVENC_TWO_PASSES),
+ PRESET_ALIAS(MEDIUM, HQ, NVENC_ONE_PASS),
+ PRESET_ALIAS(FAST, HP, NVENC_ONE_PASS),
{ { 0 } }
};
@@ -486,6 +491,7 @@ static int nvec_map_preset(NVENCContext *ctx)
}
#undef PRESET
+#undef PRESET_ALIAS
static void set_constqp(AVCodecContext *avctx, NV_ENC_RC_PARAMS *rc)
{
diff --git a/libavcodec/nvenc.h b/libavcodec/nvenc.h
index e7e6182196..26c6515c57 100644
--- a/libavcodec/nvenc.h
+++ b/libavcodec/nvenc.h
@@ -91,6 +91,9 @@ typedef struct NVENCLibraryContext
enum {
PRESET_DEFAULT,
+ PRESET_SLOW,
+ PRESET_MEDIUM,
+ PRESET_FAST,
PRESET_HP,
PRESET_HQ,
PRESET_BD ,
@@ -111,7 +114,9 @@ enum {
enum {
NVENC_LOWLATENCY = 1,
- NVENC_LOSSLESS,
+ NVENC_LOSSLESS = 2,
+ NVENC_ONE_PASS = 4,
+ NVENC_TWO_PASSES = 8,
};
enum {
diff --git a/libavcodec/nvenc_h264.c b/libavcodec/nvenc_h264.c
index ea91e077c0..d58ee88f6b 100644
--- a/libavcodec/nvenc_h264.c
+++ b/libavcodec/nvenc_h264.c
@@ -27,8 +27,11 @@
#define OFFSET(x) offsetof(NVENCContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" },
+ { "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_MEDIUM }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" },
{ "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_DEFAULT }, 0, 0, VE, "preset" },
+ { "slow", "hq 2 passes", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_SLOW }, 0, 0, VE, "preset" },
+ { "medium", "hq 1 pass", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_MEDIUM }, 0, 0, VE, "preset" },
+ { "fast", "hp 1 pass", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_FAST }, 0, 0, VE, "preset" },
{ "hp", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HP }, 0, 0, VE, "preset" },
{ "hq", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HQ }, 0, 0, VE, "preset" },
{ "bd", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_BD }, 0, 0, VE, "preset" },
diff --git a/libavcodec/nvenc_hevc.c b/libavcodec/nvenc_hevc.c
index 6ff350698c..f129826834 100644
--- a/libavcodec/nvenc_hevc.c
+++ b/libavcodec/nvenc_hevc.c
@@ -27,8 +27,11 @@
#define OFFSET(x) offsetof(NVENCContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
- { "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_HQ }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" },
+ { "preset", "Set the encoding preset", OFFSET(preset), AV_OPT_TYPE_INT, { .i64 = PRESET_MEDIUM }, PRESET_DEFAULT, PRESET_LOSSLESS_HP, VE, "preset" },
{ "default", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_DEFAULT }, 0, 0, VE, "preset" },
+ { "slow", "hq 2 passes", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_SLOW }, 0, 0, VE, "preset" },
+ { "medium", "hq 1 pass", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_MEDIUM }, 0, 0, VE, "preset" },
+ { "fast", "hp 1 pass", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_FAST }, 0, 0, VE, "preset" },
{ "hp", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HP }, 0, 0, VE, "preset" },
{ "hq", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_HQ }, 0, 0, VE, "preset" },
{ "bd", "", 0, AV_OPT_TYPE_CONST, { .i64 = PRESET_BD }, 0, 0, VE, "preset" },