diff --git a/gst-libs/gst/gl/gstglbuffer.c b/gst-libs/gst/gl/gstglbuffer.c index 833318a84e..bdfd1799b0 100644 --- a/gst-libs/gst/gl/gstglbuffer.c +++ b/gst-libs/gst/gl/gstglbuffer.c @@ -47,6 +47,7 @@ gst_gl_buffer_init (GstGLBuffer* buffer, gpointer g_class) buffer->texture = 0; buffer->texture_u = 0; buffer->texture_v = 0; + buffer->textureGL = 0; buffer->width = 0; buffer->height = 0; } diff --git a/gst-libs/gst/gl/gstglbuffer.h b/gst-libs/gst/gl/gstglbuffer.h index cf7aaaac8a..2c24b09a42 100644 --- a/gst-libs/gst/gl/gstglbuffer.h +++ b/gst-libs/gst/gl/gstglbuffer.h @@ -45,6 +45,7 @@ struct _GstGLBuffer { GLuint texture; GLuint texture_u; GLuint texture_v; + GLuint textureGL; gint width; gint height; diff --git a/gst-libs/gst/gl/gstgldisplay.c b/gst-libs/gst/gl/gstgldisplay.c index 4fff1cde98..a67bc211bf 100644 --- a/gst-libs/gst/gl/gstgldisplay.c +++ b/gst-libs/gst/gl/gstgldisplay.c @@ -130,6 +130,10 @@ gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass) display->rejectedDepthBuffer = 0; display->rejectedTextureFBO = 0; + display->displayedTexture = 0; + display->displayedTextureWidth = 0; + display->displayedTextureHeight = 0; + display->requestedTexture = 0; display->requestedTexture_u = 0; display->requestedTexture_v = 0; @@ -213,8 +217,8 @@ gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass) "void main(void) {\n" " float r,g,b,y,u,v;\n" " vec2 nxy=gl_TexCoord[0].xy;\n" - " y=texture2DRect(Ytex,nxy).r;\n" - " u=texture2DRect(Utex,nxy*0.5).r;\n" + " y=texture2DRect(Ytex,nxy*0.5).r;\n" + " u=texture2DRect(Utex,nxy).r;\n" " v=texture2DRect(Vtex,nxy*0.5).r;\n" " y=1.1643*(y-0.0625);\n" " u=u-0.5;\n" @@ -1175,7 +1179,7 @@ gst_gl_display_textureRequested (GstGLDisplay * display, GstVideoFormat video_fo void gst_gl_display_textureChanged (GstGLDisplay* display, GstVideoFormat video_format, GLuint texture, GLuint texture_u, GLuint texture_v, - gint width, gint height, gpointer data) + gint width, gint height, gpointer data, GLuint* outputTexture) { gst_gl_display_lock (display); display->candidateTexture = texture; @@ -1187,6 +1191,9 @@ gst_gl_display_textureChanged (GstGLDisplay* display, GstVideoFormat video_forma display->candidateData = data; gst_gl_display_postMessage (GST_GL_DISPLAY_ACTION_CHANGE, display); g_cond_wait (display->cond_fill, display->mutex); + //Here texture width and height are always the same than the fbo + if (outputTexture) + *outputTexture = display->textureFBO; gst_gl_display_unlock (display); } @@ -1223,12 +1230,18 @@ gst_gl_display_videoChanged (GstGLDisplay* display, GstVideoFormat video_format, /* Called by gst_gl elements */ gboolean -gst_gl_display_postRedisplay (GstGLDisplay* display) +gst_gl_display_postRedisplay (GstGLDisplay* display, GLuint texture, gint width , gint height) { gboolean isAlive = TRUE; gst_gl_display_lock (display); isAlive = display->isAlive; + if (texture) + { + display->displayedTexture = texture; + display->displayedTextureWidth = width; + display->displayedTextureHeight = height; + } gst_gl_display_postMessage (GST_GL_DISPLAY_ACTION_REDISPLAY, display); gst_gl_display_unlock (display); @@ -1390,8 +1403,8 @@ void gst_gl_display_draw(void) if (display->clientDrawCallback) { gboolean doRedisplay = - display->clientDrawCallback(display->textureFBO, - display->textureFBOWidth, display->textureFBOHeight); + display->clientDrawCallback(display->displayedTexture, + display->displayedTextureWidth, display->displayedTextureHeight); glFlush(); glutSwapBuffers(); @@ -1408,17 +1421,17 @@ void gst_gl_display_draw(void) glMatrixMode (GL_PROJECTION); glLoadIdentity (); - glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->textureFBO); + glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->displayedTexture); glEnable (GL_TEXTURE_RECTANGLE_ARB); glBegin (GL_QUADS); - glTexCoord2i (display->textureFBOWidth, 0); + glTexCoord2i (display->displayedTextureWidth, 0); glVertex2f (1.0f, 1.0f); glTexCoord2i (0, 0); glVertex2f (-1.0f, 1.0f); - glTexCoord2i (0, display->textureFBOHeight); + glTexCoord2i (0, display->displayedTextureHeight); glVertex2f (-1.0f, -1.0f); - glTexCoord2i (display->textureFBOWidth, display->textureFBOHeight); + glTexCoord2i (display->displayedTextureWidth, display->displayedTextureHeight); glVertex2f (1.0f, -1.0f); glEnd (); diff --git a/gst-libs/gst/gl/gstgldisplay.h b/gst-libs/gst/gl/gstgldisplay.h index dedeb21330..edcfca875f 100644 --- a/gst-libs/gst/gl/gstgldisplay.h +++ b/gst-libs/gst/gl/gstgldisplay.h @@ -139,6 +139,11 @@ struct _GstGLDisplay { GLuint rejectedDepthBuffer; GLuint rejectedTextureFBO; + //displayed texture + GLuint displayedTexture; + GLuint displayedTextureWidth; + GLuint displayedTextureHeight; + GLuint requestedTexture; GLuint requestedTexture_u; GLuint requestedTexture_v; @@ -232,13 +237,13 @@ void gst_gl_display_textureRequested (GstGLDisplay* display, GstVideoFormat form guint* texture_u, guint* texture_v); void gst_gl_display_textureChanged (GstGLDisplay* display, GstVideoFormat video_format, GLuint texture, GLuint texture_u, GLuint texture_v, - gint width, gint height, gpointer data); + gint width, gint height, gpointer data, GLuint* outputTexture); void gst_gl_display_clearTexture (GstGLDisplay* display, guint texture, guint texture_u, guint texture_v); void gst_gl_display_videoChanged (GstGLDisplay* display, GstVideoFormat video_format, gpointer data); -gboolean gst_gl_display_postRedisplay (GstGLDisplay* display); +gboolean gst_gl_display_postRedisplay (GstGLDisplay* display, GLuint texture, gint width, gint height); void gst_gl_display_requestFBO (GstGLDisplay* display, gint width, gint height, guint* fbo, guint* depthbuffer, guint* texture); void gst_gl_display_useFBO (GstGLDisplay* display, gint textureFBOWidth, gint textureFBOheight, diff --git a/gst/gl/gstglfilter.c b/gst/gl/gstglfilter.c index 52cfabb3d9..a5e1536bb6 100644 --- a/gst/gl/gstglfilter.c +++ b/gst/gl/gstglfilter.c @@ -211,8 +211,6 @@ gst_gl_filter_prepare_output_buffer (GstBaseTransform* trans, *buf = GST_BUFFER (gl_outbuf); gst_buffer_set_caps (*buf, caps); - g_print ("gstglfilter: gst_gl_filter_prepare_output_buffer\n"); - return GST_FLOW_OK; } @@ -249,8 +247,6 @@ gst_gl_filter_transform (GstBaseTransform* bt, GstBuffer* inbuf, filter = GST_GL_FILTER (bt); - g_print ("gstglfilter: gst_gl_filter_transform\n"); - gst_gl_filter_do_transform (filter, gl_inbuf, gl_outbuf); return GST_FLOW_OK; diff --git a/gst/gl/gstglfiltercube.c b/gst/gl/gstglfiltercube.c index 673de48af1..da273d5b89 100644 --- a/gst/gl/gstglfiltercube.c +++ b/gst/gl/gstglfiltercube.c @@ -74,10 +74,13 @@ gst_gl_filter_cube_class_init (GstGLFilterCubeClass * klass) GST_GL_FILTER_CLASS (klass)->filter = gst_gl_filter_cube_filter; } +static gint c = 0; + static void gst_gl_filter_cube_init (GstGLFilterCube* filter, GstGLFilterCubeClass* klass) { + c += 1; } static void @@ -114,16 +117,17 @@ gst_gl_filter_cube_filter (GstGLFilter* filter, GstGLBuffer* inbuf, { GstGLFilterCube* cube_filter = GST_GL_FILTER_CUBE(filter); - g_print ("gstglfiltercube: gst_gl_filter_cube_filter\n"); - //blocking call, generate a FBO gst_gl_display_useFBO (filter->display, filter->width, filter->height, filter->fbo, filter->depthbuffer, filter->texture, gst_gl_filter_cube_callback, - inbuf->width, inbuf->height, inbuf->texture); + inbuf->width, inbuf->height, inbuf->textureGL); outbuf->width = filter->width; outbuf->height = filter->height; - outbuf->texture = filter->texture; + outbuf->texture = inbuf->texture; + outbuf->texture_u = inbuf->texture_u; + outbuf->texture_v = inbuf->texture_v; + outbuf->textureGL = filter->texture; return TRUE; } @@ -136,8 +140,6 @@ gst_gl_filter_cube_callback (guint width, guint height, guint texture) static GLfloat yrot = 0; static GLfloat zrot = 0; - g_print ("gstglfiltercube: gst_gl_filter_cube_callback\n"); - glEnable(GL_DEPTH_TEST); glEnable (GL_TEXTURE_RECTANGLE_ARB); diff --git a/gst/gl/gstglgraphicmaker.c b/gst/gl/gstglgraphicmaker.c index d487b290f4..33227f4cf2 100644 --- a/gst/gl/gstglgraphicmaker.c +++ b/gst/gl/gstglgraphicmaker.c @@ -424,6 +424,7 @@ gst_gl_graphicmaker_transform (GstBaseTransform* trans, GstBuffer* inbuf, { GstGLGraphicmaker* graphicmaker; GstGLBuffer* gl_outbuf = GST_GL_BUFFER (outbuf); + guint outputTexture = 0; graphicmaker = GST_GL_GRAPHICMAKER (trans); @@ -433,7 +434,7 @@ gst_gl_graphicmaker_transform (GstBaseTransform* trans, GstBuffer* inbuf, //blocking call gst_gl_display_textureChanged(graphicmaker->display, graphicmaker->video_format, gl_outbuf->texture, gl_outbuf->texture_u, gl_outbuf->texture_v, - gl_outbuf->width, gl_outbuf->height, GST_BUFFER_DATA (inbuf)); + gl_outbuf->width, gl_outbuf->height, GST_BUFFER_DATA (inbuf), &gl_outbuf->textureGL); return GST_FLOW_OK; } diff --git a/gst/gl/gstglimagesink.c b/gst/gl/gstglimagesink.c index 4339accf9c..d75ddec8d8 100644 --- a/gst/gl/gstglimagesink.c +++ b/gst/gl/gstglimagesink.c @@ -418,7 +418,7 @@ gst_glimage_sink_render (GstBaseSink* bsink, GstBuffer* buf) //is not gl else { - //if glimagesink has not the display yet + //if glimagesink has not the display yet if (glimage_sink->display == NULL) { @@ -449,7 +449,7 @@ gst_glimage_sink_render (GstBaseSink* bsink, GstBuffer* buf) //blocking call gst_gl_display_textureChanged(glimage_sink->display, glimage_sink->format, gl_buffer->texture, gl_buffer->texture_u, gl_buffer->texture_v, - gl_buffer->width, gl_buffer->height, GST_BUFFER_DATA (buf)); + gl_buffer->width, gl_buffer->height, GST_BUFFER_DATA (buf), &gl_buffer->textureGL); //gl_buffer is created in this block, so the gl buffer is already referenced } @@ -465,7 +465,8 @@ gst_glimage_sink_render (GstBaseSink* bsink, GstBuffer* buf) glimage_sink->stored_buffer = gl_buffer; //redisplay opengl scene - isAlive = gst_gl_display_postRedisplay (glimage_sink->display); + isAlive = gst_gl_display_postRedisplay (glimage_sink->display, + gl_buffer->textureGL, gl_buffer->width, gl_buffer->height); if (isAlive) return GST_FLOW_OK; @@ -515,7 +516,7 @@ gst_glimage_sink_expose (GstXOverlay* overlay) //redisplay opengl scene if (glimage_sink->display) - gst_gl_display_postRedisplay (glimage_sink->display); + gst_gl_display_postRedisplay (glimage_sink->display, 0, 0, 0); }