1 From b579384a239683232f5558216cc03c6ae5a5dc38 Mon Sep 17 00:00:00 2001
2 From: Niklas Haas <git@haasn.xyz>
3 Date: Mon, 6 May 2019 09:56:36 +0200
4 Subject: [PATCH] placebo: update for new tone mapping desaturation algo
6 This was introduced in API version 10, and refactors the tone mapping
7 desaturation curve into a new, more tunable algorithm that has some
8 different behavior. In particular, it allows us to simulate exactly the
9 "hollywood" style of tone mapping, so we document those special values
12 Signed-off-by: Thomas Guillem <thomas@gllm.fr>
14 .../video_output/opengl/fragment_shaders.c | 6 ++++++
15 modules/video_output/opengl/vout_helper.h | 19 +++++++++++++++++--
16 modules/video_output/placebo_utils.h | 12 ++++++++++++
17 modules/video_output/vulkan/display.c | 18 ++++++++++++++++++
18 4 files changed, 53 insertions(+), 2 deletions(-)
20 diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
21 index f58b4467b6..79bba13912 100644
22 --- a/modules/video_output/opengl/fragment_shaders.c
23 +++ b/modules/video_output/opengl/fragment_shaders.c
24 @@ -558,7 +558,13 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
25 color_params.intent = var_InheritInteger(tc->gl, "rendering-intent");
26 color_params.tone_mapping_algo = var_InheritInteger(tc->gl, "tone-mapping");
27 color_params.tone_mapping_param = var_InheritFloat(tc->gl, "tone-mapping-param");
28 +# if PL_API_VER >= 10
29 + color_params.desaturation_strength = var_InheritFloat(tc->gl, "desat-strength");
30 + color_params.desaturation_exponent = var_InheritFloat(tc->gl, "desat-exponent");
31 + color_params.desaturation_base = var_InheritFloat(tc->gl, "desat-base");
33 color_params.tone_mapping_desaturate = var_InheritFloat(tc->gl, "tone-mapping-desat");
35 color_params.gamut_warning = var_InheritBool(tc->gl, "tone-mapping-warn");
37 struct pl_color_space dst_space = pl_color_space_unknown;
38 diff --git a/modules/video_output/opengl/vout_helper.h b/modules/video_output/opengl/vout_helper.h
39 index a13f66c1cc..332f63c79e 100644
40 --- a/modules/video_output/opengl/vout_helper.h
41 +++ b/modules/video_output/opengl/vout_helper.h
43 #define TONEMAP_DESAT_TEXT "Tone-mapping desaturation coefficient"
44 #define TONEMAP_DESAT_LONGTEXT "How strongly to desaturate overbright colors towards white. 0.0 disables this behavior."
46 +#define DESAT_STRENGTH_TEXT "Desaturation strength"
47 +#define DESAT_STRENGTH_LONGTEXT "How strongly to desaturate bright spectral colors towards white. 0.0 disables this behavior, 1.0 enables full desaturation (hollywood-style)"
49 +#define DESAT_EXPONENT_TEXT "Desaturation exponent"
50 +#define DESAT_EXPONENT_LONGTEXT "Controls the steepness of the desaturation curve. If you set this to 0.0, the curve will be flat, i.e. desaturation always enabled (hollywood-style)."
52 +#define DESAT_BASE_TEXT "Desaturation base"
53 +#define DESAT_BASE_LONGTEXT "Controls the starting offset of the desaturation curve. Brightness values below this base will always be colorimetrically tone mapped (never desaturated)."
55 #define TONEMAP_WARN_TEXT "Highlight clipped pixels"
56 #define TONEMAP_WARN_LONGTEXT "Debugging tool to indicate which pixels were clipped as part of the tone mapping process."
59 #ifdef HAVE_LIBPLACEBO
60 #include "../placebo_utils.h"
64 +#define add_desat_params() \
65 + add_float("desat-strength", pl_color_map_default_params.desaturation_strength, \
66 + DESAT_STRENGTH_TEXT, DESAT_STRENGTH_LONGTEXT, false) \
67 + add_float("desat-exponent", pl_color_map_default_params.desaturation_exponent, \
68 + DESAT_EXPONENT_TEXT, DESAT_EXPONENT_LONGTEXT, false) \
69 + add_float("desat-base", pl_color_map_default_params.desaturation_base, \
70 + DESAT_BASE_TEXT, DESAT_BASE_LONGTEXT, false) \
71 + add_obsolete_string("tone-mapping-desat")
73 +#define add_desat_params() \
74 + add_float("tone-mapping-desat", pl_color_map_default_params.tone_mapping_desaturate, \
75 + TONEMAP_DESAT_TEXT, TONEMAP_DESAT_LONGTEXT, false)
78 #define add_glopts_placebo() \
79 set_section(N_("Colorspace conversion"), NULL) \
80 add_integer("rendering-intent", pl_color_map_default_params.intent, \
82 add_integer("tone-mapping", PL_TONE_MAPPING_HABLE, \
83 TONEMAPPING_TEXT, TONEMAPPING_LONGTEXT, false) \
84 change_integer_list(tone_values, tone_text) \
85 + add_desat_params() \
86 add_float("tone-mapping-param", pl_color_map_default_params.tone_mapping_param, \
87 TONEMAP_PARAM_TEXT, TONEMAP_PARAM_LONGTEXT, true) \
88 - add_float("tone-mapping-desat", pl_color_map_default_params.tone_mapping_desaturate, \
89 - TONEMAP_DESAT_TEXT, TONEMAP_DESAT_LONGTEXT, false) \
90 add_bool("tone-mapping-warn", false, TONEMAP_WARN_TEXT, TONEMAP_WARN_LONGTEXT, false) \
91 set_section("Dithering", NULL) \
92 add_integer("dither-algo", -1, DITHER_TEXT, DITHER_LONGTEXT, false) \
96 From 24dc03640d3cfd89aa87ce63929aba17911c4b85 Mon Sep 17 00:00:00 2001
97 From: Niklas Haas <git@haasn.xyz>
98 Date: Mon, 6 May 2019 09:56:38 +0200
99 Subject: [PATCH] opengl: update libplacebo call for changed API
101 This will be the last time a change to this signature is needed, since
102 we just switched to using a params struct rather than updating the
103 signature constantly.
105 Signed-off-by: Thomas Guillem <thomas@gllm.fr>
107 modules/video_output/opengl/vout_helper.c | 4 +++-
108 1 file changed, 3 insertions(+), 1 deletion(-)
110 diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
111 index f1069ccb1f9..b59343f7b5f 100644
112 --- a/modules/video_output/opengl/vout_helper.c
113 +++ b/modules/video_output/opengl/vout_helper.c
114 @@ -551,7 +551,9 @@ opengl_init_program(vout_display_opengl_t *vgl, vlc_video_context *context,
116 tc->pl_ctx = vlc_placebo_Create(VLC_OBJECT(tc));
118 -# if PL_API_VER >= 6
119 +# if PL_API_VER >= 20
120 + tc->pl_sh = pl_shader_alloc(tc->pl_ctx, NULL);
121 +# elif PL_API_VER >= 6
122 tc->pl_sh = pl_shader_alloc(tc->pl_ctx, NULL, 0);
124 tc->pl_sh = pl_shader_alloc(tc->pl_ctx, NULL, 0, 0);