gl/colorconvert: operate on buffers instead of memories

This commit is contained in:
Matthew Waters 2014-05-27 18:20:29 +10:00 committed by Tim-Philipp Müller
parent 1c14c43c90
commit 625efc1757
5 changed files with 151 additions and 110 deletions

View file

@ -51,8 +51,7 @@ static void _do_convert (GstGLContext * context, GstGLColorConvert * convert);
static gboolean _init_convert (GstGLColorConvert * convert); static gboolean _init_convert (GstGLColorConvert * convert);
static gboolean _init_convert_fbo (GstGLColorConvert * convert); static gboolean _init_convert_fbo (GstGLColorConvert * convert);
static gboolean _gst_gl_color_convert_perform_unlocked (GstGLColorConvert * static gboolean _gst_gl_color_convert_perform_unlocked (GstGLColorConvert *
convert, GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES], convert, GstBuffer * inbuf, GstBuffer * outbuf);
GstGLMemory * out_tex[GST_VIDEO_MAX_PLANES]);
static gboolean _do_convert_draw (GstGLContext * context, static gboolean _do_convert_draw (GstGLContext * context,
GstGLColorConvert * convert); GstGLColorConvert * convert);
@ -375,7 +374,8 @@ struct _GstGLColorConvertPrivate
struct ConvertInfo convert_info; struct ConvertInfo convert_info;
GstGLMemory *out_temp[GST_VIDEO_MAX_PLANES]; GstGLMemory *in_tex[GST_VIDEO_MAX_PLANES];
GstGLMemory *out_tex[GST_VIDEO_MAX_PLANES];
}; };
GST_DEBUG_CATEGORY_STATIC (gst_gl_color_convert_debug); GST_DEBUG_CATEGORY_STATIC (gst_gl_color_convert_debug);
@ -465,9 +465,9 @@ gst_gl_color_convert_reset (GstGLColorConvert * convert)
} }
for (i = 0; i < convert->priv->convert_info.out_n_textures; i++) { for (i = 0; i < convert->priv->convert_info.out_n_textures; i++) {
if (convert->priv->out_temp[i]) if (convert->priv->out_tex[i])
gst_memory_unref ((GstMemory *) convert->priv->out_temp[i]); gst_memory_unref ((GstMemory *) convert->priv->out_tex[i]);
convert->priv->out_temp[i] = NULL; convert->priv->out_tex[i] = NULL;
} }
if (convert->shader) { if (convert->shader) {
@ -522,8 +522,8 @@ gst_gl_color_convert_set_format (GstGLColorConvert * convert,
/** /**
* gst_gl_color_convert_perform: * gst_gl_color_convert_perform:
* @convert: a #GstGLColorConvert * @convert: a #GstGLColorConvert
* @in_tex: the texture ids for input formatted according to in_info * @inbuf: the texture ids for input formatted according to in_info
* @out_tex: the texture ids for output formatted according to out_info * @outbuf: the texture ids for output formatted according to out_info
* *
* Converts the data contained in in_tex into out_tex using the formats * Converts the data contained in in_tex into out_tex using the formats
* specified by the #GstVideoInfo<!-- -->s passed to * specified by the #GstVideoInfo<!-- -->s passed to
@ -532,16 +532,15 @@ gst_gl_color_convert_set_format (GstGLColorConvert * convert,
* Returns: whether the conversion was successful * Returns: whether the conversion was successful
*/ */
gboolean gboolean
gst_gl_color_convert_perform (GstGLColorConvert * convert, gst_gl_color_convert_perform (GstGLColorConvert * convert, GstBuffer * inbuf,
GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES], GstBuffer * outbuf)
GstGLMemory * out_tex[GST_VIDEO_MAX_PLANES])
{ {
gboolean ret; gboolean ret;
g_return_val_if_fail (convert != NULL, FALSE); g_return_val_if_fail (convert != NULL, FALSE);
g_mutex_lock (&convert->lock); g_mutex_lock (&convert->lock);
ret = _gst_gl_color_convert_perform_unlocked (convert, in_tex, out_tex); ret = _gst_gl_color_convert_perform_unlocked (convert, inbuf, outbuf);
g_mutex_unlock (&convert->lock); g_mutex_unlock (&convert->lock);
return ret; return ret;
@ -549,27 +548,14 @@ gst_gl_color_convert_perform (GstGLColorConvert * convert,
static gboolean static gboolean
_gst_gl_color_convert_perform_unlocked (GstGLColorConvert * convert, _gst_gl_color_convert_perform_unlocked (GstGLColorConvert * convert,
GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES], GstBuffer * inbuf, GstBuffer * outbuf)
GstGLMemory * out_tex[GST_VIDEO_MAX_PLANES])
{ {
g_return_val_if_fail (convert != NULL, FALSE); g_return_val_if_fail (convert != NULL, FALSE);
g_return_val_if_fail (in_tex, FALSE); g_return_val_if_fail (inbuf, FALSE);
g_return_val_if_fail (out_tex, FALSE); g_return_val_if_fail (outbuf, FALSE);
convert->in_tex[0] = in_tex[0]; convert->inbuf = inbuf;
convert->in_tex[1] = in_tex[1]; convert->outbuf = outbuf;
convert->in_tex[2] = in_tex[2];
convert->in_tex[3] = in_tex[3];
convert->out_tex[0] = out_tex[0];
convert->out_tex[1] = out_tex[1];
convert->out_tex[2] = out_tex[2];
convert->out_tex[3] = out_tex[3];
GST_LOG ("Converting %s from %p,%p,%p,%p into %s using %p,%p,%p,%p",
gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->in_info)),
in_tex[0], in_tex[1], in_tex[2], in_tex[3],
gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&convert->out_info)),
out_tex[0], out_tex[1], out_tex[2], out_tex[3]);
gst_gl_context_thread_add (convert->context, gst_gl_context_thread_add (convert->context,
(GstGLContextThreadFunc) _do_convert, convert); (GstGLContextThreadFunc) _do_convert, convert);
@ -1142,9 +1128,9 @@ _do_convert (GstGLContext * context, GstGLColorConvert * convert)
{ {
guint in_width, in_height, out_width, out_height; guint in_width, in_height, out_width, out_height;
struct ConvertInfo *c_info = &convert->priv->convert_info; struct ConvertInfo *c_info = &convert->priv->convert_info;
GstMapInfo in_infos[GST_VIDEO_MAX_PLANES], out_infos[GST_VIDEO_MAX_PLANES]; GstMapInfo out_info[GST_VIDEO_MAX_PLANES], in_info[GST_VIDEO_MAX_PLANES];
gboolean res = TRUE; gboolean res = TRUE;
gint i = 0; gint i, j;
out_width = GST_VIDEO_INFO_WIDTH (&convert->out_info); out_width = GST_VIDEO_INFO_WIDTH (&convert->out_info);
out_height = GST_VIDEO_INFO_HEIGHT (&convert->out_info); out_height = GST_VIDEO_INFO_HEIGHT (&convert->out_info);
@ -1156,67 +1142,100 @@ _do_convert (GstGLContext * context, GstGLColorConvert * convert)
return; return;
} }
GST_TRACE ("converting to textures:%p,%p,%p,%p dimensions:%ux%u, "
"from textures:%p,%p,%p,%p dimensions:%ux%u", convert->out_tex[0],
convert->out_tex[1], convert->out_tex[2], convert->out_tex[3],
out_width, out_height, convert->in_tex[0], convert->in_tex[1],
convert->in_tex[2], convert->in_tex[3], in_width, in_height);
for (i = 0; i < c_info->in_n_textures; i++) { for (i = 0; i < c_info->in_n_textures; i++) {
gst_memory_map ((GstMemory *) convert->in_tex[i], &in_infos[i], convert->priv->in_tex[i] =
GST_MAP_READ | GST_MAP_GL); (GstGLMemory *) gst_buffer_peek_memory (convert->inbuf, i);
if (!gst_is_gl_memory ((GstMemory *) convert->priv->in_tex[i])) {
res = FALSE;
goto out;
} }
for (i = 0; i < c_info->out_n_textures; i++) { if (!gst_memory_map ((GstMemory *) convert->priv->in_tex[i], &in_info[i],
if (convert->out_tex[i]->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE GST_MAP_READ | GST_MAP_GL)) {
|| convert->out_tex[i]->tex_type == res = FALSE;
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA goto out;
|| out_width != convert->out_tex[i]->width }
|| out_height != convert->out_tex[i]->height) { }
for (j = 0; j < c_info->out_n_textures; j++) {
GstGLMemory *out_tex =
(GstGLMemory *) gst_buffer_peek_memory (convert->outbuf, j);
if (!gst_is_gl_memory ((GstMemory *) out_tex)) {
res = FALSE;
goto out;
}
if (out_tex->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE
|| out_tex->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA
|| out_width != out_tex->width || out_height != out_tex->height) {
/* Luminance formats are not color renderable */ /* Luminance formats are not color renderable */
/* renderering to a framebuffer only renders the intersection of all /* renderering to a framebuffer only renders the intersection of all
* the attachments i.e. the smallest attachment size */ * the attachments i.e. the smallest attachment size */
if (!convert->priv->out_temp[i]) if (!convert->priv->out_tex[j])
convert->priv->out_temp[i] = convert->priv->out_tex[j] =
(GstGLMemory *) gst_gl_memory_alloc (context, (GstGLMemory *) gst_gl_memory_alloc (context,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, out_width, out_height, out_width); GST_VIDEO_GL_TEXTURE_TYPE_RGBA, out_width, out_height, out_width);
} else { } else {
convert->priv->out_temp[i] = convert->out_tex[i]; convert->priv->out_tex[j] = out_tex;
} }
gst_memory_map ((GstMemory *) convert->priv->out_temp[i], &out_infos[i],
GST_MAP_WRITE | GST_MAP_GL); if (!gst_memory_map ((GstMemory *) convert->priv->out_tex[j], &out_info[j],
GST_MAP_WRITE | GST_MAP_GL)) {
res = FALSE;
goto out;
} }
}
GST_LOG_OBJECT (convert, "converting to textures:%p,%p,%p,%p "
"dimensions:%ux%u, from textures:%p,%p,%p,%p dimensions:%ux%u",
convert->priv->out_tex[0], convert->priv->out_tex[1],
convert->priv->out_tex[2], convert->priv->out_tex[3], out_width,
out_height, convert->priv->in_tex[0], convert->priv->in_tex[1],
convert->priv->in_tex[2], convert->priv->in_tex[3], in_width, in_height);
if (!convert->priv->draw (context, convert)) if (!convert->priv->draw (context, convert))
res = FALSE; res = FALSE;
for (i = 0; i < c_info->in_n_textures; i++) { out:
gst_memory_unmap ((GstMemory *) convert->in_tex[i], &in_infos[i]); for (j--; j >= 0; j--) {
GstGLMemory *out_tex =
(GstGLMemory *) gst_buffer_peek_memory (convert->outbuf, j);
gst_memory_unmap ((GstMemory *) convert->priv->out_tex[j], &out_info[j]);
if (out_tex->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE
|| out_tex->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA
|| out_width != out_tex->width || out_height != out_tex->height) {
GstMapInfo to_info, from_info;
gst_memory_unmap ((GstMemory *) convert->priv->out_tex[j], &out_info[j]);
if (!gst_memory_map ((GstMemory *) convert->priv->out_tex[j], &from_info,
GST_MAP_READ | GST_MAP_GL)) {
gst_gl_context_set_error (convert->context, "Failed to map "
"intermediate memory");
res = FALSE;
continue;
} }
for (i = 0; i < c_info->out_n_textures; i++) { if (!gst_memory_map ((GstMemory *) out_tex, &to_info,
gst_memory_unmap ((GstMemory *) convert->priv->out_temp[i], &out_infos[i]); GST_MAP_WRITE | GST_MAP_GL)) {
gst_gl_context_set_error (convert->context, "Failed to map "
if (convert->out_tex[i]->tex_type == GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE "intermediate memory");
|| convert->out_tex[i]->tex_type == res = FALSE;
GST_VIDEO_GL_TEXTURE_TYPE_LUMINANCE_ALPHA continue;
|| out_width != convert->out_tex[i]->width }
|| out_height != convert->out_tex[i]->height) { gst_gl_memory_copy_into_texture (convert->priv->out_tex[j],
GstGLMemory *gl_mem = convert->out_tex[i]; out_tex->tex_id, out_tex->tex_type, out_tex->width, out_tex->height,
GstMapInfo from_info, to_info; out_tex->stride, FALSE);
gst_memory_unmap ((GstMemory *) convert->priv->out_tex[j], &from_info);
gst_memory_map ((GstMemory *) convert->priv->out_temp[i], &from_info, gst_memory_unmap ((GstMemory *) out_tex, &to_info);
GST_MAP_READ | GST_MAP_GL);
gst_memory_map ((GstMemory *) gl_mem, &to_info,
GST_MAP_WRITE | GST_MAP_GL);
gst_gl_memory_copy_into_texture (convert->priv->out_temp[i],
gl_mem->tex_id, gl_mem->tex_type, gl_mem->width, gl_mem->height,
gl_mem->stride, FALSE);
gst_memory_unmap ((GstMemory *) gl_mem, &to_info);
gst_memory_unmap ((GstMemory *) convert->priv->out_temp[i], &from_info);
} else { } else {
convert->priv->out_temp[i] = NULL; convert->priv->out_tex[j] = NULL;
} }
} }
for (i--; i >= 0; i--) {
gst_memory_unmap ((GstMemory *) convert->priv->in_tex[i], &in_info[i]);
}
convert->priv->result = res; convert->priv->result = res;
return; return;
} }
@ -1259,10 +1278,10 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
/* attach the texture to the FBO to renderer to */ /* attach the texture to the FBO to renderer to */
for (i = 0; i < c_info->out_n_textures; i++) { for (i = 0; i < c_info->out_n_textures; i++) {
/* needed? */ /* needed? */
gl->BindTexture (GL_TEXTURE_2D, convert->out_tex[i]->tex_id); gl->BindTexture (GL_TEXTURE_2D, convert->priv->out_tex[i]->tex_id);
gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, gl->FramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i,
GL_TEXTURE_2D, convert->priv->out_temp[i]->tex_id, 0); GL_TEXTURE_2D, convert->priv->out_tex[i]->tex_id, 0);
} }
if (gl->DrawBuffers) if (gl->DrawBuffers)
@ -1291,7 +1310,7 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
gchar *scale_name = g_strdup_printf ("tex_scale%u", i); gchar *scale_name = g_strdup_printf ("tex_scale%u", i);
gl->ActiveTexture (GL_TEXTURE0 + i); gl->ActiveTexture (GL_TEXTURE0 + i);
gl->BindTexture (GL_TEXTURE_2D, convert->in_tex[i]->tex_id); gl->BindTexture (GL_TEXTURE_2D, convert->priv->in_tex[i]->tex_id);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@ -1299,7 +1318,7 @@ _do_convert_draw (GstGLContext * context, GstGLColorConvert * convert)
gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl->TexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1, gst_gl_shader_set_uniform_2fv (convert->shader, scale_name, 1,
convert->in_tex[i]->tex_scaling); convert->priv->in_tex[i]->tex_scaling);
g_free (scale_name); g_free (scale_name);
} }

