summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2023-01-21 15:21:49 +0100
committersfan5 <sfan5@live.de>2023-01-24 16:40:37 +0100
commitfc115bce2c202cc892a7391737f36d40a35a4a5b (patch)
treee58196889eef77e436e6b6679486994bb685061b
parentb64f9fe646bf929ba7befe13d3413f20fb46b320 (diff)
downloadmpv-fc115bce2c202cc892a7391737f36d40a35a4a5b.tar.bz2
mpv-fc115bce2c202cc892a7391737f36d40a35a4a5b.tar.xz
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.
-rw-r--r--video/decode/vd_lavc.c2
-rw-r--r--video/out/dr_helper.c15
-rw-r--r--video/out/dr_helper.h4
-rw-r--r--video/out/gpu/libmpv_gpu.c4
-rw-r--r--video/out/gpu/video.c2
-rw-r--r--video/out/gpu/video.h2
-rw-r--r--video/out/libmpv.h2
-rw-r--r--video/out/vo.c10
-rw-r--r--video/out/vo.h8
-rw-r--r--video/out/vo_gpu.c4
-rw-r--r--video/out/vo_gpu_next.c2
-rw-r--r--video/out/vo_libmpv.c8
12 files changed, 34 insertions, 29 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 4f38b669ec..d3bdc3c09e 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -968,7 +968,7 @@ static int get_buffer2_direct(AVCodecContext *avctx, AVFrame *pic, int flags)
struct mp_image *img = mp_image_pool_get_no_alloc(p->dr_pool, imgfmt, w, h);
if (!img) {
MP_DBG(p, "Allocating new DR image...\n");
- img = vo_get_image(p->vo, imgfmt, w, h, stride_align);
+ img = vo_get_image(p->vo, imgfmt, w, h, stride_align, 0);
if (!img) {
MP_DBG(p, "...failed..\n");
goto fallback;
diff --git a/video/out/dr_helper.c b/video/out/dr_helper.c
index 78d4633efb..3ef01e57ef 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;
@@ -149,11 +149,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 abe5e9333c..3e557a20f6 100644
--- a/video/out/gpu/video.c
+++ b/video/out/gpu/video.c
@@ -4289,7 +4289,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 4e999d0754..a063457d1a 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -1066,10 +1066,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)
@@ -1400,12 +1400,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 8ccfe3ccfe..f176bee59f 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -349,6 +349,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.
*
@@ -356,7 +358,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.
@@ -364,7 +366,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
@@ -516,7 +518,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 2830120629..0f0732592a 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;
}