mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
glupload: Use bufferpool to allocate new buffer in GLTextureUploadMeta
To improve performace of upload with GLTextureUploadMeta, use bufferpool instead of allocating new buffer every time. https://bugzilla.gnome.org/show_bug.cgi?id=769293
This commit is contained in:
parent
85d5489f58
commit
d875e0a727
1 changed files with 23 additions and 18 deletions
|
@ -705,7 +705,7 @@ struct GLUploadMeta
|
||||||
gboolean result;
|
gboolean result;
|
||||||
GstVideoGLTextureUploadMeta *meta;
|
GstVideoGLTextureUploadMeta *meta;
|
||||||
guint texture_ids[GST_GL_UPLOAD_MAX_PLANES];
|
guint texture_ids[GST_GL_UPLOAD_MAX_PLANES];
|
||||||
GstGLVideoAllocationParams *params;
|
GstBufferPool *pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
|
@ -714,6 +714,7 @@ _upload_meta_upload_new (GstGLUpload * upload)
|
||||||
struct GLUploadMeta *meta = g_new0 (struct GLUploadMeta, 1);
|
struct GLUploadMeta *meta = g_new0 (struct GLUploadMeta, 1);
|
||||||
|
|
||||||
meta->upload = upload;
|
meta->upload = upload;
|
||||||
|
meta->pool = gst_gl_buffer_pool_new (upload->context);
|
||||||
|
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
@ -766,6 +767,8 @@ _upload_meta_upload_accept (gpointer impl, GstBuffer * buffer,
|
||||||
GstCapsFeatures *features;
|
GstCapsFeatures *features;
|
||||||
GstVideoGLTextureUploadMeta *meta;
|
GstVideoGLTextureUploadMeta *meta;
|
||||||
gboolean ret = TRUE;
|
gboolean ret = TRUE;
|
||||||
|
GstStructure *config;
|
||||||
|
gsize size;
|
||||||
|
|
||||||
features = gst_caps_get_features (in_caps, 0);
|
features = gst_caps_get_features (in_caps, 0);
|
||||||
|
|
||||||
|
@ -780,13 +783,18 @@ _upload_meta_upload_accept (gpointer impl, GstBuffer * buffer,
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (upload->params)
|
if (!gst_buffer_pool_is_active (upload->pool)) {
|
||||||
gst_gl_allocation_params_free ((GstGLAllocationParams *) upload->params);
|
config = gst_buffer_pool_get_config (upload->pool);
|
||||||
if (!(upload->params =
|
|
||||||
gst_gl_video_allocation_params_new (upload->upload->context, NULL,
|
size = upload->upload->priv->in_info.size;
|
||||||
&upload->upload->priv->in_info, -1, NULL,
|
gst_buffer_pool_config_set_params (config, in_caps, size, 0, 0);
|
||||||
GST_GL_TEXTURE_TARGET_2D, 0)))
|
|
||||||
return FALSE;
|
if (!gst_buffer_pool_set_config (upload->pool, config)) {
|
||||||
|
GST_WARNING_OBJECT (upload->upload, "failed to set bufferpool config");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
gst_buffer_pool_set_active (upload->pool, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
if ((meta = gst_buffer_get_video_gl_texture_upload_meta (buffer)) == NULL)
|
if ((meta = gst_buffer_get_video_gl_texture_upload_meta (buffer)) == NULL)
|
||||||
|
@ -861,9 +869,6 @@ _upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
|
||||||
int i;
|
int i;
|
||||||
GstVideoInfo *in_info = &upload->upload->priv->in_info;
|
GstVideoInfo *in_info = &upload->upload->priv->in_info;
|
||||||
guint max_planes = GST_VIDEO_INFO_N_PLANES (in_info);
|
guint max_planes = GST_VIDEO_INFO_N_PLANES (in_info);
|
||||||
GstGLMemoryAllocator *allocator;
|
|
||||||
|
|
||||||
allocator = gst_gl_memory_allocator_get_default (upload->upload->context);
|
|
||||||
|
|
||||||
/* Support stereo views for separated multiview mode */
|
/* Support stereo views for separated multiview mode */
|
||||||
if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
|
if (GST_VIDEO_INFO_MULTIVIEW_MODE (in_info) ==
|
||||||
|
@ -874,11 +879,11 @@ _upload_meta_upload_perform (gpointer impl, GstBuffer * buffer,
|
||||||
|
|
||||||
upload->meta = gst_buffer_get_video_gl_texture_upload_meta (buffer);
|
upload->meta = gst_buffer_get_video_gl_texture_upload_meta (buffer);
|
||||||
|
|
||||||
/* FIXME: buffer pool */
|
if (gst_buffer_pool_acquire_buffer (upload->pool, outbuf,
|
||||||
*outbuf = gst_buffer_new ();
|
NULL) != GST_FLOW_OK) {
|
||||||
gst_gl_memory_setup_buffer (allocator, *outbuf, upload->params, NULL, NULL,
|
GST_WARNING_OBJECT (upload, "failed to acquire buffer from bufferpool");
|
||||||
0);
|
return GST_GL_UPLOAD_ERROR;
|
||||||
gst_object_unref (allocator);
|
}
|
||||||
|
|
||||||
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
|
for (i = 0; i < GST_GL_UPLOAD_MAX_PLANES; i++) {
|
||||||
guint tex_id = 0;
|
guint tex_id = 0;
|
||||||
|
@ -914,8 +919,8 @@ _upload_meta_upload_free (gpointer impl)
|
||||||
|
|
||||||
g_return_if_fail (impl != NULL);
|
g_return_if_fail (impl != NULL);
|
||||||
|
|
||||||
if (upload->params)
|
if (upload->pool)
|
||||||
gst_gl_allocation_params_free ((GstGLAllocationParams *) upload->params);
|
gst_object_unref (upload->pool);
|
||||||
|
|
||||||
g_free (upload);
|
g_free (upload);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue