mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-25 10:04:19 +00:00
Geglglessink: LSL: Optimize frag_YUY2_YVYU_UYVY_prog
- Avoid repeatedly performing the texture lookup - Use consts for the transform's offset and cofficients values - Use the dot product instead of the explicit mult and add
This commit is contained in:
parent
eb8f7d63d5
commit
846e77871b
1 changed files with 13 additions and 12 deletions
|
@ -239,19 +239,20 @@ static const char *frag_YUY2_YVYU_UYVY_prog = {
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 opos;"
|
"varying vec2 opos;"
|
||||||
"uniform sampler2D Ytex, UVtex;"
|
"uniform sampler2D Ytex, UVtex;"
|
||||||
|
"const vec3 offset = vec3(-0.0625, -0.5, -0.5);"
|
||||||
|
"const vec3 rcoeff = vec3(1.164, 0.000, 1.596);"
|
||||||
|
"const vec3 gcoeff = vec3(1.164,-0.391,-0.813);"
|
||||||
|
"const vec3 bcoeff = vec3(1.164, 2.018, 0.000);"
|
||||||
"void main(void) {"
|
"void main(void) {"
|
||||||
" float fx, fy, y, u, v, r, g, b;"
|
" float r, g, b;"
|
||||||
" fx = opos.x;"
|
" vec3 yuv;"
|
||||||
" fy = opos.y;"
|
" vec2 oposxy = vec2(opos.x, opos.y);"
|
||||||
" y = texture2D(Ytex,vec2(fx,fy)).%c;"
|
" yuv.x = texture2D(Ytex,oposxy).x;"
|
||||||
" u = texture2D(UVtex,vec2(fx,fy)).%c;"
|
" yuv.yz = texture2D(UVtex,oposxy).yz;"
|
||||||
" v = texture2D(UVtex,vec2(fx,fy)).%c;"
|
" yuv += offset;"
|
||||||
" y=1.1643*(y-0.0625);"
|
" r = dot(yuv, rcoeff);"
|
||||||
" u=u-0.5;"
|
" g = dot(yuv, gcoeff);"
|
||||||
" v=v-0.5;"
|
" b = dot(yuv, bcoeff);"
|
||||||
" r=y+1.5958*v;"
|
|
||||||
" g=y-0.39173*u-0.81290*v;"
|
|
||||||
" b=y+2.017*u;"
|
|
||||||
" gl_FragColor=vec4(r,g,b,1.0);"
|
" gl_FragColor=vec4(r,g,b,1.0);"
|
||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue