MythTV  master
Classes | Macros | Enumerations | Variables
openglvideo.cpp File Reference
#include "openglvideo.h"
#include "mythcontext.h"
#include "tv.h"
#include "mythrender_opengl.h"
#include "mythavutil.h"
Include dependency graph for openglvideo.cpp:

Go to the source code of this file.

Classes

class  OpenGLFilter
 

Macros

#define LOC   QString("GLVid: ")
 
#define COLOUR_UNIFORM   "m_colourMatrix"
 
#define MYTHTV_YV12   0x8a20
 
#define SAMPLEYVU   "\vec3 sampleYVU(in GLSL_SAMPLER texture, vec2 texcoordY)\n\{\n\ vec2 texcoordV, texcoordU;\n\ texcoordV = vec2(texcoordY.s / 2.0, %HEIGHT% + texcoordY.t / 4.0);\n\ texcoordU = vec2(texcoordV.s, texcoordV.t + %HEIGHT% / 4.0);\n\ if (fract(texcoordY.t * %2) >= 0.5)\n\ {\n\ texcoordV.s += %WIDTH% / 2.0;\n\ texcoordU.s += %WIDTH% / 2.0;\n\ }\n\ vec3 yvu;\n\ yvu.r = GLSL_TEXTURE(texture, texcoordY).r;\n\ yvu.g = GLSL_TEXTURE(texture, texcoordV).r;\n\ yvu.b = GLSL_TEXTURE(texture, texcoordU).r;\n\ return yvu;\n\}\n"
 
#define KERNELYVU   "\vec3 kernelYVU(in vec3 yvu, GLSL_SAMPLER texture1, GLSL_SAMPLER texture2)\n\{\n\ vec2 twoup = v_texcoord0 - vec2(0.0, %4);\n\ vec2 twodown = v_texcoord0 + vec2(0.0, %4);\n\ twodown.t = min(twodown.t, %HEIGHT% - %3);\n\ vec2 onedown = v_texcoord0 + vec2(0.0, %3);\n\ onedown.t = min(onedown.t, %HEIGHT% - %3);\n\ vec3 line0 = sampleYVU(texture1, twoup);\n\ vec3 line1 = sampleYVU(texture1, v_texcoord0 - vec2(0.0, %3));\n\ vec3 line3 = sampleYVU(texture1, onedown);\n\ vec3 line4 = sampleYVU(texture1, twodown);\n\ vec3 line00 = sampleYVU(texture2, twoup);\n\ vec3 line20 = sampleYVU(texture2, v_texcoord0);\n\ vec3 line40 = sampleYVU(texture2, twodown);\n\ yvu *= 0.125;\n\ yvu += line20 * 0.125;\n\ yvu += line1 * 0.5;\n\ yvu += line3 * 0.5;\n\ yvu += line0 * -0.0625;\n\ yvu += line4 * -0.0625;\n\ yvu += line00 * -0.0625;\n\ yvu += line40 * -0.0625;\n\ return yvu;\n\}\n"
 

Enumerations

enum  DisplayBuffer { kDefaultBuffer, kFrameBufferObject }
 

Variables

static const QString attrib_fast
 
static const QString tex_fast
 
static const QString var_fast
 
static const QString var_col
 
static const QString select_col
 
static const QString end_fast
 
static const QString var_deint
 
static const QString field_calc
 
static const QString bobdeint [2]
 
static const QString deint_end_top
 
static const QString deint_end_bot
 
static const QString linearblend [2]
 
static const QString kerneldeint [2]
 
static const QString bicubic
 
static const QString YUV2RGBVertexShader
 
static const QString SelectColumn
 
static const QString YUV2RGBFragmentShader
 
static const QString OneFieldShader [2]
 
static const QString LinearBlendShader [2]
 
static const QString KernelShader [2]
 
static const QString BicubicShader
 
static const QString DefaultFragmentShader
 
static const QString YV12RGBVertexShader
 
static const QString YV12RGBFragmentShader
 
static const QString YV12RGBOneFieldFragmentShader [2]
 
