[038/906] * sys/glsink/glimagesink.c: * sys/glsink/glimagesink.h: * sys/glsink/glvideo.c: * sys/glsink/glvideo.h: Rename GLVideo* to GstGL*.

This commit is contained in:
David Schleef 2007-12-16 22:57:21 +00:00 committed by Matthew Waters
parent dd67fc9b27
commit 4628a9a16d
4 changed files with 104 additions and 105 deletions

View file

@ -287,7 +287,7 @@ gst_glimage_sink_start (GstBaseSink * bsink)
glimage_sink = GST_GLIMAGE_SINK (bsink); glimage_sink = GST_GLIMAGE_SINK (bsink);
glimage_sink->display = glv_display_new (glimage_sink->display_name); glimage_sink->display = gst_gl_display_new (glimage_sink->display_name);
if (glimage_sink->display == NULL) { if (glimage_sink->display == NULL) {
GST_ERROR ("failed to open display"); GST_ERROR ("failed to open display");
return FALSE; return FALSE;
@ -295,10 +295,10 @@ gst_glimage_sink_start (GstBaseSink * bsink)
if (glimage_sink->window_id) { if (glimage_sink->window_id) {
glimage_sink->drawable = glimage_sink->drawable =
glv_drawable_new_from_window (glimage_sink->display, gst_gl_drawable_new_from_window (glimage_sink->display,
glimage_sink->window_id); glimage_sink->window_id);
} else { } else {
glimage_sink->drawable = glv_drawable_new_window (glimage_sink->display); glimage_sink->drawable = gst_gl_drawable_new_window (glimage_sink->display);
} }
if (glimage_sink->drawable == NULL) { if (glimage_sink->drawable == NULL) {
GST_ERROR ("failed to create window"); GST_ERROR ("failed to create window");
@ -319,8 +319,8 @@ gst_glimage_sink_stop (GstBaseSink * bsink)
glimage_sink = GST_GLIMAGE_SINK (bsink); glimage_sink = GST_GLIMAGE_SINK (bsink);
glv_drawable_free (glimage_sink->drawable); gst_gl_drawable_free (glimage_sink->drawable);
glv_display_free (glimage_sink->display); gst_gl_display_free (glimage_sink->display);
glimage_sink->display = NULL; glimage_sink->display = NULL;
glimage_sink->drawable = NULL; glimage_sink->drawable = NULL;
@ -419,25 +419,25 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
switch (format) { switch (format) {
case GST_VIDEO_FORMAT_YUY2: case GST_VIDEO_FORMAT_YUY2:
glimage_sink->type = GLVIDEO_IMAGE_TYPE_YUY2; glimage_sink->type = GST_GL_IMAGE_TYPE_YUY2;
break; break;
case GST_VIDEO_FORMAT_UYVY: case GST_VIDEO_FORMAT_UYVY:
glimage_sink->type = GLVIDEO_IMAGE_TYPE_UYVY; glimage_sink->type = GST_GL_IMAGE_TYPE_UYVY;
break; break;
case GST_VIDEO_FORMAT_AYUV: case GST_VIDEO_FORMAT_AYUV:
glimage_sink->type = GLVIDEO_IMAGE_TYPE_AYUV; glimage_sink->type = GST_GL_IMAGE_TYPE_AYUV;
break; break;
case GST_VIDEO_FORMAT_RGBx: case GST_VIDEO_FORMAT_RGBx:
glimage_sink->type = GLVIDEO_IMAGE_TYPE_RGBx; glimage_sink->type = GST_GL_IMAGE_TYPE_RGBx;
break; break;
case GST_VIDEO_FORMAT_BGRx: case GST_VIDEO_FORMAT_BGRx:
glimage_sink->type = GLVIDEO_IMAGE_TYPE_BGRx; glimage_sink->type = GST_GL_IMAGE_TYPE_BGRx;
break; break;
case GST_VIDEO_FORMAT_xRGB: case GST_VIDEO_FORMAT_xRGB:
glimage_sink->type = GLVIDEO_IMAGE_TYPE_xRGB; glimage_sink->type = GST_GL_IMAGE_TYPE_xRGB;
break; break;
case GST_VIDEO_FORMAT_xBGR: case GST_VIDEO_FORMAT_xBGR:
glimage_sink->type = GLVIDEO_IMAGE_TYPE_xBGR; glimage_sink->type = GST_GL_IMAGE_TYPE_xBGR;
break; break;
default: default:
break; break;
@ -461,7 +461,7 @@ gst_glimage_sink_render (GstBaseSink * bsink, GstBuffer * buf)
glimage_sink = GST_GLIMAGE_SINK (bsink); glimage_sink = GST_GLIMAGE_SINK (bsink);
glv_drawable_draw_image (glimage_sink->drawable, gst_gl_drawable_draw_image (glimage_sink->drawable,
glimage_sink->type, GST_BUFFER_DATA (buf), glimage_sink->type, GST_BUFFER_DATA (buf),
GST_VIDEO_SINK_WIDTH (glimage_sink), GST_VIDEO_SINK_WIDTH (glimage_sink),
GST_VIDEO_SINK_HEIGHT (glimage_sink)); GST_VIDEO_SINK_HEIGHT (glimage_sink));
@ -496,9 +496,9 @@ gst_glimage_sink_set_xwindow_id (GstXOverlay * overlay, XID window_id)
} }
glimage_sink->window_id = window_id; glimage_sink->window_id = window_id;
if (glimage_sink->drawable) { if (glimage_sink->drawable) {
glv_drawable_free (glimage_sink->drawable); gst_gl_drawable_free (glimage_sink->drawable);
glimage_sink->drawable = glimage_sink->drawable =
glv_drawable_new_from_window (glimage_sink->display, window_id); gst_gl_drawable_new_from_window (glimage_sink->display, window_id);
} }
} }

View file

@ -58,9 +58,9 @@ struct _GstGLImageSink
int fps_n, fps_d; int fps_n, fps_d;
int par_n, par_d; int par_n, par_d;
GLVideoDisplay *display; GstGLDisplay *display;
GLVideoDrawable *drawable; GstGLDrawable *drawable;
GLVideoImageType type; GstGLImageType type;
XID window_id; XID window_id;
}; };

