Revision 936
Incremental update; working on:
- new vision algorithm utilizing edge detection instead of thresholding
- sending camera images over sockets instead of using the webserver
trunk/code/projects/colonet/robot/colonet_dragonfly/colonet_dragonfly.c | ||
---|---|---|
564 | 564 |
break; |
565 | 565 |
} |
566 | 566 |
} else { |
567 |
sprintf(buf, "%s: Error: Invalid colonet message type", __FUNCTION__); |
|
567 |
sprintf(buf, "%s: Error: Invalid colonet message type\n", __FUNCTION__);
|
|
568 | 568 |
usb_puts(buf); |
569 | 569 |
} |
570 | 570 |
} |
trunk/code/projects/colonet/server/Command.cpp | ||
---|---|---|
278 | 278 |
return -1; |
279 | 279 |
} |
280 | 280 |
break; |
281 |
|
|
282 |
case CLIENT_REQUEST_IMAGE: |
|
283 |
if (parse_request_image(pool_index)) { |
|
284 |
return -1; |
|
285 |
} |
|
286 |
break; |
|
281 | 287 |
|
282 | 288 |
case CLIENT_REQUEST_ROBOT_POSITIONS: |
283 | 289 |
if (parse_request_robot_positions(pool_index)) { |
... | ... | |
366 | 372 |
} |
367 | 373 |
|
368 | 374 |
/** |
375 |
* @brief This function parses a client's request for an image from the over head camera |
|
376 |
* |
|
377 |
* @param pool_index The index in the connection pool of the client that sent this command |
|
378 |
* |
|
379 |
* @return 0 on success, negative error code on failure |
|
380 |
*/ |
|
381 |
int Command::parse_request_image(int pool_index) { |
|
382 |
//printf("*****parse_request_image\n"); |
|
383 |
|
|
384 |
unsigned char buffer[150000]; |
|
385 |
int length; |
|
386 |
|
|
387 |
//get the latest image data from the vision module |
|
388 |
length = getImageBytes(buffer, 150000); |
|
389 |
|
|
390 |
if (length > 0) |
|
391 |
connection_pool->write_to_client(pool_index, (char *)buffer, length); |
|
392 |
else |
|
393 |
return -1; |
|
394 |
|
|
395 |
return 0; |
|
396 |
} |
|
397 |
|
|
398 |
/** |
|
369 | 399 |
* @brief This functions parses a client's request for the positions of robots |
370 | 400 |
* |
371 | 401 |
* @param pool_index The index in the connection pool of the client that sent this command |
trunk/code/projects/colonet/server/colonet_wireless.cpp | ||
---|---|---|
122 | 122 |
*/ |
123 | 123 |
int colonet_wl_send(short client_source, short dest, ColonetRobotMessageType msg_type, unsigned char msg_code, |
124 | 124 |
unsigned char* args) { |
125 |
printf("colonet_wl_send: client_source:%d, dest:%d, msg_code:%d\n", client_source, dest, msg_code); |
|
125 |
//printf("colonet_wl_send: client_source:%d, dest:%d, msg_code:%d\n", client_source, dest, msg_code);
|
|
126 | 126 |
|
127 | 127 |
//create and set up new packet to be sent. |
128 | 128 |
ColonetRobotServerPacket pkt; |
trunk/code/projects/colonet/server/includes/Command.h | ||
---|---|---|
28 | 28 |
|
29 | 29 |
int parse_request_bom_matrix(int pool_index); |
30 | 30 |
int parse_request_xbee_ids(int pool_index); |
31 |
int parse_request_image(int pool_index); |
|
31 | 32 |
int parse_request_robot_positions(int pool_index); |
32 | 33 |
|
33 | 34 |
ConnectionPool * connection_pool; |
trunk/code/projects/colonet/server/vision/memdst.h | ||
---|---|---|
1 |
#ifndef MEMDST_H |
|
2 |
#define MEMDST_H |
|
3 |
|
|
4 |
GLOBAL(void) |
|
5 |
jpeg_memory_dest (j_compress_ptr cinfo, JOCTET* buffer, int bufsize, int* outsize); |
|
6 |
|
|
7 |
#endif |
trunk/code/projects/colonet/server/vision/jmorecfg.h | ||
---|---|---|
1 |
/* |
|
2 |
* jmorecfg.h |
|
3 |
* |
|
4 |
* Copyright (C) 1991-1997, Thomas G. Lane. |
|
5 |
* This file is part of the Independent JPEG Group's software. |
|
6 |
* For conditions of distribution and use, see the accompanying README file. |
|
7 |
* |
|
8 |
* This file contains additional configuration options that customize the |
|
9 |
* JPEG software for special applications or support machine-dependent |
|
10 |
* optimizations. Most users will not need to touch this file. |
|
11 |
*/ |
|
12 |
|
|
13 |
|
|
14 |
/* |
|
15 |
* Define BITS_IN_JSAMPLE as either |
|
16 |
* 8 for 8-bit sample values (the usual setting) |
|
17 |
* 12 for 12-bit sample values |
|
18 |
* Only 8 and 12 are legal data precisions for lossy JPEG according to the |
|
19 |
* JPEG standard, and the IJG code does not support anything else! |
|
20 |
* We do not support run-time selection of data precision, sorry. |
|
21 |
*/ |
|
22 |
|
|
23 |
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ |
|
24 |
|
|
25 |
|
|
26 |
/* |
|
27 |
* Maximum number of components (color channels) allowed in JPEG image. |
|
28 |
* To meet the letter of the JPEG spec, set this to 255. However, darn |
|
29 |
* few applications need more than 4 channels (maybe 5 for CMYK + alpha |
|
30 |
* mask). We recommend 10 as a reasonable compromise; use 4 if you are |
|
31 |
* really short on memory. (Each allowed component costs a hundred or so |
|
32 |
* bytes of storage, whether actually used in an image or not.) |
|
33 |
*/ |
|
34 |
|
|
35 |
#define MAX_COMPONENTS 10 /* maximum number of image components */ |
|
36 |
|
|
37 |
|
|
38 |
/* |
|
39 |
* Basic data types. |
|
40 |
* You may need to change these if you have a machine with unusual data |
|
41 |
* type sizes; for example, "char" not 8 bits, "short" not 16 bits, |
|
42 |
* or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, |
|
43 |
* but it had better be at least 16. |
|
44 |
*/ |
|
45 |
|
|
46 |
/* Representation of a single sample (pixel element value). |
|
47 |
* We frequently allocate large arrays of these, so it's important to keep |
|
48 |
* them small. But if you have memory to burn and access to char or short |
|
49 |
* arrays is very slow on your hardware, you might want to change these. |
|
50 |
*/ |
|
51 |
|
|
52 |
#if BITS_IN_JSAMPLE == 8 |
|
53 |
/* JSAMPLE should be the smallest type that will hold the values 0..255. |
|
54 |
* You can use a signed char by having GETJSAMPLE mask it with 0xFF. |
|
55 |
*/ |
|
56 |
|
|
57 |
#ifdef HAVE_UNSIGNED_CHAR |
|
58 |
|
|
59 |
typedef unsigned char JSAMPLE; |
|
60 |
#define GETJSAMPLE(value) ((int) (value)) |
|
61 |
|
|
62 |
#else /* not HAVE_UNSIGNED_CHAR */ |
|
63 |
|
|
64 |
typedef char JSAMPLE; |
|
65 |
#ifdef CHAR_IS_UNSIGNED |
|
66 |
#define GETJSAMPLE(value) ((int) (value)) |
|
67 |
#else |
|
68 |
#define GETJSAMPLE(value) ((int) (value) & 0xFF) |
|
69 |
#endif /* CHAR_IS_UNSIGNED */ |
|
70 |
|
|
71 |
#endif /* HAVE_UNSIGNED_CHAR */ |
|
72 |
|
|
73 |
#define MAXJSAMPLE 255 |
|
74 |
#define CENTERJSAMPLE 128 |
|
75 |
|
|
76 |
#endif /* BITS_IN_JSAMPLE == 8 */ |
|
77 |
|
|
78 |
|
|
79 |
#if BITS_IN_JSAMPLE == 12 |
|
80 |
/* JSAMPLE should be the smallest type that will hold the values 0..4095. |
|
81 |
* On nearly all machines "short" will do nicely. |
|
82 |
*/ |
|
83 |
|
|
84 |
typedef short JSAMPLE; |
|
85 |
#define GETJSAMPLE(value) ((int) (value)) |
|
86 |
|
|
87 |
#define MAXJSAMPLE 4095 |
|
88 |
#define CENTERJSAMPLE 2048 |
|
89 |
|
|
90 |
#endif /* BITS_IN_JSAMPLE == 12 */ |
|
91 |
|
|
92 |
|
|
93 |
/* Representation of a DCT frequency coefficient. |
|
94 |
* This should be a signed value of at least 16 bits; "short" is usually OK. |
|
95 |
* Again, we allocate large arrays of these, but you can change to int |
|
96 |
* if you have memory to burn and "short" is really slow. |
|
97 |
*/ |
|
98 |
|
|
99 |
typedef short JCOEF; |
|
100 |
|
|
101 |
|
|
102 |
/* Compressed datastreams are represented as arrays of JOCTET. |
|
103 |
* These must be EXACTLY 8 bits wide, at least once they are written to |
|
104 |
* external storage. Note that when using the stdio data source/destination |
|
105 |
* managers, this is also the data type passed to fread/fwrite. |
|
106 |
*/ |
|
107 |
|
|
108 |
#ifdef HAVE_UNSIGNED_CHAR |
|
109 |
|
|
110 |
typedef unsigned char JOCTET; |
|
111 |
#define GETJOCTET(value) (value) |
|
112 |
|
|
113 |
#else /* not HAVE_UNSIGNED_CHAR */ |
|
114 |
|
|
115 |
typedef char JOCTET; |
|
116 |
#ifdef CHAR_IS_UNSIGNED |
|
117 |
#define GETJOCTET(value) (value) |
|
118 |
#else |
|
119 |
#define GETJOCTET(value) ((value) & 0xFF) |
|
120 |
#endif /* CHAR_IS_UNSIGNED */ |
|
121 |
|
|
122 |
#endif /* HAVE_UNSIGNED_CHAR */ |
|
123 |
|
|
124 |
|
|
125 |
/* These typedefs are used for various table entries and so forth. |
|
126 |
* They must be at least as wide as specified; but making them too big |
|
127 |
* won't cost a huge amount of memory, so we don't provide special |
|
128 |
* extraction code like we did for JSAMPLE. (In other words, these |
|
129 |
* typedefs live at a different point on the speed/space tradeoff curve.) |
|
130 |
*/ |
|
131 |
|
|
132 |
/* UINT8 must hold at least the values 0..255. */ |
|
133 |
|
|
134 |
#ifdef HAVE_UNSIGNED_CHAR |
|
135 |
typedef unsigned char UINT8; |
|
136 |
#else /* not HAVE_UNSIGNED_CHAR */ |
|
137 |
#ifdef CHAR_IS_UNSIGNED |
|
138 |
typedef char UINT8; |
|
139 |
#else /* not CHAR_IS_UNSIGNED */ |
|
140 |
typedef short UINT8; |
|
141 |
#endif /* CHAR_IS_UNSIGNED */ |
|
142 |
#endif /* HAVE_UNSIGNED_CHAR */ |
|
143 |
|
|
144 |
/* UINT16 must hold at least the values 0..65535. */ |
|
145 |
|
|
146 |
#ifdef HAVE_UNSIGNED_SHORT |
|
147 |
typedef unsigned short UINT16; |
|
148 |
#else /* not HAVE_UNSIGNED_SHORT */ |
|
149 |
typedef unsigned int UINT16; |
|
150 |
#endif /* HAVE_UNSIGNED_SHORT */ |
|
151 |
|
|
152 |
/* INT16 must hold at least the values -32768..32767. */ |
|
153 |
|
|
154 |
#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ |
|
155 |
typedef short INT16; |
|
156 |
#endif |
|
157 |
|
|
158 |
/* INT32 must hold at least signed 32-bit values. */ |
|
159 |
|
|
160 |
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ |
|
161 |
typedef long INT32; |
|
162 |
#endif |
|
163 |
|
|
164 |
/* Datatype used for image dimensions. The JPEG standard only supports |
|
165 |
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore |
|
166 |
* "unsigned int" is sufficient on all machines. However, if you need to |
|
167 |
* handle larger images and you don't mind deviating from the spec, you |
|
168 |
* can change this datatype. |
|
169 |
*/ |
|
170 |
|
|
171 |
typedef unsigned int JDIMENSION; |
|
172 |
|
|
173 |
#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ |
|
174 |
|
|
175 |
|
|
176 |
/* These macros are used in all function definitions and extern declarations. |
|
177 |
* You could modify them if you need to change function linkage conventions; |
|
178 |
* in particular, you'll need to do that to make the library a Windows DLL. |
|
179 |
* Another application is to make all functions global for use with debuggers |
|
180 |
* or code profilers that require it. |
|
181 |
*/ |
|
182 |
|
|
183 |
/* a function called through method pointers: */ |
|
184 |
#define METHODDEF(type) static type |
|
185 |
/* a function used only in its module: */ |
|
186 |
#define LOCAL(type) static type |
|
187 |
/* a function referenced thru EXTERNs: */ |
|
188 |
#define GLOBAL(type) type |
|
189 |
/* a reference to a GLOBAL function: */ |
|
190 |
#define EXTERN(type) extern type |
|
191 |
|
|
192 |
|
|
193 |
/* This macro is used to declare a "method", that is, a function pointer. |
|
194 |
* We want to supply prototype parameters if the compiler can cope. |
|
195 |
* Note that the arglist parameter must be parenthesized! |
|
196 |
* Again, you can customize this if you need special linkage keywords. |
|
197 |
*/ |
|
198 |
|
|
199 |
#ifdef HAVE_PROTOTYPES |
|
200 |
#define JMETHOD(type,methodname,arglist) type (*methodname) arglist |
|
201 |
#else |
|
202 |
#define JMETHOD(type,methodname,arglist) type (*methodname) () |
|
203 |
#endif |
|
204 |
|
|
205 |
|
|
206 |
/* Here is the pseudo-keyword for declaring pointers that must be "far" |
|
207 |
* on 80x86 machines. Most of the specialized coding for 80x86 is handled |
|
208 |
* by just saying "FAR *" where such a pointer is needed. In a few places |
|
209 |
* explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. |
|
210 |
*/ |
|
211 |
|
|
212 |
#ifdef NEED_FAR_POINTERS |
|
213 |
#define FAR far |
|
214 |
#else |
|
215 |
#define FAR |
|
216 |
#endif |
|
217 |
|
|
218 |
|
|
219 |
/* |
|
220 |
* On a few systems, type boolean and/or its values FALSE, TRUE may appear |
|
221 |
* in standard header files. Or you may have conflicts with application- |
|
222 |
* specific header files that you want to include together with these files. |
|
223 |
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work. |
|
224 |
*/ |
|
225 |
|
|
226 |
#ifndef HAVE_BOOLEAN |
|
227 |
typedef int boolean; |
|
228 |
#endif |
|
229 |
#ifndef FALSE /* in case these macros already exist */ |
|
230 |
#define FALSE 0 /* values of boolean */ |
|
231 |
#endif |
|
232 |
#ifndef TRUE |
|
233 |
#define TRUE 1 |
|
234 |
#endif |
|
235 |
|
|
236 |
|
|
237 |
/* |
|
238 |
* The remaining options affect code selection within the JPEG library, |
|
239 |
* but they don't need to be visible to most applications using the library. |
|
240 |
* To minimize application namespace pollution, the symbols won't be |
|
241 |
* defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. |
|
242 |
*/ |
|
243 |
|
|
244 |
#ifdef JPEG_INTERNALS |
|
245 |
#define JPEG_INTERNAL_OPTIONS |
|
246 |
#endif |
|
247 |
|
|
248 |
#ifdef JPEG_INTERNAL_OPTIONS |
|
249 |
|
|
250 |
|
|
251 |
/* |
|
252 |
* These defines indicate whether to include various optional functions. |
|
253 |
* Undefining some of these symbols will produce a smaller but less capable |
|
254 |
* library. Note that you can leave certain source files out of the |
|
255 |
* compilation/linking process if you've #undef'd the corresponding symbols. |
|
256 |
* (You may HAVE to do that if your compiler doesn't like null source files.) |
|
257 |
*/ |
|
258 |
|
|
259 |
/* Arithmetic coding is unsupported for legal reasons. Complaints to IBM. */ |
|
260 |
|
|
261 |
/* Capability options common to encoder and decoder: */ |
|
262 |
|
|
263 |
#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ |
|
264 |
#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ |
|
265 |
#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ |
|
266 |
|
|
267 |
/* Encoder capability options: */ |
|
268 |
|
|
269 |
#undef C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ |
|
270 |
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ |
|
271 |
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ |
|
272 |
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ |
|
273 |
/* Note: if you selected 12-bit data precision, it is dangerous to turn off |
|
274 |
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit |
|
275 |
* precision, so jchuff.c normally uses entropy optimization to compute |
|
276 |
* usable tables for higher precision. If you don't want to do optimization, |
|
277 |
* you'll have to supply different default Huffman tables. |
|
278 |
* The exact same statements apply for progressive JPEG: the default tables |
|
279 |
* don't work for progressive mode. (This may get fixed, however.) |
|
280 |
*/ |
|
281 |
#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ |
|
282 |
|
|
283 |
/* Decoder capability options: */ |
|
284 |
|
|
285 |
#undef D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ |
|
286 |
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ |
|
287 |
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ |
|
288 |
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ |
|
289 |
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ |
|
290 |
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ |
|
291 |
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ |
|
292 |
#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ |
|
293 |
#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ |
|
294 |
#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ |
|
295 |
|
|
296 |
/* more capability options later, no doubt */ |
|
297 |
|
|
298 |
|
|
299 |
/* |
|
300 |
* Ordering of RGB data in scanlines passed to or from the application. |
|
301 |
* If your application wants to deal with data in the order B,G,R, just |
|
302 |
* change these macros. You can also deal with formats such as R,G,B,X |
|
303 |
* (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing |
|
304 |
* the offsets will also change the order in which colormap data is organized. |
|
305 |
* RESTRICTIONS: |
|
306 |
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. |
|
307 |
* 2. These macros only affect RGB<=>YCbCr color conversion, so they are not |
|
308 |
* useful if you are using JPEG color spaces other than YCbCr or grayscale. |
|
309 |
* 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE |
|
310 |
* is not 3 (they don't understand about dummy color components!). So you |
|
311 |
* can't use color quantization if you change that value. |
|
312 |
*/ |
|
313 |
|
|
314 |
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ |
|
315 |
#define RGB_GREEN 1 /* Offset of Green */ |
|
316 |
#define RGB_BLUE 2 /* Offset of Blue */ |
|
317 |
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ |
|
318 |
|
|
319 |
|
|
320 |
/* Definitions for speed-related optimizations. */ |
|
321 |
|
|
322 |
|
|
323 |
/* If your compiler supports inline functions, define INLINE |
|
324 |
* as the inline keyword; otherwise define it as empty. |
|
325 |
*/ |
|
326 |
|
|
327 |
#ifndef INLINE |
|
328 |
#ifdef __GNUC__ /* for instance, GNU C knows about inline */ |
|
329 |
#define INLINE __inline__ |
|
330 |
#endif |
|
331 |
#ifndef INLINE |
|
332 |
#define INLINE /* default is to define it as empty */ |
|
333 |
#endif |
|
334 |
#endif |
|
335 |
|
|
336 |
|
|
337 |
/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying |
|
338 |
* two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER |
|
339 |
* as short on such a machine. MULTIPLIER must be at least 16 bits wide. |
|
340 |
*/ |
|
341 |
|
|
342 |
#ifndef MULTIPLIER |
|
343 |
#define MULTIPLIER int /* type for fastest integer multiply */ |
|
344 |
#endif |
|
345 |
|
|
346 |
|
|
347 |
/* FAST_FLOAT should be either float or double, whichever is done faster |
|
348 |
* by your compiler. (Note that this type is only used in the floating point |
|
349 |
* DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) |
|
350 |
* Typically, float is faster in ANSI C compilers, while double is faster in |
|
351 |
* pre-ANSI compilers (because they insist on converting to double anyway). |
|
352 |
* The code below therefore chooses float if we have ANSI-style prototypes. |
|
353 |
*/ |
|
354 |
|
|
355 |
#ifndef FAST_FLOAT |
|
356 |
#ifdef HAVE_PROTOTYPES |
|
357 |
#define FAST_FLOAT float |
|
358 |
#else |
|
359 |
#define FAST_FLOAT double |
|
360 |
#endif |
|
361 |
#endif |
|
362 |
|
|
363 |
#endif /* JPEG_INTERNAL_OPTIONS */ |
trunk/code/projects/colonet/server/vision/capturetest.c | ||
---|---|---|
1 |
#include "vision.h" |
|
2 |
|
|
3 |
#include <cv.h> |
|
4 |
#include <highgui.h> |
|
5 |
|
|
6 |
#include <stdio.h> |
|
7 |
|
|
8 |
#define MINH 50 //min threshold level |
|
9 |
#define MAXH 75 //max threshold level |
|
10 |
|
|
11 |
#define MIN_BOX_WIDTH 10 |
|
12 |
#define MAX_BOX_WIDTH 20 |
|
13 |
#define MIN_BOX_HEIGHT 10 |
|
14 |
#define MAX_BOX_HEIGHT 20 |
|
15 |
|
|
16 |
#define BEST_CENTER_PADDING_X 9 |
|
17 |
#define BEST_CENTER_PADDING_Y 9 |
|
18 |
|
|
19 |
#define ELLIPSE_COUNT_TO_BE_OBJECT 7 |
|
20 |
|
|
21 |
struct CenterP { |
|
22 |
CvPoint center; |
|
23 |
int count; |
|
24 |
}; |
|
25 |
|
|
26 |
static CvCapture *capture; |
|
27 |
|
|
28 |
void compute(aTYPE *a, int length, IplImage* image, IplImage* out) |
|
29 |
{ |
|
30 |
int *values = (int*)out->imageData; |
|
31 |
|
|
32 |
for(int y = 0; y < image->height; y++) |
|
33 |
{ |
|
34 |
for(int x = 0; x < image->width; x++) |
|
35 |
{ |
|
36 |
bool d = ((uchar*)(image->imageData + image->widthStep*y))[x] > 0; |
|
37 |
if(!d) continue; |
|
38 |
for(int i = 0; i < length; i++) |
|
39 |
{ |
|
40 |
int centerj = y + a[i].rhoj; |
|
41 |
int centeri = x + a[i].thetaj; |
|
42 |
if(centerj < 0 || centerj >= image->height || centeri < 0 || centeri >= image->width) |
|
43 |
continue; |
|
44 |
values[centerj * image->width + centeri]++; |
|
45 |
} |
|
46 |
} |
|
47 |
} |
|
48 |
} |
|
49 |
void circleTransform(IplImage* image, IplImage* out, int radius) |
|
50 |
{ |
|
51 |
int amax = 8 * radius; |
|
52 |
aTYPE *a = (aTYPE*)malloc(sizeof(aTYPE) * amax); |
|
53 |
int i = 0; |
|
54 |
for(int j = 0; j < amax; j++) |
|
55 |
{ |
|
56 |
double theta = (6.2831853071795862 * ((double)j)) / ((double)amax); |
|
57 |
int rhoj = (int)cvRound(radius * cos(theta)); |
|
58 |
int thetaj = (int)cvRound(radius * sin(theta)); |
|
59 |
if(i == 0 || rhoj != a[i].rhoj && thetaj != a[i].thetaj) |
|
60 |
{ |
|
61 |
a[i].rhoj = rhoj; |
|
62 |
a[i].thetaj = thetaj; |
|
63 |
i++; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
compute(a, amax, image, out); |
|
68 |
free(a); |
|
69 |
} |
|
70 |
|
|
71 |
// A Simple Camera Capture Framework |
|
72 |
int main() { |
|
73 |
|
|
74 |
unsigned char buffer[150000]; |
|
75 |
int written; |
|
76 |
|
|
77 |
CvCapture* capture = cvCaptureFromCAM( -1 ); |
|
78 |
if( !capture ) { |
|
79 |
fprintf( stderr, "ERROR: capture is NULL \n" ); |
|
80 |
getchar(); |
|
81 |
return -1; |
|
82 |
} |
|
83 |
|
|
84 |
// Create a window in which the captured images will be presented |
|
85 |
cvNamedWindow( "mywindow1", CV_WINDOW_AUTOSIZE ); |
|
86 |
cvNamedWindow( "mywindow2", CV_WINDOW_AUTOSIZE ); |
|
87 |
//cvNamedWindow( "mywindow3", CV_WINDOW_AUTOSIZE ); |
|
88 |
//cvNamedWindow( "mywindow4", CV_WINDOW_AUTOSIZE ); |
|
89 |
//cvNamedWindow( "mywindow5", CV_WINDOW_AUTOSIZE ); |
|
90 |
//cvNamedWindow( "mywindow6", CV_WINDOW_AUTOSIZE ); |
|
91 |
//cvNamedWindow( "mywindow7", CV_WINDOW_AUTOSIZE ); |
|
92 |
|
|
93 |
|
|
94 |
// Show the image captured from the camera in the window and repeat |
|
95 |
while( 1 ) { |
|
96 |
IplImage *image03, *image04; |
|
97 |
IplImage *im_capture; |
|
98 |
|
|
99 |
if(!cvGrabFrame(capture)){ // capture a frame |
|
100 |
printf("Could not grab a frame\n\7"); |
|
101 |
exit(0); |
|
102 |
} |
|
103 |
im_capture=cvRetrieveFrame(capture); // retrieve the captured frame |
|
104 |
|
|
105 |
image03 = cvCreateImage(cvGetSize(im_capture), im_capture->depth, 1); |
|
106 |
cvCvtColor(im_capture, image03, CV_RGB2GRAY); |
|
107 |
|
|
108 |
/*/ load image and force it to be grayscale |
|
109 |
if ((image03 = cvLoadImage(filename, 0)) == 0) { |
|
110 |
fprintf(stderr, "Failed to load image.\n"); |
|
111 |
return -1; |
|
112 |
}*/ |
|
113 |
|
|
114 |
// Create the destination images |
|
115 |
IplImage* image02 = cvCloneImage(image03); |
|
116 |
|
|
117 |
// Create dynamic structure and sequence. |
|
118 |
CvMemStorage* stor = cvCreateMemStorage(0); |
|
119 |
CvSeq* cont = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint) , stor); |
|
120 |
|
|
121 |
struct CenterP bestc[100]; |
|
122 |
int index=0; |
|
123 |
|
|
124 |
// Threshold the source image. This needful for cvFindContours(). |
|
125 |
cvCanny(image03, image02, 50, 100); |
|
126 |
cvDilate(image02, image02); |
|
127 |
|
|
128 |
cvShowImage( "mywindow2", image02 ); |
|
129 |
|
|
130 |
// Find all contours. |
|
131 |
cvFindContours(image02, stor, &cont, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_NONE, cvPoint(0,0)); |
|
132 |
|
|
133 |
// Clear images. IPL use. |
|
134 |
cvZero(image02); |
|
135 |
|
|
136 |
// This cycle draw all contours and approximate it by ellipses. |
|
137 |
for(; cont; cont = cont->h_next) { |
|
138 |
int i; // Indicator of cycle. |
|
139 |
int count = cont->total; // This is number point in contour |
|
140 |
CvPoint center; |
|
141 |
CvSize size; |
|
142 |
|
|
143 |
// Number point must be more than or equal to 6 (for cvFitEllipse_32f). |
|
144 |
if (count < 6) continue; |
|
145 |
|
|
146 |
// Alloc memory for contour point set. |
|
147 |
CvPoint* PointArray = (CvPoint*) malloc(count * sizeof(CvPoint)); |
|
148 |
CvPoint2D32f* PointArray2D32f= (CvPoint2D32f*) malloc(count * sizeof(CvPoint2D32f)); |
|
149 |
|
|
150 |
// Alloc memory for ellipse data. |
|
151 |
CvBox2D32f* box = (CvBox2D32f*)malloc(sizeof(CvBox2D32f)); |
|
152 |
|
|
153 |
/* Use Hough Transform to check circularity of contours, threshold Hough space |
|
154 |
Second gen (?): Use Harr cascade on bot shape */ |
|
155 |
|
|
156 |
/*for( ; cont != 0; cont = cont->h_next ) |
|
157 |
{ |
|
158 |
CvRect rect = ((CvContour*)cont)->rect; |
|
159 |
if (rect.width < RADIUS - R_ERROR || rect.height < RADIUS - R_ERROR) continue; |
|
160 |
|
|
161 |
cvZero(imageBlobs); |
|
162 |
cvZero(imageOutlines); |
|
163 |
cvDrawContours( imageOutlines, contour, CV_RGB(255,255,255), CV_RGB(255,255,255), -1, 1, 8 ); |
|
164 |
cvDrawContours( imageBlobs, contour, CV_RGB(255,255,255), CV_RGB(255,255,255), -1, CV_FILLED, 8 ); |
|
165 |
|
|
166 |
CvScalar drawcolor = CV_RGB( rand()&255, rand()&255, rand()&255 ); |
|
167 |
cvDrawContours( imageCircles, contour, drawcolor, drawcolor, -1, CV_FILLED, 8 ); |
|
168 |
}*/ |
|
169 |
|
|
170 |
// Get contour point set. |
|
171 |
cvCvtSeqToArray(cont, PointArray, CV_WHOLE_SEQ); |
|
172 |
|
|
173 |
// Convert CvPoint set to CvBox2D32f set. |
|
174 |
for(i=0; i<count; i++) { |
|
175 |
PointArray2D32f[i].x = (float)PointArray[i].x; |
|
176 |
PointArray2D32f[i].y = (float)PointArray[i].y; |
|
177 |
} |
|
178 |
|
|
179 |
// Fits ellipse to current contour. |
|
180 |
cvFitEllipse(PointArray2D32f, count, box); |
|
181 |
|
|
182 |
// Convert ellipse data from float to integer representation. |
|
183 |
center.x = cvRound(box->center.x); |
|
184 |
center.y = cvRound(box->center.y); |
|
185 |
size.width = cvRound(box->size.width*0.5); |
|
186 |
size.height = cvRound(box->size.height*0.5); |
|
187 |
box->angle = -box->angle; |
|
188 |
|
|
189 |
if (size.width > MIN_BOX_WIDTH && size.height > MIN_BOX_HEIGHT |
|
190 |
&& size.width < MAX_BOX_WIDTH && size.height < MAX_BOX_HEIGHT){ |
|
191 |
//printf("%d %d %d %d\n",center.x,center.y,size.width,size.height); |
|
192 |
|
|
193 |
int found=0, j; |
|
194 |
for (j = 0; j < index; j++) { |
|
195 |
if (abs(bestc[j].center.x-center.x) < BEST_CENTER_PADDING_X |
|
196 |
&& abs(bestc[j].center.y-center.y) < BEST_CENTER_PADDING_Y) { |
|
197 |
bestc[j].count++; |
|
198 |
found=1; |
|
199 |
break; |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
if (!found){ |
|
204 |
struct CenterP c; |
|
205 |
c.center=center; |
|
206 |
c.count=1; |
|
207 |
bestc[index]=c; |
|
208 |
index++; |
|
209 |
} |
|
210 |
} |
|
211 |
|
|
212 |
// Free memory. |
|
213 |
free(PointArray); |
|
214 |
free(PointArray2D32f); |
|
215 |
free(box); |
|
216 |
} |
|
217 |
|
|
218 |
image04 = cvCloneImage(image03); |
|
219 |
cvZero(image04); |
|
220 |
|
|
221 |
int i; |
|
222 |
for (i = 0; i < index; i++) { |
|
223 |
//if (bestc[i].count > ELLIPSE_COUNT_TO_BE_OBJECT){ |
|
224 |
cvCircle(image04, bestc[i].center, 20, CV_RGB(0,0,0), 5, 8, 0); |
|
225 |
//} |
|
226 |
} |
|
227 |
|
|
228 |
cvReleaseImage(&image02); |
|
229 |
cvReleaseImage(&image03); |
|
230 |
|
|
231 |
// Show image. HighGUI use. |
|
232 |
cvShowImage( "mywindow1", image04 ); |
|
233 |
|
|
234 |
cvReleaseImage(&image04); |
|
235 |
|
|
236 |
cvReleaseMemStorage(&stor); |
|
237 |
|
|
238 |
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version), |
|
239 |
//remove higher bits using AND operator |
|
240 |
if( (cvWaitKey(0) & 255) == 27 ) break; |
|
241 |
} |
|
242 |
|
|
243 |
// Release the capture device housekeeping |
|
244 |
cvReleaseCapture( &capture ); |
|
245 |
|
|
246 |
cvDestroyWindow( "mywindow1" ); |
|
247 |
cvDestroyWindow( "mywindow2" ); |
|
248 |
cvDestroyWindow( "mywindow3" ); |
|
249 |
cvDestroyWindow( "mywindow4" ); |
|
250 |
cvDestroyWindow( "mywindow5" ); |
|
251 |
cvDestroyWindow( "mywindow6" ); |
|
252 |
cvDestroyWindow( "mywindow7" ); |
|
253 |
return 0; |
|
254 |
} |
trunk/code/projects/colonet/server/vision/vision.c | ||
---|---|---|
6 | 6 |
* @date 11/18/2007 |
7 | 7 |
*/ |
8 | 8 |
|
9 |
#include <vision.h>
|
|
9 |
#include "vision.h"
|
|
10 | 10 |
|
11 | 11 |
#include <cv.h> |
12 | 12 |
#include <highgui.h> |
... | ... | |
27 | 27 |
|
28 | 28 |
#define ELLIPSE_COUNT_TO_BE_OBJECT 7 |
29 | 29 |
|
30 |
#define DEBUG 0 //Debug to find threshold level
|
|
30 |
#define DEBUG 1 //Debug to find threshold level
|
|
31 | 31 |
|
32 |
int write_JPEG_to_mem (unsigned char *storage, int length, IplImage *img, int quality); |
|
33 |
|
|
32 | 34 |
struct CenterP { |
33 | 35 |
CvPoint center; |
34 | 36 |
int count; |
35 | 37 |
}; |
36 | 38 |
|
37 |
static char* filename;
|
|
39 |
/*static char* filename;*/
|
|
38 | 40 |
|
39 |
int vision_init(char* filename_) { |
|
40 |
filename = filename_; |
|
41 |
static CvCapture *capture; |
|
42 |
|
|
43 |
int vision_init(/*char* filename_*/) { |
|
44 |
/*filename = filename_;*/ |
|
45 |
|
|
46 |
if (DEBUG) |
|
47 |
cvNamedWindow("Result", CV_WINDOW_AUTOSIZE); |
|
48 |
|
|
49 |
//TODO: replace with 1394 capture so we don't have to use Coriander |
|
50 |
capture = cvCreateCameraCapture(-1); |
|
51 |
|
|
52 |
if( !capture ) { |
|
53 |
fprintf( stderr, "ERROR: capture is NULL \n" ); |
|
54 |
return -1; |
|
55 |
} |
|
56 |
|
|
41 | 57 |
return 0; |
42 | 58 |
} |
43 | 59 |
|
60 |
void vision_close() |
|
61 |
{ |
|
62 |
if (DEBUG) |
|
63 |
cvDestroyWindow("Result"); |
|
64 |
|
|
65 |
cvReleaseCapture(&capture); |
|
66 |
} |
|
67 |
|
|
68 |
int getImageBytes(unsigned char *buffer, int length) |
|
69 |
{ |
|
70 |
IplImage* im_capture; |
|
71 |
|
|
72 |
if(!cvGrabFrame(capture)){ // capture a frame |
|
73 |
printf("Could not grab a frame\n\7"); |
|
74 |
exit(0); |
|
75 |
} |
|
76 |
im_capture=cvRetrieveFrame(capture); // retrieve the captured frame |
|
77 |
|
|
78 |
return write_JPEG_to_mem (buffer, length, im_capture, 30); |
|
79 |
} |
|
80 |
|
|
44 | 81 |
int vision_get_robot_positions(VisionPosition** positions) { |
45 | 82 |
IplImage* image03; |
83 |
|
|
84 |
IplImage* im_capture; |
|
85 |
|
|
86 |
if(!cvGrabFrame(capture)){ // capture a frame |
|
87 |
printf("Could not grab a frame\n\7"); |
|
88 |
exit(0); |
|
89 |
} |
|
90 |
im_capture=cvRetrieveFrame(capture); // retrieve the captured frame |
|
91 |
|
|
92 |
image03 = cvCreateImage(cvGetSize(im_capture), im_capture->depth, 1); |
|
93 |
cvCvtColor(im_capture, image03, CV_RGB2GRAY); |
|
46 | 94 |
|
47 |
// load image and force it to be grayscale |
|
95 |
/*/ load image and force it to be grayscale
|
|
48 | 96 |
if ((image03 = cvLoadImage(filename, 0)) == 0) { |
49 | 97 |
fprintf(stderr, "Failed to load image.\n"); |
50 | 98 |
return -1; |
51 |
} |
|
99 |
}*/
|
|
52 | 100 |
|
53 | 101 |
// Create the destination images |
54 | 102 |
IplImage* image02 = cvCloneImage(image03); |
55 | 103 |
IplImage* image04 = cvCloneImage(image03); |
56 | 104 |
|
57 |
if (DEBUG) cvNamedWindow("Result", 1); |
|
58 |
|
|
59 | 105 |
// Create dynamic structure and sequence. |
60 | 106 |
CvMemStorage* stor = cvCreateMemStorage(0); |
61 | 107 |
CvSeq* cont = cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvSeq), sizeof(CvPoint) , stor); |
62 | 108 |
|
63 | 109 |
struct CenterP bestc[100]; |
64 | 110 |
int index=0; |
111 |
int h; |
|
65 | 112 |
|
66 |
for (int h = MINH; h < MAXH; h++) {
|
|
113 |
for (h = MINH; h < MAXH; h++) { |
|
67 | 114 |
// Threshold the source image. This needful for cvFindContours(). |
68 | 115 |
cvThreshold(image03, image02, h, 255, CV_THRESH_BINARY); |
69 | 116 |
|
... | ... | |
167 | 214 |
} |
168 | 215 |
} |
169 | 216 |
|
170 |
if (DEBUG) cvWaitKey(0); |
|
171 |
|
|
172 | 217 |
cvReleaseImage(&image02); |
173 | 218 |
cvReleaseImage(&image03); |
174 | 219 |
|
175 |
if (DEBUG) cvDestroyWindow("Result"); |
|
176 |
|
|
177 | 220 |
// Show image. HighGUI use. |
178 | 221 |
if (DEBUG) cvShowImage( "Result", image04 ); |
179 | 222 |
|
trunk/code/projects/colonet/server/vision/savetonetwork.c | ||
---|---|---|
1 |
#include <stdio.h> |
|
2 |
#include "jpeglib.h" |
|
3 |
#include <cv.h> |
|
4 |
#include "vision.h" |
|
5 |
#include "memdst.h" |
|
6 |
|
|
7 |
int write_JPEG_to_mem (unsigned char *storage, int length, IplImage *_img, int quality) |
|
8 |
{ |
|
9 |
struct jpeg_compress_struct cinfo; |
|
10 |
struct jpeg_error_mgr jerr; |
|
11 |
JSAMPROW row_pointer[1]; |
|
12 |
|
|
13 |
int numBytes = -1; //size of jpeg after compression |
|
14 |
|
|
15 |
IplImage *img; |
|
16 |
|
|
17 |
img = cvCloneImage(_img); |
|
18 |
cvCvtColor(_img, img, CV_RGB2BGR); |
|
19 |
|
|
20 |
cinfo.err = jpeg_std_error(&jerr); |
|
21 |
|
|
22 |
jpeg_create_compress(&cinfo); |
|
23 |
|
|
24 |
jpeg_memory_dest(&cinfo,(JOCTET*)storage,length,&numBytes); |
|
25 |
|
|
26 |
cinfo.image_width = img->width; |
|
27 |
cinfo.image_height = img->height; |
|
28 |
cinfo.input_components = img->nChannels; |
|
29 |
cinfo.in_color_space = JCS_RGB; |
|
30 |
|
|
31 |
jpeg_set_defaults(&cinfo); |
|
32 |
jpeg_set_quality(&cinfo, quality, TRUE ); |
|
33 |
|
|
34 |
jpeg_start_compress(&cinfo, TRUE); |
|
35 |
|
|
36 |
while (cinfo.next_scanline < cinfo.image_height) { |
|
37 |
row_pointer[0] = (unsigned char *)(img->imageData + cinfo.next_scanline * img->widthStep); |
|
38 |
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1); |
|
39 |
} |
|
40 |
|
|
41 |
jpeg_finish_compress(&cinfo); |
|
42 |
jpeg_destroy_compress(&cinfo); |
|
43 |
|
|
44 |
return numBytes; |
|
45 |
} |
|
46 |
|
trunk/code/projects/colonet/server/vision/vision.h | ||
---|---|---|
10 | 10 |
int y; |
11 | 11 |
} VisionPosition; |
12 | 12 |
|
13 |
int vision_init(char* filename); |
|
13 |
int vision_init(/*char* filename*/); |
|
14 |
void vision_close(void); |
|
14 | 15 |
int vision_get_robot_positions(VisionPosition** positions); |
16 |
int getImageBytes(unsigned char *buffer, int length); |
|
15 | 17 |
|
16 | 18 |
#endif |
trunk/code/projects/colonet/server/vision/jpeglib.h | ||
---|---|---|
1 |
/* |
|
2 |
* jpeglib.h |
|
3 |
* |
|
4 |
* Copyright (C) 1991-1998, Thomas G. Lane. |
|
5 |
* This file is part of the Independent JPEG Group's software. |
|
6 |
* For conditions of distribution and use, see the accompanying README file. |
|
7 |
* |
|
8 |
* This file defines the application interface for the JPEG library. |
|
9 |
* Most applications using the library need only include this file, |
|
10 |
* and perhaps jerror.h if they want to know the exact error codes. |
|
11 |
*/ |
|
12 |
|
|
13 |
#ifndef JPEGLIB_H |
|
14 |
#define JPEGLIB_H |
|
15 |
|
|
16 |
/* |
|
17 |
* First we include the configuration files that record how this |
|
18 |
* installation of the JPEG library is set up. jconfig.h can be |
|
19 |
* generated automatically for many systems. jmorecfg.h contains |
|
20 |
* manual configuration options that most people need not worry about. |
|
21 |
*/ |
|
22 |
|
|
23 |
#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ |
|
24 |
#include "jconfig.h" /* widely used configuration options */ |
|
25 |
#endif |
|
26 |
#include "jmorecfg.h" /* seldom changed options */ |
|
27 |
|
|
28 |
|
|
29 |
/* Version ID for the JPEG library. |
|
30 |
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 60". |
|
31 |
*/ |
|
32 |
|
|
33 |
#define JPEG_LIB_VERSION 62 /* Version 6b */ |
|
34 |
|
|
35 |
|
|
36 |
/* Various constants determining the sizes of things. |
|
37 |
* All of these are specified by the JPEG standard, so don't change them |
|
38 |
* if you want to be compatible. |
|
39 |
*/ |
|
40 |
|
|
41 |
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */ |
|
42 |
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ |
|
43 |
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ |
|
44 |
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ |
|
45 |
#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ |
|
46 |
#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ |
|
47 |
#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ |
|
48 |
/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; |
|
49 |
* the PostScript DCT filter can emit files with many more than 10 blocks/MCU. |
|
50 |
* If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU |
|
51 |
* to handle it. We even let you do this from the jconfig.h file. However, |
|
52 |
* we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe |
|
53 |
* sometimes emits noncompliant files doesn't mean you should too. |
|
54 |
*/ |
|
55 |
#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ |
|
56 |
#ifndef D_MAX_BLOCKS_IN_MCU |
|
57 |
#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ |
|
58 |
#endif |
|
59 |
|
|
60 |
|
|
61 |
/* Data structures for images (arrays of samples and of DCT coefficients). |
|
62 |
* On 80x86 machines, the image arrays are too big for near pointers, |
|
63 |
* but the pointer arrays can fit in near memory. |
|
64 |
*/ |
|
65 |
|
|
66 |
typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ |
|
67 |
typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ |
|
68 |
typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ |
|
69 |
|
|
70 |
typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ |
|
71 |
typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ |
|
72 |
typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ |
|
73 |
typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ |
|
74 |
|
|
75 |
typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ |
|
76 |
|
|
77 |
|
|
78 |
/* Types for JPEG compression parameters and working tables. */ |
|
79 |
|
|
80 |
|
|
81 |
/* DCT coefficient quantization tables. */ |
|
82 |
|
|
83 |
typedef struct { |
|
84 |
/* This array gives the coefficient quantizers in natural array order |
|
85 |
* (not the zigzag order in which they are stored in a JPEG DQT marker). |
|
86 |
* CAUTION: IJG versions prior to v6a kept this array in zigzag order. |
|
87 |
*/ |
|
88 |
UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ |
|
89 |
/* This field is used only during compression. It's initialized FALSE when |
|
90 |
* the table is created, and set TRUE when it's been output to the file. |
|
91 |
* You could suppress output of a table by setting this to TRUE. |
|
92 |
* (See jpeg_suppress_tables for an example.) |
|
93 |
*/ |
|
94 |
boolean sent_table; /* TRUE when table has been output */ |
|
95 |
} JQUANT_TBL; |
|
96 |
|
|
97 |
|
|
98 |
/* Huffman coding tables. */ |
|
99 |
|
|
100 |
typedef struct { |
|
101 |
/* These two fields directly represent the contents of a JPEG DHT marker */ |
|
102 |
UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ |
|
103 |
/* length k bits; bits[0] is unused */ |
|
104 |
UINT8 huffval[256]; /* The symbols, in order of incr code length */ |
|
105 |
/* This field is used only during compression. It's initialized FALSE when |
|
106 |
* the table is created, and set TRUE when it's been output to the file. |
|
107 |
* You could suppress output of a table by setting this to TRUE. |
|
108 |
* (See jpeg_suppress_tables for an example.) |
|
109 |
*/ |
|
110 |
boolean sent_table; /* TRUE when table has been output */ |
|
111 |
} JHUFF_TBL; |
|
112 |
|
|
113 |
|
|
114 |
/* Basic info about one component (color channel). */ |
|
115 |
|
|
116 |
typedef struct { |
|
117 |
/* These values are fixed over the whole image. */ |
|
118 |
/* For compression, they must be supplied by parameter setup; */ |
|
119 |
/* for decompression, they are read from the SOF marker. */ |
|
120 |
int component_id; /* identifier for this component (0..255) */ |
|
121 |
int component_index; /* its index in SOF or cinfo->comp_info[] */ |
|
122 |
int h_samp_factor; /* horizontal sampling factor (1..4) */ |
|
123 |
int v_samp_factor; /* vertical sampling factor (1..4) */ |
|
124 |
int quant_tbl_no; /* quantization table selector (0..3) */ |
|
125 |
/* These values may vary between scans. */ |
|
126 |
/* For compression, they must be supplied by parameter setup; */ |
|
127 |
/* for decompression, they are read from the SOS marker. */ |
|
128 |
/* The decompressor output side may not use these variables. */ |
|
129 |
int dc_tbl_no; /* DC entropy table selector (0..3) */ |
|
130 |
int ac_tbl_no; /* AC entropy table selector (0..3) */ |
|
131 |
|
|
132 |
/* Remaining fields should be treated as private by applications. */ |
|
133 |
|
|
134 |
/* These values are computed during compression or decompression startup: */ |
|
135 |
/* Component's size in DCT blocks. |
|
136 |
* Any dummy blocks added to complete an MCU are not counted; therefore |
|
137 |
* these values do not depend on whether a scan is interleaved or not. |
|
138 |
*/ |
|
139 |
JDIMENSION width_in_blocks; |
|
140 |
JDIMENSION height_in_blocks; |
|
141 |
/* Size of a DCT block in samples. Always DCTSIZE for compression. |
|
142 |
* For decompression this is the size of the output from one DCT block, |
|
143 |
* reflecting any scaling we choose to apply during the IDCT step. |
|
144 |
* Values of 1,2,4,8 are likely to be supported. Note that different |
|
145 |
* components may receive different IDCT scalings. |
|
146 |
*/ |
|
147 |
int DCT_scaled_size; |
|
148 |
/* The downsampled dimensions are the component's actual, unpadded number |
|
149 |
* of samples at the main buffer (preprocessing/compression interface), thus |
|
150 |
* downsampled_width = ceil(image_width * Hi/Hmax) |
|
151 |
* and similarly for height. For decompression, IDCT scaling is included, so |
|
152 |
* downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE) |
|
153 |
*/ |
|
154 |
JDIMENSION downsampled_width; /* actual width in samples */ |
|
155 |
JDIMENSION downsampled_height; /* actual height in samples */ |
|
156 |
/* This flag is used only for decompression. In cases where some of the |
|
157 |
* components will be ignored (eg grayscale output from YCbCr image), |
|
158 |
* we can skip most computations for the unused components. |
|
159 |
*/ |
|
160 |
boolean component_needed; /* do we need the value of this component? */ |
|
161 |
|
|
162 |
/* These values are computed before starting a scan of the component. */ |
|
163 |
/* The decompressor output side may not use these variables. */ |
|
164 |
int MCU_width; /* number of blocks per MCU, horizontally */ |
|
165 |
int MCU_height; /* number of blocks per MCU, vertically */ |
|
166 |
int MCU_blocks; /* MCU_width * MCU_height */ |
|
167 |
int MCU_sample_width; /* MCU width in samples, MCU_width*DCT_scaled_size */ |
|
168 |
int last_col_width; /* # of non-dummy blocks across in last MCU */ |
|
169 |
int last_row_height; /* # of non-dummy blocks down in last MCU */ |
|
170 |
|
|
171 |
/* Saved quantization table for component; NULL if none yet saved. |
|
172 |
* See jdinput.c comments about the need for this information. |
|
173 |
* This field is currently used only for decompression. |
|
174 |
*/ |
|
175 |
JQUANT_TBL * quant_table; |
|
176 |
|
|
177 |
/* Private per-component storage for DCT or IDCT subsystem. */ |
|
178 |
void * dct_table; |
|
179 |
} jpeg_component_info; |
|
180 |
|
|
181 |
|
|
182 |
/* The script for encoding a multiple-scan file is an array of these: */ |
|
183 |
|
|
184 |
typedef struct { |
|
185 |
int comps_in_scan; /* number of components encoded in this scan */ |
|
186 |
int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ |
|
187 |
int Ss, Se; /* progressive JPEG spectral selection parms */ |
|
188 |
int Ah, Al; /* progressive JPEG successive approx. parms */ |
|
189 |
} jpeg_scan_info; |
|
190 |
|
|
191 |
/* The decompressor can save APPn and COM markers in a list of these: */ |
|
192 |
|
|
193 |
typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; |
|
194 |
|
|
195 |
struct jpeg_marker_struct { |
|
196 |
jpeg_saved_marker_ptr next; /* next in list, or NULL */ |
|
197 |
UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ |
|
198 |
unsigned int original_length; /* # bytes of data in the file */ |
|
199 |
unsigned int data_length; /* # bytes of data saved at data[] */ |
|
200 |
JOCTET FAR * data; /* the data contained in the marker */ |
|
201 |
/* the marker length word is not counted in data_length or original_length */ |
|
202 |
}; |
|
203 |
|
|
204 |
/* Known color spaces. */ |
|
205 |
|
|
206 |
typedef enum { |
|
207 |
JCS_UNKNOWN, /* error/unspecified */ |
|
208 |
JCS_GRAYSCALE, /* monochrome */ |
|
209 |
JCS_RGB, /* red/green/blue */ |
|
210 |
JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ |
|
211 |
JCS_CMYK, /* C/M/Y/K */ |
|
212 |
JCS_YCCK /* Y/Cb/Cr/K */ |
|
213 |
} J_COLOR_SPACE; |
|
214 |
|
|
215 |
/* DCT/IDCT algorithm options. */ |
|
216 |
|
|
217 |
typedef enum { |
|
218 |
JDCT_ISLOW, /* slow but accurate integer algorithm */ |
|
219 |
JDCT_IFAST, /* faster, less accurate integer method */ |
|
220 |
JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ |
|
221 |
} J_DCT_METHOD; |
|
222 |
|
|
223 |
#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ |
|
224 |
#define JDCT_DEFAULT JDCT_ISLOW |
|
225 |
#endif |
|
226 |
#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ |
|
227 |
#define JDCT_FASTEST JDCT_IFAST |
|
228 |
#endif |
|
229 |
|
|
230 |
/* Dithering options for decompression. */ |
|
231 |
|
|
232 |
typedef enum { |
|
233 |
JDITHER_NONE, /* no dithering */ |
|
234 |
JDITHER_ORDERED, /* simple ordered dither */ |
|
235 |
JDITHER_FS /* Floyd-Steinberg error diffusion dither */ |
|
236 |
} J_DITHER_MODE; |
|
237 |
|
|
238 |
|
|
239 |
/* Common fields between JPEG compression and decompression master structs. */ |
|
240 |
|
|
241 |
#define jpeg_common_fields \ |
|
242 |
struct jpeg_error_mgr * err; /* Error handler module */\ |
|
243 |
struct jpeg_memory_mgr * mem; /* Memory manager module */\ |
|
244 |
struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ |
|
245 |
void * client_data; /* Available for use by application */\ |
|
246 |
boolean is_decompressor; /* So common code can tell which is which */\ |
|
247 |
int global_state /* For checking call sequence validity */ |
|
248 |
|
|
249 |
/* Routines that are to be used by both halves of the library are declared |
|
250 |
* to receive a pointer to this structure. There are no actual instances of |
|
251 |
* jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. |
|
252 |
*/ |
|
253 |
struct jpeg_common_struct { |
|
254 |
jpeg_common_fields; /* Fields common to both master struct types */ |
|
255 |
/* Additional fields follow in an actual jpeg_compress_struct or |
|
256 |
* jpeg_decompress_struct. All three structs must agree on these |
|
257 |
* initial fields! (This would be a lot cleaner in C++.) |
|
258 |
*/ |
|
259 |
}; |
|
260 |
|
|
261 |
typedef struct jpeg_common_struct * j_common_ptr; |
|
262 |
typedef struct jpeg_compress_struct * j_compress_ptr; |
|
263 |
typedef struct jpeg_decompress_struct * j_decompress_ptr; |
|
264 |
|
|
265 |
|
|
266 |
/* Master record for a compression instance */ |
|
267 |
|
|
268 |
struct jpeg_compress_struct { |
|
269 |
jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ |
|
270 |
|
|
271 |
/* Destination for compressed data */ |
|
272 |
struct jpeg_destination_mgr * dest; |
|
273 |
|
|
274 |
/* Description of source image --- these fields must be filled in by |
|
275 |
* outer application before starting compression. in_color_space must |
|
276 |
* be correct before you can even call jpeg_set_defaults(). |
|
277 |
*/ |
|
278 |
|
|
279 |
JDIMENSION image_width; /* input image width */ |
|
280 |
JDIMENSION image_height; /* input image height */ |
|
281 |
int input_components; /* # of color components in input image */ |
|
282 |
J_COLOR_SPACE in_color_space; /* colorspace of input image */ |
|
283 |
|
|
284 |
double input_gamma; /* image gamma of input image */ |
|
285 |
|
|
286 |
/* Compression parameters --- these fields must be set before calling |
|
287 |
* jpeg_start_compress(). We recommend calling jpeg_set_defaults() to |
|
288 |
* initialize everything to reasonable defaults, then changing anything |
|
289 |
* the application specifically wants to change. That way you won't get |
|
290 |
* burnt when new parameters are added. Also note that there are several |
|
291 |
* helper routines to simplify changing parameters. |
|
292 |
*/ |
|
293 |
|
|
294 |
int data_precision; /* bits of precision in image data */ |
|
295 |
|
|
296 |
int num_components; /* # of color components in JPEG image */ |
|
297 |
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ |
|
298 |
|
|
299 |
jpeg_component_info * comp_info; |
|
300 |
/* comp_info[i] describes component that appears i'th in SOF */ |
|
301 |
|
|
302 |
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; |
|
303 |
/* ptrs to coefficient quantization tables, or NULL if not defined */ |
|
304 |
|
|
305 |
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
|
306 |
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
|
307 |
/* ptrs to Huffman coding tables, or NULL if not defined */ |
|
308 |
|
|
309 |
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ |
|
310 |
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ |
|
311 |
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ |
|
312 |
|
|
313 |
int num_scans; /* # of entries in scan_info array */ |
|
314 |
const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ |
|
315 |
/* The default value of scan_info is NULL, which causes a single-scan |
|
316 |
* sequential JPEG file to be emitted. To create a multi-scan file, |
|
317 |
* set num_scans and scan_info to point to an array of scan definitions. |
|
318 |
*/ |
|
319 |
|
|
320 |
boolean raw_data_in; /* TRUE=caller supplies downsampled data */ |
|
321 |
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ |
|
322 |
boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ |
|
323 |
boolean CCIR601_sampling; /* TRUE=first samples are cosited */ |
|
324 |
int smoothing_factor; /* 1..100, or 0 for no input smoothing */ |
|
325 |
J_DCT_METHOD dct_method; /* DCT algorithm selector */ |
|
326 |
|
|
327 |
/* The restart interval can be specified in absolute MCUs by setting |
|
328 |
* restart_interval, or in MCU rows by setting restart_in_rows |
|
329 |
* (in which case the correct restart_interval will be figured |
|
330 |
* for each scan). |
|
331 |
*/ |
|
332 |
unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ |
|
333 |
int restart_in_rows; /* if > 0, MCU rows per restart interval */ |
|
334 |
|
|
335 |
/* Parameters controlling emission of special markers. */ |
|
336 |
|
|
337 |
boolean write_JFIF_header; /* should a JFIF marker be written? */ |
|
338 |
UINT8 JFIF_major_version; /* What to write for the JFIF version number */ |
|
339 |
UINT8 JFIF_minor_version; |
|
340 |
/* These three values are not used by the JPEG code, merely copied */ |
|
341 |
/* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ |
|
342 |
/* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ |
|
343 |
/* ratio is defined by X_density/Y_density even when density_unit=0. */ |
|
344 |
UINT8 density_unit; /* JFIF code for pixel size units */ |
|
345 |
UINT16 X_density; /* Horizontal pixel density */ |
|
346 |
UINT16 Y_density; /* Vertical pixel density */ |
|
347 |
boolean write_Adobe_marker; /* should an Adobe marker be written? */ |
|
348 |
|
|
349 |
/* State variable: index of next scanline to be written to |
|
350 |
* jpeg_write_scanlines(). Application may use this to control its |
|
351 |
* processing loop, e.g., "while (next_scanline < image_height)". |
|
352 |
*/ |
|
353 |
|
|
354 |
JDIMENSION next_scanline; /* 0 .. image_height-1 */ |
|
355 |
|
|
356 |
/* Remaining fields are known throughout compressor, but generally |
|
357 |
* should not be touched by a surrounding application. |
|
358 |
*/ |
|
359 |
|
|
360 |
/* |
|
361 |
* These fields are computed during compression startup |
|
362 |
*/ |
|
363 |
boolean progressive_mode; /* TRUE if scan script uses progressive mode */ |
|
364 |
int max_h_samp_factor; /* largest h_samp_factor */ |
|
365 |
int max_v_samp_factor; /* largest v_samp_factor */ |
|
366 |
|
|
367 |
JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ |
|
368 |
/* The coefficient controller receives data in units of MCU rows as defined |
|
369 |
* for fully interleaved scans (whether the JPEG file is interleaved or not). |
|
370 |
* There are v_samp_factor * DCTSIZE sample rows of each component in an |
|
371 |
* "iMCU" (interleaved MCU) row. |
|
372 |
*/ |
|
373 |
|
|
374 |
/* |
|
375 |
* These fields are valid during any one scan. |
|
376 |
* They describe the components and MCUs actually appearing in the scan. |
|
377 |
*/ |
|
378 |
int comps_in_scan; /* # of JPEG components in this scan */ |
|
379 |
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; |
|
380 |
/* *cur_comp_info[i] describes component that appears i'th in SOS */ |
|
381 |
|
|
382 |
JDIMENSION MCUs_per_row; /* # of MCUs across the image */ |
|
383 |
JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ |
|
384 |
|
|
385 |
int blocks_in_MCU; /* # of DCT blocks per MCU */ |
|
386 |
int MCU_membership[C_MAX_BLOCKS_IN_MCU]; |
|
387 |
/* MCU_membership[i] is index in cur_comp_info of component owning */ |
|
388 |
/* i'th block in an MCU */ |
|
389 |
|
|
390 |
int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ |
|
391 |
|
|
392 |
/* |
|
393 |
* Links to compression subobjects (methods and private variables of modules) |
|
394 |
*/ |
|
395 |
struct jpeg_comp_master * master; |
|
396 |
struct jpeg_c_main_controller * main; |
|
397 |
struct jpeg_c_prep_controller * prep; |
|
398 |
struct jpeg_c_coef_controller * coef; |
|
399 |
struct jpeg_marker_writer * marker; |
|
400 |
struct jpeg_color_converter * cconvert; |
|
401 |
struct jpeg_downsampler * downsample; |
|
402 |
struct jpeg_forward_dct * fdct; |
|
403 |
struct jpeg_entropy_encoder * entropy; |
|
404 |
jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ |
|
405 |
int script_space_size; |
|
406 |
}; |
|
407 |
|
|
408 |
|
|
409 |
/* Master record for a decompression instance */ |
|
410 |
|
|
411 |
struct jpeg_decompress_struct { |
|
412 |
jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ |
|
413 |
|
|
414 |
/* Source of compressed data */ |
|
415 |
struct jpeg_source_mgr * src; |
|
416 |
|
|
417 |
/* Basic description of image --- filled in by jpeg_read_header(). */ |
|
418 |
/* Application may inspect these values to decide how to process image. */ |
|
419 |
|
|
420 |
JDIMENSION image_width; /* nominal image width (from SOF marker) */ |
|
421 |
JDIMENSION image_height; /* nominal image height */ |
|
422 |
int num_components; /* # of color components in JPEG image */ |
|
423 |
J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ |
|
424 |
|
|
425 |
/* Decompression processing parameters --- these fields must be set before |
|
426 |
* calling jpeg_start_decompress(). Note that jpeg_read_header() initializes |
|
427 |
* them to default values. |
|
428 |
*/ |
|
429 |
|
|
430 |
J_COLOR_SPACE out_color_space; /* colorspace for output */ |
|
431 |
|
|
432 |
unsigned int scale_num, scale_denom; /* fraction by which to scale image */ |
|
433 |
|
|
434 |
double output_gamma; /* image gamma wanted in output */ |
|
435 |
|
|
436 |
boolean buffered_image; /* TRUE=multiple output passes */ |
|
437 |
boolean raw_data_out; /* TRUE=downsampled data wanted */ |
|
438 |
|
|
439 |
J_DCT_METHOD dct_method; /* IDCT algorithm selector */ |
|
440 |
boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ |
|
441 |
boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ |
|
442 |
|
|
443 |
boolean quantize_colors; /* TRUE=colormapped output wanted */ |
|
444 |
/* the following are ignored if not quantize_colors: */ |
|
445 |
J_DITHER_MODE dither_mode; /* type of color dithering to use */ |
|
446 |
boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ |
|
447 |
int desired_number_of_colors; /* max # colors to use in created colormap */ |
|
448 |
/* these are significant only in buffered-image mode: */ |
|
449 |
boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ |
|
450 |
boolean enable_external_quant;/* enable future use of external colormap */ |
|
451 |
boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ |
|
452 |
|
|
453 |
/* Description of actual output image that will be returned to application. |
|
454 |
* These fields are computed by jpeg_start_decompress(). |
|
455 |
* You can also use jpeg_calc_output_dimensions() to determine these values |
|
456 |
* in advance of calling jpeg_start_decompress(). |
|
457 |
*/ |
|
458 |
|
|
459 |
JDIMENSION output_width; /* scaled image width */ |
|
460 |
JDIMENSION output_height; /* scaled image height */ |
|
461 |
int out_color_components; /* # of color components in out_color_space */ |
|
462 |
int output_components; /* # of color components returned */ |
|
463 |
/* output_components is 1 (a colormap index) when quantizing colors; |
|
464 |
* otherwise it equals out_color_components. |
|
465 |
*/ |
|
466 |
int rec_outbuf_height; /* min recommended height of scanline buffer */ |
|
467 |
/* If the buffer passed to jpeg_read_scanlines() is less than this many rows |
|
468 |
* high, space and time will be wasted due to unnecessary data copying. |
|
469 |
* Usually rec_outbuf_height will be 1 or 2, at most 4. |
|
470 |
*/ |
|
471 |
|
|
472 |
/* When quantizing colors, the output colormap is described by these fields. |
|
473 |
* The application can supply a colormap by setting colormap non-NULL before |
|
474 |
* calling jpeg_start_decompress; otherwise a colormap is created during |
|
475 |
* jpeg_start_decompress or jpeg_start_output. |
|
476 |
* The map has out_color_components rows and actual_number_of_colors columns. |
|
477 |
*/ |
|
478 |
int actual_number_of_colors; /* number of entries in use */ |
|
479 |
JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ |
|
480 |
|
|
481 |
/* State variables: these variables indicate the progress of decompression. |
|
482 |
* The application may examine these but must not modify them. |
|
483 |
*/ |
|
484 |
|
|
485 |
/* Row index of next scanline to be read from jpeg_read_scanlines(). |
|
486 |
* Application may use this to control its processing loop, e.g., |
|
487 |
* "while (output_scanline < output_height)". |
|
488 |
*/ |
|
489 |
JDIMENSION output_scanline; /* 0 .. output_height-1 */ |
|
490 |
|
|
491 |
/* Current input scan number and number of iMCU rows completed in scan. |
|
492 |
* These indicate the progress of the decompressor input side. |
|
493 |
*/ |
|
494 |
int input_scan_number; /* Number of SOS markers seen so far */ |
|
495 |
JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ |
|
496 |
|
|
497 |
/* The "output scan number" is the notional scan being displayed by the |
|
498 |
* output side. The decompressor will not allow output scan/row number |
|
499 |
* to get ahead of input scan/row, but it can fall arbitrarily far behind. |
|
500 |
*/ |
|
501 |
int output_scan_number; /* Nominal scan number being displayed */ |
|
502 |
JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ |
|
503 |
|
|
504 |
/* Current progression status. coef_bits[c][i] indicates the precision |
|
505 |
* with which component c's DCT coefficient i (in zigzag order) is known. |
|
506 |
* It is -1 when no data has yet been received, otherwise it is the point |
|
507 |
* transform (shift) value for the most recent scan of the coefficient |
|
508 |
* (thus, 0 at completion of the progression). |
|
509 |
* This pointer is NULL when reading a non-progressive file. |
|
510 |
*/ |
|
511 |
int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ |
|
512 |
|
|
513 |
/* Internal JPEG parameters --- the application usually need not look at |
|
514 |
* these fields. Note that the decompressor output side may not use |
|
515 |
* any parameters that can change between scans. |
|
516 |
*/ |
|
517 |
|
|
518 |
/* Quantization and Huffman tables are carried forward across input |
|
519 |
* datastreams when processing abbreviated JPEG datastreams. |
|
520 |
*/ |
|
521 |
|
|
522 |
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; |
|
523 |
/* ptrs to coefficient quantization tables, or NULL if not defined */ |
|
524 |
|
|
525 |
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
|
526 |
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; |
|
527 |
/* ptrs to Huffman coding tables, or NULL if not defined */ |
|
528 |
|
|
529 |
/* These parameters are never carried across datastreams, since they |
|
530 |
* are given in SOF/SOS markers or defined to be reset by SOI. |
|
531 |
*/ |
|
532 |
|
|
533 |
int data_precision; /* bits of precision in image data */ |
|
534 |
|
|
535 |
jpeg_component_info * comp_info; |
|
536 |
/* comp_info[i] describes component that appears i'th in SOF */ |
|
537 |
|
|
538 |
boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ |
|
539 |
boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ |
|
540 |
|
|
541 |
UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ |
|
542 |
UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ |
|
543 |
UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ |
|
544 |
|
|
545 |
unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ |
|
546 |
|
|
547 |
/* These fields record data obtained from optional markers recognized by |
Also available in: Unified diff