15 #define JPEG_INTERNALS 94 jpeg_marker_parser_method process_COM;
95 jpeg_marker_parser_method process_APPn[16];
98 unsigned int length_limit_COM;
99 unsigned int length_limit_APPn[16];
103 unsigned int bytes_read;
119 #define INPUT_VARS(cinfo) \ 120 struct jpeg_source_mgr * datasrc = (cinfo)->src; \ 121 const JOCTET * next_input_byte = datasrc->next_input_byte; \ 122 size_t bytes_in_buffer = datasrc->bytes_in_buffer 125 #define INPUT_SYNC(cinfo) \ 126 ( datasrc->next_input_byte = next_input_byte, \ 127 datasrc->bytes_in_buffer = bytes_in_buffer ) 130 #define INPUT_RELOAD(cinfo) \ 131 ( next_input_byte = datasrc->next_input_byte, \ 132 bytes_in_buffer = datasrc->bytes_in_buffer ) 138 #define MAKE_BYTE_AVAIL(cinfo,action) \ 139 if (bytes_in_buffer == 0) { \ 140 if (! (*datasrc->fill_input_buffer) (cinfo)) \ 142 INPUT_RELOAD(cinfo); \ 148 #define INPUT_BYTE(cinfo,V,action) \ 149 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ 151 V = GETJOCTET(*next_input_byte++); ) 156 #define INPUT_2BYTES(cinfo,V,action) \ 157 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \ 159 V = ((unsigned int) GETJOCTET(*next_input_byte++)) << 8; \ 160 MAKE_BYTE_AVAIL(cinfo,action); \ 162 V += GETJOCTET(*next_input_byte++); ) 204 if (cinfo->marker->saw_SOI)
205 ERREXIT(cinfo, JERR_SOI_DUPLICATE);
210 cinfo->arith_dc_L[
i] = 0;
211 cinfo->arith_dc_U[
i] = 1;
212 cinfo->arith_ac_K[
i] = 5;
214 cinfo->restart_interval = 0;
219 cinfo->CCIR601_sampling =
FALSE;
221 cinfo->saw_JFIF_marker =
FALSE;
222 cinfo->JFIF_major_version = 1;
223 cinfo->JFIF_minor_version = 1;
224 cinfo->density_unit = 0;
225 cinfo->X_density = 1;
226 cinfo->Y_density = 1;
227 cinfo->saw_Adobe_marker =
FALSE;
228 cinfo->Adobe_transform = 0;
230 cinfo->marker->saw_SOI =
TRUE;
245 cinfo->progressive_mode = is_prog;
246 cinfo->arith_code = is_arith;
257 TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
258 (
int) cinfo->image_width, (
int) cinfo->image_height,
259 cinfo->num_components);
261 if (cinfo->marker->saw_SOF)
262 ERREXIT(cinfo, JERR_SOF_DUPLICATE);
267 if (cinfo->image_height <= 0 || cinfo->image_width <= 0
268 || cinfo->num_components <= 0)
269 ERREXIT(cinfo, JERR_EMPTY_IMAGE);
271 if (
length != (cinfo->num_components * 3))
272 ERREXIT(cinfo, JERR_BAD_LENGTH);
274 if (cinfo->comp_info ==
NULL)
279 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
288 TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
293 cinfo->marker->saw_SOF =
TRUE;
309 if (! cinfo->marker->saw_SOF)
310 ERREXIT(cinfo, JERR_SOS_NO_SOF);
319 ERREXIT(cinfo, JERR_BAD_LENGTH);
321 cinfo->comps_in_scan =
n;
325 for (
i = 0;
i <
n;
i++) {
329 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
335 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
343 TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
353 cinfo->Ah = (
c >> 4) & 15;
354 cinfo->Al = (
c ) & 15;
356 TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
357 cinfo->Ah, cinfo->Al);
360 cinfo->marker->next_restart_num = 0;
363 cinfo->input_scan_number++;
370 #ifdef D_ARITH_CODING_SUPPORTED 389 TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
392 ERREXIT1(cinfo, JERR_DAC_INDEX, index);
400 ERREXIT1(cinfo, JERR_DAC_VALUE, val);
405 ERREXIT(cinfo, JERR_BAD_LENGTH);
413 #define get_dac(cinfo) skip_variable(cinfo) 432 while (length > 16) {
435 TRACEMS1(cinfo, 1, JTRC_DHT, index);
439 for (i = 1; i <= 16; i++) {
447 bits[1], bits[2], bits[3], bits[4],
448 bits[5], bits[6], bits[7], bits[8]);
450 bits[9], bits[10], bits[11], bits[12],
451 bits[13], bits[14], bits[15], bits[16]);
456 if (count > 256 || ((
INT32) count) > length)
457 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
459 for (i = 0; i <
count; i++)
466 htblptr = &cinfo->ac_huff_tbl_ptrs[
index];
468 htblptr = &cinfo->dc_huff_tbl_ptrs[
index];
472 ERREXIT1(cinfo, JERR_DHT_INDEX, index);
474 if (*htblptr ==
NULL)
478 MEMCOPY((*htblptr)->huffval, huffval,
SIZEOF((*htblptr)->huffval));
482 ERREXIT(cinfo, JERR_BAD_LENGTH);
514 quant_ptr = cinfo->quant_tbl_ptrs[
n];
525 if (cinfo->err->trace_level >= 2) {
540 ERREXIT(cinfo, JERR_BAD_LENGTH);
558 ERREXIT(cinfo, JERR_BAD_LENGTH);
578 #define APP0_DATA_LEN 14 579 #define APP14_DATA_LEN 12 580 #define APPN_DATA_LEN 14 600 cinfo->saw_JFIF_marker =
TRUE;
601 cinfo->JFIF_major_version =
GETJOCTET(data[5]);
602 cinfo->JFIF_minor_version =
GETJOCTET(data[6]);
603 cinfo->density_unit =
GETJOCTET(data[7]);
612 if (cinfo->JFIF_major_version != 1)
613 WARNMS2(cinfo, JWRN_JFIF_MAJOR,
614 cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
617 cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
618 cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
621 TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL,
626 TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (
int) totallen);
627 }
else if (datalen >= 6 &&
639 TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (
int) totallen);
642 TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (
int) totallen);
645 TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (
int) totallen);
648 TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
654 TRACEMS1(cinfo, 1, JTRC_APP0, (
int) totallen);
696 unsigned int i, numtoread;
709 for (
i = 0;
i < numtoread;
i++)
730 (*cinfo->
src->skip_input_data) (cinfo, (
long)
length);
736 #ifdef SAVE_MARKERS_SUPPORTED 744 unsigned int bytes_read, data_length;
749 if (cur_marker ==
NULL) {
757 limit =
marker->length_limit_COM;
761 limit = (
unsigned int)
length;
766 cur_marker->next =
NULL;
768 cur_marker->original_length = (
unsigned int)
length;
769 cur_marker->data_length =
limit;
772 marker->cur_marker = cur_marker;
778 bytes_read = data_length = 0;
783 bytes_read =
marker->bytes_read;
784 data_length = cur_marker->data_length;
785 data = cur_marker->data + bytes_read;
788 while (bytes_read < data_length) {
790 marker->bytes_read = bytes_read;
794 while (bytes_read < data_length && bytes_in_buffer > 0) {
795 *
data++ = *next_input_byte++;
802 if (cur_marker !=
NULL) {
808 while (prev->next !=
NULL)
810 prev->next = cur_marker;
813 data = cur_marker->data;
814 length = cur_marker->original_length - data_length;
829 (
int) (data_length +
length));
836 (*cinfo->
src->skip_input_data) (cinfo, (
long)
length);
858 (*cinfo->
src->skip_input_data) (cinfo, (
long)
length);
934 if (
c != 0xFF || c2 != (
int)
M_SOI)
1130 if (! (*cinfo->
src->resync_to_restart) (cinfo,
1251 marker->pub.discarded_bytes = 0;
1270 SIZEOF(my_marker_reader));
1281 marker->length_limit_COM = 0;
1282 for (i = 0; i < 16; i++) {
1284 marker->length_limit_APPn[
i] = 0;
1297 #ifdef SAVE_MARKERS_SUPPORTED 1305 jpeg_marker_parser_method processor;
1332 marker->process_COM = processor;
1350 jpeg_marker_parser_method
routine)
GLenum GLuint GLenum GLsizei length
my_marker_reader * my_marker_ptr
UINT16 quantval[DCTSIZE2]
unsigned int discarded_bytes
jpeg_component_info * comp_info
UINT8 arith_dc_U[NUM_ARITH_TBLS]
get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
const int jpeg_natural_order[]
first_marker(j_decompress_ptr cinfo)
struct jpeg_common_struct * j_common_ptr
int unsigned int length_limit
#define INPUT_BYTE(cinfo, V, action)
struct jpeg_marker_reader * marker
read_restart_marker(j_decompress_ptr cinfo)
#define INPUT_VARS(cinfo)
#define ERREXIT(cinfo, code)
#define TRACEMS2(cinfo, lvl, code, p1, p2)
struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr
jpeg_alloc_huff_table(j_common_ptr cinfo)
int const JOCTET unsigned int datalen
get_sos(j_decompress_ptr cinfo)
get_dri(j_decompress_ptr cinfo)
jpeg_save_markers(j_decompress_ptr cinfo, int marker_code, unsigned int length_limit)
GLboolean GLboolean GLboolean b
jpeg_component_info * compptr
UINT8 arith_dc_L[NUM_ARITH_TBLS]
examine_app0(j_decompress_ptr cinfo, JOCTET FAR *data, unsigned int datalen, INT32 remaining)
skip_variable(j_decompress_ptr cinfo)
#define TRACEMS(cinfo, lvl, code)
get_soi(j_decompress_ptr cinfo)
jpeg_saved_marker_ptr marker_list
#define WARNMS2(cinfo, code, p1, p2)
UINT8 arith_ac_K[NUM_ARITH_TBLS]
#define TRACEMS1(cinfo, lvl, code, p1)
#define MEMCOPY(dest, src, size)
#define INPUT_SYNC(cinfo)
#define TRACEMS5(cinfo, lvl, code, p1, p2, p3, p4, p5)
my_marker_writer * my_marker_ptr
GLsizei GLsizei GLenum GLenum const GLvoid * data
unsigned int restart_interval
get_interesting_appn(j_decompress_ptr cinfo)
save_marker(j_decompress_ptr cinfo)
#define ERREXIT1(cinfo, code, p1)
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
jpeg_set_marker_processor(j_decompress_ptr cinfo, int marker_code, jpeg_marker_parser_method routine)
int jpeg_marker_parser_method routine
jpeg_alloc_quant_table(j_common_ptr cinfo)
reset_marker_reader(j_decompress_ptr cinfo)
struct jpeg_source_mgr * src
if(!abbox) return FT_THROW(Invalid_Argument)
#define TRACEMS8(cinfo, lvl, code, p1, p2, p3, p4, p5, p6, p7, p8)
read_markers(j_decompress_ptr cinfo)
GLuint GLenum GLenum transform
GLuint GLuint GLsizei count
#define TRACEMS3(cinfo, lvl, code, p1, p2, p3)
jinit_marker_reader(j_decompress_ptr cinfo)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
#define TRACEMS4(cinfo, lvl, code, p1, p2, p3, p4)
get_dqt(j_decompress_ptr cinfo)
get_dht(j_decompress_ptr cinfo)
#define ERREXIT2(cinfo, code, p1, p2)
#define INPUT_2BYTES(cinfo, V, action)
JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]
next_marker(j_decompress_ptr cinfo)
#define MAX_COMPS_IN_SCAN
examine_app14(j_decompress_ptr cinfo, JOCTET FAR *data, unsigned int datalen, INT32 remaining)
#define MAKE_BYTE_AVAIL(cinfo, action)