Lines Matching full:marker
10 * suspension: if not all of the data for a marker is available,
12 * the marker.
20 typedef enum { /* JPEG marker codes */
93 /* Application-overridable marker processing methods */
97 /* Limit on marker data length to save for each marker type */
101 /* Status of COM/APPn marker saving */
102 jpeg_saved_marker_ptr cur_marker; /* NULL if not processing a marker */
103 unsigned int bytes_read; /* data bytes read so far in marker */
168 * Entry condition: JPEG marker itself has been read and its code saved
169 * in cinfo->unread_marker; input restart point is just after the marker.
174 * marker parameters; restart point has not been moved. Same routine
177 * This approach to suspension assumes that all of a marker's parameters
180 * that might not fit. If we are simply dropping such a marker, we use
182 * source manager's shoulders. If we are saving the marker's contents
184 * suspend, the marker processor updates the restart point to the end of
186 * On resumption, cinfo->unread_marker still contains the marker code,
187 * but the data source will point to the next chunk of marker data.
188 * The marker processor must retain internal state to deal with this.
191 * suspension occurs within marker parameters. Other side effects
198 /* Process an SOI marker */
204 if (cinfo->marker->saw_SOI)
230 cinfo->marker->saw_SOI = TRUE;
238 /* Process a SOFn marker */
261 if (cinfo->marker->saw_SOF)
293 cinfo->marker->saw_SOF = TRUE;
302 /* Process a SOS marker */
309 if (! cinfo->marker->saw_SOF)
366 cinfo->marker->next_restart_num = 0;
368 /* Count another SOS marker */
380 /* Process a DAC marker */
426 /* Process a DHT marker */
499 /* Process a DQT marker */
557 /* Process a DRI marker */
595 * Take appropriate action if it is a JFIF marker.
596 * datalen is # of bytes at data[], remaining is length of rest of marker data.
607 /* Found JFIF APP0 marker: save info */
641 /* Found JFIF "JFXX" extension APP0 marker */
671 * Take appropriate action if it is an Adobe marker.
672 * datalen is # of bytes at data[], remaining is length of rest of marker data.
683 /* Found Adobe APP14 marker */
700 /* Process an APP0 or APP14 marker without saving it */
710 /* get the interesting part of the marker data */
748 /* Save an APPn or COM marker into the marker list */
750 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
751 jpeg_saved_marker_ptr cur_marker = marker->cur_marker;
758 /* begin reading a marker */
765 limit = marker->length_limit_COM;
767 limit = marker->length_limit_APPn[cinfo->unread_marker - (int) M_APP0];
770 /* allocate and initialize the marker item */
775 cur_marker->marker = (UINT8) cinfo->unread_marker;
780 marker->cur_marker = cur_marker;
781 marker->bytes_read = 0;
790 /* resume reading a marker */
791 bytes_read = marker->bytes_read;
798 marker->bytes_read = bytes_read;
811 /* Add new marker to end of list */
824 /* Reset to initial state for next marker */
825 marker->cur_marker = NULL;
827 /* Process the marker if interesting; else just make a generic trace msg */
854 /* Skip over an unknown or uninteresting variable-length marker */
873 * Find the next JPEG marker, save it in cinfo->unread_marker.
874 * Returns FALSE if had to suspend before reaching a marker;
877 * Note that the result might not be a valid marker code,
895 cinfo->marker->discarded_bytes++;
908 break; /* found a valid marker, exit loop */
912 cinfo->marker->discarded_bytes += 2;
916 if (cinfo->marker->discarded_bytes != 0) {
917 WARNMS2(cinfo, JWRN_EXTRANEOUS_DATA, cinfo->marker->discarded_bytes, c);
918 cinfo->marker->discarded_bytes = 0;
930 /* Like next_marker, but used to obtain the initial SOI marker. */
931 /* For this marker, we do not allow preceding garbage or fill; otherwise,
962 /* Outer loop repeats once for each marker. */
964 /* Collect the marker proper, unless we already did. */
967 if (! cinfo->marker->saw_SOI) {
977 * Save the position of the fist marker after SOF.
979 if (cinfo->marker->current_sos_marker_position == -1)
980 cinfo->marker->current_sos_marker_position =
983 /* At this point cinfo->unread_marker contains the marker code and the
984 * input point is just past the marker proper, but before any parameters.
1000 cinfo->marker->current_sos_marker_position = -1;
1031 cinfo->unread_marker = 0; /* processed the marker */
1036 cinfo->unread_marker = 0; /* processed the marker */
1075 if (! (*((my_marker_ptr) cinfo->marker)->process_APPn[
1081 if (! (*((my_marker_ptr) cinfo->marker)->process_COM) (cinfo))
1105 * Once the JPEG 3 version-number marker is well defined, this code
1111 /* Successfully processed marker, so reset state variable */
1118 * Read a restart marker, which is expected to appear next in the datastream;
1119 * if the marker is not there, take appropriate recovery action.
1124 * has already read a marker from the data source. Under normal conditions
1126 * it holds a marker which the decoder will be unable to read past.
1132 /* Obtain a marker unless we already did. */
1140 ((int) M_RST0 + cinfo->marker
1141 /* Normal case --- swallow the marker and let entropy decoder continue */
1142 TRACEMS1(cinfo, 3, JTRC_RST, cinfo->marker->next_restart_num);
1148 cinfo->marker->next_restart_num))
1153 cinfo->marker->next_restart_num = (cinfo->marker->next_restart_num + 1) & 7;
1166 * read_restart_marker calls resync_to_restart if it finds a marker other than
1167 * the restart marker it was expecting. (This code is *not* used unless
1169 * the marker code actually found (might be anything, except 0 or FF).
1170 * The desired restart marker number (0..7) is passed as a parameter.
1173 * Note that cinfo->unread_marker is treated as a marker appearing before
1181 * 1. Simply discard the marker and let the entropy decoder resume at next
1183 * 2. Read forward until we find another marker, discarding intervening
1185 * without having to discard data if we don't find the desired marker.
1188 * 3. Leave the marker unread (by failing to zero cinfo->unread_marker).
1190 * inserting dummy zeroes, and then we will reprocess the marker.
1192 * #2 is appropriate if we think the desired marker lies ahead, while #3 is
1193 * appropriate if the found marker is a future restart marker (indicating
1194 * that we have missed the desired restart marker, probably because it got
1196 * We apply #2 or #3 if the found marker is a restart marker no more than
1198 * found marker is not a legal JPEG marker code (it's certainly bogus data).
1199 * If the found marker is a restart marker more than 2 counts away, we do #1
1200 * (too much risk that the marker is erroneous; with luck we will be able to
1202 * For any valid non-restart JPEG marker, we apply #3. This keeps us from
1205 * any other marker would have to be bogus data in that case.
1211 int marker = cinfo->unread_marker;
1215 WARNMS2(cinfo, JWRN_MUST_RESYNC, marker, desired);
1219 if (marker < (int) M_SOF0)
1220 action = 2; /* invalid marker */
1221 else if (marker < (int) M_RST0 || marker > (int) M_RST7)
1222 action = 3; /* valid non-restart marker */
1224 if (marker == ((int) M_RST0 + ((desired+1) & 7)) ||
1225 marker == ((int) M_RST0 + ((desired+2) & 7)))
1227 else if (marker == ((int) M_RST0 + ((desired-1) & 7)) ||
1228 marker == ((int) M_RST0 + ((desired-2) & 7)))
1233 TRACEMS2(cinfo, 4, JTRC_RECOVERY_ACTION, marker, action);
1236 /* Discard marker and let entropy decoder resume processing. */
1240 /* Scan to the next marker, and repeat the decision loop. */
1243 marker = cinfo->unread_marker;
1246 /* Return without advancing past this marker. */
1267 cinfo->marker->current_sos_marker_position);
1268 // Skips scan content to the next non-RST JPEG marker.
1272 cinfo->marker->current_sos_marker_position =
1282 * Reset marker processing state to begin a fresh datastream.
1288 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1292 cinfo->unread_marker = 0; /* no pending marker */
1293 marker->pub.saw_SOI = FALSE; /* set internal state too */
1294 marker->pub.saw_SOF = FALSE;
1295 marker->pub.discarded_bytes = 0;
1296 marker->cur_marker = NULL;
1301 * Initialize the marker reader module.
1308 my_marker_ptr marker;
1312 marker = (my_marker_ptr)
1315 cinfo->marker = (struct jpeg_marker_reader *) marker;
1317 marker->pub.reset_marker_reader = reset_marker_reader;
1318 marker->pub.read_markers = read_markers;
1319 marker->pub.read_restart_marker = read_restart_marker;
1320 marker->pub.get_sos_marker_position = get_sos_marker_position;
1322 // Initialize the SOS marker position to avoid underdefined behavior due to
1324 marker->pub.current_sos_marker_position = 0;
1330 marker->process_COM = skip_variable;
1331 marker->length_limit_COM = 0;
1333 marker->process_APPn[i] = skip_variable;
1334 marker->length_limit_APPn[i] = 0;
1336 marker->process_APPn[0] = get_interesting_appn;
1337 marker->process_APPn[14] = get_interesting_appn;
1338 /* Reset marker processing state */
1353 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1382 marker->process_COM = processor;
1383 marker->length_limit_COM = length_limit;
1385 marker->process_APPn[marker_code - (int) M_APP0] = processor;
1386 marker->length_limit_APPn[marker_code - (int) M_APP0] = length_limit;
1402 my_marker_ptr marker = (my_marker_ptr) cinfo->marker;
1405 marker->process_COM = routine;
1407 marker->process_APPn[marker_code - (int) M_APP0] = routine;