From b4b719e33748970a9bf98a82a017d8f149ecb557 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 3 Jan 2019 17:18:58 +0100 Subject: vo_gpu: clamp sigmoid function Can explode on some clips otherwise --- video/out/gpu/video.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 5e805019ea..df357b3552 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -2381,6 +2381,7 @@ static void pass_scale_main(struct gl_video *p) // values at 1 and 0, and then scale/shift them, respectively. sig_offset = 1.0/(1+expf(sig_slope * sig_center)); sig_scale = 1.0/(1+expf(sig_slope * (sig_center-1))) - sig_offset; + GLSL(color.rgb = clamp(color.rgb, 0.0, 1.0);) GLSLF("color.rgb = %f - log(1.0/(color.rgb * %f + %f) - 1.0) * 1.0/%f;\n", sig_center, sig_scale, sig_offset, sig_slope); pass_opt_hook_point(p, "SIGMOID", NULL); @@ -2408,6 +2409,7 @@ static void pass_scale_main(struct gl_video *p) GLSLF("// scaler post-conversion\n"); if (use_sigmoid) { // Inverse of the transformation above + GLSL(color.rgb = clamp(color.rgb, 0.0, 1.0);) GLSLF("color.rgb = (1.0/(1.0 + exp(%f * (%f - color.rgb))) - %f) * 1.0/%f;\n", sig_slope, sig_center, sig_offset, sig_scale); } -- cgit v1.2.3