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 {
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;
......
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