diff options
author | Niklas Haas <git@nand.wakku.to> | 2016-06-26 19:28:06 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2016-06-28 19:48:29 +0200 |
commit | f3b6966d14e8cb34477474b85c83beb46e542e70 (patch) | |
tree | 23b0e2c0fd892c5d57a7b3ca73805cf31b8e6fad /video/out/opengl/video_shaders.c | |
parent | 740fdc139fae87144deb3cfe5897649ba2571b27 (diff) | |
download | mpv-f3b6966d14e8cb34477474b85c83beb46e542e70.tar.bz2 mpv-f3b6966d14e8cb34477474b85c83beb46e542e70.tar.xz |
vo_opengl: implement the Panasonic V-Log function
User request and not that hard. Closes #3157.
Note that FFmpeg doesn't support this and there's no signalling in HEVC
etc., so the only way users can access it is by using vf_format
manually.
Mind: This encoding uses full range values, not TV range.
Diffstat (limited to 'video/out/opengl/video_shaders.c')
-rw-r--r-- | video/out/opengl/video_shaders.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c index 4a15b6ceed..7b736f1d5d 100644 --- a/video/out/opengl/video_shaders.c +++ b/video/out/opengl/video_shaders.c @@ -232,6 +232,12 @@ static const float B67_A = 0.17883277, B67_B = 0.28466892, B67_C = 0.55991073; +// Common constants for Panasonic V-Log +static const float VLOG_B = 0.00873, + VLOG_C = 0.241514, + VLOG_D = 0.598206, + VLOG_R = 46.085527; // nominal peak + // Linearize (expand), given a TRC as input void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc) { @@ -281,6 +287,16 @@ void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc) // assume 1.0 is the maximum brightness, not the reference peak) GLSL(color.rgb /= vec3(12.0);) break; + case MP_CSP_TRC_V_LOG: + GLSLF("color.rgb = mix((color.rgb - vec3(0.125)) / vec3(5.6), \n" + " pow(vec3(10.0), (color.rgb - vec3(%f)) / vec3(%f)) \n" + " - vec3(%f), \n" + " lessThanEqual(vec3(0.181), color.rgb)); \n", + VLOG_D, VLOG_C, VLOG_B); + // Same deal as with the B67 function, renormalize to texture range + GLSLF("color.rgb /= vec3(%f);\n", VLOG_R); + GLSL(color.rgb = clamp(color.rgb, 0.0, 1.0);) + break; default: abort(); } @@ -331,6 +347,14 @@ void pass_delinearize(struct gl_shader_cache *sc, enum mp_csp_trc trc) " lessThan(vec3(1.0), color.rgb));\n", B67_A, B67_B, B67_C); break; + case MP_CSP_TRC_V_LOG: + GLSLF("color.rgb *= vec3(%f);\n", VLOG_R); + GLSLF("color.rgb = mix(vec3(5.6) * color.rgb + vec3(0.125), \n" + " vec3(%f) * log(color.rgb + vec3(%f)) \n" + " + vec3(%f), \n" + " lessThanEqual(vec3(0.01), color.rgb)); \n", + VLOG_C / M_LN10, VLOG_B, VLOG_D); + break; default: abort(); } |