Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst / gstcaps.c
index 6bf86cd..cde2f3b 100644 (file)
@@ -43,8 +43,8 @@
  *  <title>Creating caps</title>
  *  <programlisting>
  *  GstCaps *caps;
- *  caps = gst_caps_new_simple ("video/x-raw-yuv",
- *       "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
+ *  caps = gst_caps_new_simple ("video/x-raw",
+ *       "format", G_TYPE_STRING, "I420"),
  *       "framerate", GST_TYPE_FRACTION, 25, 1,
  *       "pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
  *       "width", G_TYPE_INT, 320,
@@ -115,10 +115,12 @@ static gboolean gst_caps_from_string_inplace (GstCaps * caps,
 
 GType _gst_caps_type = 0;
 
+GST_DEFINE_MINI_OBJECT_TYPE (GstCaps, gst_caps);
+
 void
-_gst_caps_initialize (void)
+_priv_gst_caps_initialize (void)
 {
-  _gst_caps_type = gst_mini_object_register ("GstCaps");
+  _gst_caps_type = gst_caps_get_type ();
 
   g_value_register_transform_func (_gst_caps_type,
       G_TYPE_STRING, gst_caps_transform_to_string);
@@ -590,7 +592,7 @@ gst_caps_remove_structure (GstCaps * caps, guint idx)
 
 /**
  * gst_caps_merge_structure:
- * @caps: the #GstCaps that will the the new structure
+ * @caps: the #GstCaps that will the new structure
  * @structure: (transfer full): the #GstStructure to merge
  *
  * Appends @structure to @caps if its not already expressed by @caps.  The
@@ -1116,7 +1118,7 @@ gst_caps_can_intersect (const GstCaps * caps1, const GstCaps * caps2)
     j = MIN (i, len1 - 1);
     /* subset index stays 0 until i reaches superset->structs->len, then it
      * counts up from 1 to subset->structs->len - 1 */
-    k = MAX (0, i - j);
+    k = (i > j) ? (i - j) : 0;  /* MAX (0, i - j) */
 
     /* now run the diagonal line, end condition is the left or bottom
      * border */
@@ -1187,7 +1189,7 @@ gst_caps_intersect_zig_zag (const GstCaps * caps1, const GstCaps * caps2)
     j = MIN (i, len1 - 1);
     /* caps2 index stays 0 until i reaches GST_CAPS_LEN (caps1), then it counts
      * up from 1 to GST_CAPS_LEN (caps2) - 1 */
-    k = MAX (0, i - j);
+    k = (i > j) ? (i - j) : 0;  /* MAX (0, i - j) */
 
     /* now run the diagonal line, end condition is the left or bottom
      * border */
@@ -1374,8 +1376,8 @@ gst_caps_structure_subtract (GSList ** into, const GstStructure * minuend,
 
 /**
  * gst_caps_subtract:
- * @minuend: #GstCaps to substract from
- * @subtrahend: #GstCaps to substract
+ * @minuend: #GstCaps to subtract from
+ * @subtrahend: #GstCaps to subtract
  *
  * Subtracts the @subtrahend from the @minuend.
  * <note>This function does not work reliably if optional properties for caps
@@ -1776,6 +1778,28 @@ gst_caps_do_simplify (GstCaps * caps)
   return TRUE;
 }
 
+/**
+ * gst_caps_fixate:
+ * @caps: a #GstCaps to fixate
+ *
+ * Modifies the given @caps inplace into a representation with only fixed
+ * values. First the caps will be truncated and then the first structure will be
+ * fixated with gst_structure_fixate(). @caps should be writable.
+ */
+void
+gst_caps_fixate (GstCaps * caps)
+{
+  GstStructure *s;
+
+  g_return_if_fail (GST_IS_CAPS (caps));
+  g_return_if_fail (IS_WRITABLE (caps));
+
+  /* default fixation */
+  gst_caps_truncate (caps);
+  s = gst_caps_get_structure (caps, 0);
+  gst_structure_fixate (s);
+}
+
 /* utility */
 
 /**