From 6c1dd02f322eba2990f4cd9a6b8ddd7a94fbf1dc Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 22 May 2021 21:18:51 +0200 Subject: vo_gpu: fix extreme clipping with --gamut-clipping for HDR outputs Checking against 1.0 is wrong for this code, because it's in an absolute luminance scale relative to reference white. We should be normalizing this by `dst.sig_peak`. --- video/out/gpu/video_shaders.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'video/out') diff --git a/video/out/gpu/video_shaders.c b/video/out/gpu/video_shaders.c index 91c9aac865..d39b867e2a 100644 --- a/video/out/gpu/video_shaders.c +++ b/video/out/gpu/video_shaders.c @@ -888,7 +888,8 @@ void pass_color_map(struct gl_shader_cache *sc, bool is_linear, float coeff = cmin / (cmin - luma); color.rgb = mix(color.rgb, vec3(luma), coeff); }) - GLSL(float cmax = max(max(color.r, color.g), color.b);) + GLSLF("float cmax = 1.0/%f * max(max(color.r, color.g), color.b);\n", + dst.sig_peak); GLSL(if (cmax > 1.0) color.rgb /= cmax;) } } -- cgit v1.2.3