summaryrefslogtreecommitdiff
path: root/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@infradead.org>2008-07-26 06:41:37 -0300
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-26 06:41:37 -0300
commitdbe96ea057cb7cf8050f22c934df078560d88c65 (patch)
treec3bcb1a051272ee414836c3186f1fb67c206edb9 /v4l2-apps/lib/libv4l/libv4lconvert/spca501.c
parentc241933ee2723ed8ac2f3e493a3abfa9a8aa35fa (diff)
parentdd206111ac475d3fe5b1da56cfd0b54544ab0591 (diff)
downloadmediapointer-dvb-s2-dbe96ea057cb7cf8050f22c934df078560d88c65.tar.gz
mediapointer-dvb-s2-dbe96ea057cb7cf8050f22c934df078560d88c65.tar.bz2
merge: http://www.linuxtv.org/hg/~hverkuil/v4l-dvb-audiochip
From: Mauro Carvalho Chehab <mchehab@infradead.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/lib/libv4l/libv4lconvert/spca501.c')
-rw-r--r--v4l2-apps/lib/libv4l/libv4lconvert/spca501.c73
1 files changed, 66 insertions, 7 deletions
diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c b/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c
index b0170e7cb..1e54cb7bb 100644
--- a/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c
+++ b/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c
@@ -18,14 +18,14 @@
#include "libv4lconvert-priv.h"
+/* YUYV per line */
void v4lconvert_spca501_to_yuv420(const unsigned char *src, unsigned char *dst,
int width, int height)
{
int i,j;
+ unsigned long *lsrc = (unsigned long *)src;
for (i = 0; i < height; i += 2) {
- unsigned long *lsrc = (unsigned long *)(src + (i / 2) * 3 * width);
-
/* -128 - 127 --> 0 - 255 and copy first line Y */
unsigned long *ldst = (unsigned long *)(dst + i * width);
for (j = 0; j < width; j += sizeof(long)) {
@@ -56,12 +56,71 @@ void v4lconvert_spca501_to_yuv420(const unsigned char *src, unsigned char *dst,
}
}
-/* IMPROVEME (maybe?) make this convert in one go?? */
-void v4lconvert_spca501_to_bgr24(const unsigned char *src, unsigned char *dst,
+/* YYUV per line */
+void v4lconvert_spca505_to_yuv420(const unsigned char *src, unsigned char *dst,
int width, int height)
{
- unsigned char buf[(width * height * 6) / 4];
+ int i,j;
+ unsigned long *lsrc = (unsigned long *)src;
+
+ for (i = 0; i < height; i += 2) {
+ /* -128 - 127 --> 0 - 255 and copy 2 lines of Y */
+ unsigned long *ldst = (unsigned long *)(dst + i * width);
+ for (j = 0; j < width*2; j += sizeof(long)) {
+ *ldst = *lsrc++;
+ *ldst++ ^= 0x8080808080808080ULL;
+ }
+
+ /* -128 - 127 --> 0 - 255 and copy 1 line U */
+ ldst = (unsigned long *)(dst + width * height + i * width / 4);
+ for (j = 0; j < width/2; j += sizeof(long)) {
+ *ldst = *lsrc++;
+ *ldst++ ^= 0x8080808080808080ULL;
+ }
- v4lconvert_spca501_to_yuv420(src, buf, width, height);
- v4lconvert_yuv420_to_bgr24(buf, dst, width, height);
+ /* -128 - 127 --> 0 - 255 and copy 1 line V */
+ ldst = (unsigned long *)(dst + (width * height * 5) / 4 + i * width / 4);
+ for (j = 0; j < width/2; j += sizeof(long)) {
+ *ldst = *lsrc++;
+ *ldst++ ^= 0x8080808080808080ULL;
+ }
+ }
+}
+
+/* YUVY per line */
+void v4lconvert_spca508_to_yuv420(const unsigned char *src, unsigned char *dst,
+ int width, int height)
+{
+ int i,j;
+ unsigned long *lsrc = (unsigned long *)src;
+
+ for (i = 0; i < height; i += 2) {
+ /* -128 - 127 --> 0 - 255 and copy first line Y */
+ unsigned long *ldst = (unsigned long *)(dst + i * width);
+ for (j = 0; j < width; j += sizeof(long)) {
+ *ldst = *lsrc++;
+ *ldst++ ^= 0x8080808080808080ULL;
+ }
+
+ /* -128 - 127 --> 0 - 255 and copy 1 line U */
+ ldst = (unsigned long *)(dst + width * height + i * width / 4);
+ for (j = 0; j < width/2; j += sizeof(long)) {
+ *ldst = *lsrc++;
+ *ldst++ ^= 0x8080808080808080ULL;
+ }
+
+ /* -128 - 127 --> 0 - 255 and copy 1 line V */
+ ldst = (unsigned long *)(dst + (width * height * 5) / 4 + i * width / 4);
+ for (j = 0; j < width/2; j += sizeof(long)) {
+ *ldst = *lsrc++;
+ *ldst++ ^= 0x8080808080808080ULL;
+ }
+
+ /* -128 - 127 --> 0 - 255 and copy second line Y */
+ ldst = (unsigned long *)(dst + i * width + width);
+ for (j = 0; j < width; j += sizeof(long)) {
+ *ldst = *lsrc++;
+ *ldst++ ^= 0x8080808080808080ULL;
+ }
+ }
}