gl/upload: avoid recreating the GLMemory struct for output textures
authorMatthew Waters <ystreet00@gmail.com>
Sat, 10 May 2014 12:48:05 +0000 (22:48 +1000)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:31:40 +0000 (19:31 +0000)
gst-libs/gst/gl/gstglupload.c

index 766b6ed..b7f3299 100644 (file)
@@ -491,19 +491,20 @@ _gst_gl_upload_perform_for_gl_texture_upload_meta (GstVideoGLTextureUploadMeta *
 
   g_mutex_lock (&upload->lock);
 
-  upload->out_tex = gst_gl_memory_wrapped_texture (upload->context,
-      texture_id[0], GST_VIDEO_GL_TEXTURE_TYPE_RGBA,
-      GST_VIDEO_INFO_WIDTH (&upload->in_info),
-      GST_VIDEO_INFO_HEIGHT (&upload->in_info), NULL, NULL);;
+  if (!upload->out_tex)
+    upload->out_tex = gst_gl_memory_wrapped_texture (upload->context,
+        texture_id[0], GST_VIDEO_GL_TEXTURE_TYPE_RGBA,
+        GST_VIDEO_INFO_WIDTH (&upload->in_info),
+        GST_VIDEO_INFO_HEIGHT (&upload->in_info), NULL, NULL);;
+
+  /* FIXME: kinda breaks the abstraction */
+  upload->out_tex->tex_id = texture_id[0];
 
   GST_LOG ("Uploading for meta with textures %i,%i,%i,%i", texture_id[0],
       texture_id[1], texture_id[2], texture_id[3]);
 
   ret = _do_upload_for_meta (upload, meta);
 
-  gst_memory_unref ((GstMemory *) upload->out_tex);
-  upload->out_tex = NULL;
-
   g_mutex_unlock (&upload->lock);
 
   return ret;
@@ -566,14 +567,15 @@ gst_gl_upload_perform_with_data (GstGLUpload * upload, GLuint texture_id,
 
   g_mutex_lock (&upload->lock);
 
-  upload->out_tex = gst_gl_memory_wrapped_texture (upload->context, texture_id,
-      GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&upload->in_info),
-      GST_VIDEO_INFO_HEIGHT (&upload->in_info), NULL, NULL);
+  if (!upload->out_tex)
+    upload->out_tex = gst_gl_memory_wrapped_texture (upload->context, texture_id,
+        GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&upload->in_info),
+        GST_VIDEO_INFO_HEIGHT (&upload->in_info), NULL, NULL);
 
-  ret = _gst_gl_upload_perform_with_data_unlocked (upload, texture_id, data);
+  /* FIXME: kinda breaks the abstraction */
+  upload->out_tex->tex_id = texture_id;
 
-  gst_memory_unref ((GstMemory *) upload->out_tex);
-  upload->out_tex = NULL;
+  ret = _gst_gl_upload_perform_with_data_unlocked (upload, texture_id, data);
 
   g_mutex_unlock (&upload->lock);