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.
This commit is contained in:
sfan5 2023-07-17 23:29:12 +02:00
parent a960b75604
commit a0d8962be8
1 changed files with 3 additions and 2 deletions

View File

@ -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, &params);
if (!st->graph) {