Add function to copy from yv12 image to nv12 surface for VAAPI putimage call. 
We need this function in VaPutImage call where copying from yv12 image to nv12 
surface for encoding. Existing function can't be used because it only work for 
copying from yv12 surface to nv12 image in Vaapi.

Signed-off-by: Boyuan Zhang <boyuan.zh...@amd.com>
---
 src/gallium/auxiliary/util/u_video.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_video.h 
b/src/gallium/auxiliary/util/u_video.h
index 9196afc..d147295 100644
--- a/src/gallium/auxiliary/util/u_video.h
+++ b/src/gallium/auxiliary/util/u_video.h
@@ -130,6 +130,29 @@ u_copy_yv12_to_nv12(void *const *destination_data,
 }
 
 static inline void
+u_copy_yv12_img_to_nv12_surf(uint8_t *const *src,
+                             uint8_t *dest,
+                             int *offset,
+                             int field)
+{
+   if (field == 0) {
+      for (int i = 0; i < offset[1] ; i++)
+         dest[i] = src[field][i];
+   } else if (field == 1) {
+      bool odd = false;
+      for (int i = 0; i < (offset[1]/2) ; i++){
+         if (odd == false) {
+            dest[i] = src[field][i/2];
+            odd = true;
+         } else {
+            dest[i] = src[field+1][i/2];
+            odd = false;
+         }
+      }
+   }
+}
+
+static inline void
 u_copy_swap422_packed(void *const *destination_data,
                        uint32_t const *destination_pitches,
                        int src_plane, int src_field,
-- 
2.7.4

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

Reply via email to