10 #define JPEG_INTERNALS 90 jpeg_marker_parser_method process_APPn[16];
94 unsigned int length_limit_APPn[16];
114 #define INPUT_VARS(cinfo) \ 115 struct jpeg_source_mgr * datasrc = (cinfo)->src; \ 116 const JOCTET * next_input_byte = datasrc->next_input_byte; \ 117 size_t bytes_in_buffer = datasrc->bytes_in_buffer 120 #define INPUT_SYNC(cinfo) \ 121 ( datasrc->next_input_byte = next_input_byte, \ 122 datasrc->bytes_in_buffer = bytes_in_buffer ) 125 #define INPUT_RELOAD(cinfo) \ 126 ( next_input_byte = datasrc->next_input_byte, \ 127 bytes_in_buffer = datasrc->bytes_in_buffer ) 133 #define MAKE_BYTE_AVAIL(cinfo,action) \ 134 if (bytes_in_buffer == 0) { \ 135 if (! (*datasrc->fill_input_buffer) (cinfo)) \ 137 INPUT_RELOAD(cinfo); \ 143 #define INPUT_BYTE(cinfo,V,action) \ 144 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ 146 V = GETJOCTET(*next_input_byte++); ) 151 #define INPUT_2BYTES(cinfo,V,action) \ 152 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ 154 V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ 155 MAKE_BYTE_AVAIL(cinfo,action); \ 157 V += GETJOCTET(*next_input_byte++); ) 199 if (cinfo->marker->saw_SOI)
200 ERREXIT(cinfo, JERR_SOI_DUPLICATE);
205 cinfo->arith_dc_L[i] = 0;
206 cinfo->arith_dc_U[i] = 1;
207 cinfo->arith_ac_K[i] = 5;
209 cinfo->restart_interval = 0;
214 cinfo->CCIR601_sampling =
FALSE;
216 cinfo->saw_JFIF_marker =
FALSE;
217 cinfo->JFIF_major_version = 1;
218 cinfo->JFIF_minor_version = 1;
219 cinfo->density_unit = 0;
220 cinfo->X_density = 1;
221 cinfo->Y_density = 1;
222 cinfo->saw_Adobe_marker =
FALSE;
223 cinfo->Adobe_transform = 0;
225 cinfo->marker->saw_SOI =
TRUE;
240 cinfo->progressive_mode = is_prog;
241 cinfo->arith_code = is_arith;
252 TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
253 (
int) cinfo->image_width, (
int) cinfo->image_height,
254 cinfo->num_components);
256 if (cinfo->marker->saw_SOF)
257 ERREXIT(cinfo, JERR_SOF_DUPLICATE);
262 if (cinfo->image_height <= 0 || cinfo->image_width <= 0
263 || cinfo->num_components <= 0)
264 ERREXIT(cinfo, JERR_EMPTY_IMAGE);
266 if (
length != (cinfo->num_components * 3))
267 ERREXIT(cinfo, JERR_BAD_LENGTH);
269 if (cinfo->comp_info == NULL)
274 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
283 TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
288 cinfo->marker->saw_SOF =
TRUE;
304 if (! cinfo->marker->saw_SOF)
305 ERREXIT(cinfo, JERR_SOS_NO_SOF);
314 ERREXIT(cinfo, JERR_BAD_LENGTH);
316 cinfo->comps_in_scan =
n;
320 for (i = 0; i <
n; i++) {
324 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
330 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
334 cinfo->cur_comp_info[i] =
compptr;
338 TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
348 cinfo->Ah = (
c >> 4) & 15;
349 cinfo->Al = (
c ) & 15;
351 TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
352 cinfo->Ah, cinfo->Al);
355 cinfo->marker->next_restart_num = 0;
358 cinfo->input_scan_number++;
365 #ifdef D_ARITH_CODING_SUPPORTED 400 ERREXIT(cinfo, JERR_BAD_LENGTH);
408 #define get_dac(cinfo) skip_variable(cinfo) 434 for (i = 1; i <= 16; i++) {
442 bits[1], bits[2], bits[3], bits[4],
443 bits[5], bits[6], bits[7], bits[8]);
445 bits[9], bits[10], bits[11], bits[12],
446 bits[13], bits[14], bits[15], bits[16]);
452 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
454 for (i = 0; i <
count; i++)
461 htblptr = &cinfo->ac_huff_tbl_ptrs[
index];
463 htblptr = &cinfo->dc_huff_tbl_ptrs[
index];
469 if (*htblptr == NULL)
473 MEMCOPY((*htblptr)->huffval, huffval,
SIZEOF((*htblptr)->huffval));
477 ERREXIT(cinfo, JERR_BAD_LENGTH);
507 if (cinfo->quant_tbl_ptrs[
n] == NULL)
509 quant_ptr = cinfo->quant_tbl_ptrs[
n];
520 if (cinfo->err->trace_level >= 2) {
535 ERREXIT(cinfo, JERR_BAD_LENGTH);
553 ERREXIT(cinfo, JERR_BAD_LENGTH);
559 cinfo->restart_interval = tmp;
573 #define APP0_DATA_LEN 14 574 #define APP14_DATA_LEN 12 575 #define APPN_DATA_LEN 14 595 cinfo->saw_JFIF_marker =
TRUE;
607 if (cinfo->JFIF_major_version != 1)
608 WARNMS2(cinfo, JWRN_JFIF_MAJOR,
609 cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
612 cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
613 cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
616 TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL,
621 TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (
int) totallen);
634 TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (
int) totallen);
637 TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (
int) totallen);
640 TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (
int) totallen);
643 TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
649 TRACEMS1(cinfo, 1, JTRC_APP0, (
int) totallen);
676 cinfo->saw_Adobe_marker =
TRUE;
691 unsigned int i, numtoread;
701 numtoread = (
unsigned int)
length;
704 for (i = 0; i < numtoread; i++)
709 switch (cinfo->unread_marker) {
718 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
725 (*cinfo->src->skip_input_data) (cinfo, (
long)
length);
731 #ifdef SAVE_MARKERS_SUPPORTED 739 unsigned int bytes_read, data_length;
744 if (cur_marker == NULL) {
751 if (cinfo->unread_marker == (
int)
M_COM)
761 cur_marker->next = NULL;
762 cur_marker->marker = (
UINT8) cinfo->unread_marker;
763 cur_marker->original_length = (
unsigned int)
length;
764 cur_marker->data_length =
limit;
767 marker->cur_marker = cur_marker;
773 bytes_read = data_length = 0;
778 bytes_read =
marker->bytes_read;
779 data_length = cur_marker->data_length;
780 data = cur_marker->data + bytes_read;
783 while (bytes_read < data_length) {
785 marker->bytes_read = bytes_read;
789 while (bytes_read < data_length && bytes_in_buffer > 0) {
790 *
data++ = *next_input_byte++;
797 if (cur_marker != NULL) {
799 if (cinfo->marker_list == NULL) {
800 cinfo->marker_list = cur_marker;
803 while (prev->next != NULL)
805 prev->next = cur_marker;
808 data = cur_marker->data;
809 length = cur_marker->original_length - data_length;
812 marker->cur_marker = NULL;
815 switch (cinfo->unread_marker) {
823 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
824 (
int) (data_length +
length));
831 (*cinfo->src->skip_input_data) (cinfo, (
long)
length);
849 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (
int)
length);
853 (*cinfo->src->skip_input_data) (cinfo, (
long)
length);
882 cinfo->marker->discarded_bytes++;
899 cinfo->marker->discarded_bytes += 2;
903 if (cinfo->marker->discarded_bytes != 0) {
904 WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes,
c);
905 cinfo->marker->discarded_bytes = 0;
908 cinfo->unread_marker =
c;
929 if (
c != 0xFF || c2 != (
int)
M_SOI)
932 cinfo->unread_marker = c2;
953 if (cinfo->unread_marker == 0) {
954 if (! cinfo->marker->saw_SOI) {
966 switch (cinfo->unread_marker) {
1003 ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);
1009 cinfo->unread_marker = 0;
1014 cinfo->unread_marker = 0;
1054 cinfo->unread_marker - (
int)
M_APP0]) (cinfo))
1059 if (! (*((
my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
1072 TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);
1086 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
1090 cinfo->unread_marker = 0;
1112 if (cinfo->unread_marker == 0) {
1117 if (cinfo->unread_marker ==
1118 ((
int)
M_RST0 + cinfo->marker->next_restart_num)) {
1120 TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
1121 cinfo->unread_marker = 0;
1125 if (! (*cinfo->src->resync_to_restart) (cinfo,
1126 cinfo->marker->next_restart_num))
1131 cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
1189 int marker = cinfo->unread_marker;
1215 cinfo->unread_marker = 0;
1221 marker = cinfo->unread_marker;
1241 cinfo->comp_info = NULL;
1242 cinfo->input_scan_number = 0;
1243 cinfo->unread_marker = 0;
1246 marker->pub.discarded_bytes = 0;
1247 marker->cur_marker = NULL;
1276 marker->length_limit_COM = 0;
1277 for (i = 0; i < 16; i++) {
1279 marker->length_limit_APPn[i] = 0;
1292 #ifdef SAVE_MARKERS_SUPPORTED 1300 jpeg_marker_parser_method processor;
1327 marker->process_COM = processor;
1345 jpeg_marker_parser_method
routine)
#define INPUT_VARS(cinfo)
jinit_marker_reader(j_decompress_ptr cinfo)
#define INPUT_2BYTES(cinfo, V, action)
GLuint GLuint GLsizei count
UINT16 quantval[DCTSIZE2]
get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
first_marker(j_decompress_ptr cinfo)
skip_variable(j_decompress_ptr cinfo)
#define MAX_COMPS_IN_SCAN
int jpeg_marker_parser_method routine
UINT8 arith_dc_U[NUM_ARITH_TBLS]
const int jpeg_natural_order[]
struct jpeg_common_struct * j_common_ptr
#define ERREXIT(cinfo, code)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr
read_markers(j_decompress_ptr cinfo)
my_marker_reader * my_marker_ptr
#define INPUT_BYTE(cinfo, V, action)
jpeg_component_info * compptr
UINT8 arith_dc_L[NUM_ARITH_TBLS]
#define TRACEMS(cinfo, lvl, code)
get_sos(j_decompress_ptr cinfo)
#define WARNMS2(cinfo, code, p1, p2)
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
UINT8 arith_ac_K[NUM_ARITH_TBLS]
#define TRACEMS1(cinfo, lvl, code, p1)
#define MEMCOPY(dest, src, size)
read_restart_marker(j_decompress_ptr cinfo)
#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5)
int unsigned int length_limit
save_marker(j_decompress_ptr cinfo)
int const JOCTET unsigned int datalen
jpeg_alloc_huff_table(j_common_ptr cinfo)
examine_app0(j_decompress_ptr cinfo, JOCTET FAR *data, unsigned int datalen, INT32 remaining)
jpeg_marker_parser_method process_COM
reset_marker_reader(j_decompress_ptr cinfo)
get_dht(j_decompress_ptr cinfo)
jpeg_alloc_quant_table(j_common_ptr cinfo)
#define ERREXIT1(cinfo, code, p1)
get_dqt(j_decompress_ptr cinfo)
jpeg_save_markers(j_decompress_ptr cinfo, int marker_code, unsigned int length_limit)
next_marker(j_decompress_ptr cinfo)
GLuint GLsizei GLsizei * length
#define MAKE_BYTE_AVAIL(cinfo, action)
get_dri(j_decompress_ptr cinfo)
#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8)
get_soi(j_decompress_ptr cinfo)
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3)
jpeg_saved_marker_ptr cur_marker
#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4)
jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code, jpeg_marker_parser_method routine)
GLuint GLenum GLenum transform
#define ERREXIT2(cinfo, code, p1, p2)
GLsizei GLsizei GLenum GLenum const GLvoid * data
unsigned int length_limit_COM
#define INPUT_SYNC(cinfo)
examine_app14(j_decompress_ptr cinfo, JOCTET FAR *data, unsigned int datalen, INT32 remaining)
get_interesting_appn(j_decompress_ptr cinfo)