[vlc-devel] [PATCH 1/2] placebo: update for new tone mapping desaturation algo
Jean-Baptiste Kempf
jb at videolan.org
Mon Mar 30 20:18:19 CEST 2020
LGTM.
On Mon, Mar 30, 2020, at 20:01, Konstantin Pavlov wrote:
> This was introduced in API version 10, and refactors the tone mapping
> desaturation curve into a new, more tunable algorithm that has some
> different behavior. In particular, it allows us to simulate exactly the
> "hollywood" style of tone mapping, so we document those special values
> specifically.
>
> This is a manual backport of b579384a239683232f5558216cc03c6ae5a5dc38
> ---
> .../video_output/opengl/fragment_shaders.c | 7 ++++
> modules/video_output/opengl/vout_helper.h | 34 +++++++++++++++++--
> 2 files changed, 38 insertions(+), 3 deletions(-)
>
> diff --git a/modules/video_output/opengl/fragment_shaders.c
> b/modules/video_output/opengl/fragment_shaders.c
> index 8c1f67ee7a..e0b98732ca 100644
> --- a/modules/video_output/opengl/fragment_shaders.c
> +++ b/modules/video_output/opengl/fragment_shaders.c
> @@ -616,7 +616,14 @@
> opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum
> tex_target,
> color_params.intent = var_InheritInteger(tc->gl,
> "rendering-intent");
> color_params.tone_mapping_algo = var_InheritInteger(tc->gl,
> "tone-mapping");
> color_params.tone_mapping_param = var_InheritFloat(tc->gl,
> "tone-mapping-param");
> +#if PL_API_VER >= 10
> + color_params.desaturation_strength = var_InheritFloat(tc->gl,
> "desat-strength");
> + color_params.desaturation_exponent = var_InheritFloat(tc->gl,
> "desat-exponent");
> + color_params.desaturation_base = var_InheritFloat(tc->gl,
> "desat-base");
> + color_params.max_boost = var_InheritFloat(tc->gl, "max-boost");
> +#else
> color_params.tone_mapping_desaturate =
> var_InheritFloat(tc->gl, "tone-mapping-desat");
> +#endif
> color_params.gamut_warning = var_InheritBool(tc->gl,
> "tone-mapping-warn");
>
> struct pl_color_space dst_space = pl_color_space_unknown;
> diff --git a/modules/video_output/opengl/vout_helper.h
> b/modules/video_output/opengl/vout_helper.h
> index 978669f89c..db9ed52e39 100644
> --- a/modules/video_output/opengl/vout_helper.h
> +++ b/modules/video_output/opengl/vout_helper.h
> @@ -148,6 +148,18 @@ static const char * const tone_text[] = {
> #define TONEMAP_DESAT_TEXT "Tone-mapping desaturation coefficient"
> #define TONEMAP_DESAT_LONGTEXT "How strongly to desaturate overbright
> colors towards white. 0.0 disables this behavior."
>
> +#define DESAT_STRENGTH_TEXT "Desaturation strength"
> +#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)"
> +
> +#define DESAT_EXPONENT_TEXT "Desaturation exponent"
> +#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)."
> +
> +#define DESAT_BASE_TEXT "Desaturation base"
> +#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)."
> +
> +#define MAX_BOOST_TEXT "Maximum brightness boost"
> +#define MAX_BOOST_LONGTEXT "Maximum allowed brightness boost to
> compensate for dark scenes. A value of 1.0 means no brightness boost is
> allowed."
> +
> #define TONEMAP_WARN_TEXT "Highlight clipped pixels"
> #define TONEMAP_WARN_LONGTEXT "Debugging tool to indicate which pixels
> were clipped as part of the tone mapping process."
>
> @@ -171,6 +183,23 @@ static const char * const dither_text[] = {
> #define DEPTH_TEXT "Dither depth override (0 = framebuffer depth)"
> #define DEPTH_LONGTEXT "Overrides the detected framebuffer depth.
> Useful to dither to lower bit depths than otherwise required."
>
> +#if PL_API_VER >= 10
> +#define add_desat_params() \
> + add_float("desat-strength",
> pl_color_map_default_params.desaturation_strength, \
> + DESAT_STRENGTH_TEXT, DESAT_STRENGTH_LONGTEXT, false) \
> + add_float("desat-exponent",
> pl_color_map_default_params.desaturation_exponent, \
> + DESAT_EXPONENT_TEXT, DESAT_EXPONENT_LONGTEXT, false) \
> + add_float("desat-base",
> pl_color_map_default_params.desaturation_base, \
> + DESAT_BASE_TEXT, DESAT_BASE_LONGTEXT, false) \
> + add_float("max-boost", pl_color_map_default_params.max_boost, \
> + MAX_BOOST_TEXT, MAX_BOOST_LONGTEXT, false) \
> + add_obsolete_string("tone-mapping-desat")
> +#else
> +#define add_desat_params() \
> + add_float("tone-mapping-desat",
> pl_color_map_default_params.tone_mapping_desaturate, \
> + TONEMAP_DESAT_TEXT, TONEMAP_DESAT_LONGTEXT, false)
> +#endif
> +
> #define add_glopts_placebo() \
> set_section("Colorspace conversion", NULL) \
> add_integer("rendering-intent",
> pl_color_map_default_params.intent, \
> @@ -186,13 +215,12 @@ static const char * const dither_text[] = {
> change_integer_list(tone_values, tone_text) \
> add_float("tone-mapping-param",
> pl_color_map_default_params.tone_mapping_param, \
> TONEMAP_PARAM_TEXT, TONEMAP_PARAM_LONGTEXT, true) \
> - add_float("tone-mapping-desat",
> pl_color_map_default_params.tone_mapping_desaturate, \
> - TONEMAP_DESAT_TEXT, TONEMAP_DESAT_LONGTEXT, false) \
> add_bool("tone-mapping-warn", false, TONEMAP_WARN_TEXT,
> TONEMAP_WARN_LONGTEXT, false) \
> set_section("Dithering", NULL) \
> add_integer("dither-algo", -1, DITHER_TEXT, DITHER_LONGTEXT,
> false) \
> change_integer_list(dither_values, dither_text) \
> - add_integer_with_range("dither-depth", 0, 0, 16, DEPTH_TEXT,
> DEPTH_LONGTEXT, false)
> + add_integer_with_range("dither-depth", 0, 0, 16, DEPTH_TEXT,
> DEPTH_LONGTEXT, false) \
> + add_desat_params()
> #else
> #define add_glopts_placebo()
> #endif
> --
> 2.25.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
--
Jean-Baptiste Kempf - President
+33 672 704 734
More information about the vlc-devel
mailing list