vo_gpu_next: tag screenshots with correct colorspace

When taking window screenshots with a colorspace override, tag them
appropriately, based on the best-known colorspace info. Note that this
is imperfect, we should ideally also attach the output ICC profile if
one exists. But this is better than nothing.

Also force 1:1 PAR in this case. In all other cases, default to sRGB.
This commit is contained in:
Niklas Haas 2022-12-12 21:41:15 +01:00 committed by Niklas Haas
parent 5078132b28
commit 862be6c237
1 changed files with 15 additions and 0 deletions

View File

@ -1229,6 +1229,8 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
if (args->scaled) {
// Apply target LUT, ICC profile and CSP override only in window mode
apply_target_options(p, &target);
} else {
target.color = pl_color_space_srgb;
}
apply_crop(&image, src, mpi->params.w, mpi->params.h);
@ -1252,6 +1254,19 @@ static void video_screenshot(struct vo *vo, struct voctrl_screenshot *args)
if (!args->res)
goto done;
if (args->scaled) {
// Provide tagging for target CSP info (if known)
const struct gl_video_opts *opts = p->opts_cache->opts;
args->res->params.color.primaries = opts->target_prim;
args->res->params.color.gamma = opts->target_trc;
args->res->params.color.levels = p->output_levels;
args->res->params.color.sig_peak = opts->target_peak;
args->res->params.p_w = args->res->params.p_h = 1;
} else {
args->res->params.color.primaries = MP_CSP_PRIM_BT_709;
args->res->params.color.gamma = MP_CSP_TRC_SRGB;
}
bool ok = pl_tex_download(gpu, pl_tex_transfer_params(
.tex = fbo,
.ptr = args->res->planes[0],