static const QString YV12RGBLinearBlendFragmentShader [2]
 
static const QString YV12RGBKernelShader [2]
 

Macro Definition Documentation

◆ LOC

#define LOC   QString("GLVid: ")

Definition at line 8 of file openglvideo.cpp.

◆ COLOUR_UNIFORM

#define COLOUR_UNIFORM   "m_colourMatrix"

Definition at line 9 of file openglvideo.cpp.

◆ MYTHTV_YV12

#define MYTHTV_YV12   0x8a20

Definition at line 10 of file openglvideo.cpp.

◆ SAMPLEYVU

#define SAMPLEYVU   "\vec3 sampleYVU(in GLSL_SAMPLER texture, vec2 texcoordY)\n\{\n\ vec2 texcoordV, texcoordU;\n\ texcoordV = vec2(texcoordY.s / 2.0, %HEIGHT% + texcoordY.t / 4.0);\n\ texcoordU = vec2(texcoordV.s, texcoordV.t + %HEIGHT% / 4.0);\n\ if (fract(texcoordY.t * %2) >= 0.5)\n\ {\n\ texcoordV.s += %WIDTH% / 2.0;\n\ texcoordU.s += %WIDTH% / 2.0;\n\ }\n\ vec3 yvu;\n\ yvu.r = GLSL_TEXTURE(texture, texcoordY).r;\n\ yvu.g = GLSL_TEXTURE(texture, texcoordV).r;\n\ yvu.b = GLSL_TEXTURE(texture, texcoordU).r;\n\ return yvu;\n\}\n"

Definition at line 1670 of file openglvideo.cpp.

◆ KERNELYVU

#define KERNELYVU   "\vec3 kernelYVU(in vec3 yvu, GLSL_SAMPLER texture1, GLSL_SAMPLER texture2)\n\{\n\ vec2 twoup = v_texcoord0 - vec2(0.0, %4);\n\ vec2 twodown = v_texcoord0 + vec2(0.0, %4);\n\ twodown.t = min(twodown.t, %HEIGHT% - %3);\n\ vec2 onedown = v_texcoord0 + vec2(0.0, %3);\n\ onedown.t = min(onedown.t, %HEIGHT% - %3);\n\ vec3 line0 = sampleYVU(texture1, twoup);\n\ vec3 line1 = sampleYVU(texture1, v_texcoord0 - vec2(0.0, %3));\n\ vec3 line3 = sampleYVU(texture1, onedown);\n\ vec3 line4 = sampleYVU(texture1, twodown);\n\ vec3 line00 = sampleYVU(texture2, twoup);\n\ vec3 line20 = sampleYVU(texture2, v_texcoord0);\n\ vec3 line40 = sampleYVU(texture2, twodown);\n\ yvu *= 0.125;\n\ yvu += line20 * 0.125;\n\ yvu += line1 * 0.5;\n\ yvu += line3 * 0.5;\n\ yvu += line0 * -0.0625;\n\ yvu += line4 * -0.0625;\n\ yvu += line00 * -0.0625;\n\ yvu += line40 * -0.0625;\n\ return yvu;\n\}\n"

Definition at line 1766 of file openglvideo.cpp.

Enumeration Type Documentation

◆ DisplayBuffer

Enumerator
kDefaultBuffer 
kFrameBufferObject 

Definition at line 12 of file openglvideo.cpp.

Variable Documentation

◆ attrib_fast

const QString attrib_fast
static
Initial value:
=
"ATTRIB tex = fragment.texcoord[0];\n"
"PARAM yuv[3] = { program.local[0..2] };\n"

Definition at line 1207 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ tex_fast

const QString tex_fast
static
Initial value:
=
"TEX res, tex, texture[0], %1;\n"

Definition at line 1211 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ var_fast

const QString var_fast
static
Initial value:
=
"TEMP tmp, res;\n"

Definition at line 1214 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ var_col

const QString var_col
static
Initial value:
=
"TEMP col;\n"

Definition at line 1217 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ select_col

