Lines Matching refs:cinfo
113 * At all times, cinfo->src->next_input_byte and ->bytes_in_buffer reflect
119 #define INPUT_VARS(cinfo) \
120 struct jpeg_source_mgr * datasrc = (cinfo)->src; \
125 #define INPUT_SYNC(cinfo) \
130 #define INPUT_RELOAD(cinfo) \
138 #define MAKE_BYTE_AVAIL(cinfo,action) \
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); \
156 #define INPUT_2BYTES(cinfo,V,action) \
157 MAKESTMT( MAKE_BYTE_AVAIL(cinfo,action); \
160 MAKE_BYTE_AVAIL(cinfo,action); \
169 * in cinfo->unread_marker; input restart point is just after the marker.
186 * On resumption, cinfo->unread_marker still contains the marker code,
197 get_soi (j_decompress_ptr cinfo)
202 TRACEMS(cinfo, 1, JTRC_SOI);
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;
218 cinfo->jpeg_color_space = JCS_UNKNOWN;
219 cinfo->CCIR601_sampling = FALSE; /* Assume non-CCIR sampling??? */
221 cinfo->saw_JFIF_marker = FALSE;
222 cinfo->JFIF_major_version = 1; /* set default JFIF APP0 values */
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;
237 get_sof (j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
243 INPUT_VARS(cinfo);
245 cinfo->progressive_mode = is_prog;
246 cinfo->arith_code = is_arith;
248 INPUT_2BYTES(cinfo, length, return FALSE);
250 INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
251 INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
252 INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
253 INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);
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) /* do only once, even if suspend */
275 cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
276 ((j_common_ptr) cinfo, JPOOL_IMAGE,
277 cinfo->num_components * SIZEOF(jpeg_component_info));
279 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
282 INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
283 INPUT_BYTE(cinfo, c, return FALSE);
286 INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);
288 TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
293 cinfo->marker->saw_SOF = TRUE;
295 INPUT_SYNC(cinfo);
301 get_sos (j_decompress_ptr cinfo)
307 INPUT_VARS(cinfo);
309 if (! cinfo->marker->saw_SOF)
310 ERREXIT(cinfo, JERR_SOS_NO_SOF);
312 INPUT_2BYTES(cinfo, length, return FALSE);
314 INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */
316 TRACEMS1(cinfo, 1, JTRC_SOS, n);
319 ERREXIT(cinfo, JERR_BAD_LENGTH);
321 cinfo->comps_in_scan = n;
326 INPUT_BYTE(cinfo, cc, return FALSE);
327 INPUT_BYTE(cinfo, c, return FALSE);
329 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
335 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
339 cinfo->cur_comp_info[i] = compptr;
343 TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
348 INPUT_BYTE(cinfo, c, return FALSE);
349 cinfo->Ss = c;
350 INPUT_BYTE(cinfo, c, return FALSE);
351 cinfo->Se = c;
352 INPUT_BYTE(cinfo, c, return FALSE);
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++;
365 INPUT_SYNC(cinfo);
373 get_dac (j_decompress_ptr cinfo)
378 INPUT_VARS(cinfo);
380 INPUT_2BYTES(cinfo, length, return FALSE);
384 INPUT_BYTE(cinfo, index, return FALSE);
385 INPUT_BYTE(cinfo, val, return FALSE);
389 TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
392 ERREXIT1(cinfo, JERR_DAC_INDEX, index);
395 cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;
397 cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);
398 cinfo->arith_dc_U[index] = (UINT8) (val >> 4);
399 if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
400 ERREXIT1(cinfo, JERR_DAC_VALUE, val);
405 ERREXIT(cinfo, JERR_BAD_LENGTH);
407 INPUT_SYNC(cinfo);
413 #define get_dac(cinfo) skip_variable(cinfo)
419 get_dht (j_decompress_ptr cinfo)
427 INPUT_VARS(cinfo);
429 INPUT_2BYTES(cinfo, length, return FALSE);
433 INPUT_BYTE(cinfo, index, return FALSE);
435 TRACEMS1(cinfo, 1, JTRC_DHT, index);
440 INPUT_BYTE(cinfo, bits[i], return FALSE);
446 TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
449 TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
457 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
460 INPUT_BYTE(cinfo, huffval[i], return FALSE);
466 htblptr = &cinfo->ac_huff_tbl_ptrs[index];
468 htblptr = &cinfo->dc_huff_tbl_ptrs[index];
472 ERREXIT1(cinfo, JERR_DHT_INDEX, index);
475 *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
482 ERREXIT(cinfo, JERR_BAD_LENGTH);
484 INPUT_SYNC(cinfo);
490 get_dqt (j_decompress_ptr cinfo)
497 INPUT_VARS(cinfo);
499 INPUT_2BYTES(cinfo, length, return FALSE);
503 INPUT_BYTE(cinfo, n, return FALSE);
507 TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
510 ERREXIT1(cinfo, JERR_DQT_INDEX, n);
512 if (cinfo->quant_tbl_ptrs[n] == NULL)
513 cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
514 quant_ptr = cinfo->quant_tbl_ptrs[n];
518 INPUT_2BYTES(cinfo, tmp, return FALSE);
520 INPUT_BYTE(cinfo, tmp, return FALSE);
525 if (cinfo->err->trace_level >= 2) {
527 TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
540 ERREXIT(cinfo, JERR_BAD_LENGTH);
542 INPUT_SYNC(cinfo);
548 get_dri (j_decompress_ptr cinfo)
553 INPUT_VARS(cinfo);
555 INPUT_2BYTES(cinfo, length, return FALSE);
558 ERREXIT(cinfo, JERR_BAD_LENGTH);
560 INPUT_2BYTES(cinfo, tmp, return FALSE);
562 TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
564 cinfo->restart_interval = tmp;
566 INPUT_SYNC(cinfo);
584 examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
600 cinfo->saw_JFIF_marker = TRUE;
601 cinfo->JFIF_major_version = GETJOCTET(data[5]);
602 cinfo->JFIF_minor_version = GETJOCTET(data[6]);
603 cinfo
604 cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
605 cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
612 if (cinfo->JFIF_major_version != 1)
613 WARNMS2(cinfo, JWRN_JFIF_MAJOR,
614 cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
616 TRACEMS5(cinfo, 1, JTRC_JFIF,
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);
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);
660 examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data,
680 TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
681 cinfo->saw_Adobe_marker = TRUE;
682 cinfo->Adobe_transform = (UINT8) transform;
685 TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining));
691 get_interesting_appn (j_decompress_ptr cinfo)
697 INPUT_VARS(cinfo);
699 INPUT_2BYTES(cinfo, length, return FALSE);
710 INPUT_BYTE(cinfo, b[i], return FALSE);
714 switch (cinfo->unread_marker) {
716 examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length);
719 examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length);
723 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
728 INPUT_SYNC(cinfo);
730 (*cinfo->src->skip_input_data) (cinfo, (long) length);
739 save_marker (j_decompress_ptr cinfo)
742 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
747 INPUT_VARS(cinfo);
751 INPUT_2BYTES(cinfo, length, return FALSE);
756 if (cinfo->unread_marker == (int) M_COM)
759 limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0];
764 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
767 cur_marker->marker = (UINT8) cinfo->unread_marker;
789 INPUT_SYNC(cinfo); /* move the restart point to here */
792 MAKE_BYTE_AVAIL(cinfo, return FALSE);
804 if (cinfo->marker_list == NULL) {
805 cinfo->marker_list = cur_marker;
807 jpeg_saved_marker_ptr prev = cinfo->marker_list;
820 switch (cinfo->unread_marker) {
822 examine_app0(cinfo, data, data_length, length);
825 examine_app14(cinfo, data, data_length, length);
828 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
834 INPUT_SYNC(cinfo); /* do before skip_input_data */
836 (*cinfo->src->skip_input_data) (cinfo, (long) length);
845 skip_variable (j_decompress_ptr cinfo)
849 INPUT_VARS(cinfo);
851 INPUT_2BYTES(cinfo, length, return FALSE);
854 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);
856 INPUT_SYNC(cinfo); /* do before skip_input_data */
858 (*cinfo->src->skip_input_data) (cinfo, (long) length);
865 * Find the next JPEG marker, save it in cinfo->unread_marker.
867 * in that case cinfo->unread_marker is unchanged.
874 next_marker (j_decompress_ptr cinfo)
877 INPUT_VARS(cinfo);
880 INPUT_BYTE(cinfo, c, return FALSE);
887 cinfo->marker->discarded_bytes++;
888 INPUT_SYNC(cinfo);
889 INPUT_BYTE(cinfo, c, return FALSE);
897 INPUT_BYTE(cinfo, c, return FALSE);
904 cinfo->marker->discarded_bytes += 2;
905 INPUT_SYNC(cinfo);
908 if (cinfo->marker->discarded_bytes != 0) {
909 WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
910 cinfo->marker->discarded_bytes = 0;
913 cinfo->unread_marker = c;
915 INPUT_SYNC(cinfo);
921 first_marker (j_decompress_ptr cinfo)
930 INPUT_VARS(cinfo);
932 INPUT_BYTE(cinfo, c, return FALSE);
933 INPUT_BYTE(cinfo, c2, return FALSE);
935 ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
937 cinfo->unread_marker = c2;
939 INPUT_SYNC(cinfo);
952 read_markers (j_decompress_ptr cinfo)
958 if (cinfo->unread_marker == 0) {
959 if (! cinfo->marker->saw_SOI) {
960 if (! first_marker(cinfo))
963 if (! next_marker(cinfo))
971 if (cinfo->marker->current_sos_marker_position == -1)
972 cinfo->marker->current_sos_marker_position =
973 jget_input_stream_position(cinfo) - 2;
975 /* At this point cinfo->unread_marker contains the marker code and the
979 switch (cinfo->unread_marker) {
981 if (! get_soi(cinfo))
987 if (! get_sof(cinfo, FALSE, FALSE))
992 cinfo->marker->current_sos_marker_position = -1;
993 if (! get_sof(cinfo, TRUE, FALSE))
998 if (! get_sof(cinfo, FALSE, TRUE))
1003 if (! get_sof(cinfo, TRUE, TRUE))
1017 ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);
1021 if (! get_sos(cinfo))
1023 cinfo->unread_marker = 0; /* processed the marker */
1027 TRACEMS(cinfo, 1, JTRC_EOI);
1028 cinfo->unread_marker = 0; /* processed the marker */
1032 if (! get_dac(cinfo))
1037 if (! get_dht(cinfo))
1042 if (! get_dqt(cinfo))
1047 if (! get_dri(cinfo))
1067 if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[
1068 cinfo->unread_marker - (int) M_APP0]) (cinfo))
1073 if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
1086 TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);
1090 if (! skip_variable(cinfo))
1100 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
1104 cinfo->unread_marker = 0;
1115 * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder
1117 * cinfo->unread_marker will be reset to 0 before returning; if not reset,
1122 read_restart_marker (j_decompress_ptr cinfo)
1126 if (cinfo->unread_marker == 0) {
1127 if (! next_marker(cinfo))
1131 if (cinfo->unread_marker ==
1132 ((int) M_RST0 + cinfo->marker->next_restart_num)) {
1134 TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
1135 cinfo->unread_marker = 0;
1139 if (! (*cinfo->src->resync_to_restart) (cinfo,
1140 cinfo->marker->next_restart_num))
1145 cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
1160 * a nonzero restart interval has been declared.) cinfo->unread_marker is
1165 * Note that cinfo->unread_marker is treated as a marker appearing before
1180 * 3. Leave the marker unread (by failing to zero cinfo->unread_marker).
1201 jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
1203 int marker = cinfo->unread_marker;
1207 WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
1225 TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
1229 cinfo->unread_marker = 0;
1233 if (! next_marker(cinfo))
1235 marker = cinfo->unread_marker;
1250 get_sos_marker_position(j_decompress_ptr cinfo, huffman_index *index)
1256 while (cinfo->src->bytes_in_buffer > 0) {
1258 jpeg_configure_huffman_index_scan(cinfo, index, count++,
1259 cinfo->marker->current_sos_marker_position);
1261 while(next_marker(cinfo) &&
1262 cinfo->unread_marker >= M_RST0 && cinfo->unread_marker <= M_RST7)
1264 cinfo->marker->current_sos_marker_position =
1265 jget_input_stream_position(cinfo) - 2;
1266 retcode = read_markers(cinfo);
1278 reset_marker_reader (j_decompress_ptr cinfo)
1280 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1282 cinfo->comp_info = NULL; /* until allocated by get_sof */
1283 cinfo->input_scan_number = 0; /* no SOS seen yet */
1284 cinfo->unread_marker = 0; /* no pending marker */
1298 jinit_marker_reader (j_decompress_ptr cinfo)
1305 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
1307 cinfo->marker = (struct jpeg_marker_reader *) marker;
1331 reset_marker_reader(cinfo);
1342 jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
1345 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1352 maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct);
1380 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
1391 jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,
1394 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1401 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);