Hello All,
I am trying to convert and render YUV data(in three buffers i.e FrameY, FrameU and FrameV ) to RGB by using the below formula which i have googled, the problem is that the video is being rendered but there is a prominent green shade on top of the video. Can you please help me where I am doing wrong.
Shader Program:
glShaderProgram->addShaderFromSourceCode(QOpenGLShader::Vertex, // glShaderProgram is the pointer of the QOpenGLShaderProgram*
"attribute highp vec4 vertex;
"
"attribute highp vec4 texCoord;
"
"varying highp vec2 coords;
"
"
"
"void main() {
"
" gl_Position = vertex;
"
" coords = texCoord.xy;
"
"}
");
// Add Fragment Shader - fourcc: 420
glShaderProgram->addShaderFromSourceCode(QOpenGLShader::Fragment,
"varying highp vec2 coords;
"
"uniform highp sampler2D texture_y;
"
"uniform highp sampler2D texture_u;
"
"uniform highp sampler2D texture_v;
"
"
"
"void main() {
"
"
"
" highp float y = texture2D(texture_y, coords).r;
"
" highp float u = texture2D(texture_u, coords).r;
"
" highp float v = texture2D(texture_v, coords).r;
"
"
"
" y = 1.1643 * (y - 0.0625);
"
" u = u - 0.5;
"
" v = v - 0.5;
"
"
"
" highp float r = y + 1.5958 * v;
"
" highp float g = y - 0.39173 * u - 0.81290 * v;
"
" highp float b = y + 2.017 * u;
"
"
"
" gl_FragColor = vec4(r, g, b, 1.0);
"
"
"
"}
");
Thanks & Regards,
Keshav