From c5c1477eb44cdc13cb06fafa696448115e3545ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Tue, 8 Jul 2025 02:39:13 +0200 Subject: [PATCH] vo_gpu_next: change `--target-colorspace-hint` to `auto` by default Auto mode will also enable hint for SDR formats if target metadata is reported by current output context. --- .../target-colorspace-hint.txt | 1 + DOCS/man/options.rst | 19 ++++++++++++++----- video/out/vo_gpu_next.c | 13 +++++++------ 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 DOCS/interface-changes/target-colorspace-hint.txt diff --git a/DOCS/interface-changes/target-colorspace-hint.txt b/DOCS/interface-changes/target-colorspace-hint.txt new file mode 100644 index 0000000000..b6a37f9744 --- /dev/null +++ b/DOCS/interface-changes/target-colorspace-hint.txt @@ -0,0 +1 @@ +Change `--target-colorspace-hint` to `auto` by default. Auto mode will also enable hint for SDR formats if target metadata is reported by current output context. diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index c11c133d3b..a4d9fddc0c 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -7017,11 +7017,20 @@ them. image's native colorspace and output normalized non-linear RGB. ``--target-colorspace-hint=`` - Automatically configure the output colorspace of the display to pass - through the input values of the stream (e.g. for HDR passthrough), if - possible. In ``auto`` mode, the target colorspace is only set, - if the display signals support for HDR colorspace. - Requires a supporting driver and ``--vo=gpu-next``. (Default: ``no``) + When enabled, output colorspace metadata will be set on the swapchain + depending on the GPU context and platform this may affect compositor/display. + This can be used for "HDR passthrough" and to set the output colorspace + for SDR content. In ``auto`` mode, the target colorspace is only set if the + current display parameters are known. Currently, this is supported on + Wayland, D3D11 and winvk contexts. The ``yes`` option will always try to set + the colorspace, you may need to adjust the ``--target-*`` options to match + your display capabilities. + Requires a supporting driver and ``--vo=gpu-next``. (Default: ``auto``) + + .. note:: + Auto detected target colorspace metadata is not guaranteed to be always + best choice. It depends on your compositor, driver, and display + capabilities. However in most cases ``auto`` mode should work fine. ``--target-colorspace-hint-mode=`` Select which metadata to use for the ``--target-colorspace-hint``. diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 7c8e09d446..5414a76aff 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -216,6 +216,7 @@ const struct m_sub_options gl_next_conf = { .inter_preserve = true, .sub_hdr_peak = PL_COLOR_SDR_WHITE, .image_subs_hdr_peak = PL_COLOR_SDR_WHITE, + .target_hint = -1, }, .size = sizeof(struct gl_next_opts), .change_flags = UPDATE_VIDEO, @@ -1009,11 +1010,6 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame) // TODO: Implement this for all backends if (sw->fns->target_csp) target_csp = sw->fns->target_csp(sw); - // Assume HDR is supported, if query is not available - if (target_csp.transfer == PL_COLOR_TRC_UNKNOWN) { - target_csp = (struct pl_color_space){ - .transfer = opts->target_trc ? opts->target_trc : PL_COLOR_TRC_PQ }; - } if (!pl_color_transfer_is_hdr(target_csp.transfer)) { // Don't use reported display peak in SDR mode. Mostly because libplacebo // forcefully switches to PQ if hinting hdr metadata, ignoring the transfer @@ -1028,7 +1024,12 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame) struct pl_color_space hint; bool target_hint = p->next_opts->target_hint == 1 || (p->next_opts->target_hint == -1 && - pl_color_transfer_is_hdr(target_csp.transfer)); + target_csp.transfer != PL_COLOR_TRC_UNKNOWN); + // Assume HDR is supported, if target_csp() is not available + if (target_csp.transfer == PL_COLOR_TRC_UNKNOWN) { + target_csp = (struct pl_color_space){ + .transfer = opts->target_trc ? opts->target_trc : PL_COLOR_TRC_PQ }; + } if (target_hint && frame->current) { const struct pl_color_space *source = &frame->current->params.color; const struct pl_color_space *target = &target_csp;