mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
[699/906] display: remove list of upload and download objects
and only create an up/download object when needed.
This commit is contained in:
parent
81334a1af0
commit
38e0434d95
10 changed files with 33 additions and 216 deletions
|
@ -238,14 +238,6 @@ gst_gl_display_finalize (GObject * object)
|
|||
g_free (display->error_message);
|
||||
display->error_message = NULL;
|
||||
}
|
||||
if (display->uploads) {
|
||||
g_slist_free_full (display->uploads, g_object_unref);
|
||||
display->uploads = NULL;
|
||||
}
|
||||
if (display->downloads) {
|
||||
g_slist_free_full (display->downloads, g_object_unref);
|
||||
display->downloads = NULL;
|
||||
}
|
||||
|
||||
if (display->gl_vtable) {
|
||||
g_slice_free (GstGLFuncs, display->gl_vtable);
|
||||
|
|
|
@ -27,14 +27,10 @@
|
|||
|
||||
#include <gst/video/video.h>
|
||||
|
||||
typedef struct _GstGLUpload GstGLUpload;
|
||||
typedef struct _GstGLDownload GstGLDownload;
|
||||
typedef struct _GstGLShader GstGLShader;
|
||||
|
||||
#include "gstglwindow.h"
|
||||
#include "gstglshader.h"
|
||||
#include "gstglupload.h"
|
||||
#include "gstgldownload.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -155,9 +151,6 @@ struct _GstGLDisplay
|
|||
|
||||
GstGLDisplayConversion colorspace_conversion;
|
||||
|
||||
GSList *uploads;
|
||||
GSList *downloads;
|
||||
|
||||
gchar *error_message;
|
||||
|
||||
GstGLFuncs *gl_vtable;
|
||||
|
|
|
@ -640,80 +640,6 @@ gst_gl_download_perform_with_data_unlocked_thread (GstGLDownload * download,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_display_find_download_unlocked:
|
||||
* @display: a #GstGLDisplay
|
||||
* @v_format: a #GstVideoFormat
|
||||
* @out_width: the width to download to
|
||||
* @out_height: the height to download to
|
||||
*
|
||||
* Finds a #GstGLDownload with the required download settings, creating one
|
||||
* if needed. The returned object may not be initialized so you still
|
||||
* have to call gst_gl_download_init_format.
|
||||
*
|
||||
* This function is safe to be called in the GL thread
|
||||
*
|
||||
* Returns: a #GstGLDownload object with the required settings
|
||||
*/
|
||||
GstGLDownload *
|
||||
gst_gl_display_find_download_unlocked (GstGLDisplay * display,
|
||||
GstVideoFormat v_format, guint out_width, guint out_height)
|
||||
{
|
||||
GstGLDownload *ret = NULL;
|
||||
GSList *walk;
|
||||
|
||||
walk = display->downloads;
|
||||
|
||||
while (walk) {
|
||||
ret = walk->data;
|
||||
|
||||
if (ret && v_format == GST_VIDEO_INFO_FORMAT (&ret->info) &&
|
||||
out_width == GST_VIDEO_INFO_WIDTH (&ret->info) &&
|
||||
out_height == GST_VIDEO_INFO_HEIGHT (&ret->info))
|
||||
break;
|
||||
|
||||
ret = NULL;
|
||||
walk = g_slist_next (walk);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
ret = gst_gl_download_new (display);
|
||||
|
||||
display->downloads = g_slist_prepend (display->downloads, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_display_find_download:
|
||||
* @display: a #GstGLDisplay
|
||||
* @v_format: a #GstVideoFormat
|
||||
* @out_width: the width to download to
|
||||
* @out_height: the height to download to
|
||||
*
|
||||
* Finds a #GstGLDownload with the required download settings, creating one
|
||||
* if needed. The returned object may not be initialized so you still
|
||||
* have to call gst_gl_download_init_format.
|
||||
*
|
||||
* Returns: a #GstGLDownload object with the required settings
|
||||
*/
|
||||
GstGLDownload *
|
||||
gst_gl_display_find_download (GstGLDisplay * display, GstVideoFormat v_format,
|
||||
guint out_width, guint out_height)
|
||||
{
|
||||
GstGLDownload *ret;
|
||||
|
||||
gst_gl_display_lock (display);
|
||||
|
||||
ret = gst_gl_display_find_download_unlocked (display, v_format,
|
||||
out_width, out_height);
|
||||
|
||||
gst_gl_display_unlock (display);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
_init_download (GstGLDisplay * display, GstGLDownload * download)
|
||||
{
|
||||
|
|
|
@ -127,11 +127,6 @@ gboolean gst_gl_download_perform_with_memory (GstGLDownload * download, G
|
|||
gboolean gst_gl_download_perform_with_data (GstGLDownload * download, GLuint texture_id,
|
||||
gpointer data[GST_VIDEO_MAX_PLANES]);
|
||||
|
||||
GstGLDownload * gst_gl_display_find_download_unlocked (GstGLDisplay * display, GstVideoFormat v_format,
|
||||
guint out_width, guint out_height);
|
||||
GstGLDownload * gst_gl_display_find_download (GstGLDisplay * display, GstVideoFormat v_format,
|
||||
guint out_width, guint out_height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_GL_DOWNLOAD_H__ */
|
||||
|
|
|
@ -934,12 +934,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
"attempting to wrap for upload");
|
||||
|
||||
if (!filter->upload) {
|
||||
filter->upload = gst_gl_display_find_upload (filter->display,
|
||||
GST_VIDEO_FRAME_FORMAT (&in_frame),
|
||||
GST_VIDEO_FRAME_WIDTH (&in_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&in_frame),
|
||||
GST_VIDEO_FRAME_WIDTH (&out_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&out_frame));
|
||||
filter->upload = gst_gl_upload_new (filter->display);
|
||||
|
||||
gst_gl_upload_init_format (filter->upload,
|
||||
GST_VIDEO_FRAME_FORMAT (&in_frame),
|
||||
|
@ -956,10 +951,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
"attempting to wrap for download");
|
||||
|
||||
if (!filter->download) {
|
||||
filter->download = gst_gl_display_find_download (filter->display,
|
||||
GST_VIDEO_FRAME_FORMAT (&out_frame),
|
||||
GST_VIDEO_FRAME_WIDTH (&out_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&out_frame));
|
||||
filter->download = gst_gl_download_new (filter->display);
|
||||
|
||||
gst_gl_download_init_format (filter->download,
|
||||
GST_VIDEO_FRAME_FORMAT (&out_frame),
|
||||
|
@ -971,12 +963,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
out_tex = filter->out_tex_id;
|
||||
} else { /* both non-GL */
|
||||
if (!filter->upload) {
|
||||
filter->upload = gst_gl_display_find_upload (filter->display,
|
||||
GST_VIDEO_FRAME_FORMAT (&in_frame),
|
||||
GST_VIDEO_FRAME_WIDTH (&in_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&in_frame),
|
||||
GST_VIDEO_FRAME_WIDTH (&out_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&out_frame));
|
||||
filter->upload = gst_gl_upload_new (filter->display);
|
||||
|
||||
gst_gl_upload_init_format (filter->upload,
|
||||
GST_VIDEO_FRAME_FORMAT (&in_frame),
|
||||
|
@ -987,10 +974,7 @@ gst_gl_filter_filter_texture (GstGLFilter * filter, GstBuffer * inbuf,
|
|||
}
|
||||
|
||||
if (!filter->download) {
|
||||
filter->download = gst_gl_display_find_download (filter->display,
|
||||
GST_VIDEO_FRAME_FORMAT (&out_frame),
|
||||
GST_VIDEO_FRAME_WIDTH (&out_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&out_frame));
|
||||
filter->download = gst_gl_download_new (filter->display);
|
||||
|
||||
gst_gl_download_init_format (filter->download,
|
||||
GST_VIDEO_FRAME_FORMAT (&out_frame),
|
||||
|
|
|
@ -80,10 +80,8 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
|
|||
mem->notify = notify;
|
||||
mem->user_data = user_data;
|
||||
mem->wrapped = FALSE;
|
||||
mem->upload = gst_gl_display_find_upload (display, v_format,
|
||||
width, height, width, height);
|
||||
mem->download = gst_gl_display_find_download (display, v_format,
|
||||
width, height);
|
||||
mem->upload = gst_gl_upload_new (display);
|
||||
mem->download = gst_gl_download_new (display);
|
||||
|
||||
GST_CAT_DEBUG (GST_CAT_GL_MEMORY,
|
||||
"new GL texture memory:%p format:%u dimensions:%" G_GSIZE_FORMAT
|
||||
|
|
|
@ -1095,7 +1095,6 @@ gst_gl_mixer_src_setcaps (GstPad * pad, GstGLMixer * mix, GstCaps * caps)
|
|||
GstGLMixerPrivate *priv = mix->priv;
|
||||
GstVideoInfo info;
|
||||
guint out_width, out_height;
|
||||
GstVideoFormat out_format;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
GST_INFO_OBJECT (mix, "set src caps: %" GST_PTR_FORMAT, caps);
|
||||
|
@ -1118,7 +1117,6 @@ gst_gl_mixer_src_setcaps (GstPad * pad, GstGLMixer * mix, GstCaps * caps)
|
|||
|
||||
mix->out_info = info;
|
||||
|
||||
out_format = GST_VIDEO_INFO_FORMAT (&mix->out_info);
|
||||
out_width = GST_VIDEO_INFO_WIDTH (&mix->out_info);
|
||||
out_height = GST_VIDEO_INFO_HEIGHT (&mix->out_info);
|
||||
|
||||
|
@ -1126,12 +1124,6 @@ gst_gl_mixer_src_setcaps (GstPad * pad, GstGLMixer * mix, GstCaps * caps)
|
|||
&mix->fbo, &mix->depthbuffer))
|
||||
goto display_error;
|
||||
|
||||
mix->download = gst_gl_display_find_download (mix->display,
|
||||
out_format, out_width, out_height);
|
||||
|
||||
gst_gl_download_init_format (mix->download, out_format, out_width,
|
||||
out_height);
|
||||
|
||||
if (mix->out_tex_id)
|
||||
gst_gl_display_del_texture (mix->display, &mix->out_tex_id);
|
||||
gst_gl_display_gen_texture (mix->display, &mix->out_tex_id,
|
||||
|
@ -1450,6 +1442,14 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
|
|||
|
||||
out_tex = mix->out_tex_id;;
|
||||
|
||||
if (!mix->download) {
|
||||
mix->download = gst_gl_download_new (mix->display);
|
||||
gst_gl_download_init_format (mix->download,
|
||||
GST_VIDEO_FRAME_FORMAT (&out_frame),
|
||||
GST_VIDEO_FRAME_WIDTH (&out_frame),
|
||||
GST_VIDEO_FRAME_HEIGHT (&out_frame));
|
||||
}
|
||||
|
||||
out_gl_wrapped = TRUE;
|
||||
}
|
||||
|
||||
|
@ -1501,8 +1501,7 @@ gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf)
|
|||
out_height = GST_VIDEO_INFO_HEIGHT (&mix->out_info);
|
||||
|
||||
if (!pad->upload) {
|
||||
pad->upload = gst_gl_display_find_upload (mix->display,
|
||||
in_format, in_width, in_height, in_width, in_height);
|
||||
pad->upload = gst_gl_upload_new (mix->display);
|
||||
|
||||
gst_gl_upload_init_format (pad->upload, in_format,
|
||||
in_width, in_height, in_width, in_height);
|
||||
|
@ -2113,6 +2112,7 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
|
|||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
{
|
||||
guint i;
|
||||
GSList *walk = mix->sinkpads;
|
||||
|
||||
GST_LOG_OBJECT (mix, "stopping collectpads");
|
||||
gst_collect_pads_stop (mix->collect);
|
||||
|
@ -2132,6 +2132,22 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition)
|
|||
mix->fbo = 0;
|
||||
mix->depthbuffer = 0;
|
||||
}
|
||||
if (mix->download) {
|
||||
g_object_unref (mix->download);
|
||||
mix->download = NULL;
|
||||
}
|
||||
|
||||
while (walk) {
|
||||
GstGLMixerPad *pad = (GstGLMixerPad *) (walk->data);
|
||||
|
||||
if (pad->upload) {
|
||||
g_object_unref (pad->upload);
|
||||
pad->upload = NULL;
|
||||
}
|
||||
|
||||
walk = walk->next;
|
||||
}
|
||||
|
||||
if (mix->display) {
|
||||
g_object_unref (mix->display);
|
||||
mix->display = NULL;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <gst/base/gstcollectpads.h>
|
||||
|
||||
#include "gstgldisplay.h"
|
||||
#include <gst/gl/gstglupload.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
|
|
@ -617,87 +617,6 @@ gst_gl_upload_perform_with_data_unlocked_thread (GstGLUpload * upload,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_display_find_upload_unlocked:
|
||||
* @display: a #GstGLDisplay
|
||||
* @v_format: a #GstVideoFormat
|
||||
* @in_width: the width of the data to upload
|
||||
* @in_height: the height of the data to upload
|
||||
* @out_width: the width to upload to
|
||||
* @out_height: the height to upload to
|
||||
*
|
||||
* Finds a #GstGLDownload with the required upload settings, creating one
|
||||
* if needed. The returned object may not be initialized so you still
|
||||
* have to call gst_gl_upload_init_format.
|
||||
*
|
||||
* This function is safe to be called in the GL thread
|
||||
*
|
||||
* Returns: a #GstGLUpload object with the required settings
|
||||
*/
|
||||
GstGLUpload *
|
||||
gst_gl_display_find_upload_unlocked (GstGLDisplay * display,
|
||||
GstVideoFormat v_format, guint in_width, guint in_height,
|
||||
guint out_width, guint out_height)
|
||||
{
|
||||
GstGLUpload *ret = NULL;
|
||||
GSList *walk;
|
||||
|
||||
walk = display->uploads;
|
||||
|
||||
while (walk) {
|
||||
ret = walk->data;
|
||||
|
||||
if (ret && v_format == GST_VIDEO_INFO_FORMAT (&ret->info) &&
|
||||
out_width == GST_VIDEO_INFO_WIDTH (&ret->info) &&
|
||||
out_height == GST_VIDEO_INFO_HEIGHT (&ret->info) &&
|
||||
in_width == ret->in_width && in_height == ret->in_height)
|
||||
break;
|
||||
|
||||
ret = NULL;
|
||||
walk = g_slist_next (walk);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
ret = gst_gl_upload_new (display);
|
||||
|
||||
display->uploads = g_slist_prepend (display->uploads, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_gl_display_find_upload:
|
||||
* @display: a #GstGLDisplay
|
||||
* @v_format: a #GstVideoFormat
|
||||
* @in_width: the width of the data to upload
|
||||
* @in_height: the height of the data to upload
|
||||
* @out_width: the width to upload to
|
||||
* @out_height: the height to upload to
|
||||
*
|
||||
* Finds a #GstGLDownload with the required upload settings, creating one
|
||||
* if needed. The returned object may not be initialized so you still
|
||||
* have to call gst_gl_upload_init_format.
|
||||
*
|
||||
* Returns: a #GstGLUpload object with the required settings
|
||||
*/
|
||||
GstGLUpload *
|
||||
gst_gl_display_find_upload (GstGLDisplay * display, GstVideoFormat v_format,
|
||||
guint in_width, guint in_height, guint out_width, guint out_height)
|
||||
{
|
||||
GstGLUpload *ret;
|
||||
|
||||
gst_gl_display_lock (display);
|
||||
|
||||
ret =
|
||||
gst_gl_display_find_upload_unlocked (display, v_format, in_width,
|
||||
in_height, out_width, out_height);
|
||||
|
||||
gst_gl_display_unlock (display);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_create_shader (GstGLDisplay * display, const gchar * vertex_src,
|
||||
const gchar * fragment_src, GstGLShader ** out_shader)
|
||||
|
|
|
@ -131,13 +131,6 @@ gboolean gst_gl_upload_perform_with_memory_thread (GstGLUpload * upload, GstGLMe
|
|||
gboolean gst_gl_upload_perform_with_data_thread (GstGLUpload * upload, GLuint texture_id,
|
||||
gpointer data[GST_VIDEO_MAX_PLANES]);
|
||||
|
||||
GstGLUpload * gst_gl_display_find_upload (GstGLDisplay * display, GstVideoFormat v_format,
|
||||
guint in_width, guint in_height,
|
||||
guint out_width, guint out_height);
|
||||
GstGLUpload * gst_gl_display_find_upload_unlocked (GstGLDisplay * display, GstVideoFormat v_format,
|
||||
guint in_width, guint in_height,
|
||||
guint out_width, guint out_height);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_GL_UPLOAD_H__ */
|
||||
|
|
Loading…
Reference in a new issue