mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
[075/906] indent
git-svn-id: svn://svn.wobow.com/GStreamer_playground/gst-plugins-gl@451 93df14bb-0f41-7a43-8087-d3e2a2f0e464
This commit is contained in:
parent
60498e3370
commit
890ca473e1
1 changed files with 282 additions and 283 deletions
|
@ -87,8 +87,8 @@ gst_gl_display_class_init (GstGLDisplayClass * klass)
|
||||||
static void
|
static void
|
||||||
gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass)
|
gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass)
|
||||||
{
|
{
|
||||||
display->mutex = g_mutex_new ();
|
display->mutex = g_mutex_new ();
|
||||||
display->texturePool = g_queue_new ();
|
display->texturePool = g_queue_new ();
|
||||||
display->cond_make = g_cond_new ();
|
display->cond_make = g_cond_new ();
|
||||||
display->cond_fill = g_cond_new ();
|
display->cond_fill = g_cond_new ();
|
||||||
display->cond_clear = g_cond_new ();
|
display->cond_clear = g_cond_new ();
|
||||||
|
@ -109,7 +109,7 @@ gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass)
|
||||||
display->requestedTexture = 0;
|
display->requestedTexture = 0;
|
||||||
display->requestedTexture_u = 0;
|
display->requestedTexture_u = 0;
|
||||||
display->requestedTexture_v = 0;
|
display->requestedTexture_v = 0;
|
||||||
display->requestedVideo_format = 0;
|
display->requestedVideo_format = 0;
|
||||||
display->requestedTextureWidth = 0;
|
display->requestedTextureWidth = 0;
|
||||||
display->requestedTextureHeight = 0;
|
display->requestedTextureHeight = 0;
|
||||||
|
|
||||||
|
@ -154,135 +154,135 @@ gst_gl_display_init (GstGLDisplay *display, GstGLDisplayClass *klass)
|
||||||
display->clientDrawCallback = NULL;
|
display->clientDrawCallback = NULL;
|
||||||
display->title = g_string_new ("OpenGL renderer ");
|
display->title = g_string_new ("OpenGL renderer ");
|
||||||
|
|
||||||
display->GLSLProgram_YUY2 = 0;
|
display->GLSLProgram_YUY2 = 0;
|
||||||
display->GLSLProgram_UYVY = 0;
|
display->GLSLProgram_UYVY = 0;
|
||||||
display->GLSLProgram_I420_YV12 = 0;
|
display->GLSLProgram_I420_YV12 = 0;
|
||||||
display->GLSLProgram_AYUV = 0;
|
display->GLSLProgram_AYUV = 0;
|
||||||
|
|
||||||
display->GLSLProgram_to_YUY2 = 0;
|
display->GLSLProgram_to_YUY2 = 0;
|
||||||
display->GLSLProgram_to_UYVY = 0;
|
display->GLSLProgram_to_UYVY = 0;
|
||||||
display->GLSLProgram_to_I420_YV12 = 0;
|
display->GLSLProgram_to_I420_YV12 = 0;
|
||||||
display->GLSLProgram_to_AYUV = 0;
|
display->GLSLProgram_to_AYUV = 0;
|
||||||
|
|
||||||
//YUY2:r,g,a
|
//YUY2:r,g,a
|
||||||
//UYVY:a,b,r
|
//UYVY:a,b,r
|
||||||
display->textFProgram_YUY2_UYVY =
|
display->textFProgram_YUY2_UYVY =
|
||||||
"uniform sampler2DRect Ytex, UVtex;\n"
|
"uniform sampler2DRect Ytex, UVtex;\n"
|
||||||
"void main(void) {\n"
|
"void main(void) {\n"
|
||||||
" float fx, fy, y, u, v, r, g, b;\n"
|
" float fx, fy, y, u, v, r, g, b;\n"
|
||||||
" fx = gl_TexCoord[0].x;\n"
|
" fx = gl_TexCoord[0].x;\n"
|
||||||
" fy = gl_TexCoord[0].y;\n"
|
" fy = gl_TexCoord[0].y;\n"
|
||||||
" y = texture2DRect(Ytex,vec2(fx,fy)).%c;\n"
|
" y = texture2DRect(Ytex,vec2(fx,fy)).%c;\n"
|
||||||
" u = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
|
" u = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
|
||||||
" v = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
|
" v = texture2DRect(UVtex,vec2(fx*0.5,fy)).%c;\n"
|
||||||
" y=1.164*(y-0.0627);\n"
|
" y=1.164*(y-0.0627);\n"
|
||||||
" u=u-0.5;\n"
|
" u=u-0.5;\n"
|
||||||
" v=v-0.5;\n"
|
" v=v-0.5;\n"
|
||||||
" r = y+1.5958*v;\n"
|
" r = y+1.5958*v;\n"
|
||||||
" g = y-0.39173*u-0.81290*v;\n"
|
" g = y-0.39173*u-0.81290*v;\n"
|
||||||
" b = y+2.017*u;\n"
|
" b = y+2.017*u;\n"
|
||||||
" gl_FragColor = vec4(r, g, b, 1.0);\n"
|
" gl_FragColor = vec4(r, g, b, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
display->textFProgram_I420_YV12 =
|
display->textFProgram_I420_YV12 =
|
||||||
"uniform sampler2DRect Ytex,Utex,Vtex;\n"
|
"uniform sampler2DRect Ytex,Utex,Vtex;\n"
|
||||||
"void main(void) {\n"
|
"void main(void) {\n"
|
||||||
" float r,g,b,y,u,v;\n"
|
" float r,g,b,y,u,v;\n"
|
||||||
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
||||||
" y=texture2DRect(Ytex,nxy*0.5).r;\n"
|
" y=texture2DRect(Ytex,nxy*0.5).r;\n"
|
||||||
" u=texture2DRect(Utex,nxy).r;\n"
|
" u=texture2DRect(Utex,nxy).r;\n"
|
||||||
" v=texture2DRect(Vtex,nxy*0.5).r;\n"
|
" v=texture2DRect(Vtex,nxy*0.5).r;\n"
|
||||||
" y=1.1643*(y-0.0625);\n"
|
" y=1.1643*(y-0.0625);\n"
|
||||||
" u=u-0.5;\n"
|
" u=u-0.5;\n"
|
||||||
" v=v-0.5;\n"
|
" v=v-0.5;\n"
|
||||||
" r=y+1.5958*v;\n"
|
" r=y+1.5958*v;\n"
|
||||||
" g=y-0.39173*u-0.81290*v;\n"
|
" g=y-0.39173*u-0.81290*v;\n"
|
||||||
" b=y+2.017*u;\n"
|
" b=y+2.017*u;\n"
|
||||||
" gl_FragColor=vec4(r,g,b,1.0);\n"
|
" gl_FragColor=vec4(r,g,b,1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
display->textFProgram_AYUV =
|
display->textFProgram_AYUV =
|
||||||
"uniform sampler2DRect tex;\n"
|
"uniform sampler2DRect tex;\n"
|
||||||
"void main(void) {\n"
|
"void main(void) {\n"
|
||||||
" float r,g,b,y,u,v;\n"
|
" float r,g,b,y,u,v;\n"
|
||||||
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
||||||
" y=texture2DRect(tex,nxy).r;\n"
|
" y=texture2DRect(tex,nxy).r;\n"
|
||||||
" u=texture2DRect(tex,nxy).g;\n"
|
" u=texture2DRect(tex,nxy).g;\n"
|
||||||
" v=texture2DRect(tex,nxy).b;\n"
|
" v=texture2DRect(tex,nxy).b;\n"
|
||||||
" y=1.1643*(y-0.0625);\n"
|
" y=1.1643*(y-0.0625);\n"
|
||||||
" u=u-0.5;\n"
|
" u=u-0.5;\n"
|
||||||
" v=v-0.5;\n"
|
" v=v-0.5;\n"
|
||||||
" r=y+1.5958*v;\n"
|
" r=y+1.5958*v;\n"
|
||||||
" g=y-0.39173*u-0.81290*v;\n"
|
" g=y-0.39173*u-0.81290*v;\n"
|
||||||
" b=y+2.017*u;\n"
|
" b=y+2.017*u;\n"
|
||||||
" gl_FragColor=vec4(r,g,b,1.0);\n"
|
" gl_FragColor=vec4(r,g,b,1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
//YUY2:y2,u,y1,v
|
//YUY2:y2,u,y1,v
|
||||||
//UYVY:v,y1,u,y2
|
//UYVY:v,y1,u,y2
|
||||||
display->textFProgram_to_YUY2_UYVY =
|
display->textFProgram_to_YUY2_UYVY =
|
||||||
"uniform sampler2DRect tex;\n"
|
"uniform sampler2DRect tex;\n"
|
||||||
"void main(void) {\n"
|
"void main(void) {\n"
|
||||||
" float fx,fy,r,g,b,r2,g2,b2,y1,y2,u,v;\n"
|
" float fx,fy,r,g,b,r2,g2,b2,y1,y2,u,v;\n"
|
||||||
" fx = gl_TexCoord[0].x;\n"
|
" fx = gl_TexCoord[0].x;\n"
|
||||||
" fy = gl_TexCoord[0].y;\n"
|
" fy = gl_TexCoord[0].y;\n"
|
||||||
" r=texture2DRect(tex,vec2(fx*2.0,fy)).r;\n"
|
" r=texture2DRect(tex,vec2(fx*2.0,fy)).r;\n"
|
||||||
" g=texture2DRect(tex,vec2(fx*2.0,fy)).g;\n"
|
" g=texture2DRect(tex,vec2(fx*2.0,fy)).g;\n"
|
||||||
" b=texture2DRect(tex,vec2(fx*2.0,fy)).b;\n"
|
" b=texture2DRect(tex,vec2(fx*2.0,fy)).b;\n"
|
||||||
" r2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).r;\n"
|
" r2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).r;\n"
|
||||||
" g2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).g;\n"
|
" g2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).g;\n"
|
||||||
" b2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).b;\n"
|
" b2=texture2DRect(tex,vec2(fx*2.0+1.0,fy)).b;\n"
|
||||||
" y1=0.299011*r + 0.586987*g + 0.114001*b;\n"
|
" y1=0.299011*r + 0.586987*g + 0.114001*b;\n"
|
||||||
" y2=0.299011*r2 + 0.586987*g2 + 0.114001*b2;\n"
|
" y2=0.299011*r2 + 0.586987*g2 + 0.114001*b2;\n"
|
||||||
" u=-0.148246*r -0.29102*g + 0.439266*b;\n"
|
" u=-0.148246*r -0.29102*g + 0.439266*b;\n"
|
||||||
" v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
|
" v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
|
||||||
" y1=0.858885*y1 + 0.0625;\n"
|
" y1=0.858885*y1 + 0.0625;\n"
|
||||||
" y2=0.858885*y2 + 0.0625;\n"
|
" y2=0.858885*y2 + 0.0625;\n"
|
||||||
" u=u + 0.5;\n"
|
" u=u + 0.5;\n"
|
||||||
" v=v + 0.5;\n"
|
" v=v + 0.5;\n"
|
||||||
" gl_FragColor=vec4(%s);\n"
|
" gl_FragColor=vec4(%s);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
display->textFProgram_to_I420_YV12 =
|
display->textFProgram_to_I420_YV12 =
|
||||||
"uniform sampler2DRect tex;\n"
|
"uniform sampler2DRect tex;\n"
|
||||||
"uniform float w, h;\n"
|
"uniform float w, h;\n"
|
||||||
"void main(void) {\n"
|
"void main(void) {\n"
|
||||||
" float r,g,b,r2,b2,g2,y,u,v;\n"
|
" float r,g,b,r2,b2,g2,y,u,v;\n"
|
||||||
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
||||||
" vec2 nxy2=mod(2.0*nxy, vec2(w, h));\n"
|
" vec2 nxy2=mod(2.0*nxy, vec2(w, h));\n"
|
||||||
" r=texture2DRect(tex,nxy).r;\n"
|
" r=texture2DRect(tex,nxy).r;\n"
|
||||||
" g=texture2DRect(tex,nxy).g;\n"
|
" g=texture2DRect(tex,nxy).g;\n"
|
||||||
" b=texture2DRect(tex,nxy).b;\n"
|
" b=texture2DRect(tex,nxy).b;\n"
|
||||||
" r2=texture2DRect(tex,nxy2).r;\n"
|
" r2=texture2DRect(tex,nxy2).r;\n"
|
||||||
" g2=texture2DRect(tex,nxy2).g;\n"
|
" g2=texture2DRect(tex,nxy2).g;\n"
|
||||||
" b2=texture2DRect(tex,nxy2).b;\n"
|
" b2=texture2DRect(tex,nxy2).b;\n"
|
||||||
" y=0.299011*r + 0.586987*g + 0.114001*b;\n"
|
" y=0.299011*r + 0.586987*g + 0.114001*b;\n"
|
||||||
" u=-0.148246*r2 -0.29102*g2 + 0.439266*b2;\n"
|
" u=-0.148246*r2 -0.29102*g2 + 0.439266*b2;\n"
|
||||||
" v=0.439271*r2 - 0.367833*g2 - 0.071438*b2 ;\n"
|
" v=0.439271*r2 - 0.367833*g2 - 0.071438*b2 ;\n"
|
||||||
" y=0.858885*y + 0.0625;\n"
|
" y=0.858885*y + 0.0625;\n"
|
||||||
" u=u + 0.5;\n"
|
" u=u + 0.5;\n"
|
||||||
" v=v + 0.5;\n"
|
" v=v + 0.5;\n"
|
||||||
" gl_FragData[0] = vec4(y, 0.0, 0.0, 1.0);\n"
|
" gl_FragData[0] = vec4(y, 0.0, 0.0, 1.0);\n"
|
||||||
" gl_FragData[1] = vec4(u, 0.0, 0.0, 1.0);\n"
|
" gl_FragData[1] = vec4(u, 0.0, 0.0, 1.0);\n"
|
||||||
" gl_FragData[2] = vec4(v, 0.0, 0.0, 1.0);\n"
|
" gl_FragData[2] = vec4(v, 0.0, 0.0, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
display->textFProgram_to_AYUV =
|
display->textFProgram_to_AYUV =
|
||||||
"uniform sampler2DRect tex;\n"
|
"uniform sampler2DRect tex;\n"
|
||||||
"void main(void) {\n"
|
"void main(void) {\n"
|
||||||
" float r,g,b,y,u,v;\n"
|
" float r,g,b,y,u,v;\n"
|
||||||
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
" vec2 nxy=gl_TexCoord[0].xy;\n"
|
||||||
" r=texture2DRect(tex,nxy).r;\n"
|
" r=texture2DRect(tex,nxy).r;\n"
|
||||||
" g=texture2DRect(tex,nxy).g;\n"
|
" g=texture2DRect(tex,nxy).g;\n"
|
||||||
" b=texture2DRect(tex,nxy).b;\n"
|
" b=texture2DRect(tex,nxy).b;\n"
|
||||||
" y=0.299011*r + 0.586987*g + 0.114001*b;\n"
|
" y=0.299011*r + 0.586987*g + 0.114001*b;\n"
|
||||||
" u=-0.148246*r -0.29102*g + 0.439266*b;\n"
|
" u=-0.148246*r -0.29102*g + 0.439266*b;\n"
|
||||||
" v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
|
" v=0.439271*r - 0.367833*g - 0.071438*b ;\n"
|
||||||
" y=0.858885*y + 0.0625;\n"
|
" y=0.858885*y + 0.0625;\n"
|
||||||
" u=u + 0.5;\n"
|
" u=u + 0.5;\n"
|
||||||
" v=v + 0.5;\n"
|
" v=v + 0.5;\n"
|
||||||
" gl_FragColor=vec4(y,u,v,1.0);\n"
|
" gl_FragColor=vec4(y,u,v,1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -343,7 +343,7 @@ gst_gl_display_finalize (GObject *object)
|
||||||
if (g_hash_table_size (gst_gl_display_map) == 0)
|
if (g_hash_table_size (gst_gl_display_map) == 0)
|
||||||
{
|
{
|
||||||
g_thread_join (gst_gl_display_glutThread);
|
g_thread_join (gst_gl_display_glutThread);
|
||||||
g_print ("Glut thread joined\n");
|
GST_DEBUG ("Glut thread joined");
|
||||||
gst_gl_display_glutThread = NULL;
|
gst_gl_display_glutThread = NULL;
|
||||||
g_async_queue_unref (gst_gl_display_messageQueue);
|
g_async_queue_unref (gst_gl_display_messageQueue);
|
||||||
g_hash_table_unref (gst_gl_display_map);
|
g_hash_table_unref (gst_gl_display_map);
|
||||||
|
@ -370,9 +370,9 @@ gst_gl_display_glutThreadFunc (GstGLDisplay *display)
|
||||||
gst_gl_display_glutCreateWindow (display);
|
gst_gl_display_glutCreateWindow (display);
|
||||||
gst_gl_display_unlock (display);
|
gst_gl_display_unlock (display);
|
||||||
|
|
||||||
g_print ("Glut mainLoop start\n");
|
GST_DEBUG ("Glut mainLoop start");
|
||||||
glutMainLoop ();
|
glutMainLoop ();
|
||||||
g_print ("Glut mainLoop exited\n");
|
GST_DEBUG ("Glut mainLoop exited");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -405,13 +405,13 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
//Init glew
|
//Init glew
|
||||||
err = glewInit();
|
err = glewInit();
|
||||||
if (err != GLEW_OK)
|
if (err != GLEW_OK)
|
||||||
g_print ("Error: %s\n", glewGetErrorString(err));
|
GST_DEBUG ("Error: %s", glewGetErrorString(err));
|
||||||
else
|
else
|
||||||
g_print ("Context %d, Using GLEW %s\n", glutWinId, glewGetString(GLEW_VERSION));
|
GST_DEBUG ("Context %d, Using GLEW %s", glutWinId, glewGetString(GLEW_VERSION));
|
||||||
|
|
||||||
if (GLEW_EXT_framebuffer_object)
|
if (GLEW_EXT_framebuffer_object)
|
||||||
{
|
{
|
||||||
g_print ("Context %d, EXT_framebuffer_object supported: yes\n", glutWinId);
|
GST_DEBUG ("Context %d, EXT_framebuffer_object supported: yes", glutWinId);
|
||||||
|
|
||||||
//-- init intput frame buffer object (video -> GL)
|
//-- init intput frame buffer object (video -> GL)
|
||||||
|
|
||||||
|
@ -431,9 +431,9 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||||
display->textureFBOWidth, display->textureFBOHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
display->textureFBOWidth, display->textureFBOHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
//attach the texture to the FBO to renderer to
|
//attach the texture to the FBO to renderer to
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||||
|
@ -457,8 +457,8 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
|
|
||||||
//setup the render buffer for depth
|
//setup the render buffer for depth
|
||||||
glGenRenderbuffersEXT(1, &display->graphicDepthBuffer);
|
glGenRenderbuffersEXT(1, &display->graphicDepthBuffer);
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, display->graphicDepthBuffer);
|
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, display->graphicDepthBuffer);
|
||||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
|
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
|
||||||
display->glcontext_width, display->glcontext_height);
|
display->glcontext_width, display->glcontext_height);
|
||||||
|
|
||||||
//setup a texture to render to
|
//setup a texture to render to
|
||||||
|
@ -467,9 +467,9 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||||
display->glcontext_width, display->glcontext_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
display->glcontext_width, display->glcontext_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
//attach the texture to the FBO to renderer to
|
//attach the texture to the FBO to renderer to
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||||
|
@ -496,8 +496,8 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
|
|
||||||
//setup the render buffer for depth
|
//setup the render buffer for depth
|
||||||
glGenRenderbuffersEXT(1, &display->videoDepthBuffer);
|
glGenRenderbuffersEXT(1, &display->videoDepthBuffer);
|
||||||
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, display->videoDepthBuffer);
|
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, display->videoDepthBuffer);
|
||||||
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
|
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT,
|
||||||
display->outputWidth, display->outputHeight);
|
display->outputWidth, display->outputHeight);
|
||||||
|
|
||||||
//setup a first texture to render to
|
//setup a first texture to render to
|
||||||
|
@ -506,9 +506,9 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||||
display->outputWidth, display->outputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
display->outputWidth, display->outputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
//attach the first texture to the FBO to renderer to
|
//attach the first texture to the FBO to renderer to
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||||
|
@ -520,9 +520,9 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||||
display->outputWidth, display->outputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
display->outputWidth, display->outputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
//attach the second texture to the FBO to renderer to
|
//attach the second texture to the FBO to renderer to
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT,
|
||||||
|
@ -534,9 +534,9 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||||
display->outputWidth, display->outputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
display->outputWidth, display->outputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
//attach the third texture to the FBO to renderer to
|
//attach the third texture to the FBO to renderer to
|
||||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT,
|
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT2_EXT,
|
||||||
|
@ -561,30 +561,30 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_print ("Context %d, EXT_framebuffer_object supported: no\n", glutWinId);
|
GST_DEBUG ("Context %d, EXT_framebuffer_object supported: no", glutWinId);
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if fragment program is available, then load them
|
//check if fragment program is available, then load them
|
||||||
if (GLEW_ARB_vertex_program)
|
if (GLEW_ARB_vertex_program)
|
||||||
{
|
{
|
||||||
gchar program[2048];
|
gchar program[2048];
|
||||||
|
|
||||||
g_print ("Context %d, ARB_fragment_program supported: yes\n", glutWinId);
|
GST_DEBUG ("Context %d, ARB_fragment_program supported: yes", glutWinId);
|
||||||
|
|
||||||
//from video to texture
|
//from video to texture
|
||||||
|
|
||||||
sprintf (program, display->textFProgram_YUY2_UYVY, 'r', 'g', 'a');
|
sprintf (program, display->textFProgram_YUY2_UYVY, 'r', 'g', 'a');
|
||||||
|
|
||||||
display->GLSLProgram_YUY2 = gst_gl_display_loadGLSLprogram (program);
|
display->GLSLProgram_YUY2 = gst_gl_display_loadGLSLprogram (program);
|
||||||
|
|
||||||
sprintf (program, display->textFProgram_YUY2_UYVY, 'a', 'b', 'r');
|
sprintf (program, display->textFProgram_YUY2_UYVY, 'a', 'b', 'r');
|
||||||
|
|
||||||
display->GLSLProgram_UYVY = gst_gl_display_loadGLSLprogram (program);
|
display->GLSLProgram_UYVY = gst_gl_display_loadGLSLprogram (program);
|
||||||
|
|
||||||
display->GLSLProgram_I420_YV12 = gst_gl_display_loadGLSLprogram (display->textFProgram_I420_YV12);
|
display->GLSLProgram_I420_YV12 = gst_gl_display_loadGLSLprogram (display->textFProgram_I420_YV12);
|
||||||
|
|
||||||
display->GLSLProgram_AYUV = gst_gl_display_loadGLSLprogram (display->textFProgram_AYUV);
|
display->GLSLProgram_AYUV = gst_gl_display_loadGLSLprogram (display->textFProgram_AYUV);
|
||||||
|
|
||||||
//from texture to video
|
//from texture to video
|
||||||
|
|
||||||
|
@ -600,22 +600,22 @@ gst_gl_display_glutCreateWindow (GstGLDisplay *display)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_print ("Context %d, ARB_fragment_program supported: no\n", glutWinId);
|
GST_DEBUG ("Context %d, ARB_fragment_program supported: no", glutWinId);
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//setup callbacks
|
//setup callbacks
|
||||||
glutReshapeFunc (gst_gl_display_onReshape);
|
glutReshapeFunc (gst_gl_display_onReshape);
|
||||||
glutDisplayFunc (gst_gl_display_draw);
|
glutDisplayFunc (gst_gl_display_draw);
|
||||||
glutCloseFunc (gst_gl_display_onClose);
|
glutCloseFunc (gst_gl_display_onClose);
|
||||||
|
|
||||||
//insert glut context to the map
|
//insert glut context to the map
|
||||||
display->glutWinId = glutWinId;
|
display->glutWinId = glutWinId;
|
||||||
g_hash_table_insert (gst_gl_display_map, GINT_TO_POINTER (glutWinId), display);
|
g_hash_table_insert (gst_gl_display_map, GUINT_TO_POINTER ((guint64)glutWinId), display);
|
||||||
|
|
||||||
//check glut id validity
|
//check glut id validity
|
||||||
g_assert (glutGetWindow() == glutWinId);
|
g_assert (glutGetWindow() == glutWinId);
|
||||||
g_print ("Context %d initialized\n", display->glutWinId);
|
GST_DEBUG ("Context %d initialized", display->glutWinId);
|
||||||
|
|
||||||
//release display constructor
|
//release display constructor
|
||||||
g_cond_signal (display->cond_create);
|
g_cond_signal (display->cond_create);
|
||||||
|
@ -629,15 +629,15 @@ gst_gl_display_glutDestroyWindow (GstGLDisplay *display)
|
||||||
glutSetWindow (display->glutWinId);
|
glutSetWindow (display->glutWinId);
|
||||||
glutReshapeFunc (NULL);
|
glutReshapeFunc (NULL);
|
||||||
glutDestroyWindow (display->glutWinId);
|
glutDestroyWindow (display->glutWinId);
|
||||||
glUseProgramObjectARB (0);
|
glUseProgramObjectARB (0);
|
||||||
|
|
||||||
glDeleteObjectARB (display->GLSLProgram_YUY2);
|
glDeleteObjectARB (display->GLSLProgram_YUY2);
|
||||||
glDeleteObjectARB (display->GLSLProgram_UYVY);
|
glDeleteObjectARB (display->GLSLProgram_UYVY);
|
||||||
glDeleteObjectARB (display->GLSLProgram_I420_YV12);
|
glDeleteObjectARB (display->GLSLProgram_I420_YV12);
|
||||||
glDeleteObjectARB (display->GLSLProgram_AYUV);
|
glDeleteObjectARB (display->GLSLProgram_AYUV);
|
||||||
|
|
||||||
glDeleteObjectARB (display->GLSLProgram_to_YUY2);
|
glDeleteObjectARB (display->GLSLProgram_to_YUY2);
|
||||||
glDeleteObjectARB (display->GLSLProgram_to_UYVY);
|
glDeleteObjectARB (display->GLSLProgram_to_UYVY);
|
||||||
glDeleteObjectARB (display->GLSLProgram_to_I420_YV12);
|
glDeleteObjectARB (display->GLSLProgram_to_I420_YV12);
|
||||||
glDeleteObjectARB (display->GLSLProgram_to_AYUV);
|
glDeleteObjectARB (display->GLSLProgram_to_AYUV);
|
||||||
|
|
||||||
|
@ -656,22 +656,22 @@ gst_gl_display_glutDestroyWindow (GstGLDisplay *display)
|
||||||
glDeleteTextures (1, &display->videoTexture_v);
|
glDeleteTextures (1, &display->videoTexture_v);
|
||||||
|
|
||||||
//clean up the texture pool
|
//clean up the texture pool
|
||||||
while (g_queue_get_length (display->texturePool))
|
while (g_queue_get_length (display->texturePool))
|
||||||
{
|
{
|
||||||
GstGLDisplayTex* tex = g_queue_pop_head (display->texturePool);
|
GstGLDisplayTex* tex = g_queue_pop_head (display->texturePool);
|
||||||
|
|
||||||
//delete textures
|
//delete textures
|
||||||
glDeleteTextures (1, &tex->texture);
|
glDeleteTextures (1, &tex->texture);
|
||||||
if (tex->texture_u) {
|
if (tex->texture_u) {
|
||||||
glDeleteTextures (1, &tex->texture_u);
|
glDeleteTextures (1, &tex->texture_u);
|
||||||
}
|
}
|
||||||
if (tex->texture_v) {
|
if (tex->texture_v) {
|
||||||
glDeleteTextures (1, &tex->texture_v);
|
glDeleteTextures (1, &tex->texture_v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_remove (gst_gl_display_map, GINT_TO_POINTER (display->glutWinId));
|
g_hash_table_remove (gst_gl_display_map, GINT_TO_POINTER ((guint64)display->glutWinId));
|
||||||
g_print ("glut window destroyed: %d\n", display->glutWinId);
|
GST_DEBUG ("glut window destroyed: %d", display->glutWinId);
|
||||||
|
|
||||||
//if the map is empty, leaveMainloop and join the thread
|
//if the map is empty, leaveMainloop and join the thread
|
||||||
if (g_hash_table_size (gst_gl_display_map) == 0)
|
if (g_hash_table_size (gst_gl_display_map) == 0)
|
||||||
|
@ -721,20 +721,20 @@ gst_gl_display_glutCleanTexture (GstGLDisplay * display)
|
||||||
{
|
{
|
||||||
GstGLDisplayTex* tex = NULL;
|
GstGLDisplayTex* tex = NULL;
|
||||||
|
|
||||||
glutSetWindow (display->glutWinId);
|
glutSetWindow (display->glutWinId);
|
||||||
|
|
||||||
//contructuct a texture pool element
|
//contructuct a texture pool element
|
||||||
tex = g_new0 (GstGLDisplayTex, 1);
|
tex = g_new0 (GstGLDisplayTex, 1);
|
||||||
tex->texture = display->textureTrash;
|
tex->texture = display->textureTrash;
|
||||||
tex->texture_u = display->textureTrash_u;
|
tex->texture_u = display->textureTrash_u;
|
||||||
tex->texture_v = display->textureTrash_v;
|
tex->texture_v = display->textureTrash_v;
|
||||||
|
|
||||||
display->textureTrash = 0;
|
display->textureTrash = 0;
|
||||||
display->textureTrash_u = 0;
|
display->textureTrash_u = 0;
|
||||||
display->textureTrash_v = 0;
|
display->textureTrash_v = 0;
|
||||||
|
|
||||||
//add tex to the pool, it makes texture allocation reusable
|
//add tex to the pool, it makes texture allocation reusable
|
||||||
g_queue_push_tail (display->texturePool, tex);
|
g_queue_push_tail (display->texturePool, tex);
|
||||||
|
|
||||||
g_cond_signal (display->cond_clear);
|
g_cond_signal (display->cond_clear);
|
||||||
}
|
}
|
||||||
|
@ -782,7 +782,7 @@ gst_gl_display_glut_idle (void)
|
||||||
gst_gl_display_glutDispatchAction (msg);
|
gst_gl_display_glutDispatchAction (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else g_print ("timeout reached in idle func\n");
|
else GST_DEBUG ("timeout reached in idle func");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -844,7 +844,7 @@ gst_gl_display_checkMsgValidity (GstGLDisplayMsg *msg)
|
||||||
case GST_GL_DISPLAY_ACTION_VIDEO:
|
case GST_GL_DISPLAY_ACTION_VIDEO:
|
||||||
case GST_GL_DISPLAY_ACTION_REDISPLAY:
|
case GST_GL_DISPLAY_ACTION_REDISPLAY:
|
||||||
//msg is out of date if the associated display is not in the map
|
//msg is out of date if the associated display is not in the map
|
||||||
if (!g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER (msg->glutWinId)))
|
if (!g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER ((guint64)msg->glutWinId)))
|
||||||
valid = FALSE;
|
valid = FALSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -955,12 +955,12 @@ gst_gl_display_setClientDrawCallback (GstGLDisplay * display, CDCB cb)
|
||||||
void
|
void
|
||||||
gst_gl_display_setVisibleWindow (GstGLDisplay * display, gboolean visible)
|
gst_gl_display_setVisibleWindow (GstGLDisplay * display, gboolean visible)
|
||||||
{
|
{
|
||||||
gst_gl_display_lock (display);
|
gst_gl_display_lock (display);
|
||||||
if (display->visible != visible)
|
if (display->visible != visible)
|
||||||
{
|
{
|
||||||
display->visible = visible;
|
display->visible = visible;
|
||||||
gst_gl_display_postMessage (GST_GL_DISPLAY_ACTION_VISIBLE, display);
|
gst_gl_display_postMessage (GST_GL_DISPLAY_ACTION_VISIBLE, display);
|
||||||
}
|
}
|
||||||
gst_gl_display_unlock (display);
|
gst_gl_display_unlock (display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1064,7 +1064,7 @@ gst_gl_display_set_windowId (GstGLDisplay* display, gulong winId)
|
||||||
if (g_hash_table_size (gst_gl_display_map) == 0)
|
if (g_hash_table_size (gst_gl_display_map) == 0)
|
||||||
{
|
{
|
||||||
g_thread_join (gst_gl_display_glutThread);
|
g_thread_join (gst_gl_display_glutThread);
|
||||||
g_print ("Glut thread joined when setting winId\n");
|
GST_DEBUG ("Glut thread joined when setting winId");
|
||||||
gst_gl_display_glutThread = NULL;
|
gst_gl_display_glutThread = NULL;
|
||||||
g_async_queue_unref (gst_gl_display_messageQueue);
|
g_async_queue_unref (gst_gl_display_messageQueue);
|
||||||
g_hash_table_unref (gst_gl_display_map);
|
g_hash_table_unref (gst_gl_display_map);
|
||||||
|
@ -1091,7 +1091,7 @@ gst_gl_display_onReshape(gint width, gint height)
|
||||||
|
|
||||||
//retrieve the display associated to the glut context
|
//retrieve the display associated to the glut context
|
||||||
glutWinId = glutGetWindow ();
|
glutWinId = glutGetWindow ();
|
||||||
display = g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER (glutWinId));
|
display = g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER ((guint64)glutWinId));
|
||||||
|
|
||||||
//glutGetWindow return 0 if no windows exists, then g_hash_table_lookup return NULL
|
//glutGetWindow return 0 if no windows exists, then g_hash_table_lookup return NULL
|
||||||
if (display == NULL) return;
|
if (display == NULL) return;
|
||||||
|
@ -1123,7 +1123,7 @@ void gst_gl_display_draw(void)
|
||||||
|
|
||||||
//retrieve the display associated to the glut context
|
//retrieve the display associated to the glut context
|
||||||
glutWinId = glutGetWindow ();
|
glutWinId = glutGetWindow ();
|
||||||
display = g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER (glutWinId));
|
display = g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER ((guint64)glutWinId));
|
||||||
|
|
||||||
//glutGetWindow return 0 if no windows exists, then g_hash_table_lookup return NULL
|
//glutGetWindow return 0 if no windows exists, then g_hash_table_lookup return NULL
|
||||||
if (display == NULL) return;
|
if (display == NULL) return;
|
||||||
|
@ -1200,12 +1200,12 @@ void gst_gl_display_onClose (void)
|
||||||
|
|
||||||
//retrieve the display associated to the glut context
|
//retrieve the display associated to the glut context
|
||||||
glutWinId = glutGetWindow ();
|
glutWinId = glutGetWindow ();
|
||||||
display = g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER (glutWinId));
|
display = g_hash_table_lookup (gst_gl_display_map, GINT_TO_POINTER ((guint64)glutWinId));
|
||||||
|
|
||||||
//glutGetWindow return 0 if no windows exists, then g_hash_table_lookup return NULL
|
//glutGetWindow return 0 if no windows exists, then g_hash_table_lookup return NULL
|
||||||
if (display == NULL) return;
|
if (display == NULL) return;
|
||||||
|
|
||||||
g_print ("on close\n");
|
GST_DEBUG ("on close");
|
||||||
|
|
||||||
gst_gl_display_lock (display);
|
gst_gl_display_lock (display);
|
||||||
display->isAlive = FALSE;
|
display->isAlive = FALSE;
|
||||||
|
@ -1218,91 +1218,91 @@ void gst_gl_display_make_texture (GstGLDisplay * display)
|
||||||
{
|
{
|
||||||
GstGLDisplayTex* tex = NULL;
|
GstGLDisplayTex* tex = NULL;
|
||||||
|
|
||||||
//check if there is a tex available in the pool
|
//check if there is a tex available in the pool
|
||||||
if (g_queue_get_length (display->texturePool))
|
if (g_queue_get_length (display->texturePool))
|
||||||
tex = g_queue_pop_head (display->texturePool);
|
tex = g_queue_pop_head (display->texturePool);
|
||||||
|
|
||||||
//one tex is available
|
//one tex is available
|
||||||
if (tex)
|
if (tex)
|
||||||
display->requestedTexture = tex->texture;
|
display->requestedTexture = tex->texture;
|
||||||
else
|
else
|
||||||
glGenTextures (1, &display->requestedTexture);
|
glGenTextures (1, &display->requestedTexture);
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture);
|
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture);
|
||||||
switch (display->requestedVideo_format) {
|
switch (display->requestedVideo_format) {
|
||||||
case GST_VIDEO_FORMAT_RGBx:
|
case GST_VIDEO_FORMAT_RGBx:
|
||||||
case GST_VIDEO_FORMAT_BGRx:
|
case GST_VIDEO_FORMAT_BGRx:
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
case GST_VIDEO_FORMAT_xRGB:
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
case GST_VIDEO_FORMAT_xBGR:
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
case GST_VIDEO_FORMAT_RGBA:
|
||||||
case GST_VIDEO_FORMAT_BGRA:
|
case GST_VIDEO_FORMAT_BGRA:
|
||||||
case GST_VIDEO_FORMAT_ARGB:
|
case GST_VIDEO_FORMAT_ARGB:
|
||||||
case GST_VIDEO_FORMAT_ABGR:
|
case GST_VIDEO_FORMAT_ABGR:
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
|
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,
|
||||||
display->requestedTextureWidth, display->requestedTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
display->requestedTextureWidth, display->requestedTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_RGB:
|
case GST_VIDEO_FORMAT_RGB:
|
||||||
case GST_VIDEO_FORMAT_BGR:
|
case GST_VIDEO_FORMAT_BGR:
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
|
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB,
|
||||||
display->requestedTextureWidth, display->requestedTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
display->requestedTextureWidth, display->requestedTextureHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
case GST_VIDEO_FORMAT_YUY2:
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
case GST_VIDEO_FORMAT_UYVY:
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
|
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
|
||||||
display->requestedTextureWidth, display->requestedTextureHeight,
|
display->requestedTextureWidth, display->requestedTextureHeight,
|
||||||
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
//one tex is available
|
//one tex is available
|
||||||
if (tex)
|
if (tex)
|
||||||
display->requestedTexture_u = tex->texture_u;
|
display->requestedTexture_u = tex->texture_u;
|
||||||
else
|
else
|
||||||
glGenTextures (1, &display->requestedTexture_u);
|
glGenTextures (1, &display->requestedTexture_u);
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture_u);
|
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture_u);
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||||
display->requestedTextureWidth, display->requestedTextureHeight,
|
display->requestedTextureWidth, display->requestedTextureHeight,
|
||||||
0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||||
display->requestedTextureWidth, display->requestedTextureHeight,
|
display->requestedTextureWidth, display->requestedTextureHeight,
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
//one tex is available
|
//one tex is available
|
||||||
if (tex)
|
if (tex)
|
||||||
display->requestedTexture_u = tex->texture_u;
|
display->requestedTexture_u = tex->texture_u;
|
||||||
else
|
else
|
||||||
glGenTextures (1, &display->requestedTexture_u);
|
glGenTextures (1, &display->requestedTexture_u);
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture_u);
|
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture_u);
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||||
GST_ROUND_UP_2 (display->requestedTextureWidth) / 2,
|
GST_ROUND_UP_2 (display->requestedTextureWidth) / 2,
|
||||||
GST_ROUND_UP_2 (display->requestedTextureHeight) / 2,
|
GST_ROUND_UP_2 (display->requestedTextureHeight) / 2,
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
|
||||||
//one tex is available
|
//one tex is available
|
||||||
if (tex)
|
if (tex)
|
||||||
display->requestedTexture_v = tex->texture_v;
|
display->requestedTexture_v = tex->texture_v;
|
||||||
else
|
else
|
||||||
glGenTextures (1, &display->requestedTexture_v);
|
glGenTextures (1, &display->requestedTexture_v);
|
||||||
|
|
||||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture_v);
|
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->requestedTexture_v);
|
||||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||||
GST_ROUND_UP_2 (display->requestedTextureWidth) / 2,
|
GST_ROUND_UP_2 (display->requestedTextureWidth) / 2,
|
||||||
GST_ROUND_UP_2 (display->requestedTextureHeight) / 2,
|
GST_ROUND_UP_2 (display->requestedTextureHeight) / 2,
|
||||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
if (tex)
|
if (tex)
|
||||||
g_free (tex);
|
g_free (tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1838,18 +1838,18 @@ gst_gl_display_fill_video (GstGLDisplay* display)
|
||||||
gint offsetV = 0;
|
gint offsetV = 0;
|
||||||
|
|
||||||
switch (outputVideo_format)
|
switch (outputVideo_format)
|
||||||
{
|
{
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
offsetU = 1;
|
offsetU = 1;
|
||||||
offsetV = 2;
|
offsetV = 2;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_YV12:
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
offsetU = 2;
|
offsetU = 2;
|
||||||
offsetV = 1;
|
offsetV = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
}
|
}
|
||||||
|
|
||||||
glReadPixels (0, 0, width, height, GL_LUMINANCE,
|
glReadPixels (0, 0, width, height, GL_LUMINANCE,
|
||||||
GL_UNSIGNED_BYTE, data);
|
GL_UNSIGNED_BYTE, data);
|
||||||
|
@ -1880,15 +1880,15 @@ gst_gl_display_fill_video (GstGLDisplay* display)
|
||||||
GLhandleARB
|
GLhandleARB
|
||||||
gst_gl_display_loadGLSLprogram (gchar* textFProgram)
|
gst_gl_display_loadGLSLprogram (gchar* textFProgram)
|
||||||
{
|
{
|
||||||
GLhandleARB FHandle = 0;
|
GLhandleARB FHandle = 0;
|
||||||
GLhandleARB PHandle = 0;
|
GLhandleARB PHandle = 0;
|
||||||
gchar s[32768];
|
gchar s[32768];
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
//Set up program objects
|
//Set up program objects
|
||||||
PHandle = glCreateProgramObjectARB ();
|
PHandle = glCreateProgramObjectARB ();
|
||||||
|
|
||||||
//Compile the shader
|
//Compile the shader
|
||||||
FHandle = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);
|
FHandle = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);
|
||||||
glShaderSourceARB (FHandle, 1, (const GLcharARB**)&textFProgram, NULL);
|
glShaderSourceARB (FHandle, 1, (const GLcharARB**)&textFProgram, NULL);
|
||||||
glCompileShaderARB (FHandle);
|
glCompileShaderARB (FHandle);
|
||||||
|
@ -1896,7 +1896,7 @@ gst_gl_display_loadGLSLprogram (gchar* textFProgram)
|
||||||
//Print the compilation log
|
//Print the compilation log
|
||||||
glGetObjectParameterivARB (FHandle, GL_OBJECT_COMPILE_STATUS_ARB, &i);
|
glGetObjectParameterivARB (FHandle, GL_OBJECT_COMPILE_STATUS_ARB, &i);
|
||||||
glGetInfoLogARB (FHandle, sizeof(s)/sizeof(char), NULL, s);
|
glGetInfoLogARB (FHandle, sizeof(s)/sizeof(char), NULL, s);
|
||||||
g_print ("Compile Log: %s\n", s);
|
GST_DEBUG ("Compile Log: %s", s);
|
||||||
|
|
||||||
//link the shader
|
//link the shader
|
||||||
glAttachObjectARB (PHandle, FHandle);
|
glAttachObjectARB (PHandle, FHandle);
|
||||||
|
@ -1904,9 +1904,9 @@ gst_gl_display_loadGLSLprogram (gchar* textFProgram)
|
||||||
|
|
||||||
//Print the link log
|
//Print the link log
|
||||||
glGetInfoLogARB (PHandle, sizeof(s)/sizeof(char), NULL, s);
|
glGetInfoLogARB (PHandle, sizeof(s)/sizeof(char), NULL, s);
|
||||||
g_print ("Link Log: %s\n", s);
|
GST_DEBUG ("Link Log: %s", s);
|
||||||
|
|
||||||
return PHandle;
|
return PHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1914,7 +1914,6 @@ gst_gl_display_loadGLSLprogram (gchar* textFProgram)
|
||||||
void
|
void
|
||||||
checkFramebufferStatus(void)
|
checkFramebufferStatus(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
|
||||||
|
|
||||||
switch(status)
|
switch(status)
|
||||||
|
@ -1923,10 +1922,10 @@ checkFramebufferStatus(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
||||||
g_print("GL_FRAMEBUFFER_UNSUPPORTED_EXT\n");
|
GST_DEBUG("GL_FRAMEBUFFER_UNSUPPORTED_EXT");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_print("General FBO error\n");
|
GST_DEBUG("General FBO error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue