From 326e02e955fbd88b5fbd489a14cf332b1e450957 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 10 Jun 2017 02:05:28 +0200 Subject: vo_opengl: implement sony s-log1 trc Source: https://pro.sony.com/bbsccms/assets/files/mkt/cinema/solutions/slog_manual.pdf Not 100% confident in the implementation since the values from the spec seem to be very subtly off (~1%), but it should be close enough for practical purposes. --- video/out/opengl/video_shaders.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'video/out') diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c index 26f751afb2..63a4713a34 100644 --- a/video/out/opengl/video_shaders.c +++ b/video/out/opengl/video_shaders.c @@ -235,6 +235,11 @@ static const float VLOG_B = 0.00873, VLOG_C = 0.241514, VLOG_D = 0.598206; +// Common constants for Sony S-Log +static const float SLOG_A = 0.432699, + SLOG_B = 0.037584, + SLOG_C = 0.616596 + 0.03; + // Linearize (expand), given a TRC as input. In essence, this is the ITU-R // EOTF, calculated on an idealized (reference) monitor with a white point of // MP_REF_WHITE and infinite contrast. @@ -298,6 +303,11 @@ void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc) " lessThanEqual(vec3(0.181), color.rgb)); \n", VLOG_D, VLOG_C, VLOG_B); break; + case MP_CSP_TRC_S_LOG1: + GLSLF("color.rgb = pow(vec3(10.0), (color.rgb - vec3(%f)) / vec3(%f))\n" + " - vec3(%f);\n", + SLOG_C, SLOG_A, SLOG_B); + break; default: abort(); } @@ -363,6 +373,10 @@ void pass_delinearize(struct gl_shader_cache *sc, enum mp_csp_trc trc) " lessThanEqual(vec3(0.01), color.rgb)); \n", VLOG_C / M_LN10, VLOG_B, VLOG_D); break; + case MP_CSP_TRC_S_LOG1: + GLSLF("color.rgb = vec3(%f) * log(color.rgb + vec3(%f)) + vec3(%f);\n", + SLOG_A / M_LN10, SLOG_B, SLOG_C); + break; default: abort(); } -- cgit v1.2.3