const QString select_col
static
Initial value:
=
"MUL col, tex.xxxx, %8;\n"
"FRC col, col;\n"
"SUB col, col, 0.5;\n"
"CMP res, col, res.rabg, res.rgba;\n"

Definition at line 1220 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ end_fast

const QString end_fast
static
Initial value:
=
"DPH tmp.r, res.%SWIZZLE%g, yuv[0];\n"
"DPH tmp.g, res.%SWIZZLE%g, yuv[1];\n"
"DPH tmp.b, res.%SWIZZLE%g, yuv[2];\n"
"MOV tmp.a, 1.0;\n"
"MOV result.color, tmp;\n"

Definition at line 1226 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ var_deint

const QString var_deint
static
Initial value:
=
"TEMP other, current, mov, prev;\n"

Definition at line 1233 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ field_calc

const QString field_calc
static
Initial value:
=
"MUL prev, tex.yyyy, %2;\n"
"FRC prev, prev;\n"
"SUB prev, prev, 0.5;\n"

Definition at line 1236 of file openglvideo.cpp.

◆ bobdeint

const QString bobdeint[2]
static
Initial value:
= {
"ADD other, tex, {0.0, %3, 0.0, 0.0};\n"
"MIN other, other, {10000.0, %9, 10000.0, 10000.0};\n"
"TEX other, other, texture[0], %1;\n"
"CMP res, prev, res, other;\n",
"SUB other, tex, {0.0, %3, 0.0, 0.0};\n"
"TEX other, other, texture[0], %1;\n"
"CMP res, prev, other, res;\n"
}
static const QString field_calc

Definition at line 1241 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ deint_end_top

const QString deint_end_top
static
Initial value:
=
"CMP res, prev, current, other;\n"

Definition at line 1253 of file openglvideo.cpp.

◆ deint_end_bot

const QString deint_end_bot
static
Initial value:
=
"CMP res, prev, other, current;\n"

Definition at line 1256 of file openglvideo.cpp.

◆ linearblend

const QString linearblend[2]
static
Initial value:
= {
"TEX current, tex, texture[0], %1;\n"
"ADD other, tex, {0.0, %3, 0.0, 0.0};\n"
"MIN other, other, {10000.0, %9, 10000.0, 10000.0};\n"
"TEX other, other, texture[0], %1;\n"
"SUB mov, tex, {0.0, %3, 0.0, 0.0};\n"
"TEX mov, mov, texture[0], %1;\n"
"LRP other, 0.5, other, mov;\n"
"TEX current, tex, texture[0], %1;\n"
"SUB other, tex, {0.0, %3, 0.0, 0.0};\n"
"TEX other, other, texture[0], %1;\n"
"ADD mov, tex, {0.0, %3, 0.0, 0.0};\n"
"TEX mov, mov, texture[0], %1;\n"
"LRP other, 0.5, other, mov;\n"
}
static const QString deint_end_top
static const QString field_calc
static const QString deint_end_bot

Definition at line 1259 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ kerneldeint

const QString kerneldeint[2]
static

Definition at line 1278 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ bicubic

const QString bicubic
static
Initial value:
=
"TEMP coord, coord2, cdelta, parmx, parmy, a, b, c, d;\n"
"MAD coord.xy, fragment.texcoord[0], {%6, 0.0}, {0.5, 0.5};\n"
"MAD coord2.xy, fragment.texcoord[0], {0.0, %7}, {0.5, 0.5};\n"
"TEX parmx, coord.xy, texture[1], 2D;\n"
"TEX parmy, coord2.yx, texture[1], 2D;\n"
"MUL cdelta.xz, parmx.rrgg, {-%5, 0, %5, 0};\n"
"MUL cdelta.yw, parmy.rrgg, {0, -%3, 0, %3};\n"
"ADD coord, fragment.texcoord[0].xyxy, cdelta.xyxw;\n"
"ADD coord2, fragment.texcoord[0].xyxy, cdelta.zyzw;\n"
"TEX a, coord.xyxy, texture[0], 2D;\n"
"TEX b, coord.zwzw, texture[0], 2D;\n"
"TEX c, coord2.xyxy, texture[0], 2D;\n"
"TEX d, coord2.zwzw, texture[0], 2D;\n"
"LRP a, parmy.b, a, b;\n"
"LRP c, parmy.b, c, d;\n"
"LRP result.color, parmx.b, a, c;\n"

