summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-07-06 05:59:08 +0200
committerNiklas Haas <git@haasn.xyz>2017-07-06 05:59:08 +0200
commitef43854b3439907fa8bf77e25d450f3c71395218 (patch)
tree2fcfb8cd1e8662fb3f41ff26bb8c0f0e335a4937 /video
parent9e04018f920c6c8eed46a779af00f9543e6539d6 (diff)
downloadmpv-ef43854b3439907fa8bf77e25d450f3c71395218.tar.bz2
mpv-ef43854b3439907fa8bf77e25d450f3c71395218.tar.xz
vo_opengl: prevent division by zero in shader
In theory the max() should clamp it away anyway but I believe division by zero is UB so just avoid it altogether.
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/video_shaders.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c
index 995fbd2a1a..38d7939f96 100644
--- a/video/out/opengl/video_shaders.c
+++ b/video/out/opengl/video_shaders.c
@@ -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);\n", desat);
+ GLSLF("float overbright = max(0.0, (luma - %f) / (luma + 1e-6));\n", desat);
GLSL(color.rgb = mix(color.rgb, vec3(luma), overbright);)
}