}
g_clear_object (&plugin->srcpad_buffer_pool);
+ g_clear_object (&plugin->sinkpad_allocator);
+ g_clear_object (&plugin->srcpad_allocator);
+
gst_caps_replace (&plugin->srcpad_caps, NULL);
gst_video_info_init (&plugin->srcpad_info);
gst_caps_replace (&plugin->allowed_raw_caps, NULL);
return FALSE;
gst_buffer_pool_config_set_allocator (config, allocator, NULL);
ret = gst_buffer_pool_set_config (pool, config);
- gst_object_unref (allocator);
+ if (plugin->sinkpad_allocator)
+ gst_object_unref (plugin->sinkpad_allocator);
+ plugin->sinkpad_allocator = allocator;
return ret;
}
return ret;
}
+static gboolean
+ensure_sinkpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo)
+{
+ if (plugin->sinkpad_allocator)
+ return TRUE;
+
+ plugin->sinkpad_allocator =
+ gst_vaapi_video_allocator_new (plugin->display, vinfo, 0);
+ return plugin->sinkpad_allocator != NULL;
+}
+
+static gboolean
+ensure_srcpad_allocator (GstVaapiPluginBase * plugin, GstVideoInfo * vinfo)
+{
+ if (plugin->srcpad_allocator)
+ return TRUE;
+
+ plugin->srcpad_allocator =
+ gst_vaapi_video_allocator_new (plugin->display, vinfo, 0);
+ return plugin->srcpad_allocator != NULL;
+}
+
/**
* gst_vaapi_plugin_base_create_pool:
* @plugin: a #GstVaapiPluginBase
{
GstBufferPool *pool;
GstVideoInfo vi;
- GstAllocator *allocator;
/* video decoders don't use a buffer pool in the sink pad */
if (GST_IS_VIDEO_DECODER (plugin))
goto error_invalid_caps;
gst_video_info_force_nv12_if_encoded (&vi);
- allocator = gst_vaapi_video_allocator_new (plugin->display, &vi, 0);
- if (!allocator)
+ if (!ensure_sinkpad_allocator (plugin, &vi))
goto error_create_allocator;
-
pool = gst_vaapi_plugin_base_create_pool (plugin, caps,
GST_VIDEO_INFO_SIZE (&vi), 0, 0,
- GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META, allocator);
- gst_object_unref (allocator);
+ GST_VAAPI_VIDEO_BUFFER_POOL_OPTION_VIDEO_META, plugin->sinkpad_allocator);
if (!pool)
goto error_create_pool;
plugin->sinkpad_buffer_pool = pool;
GstCaps * outcaps)
{
if (incaps && incaps != plugin->sinkpad_caps) {
+ g_clear_object (&plugin->sinkpad_allocator);
gst_caps_replace (&plugin->sinkpad_caps, incaps);
if (!gst_video_info_from_caps (&plugin->sinkpad_info, incaps))
return FALSE;
}
if (outcaps && outcaps != plugin->srcpad_caps) {
+ g_clear_object (&plugin->srcpad_allocator);
gst_caps_replace (&plugin->srcpad_caps, outcaps);
if (!gst_video_info_from_caps (&plugin->srcpad_info, outcaps))
return FALSE;
guint size, min, max;
gboolean update_pool = FALSE;
guint pool_options;
- GstAllocator *allocator;
#if (USE_GLX || USE_EGL)
guint idx;
#endif
}
if (!pool) {
- allocator = gst_vaapi_video_allocator_new (plugin->display, &vi, 0);
- if (!allocator)
+ if (!ensure_srcpad_allocator (plugin, &vi))
goto error_create_allocator;
pool = gst_vaapi_plugin_base_create_pool (plugin, caps, size, min, max,
- pool_options, allocator);
- gst_object_unref (allocator);
+ pool_options, plugin->srcpad_allocator);
if (!pool)
goto error_create_pool;
}