[Mesa-dev] [PATCH 05/12] st/va: add nv12 i420 yv12 format to deriveimage call

Christian König deathsimple at vodafone.de
Fri Jul 1 12:37:22 UTC 2016


Am 30.06.2016 um 20:30 schrieb Boyuan Zhang:
> Signed-off-by: Boyuan Zhang <boyuan.zhang at amd.com>

That only works by coincident correctly, the buffer only contains a 
reference to the first texture plane and not all of them.

So vlVaMapBuffer() won't be able to come up with something reasonable 
for other planes.

Additional to that the offsets and pitches can change when backing 
buffers are reallocated.

So the only correct implementation would be to create a persistent 
mapping in the vlVaMapBuffer() call and then come up with the offset and 
keep that mapping until the derived image is destroyed again.

Regards,
Christian.
> ---
>   src/gallium/state_trackers/va/image.c | 21 +++++++++++++++++++++
>   1 file changed, 21 insertions(+)
>
> diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c
> index c82b554..3c8cc9c 100644
> --- a/src/gallium/state_trackers/va/image.c
> +++ b/src/gallium/state_trackers/va/image.c
> @@ -275,6 +275,27 @@ vlVaDeriveImage(VADriverContextP ctx, VASurfaceID surface, VAImage *image)
>      }
>   
>      switch (img->format.fourcc) {
> +   case VA_FOURCC('N','V','1','2'):
> +      img->num_planes = 2;
> +      img->pitches[0] = pitch[0];
> +      img->offsets[0] = 0;
> +      img->pitches[1] = pitch[1];
> +      img->offsets[1] = pitch[0] * h;
> +      img->data_size  = pitch[0] * h + pitch[1] * h / 2;
> +      break;
> +
> +   case VA_FOURCC('I','4','2','0'):
> +   case VA_FOURCC('Y','V','1','2'):
> +      img->num_planes = 3;
> +      img->pitches[0] = pitch[0];
> +      img->offsets[0] = 0;
> +      img->pitches[1] = pitch[1];
> +      img->offsets[1] = pitch[0] * h;
> +      img->pitches[2] = pitch[2];
> +      img->offsets[2] = pitch[0] * h + pitch[1] * h / 4;
> +      img->data_size  = pitch[0] * h + pitch[1] * h / 4 + pitch[2] * h / 4;
> +      break;
> +
>      case VA_FOURCC('U','Y','V','Y'):
>      case VA_FOURCC('Y','U','Y','V'):
>         img->num_planes = 1;



More information about the mesa-dev mailing list