From bf8f244de3262c782f425252afe919dbad0f554b Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Thu, 12 Dec 2013 17:01:29 +0000 Subject: [PATCH] plugins: implement GLTextureUploadMeta user data copy. Makes the copies of a buffer reference their own GLTextureUploadMeta user data and prevent the original buffer accessing already freed memory if its copies has been released and freed. https://bugzilla.gnome.org/show_bug.cgi?id=720336 [Propagate the original meta texture to the copy too] Signed-off-by: Gwenole Beauchesne --- gst/vaapi/gstvaapivideometa_texture.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/gst/vaapi/gstvaapivideometa_texture.c b/gst/vaapi/gstvaapivideometa_texture.c index 8a38be632e..8d96770748 100644 --- a/gst/vaapi/gstvaapivideometa_texture.c +++ b/gst/vaapi/gstvaapivideometa_texture.c @@ -57,6 +57,19 @@ meta_texture_new(void) return meta; } +static GstVaapiVideoMetaTexture * +meta_texture_copy(GstVaapiVideoMetaTexture *meta) +{ + GstVaapiVideoMetaTexture *copy; + + copy = meta_texture_new(); + if (!copy) + return NULL; + + gst_vaapi_texture_replace(©->texture, meta->texture); + return copy; +} + static gboolean gst_vaapi_texture_upload(GstVideoGLTextureUploadMeta *meta, guint texture_id[4]) { @@ -108,7 +121,8 @@ gst_buffer_add_texture_upload_meta(GstBuffer *buffer) meta = gst_buffer_add_video_gl_texture_upload_meta(buffer, GST_VIDEO_GL_TEXTURE_ORIENTATION_X_NORMAL_Y_NORMAL, 1, tex_type, gst_vaapi_texture_upload, - meta_texture, NULL, (GBoxedFreeFunc)meta_texture_free); + meta_texture, (GBoxedCopyFunc)meta_texture_copy, + (GBoxedFreeFunc)meta_texture_free); if (!meta) goto error; return TRUE;