From feec7dd735a92d1d390cc0669f879e2b6d36389e Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Wed, 30 Jul 2008 20:05:21 -0700 Subject: libv4l: silence the creation of pkg-config files Signed-off-by: Brandon Philips --- v4l2-apps/lib/libv4l/libv4lconvert/Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'v4l2-apps/lib/libv4l/libv4lconvert') diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/Makefile b/v4l2-apps/lib/libv4l/libv4lconvert/Makefile index 3fd561f4e..014692ed6 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/Makefile +++ b/v4l2-apps/lib/libv4l/libv4lconvert/Makefile @@ -31,14 +31,14 @@ all: $(TARGETS) $(CONVERT_LIB): $(CONVERT_OBJS) libv4lconvert.pc: - echo prefix=$(PREFIX) > libv4lconvert.pc - echo libdir=$(LIBDIR) >> libv4lconvert.pc - echo >> libv4lconvert.pc - echo 'Name: libv4lconvert' >> libv4lconvert.pc - echo 'Description: v4l format conversion library' >> libv4lconvert.pc - echo 'Version: '$(V4L2_LIB_VERSION) >> libv4lconvert.pc - echo 'Libs: -L$${libdir} -lv4lconvert' >> libv4lconvert.pc - echo 'Cflags: -I$${prefix}/include' >> libv4lconvert.pc + @echo prefix=$(PREFIX) > libv4lconvert.pc + @echo libdir=$(LIBDIR) >> libv4lconvert.pc + @echo >> libv4lconvert.pc + @echo 'Name: libv4lconvert' >> libv4lconvert.pc + @echo 'Description: v4l format conversion library' >> libv4lconvert.pc + @echo 'Version: '$(V4L2_LIB_VERSION) >> libv4lconvert.pc + @echo 'Libs: -L$${libdir} -lv4lconvert' >> libv4lconvert.pc + @echo 'Cflags: -I$${prefix}/include' >> libv4lconvert.pc install: all mkdir -p $(DESTDIR)$(PREFIX)/include -- cgit v1.2.3 From 474932fcb19fc298b8786e737bd1ae5115c9a6d2 Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Thu, 31 Jul 2008 09:37:27 +0200 Subject: libv4l: fixup copyright headers From: Brandon Philips Part of the copyright headers refered GPL instead of LGPL due to a copy and paste error (Brandon Philips) Signed-off-by: Brandon Philips Signed-off-by: Hans de Goede --- v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h | 2 +- v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 2 +- v4l2-apps/lib/libv4l/libv4lconvert/pac207.c | 2 +- v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c | 2 +- v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c | 2 +- v4l2-apps/lib/libv4l/libv4lconvert/spca501.c | 2 +- v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'v4l2-apps/lib/libv4l/libv4lconvert') diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h index 3148065f3..90d8f2bdb 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h @@ -9,7 +9,7 @@ # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index 3d61225b9..2bbc44bd6 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -9,7 +9,7 @@ # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/pac207.c b/v4l2-apps/lib/libv4l/libv4lconvert/pac207.c index 085d7a772..4887c25ee 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/pac207.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/pac207.c @@ -12,7 +12,7 @@ # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c index 79c8ecb35..388e64111 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c @@ -12,7 +12,7 @@ # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c b/v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c index b23ad4630..98a513378 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/sn9c10x.c @@ -10,7 +10,7 @@ # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c b/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c index 1e54cb7bb..9157629e3 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/spca501.c @@ -9,7 +9,7 @@ # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c b/v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c index 40b0f90db..802345af0 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/spca561-decompress.c @@ -10,7 +10,7 @@ # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, write to the Free Software -- cgit v1.2.3 From d0280d4d77c5f7dd211cc827284347828e260ab9 Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Sun, 3 Aug 2008 12:43:49 +0200 Subject: libv4l: add support for converting to rgb24 From: Jean-Francois Moine Add support for conversion to RGB24 (before we only support BGR24) based on a patch by Jean-Francois Moine Signed-off-by: Jean-Francois Moine Signed-off-by: Hans de Goede --- v4l2-apps/lib/libv4l/libv4lconvert/bayer.c | 30 +++++++--- .../lib/libv4l/libv4lconvert/libv4lconvert-priv.h | 6 ++ v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 69 +++++++++++++++++----- v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c | 47 +++++++++++++++ 4 files changed, 130 insertions(+), 22 deletions(-) (limited to 'v4l2-apps/lib/libv4l/libv4lconvert') diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c b/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c index 166c13011..ca7bb486f 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/bayer.c @@ -163,14 +163,10 @@ static void v4lconvert_border_bayer_line_to_bgr24( } /* From libdc1394, which on turn was based on OpenCV's Bayer decoding */ -void v4lconvert_bayer_to_bgr24(const unsigned char *bayer, - unsigned char *bgr, int width, int height, unsigned int pixfmt) +static void bayer_to_rgbbgr24(const unsigned char *bayer, + unsigned char *bgr, int width, int height, unsigned int pixfmt, + int start_with_green, int blue_line) { - int blue_line = pixfmt == V4L2_PIX_FMT_SBGGR8 - || pixfmt == V4L2_PIX_FMT_SGBRG8; - int start_with_green = pixfmt == V4L2_PIX_FMT_SGBRG8 - || pixfmt == V4L2_PIX_FMT_SGRBG8; - /* render the first line */ v4lconvert_border_bayer_line_to_bgr24(bayer, bayer + width, bgr, width, start_with_green, blue_line); @@ -317,6 +313,26 @@ void v4lconvert_bayer_to_bgr24(const unsigned char *bayer, !start_with_green, !blue_line); } +void v4lconvert_bayer_to_rgb24(const unsigned char *bayer, + unsigned char *bgr, int width, int height, unsigned int pixfmt) +{ + bayer_to_rgbbgr24(bayer, bgr, width, height, pixfmt, + pixfmt == V4L2_PIX_FMT_SGBRG8 /* start with green */ + || pixfmt == V4L2_PIX_FMT_SGRBG8, + pixfmt != V4L2_PIX_FMT_SBGGR8 /* blue line */ + && pixfmt != V4L2_PIX_FMT_SGBRG8); +} + +void v4lconvert_bayer_to_bgr24(const unsigned char *bayer, + unsigned char *bgr, int width, int height, unsigned int pixfmt) +{ + bayer_to_rgbbgr24(bayer, bgr, width, height, pixfmt, + pixfmt == V4L2_PIX_FMT_SGBRG8 /* start with green */ + || pixfmt == V4L2_PIX_FMT_SGRBG8, + pixfmt == V4L2_PIX_FMT_SBGGR8 /* blue line */ + || pixfmt == V4L2_PIX_FMT_SGBRG8); +} + static void v4lconvert_border_bayer_line_to_y( const unsigned char* bayer, const unsigned char* adjacent_bayer, unsigned char *y, int width, int start_with_green, int blue_line) diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h index 90d8f2bdb..a85121cad 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h @@ -71,6 +71,9 @@ struct v4lconvert_data { }; +void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dst, + int width, int height); + void v4lconvert_yuv420_to_bgr24(const unsigned char *src, unsigned char *dst, int width, int height); @@ -92,6 +95,9 @@ void v4lconvert_decode_sn9c10x(const unsigned char *src, unsigned char *dst, void v4lconvert_decode_pac207(const unsigned char *src, unsigned char *dst, int width, int height); +void v4lconvert_bayer_to_rgb24(const unsigned char *bayer, + unsigned char *rgb, int width, int height, unsigned int pixfmt); + void v4lconvert_bayer_to_bgr24(const unsigned char *bayer, unsigned char *rgb, int width, int height, unsigned int pixfmt); diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index 2bbc44bd6..ffde7e1e8 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -30,6 +30,7 @@ /* Note for proper functioning of v4lconvert_enum_fmt the first entries in supported_src_pixfmts must match with the entries in supported_dst_pixfmts */ #define SUPPORTED_DST_PIXFMTS \ + V4L2_PIX_FMT_RGB24, \ V4L2_PIX_FMT_BGR24, \ V4L2_PIX_FMT_YUV420 @@ -191,6 +192,7 @@ int v4lconvert_try_format(struct v4lconvert_data *data, if (closest_fmt.fmt.pix.pixelformat != desired_pixfmt) { dest_fmt->fmt.pix.pixelformat = desired_pixfmt; switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_BGR24: dest_fmt->fmt.pix.bytesperline = dest_fmt->fmt.pix.width * 3; dest_fmt->fmt.pix.sizeimage = dest_fmt->fmt.pix.width * @@ -228,6 +230,7 @@ int v4lconvert_convert(struct v4lconvert_data *data, /* sanity check, is the dest buffer large enough? */ switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_BGR24: needed = dest_fmt->fmt.pix.width * dest_fmt->fmt.pix.height * 3; break; @@ -283,12 +286,19 @@ int v4lconvert_convert(struct v4lconvert_data *data, components[2] = components[1] + (dest_fmt->fmt.pix.width * dest_fmt->fmt.pix.height) / 4; - if (dest_fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) { + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: + tinyjpeg_set_components(data->jdec, components, 1); + result = tinyjpeg_decode(data->jdec, TINYJPEG_FMT_RGB24); + break; + case V4L2_PIX_FMT_BGR24: tinyjpeg_set_components(data->jdec, components, 1); result = tinyjpeg_decode(data->jdec, TINYJPEG_FMT_BGR24); - } else { + break; + default: tinyjpeg_set_components(data->jdec, components, 3); result = tinyjpeg_decode(data->jdec, TINYJPEG_FMT_YUV420P); + break; } /* If the JPEG header checked out ok and we get an error during actual @@ -304,12 +314,20 @@ int v4lconvert_convert(struct v4lconvert_data *data, case V4L2_PIX_FMT_SGBRG8: case V4L2_PIX_FMT_SGRBG8: case V4L2_PIX_FMT_SRGGB8: - if (dest_fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: + v4lconvert_bayer_to_rgb24(src, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height, src_fmt->fmt.pix.pixelformat); + break; + case V4L2_PIX_FMT_BGR24: v4lconvert_bayer_to_bgr24(src, dest, dest_fmt->fmt.pix.width, dest_fmt->fmt.pix.height, src_fmt->fmt.pix.pixelformat); - else + break; + default: v4lconvert_bayer_to_yuv420(src, dest, dest_fmt->fmt.pix.width, dest_fmt->fmt.pix.height, src_fmt->fmt.pix.pixelformat); + break; + } break; /* YUYV line by line formats */ @@ -319,8 +337,8 @@ int v4lconvert_convert(struct v4lconvert_data *data, { 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; + unsigned char *my_dst = (dest_fmt->fmt.pix.pixelformat != + V4L2_PIX_FMT_YUV420) ? tmpbuf : dest; switch (src_fmt->fmt.pix.pixelformat) { case V4L2_PIX_FMT_SPCA501: @@ -337,10 +355,16 @@ int v4lconvert_convert(struct v4lconvert_data *data, break; } - if (dest_fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: + v4lconvert_yuv420_to_rgb24(tmpbuf, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_BGR24: v4lconvert_yuv420_to_bgr24(tmpbuf, dest, dest_fmt->fmt.pix.width, dest_fmt->fmt.pix.height); - + break; + } break; } @@ -370,24 +394,39 @@ int v4lconvert_convert(struct v4lconvert_data *data, break; } - if (dest_fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_BGR24) + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: + v4lconvert_bayer_to_rgb24(tmpbuf, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height, bayer_fmt); + break; + case V4L2_PIX_FMT_BGR24: v4lconvert_bayer_to_bgr24(tmpbuf, dest, dest_fmt->fmt.pix.width, dest_fmt->fmt.pix.height, bayer_fmt); - else + break; + default: v4lconvert_bayer_to_yuv420(tmpbuf, dest, dest_fmt->fmt.pix.width, dest_fmt->fmt.pix.height, bayer_fmt); + break; + } break; } + case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_BGR24: - /* dest must be V4L2_PIX_FMT_YUV420 then */ - printf("FIXME add bgr24 -> yuv420 conversion\n"); + printf("FIXME add rgb24/bgr24 -> yuv420 conversion\n"); break; case V4L2_PIX_FMT_YUV420: - /* dest must be V4L2_PIX_FMT_BGR24 then */ - v4lconvert_yuv420_to_bgr24(src, dest, dest_fmt->fmt.pix.width, - dest_fmt->fmt.pix.height); + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: + v4lconvert_yuv420_to_rgb24(src, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_BGR24: + v4lconvert_yuv420_to_bgr24(src, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + } break; default: diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c index 388e64111..bda4cc342 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c @@ -80,3 +80,50 @@ void v4lconvert_yuv420_to_bgr24(const unsigned char *src, unsigned char *dest, } } } + +void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dest, + int width, int height) +{ + int i,j; + + const unsigned char *ysrc = src; + const unsigned char *usrc = src + width * height; + const unsigned char *vsrc = usrc + (width * height) / 4; + + for (i = 0; i < height; i++) { + for (j = 0; j < width; j += 2) { +#if 1 /* fast slightly less accurate multiplication free code */ + int u1 = (((*usrc - 128) << 7) + (*usrc - 128)) >> 6; + int rg = (((*usrc - 128) << 1) + (*usrc - 128) + + ((*vsrc - 128) << 2) + ((*vsrc - 128) << 1)) >> 3; + int v1 = (((*vsrc - 128) << 1) + (*vsrc - 128)) >> 1; + + *dest++ = CLIP(*ysrc + v1); + *dest++ = CLIP(*ysrc - rg); + *dest++ = CLIP(*ysrc + u1); + ysrc++; + + *dest++ = CLIP(*ysrc + v1); + *dest++ = CLIP(*ysrc - rg); + *dest++ = CLIP(*ysrc + u1); +#else + *dest++ = YUV2R(*ysrc, *usrc, *vsrc); + *dest++ = YUV2G(*ysrc, *usrc, *vsrc); + *dest++ = YUV2B(*ysrc, *usrc, *vsrc); + ysrc++; + + *dest++ = YUV2R(*ysrc, *usrc, *vsrc); + *dest++ = YUV2G(*ysrc, *usrc, *vsrc); + *dest++ = YUV2B(*ysrc, *usrc, *vsrc); +#endif + ysrc++; + usrc++; + vsrc++; + } + /* Rewind u and v for next line */ + if (i&1) { + usrc -= width / 2; + vsrc -= width / 2; + } + } +} -- cgit v1.2.3 From 1d60339ee5ca9a861de510dc4c57576ec9f2e5be Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Sun, 3 Aug 2008 13:15:46 +0200 Subject: libv4l: makefile and pkgconfig improvements From: Gregor Jasny Various Makefile and pkgconfig file improvements by Gregor Jasny (Debian) Signed-off-by: Gregor Jasny Signed-off-by: Hans de Goede --- v4l2-apps/lib/libv4l/libv4lconvert/Makefile | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'v4l2-apps/lib/libv4l/libv4lconvert') diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/Makefile b/v4l2-apps/lib/libv4l/libv4lconvert/Makefile index 014692ed6..c2a5be942 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/Makefile +++ b/v4l2-apps/lib/libv4l/libv4lconvert/Makefile @@ -1,14 +1,15 @@ -CC = gcc -LD = gcc - -CPPFLAGS = -fPIC -I../include -I../../../../linux/include +CPPFLAGS = -I../include -I../../../../linux/include CFLAGS := -g -O1 CFLAGS += -Wall -W -Wno-unused -Wpointer-arith -Wstrict-prototypes -LDFLAGS = -shared - +ifeq ($(LINKTYPE),static) +CONVERT_LIB = libv4lconvert.a +else CONVERT_LIB = libv4lconvert.so +CPPFLAGS += -fPIC +endif + CONVERT_OBJS = libv4lconvert.o tinyjpeg.o sn9c10x.o pac207.o \ jidctflt.o spca561-decompress.o rgbyuv.o spca501.o bayer.o TARGETS = $(CONVERT_LIB) libv4lconvert.pc @@ -44,18 +45,26 @@ install: all mkdir -p $(DESTDIR)$(PREFIX)/include install -p -m 644 $(INCLUDES) $(DESTDIR)$(PREFIX)/include mkdir -p $(DESTDIR)$(LIBDIR) +ifeq ($(LINKTYPE),static) + mkdir -p $(DESTDIR)$(LIBDIR) + install -m 644 $(CONVERT_LIB) $(DESTDIR)$(LIBDIR) +else install -m 755 $(CONVERT_LIB).$(LIB_RELEASE) $(DESTDIR)$(LIBDIR) cd $(DESTDIR)$(LIBDIR) && \ ln -f -s $(CONVERT_LIB).$(LIB_RELEASE) $(CONVERT_LIB) +endif mkdir -p $(DESTDIR)$(LIBDIR)/pkgconfig install -m 644 libv4lconvert.pc $(DESTDIR)$(LIBDIR)/pkgconfig clean:: - rm -f *.so* *.o *.d libv4lconvert.pc log *~ + rm -f *.a *.so* *.o *.d libv4lconvert.pc log *~ %.o: %.c $(CC) -c -MMD $(CPPFLAGS) $(CFLAGS) -o $@ $< %.so: - $(CC) $(LDFLAGS) -Wl,-soname,$@.$(LIB_RELEASE) -o $@.$(LIB_RELEASE) $^ + $(CC) -shared $(LDFLAGS) -Wl,-soname,$@.$(LIB_RELEASE) -o $@.$(LIB_RELEASE) $^ ln -f -s $@.$(LIB_RELEASE) $@ + +%.a: + $(AR) cqs $@ $^ -- cgit v1.2.3 From b373ec3cc6f05fec60f972d8b42ddcd0f2d1c29a Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Sun, 3 Aug 2008 16:53:49 +0200 Subject: libv4l: prefer native formats From: Hans de Goede When the hardware supports a format natively prefer using the native version over converting from another supported format Signed-off-by: Hans de Goede --- v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'v4l2-apps/lib/libv4l/libv4lconvert') diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index ffde7e1e8..e19b2f05b 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -171,7 +171,9 @@ int v4lconvert_try_format(struct v4lconvert_data *data, (int)dest_fmt->fmt.pix.height); unsigned int size_diff = size_x_diff * size_x_diff + size_y_diff * size_y_diff; - if (size_diff < closest_fmt_size_diff) { + if (size_diff < closest_fmt_size_diff || + (size_diff == closest_fmt_size_diff && + try_fmt.fmt.pix.pixelformat == desired_pixfmt)) { closest_fmt_size_diff = size_diff; closest_fmt = try_fmt; } -- cgit v1.2.3 From 6d0c45027f9fe1891269de296adab0af9a21d214 Mon Sep 17 00:00:00 2001 From: "hans@localhost.localdomain" Date: Sun, 3 Aug 2008 17:15:12 +0200 Subject: libv4l: add rgb24 <-> bgr24 conversion From: Hans de Goede libv4l: add rgb24 <-> bgr24 conversion Signed-off-by: Hans de Goede --- .../lib/libv4l/libv4lconvert/libv4lconvert-priv.h | 3 +++ v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c | 20 +++++++++++++++++++- v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) (limited to 'v4l2-apps/lib/libv4l/libv4lconvert') diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h index a85121cad..bdf847186 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert-priv.h @@ -77,6 +77,9 @@ void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dst, void v4lconvert_yuv420_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); + void v4lconvert_spca501_to_yuv420(const unsigned char *src, unsigned char *dst, int width, int height); diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c index e19b2f05b..4c9e67d52 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/libv4lconvert.c @@ -414,8 +414,26 @@ int v4lconvert_convert(struct v4lconvert_data *data, } case V4L2_PIX_FMT_RGB24: + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_BGR24: + v4lconvert_swap_rgb(src, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_YUV420: + printf("FIXME add rgb24 -> yuv420 conversion\n"); + break; + } + break; case V4L2_PIX_FMT_BGR24: - printf("FIXME add rgb24/bgr24 -> yuv420 conversion\n"); + switch (dest_fmt->fmt.pix.pixelformat) { + case V4L2_PIX_FMT_RGB24: + v4lconvert_swap_rgb(src, dest, dest_fmt->fmt.pix.width, + dest_fmt->fmt.pix.height); + break; + case V4L2_PIX_FMT_YUV420: + printf("FIXME add bgr24 -> yuv420 conversion\n"); + break; + } break; case V4L2_PIX_FMT_YUV420: diff --git a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c index bda4cc342..742dd06ce 100644 --- a/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c +++ b/v4l2-apps/lib/libv4l/libv4lconvert/rgbyuv.c @@ -127,3 +127,18 @@ void v4lconvert_yuv420_to_rgb24(const unsigned char *src, unsigned char *dest, } } } + +void v4lconvert_swap_rgb(const unsigned char *src, unsigned char *dst, + int width, int height) +{ + int i; + + for (i = 0; i < (width * height); i++) { + unsigned char tmp0, tmp1; + tmp0 = *src++; + tmp1 = *src++; + *dst++ = *src++; + *dst++ = tmp1; + *dst++ = tmp0; + } +} -- cgit v1.2.3