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 <jisorce@oblong.com>
Reviewed-by: Leo Liu <leo.liu@amd.com>
This commit is contained in:
Julien Isorce
2019-04-23 14:30:06 -07:00
committed by Julien Isorce
parent 1cec049d4d
commit 0e3a348bec
+25 -10
View File
@@ -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;