summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libvo/vo_opengl.c16
-rw-r--r--libvo/vo_opengl_shaders.glsl9
2 files changed, 11 insertions, 14 deletions
diff --git a/libvo/vo_opengl.c b/libvo/vo_opengl.c
index 261e1b102f..04a3559be5 100644
--- a/libvo/vo_opengl.c
+++ b/libvo/vo_opengl.c
@@ -698,6 +698,7 @@ static void compile_shaders(struct gl_priv *p)
shader_def_opt(&header_final, "USE_LINEAR_CONV_INV", p->use_lut_3d);
shader_def_opt(&header_final, "USE_GAMMA_POW", p->use_gamma);
shader_def_opt(&header_final, "USE_3DLUT", p->use_lut_3d);
+ shader_def_opt(&header_final, "USE_SRGB", p->use_srgb);
shader_def_opt(&header_final, "USE_DITHER", p->dither_texture != 0);
if (p->use_scale_sep && p->scalers[0].kernel) {
@@ -1122,11 +1123,6 @@ static void do_render(struct gl_priv *p)
float final_texw = p->image_width * source->tex_w / (float)source->vp_w;
float final_texh = p->image_height * source->tex_h / (float)source->vp_h;
- bool use_srgb_fb = p->use_srgb && !p->use_lut_3d;
-
- if (use_srgb_fb)
- gl->Enable(GL_FRAMEBUFFER_SRGB);
-
if (p->stereo_mode) {
int w = p->src_rect.x1 - p->src_rect.x0;
int imgw = p->image_width;
@@ -1165,9 +1161,6 @@ static void do_render(struct gl_priv *p)
draw_triangles(p, vb, VERTICES_PER_QUAD);
}
- if (use_srgb_fb)
- gl->Disable(GL_FRAMEBUFFER_SRGB);
-
gl->UseProgram(0);
debug_check_gl(p, "after video rendering");
@@ -1457,8 +1450,7 @@ static void check_gl_features(struct gl_priv *p)
GL *gl = p->gl;
bool have_float_tex = gl->mpgl_caps & MPGL_CAP_FLOAT_TEX;
bool have_fbo = gl->mpgl_caps & MPGL_CAP_FB;
- bool have_srgb = (gl->mpgl_caps & MPGL_CAP_SRGB_TEX) &&
- (gl->mpgl_caps & MPGL_CAP_SRGB_FB);
+ bool have_srgb = gl->mpgl_caps & MPGL_CAP_SRGB_TEX;
char *disabled[10];
int n_disabled = 0;
@@ -1493,10 +1485,6 @@ static void check_gl_features(struct gl_priv *p)
p->use_lut_3d = false;
disabled[n_disabled++] = "color management (FBO)";
}
- if (!have_srgb && p->use_lut_3d) {
- p->use_lut_3d = false;
- disabled[n_disabled++] = "color management (sRGB)";
- }
if (!have_fbo) {
p->use_scale_sep = false;
diff --git a/libvo/vo_opengl_shaders.glsl b/libvo/vo_opengl_shaders.glsl
index 01e1433f7f..32804b99ff 100644
--- a/libvo/vo_opengl_shaders.glsl
+++ b/libvo/vo_opengl_shaders.glsl
@@ -292,6 +292,12 @@ vec4 sample_sharpen5(sampler2D tex, vec2 texsize, vec2 texcoord) {
return p + t * filter_param1;
}
+vec3 srgb_compand(vec3 v)
+{
+ return mix(1.055 * pow(v, vec3(1.0/2.4)) - vec3(0.055), v * 12.92,
+ lessThanEqual(v, vec3(0.0031308)));
+}
+
void main() {
#ifdef USE_PLANAR
vec3 color = vec3(SAMPLE_L(textures[0], textures_size[0], texcoord).r,
@@ -325,6 +331,9 @@ void main() {
#ifdef USE_3DLUT
color = texture3D(lut_3d, color).rgb;
#endif
+#ifdef USE_SRGB
+ color.rgb = srgb_compand(color.rgb);
+#endif
#ifdef USE_DITHER
float dither_value = texture(dither, gl_FragCoord.xy / dither_size).r;
color = floor(color * dither_multiply + dither_value ) / dither_quantization;