From db403023c0163b50528fccfda803dcb28eeb5aca Mon Sep 17 00:00:00 2001 From: Lukasz Marek Date: Sat, 8 Feb 2014 03:39:34 +0100 Subject: [PATCH] lavd/opengl_enc: add gray8/16 formats Signed-off-by: Lukasz Marek --- libavdevice/opengl_enc.c | 2 ++ libavdevice/opengl_enc_shaders.h | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c index 9fdaa430f9..287d3ce18b 100644 --- a/libavdevice/opengl_enc.c +++ b/libavdevice/opengl_enc.c @@ -265,6 +265,8 @@ static const struct OpenGLFormatDesc { { AV_PIX_FMT_GBRP16, &FF_OPENGL_FRAGMENT_SHADER_RGB_PLANAR, FF_GL_RED_COMPONENT, GL_UNSIGNED_SHORT }, { AV_PIX_FMT_GBRAP, &FF_OPENGL_FRAGMENT_SHADER_RGBA_PLANAR, FF_GL_RED_COMPONENT, GL_UNSIGNED_BYTE }, { AV_PIX_FMT_GBRAP16, &FF_OPENGL_FRAGMENT_SHADER_RGBA_PLANAR, FF_GL_RED_COMPONENT, GL_UNSIGNED_SHORT }, + { AV_PIX_FMT_GRAY8, &FF_OPENGL_FRAGMENT_SHADER_GRAY, FF_GL_RED_COMPONENT, GL_UNSIGNED_BYTE }, + { AV_PIX_FMT_GRAY16, &FF_OPENGL_FRAGMENT_SHADER_GRAY, FF_GL_RED_COMPONENT, GL_UNSIGNED_SHORT }, { AV_PIX_FMT_NONE, NULL } }; diff --git a/libavdevice/opengl_enc_shaders.h b/libavdevice/opengl_enc_shaders.h index 66104e03cb..6378dfb8cc 100644 --- a/libavdevice/opengl_enc_shaders.h +++ b/libavdevice/opengl_enc_shaders.h @@ -173,4 +173,16 @@ static const char * const FF_OPENGL_FRAGMENT_SHADER_YUVA_PLANAR = "1.5958, -0.81290, 0.0) * yuv, texture2D(u_texture3, texture_coordinate).r), 0.0, 1.0);" "}"; +static const char * const FF_OPENGL_FRAGMENT_SHADER_GRAY = +#if defined(GL_ES_VERSION_2_0) + "precision mediump float;" +#endif + "uniform sampler2D u_texture0;" + "varying vec2 texture_coordinate;" + "void main()" + "{" + "float c = texture2D(u_texture0, texture_coordinate);" + "gl_FragColor = vec4(c, c, c, 1.0);" + "}"; + #endif /* AVDEVICE_OPENGL_SHADERS_H */