View file

@ -23,22 +23,21 @@
#include "glvideo.h" #include "glvideo.h"
#include "glextensions.h" #include "glextensions.h"
/* only use gst for debugging */
#include <gst/gst.h> #include <gst/gst.h>
#include <string.h> #include <string.h>
static gboolean glv_display_check_features (GLVideoDisplay * display); static gboolean gst_gl_display_check_features (GstGLDisplay * display);
GLVideoDisplay * GstGLDisplay *
glv_display_new (const char *display_name) gst_gl_display_new (const char *display_name)
{ {
GLVideoDisplay *display; GstGLDisplay *display;
gboolean usable; gboolean usable;
display = g_malloc0 (sizeof (GLVideoDisplay)); display = g_malloc0 (sizeof (GstGLDisplay));
display->display = XOpenDisplay (display_name); display->display = XOpenDisplay (display_name);
if (display->display == NULL) { if (display->display == NULL) {
@ -46,7 +45,7 @@ glv_display_new (const char *display_name)
return NULL; return NULL;
} }
usable = glv_display_check_features (display); usable = gst_gl_display_check_features (display);
if (!usable) { if (!usable) {
g_free (display); g_free (display);
return NULL; return NULL;
@ -58,7 +57,7 @@ glv_display_new (const char *display_name)
} }
static gboolean static gboolean
glv_display_check_features (GLVideoDisplay * display) gst_gl_display_check_features (GstGLDisplay * display)
{ {
gboolean ret; gboolean ret;
XVisualInfo *visinfo; XVisualInfo *visinfo;
@ -143,18 +142,18 @@ glv_display_check_features (GLVideoDisplay * display)
} }
gboolean gboolean
glv_display_can_handle_type (GLVideoDisplay * display, GLVideoImageType type) gst_gl_display_can_handle_type (GstGLDisplay * display, GstGLImageType type)
{ {
switch (type) { switch (type) {
case GLVIDEO_IMAGE_TYPE_RGBx: case GST_GL_IMAGE_TYPE_RGBx:
case GLVIDEO_IMAGE_TYPE_BGRx: case GST_GL_IMAGE_TYPE_BGRx:
case GLVIDEO_IMAGE_TYPE_xRGB: case GST_GL_IMAGE_TYPE_xRGB:
case GLVIDEO_IMAGE_TYPE_xBGR: case GST_GL_IMAGE_TYPE_xBGR:
return TRUE; return TRUE;
case GLVIDEO_IMAGE_TYPE_YUY2: case GST_GL_IMAGE_TYPE_YUY2:
case GLVIDEO_IMAGE_TYPE_UYVY: case GST_GL_IMAGE_TYPE_UYVY:
return display->have_ycbcr_texture; return display->have_ycbcr_texture;
case GLVIDEO_IMAGE_TYPE_AYUV: case GST_GL_IMAGE_TYPE_AYUV:
return display->have_color_matrix; return display->have_color_matrix;
default: default:
return FALSE; return FALSE;
@ -162,7 +161,7 @@ glv_display_can_handle_type (GLVideoDisplay * display, GLVideoImageType type)
} }
void void
glv_display_free (GLVideoDisplay * display) gst_gl_display_free (GstGLDisplay * display)
{ {
/* sure hope nobody is using it as it's being freed */ /* sure hope nobody is using it as it's being freed */
g_mutex_lock (display->lock); g_mutex_lock (display->lock);
@ -186,17 +185,17 @@ glv_display_free (GLVideoDisplay * display)
/* drawable */ /* drawable */
GLVideoDrawable * GstGLDrawable *
glv_drawable_new_window (GLVideoDisplay * display) gst_gl_drawable_new_window (GstGLDisplay * display)
{ {
GLVideoDrawable *drawable; GstGLDrawable *drawable;
XSetWindowAttributes attr = { 0 }; XSetWindowAttributes attr = { 0 };
int scrnum; int scrnum;
int mask; int mask;
Window root; Window root;
Screen *screen; Screen *screen;
drawable = g_malloc0 (sizeof (GLVideoDrawable)); drawable = g_malloc0 (sizeof (GstGLDrawable));
g_mutex_lock (display->lock); g_mutex_lock (display->lock);
drawable->display = display; drawable->display = display;
@ -230,14 +229,14 @@ glv_drawable_new_window (GLVideoDisplay * display)
return drawable; return drawable;
} }
GLVideoDrawable * GstGLDrawable *
glv_drawable_new_root_window (GLVideoDisplay * display) gst_gl_drawable_new_root_window (GstGLDisplay * display)
{ {
GLVideoDrawable *drawable; GstGLDrawable *drawable;
int scrnum; int scrnum;
Screen *screen; Screen *screen;
drawable = g_malloc0 (sizeof (GLVideoDrawable)); drawable = g_malloc0 (sizeof (GstGLDrawable));
g_mutex_lock (display->lock); g_mutex_lock (display->lock);
drawable->display = display; drawable->display = display;
@ -252,12 +251,12 @@ glv_drawable_new_root_window (GLVideoDisplay * display)
return drawable; return drawable;
} }
GLVideoDrawable * GstGLDrawable *
glv_drawable_new_from_window (GLVideoDisplay * display, Window window) gst_gl_drawable_new_from_window (GstGLDisplay * display, Window window)
{ {
GLVideoDrawable *drawable; GstGLDrawable *drawable;
drawable = g_malloc0 (sizeof (GLVideoDrawable)); drawable = g_malloc0 (sizeof (GstGLDrawable));
g_mutex_lock (display->lock); g_mutex_lock (display->lock);
drawable->display = display; drawable->display = display;
@ -270,7 +269,7 @@ glv_drawable_new_from_window (GLVideoDisplay * display, Window window)
} }
void void
glv_drawable_free (GLVideoDrawable * drawable) gst_gl_drawable_free (GstGLDrawable * drawable)
{ {
g_mutex_lock (drawable->display->lock); g_mutex_lock (drawable->display->lock);
@ -283,7 +282,7 @@ glv_drawable_free (GLVideoDrawable * drawable)
} }
void void
glv_drawable_lock (GLVideoDrawable * drawable) gst_gl_drawable_lock (GstGLDrawable * drawable)
{ {
g_mutex_lock (drawable->display->lock); g_mutex_lock (drawable->display->lock);
glXMakeCurrent (drawable->display->display, drawable->window, glXMakeCurrent (drawable->display->display, drawable->window,
@ -291,14 +290,14 @@ glv_drawable_lock (GLVideoDrawable * drawable)
} }
void void
glv_drawable_unlock (GLVideoDrawable * drawable) gst_gl_drawable_unlock (GstGLDrawable * drawable)
{ {
glXMakeCurrent (drawable->display->display, None, NULL); glXMakeCurrent (drawable->display->display, None, NULL);
g_mutex_unlock (drawable->display->lock); g_mutex_unlock (drawable->display->lock);
} }
void void
glv_drawable_update_attributes (GLVideoDrawable * drawable) gst_gl_drawable_update_attributes (GstGLDrawable * drawable)
{ {
XWindowAttributes attr; XWindowAttributes attr;
@ -309,23 +308,23 @@ glv_drawable_update_attributes (GLVideoDrawable * drawable)
} }
void void
glv_drawable_clear (GLVideoDrawable * drawable) gst_gl_drawable_clear (GstGLDrawable * drawable)
{ {
glv_drawable_lock (drawable); gst_gl_drawable_lock (drawable);
glDepthFunc (GL_LESS); glDepthFunc (GL_LESS);
glEnable (GL_DEPTH_TEST); glEnable (GL_DEPTH_TEST);
glClearColor (0.2, 0.2, 0.2, 1.0); glClearColor (0.2, 0.2, 0.2, 1.0);
glViewport (0, 0, drawable->win_width, drawable->win_height); glViewport (0, 0, drawable->win_width, drawable->win_height);
glv_drawable_unlock (drawable); gst_gl_drawable_unlock (drawable);
} }
static void static void
draw_rect_texture (GLVideoDrawable * drawable, GLVideoImageType type, draw_rect_texture (GstGLDrawable * drawable, GstGLImageType type,
void *data, int width, int height) void *data, int width, int height)
{ {
GLuint texture; GLuint texture;
@ -343,43 +342,43 @@ draw_rect_texture (GLVideoDrawable * drawable, GLVideoImageType type,
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
switch (type) { switch (type) {
case GLVIDEO_IMAGE_TYPE_RGBx: case GST_GL_IMAGE_TYPE_RGBx:
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
GL_RGBA, GL_UNSIGNED_BYTE, data); GL_RGBA, GL_UNSIGNED_BYTE, data);
break; break;
case GLVIDEO_IMAGE_TYPE_BGRx: case GST_GL_IMAGE_TYPE_BGRx:
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
GL_BGRA, GL_UNSIGNED_BYTE, data); GL_BGRA, GL_UNSIGNED_BYTE, data);
break; break;
case GLVIDEO_IMAGE_TYPE_xRGB: case GST_GL_IMAGE_TYPE_xRGB:
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data); GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
break; break;
case GLVIDEO_IMAGE_TYPE_xBGR: case GST_GL_IMAGE_TYPE_xBGR:
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data); GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data);
break; break;
case GLVIDEO_IMAGE_TYPE_YUY2: case GST_GL_IMAGE_TYPE_YUY2:
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL); 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data); GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
break; break;
case GLVIDEO_IMAGE_TYPE_UYVY: case GST_GL_IMAGE_TYPE_UYVY:
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL); 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data); GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
break; break;
case GLVIDEO_IMAGE_TYPE_AYUV: case GST_GL_IMAGE_TYPE_AYUV:
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height, glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
@ -390,7 +389,7 @@ draw_rect_texture (GLVideoDrawable * drawable, GLVideoImageType type,
} }
#ifdef GL_POST_COLOR_MATRIX_RED_BIAS #ifdef GL_POST_COLOR_MATRIX_RED_BIAS
if (type == GLVIDEO_IMAGE_TYPE_AYUV) { if (type == GST_GL_IMAGE_TYPE_AYUV) {
const double matrix[16] = { const double matrix[16] = {
1, 1, 1, 0, 1, 1, 1, 0,
0, -0.344 * 1, 1.770 * 1, 0, 0, -0.344 * 1, 1.770 * 1, 0,
@ -426,7 +425,7 @@ draw_rect_texture (GLVideoDrawable * drawable, GLVideoImageType type,
} }
static void static void
draw_pow2_texture (GLVideoDrawable * drawable, GLVideoImageType type, draw_pow2_texture (GstGLDrawable * drawable, GstGLImageType type,
void *data, int width, int height) void *data, int width, int height)
{ {
int pow2_width; int pow2_width;
@ -450,43 +449,43 @@ draw_pow2_texture (GLVideoDrawable * drawable, GLVideoImageType type,
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
switch (type) { switch (type) {
case GLVIDEO_IMAGE_TYPE_RGBx: case GST_GL_IMAGE_TYPE_RGBx:
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height, glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_RGBA, GL_UNSIGNED_BYTE, data); GL_RGBA, GL_UNSIGNED_BYTE, data);
break; break;
case GLVIDEO_IMAGE_TYPE_BGRx: case GST_GL_IMAGE_TYPE_BGRx:
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height, glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_BGRA, GL_UNSIGNED_BYTE, data); GL_BGRA, GL_UNSIGNED_BYTE, data);
break; break;
case GLVIDEO_IMAGE_TYPE_xRGB: case GST_GL_IMAGE_TYPE_xRGB:
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height, glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data); GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
break; break;
case GLVIDEO_IMAGE_TYPE_xBGR: case GST_GL_IMAGE_TYPE_xBGR:
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height, glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data); GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data);
break; break;
case GLVIDEO_IMAGE_TYPE_YUY2: case GST_GL_IMAGE_TYPE_YUY2:
glTexImage2D (GL_TEXTURE_2D, 0, GL_YCBCR_MESA, pow2_width, pow2_height, glTexImage2D (GL_TEXTURE_2D, 0, GL_YCBCR_MESA, pow2_width, pow2_height,
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL); 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data); GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
break; break;
case GLVIDEO_IMAGE_TYPE_UYVY: case GST_GL_IMAGE_TYPE_UYVY:
glTexImage2D (GL_TEXTURE_2D, 0, GL_YCBCR_MESA, pow2_width, pow2_height, glTexImage2D (GL_TEXTURE_2D, 0, GL_YCBCR_MESA, pow2_width, pow2_height,
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL); 0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data); GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
break; break;
case GLVIDEO_IMAGE_TYPE_AYUV: case GST_GL_IMAGE_TYPE_AYUV:
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height, glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
@ -497,7 +496,7 @@ draw_pow2_texture (GLVideoDrawable * drawable, GLVideoImageType type,
} }
#ifdef GL_POST_COLOR_MATRIX_RED_BIAS #ifdef GL_POST_COLOR_MATRIX_RED_BIAS
if (type == GLVIDEO_IMAGE_TYPE_AYUV) { if (type == GST_GL_IMAGE_TYPE_AYUV) {
const double matrix[16] = { const double matrix[16] = {
1, 1, 1, 0, 1, 1, 1, 0,
0, -0.344 * 1, 1.770 * 1, 0, 0, -0.344 * 1, 1.770 * 1, 0,
@ -533,14 +532,14 @@ draw_pow2_texture (GLVideoDrawable * drawable, GLVideoImageType type,
} }
void void
glv_drawable_draw_image (GLVideoDrawable * drawable, GLVideoImageType type, gst_gl_drawable_draw_image (GstGLDrawable * drawable, GstGLImageType type,
void *data, int width, int height) void *data, int width, int height)
{ {
g_return_if_fail (data != NULL); g_return_if_fail (data != NULL);
g_return_if_fail (width > 0); g_return_if_fail (width > 0);
g_return_if_fail (height > 0); g_return_if_fail (height > 0);
glv_drawable_lock (drawable); gst_gl_drawable_lock (drawable);
#if 0 #if 0
/* Doesn't work */ /* Doesn't work */
@ -569,7 +568,7 @@ glv_drawable_draw_image (GLVideoDrawable * drawable, GLVideoImageType type,
} }
#endif #endif
glv_drawable_update_attributes (drawable); gst_gl_drawable_update_attributes (drawable);
glXSwapIntervalSGI (1); glXSwapIntervalSGI (1);
glViewport (0, 0, drawable->win_width, drawable->win_height); glViewport (0, 0, drawable->win_width, drawable->win_height);
@ -605,5 +604,5 @@ glv_drawable_draw_image (GLVideoDrawable * drawable, GLVideoImageType type,
} }
#endif #endif
glv_drawable_unlock (drawable); gst_gl_drawable_unlock (drawable);
} }

View file

@ -1,26 +1,26 @@
#ifndef __GLVIDEO_H__ #ifndef __GST_GL_H__
#define __GLVIDEO_H__ #define __GST_GL_H__
#include <GL/glx.h> #include <GL/glx.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <glib.h> #include <gst/gst.h>
typedef struct _GLVideoDisplay GLVideoDisplay; typedef struct _GstGLDisplay GstGLDisplay;
typedef struct _GLVideoDrawable GLVideoDrawable; typedef struct _GstGLDrawable GstGLDrawable;
typedef enum { typedef enum {
GLVIDEO_IMAGE_TYPE_RGBx, GST_GL_IMAGE_TYPE_RGBx,
GLVIDEO_IMAGE_TYPE_BGRx, GST_GL_IMAGE_TYPE_BGRx,
GLVIDEO_IMAGE_TYPE_xRGB, GST_GL_IMAGE_TYPE_xRGB,
GLVIDEO_IMAGE_TYPE_xBGR, GST_GL_IMAGE_TYPE_xBGR,
GLVIDEO_IMAGE_TYPE_YUY2, GST_GL_IMAGE_TYPE_YUY2,
GLVIDEO_IMAGE_TYPE_UYVY, GST_GL_IMAGE_TYPE_UYVY,
GLVIDEO_IMAGE_TYPE_AYUV, GST_GL_IMAGE_TYPE_AYUV,
} GLVideoImageType; } GstGLImageType;
struct _GLVideoDisplay { struct _GstGLDisplay {
Display *display; Display *display;
XVisualInfo *visinfo; XVisualInfo *visinfo;
GLXContext context; GLXContext context;
@ -37,8 +37,8 @@ struct _GLVideoDisplay {
gboolean have_color_matrix; gboolean have_color_matrix;
}; };
struct _GLVideoDrawable { struct _GstGLDrawable {
GLVideoDisplay *display; GstGLDisplay *display;
Window window; Window window;
@ -49,22 +49,22 @@ struct _GLVideoDrawable {
}; };
GLVideoDisplay *glv_display_new (const char *display_name); GstGLDisplay *gst_gl_display_new (const char *display_name);
gboolean glv_display_can_handle_type (GLVideoDisplay *display, gboolean gst_gl_display_can_handle_type (GstGLDisplay *display,
GLVideoImageType type); GstGLImageType type);
void glv_display_free (GLVideoDisplay *display); void gst_gl_display_free (GstGLDisplay *display);
/* drawable */ /* drawable */
GLVideoDrawable * glv_drawable_new_window (GLVideoDisplay *display); GstGLDrawable * gst_gl_drawable_new_window (GstGLDisplay *display);
GLVideoDrawable * glv_drawable_new_root_window (GLVideoDisplay *display); GstGLDrawable * gst_gl_drawable_new_root_window (GstGLDisplay *display);
GLVideoDrawable * glv_drawable_new_from_window (GLVideoDisplay *display, Window window); GstGLDrawable * gst_gl_drawable_new_from_window (GstGLDisplay *display, Window window);
void glv_drawable_free (GLVideoDrawable *drawable); void gst_gl_drawable_free (GstGLDrawable *drawable);
void glv_drawable_lock (GLVideoDrawable *drawable); void gst_gl_drawable_lock (GstGLDrawable *drawable);
void glv_drawable_unlock (GLVideoDrawable *drawable); void gst_gl_drawable_unlock (GstGLDrawable *drawable);
void glv_drawable_update_attributes (GLVideoDrawable *drawable); void gst_gl_drawable_update_attributes (GstGLDrawable *drawable);
void glv_drawable_clear (GLVideoDrawable *drawable); void gst_gl_drawable_clear (GstGLDrawable *drawable);
void glv_drawable_draw_image (GLVideoDrawable *drawable, GLVideoImageType type, void *data, int width, int height); void gst_gl_drawable_draw_image (GstGLDrawable *drawable, GstGLImageType type, void *data, int width, int height);
#endif #endif