summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-08-03 12:03:43 +0200
committerNiklas Haas <git@haasn.xyz>2017-08-03 12:05:37 +0200
commit6074cfdfd4b461c7991c9d16e57a6d1b63751c72 (patch)
treee31ffe61c8ce5254a5b5288c73be140cf2f27c78
parent955cc50e1beb362f01475786696c8f5125077fd1 (diff)
downloadmpv-6074cfdfd4b461c7991c9d16e57a6d1b63751c72.tar.bz2
mpv-6074cfdfd4b461c7991c9d16e57a6d1b63751c72.tar.xz
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.
-rw-r--r--video/out/opengl/video_shaders.c11
1 files changed, 3 insertions, 8 deletions
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));)