From 02595011eb11a1f4d22339519205c2e087a45663 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Mon, 17 Jul 2023 16:37:36 +0200 Subject: [PATCH] vo_gpu_next: add --hdr-contrast-recovery/smoothness New upstream feature. Disabled by default. --- DOCS/interface-changes.rst | 1 + DOCS/man/options.rst | 12 ++++++++++++ video/out/gpu/video.c | 5 +++++ video/out/gpu/video.h | 2 ++ video/out/vo_gpu_next.c | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index b6fbb0c516..2e1bbac4b6 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -87,6 +87,7 @@ Interface changes --no-gpu-shader-cache to disable) - add `--directory-mode=recursive|lazy|ignore` - ctrl+h now uses `auto-safe` rather than `auto` when turing on hardware decoding + - add `--hdr-contrast-recovery` and `--hdr-contrast-smoothness` --- mpv 0.35.0 --- - add the `--vo=gpu-next` video output driver, as well as the options `--allow-delayed-peak-detect`, `--builtin-scalers`, diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index a9684b2b50..a40d6befb0 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -6713,6 +6713,18 @@ them. aggressive, up to the limit of the high threshold (at which point the filter becomes instant). +``--hdr-contrast-recovery=<0.0..2.0>``, ``--hdr-contrast-smoothness=<1.0..100.0>`` + Enables the HDR contrast recovery algorithm, which is to designed to + enhance contrast of HDR video after tone mapping. The strength (default: + 0.0) indicates the degree of contrast recovery, with 0.0 being completely + disabled and 1.0 being 100% strength. Values higher than 1.0 are allowed, + but may result in excessive sharpening. The smoothness (default: 3.5) + indicates the degree to which the HDR source is low-passed in order to + obtain contrast information - a value of 2.0 corresponds to 2x downscaling. + Users on low DPI displays (<= 100) may want to lower this value, while + users on very high DPI displays ("retina") may want to increase it. (Only + for ``vo=gpu-next``) + ``--use-embedded-icc-profile`` Load the embedded ICC profile contained in media files such as PNG images. (Default: yes). Note that this option only works when also using a display diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index b38c88d054..4233f14336 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -325,6 +325,7 @@ static const struct gl_video_opts gl_video_opts_def = { .decay_rate = 100.0, .scene_threshold_low = 5.5, .scene_threshold_high = 10.0, + .contrast_smoothness = 3.5, }, .early_flush = -1, .shader_cache = true, @@ -421,6 +422,10 @@ const struct m_sub_options gl_video_conf = { M_RANGE(0, 20.0)}, {"hdr-scene-threshold-high", OPT_FLOAT(tone_map.scene_threshold_high), M_RANGE(0, 20.0)}, + {"hdr-contrast-recovery", OPT_FLOAT(tone_map.contrast_recovery), + M_RANGE(0, 2.0)}, + {"hdr-contrast-smoothness", OPT_FLOAT(tone_map.contrast_smoothness), + M_RANGE(1.0, 100.0)}, {"opengl-pbo", OPT_BOOL(pbo)}, SCALER_OPTS("scale", SCALER_SCALE), SCALER_OPTS("dscale", SCALER_DSCALE), diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h index 307f7ea2ca..30c100e302 100644 --- a/video/out/gpu/video.h +++ b/video/out/gpu/video.h @@ -133,6 +133,8 @@ struct gl_tone_map_opts { float decay_rate; float scene_threshold_low; float scene_threshold_high; + float contrast_recovery; + float contrast_smoothness; int gamut_mode; bool visualize; }; diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 42164ecd98..155a97cc18 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -1967,6 +1967,11 @@ static void update_render_options(struct vo *vo) p->color_map.tone_mapping_param = 0.0; p->color_map.visualize_lut = opts->tone_map.visualize; +#if PL_API_VER >= 285 + p->color_map.contrast_recovery = opts->tone_map.contrast_recovery; + p->color_map.contrast_smoothness = opts->tone_map.contrast_smoothness; +#endif + #if PL_API_VER >= 269 if (opts->tone_map.gamut_mode != GAMUT_AUTO) p->color_map.gamut_mapping = gamut_modes[opts->tone_map.gamut_mode];