summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Landwerlin <llandwerlin@gmail.com>2014-06-26 21:56:21 +0100
committerLionel Landwerlin <llandwerlin@gmail.com>2014-06-26 21:56:21 +0100
commitb7eb4d54e863a96e231d11668d5e84613bba3f8a (patch)
tree36e62346c64e6a4ccb577a4292e61dfeacee4c3f
parent42f991887665ebe1507bfdace52786ea62d7122e (diff)
downloadclutter-gst-b7eb4d54e863a96e231d11668d5e84613bba3f8a.tar.gz
video-sink: keep GstBuffer around until the next frame
We're working around the blitter here... The only supported GL texture upload plugin (as far as I know) is vaapidecode at the moment. This plugin has a fairly slow upload path : vaapisurface -> Pixmap -> GL texture This can take some time and the last part is currently not synchronized. Therefore it leads to tearing. This patch tries to keep the buffer around to prevent that but it's not perfect.
-rw-r--r--clutter-gst/clutter-gst-video-sink.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/clutter-gst/clutter-gst-video-sink.c b/clutter-gst/clutter-gst-video-sink.c
index ed9be81..b81731c 100644
--- a/clutter-gst/clutter-gst-video-sink.c
+++ b/clutter-gst/clutter-gst-video-sink.c
@@ -1259,6 +1259,8 @@ clutter_gst_rgb32_upload (ClutterGstVideoSink *sink,
}
}
+static CoglUserDataKey gl_upload_texture_private_key;
+#define MAX_ALLOCATED_GL_TEXTURES (1)
static gboolean
clutter_gst_rgb32_upload_gl (ClutterGstVideoSink *sink,
@@ -1266,6 +1268,7 @@ clutter_gst_rgb32_upload_gl (ClutterGstVideoSink *sink,
{
ClutterGstVideoSinkPrivate *priv = sink->priv;
GstVideoGLTextureUploadMeta *upload_meta;
+ gint i;
guint gl_handle[1];
//clear_frame_textures (sink);
@@ -1284,16 +1287,33 @@ clutter_gst_rgb32_upload_gl (ClutterGstVideoSink *sink,
if (priv->frame[0] == NULL)
{
- priv->frame[0] = COGL_TEXTURE (cogl_texture_2d_new_with_size (priv->ctx,
- priv->info.width,
- priv->info.height));
- cogl_texture_set_components (priv->frame[0], COGL_TEXTURE_COMPONENTS_RGBA);
-
- if (!cogl_texture_allocate (priv->frame[0], NULL)) {
- GST_WARNING ("Couldn't allocate cogl texture");
- return FALSE;
+ for (i = 0; i < MAX_ALLOCATED_GL_TEXTURES; i++) {
+ priv->frame[i] = COGL_TEXTURE (cogl_texture_2d_new_with_size (priv->ctx,
+ priv->info.width,
+ priv->info.height));
+ cogl_texture_set_components (priv->frame[i], COGL_TEXTURE_COMPONENTS_RGBA);
+
+ if (!cogl_texture_allocate (priv->frame[i], NULL)) {
+ GST_WARNING ("Couldn't allocate cogl texture");
+ return FALSE;
+ }
}
}
+ else
+ {
+ CoglTexture *tmp;
+
+ tmp = priv->frame[0];
+ for (i = 0; i < MAX_ALLOCATED_GL_TEXTURES - 1; i++)
+ priv->frame[i] = priv->frame[i + 1];
+ priv->frame[MAX_ALLOCATED_GL_TEXTURES - 1] = tmp;
+ }
+
+ cogl_object_set_user_data (COGL_OBJECT (priv->frame[0]),
+ &gl_upload_texture_private_key,
+ gst_buffer_ref (buffer),
+ (CoglUserDataDestroyCallback) gst_buffer_unref);
+
if (!cogl_texture_get_gl_texture (priv->frame[0], &gl_handle[0], NULL)) {
GST_WARNING ("Couldn't get gl texture");