From 6074cfdfd4b461c7991c9d16e57a6d1b63751c72 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 3 Aug 2017 12:03:43 +0200 Subject: vo_opengl: implement HLG OOTF inverse Huge thanks to @rusxg for finding this solution, which was previously believed not to exist. Of course, we still don't actually need it, but I don't want to leave this half-implemented in case somebody does in the future. --- video/out/opengl/video_shaders.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'video') diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c index d0e3eaff07..4708187580 100644 --- a/video/out/opengl/video_shaders.c +++ b/video/out/opengl/video_shaders.c @@ -537,12 +537,7 @@ void pass_ootf(struct gl_shader_cache *sc, enum mp_csp_light light, float peak) GLSLF("color.rgb *= vec3(1.0/%f);\n", peak); } -// Inverse of the function pass_ootf, for completeness' sake. Note that the -// inverse OOTF for MP_CSP_LIGHT_SCENE_HLG has no analytical solution and is -// therefore unimplemented. Care must be used to never call this function -// in that way.(In principle, a iterative algorithm can approach -// the solution numerically, but this is tricky and we don't really need it -// since mpv currently only supports outputting display-referred light) +// Inverse of the function pass_ootf, for completeness' sake. void pass_inverse_ootf(struct gl_shader_cache *sc, enum mp_csp_light light, float peak) { if (light == MP_CSP_LIGHT_DISPLAY) @@ -554,8 +549,8 @@ void pass_inverse_ootf(struct gl_shader_cache *sc, enum mp_csp_light light, floa switch (light) { case MP_CSP_LIGHT_SCENE_HLG: - // Has no analytical solution - abort(); + GLSLF("color.rgb *= vec3(1.0/%f);\n", (1000 / MP_REF_WHITE) / pow(12, 1.2)); + GLSL(color.rgb *= vec3(pow(dot(src_luma, color.rgb), 0.2/1.2));) break; case MP_CSP_LIGHT_SCENE_709_1886: GLSL(color.rgb = pow(color.rgb, vec3(1.0/2.4));) -- cgit v1.2.3