Commit a81b000a authored by Timo Rothenpieler's avatar 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
parent 2679ad47
...@@ -525,21 +525,26 @@ typedef struct GUIDTuple { ...@@ -525,21 +525,26 @@ typedef struct GUIDTuple {
int flags; int flags;
} GUIDTuple; } 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) static void nvenc_map_preset(NvencContext *ctx)
{ {
GUIDTuple presets[] = { GUIDTuple presets[] = {
{ NV_ENC_PRESET_DEFAULT_GUID }, PRESET(DEFAULT),
{ NV_ENC_PRESET_HQ_GUID, NVENC_TWO_PASSES }, /* slow */ PRESET(HP),
{ NV_ENC_PRESET_HQ_GUID, NVENC_ONE_PASS }, /* medium */ PRESET(HQ),
{ NV_ENC_PRESET_HP_GUID, NVENC_ONE_PASS }, /* fast */ PRESET(BD),
{ NV_ENC_PRESET_HP_GUID }, PRESET_ALIAS(SLOW, HQ, NVENC_TWO_PASSES),
{ NV_ENC_PRESET_HQ_GUID }, PRESET_ALIAS(MEDIUM, HQ, NVENC_ONE_PASS),
{ NV_ENC_PRESET_BD_GUID }, PRESET_ALIAS(FAST, HP, NVENC_ONE_PASS),
{ NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID, NVENC_LOWLATENCY }, PRESET(LOW_LATENCY_DEFAULT, NVENC_LOWLATENCY),
{ NV_ENC_PRESET_LOW_LATENCY_HQ_GUID, NVENC_LOWLATENCY }, PRESET(LOW_LATENCY_HP, NVENC_LOWLATENCY),
{ NV_ENC_PRESET_LOW_LATENCY_HP_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),
}; };
GUIDTuple *t = &presets[ctx->preset]; GUIDTuple *t = &presets[ctx->preset];
...@@ -548,6 +553,9 @@ static void nvenc_map_preset(NvencContext *ctx) ...@@ -548,6 +553,9 @@ static void nvenc_map_preset(NvencContext *ctx)
ctx->flags = t->flags; ctx->flags = t->flags;
} }
#undef PRESET
#undef PRESET_ALIAS
static av_cold void set_constqp(AVCodecContext *avctx) static av_cold void set_constqp(AVCodecContext *avctx)
{ {
NvencContext *ctx = avctx->priv_data; NvencContext *ctx = avctx->priv_data;
......
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