From f4a7931c534158d254a4a36f289494c1de6a16b9 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Sun, 24 Mar 2024 14:20:58 -0400 Subject: [PATCH] vo_gpu: support video-target-params --- video/out/gpu/video.c | 21 +++++++++++++++++++++ video/out/gpu/video.h | 1 + video/out/vo_gpu.c | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index 3764e5d712..1478ec4687 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -183,6 +183,7 @@ struct gl_video { struct mp_image_params real_image_params; // configured format struct mp_image_params image_params; // texture format (mind hwdec case) + struct mp_image_params target_params; // target format struct ra_imgfmt_desc ra_format; // texture format int plane_count; @@ -2726,6 +2727,21 @@ static void pass_colormanage(struct gl_video *p, struct pl_color_space src, // Adapt from src to dst as necessary pass_color_map(p->sc, p->use_linear && !osd, src, dst, src_light, dst_light, &tone_map); + if (!osd) { + struct mp_csp_params cparams = MP_CSP_PARAMS_DEFAULTS; + mp_csp_equalizer_state_get(p->video_eq, &cparams); + if (cparams.levels_out == PL_COLOR_LEVELS_UNKNOWN) + cparams.levels_out = PL_COLOR_LEVELS_FULL; + p->target_params = (struct mp_image_params){ + .imgfmt_name = p->fbo_format ? p->fbo_format->name : "unknown", + .w = p->texture_w, + .h = p->texture_h, + .color = dst, + .repr = {.sys = PL_COLOR_SYSTEM_RGB, .levels = cparams.levels_out}, + .rotate = p->image_params.rotate, + }; + } + if (p->use_lut_3d && (flags & RENDER_SCREEN_COLOR)) { gl_sc_uniform_texture(p->sc, "lut_3d", p->lut_3d_texture); GLSL(vec3 cpos;) @@ -4375,3 +4391,8 @@ void gl_video_load_hwdecs_for_img_fmt(struct gl_video *p, struct mp_hwdec_device assert(p->hwdec_ctx.ra_ctx); ra_hwdec_ctx_load_fmt(&p->hwdec_ctx, devs, params); } + +struct mp_image_params *gl_video_get_target_params_ptr(struct gl_video *p) +{ + return &p->target_params; +} diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h index a929970686..66ccd9c850 100644 --- a/video/out/gpu/video.h +++ b/video/out/gpu/video.h @@ -232,5 +232,6 @@ void gl_video_configure_queue(struct gl_video *p, struct vo *vo); struct mp_image *gl_video_get_image(struct gl_video *p, int imgfmt, int w, int h, int stride_align, int flags); +struct mp_image_params *gl_video_get_target_params_ptr(struct gl_video *p); #endif diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c index 0d9b488abf..d49a6ba8a2 100644 --- a/video/out/vo_gpu.c +++ b/video/out/vo_gpu.c @@ -85,6 +85,11 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame) MP_ERR(vo, "Failed presenting frame!\n"); return; } + + struct mp_image_params *params = gl_video_get_target_params_ptr(p->renderer); + mp_mutex_lock(&vo->params_mutex); + vo->target_params = params; + mp_mutex_unlock(&vo->params_mutex); } static void flip_page(struct vo *vo)