From 0b6feb993be3fd0363073ee04d8cd785b08d102f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Wed, 9 Jul 2025 18:37:31 +0200 Subject: [PATCH] vo_gpu_next: add `source-dynamic` mode to colorspace hint --- DOCS/man/options.rst | 9 ++++++++- video/out/vo_gpu_next.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index a4d9fddc0c..4a38d4d3b6 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -7032,7 +7032,7 @@ them. best choice. It depends on your compositor, driver, and display capabilities. However in most cases ``auto`` mode should work fine. -``--target-colorspace-hint-mode=`` +``--target-colorspace-hint-mode=`` Select which metadata to use for the ``--target-colorspace-hint``. (Only for ``--vo=gpu-next``) @@ -7048,6 +7048,13 @@ them. and display will handle the colorspace directly and perform any necessary mappings. + source-dynamic + The same as ``source``, but uses dynamic per-scene metadata instead of + static HDR10. This is experimental and depends on the display's ability + to react to metadata changes. Note that this does not send full HDR10+ + or Dolby Vision metadata, but uses that information to produce HDR10 + with per-scene luminance values. + Default is ``target``. If target display parameters are not available, this will fall back to ``source``. Note that this is done on individual properties basis, i.e. it will merge source params into target for unknown properties, diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index 3664a2467e..1052b7074d 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -206,7 +206,7 @@ const struct m_sub_options gl_next_conf = { {"image-lut-type", OPT_CHOICE_C(image_lut.type, lut_types)}, {"target-lut", OPT_STRING(target_lut.opt), .flags = M_OPT_FILE}, {"target-colorspace-hint", OPT_CHOICE(target_hint, {"auto", -1}, {"no", 0}, {"yes", 1})}, - {"target-colorspace-hint-mode", OPT_CHOICE(target_hint_mode, {"target", 0}, {"source", 1})}, + {"target-colorspace-hint-mode", OPT_CHOICE(target_hint_mode, {"target", 0}, {"source", 1}, {"source-dynamic", 2})}, // No `target-lut-type` because we don't support non-RGB targets {"libplacebo-opts", OPT_KEYVALUELIST(raw_opts)}, {0}, @@ -1068,6 +1068,15 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame) hint = *(p->next_opts->target_hint_mode == 0 ? target : source); if (pl_color_transfer_is_hdr(hint.transfer) && !pl_primaries_valid(&hint.hdr.prim)) pl_color_space_merge(&hint, source); + if (p->next_opts->target_hint_mode == 2) { // source-dynamic + pl_color_space_nominal_luma_ex(pl_nominal_luma_params( + .color = &hint, + .metadata = PL_HDR_METADATA_ANY, + .scaling = PL_HDR_NITS, + .out_min = &hint.hdr.min_luma, + .out_max = &hint.hdr.max_luma, + )); + } // Infer missing bits now. This is important so that we don't lose // information after user option overrides. For example, if the user // sets target_trc to PQ, but the hint(source) is SDR, we want to fill