From 8cd71f399e73c5d87e9162cc74da76e317a9f41f Mon Sep 17 00:00:00 2001 From: Julien Isorce Date: Thu, 2 May 2019 15:36:04 -0700 Subject: [PATCH] st/va: check resource_get_info nullity in vlVaDeriveImage This pipe_screen function is not implemented by all backends. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110443 Signed-off-by: Julien Isorce Reviewed-by: Leo Liu --- src/gallium/state_trackers/va/image.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 491c2d82858..d4b9ce5596d 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -251,23 +251,26 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image) } mtx_lock(&drv->mutex); - screen->resource_get_info(screen, surfaces[0]->texture, &stride, &offset); - if (!stride) - offset = 0; + if (screen->resource_get_info) { + screen->resource_get_info(screen, surfaces[0]->texture, &stride, + &offset); + if (!stride) + offset = 0; + } switch (img->format.fourcc) { case VA_FOURCC('U','Y','V','Y'): case VA_FOURCC('Y','U','Y','V'): - assert(stride >= (w * 2)); img->pitches[0] = stride > 0 ? stride : w * 2; + assert(img->pitches[0] >= (w * 2)); break; case VA_FOURCC('B','G','R','A'): case VA_FOURCC('R','G','B','A'): case VA_FOURCC('B','G','R','X'): case VA_FOURCC('R','G','B','X'): - assert(stride >= (w * 4)); img->pitches[0] = stride > 0 ? stride : w * 4; + assert(img->pitches[0] >= (w * 4)); break; default: -- 2.30.2