mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
sys/glsink/: Add support for xRGB, xBGR, and AYUV. Re-add support for power-of-2 textures.
Original commit message from CVS: * sys/glsink/Makefile.am: * sys/glsink/glimagesink.c: * sys/glsink/glvideo.c: * sys/glsink/glvideo.h: * sys/glsink/gstvideo-common.c: * sys/glsink/gstvideo-common.h: Add support for xRGB, xBGR, and AYUV. Re-add support for power-of-2 textures.
This commit is contained in:
parent
cd9b0d7168
commit
601b1f640b
7 changed files with 323 additions and 62 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2007-12-15 David Schleef <ds@schleef.org>
|
||||
|
||||
* sys/glsink/Makefile.am:
|
||||
* sys/glsink/glimagesink.c:
|
||||
* sys/glsink/glvideo.c:
|
||||
* sys/glsink/glvideo.h:
|
||||
* sys/glsink/gstvideo-common.c:
|
||||
* sys/glsink/gstvideo-common.h:
|
||||
Add support for xRGB, xBGR, and AYUV. Re-add support for
|
||||
power-of-2 textures.
|
||||
|
||||
2007-12-15 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* gst/videoparse/gstvideoparse.c: (gst_video_parse_dispose),
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
plugin_LTLIBRARIES = libgstglimagesink.la
|
||||
|
||||
libgstglimagesink_la_SOURCES = \
|
||||
glimagesink.h \
|
||||
glimagesink.c \
|
||||
glvideo.c \
|
||||
glvideo.h \
|
||||
gstopengl.c \
|
||||
gstvideo-common.h \
|
||||
gstvideo-common.c
|
||||
libgstglimagesink_la_CFLAGS = $(GST_CFLAGS) $(X_CFLAGS) $(GST_BASE_CFLAGS) \
|
||||
$(GST_PLUGINS_BASE_CFLAGS)
|
||||
|
@ -17,4 +14,6 @@ libgstglimagesink_la_LIBADD = $(X_LIBS) $(XSHM_LIBS) -lGL \
|
|||
libgstglimagesink_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
|
||||
noinst_HEADERS = \
|
||||
glimagesink.h \
|
||||
gstvideo-common.h \
|
||||
glvideo.h
|
||||
|
|
|
@ -77,7 +77,7 @@ GST_ELEMENT_DETAILS ("OpenGL video sink",
|
|||
"David Schleef <ds@schleef.org>");
|
||||
|
||||
#ifdef GL_YCBCR_MESA
|
||||
#define YUV_CAPS ";" GST_VIDEO_CAPS_YUV ("{ UYVY, YUY2 }")
|
||||
#define YUV_CAPS ";" GST_VIDEO_CAPS_YUV ("{ AYUV, UYVY, YUY2 }")
|
||||
#else
|
||||
#define YUV_CAPS
|
||||
#endif
|
||||
|
@ -85,7 +85,8 @@ static GstStaticPadTemplate gst_glimage_sink_template =
|
|||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx YUV_CAPS)
|
||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx ";"
|
||||
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR YUV_CAPS)
|
||||
);
|
||||
|
||||
enum
|
||||
|
@ -423,12 +424,21 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
|
|||
case GST_VIDEO_FORMAT_UYVY:
|
||||
glimage_sink->type = GLVIDEO_IMAGE_TYPE_UYVY;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
glimage_sink->type = GLVIDEO_IMAGE_TYPE_AYUV;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
glimage_sink->type = GLVIDEO_IMAGE_TYPE_RGBx;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
glimage_sink->type = GLVIDEO_IMAGE_TYPE_BGRx;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
glimage_sink->type = GLVIDEO_IMAGE_TYPE_xRGB;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
glimage_sink->type = GLVIDEO_IMAGE_TYPE_xBGR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -557,11 +567,13 @@ gst_glimage_sink_update_caps (GstGLImageSink * glimage_sink)
|
|||
return;
|
||||
}
|
||||
|
||||
caps = gst_caps_from_string (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx);
|
||||
caps =
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_BGRx ";"
|
||||
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_xBGR);
|
||||
#ifdef GL_YCBCR_MESA
|
||||
if (glimage_sink->display->have_ycbcr_texture) {
|
||||
GstCaps *ycaps =
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_YUV ("{ UYVY, YUY2 }"));
|
||||
gst_caps_from_string (GST_VIDEO_CAPS_YUV ("{ AYUV, UYVY, YUY2 }"));
|
||||
gst_caps_append (ycaps, caps);
|
||||
caps = ycaps;
|
||||
}
|
||||
|
|
|
@ -113,14 +113,26 @@ glv_display_check_features (GLVideoDisplay * display)
|
|||
glGetIntegerv (GL_MAX_TEXTURE_SIZE, &display->max_texture_size);
|
||||
|
||||
extstring = (const char *) glGetString (GL_EXTENSIONS);
|
||||
|
||||
display->have_ycbcr_texture = FALSE;
|
||||
#ifdef GL_YCBCR_MESA
|
||||
if (strstr (extstring, "GL_MESA_ycbcr_texture")) {
|
||||
display->have_ycbcr_texture = TRUE;
|
||||
} else {
|
||||
display->have_ycbcr_texture = FALSE;
|
||||
}
|
||||
#else
|
||||
display->have_ycbcr_texture = FALSE;
|
||||
#endif
|
||||
|
||||
display->have_color_matrix = FALSE;
|
||||
#ifdef GL_POST_COLOR_MATRIX_RED_BIAS
|
||||
if (strstr (extstring, "GL_SGI_color_matrix")) {
|
||||
display->have_color_matrix = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
display->have_texture_rectangle = FALSE;
|
||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
||||
if (strstr (extstring, "GL_ARB_texture_rectangle")) {
|
||||
display->have_texture_rectangle = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
glXMakeCurrent (display->display, None, NULL);
|
||||
|
@ -129,6 +141,25 @@ glv_display_check_features (GLVideoDisplay * display)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
glv_display_can_handle_type (GLVideoDisplay * display, GLVideoImageType type)
|
||||
{
|
||||
switch (type) {
|
||||
case GLVIDEO_IMAGE_TYPE_RGBx:
|
||||
case GLVIDEO_IMAGE_TYPE_BGRx:
|
||||
case GLVIDEO_IMAGE_TYPE_xRGB:
|
||||
case GLVIDEO_IMAGE_TYPE_xBGR:
|
||||
return TRUE;
|
||||
case GLVIDEO_IMAGE_TYPE_YUY2:
|
||||
case GLVIDEO_IMAGE_TYPE_UYVY:
|
||||
return display->have_ycbcr_texture;
|
||||
case GLVIDEO_IMAGE_TYPE_AYUV:
|
||||
return display->have_color_matrix;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glv_display_free (GLVideoDisplay * display)
|
||||
{
|
||||
|
@ -292,6 +323,207 @@ glv_drawable_clear (GLVideoDrawable * drawable)
|
|||
|
||||
|
||||
|
||||
static void
|
||||
draw_rect_texture (GLVideoDrawable * drawable, GLVideoImageType type,
|
||||
void *data, int width, int height)
|
||||
{
|
||||
GST_DEBUG ("using rectangular texture");
|
||||
|
||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 1);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
switch (type) {
|
||||
case GLVIDEO_IMAGE_TYPE_RGBx:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_BGRx:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_xRGB:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_xBGR:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_YUY2:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_UYVY:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_AYUV:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
#ifdef GL_POST_COLOR_MATRIX_RED_BIAS
|
||||
if (type == GLVIDEO_IMAGE_TYPE_AYUV) {
|
||||
const double matrix[16] = {
|
||||
1, 1, 1, 0,
|
||||
0, -0.344 * 1, 1.770 * 1, 0,
|
||||
1.403 * 1, -0.714 * 1, 0, 0,
|
||||
0, 0, 0, 1
|
||||
};
|
||||
glMatrixMode (GL_COLOR);
|
||||
glLoadMatrixd (matrix);
|
||||
glPixelTransferf (GL_POST_COLOR_MATRIX_RED_BIAS, -1.403 / 2);
|
||||
glPixelTransferf (GL_POST_COLOR_MATRIX_GREEN_BIAS, (0.344 + 0.714) / 2);
|
||||
glPixelTransferf (GL_POST_COLOR_MATRIX_BLUE_BIAS, -1.770 / 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
glColor4f (1, 0, 1, 1);
|
||||
glBegin (GL_QUADS);
|
||||
|
||||
glNormal3f (0, 0, -1);
|
||||
|
||||
glTexCoord2f (width, 0);
|
||||
glVertex3f (1.0, 1.0, 0);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex3f (-1.0, 1.0, 0);
|
||||
glTexCoord2f (0, height);
|
||||
glVertex3f (-1.0, -1.0, 0);
|
||||
glTexCoord2f (width, height);
|
||||
glVertex3f (1.0, -1.0, 0);
|
||||
glEnd ();
|
||||
#else
|
||||
g_assert_not_reached ();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
draw_pow2_texture (GLVideoDrawable * drawable, GLVideoImageType type,
|
||||
void *data, int width, int height)
|
||||
{
|
||||
int pow2_width;
|
||||
int pow2_height;
|
||||
double x, y;
|
||||
|
||||
GST_DEBUG ("using power-of-2 texture");
|
||||
|
||||
for (pow2_height = 64;
|
||||
pow2_height < height && pow2_height > 0; pow2_height <<= 1);
|
||||
for (pow2_width = 64; pow2_width < width && pow2_width > 0; pow2_width <<= 1);
|
||||
|
||||
glEnable (GL_TEXTURE_2D);
|
||||
glBindTexture (GL_TEXTURE_2D, 1);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
switch (type) {
|
||||
case GLVIDEO_IMAGE_TYPE_RGBx:
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_BGRx:
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_xRGB:
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_xBGR:
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
|
||||
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_YUY2:
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_YCBCR_MESA, pow2_width, pow2_height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
|
||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_UYVY:
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_YCBCR_MESA, pow2_width, pow2_height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
|
||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_AYUV:
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, pow2_width, pow2_height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height,
|
||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
#ifdef GL_POST_COLOR_MATRIX_RED_BIAS
|
||||
if (type == GLVIDEO_IMAGE_TYPE_AYUV) {
|
||||
const double matrix[16] = {
|
||||
1, 1, 1, 0,
|
||||
0, -0.344 * 1, 1.770 * 1, 0,
|
||||
1.403 * 1, -0.714 * 1, 0, 0,
|
||||
0, 0, 0, 1
|
||||
};
|
||||
glMatrixMode (GL_COLOR);
|
||||
glLoadMatrixd (matrix);
|
||||
glPixelTransferf (GL_POST_COLOR_MATRIX_RED_BIAS, -1.403 / 2);
|
||||
glPixelTransferf (GL_POST_COLOR_MATRIX_GREEN_BIAS, (0.344 + 0.714) / 2);
|
||||
glPixelTransferf (GL_POST_COLOR_MATRIX_BLUE_BIAS, -1.770 / 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
glColor4f (1, 0, 1, 1);
|
||||
glBegin (GL_QUADS);
|
||||
|
||||
glNormal3f (0, 0, -1);
|
||||
|
||||
x = (double) width / pow2_width;
|
||||
y = (double) height / pow2_height;
|
||||
|
||||
glTexCoord2f (x, 0);
|
||||
glVertex3f (1.0, 1.0, 0);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex3f (-1.0, 1.0, 0);
|
||||
glTexCoord2f (0, y);
|
||||
glVertex3f (-1.0, -1.0, 0);
|
||||
glTexCoord2f (x, y);
|
||||
glVertex3f (1.0, -1.0, 0);
|
||||
glEnd ();
|
||||
}
|
||||
|
||||
void
|
||||
glv_drawable_draw_image (GLVideoDrawable * drawable, GLVideoImageType type,
|
||||
void *data, int width, int height)
|
||||
|
@ -315,62 +547,16 @@ glv_drawable_draw_image (GLVideoDrawable * drawable, GLVideoImageType type,
|
|||
glLoadIdentity ();
|
||||
|
||||
glDisable (GL_CULL_FACE);
|
||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glColor4f (1, 1, 1, 1);
|
||||
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, 1);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
|
||||
switch (type) {
|
||||
case GLVIDEO_IMAGE_TYPE_RGBx:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_BGRx:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, width, height,
|
||||
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_YUY2:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
|
||||
break;
|
||||
case GLVIDEO_IMAGE_TYPE_UYVY:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
|
||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
if (drawable->display->have_texture_rectangle) {
|
||||
draw_rect_texture (drawable, type, data, width, height);
|
||||
} else {
|
||||
draw_pow2_texture (drawable, type, data, width, height);
|
||||
}
|
||||
|
||||
glColor4f (1, 0, 1, 1);
|
||||
glBegin (GL_QUADS);
|
||||
|
||||
glNormal3f (0, 0, -1);
|
||||
|
||||
glTexCoord2f (width, 0);
|
||||
glVertex3f (1.0, 1.0, 0);
|
||||
glTexCoord2f (0, 0);
|
||||
glVertex3f (-1.0, 1.0, 0);
|
||||
glTexCoord2f (0, height);
|
||||
glVertex3f (-1.0, -1.0, 0);
|
||||
glTexCoord2f (width, height);
|
||||
glVertex3f (1.0, -1.0, 0);
|
||||
glEnd ();
|
||||
|
||||
glFlush ();
|
||||
glXSwapBuffers (drawable->display->display, drawable->window);
|
||||
|
||||
|
|
|
@ -12,8 +12,11 @@ typedef struct _GLVideoDrawable GLVideoDrawable;
|
|||
typedef enum {
|
||||
GLVIDEO_IMAGE_TYPE_RGBx,
|
||||
GLVIDEO_IMAGE_TYPE_BGRx,
|
||||
GLVIDEO_IMAGE_TYPE_xRGB,
|
||||
GLVIDEO_IMAGE_TYPE_xBGR,
|
||||
GLVIDEO_IMAGE_TYPE_YUY2,
|
||||
GLVIDEO_IMAGE_TYPE_UYVY,
|
||||
GLVIDEO_IMAGE_TYPE_AYUV,
|
||||
} GLVideoImageType;
|
||||
|
||||
|
||||
|
@ -30,6 +33,8 @@ struct _GLVideoDisplay {
|
|||
int max_texture_size;
|
||||
|
||||
gboolean have_ycbcr_texture;
|
||||
gboolean have_texture_rectangle;
|
||||
gboolean have_color_matrix;
|
||||
};
|
||||
|
||||
struct _GLVideoDrawable {
|
||||
|
@ -45,6 +50,8 @@ struct _GLVideoDrawable {
|
|||
|
||||
|
||||
GLVideoDisplay *glv_display_new (const char *display_name);
|
||||
gboolean glv_display_can_handle_type (GLVideoDisplay *display,
|
||||
GLVideoImageType type);
|
||||
void glv_display_free (GLVideoDisplay *display);
|
||||
|
||||
/* drawable */
|
||||
|
|
|
@ -208,6 +208,14 @@ gst_video_rgb32_masks_to_format (int red_mask, int green_mask, int blue_mask)
|
|||
blue_mask == 0xff000000) {
|
||||
return GST_VIDEO_FORMAT_BGRx;
|
||||
}
|
||||
if (red_mask == 0x00ff0000 && green_mask == 0x0000ff00 &&
|
||||
blue_mask == 0x000000ff) {
|
||||
return GST_VIDEO_FORMAT_xRGB;
|
||||
}
|
||||
if (red_mask == 0x000000ff && green_mask == 0x0000ff00 &&
|
||||
blue_mask == 0x00ff0000) {
|
||||
return GST_VIDEO_FORMAT_xBGR;
|
||||
}
|
||||
|
||||
return GST_VIDEO_FORMAT_UNKNOWN;
|
||||
}
|
||||
|
@ -224,6 +232,8 @@ gst_video_format_is_rgb (GstVideoFormat format)
|
|||
return FALSE;
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -242,6 +252,8 @@ gst_video_format_is_yuv (GstVideoFormat format)
|
|||
return TRUE;
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return FALSE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -261,6 +273,8 @@ gst_video_format_has_alpha (GstVideoFormat format)
|
|||
return TRUE;
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return FALSE;
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -285,6 +299,8 @@ gst_video_format_get_row_stride (GstVideoFormat format, int component,
|
|||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return width * 4;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -308,6 +324,8 @@ gst_video_format_get_pixel_stride (GstVideoFormat format, int component)
|
|||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -331,6 +349,8 @@ gst_video_format_get_component_width (GstVideoFormat format, int component,
|
|||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return width;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -354,6 +374,8 @@ gst_video_format_get_component_height (GstVideoFormat format, int component,
|
|||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return height;
|
||||
default:
|
||||
return 0;
|
||||
|
@ -425,6 +447,26 @@ gst_video_format_get_component_offset (GstVideoFormat format, int component,
|
|||
if (component == 3)
|
||||
return 3;
|
||||
return 0;
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
if (component == 0)
|
||||
return 1;
|
||||
if (component == 1)
|
||||
return 2;
|
||||
if (component == 2)
|
||||
return 3;
|
||||
if (component == 3)
|
||||
return 0;
|
||||
return 0;
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
if (component == 0)
|
||||
return 3;
|
||||
if (component == 1)
|
||||
return 2;
|
||||
if (component == 2)
|
||||
return 1;
|
||||
if (component == 3)
|
||||
return 0;
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
@ -448,6 +490,8 @@ gst_video_format_get_size (GstVideoFormat format, int width, int height)
|
|||
case GST_VIDEO_FORMAT_AYUV:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
return width * 4 * height;
|
||||
default:
|
||||
return 0;
|
||||
|
|
|
@ -13,7 +13,9 @@ typedef enum {
|
|||
GST_VIDEO_FORMAT_UYVY,
|
||||
GST_VIDEO_FORMAT_AYUV,
|
||||
GST_VIDEO_FORMAT_RGBx,
|
||||
GST_VIDEO_FORMAT_BGRx
|
||||
GST_VIDEO_FORMAT_BGRx,
|
||||
GST_VIDEO_FORMAT_xRGB,
|
||||
GST_VIDEO_FORMAT_xBGR
|
||||
} GstVideoFormat;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue