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
pull/231/head
Timo Rothenpieler 8 years ago
parent 2679ad4773
commit a81b000a39
  1. 32
      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;

Loading…
Cancel
Save