summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorJulien Isorce <[email protected]>2019-04-23 14:30:06 -0700
committerJulien Isorce <[email protected]>2019-04-30 17:53:12 +0000
commit0e3a348bec436b9d949e85574e363a1fe0e7683c (patch)
treece6d9633b9495627566507e1dfb262c805daadb6 /src/gallium/state_trackers
parent1cec049d4db1c4dcd121bad17df4a77273dd9bb1 (diff)
st/va: properly set stride and offset in vlVaDeriveImage
Using the new resource_get_info function. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=110443 Signed-off-by: Julien Isorce <[email protected]> Reviewed-by: Leo Liu <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/va/image.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c
index f7e0db08961..491c2d82858 100644
--- a/src/gallium/state_trackers/va/image.c
+++ b/src/gallium/state_trackers/va/image.c
@@ -197,10 +197,13 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
vlVaSurface *surf;
vlVaBuffer *img_buf;
VAImage *img;
+ struct pipe_screen *screen;
struct pipe_surface **surfaces;
int w;
int h;
int i;
+ unsigned stride = 0;
+ unsigned offset = 0;
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
@@ -210,6 +213,11 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
if (!drv)
return VA_STATUS_ERROR_INVALID_CONTEXT;
+ screen = VL_VA_PSCREEN(ctx);
+
+ if (!screen)
+ return VA_STATUS_ERROR_INVALID_CONTEXT;
+
surf = handle_table_get(drv->htab, surface);
if (!surf || !surf->buffer)
@@ -242,38 +250,45 @@ 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;
+
switch (img->format.fourcc) {
case VA_FOURCC('U','Y','V','Y'):
case VA_FOURCC('Y','U','Y','V'):
- img->num_planes = 1;
- img->pitches[0] = w * 2;
- img->offsets[0] = 0;
- img->data_size = w * h * 2;
+ assert(stride >= (w * 2));
+ img->pitches[0] = stride > 0 ? stride : 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'):
- img->num_planes = 1;
- img->pitches[0] = w * 4;
- img->offsets[0] = 0;
- img->data_size = w * h * 4;
+ assert(stride >= (w * 4));
+ img->pitches[0] = stride > 0 ? stride : w * 4;
break;
default:
- /* VaDeriveImage is designed for contiguous planes. */
+ /* VaDeriveImage only supports contiguous planes. But there is now a
+ more generic api vlVaExportSurfaceHandle. */
FREE(img);
+ mtx_unlock(&drv->mutex);
return VA_STATUS_ERROR_OPERATION_FAILED;
}
+ img->num_planes = 1;
+ img->offsets[0] = offset;
+ img->data_size = img->pitches[0] * h;
+
img_buf = CALLOC(1, sizeof(vlVaBuffer));
if (!img_buf) {
FREE(img);
+ mtx_unlock(&drv->mutex);
return VA_STATUS_ERROR_ALLOCATION_FAILED;
}
- mtx_lock(&drv->mutex);
img->image_id = handle_table_add(drv->htab, img);
img_buf->type = VAImageBufferType;