summaryrefslogtreecommitdiff
path: root/libavcodec/nvenc.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2016-09-28 13:52:47 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2016-09-28 16:48:43 +0200
commita81b000a392e5c7119d2eddb3f4c90ab9f1e0554 (patch)
treee41682897d7a4ff8371e7b339fdf018f38e487f0 /libavcodec/nvenc.c
parent2679ad4773aa356e7c3da5c68bc81f02a194617f (diff)
avcodec/nvenc: Make sure that enum and array index match
Based on libav commits by Luca Barbato and Yogender Gupta: https://git.libav.org/?p=libav.git;a=commit;h=352741b5ead1543d775ccf6040f33023e4491186 https://git.libav.org/?p=libav.git;a=commit;h=e02e2515b24bfc37ede6ca1744696230be55e50b
Diffstat (limited to 'libavcodec/nvenc.c')
-rw-r--r--libavcodec/nvenc.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index fc5253adf8..ecc1c4f9e2 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -525,21 +525,26 @@ typedef struct GUIDTuple {
int flags;
} GUIDTuple;
+#define PRESET_ALIAS(alias, name, ...) \
+ [PRESET_ ## alias] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ }
+
+#define PRESET(name, ...) PRESET_ALIAS(name, name, __VA_ARGS__)
+
static void nvenc_map_preset(NvencContext *ctx)
{
GUIDTuple presets[] = {
- { NV_ENC_PRESET_DEFAULT_GUID },
- { NV_ENC_PRESET_HQ_GUID, NVENC_TWO_PASSES }, /* slow */
- { NV_ENC_PRESET_HQ_GUID, NVENC_ONE_PASS }, /* medium */
- { NV_ENC_PRESET_HP_GUID, NVENC_ONE_PASS }, /* fast */
- { NV_ENC_PRESET_HP_GUID },
- { NV_ENC_PRESET_HQ_GUID },
- { NV_ENC_PRESET_BD_GUID },
- { NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID, NVENC_LOWLATENCY },
- { NV_ENC_PRESET_LOW_LATENCY_HQ_GUID, NVENC_LOWLATENCY },
- { NV_ENC_PRESET_LOW_LATENCY_HP_GUID, NVENC_LOWLATENCY },
- { NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID, NVENC_LOSSLESS },
- { NV_ENC_PRESET_LOSSLESS_HP_GUID, NVENC_LOSSLESS },
+ PRESET(DEFAULT),
+ PRESET(HP),
+ PRESET(HQ),
+ PRESET(BD),
+ PRESET_ALIAS(SLOW, HQ, NVENC_TWO_PASSES),
+ PRESET_ALIAS(MEDIUM, HQ, NVENC_ONE_PASS),
+ PRESET_ALIAS(FAST, HP, NVENC_ONE_PASS),
+ PRESET(LOW_LATENCY_DEFAULT, NVENC_LOWLATENCY),
+ PRESET(LOW_LATENCY_HP, NVENC_LOWLATENCY),
+ PRESET(LOW_LATENCY_HQ, NVENC_LOWLATENCY),
+ PRESET(LOSSLESS_DEFAULT, NVENC_LOSSLESS),
+ PRESET(LOSSLESS_HP, NVENC_LOSSLESS),
};
GUIDTuple *t = &presets[ctx->preset];
@@ -548,6 +553,9 @@ static void nvenc_map_preset(NvencContext *ctx)
ctx->flags = t->flags;
}
+#undef PRESET
+#undef PRESET_ALIAS
+
static av_cold void set_constqp(AVCodecContext *avctx)
{
NvencContext *ctx = avctx->priv_data;