15 #define JPEG_INTERNALS
97 #define INPUT_VARS(cinfo) \
98 struct jpeg_source_mgr * datasrc = (cinfo)->src; \
99 const JOCTET * next_input_byte = datasrc->next_input_byte; \
100 size_t bytes_in_buffer = datasrc->bytes_in_buffer
103 #define INPUT_SYNC(cinfo) \
104 ( datasrc->next_input_byte = next_input_byte, \
105 datasrc->bytes_in_buffer = bytes_in_buffer )
108 #define INPUT_RELOAD(cinfo) \
109 ( next_input_byte = datasrc->next_input_byte, \
110 bytes_in_buffer = datasrc->bytes_in_buffer )
116 #define MAKE_BYTE_AVAIL(cinfo,action) \
117 if (bytes_in_buffer == 0) { \
118 if (! (*datasrc->fill_input_buffer) (cinfo)) \
120 INPUT_RELOAD(cinfo); \
127 #define INPUT_BYTE(cinfo,V,action) \
128 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
129 V = GETJOCTET(*next_input_byte++); )
134 #define INPUT_2BYTES(cinfo,V,action) \
135 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
136 V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \
137 MAKE_BYTE_AVAIL(cinfo,action); \
138 V += GETJOCTET(*next_input_byte++); )
174 ERREXIT(cinfo, JERR_SOI_DUPLICATE);
229 ERREXIT(cinfo, JERR_SOF_DUPLICATE);
236 ERREXIT(cinfo, JERR_EMPTY_IMAGE);
239 ERREXIT(cinfo, JERR_BAD_LENGTH);
246 for (ci = 0, compptr = cinfo->
comp_info; ci < cinfo->num_components;
255 TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
277 ERREXIT(cinfo, JERR_SOS_NO_SOF);
284 ERREXIT(cinfo, JERR_BAD_LENGTH);
292 for (i = 0; i <
n; i++) {
296 for (ci = 0, compptr = cinfo->
comp_info; ci < cinfo->num_components;
302 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
310 TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
320 cinfo->
Ah = (c >> 4) & 15;
321 cinfo->
Al = (
c ) & 15;
323 TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->
Ss, cinfo->
Se,
324 cinfo->
Ah, cinfo->
Al);
353 for (buffp = 0; buffp <
JFIF_LEN; buffp++)
357 if (b[0]==0x4A && b[1]==0x46 && b[2]==0x49 && b[3]==0x46 && b[4]==0) {
365 WARNMS2(cinfo, JWRN_JFIF_MAJOR, b[5], b[6]);
367 TRACEMS2(cinfo, 1, JTRC_JFIF_MINOR, b[5], b[6]);
376 TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, b[12], b[13]);
378 TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (
int) length);
381 TRACEMS1(cinfo, 1, JTRC_APP0, (
int) length + JFIF_LEN);
385 TRACEMS1(cinfo, 1, JTRC_APP0, (
int) length);
390 (*cinfo->
src->skip_input_data) (cinfo, (
long)
length);
413 for (buffp = 0; buffp <
ADOBE_LEN; buffp++)
417 if (b[0]==0x41 && b[1]==0x64 && b[2]==0x6F && b[3]==0x62 && b[4]==0x65) {
419 version = (b[5] << 8) + b[6];
420 flags0 = (b[7] << 8) + b[8];
421 flags1 = (b[9] << 8) + b[10];
423 TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
428 TRACEMS1(cinfo, 1, JTRC_APP14, (
int) length + ADOBE_LEN);
432 TRACEMS1(cinfo, 1, JTRC_APP14, (
int) length);
437 (*cinfo->
src->skip_input_data) (cinfo, (
long)
length);
460 TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
463 ERREXIT1(cinfo, JERR_DAC_INDEX, index);
471 ERREXIT1(cinfo, JERR_DAC_VALUE, val);
497 TRACEMS1(cinfo, 1, JTRC_DHT, index);
501 for (i = 1; i <= 16; i++) {
509 bits[1], bits[2], bits[3], bits[4],
510 bits[5], bits[6], bits[7], bits[8]);
512 bits[9], bits[10], bits[11], bits[12],
513 bits[13], bits[14], bits[15], bits[16]);
515 if (count > 256 || ((
INT32) count) > length)
516 ERREXIT(cinfo, JERR_DHT_COUNTS);
518 for (i = 0; i <
count; i++)
531 ERREXIT1(cinfo, JERR_DHT_INDEX, index);
533 if (*htblptr ==
NULL)
537 MEMCOPY((*htblptr)->huffval, huffval,
SIZEOF((*htblptr)->huffval));
563 TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
570 quant_ptr = cinfo->quant_tbl_ptrs[
n];
588 length -= DCTSIZE2+1;
608 ERREXIT(cinfo, JERR_BAD_LENGTH);
633 (*cinfo->
src->skip_input_data) (cinfo, (
long) length - 2
L);
709 if (c != 0xFF || c2 != (
int)
M_SOI)
710 ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
904 if (! (*cinfo->
src->resync_to_restart) (cinfo,
972 WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
976 if (marker < (
int)
M_SOF0)
978 else if (marker < (
int)
M_RST0 || marker > (
int)
M_RST7)
981 if (marker == ((
int)
M_RST0 + ((desired+1) & 7)) ||
982 marker == ((
int)
M_RST0 + ((desired+2) & 7)))
984 else if (marker == ((
int)
M_RST0 + ((desired-1) & 7)) ||
985 marker == ((
int)
M_RST0 + ((desired-2) & 7)))
990 TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
1046 for (i = 0; i < 16; i++)
LOCAL boolean get_sos(j_decompress_ptr cinfo)
UINT16 quantval[DCTSIZE2]
LOCAL boolean get_dqt(j_decompress_ptr cinfo)
unsigned int discarded_bytes
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
LOCAL boolean get_dri(j_decompress_ptr cinfo)
METHODDEF void reset_marker_reader(j_decompress_ptr cinfo)
jpeg_component_info * comp_info
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]
UINT8 arith_dc_U[NUM_ARITH_TBLS]
struct jpeg_common_struct * j_common_ptr
LOCAL boolean get_dac(j_decompress_ptr cinfo)
#define INPUT_BYTE(cinfo, V, action)
struct jpeg_marker_reader * marker
#define INPUT_VARS(cinfo)
GLOBAL JHUFF_TBL * jpeg_alloc_huff_table(j_common_ptr cinfo)
#define ERREXIT(cinfo, code)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
METHODDEF boolean skip_variable(j_decompress_ptr cinfo)
UINT8 arith_dc_L[NUM_ARITH_TBLS]
METHODDEF int read_markers(j_decompress_ptr cinfo)
GLOBAL void jinit_marker_reader(j_decompress_ptr cinfo)
#define TRACEMS(cinfo, lvl, code)
#define WARNMS2(cinfo, code, p1, p2)
LOCAL boolean get_dht(j_decompress_ptr cinfo)
UINT8 arith_ac_K[NUM_ARITH_TBLS]
#define TRACEMS1(cinfo, lvl, code, p1)
LOCAL boolean first_marker(j_decompress_ptr cinfo)
#define MEMCOPY(dest, src, size)
METHODDEF boolean read_restart_marker(j_decompress_ptr cinfo)
GLuint GLuint GLsizei count
#define INPUT_SYNC(cinfo)
unsigned int restart_interval
LOCAL boolean get_soi(j_decompress_ptr cinfo)
LOCAL boolean next_marker(j_decompress_ptr cinfo)
#define ERREXIT1(cinfo, code, p1)
jpeg_marker_parser_method process_COM
LOCAL boolean get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
struct jpeg_source_mgr * src
jpeg_marker_parser_method process_APPn[16]
GLOBAL boolean jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
GLsizei const GLcharARB const GLint * length
#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8)
METHODDEF boolean get_app14(j_decompress_ptr cinfo)
GLOBAL JQUANT_TBL * jpeg_alloc_quant_table(j_common_ptr cinfo)
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3)
#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4)
GLuint GLenum GLenum transform
#define ERREXIT2(cinfo, code, p1, p2)
#define INPUT_2BYTES(cinfo, V, action)
jpeg_marker_parser_method read_restart_marker
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]
#define MAX_COMPS_IN_SCAN
J_COLOR_SPACE jpeg_color_space
METHODDEF boolean get_app0(j_decompress_ptr cinfo)