gl/filter: attempt to passthrough the pool if the caps are the same

Reduces the number of glbufferpool instances required for >=2
consecutive GL elements in a pipeline.
This commit is contained in:
Matthew Waters 2014-05-08 00:48:07 +10:00
parent c2cdac278e
commit 810d6710d4

View file

@ -746,7 +746,7 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
GstGLFilter *filter = GST_GL_FILTER (trans); GstGLFilter *filter = GST_GL_FILTER (trans);
GstBufferPool *pool; GstBufferPool *pool;
GstStructure *config; GstStructure *config;
GstCaps *caps; GstCaps *caps, *decide_caps;
guint size; guint size;
gboolean need_pool; gboolean need_pool;
GError *error = NULL; GError *error = NULL;
@ -792,11 +792,18 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
if (pool == NULL && need_pool) { if (pool == NULL && need_pool) {
GstVideoInfo info; GstVideoInfo info;
GstBufferPool *decide_pool;
if (!gst_video_info_from_caps (&info, caps)) if (!gst_video_info_from_caps (&info, caps))
goto invalid_caps; goto invalid_caps;
gst_query_parse_allocation (decide_query, &decide_caps, NULL);
decide_pool = gst_base_transform_get_buffer_pool (trans);
if (gst_caps_is_equal_fixed (decide_caps, caps)) {
pool = decide_pool;
} else {
GST_DEBUG_OBJECT (filter, "create new pool"); GST_DEBUG_OBJECT (filter, "create new pool");
gst_object_unref (decide_pool);
pool = gst_gl_buffer_pool_new (filter->context); pool = gst_gl_buffer_pool_new (filter->context);
/* the normal size of a frame */ /* the normal size of a frame */
@ -807,6 +814,7 @@ gst_gl_filter_propose_allocation (GstBaseTransform * trans,
if (!gst_buffer_pool_set_config (pool, config)) if (!gst_buffer_pool_set_config (pool, config))
goto config_failed; goto config_failed;
} }
}
/* we need at least 2 buffer because we hold on to the last one */ /* we need at least 2 buffer because we hold on to the last one */
if (pool) { if (pool) {
gst_query_add_allocation_pool (query, pool, size, 1, 0); gst_query_add_allocation_pool (query, pool, size, 1, 0);