LMMS
Loading...
Searching...
No Matches
jdmarker.c
Go to the documentation of this file.
1/*
2 * jdmarker.c
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 contains routines to decode JPEG datastream markers.
9 * Most of the complexity arises from our desire to support input
10 * suspension: if not all of the data for a marker is available,
11 * we must exit back to the application. On resumption, we reprocess
12 * the marker.
13 */
14
15#define JPEG_INTERNALS
16#include "jinclude.h"
17#include "jpeglib.h"
18
19
20/* Private state */
21
22typedef struct {
23 struct jpeg_marker_reader pub; /* public fields */
24
25 /* Application-overridable marker processing methods */
26 jpeg_marker_parser_method process_COM;
27 jpeg_marker_parser_method process_APPn[16];
28
29 /* Limit on marker data length to save for each marker type */
30 unsigned int length_limit_COM;
31 unsigned int length_limit_APPn[16];
32
33 /* Status of COM/APPn marker saving */
34 jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */
35 unsigned int bytes_read; /* data bytes read so far in marker */
36 /* Note: cur_marker is not linked into marker_list until it's all read. */
38
40
41
42/*
43 * Macros for fetching data from the data source module.
44 *
45 * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect
46 * the current restart point; we update them only when we have reached a
47 * suitable place to restart if a suspension occurs.
48 */
49
50/* Declare and initialize local copies of input pointer/count */
51#define INPUT_VARS(cinfo) \
52 struct jpeg_source_mgr * datasrc = (cinfo)->src; \
53 const JOCTET * next_input_byte = datasrc->next_input_byte; \
54 size_t bytes_in_buffer = datasrc->bytes_in_buffer
55
56/* Unload the local copies --- do this only at a restart boundary */
57#define INPUT_SYNC(cinfo) \
58 ( datasrc->next_input_byte = next_input_byte, \
59 datasrc->bytes_in_buffer = bytes_in_buffer )
60
61/* Reload the local copies --- used only in MAKE_BYTE_AVAIL */
62#define INPUT_RELOAD(cinfo) \
63 ( next_input_byte = datasrc->next_input_byte, \
64 bytes_in_buffer = datasrc->bytes_in_buffer )
65
66/* Internal macro for INPUT_BYTE and INPUT_2BYTES: make a byte available.
67 * Note we do *not* do INPUT_SYNC before calling fill_input_buffer,
68 * but we must reload the local copies after a successful fill.
69 */
70#define MAKE_BYTE_AVAIL(cinfo,action) \
71 if (bytes_in_buffer == 0) { \
72 if (! (*datasrc->fill_input_buffer) (cinfo)) \
73 { action; } \
74 INPUT_RELOAD(cinfo); \
75 }
76
77/* Read a byte into variable V.
78 * If must suspend, take the specified action (typically "return FALSE").
79 */
80#define INPUT_BYTE(cinfo,V,action) \
81 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
82 bytes_in_buffer--; \
83 V = GETJOCTET(*next_input_byte++); )
84
85/* As above, but read two bytes interpreted as an unsigned 16-bit integer.
86 * V should be declared unsigned int or perhaps INT32.
87 */
88#define INPUT_2BYTES(cinfo,V,action) \
89 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
90 bytes_in_buffer--; \
91 V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \
92 MAKE_BYTE_AVAIL(cinfo,action); \
93 bytes_in_buffer--; \
94 V += GETJOCTET(*next_input_byte++); )
95
96
97/*
98 * Routines to process JPEG markers.
99 *
100 * Entry condition: JPEG marker itself has been read and its code saved
101 * in cinfo->unread_marker; input restart point is just after the marker.
102 *
103 * Exit: if return TRUE, have read and processed any parameters, and have
104 * updated the restart point to point after the parameters.
105 * If return FALSE, was forced to suspend before reaching end of
106 * marker parameters; restart point has not been moved. Same routine
107 * will be called again after application supplies more input data.
108 *
109 * This approach to suspension assumes that all of a marker's parameters
110 * can fit into a single input bufferload. This should hold for "normal"
111 * markers. Some COM/APPn markers might have large parameter segments
112 * that might not fit. If we are simply dropping such a marker, we use
113 * skip_input_data to get past it, and thereby put the problem on the
114 * source manager's shoulders. If we are saving the marker's contents
115 * into memory, we use a slightly different convention: when forced to
116 * suspend, the marker processor updates the restart point to the end of
117 * what it's consumed (ie, the end of the buffer) before returning FALSE.
118 * On resumption, cinfo->unread_marker still contains the marker code,
119 * but the data source will point to the next chunk of marker data.
120 * The marker processor must retain internal state to deal with this.
121 *
122 * Note that we don't bother to avoid duplicate trace messages if a
123 * suspension occurs within marker parameters. Other side effects
124 * require more care.
125 */
126
127
128LOCAL(boolean)
130/* Process an SOI marker */
131{
132 int i;
133
134 TRACEMS(cinfo, 1, JTRC_SOI);
135
136 if (cinfo->marker->saw_SOI)
137 ERREXIT(cinfo, JERR_SOI_DUPLICATE);
138
139 /* Reset all parameters that are defined to be reset by SOI */
140
141 for (i = 0; i < NUM_ARITH_TBLS; i++) {
142 cinfo->arith_dc_L[i] = 0;
143 cinfo->arith_dc_U[i] = 1;
144 cinfo->arith_ac_K[i] = 5;
145 }
146 cinfo->restart_interval = 0;
147
148 /* Set initial assumptions for colorspace etc */
149
150 cinfo->jpeg_color_space = JCS_UNKNOWN;
151 cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */
152
153 cinfo->saw_JFIF_marker = FALSE;
154 cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */
155 cinfo->JFIF_minor_version = 1;
156 cinfo->density_unit = 0;
157 cinfo->X_density = 1;
158 cinfo->Y_density = 1;
159 cinfo->saw_Adobe_marker = FALSE;
160 cinfo->Adobe_transform = 0;
161
162 cinfo->marker->saw_SOI = TRUE;
163
164 return TRUE;
165}
166
167
168LOCAL(boolean)
169get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
170/* Process a SOFn marker */
171{
173 int c, ci;
175 INPUT_VARS(cinfo);
176
177 cinfo->progressive_mode = is_prog;
178 cinfo->arith_code = is_arith;
179
180 INPUT_2BYTES(cinfo, length, return FALSE);
181
182 INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
183 INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
184 INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
185 INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);
186
187 length -= 8;
188
189 TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
190 (int) cinfo->image_width, (int) cinfo->image_height,
191 cinfo->num_components);
192
193 if (cinfo->marker->saw_SOF)
194 ERREXIT(cinfo, JERR_SOF_DUPLICATE);
195
196 /* We don't support files in which the image height is initially specified */
197 /* as 0 and is later redefined by DNL. As long as we have to check that, */
198 /* might as well have a general sanity check. */
199 if (cinfo->image_height <= 0 || cinfo->image_width <= 0
200 || cinfo->num_components <= 0)
201 ERREXIT(cinfo, JERR_EMPTY_IMAGE);
202
203 if (length != (cinfo->num_components * 3))
204 ERREXIT(cinfo, JERR_BAD_LENGTH);
205
206 if (cinfo->comp_info == NULL) /* do only once, even if suspend */
207 cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
208 ((j_common_ptr) cinfo, JPOOL_IMAGE,
209 cinfo->num_components * SIZEOF(jpeg_component_info));
210
211 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
212 ci++, compptr++) {
213 compptr->component_index = ci;
214 INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
215 INPUT_BYTE(cinfo, c, return FALSE);
216 compptr->h_samp_factor = (c >> 4) & 15;
217 compptr->v_samp_factor = (c ) & 15;
218 INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);
219
220 TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
221 compptr->component_id, compptr->h_samp_factor,
222 compptr->v_samp_factor, compptr->quant_tbl_no);
223 }
224
225 cinfo->marker->saw_SOF = TRUE;
226
227 INPUT_SYNC(cinfo);
228 return TRUE;
229}
230
231
232LOCAL(boolean)
234/* Process a SOS marker */
235{
237 int i, ci, n, c, cc;
239 INPUT_VARS(cinfo);
240
241 if (! cinfo->marker->saw_SOF)
242 ERREXIT(cinfo, JERR_SOS_NO_SOF);
243
244 INPUT_2BYTES(cinfo, length, return FALSE);
245
246 INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */
247
248 TRACEMS1(cinfo, 1, JTRC_SOS, n);
249
250 if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
251 ERREXIT(cinfo, JERR_BAD_LENGTH);
252
253 cinfo->comps_in_scan = n;
254
255 /* Collect the component-spec parameters */
256
257 for (i = 0; i < n; i++) {
258 INPUT_BYTE(cinfo, cc, return FALSE);
259 INPUT_BYTE(cinfo, c, return FALSE);
260
261 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
262 ci++, compptr++) {
263 if (cc == compptr->component_id)
264 goto id_found;
265 }
266
267 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
268
269 id_found:
270
271 cinfo->cur_comp_info[i] = compptr;
272 compptr->dc_tbl_no = (c >> 4) & 15;
273 compptr->ac_tbl_no = (c ) & 15;
274
275 TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
276 compptr->dc_tbl_no, compptr->ac_tbl_no);
277 }
278
279 /* Collect the additional scan parameters Ss, Se, Ah/Al. */
280 INPUT_BYTE(cinfo, c, return FALSE);
281 cinfo->Ss = c;
282 INPUT_BYTE(cinfo, c, return FALSE);
283 cinfo->Se = c;
284 INPUT_BYTE(cinfo, c, return FALSE);
285 cinfo->Ah = (c >> 4) & 15;
286 cinfo->Al = (c ) & 15;
287
288 TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
289 cinfo->Ah, cinfo->Al);
290
291 /* Prepare to scan data & restart markers */
292 cinfo->marker->next_restart_num = 0;
293
294 /* Count another SOS marker */
295 cinfo->input_scan_number++;
296
297 INPUT_SYNC(cinfo);
298 return TRUE;
299}
300
301
302#ifdef D_ARITH_CODING_SUPPORTED
303
304LOCAL(boolean)
306/* Process a DAC marker */
307{
309 int index, val;
310 INPUT_VARS(cinfo);
311
312 INPUT_2BYTES(cinfo, length, return FALSE);
313 length -= 2;
314
315 while (length > 0) {
316 INPUT_BYTE(cinfo, index, return FALSE);
317 INPUT_BYTE(cinfo, val, return FALSE);
318
319 length -= 2;
320
321 TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
322
323 if (index < 0 || index >= (2*NUM_ARITH_TBLS))
324 ERREXIT1(cinfo, JERR_DAC_INDEX, index);
325
326 if (index >= NUM_ARITH_TBLS) { /* define AC table */
327 cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;
328 } else { /* define DC table */
329 cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);
330 cinfo->arith_dc_U[index] = (UINT8) (val >> 4);
331 if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
332 ERREXIT1(cinfo, JERR_DAC_VALUE, val);
333 }
334 }
335
336 if (length != 0)
337 ERREXIT(cinfo, JERR_BAD_LENGTH);
338
339 INPUT_SYNC(cinfo);
340 return TRUE;
341}
342
343#else /* ! D_ARITH_CODING_SUPPORTED */
344
345#define get_dac(cinfo) skip_variable(cinfo)
346
347#endif /* D_ARITH_CODING_SUPPORTED */
348
349
350LOCAL(boolean)
352/* Process a DHT marker */
353{
355 UINT8 bits[17];
356 UINT8 huffval[256];
357 int i, index, count;
358 JHUFF_TBL **htblptr;
359 INPUT_VARS(cinfo);
360
361 INPUT_2BYTES(cinfo, length, return FALSE);
362 length -= 2;
363
364 while (length > 16) {
365 INPUT_BYTE(cinfo, index, return FALSE);
366
367 TRACEMS1(cinfo, 1, JTRC_DHT, index);
368
369 bits[0] = 0;
370 count = 0;
371 for (i = 1; i <= 16; i++) {
372 INPUT_BYTE(cinfo, bits[i], return FALSE);
373 count += bits[i];
374 }
375
376 length -= 1 + 16;
377
378 TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
379 bits[1], bits[2], bits[3], bits[4],
380 bits[5], bits[6], bits[7], bits[8]);
381 TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
382 bits[9], bits[10], bits[11], bits[12],
383 bits[13], bits[14], bits[15], bits[16]);
384
385 /* Here we just do minimal validation of the counts to avoid walking
386 * off the end of our table space. jdhuff.c will check more carefully.
387 */
388 if (count > 256 || ((INT32) count) > length)
389 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
390
391 for (i = 0; i < count; i++)
392 INPUT_BYTE(cinfo, huffval[i], return FALSE);
393
394 length -= count;
395
396 if (index & 0x10) { /* AC table definition */
397 index -= 0x10;
398 htblptr = &cinfo->ac_huff_tbl_ptrs[index];
399 } else { /* DC table definition */
400 htblptr = &cinfo->dc_huff_tbl_ptrs[index];
401 }
402
403 if (index < 0 || index >= NUM_HUFF_TBLS)
404 ERREXIT1(cinfo, JERR_DHT_INDEX, index);
405
406 if (*htblptr == NULL)
407 *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
408
409 MEMCOPY((*htblptr)->bits, bits, SIZEOF((*htblptr)->bits));
410 MEMCOPY((*htblptr)->huffval, huffval, SIZEOF((*htblptr)->huffval));
411 }
412
413 if (length != 0)
414 ERREXIT(cinfo, JERR_BAD_LENGTH);
415
416 INPUT_SYNC(cinfo);
417 return TRUE;
418}
419
420
421LOCAL(boolean)
423/* Process a DQT marker */
424{
426 int n, i, prec;
427 unsigned int tmp;
428 JQUANT_TBL *quant_ptr;
429 INPUT_VARS(cinfo);
430
431 INPUT_2BYTES(cinfo, length, return FALSE);
432 length -= 2;
433
434 while (length > 0) {
435 INPUT_BYTE(cinfo, n, return FALSE);
436 prec = n >> 4;
437 n &= 0x0F;
438
439 TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
440
441 if (n >= NUM_QUANT_TBLS)
442 ERREXIT1(cinfo, JERR_DQT_INDEX, n);
443
444 if (cinfo->quant_tbl_ptrs[n] == NULL)
445 cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
446 quant_ptr = cinfo->quant_tbl_ptrs[n];
447
448 for (i = 0; i < DCTSIZE2; i++) {
449 if (prec)
450 INPUT_2BYTES(cinfo, tmp, return FALSE);
451 else
452 INPUT_BYTE(cinfo, tmp, return FALSE);
453 /* We convert the zigzag-order table to natural array order. */
454 quant_ptr->quantval[jpeg_natural_order[i]] = (UINT16) tmp;
455 }
456
457 if (cinfo->err->trace_level >= 2) {
458 for (i = 0; i < DCTSIZE2; i += 8) {
459 TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
460 quant_ptr->quantval[i], quant_ptr->quantval[i+1],
461 quant_ptr->quantval[i+2], quant_ptr->quantval[i+3],
462 quant_ptr->quantval[i+4], quant_ptr->quantval[i+5],
463 quant_ptr->quantval[i+6], quant_ptr->quantval[i+7]);
464 }
465 }
466
467 length -= DCTSIZE2+1;
468 if (prec) length -= DCTSIZE2;
469 }
470
471 if (length != 0)
472 ERREXIT(cinfo, JERR_BAD_LENGTH);
473
474 INPUT_SYNC(cinfo);
475 return TRUE;
476}
477
478
479LOCAL(boolean)
481/* Process a DRI marker */
482{
484 unsigned int tmp;
485 INPUT_VARS(cinfo);
486
487 INPUT_2BYTES(cinfo, length, return FALSE);
488
489 if (length != 4)
490 ERREXIT(cinfo, JERR_BAD_LENGTH);
491
492 INPUT_2BYTES(cinfo, tmp, return FALSE);
493
494 TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
495
496 cinfo->restart_interval = tmp;
497
498 INPUT_SYNC(cinfo);
499 return TRUE;
500}
501
502
503/*
504 * Routines for processing APPn and COM markers.
505 * These are either saved in memory or discarded, per application request.
506 * APP0 and APP14 are specially checked to see if they are
507 * JFIF and Adobe markers, respectively.
508 */
509
510#define APP0_DATA_LEN 14 /* Length of interesting data in APP0 */
511#define APP14_DATA_LEN 12 /* Length of interesting data in APP14 */
512#define APPN_DATA_LEN 14 /* Must be the largest of the above!! */
513
514
515LOCAL(void)
517 unsigned int datalen, INT32 remaining)
518/* Examine first few bytes from an APP0.
519 * Take appropriate action if it is a JFIF marker.
520 * datalen is # of bytes at data[], remaining is length of rest of marker data.
521 */
522{
523 INT32 totallen = (INT32) datalen + remaining;
524
525 if (datalen >= APP0_DATA_LEN &&
526 GETJOCTET(data[0]) == 0x4A &&
527 GETJOCTET(data[1]) == 0x46 &&
528 GETJOCTET(data[2]) == 0x49 &&
529 GETJOCTET(data[3]) == 0x46 &&
530 GETJOCTET(data[4]) == 0) {
531 /* Found JFIF APP0 marker: save info */
532 cinfo->saw_JFIF_marker = TRUE;
533 cinfo->JFIF_major_version = GETJOCTET(data[5]);
534 cinfo->JFIF_minor_version = GETJOCTET(data[6]);
535 cinfo->density_unit = GETJOCTET(data[7]);
536 cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
537 cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
538 /* Check version.
539 * Major version must be 1, anything else signals an incompatible change.
540 * (We used to treat this as an error, but now it's a nonfatal warning,
541 * because some bozo at Hijaak couldn't read the spec.)
542 * Minor version should be 0..2, but process anyway if newer.
543 */
544 if (cinfo->JFIF_major_version != 1)
545 WARNMS2(cinfo, JWRN_JFIF_MAJOR,
546 cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
547 /* Generate trace messages */
548 TRACEMS5(cinfo, 1, JTRC_JFIF,
549 cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
550 cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
551 /* Validate thumbnail dimensions and issue appropriate messages */
552 if (GETJOCTET(data[12]) | GETJOCTET(data[13]))
553 TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL,
554 GETJOCTET(data[12]), GETJOCTET(data[13]));
555 totallen -= APP0_DATA_LEN;
556 if (totallen !=
557 ((INT32)GETJOCTET(data[12]) * (INT32)GETJOCTET(data[13]) * (INT32) 3))
558 TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen);
559 } else if (datalen >= 6 &&
560 GETJOCTET(data[0]) == 0x4A &&
561 GETJOCTET(data[1]) == 0x46 &&
562 GETJOCTET(data[2]) == 0x58 &&
563 GETJOCTET(data[3]) == 0x58 &&
564 GETJOCTET(data[4]) == 0) {
565 /* Found JFIF "JFXX" extension APP0 marker */
566 /* The library doesn't actually do anything with these,
567 * but we try to produce a helpful trace message.
568 */
569 switch (GETJOCTET(data[5])) {
570 case 0x10:
571 TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen);
572 break;
573 case 0x11:
574 TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen);
575 break;
576 case 0x13:
577 TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen);
578 break;
579 default:
580 TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
581 GETJOCTET(data[5]), (int) totallen);
582 break;
583 }
584 } else {
585 /* Start of APP0 does not match "JFIF" or "JFXX", or too short */
586 TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen);
587 }
588}
589
590
591LOCAL(void)
593 unsigned int datalen, INT32 remaining)
594/* Examine first few bytes from an APP14.
595 * Take appropriate action if it is an Adobe marker.
596 * datalen is # of bytes at data[], remaining is length of rest of marker data.
597 */
598{
599 unsigned int version, flags0, flags1, transform;
600
601 if (datalen >= APP14_DATA_LEN &&
602 GETJOCTET(data[0]) == 0x41 &&
603 GETJOCTET(data[1]) == 0x64 &&
604 GETJOCTET(data[2]) == 0x6F &&
605 GETJOCTET(data[3]) == 0x62 &&
606 GETJOCTET(data[4]) == 0x65) {
607 /* Found Adobe APP14 marker */
608 version = (GETJOCTET(data[5]) << 8) + GETJOCTET(data[6]);
609 flags0 = (GETJOCTET(data[7]) << 8) + GETJOCTET(data[8]);
610 flags1 = (GETJOCTET(data[9]) << 8) + GETJOCTET(data[10]);
611 transform = GETJOCTET(data[11]);
612 TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
613 cinfo->saw_Adobe_marker = TRUE;
614 cinfo->Adobe_transform = (UINT8) transform;
615 } else {
616 /* Start of APP14 does not match "Adobe", or too short */
617 TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining));
618 }
619}
620
621
622METHODDEF(boolean)
624/* Process an APP0 or APP14 marker without saving it */
625{
628 unsigned int i, numtoread;
629 INPUT_VARS(cinfo);
630
631 INPUT_2BYTES(cinfo, length, return FALSE);
632 length -= 2;
633
634 /* get the interesting part of the marker data */
635 if (length >= APPN_DATA_LEN)
636 numtoread = APPN_DATA_LEN;
637 else if (length > 0)
638 numtoread = (unsigned int) length;
639 else
640 numtoread = 0;
641 for (i = 0; i < numtoread; i++)
642 INPUT_BYTE(cinfo, b[i], return FALSE);
643 length -= numtoread;
644
645 /* process it */
646 switch (cinfo->unread_marker) {
647 case M_APP0:
648 examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length);
649 break;
650 case M_APP14:
651 examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length);
652 break;
653 default:
654 /* can't get here unless jpeg_save_markers chooses wrong processor */
655 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
656 break;
657 }
658
659 /* skip any remaining data -- could be lots */
660 INPUT_SYNC(cinfo);
661 if (length > 0)
662 (*cinfo->src->skip_input_data) (cinfo, (long) length);
663
664 return TRUE;
665}
666
667
668#ifdef SAVE_MARKERS_SUPPORTED
669
670METHODDEF(boolean)
672/* Save an APPn or COM marker into the marker list */
673{
674 my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker;
675 jpeg_saved_marker_ptr cur_marker = marker->cur_marker;
676 unsigned int bytes_read, data_length;
677 JOCTET FAR * data;
678 INT32 length = 0;
679 INPUT_VARS(cinfo);
680
681 if (cur_marker == NULL) {
682 /* begin reading a marker */
683 INPUT_2BYTES(cinfo, length, return FALSE);
684 length -= 2;
685 if (length >= 0) { /* watch out for bogus length word */
686 /* figure out how much we want to save */
687 unsigned int limit;
688 if (cinfo->unread_marker == (int) M_COM)
689 limit = marker->length_limit_COM;
690 else
691 limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0];
692 if ((unsigned int) length < limit)
693 limit = (unsigned int) length;
694 /* allocate and initialize the marker item */
695 cur_marker = (jpeg_saved_marker_ptr)
696 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
698 cur_marker->next = NULL;
699 cur_marker->marker = (UINT8) cinfo->unread_marker;
700 cur_marker->original_length = (unsigned int) length;
701 cur_marker->data_length = limit;
702 /* data area is just beyond the jpeg_marker_struct */
703 data = cur_marker->data = (JOCTET FAR *) (cur_marker + 1);
704 marker->cur_marker = cur_marker;
705 marker->bytes_read = 0;
706 bytes_read = 0;
707 data_length = limit;
708 } else {
709 /* deal with bogus length word */
710 bytes_read = data_length = 0;
711 data = NULL;
712 }
713 } else {
714 /* resume reading a marker */
715 bytes_read = marker->bytes_read;
716 data_length = cur_marker->data_length;
717 data = cur_marker->data + bytes_read;
718 }
719
720 while (bytes_read < data_length) {
721 INPUT_SYNC(cinfo); /* move the restart point to here */
722 marker->bytes_read = bytes_read;
723 /* If there's not at least one byte in buffer, suspend */
724 MAKE_BYTE_AVAIL(cinfo, return FALSE);
725 /* Copy bytes with reasonable rapidity */
726 while (bytes_read < data_length && bytes_in_buffer > 0) {
727 *data++ = *next_input_byte++;
728 bytes_in_buffer--;
729 bytes_read++;
730 }
731 }
732
733 /* Done reading what we want to read */
734 if (cur_marker != NULL) { /* will be NULL if bogus length word */
735 /* Add new marker to end of list */
736 if (cinfo->marker_list == NULL) {
737 cinfo->marker_list = cur_marker;
738 } else {
739 jpeg_saved_marker_ptr prev = cinfo->marker_list;
740 while (prev->next != NULL)
741 prev = prev->next;
742 prev->next = cur_marker;
743 }
744 /* Reset pointer & calc remaining data length */
745 data = cur_marker->data;
746 length = cur_marker->original_length - data_length;
747 }
748 /* Reset to initial state for next marker */
749 marker->cur_marker = NULL;
750
751 /* Process the marker if interesting; else just make a generic trace msg */
752 switch (cinfo->unread_marker) {
753 case M_APP0:
754 examine_app0(cinfo, data, data_length, length);
755 break;
756 case M_APP14:
757 examine_app14(cinfo, data, data_length, length);
758 break;
759 default:
760 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
761 (int) (data_length + length));
762 break;
763 }
764
765 /* skip any remaining data -- could be lots */
766 INPUT_SYNC(cinfo); /* do before skip_input_data */
767 if (length > 0)
768 (*cinfo->src->skip_input_data) (cinfo, (long) length);
769
770 return TRUE;
771}
772
773#endif /* SAVE_MARKERS_SUPPORTED */
774
775
776METHODDEF(boolean)
778/* Skip over an unknown or uninteresting variable-length marker */
779{
781 INPUT_VARS(cinfo);
782
783 INPUT_2BYTES(cinfo, length, return FALSE);
784 length -= 2;
785
786 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);
787
788 INPUT_SYNC(cinfo); /* do before skip_input_data */
789 if (length > 0)
790 (*cinfo->src->skip_input_data) (cinfo, (long) length);
791
792 return TRUE;
793}
794
795
796/*
797 * Find the next JPEG marker, save it in cinfo->unread_marker.
798 * Returns FALSE if had to suspend before reaching a marker;
799 * in that case cinfo->unread_marker is unchanged.
800 *
801 * Note that the result might not be a valid marker code,
802 * but it will never be 0 or FF.
803 */
804
805LOCAL(boolean)
807{
808 int c;
809 INPUT_VARS(cinfo);
810
811 for (;;) {
812 INPUT_BYTE(cinfo, c, return FALSE);
813 /* Skip any non-FF bytes.
814 * This may look a bit inefficient, but it will not occur in a valid file.
815 * We sync after each discarded byte so that a suspending data source
816 * can discard the byte from its buffer.
817 */
818 while (c != 0xFF) {
819 cinfo->marker->discarded_bytes++;
820 INPUT_SYNC(cinfo);
821 INPUT_BYTE(cinfo, c, return FALSE);
822 }
823 /* This loop swallows any duplicate FF bytes. Extra FFs are legal as
824 * pad bytes, so don't count them in discarded_bytes. We assume there
825 * will not be so many consecutive FF bytes as to overflow a suspending
826 * data source's input buffer.
827 */
828 do {
829 INPUT_BYTE(cinfo, c, return FALSE);
830 } while (c == 0xFF);
831 if (c != 0)
832 break; /* found a valid marker, exit loop */
833 /* Reach here if we found a stuffed-zero data sequence (FF/00).
834 * Discard it and loop back to try again.
835 */
836 cinfo->marker->discarded_bytes += 2;
837 INPUT_SYNC(cinfo);
838 }
839
840 if (cinfo->marker->discarded_bytes != 0) {
841 WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
842 cinfo->marker->discarded_bytes = 0;
843 }
844
845 cinfo->unread_marker = c;
846
847 INPUT_SYNC(cinfo);
848 return TRUE;
849}
850
851
852LOCAL(boolean)
854/* Like next_marker, but used to obtain the initial SOI marker. */
855/* For this marker, we do not allow preceding garbage or fill; otherwise,
856 * we might well scan an entire input file before realizing it ain't JPEG.
857 * If an application wants to process non-JFIF files, it must seek to the
858 * SOI before calling the JPEG library.
859 */
860{
861 int c, c2;
862 INPUT_VARS(cinfo);
863
864 INPUT_BYTE(cinfo, c, return FALSE);
865 INPUT_BYTE(cinfo, c2, return FALSE);
866 if (c != 0xFF || c2 != (int) M_SOI)
867 ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
868
869 cinfo->unread_marker = c2;
870
871 INPUT_SYNC(cinfo);
872 return TRUE;
873}
874
875
876/*
877 * Read markers until SOS or EOI.
878 *
879 * Returns same codes as are defined for jpeg_consume_input:
880 * JPEG_SUSPENDED, JPEG_REACHED_SOS, or JPEG_REACHED_EOI.
881 */
882
883METHODDEF(int)
885{
886 /* Outer loop repeats once for each marker. */
887 for (;;) {
888 /* Collect the marker proper, unless we already did. */
889 /* NB: first_marker() enforces the requirement that SOI appear first. */
890 if (cinfo->unread_marker == 0) {
891 if (! cinfo->marker->saw_SOI) {
892 if (! first_marker(cinfo))
893 return JPEG_SUSPENDED;
894 } else {
895 if (! next_marker(cinfo))
896 return JPEG_SUSPENDED;
897 }
898 }
899 /* At this point cinfo->unread_marker contains the marker code and the
900 * input point is just past the marker proper, but before any parameters.
901 * A suspension will cause us to return with this state still true.
902 */
903 switch (cinfo->unread_marker) {
904 case M_SOI:
905 if (! get_soi(cinfo))
906 return JPEG_SUSPENDED;
907 break;
908
909 case M_SOF0: /* Baseline */
910 case M_SOF1: /* Extended sequential, Huffman */
911 if (! get_sof(cinfo, FALSE, FALSE))
912 return JPEG_SUSPENDED;
913 break;
914
915 case M_SOF2: /* Progressive, Huffman */
916 if (! get_sof(cinfo, TRUE, FALSE))
917 return JPEG_SUSPENDED;
918 break;
919
920 case M_SOF9: /* Extended sequential, arithmetic */
921 if (! get_sof(cinfo, FALSE, TRUE))
922 return JPEG_SUSPENDED;
923 break;
924
925 case M_SOF10: /* Progressive, arithmetic */
926 if (! get_sof(cinfo, TRUE, TRUE))
927 return JPEG_SUSPENDED;
928 break;
929
930 /* Currently unsupported SOFn types */
931 case M_SOF3: /* Lossless, Huffman */
932 case M_SOF5: /* Differential sequential, Huffman */
933 case M_SOF6: /* Differential progressive, Huffman */
934 case M_SOF7: /* Differential lossless, Huffman */
935 case M_JPG: /* Reserved for JPEG extensions */
936 case M_SOF11: /* Lossless, arithmetic */
937 case M_SOF13: /* Differential sequential, arithmetic */
938 case M_SOF14: /* Differential progressive, arithmetic */
939 case M_SOF15: /* Differential lossless, arithmetic */
940 ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);
941 break;
942
943 case M_SOS:
944 if (! get_sos(cinfo))
945 return JPEG_SUSPENDED;
946 cinfo->unread_marker = 0; /* processed the marker */
947 return JPEG_REACHED_SOS;
948
949 case M_EOI:
950 TRACEMS(cinfo, 1, JTRC_EOI);
951 cinfo->unread_marker = 0; /* processed the marker */
952 return JPEG_REACHED_EOI;
953
954 case M_DAC:
955 if (! get_dac(cinfo))
956 return JPEG_SUSPENDED;
957 break;
958
959 case M_DHT:
960 if (! get_dht(cinfo))
961 return JPEG_SUSPENDED;
962 break;
963
964 case M_DQT:
965 if (! get_dqt(cinfo))
966 return JPEG_SUSPENDED;
967 break;
968
969 case M_DRI:
970 if (! get_dri(cinfo))
971 return JPEG_SUSPENDED;
972 break;
973
974 case M_APP0:
975 case M_APP1:
976 case M_APP2:
977 case M_APP3:
978 case M_APP4:
979 case M_APP5:
980 case M_APP6:
981 case M_APP7:
982 case M_APP8:
983 case M_APP9:
984 case M_APP10:
985 case M_APP11:
986 case M_APP12:
987 case M_APP13:
988 case M_APP14:
989 case M_APP15:
990 if (! (*((my_marker_ptr2) cinfo->marker)->process_APPn[
991 cinfo->unread_marker - (int) M_APP0]) (cinfo))
992 return JPEG_SUSPENDED;
993 break;
994
995 case M_COM:
996 if (! (*((my_marker_ptr2) cinfo->marker)->process_COM) (cinfo))
997 return JPEG_SUSPENDED;
998 break;
999
1000 case M_RST0: /* these are all parameterless */
1001 case M_RST1:
1002 case M_RST2:
1003 case M_RST3:
1004 case M_RST4:
1005 case M_RST5:
1006 case M_RST6:
1007 case M_RST7:
1008 case M_TEM:
1009 TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);
1010 break;
1011
1012 case M_DNL: /* Ignore DNL ... perhaps the wrong thing */
1013 if (! skip_variable(cinfo))
1014 return JPEG_SUSPENDED;
1015 break;
1016
1017 default: /* must be DHP, EXP, JPGn, or RESn */
1018 /* For now, we treat the reserved markers as fatal errors since they are
1019 * likely to be used to signal incompatible JPEG Part 3 extensions.
1020 * Once the JPEG 3 version-number marker is well defined, this code
1021 * ought to change!
1022 */
1023 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
1024 break;
1025 }
1026 /* Successfully processed marker, so reset state variable */
1027 cinfo->unread_marker = 0;
1028 } /* end loop */
1029}
1030
1031
1032/*
1033 * Read a restart marker, which is expected to appear next in the datastream;
1034 * if the marker is not there, take appropriate recovery action.
1035 * Returns FALSE if suspension is required.
1036 *
1037 * This is called by the entropy decoder after it has read an appropriate
1038 * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder
1039 * has already read a marker from the data source. Under normal conditions
1040 * cinfo->unread_marker will be reset to 0 before returning; if not reset,
1041 * it holds a marker which the decoder will be unable to read past.
1042 */
1043
1044METHODDEF(boolean)
1046{
1047 /* Obtain a marker unless we already did. */
1048 /* Note that next_marker will complain if it skips any data. */
1049 if (cinfo->unread_marker == 0) {
1050 if (! next_marker(cinfo))
1051 return FALSE;
1052 }
1053
1054 if (cinfo->unread_marker ==
1055 ((int) M_RST0 + cinfo->marker->next_restart_num)) {
1056 /* Normal case --- swallow the marker and let entropy decoder continue */
1057 TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
1058 cinfo->unread_marker = 0;
1059 } else {
1060 /* Uh-oh, the restart markers have been messed up. */
1061 /* Let the data source manager determine how to resync. */
1062 if (! (*cinfo->src->resync_to_restart) (cinfo,
1063 cinfo->marker->next_restart_num))
1064 return FALSE;
1065 }
1066
1067 /* Update next-restart state */
1068 cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
1069
1070 return TRUE;
1071}
1072
1073
1074/*
1075 * This is the default resync_to_restart method for data source managers
1076 * to use if they don't have any better approach. Some data source managers
1077 * may be able to back up, or may have additional knowledge about the data
1078 * which permits a more intelligent recovery strategy; such managers would
1079 * presumably supply their own resync method.
1080 *
1081 * read_restart_marker calls resync_to_restart if it finds a marker other than
1082 * the restart marker it was expecting. (This code is *not* used unless
1083 * a nonzero restart interval has been declared.) cinfo->unread_marker is
1084 * the marker code actually found (might be anything, except 0 or FF).
1085 * The desired restart marker number (0..7) is passed as a parameter.
1086 * This routine is supposed to apply whatever error recovery strategy seems
1087 * appropriate in order to position the input stream to the next data segment.
1088 * Note that cinfo->unread_marker is treated as a marker appearing before
1089 * the current data-source input point; usually it should be reset to zero
1090 * before returning.
1091 * Returns FALSE if suspension is required.
1092 *
1093 * This implementation is substantially constrained by wanting to treat the
1094 * input as a data stream; this means we can't back up. Therefore, we have
1095 * only the following actions to work with:
1096 * 1. Simply discard the marker and let the entropy decoder resume at next
1097 * byte of file.
1098 * 2. Read forward until we find another marker, discarding intervening
1099 * data. (In theory we could look ahead within the current bufferload,
1100 * without having to discard data if we don't find the desired marker.
1101 * This idea is not implemented here, in part because it makes behavior
1102 * dependent on buffer size and chance buffer-boundary positions.)
1103 * 3. Leave the marker unread (by failing to zero cinfo->unread_marker).
1104 * This will cause the entropy decoder to process an empty data segment,
1105 * inserting dummy zeroes, and then we will reprocess the marker.
1106 *
1107 * #2 is appropriate if we think the desired marker lies ahead, while #3 is
1108 * appropriate if the found marker is a future restart marker (indicating
1109 * that we have missed the desired restart marker, probably because it got
1110 * corrupted).
1111 * We apply #2 or #3 if the found marker is a restart marker no more than
1112 * two counts behind or ahead of the expected one. We also apply #2 if the
1113 * found marker is not a legal JPEG marker code (it's certainly bogus data).
1114 * If the found marker is a restart marker more than 2 counts away, we do #1
1115 * (too much risk that the marker is erroneous; with luck we will be able to
1116 * resync at some future point).
1117 * For any valid non-restart JPEG marker, we apply #3. This keeps us from
1118 * overrunning the end of a scan. An implementation limited to single-scan
1119 * files might find it better to apply #2 for markers other than EOI, since
1120 * any other marker would have to be bogus data in that case.
1121 */
1122
1123GLOBAL(boolean)
1125{
1126 int marker = cinfo->unread_marker;
1127 int action = 1;
1128
1129 /* Always put up a warning. */
1130 WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
1131
1132 /* Outer loop handles repeated decision after scanning forward. */
1133 for (;;) {
1134 if (marker < (int) M_SOF0)
1135 action = 2; /* invalid marker */
1136 else if (marker < (int) M_RST0 || marker > (int) M_RST7)
1137 action = 3; /* valid non-restart marker */
1138 else {
1139 if (marker == ((int) M_RST0 + ((desired+1) & 7)) ||
1140 marker == ((int) M_RST0 + ((desired+2) & 7)))
1141 action = 3; /* one of the next two expected restarts */
1142 else if (marker == ((int) M_RST0 + ((desired-1) & 7)) ||
1143 marker == ((int) M_RST0 + ((desired-2) & 7)))
1144 action = 2; /* a prior restart, so advance */
1145 else
1146 action = 1; /* desired restart or too far away */
1147 }
1148 TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
1149 switch (action) {
1150 case 1:
1151 /* Discard marker and let entropy decoder resume processing. */
1152 cinfo->unread_marker = 0;
1153 return TRUE;
1154 case 2:
1155 /* Scan to the next marker, and repeat the decision loop. */
1156 if (! next_marker(cinfo))
1157 return FALSE;
1158 marker = cinfo->unread_marker;
1159 break;
1160 case 3:
1161 /* Return without advancing past this marker. */
1162 /* Entropy decoder will be forced to process an empty segment. */
1163 return TRUE;
1164 }
1165 } /* end loop */
1166}
1167
1168
1169/*
1170 * Reset marker processing state to begin a fresh datastream.
1171 */
1172
1173METHODDEF(void)
1175{
1176 my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker;
1177
1178 cinfo->comp_info = NULL; /* until allocated by get_sof */
1179 cinfo->input_scan_number = 0; /* no SOS seen yet */
1180 cinfo->unread_marker = 0; /* no pending marker */
1181 marker->pub.saw_SOI = FALSE; /* set internal state too */
1182 marker->pub.saw_SOF = FALSE;
1183 marker->pub.discarded_bytes = 0;
1184 marker->cur_marker = NULL;
1185}
1186
1187
1188/*
1189 * Initialize the marker reader module.
1190 * This is called only once, when the decompression object is created.
1191 */
1192
1193GLOBAL(void)
1195{
1197 int i;
1198
1199 /* Create subobject in permanent pool */
1201 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
1203 cinfo->marker = (struct jpeg_marker_reader *) marker;
1204 /* Initialize public method pointers */
1205 marker->pub.reset_marker_reader = reset_marker_reader;
1206 marker->pub.read_markers = read_markers;
1207 marker->pub.read_restart_marker = read_restart_marker;
1208 /* Initialize COM/APPn processing.
1209 * By default, we examine and then discard APP0 and APP14,
1210 * but simply discard COM and all other APPn.
1211 */
1212 marker->process_COM = skip_variable;
1213 marker->length_limit_COM = 0;
1214 for (i = 0; i < 16; i++) {
1215 marker->process_APPn[i] = skip_variable;
1216 marker->length_limit_APPn[i] = 0;
1217 }
1218 marker->process_APPn[0] = get_interesting_appn;
1219 marker->process_APPn[14] = get_interesting_appn;
1220 /* Reset marker processing state */
1221 reset_marker_reader(cinfo);
1222}
1223
1224
1225/*
1226 * Control saving of COM and APPn markers into marker_list.
1227 */
1228
1229#ifdef SAVE_MARKERS_SUPPORTED
1230
1231GLOBAL(void)
1233 unsigned int length_limit)
1234{
1235 my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker;
1236 long maxlength;
1237 jpeg_marker_parser_method processor;
1238
1239 /* Length limit mustn't be larger than what we can allocate
1240 * (should only be a concern in a 16-bit environment).
1241 */
1242 maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct);
1243 if (((long) length_limit) > maxlength)
1244 length_limit = (unsigned int) maxlength;
1245
1246 /* Choose processor routine to use.
1247 * APP0/APP14 have special requirements.
1248 */
1249 if (length_limit) {
1250 processor = save_marker;
1251 /* If saving APP0/APP14, save at least enough for our internal use. */
1252 if (marker_code == (int) M_APP0 && length_limit < APP0_DATA_LEN)
1254 else if (marker_code == (int) M_APP14 && length_limit < APP14_DATA_LEN)
1256 } else {
1257 processor = skip_variable;
1258 /* If discarding APP0/APP14, use our regular on-the-fly processor. */
1259 if (marker_code == (int) M_APP0 || marker_code == (int) M_APP14)
1260 processor = get_interesting_appn;
1261 }
1262
1263 if (marker_code == (int) M_COM) {
1264 marker->process_COM = processor;
1265 marker->length_limit_COM = length_limit;
1266 } else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) {
1267 marker->process_APPn[marker_code - (int) M_APP0] = processor;
1268 marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit;
1269 } else
1270 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
1271}
1272
1273#endif /* SAVE_MARKERS_SUPPORTED */
1274
1275
1276/*
1277 * Install a special processing method for COM or APPn markers.
1278 */
1279
1280GLOBAL(void)
1282 jpeg_marker_parser_method routine)
1283{
1284 my_marker_ptr2 marker = (my_marker_ptr2) cinfo->marker;
1285
1286 if (marker_code == (int) M_COM)
1287 marker->process_COM = routine;
1288 else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15)
1289 marker->process_APPn[marker_code - (int) M_APP0] = routine;
1290 else
1291 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
1292}
#define NULL
Definition CarlaBridgeFormat.cpp:30
T limit(T val, T min, T max)
Definition Util.h:78
register unsigned i
Definition inflate.c:1575
static void c2(register WDL_FFT_COMPLEX *a)
Definition fft.c:270
jpeg_alloc_quant_table(j_common_ptr cinfo)
Definition jcomapi.c:86
jpeg_alloc_huff_table(j_common_ptr cinfo)
Definition jcomapi.c:98
jpeg_component_info * compptr
Definition jdct.h:105
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
Definition jdmarker.c:1124
#define APP0_DATA_LEN
Definition jdmarker.c:510
#define INPUT_BYTE(cinfo, V, action)
Definition jdmarker.c:80
first_marker(j_decompress_ptr cinfo)
Definition jdmarker.c:853
reset_marker_reader(j_decompress_ptr cinfo)
Definition jdmarker.c:1174
skip_variable(j_decompress_ptr cinfo)
Definition jdmarker.c:777
read_restart_marker(j_decompress_ptr cinfo)
Definition jdmarker.c:1045
jpeg_save_markers(j_decompress_ptr cinfo, int marker_code, unsigned int length_limit)
Definition jdmarker.c:1232
#define INPUT_2BYTES(cinfo, V, action)
Definition jdmarker.c:88
#define INPUT_VARS(cinfo)
Definition jdmarker.c:51
jinit_marker_reader(j_decompress_ptr cinfo)
Definition jdmarker.c:1194
read_markers(j_decompress_ptr cinfo)
Definition jdmarker.c:884
examine_app0(j_decompress_ptr cinfo, JOCTET FAR *data, unsigned int datalen, INT32 remaining)
Definition jdmarker.c:516
jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code, jpeg_marker_parser_method routine)
Definition jdmarker.c:1281
#define INPUT_SYNC(cinfo)
Definition jdmarker.c:57
get_dri(j_decompress_ptr cinfo)
Definition jdmarker.c:480
my_marker_reader * my_marker_ptr2
Definition jdmarker.c:39
next_marker(j_decompress_ptr cinfo)
Definition jdmarker.c:806
save_marker(j_decompress_ptr cinfo)
Definition jdmarker.c:671
get_dht(j_decompress_ptr cinfo)
Definition jdmarker.c:351
#define APP14_DATA_LEN
Definition jdmarker.c:511
#define APPN_DATA_LEN
Definition jdmarker.c:512
get_interesting_appn(j_decompress_ptr cinfo)
Definition jdmarker.c:623
examine_app14(j_decompress_ptr cinfo, JOCTET FAR *data, unsigned int datalen, INT32 remaining)
Definition jdmarker.c:592
get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
Definition jdmarker.c:169
get_dqt(j_decompress_ptr cinfo)
Definition jdmarker.c:422
get_sos(j_decompress_ptr cinfo)
Definition jdmarker.c:233
#define MAKE_BYTE_AVAIL(cinfo, action)
Definition jdmarker.c:70
#define get_dac(cinfo)
Definition jdmarker.c:345
get_soi(j_decompress_ptr cinfo)
Definition jdmarker.c:129
#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8)
Definition jerror.h:280
#define WARNMS2(cinfo, code, p1, p2)
Definition jerror.h:245
#define ERREXIT(cinfo, code)
Definition jerror.h:205
#define TRACEMS1(cinfo, lvl, code, p1)
Definition jerror.h:255
#define TRACEMS(cinfo, lvl, code)
Definition jerror.h:252
#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5)
Definition jerror.h:274
#define TRACEMS2(cinfo, lvl, code, p1, p2)
Definition jerror.h:259
#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4)
Definition jerror.h:269
#define ERREXIT1(cinfo, code, p1)
Definition jerror.h:208
#define ERREXIT2(cinfo, code, p1, p2)
Definition jerror.h:212
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3)
Definition jerror.h:264
#define MEMCOPY(dest, src, size)
Definition jinclude.h:71
#define SIZEOF(object)
Definition jinclude.h:83
@ M_RST4
Definition jinclude.h:125
@ M_COM
Definition jinclude.h:158
@ M_RST5
Definition jinclude.h:126
@ M_DNL
Definition jinclude.h:134
@ M_SOF14
Definition jinclude.h:114
@ M_APP3
Definition jinclude.h:142
@ M_SOF7
Definition jinclude.h:106
@ M_EOI
Definition jinclude.h:131
@ M_APP11
Definition jinclude.h:150
@ M_APP1
Definition jinclude.h:140
@ M_APP12
Definition jinclude.h:151
@ M_APP2
Definition jinclude.h:141
@ M_APP13
Definition jinclude.h:152
@ M_RST3
Definition jinclude.h:124
@ M_APP9
Definition jinclude.h:148
@ M_DQT
Definition jinclude.h:133
@ M_DHT
Definition jinclude.h:117
@ M_SOF3
Definition jinclude.h:102
@ M_SOF2
Definition jinclude.h:101
@ M_APP14
Definition jinclude.h:153
@ M_DAC
Definition jinclude.h:119
@ M_SOF6
Definition jinclude.h:105
@ M_APP6
Definition jinclude.h:145
@ M_RST0
Definition jinclude.h:121
@ M_APP8
Definition jinclude.h:147
@ M_SOF15
Definition jinclude.h:115
@ M_SOI
Definition jinclude.h:130
@ M_RST7
Definition jinclude.h:128
@ M_DRI
Definition jinclude.h:135
@ M_SOF9
Definition jinclude.h:109
@ M_JPG
Definition jinclude.h:108
@ M_APP10
Definition jinclude.h:149
@ M_SOF10
Definition jinclude.h:110
@ M_SOF11
Definition jinclude.h:111
@ M_TEM
Definition jinclude.h:160
@ M_SOF13
Definition jinclude.h:113
@ M_RST6
Definition jinclude.h:127
@ M_APP4
Definition jinclude.h:143
@ M_APP5
Definition jinclude.h:144
@ M_SOF1
Definition jinclude.h:100
@ M_SOS
Definition jinclude.h:132
@ M_APP7
Definition jinclude.h:146
@ M_SOF0
Definition jinclude.h:99
@ M_APP0
Definition jinclude.h:139
@ M_APP15
Definition jinclude.h:154
@ M_RST2
Definition jinclude.h:123
@ M_SOF5
Definition jinclude.h:104
@ M_RST1
Definition jinclude.h:122
long INT32
Definition jmorecfg.h:161
char JOCTET
Definition jmorecfg.h:115
unsigned int UINT16
Definition jmorecfg.h:149
#define LOCAL(type)
Definition jmorecfg.h:186
#define METHODDEF(type)
Definition jmorecfg.h:184
#define GETJOCTET(value)
Definition jmorecfg.h:119
short UINT8
Definition jmorecfg.h:140
const int jpeg_natural_order[]
Definition jutils.c:53
struct jpeg_decompress_struct * j_decompress_ptr
Definition jpeglib.h:263
struct jpeg_common_struct * j_common_ptr
Definition jpeglib.h:261
struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr
Definition jpeglib.h:193
int desired
Definition jpeglib.h:1038
int const JOCTET unsigned int datalen
Definition jpeglib.h:951
int marker_code
Definition jpeglib.h:1006
#define NUM_ARITH_TBLS
Definition jpeglib.h:45
int unsigned int length_limit
Definition jpeglib.h:1007
int marker
Definition jpeglib.h:950
#define JPEG_REACHED_SOS
Definition jpeglib.h:996
#define NUM_HUFF_TBLS
Definition jpeglib.h:44
@ JCS_UNKNOWN
Definition jpeglib.h:207
int jpeg_marker_parser_method routine
Definition jpeglib.h:1012
int val
Definition jpeglib.h:956
JSAMPIMAGE data
Definition jpeglib.h:945
#define JPEG_REACHED_EOI
Definition jpeglib.h:997
int version
Definition jpeglib.h:901
#define NUM_QUANT_TBLS
Definition jpeglib.h:43
#define JPOOL_PERMANENT
Definition jpeglib.h:748
#define JPOOL_IMAGE
Definition jpeglib.h:749
#define MAX_COMPS_IN_SCAN
Definition jpeglib.h:46
#define JPEG_SUSPENDED
Definition jpeglib.h:965
#define DCTSIZE2
Definition jpeglib.h:42
png_uint_32 length
Definition png.c:2247
Definition jpeglib.h:100
Definition jpeglib.h:83
UINT16 quantval[DCTSIZE2]
Definition jpeglib.h:88
Definition jpeglib.h:116
UINT8 arith_dc_L[NUM_ARITH_TBLS]
Definition jpeglib.h:541
UINT8 arith_ac_K[NUM_ARITH_TBLS]
Definition jpeglib.h:543
UINT8 arith_dc_U[NUM_ARITH_TBLS]
Definition jpeglib.h:542
Definition jpegint.h:189
Definition jpeglib.h:195
Definition jdmarker.c:22
unsigned int length_limit_APPn[16]
Definition jdmarker.c:31
jpeg_marker_parser_method process_APPn[16]
Definition jdmarker.c:27
jpeg_marker_parser_method process_COM
Definition jdmarker.c:26
jpeg_saved_marker_ptr cur_marker
Definition jdmarker.c:34
unsigned int length_limit_COM
Definition jdmarker.c:30
struct jpeg_marker_reader pub
Definition jdmarker.c:23
unsigned int bytes_read
Definition jdmarker.c:35
int n
Definition crypt.c:458
#define GLOBAL(g)
Definition crypt.c:87
return c
Definition crypt.c:175
if(GLOBAL(newzip))
Definition crypt.c:475
b
Definition crypt.c:628
typedef int(UZ_EXP MsgFn)()
#define TRUE
Definition unzpriv.h:1295
#define FALSE
Definition unzpriv.h:1298
_WDL_CSTRING_PREFIX void INT_PTR count
Definition wdlcstring.h:263
#define FAR
Definition zconf.h:270