[packages] libv4l: update to 0.8.6, add v4l-utils package
[openwrt/svn-archive/archive.git] / libs / libv4l / patches / 002-allow-disabling-libjpeg.patch
1 --- a/lib/libv4lconvert/Makefile
2 +++ b/lib/libv4lconvert/Makefile
3 @@ -1,6 +1,6 @@
4 override CPPFLAGS += -I../include -fvisibility=hidden
5
6 -LIBS_libv4lconvert = -lrt -lm -ljpeg
7 +LIBS_libv4lconvert = -lrt -lm
8
9 ifeq ($(LINKTYPE),static)
10 CONVERT_LIB = libv4lconvert.a
11 @@ -10,16 +10,22 @@ override CPPFLAGS += -fPIC
12 endif
13
14 CONVERT_OBJS = libv4lconvert.o tinyjpeg.o sn9c10x.o sn9c20x.o pac207.o \
15 - jl2005bcd.o \
16 mr97310a.o flip.o crop.o jidctflt.o spca561-decompress.o \
17 rgbyuv.o sn9c2028-decomp.o spca501.o sq905c.o bayer.o hm12.o \
18 - stv0680.o cpia1.o se401.o jpgl.o jpeg.o jpeg_memsrcdest.o \
19 + stv0680.o cpia1.o se401.o jpgl.o jpeg.o \
20 control/libv4lcontrol.o processing/libv4lprocessing.o \
21 processing/whitebalance.o processing/autogain.o \
22 processing/gamma.o helper.o
23 TARGETS = $(CONVERT_LIB) libv4lconvert.pc ov511-decomp ov518-decomp
24 INCLUDES = ../include/libv4lconvert.h
25
26 +ifeq ($(DISABLE_LIBJPEG),1)
27 +override CFLAGS += -DDISABLE_LIBJPEG
28 +else
29 +LIBS_libv4lconvert += -ljpeg
30 +CONVERT_OBJS += jl2005bcd.o jpeg_memsrcdest.o
31 +endif
32 +
33 override CPPFLAGS += -DLIBDIR=\"$(LIBDIR)\" -DLIBSUBDIR=\"$(LIBSUBDIR)\"
34
35 all: $(TARGETS)
36 --- a/lib/libv4lconvert/jpeg.c
37 +++ b/lib/libv4lconvert/jpeg.c
38 @@ -19,7 +19,9 @@
39 #include <errno.h>
40 #include <stdlib.h>
41 #include "libv4lconvert-priv.h"
42 +#ifndef DISABLE_LIBJPEG
43 #include "jpeg_memsrcdest.h"
44 +#endif
45
46 int v4lconvert_decode_jpeg_tinyjpeg(struct v4lconvert_data *data,
47 unsigned char *src, int src_size, unsigned char *dest,
48 @@ -107,6 +109,8 @@ int v4lconvert_decode_jpeg_tinyjpeg(stru
49 return 0;
50 }
51
52 +#ifndef DISABLE_LIBJPEG
53 +
54 static void jerr_error_exit(j_common_ptr cinfo)
55 {
56 struct v4lconvert_data *data = cinfo->client_data;
57 @@ -405,3 +409,6 @@ int v4lconvert_decode_jpeg_libjpeg(struc
58
59 return result;
60 }
61 +
62 +#endif
63 +
64 --- a/lib/libv4lconvert/libv4lconvert-priv.h
65 +++ b/lib/libv4lconvert/libv4lconvert-priv.h
66 @@ -22,7 +22,9 @@
67 #include <stdio.h>
68 #include <stdint.h>
69 #include <sys/types.h>
70 +#ifndef DISABLE_LIBJPEG
71 #include <jpeglib.h>
72 +#endif
73 #include <setjmp.h>
74 #include "libv4lconvert.h"
75 #include "control/libv4lcontrol.h"
76 @@ -50,11 +52,13 @@ struct v4lconvert_data {
77 int64_t supported_src_formats; /* bitfield */
78 char error_msg[V4LCONVERT_ERROR_MSG_SIZE];
79 struct jdec_private *tinyjpeg;
80 +#ifndef DISABLE_LIBJPEG
81 struct jpeg_error_mgr jerr;
82 int jerr_errno;
83 jmp_buf jerr_jmp_state;
84 struct jpeg_decompress_struct cinfo;
85 int cinfo_initialized;
86 +#endif
87 struct v4l2_frmsizeenum framesizes[V4LCONVERT_MAX_FRAMESIZES];
88 unsigned int no_framesizes;
89 int bandwidth;
90 --- a/lib/libv4lconvert/libv4lconvert.c
91 +++ b/lib/libv4lconvert/libv4lconvert.c
92 @@ -78,7 +78,9 @@ static const struct v4lconvert_pixfmt su
93 { V4L2_PIX_FMT_SN9C2028, 0, 9, 9, 1 },
94 { V4L2_PIX_FMT_PAC207, 0, 9, 9, 1 },
95 { V4L2_PIX_FMT_MR97310A, 0, 9, 9, 1 },
96 +#ifndef DISABLE_LIBJPEG
97 { V4L2_PIX_FMT_JL2005BCD, 0, 9, 9, 1 },
98 +#endif
99 { V4L2_PIX_FMT_SQ905C, 0, 9, 9, 1 },
100 /* special */
101 { V4L2_PIX_FMT_SE401, 0, 8, 9, 1 },
102 @@ -186,8 +188,10 @@ void v4lconvert_destroy(struct v4lconver
103 tinyjpeg_set_components(data->tinyjpeg, comps, 3);
104 tinyjpeg_free(data->tinyjpeg);
105 }
106 +#ifndef DISABLE_LIBJPEG
107 if (data->cinfo_initialized)
108 jpeg_destroy_decompress(&data->cinfo);
109 +#endif
110 v4lconvert_helper_cleanup(data);
111 free(data->convert1_buf);
112 free(data->convert2_buf);
113 @@ -634,10 +638,13 @@ static int v4lconvert_convert_pixfmt(str
114 /* JPG and variants */
115 case V4L2_PIX_FMT_MJPEG:
116 case V4L2_PIX_FMT_JPEG:
117 +#ifndef DISABLE_LIBJPEG
118 if (data->flags & V4LCONVERT_USE_TINYJPEG) {
119 +#endif
120 result = v4lconvert_decode_jpeg_tinyjpeg(data,
121 src, src_size, dest,
122 fmt, dest_pix_fmt, 0);
123 +#ifndef DISABLE_LIBJPEG
124 } else {
125 result = v4lconvert_decode_jpeg_libjpeg(data,
126 src, src_size, dest,
127 @@ -652,6 +659,7 @@ static int v4lconvert_convert_pixfmt(str
128 fmt, dest_pix_fmt, 0);
129 }
130 }
131 +#endif
132 break;
133 case V4L2_PIX_FMT_PJPG:
134 result = v4lconvert_decode_jpeg_tinyjpeg(data, src, src_size,
135 @@ -777,7 +785,9 @@ static int v4lconvert_convert_pixfmt(str
136 case V4L2_PIX_FMT_SN9C10X:
137 case V4L2_PIX_FMT_PAC207:
138 case V4L2_PIX_FMT_MR97310A:
139 +#ifndef DISABLE_LIBJPEG
140 case V4L2_PIX_FMT_JL2005BCD:
141 +#endif
142 case V4L2_PIX_FMT_SN9C2028:
143 case V4L2_PIX_FMT_SQ905C:
144 case V4L2_PIX_FMT_STV0680: { /* Not compressed but needs some shuffling */
145 @@ -816,6 +826,7 @@ static int v4lconvert_convert_pixfmt(str
146 }
147 tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR8;
148 break;
149 +#ifndef DISABLE_LIBJPEG
150 case V4L2_PIX_FMT_JL2005BCD:
151 if (v4lconvert_decode_jl2005bcd(data, src, src_size,
152 tmpbuf,
153 @@ -826,6 +837,7 @@ static int v4lconvert_convert_pixfmt(str
154 }
155 tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SRGGB8;
156 break;
157 +#endif
158 case V4L2_PIX_FMT_SN9C2028:
159 v4lconvert_decode_sn9c2028(src, tmpbuf, width, height);
160 tmpfmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SBGGR8;