--- /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 "glyuv444shader.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 textureYUV;\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=texture2D(textureYUV,out_texCoord).rgb-vec3(y_corr,uv_corr,uv_corr);\n"\r
+ "gl_FragColor.rgb=help*yuvtransform;\n"\r
+ "gl_FragColor.a=1.;\n"\r
+ "}\n";\r
+\r
+GLYuv444Shader::GLYuv444Shader(): GLShader("GLYuv444Shader")\r
+{\r
+\r
+}\r
+\r
+GLYuv444Shader::~GLYuv444Shader()\r
+{\r
+ //parent does everything\r
+}\r
+\r
+int GLYuv444Shader::init() {\r
+ if (!initShaders(generic_vertex_shader, frame_frag_shader)) {\r
+ return 0;\r
+ }\r
+ frame_sampler_locYUV = glGetUniformLocation(shad_program, "textureYUV");\r
+ return 1;\r
+\r
+}\r
+\r
+int GLYuv444Shader::deinit()\r
+{\r
+ return deinitShaders();\r
+}\r
+\r
+int GLYuv444Shader::PrepareRendering(GLuint yuv_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
+\r
+\r
+\r
+ glActiveTexture( GL_TEXTURE0);\r
+ glBindTexture(GL_TEXTURE_2D, yuv_tex);\r
+ //Log::getInstance()->log("OSD", Log::WARN, "mark3 glerror %x %x",glGetError(),yuv_tex);\r
+ glUniform1i(frame_sampler_locYUV, 0);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\r
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\r
+\r
+ return 1;\r
+\r
+}\r
+\r
+int GLYuv444Shader::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_YUV444SHADER_H\r
+#define GL_YUV444SHADER_H\r
+\r
+#include "glshader.h"\r
+\r
+class GLYuv444Shader: public GLShader {\r
+public:\r
+ GLYuv444Shader();\r
+ virtual ~GLYuv444Shader();\r
+\r
+ int init();\r
+ int deinit();\r
+\r
+ int PrepareRendering(GLuint y_tex); // This Function setups the rendering pipeline according to the shaders standards\r
+\r
+protected:\r
+ virtual int BindAttributes();\r
+\r
+ GLint frame_sampler_locYUV;\r
+\r
+\r
+};\r
+\r
+\r
+#endif\r