View file

@ -56,8 +56,8 @@ struct _GstGLColorConvert
gboolean initted; gboolean initted;
GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES]; GstBuffer * inbuf;
GstGLMemory * out_tex[GST_VIDEO_MAX_PLANES]; GstBuffer * outbuf;
/* used for the conversion */ /* used for the conversion */
GLuint fbo; GLuint fbo;
@ -106,8 +106,7 @@ void gst_gl_color_convert_set_format (GstGLColorConvert * convert,
GstVideoInfo * out_info); GstVideoInfo * out_info);
gboolean gst_gl_color_convert_perform (GstGLColorConvert * convert, gboolean gst_gl_color_convert_perform (GstGLColorConvert * convert,
GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES], GstBuffer * inbuf, GstBuffer * outbuf);
GstGLMemory * out_tex[GST_VIDEO_MAX_PLANES]);
G_END_DECLS G_END_DECLS

View file

@ -60,6 +60,9 @@ struct _GstGLDownloadPrivate
const gchar *vert_shader; const gchar *vert_shader;
gboolean result; gboolean result;
GstGLMemory *in_tex[GST_VIDEO_MAX_PLANES];
GstGLMemory *out_tex[GST_VIDEO_MAX_PLANES];
}; };
GST_DEBUG_CATEGORY_STATIC (gst_gl_download_debug); GST_DEBUG_CATEGORY_STATIC (gst_gl_download_debug);
@ -143,16 +146,16 @@ gst_gl_download_reset (GstGLDownload * download)
guint i; guint i;
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) { for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
if (download->out_tex[i]) { if (download->priv->out_tex[i]) {
gst_memory_unref ((GstMemory *) download->out_tex[i]); gst_memory_unref ((GstMemory *) download->priv->out_tex[i]);
download->out_tex[i] = NULL; download->priv->out_tex[i] = NULL;
} }
} }
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) { for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
if (download->in_tex[i]) { if (download->priv->in_tex[i]) {
gst_memory_unref ((GstMemory *) download->in_tex[i]); gst_memory_unref ((GstMemory *) download->priv->in_tex[i]);
download->in_tex[i] = NULL; download->priv->in_tex[i] = NULL;
} }
} }
} }
@ -236,18 +239,18 @@ _gst_gl_download_perform_with_data_unlocked (GstGLDownload * download,
g_return_val_if_fail (data[i] != NULL, FALSE); g_return_val_if_fail (data[i] != NULL, FALSE);
} }
if (!download->in_tex[0]) if (!download->priv->in_tex[0])
download->in_tex[0] = gst_gl_memory_wrapped_texture (download->context, download->priv->in_tex[0] =
texture_id, GST_VIDEO_GL_TEXTURE_TYPE_RGBA, gst_gl_memory_wrapped_texture (download->context, texture_id,
GST_VIDEO_INFO_WIDTH (&download->info), GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&download->info),
GST_VIDEO_INFO_HEIGHT (&download->info), NULL, NULL); GST_VIDEO_INFO_HEIGHT (&download->info), NULL, NULL);
download->in_tex[0]->tex_id = texture_id; download->priv->in_tex[0]->tex_id = texture_id;
if (!download->out_tex[0]) { if (!download->priv->out_tex[0]) {
if (GST_VIDEO_INFO_FORMAT (&download->info) == GST_VIDEO_FORMAT_YUY2 if (GST_VIDEO_INFO_FORMAT (&download->info) == GST_VIDEO_FORMAT_YUY2
|| GST_VIDEO_INFO_FORMAT (&download->info) == GST_VIDEO_FORMAT_UYVY) { || GST_VIDEO_INFO_FORMAT (&download->info) == GST_VIDEO_FORMAT_UYVY) {
download->out_tex[0] = gst_gl_memory_wrapped (download->context, download->priv->out_tex[0] = gst_gl_memory_wrapped (download->context,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_GL_TEXTURE_TYPE_RGBA,
GST_VIDEO_INFO_COMP_WIDTH (&download->info, 1), GST_VIDEO_INFO_COMP_WIDTH (&download->info, 1),
GST_VIDEO_INFO_HEIGHT (&download->info), GST_VIDEO_INFO_HEIGHT (&download->info),
@ -255,19 +258,19 @@ _gst_gl_download_perform_with_data_unlocked (GstGLDownload * download,
NULL); NULL);
} else { } else {
gst_gl_memory_setup_wrapped (download->context, &download->info, gst_gl_memory_setup_wrapped (download->context, &download->info,
data, download->out_tex); data, download->priv->out_tex);
} }
} }
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&download->info); i++) { for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&download->info); i++) {
download->out_tex[i]->data = data[i]; download->priv->out_tex[i]->data = data[i];
} }
if (GST_VIDEO_INFO_FORMAT (&download->info) == GST_VIDEO_FORMAT_YV12) { if (GST_VIDEO_INFO_FORMAT (&download->info) == GST_VIDEO_FORMAT_YV12) {
/* YV12 same as I420 except planes 1+2 swapped */ /* YV12 same as I420 except planes 1+2 swapped */
temp_data = download->out_tex[1]->data; temp_data = download->priv->out_tex[1]->data;
download->out_tex[1]->data = download->out_tex[2]->data; download->priv->out_tex[1]->data = download->priv->out_tex[2]->data;
download->out_tex[2]->data = temp_data; download->priv->out_tex[2]->data = temp_data;
} }
gst_gl_context_thread_add (download->context, gst_gl_context_thread_add (download->context,
@ -315,6 +318,7 @@ static void
_do_download (GstGLContext * context, GstGLDownload * download) _do_download (GstGLContext * context, GstGLDownload * download)
{ {
guint out_width, out_height; guint out_width, out_height;
GstBuffer *inbuf, *outbuf;
GstMapInfo map_info; GstMapInfo map_info;
gint i; gint i;
@ -327,17 +331,29 @@ _do_download (GstGLContext * context, GstGLDownload * download)
} }
GST_TRACE ("doing download of texture:%u (%ux%u)", GST_TRACE ("doing download of texture:%u (%ux%u)",
download->in_tex[0]->tex_id, out_width, out_height); download->priv->in_tex[0]->tex_id, out_width, out_height);
inbuf = gst_buffer_new ();
gst_buffer_append_memory (inbuf,
gst_memory_ref ((GstMemory *) download->priv->in_tex[0]));
outbuf = gst_buffer_new ();
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&download->info); i++) {
gst_buffer_append_memory (outbuf,
gst_memory_ref ((GstMemory *) download->priv->out_tex[0]));
}
download->priv->result = download->priv->result =
gst_gl_color_convert_perform (download->convert, download->in_tex, gst_gl_color_convert_perform (download->convert, inbuf, outbuf);
download->out_tex);
if (!download->priv->result) if (!download->priv->result)
return; return;
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&download->info); i++) { for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&download->info); i++) {
gst_memory_map ((GstMemory *) download->out_tex[i], &map_info, gst_memory_map ((GstMemory *) download->priv->out_tex[i], &map_info,
GST_MAP_READ); GST_MAP_READ);
gst_memory_unmap ((GstMemory *) download->out_tex[i], &map_info); gst_memory_unmap ((GstMemory *) download->priv->out_tex[i], &map_info);
} }
gst_buffer_unref (inbuf);
gst_buffer_unref (outbuf);
} }

