mirror of https://github.com/mpv-player/mpv
vaapi: check image format in va_surface_upload()
Just for robustness. Also print a warning in vo_vaapi if this happens.
This commit is contained in:
parent
4d2f354da6
commit
0901fc8e0e
|
@ -249,10 +249,10 @@ static void draw_image(struct vo *vo, struct mp_image *mpi)
|
|||
if (!IMGFMT_IS_VAAPI(mpi->imgfmt)) {
|
||||
struct mp_image *wrapper = p->swdec_surfaces[p->output_surface];
|
||||
struct va_surface *surface = va_surface_in_mp_image(wrapper);
|
||||
if (!surface)
|
||||
return;
|
||||
if (!va_surface_upload(surface, mpi))
|
||||
if (!surface || !va_surface_upload(surface, mpi)) {
|
||||
MP_WARN(vo, "Could not upload surface.\n");
|
||||
return;
|
||||
}
|
||||
mp_image_copy_attributes(wrapper, mpi);
|
||||
mpi = wrapper;
|
||||
}
|
||||
|
|
|
@ -453,16 +453,19 @@ bool va_image_unmap(VADisplay display, VAImage *image)
|
|||
return check_va_status(status, "vaUnmapBuffer()");
|
||||
}
|
||||
|
||||
bool va_surface_upload(struct va_surface *surface, const struct mp_image *mpi)
|
||||
bool va_surface_upload(struct va_surface *surface, struct mp_image *mpi)
|
||||
{
|
||||
va_surface_priv_t *p = surface->p;
|
||||
if (p->image.image_id == VA_INVALID_ID)
|
||||
return false;
|
||||
|
||||
if (va_fourcc_to_imgfmt(p->image.format.fourcc) != mpi->imgfmt)
|
||||
return false;
|
||||
|
||||
struct mp_image img;
|
||||
if (!va_image_map(p->display, &p->image, &img))
|
||||
return false;
|
||||
mp_image_copy(&img, (struct mp_image*)mpi);
|
||||
mp_image_copy(&img, mpi);
|
||||
va_image_unmap(p->display, &p->image);
|
||||
|
||||
if (!p->is_derived) {
|
||||
|
|
|
@ -118,7 +118,7 @@ struct va_surface * va_surface_in_mp_image(struct mp_image *mpi);
|
|||
struct mp_image * va_surface_wrap(struct va_surface *surface); // takes ownership
|
||||
VASurfaceID va_surface_id(const struct va_surface *surface);
|
||||
VASurfaceID va_surface_id_in_mp_image(const struct mp_image *mpi);
|
||||
bool va_surface_upload(struct va_surface *surface, const struct mp_image *mpi);
|
||||
bool va_surface_upload(struct va_surface *surface, struct mp_image *mpi);
|
||||
struct mp_image * va_surface_download(struct va_surface *surface,
|
||||
const struct va_image_formats *formats,
|
||||
struct mp_image_pool *pool);
|
||||
|
|
Loading…
Reference in New Issue