[FFmpeg-cvslog] nvenc: Make sure that enum and array index match

Luca Barbato git at videolan.org
Mon Mar 20 23:38:38 EET 2017


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Sat Sep 24 17:54:57 2016 +0200| [352741b5ead1543d775ccf6040f33023e4491186] | committer: Luca Barbato

nvenc: Make sure that enum and array index match

And use a macro to reduce the boilerplate.

Signed-off-by: Luca Barbato <lu_zero at gentoo.org>
Signed-off-by: Diego Biurrun <diego at biurrun.de>
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=352741b5ead1543d775ccf6040f33023e4491186
---

 libavcodec/nvenc.c | 23 ++++++++++++++---------
 1 file 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;



More information about the ffmpeg-cvslog mailing list