vo_opengl: prevent desat from blowing up for negative

The current algorithm blew up when the color was negative, such as the
case when downscaling with dscale=mitchell or other algorithms that
introduce negative ringing. The simplest solution is to just slightly
change the calculation to force both parameters to be in-range.
This commit is contained in:
Niklas Haas 2017-07-07 11:26:30 +02:00
parent 6a59d7342f
commit 9c9d3e7b25
No known key found for this signature in database
GPG Key ID: 9A09076581B27402
1 changed files with 1 additions and 1 deletions

View File

@ -532,7 +532,7 @@ static void pass_tone_map(struct gl_shader_cache *sc, float ref_peak,
// Desaturate the color using a coefficient dependent on the brightness
if (desat > 0 && ref_peak > desat) {
GLSLF("float overbright = max(0.0, (luma - %f) / (luma + 1e-6));\n", desat);
GLSLF("float overbright = max(luma - %f, 1e-6) / max(luma, 1e-6);\n", desat);
GLSL(color.rgb = mix(color.rgb, vec3(luma), overbright);)
}