mirror of
https://github.com/mpv-player/mpv
synced 2024-09-12 23:45:53 +02:00
vaapi: set our own context in AVHWFramesContext not AVHWDeviceContext
AVHWDeviceContext.user_opaque is reserved to libavutil under certain circumstances, while AVHWFramesContext.user_opaque is truly free for use by us. It's slightly simpler too.
This commit is contained in:
parent
fcb970492c
commit
a51e991b56
@ -80,6 +80,9 @@ static int init_decoder(struct lavc_ctx *ctx, int w, int h)
|
|||||||
|
|
||||||
fctx->initial_pool_size = hwdec_get_max_refs(ctx) + ADDITIONAL_SURFACES;
|
fctx->initial_pool_size = hwdec_get_max_refs(ctx) + ADDITIONAL_SURFACES;
|
||||||
|
|
||||||
|
// Some mpv downstream code uses this.
|
||||||
|
fctx->user_opaque = p->ctx;
|
||||||
|
|
||||||
va_lock(p->ctx);
|
va_lock(p->ctx);
|
||||||
int res = av_hwframe_ctx_init(p->frames_ref);
|
int res = av_hwframe_ctx_init(p->frames_ref);
|
||||||
va_unlock(p->ctx);
|
va_unlock(p->ctx);
|
||||||
@ -151,9 +154,6 @@ static int init(struct lavc_ctx *ctx, bool direct)
|
|||||||
|
|
||||||
vactx->display = p->ctx->display;
|
vactx->display = p->ctx->display;
|
||||||
|
|
||||||
// Some mpv downstream code uses this.
|
|
||||||
hwctx->user_opaque = p->ctx;
|
|
||||||
|
|
||||||
if (av_hwdevice_ctx_init(p->device_ref) < 0)
|
if (av_hwdevice_ctx_init(p->device_ref) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -521,15 +521,15 @@ struct mp_image *va_surface_download(struct mp_image *src,
|
|||||||
if (!src->hwctx)
|
if (!src->hwctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
AVHWFramesContext *fctx = (void *)src->hwctx->data;
|
AVHWFramesContext *fctx = (void *)src->hwctx->data;
|
||||||
AVHWDeviceContext *dctx = fctx->device_ctx;
|
// as set by video/decode/vaapi.c
|
||||||
AVVAAPIDeviceContext *vactx = dctx->hwctx;
|
struct mp_vaapi_ctx *ctx = fctx->user_opaque;
|
||||||
tmp_p = (struct va_surface){
|
tmp_p = (struct va_surface){
|
||||||
.ctx = dctx->user_opaque, // as set by video/decode/vaapi.c
|
.ctx = ctx,
|
||||||
.id = va_surface_id(src),
|
.id = va_surface_id(src),
|
||||||
.rt_format = VA_RT_FORMAT_YUV420,
|
.rt_format = VA_RT_FORMAT_YUV420,
|
||||||
.w = fctx->width,
|
.w = fctx->width,
|
||||||
.h = fctx->height,
|
.h = fctx->height,
|
||||||
.display = vactx->display,
|
.display = ctx->display,
|
||||||
.image = { .image_id = VA_INVALID_ID, .buf = VA_INVALID_ID },
|
.image = { .image_id = VA_INVALID_ID, .buf = VA_INVALID_ID },
|
||||||
};
|
};
|
||||||
p = &tmp_p;
|
p = &tmp_p;
|
||||||
|
Loading…
Reference in New Issue
Block a user