Skip to content

Commit

Permalink
vo_gpu: support video-target-params
Browse files Browse the repository at this point in the history
  • Loading branch information
na-na-hi authored and sfan5 committed Mar 27, 2024
1 parent 3f17b18 commit f4a7931
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions video/out/gpu/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;)
Expand Down Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions video/out/gpu/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions video/out/vo_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f4a7931

Please sign in to comment.