basetransform: Pass the complete caps to transform_caps
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 26 May 2011 12:56:12 +0000 (14:56 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Fri, 27 May 2011 09:37:24 +0000 (11:37 +0200)
Instead of passing it structure by structure. This allows
better optimized transform_caps functions and allows better
transformation decisions.

See bug #619844.

docs/random/porting-to-0.11.txt
libs/gst/base/gstbasetransform.c

index e5b51b1..e261e0b 100644 (file)
@@ -248,4 +248,8 @@ The 0.11 porting guide
     GstBaseSink::get_caps() now take a filter GstCaps* parameter to
     filter the caps and allow better negotiation decisions.
  
-  
+* GstBaseTransform
+    GstBaseTransform::transform_caps() now gets the complete caps passed
+    instead of getting it passed structure by structure.
+
+
index f5423d7..db84544 100644 (file)
@@ -461,53 +461,18 @@ gst_base_transform_transform_caps (GstBaseTransform * trans,
 
   /* if there is a custom transform function, use this */
   if (klass->transform_caps) {
-    GstCaps *temp;
-    gint i;
 
-    /* start with empty caps */
-    ret = gst_caps_new_empty ();
     GST_DEBUG_OBJECT (trans, "transform caps (direction = %d)", direction);
 
-    if (gst_caps_is_any (caps)) {
-      /* for any caps we still have to call the transform function */
-      GST_DEBUG_OBJECT (trans, "from: ANY");
-      temp = klass->transform_caps (trans, direction, caps, filter);
-      GST_DEBUG_OBJECT (trans, "  to: %" GST_PTR_FORMAT, temp);
-      temp = gst_caps_make_writable (temp);
-      gst_caps_append (ret, temp);
-    } else {
-      gint n = gst_caps_get_size (caps);
-      /* we send caps with just one structure to the transform
-       * function as this is easier for the element */
-      for (i = 0; i < n; i++) {
-        GstCaps *nth;
-
-        nth = gst_caps_copy_nth (caps, i);
-        GST_LOG_OBJECT (trans, "from[%d]: %" GST_PTR_FORMAT, i, nth);
-        temp = klass->transform_caps (trans, direction, nth, filter);
-        gst_caps_unref (nth);
-
-        GST_LOG_OBJECT (trans, "  to[%d]: %" GST_PTR_FORMAT, i, temp);
-
-        temp = gst_caps_make_writable (temp);
-
-        /* here we need to only append those structures, that are not yet
-         * in there, we use the merge function for this */
-        gst_caps_merge (ret, temp);
-
-        GST_LOG_OBJECT (trans, "  merged[%d]: %" GST_PTR_FORMAT, i, ret);
-      }
-      GST_LOG_OBJECT (trans, "merged: (%d)", gst_caps_get_size (ret));
-      /* FIXME: we can't do much simplification here because we don't really want to
-       * change the caps order
-       gst_caps_do_simplify (ret);
-       GST_DEBUG_OBJECT (trans, "simplified: (%d)", gst_caps_get_size (ret));
-       */
-    }
+    GST_LOG_OBJECT (trans, "from: %" GST_PTR_FORMAT, caps);
+    ret = klass->transform_caps (trans, direction, caps, filter);
+    GST_LOG_OBJECT (trans, "  to: %" GST_PTR_FORMAT, ret);
 
 #ifndef G_DISABLE_ASSERT
     if (filter) {
       if (!gst_caps_is_subset (ret, filter)) {
+        GstCaps *intersection;
+
         GST_ERROR_OBJECT (trans,
             "transform_caps returned caps %" GST_PTR_FORMAT
             " which are not a real subset of the filter caps %"
@@ -515,9 +480,10 @@ gst_base_transform_transform_caps (GstBaseTransform * trans,
         g_warning ("%s: transform_caps returned caps which are not a real "
             "subset of the filter caps", GST_ELEMENT_NAME (trans));
 
-        temp = gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
-        gst_caps_unref (ret);
-        ret = temp;
+        intersection =
+            gst_caps_intersect_full (filter, ret, GST_CAPS_INTERSECT_FIRST);
+        gst_caps_unref (intersection);
+        ret = intersection;
       }
     }
 #endif