public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] YVYU decoding
@ 2008-08-29 16:57 Jean-Francois Moine
  2008-08-29 18:12 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Francois Moine @ 2008-08-29 16:57 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Video 4 Linux

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

Hi Hans,

Here is a patch for decoding the YVYU frames of the vc0321.

Cheers.

-- 
Ken ar c'hentañ |             ** Breizh ha Linux atav! **
Jef             |               http://moinejf.free.fr/


[-- Attachment #2: yvyu.pat --]
[-- Type: text/plain, Size: 3688 bytes --]

This patch adds the decoding of YVYU images generated by vc0321.

Signed-off-by: Jean-Francois Moine <moinejf@free.fr>

--- v4l-dvb-423381bc0d61/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h.orig	2008-08-29 14:00:57.000000000 +0200
+++ v4l-dvb-423381bc0d61/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h	2008-08-29 18:24:40.000000000 +0200
@@ -59,6 +59,10 @@
 #define V4L2_PIX_FMT_SRGGB8 v4l2_fourcc('R','G','G','B')
 #endif
 
+#ifndef V4L2_PIX_FMT_YVYU
+#define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U')
+#endif
+
 #define V4LCONVERT_ERROR_MSG_SIZE 256
 
 #define V4LCONVERT_ERR(...) \
@@ -87,6 +91,12 @@
 void v4lconvert_yuv420_to_bgr24(const unsigned char *src, unsigned char *dst,
   int width, int height);
 
+void v4lconvert_yvyu_to_rgb24(const unsigned char *src, unsigned char *dst,
+  int width, int height);
+
+void v4lconvert_yvyu_to_bgr24(const unsigned char *src, unsigned char *dst,
+  int width, int height);
+
 void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst,
   int width, int height);
 
--- v4l-dvb-423381bc0d61/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c.orig	2008-08-29 14:00:57.000000000 +0200
+++ v4l-dvb-423381bc0d61/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c	2008-08-29 18:22:10.000000000 +0200
@@ -49,6 +49,7 @@
   V4L2_PIX_FMT_SN9C10X,
   V4L2_PIX_FMT_PAC207,
   V4L2_PIX_FMT_PJPG,
+  V4L2_PIX_FMT_YVYU,
 };
 
 static const unsigned int supported_dst_pixfmts[] = {
@@ -518,6 +519,19 @@
       }
       break;
 
+    case V4L2_PIX_FMT_YVYU:
+      switch (dest_fmt->fmt.pix.pixelformat) {
+      case V4L2_PIX_FMT_RGB24:
+	v4lconvert_yvyu_to_rgb24(src, dest, dest_fmt->fmt.pix.width,
+				   dest_fmt->fmt.pix.height);
+	break;
+      case V4L2_PIX_FMT_BGR24:
+	v4lconvert_yvyu_to_bgr24(src, dest, dest_fmt->fmt.pix.width,
+				   dest_fmt->fmt.pix.height);
+	break;
+      }
+      break;
+
     default:
       V4LCONVERT_ERR("Unknown src format in conversion\n");
       errno = EINVAL;
--- v4l-dvb-423381bc0d61/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c.orig	2008-08-29 14:00:57.000000000 +0200
+++ v4l-dvb-423381bc0d61/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c	2008-08-29 18:40:08.000000000 +0200
@@ -130,6 +130,58 @@
   }
 }
 
+void v4lconvert_yvyu_to_bgr24(const unsigned char *src, unsigned char *dest,
+  int width, int height)
+{
+  int j;
+
+  while (--height >= 0) {
+    for (j = 0; j < width; j += 2) {
+      int u = src[3];
+      int v = src[1];
+      int u1 = (((u - 128) << 7) +  (u - 128)) >> 6;
+      int rg = (((u - 128) << 1) +  (u - 128) +
+		((v - 128) << 2) + ((v - 128) << 1)) >> 3;
+      int v1 = (((v - 128) << 1) +  (v - 128)) >> 1;
+
+      *dest++ = CLIP(*src + u1);
+      *dest++ = CLIP(*src - rg);
+      *dest++ = CLIP(*src + v1);
+
+      *dest++ = CLIP(src[2] + u1);
+      *dest++ = CLIP(src[2] - rg);
+      *dest++ = CLIP(src[2] + v1);
+      src += 4;
+    }
+  }
+}
+
+void v4lconvert_yvyu_to_rgb24(const unsigned char *src, unsigned char *dest,
+  int width, int height)
+{
+  int j;
+
+  while (--height >= 0) {
+    for (j = 0; j < width; j += 2) {
+      int u = src[3];
+      int v = src[1];
+      int u1 = (((u - 128) << 7) +  (u - 128)) >> 6;
+      int rg = (((u - 128) << 1) +  (u - 128) +
+		((v - 128) << 2) + ((v - 128) << 1)) >> 3;
+      int v1 = (((v - 128) << 1) +  (v - 128)) >> 1;
+
+      *dest++ = CLIP(*src + v1);
+      *dest++ = CLIP(*src - rg);
+      *dest++ = CLIP(*src + u1);
+
+      *dest++ = CLIP(src[2] + v1);
+      *dest++ = CLIP(src[2] - rg);
+      *dest++ = CLIP(src[2] + u1);
+      src += 4;
+    }
+  }
+}
+
 void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst,
   int width, int height)
 {

[-- Attachment #3: Type: text/plain, Size: 164 bytes --]

--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-08-29 18:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-29 16:57 [PATCH] YVYU decoding Jean-Francois Moine
2008-08-29 18:12 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox