+2008-03-17 Tim-Philipp Müller <tim at centricular dot net>
+
+ * gst-libs/gst/video/video.c: (gst_video_format_parse_caps),
+ (gst_video_format_from_rgba32_masks):
+ Fix gst_video_format_parse_caps() for RGB caps with alpha channel
+ (#522635).
+
+ * tests/check/libs/video.c: (test_parse_caps_rgb), (video_suite):
+ Add unit test for the RGB caps parsing and creation, checking for
+ internal consistency of the new API and consistency of the API with
+ the old GST_VIDEO_CAPS_* defines.
+
2008-03-14 David Schleef <ds@schleef.org>
* gst/videotestsrc/videotestsrc.c: Oops, revert last change
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);
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;
}
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)
{
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;
}