From 856b57e41846490e63a17e05bf399356e2388b1f Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Fri, 6 Jun 2014 14:56:59 +0200 Subject: vo_opengl: Make approx-gamma affect OSD/sub Close #837 Signed-off-by: wm4 --- video/out/gl_video.c | 5 ++++- video/out/gl_video_shaders.glsl | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 52ad1a66f4..2c6e2d35b7 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -926,7 +926,10 @@ static void compile_shaders(struct gl_video *p) shader_def_opt(&header, "USE_ALPHA", p->has_alpha); char *header_osd = talloc_strdup(tmp, header); - shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV", use_cms); + shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV_APPROX", + use_cms && p->opts.approx_gamma); + shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV_BT2020", + use_cms && !p->opts.approx_gamma); shader_def_opt(&header_osd, "USE_OSD_CMS_MATRIX", use_cms_matrix); shader_def_opt(&header_osd, "USE_OSD_3DLUT", p->use_lut_3d); // 3DLUT overrides SRGB diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index 37834dc948..6019b78243 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -88,13 +88,14 @@ void main() { gl_Position = vec4(position, 1); color = vertex_color; -#ifdef USE_OSD_LINEAR_CONV // Although we are not scaling in linear light, both 3DLUT and SRGB still // operate on linear light inputs so we have to convert to it before // either step can be applied. +#ifdef USE_OSD_LINEAR_CONV_APPROX + color.rgb = pow(color.rgb, vec3(1.95)); +#endif +#ifdef USE_OSD_LINEAR_CONV_BT2020 color.rgb = bt2020_expand(color.rgb); - // NOTE: This always applies the true BT2020, maybe we need to use - // approx-gamma here too? #endif #ifdef USE_OSD_CMS_MATRIX // Convert to the right target gamut first (to BT.709 for sRGB, -- cgit v1.2.3