| OLD | NEW |
| 1 /* | 1 /* |
| 2 * jdmarker.c | 2 * jdmarker.c |
| 3 * | 3 * |
| 4 * Copyright (C) 1991-1998, Thomas G. Lane. | 4 * Copyright (C) 1991-1998, Thomas G. Lane. |
| 5 * Copyright (C) 2012, D. R. Commander. |
| 5 * This file is part of the Independent JPEG Group's software. | 6 * This file is part of the Independent JPEG Group's software. |
| 6 * For conditions of distribution and use, see the accompanying README file. | 7 * For conditions of distribution and use, see the accompanying README file. |
| 7 * | 8 * |
| 8 * This file contains routines to decode JPEG datastream markers. | 9 * This file contains routines to decode JPEG datastream markers. |
| 9 * Most of the complexity arises from our desire to support input | 10 * Most of the complexity arises from our desire to support input |
| 10 * suspension: if not all of the data for a marker is available, | 11 * suspension: if not all of the data for a marker is available, |
| 11 * we must exit back to the application. On resumption, we reprocess | 12 * we must exit back to the application. On resumption, we reprocess |
| 12 * the marker. | 13 * the marker. |
| 13 */ | 14 */ |
| 14 | 15 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 316 |
| 316 TRACEMS1(cinfo, 1, JTRC_SOS, n); | 317 TRACEMS1(cinfo, 1, JTRC_SOS, n); |
| 317 | 318 |
| 318 if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) | 319 if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN) |
| 319 ERREXIT(cinfo, JERR_BAD_LENGTH); | 320 ERREXIT(cinfo, JERR_BAD_LENGTH); |
| 320 | 321 |
| 321 cinfo->comps_in_scan = n; | 322 cinfo->comps_in_scan = n; |
| 322 | 323 |
| 323 /* Collect the component-spec parameters */ | 324 /* Collect the component-spec parameters */ |
| 324 | 325 |
| 326 for (i = 0; i < cinfo->num_components; i++) |
| 327 cinfo->cur_comp_info[i] = NULL; |
| 328 |
| 325 for (i = 0; i < n; i++) { | 329 for (i = 0; i < n; i++) { |
| 326 INPUT_BYTE(cinfo, cc, return FALSE); | 330 INPUT_BYTE(cinfo, cc, return FALSE); |
| 327 INPUT_BYTE(cinfo, c, return FALSE); | 331 INPUT_BYTE(cinfo, c, return FALSE); |
| 328 | 332 |
| 329 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 333 for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 330 ci++, compptr++) { | 334 ci++, compptr++) { |
| 331 if (cc == compptr->component_id) | 335 if (cc == compptr->component_id && !cinfo->cur_comp_info[ci]) |
| 332 goto id_found; | 336 goto id_found; |
| 333 } | 337 } |
| 334 | 338 |
| 335 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); | 339 ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc); |
| 336 | 340 |
| 337 id_found: | 341 id_found: |
| 338 | 342 |
| 339 cinfo->cur_comp_info[i] = compptr; | 343 cinfo->cur_comp_info[i] = compptr; |
| 340 compptr->dc_tbl_no = (c >> 4) & 15; | 344 compptr->dc_tbl_no = (c >> 4) & 15; |
| 341 compptr->ac_tbl_no = (c ) & 15; | 345 compptr->ac_tbl_no = (c ) & 15; |
| (...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 { | 1493 { |
| 1490 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; | 1494 my_marker_ptr marker = (my_marker_ptr) cinfo->marker; |
| 1491 | 1495 |
| 1492 if (marker_code == (int) M_COM) | 1496 if (marker_code == (int) M_COM) |
| 1493 marker->process_COM = routine; | 1497 marker->process_COM = routine; |
| 1494 else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) | 1498 else if (marker_code >= (int) M_APP0 && marker_code <= (int) M_APP15) |
| 1495 marker->process_APPn[marker_code - (int) M_APP0] = routine; | 1499 marker->process_APPn[marker_code - (int) M_APP0] = routine; |
| 1496 else | 1500 else |
| 1497 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); | 1501 ERREXIT1(cinfo, JERR_UNKNOWN_MARKER, marker_code); |
| 1498 } | 1502 } |
| OLD | NEW |