mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 14:36:24 +00:00
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.
This commit is contained in:
parent
c82a1bc0ff
commit
5e18a5b1bd
1 changed files with 9 additions and 4 deletions
|
@ -38,6 +38,7 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstVaapiVideoBufferPoolPrivate {
|
struct _GstVaapiVideoBufferPoolPrivate {
|
||||||
|
GstCaps *caps;
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
GstVaapiDisplay *display;
|
GstVaapiDisplay *display;
|
||||||
guint has_video_meta : 1;
|
guint has_video_meta : 1;
|
||||||
|
@ -58,6 +59,7 @@ gst_vaapi_video_buffer_pool_finalize(GObject *object)
|
||||||
|
|
||||||
gst_vaapi_display_replace(&priv->display, NULL);
|
gst_vaapi_display_replace(&priv->display, NULL);
|
||||||
g_clear_object(&priv->allocator);
|
g_clear_object(&priv->allocator);
|
||||||
|
gst_caps_replace(&priv->caps, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -118,10 +120,13 @@ gst_vaapi_video_buffer_pool_set_config(GstBufferPool *pool,
|
||||||
if (!caps)
|
if (!caps)
|
||||||
goto error_no_caps;
|
goto error_no_caps;
|
||||||
|
|
||||||
|
if (!priv->caps || !gst_caps_is_equal(priv->caps, caps)) {
|
||||||
g_clear_object(&priv->allocator);
|
g_clear_object(&priv->allocator);
|
||||||
priv->allocator = gst_vaapi_video_allocator_new(priv->display, caps);
|
priv->allocator = gst_vaapi_video_allocator_new(priv->display, caps);
|
||||||
if (!priv->allocator)
|
if (!priv->allocator)
|
||||||
goto error_create_allocator;
|
goto error_create_allocator;
|
||||||
|
gst_caps_replace(&priv->caps, caps);
|
||||||
|
}
|
||||||
|
|
||||||
if (!gst_buffer_pool_config_has_option(config,
|
if (!gst_buffer_pool_config_has_option(config,
|
||||||
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META))
|
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META))
|
||||||
|
|
Loading…
Reference in a new issue