Am 30.06.2016 um 20:30 schrieb Boyuan Zhang:
Signed-off-by: Boyuan Zhang <boyuan.zh...@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;

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to