From a6fd76702549c525784b1a98a99f55ff3ab4ebca Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Tue, 16 Nov 2021 12:56:38 +0000 Subject: [PATCH] wpevideosrc: Fix frame stuttering in GL rendering path Make sure the EGLImage we're rendering to the GL memory stays alive long enough, until the the GL memory has been destroyed. This change fixes tearing and black flashes artefacts that were happening because the EGLImage was sometimes destroyed before the sink actually rendered the associated texture. Fixes #889 Part-of: --- subprojects/gst-plugins-bad/ext/wpe/gstwpevideosrc.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/subprojects/gst-plugins-bad/ext/wpe/gstwpevideosrc.cpp b/subprojects/gst-plugins-bad/ext/wpe/gstwpevideosrc.cpp index 770d10e..819da96 100644 --- a/subprojects/gst-plugins-bad/ext/wpe/gstwpevideosrc.cpp +++ b/subprojects/gst-plugins-bad/ext/wpe/gstwpevideosrc.cpp @@ -215,6 +215,16 @@ gst_wpe_video_src_create (GstBaseSrc * bsrc, guint64 offset, guint length, return ret; } +static GQuark +_egl_image_quark (void) +{ + static GQuark quark = 0; + + if (!quark) + quark = g_quark_from_static_string ("GstWPEEGLImage"); + return quark; +} + static gboolean gst_wpe_video_src_fill_memory (GstGLBaseSrc * bsrc, GstGLMemory * memory) { @@ -240,6 +250,11 @@ gst_wpe_video_src_fill_memory (GstGLBaseSrc * bsrc, GstGLMemory * memory) return TRUE; } + // The EGLImage is implicitely associated with the memory we're filling, so we + // need to ensure their life cycles are tied. + gst_mini_object_set_qdata (GST_MINI_OBJECT_CAST (memory), _egl_image_quark (), + gst_egl_image_ref (locked_image), (GDestroyNotify) gst_egl_image_unref); + gl->ActiveTexture (GL_TEXTURE0 + memory->plane); gl->BindTexture (GL_TEXTURE_2D, tex_id); gl->EGLImageTargetTexture2D (GL_TEXTURE_2D, -- 2.7.4