mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
[061/906] First SVN commit. This commit is a hack to make git-rebase work
This commit is contained in:
parent
01d6f2818c
commit
98e2942fed
9 changed files with 2 additions and 2138 deletions
|
@ -2,17 +2,13 @@
|
||||||
lib_LTLIBRARIES = libgstgl-@GST_MAJORMINOR@.la
|
lib_LTLIBRARIES = libgstgl-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
libgstgl_@GST_MAJORMINOR@_la_SOURCES = \
|
libgstgl_@GST_MAJORMINOR@_la_SOURCES = \
|
||||||
glextensions.c \
|
|
||||||
gstglbuffer.c \
|
|
||||||
gstgldisplay.c \
|
gstgldisplay.c \
|
||||||
gstglfilter.c
|
gstglbuffer.c
|
||||||
|
|
||||||
libgstgl_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/gl
|
libgstgl_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/gl
|
||||||
libgstgl_@GST_MAJORMINOR@include_HEADERS = \
|
libgstgl_@GST_MAJORMINOR@include_HEADERS = \
|
||||||
glextensions.h \
|
|
||||||
gstglbuffer.h \
|
|
||||||
gstgldisplay.h \
|
gstgldisplay.h \
|
||||||
gstglfilter.h
|
gstglbuffer.h
|
||||||
|
|
||||||
libgstgl_@GST_MAJORMINOR@_la_LIBADD = \
|
libgstgl_@GST_MAJORMINOR@_la_LIBADD = \
|
||||||
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
|
$(GST_PLUGINS_BASE_LIBS) -lgstvideo-$(GST_MAJORMINOR) \
|
||||||
|
|
|
@ -1,190 +0,0 @@
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <GL/glx.h>
|
|
||||||
#include <GL/glxext.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "glextensions.h"
|
|
||||||
|
|
||||||
int
|
|
||||||
gl_have_extension (const char *name)
|
|
||||||
{
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
s = (const char *) glGetString (GL_EXTENSIONS);
|
|
||||||
if (s == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (strstr (s, name))
|
|
||||||
return TRUE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
|
|
||||||
|
|
||||||
#define DEFINE_FUNC_RET(name,return_type,prototype,args) \
|
|
||||||
return_type name prototype \
|
|
||||||
{ \
|
|
||||||
static return_type (*func) prototype; \
|
|
||||||
if (func == NULL) { \
|
|
||||||
func = (void *) glXGetProcAddressARB ((unsigned char *) #name); \
|
|
||||||
} \
|
|
||||||
return func args; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define DEFINE_FUNC(name,prototype,args) \
|
|
||||||
void name prototype \
|
|
||||||
{ \
|
|
||||||
static void (*func) prototype; \
|
|
||||||
if (func == NULL) { \
|
|
||||||
func = (void *) glXGetProcAddressARB ((unsigned char *) #name); \
|
|
||||||
} \
|
|
||||||
func args; \
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glCreateShaderObjectARB, GLhandleARB,
|
|
||||||
(GLenum shaderType), (shaderType));
|
|
||||||
#if 0
|
|
||||||
typedef GLhandleARB type_glCreateShaderObjectARB (GLenum shaderType);
|
|
||||||
|
|
||||||
GLhandleARB
|
|
||||||
glCreateShaderObjectARB (GLenum shaderType)
|
|
||||||
{
|
|
||||||
type_glCreateShaderObjectARB *func;
|
|
||||||
|
|
||||||
if (func == NULL) {
|
|
||||||
func = (type_glCreateShaderObjectARB *)
|
|
||||||
glXGetProcAddress ((unsigned char *) "glCreateShaderObjectARB");
|
|
||||||
}
|
|
||||||
return (*func) (shaderType);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DEFINE_FUNC (glShaderSourceARB,
|
|
||||||
(GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string,
|
|
||||||
const GLint * length), (shaderObj, count, string, length));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glUniform2fARB,
|
|
||||||
(GLint location, GLfloat val1, GLfloat val2), (location, val1, val2));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glGetUniformLocationARB, GLint,
|
|
||||||
(GLhandleARB programObj, const GLcharARB * name), (programObj, name));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glUniform1iARB, (GLint location, GLint val), (location, val));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glGetObjectParameterivARB, (GLhandleARB object, GLenum pname,
|
|
||||||
GLint * params), (object, pname, params));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glCompileShaderARB, (GLhandleARB shader), (shader));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glGetInfoLogARB, (GLhandleARB object, GLsizei maxLength,
|
|
||||||
GLsizei * length, GLcharARB * infoLog), (object, maxLength, length,
|
|
||||||
infoLog));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glCreateProgramObjectARB, GLhandleARB, (void), ());
|
|
||||||
|
|
||||||
DEFINE_FUNC (glAttachObjectARB, (GLhandleARB program, GLhandleARB shader),
|
|
||||||
(program, shader));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glLinkProgramARB, (GLhandleARB program), (program));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glUseProgramObjectARB, (GLhandleARB program), (program));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glPixelDataRangeNV, (GLenum target, GLsizei length, void *pointer),
|
|
||||||
(target, length, pointer));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glXGetSyncValuesOML, Bool,
|
|
||||||
(Display * display, GLXDrawable drawable, int64_t * ust, int64_t * msc,
|
|
||||||
int64_t * sbc), (display, drawable, ust, msc, sbc));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glXGetMscRateOML, Bool,
|
|
||||||
(Display * display, GLXDrawable drawable, int32_t * numerator,
|
|
||||||
int32_t * denominator), (display, drawable, numerator, denominator));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glXSwapBuffersMscOML, int64_t,
|
|
||||||
(Display * display, GLXDrawable drawable, int64_t target_msc,
|
|
||||||
int64_t divisor, int64_t remainder), (display, drawable, target_msc,
|
|
||||||
divisor, remainder));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glXWaitForMscOML, Bool,
|
|
||||||
(Display * display, GLXDrawable drawable, int64_t target_msc,
|
|
||||||
int64_t divisor, int64_t remainder, int64_t * ust, int64_t * msc,
|
|
||||||
int64_t * sbc), (display, drawable, target_msc, divisor, remainder, ust,
|
|
||||||
msc, sbc));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glXWaitForSbcOML, Bool,
|
|
||||||
(Display * display, GLXDrawable drawable, int64_t target_sbc, int64_t * ust,
|
|
||||||
int64_t * msc, int64_t * sbc), (display, drawable, target_sbc, ust, msc,
|
|
||||||
sbc));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glXSwapIntervalSGI, int, (int interval), (interval));
|
|
||||||
|
|
||||||
DEFINE_FUNC_RET (glXSwapIntervalMESA, int, (unsigned int interval), (interval));
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
DEFINE_FUNC (glBindFramebufferEXT, (int target, uint framebuffer),
|
|
||||||
(target, framebuffer));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glDeleteRenderbuffersEXT, (int n, unsigned int *renderbuffers),
|
|
||||||
(n, renderbuffers));
|
|
||||||
DEFINE_FUNC (glGenRenderbuffersEXT, (int n, unsigned int *renderbuffers),
|
|
||||||
(n, renderbuffers));
|
|
||||||
DEFINE_FUNC (glRenderbufferStorageEXT, (int target, int internalformat,
|
|
||||||
int width, int height), (target, internalformat, width, height));
|
|
||||||
DEFINE_FUNC (glBindRenderbufferEXT, (int target, unsigned int renderbuffer),
|
|
||||||
(target, renderbuffer));
|
|
||||||
DEFINE_FUNC (glFramebufferRenderbufferEXT,
|
|
||||||
(int target, int attachment, int renderbuffertarget,
|
|
||||||
unsigned int renderbuffer), (target, attachment, renderbuffertarget,
|
|
||||||
renderbuffer));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* EXT_framebuffer_object */
|
|
||||||
DEFINE_FUNC_RET (glIsRenderbufferEXT, Bool,
|
|
||||||
(GLuint renderbuffer), (renderbuffer));
|
|
||||||
DEFINE_FUNC (glBindRenderbufferEXT,
|
|
||||||
(GLenum target, GLuint renderbuffer), (target, renderbuffer));
|
|
||||||
DEFINE_FUNC (glDeleteRenderbuffersEXT,
|
|
||||||
(GLsizei n, GLuint * renderbuffers), (n, renderbuffers));
|
|
||||||
DEFINE_FUNC (glGenRenderbuffersEXT,
|
|
||||||
(GLsizei n, GLuint * renderbuffers), (n, renderbuffers));
|
|
||||||
DEFINE_FUNC (glRenderbufferStorageEXT,
|
|
||||||
(GLenum target, GLenum internalformat, GLsizei width, GLsizei height),
|
|
||||||
(target, internalformat, width, height));
|
|
||||||
DEFINE_FUNC (glGetRenderbufferParameterivEXT,
|
|
||||||
(GLenum target, GLenum pname, GLint * params), (target, pname, params));
|
|
||||||
DEFINE_FUNC_RET (glIsFramebufferEXT, Bool, (GLuint framebuffer), (framebuffer));
|
|
||||||
DEFINE_FUNC (glBindFramebufferEXT,
|
|
||||||
(GLenum target, GLuint framebuffer), (target, framebuffer));
|
|
||||||
DEFINE_FUNC (glDeleteFramebuffersEXT,
|
|
||||||
(GLsizei n, GLuint * framebuffers), (n, framebuffers));
|
|
||||||
DEFINE_FUNC (glGenFramebuffersEXT,
|
|
||||||
(GLsizei n, GLuint * framebuffers), (n, framebuffers));
|
|
||||||
DEFINE_FUNC_RET (glCheckFramebufferStatusEXT, GLenum,
|
|
||||||
(GLenum target), (target));
|
|
||||||
DEFINE_FUNC (glFramebufferTexture1DEXT,
|
|
||||||
(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
|
|
||||||
GLint level), (target, attachment, textarget, texture, level));
|
|
||||||
DEFINE_FUNC (glFramebufferTexture2DEXT, (GLenum target, GLenum attachment,
|
|
||||||
GLenum textarget, GLuint texture, GLint level), (target, attachment,
|
|
||||||
textarget, texture, level));
|
|
||||||
DEFINE_FUNC (glFramebufferTexture3DEXT, (GLenum target, GLenum attachment,
|
|
||||||
GLenum textarget, GLuint texture, GLint level, GLint zoffset), (target,
|
|
||||||
attachment, textarget, texture, level, zoffset));
|
|
||||||
DEFINE_FUNC (glFramebufferRenderbufferEXT, (GLenum target, GLenum attachment,
|
|
||||||
GLenum renderbuffertarget, GLuint renderbuffer), (target, attachment,
|
|
||||||
renderbuffertarget, renderbuffer));
|
|
||||||
DEFINE_FUNC (glGetFramebufferAttachmentParameterivEXT, (GLenum target,
|
|
||||||
GLenum pname, GLint * params), (target, pname, params));
|
|
||||||
DEFINE_FUNC (glGenerateMipmapEXT, (GLenum target), (target));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glWindowPos2iARB, (GLint x, GLint y), (x, y));
|
|
||||||
|
|
||||||
DEFINE_FUNC (glGenProgramsARB, (GLsizei a, GLuint * b), (a, b));
|
|
||||||
DEFINE_FUNC (glBindProgramARB, (GLenum a, GLuint b), (a, b));
|
|
||||||
DEFINE_FUNC (glProgramStringARB,
|
|
||||||
(GLenum a, GLenum b, GLsizei c, const GLvoid * d), (a, b, c, d));
|
|
|
@ -1,64 +0,0 @@
|
||||||
#ifndef __GST_GLEXTENSIONS_H__
|
|
||||||
#define __GST_GLEXTENSIONS_H__
|
|
||||||
|
|
||||||
#include <GL/gl.h>
|
|
||||||
//#include <glib.h>
|
|
||||||
|
|
||||||
int gl_have_extension (const char *name);
|
|
||||||
|
|
||||||
GLhandleARB glCreateShaderObjectARB (GLenum shaderType);
|
|
||||||
void glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint *length);
|
|
||||||
void glUniform2fARB (GLint location, GLfloat val1, GLfloat val2);
|
|
||||||
GLint glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name);
|
|
||||||
void glUniform1iARB (GLint location, GLint val);
|
|
||||||
void glCompileShaderARB (GLhandleARB shader);
|
|
||||||
void glGetObjectParameterivARB (GLhandleARB object, GLenum pname, GLint *params);
|
|
||||||
void glGetInfoLogARB (GLhandleARB object, GLsizei maxLength, GLsizei *length,
|
|
||||||
GLcharARB *infoLog);
|
|
||||||
GLhandleARB glCreateProgramObjectARB (void);
|
|
||||||
void glAttachObjectARB (GLhandleARB program, GLhandleARB shader);
|
|
||||||
void glLinkProgramARB (GLhandleARB program);
|
|
||||||
void glUseProgramObjectARB (GLhandleARB program);
|
|
||||||
void glPixelDataRangeNV(GLenum target, GLsizei length, void *pointer);
|
|
||||||
void glActiveTexture(GLenum target);
|
|
||||||
Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *);
|
|
||||||
Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *);
|
|
||||||
int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t);
|
|
||||||
Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *);
|
|
||||||
Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *);
|
|
||||||
int glXSwapIntervalSGI (int);
|
|
||||||
int glXSwapIntervalMESA (unsigned int);
|
|
||||||
|
|
||||||
/* EXT_framebuffer_object */
|
|
||||||
Bool glIsRenderbufferEXT (GLuint renderbuffer);
|
|
||||||
void glBindRenderbufferEXT (GLenum target, GLuint renderbuffer);
|
|
||||||
void glDeleteRenderbuffersEXT (GLsizei n, GLuint *renderbuffers);
|
|
||||||
void glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers);
|
|
||||||
void glRenderbufferStorageEXT (GLenum target, GLenum internalformat,
|
|
||||||
GLsizei width, GLsizei height);
|
|
||||||
void glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params);
|
|
||||||
Bool glIsFramebufferEXT (GLuint framebuffer);
|
|
||||||
void glBindFramebufferEXT (GLenum target, GLuint framebuffer);
|
|
||||||
void glDeleteFramebuffersEXT (GLsizei n, GLuint *framebuffers);
|
|
||||||
void glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers);
|
|
||||||
GLenum glCheckFramebufferStatusEXT (GLenum target);
|
|
||||||
void glFramebufferTexture1DEXT (GLenum target, GLenum attachment,
|
|
||||||
GLenum textarget, GLuint texture, GLint level);
|
|
||||||
void glFramebufferTexture2DEXT (GLenum target, GLenum attachment,
|
|
||||||
GLenum textarget, GLuint texture, GLint level);
|
|
||||||
void glFramebufferTexture3DEXT (GLenum target, GLenum attachment,
|
|
||||||
GLenum textarget, GLuint texture, GLint level, GLint zoffset);
|
|
||||||
void glFramebufferRenderbufferEXT (GLenum target, GLenum attachment,
|
|
||||||
GLenum renderbuffertarget, GLuint renderbuffer);
|
|
||||||
void glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum pname,
|
|
||||||
GLint *params);
|
|
||||||
void glGenerateMipmapEXT (GLenum target);
|
|
||||||
|
|
||||||
void glWindowPos2iARB (GLint x, GLint y);
|
|
||||||
|
|
||||||
void glGenProgramsARB (GLsizei, GLuint *);
|
|
||||||
void glBindProgramARB (GLenum, GLuint);
|
|
||||||
void glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,454 +0,0 @@
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <gstglbuffer.h>
|
|
||||||
#include <gstgldisplay.h>
|
|
||||||
#include <GL/glext.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include "glextensions.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static GObjectClass *gst_gl_buffer_parent_class;
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_buffer_finalize (GstGLBuffer * buffer)
|
|
||||||
{
|
|
||||||
gst_gl_display_lock (buffer->display);
|
|
||||||
|
|
||||||
glDeleteTextures (1, &buffer->texture);
|
|
||||||
if (buffer->texture_u) {
|
|
||||||
glDeleteTextures (1, &buffer->texture_u);
|
|
||||||
}
|
|
||||||
if (buffer->texture_v) {
|
|
||||||
glDeleteTextures (1, &buffer->texture_v);
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_gl_display_unlock (buffer->display);
|
|
||||||
g_object_unref (buffer->display);
|
|
||||||
|
|
||||||
GST_MINI_OBJECT_CLASS (gst_gl_buffer_parent_class)->
|
|
||||||
finalize (GST_MINI_OBJECT (buffer));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_buffer_init (GstGLBuffer * buffer, gpointer g_class)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_buffer_class_init (gpointer g_class, gpointer class_data)
|
|
||||||
{
|
|
||||||
GstMiniObjectClass *mini_object_class = GST_MINI_OBJECT_CLASS (g_class);
|
|
||||||
|
|
||||||
gst_gl_buffer_parent_class = g_type_class_peek_parent (g_class);
|
|
||||||
|
|
||||||
mini_object_class->finalize = (GstMiniObjectFinalizeFunction)
|
|
||||||
gst_gl_buffer_finalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GType
|
|
||||||
gst_gl_buffer_get_type (void)
|
|
||||||
{
|
|
||||||
static GType _gst_gl_buffer_type;
|
|
||||||
|
|
||||||
if (G_UNLIKELY (_gst_gl_buffer_type == 0)) {
|
|
||||||
static const GTypeInfo info = {
|
|
||||||
sizeof (GstBufferClass),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
gst_gl_buffer_class_init,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
sizeof (GstGLBuffer),
|
|
||||||
0,
|
|
||||||
(GInstanceInitFunc) gst_gl_buffer_init,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
_gst_gl_buffer_type = g_type_register_static (GST_TYPE_BUFFER,
|
|
||||||
"GstGLBuffer", &info, 0);
|
|
||||||
}
|
|
||||||
return _gst_gl_buffer_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GstGLBuffer *
|
|
||||||
gst_gl_buffer_new (GstGLDisplay * display, int width, int height)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (display != NULL, NULL);
|
|
||||||
g_return_val_if_fail (width > 0, NULL);
|
|
||||||
g_return_val_if_fail (height > 0, NULL);
|
|
||||||
|
|
||||||
return gst_gl_buffer_new_with_format (display, GST_GL_BUFFER_FORMAT_RGBA,
|
|
||||||
width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
GstGLBuffer *
|
|
||||||
gst_gl_buffer_new_with_format (GstGLDisplay * display,
|
|
||||||
GstGLBufferFormat format, int width, int height)
|
|
||||||
{
|
|
||||||
GstGLBuffer *buffer;
|
|
||||||
|
|
||||||
g_return_val_if_fail (format != GST_GL_BUFFER_FORMAT_UNKNOWN, NULL);
|
|
||||||
g_return_val_if_fail (display != NULL, NULL);
|
|
||||||
g_return_val_if_fail (width > 0, NULL);
|
|
||||||
g_return_val_if_fail (height > 0, NULL);
|
|
||||||
|
|
||||||
buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER);
|
|
||||||
|
|
||||||
buffer->display = g_object_ref (display);
|
|
||||||
buffer->width = width;
|
|
||||||
buffer->height = height;
|
|
||||||
buffer->format = format;
|
|
||||||
GST_BUFFER_SIZE (buffer) = gst_gl_buffer_format_get_size (format, width,
|
|
||||||
height);
|
|
||||||
|
|
||||||
gst_gl_display_lock (buffer->display);
|
|
||||||
glGenTextures (1, &buffer->texture);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture);
|
|
||||||
switch (format) {
|
|
||||||
case GST_GL_BUFFER_FORMAT_RGBA:
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
|
|
||||||
buffer->width, buffer->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
break;
|
|
||||||
case GST_GL_BUFFER_FORMAT_RGB:
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
|
|
||||||
buffer->width, buffer->height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
break;
|
|
||||||
case GST_GL_BUFFER_FORMAT_YUYV:
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA,
|
|
||||||
buffer->width, buffer->height,
|
|
||||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, NULL);
|
|
||||||
break;
|
|
||||||
case GST_GL_BUFFER_FORMAT_PLANAR444:
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
buffer->width, buffer->height,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
|
|
||||||
glGenTextures (1, &buffer->texture_u);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_u);
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
buffer->width, buffer->height,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
|
|
||||||
glGenTextures (1, &buffer->texture_v);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_v);
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
buffer->width, buffer->height,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
break;
|
|
||||||
case GST_GL_BUFFER_FORMAT_PLANAR422:
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
buffer->width, buffer->height,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
|
|
||||||
glGenTextures (1, &buffer->texture_u);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_u);
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2, buffer->height,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
|
|
||||||
glGenTextures (1, &buffer->texture_v);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_v);
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2, buffer->height,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
break;
|
|
||||||
case GST_GL_BUFFER_FORMAT_PLANAR420:
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
buffer->width, buffer->height,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
|
|
||||||
glGenTextures (1, &buffer->texture_u);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_u);
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2,
|
|
||||||
GST_ROUND_UP_2 (buffer->height) / 2,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
|
|
||||||
glGenTextures (1, &buffer->texture_v);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_v);
|
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2,
|
|
||||||
GST_ROUND_UP_2 (buffer->height) / 2,
|
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_warning ("GL buffer format not handled");
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_gl_display_unlock (buffer->display);
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
GstGLBuffer *
|
|
||||||
gst_gl_buffer_new_from_video_format (GstGLDisplay * display,
|
|
||||||
GstVideoFormat video_format, int width, int height)
|
|
||||||
{
|
|
||||||
GstGLBuffer *buffer;
|
|
||||||
|
|
||||||
g_return_val_if_fail (width > 0, NULL);
|
|
||||||
g_return_val_if_fail (height > 0, NULL);
|
|
||||||
|
|
||||||
buffer = gst_gl_buffer_new_with_format (display,
|
|
||||||
gst_gl_buffer_format_from_video_format (video_format), width, height);
|
|
||||||
|
|
||||||
switch (video_format) {
|
|
||||||
case GST_VIDEO_FORMAT_RGBx:
|
|
||||||
case GST_VIDEO_FORMAT_BGRx:
|
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
|
||||||
buffer->is_yuv = FALSE;
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
|
||||||
/* counterintuitive: when you use a GL_YCBCR_MESA texture, the
|
|
||||||
* colorspace is automatically converted, so it's referred to
|
|
||||||
* as RGB */
|
|
||||||
buffer->is_yuv = FALSE;
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
|
||||||
case GST_VIDEO_FORMAT_I420:
|
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
|
||||||
buffer->is_yuv = TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_buffer_upload (GstGLBuffer * buffer, GstVideoFormat video_format,
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
int width = buffer->width;
|
|
||||||
int height = buffer->height;
|
|
||||||
|
|
||||||
GST_DEBUG ("uploading %p %dx%d", data, width, height);
|
|
||||||
|
|
||||||
g_return_if_fail (buffer->format ==
|
|
||||||
gst_gl_buffer_format_from_video_format (video_format));
|
|
||||||
|
|
||||||
gst_gl_display_lock (buffer->display);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture);
|
|
||||||
|
|
||||||
switch (video_format) {
|
|
||||||
case GST_VIDEO_FORMAT_RGBx:
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
|
||||||
GL_RGBA, GL_UNSIGNED_BYTE, data);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_BGRx:
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
|
||||||
GL_BGRA, GL_UNSIGNED_BYTE, data);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
|
||||||
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, data);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
|
||||||
GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, data);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
|
||||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_REV_MESA, data);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
|
||||||
GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, data);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_I420:
|
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0, width, height,
|
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_u);
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2,
|
|
||||||
GST_ROUND_UP_2 (buffer->height) / 2,
|
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
(guint8 *) data +
|
|
||||||
gst_video_format_get_component_offset (video_format, 1, width,
|
|
||||||
height));
|
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, buffer->texture_v);
|
|
||||||
glTexSubImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, 0, 0,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2,
|
|
||||||
GST_ROUND_UP_2 (buffer->height) / 2,
|
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
(guint8 *) data +
|
|
||||||
gst_video_format_get_component_offset (video_format, 2, width,
|
|
||||||
height));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_gl_display_unlock (buffer->display);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_buffer_download (GstGLBuffer * buffer, GstVideoFormat video_format,
|
|
||||||
void *data)
|
|
||||||
{
|
|
||||||
GLuint fbo;
|
|
||||||
|
|
||||||
g_return_if_fail (buffer->format ==
|
|
||||||
gst_gl_buffer_format_from_video_format (video_format));
|
|
||||||
|
|
||||||
GST_DEBUG ("downloading");
|
|
||||||
|
|
||||||
gst_gl_display_lock (buffer->display);
|
|
||||||
|
|
||||||
/* we need a reset function */
|
|
||||||
glMatrixMode (GL_COLOR);
|
|
||||||
glLoadIdentity ();
|
|
||||||
glPixelTransferf (GL_POST_COLOR_MATRIX_RED_BIAS, 0);
|
|
||||||
glPixelTransferf (GL_POST_COLOR_MATRIX_GREEN_BIAS, 0);
|
|
||||||
glPixelTransferf (GL_POST_COLOR_MATRIX_BLUE_BIAS, 0);
|
|
||||||
|
|
||||||
glGenFramebuffersEXT (1, &fbo);
|
|
||||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo);
|
|
||||||
|
|
||||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
|
|
||||||
GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB, buffer->texture, 0);
|
|
||||||
|
|
||||||
glDrawBuffer (GL_COLOR_ATTACHMENT1_EXT);
|
|
||||||
glReadBuffer (GL_COLOR_ATTACHMENT1_EXT);
|
|
||||||
|
|
||||||
g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
|
|
||||||
GL_FRAMEBUFFER_COMPLETE_EXT);
|
|
||||||
|
|
||||||
switch (video_format) {
|
|
||||||
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_AYUV:
|
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
|
||||||
glReadPixels (0, 0, buffer->width, buffer->height, GL_BGRA,
|
|
||||||
GL_UNSIGNED_INT_8_8_8_8, data);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
|
||||||
g_warning ("video format not supported for download from GL texture");
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_I420:
|
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
|
||||||
glReadPixels (0, 0, buffer->width, buffer->height,
|
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
|
|
||||||
|
|
||||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
|
|
||||||
GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB,
|
|
||||||
buffer->texture_u, 0);
|
|
||||||
glReadPixels (0, 0,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2,
|
|
||||||
GST_ROUND_UP_2 (buffer->height) / 2,
|
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
(guint8 *) data +
|
|
||||||
gst_video_format_get_component_offset (video_format, 1, buffer->width,
|
|
||||||
buffer->height));
|
|
||||||
|
|
||||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
|
|
||||||
GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB,
|
|
||||||
buffer->texture_v, 0);
|
|
||||||
glReadPixels (0, 0,
|
|
||||||
GST_ROUND_UP_2 (buffer->width) / 2,
|
|
||||||
GST_ROUND_UP_2 (buffer->height) / 2,
|
|
||||||
GL_LUMINANCE, GL_UNSIGNED_BYTE,
|
|
||||||
(guint8 *) data +
|
|
||||||
gst_video_format_get_component_offset (video_format, 2, buffer->width,
|
|
||||||
buffer->height));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
|
|
||||||
glDeleteFramebuffersEXT (1, &fbo);
|
|
||||||
|
|
||||||
gst_gl_display_unlock (buffer->display);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* buffer format */
|
|
||||||
|
|
||||||
GstGLBufferFormat
|
|
||||||
gst_gl_buffer_format_from_video_format (GstVideoFormat format)
|
|
||||||
{
|
|
||||||
switch (format) {
|
|
||||||
case GST_VIDEO_FORMAT_RGBx:
|
|
||||||
case GST_VIDEO_FORMAT_BGRx:
|
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
|
||||||
case GST_VIDEO_FORMAT_BGRA:
|
|
||||||
case GST_VIDEO_FORMAT_ARGB:
|
|
||||||
case GST_VIDEO_FORMAT_ABGR:
|
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
|
||||||
return GST_GL_BUFFER_FORMAT_RGBA;
|
|
||||||
case GST_VIDEO_FORMAT_RGB:
|
|
||||||
case GST_VIDEO_FORMAT_BGR:
|
|
||||||
return GST_GL_BUFFER_FORMAT_RGB;
|
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
|
||||||
return GST_GL_BUFFER_FORMAT_YUYV;
|
|
||||||
case GST_VIDEO_FORMAT_I420:
|
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
|
||||||
return GST_GL_BUFFER_FORMAT_PLANAR420;
|
|
||||||
default:
|
|
||||||
GST_WARNING ("GstVideoFormat %d not implemented", format);
|
|
||||||
/* fall through */
|
|
||||||
case GST_VIDEO_FORMAT_UNKNOWN:
|
|
||||||
return GST_GL_BUFFER_FORMAT_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_return_val_if_reached (GST_GL_BUFFER_FORMAT_UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
gst_gl_buffer_format_get_size (GstGLBufferFormat format, int width, int height)
|
|
||||||
{
|
|
||||||
/* this is not strictly true, but it's used for compatibility with
|
|
||||||
* queue and BaseTransform */
|
|
||||||
return width * height * 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_gl_buffer_format_parse_caps (GstCaps * caps, GstGLBufferFormat * format,
|
|
||||||
int *width, int *height)
|
|
||||||
{
|
|
||||||
GstStructure *structure;
|
|
||||||
int format_as_int;
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (caps, 0);
|
|
||||||
|
|
||||||
if (!gst_structure_has_name (structure, "video/x-raw-gl")) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = gst_structure_get_int (structure, "format", &format_as_int);
|
|
||||||
*format = format_as_int;
|
|
||||||
ret &= gst_structure_get_int (structure, "width", width);
|
|
||||||
ret &= gst_structure_get_int (structure, "height", height);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
|
@ -1,76 +0,0 @@
|
||||||
|
|
||||||
#ifndef _GST_GL_BUFFER_H_
|
|
||||||
#define _GST_GL_BUFFER_H_
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gstgldisplay.h>
|
|
||||||
|
|
||||||
typedef struct _GstGLBuffer GstGLBuffer;
|
|
||||||
|
|
||||||
#define GST_TYPE_GL_BUFFER (gst_gl_buffer_get_type())
|
|
||||||
|
|
||||||
#define GST_IS_GL_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_GL_BUFFER))
|
|
||||||
#define GST_GL_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_GL_BUFFER, GstGLBuffer))
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GST_GL_BUFFER_FORMAT_UNKNOWN,
|
|
||||||
GST_GL_BUFFER_FORMAT_RGBA,
|
|
||||||
GST_GL_BUFFER_FORMAT_RGB,
|
|
||||||
GST_GL_BUFFER_FORMAT_YUYV,
|
|
||||||
GST_GL_BUFFER_FORMAT_PLANAR444,
|
|
||||||
GST_GL_BUFFER_FORMAT_PLANAR422,
|
|
||||||
GST_GL_BUFFER_FORMAT_PLANAR420
|
|
||||||
} GstGLBufferFormat;
|
|
||||||
|
|
||||||
struct _GstGLBuffer {
|
|
||||||
GstBuffer buffer;
|
|
||||||
|
|
||||||
GstGLDisplay *display;
|
|
||||||
|
|
||||||
GstGLBufferFormat format;
|
|
||||||
gboolean is_yuv;
|
|
||||||
|
|
||||||
GLuint texture;
|
|
||||||
GLuint texture_u;
|
|
||||||
GLuint texture_v;
|
|
||||||
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_gl_buffer_get_type (void);
|
|
||||||
|
|
||||||
#define gst_gl_buffer_ref(x) ((GstGLBuffer *)(gst_buffer_ref((GstBuffer *)(x))))
|
|
||||||
#define gst_gl_buffer_unref(x) (gst_buffer_unref((GstBuffer *)(x)))
|
|
||||||
|
|
||||||
GstGLBuffer * gst_gl_buffer_new (GstGLDisplay *display,
|
|
||||||
int width, int height);
|
|
||||||
GstGLBuffer * gst_gl_buffer_new_with_format (GstGLDisplay *display,
|
|
||||||
GstGLBufferFormat format, int width, int height);
|
|
||||||
GstGLBuffer * gst_gl_buffer_new_from_video_format (GstGLDisplay *display,
|
|
||||||
GstVideoFormat format, int width, int height);
|
|
||||||
void gst_gl_buffer_upload (GstGLBuffer *buffer,
|
|
||||||
GstVideoFormat format, void *data);
|
|
||||||
void gst_gl_buffer_download (GstGLBuffer *buffer, GstVideoFormat format,
|
|
||||||
void *data);
|
|
||||||
|
|
||||||
|
|
||||||
#define GST_GL_VIDEO_CAPS \
|
|
||||||
"video/x-raw-gl," \
|
|
||||||
"format=(int)1," \
|
|
||||||
"is_yuv=(boolean)FALSE," \
|
|
||||||
"width=(int)[1,2048]," \
|
|
||||||
"height=(int)[1,2048]," \
|
|
||||||
"pixel-aspect-ratio=(fraction)1/1," \
|
|
||||||
"framerate=(fraction)[0/1,100/1]"
|
|
||||||
|
|
||||||
GstGLBufferFormat gst_gl_buffer_format_from_video_format (GstVideoFormat format);
|
|
||||||
int gst_gl_buffer_format_get_size (GstGLBufferFormat format, int width,
|
|
||||||
int height);
|
|
||||||
gboolean gst_gl_buffer_format_parse_caps (GstCaps *caps, GstGLBufferFormat *format,
|
|
||||||
int *width, int *height);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,875 +0,0 @@
|
||||||
/* gstgldisplay.c
|
|
||||||
* Copyright (C) 2007 David A. Schleef <ds@schleef.org>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gstgldisplay.h"
|
|
||||||
#include "glextensions.h"
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static void gst_gl_display_finalize (GObject * object);
|
|
||||||
static void gst_gl_display_init_tmp_window (GstGLDisplay * display);
|
|
||||||
|
|
||||||
GST_BOILERPLATE (GstGLDisplay, gst_gl_display, GObject, G_TYPE_OBJECT);
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_display_base_init (gpointer g_class)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_display_class_init (GstGLDisplayClass * klass)
|
|
||||||
{
|
|
||||||
G_OBJECT_CLASS (klass)->finalize = gst_gl_display_finalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_display_init (GstGLDisplay * display, GstGLDisplayClass * klass)
|
|
||||||
{
|
|
||||||
|
|
||||||
display->lock = g_mutex_new ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_display_finalize (GObject * object)
|
|
||||||
{
|
|
||||||
GstGLDisplay *display = GST_GL_DISPLAY (object);
|
|
||||||
|
|
||||||
GST_DEBUG ("finalize %p", object);
|
|
||||||
|
|
||||||
if (display->window != None) {
|
|
||||||
XDestroyWindow (display->display, display->window);
|
|
||||||
}
|
|
||||||
if (display->context) {
|
|
||||||
glXDestroyContext (display->display, display->context);
|
|
||||||
}
|
|
||||||
//if (display->visinfo) {
|
|
||||||
// XFree (display->visinfo);
|
|
||||||
//}
|
|
||||||
if (display->display) {
|
|
||||||
XCloseDisplay (display->display);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (display->lock) {
|
|
||||||
g_mutex_free (display->lock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean gst_gl_display_check_features (GstGLDisplay * display);
|
|
||||||
|
|
||||||
GstGLDisplay *
|
|
||||||
gst_gl_display_new (void)
|
|
||||||
{
|
|
||||||
return g_object_new (GST_TYPE_GL_DISPLAY, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
//#define HANDLE_X_ERRORS
|
|
||||||
#ifdef HANDLE_X_ERRORS
|
|
||||||
static int
|
|
||||||
x_error_handler (Display * display, XErrorEvent * event)
|
|
||||||
{
|
|
||||||
g_assert_not_reached ();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_gl_display_connect (GstGLDisplay * display, const char *display_name)
|
|
||||||
{
|
|
||||||
gboolean usable;
|
|
||||||
XGCValues values;
|
|
||||||
XPixmapFormatValues *px_formats;
|
|
||||||
int n_formats;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
display->display = XOpenDisplay (display_name);
|
|
||||||
if (display->display == NULL) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#ifdef HANDLE_X_ERRORS
|
|
||||||
XSynchronize (display->display, True);
|
|
||||||
XSetErrorHandler (x_error_handler);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
usable = gst_gl_display_check_features (display);
|
|
||||||
if (!usable) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
display->screen = DefaultScreenOfDisplay (display->display);
|
|
||||||
display->screen_num = DefaultScreen (display->display);
|
|
||||||
display->visual = DefaultVisual (display->display, display->screen_num);
|
|
||||||
display->root = DefaultRootWindow (display->display);
|
|
||||||
display->white = XWhitePixel (display->display, display->screen_num);
|
|
||||||
display->black = XBlackPixel (display->display, display->screen_num);
|
|
||||||
display->depth = DefaultDepthOfScreen (display->screen);
|
|
||||||
|
|
||||||
display->gc = XCreateGC (display->display,
|
|
||||||
DefaultRootWindow (display->display), 0, &values);
|
|
||||||
|
|
||||||
px_formats = XListPixmapFormats (display->display, &n_formats);
|
|
||||||
for (i = 0; i < n_formats; i++) {
|
|
||||||
GST_DEBUG ("%d: depth %d bpp %d pad %d", i,
|
|
||||||
px_formats[i].depth,
|
|
||||||
px_formats[i].bits_per_pixel, px_formats[i].scanline_pad);
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_gl_display_init_tmp_window (display);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_display_check_features (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
gboolean ret;
|
|
||||||
XVisualInfo *visinfo;
|
|
||||||
Screen *screen;
|
|
||||||
Window root;
|
|
||||||
int scrnum;
|
|
||||||
int attrib[] = { GLX_RGBA, GLX_DOUBLEBUFFER, GLX_RED_SIZE, 8,
|
|
||||||
GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, None
|
|
||||||
};
|
|
||||||
XSetWindowAttributes attr;
|
|
||||||
int error_base;
|
|
||||||
int event_base;
|
|
||||||
int mask;
|
|
||||||
const char *extstring;
|
|
||||||
Window window;
|
|
||||||
|
|
||||||
screen = XDefaultScreenOfDisplay (display->display);
|
|
||||||
scrnum = XScreenNumberOfScreen (screen);
|
|
||||||
root = XRootWindow (display->display, scrnum);
|
|
||||||
|
|
||||||
ret = glXQueryExtension (display->display, &error_base, &event_base);
|
|
||||||
if (!ret) {
|
|
||||||
GST_DEBUG ("No GLX extension");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
visinfo = glXChooseVisual (display->display, scrnum, attrib);
|
|
||||||
if (visinfo == NULL) {
|
|
||||||
GST_DEBUG ("No usable visual");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
display->visinfo = visinfo;
|
|
||||||
|
|
||||||
display->context = glXCreateContext (display->display, visinfo, NULL, True);
|
|
||||||
|
|
||||||
attr.background_pixel = 0;
|
|
||||||
attr.border_pixel = 0;
|
|
||||||
attr.colormap = XCreateColormap (display->display, root,
|
|
||||||
visinfo->visual, AllocNone);
|
|
||||||
attr.event_mask = StructureNotifyMask | ExposureMask;
|
|
||||||
attr.override_redirect = True;
|
|
||||||
|
|
||||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect;
|
|
||||||
|
|
||||||
GST_DEBUG ("creating window with visual %ld", visinfo->visualid);
|
|
||||||
|
|
||||||
window = XCreateWindow (display->display, root, 0, 0,
|
|
||||||
100, 100, 0, visinfo->depth, InputOutput, visinfo->visual, mask, &attr);
|
|
||||||
|
|
||||||
XSync (display->display, FALSE);
|
|
||||||
|
|
||||||
glXMakeCurrent (display->display, window, display->context);
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
#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);
|
|
||||||
XDestroyWindow (display->display, window);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
|
||||||
gst_gl_display_can_handle_type (GstGLDisplay * display, GstVideoFormat type)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case GST_VIDEO_FORMAT_RGBx:
|
|
||||||
case GST_VIDEO_FORMAT_BGRx:
|
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
|
||||||
return TRUE;
|
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
|
||||||
return display->have_ycbcr_texture;
|
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
|
||||||
return display->have_color_matrix;
|
|
||||||
default:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_lock (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
g_assert (display->window != None);
|
|
||||||
g_assert (display->context != NULL);
|
|
||||||
|
|
||||||
g_mutex_lock (display->lock);
|
|
||||||
ret = glXMakeCurrent (display->display, display->window, display->context);
|
|
||||||
if (!ret) {
|
|
||||||
g_warning ("glxMakeCurrent failed");
|
|
||||||
}
|
|
||||||
gst_gl_display_check_error (display, __LINE__);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_unlock (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
gst_gl_display_check_error (display, __LINE__);
|
|
||||||
glXMakeCurrent (display->display, None, NULL);
|
|
||||||
g_mutex_unlock (display->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_display_init_tmp_window (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
XSetWindowAttributes attr = { 0 };
|
|
||||||
int scrnum;
|
|
||||||
int mask;
|
|
||||||
Window root;
|
|
||||||
Window parent_window;
|
|
||||||
Screen *screen;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
|
|
||||||
GST_DEBUG ("creating temp window");
|
|
||||||
|
|
||||||
screen = XDefaultScreenOfDisplay (display->display);
|
|
||||||
scrnum = XScreenNumberOfScreen (screen);
|
|
||||||
root = XRootWindow (display->display, scrnum);
|
|
||||||
|
|
||||||
attr.background_pixel = 0;
|
|
||||||
attr.border_pixel = 0;
|
|
||||||
attr.colormap = XCreateColormap (display->display, root,
|
|
||||||
display->visinfo->visual, AllocNone);
|
|
||||||
if (display->parent_window != None) {
|
|
||||||
XWindowAttributes parent_attr;
|
|
||||||
|
|
||||||
attr.override_redirect = True;
|
|
||||||
parent_window = display->parent_window;
|
|
||||||
|
|
||||||
XGetWindowAttributes (display->display, parent_window, &parent_attr);
|
|
||||||
width = parent_attr.width;
|
|
||||||
height = parent_attr.height;
|
|
||||||
} else {
|
|
||||||
attr.override_redirect = False;
|
|
||||||
parent_window = root;
|
|
||||||
width = 100;
|
|
||||||
height = 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWOverrideRedirect;
|
|
||||||
|
|
||||||
display->window = XCreateWindow (display->display,
|
|
||||||
parent_window, 0, 0, width, height,
|
|
||||||
0, display->visinfo->depth, InputOutput,
|
|
||||||
display->visinfo->visual, mask, &attr);
|
|
||||||
if (display->visible) {
|
|
||||||
XMapWindow (display->display, display->window);
|
|
||||||
}
|
|
||||||
XSync (display->display, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_display_destroy_tmp_window (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
XDestroyWindow (display->display, display->window);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_set_visible (GstGLDisplay * display, gboolean visible)
|
|
||||||
{
|
|
||||||
if (display->visible == visible)
|
|
||||||
return;
|
|
||||||
display->visible = visible;
|
|
||||||
if (display->visible) {
|
|
||||||
XMapWindow (display->display, display->window);
|
|
||||||
} else {
|
|
||||||
XUnmapWindow (display->display, display->window);
|
|
||||||
}
|
|
||||||
XSync (display->display, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_set_window (GstGLDisplay * display, Window window)
|
|
||||||
{
|
|
||||||
g_mutex_lock (display->lock);
|
|
||||||
|
|
||||||
if (display->display == NULL) {
|
|
||||||
display->parent_window = window;
|
|
||||||
} else {
|
|
||||||
if (window != display->parent_window) {
|
|
||||||
XSync (display->display, False);
|
|
||||||
|
|
||||||
gst_gl_display_destroy_tmp_window (display);
|
|
||||||
|
|
||||||
display->parent_window = window;
|
|
||||||
|
|
||||||
gst_gl_display_init_tmp_window (display);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_mutex_unlock (display->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_update_window (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
XWindowAttributes attr;
|
|
||||||
|
|
||||||
g_return_if_fail (display != NULL);
|
|
||||||
|
|
||||||
g_mutex_lock (display->lock);
|
|
||||||
if (display->window != None && display->parent_window != None) {
|
|
||||||
XSync (display->display, False);
|
|
||||||
XGetWindowAttributes (display->display, display->parent_window, &attr);
|
|
||||||
|
|
||||||
GST_DEBUG ("new size %d %d", attr.width, attr.height);
|
|
||||||
|
|
||||||
if (display->win_width != attr.width || display->win_height != attr.height) {
|
|
||||||
XResizeWindow (display->display, display->window,
|
|
||||||
attr.width, attr.height);
|
|
||||||
//XSync (display->display, False);
|
|
||||||
}
|
|
||||||
display->win_width = attr.width;
|
|
||||||
display->win_height = attr.height;
|
|
||||||
}
|
|
||||||
g_mutex_unlock (display->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_update_attributes (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
XWindowAttributes attr;
|
|
||||||
|
|
||||||
if (display->window != None) {
|
|
||||||
XGetWindowAttributes (display->display, display->window, &attr);
|
|
||||||
|
|
||||||
GST_DEBUG ("window visual %ld display visual %ld",
|
|
||||||
attr.visual->visualid, display->visinfo->visual->visualid);
|
|
||||||
|
|
||||||
display->win_width = attr.width;
|
|
||||||
display->win_height = attr.height;
|
|
||||||
} else {
|
|
||||||
display->win_width = 0;
|
|
||||||
display->win_height = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_set_window_size (GstGLDisplay * display, int width, int height)
|
|
||||||
{
|
|
||||||
if (display->win_width != width || display->win_height != height) {
|
|
||||||
display->win_width = width;
|
|
||||||
display->win_height = height;
|
|
||||||
XResizeWindow (display->display, display->window, width, height);
|
|
||||||
XSync (display->display, False);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_clear (GstGLDisplay * display)
|
|
||||||
{
|
|
||||||
gst_gl_display_lock (display);
|
|
||||||
|
|
||||||
glDepthFunc (GL_LESS);
|
|
||||||
glEnable (GL_DEPTH_TEST);
|
|
||||||
glClearColor (0.2, 0.2, 0.2, 1.0);
|
|
||||||
glViewport (0, 0, display->win_width, display->win_height);
|
|
||||||
|
|
||||||
gst_gl_display_unlock (display);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_check_error (GstGLDisplay * display, int line)
|
|
||||||
{
|
|
||||||
GLenum err = glGetError ();
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
GST_ERROR ("GL Error 0x%x at line %d", (int) err, line);
|
|
||||||
g_assert (0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GLuint
|
|
||||||
gst_gl_display_upload_texture_rectangle (GstGLDisplay * display,
|
|
||||||
GstVideoFormat type, void *data, int width, int height)
|
|
||||||
{
|
|
||||||
GLuint texture;
|
|
||||||
|
|
||||||
glGenTextures (1, &texture);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 ();
|
|
||||||
}
|
|
||||||
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
static void
|
|
||||||
draw_rect_texture (GstGLDisplay * display, GstVideoFormat type,
|
|
||||||
void *data, int width, int height)
|
|
||||||
{
|
|
||||||
GLuint texture;
|
|
||||||
|
|
||||||
GST_DEBUG ("using rectangular texture");
|
|
||||||
|
|
||||||
#ifdef GL_TEXTURE_RECTANGLE_ARB
|
|
||||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
|
||||||
|
|
||||||
texture = gst_gl_display_upload_texture_rectangle (display, type,
|
|
||||||
data, width, height);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
switch (type) {
|
|
||||||
case GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 == GST_VIDEO_FORMAT_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
|
|
||||||
#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 ();
|
|
||||||
glDeleteTextures (1, &texture);
|
|
||||||
#else
|
|
||||||
g_assert_not_reached ();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
draw_pow2_texture (GstGLDisplay * display, GstVideoFormat type,
|
|
||||||
void *data, int width, int height)
|
|
||||||
{
|
|
||||||
int pow2_width;
|
|
||||||
int pow2_height;
|
|
||||||
double x, y;
|
|
||||||
GLuint texture;
|
|
||||||
|
|
||||||
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);
|
|
||||||
glGenTextures (1, &texture);
|
|
||||||
glBindTexture (GL_TEXTURE_2D, texture);
|
|
||||||
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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 GST_VIDEO_FORMAT_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 == GST_VIDEO_FORMAT_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 ();
|
|
||||||
glDeleteTextures (1, &texture);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void
|
|
||||||
gst_gl_display_draw_image (GstGLDisplay * display, GstVideoFormat type,
|
|
||||||
void *data, int width, int height)
|
|
||||||
{
|
|
||||||
g_return_if_fail (data != NULL);
|
|
||||||
g_return_if_fail (width > 0);
|
|
||||||
g_return_if_fail (height > 0);
|
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Doesn't work */
|
|
||||||
{
|
|
||||||
int64_t ust = 1234;
|
|
||||||
int64_t mst = 1234;
|
|
||||||
int64_t sbc = 1234;
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
ret = glXGetSyncValuesOML (display->display, display->window,
|
|
||||||
&ust, &mst, &sbc);
|
|
||||||
GST_ERROR ("sync values %d %" G_GINT64_FORMAT " %" G_GINT64_FORMAT
|
|
||||||
" %" G_GINT64_FORMAT, ret, ust, mst, sbc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Does work, but is not relevant */
|
|
||||||
{
|
|
||||||
int32_t num = 1234;
|
|
||||||
int32_t den = 1234;
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
ret = glXGetMscRateOML (display->display, display->window, &num, &den);
|
|
||||||
GST_DEBUG ("rate %d %d %d", ret, num, den);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gst_gl_display_update_attributes (display);
|
|
||||||
|
|
||||||
glXSwapIntervalSGI (1);
|
|
||||||
glViewport (0, 0, display->win_width, display->win_height);
|
|
||||||
|
|
||||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glMatrixMode (GL_MODELVIEW);
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glDisable (GL_CULL_FACE);
|
|
||||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
|
||||||
|
|
||||||
glColor4f (1, 1, 1, 1);
|
|
||||||
|
|
||||||
if (display->have_texture_rectangle) {
|
|
||||||
draw_rect_texture (display, type, data, width, height);
|
|
||||||
} else {
|
|
||||||
draw_pow2_texture (display, type, data, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
glXSwapBuffers (display->display, display->window);
|
|
||||||
#if 0
|
|
||||||
/* Doesn't work */
|
|
||||||
{
|
|
||||||
ret = glXSwapBuffersMscOML (display->display, display->window, 0, 1, 0);
|
|
||||||
if (ret == 0) {
|
|
||||||
GST_DEBUG ("glXSwapBuffersMscOML failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gst_gl_display_unlock (display);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
|
||||||
gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture,
|
|
||||||
int width, int height, gboolean sync)
|
|
||||||
{
|
|
||||||
g_return_if_fail (width > 0);
|
|
||||||
g_return_if_fail (height > 0);
|
|
||||||
g_return_if_fail (texture != None);
|
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
|
||||||
|
|
||||||
g_assert (display->window != None);
|
|
||||||
g_assert (display->context != NULL);
|
|
||||||
|
|
||||||
//gst_gl_display_update_attributes (display);
|
|
||||||
#if 0
|
|
||||||
/* Doesn't work */
|
|
||||||
{
|
|
||||||
int64_t ust = 1234;
|
|
||||||
int64_t mst = 1234;
|
|
||||||
int64_t sbc = 1234;
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
ret = glXGetSyncValuesOML (display->display, display->window,
|
|
||||||
&ust, &mst, &sbc);
|
|
||||||
GST_ERROR ("sync values %d %" G_GINT64_FORMAT " %" G_GINT64_FORMAT
|
|
||||||
" %" G_GINT64_FORMAT, ret, ust, mst, sbc);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (sync) {
|
|
||||||
glXSwapIntervalSGI (1);
|
|
||||||
} else {
|
|
||||||
glXSwapIntervalSGI (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
glViewport (0, 0, display->win_width, display->win_height);
|
|
||||||
|
|
||||||
glClearColor (0.3, 0.3, 0.3, 1.0);
|
|
||||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glMatrixMode (GL_MODELVIEW);
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glDisable (GL_CULL_FACE);
|
|
||||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
|
||||||
|
|
||||||
glColor4f (1, 1, 1, 1);
|
|
||||||
|
|
||||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, texture);
|
|
||||||
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);
|
|
||||||
|
|
||||||
glColor4f (1, 0, 1, 1);
|
|
||||||
gst_gl_display_check_error (display, __LINE__);
|
|
||||||
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 ();
|
|
||||||
gst_gl_display_check_error (display, __LINE__);
|
|
||||||
|
|
||||||
glXSwapBuffers (display->display, display->window);
|
|
||||||
|
|
||||||
gst_gl_display_unlock (display);
|
|
||||||
}
|
|
|
@ -1,85 +0,0 @@
|
||||||
|
|
||||||
#ifndef __GST_GL_H__
|
|
||||||
#define __GST_GL_H__
|
|
||||||
|
|
||||||
#include <GL/glx.h>
|
|
||||||
#include <GL/gl.h>
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
|
|
||||||
typedef struct _GstGLDisplay GstGLDisplay;
|
|
||||||
typedef struct _GstGLDisplayClass GstGLDisplayClass;
|
|
||||||
|
|
||||||
#define GST_TYPE_GL_DISPLAY \
|
|
||||||
(gst_gl_display_get_type())
|
|
||||||
#define GST_GL_DISPLAY(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_DISPLAY,GstGLDisplay))
|
|
||||||
#define GST_GL_DISPLAY_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GL_DISPLAY,GstGLDisplayClass))
|
|
||||||
#define GST_IS_GL_DISPLAY(obj) \
|
|
||||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_DISPLAY))
|
|
||||||
#define GST_IS_GL_DISPLAY_CLASS(klass) \
|
|
||||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GL_DISPLAY))
|
|
||||||
|
|
||||||
|
|
||||||
struct _GstGLDisplay {
|
|
||||||
GObject object;
|
|
||||||
|
|
||||||
Display *display;
|
|
||||||
GC gc;
|
|
||||||
XVisualInfo *visinfo;
|
|
||||||
GLXContext context;
|
|
||||||
GMutex *lock;
|
|
||||||
|
|
||||||
Screen *screen;
|
|
||||||
int screen_num;
|
|
||||||
Visual *visual;
|
|
||||||
Window root;
|
|
||||||
guint32 white;
|
|
||||||
guint32 black;
|
|
||||||
int depth;
|
|
||||||
|
|
||||||
int max_texture_size;
|
|
||||||
|
|
||||||
gboolean have_ycbcr_texture;
|
|
||||||
gboolean have_texture_rectangle;
|
|
||||||
gboolean have_color_matrix;
|
|
||||||
|
|
||||||
Window window;
|
|
||||||
gboolean visible;
|
|
||||||
Window parent_window;
|
|
||||||
|
|
||||||
int win_width;
|
|
||||||
int win_height;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GstGLDisplayClass {
|
|
||||||
GObjectClass object_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_gl_display_get_type (void);
|
|
||||||
|
|
||||||
|
|
||||||
GstGLDisplay *gst_gl_display_new (void);
|
|
||||||
gboolean gst_gl_display_connect (GstGLDisplay *display,
|
|
||||||
const char *display_name);
|
|
||||||
gboolean gst_gl_display_can_handle_type (GstGLDisplay *display,
|
|
||||||
GstVideoFormat type);
|
|
||||||
void gst_gl_display_lock (GstGLDisplay *display);
|
|
||||||
void gst_gl_display_unlock (GstGLDisplay *display);
|
|
||||||
void gst_gl_display_set_window (GstGLDisplay *display, Window window);
|
|
||||||
void gst_gl_display_update_attributes (GstGLDisplay *display);
|
|
||||||
void gst_gl_display_clear (GstGLDisplay *display);
|
|
||||||
void gst_gl_display_draw_texture (GstGLDisplay * display, GLuint texture,
|
|
||||||
int width, int height, gboolean sync);
|
|
||||||
void gst_gl_display_check_error (GstGLDisplay *display, int line);
|
|
||||||
GLuint gst_gl_display_upload_texture_rectangle (GstGLDisplay *display,
|
|
||||||
GstVideoFormat type, void *data, int width, int height);
|
|
||||||
void gst_gl_display_set_visible (GstGLDisplay *display, gboolean visible);
|
|
||||||
void gst_gl_display_set_window_size (GstGLDisplay *display, int width,
|
|
||||||
int height);
|
|
||||||
void gst_gl_display_update_window (GstGLDisplay * display);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,323 +0,0 @@
|
||||||
/*
|
|
||||||
* GStreamer
|
|
||||||
* Copyright (C) 2007 David Schleef <ds@schleef.org>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gstglbuffer.h>
|
|
||||||
#include <gstglfilter.h>
|
|
||||||
#include "glextensions.h"
|
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT gst_gl_filter_debug
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
|
||||||
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_gl_filter_src_pad_template =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
|
||||||
);
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_gl_filter_sink_pad_template =
|
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (GST_GL_VIDEO_CAPS)
|
|
||||||
);
|
|
||||||
|
|
||||||
#define DEBUG_INIT(bla) \
|
|
||||||
GST_DEBUG_CATEGORY_INIT (gst_gl_filter_debug, "glfilter", 0, "glfilter element");
|
|
||||||
|
|
||||||
GST_BOILERPLATE_FULL (GstGLFilter, gst_gl_filter, GstBaseTransform,
|
|
||||||
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
|
||||||
|
|
||||||
static void gst_gl_filter_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec);
|
|
||||||
static void gst_gl_filter_get_property (GObject * object, guint prop_id,
|
|
||||||
GValue * value, GParamSpec * pspec);
|
|
||||||
|
|
||||||
static void gst_gl_filter_reset (GstGLFilter * filter);
|
|
||||||
static gboolean gst_gl_filter_start (GstBaseTransform * bt);
|
|
||||||
static gboolean gst_gl_filter_stop (GstBaseTransform * bt);
|
|
||||||
static gboolean gst_gl_filter_get_unit_size (GstBaseTransform * trans,
|
|
||||||
GstCaps * caps, guint * size);
|
|
||||||
static GstFlowReturn gst_gl_filter_transform (GstBaseTransform * bt,
|
|
||||||
GstBuffer * inbuf, GstBuffer * outbuf);
|
|
||||||
static GstFlowReturn gst_gl_filter_prepare_output_buffer (GstBaseTransform *
|
|
||||||
trans, GstBuffer * input, gint size, GstCaps * caps, GstBuffer ** buf);
|
|
||||||
static gboolean gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
|
||||||
GstCaps * outcaps);
|
|
||||||
static gboolean gst_gl_filter_do_transform (GstGLFilter * filter,
|
|
||||||
GstGLBuffer * inbuf, GstGLBuffer * outbuf);
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_filter_base_init (gpointer klass)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_gl_filter_src_pad_template));
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&gst_gl_filter_sink_pad_template));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_filter_class_init (GstGLFilterClass * klass)
|
|
||||||
{
|
|
||||||
GObjectClass *gobject_class;
|
|
||||||
|
|
||||||
gobject_class = (GObjectClass *) klass;
|
|
||||||
gobject_class->set_property = gst_gl_filter_set_property;
|
|
||||||
gobject_class->get_property = gst_gl_filter_get_property;
|
|
||||||
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->transform = gst_gl_filter_transform;
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->start = gst_gl_filter_start;
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->stop = gst_gl_filter_stop;
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->set_caps = gst_gl_filter_set_caps;
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->get_unit_size = gst_gl_filter_get_unit_size;
|
|
||||||
GST_BASE_TRANSFORM_CLASS (klass)->prepare_output_buffer =
|
|
||||||
gst_gl_filter_prepare_output_buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_filter_init (GstGLFilter * filter, GstGLFilterClass * klass)
|
|
||||||
{
|
|
||||||
//gst_element_create_all_pads (GST_ELEMENT (filter));
|
|
||||||
|
|
||||||
filter->sinkpad = gst_element_get_static_pad (GST_ELEMENT (filter), "sink");
|
|
||||||
filter->srcpad = gst_element_get_static_pad (GST_ELEMENT (filter), "src");
|
|
||||||
|
|
||||||
gst_gl_filter_reset (filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_filter_set_property (GObject * object, guint prop_id,
|
|
||||||
const GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
//GstGLFilter *filter = GST_GL_FILTER (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_filter_get_property (GObject * object, guint prop_id,
|
|
||||||
GValue * value, GParamSpec * pspec)
|
|
||||||
{
|
|
||||||
//GstGLFilter *filter = GST_GL_FILTER (object);
|
|
||||||
|
|
||||||
switch (prop_id) {
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_gl_filter_reset (GstGLFilter * filter)
|
|
||||||
{
|
|
||||||
if (filter->display) {
|
|
||||||
g_object_unref (filter->display);
|
|
||||||
filter->display = NULL;
|
|
||||||
}
|
|
||||||
filter->format = GST_GL_BUFFER_FORMAT_UNKNOWN;
|
|
||||||
filter->width = 0;
|
|
||||||
filter->height = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_filter_start (GstBaseTransform * bt)
|
|
||||||
{
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_filter_stop (GstBaseTransform * bt)
|
|
||||||
{
|
|
||||||
GstGLFilter *filter = GST_GL_FILTER (bt);
|
|
||||||
|
|
||||||
gst_gl_filter_reset (filter);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_filter_get_unit_size (GstBaseTransform * trans, GstCaps * caps,
|
|
||||||
guint * size)
|
|
||||||
{
|
|
||||||
gboolean ret;
|
|
||||||
GstGLBufferFormat format;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
|
|
||||||
ret = gst_gl_buffer_format_parse_caps (caps, &format, &width, &height);
|
|
||||||
if (ret) {
|
|
||||||
*size = gst_gl_buffer_format_get_size (format, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_gl_filter_prepare_output_buffer (GstBaseTransform * trans,
|
|
||||||
GstBuffer * inbuf, gint size, GstCaps * caps, GstBuffer ** buf)
|
|
||||||
{
|
|
||||||
GstGLFilter *filter;
|
|
||||||
GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
|
|
||||||
GstGLBuffer *gl_outbuf;
|
|
||||||
|
|
||||||
filter = GST_GL_FILTER (trans);
|
|
||||||
|
|
||||||
if (filter->display == NULL) {
|
|
||||||
filter->display = gl_inbuf->display;
|
|
||||||
}
|
|
||||||
|
|
||||||
gl_outbuf = gst_gl_buffer_new_with_format (filter->display,
|
|
||||||
filter->format, filter->width, filter->height);
|
|
||||||
|
|
||||||
*buf = GST_BUFFER (gl_outbuf);
|
|
||||||
gst_buffer_set_caps (*buf, caps);
|
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_filter_set_caps (GstBaseTransform * bt, GstCaps * incaps,
|
|
||||||
GstCaps * outcaps)
|
|
||||||
{
|
|
||||||
GstGLFilter *filter;
|
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
filter = GST_GL_FILTER (bt);
|
|
||||||
|
|
||||||
ret = gst_gl_buffer_format_parse_caps (incaps, &filter->format,
|
|
||||||
&filter->width, &filter->height);
|
|
||||||
|
|
||||||
if (!ret) {
|
|
||||||
GST_DEBUG ("bad caps");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_ERROR ("set_caps %d %d", filter->width, filter->height);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstFlowReturn
|
|
||||||
gst_gl_filter_transform (GstBaseTransform * bt, GstBuffer * inbuf,
|
|
||||||
GstBuffer * outbuf)
|
|
||||||
{
|
|
||||||
GstGLFilter *filter;
|
|
||||||
GstGLBuffer *gl_inbuf = GST_GL_BUFFER (inbuf);
|
|
||||||
GstGLBuffer *gl_outbuf = GST_GL_BUFFER (outbuf);
|
|
||||||
|
|
||||||
filter = GST_GL_FILTER (bt);
|
|
||||||
|
|
||||||
gst_gl_filter_do_transform (filter, gl_inbuf, gl_outbuf);
|
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_gl_filter_do_transform (GstGLFilter * filter,
|
|
||||||
GstGLBuffer * inbuf, GstGLBuffer * outbuf)
|
|
||||||
{
|
|
||||||
GstGLDisplay *display = inbuf->display;
|
|
||||||
GstGLFilterClass *filter_class;
|
|
||||||
unsigned int fbo;
|
|
||||||
|
|
||||||
filter_class = GST_GL_FILTER_GET_CLASS (filter);
|
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
|
||||||
|
|
||||||
glGenFramebuffersEXT (1, &fbo);
|
|
||||||
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo);
|
|
||||||
|
|
||||||
glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT,
|
|
||||||
GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, outbuf->texture, 0);
|
|
||||||
|
|
||||||
glDrawBuffer (GL_COLOR_ATTACHMENT0_EXT);
|
|
||||||
glReadBuffer (GL_COLOR_ATTACHMENT0_EXT);
|
|
||||||
|
|
||||||
g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) ==
|
|
||||||
GL_FRAMEBUFFER_COMPLETE_EXT);
|
|
||||||
|
|
||||||
glViewport (0, 0, outbuf->width, outbuf->height);
|
|
||||||
|
|
||||||
glClearColor (0.3, 0.3, 0.3, 1.0);
|
|
||||||
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
|
|
||||||
glMatrixMode (GL_PROJECTION);
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glMatrixMode (GL_MODELVIEW);
|
|
||||||
glLoadIdentity ();
|
|
||||||
|
|
||||||
glDisable (GL_CULL_FACE);
|
|
||||||
glEnableClientState (GL_TEXTURE_COORD_ARRAY);
|
|
||||||
|
|
||||||
glColor4f (1, 1, 1, 1);
|
|
||||||
|
|
||||||
glEnable (GL_TEXTURE_RECTANGLE_ARB);
|
|
||||||
glActiveTexture (GL_TEXTURE0);
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, inbuf->texture);
|
|
||||||
|
|
||||||
filter_class->filter (filter, inbuf, outbuf);
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
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);
|
|
||||||
|
|
||||||
glColor4f (1, 0, 1, 1);
|
|
||||||
glBegin (GL_QUADS);
|
|
||||||
|
|
||||||
glNormal3f (0, 0, -1);
|
|
||||||
|
|
||||||
glTexCoord2f (inbuf->width, 0);
|
|
||||||
glVertex3f (0.9, -0.9, 0);
|
|
||||||
glTexCoord2f (0, 0);
|
|
||||||
glVertex3f (-1.0, -1.0, 0);
|
|
||||||
glTexCoord2f (0, inbuf->height);
|
|
||||||
glVertex3f (-1.0, 1.0, 0);
|
|
||||||
glTexCoord2f (inbuf->width, inbuf->height);
|
|
||||||
glVertex3f (1.0, 1.0, 0);
|
|
||||||
glEnd ();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glFlush ();
|
|
||||||
|
|
||||||
glDeleteFramebuffersEXT (1, &fbo);
|
|
||||||
|
|
||||||
gst_gl_display_unlock (display);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* GStreamer
|
|
||||||
* Copyright (C) 2007 David Schleef <ds@schleef.org>
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Library General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 2 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Library General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Library General Public
|
|
||||||
* License along with this library; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _GST_GL_FILTER_H_
|
|
||||||
#define _GST_GL_FILTER_H_
|
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
#include <gst/video/video.h>
|
|
||||||
#include <gst/base/gstbasetransform.h>
|
|
||||||
#include <gstglbuffer.h>
|
|
||||||
|
|
||||||
#define GST_TYPE_GL_FILTER (gst_gl_filter_get_type())
|
|
||||||
#define GST_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GL_FILTER,GstGLFilter))
|
|
||||||
#define GST_IS_GL_FILTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GL_FILTER))
|
|
||||||
#define GST_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
|
|
||||||
#define GST_IS_GL_FILTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_GL_FILTER))
|
|
||||||
#define GST_GL_FILTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_GL_FILTER,GstGLFilterClass))
|
|
||||||
typedef struct _GstGLFilter GstGLFilter;
|
|
||||||
typedef struct _GstGLFilterClass GstGLFilterClass;
|
|
||||||
|
|
||||||
typedef gboolean (*GstGLFilterProcessFunc) (GstGLFilter *filter,
|
|
||||||
GstGLBuffer *inbuf, GstGLBuffer *outbuf);
|
|
||||||
|
|
||||||
struct _GstGLFilter
|
|
||||||
{
|
|
||||||
GstBaseTransform base_transform;
|
|
||||||
|
|
||||||
GstPad *srcpad;
|
|
||||||
GstPad *sinkpad;
|
|
||||||
|
|
||||||
/* < private > */
|
|
||||||
|
|
||||||
GstGLDisplay *display;
|
|
||||||
GstGLBufferFormat format;
|
|
||||||
int width;
|
|
||||||
int height;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GstGLFilterClass
|
|
||||||
{
|
|
||||||
GstBaseTransformClass base_transform_class;
|
|
||||||
GstGLFilterProcessFunc filter;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType gst_gl_filter_get_type(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in a new issue