From 1f2d8ed01cfc85fb910f21e9a7290265d0dcf11c Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Fri, 23 Feb 2018 13:35:59 +0100 Subject: vo_gpu: fix mobius tone mapping when sig_peak <= 1.0 Mobius isn't well-defined for sig_peak <= 1.0. We can solve this by just soft-clamping sig_peak to 1.0. Although, in this case, we can just skip tone mapping altogether since the limit of mobius as sig_peak -> 1.0 is just a linear function. --- video/out/gpu/video_shaders.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c index b3eec11066..19fb0ccde8 100644 --- a/video/out/gpu/video_shaders.c +++ b/video/out/gpu/video_shaders.c @@ -689,6 +689,7 @@ static void pass_tone_map(struct gl_shader_cache *sc, bool detect_peak, break; case TONE_MAPPING_MOBIUS: + GLSLF("if (sig_peak > (1.0 + 1e-6)) {\n"); GLSLF("const float j = %f;\n", isnan(param) ? 0.3 : param); // solve for M(j) = j; M(sig_peak) = 1.0; M'(j) = 1.0 // where M(x) = scale * (x+a)/(x+b) @@ -697,6 +698,7 @@ static void pass_tone_map(struct gl_shader_cache *sc, bool detect_peak, "max(1e-6, sig_peak - 1.0);\n"); GLSLF("float scale = (b*b + 2.0*b*j + j*j) / (b-a);\n"); GLSL(sig = sig > j ? scale * (sig + a) / (sig + b) : sig;) + GLSLF("}\n"); break; case TONE_MAPPING_REINHARD: { -- cgit v1.2.3