[524/906] GstGLDisplay: rework the download code

data paramaters now take GstVideoFrame
remove redundant parameters
This commit is contained in:
Matthew Waters 2012-07-08 01:49:06 +10:00
parent 3d7788dabb
commit 0e5daa29f7
2 changed files with 33 additions and 29 deletions

View file

@ -201,7 +201,7 @@ gst_gl_display_init (GstGLDisplay * display)
display->download_width = 0; display->download_width = 0;
display->download_height = 0; display->download_height = 0;
display->download_video_format = 0; display->download_video_format = 0;
display->download_data = NULL; display->download_frame = NULL;
display->ouput_texture = 0; display->ouput_texture = 0;
display->ouput_texture_width = 0; display->ouput_texture_width = 0;
display->ouput_texture_height = 0; display->ouput_texture_height = 0;
@ -1549,7 +1549,10 @@ gst_gl_display_thread_init_download (GstGLDisplay * display)
void void
gst_gl_display_thread_do_download (GstGLDisplay * display) gst_gl_display_thread_do_download (GstGLDisplay * display)
{ {
switch (display->download_video_format) { GstVideoFormat video_format =
GST_VIDEO_INFO_FORMAT (&display->download_frame->info);
switch (video_format) {
case GST_VIDEO_FORMAT_RGBx: case GST_VIDEO_FORMAT_RGBx:
case GST_VIDEO_FORMAT_BGRx: case GST_VIDEO_FORMAT_BGRx:
case GST_VIDEO_FORMAT_xRGB: case GST_VIDEO_FORMAT_xRGB:
@ -1573,7 +1576,7 @@ gst_gl_display_thread_do_download (GstGLDisplay * display)
break; break;
default: default:
gst_gl_display_set_error (display, "Unsupported download video format %d", gst_gl_display_set_error (display, "Unsupported download video format %d",
display->download_video_format); video_format);
} }
} }
@ -2312,7 +2315,7 @@ gst_gl_display_init_download (GstGLDisplay * display,
/* Called by the gldownload and glcolorscale element */ /* Called by the gldownload and glcolorscale element */
gboolean gboolean
gst_gl_display_do_download (GstGLDisplay * display, GLuint texture, gst_gl_display_do_download (GstGLDisplay * display, GLuint texture,
gint width, gint height, gpointer data) GstVideoFrame * frame)
{ {
gboolean isAlive = TRUE; gboolean isAlive = TRUE;
@ -2320,10 +2323,8 @@ gst_gl_display_do_download (GstGLDisplay * display, GLuint texture,
isAlive = display->isAlive; isAlive = display->isAlive;
if (isAlive) { if (isAlive) {
//data size is aocciated to the glcontext size //data size is aocciated to the glcontext size
display->download_data = data; display->download_frame = frame;
display->ouput_texture = texture; display->ouput_texture = texture;
display->ouput_texture_width = width;
display->ouput_texture_height = height;
gst_gl_window_send_message (display->gl_window, gst_gl_window_send_message (display->gl_window,
GST_GL_WINDOW_CB (gst_gl_display_thread_do_download), display); GST_GL_WINDOW_CB (gst_gl_display_thread_do_download), display);
isAlive = display->isAlive; isAlive = display->isAlive;
@ -3208,7 +3209,7 @@ void
gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display) gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
{ {
GstVideoFormat video_format = display->download_video_format; GstVideoFormat video_format = display->download_video_format;
gpointer data = display->download_data; GstVideoFrame *frame = display->download_frame;
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
if (display->upload_colorspace_conversion == GST_GL_DISPLAY_CONVERSION_GLSL) if (display->upload_colorspace_conversion == GST_GL_DISPLAY_CONVERSION_GLSL)
@ -3216,8 +3217,8 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
glEnable (GL_TEXTURE_RECTANGLE_ARB); glEnable (GL_TEXTURE_RECTANGLE_ARB);
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture); glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->ouput_texture);
#else #else
gint width = display->ouput_texture_width; gint width = GST_VIDEO_INFO_WIDTH (&frame->info);
gint height = display->ouput_texture_height; gint height = GST_VIDEO_INFO_HEIGHT (&frame->info);
const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f, const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
1.0f, 0.0f, 1.0f, 0.0f,
@ -3262,9 +3263,10 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
case GST_VIDEO_FORMAT_ARGB: case GST_VIDEO_FORMAT_ARGB:
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
GL_UNSIGNED_BYTE, data); GL_UNSIGNED_BYTE, frame->data[0]);
#else #else
glReadPixels (0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); glReadPixels (0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE,
frame->data[0]);
#endif #endif
break; break;
case GST_VIDEO_FORMAT_BGRx: case GST_VIDEO_FORMAT_BGRx:
@ -3273,21 +3275,22 @@ gst_gl_display_thread_do_download_draw_rgb (GstGLDisplay * display)
case GST_VIDEO_FORMAT_ABGR: case GST_VIDEO_FORMAT_ABGR:
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA, glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,
GL_UNSIGNED_BYTE, data); GL_UNSIGNED_BYTE, frame->data[0]);
#endif #endif
break; break;
case GST_VIDEO_FORMAT_RGB: case GST_VIDEO_FORMAT_RGB:
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
GL_UNSIGNED_BYTE, data); GL_UNSIGNED_BYTE, frame->data[0]);
#else #else
glReadPixels (0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE, data); glReadPixels (0, 0, width, height, GL_RGB, GL_UNSIGNED_BYTE,
frame->data[0]);
#endif #endif
break; break;
case GST_VIDEO_FORMAT_BGR: case GST_VIDEO_FORMAT_BGR:
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR, glGetTexImage (GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGR,
GL_UNSIGNED_BYTE, data); GL_UNSIGNED_BYTE, frame->data[0]);
#endif #endif
break; break;
default: default:
@ -3309,13 +3312,13 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
gint width, height; gint width, height;
GstVideoFormat video_format; GstVideoFormat video_format;
GstVideoInfo vinfo; GstVideoInfo vinfo;
gpointer data; GstVideoFrame *frame;
width = display->download_width; frame = display->download_frame;
height = display->download_height; vinfo = frame->info;
video_format = display->download_video_format; width = GST_VIDEO_INFO_WIDTH (&vinfo);
data = display->download_data; height = GST_VIDEO_INFO_HEIGHT (&vinfo);
gst_video_info_set_format (&vinfo, video_format, width, height); video_format = GST_VIDEO_INFO_FORMAT (&vinfo);
#ifdef OPENGL_ES2 #ifdef OPENGL_ES2
GLint viewport_dim[4]; GLint viewport_dim[4];
@ -3508,30 +3511,31 @@ gst_gl_display_thread_do_download_draw_yuv (GstGLDisplay * display)
case GST_VIDEO_FORMAT_AYUV: case GST_VIDEO_FORMAT_AYUV:
case GST_VIDEO_FORMAT_xRGB: case GST_VIDEO_FORMAT_xRGB:
glReadPixels (0, 0, width, height, GL_BGRA, glReadPixels (0, 0, width, height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, data); GL_UNSIGNED_INT_8_8_8_8, frame->data[0]);
break; break;
case GST_VIDEO_FORMAT_YUY2: case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY: case GST_VIDEO_FORMAT_UYVY:
glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, height, GL_BGRA, glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8_REV, data); GL_UNSIGNED_INT_8_8_8_8_REV, frame->data[0]);
break; break;
case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12: case GST_VIDEO_FORMAT_YV12:
{ {
glReadPixels (0, 0, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); glReadPixels (0, 0, width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE,
frame->data[0]);
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
glReadBuffer (GL_COLOR_ATTACHMENT1_EXT); glReadBuffer (GL_COLOR_ATTACHMENT1_EXT);
#endif #endif
glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2,
GST_ROUND_UP_2 (height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE, GST_ROUND_UP_2 (height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
(guint8 *) data + GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 1)); frame->data[1]);
#ifndef OPENGL_ES2 #ifndef OPENGL_ES2
glReadBuffer (GL_COLOR_ATTACHMENT2_EXT); glReadBuffer (GL_COLOR_ATTACHMENT2_EXT);
#endif #endif
glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2, glReadPixels (0, 0, GST_ROUND_UP_2 (width) / 2,
GST_ROUND_UP_2 (height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE, GST_ROUND_UP_2 (height) / 2, GL_LUMINANCE, GL_UNSIGNED_BYTE,
(guint8 *) data + GST_VIDEO_INFO_COMP_OFFSET (&vinfo, 2)); frame->data[2]);
} }
break; break;
default: default:

View file

@ -180,7 +180,7 @@ struct _GstGLDisplay
gint download_width; gint download_width;
gint download_height; gint download_height;
GstVideoFormat download_video_format; GstVideoFormat download_video_format;
gpointer download_data; GstVideoFrame *download_frame;
GLenum multipleRT[3]; GLenum multipleRT[3];
GLuint ouput_texture; GLuint ouput_texture;
GLuint ouput_texture_width; GLuint ouput_texture_width;
@ -269,7 +269,7 @@ gboolean gst_gl_display_do_upload (GstGLDisplay * display, GLuint texture,
gboolean gst_gl_display_init_download (GstGLDisplay * display, gboolean gst_gl_display_init_download (GstGLDisplay * display,
GstVideoFormat video_format, gint width, gint height); GstVideoFormat video_format, gint width, gint height);
gboolean gst_gl_display_do_download (GstGLDisplay * display, GLuint texture, gboolean gst_gl_display_do_download (GstGLDisplay * display, GLuint texture,
gint width, gint height, gpointer data); GstVideoFrame *frame);
gboolean gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height, gboolean gst_gl_display_gen_fbo (GstGLDisplay * display, gint width, gint height,
GLuint * fbo, GLuint * depthbuffer); GLuint * fbo, GLuint * depthbuffer);