Definition at line 1324 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramString().

◆ YUV2RGBVertexShader

const QString YUV2RGBVertexShader
static
Initial value:
=
"GLSL_DEFINES"
"attribute vec2 a_position;\n"
"attribute vec2 a_texcoord0;\n"
"varying vec2 v_texcoord0;\n"
"uniform mat4 u_projection;\n"
"void main() {\n"
" gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\n"
" v_texcoord0 = a_texcoord0;\n"
"}\n"

Definition at line 1465 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ SelectColumn

const QString SelectColumn
static
Initial value:
=
" if (fract(v_texcoord0.x * %8) < 0.5)\n"
" yuva = yuva.rabg;\n"

Definition at line 1476 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ YUV2RGBFragmentShader

const QString YUV2RGBFragmentShader
static
Initial value:
=
"GLSL_DEFINES"
"uniform GLSL_SAMPLER s_texture0;\n"
"uniform mat4 COLOUR_UNIFORM;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" vec4 yuva = GLSL_TEXTURE(s_texture0, v_texcoord0);\n"
"SELECT_COLUMN"
" gl_FragColor = vec4(yuva.%SWIZZLE%, 1.0) * COLOUR_UNIFORM;\n"
"}\n"

Definition at line 1480 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ OneFieldShader

const QString OneFieldShader[2]
static
Initial value:
= {
"GLSL_DEFINES"
"uniform GLSL_SAMPLER s_texture0;\n"
"uniform mat4 COLOUR_UNIFORM;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" float field = v_texcoord0.y + (step(0.5, fract(v_texcoord0.y * %2)) * %3);\n"
" field = clamp(field, 0.0, %9);\n"
" vec4 yuva = GLSL_TEXTURE(s_texture0, vec2(v_texcoord0.x, field));\n"
"SELECT_COLUMN"
" gl_FragColor = vec4(yuva.%SWIZZLE%, 1.0) * COLOUR_UNIFORM;\n"
"}\n",
"GLSL_DEFINES"
"uniform GLSL_SAMPLER s_texture0;\n"
"uniform mat4 COLOUR_UNIFORM;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" vec2 field = vec2(0.0, step(0.5, 1.0 - fract(v_texcoord0.y * %2)) * %3);\n"
" vec4 yuva = GLSL_TEXTURE(s_texture0, v_texcoord0 + field);\n"
"SELECT_COLUMN"
" gl_FragColor = vec4(yuva.%SWIZZLE%, 1.0) * COLOUR_UNIFORM;\n"
"}\n"
}

Definition at line 1492 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ LinearBlendShader

const QString LinearBlendShader[2]
static

Definition at line 1519 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ KernelShader

const QString KernelShader[2]
static

Definition at line 1551 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ BicubicShader

const QString BicubicShader
static
Initial value:
=
"GLSL_DEFINES"
"uniform sampler2D s_texture0;\n"
"uniform sampler2D s_texture1;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" vec2 coord = (v_texcoord0 * vec2(%6, %7)) - vec2(0.5, 0.5);\n"
" vec4 parmx = texture2D(s_texture1, vec2(coord.x, 0.0));\n"
" vec4 parmy = texture2D(s_texture1, vec2(coord.y, 0.0));\n"
" vec2 e_x = vec2(%5, 0.0);\n"
" vec2 e_y = vec2(0.0, %3);\n"
" vec2 coord10 = v_texcoord0 + parmx.x * e_x;\n"
" vec2 coord00 = v_texcoord0 - parmx.y * e_x;\n"
" vec2 coord11 = coord10 + parmy.x * e_y;\n"
" vec2 coord01 = coord00 + parmy.x * e_y;\n"
" coord10 = coord10 - parmy.y * e_y;\n"
" coord00 = coord00 - parmy.y * e_y;\n"
" vec4 tex00 = texture2D(s_texture0, coord00);\n"
" vec4 tex10 = texture2D(s_texture0, coord10);\n"
" vec4 tex01 = texture2D(s_texture0, coord01);\n"
" vec4 tex11 = texture2D(s_texture0, coord11);\n"
" tex00 = mix(tex00, tex01, parmy.z);\n"
" tex10 = mix(tex10, tex11, parmy.z);\n"
" gl_FragColor = mix(tex00, tex10, parmx.z);\n"
"}\n"

