[FFmpeg-cvslog] avcodec/nvenc: Make sure that enum and array index match
Timo Rothenpieler
git at videolan.org
Wed Sep 28 17:57:14 EEST 2016
ffmpeg | branch: master | Timo Rothenpieler <timo at rothenpieler.org> | Wed Sep 28 13:52:47 2016 +0200| [a81b000a392e5c7119d2eddb3f4c90ab9f1e0554] | committer: Timo Rothenpieler
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
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a81b000a392e5c7119d2eddb3f4c90ab9f1e0554
---
libavcodec/nvenc.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index fc5253a..ecc1c4f 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;
More information about the ffmpeg-cvslog
mailing list