From 8cbb9608f952b3c40cf58d55aaefba61137dedda Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 15 Mar 2010 18:14:19 +0100 Subject: [PATCH] alphacolor: Use libgstvideo for caps parsing --- gst/alpha/gstalphacolor.c | 36 +++++++++--------------------------- gst/alpha/gstalphacolor.h | 5 ++--- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/gst/alpha/gstalphacolor.c b/gst/alpha/gstalphacolor.c index 2254f30..c0d5aad 100644 --- a/gst/alpha/gstalphacolor.c +++ b/gst/alpha/gstalphacolor.c @@ -157,39 +157,21 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps, GstCaps * outcaps) { GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans); - GstStructure *structure; gboolean ret; - const GValue *fps; - gint red_mask, alpha_mask; - gint w, h, depth, bpp; + gint w, h; + GstVideoFormat format; - structure = gst_caps_get_structure (incaps, 0); + ret = gst_video_format_parse_caps (outcaps, &format, &w, &h); - ret = gst_structure_get_int (structure, "width", &w); - ret &= gst_structure_get_int (structure, "height", &h); - fps = gst_structure_get_value (structure, "framerate"); - ret &= (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)); - ret &= gst_structure_get_int (structure, "red_mask", &red_mask); - - /* make sure these are really full RGBA caps */ - ret &= gst_structure_get_int (structure, "alpha_mask", &alpha_mask); - ret &= gst_structure_get_int (structure, "depth", &depth); - ret &= gst_structure_get_int (structure, "bpp", &bpp); - - if (!ret || alpha_mask == 0 || red_mask == 0 || depth != 32 || bpp != 32) { + if (!ret || (format != GST_VIDEO_FORMAT_ARGB + && format != GST_VIDEO_FORMAT_BGRA)) { GST_DEBUG_OBJECT (alpha, "incomplete or non-RGBA input caps!"); return FALSE; } - alpha->in_width = w; - alpha->in_height = h; - alpha->in_rgba = TRUE; -#if (G_BYTE_ORDER == G_BIG_ENDIAN) - if (red_mask != 0x000000ff) -#else - if (red_mask != 0xff000000) -#endif - alpha->in_rgba = FALSE; + alpha->format = format; + alpha->width = w; + alpha->height = h; return TRUE; } @@ -241,7 +223,7 @@ gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf) GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans); /* Transform in place */ - if (alpha->in_rgba) + if (alpha->format == GST_VIDEO_FORMAT_ARGB) transform_rgb (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf)); else transform_bgr (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf)); diff --git a/gst/alpha/gstalphacolor.h b/gst/alpha/gstalphacolor.h index 0d470f9..63e0ec9 100644 --- a/gst/alpha/gstalphacolor.h +++ b/gst/alpha/gstalphacolor.h @@ -43,9 +43,8 @@ struct _GstAlphaColor /*< private >*/ /* caps */ - gint in_width, in_height; - gboolean in_rgba; - gint out_width, out_height; + GstVideoFormat format; + gint width, height; }; struct _GstAlphaColorClass -- 2.7.4