Commit 352741b5 authored by Luca Barbato's avatar Luca Barbato

nvenc: Make sure that enum and array index match

And use a macro to reduce the boilerplate.
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
Signed-off-by: 's avatarDiego Biurrun <diego@biurrun.de>
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 12004a9a
...@@ -459,18 +459,21 @@ typedef struct GUIDTuple { ...@@ -459,18 +459,21 @@ typedef struct GUIDTuple {
int flags; int flags;
} GUIDTuple; } GUIDTuple;
#define PRESET(name, ...) \
[PRESET_ ## name] = { NV_ENC_PRESET_ ## name ## _GUID, __VA_ARGS__ }
static int nvec_map_preset(NVENCContext *ctx) static int nvec_map_preset(NVENCContext *ctx)
{ {
GUIDTuple presets[] = { GUIDTuple presets[] = {
{ NV_ENC_PRESET_DEFAULT_GUID }, PRESET(DEFAULT),
{ NV_ENC_PRESET_HP_GUID }, PRESET(HP),
{ NV_ENC_PRESET_HQ_GUID }, PRESET(HQ),
{ NV_ENC_PRESET_BD_GUID }, PRESET(BD),
{ NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID, NVENC_LOWLATENCY }, PRESET(LOW_LATENCY_DEFAULT, NVENC_LOWLATENCY),
{ NV_ENC_PRESET_LOW_LATENCY_HP_GUID, NVENC_LOWLATENCY }, PRESET(LOW_LATENCY_HP, NVENC_LOWLATENCY),
{ NV_ENC_PRESET_LOW_LATENCY_HQ_GUID, NVENC_LOWLATENCY }, PRESET(LOW_LATENCY_HQ, NVENC_LOWLATENCY),
{ NV_ENC_PRESET_LOSSLESS_DEFAULT_GUID, NVENC_LOSSLESS }, PRESET(LOSSLESS_DEFAULT, NVENC_LOSSLESS),
{ NV_ENC_PRESET_LOSSLESS_HP_GUID, NVENC_LOSSLESS }, PRESET(LOSSLESS_HP, NVENC_LOSSLESS),
{ { 0 } } { { 0 } }
}; };
...@@ -482,6 +485,8 @@ static int nvec_map_preset(NVENCContext *ctx) ...@@ -482,6 +485,8 @@ static int nvec_map_preset(NVENCContext *ctx)
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
#undef PRESET
static void set_constqp(AVCodecContext *avctx, NV_ENC_RC_PARAMS *rc) static void set_constqp(AVCodecContext *avctx, NV_ENC_RC_PARAMS *rc)
{ {
rc->rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; rc->rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment