From 89321cd3c42b6bec568dc59189d096b3624669bf Mon Sep 17 00:00:00 2001 From: Wind Yuan Date: Wed, 24 Apr 2013 10:39:03 +0800 Subject: [PATCH] image: add support for raw YUY2/UYVY image copies. 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 --- gst-libs/gst/vaapi/gstvaapiimage.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapiimage.c b/gst-libs/gst/vaapi/gstvaapiimage.c index bb46866f50..9c39ee5ded 100644 --- a/gst-libs/gst/vaapi/gstvaapiimage.c +++ b/gst-libs/gst/vaapi/gstvaapiimage.c @@ -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: