diff options
Diffstat (limited to 'video/vaapi.c')
-rw-r--r-- | video/vaapi.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/video/vaapi.c b/video/vaapi.c index 61d94ef156..9a5820a98c 100644 --- a/video/vaapi.c +++ b/video/vaapi.c @@ -487,6 +487,38 @@ struct mp_image *va_surface_download(struct mp_image *src, return NULL; } +// Set the hw_subfmt from the surface's real format. Because of this bug: +// https://bugs.freedesktop.org/show_bug.cgi?id=79848 +// it should be assumed that the real format is only known after an arbitrary +// vaCreateContext() call has been made, or even better, after the surface +// has been rendered to. +// If the hw_subfmt is already set, this is a NOP. +void va_surface_init_subformat(struct mp_image *mpi) +{ + VAStatus status; + if (mpi->params.hw_subfmt) + return; + struct va_surface *p = va_surface_in_mp_image(mpi); + if (!p) + return; + + VAImage va_image = { .image_id = VA_INVALID_ID }; + + va_lock(p->ctx); + + status = vaDeriveImage(p->display, va_surface_id(mpi), &va_image); + if (status != VA_STATUS_SUCCESS) + goto err; + + mpi->params.hw_subfmt = va_image.format.fourcc; + + status = vaDestroyImage(p->display, va_image.image_id); + CHECK_VA_STATUS(p->ctx, "vaDestroyImage()"); + +err: + va_unlock(p->ctx); +} + struct pool_alloc_ctx { struct mp_vaapi_ctx *vaapi; int rt_format; |