Skip to content
Browse files

shaders: add generic planar formats for OpenGL rendering.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
  • Loading branch information...
1 parent df0f8c3 commit 88e9842eaf809d1a38846d1b2cc186641ff3947e @gbeauchesne committed
View
24 system/shaders/yuv2rgb_basic.glsl
@@ -70,6 +70,30 @@ void main()
rgb.a = gl_Color.a;
gl_FragColor = rgb;
+#elif defined(XBMC_Y_UV)
+
+ vec4 yuv, rgb;
+ yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r
+ , texture2D(m_sampU, stretch(m_cordU)).r
+ , texture2D(m_sampV, stretch(m_cordV)).g
+ , 1.0 );
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = gl_Color.a;
+ gl_FragColor = rgb;
+
+#elif defined(XBMC_Y_U_V)
+
+ vec4 yuv, rgb;
+ yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r
+ , texture2D(m_sampU, stretch(m_cordU)).r
+ , texture2D(m_sampV, stretch(m_cordV)).r
+ , 1.0 );
+
+ rgb = m_yuvmat * yuv;
+ rgb.a = gl_Color.a;
+ gl_FragColor = rgb;
+
#elif defined(XBMC_YUY2) || defined(XBMC_UYVY)
#if(XBMC_texture_rectangle)
View
21 xbmc/cores/VideoRenderers/RenderFormats.h
@@ -35,6 +35,27 @@ enum ERenderFormat {
RENDER_FMT_OMXEGL,
RENDER_FMT_CVBREF,
RENDER_FMT_BYPASS,
+
+ /*
+ * Generic OpenGL planar formats.
+ *
+ * This depends on the following extensions:
+ * - EXT_texture_rg
+ * - OES_texture_npot (GLESv2), or ARB_texture_non_power_of_two (GL)
+ *
+ * The naming convention separates planes by '_' and within each
+ * plane, the order of R, G, B, A, Y, U and V indicates how those
+ * components map to the rgba value returned by the sampler. X
+ * indicates that the corresponding component in the rgba value is
+ * not used.
+ *
+ * For example, RENDER_FMT_Y_UV means:
+ * - texture[0].r = 'Y' component
+ * - texture[1].r = 'U' component
+ * - texture[1].g = 'V' component
+ */
+ RENDER_FMT_Y_UV, // 1 plane for Y and 1 plane for UV
+ RENDER_FMT_Y_U_V // 3 planes for Y U V
};
#endif
View
4 xbmc/cores/VideoRenderers/VideoShaders/YUV2RGBShader.cpp
@@ -201,6 +201,10 @@ BaseYUV2RGBGLSLShader::BaseYUV2RGBGLSLShader(bool rect, unsigned flags, ERenderF
m_defines += "#define XBMC_YUY2\n";
else if (m_format == RENDER_FMT_UYVY422)
m_defines += "#define XBMC_UYVY\n";
+ else if (m_format == RENDER_FMT_Y_UV)
+ m_defines += "#define XBMC_Y_UV";
+ else if (m_format == RENDER_FMT_Y_U_V)
+ m_defines += "#define XBMC_Y_U_V";
else
CLog::Log(LOGERROR, "GL: BaseYUV2RGBGLSLShader - unsupported format %d", m_format);
View
6 xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
@@ -1111,6 +1111,12 @@ int CDVDPlayerVideo::OutputPicture(const DVDVideoPicture* src, double pts)
case RENDER_FMT_BYPASS:
formatstr = "BYPASS";
break;
+ case RENDER_FMT_Y_UV:
+ formatstr = "GL:Y:UV";
+ break;
+ case RENDER_FMT_Y_U_V:
+ formatstr = "GL:Y:U:V";
+ break;
case RENDER_FMT_NONE:
formatstr = "NONE";
break;

0 comments on commit 88e9842

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