Definition at line 1621 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ DefaultFragmentShader

const QString DefaultFragmentShader
static
Initial value:
=
"GLSL_DEFINES"
"uniform GLSL_SAMPLER s_texture0;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" vec4 color = GLSL_TEXTURE(s_texture0, v_texcoord0);\n"
" gl_FragColor = vec4(color.xyz, 1.0);\n"
"}\n"

Definition at line 1648 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ YV12RGBVertexShader

const QString YV12RGBVertexShader
static
Initial value:
=
"//YV12RGBVertexShader\n"
"GLSL_DEFINES"
"attribute vec2 a_position;\n"
"attribute vec2 a_texcoord0;\n"
"varying vec2 v_texcoord0;\n"
"uniform mat4 u_projection;\n"
"void main() {\n"
" gl_Position = u_projection * vec4(a_position, 0.0, 1.0);\n"
" v_texcoord0 = a_texcoord0;\n"
"}\n"

Definition at line 1658 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ YV12RGBFragmentShader

const QString YV12RGBFragmentShader
static
Initial value:
=
"//YV12RGBFragmentShader\n"
"GLSL_DEFINES"
"uniform GLSL_SAMPLER s_texture0; // 4:1:1 YVU planar\n"
"uniform mat4 COLOUR_UNIFORM;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" vec3 yvu = sampleYVU(s_texture0, v_texcoord0);\n"
" gl_FragColor = vec4(yvu, 1.0) * COLOUR_UNIFORM;\n"
"}\n"
#define SAMPLEYVU

Definition at line 1688 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ YV12RGBOneFieldFragmentShader

const QString YV12RGBOneFieldFragmentShader[2]
static
Initial value:
= {
"//YV12RGBOneFieldFragmentShader 1\n"
"GLSL_DEFINES"
"uniform GLSL_SAMPLER s_texture0;\n"
"uniform mat4 COLOUR_UNIFORM;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" float field = min(v_texcoord0.y + (step(0.5, fract(v_texcoord0.y * %2))) * %3, %HEIGHT% - %3);\n"
" vec3 yvu = sampleYVU(s_texture0, vec2(v_texcoord0.x, field));\n"
" gl_FragColor = vec4(yvu, 1.0) * COLOUR_UNIFORM;\n"
"}\n",
"//YV12RGBOneFieldFragmentShader 2\n"
"GLSL_DEFINES"
"uniform GLSL_SAMPLER s_texture0;\n"
"uniform mat4 COLOUR_UNIFORM;\n"
"varying vec2 v_texcoord0;\n"
"void main(void)\n"
"{\n"
" float field = max(v_texcoord0.y + (step(0.5, 1.0 - fract(v_texcoord0.y * %2))) * %3, 0.0);\n"
" vec3 yvu = sampleYVU(s_texture0, vec2(v_texcoord0.x, field));\n"
" gl_FragColor = vec4(yvu, 1.0) * COLOUR_UNIFORM;\n"
"}\n"
}
#define SAMPLEYVU

Definition at line 1701 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ YV12RGBLinearBlendFragmentShader

const QString YV12RGBLinearBlendFragmentShader[2]
static

Definition at line 1729 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().

◆ YV12RGBKernelShader

const QString YV12RGBKernelShader[2]
static

Definition at line 1792 of file openglvideo.cpp.

Referenced by OpenGLVideo::GetProgramStrings().