From 5e18a5b1bd187c9e59a6356611557903abb91bb5 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Fri, 12 Jul 2013 17:47:07 +0200 Subject: [PATCH] plugins: don't reallocate pool allocator for the same caps. If the video buffer pool config doesn't have new caps, then it's not necessary to reinstantiate the allocator. That could be a costly operation as we could do some extra heavy checking in there. --- gst/vaapi/gstvaapivideobufferpool.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gst/vaapi/gstvaapivideobufferpool.c b/gst/vaapi/gstvaapivideobufferpool.c index 5c84ab1b43..fdcc360eb1 100644 --- a/gst/vaapi/gstvaapivideobufferpool.c +++ b/gst/vaapi/gstvaapivideobufferpool.c @@ -38,6 +38,7 @@ enum { }; struct _GstVaapiVideoBufferPoolPrivate { + GstCaps *caps; GstAllocator *allocator; GstVaapiDisplay *display; guint has_video_meta : 1; @@ -58,6 +59,7 @@ gst_vaapi_video_buffer_pool_finalize(GObject *object) gst_vaapi_display_replace(&priv->display, NULL); g_clear_object(&priv->allocator); + gst_caps_replace(&priv->caps, NULL); } static void @@ -118,10 +120,13 @@ gst_vaapi_video_buffer_pool_set_config(GstBufferPool *pool, if (!caps) goto error_no_caps; - g_clear_object(&priv->allocator); - priv->allocator = gst_vaapi_video_allocator_new(priv->display, caps); - if (!priv->allocator) - goto error_create_allocator; + if (!priv->caps || !gst_caps_is_equal(priv->caps, caps)) { + g_clear_object(&priv->allocator); + priv->allocator = gst_vaapi_video_allocator_new(priv->display, caps); + if (!priv->allocator) + goto error_create_allocator; + gst_caps_replace(&priv->caps, caps); + } if (!gst_buffer_pool_config_has_option(config, GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META))