summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.xyz>2017-06-10 02:05:28 +0200
committerwm4 <wm4@nowhere>2017-06-18 20:54:44 +0200
commit326e02e955fbd88b5fbd489a14cf332b1e450957 (patch)
tree36356313f212dadf85890fba1e5f3a0cdcbae933 /video
parentda7ae75e2626750bb254ac174b21fecba5eb41cd (diff)
downloadmpv-326e02e955fbd88b5fbd489a14cf332b1e450957.tar.bz2
mpv-326e02e955fbd88b5fbd489a14cf332b1e450957.tar.xz
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.
Diffstat (limited to 'video')
-rw-r--r--video/csputils.c2
-rw-r--r--video/csputils.h1
-rw-r--r--video/out/opengl/video_shaders.c14
3 files changed, 17 insertions, 0 deletions
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();
}