1
mirror of https://github.com/mpv-player/mpv synced 2024-11-03 03:19:24 +01:00

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.
This commit is contained in:
Niklas Haas 2018-02-23 13:35:59 +01:00 committed by Jan Ekström
parent 66dfb96fa1
commit 1f2d8ed01c

View File

@ -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: {