diff options
author | Luca Barbato <lu_zero@gentoo.org> | 2016-09-24 17:54:57 +0200 |
---|---|---|
committer | Luca Barbato <lu_zero@gentoo.org> | 2016-09-24 18:08:54 +0200 |
commit | 352741b5ead1543d775ccf6040f33023e4491186 (patch) | |
tree | e6f9bb82b29588c24a1ebacb5bbd74fad3aa26c8 | |
parent | 12004a9a7f20e44f4da2ee6c372d5e1794c8d6c5 (diff) | |
download | ffmpeg-streaming-352741b5ead1543d775ccf6040f33023e4491186.zip ffmpeg-streaming-352741b5ead1543d775ccf6040f33023e4491186.tar.gz |
nvenc: Make sure that enum and array index match
And use a macro to reduce the boilerplate.
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.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c index 1ff27a1..6db5b0d 100644 --- a/libavcodec/nvenc.c +++ b/libavcodec/nvenc.c @@ -459,18 +459,21 @@ typedef struct GUIDTuple { int flags; } GUIDTuple; +#define PRESET(name, ...) \ + [PRESET_ ## name] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ } + static int nvec_map_preset(NVENCContext *ctx) { GUIDTuple presets[] = { - { NV_ENC_PRESET_DEFAULT_GUID }, - { 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_HP_GUID, NVENC_LOWLATENCY }, - { NV_ENC_PRESET_LOW_LATENCY_HQ_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(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), { { 0 } } }; @@ -482,6 +485,8 @@ static int nvec_map_preset(NVENCContext *ctx) return AVERROR(EINVAL); } +#undef PRESET + static void set_constqp(AVCodecContext *avctx, NV_ENC_RC_PARAMS *rc) { rc->rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; |