image: add support for raw YUY2/UYVY image copies.
authorWind Yuan <feng.yuan@intel.com>
Wed, 24 Apr 2013 02:39:03 +0000 (10:39 +0800)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 11 Jul 2013 17:09:53 +0000 (19:09 +0200)
Implement raw image copies for YUY2 format. Add support for UYVY format
too, with the same copy function as for YUY2. Even though components
ordering differs, copying line strides is essentially the same.

https://bugzilla.gnome.org/show_bug.cgi?id=703939
https://bugzilla.gnome.org/show_bug.cgi?id=703940

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapiimage.c

index bb46866..9c39ee5 100644 (file)
@@ -869,6 +869,25 @@ copy_image_YV12(
     }
 }
 
+/* Copy YUY2 images */
+static void
+copy_image_YUY2(
+    GstVaapiImageRaw        *dst_image,
+    GstVaapiImageRaw        *src_image,
+    const GstVaapiRectangle *rect
+)
+{
+    guchar *dst, *src;
+    guint dst_stride, src_stride;
+
+    /* YUV 4:2:2, full vertical resolution */
+    dst_stride = dst_image->stride[0];
+    dst = dst_image->pixels[0] + rect->y * dst_stride + rect->x * 2;
+    src_stride = src_image->stride[0];
+    src = src_image->pixels[0] + rect->y * src_stride + rect->x * 2;
+    memcpy_pic(dst, dst_stride, src, src_stride, rect->width * 2, rect->height);
+}
+
 /* Copy RGBA images */
 static void
 copy_image_RGBA(
@@ -924,6 +943,10 @@ copy_image(
     case GST_VIDEO_FORMAT_I420:
         copy_image_YV12(dst_image, src_image, rect);
         break;
+    case GST_VIDEO_FORMAT_YUY2:
+    case GST_VIDEO_FORMAT_UYVY:
+        copy_image_YUY2(dst_image, src_image, rect);
+        break;
     case GST_VIDEO_FORMAT_ARGB:
     case GST_VIDEO_FORMAT_RGBA:
     case GST_VIDEO_FORMAT_ABGR: