[vlc-commits] opengl: add GUI options for libplacebo settings
Niklas Haas
git at videolan.org
Mon Jan 8 11:47:07 CET 2018
vlc/vlc-3.0 | branch: master | Niklas Haas <vlc at haasn.xyz> | Thu Dec 28 04:48:56 2017 +0100| [f1bf13e4bc4a7f1e4b99b6c850abaa923948b56d] | committer: Jean-Baptiste Kempf
opengl: add GUI options for libplacebo settings
This allows users to override the target colorspace, some of the
colorspace conversion options, the tone mapping settings, and some of
the dithering settings.
Settings which I decided to omit include:
- dither LUT size (limited by the shader embedding method)
- temporal dither (not currently possible)
- overrides for the source colorspace (shouldn't persist)
- target display's light type (unlikely to not be _DISPLAY)
- target display's HDR metadata (usually taken care of by the display)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
(cherry picked from commit 8f1a8a15cce213d6d5c4a3892a6a9fa6e2719860)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=f1bf13e4bc4a7f1e4b99b6c850abaa923948b56d
---
modules/video_output/opengl/fragment_shaders.c | 15 ++-
modules/video_output/opengl/vout_helper.h | 146 ++++++++++++++++++++++++-
2 files changed, 158 insertions(+), 3 deletions(-)
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index ac2edcc618..74fb3b5b1a 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -606,9 +606,20 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
#ifdef HAVE_LIBPLACEBO
if (tc->pl_sh) {
struct pl_shader *sh = tc->pl_sh;
- pl_shader_color_map(sh, &pl_color_map_default_params,
+ struct pl_color_map_params color_params = pl_color_map_default_params;
+ 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");
+ color_params.tone_mapping_desaturate = var_InheritFloat(tc->gl, "tone-mapping-desat");
+ color_params.gamut_warning = var_InheritBool(tc->gl, "tone-mapping-warn");
+
+ struct pl_color_space dst_space = pl_color_space_unknown;
+ dst_space.primaries = var_InheritInteger(tc->gl, "target-prim");
+ dst_space.transfer = var_InheritInteger(tc->gl, "target-trc");
+
+ pl_shader_color_map(sh, &color_params,
pl_color_space_from_video_format(&tc->fmt),
- pl_color_space_unknown, NULL, false);
+ dst_space, NULL, false);
const struct pl_shader_res *res = tc->pl_sh_res = pl_shader_finalize(sh);
diff --git a/modules/video_output/opengl/vout_helper.h b/modules/video_output/opengl/vout_helper.h
index 939a000d2e..69ba699935 100644
--- a/modules/video_output/opengl/vout_helper.h
+++ b/modules/video_output/opengl/vout_helper.h
@@ -58,11 +58,155 @@
# endif
#endif
+#ifdef HAVE_LIBPLACEBO
+#include <libplacebo/shaders/colorspace.h>
+
+#define RENDER_INTENT_TEXT "Rendering intent for color conversion"
+#define RENDER_INTENT_LONGTEXT "The algorithm used to convert between color spaces"
+
+static const int intent_values[] = {
+ PL_INTENT_PERCEPTUAL,
+ PL_INTENT_RELATIVE_COLORIMETRIC,
+ PL_INTENT_SATURATION,
+ PL_INTENT_ABSOLUTE_COLORIMETRIC,
+};
+
+static const char * const intent_text[] = {
+ "Perceptual",
+ "Relative colorimetric",
+ "Absolute colorimetric",
+ "Saturation",
+};
+
+#define PRIM_TEXT "Display primaries"
+#define PRIM_LONGTEXT "The primaries associated with the output display"
+
+static const int prim_values[] = {
+ PL_COLOR_PRIM_UNKNOWN,
+ PL_COLOR_PRIM_BT_601_525,
+ PL_COLOR_PRIM_BT_601_625,
+ PL_COLOR_PRIM_BT_709,
+ PL_COLOR_PRIM_BT_470M,
+ PL_COLOR_PRIM_BT_2020,
+ PL_COLOR_PRIM_APPLE,
+ PL_COLOR_PRIM_ADOBE,
+ PL_COLOR_PRIM_PRO_PHOTO,
+ PL_COLOR_PRIM_CIE_1931,
+ PL_COLOR_PRIM_DCI_P3,
+ PL_COLOR_PRIM_V_GAMUT,
+ PL_COLOR_PRIM_S_GAMUT,
+};
+
+static const char * const prim_text[] = {
+ "Unknown primaries",
+ "ITU-R Rec. BT.601 (525-line = NTSC, SMPTE-C)",
+ "ITU-R Rec. BT.601 (625-line = PAL, SECAM)",
+ "ITU-R Rec. BT.709 (HD), also sRGB",
+ "ITU-R Rec. BT.470 M",
+ "ITU-R Rec. BT.2020 (UltraHD)",
+ "Apple RGB",
+ "Adobe RGB (1998)",
+ "ProPhoto RGB (ROMM)",
+ "CIE 1931 RGB primaries",
+ "DCI-P3 (Digital Cinema)",
+ "Panasonic V-Gamut (VARICAM)",
+ "Sony S-Gamut",
+};
+
+#define TRC_TEXT "Display gamma / transfer function"
+#define TRC_LONGTEXT "The gamma/transfer function associated with the output display"
+
+static const int trc_values[] = {
+ PL_COLOR_TRC_UNKNOWN,
+ PL_COLOR_TRC_BT_1886,
+ PL_COLOR_TRC_SRGB,
+ PL_COLOR_TRC_LINEAR,
+ PL_COLOR_TRC_GAMMA18,
+ PL_COLOR_TRC_GAMMA22,
+ PL_COLOR_TRC_GAMMA28,
+ PL_COLOR_TRC_PRO_PHOTO,
+ PL_COLOR_TRC_PQ,
+ PL_COLOR_TRC_HLG,
+ PL_COLOR_TRC_V_LOG,
+ PL_COLOR_TRC_S_LOG1,
+ PL_COLOR_TRC_S_LOG2,
+};
+
+static const char * const trc_text[] = {
+ "Unknown gamma",
+ "ITU-R Rec. BT.1886 (CRT emulation + OOTF)",
+ "IEC 61966-2-4 sRGB (CRT emulation)",
+ "Linear light content",
+ "Pure power gamma 1.8",
+ "Pure power gamma 2.2",
+ "Pure power gamma 2.8",
+ "ProPhoto RGB (ROMM)",
+ "ITU-R BT.2100 PQ (perceptual quantizer), aka SMPTE ST2048",
+ "ITU-R BT.2100 HLG (hybrid log-gamma), aka ARIB STD-B67",
+ "Panasonic V-Log (VARICAM)",
+ "Sony S-Log1",
+ "Sony S-Log2",
+};
+
+#define TONEMAPPING_TEXT "Tone-mapping algorithm"
+#define TONEMAPPING_LONGTEXT "Algorithm to use when converting from wide gamut to standard gamut, or from HDR to SDR"
+
+static const int tone_values[] = {
+ PL_TONE_MAPPING_HABLE,
+ PL_TONE_MAPPING_MOBIUS,
+ PL_TONE_MAPPING_REINHARD,
+ PL_TONE_MAPPING_GAMMA,
+ PL_TONE_MAPPING_LINEAR,
+ PL_TONE_MAPPING_CLIP,
+};
+
+static const char * const tone_text[] = {
+ "Hable (filmic mapping, recommended)",
+ "Mobius (linear + knee)",
+ "Reinhard (simple non-linear)",
+ "Gamma-Power law",
+ "Linear stretch (peak to peak)",
+ "Hard clip out-of-gamut",
+};
+
+#define TONEMAP_PARAM_TEXT "Tone-mapping parameter"
+#define TONEMAP_PARAM_LONGTEXT "This parameter can be used to tune the tone-mapping curve. Specifics depend on the curve used."
+
+#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 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."
+
+#define add_glopts_placebo() \
+ set_section("Colorspace conversion", NULL) \
+ add_integer("rendering-intent", pl_color_map_default_params.intent, \
+ RENDER_INTENT_TEXT, RENDER_INTENT_LONGTEXT, false) \
+ change_integer_list(intent_values, intent_text) \
+ add_integer("target-prim", PL_COLOR_PRIM_UNKNOWN, PRIM_TEXT, PRIM_LONGTEXT, false) \
+ change_integer_list(prim_values, prim_text) \
+ add_integer("target-trc", PL_COLOR_TRC_UNKNOWN, TRC_TEXT, TRC_LONGTEXT, false) \
+ change_integer_list(trc_values, trc_text) \
+ set_section("Tone mapping", NULL) \
+ add_integer("tone-mapping", PL_TONE_MAPPING_HABLE, \
+ TONEMAPPING_TEXT, TONEMAPPING_LONGTEXT, false) \
+ 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)
+#else
+#define add_glopts_placebo()
+#endif
+
#define GLCONV_TEXT N_("Open GL/GLES hardware converter")
#define GLCONV_LONGTEXT N_( \
"Force a \"glconv\" module.")
+
#define add_glopts() \
- add_module ("glconv", "glconv", NULL, GLCONV_TEXT, GLCONV_LONGTEXT, true)
+ add_module ("glconv", "glconv", NULL, GLCONV_TEXT, GLCONV_LONGTEXT, true) \
+ add_glopts_placebo ()
static const vlc_fourcc_t gl_subpicture_chromas[] = {
VLC_CODEC_RGBA,
More information about the vlc-commits
mailing list