Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add GLSL 'onefield' and 'bob' hardware deinterlacers.

  • Loading branch information...
commit 8cb1707aafca7d8fbe59b032f217b8c2080fa63d 1 parent 56dab84
Mark Kendall authored
View
76 mythtv/libs/libmythtv/openglvideo.cpp
@@ -1527,8 +1527,18 @@ QString OpenGLVideo::GetProgramString(OpenGLFilterType name,
break;
}
- QString temp = textureRects ? "RECT" : "2D";
- ret.replace("%1", temp);
+ CustomiseProgramString(ret);
+ ret += "END";
+
+ VERBOSE(VB_PLAYBACK, LOC + QString("Created %1 fragment program %2")
+ .arg(FilterToString(name)).arg(deint));
+
+ return ret;
+}
+
+void OpenGLVideo::CustomiseProgramString(QString &string)
+{
+ string.replace("%1", textureRects ? "RECT" : "2D");
float lineHeight = 1.0f;
float colWidth = 1.0f;
@@ -1543,25 +1553,16 @@ QString OpenGLVideo::GetProgramString(OpenGLFilterType name,
float fieldSize = 1.0f / (lineHeight * 2.0);
- ret.replace("%2", temp.setNum(fieldSize, 'f', 8));
- ret.replace("%3", temp.setNum(lineHeight, 'f', 8));
- ret.replace("%4", temp.setNum(lineHeight * 2.0, 'f', 8));
- ret.replace("%5", temp.setNum(colWidth, 'f', 8));
- ret.replace("%6", temp.setNum((float)fb_size.width(), 'f', 1));
- ret.replace("%7", temp.setNum((float)fb_size.height(), 'f', 1));
-
- ret += "END";
-
- VERBOSE(VB_PLAYBACK|VB_EXTRA, "\n" + ret + "\n");
- VERBOSE(VB_PLAYBACK, LOC + QString("Created %1 fragment program %2")
- .arg(FilterToString(name)).arg(deint));
-
- return ret;
+ string.replace("%2", QString::number(fieldSize, 'f', 8));
+ string.replace("%3", QString::number(lineHeight, 'f', 8));
+ string.replace("%4", QString::number(lineHeight * 2.0, 'f', 8));
+ string.replace("%5", QString::number(colWidth, 'f', 8));
+ string.replace("%6", QString::number((float)fb_size.width(), 'f', 1));
+ string.replace("%7", QString::number((float)fb_size.height(), 'f', 1));
}
static const QString YUV2RGBVertexShader =
"GLSL_DEFINES"
-"attribute vec4 a_color;\n"
"attribute vec2 a_texcoord0;\n"
"varying vec2 v_texcoord0;\n"
"void main() {\n"
@@ -1581,12 +1582,49 @@ static const QString YUV2RGBFragmentShader =
" gl_FragColor = vec4(res.rgb, yuva.g);\n"
"}\n";
+static const QString OneFieldShader[2] = {
+"GLSL_DEFINES"
+"uniform sampler2D s_texture0;\n"
+"uniform mat4 m_colourMatrix;\n"
+"varying vec2 v_texcoord0;\n"
+"void main(void)\n"
+"{\n"
+" vec2 field = vec2(0.0, step(0.5, fract(v_texcoord0.y * %2)) * %3);\n"
+" vec4 yuva = texture2D(s_texture0, v_texcoord0 + field);\n"
+" vec4 res = vec4(yuva.arb, 1.0) * m_colourMatrix;\n"
+" gl_FragColor = vec4(res.rgb, yuva.g);\n"
+"}\n",
+
+"GLSL_DEFINES"
+"uniform sampler2D s_texture0;\n"
+"uniform mat4 m_colourMatrix;\n"
+"varying vec2 v_texcoord0;\n"
+"void main(void)\n"
+"{\n"
+" vec2 field = vec2(0.0, step(0.5, 1 - fract(v_texcoord0.y * %2)) * %3);\n"
+" vec4 yuva = texture2D(s_texture0, v_texcoord0 + field);\n"
+" vec4 res = vec4(yuva.arb, 1.0) * m_colourMatrix;\n"
+" gl_FragColor = vec4(res.rgb, yuva.g);\n"
+"}\n"
+};
+
void OpenGLVideo::GetProgramStrings(QString &vertex, QString &fragment,
OpenGLFilterType filter,
QString deint, FrameScanType field)
{
- vertex = YUV2RGBVertexShader;
- fragment = YUV2RGBFragmentShader;
+ uint bottom = field == kScan_Intr2ndField;
+ switch (filter)
+ {
+ default:
+ vertex = YUV2RGBVertexShader;
+ if (deint == "openglonefield" || deint == "openglbobdeint")
+ fragment = OneFieldShader[bottom];
+ else
+ fragment = YUV2RGBFragmentShader;
+ break;
+ }
+ CustomiseProgramString(vertex);
+ CustomiseProgramString(fragment);
}
uint OpenGLVideo::ParseOptions(QString options)
View
1  mythtv/libs/libmythtv/openglvideo.h
@@ -94,6 +94,7 @@ class OpenGLVideo
OpenGLFilterType filter,
QString deint = QString::null,
FrameScanType field = kScan_Progressive);
+ void CustomiseProgramString(QString &string);
static QString FilterToString(OpenGLFilterType filter);
static OpenGLFilterType StringToFilter(const QString &filter);
QSize GetTextureSize(const QSize &size);
View
3  mythtv/libs/libmythui/mythrender_opengl.cpp
@@ -807,7 +807,10 @@ bool MythRenderOpenGL::CreateFragmentProgram(const QString &program, uint &prog)
}
if (success)
+ {
+ VERBOSE(VB_PLAYBACK|VB_EXTRA, "\n" + program + "\n");
m_programs.push_back(glfp);
+ }
else
m_glDeleteProgramsARB(1, &glfp);

0 comments on commit 8cb1707

Please sign in to comment.
Something went wrong with that request. Please try again.