From 0901fc8e0ea4b6c0337add563d1763f0db238023 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 27 Sep 2013 17:44:21 +0200 Subject: vaapi: check image format in va_surface_upload() Just for robustness. Also print a warning in vo_vaapi if this happens. --- video/out/vo_vaapi.c | 6 +++--- video/vaapi.c | 7 +++++-- video/vaapi.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/video/out/vo_vaapi.c b/video/out/vo_vaapi.c index 4f79bbbd1f..6973882176 100644 --- a/video/out/vo_vaapi.c +++ b/video/out/vo_vaapi.c @@ -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; } diff --git a/video/vaapi.c b/video/vaapi.c index b18b9135cd..b7c6013e79 100644 --- a/video/vaapi.c +++ b/video/vaapi.c @@ -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) { diff --git a/video/vaapi.h b/video/vaapi.h index 8e09193fd9..2dbf03a208 100644 --- a/video/vaapi.h +++ b/video/vaapi.h @@ -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); -- cgit v1.2.3