summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-06-10 02:51:32 +0200
committerwm4 <wm4@nowhere>2017-06-18 20:54:44 +0200
commit2e45b8fa1ad7577fa733db2927fc1ca64d1f921e (patch)
treefa74b9e55a8fb45ec1fec1b36b2a66d33947d8ab
parent326e02e955fbd88b5fbd489a14cf332b1e450957 (diff)
downloadmpv-2e45b8fa1ad7577fa733db2927fc1ca64d1f921e.tar.bz2
mpv-2e45b8fa1ad7577fa733db2927fc1ca64d1f921e.tar.xz
vo_opengl: implement sony s-log2 trc
Apparently this is virtually identical to Panasonic's V-Log, but using the constants from S-Log1 and an extra scaling coefficient to make the S-Log1 curve less limited. Whatever floats their NIH boat, I guess. Source: https://pro.sony.com/bbsccms/assets/files/micro/dmpc/training/S-Log2_Technical_PaperV1_0.pdf
-rw-r--r--DOCS/man/options.rst2
-rw-r--r--DOCS/man/vf.rst1
-rw-r--r--video/csputils.c2
-rw-r--r--video/csputils.h1
-rw-r--r--video/out/opengl/video_shaders.c19
5 files changed, 24 insertions, 1 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 00ff88447f..ab6508d20a 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -4629,6 +4629,8 @@ The following video options are currently all specific to ``--vo=opengl`` and
Panasonic V-Log (VARICAM) curve
s-log1
Sony S-Log1 curve
+ s-log2
+ Sony S-Log2 curve
.. note::
diff --git a/DOCS/man/vf.rst b/DOCS/man/vf.rst
index 17a1191dc3..9e416b8df8 100644
--- a/DOCS/man/vf.rst
+++ b/DOCS/man/vf.rst
@@ -367,6 +367,7 @@ Available mpv-only filters are:
:hlg: ITU-R BT.2100 HLG (Hybrid Log-gamma) curve
:v-log: Panasonic V-Log transfer curve
:s-log1: Sony S-Log1 transfer curve
+ :s-log2: Sony S-Log2 transfer curve
``<sig-peak>``
Reference peak illumination for the video file, relative to the
diff --git a/video/csputils.c b/video/csputils.c
index 0412ee28eb..a4ed9337d2 100644
--- a/video/csputils.c
+++ b/video/csputils.c
@@ -83,6 +83,7 @@ const struct m_opt_choice_alternatives mp_csp_trc_names[] = {
{"hlg", MP_CSP_TRC_HLG},
{"v-log", MP_CSP_TRC_V_LOG},
{"s-log1", MP_CSP_TRC_S_LOG1},
+ {"s-log2", MP_CSP_TRC_S_LOG2},
{0}
};
@@ -478,6 +479,7 @@ float mp_trc_nom_peak(enum mp_csp_trc trc)
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;
+ case MP_CSP_TRC_S_LOG2: return 9.212;
}
return 1.0;
diff --git a/video/csputils.h b/video/csputils.h
index dc78a670ff..2119cca45a 100644
--- a/video/csputils.h
+++ b/video/csputils.h
@@ -84,6 +84,7 @@ enum mp_csp_trc {
MP_CSP_TRC_HLG,
MP_CSP_TRC_V_LOG,
MP_CSP_TRC_S_LOG1,
+ MP_CSP_TRC_S_LOG2,
MP_CSP_TRC_COUNT
};
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c
index 63a4713a34..d2623738d7 100644
--- a/video/out/opengl/video_shaders.c
+++ b/video/out/opengl/video_shaders.c
@@ -238,7 +238,10 @@ static const float VLOG_B = 0.00873,
// Common constants for Sony S-Log
static const float SLOG_A = 0.432699,
SLOG_B = 0.037584,
- SLOG_C = 0.616596 + 0.03;
+ SLOG_C = 0.616596 + 0.03,
+ SLOG_P = 3.538813,
+ SLOG_Q = 0.030001,
+ SLOG_K2 = 155.0 / 219.0;
// 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
@@ -308,6 +311,13 @@ void pass_linearize(struct gl_shader_cache *sc, enum mp_csp_trc trc)
" - vec3(%f);\n",
SLOG_C, SLOG_A, SLOG_B);
break;
+ case MP_CSP_TRC_S_LOG2:
+ GLSLF("color.rgb = mix((color.rgb - vec3(%f)) / vec3(%f), \n"
+ " (pow(vec3(10.0), (color.rgb - vec3(%f)) / vec3(%f)) \n"
+ " - vec3(%f)) / vec3(%f), \n"
+ " lessThanEqual(vec3(%f), color.rgb)); \n",
+ SLOG_Q, SLOG_P, SLOG_C, SLOG_A, SLOG_B, SLOG_K2, SLOG_Q);
+ break;
default:
abort();
}
@@ -377,6 +387,13 @@ void pass_delinearize(struct gl_shader_cache *sc, enum mp_csp_trc trc)
GLSLF("color.rgb = vec3(%f) * log(color.rgb + vec3(%f)) + vec3(%f);\n",
SLOG_A / M_LN10, SLOG_B, SLOG_C);
break;
+ case MP_CSP_TRC_S_LOG2:
+ GLSLF("color.rgb = mix(vec3(%f) * color.rgb + vec3(%f), \n"
+ " vec3(%f) * log(vec3(%f) * color.rgb + vec3(%f)) \n"
+ " + vec3(%f), \n"
+ " lessThanEqual(vec3(0.0), color.rgb)); \n",
+ SLOG_P, SLOG_Q, SLOG_A / M_LN10, SLOG_K2, SLOG_B, SLOG_C);
+ break;
default:
abort();
}