diff options
author | Niklas Haas <git@haasn.xyz> | 2018-02-23 13:35:59 +0100 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2018-02-25 16:11:26 +0200 |
commit | 1f2d8ed01cfc85fb910f21e9a7290265d0dcf11c (patch) | |
tree | 714430fa690d1ab837dd4fadb47f8fc07e6c319a /video | |
parent | 66dfb96fa1e49127fb76eddec8ecfce973acdc21 (diff) | |
download | mpv-1f2d8ed01cfc85fb910f21e9a7290265d0dcf11c.tar.bz2 mpv-1f2d8ed01cfc85fb910f21e9a7290265d0dcf11c.tar.xz |
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.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gpu/video_shaders.c | 2 |
1 files changed, 2 insertions, 0 deletions
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: { |