From f8c17f55f975ea3b46ba7cea299f1a8e5d980b4c Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sat, 21 Jan 2023 15:21:49 +0100 Subject: vo: add `int flags` to the get_image signature This is a huge disgusting mess to thread through everywhere. Maybe I'm stupid for attempting to solve the problem this way. --- video/out/dr_helper.c | 15 +++++++++------ video/out/dr_helper.h | 4 ++-- video/out/gpu/libmpv_gpu.c | 4 ++-- video/out/gpu/video.c | 2 +- video/out/gpu/video.h | 2 +- video/out/libmpv.h | 2 +- video/out/vo.c | 10 +++++----- video/out/vo.h | 8 +++++--- video/out/vo_gpu.c | 4 ++-- video/out/vo_gpu_next.c | 2 +- video/out/vo_libmpv.c | 8 ++++---- 11 files changed, 33 insertions(+), 28 deletions(-) (limited to 'video/out') diff --git a/video/out/dr_helper.c b/video/out/dr_helper.c index 5b585f5528..33b55e17c8 100644 --- a/video/out/dr_helper.c +++ b/video/out/dr_helper.c @@ -20,7 +20,7 @@ struct dr_helper { atomic_ullong dr_in_flight; struct mp_image *(*get_image)(void *ctx, int imgfmt, int w, int h, - int stride_align); + int stride_align, int flags); void *get_image_ctx; }; @@ -37,7 +37,7 @@ static void dr_helper_destroy(void *ptr) struct dr_helper *dr_helper_create(struct mp_dispatch_queue *dispatch, struct mp_image *(*get_image)(void *ctx, int imgfmt, int w, int h, - int stride_align), + int stride_align, int flags), void *get_image_ctx) { struct dr_helper *dr = talloc_ptrtype(NULL, dr); @@ -108,7 +108,7 @@ static void free_dr_buffer_on_dr_thread(void *opaque, uint8_t *data) struct get_image_cmd { struct dr_helper *dr; - int imgfmt, w, h, stride_align; + int imgfmt, w, h, stride_align, flags; struct mp_image *res; }; @@ -118,7 +118,7 @@ static void sync_get_image(void *ptr) struct dr_helper *dr = cmd->dr; cmd->res = dr->get_image(dr->get_image_ctx, cmd->imgfmt, cmd->w, cmd->h, - cmd->stride_align); + cmd->stride_align, cmd->flags); if (!cmd->res) return; @@ -148,11 +148,14 @@ static void sync_get_image(void *ptr) } struct mp_image *dr_helper_get_image(struct dr_helper *dr, int imgfmt, - int w, int h, int stride_align) + int w, int h, int stride_align, int flags) { struct get_image_cmd cmd = { .dr = dr, - .imgfmt = imgfmt, .w = w, .h = h, .stride_align = stride_align, + .imgfmt = imgfmt, + .w = w, .h = h, + .stride_align = stride_align, + .flags = flags, }; mp_dispatch_run(dr->dispatch, sync_get_image, &cmd); return cmd.res; diff --git a/video/out/dr_helper.h b/video/out/dr_helper.h index ff1d268426..71b32f8a4a 100644 --- a/video/out/dr_helper.h +++ b/video/out/dr_helper.h @@ -15,7 +15,7 @@ struct mp_dispatch_queue; // dr_helper instance can be destroyed. struct dr_helper *dr_helper_create(struct mp_dispatch_queue *dispatch, struct mp_image *(*get_image)(void *ctx, int imgfmt, int w, int h, - int stride_align), + int stride_align, int flags), void *get_image_ctx); // Make DR release calls (freeing images) reentrant if they are called on this @@ -34,4 +34,4 @@ void dr_helper_release_thread(struct dr_helper *dr); // allocate a DR'ed image on the render thread (at least not in a way which // actually works if you want foreign threads to be able to free them). struct mp_image *dr_helper_get_image(struct dr_helper *dr, int imgfmt, - int w, int h, int stride_align); + int w, int h, int stride_align, int flags); diff --git a/video/out/gpu/libmpv_gpu.c b/video/out/gpu/libmpv_gpu.c index 0c43a71c20..8cf3082380 100644 --- a/video/out/gpu/libmpv_gpu.c +++ b/video/out/gpu/libmpv_gpu.c @@ -192,11 +192,11 @@ static int render(struct render_backend *ctx, mpv_render_param *params, } static struct mp_image *get_image(struct render_backend *ctx, int imgfmt, - int w, int h, int stride_align) + int w, int h, int stride_align, int flags) { struct priv *p = ctx->priv; - return gl_video_get_image(p->renderer, imgfmt, w, h, stride_align); + return gl_video_get_image(p->renderer, imgfmt, w, h, stride_align, flags); } static void screenshot(struct render_backend *ctx, struct vo_frame *frame, diff --git a/video/out/gpu/video.c b/video/out/gpu/video.c index c9ab48d170..c04f5c57a4 100644 --- a/video/out/gpu/video.c +++ b/video/out/gpu/video.c @@ -4288,7 +4288,7 @@ static void gl_video_dr_free_buffer(void *opaque, uint8_t *data) } struct mp_image *gl_video_get_image(struct gl_video *p, int imgfmt, int w, int h, - int stride_align) + int stride_align, int flags) { if (!gl_video_check_format(p, imgfmt)) return NULL; diff --git a/video/out/gpu/video.h b/video/out/gpu/video.h index 30abd972f9..b7f6e6b485 100644 --- a/video/out/gpu/video.h +++ b/video/out/gpu/video.h @@ -229,7 +229,7 @@ struct vo; 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 stride_align, int flags); #endif diff --git a/video/out/libmpv.h b/video/out/libmpv.h index 485ba8a76c..a697eaf45f 100644 --- a/video/out/libmpv.h +++ b/video/out/libmpv.h @@ -58,7 +58,7 @@ struct render_backend_fns { struct voctrl_performance_data *out); // Like vo_driver.get_image(). struct mp_image *(*get_image)(struct render_backend *ctx, int imgfmt, - int w, int h, int stride_align); + int w, int h, int stride_align, int flags); // This has two purposes: 1. set queue attributes on VO, 2. update the // renderer's OSD pointer. Keep in mind that as soon as the caller releases // the renderer lock, the VO pointer can become invalid. The OSD pointer diff --git a/video/out/vo.c b/video/out/vo.c index c0043ce2a7..031a4e61a2 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -1067,10 +1067,10 @@ static void do_redraw(struct vo *vo) } static struct mp_image *get_image_vo(void *ctx, int imgfmt, int w, int h, - int stride_align) + int stride_align, int flags) { struct vo *vo = ctx; - return vo->driver->get_image(vo, imgfmt, w, h, stride_align); + return vo->driver->get_image(vo, imgfmt, w, h, stride_align, flags); } static void *vo_thread(void *ptr) @@ -1401,12 +1401,12 @@ struct vo_frame *vo_get_current_vo_frame(struct vo *vo) } struct mp_image *vo_get_image(struct vo *vo, int imgfmt, int w, int h, - int stride_align) + int stride_align, int flags) { if (vo->driver->get_image_ts) - return vo->driver->get_image_ts(vo, imgfmt, w, h, stride_align); + return vo->driver->get_image_ts(vo, imgfmt, w, h, stride_align, flags); if (vo->in->dr_helper) - return dr_helper_get_image(vo->in->dr_helper, imgfmt, w, h, stride_align); + return dr_helper_get_image(vo->in->dr_helper, imgfmt, w, h, stride_align, flags); return NULL; } diff --git a/video/out/vo.h b/video/out/vo.h index 05882064a2..8df825e582 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -359,6 +359,8 @@ struct vo_driver { * stride_align is always a value >=1 that is a power of 2. The stride * values of the returned image must be divisible by this value. * + * flags is a combination of VO_DR_FLAG_* flags. + * * Currently, the returned image must have exactly 1 AVBufferRef set, for * internal implementation simplicity. * @@ -366,7 +368,7 @@ struct vo_driver { * will silently fallback to a default allocator */ struct mp_image *(*get_image)(struct vo *vo, int imgfmt, int w, int h, - int stride_align); + int stride_align, int flags); /* * Thread-safe variant of get_image. Set at most one of these callbacks. @@ -374,7 +376,7 @@ struct vo_driver { * vo_driver.uninit is not called before this function returns. */ struct mp_image *(*get_image_ts)(struct vo *vo, int imgfmt, int w, int h, - int stride_align); + int stride_align, int flags); /* * Render the given frame to the VO's backbuffer. This operation will be @@ -527,7 +529,7 @@ double vo_get_delay(struct vo *vo); void vo_discard_timing_info(struct vo *vo); struct vo_frame *vo_get_current_vo_frame(struct vo *vo); struct mp_image *vo_get_image(struct vo *vo, int imgfmt, int w, int h, - int stride_align); + int stride_align, int flags); void vo_wakeup(struct vo *vo); void vo_wait_default(struct vo *vo, int64_t until_time); diff --git a/video/out/vo_gpu.c b/video/out/vo_gpu.c index 404b7e77d7..db30d83017 100644 --- a/video/out/vo_gpu.c +++ b/video/out/vo_gpu.c @@ -265,11 +265,11 @@ static void wait_events(struct vo *vo, int64_t until_time_us) } static struct mp_image *get_image(struct vo *vo, int imgfmt, int w, int h, - int stride_align) + int stride_align, int flags) { struct gpu_priv *p = vo->priv; - return gl_video_get_image(p->renderer, imgfmt, w, h, stride_align); + return gl_video_get_image(p->renderer, imgfmt, w, h, stride_align, flags); } static void uninit(struct vo *vo) diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c index e88f5c8f9f..a5d19ad4f9 100644 --- a/video/out/vo_gpu_next.c +++ b/video/out/vo_gpu_next.c @@ -189,7 +189,7 @@ static void free_dr_buf(void *opaque, uint8_t *data) } static struct mp_image *get_image(struct vo *vo, int imgfmt, int w, int h, - int stride_align) + int stride_align, int flags) { struct priv *p = vo->priv; pl_gpu gpu = p->gpu; diff --git a/video/out/vo_libmpv.c b/video/out/vo_libmpv.c index d07ab4c4eb..5325a1d337 100644 --- a/video/out/vo_libmpv.c +++ b/video/out/vo_libmpv.c @@ -152,11 +152,11 @@ static void dispatch_wakeup(void *ptr) } static struct mp_image *render_get_image(void *ptr, int imgfmt, int w, int h, - int stride_align) + int stride_align, int flags) { struct mpv_render_context *ctx = ptr; - return ctx->renderer->fns->get_image(ctx->renderer, imgfmt, w, h, stride_align); + return ctx->renderer->fns->get_image(ctx->renderer, imgfmt, w, h, stride_align, flags); } int mpv_render_context_create(mpv_render_context **res, mpv_handle *mpv, @@ -654,13 +654,13 @@ static int control(struct vo *vo, uint32_t request, void *data) } static struct mp_image *get_image(struct vo *vo, int imgfmt, int w, int h, - int stride_align) + int stride_align, int flags) { struct vo_priv *p = vo->priv; struct mpv_render_context *ctx = p->ctx; if (ctx->dr) - return dr_helper_get_image(ctx->dr, imgfmt, w, h, stride_align); + return dr_helper_get_image(ctx->dr, imgfmt, w, h, stride_align, flags); return NULL; } -- cgit v1.2.3