mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
eglglessink: Documentation: GLSL Shaders
Brief explanatory comments plus some rerdering to group packed/planar converters.
This commit is contained in:
parent
731be48dac
commit
95a223a030
1 changed files with 58 additions and 45 deletions
|
@ -168,6 +168,15 @@ static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC my_glEGLImageTargetTexture2DOES;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
|
|
||||||
|
/* GLESv2 GLSL Shaders
|
||||||
|
*
|
||||||
|
* OpenGL ES Standard does not mandate YUV support. This is
|
||||||
|
* why most of these shaders deal with Packed/Planar YUV->RGB
|
||||||
|
* conversion.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Direct vertex copy */
|
||||||
static const char *vert_COPY_prog = {
|
static const char *vert_COPY_prog = {
|
||||||
"attribute vec3 position;"
|
"attribute vec3 position;"
|
||||||
"attribute vec2 texpos;"
|
"attribute vec2 texpos;"
|
||||||
|
@ -179,6 +188,7 @@ static const char *vert_COPY_prog = {
|
||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Direct fragments copy */
|
||||||
static const char *frag_COPY_prog = {
|
static const char *frag_COPY_prog = {
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 opos;"
|
"varying vec2 opos;"
|
||||||
|
@ -190,6 +200,7 @@ static const char *frag_COPY_prog = {
|
||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Channel reordering for XYZ <-> ZYX conversion */
|
||||||
static const char *frag_REORDER_prog = {
|
static const char *frag_REORDER_prog = {
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 opos;"
|
"varying vec2 opos;"
|
||||||
|
@ -201,7 +212,9 @@ static const char *frag_REORDER_prog = {
|
||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* From gst-plugins-gl */
|
/* Packed YUV converters */
|
||||||
|
|
||||||
|
/** From gst-plugins-gl: AYUV to RGB conversion */
|
||||||
static const char *frag_AYUV_prog = {
|
static const char *frag_AYUV_prog = {
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 opos;"
|
"varying vec2 opos;"
|
||||||
|
@ -222,46 +235,7 @@ static const char *frag_AYUV_prog = {
|
||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *frag_PLANAR_YUV_prog = {
|
/** YUY2/UYVY to RGB conversion */
|
||||||
"precision mediump float;"
|
|
||||||
"varying vec2 opos;"
|
|
||||||
"uniform sampler2D Ytex,Utex,Vtex;"
|
|
||||||
"void main(void) {"
|
|
||||||
" float r,g,b,y,u,v;"
|
|
||||||
" vec2 nxy = opos.xy;"
|
|
||||||
" y=texture2D(Ytex,nxy).r;"
|
|
||||||
" u=texture2D(Utex,nxy).r;"
|
|
||||||
" v=texture2D(Vtex,nxy).r;"
|
|
||||||
" y=1.1643*(y-0.0625);"
|
|
||||||
" u=u-0.5;"
|
|
||||||
" v=v-0.5;"
|
|
||||||
" 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);"
|
|
||||||
"}"
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *frag_NV12_NV21_prog = {
|
|
||||||
"precision mediump float;"
|
|
||||||
"varying vec2 opos;"
|
|
||||||
"uniform sampler2D Ytex,UVtex;"
|
|
||||||
"void main(void) {"
|
|
||||||
" float r,g,b,y,u,v;"
|
|
||||||
" vec2 nxy = opos.xy;"
|
|
||||||
" y=texture2D(Ytex,nxy).r;"
|
|
||||||
" u=texture2D(UVtex,nxy).%c;"
|
|
||||||
" v=texture2D(UVtex,nxy).%c;"
|
|
||||||
" y=1.1643*(y-0.0625);"
|
|
||||||
" u=u-0.5;"
|
|
||||||
" v=v-0.5;"
|
|
||||||
" 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);"
|
|
||||||
"}"
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *frag_YUY2_UYVY_prog = {
|
static const char *frag_YUY2_UYVY_prog = {
|
||||||
"precision mediump float;"
|
"precision mediump float;"
|
||||||
"varying vec2 opos;"
|
"varying vec2 opos;"
|
||||||
|
@ -283,13 +257,52 @@ static const char *frag_YUY2_UYVY_prog = {
|
||||||
"}"
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Planar YUV converters */
|
||||||
|
|
||||||
|
/** YUV to RGB conversion */
|
||||||
|
static const char *frag_PLANAR_YUV_prog = {
|
||||||
|
"precision mediump float;"
|
||||||
|
"varying vec2 opos;"
|
||||||
|
"uniform sampler2D Ytex,Utex,Vtex;"
|
||||||
|
"void main(void) {"
|
||||||
|
" float r,g,b,y,u,v;"
|
||||||
|
" vec2 nxy = opos.xy;"
|
||||||
|
" y=texture2D(Ytex,nxy).r;"
|
||||||
|
" u=texture2D(Utex,nxy).r;"
|
||||||
|
" v=texture2D(Vtex,nxy).r;"
|
||||||
|
" y=1.1643*(y-0.0625);"
|
||||||
|
" u=u-0.5;"
|
||||||
|
" v=v-0.5;"
|
||||||
|
" 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);"
|
||||||
|
"}"
|
||||||
|
};
|
||||||
|
|
||||||
|
/** NV12/NV21 to RGB conversion */
|
||||||
|
static const char *frag_NV12_NV21_prog = {
|
||||||
|
"precision mediump float;"
|
||||||
|
"varying vec2 opos;"
|
||||||
|
"uniform sampler2D Ytex,UVtex;"
|
||||||
|
"void main(void) {"
|
||||||
|
" float r,g,b,y,u,v;"
|
||||||
|
" vec2 nxy = opos.xy;"
|
||||||
|
" y=texture2D(Ytex,nxy).r;"
|
||||||
|
" u=texture2D(UVtex,nxy).%c;"
|
||||||
|
" v=texture2D(UVtex,nxy).%c;"
|
||||||
|
" y=1.1643*(y-0.0625);"
|
||||||
|
" u=u-0.5;"
|
||||||
|
" v=v-0.5;"
|
||||||
|
" 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);"
|
||||||
|
"}"
|
||||||
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
/* Input capabilities.
|
/* Input capabilities. */
|
||||||
*
|
|
||||||
* Note: OpenGL ES Standard does not mandate YUV support.
|
|
||||||
*/
|
|
||||||
static GstStaticPadTemplate gst_eglglessink_sink_template_factory =
|
static GstStaticPadTemplate gst_eglglessink_sink_template_factory =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
|
|
Loading…
Reference in a new issue