mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-21 13:36:39 +00:00
eglglessink: GLSL: Planar YUV converters optimization
- Use consts for the transform's offset and cofficients values - Use dot product instead of mult and add - Avoid unneeded texture lookups
This commit is contained in:
parent
846e77871b
commit
73d865091c
1 changed files with 26 additions and 20 deletions
|
@ -264,18 +264,21 @@ static const char *frag_PLANAR_YUV_prog = {
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 opos;"
|
"varying vec2 opos;"
|
||||||
"uniform sampler2D Ytex,Utex,Vtex;"
|
"uniform sampler2D Ytex,Utex,Vtex;"
|
||||||
|
"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 r,g,b,y,u,v;"
|
" float r,g,b;"
|
||||||
|
" vec3 yuv;"
|
||||||
" vec2 nxy = opos.xy;"
|
" vec2 nxy = opos.xy;"
|
||||||
" y=texture2D(Ytex,nxy).r;"
|
" yuv.x=texture2D(Ytex,nxy).r;"
|
||||||
" u=texture2D(Utex,nxy).r;"
|
" yuv.y=texture2D(Utex,nxy).r;"
|
||||||
" v=texture2D(Vtex,nxy).r;"
|
" yuv.z=texture2D(Vtex,nxy).r;"
|
||||||
" y=1.1643*(y-0.0625);"
|
" yuv += offset;"
|
||||||
" u=u-0.5;"
|
" r = dot(yuv, rcoeff);"
|
||||||
" v=v-0.5;"
|
" g = dot(yuv, gcoeff);"
|
||||||
" r=y+1.5958*v;"
|
" b = dot(yuv, bcoeff);"
|
||||||
" 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);"
|
||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
@ -285,18 +288,21 @@ static const char *frag_NV12_NV21_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 r,g,b,y,u,v;"
|
" float r,g,b;"
|
||||||
|
" vec3 yuv;"
|
||||||
" vec2 nxy = opos.xy;"
|
" vec2 nxy = opos.xy;"
|
||||||
" y=texture2D(Ytex,nxy).r;"
|
" yuv.x=texture2D(Ytex,nxy).r;"
|
||||||
" u=texture2D(UVtex,nxy).%c;"
|
" yuv.y=texture2D(UVtex,nxy).%c;"
|
||||||
" v=texture2D(UVtex,nxy).%c;"
|
" yuv.z=texture2D(UVtex,nxy).%c;"
|
||||||
" y=1.1643*(y-0.0625);"
|
" yuv += offset;"
|
||||||
" u=u-0.5;"
|
" r = dot(yuv, rcoeff);"
|
||||||
" v=v-0.5;"
|
" g = dot(yuv, gcoeff);"
|
||||||
" r=y+1.5958*v;"
|
" b = dot(yuv, bcoeff);"
|
||||||
" 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