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 if (cinfo->cur_comp_info[pi] == compptr)
349 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
354 INPUT_BYTE(cinfo, c, return FALSE);
355 cinfo->Ss = c;
356 INPUT_BYTE(cinfo, c, return FALSE);
357 cinfo->Se = c;
358 INPUT_BYTE(cinfo, c, return FALSE);
359 cinfo->Ah = (c >> 4) & 15;
360 cinfo->Al = (c ) & 15;
362 TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
363 cinfo->Ah, cinfo->Al);
366 cinfo->marker->next_restart_num = 0;
369 cinfo->input_scan_number++;
371 INPUT_SYNC(cinfo);
379 get_dac (j_decompress_ptr cinfo)
384 INPUT_VARS(cinfo);
386 INPUT_2BYTES(cinfo, length, return FALSE);
390 INPUT_BYTE(cinfo, index, return FALSE);
391 INPUT_BYTE(cinfo, val, return FALSE);
395 TRACEMS2(cinfo, 1, JTRC_DAC, index, val);
398 ERREXIT1(cinfo, JERR_DAC_INDEX, index);
401 cinfo->arith_ac_K[index-NUM_ARITH_TBLS] = (UINT8) val;
403 cinfo->arith_dc_L[index] = (UINT8) (val & 0x0F);
404 cinfo->arith_dc_U[index] = (UINT8) (val >> 4);
405 if (cinfo->arith_dc_L[index] > cinfo->arith_dc_U[index])
406 ERREXIT1(cinfo, JERR_DAC_VALUE, val);
411 ERREXIT(cinfo, JERR_BAD_LENGTH);
413 INPUT_SYNC(cinfo);
419 #define get_dac(cinfo) skip_variable(cinfo)
425 get_dht (j_decompress_ptr cinfo)
433 INPUT_VARS(cinfo);
435 INPUT_2BYTES(cinfo, length, return FALSE);
439 INPUT_BYTE(cinfo, index, return FALSE);
441 TRACEMS1(cinfo, 1, JTRC_DHT, index);
446 INPUT_BYTE(cinfo, bits[i], return FALSE);
452 TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
455 TRACEMS8(cinfo, 2, JTRC_HUFFBITS,
463 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
466 INPUT_BYTE(cinfo, huffval[i], return FALSE);
474 htblptr = &cinfo->ac_huff_tbl_ptrs[index];
476 htblptr = &cinfo->dc_huff_tbl_ptrs[index];
480 ERREXIT1(cinfo, JERR_DHT_INDEX, index);
483 *htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
490 ERREXIT(cinfo, JERR_BAD_LENGTH);
492 INPUT_SYNC(cinfo);
498 get_dqt (j_decompress_ptr cinfo)
505 INPUT_VARS(cinfo);
507 INPUT_2BYTES(cinfo, length, return FALSE);
511 INPUT_BYTE(cinfo, n, return FALSE);
515 TRACEMS2(cinfo, 1, JTRC_DQT, n, prec);
518 ERREXIT1(cinfo, JERR_DQT_INDEX, n);
520 if (cinfo->quant_tbl_ptrs[n] == NULL)
521 cinfo->quant_tbl_ptrs[n] = jpeg_alloc_quant_table((j_common_ptr) cinfo);
522 quant_ptr = cinfo->quant_tbl_ptrs[n];
526 INPUT_2BYTES(cinfo, tmp, return FALSE);
528 INPUT_BYTE(cinfo, tmp, return FALSE);
533 if (cinfo->err->trace_level >= 2) {
535 TRACEMS8(cinfo, 2, JTRC_QUANTVALS,
548 ERREXIT(cinfo, JERR_BAD_LENGTH);
550 INPUT_SYNC(cinfo);
556 get_dri (j_decompress_ptr cinfo)
561 INPUT_VARS(cinfo);
563 INPUT_2BYTES(cinfo, length, return FALSE);
566 ERREXIT(cinfo, JERR_BAD_LENGTH);
568 INPUT_2BYTES(cinfo, tmp, return FALSE);
570 TRACEMS1(cinfo, 1, JTRC_DRI, tmp);
572 cinfo->restart_interval = tmp;
574 INPUT_SYNC(cinfo);
592 examine_app0 (j_decompress_ptr cinfo, JOCTET FAR * data,
608 cinfo->saw_JFIF_marker = TRUE;
609 cinfo->JFIF_major_version = GETJOCTET(data[5]);
610 cinfo->JFIF_minor_version = GETJOCTET(data[6]);
611 cinfo->density_unit = GETJOCTET(data[7]);
612 cinfo->X_density = (GETJOCTET(data[8]) << 8) + GETJOCTET(data[9]);
613 cinfo->Y_density = (GETJOCTET(data[10]) << 8) + GETJOCTET(data[11]);
620 if (cinfo->JFIF_major_version != 1)
621 WARNMS2(cinfo, JWRN_JFIF_MAJOR,
622 cinfo->JFIF_major_version, cinfo->JFIF_minor_version);
624 TRACEMS5(cinfo, 1, JTRC_JFIF,
625 cinfo->JFIF_major_version, cinfo->JFIF_minor_version,
626 cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
629 TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL,
634 TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) totallen);
647 TRACEMS1(cinfo, 1, JTRC_THUMB_JPEG, (int) totallen);
650 TRACEMS1(cinfo, 1, JTRC_THUMB_PALETTE, (int) totallen);
653 TRACEMS1(cinfo, 1, JTRC_THUMB_RGB, (int) totallen);
656 TRACEMS2(cinfo, 1, JTRC_JFIF_EXTENSION,
662 TRACEMS1(cinfo, 1, JTRC_APP0, (int) totallen);
668 examine_app14 (j_decompress_ptr cinfo, JOCTET FAR * data,
688 TRACEMS4(cinfo, 1, JTRC_ADOBE, version, flags0, flags1, transform);
689 cinfo->saw_Adobe_marker = TRUE;
690 cinfo->Adobe_transform = (UINT8) transform;
693 TRACEMS1(cinfo, 1, JTRC_APP14, (int) (datalen + remaining));
699 get_interesting_appn (j_decompress_ptr cinfo)
705 INPUT_VARS(cinfo);
707 INPUT_2BYTES(cinfo, length, return FALSE);
718 INPUT_BYTE(cinfo, b[i], return FALSE);
722 switch (cinfo->unread_marker) {
724 examine_app0(cinfo, (JOCTET FAR *) b, numtoread, length);
727 examine_app14(cinfo, (JOCTET FAR *) b, numtoread, length);
731 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
736 INPUT_SYNC(cinfo);
738 (*cinfo->src->skip_input_data) (cinfo, (long) length);
747 save_marker (j_decompress_ptr cinfo)
750 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
755 INPUT_VARS(cinfo);
759 INPUT_2BYTES(cinfo, length, return FALSE);
764 if (cinfo->unread_marker == (int) M_COM)
767 limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0];
772 (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,
775 cur_marker->marker = (UINT8) cinfo->unread_marker;
797 INPUT_SYNC(cinfo); /* move the restart point to here */
800 MAKE_BYTE_AVAIL(cinfo, return FALSE);
812 if (cinfo->marker_list == NULL) {
813 cinfo->marker_list = cur_marker;
815 jpeg_saved_marker_ptr prev = cinfo->marker_list;
828 switch (cinfo->unread_marker) {
830 examine_app0(cinfo, data, data_length, length);
833 examine_app14(cinfo, data, data_length, length);
836 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker,
842 INPUT_SYNC(cinfo); /* do before skip_input_data */
844 (*cinfo->src->skip_input_data) (cinfo, (long) length);
853 skip_variable (j_decompress_ptr cinfo)
857 INPUT_VARS(cinfo);
859 INPUT_2BYTES(cinfo, length, return FALSE);
862 TRACEMS2(cinfo, 1, JTRC_MISC_MARKER, cinfo->unread_marker, (int) length);
864 INPUT_SYNC(cinfo); /* do before skip_input_data */
866 (*cinfo->src->skip_input_data) (cinfo, (long) length);
873 * Find the next JPEG marker, save it in cinfo->unread_marker.
875 * in that case cinfo->unread_marker is unchanged.
882 next_marker (j_decompress_ptr cinfo)
885 INPUT_VARS(cinfo);
888 INPUT_BYTE(cinfo, c, return FALSE);
895 cinfo->marker->discarded_bytes++;
896 INPUT_SYNC(cinfo);
897 INPUT_BYTE(cinfo, c, return FALSE);
905 INPUT_BYTE(cinfo, c, return FALSE);
912 cinfo->marker->discarded_bytes += 2;
913 INPUT_SYNC(cinfo);
916 if (cinfo->marker->discarded_bytes != 0) {
917 WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
918 cinfo->marker->discarded_bytes = 0;
921 cinfo->unread_marker = c;
923 INPUT_SYNC(cinfo);
929 first_marker (j_decompress_ptr cinfo)
938 INPUT_VARS(cinfo);
940 INPUT_BYTE(cinfo, c, return FALSE);
941 INPUT_BYTE(cinfo, c2, return FALSE);
943 ERREXIT2(cinfo, JERR_NO_SOI, c, c2);
945 cinfo->unread_marker = c2;
947 INPUT_SYNC(cinfo);
960 read_markers (j_decompress_ptr cinfo)
966 if (cinfo->unread_marker == 0) {
967 if (! cinfo->marker->saw_SOI) {
968 if (! first_marker(cinfo))
971 if (! next_marker(cinfo))
979 if (cinfo->marker->current_sos_marker_position == -1)
980 cinfo->marker->current_sos_marker_position =
981 jget_input_stream_position(cinfo) - 2;
983 /* At this point cinfo->unread_marker contains the marker code and the
987 switch (cinfo->unread_marker) {
989 if (! get_soi(cinfo))
995 if (! get_sof(cinfo, FALSE, FALSE))
1000 cinfo->marker->current_sos_marker_position = -1;
1001 if (! get_sof(cinfo, TRUE, FALSE))
1006 if (! get_sof(cinfo, FALSE, TRUE))
1011 if (! get_sof(cinfo, TRUE, TRUE))
1025 ERREXIT1(cinfo, JERR_SOF_UNSUPPORTED, cinfo->unread_marker);
1029 if (! get_sos(cinfo))
1031 cinfo->unread_marker = 0; /* processed the marker */
1035 TRACEMS(cinfo, 1, JTRC_EOI);
1036 cinfo->unread_marker = 0; /* processed the marker */
1040 if (! get_dac(cinfo))
1045 if (! get_dht(cinfo))
1050 if (! get_dqt(cinfo))
1055 if (! get_dri(cinfo))
1075 if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[
1076 cinfo->unread_marker - (int) M_APP0]) (cinfo))
1081 if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
1094 TRACEMS1(cinfo, 1, JTRC_PARMLESS_MARKER, cinfo->unread_marker);
1098 if (! skip_variable(cinfo))
1108 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, cinfo->unread_marker);
1112 cinfo->unread_marker = 0;
1123 * number of MCUs. cinfo->unread_marker may be nonzero if the entropy decoder
1125 * cinfo->unread_marker will be reset to 0 before returning; if not reset,
1130 read_restart_marker (j_decompress_ptr cinfo)
1134 if (cinfo->unread_marker == 0) {
1135 if (! next_marker(cinfo))
1139 if (cinfo->unread_marker ==
1140 ((int) M_RST0 + cinfo
1142 TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
1143 cinfo->unread_marker = 0;
1147 if (! (*cinfo->src->resync_to_restart) (cinfo,
1148 cinfo->marker->next_restart_num))
1153 cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
1168 * a nonzero restart interval has been declared.) cinfo->unread_marker is
1173 * Note that cinfo->unread_marker is treated as a marker appearing before
1188 * 3. Leave the marker unread (by failing to zero cinfo->unread_marker).
1209 jpeg_resync_to_restart (j_decompress_ptr cinfo, int desired)
1211 int marker = cinfo->unread_marker;
1215 WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
1233 TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
1237 cinfo->unread_marker = 0;
1241 if (! next_marker(cinfo))
1243 marker = cinfo->unread_marker;
1258 get_sos_marker_position(j_decompress_ptr cinfo, huffman_index *index)
1264 while (cinfo->src->bytes_in_buffer > 0) {
1266 jpeg_configure_huffman_index_scan(cinfo, index, count++,
1267 cinfo->marker->current_sos_marker_position);
1269 while(next_marker(cinfo) &&
1270 cinfo->unread_marker >= M_RST0 && cinfo->unread_marker <= M_RST7)
1272 cinfo->marker->current_sos_marker_position =
1273 jget_input_stream_position(cinfo) - 2;
1274 retcode = read_markers(cinfo);
1286 reset_marker_reader (j_decompress_ptr cinfo)
1288 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1290 cinfo->comp_info = NULL; /* until allocated by get_sof */
1291 cinfo->input_scan_number = 0; /* no SOS seen yet */
1292 cinfo->unread_marker = 0; /* no pending marker */
1306 jinit_marker_reader (j_decompress_ptr cinfo)
1313 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
1315 cinfo->marker = (struct jpeg_marker_reader *) marker;
1339 reset_marker_reader(cinfo);
1350 jpeg_save_markers (j_decompress_ptr cinfo, int marker_code,
1353 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1360 maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct);
1388 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);
1399 jpeg_set_marker_processor (j_decompress_ptr cinfo, int marker_code,
1402 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1409 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code);