[047/906] * sys/glsink/gltestsrc.c: * sys/glsink/gstglbuffer.c: * sys/glsink/gstglbuffer.h: * sys/glsink/gstgldownload.c: * sys/glsink/gstglfilter.c: * sys/glsink/gstglfilterexample.c: * sys/glsink/gstgltestsrc.c: * sys/glsink/gstglupload.c: Convert gldownload to BaseTransform. Make glfilterexample visually interesting. Add support for various formats to downloading. Fix a few places where we leak GL state to other elements (bad, but hard to prevent).
This commit is contained in:
parent
5e620c9673
commit
2a6bf50ba7
@ -90,6 +90,9 @@ gst_gl_buffer_new (GstGLDisplay * display, GstGLBufferFormat format,
|
|||||||
buffer->display = g_object_ref (display);
|
buffer->display = g_object_ref (display);
|
||||||
buffer->width = width;
|
buffer->width = width;
|
||||||
buffer->height = height;
|
buffer->height = height;
|
||||||
|
/* this is not strictly true, but it's used for compatibility with
|
||||||
|
* queue and BaseTransform */
|
||||||
|
GST_BUFFER_SIZE (buffer) = width * height * 4;
|
||||||
|
|
||||||
gst_gl_display_lock (buffer->display);
|
gst_gl_display_lock (buffer->display);
|
||||||
glGenTextures (1, &buffer->texture);
|
glGenTextures (1, &buffer->texture);
|
||||||
@ -129,6 +132,9 @@ gst_gl_buffer_new_from_data (GstGLDisplay * display, GstVideoFormat format,
|
|||||||
buffer->display = g_object_ref (display);
|
buffer->display = g_object_ref (display);
|
||||||
buffer->width = width;
|
buffer->width = width;
|
||||||
buffer->height = height;
|
buffer->height = height;
|
||||||
|
/* this is not strictly true, but it's used for compatibility with
|
||||||
|
* queue and BaseTransform */
|
||||||
|
GST_BUFFER_SIZE (buffer) = width * height * 4;
|
||||||
|
|
||||||
gst_gl_display_lock (buffer->display);
|
gst_gl_display_lock (buffer->display);
|
||||||
glGenTextures (1, &buffer->texture);
|
glGenTextures (1, &buffer->texture);
|
||||||
@ -234,7 +240,7 @@ gst_gl_buffer_new_from_data (GstGLDisplay * display, GstVideoFormat format,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_gl_buffer_download (GstGLBuffer * buffer, void *data)
|
gst_gl_buffer_download (GstGLBuffer * buffer, GstVideoFormat format, void *data)
|
||||||
{
|
{
|
||||||
GLuint fbo;
|
GLuint fbo;
|
||||||
|
|
||||||
@ -254,15 +260,33 @@ gst_gl_buffer_download (GstGLBuffer * buffer, void *data)
|
|||||||
g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
|
g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
|
||||||
GL_FRAMEBUFFER_COMPLETE_EXT);
|
GL_FRAMEBUFFER_COMPLETE_EXT);
|
||||||
|
|
||||||
/* needs a reset function */
|
/* we need a reset function */
|
||||||
glMatrixMode (GL_COLOR);
|
glMatrixMode (GL_COLOR);
|
||||||
glLoadIdentity ();
|
glLoadIdentity ();
|
||||||
glPixelTransferf (GL_POST_COLOR_MATRIX_RED_BIAS, 0);
|
glPixelTransferf (GL_POST_COLOR_MATRIX_RED_BIAS, 0);
|
||||||
glPixelTransferf (GL_POST_COLOR_MATRIX_GREEN_BIAS, 0);
|
glPixelTransferf (GL_POST_COLOR_MATRIX_GREEN_BIAS, 0);
|
||||||
glPixelTransferf (GL_POST_COLOR_MATRIX_BLUE_BIAS, 0);
|
glPixelTransferf (GL_POST_COLOR_MATRIX_BLUE_BIAS, 0);
|
||||||
|
|
||||||
glReadPixels (0, 0, buffer->width, buffer->height, GL_RGBA,
|
switch (format) {
|
||||||
GL_UNSIGNED_BYTE, data);
|
case GST_VIDEO_FORMAT_RGBx:
|
||||||
|
glReadPixels (0, 0, buffer->width, buffer->height, GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE, data);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_BGRx:
|
||||||
|
glReadPixels (0, 0, buffer->width, buffer->height, GL_BGRA,
|
||||||
|
GL_UNSIGNED_BYTE, data);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_xBGR:
|
||||||
|
glReadPixels (0, 0, buffer->width, buffer->height, GL_RGBA,
|
||||||
|
GL_UNSIGNED_INT_8_8_8_8, data);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_xRGB:
|
||||||
|
glReadPixels (0, 0, buffer->width, buffer->height, GL_BGRA,
|
||||||
|
GL_UNSIGNED_INT_8_8_8_8, data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
}
|
||||||
|
|
||||||
glDeleteFramebuffersEXT (1, &fbo);
|
glDeleteFramebuffersEXT (1, &fbo);
|
||||||
|
|
||||||
|
@ -44,7 +44,18 @@ GstGLBuffer * gst_gl_buffer_new (GstGLDisplay *display,
|
|||||||
GstGLBufferFormat format, int width, int height);
|
GstGLBufferFormat format, int width, int height);
|
||||||
GstGLBuffer * gst_gl_buffer_new_from_data (GstGLDisplay *display,
|
GstGLBuffer * gst_gl_buffer_new_from_data (GstGLDisplay *display,
|
||||||
GstVideoFormat format, int width, int height, void *data);
|
GstVideoFormat format, int width, int height, void *data);
|
||||||
void gst_gl_buffer_download (GstGLBuffer *buffer, void *data);
|
void gst_gl_buffer_download (GstGLBuffer *buffer, GstVideoFormat format,
|
||||||
|
void *data);
|
||||||
|
|
||||||
|
|
||||||
|
#define GST_GL_VIDEO_CAPS \
|
||||||
|
"video/x-raw-gl," \
|
||||||
|
"format=(int)[0,10]," \
|
||||||
|
"width=(int)[1,2048]," \
|
||||||
|
"height=(int)[1,2048]," \
|
||||||
|
"pixel-aspect-ratio=(fraction)1/1," \
|
||||||
|
"framerate=(fraction)[0/1,100/1]"
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user