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. --- DOCS/man/options.rst | 2 ++ DOCS/man/vf.rst | 1 + video/csputils.c | 2 ++ video/csputils.h | 1 + video/out/opengl/video_shaders.c | 14 ++++++++++++++ 5 files changed, 20 insertions(+) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 74890d2433..00ff88447f 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -4627,6 +4627,8 @@ The following video options are currently all specific to ``--vo=opengl`` and ITU-R BT.2100 HLG (Hybrid Log-gamma) curve, aka ARIB STD-B67 v-log Panasonic V-Log (VARICAM) curve + s-log1 + Sony S-Log1 curve .. note:: diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst index b9a3dd41d8..17a1191dc3 100644 --- a/DOCS/man/vf.rst +++ b/DOCS/man/vf.rst @@ -366,6 +366,7 @@ Available mpv-only filters are: :pq: ITU-R BT.2100 PQ (Perceptual quantizer) curve :hlg: ITU-R BT.2100 HLG (Hybrid Log-gamma) curve :v-log: Panasonic V-Log transfer curve + :s-log1: Sony S-Log1 transfer curve ```` Reference peak illumination for the video file, relative to the diff --git a/video/csputils.c b/video/csputils.c index c97f08ea0c..0412ee28eb 100644 --- a/video/csputils.c +++ b/video/csputils.c @@ -82,6 +82,7 @@ const struct m_opt_choice_alternatives mp_csp_trc_names[] = { {"pq", MP_CSP_TRC_PQ}, {"hlg", MP_CSP_TRC_HLG}, {"v-log", MP_CSP_TRC_V_LOG}, + {"s-log1", MP_CSP_TRC_S_LOG1}, {0} }; @@ -476,6 +477,7 @@ float mp_trc_nom_peak(enum mp_csp_trc trc) case MP_CSP_TRC_PQ: return 10000.0 / MP_REF_WHITE; case MP_CSP_TRC_HLG: return 12.0; case MP_CSP_TRC_V_LOG: return 46.0855; + case MP_CSP_TRC_S_LOG1: return 6.52; } return 1.0; diff --git a/video/csputils.h b/video/csputils.h index b5446c4d6c..dc78a670ff 100644 --- a/video/csputils.h +++ b/video/csputils.h @@ -83,6 +83,7 @@ enum mp_csp_trc { MP_CSP_TRC_PQ, MP_CSP_TRC_HLG, MP_CSP_TRC_V_LOG, + MP_CSP_TRC_S_LOG1, MP_CSP_TRC_COUNT }; 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