summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
Diffstat (limited to 'video')
-rw-r--r--video/out/opengl/video.c1
-rw-r--r--video/out/opengl/video.h1
-rw-r--r--video/out/opengl/video_shaders.c15
3 files changed, 17 insertions, 0 deletions
diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c
index 0bfba10ae1..4a91db69f0 100644
--- a/video/out/opengl/video.c
+++ b/video/out/opengl/video.c
@@ -328,6 +328,7 @@ const struct m_sub_options gl_video_conf = {
OPT_INTRANGE("target-brightness", target_brightness, 0, 1, 100000),
OPT_CHOICE("hdr-tone-mapping", hdr_tone_mapping, 0,
({"clip", TONE_MAPPING_CLIP},
+ {"mobius", TONE_MAPPING_MOBIUS},
{"reinhard", TONE_MAPPING_REINHARD},
{"hable", TONE_MAPPING_HABLE},
{"gamma", TONE_MAPPING_GAMMA},
diff --git a/video/out/opengl/video.h b/video/out/opengl/video.h
index 236ab067c4..3b6533e0ef 100644
--- a/video/out/opengl/video.h
+++ b/video/out/opengl/video.h
@@ -91,6 +91,7 @@ enum blend_subs_mode {
enum tone_mapping {
TONE_MAPPING_CLIP,
+ TONE_MAPPING_MOBIUS,
TONE_MAPPING_REINHARD,
TONE_MAPPING_HABLE,
TONE_MAPPING_GAMMA,
diff --git a/video/out/opengl/video_shaders.c b/video/out/opengl/video_shaders.c
index 5421589d06..95ac712f05 100644
--- a/video/out/opengl/video_shaders.c
+++ b/video/out/opengl/video_shaders.c
@@ -377,6 +377,21 @@ static void pass_tone_map(struct gl_shader_cache *sc, float ref_peak,
GLSL(color.rgb = clamp(color.rgb, 0.0, 1.0);)
break;
+ case TONE_MAPPING_MOBIUS: {
+ float j = isnan(param) ? 0.3 : param;
+ // solve for M(j) = j; M(ref_peak) = 1.0; M'(j) = 1.0
+ // where M(x) = scale * (x+a)/(x+b)
+ float a = -j*j * (ref_peak - 1) / (j*j - 2*j + ref_peak),
+ b = (j*j - 2*j*ref_peak + ref_peak) / (ref_peak - 1);
+
+ GLSLF("color.rgb = mix(vec3(%f) * (color.rgb + vec3(%f))\n"
+ " / (color.rgb + vec3(%f)),\n"
+ " color.rgb,\n"
+ " lessThanEqual(color.rgb, vec3(%f)));\n",
+ (b*b + 2*b*j + j*j) / (b - a), a, b, j);
+ break;
+ }
+
case TONE_MAPPING_REINHARD: {
float contrast = isnan(param) ? 0.5 : param,
offset = (1.0 - contrast) / contrast;