View file

@ -56,10 +56,6 @@ struct _GstGLDownload
gboolean initted; gboolean initted;
/* used for the conversion */
GstGLMemory * in_tex[GST_VIDEO_MAX_PLANES];
GstGLMemory * out_tex[GST_VIDEO_MAX_PLANES];
GstGLDownloadPrivate *priv; GstGLDownloadPrivate *priv;
gpointer _reserved[GST_PADDING]; gpointer _reserved[GST_PADDING];

View file

@ -684,6 +684,8 @@ _upload_memory (GstGLUpload * upload)
guint in_width, in_height; guint in_width, in_height;
guint in_texture[GST_VIDEO_MAX_PLANES]; guint in_texture[GST_VIDEO_MAX_PLANES];
GstGLMemory *out_texture[GST_VIDEO_MAX_PLANES] = {upload->out_tex, 0, 0, 0}; GstGLMemory *out_texture[GST_VIDEO_MAX_PLANES] = {upload->out_tex, 0, 0, 0};
GstBuffer *inbuf, *outbuf;
gboolean ret;
gint i; gint i;
in_width = GST_VIDEO_INFO_WIDTH (&upload->in_info); in_width = GST_VIDEO_INFO_WIDTH (&upload->in_info);
@ -695,13 +697,22 @@ _upload_memory (GstGLUpload * upload)
} }
} }
inbuf = gst_buffer_new ();
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->in_info); i++) { for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->in_info); i++) {
in_texture[i] = upload->in_tex[i]->tex_id; in_texture[i] = upload->in_tex[i]->tex_id;
gst_buffer_append_memory (inbuf, gst_memory_ref ((GstMemory *) upload->in_tex[i]));
} }
outbuf = gst_buffer_new ();
gst_buffer_append_memory (outbuf, gst_memory_ref ((GstMemory *) upload->out_tex));
GST_TRACE ("uploading to texture:%u with textures:%u,%u,%u dimensions:%ux%u", GST_TRACE ("uploading to texture:%u with textures:%u,%u,%u dimensions:%ux%u",
out_texture[0]->tex_id, in_texture[0], in_texture[1], in_texture[2], out_texture[0]->tex_id, in_texture[0], in_texture[1], in_texture[2],
in_width, in_height); in_width, in_height);
return gst_gl_color_convert_perform (upload->convert, upload->in_tex, out_texture); ret = gst_gl_color_convert_perform (upload->convert, inbuf, outbuf);
gst_buffer_unref (inbuf);
gst_buffer_unref (outbuf);
return ret;
} }