[Libva] [PATCH 4/6] avoid U_row overwrite NULL value if src_fourcc and dst_fourcc is NV12

Lim Siew Hoon siew.hoon.lim at intel.com
Fri Jul 1 05:29:11 UTC 2016


Signed-off-by: Lim Siew Hoon <siew.hoon.lim at intel.com>
---
 test/loadsurface.h | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/test/loadsurface.h b/test/loadsurface.h
index 00b0653..a024ed4 100755
--- a/test/loadsurface.h
+++ b/test/loadsurface.h
@@ -370,9 +370,12 @@ static int upload_surface_yuv(VADisplay va_dpy, VASurfaceID surface_id,
                 v_ptr = src_U + row * (src_width/2);
                 u_ptr = src_V + row * (src_width/2);
             }
-            for(j = 0; j < src_width/2; j++) {
-                U_row[2*j] = u_ptr[j];
-                U_row[2*j+1] = v_ptr[j];
+            if ((src_fourcc == VA_FOURCC_IYUV) ||
+                (src_fourcc == VA_FOURCC_YV12)) {
+                for(j = 0; j < src_width/2; j++) {
+                    U_row[2*j] = u_ptr[j];
+                    U_row[2*j+1] = v_ptr[j];
+                }
             }
             break;
         case VA_FOURCC_IYUV:
@@ -460,9 +463,12 @@ static int download_surface_yuv(VADisplay va_dpy, VASurfaceID surface_id,
                 v_ptr = dst_U + row * (dst_width/2);
                 u_ptr = dst_V + row * (dst_width/2);
             }
-            for(j = 0; j < dst_width/2; j++) {
-                u_ptr[j] = U_row[2*j];
-                v_ptr[j] = U_row[2*j+1];
+            if ((dst_fourcc == VA_FOURCC_IYUV) ||
+                (dst_fourcc == VA_FOURCC_YV12)) {
+                for(j = 0; j < dst_width/2; j++) {
+                    u_ptr[j] = U_row[2*j];
+                    v_ptr[j] = U_row[2*j+1];
+                }
             }
             break;
         case VA_FOURCC_IYUV:
-- 
2.1.0



More information about the Libva mailing list