diff options
Diffstat (limited to 'v4l2-apps/lib/libv4l')
-rw-r--r-- | v4l2-apps/lib/libv4l/ChangeLog | 5 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/Makefile | 2 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h | 15 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 35 | ||||
-rw-r--r-- | v4l2-apps/lib/libv4l/libv4lconvert/spca501.c | 73 |
5 files changed, 115 insertions, 15 deletions
diff --git a/v4l2-apps/lib/libv4l/ChangeLog b/v4l2-apps/lib/libv4l/ChangeLog index 286963543..9d642da7c 100644 --- a/v4l2-apps/lib/libv4l/ChangeLog +++ b/v4l2-apps/lib/libv4l/ChangeLog @@ -1,3 +1,8 @@ +libv4l-0.3.7 +------------ +* Add spca505/6 and spca508 cam specific formats (YUYV per line variations) + + libv4l-0.3.6 ------------ * Add missing COPYING.LIB file diff --git a/v4l2-apps/lib/libv4l/Makefile b/v4l2-apps/lib/libv4l/Makefile index 0f4428eba..3497fdbf2 100644 --- a/v4l2-apps/lib/libv4l/Makefile +++ b/v4l2-apps/lib/libv4l/Makefile @@ -1,5 +1,5 @@ LIB_RELEASE=0 -V4L2_LIB_VERSION=$(LIB_RELEASE).3.6 +V4L2_LIB_VERSION=$(LIB_RELEASE).3.7 all clean install: $(MAKE) -C libv4lconvert $@ diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h index badb89d62..3148065f3 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h @@ -24,7 +24,15 @@ #include "tinyjpeg.h" #ifndef V4L2_PIX_FMT_SPCA501 -#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S','5','0','1') +#define V4L2_PIX_FMT_SPCA501 v4l2_fourcc('S','5','0','1') /* YUYV per line */ +#endif + +#ifndef V4L2_PIX_FMT_SPCA505 +#define V4L2_PIX_FMT_SPCA505 v4l2_fourcc('S','5','0','5') /* YYUV per line */ +#endif + +#ifndef V4L2_PIX_FMT_SPCA508 +#define V4L2_PIX_FMT_SPCA508 v4l2_fourcc('S','5','0','8') /* YUVY per line */ #endif #ifndef V4L2_PIX_FMT_SPCA561 @@ -69,7 +77,10 @@ void v4lconvert_yuv420_to_bgr24(const unsigned char *src, unsigned char *dst, void v4lconvert_spca501_to_yuv420(const unsigned char *src, unsigned char *dst, int width, int height); -void v4lconvert_spca501_to_bgr24(const unsigned char *src, unsigned char *dst, +void v4lconvert_spca505_to_yuv420(const unsigned char *src, unsigned char *dst, + int width, int height); + +void v4lconvert_spca508_to_yuv420(const unsigned char *src, unsigned char *dst, int width, int height); void v4lconvert_decode_spca561(const unsigned char *src, unsigned char *dst, diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index 6c6cb693d..3d61225b9 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -42,6 +42,8 @@ static const unsigned int supported_src_pixfmts[] = { V4L2_PIX_FMT_SGRBG8, V4L2_PIX_FMT_SRGGB8, V4L2_PIX_FMT_SPCA501, + V4L2_PIX_FMT_SPCA505, + V4L2_PIX_FMT_SPCA508, V4L2_PIX_FMT_SPCA561, V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_PAC207, @@ -310,14 +312,37 @@ int v4lconvert_convert(struct v4lconvert_data *data, dest_fmt->fmt.pix.height, src_fmt->fmt.pix.pixelformat); break; + /* YUYV line by line formats */ case V4L2_PIX_FMT_SPCA501: + case V4L2_PIX_FMT_SPCA505: + case V4L2_PIX_FMT_SPCA508: + { + unsigned char tmpbuf[dest_fmt->fmt.pix.width * dest_fmt->fmt.pix.height * + 3 / 2]; + unsigned char *my_dst = (dest_fmt->fmt.pix.pixelformat == + V4L2_PIX_FMT_BGR24) ? tmpbuf : dest; + + switch (src_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_SPCA501: + v4lconvert_spca501_to_yuv420(src, my_dst, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_SPCA505: + v4lconvert_spca505_to_yuv420(src, my_dst, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_SPCA508: + v4lconvert_spca508_to_yuv420(src, my_dst, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + } + if (dest_fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) - v4lconvert_spca501_to_bgr24(src, dest, dest_fmt->fmt.pix.width, - dest_fmt->fmt.pix.height); - else - v4lconvert_spca501_to_yuv420(src, dest, dest_fmt->fmt.pix.width, - dest_fmt->fmt.pix.height); + v4lconvert_yuv420_to_bgr24(tmpbuf, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + } /* compressed bayer formats */ case V4L2_PIX_FMT_SPCA561: 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; + } + } } |