[Mesa-dev] [PATCH v4 8/9] st/va: implement VaDeriveImage

Julien Isorce j.isorce at samsung.com
Fri Oct 30 04:22:56 PDT 2015


Ok I'll make a separate patch for the add of errors checks and add the break in the loop.
Thx
Julien

-----Original Message-----
From: Emil Velikov [mailto:emil.l.velikov at gmail.com] 
Sent: 29 October 2015 22:03
To: Julien Isorce
Cc: ML mesa-dev
Subject: Re: [Mesa-dev] [PATCH v4 8/9] st/va: implement VaDeriveImage

Hi Julien,

One can separate the errors checks and get those separately (+stable).
I'll let others be the judge of that - I'm just going to point the sections I have in mind.

On 29 October 2015 at 17:40, Julien Isorce <j.isorce at samsung.com> wrote:

> @@ -73,6 +76,10 @@ vlVaBufferSetNumElements(VADriverContextP ctx, VABufferID buf_id,
>        return VA_STATUS_ERROR_INVALID_CONTEXT;
>
>     buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id);
> +
> +   if (!buf || buf->derived_surface.resource)
> +      return VA_STATUS_ERROR_INVALID_BUFFER;
> +
Here ...


> @@ -86,16 +93,32 @@ vlVaBufferSetNumElements(VADriverContextP ctx, 
> VABufferID buf_id,  VAStatus  vlVaMapBuffer(VADriverContextP ctx, 
> VABufferID buf_id, void **pbuff)  {
> +   vlVaDriver *drv;
>     vlVaBuffer *buf;
>
>     if (!ctx)
>        return VA_STATUS_ERROR_INVALID_CONTEXT;
>
> -   buf = handle_table_get(VL_VA_DRIVER(ctx)->htab, buf_id);
> +   if (!pbuff)
> +      return VA_STATUS_ERROR_INVALID_BUFFER;
> +
> +   drv = VL_VA_DRIVER(ctx);
> +
> +   buf = handle_table_get(drv->htab, buf_id);
... and these two.


> diff --git a/src/gallium/state_trackers/va/image.c 
> b/src/gallium/state_trackers/va/image.c
> index 8e64673..f266ce8 100644
> --- a/src/gallium/state_trackers/va/image.c
> +++ b/src/gallium/state_trackers/va/image.c
> @@ -184,10 +184,95 @@ vlVaCreateImage(VADriverContextP ctx, 
> VAImageFormat *format, int width, int heig  VAStatus  
> vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage 
> *image)  {
> +   vlVaDriver *drv;
> +   vlVaSurface *surf;
> +   vlVaBuffer *img_buf;
> +   VAImage *img;
> +   struct pipe_surface **surfaces;
> +   int w;
> +   int h;
> +   int i;
> +
>     if (!ctx)
>        return VA_STATUS_ERROR_INVALID_CONTEXT;
>
> -   return VA_STATUS_ERROR_UNIMPLEMENTED;
> +   drv = VL_VA_DRIVER(ctx);
> +
> +   if (!drv)
> +      return VA_STATUS_ERROR_INVALID_CONTEXT;
> +
> +   surf = handle_table_get(drv->htab, surface);
> +
> +   if (!surf || !surf->buffer || surf->buffer->interlaced)
> +      return VA_STATUS_ERROR_INVALID_SURFACE;
> +
> +   surfaces = surf->buffer->get_surfaces(surf->buffer);
> +   if (!surfaces || !surfaces[0]->texture)
> +      return VA_STATUS_ERROR_ALLOCATION_FAILED;
> +
> +   img = CALLOC(1, sizeof(VAImage));
> +   if (!img)
> +      return VA_STATUS_ERROR_ALLOCATION_FAILED;
> +
> +   img->format.fourcc = PipeToYCbCr(surf->buffer->buffer_format);
> +   img->buf = VA_INVALID_ID;
> +   img->width = surf->buffer->width;
> +   img->height = surf->buffer->height;
> +   img->num_palette_entries = 0;
> +   img->entry_bytes = 0;
> +   w = align(surf->buffer->width, 2);
> +   h = align(surf->buffer->height, 2);
> +
> +   for (i = 0; i < ARRAY_SIZE(formats); ++i) {
> +      if (img->format.fourcc == formats[i].fourcc)
> +         img->format = formats[i];
Break out of the loop ? Not a big deal either way.

-Emil



More information about the mesa-dev mailing list