video-color: Add compile-time assert for ColorimetryInfo enum
authorNirbheek Chauhan <nirbheek@centricular.com>
Wed, 26 Jun 2019 11:35:04 +0000 (17:05 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Wed, 26 Jun 2019 12:10:47 +0000 (17:40 +0530)
A comment is not sufficient because this will break when
cherry-picking or backporting commits.

gst-libs/gst/video/video-color.c

index e49a412..a25f3ff 100644 (file)
@@ -80,6 +80,10 @@ static const ColorimetryInfo colorimetry[] = {
   MAKE_COLORIMETRY (NONAME, _UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN),
 };
 
+/* Ensure that DEFAULT_UNKNOWN is indeed updated */
+G_STATIC_ASSERT (sizeof (colorimetry) ==
+    (sizeof (gchar *) + sizeof (GstVideoColorimetry)) * (DEFAULT_UNKNOWN + 1));
+
 static const ColorimetryInfo *
 gst_video_get_colorimetry (const gchar * s)
 {