From a0d8962be8beea6393aa27a8526b3ff5447e0749 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Mon, 17 Jul 2023 23:29:12 +0200 Subject: zimg: fix broken sig_peak handling In sum there were three issues: 1. nominal_peak_luminance is an output parameter, not input 2. mpv internally uses MP_REF_WHITE which we need to scale by 3. the value should be left at its default for SDR Together with the last change this means mpv can sucessfully take HDR screenshots with --screenshot-sw without resulting in a brightly colored mess. Though note that zimg does not perform proper tonemapping. --- video/zimg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'video') diff --git a/video/zimg.c b/video/zimg.c index f0a945f494..c3560a0ff7 100644 --- a/video/zimg.c +++ b/video/zimg.c @@ -540,8 +540,9 @@ static bool mp_zimg_state_init(struct mp_zimg_context *ctx, if (opts->fast) params.allow_approximate_gamma = 1; - if (ctx->src.color.sig_peak > 0) - params.nominal_peak_luminance = ctx->src.color.sig_peak; + // leave at default for SDR, which means 100 cd/m^2 for zimg + if (ctx->dst.color.sig_peak > 0 && mp_trc_is_hdr(ctx->dst.color.gamma)) + params.nominal_peak_luminance = ctx->dst.color.sig_peak * MP_REF_WHITE; st->graph = zimg_filter_graph_build(&src_fmt, &dst_fmt, ¶ms); if (!st->graph) { -- cgit v1.2.3