Module: libav
Branch: master
Commit: 352741b5ead1543d775ccf6040f33023e4491186

Author:    Luca Barbato <[email protected]>
Committer: Luca Barbato <[email protected]>
Date:      Sat Sep 24 17:54:57 2016 +0200

nvenc: Make sure that enum and array index match

And use a macro to reduce the boilerplate.

Signed-off-by: Luca Barbato <[email protected]>
Signed-off-by: Diego Biurrun <[email protected]>
Signed-off-by: Luca Barbato <[email protected]>

---

 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;

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to