tests: Fix alpha test on big endian machines.
authorDoug Nazar <nazard@nazar.ca>
Tue, 13 Apr 2021 01:36:58 +0000 (21:36 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 13 Apr 2021 08:20:45 +0000 (08:20 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/943>

tests/check/elements/alpha.c

index 7c03bc1..b2f21fa 100644 (file)
@@ -87,6 +87,13 @@ create_caps_rgba32 (void)
   return caps;
 }
 
+#if G_BYTE_ORDER == G_BIG_ENDIAN
+#define RGBA(r,g,b,a) (guint32)(((r&0xff)<<24)|((g&0xff)<<16)|((b&0xff)<<8)|(a&0xff))
+#else
+#define RGBA(r,g,b,a) (guint32)(((a&0xff)<<24)|((b&0xff)<<16)|((g&0xff)<<8)|(r&0xff))
+#endif
+#define RGB(r,g,b) RGBA(r,g,b,0xff)
+
 static GstBuffer *
 create_buffer_rgba32 (FillColor color)
 {
@@ -99,9 +106,9 @@ create_buffer_rgba32 (FillColor color)
   int i;
 
   if (color == FILL_GREEN)
-    rgba_col = 0xff00ff00;      /* GREEN */
+    rgba_col = RGB (0, 255, 0); /* GREEN */
   else
-    rgba_col = 0xffff0000;      /* BLUE */
+    rgba_col = RGB (0, 0, 255); /* BLUE */
 
   for (i = 0; i < HEIGHT * WIDTH; i++)
     rgba32[i] = rgba_col;