videofilter: Use a GstVideoBufferPool if none was provided
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 26 Apr 2012 16:12:39 +0000 (18:12 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 1 May 2012 11:33:20 +0000 (13:33 +0200)
gst-libs/gst/video/gstvideofilter.c

index 1eab2b5..40364d2 100644 (file)
@@ -116,22 +116,44 @@ config_failed:
 static gboolean
 gst_video_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
 {
+  GstBufferPool *pool = NULL;
+  GstStructure *config;
+  guint min, max, size;
+  gboolean update_pool;
 
   if (gst_query_get_n_allocation_pools (query) > 0) {
-    GstBufferPool *pool = NULL;
+    gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
 
-    gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
+    if (!pool)
+      pool = gst_video_buffer_pool_new ();
 
-    if (pool) {
-      GstStructure *config;
-
-      config = gst_buffer_pool_get_config (pool);
-      gst_buffer_pool_config_add_option (config,
-          GST_BUFFER_POOL_OPTION_VIDEO_META);
-      gst_buffer_pool_set_config (pool, config);
-      gst_object_unref (pool);
-    }
+    update_pool = TRUE;
+  } else {
+    GstCaps *outcaps;
+    GstVideoInfo vinfo;
+
+    gst_query_parse_allocation (query, &outcaps, NULL);
+    gst_video_info_init (&vinfo);
+    gst_video_info_from_caps (&vinfo, outcaps);
+    size = vinfo.size;
+    min = max = 0;
+    update_pool = FALSE;
   }
+
+  if (!pool)
+    pool = gst_video_buffer_pool_new ();
+
+  config = gst_buffer_pool_get_config (pool);
+  gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META);
+  gst_buffer_pool_set_config (pool, config);
+
+  if (update_pool)
+    gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
+  else
+    gst_query_add_allocation_pool (query, pool, size, min, max);
+
+  gst_object_unref (pool);
+
   return GST_BASE_TRANSFORM_CLASS (parent_class)->decide_allocation (trans,
       query);
 }