mirror of
https://github.com/mpv-player/mpv
synced 2025-03-21 18:57:35 +00:00
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.
This commit is contained in:
parent
8eb7a00fa1
commit
f8c17f55f9
@ -985,7 +985,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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user