Index: gst-libs/gst/video/video.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/gst-libs/gst/video/video.c,v
retrieving revision 1.21
diff -u -p -r1.21 video.c
--- gst-libs/gst/video/video.c	2 Mar 2008 18:20:44 -0000	1.21
+++ gst-libs/gst/video/video.c	15 Mar 2008 15:56:12 -0000
@@ -256,7 +256,7 @@ gst_video_format_parse_caps (GstCaps * c
         if (*format == GST_VIDEO_FORMAT_UNKNOWN) {
           ok = FALSE;
         }
-      } else if (depth == 24 && bpp == 32 && endianness == G_BIG_ENDIAN &&
+      } else if (depth == 32 && bpp == 32 && endianness == G_BIG_ENDIAN &&
           have_alpha) {
         *format = gst_video_format_from_rgba32_masks (red_mask, green_mask,
             blue_mask, alpha_mask);
@@ -574,11 +574,11 @@ gst_video_format_from_rgba32_masks (int 
     return GST_VIDEO_FORMAT_BGRA;
   }
   if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
-      blue_mask == 0x0000ff00 && alpha_mask == 0xff000000) {
+      blue_mask == 0x000000ff && alpha_mask == 0xff000000) {
     return GST_VIDEO_FORMAT_ARGB;
   }
   if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
-      blue_mask == 0xff000000 && alpha_mask == 0xff000000) {
+      blue_mask == 0x00ff0000 && alpha_mask == 0xff000000) {
     return GST_VIDEO_FORMAT_ABGR;
   }
 
Index: tests/check/libs/video.c
===================================================================
RCS file: /cvs/gstreamer/gst-plugins-base/tests/check/libs/video.c,v
retrieving revision 1.2
diff -u -p -r1.2 video.c
--- tests/check/libs/video.c	2 Mar 2008 18:24:37 -0000	1.2
+++ tests/check/libs/video.c	15 Mar 2008 15:56:12 -0000
@@ -448,6 +447,58 @@ GST_START_TEST (test_dar_calc)
 
 GST_END_TEST;
 
+GST_START_TEST (test_parse_caps_rgb)
+{
+  struct {
+    const gchar *tmpl_caps_string;
+    GstVideoFormat fmt;
+  } formats[] = {
+    /* 24 bit */
+    { GST_VIDEO_CAPS_RGB, GST_VIDEO_FORMAT_RGB },
+    { GST_VIDEO_CAPS_BGR, GST_VIDEO_FORMAT_BGR },
+    /* 32 bit (no alpha) */
+    { GST_VIDEO_CAPS_RGBx, GST_VIDEO_FORMAT_RGBx },
+    { GST_VIDEO_CAPS_xRGB, GST_VIDEO_FORMAT_xRGB },
+    { GST_VIDEO_CAPS_BGRx, GST_VIDEO_FORMAT_BGRx },
+    { GST_VIDEO_CAPS_xBGR, GST_VIDEO_FORMAT_xBGR },
+    /* 32 bit (with alpha) */
+    { GST_VIDEO_CAPS_RGBA, GST_VIDEO_FORMAT_RGBA },
+    { GST_VIDEO_CAPS_ARGB, GST_VIDEO_FORMAT_ARGB },
+    { GST_VIDEO_CAPS_BGRA, GST_VIDEO_FORMAT_BGRA },
+    { GST_VIDEO_CAPS_ABGR, GST_VIDEO_FORMAT_ABGR }
+  };
+  gint i;
+
+  for (i = 0; i < G_N_ELEMENTS (formats); ++i) {
+    GstVideoFormat fmt = GST_VIDEO_FORMAT_UNKNOWN;
+    GstCaps *caps, *caps2;
+    int w = -1, h = -1;
+
+    caps = gst_caps_from_string (formats[i].tmpl_caps_string);
+    gst_caps_set_simple (caps, "width", G_TYPE_INT, 2 * i, "height",
+        G_TYPE_INT, i, "framerate", GST_TYPE_FRACTION, 15, 1,
+        "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1, NULL);
+    g_assert (gst_caps_is_fixed (caps));
+
+    GST_DEBUG ("testing caps: %" GST_PTR_FORMAT, caps);
+
+    fail_unless (gst_video_format_parse_caps (caps, &fmt, &w, &h));
+    fail_unless_equals_int (fmt, formats[i].fmt);
+    fail_unless_equals_int (w, 2 * i);
+    fail_unless_equals_int (h, i);
+
+    /* make sure they're serialised back correctly */
+    caps2 = gst_video_format_new_caps (fmt, w, h, 15, 1, 1, 1);
+    fail_unless (caps != NULL);
+    fail_unless (gst_caps_is_equal (caps, caps2));
+
+    gst_caps_unref (caps);
+    gst_caps_unref (caps2);
+  }
+}
+
+GST_END_TEST;
+
 static Suite *
 video_suite (void)
 {
@@ -457,8 +508,10 @@ video_suite (void)
   suite_add_tcase (s, tc_chain);
   tcase_add_test (tc_chain, test_video_formats);
   tcase_add_test (tc_chain, test_dar_calc);
+  tcase_add_test (tc_chain, test_parse_caps_rgb);
 
   return s;
 }
 
 GST_CHECK_MAIN (video);
+
