gl/upload: small code cleanup and gst-indent

This commit is contained in:
Matthew Waters 2014-05-29 16:29:09 +10:00 committed by Tim-Philipp Müller
parent 82910401c8
commit 8b50888179

View file

@ -48,42 +48,19 @@
#define USING_GLES3(context) (gst_gl_context_get_gl_api (context) & GST_GL_API_GLES3)
static gboolean _upload_memory (GstGLUpload * upload);
//static gboolean _do_upload_fill (GstGLContext * context, GstGLUpload * upload);
//static gboolean _do_upload_make (GstGLContext * context, GstGLUpload * upload);
static gboolean _init_upload (GstGLUpload * upload);
//static gboolean _init_upload_fbo (GstGLContext * context, GstGLUpload * upload);
static gboolean _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload,
GLuint * texture_id, gpointer data[GST_VIDEO_MAX_PLANES]);
static void _do_upload_with_meta (GstGLContext * context, GstGLUpload * upload);
static void gst_gl_upload_reset (GstGLUpload * upload);
/* *INDENT-OFF* */
#define YUV_TO_RGB_COEFFICIENTS \
"uniform vec3 offset;\n" \
"uniform vec3 rcoeff;\n" \
"uniform vec3 gcoeff;\n" \
"uniform vec3 bcoeff;\n"
/* FIXME: use the colormatrix support from videoconvert */
struct TexData
{
guint format, type, width, height;
gfloat tex_scaling[2];
guint unpack_length;
};
struct _GstGLUploadPrivate
{
gboolean result;
struct TexData texture_info[GST_VIDEO_MAX_PLANES];
GstBuffer *buffer;
GstVideoFrame frame;
GstVideoGLTextureUploadMeta *meta;
guint tex_id;
gboolean mapped;
GstVideoFrame frame;
GstBuffer *outbuf;
};
@ -94,10 +71,10 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_upload_debug);
#define DEBUG_INIT \
GST_DEBUG_CATEGORY_INIT (gst_gl_upload_debug, "glupload", 0, "upload");
G_DEFINE_TYPE_WITH_CODE (GstGLUpload, gst_gl_upload, GST_TYPE_OBJECT, DEBUG_INIT);
G_DEFINE_TYPE_WITH_CODE (GstGLUpload, gst_gl_upload, GST_TYPE_OBJECT,
DEBUG_INIT);
static void gst_gl_upload_finalize (GObject * object);
#define GST_GL_UPLOAD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
GST_TYPE_GL_UPLOAD, GstGLUploadPrivate))
@ -186,7 +163,7 @@ gst_gl_upload_reset (GstGLUpload * upload)
static void
_gst_gl_upload_set_format_unlocked (GstGLUpload * upload,
GstVideoInfo *in_info)
GstVideoInfo * in_info)
{
g_return_if_fail (upload != NULL);
g_return_if_fail (GST_VIDEO_INFO_FORMAT (in_info) !=
@ -203,7 +180,6 @@ _gst_gl_upload_set_format_unlocked (GstGLUpload * upload,
upload->initted = FALSE;
}
/**
* gst_gl_upload_set_format:
* @upload: a #GstGLUpload
@ -273,7 +249,7 @@ gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer,
gst_memory_map (mem, &map_info, GST_MAP_READ | GST_MAP_GL);
gst_memory_unmap (mem, &map_info);
*tex_id = ((GstGLMemory *)mem)->tex_id;
*tex_id = ((GstGLMemory *) mem)->tex_id;
return TRUE;
}
@ -290,11 +266,10 @@ gst_gl_upload_perform_with_buffer (GstGLUpload * upload, GstBuffer * buffer,
}
return ret;
}
#if GST_GL_HAVE_PLATFORM_EGL
if (!upload->priv->tex_id && gst_is_egl_image_memory (mem))
gst_gl_context_gen_texture (upload->context, &upload->priv->tex_id,
GST_VIDEO_FORMAT_RGBA, 0, 0);
GST_VIDEO_FORMAT_RGBA, 0, 0);
#endif
if (!upload->priv->tex_id)
@ -467,7 +442,8 @@ _gst_gl_upload_perform_with_data_unlocked (GstGLUpload * upload,
for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
if (upload->in_tex[i] && upload->in_tex[i]->data != data[i]) {
upload->in_tex[i]->data = data[i];
GST_GL_MEMORY_FLAG_SET (upload->in_tex[i], GST_GL_MEMORY_FLAG_NEED_UPLOAD);
GST_GL_MEMORY_FLAG_SET (upload->in_tex[i],
GST_GL_MEMORY_FLAG_NEED_UPLOAD);
}
}
@ -502,7 +478,8 @@ _init_upload (GstGLUpload * upload)
GST_VIDEO_INFO_WIDTH (&upload->in_info),
GST_VIDEO_INFO_HEIGHT (&upload->in_info));
gst_gl_color_convert_set_format (upload->convert, &upload->in_info, &out_info);
gst_gl_color_convert_set_format (upload->convert, &upload->in_info,
&out_info);
upload->out_tex = gst_gl_memory_wrapped_texture (upload->context, 0,
GST_VIDEO_GL_TEXTURE_TYPE_RGBA, GST_VIDEO_INFO_WIDTH (&upload->in_info),
@ -538,18 +515,20 @@ _upload_memory (GstGLUpload * upload)
inbuf = gst_buffer_new ();
for (i = 0; i < GST_VIDEO_INFO_N_PLANES (&upload->in_info); i++) {
in_texture[i] = upload->in_tex[i]->tex_id;
gst_buffer_append_memory (inbuf, gst_memory_ref ((GstMemory *) upload->in_tex[i]));
gst_buffer_append_memory (inbuf,
gst_memory_ref ((GstMemory *) upload->in_tex[i]));
}
GST_TRACE ("uploading with textures:%u,%u,%u dimensions:%ux%u",
GST_TRACE ("uploading with textures:%u,%u,%u dimensions:%ux%u",
in_texture[0], in_texture[1], in_texture[2], in_width, in_height);
upload->priv->outbuf = gst_gl_color_convert_perform (upload->convert, inbuf);
gst_buffer_unref (inbuf);
gst_video_info_set_format (&out_info, GST_VIDEO_FORMAT_RGBA, in_width, in_height);
gst_video_info_set_format (&out_info, GST_VIDEO_FORMAT_RGBA, in_width,
in_height);
if (!gst_video_frame_map (&out_frame, &out_info, upload->priv->outbuf,
GST_MAP_READ | GST_MAP_GL)) {
GST_MAP_READ | GST_MAP_GL)) {
gst_buffer_unref (upload->priv->outbuf);
upload->priv->outbuf = NULL;
return FALSE;