alpha: Use new transform_caps vmethod (with filter)
authorEdward Hervey <edward.hervey@collabora.co.uk>
Tue, 7 Jun 2011 09:20:00 +0000 (11:20 +0200)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Tue, 7 Jun 2011 09:20:00 +0000 (11:20 +0200)
gst/alpha/gstalpha.c
gst/alpha/gstalphacolor.c

index 084f83a..8bbf9c1 100644 (file)
@@ -176,7 +176,7 @@ static gboolean gst_alpha_start (GstBaseTransform * trans);
 static gboolean gst_alpha_get_unit_size (GstBaseTransform * btrans,
     GstCaps * caps, gsize * size);
 static GstCaps *gst_alpha_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps);
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter);
 static gboolean gst_alpha_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps);
 static GstFlowReturn gst_alpha_transform (GstBaseTransform * btrans,
@@ -472,7 +472,7 @@ gst_alpha_get_unit_size (GstBaseTransform * btrans,
 
 static GstCaps *
 gst_alpha_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
   GstAlpha *alpha = GST_ALPHA (btrans);
   GstCaps *ret, *tmp, *tmp2;
@@ -527,6 +527,18 @@ gst_alpha_transform_caps (GstBaseTransform * btrans,
   GST_DEBUG_OBJECT (alpha,
       "Transformed %" GST_PTR_FORMAT " -> %" GST_PTR_FORMAT, caps, ret);
 
+  if (filter) {
+    GstCaps *intersection;
+
+    GST_DEBUG_OBJECT (alpha, "Using filter caps %" GST_PTR_FORMAT, filter);
+    intersection =
+        gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (ret);
+    ret = intersection;
+    GST_DEBUG_OBJECT (alpha, "Intersection %" GST_PTR_FORMAT, ret);
+  }
+
+
   GST_ALPHA_UNLOCK (alpha);
 
   return ret;
index 7a26b19..08effaa 100644 (file)
@@ -65,7 +65,7 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
 G_DEFINE_TYPE (GstAlphaColor, gst_alpha_color, GST_TYPE_VIDEO_FILTER);
 
 static GstCaps *gst_alpha_color_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps);
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter);
 static gboolean gst_alpha_color_set_caps (GstBaseTransform * btrans,
     GstCaps * incaps, GstCaps * outcaps);
 static GstFlowReturn gst_alpha_color_transform_ip (GstBaseTransform * btrans,
@@ -110,7 +110,7 @@ gst_alpha_color_init (GstAlphaColor * alpha)
 
 static GstCaps *
 gst_alpha_color_transform_caps (GstBaseTransform * btrans,
-    GstPadDirection direction, GstCaps * caps)
+    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
 {
   const GstCaps *tmpl_caps = NULL;
   GstCaps *result = NULL, *local_caps = NULL;
@@ -156,6 +156,18 @@ gst_alpha_color_transform_caps (GstBaseTransform * btrans,
   GST_LOG_OBJECT (btrans, "transformed %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT,
       caps, result);
 
+  if (filter) {
+    GstCaps *intersection;
+
+    GST_DEBUG_OBJECT (btrans, "Using filter caps %" GST_PTR_FORMAT, filter);
+    intersection =
+        gst_caps_intersect_full (filter, result, GST_CAPS_INTERSECT_FIRST);
+    gst_caps_unref (result);
+    result = intersection;
+    GST_DEBUG_OBJECT (btrans, "Intersection %" GST_PTR_FORMAT, result);
+  }
+
+
   return result;
 }