2004-01-12 04:15:47 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2003-10-28 18:54:20 +00:00
|
|
|
#include "config.h"
|
2004-01-12 04:15:47 +00:00
|
|
|
#endif
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
/* gcc -ansi -pedantic on GNU/Linux causes warnings and errors
|
|
|
|
* unless this is defined:
|
|
|
|
* warning: #warning "Files using this header must be compiled with _SVID_SOURCE or _XOPEN_SOURCE"
|
|
|
|
*/
|
|
|
|
#ifndef _XOPEN_SOURCE
|
|
|
|
# define _XOPEN_SOURCE 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#define GL_GLEXT_PROTOTYPES
|
|
|
|
|
|
|
|
// VERY dangerous:
|
|
|
|
#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
|
|
|
#include <GL/glx.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#include <GL/glext.h>
|
|
|
|
#include <GL/glu.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gstglsink.h"
|
|
|
|
|
|
|
|
typedef struct _GstGLImageConnection GstGLImageConnection;
|
2004-03-14 22:34:33 +00:00
|
|
|
struct _GstGLImageConnection
|
|
|
|
{
|
2003-10-28 18:54:20 +00:00
|
|
|
GstImageConnection conn;
|
|
|
|
Display *dpy;
|
|
|
|
gint w, h;
|
|
|
|
gint bpp;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
int ytex_id;
|
|
|
|
int uvtex_id;
|
2004-03-14 22:34:33 +00:00
|
|
|
int septex_id;
|
2003-10-28 18:54:20 +00:00
|
|
|
unsigned char *m_memory;
|
|
|
|
int m_bufslots[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TEX_XSIZE 1024
|
|
|
|
#define TEX_YSIZE 1024
|
|
|
|
#define YUVTEX_SIZE ((TEX_XSIZE * TEX_YSIZE) * 3 /2)
|
|
|
|
|
|
|
|
#define AGP_BUFSLOTS 4
|
|
|
|
|
|
|
|
typedef struct _GstNvImage GstNvImage;
|
|
|
|
struct _GstNvImage
|
|
|
|
{
|
|
|
|
GstImageData data;
|
2004-03-15 19:32:27 +00:00
|
|
|
int slot; // < AGP_BUFSLOTS: allocated from AGP mem, otherwise from CPU mem
|
2003-10-28 18:54:20 +00:00
|
|
|
GstGLImageConnection *conn;
|
|
|
|
};
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstGLImageInfo *gst_gl_nvimage_info (GstImageInfo * info);
|
|
|
|
static GstGLImageConnection *gst_gl_nvimage_connection (GstImageConnection *
|
|
|
|
conn);
|
|
|
|
static gboolean gst_gl_nvimage_check_xvideo ();
|
|
|
|
|
|
|
|
static GstCaps *gst_gl_nvimage_get_caps (GstImageInfo * info);
|
|
|
|
static GstImageConnection *gst_gl_nvimage_set_caps (GstImageInfo * info,
|
|
|
|
GstCaps * caps);
|
|
|
|
static GstImageData *gst_gl_nvimage_get_image (GstImageInfo * info,
|
|
|
|
GstImageConnection * conn);
|
|
|
|
static void gst_gl_nvimage_put_image (GstImageInfo * info,
|
|
|
|
GstImageData * image);
|
|
|
|
static void gst_gl_nvimage_free_image (GstImageData * image);
|
|
|
|
static void gst_gl_nvimage_open_conn (GstImageConnection * conn,
|
|
|
|
GstImageInfo * info);
|
|
|
|
static void gst_gl_nvimage_close_conn (GstImageConnection * conn,
|
|
|
|
GstImageInfo * info);
|
|
|
|
static void gst_gl_nvimage_free_conn (GstImageConnection * conn);
|
|
|
|
|
|
|
|
GstImagePlugin *
|
|
|
|
get_gl_nvimage_plugin (void)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
static GstImagePlugin plugin = { gst_gl_nvimage_get_caps,
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gl_nvimage_set_caps,
|
|
|
|
gst_gl_nvimage_get_image,
|
|
|
|
gst_gl_nvimage_put_image,
|
|
|
|
gst_gl_nvimage_free_image
|
|
|
|
};
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
return &plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GstGLImageInfo *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gl_nvimage_info (GstImageInfo * info)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
if (info == NULL || info->id != GST_MAKE_FOURCC ('X', 'l', 'i', 'b')) {
|
2003-10-28 18:54:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return (GstGLImageInfo *) info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstGLImageConnection *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gl_nvimage_connection (GstImageConnection * conn)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
if (conn == NULL || conn->free_conn != gst_gl_nvimage_free_conn)
|
2004-03-14 22:34:33 +00:00
|
|
|
return NULL;
|
2003-10-28 18:54:20 +00:00
|
|
|
return (GstGLImageConnection *) conn;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gst_gl_nvimage_check_xvideo ()
|
|
|
|
{
|
|
|
|
int ver, rel, req, ev, err;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
#if 0
|
2003-10-28 18:54:20 +00:00
|
|
|
if (display == NULL)
|
|
|
|
return FALSE;
|
2004-03-14 22:34:33 +00:00
|
|
|
if (Success == XvQueryExtension (display, &ver, &rel, &req, &ev, &err))
|
2003-10-28 18:54:20 +00:00
|
|
|
return TRUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static GstCaps *
|
|
|
|
gst_gl_nvimage_get_caps (GstImageInfo * info)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
int adaptors;
|
|
|
|
int formats;
|
|
|
|
GstCaps *caps = NULL;
|
|
|
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
/* we don't handle these image information */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (xinfo == NULL)
|
|
|
|
return NULL;
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (gst_gl_nvimage_check_xvideo () == FALSE) {
|
|
|
|
g_warning ("GL_NVImage: Server has no NVidia extension support\n");
|
2003-10-28 18:54:20 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
caps = gst_caps_append (caps, GST_CAPS_NEW ("xvimage_caps",
|
2004-03-15 19:32:27 +00:00
|
|
|
"video/raw",
|
|
|
|
"format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('Y', 'C', '1', '2')),
|
|
|
|
"width", GST_PROPS_INT_RANGE (0, 1024),
|
|
|
|
"height", GST_PROPS_INT_RANGE (0, 1024))
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
2003-10-28 18:54:20 +00:00
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstImageConnection *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gl_nvimage_set_caps (GstImageInfo * info, GstCaps * caps)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
gint i, j = 0;
|
|
|
|
int adaptors;
|
|
|
|
int formats;
|
|
|
|
GstGLImageConnection *conn;
|
|
|
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
|
|
|
guint32 format;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
/* we don't handle these image information */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (xinfo == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
conn = g_new0 (GstGLImageConnection, 1);
|
|
|
|
conn->conn.open_conn = gst_gl_nvimage_open_conn;
|
|
|
|
conn->conn.close_conn = gst_gl_nvimage_close_conn;
|
|
|
|
conn->conn.free_conn = gst_gl_nvimage_free_conn;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_caps_get (caps,
|
|
|
|
"width", &conn->w, "height", &conn->h, "format", &format, NULL);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
// maybe I should a bit more checking here, e.g. maximum size smaller than maximum texture extents
|
2004-03-14 22:34:33 +00:00
|
|
|
if (format != GST_MAKE_FOURCC ('R', 'G', 'B', ' ')) {
|
|
|
|
GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: Format is invalid !\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-03-15 19:32:27 +00:00
|
|
|
if (0) //conn->port == (XvPortID) -1)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
/* this happens if the plugin can't handle the caps, so no warning */
|
|
|
|
g_free (conn);
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
GST_DEBUG (GST_CAT_PLUGIN_INFO, "GL_NVImage: caps %p are ok, creating image",
|
|
|
|
caps);
|
2003-10-28 18:54:20 +00:00
|
|
|
return (GstImageConnection *) conn;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstImageData *
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gl_nvimage_get_image (GstImageInfo * info, GstImageConnection * conn)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
GstNvImage *image;
|
2004-03-14 22:34:33 +00:00
|
|
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
|
|
|
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
2003-10-28 18:54:20 +00:00
|
|
|
int slot = 0;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
/* checks */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (xinfo == NULL)
|
|
|
|
return NULL;
|
|
|
|
if (nvconn == NULL)
|
|
|
|
return NULL;
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
// I should also check the current GLX context !
|
|
|
|
// Ah, Don't have to, I am guarantueed to always be in the same thread
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
image = g_new0 (GstNvImage, 1);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (slot = 0; slot < AGP_BUFSLOTS; slot++) {
|
|
|
|
if (!nvconn->m_bufslots[slot])
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
image->data.size = nvconn->w * nvconn->h * 3 / 2;
|
|
|
|
|
2004-03-15 19:32:27 +00:00
|
|
|
if (slot < AGP_BUFSLOTS) // found an AGP buffer slot
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
image->data.data = nvconn->m_memory + slot * YUVTEX_SIZE;
|
2004-03-15 19:32:27 +00:00
|
|
|
image->slot = slot; // store for freeing
|
|
|
|
nvconn->m_bufslots[slot] = 1; // it is now taken
|
2004-03-14 22:34:33 +00:00
|
|
|
} else {
|
|
|
|
g_warning ("Allocating from main memory !");
|
|
|
|
image->data.data = g_malloc (image->data.size);
|
2004-03-15 19:32:27 +00:00
|
|
|
image->slot = AGP_BUFSLOTS; // no AGP slot
|
2004-03-14 22:34:33 +00:00
|
|
|
}
|
|
|
|
image->conn = nvconn;
|
|
|
|
|
|
|
|
if (image->data.data == NULL) {
|
2003-10-28 18:54:20 +00:00
|
|
|
g_warning ("GL_NvImage: data allocation failed!");
|
|
|
|
g_free (image);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (GstImageData *) image;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_gl_nvimage_put_image (GstImageInfo * info, GstImageData * image)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
GstNvImage *im = (GstNvImage *) image;
|
2004-03-14 22:34:33 +00:00
|
|
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
/* checks omitted for speed (and lazyness), do we need them? */
|
|
|
|
g_assert (xinfo != NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
/* Upload the texture here */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_warning ("PUTTING IMAGE - BROOOKEN");
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
// both upload the video, and redraw the screen
|
2004-03-14 22:34:33 +00:00
|
|
|
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glEnable (GL_TEXTURE_2D);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glPushMatrix ();
|
2003-10-28 18:54:20 +00:00
|
|
|
//glTranslatef(0,1,0);
|
2004-03-14 22:34:33 +00:00
|
|
|
glRotatef (xinfo->rotX - 250, 1, 0, 0);
|
|
|
|
glRotatef (xinfo->rotY, 0, 1, 0);
|
2003-10-28 18:54:20 +00:00
|
|
|
int zoom = xinfo->zoom;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
glScaled (zoom, zoom, zoom);
|
2003-10-28 18:54:20 +00:00
|
|
|
//Draws the surface rectangle
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glBindTexture (GL_TEXTURE_2D, im->conn->ytex_id);
|
|
|
|
glTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
|
|
|
|
GL_UNSIGNED_BYTE, im->data.data);
|
|
|
|
float xmax = (float) im->conn->w / TEX_XSIZE;
|
|
|
|
float ymax = (float) im->conn->h / TEX_YSIZE;
|
|
|
|
|
|
|
|
glColor4f (1, 1, 1, 1);
|
|
|
|
glBegin (GL_QUADS);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glNormal3f (0, -1, 0);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glTexCoord2f (xmax, 0);
|
|
|
|
glVertex3f (4, 0, -4);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glTexCoord2f (0, 0);
|
|
|
|
glVertex3f (-4, 0, -4);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glTexCoord2f (0, ymax);
|
|
|
|
glVertex3f (-4, 0, 4);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glTexCoord2f (xmax, ymax);
|
|
|
|
glVertex3f (4, 0, 4);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glEnd ();
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glPopMatrix ();
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
glXSwapBuffers (xinfo->dpy, xinfo->win);
|
2003-10-28 18:54:20 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_gl_nvimage_free_image (GstImageData * image)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
GstNvImage *im = (GstNvImage *) image;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
2003-10-28 18:54:20 +00:00
|
|
|
g_return_if_fail (im != NULL);
|
2004-03-14 22:34:33 +00:00
|
|
|
GstGLImageConnection *nvconn = im->conn;
|
2003-10-28 18:54:20 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (im->slot < AGP_BUFSLOTS) {
|
|
|
|
nvconn->m_bufslots[im->slot] = 0;
|
|
|
|
} else
|
|
|
|
g_free (im->data.data);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
g_free (im);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gl_nvimage_open_conn (GstImageConnection * conn, GstImageInfo * info)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
2003-10-28 18:54:20 +00:00
|
|
|
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
unsigned char data_sep[2][2] = { {0, 255}, {0, 255} };
|
2003-10-28 18:54:20 +00:00
|
|
|
int slot;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_warning ("Opening NVidia Connection");
|
|
|
|
xconn->m_memory =
|
|
|
|
(unsigned char *) glXAllocateMemoryNV (AGP_BUFSLOTS * YUVTEX_SIZE, 0, 1.0,
|
|
|
|
1.0);
|
|
|
|
|
|
|
|
if (!xconn->m_memory) {
|
|
|
|
printf
|
2004-03-15 19:32:27 +00:00
|
|
|
("Unable to acquire graphics card mem... will acquire in normal memory.\n");
|
2004-03-14 22:34:33 +00:00
|
|
|
for (slot = 0; slot < AGP_BUFSLOTS; slot++)
|
|
|
|
xconn->m_bufslots[slot] = 1;
|
|
|
|
} else {
|
|
|
|
// maybe this fast writable memory, awfully slow to read from, though
|
|
|
|
glPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV,
|
2004-03-15 19:32:27 +00:00
|
|
|
AGP_BUFSLOTS * YUVTEX_SIZE, xconn->m_memory);
|
2004-03-14 22:34:33 +00:00
|
|
|
glEnableClientState (GL_WRITE_PIXEL_DATA_RANGE_NV);
|
|
|
|
|
|
|
|
for (slot = 0; slot < AGP_BUFSLOTS; slot++)
|
|
|
|
xconn->m_bufslots[slot] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
glGenTextures (1, &xconn->ytex_id);
|
|
|
|
glBindTexture (GL_TEXTURE_2D, xconn->ytex_id);
|
|
|
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
|
|
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
|
|
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE, TEX_YSIZE, 0,
|
|
|
|
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
|
|
|
|
|
|
|
glActiveTextureARB (GL_TEXTURE1_ARB);
|
|
|
|
glGenTextures (1, &xconn->uvtex_id);
|
|
|
|
glBindTexture (GL_TEXTURE_2D, xconn->uvtex_id);
|
|
|
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8_ALPHA8, TEX_XSIZE / 2,
|
|
|
|
TEX_YSIZE / 2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
|
|
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
|
|
|
|
|
|
|
|
glActiveTextureARB (GL_TEXTURE2_ARB);
|
|
|
|
glGenTextures (1, &xconn->septex_id);
|
|
|
|
glBindTexture (GL_TEXTURE_2D, xconn->septex_id);
|
|
|
|
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
|
|
|
glTexImage2D (GL_TEXTURE_2D, 0, GL_LUMINANCE8, 2, 2, 0, GL_LUMINANCE,
|
|
|
|
GL_UNSIGNED_BYTE, data_sep);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
|
|
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
|
|
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
|
|
|
|
|
|
|
|
glFlushPixelDataRangeNV (GL_WRITE_PIXEL_DATA_RANGE_NV);
|
2003-10-28 18:54:20 +00:00
|
|
|
//glEnable(GL_TEXTURE_2D);
|
2004-03-14 22:34:33 +00:00
|
|
|
glActiveTextureARB (GL_TEXTURE0_ARB);
|
|
|
|
glEnable (GL_TEXTURE_2D);
|
|
|
|
glActiveTextureARB (GL_TEXTURE1_ARB);
|
|
|
|
glEnable (GL_TEXTURE_2D);
|
|
|
|
glActiveTextureARB (GL_TEXTURE2_ARB);
|
|
|
|
glEnable (GL_TEXTURE_2D);
|
|
|
|
glActiveTextureARB (GL_TEXTURE0_ARB);
|
2003-10-28 18:54:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_gl_nvimage_close_conn (GstImageConnection * conn, GstImageInfo * info)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
|
|
|
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
|
2004-03-14 22:34:33 +00:00
|
|
|
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
// anything needed in here ? Oh, maybe drawing de-init, or something
|
2004-03-14 22:34:33 +00:00
|
|
|
glDeleteTextures (1, &xconn->ytex_id);
|
|
|
|
glDeleteTextures (1, &xconn->uvtex_id);
|
|
|
|
glDeleteTextures (1, &xconn->septex_id);
|
2003-10-28 18:54:20 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
static void
|
|
|
|
gst_gl_nvimage_free_conn (GstImageConnection * conn)
|
2003-10-28 18:54:20 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
GstGLImageConnection *nvconn = gst_gl_nvimage_connection (conn);
|
2003-10-28 18:54:20 +00:00
|
|
|
|
|
|
|
g_free (nvconn);
|
|
|
|
}
|