LDFLAGS = -Wall\r
LIBS = -L/opt/vc/lib -lpthread -lrt -lEGL -lGLESv2 -lopenmaxil -lbcm_host -lavcodec -lavformat -lavutil\r
\r
-OBJECTS += main.o threadp.o osdopengl.o surfaceopengl.o ledraspberry.o mtdraspberry.o videovpeogl.o audiovpe.o wjpegsimple.o remotelinux.o\r
+OBJECTS += main.o threadp.o osdopengl.o surfaceopengl.o ledraspberry.o mtdraspberry.o videovpeogl.o audiovpe.o wjpegsimple.o remotelinux.o glshader.o glosdshader.o glyuv400shader.o\r
LIBS+= -ljpeg\r
CROSSLIBS =\r
INCLUDES = -DVOMP_PLATTFORM_RASPBERRY -I/opt/vc/include \r
--- /dev/null
+/*\r
+ Copyright 2012 Marten Richter\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+*/\r
+#include "glosdshader.h"\r
+\r
+const GLchar generic_vertex_shader[] =\r
+ "attribute vec4 vec_pos;\n"\r
+ "attribute vec2 tex_coord;\n"\r
+ "varying vec2 out_texCoord;\n"\r
+ "void main()\n"\r
+ "{\n"\r
+ " gl_Position=vec_pos;\n"\r
+ " out_texCoord=tex_coord;\n"\r
+ "}\n";\r
+\r
+const GLchar osd_frag_shader[] =\r
+ "precision mediump float;\n"\r
+ "uniform sampler2D texture;\n"\r
+ "varying vec2 out_texCoord;\n"\r
+ "void main()\n"\r
+ "{\n"\r
+ " gl_FragColor=texture2D(texture,out_texCoord);\n"\r
+ "}\n";\r
+\r
+GLOsdShader::GLOsdShader(): GLShader("GLOsdShader")\r
+{\r
+\r
+}\r
+\r
+GLOsdShader::~GLOsdShader()\r
+{\r
+ //parent does everything\r
+}\r
+\r
+int GLOsdShader::init()\r
+{\r
+ if (!initShaders(generic_vertex_shader,osd_frag_shader)) {\r
+ return 0;\r
+ }\r
+ osd_sampler_loc=glGetUniformLocation(shad_program,"texture");\r
+ return 1;\r
+\r
+}\r
+\r
+int GLOsdShader::deinit()\r
+{\r
+ return deinitShaders();\r
+}\r
+\r
+int GLOsdShader::PrepareRendering(GLuint osd_tex){ // This Function setups the rendering pipeline according to the shaders standards\r
+ glUseProgram(shad_program);\r
+\r
+ glActiveTexture(GL_TEXTURE0);\r
+ glBindTexture(GL_TEXTURE_2D,osd_tex);\r
+\r
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);\r
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);\r
+\r
+ glUniform1i(osd_sampler_loc,0);\r
+ return 1;\r
+\r
+}\r
+\r
+int GLOsdShader::BindAttributes()\r
+{\r
+ glBindAttribLocation(shad_program,0,"vec_pos");\r
+ glBindAttribLocation(shad_program,1,"tex_coord");\r
+ return 1;\r
+}\r
--- /dev/null
+/*\r
+ Copyright 2012 Marten Richter\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+*/\r
+\r
+#ifndef GL_OSDSHADER_H\r
+#define GL_OSDSHADER_H\r
+\r
+#include "glshader.h"\r
+\r
+class GLOsdShader: public GLShader {\r
+public:\r
+ GLOsdShader();\r
+ virtual ~GLOsdShader();\r
+\r
+ int init();\r
+ int deinit();\r
+\r
+ int PrepareRendering(GLuint osd_tex); // This Function setups the rendering pipeline according to the shaders standards\r
+\r
+protected:\r
+ virtual int BindAttributes();\r
+\r
+ GLint osd_sampler_loc;\r
+\r
+};\r
+\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ Copyright 2012 Marten Richter\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+*/\r
+#include "glshader.h"\r
+\r
+GLShader::GLShader(const char* name)\r
+{\r
+ initted=0;\r
+ objname=name;\r
+}\r
+\r
+GLShader::~GLShader()\r
+{\r
+ if (initted) {\r
+ deinitShaders();\r
+ }\r
+\r
+\r
+\r
+}\r
+\r
+int GLShader::initShaders(const char * vertex_shad,const char *fragment_shad)\r
+{\r
+ vertex_shader=CreateShader(vertex_shad, GL_VERTEX_SHADER);\r
+ frag_shader=CreateShader(fragment_shad, GL_FRAGMENT_SHADER);\r
+\r
+ // Create the program for osd rendering\r
+ shad_program=glCreateProgram();\r
+ if (shad_program==0) {\r
+ Log::getInstance()->log("GLShader", Log::WARN, "%s: Creating glsl program failed!%d",objname,glGetError());\r
+ return 0;\r
+ }\r
+ glAttachShader(shad_program,vertex_shader);\r
+ glAttachShader(shad_program,frag_shader);\r
+ if (!BindAttributes()) {\r
+ return 0;\r
+ }\r
+ glLinkProgram(shad_program);\r
+\r
+\r
+ GLint link_status;\r
+ glGetProgramiv(shad_program,GL_LINK_STATUS, &link_status);\r
+\r
+ if (!link_status) {\r
+ char buffer[1024];\r
+ glGetProgramInfoLog(shad_program,1024,NULL,buffer);\r
+ Log::getInstance()->log("GLShader", Log::WARN, "%s: Compiling Programm failed!",objname);\r
+ Log::getInstance()->log("GLShader", Log::WARN, "%s",buffer);\r
+ glDeleteProgram(shad_program);\r
+ return 0;\r
+ }\r
+\r
+}\r
+\r
+GLuint GLShader::CreateShader(const GLchar * source, GLenum type)\r
+{\r
+ GLuint ret_shad=0;\r
+\r
+ ret_shad=glCreateShader(type);\r
+ if (ret_shad==0 ) {\r
+ Log::getInstance()->log("GLShader", Log::WARN, "%s: Creating Shader failed! %d",objname, glGetError());\r
+ return 0;\r
+ }\r
+ glShaderSource(ret_shad,1,&source,NULL);\r
+ glCompileShader(ret_shad);\r
+ GLint comp_status;\r
+ glGetShaderiv(ret_shad,GL_COMPILE_STATUS, &comp_status);\r
+\r
+ if (!comp_status) {\r
+ char buffer[1024];\r
+ Log::getInstance()->log("GLShader", Log::WARN, "%s: Compiling Shader failed!",objname);\r
+ glGetShaderInfoLog(ret_shad,1024,NULL,buffer);\r
+ Log::getInstance()->log("GLShader", Log::WARN, "%s: %s",objname,buffer);\r
+ glDeleteShader(ret_shad);\r
+ return 0;\r
+ }\r
+ return ret_shad;\r
+}\r
+\r
+int GLShader::deinitShaders()\r
+{\r
+ if (frag_shader!=0) glDeleteShader(frag_shader);\r
+ frag_shader=0;\r
+ if (vertex_shader!=0) glDeleteShader(vertex_shader);\r
+ vertex_shader=0;\r
+ if (shad_program!=0) glDeleteProgram(shad_program);\r
+ shad_program=0;\r
+}\r
+\r
--- /dev/null
+/*\r
+ Copyright 2012 Marten Richter\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+*/\r
+\r
+#ifndef GL_SHADER_H\r
+#define GL_SHADER_H\r
+\r
+#include <GLES2/gl2.h>\r
+#include "log.h"\r
+\r
+class GLShader {\r
+public:\r
+ GLShader(const char* name);\r
+ virtual ~GLShader();\r
+\r
+ int initShaders(const GLchar * vertex_shad,const GLchar *fragment_shad);\r
+\r
+ int deinitShaders();\r
+\r
+\r
+\r
+protected:\r
+\r
+ GLuint CreateShader(const GLchar * source, GLenum type);\r
+\r
+ virtual int BindAttributes() {return 1;};\r
+\r
+ GLuint vertex_shader;\r
+ GLuint frag_shader;\r
+\r
+ GLuint shad_program;\r
+ int initted;\r
+ const char* objname;\r
+\r
+};\r
+\r
+\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ Copyright 2012 Marten Richter\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+*/\r
+#include "glyuv400shader.h"\r
+\r
+const GLchar generic_vertex_shader[] =\r
+ "attribute vec4 vec_pos;\n"\r
+ "attribute vec2 tex_coord;\n"\r
+ "varying vec2 out_texCoord;\n"\r
+ "void main()\n"\r
+ "{\n"\r
+ " gl_Position=vec_pos;\n"\r
+ " out_texCoord=tex_coord;\n"\r
+ "}\n";\r
+\r
+const GLchar frame_frag_shader[] =\r
+ "precision mediump float;\n"\r
+ "uniform sampler2D textureU;\n"\r
+ "uniform sampler2D textureV;\n"\r
+ "uniform sampler2D textureY;\n"\r
+ "const float uv_corr=0.5;\n"\r
+ "const float y_corr=0.0625;\n"\r
+ "const mat3 yuvtransform= mat3( 1.164 ,0.0 ,1.596 ,\n"\r
+ " 1.164 ,-0.391,-0.813 ,\n"\r
+ " 1.164,2.018 , 0.0 );\n"\r
+// "const mat3 yuvtransform= mat3( 1. ,1. ,1. ,\n"\r
+// " 0.0 ,-0.3960,2.029 ,\n"\r
+// " 1.140,-0.581 , 0.0 );\n"\r
+// "const mat3 yuvtransform= mat3( 1. ,0 ,0. ,\n"\r
+// " 0.0 ,1.,0. ,\n"\r
+// " 0.,0. , 1.0 );\n"\r
+// "const mat3 yuvtransform= mat3( 1. ,1. ,1. ,\n"\r
+// " 0.0 ,-0.03960,0.2029 ,\n"\r
+// " 0.1140,-0.0581 , 0.0 );\n"\r
+ "varying vec2 out_texCoord;\n"\r
+ "void main()\n"\r
+ "{\n"\r
+ " vec3 help;\n"\r
+ "help.x=texture2D(textureY,out_texCoord).r-y_corr;\n"\r
+ "help.y=texture2D(textureU,out_texCoord).r-uv_corr;\n"\r
+ "help.z=texture2D(textureV,out_texCoord).r-uv_corr;\n" //-uv_corr;\n"\r
+ " gl_FragColor.rgb=help*yuvtransform;\n"\r
+ " gl_FragColor.a=1.;\n"\r
+ "}\n";\r
+\r
+GLYuv400Shader::GLYuv400Shader(): GLShader("GLYuv400Shader")\r
+{\r
+\r
+}\r
+\r
+GLYuv400Shader::~GLYuv400Shader()\r
+{\r
+ //parent does everything\r
+}\r
+\r
+int GLYuv400Shader::init() {\r
+ if (!initShaders(generic_vertex_shader, frame_frag_shader)) {\r
+ return 0;\r
+ }\r
+ frame_sampler_locY = glGetUniformLocation(shad_program, "textureY");\r
+ // Log::getInstance()->log("OSD", Log::WARN, "uniform location %x %x",frame_sampler_locY,glGetError());\r
+ frame_sampler_locU = glGetUniformLocation(shad_program, "textureU");\r
+ //Log::getInstance()->log("OSD", Log::WARN, "uniform location %x %x",frame_sampler_locU,glGetError());\r
+ frame_sampler_locV = glGetUniformLocation(shad_program, "textureV");\r
+ return 1;\r
+\r
+}\r
+\r
+int GLYuv400Shader::deinit()\r
+{\r
+ return deinitShaders();\r
+}\r
+\r
+int GLYuv400Shader::PrepareRendering(GLuint y_tex, GLuint u_tex, GLuint v_tex) { // This Function setups the rendering pipeline according to the shaders standards\r
+ glUseProgram(shad_program);\r
+ //Log::getInstance()->log("OSD", Log::WARN, "mark1 glerror %x",glGetError());\r
+\r
+\r
+ //Log::getInstance()->log("OSD", Log::WARN, "mark2 glerror %x",glGetError());\r
+\r
+\r
+ glActiveTexture( GL_TEXTURE2);\r
+ glBindTexture(GL_TEXTURE_2D, v_tex);\r
+ glUniform1i(frame_sampler_locV, 2);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
+\r
+ glActiveTexture( GL_TEXTURE1);\r
+ glBindTexture(GL_TEXTURE_2D, u_tex);\r
+ glUniform1i(frame_sampler_locU, 1);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
+\r
+ glActiveTexture( GL_TEXTURE0);\r
+ glBindTexture(GL_TEXTURE_2D, y_tex);\r
+ glUniform1i(frame_sampler_locY, 0);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
+ return 1;\r
+\r
+}\r
+\r
+int GLYuv400Shader::BindAttributes()\r
+{\r
+ glBindAttribLocation(shad_program,0,"vec_pos");\r
+ glBindAttribLocation(shad_program,1,"tex_coord");\r
+ return 1;\r
+}\r
--- /dev/null
+/*\r
+ Copyright 2012 Marten Richter\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+*/\r
+\r
+#ifndef GL_YUV400SHADER_H\r
+#define GL_YUV400SHADER_H\r
+\r
+#include "glshader.h"\r
+\r
+class GLYuv400Shader: public GLShader {\r
+public:\r
+ GLYuv400Shader();\r
+ virtual ~GLYuv400Shader();\r
+\r
+ int init();\r
+ int deinit();\r
+\r
+ int PrepareRendering(GLuint y_tex,GLuint u_tex,GLuint v_tex); // This Function setups the rendering pipeline according to the shaders standards\r
+\r
+protected:\r
+ virtual int BindAttributes();\r
+\r
+ GLint frame_sampler_locY;\r
+ GLint frame_sampler_locU;\r
+ GLint frame_sampler_locV;\r
+\r
+};\r
+\r
+\r
+#endif\r
#include "message.h"\r
#include "command.h"\r
\r
-#include "shaders/generic__vertex_shader.h"\r
-#include "shaders/osd__frag_shader.h"\r
-#include "shaders/frame__frag_shader.h"\r
\r
#define BACKBUFFER_WIDTH 1920\r
#define BACKBUFFER_HEIGHT 1080\r
lastrendertime=getTimeMS();\r
display_height=0;\r
display_width=0;\r
- osd_shader=0;\r
- gen_shader=0;\r
- osd_program=0;\r
- frame_program=0;\r
\r
#ifdef BENCHMARK_FPS\r
last_benchmark_time=getTimeMS();\r
\r
if (egl_display==EGL_NO_DISPLAY) {\r
Log::getInstance()->log("OSD", Log::WARN, "Could not get egl display! %x",eglGetError());\r
+ glmutex.Unlock();\r
return 0;\r
}\r
\r
\r
if (eglInitialize(egl_display, NULL, NULL)==EGL_FALSE) {\r
Log::getInstance()->log("OSD", Log::WARN, "Initialising display failed! %x",eglGetError());\r
+ glmutex.Unlock();\r
return 0;\r
}\r
\r
\r
if (eglChooseConfig(egl_display, attributs, &egl_ourconfig, 1, &number)==EGL_FALSE) {\r
Log::getInstance()->log("OSD", Log::WARN, "Choosing egl config failed! %d",eglGetError());\r
+ glmutex.Unlock();\r
return 0;\r
}\r
\r
egl_context=eglCreateContext(egl_display,egl_ourconfig,EGL_NO_CONTEXT,attr_context);\r
if (egl_context==EGL_NO_CONTEXT) {\r
Log::getInstance()->log("OSD", Log::WARN, "Creating egl context failed! %d",eglGetError());\r
+ glmutex.Unlock();\r
return 0;\r
}\r
\r
display_width=display_height=0;\r
if (graphics_get_display_size(0, &display_width, &display_height)<0) {\r
Log::getInstance()->log("OSD", Log::WARN, "Getting display size failed! (BCM API) ");\r
+ glmutex.Unlock();\r
return 0;\r
}\r
Log::getInstance()->log("OSD", Log::NOTICE, "Displaysize is %d x %d ",display_width, display_height);\r
egl_surface = eglCreateWindowSurface(egl_display,egl_ourconfig, &nativewindow,NULL );\r
if (egl_surface==EGL_NO_SURFACE) {\r
Log::getInstance()->log("OSD", Log::WARN, "Creating egl window surface failed!");\r
+ glmutex.Unlock();\r
return 0;\r
}\r
\r
if (eglMakeCurrent(egl_display, egl_surface, egl_surface, egl_context)== EGL_FALSE) {\r
Log::getInstance()->log("OSD", Log::WARN, "Making egl Current failed");\r
+ glmutex.Unlock();\r
return 0;\r
}\r
// Test stuff\r
\r
//Preparing the Shaders\r
\r
- gen_shader=CreateShader(generic_vertex_shader, GL_VERTEX_SHADER);\r
+ if (!osd_shader.init()) {\r
+ Log::getInstance()->log("OSD", Log::WARN, "Init Osd Shader failed");\r
+ glmutex.Unlock();\r
+ return 0;\r
+ }\r
+ if (!yuv400_shader.init()) {\r
+ Log::getInstance()->log("OSD", Log::WARN, "Init Yuv400 Shader failed");\r
+ glmutex.Unlock();\r
+ return 0;\r
+ }\r
+\r
+ /* gen_shader=CreateShader(generic_vertex_shader, GL_VERTEX_SHADER);\r
osd_shader=CreateShader(osd_frag_shader, GL_FRAGMENT_SHADER);\r
\r
// Create the program for osd rendering\r
frame_sampler_locU=glGetUniformLocation(frame_program,"textureU");\r
//Log::getInstance()->log("OSD", Log::WARN, "uniform location %x %x",frame_sampler_locU,glGetError());\r
frame_sampler_locV=glGetUniformLocation(frame_program,"textureV");\r
-\r
+*/\r
\r
\r
glClearColor(0.0f,0.0f,0.0f,1.f);\r
}\r
\r
\r
-GLuint OsdOpenGL::CreateShader(const GLchar * source, GLenum type)\r
-{\r
- GLuint ret_shad=0;\r
\r
- ret_shad=glCreateShader(type);\r
- if (ret_shad==0 ) {\r
- Log::getInstance()->log("OSD", Log::WARN, "Creating Shader failed! %d",glGetError());\r
- return 0;\r
- }\r
- glShaderSource(ret_shad,1,&source,NULL);\r
- glCompileShader(ret_shad);\r
- GLint comp_status;\r
- glGetShaderiv(ret_shad,GL_COMPILE_STATUS, &comp_status);\r
-\r
- if (!comp_status) {\r
- char buffer[1024];\r
- Log::getInstance()->log("OSD", Log::WARN, "Compiling Shader failed!");\r
- glGetShaderInfoLog(ret_shad,1024,NULL,buffer);\r
- Log::getInstance()->log("OSD", Log::WARN, "%s",buffer);\r
- glDeleteShader(ret_shad);\r
- return 0;\r
- }\r
- return ret_shad;\r
-}\r
\r
\r
void OsdOpenGL::InitVertexBuffer(float scalex,float scaley)\r
(((VideoVPEOGL*)Video::getInstance())->shutdownUsingOSDObjects());\r
\r
\r
- if (osd_shader!=0) glDeleteShader(osd_shader);\r
- if (gen_shader!=0) glDeleteShader(gen_shader);\r
- if (osd_program!=0) glDeleteProgram(osd_program);\r
+ osd_shader.deinit();\r
+ yuv400_shader.deinit();\r
\r
glClear(GL_COLOR_BUFFER_BIT);\r
eglSwapBuffers(egl_display, egl_surface);\r
\r
if (frame) {\r
//Log::getInstance()->log("OSD", Log::WARN, "mark1 glerror %x",glGetError());\r
- glUseProgram(frame_program);\r
+ /* glUseProgram(frame_program);\r
//Log::getInstance()->log("OSD", Log::WARN, "mark1 glerror %x",glGetError());\r
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), osdvertices);\r
glEnableVertexAttribArray(0);\r
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), &(osdvertices[0].u));\r
glEnableVertexAttribArray(1);\r
- glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), osdvertices);\r
- glEnableVertexAttribArray(0);\r
- glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), &(osdvertices[0].u));\r
- glEnableVertexAttribArray(1);\r
\r
\r
//Log::getInstance()->log("OSD", Log::WARN, "mark2 glerror %x",glGetError());\r
glBindTexture(GL_TEXTURE_2D,frame->textures[0]);\r
glUniform1i(frame_sampler_locY,0);\r
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);\r
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);\r
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);*/\r
+\r
+ yuv400_shader.PrepareRendering(frame->textures[0],frame->textures[1],frame->textures[2]);\r
+\r
+\r
\r
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), osdvertices);\r
+ glEnableVertexAttribArray(0);\r
+ glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), &(osdvertices[0].u));\r
+ glEnableVertexAttribArray(1);\r
\r
\r
//Log::getInstance()->log("OSD", Log::WARN, "mark8 glerror %x %x",glGetError(),osd_sampler_loc);\r
\r
\r
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r
- glEnable(GL_BLEND);\r
- glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,GL_ZERO,GL_ONE);\r
+\r
\r
}\r
\r
- glUseProgram(osd_program);\r
+\r
+ /*glUseProgram(osd_program);\r
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), osdvertices);\r
glEnableVertexAttribArray(0);\r
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), &(osdvertices[0].u));\r
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);\r
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);\r
\r
- glUniform1i(osd_sampler_loc,0);\r
-\r
- if (0) { //This is ok for ffmpeg rendering not OMX\r
- glEnable(GL_BLEND);\r
- glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,GL_ZERO,GL_ONE);\r
+ glUniform1i(osd_sampler_loc,0);*/\r
\r
- }\r
-/* glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX),\r
- (GLvoid*)(((char*)osdvertices)+3*sizeof(GLfloat)));\r
- glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX),\r
- (GLvoid*)(((char*)osdvertices)+3*sizeof(GLfloat)+sizeof(OSDCOLOR)));*/\r
- //glDisable(GL_LIGHTING);\r
- //glEnable(GL_TEXTURE_2D);\r
- //glEnable(GL_BLEND);\r
- //glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);\r
- //glDepthFunc(GL_ALWAYS);\r
- //glDisable(GL_DEPTH_TEST);\r
- //glDisable(GL_STENCIL_TEST);\r
- //glDisable(GL_CULL_FACE);\r
+ osd_shader.PrepareRendering(((SurfaceOpenGL*)screen)->getTexture());\r
\r
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), osdvertices);\r
+ glEnableVertexAttribArray(0);\r
+ glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), &(osdvertices[0].u));\r
+ glEnableVertexAttribArray(1);\r
\r
\r
-/*\r
- glActiveTexture(GL_TEXTURE0);\r
- glBindTexture(GL_TEXTURE_2D,((SurfaceOpenGL*)screen)->getTexture());\r
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);\r
- glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);*/\r
-// glUniform1i(mTextureUniformHandle, present);\r
+ if (frame!=NULL) { //This is ok for ffmpeg rendering not OMX\r
+ glEnable(GL_BLEND);\r
+ glBlendFuncSeparate (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,GL_ZERO,GL_ONE);\r
\r
+ } else {\r
+ glDisable(GL_BLEND);\r
+ }\r
\r
\r
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);\r
\r
- //glDrawElements(GL_TRIANGLES, sizeof(osdindices)/sizeof(osdindices[0]), GL_UNSIGNED_BYTE, 0);\r
-\r
-\r
-\r
-\r
-/* glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX), 0);\r
- glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX),\r
- (GLvoid*)(3*sizeof(GLfloat)));\r
- glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE,sizeof(OSDVERTEX),\r
- (GLvoid*)(3*sizeof(GLfloat)+sizeof(OSDCOLOR)));*/\r
-\r
- //glDisable(GL_BLEND);\r
- //glDisable(GL_TEXTURE_2D);\r
\r
+\r
//Show it to the user!\r
eglSwapBuffers(egl_display, egl_surface);\r
\r
#include "mutex.h"\r
#include "videovpeogl.h"\r
\r
+#include "glosdshader.h"\r
+#include "glyuv400shader.h"\r
+\r
\r
\r
\r
\r
//Maybe move the following stuff to a generic opengl object also for boosting DCT etc.\r
\r
- GLuint CreateShader(const GLchar * source, GLenum type);\r
+\r
\r
void threadMethod();\r
void threadPostStopCleanup();\r
GLubyte osdindices[6];\r
\r
\r
- GLuint osd_shader;\r
+/* GLuint osd_shader;\r
GLuint gen_shader;\r
\r
GLuint osd_program;\r
GLint frame_sampler_locU;\r
GLint frame_sampler_locV;\r
\r
- GLint osd_sampler_loc;\r
+ GLint osd_sampler_loc;*/\r
+ GLOsdShader osd_shader;\r
+ GLYuv400Shader yuv400_shader;\r
+\r
\r
\r
\r
+++ /dev/null
-/*\r
- Copyright 2012 Marten Richter\r
-\r
- This file is part of VOMP.\r
-\r
- VOMP is free software; you can redistribute it and/or modify\r
- it under the terms of the GNU General Public License as published by\r
- the Free Software Foundation; either version 2 of the License, or\r
- (at your option) any later version.\r
-\r
- VOMP is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with VOMP; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
-*/\r
-\r
-#ifndef FRAME_FRAG_SHADER_H\r
-#define FRAME_FRAG_SHADER_H\r
-\r
-const GLchar frame_frag_shader[] =\r
- "precision mediump float;\n"\r
- "uniform sampler2D textureU;\n"\r
- "uniform sampler2D textureV;\n"\r
- "uniform sampler2D textureY;\n"\r
- "const float uv_corr=0.5;\n"\r
- "const float y_corr=0.0625;\n"\r
- "const mat3 yuvtransform= mat3( 1.164 ,0.0 ,1.596 ,\n"\r
- " 1.164 ,-0.391,-0.813 ,\n"\r
- " 1.164,2.018 , 0.0 );\n"\r
-// "const mat3 yuvtransform= mat3( 1. ,1. ,1. ,\n"\r
-// " 0.0 ,-0.3960,2.029 ,\n"\r
-// " 1.140,-0.581 , 0.0 );\n"\r
-// "const mat3 yuvtransform= mat3( 1. ,0 ,0. ,\n"\r
-// " 0.0 ,1.,0. ,\n"\r
-// " 0.,0. , 1.0 );\n"\r
-// "const mat3 yuvtransform= mat3( 1. ,1. ,1. ,\n"\r
-// " 0.0 ,-0.03960,0.2029 ,\n"\r
-// " 0.1140,-0.0581 , 0.0 );\n"\r
- "varying vec2 out_texCoord;\n"\r
- "void main()\n"\r
- "{\n"\r
- // " vec3 inputcoloryuv=vec3(texture2D(textureY,out_texCoord).r-y_corr,0,0);\n"\r
- //" texture2D(textureU,out_texCoord)-uv_corr,"\r
- //" texture2D(textureV,out_texCoord)-uv_corr);"\r
- // " gl_FragColor.rgb=yuvtransform*inputcoloryuv;\n"\r
- " vec3 help;\n"\r
- "help.x=texture2D(textureY,out_texCoord).r-y_corr;\n"\r
- "help.y=texture2D(textureU,out_texCoord).r-uv_corr;\n"\r
- "help.z=texture2D(textureV,out_texCoord).r-uv_corr;\n" //-uv_corr;\n"\r
- " gl_FragColor.rgb=help*yuvtransform;\n"\r
- //" gl_FragColor.g=texture2D(textureU,out_texCoord).r;\n"\r
- //" gl_FragColor.b=texture2D(textureV,out_texCoord).r;\n"\r
- " gl_FragColor.a=1.;\n"\r
-// " gl_FragColor=texture2D(texture,out_texCoord);\n"\r
- //" vec4 temp=vec4(0.3,0.4,0.5,0.5);\n"\r
- //"gl_FragColor=temp;\n"\r
- "}\n";\r
-#endif\r
-\r
+++ /dev/null
-/*\r
- Copyright 2012 Marten Richter\r
-\r
- This file is part of VOMP.\r
-\r
- VOMP is free software; you can redistribute it and/or modify\r
- it under the terms of the GNU General Public License as published by\r
- the Free Software Foundation; either version 2 of the License, or\r
- (at your option) any later version.\r
-\r
- VOMP is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with VOMP; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
-*/\r
-\r
-#ifndef OSD_GEN_SHADER_H\r
-#define OSD_GEN_SHADER_H\r
-\r
-const GLchar generic_vertex_shader[] =\r
- "attribute vec4 vec_pos;\n"\r
- "attribute vec2 tex_coord;\n"\r
- "varying vec2 out_texCoord;\n"\r
- "void main()\n"\r
- "{\n"\r
- " gl_Position=vec_pos;\n"\r
- " out_texCoord=tex_coord;\n"\r
- "}\n";\r
-#endif\r
+++ /dev/null
-/*\r
- Copyright 2012 Marten Richter\r
-\r
- This file is part of VOMP.\r
-\r
- VOMP is free software; you can redistribute it and/or modify\r
- it under the terms of the GNU General Public License as published by\r
- the Free Software Foundation; either version 2 of the License, or\r
- (at your option) any later version.\r
-\r
- VOMP is distributed in the hope that it will be useful,\r
- but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- GNU General Public License for more details.\r
-\r
- You should have received a copy of the GNU General Public License\r
- along with VOMP; if not, write to the Free Software\r
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
-*/\r
-\r
-#ifndef OSD_FRAG_SHADER_H\r
-#define OSD_FRAG_SHADER_H\r
-\r
-const GLchar osd_frag_shader[] =\r
- "precision mediump float;\n"\r
- "uniform sampler2D texture;\n"\r
- "varying vec2 out_texCoord;\n"\r
- "void main()\n"\r
- "{\n"\r
- // " vec4 temp=vec4(0.3,0.4,0.5,0.5);\n"\r
- // " temp.r=0.6;\n"\r
- " gl_FragColor=texture2D(texture,out_texCoord);\n"\r
- // " temp.r=temp2.r;\n"\r
- // " temp.b=temp2.b;\n"\r
- // "gl_FragColor=temp;\n"\r
- "}\n";\r
-#endif\r
-//"vec4 temp=vec4(0.3,0.4,0.5);\n"\r
-// "temp.a=1.0f;\n"\r
-// " gl_FragColor.r=texture2D(texture,out_texCoord.st).r;\n"\r
-// " gl_FragColor.b=0.2f;\n"\r
-// " gl_FragColor.g=0.2f;\n"\r
-// "gl_FragColor.a=0.5f;\n"\r
-//"gl_FragColor=vec4(0.3,0.4,0.5,0.5);\n"\r
dec_frame_ff_all.clear();
dec_frame_ff_mutex.Unlock();
dec_frame_ff_decoding=NULL;
-
while (ogl_frame_outside) {
Log::getInstance()->log("Video", Log::NOTICE, "Wait for ogl frame from outside");
MILLISLEEP(20);
if ((num_frames%100)==0) {
float fps=1000./(float)(time_in_decoder);
fps*=((float)num_frames);
- Log::getInstance()->log("OSD", Log::NOTICE, "Current Pure Decoding FPS %g", fps);
+ Log::getInstance()->log("Video", Log::NOTICE, "Current Pure Decoding FPS %g", fps);
}
#endif
if (dec_bytes<0) {