diff options
author | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-07-12 17:47:07 +0200 |
---|---|---|
committer | Gwenole Beauchesne <gwenole.beauchesne@intel.com> | 2013-07-12 17:55:37 +0200 |
commit | 5e18a5b1bd187c9e59a6356611557903abb91bb5 (patch) | |
tree | 43dbb0f2430f0426bd4c4eb274e958961f53c1b4 | |
parent | c82a1bc0ff4339a150cf4e8f8075d51ba49c50f8 (diff) |
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.
-rw-r--r-- | gst/vaapi/gstvaapivideobufferpool.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/gst/vaapi/gstvaapivideobufferpool.c b/gst/vaapi/gstvaapivideobufferpool.c index 5c84ab1b..fdcc360e 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)) |