basetransform: remove metadata tagged with the memory tag
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 1 Mar 2012 14:18:04 +0000 (15:18 +0100)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 1 Mar 2012 16:41:57 +0000 (17:41 +0100)
Remove metadata that describes the particular memory of the buffer it is
attached to. We need to do this because in non-passthrough mode we will allocate
new memory for our output buffer.

libs/gst/base/gstbasetransform.c
libs/gst/base/gstbasetransform.h

index 53027a5..4b67ed7 100644 (file)
@@ -802,6 +802,21 @@ static gboolean
 gst_base_transform_default_decide_allocation (GstBaseTransform * trans,
     GstQuery * query)
 {
+  guint i, n_metas;
+
+  n_metas = gst_query_get_n_allocation_metas (query);
+  for (i = 0; i < n_metas; i++) {
+    GType api;
+
+    api = gst_query_parse_nth_allocation_meta (query, i);
+    /* remove all memory dependent metadata because we are going to have to
+     * allocate different memory for input and output. */
+    if (gst_meta_api_type_has_tag (api, GST_META_TAG_MEMORY)) {
+      gst_query_remove_nth_allocation_meta (query, i);
+      i--;
+    }
+  }
+
   return TRUE;
 }
 
index 1ae2ade..9a664ad 100644 (file)
@@ -141,8 +141,9 @@ struct _GstBaseTransform {
  * @decide_allocation: Setup the allocation parameters for allocating output
  *                    buffers. The passed in query contains the result of the
  *                    downstream allocation query. This function is only called
- *                    when not operating in passthrough mode. The default
- *                    implementation is NULL.
+ *                    when not operating in passthrough mode. the default
+ *                    implementation will remove metadata that depends on the
+ *                    memory.
  * @propose_allocation: Propose buffer allocation parameters for upstream elements.
  *                      This function must be implemented if the element reads or
  *                      writes the buffer content. The query that was passed to