| 175 | #ifdef C_MULTISCAN_FILES_SUPPORTED |
| 176 | |
| 177 | LOCAL(void) |
| 178 | validate_script (j_compress_ptr cinfo) |
| 179 | /* Verify that the scan script in cinfo->scan_info[] is valid; also |
| 180 | * determine whether it uses progressive JPEG, and set cinfo->progressive_mode. |
| 181 | */ |
| 182 | { |
| 183 | const jpeg_scan_info * scanptr; |
| 184 | int scanno, ncomps, ci, coefi, thisi; |
| 185 | int Ss, Se, Ah, Al; |
| 186 | boolean component_sent[MAX_COMPONENTS]; |
| 187 | #ifdef C_PROGRESSIVE_SUPPORTED |
| 188 | int * last_bitpos_ptr; |
| 189 | int last_bitpos[MAX_COMPONENTS][DCTSIZE2]; |
| 190 | /* -1 until that coefficient has been seen; then last Al for it */ |
| 191 | #endif |
| 192 | |
| 193 | if (cinfo->num_scans <= 0) |
| 194 | ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0); |
| 195 | |
| 196 | /* For sequential JPEG, all scans must have Ss=0, Se=DCTSIZE2-1; |
| 197 | * for progressive JPEG, no scan can have this. |
| 198 | */ |
| 199 | scanptr = cinfo->scan_info; |
| 200 | if (scanptr->Ss != 0 || scanptr->Se != DCTSIZE2-1) { |
| 201 | #ifdef C_PROGRESSIVE_SUPPORTED |
| 202 | cinfo->progressive_mode = TRUE; |
| 203 | last_bitpos_ptr = & last_bitpos[0][0]; |
| 204 | for (ci = 0; ci < cinfo->num_components; ci++) |
| 205 | for (coefi = 0; coefi < DCTSIZE2; coefi++) |
| 206 | *last_bitpos_ptr++ = -1; |
| 207 | #else |
| 208 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
| 209 | #endif |
| 210 | } else { |
| 211 | cinfo->progressive_mode = FALSE; |
| 212 | for (ci = 0; ci < cinfo->num_components; ci++) |
| 213 | component_sent[ci] = FALSE; |
| 214 | } |
| 215 | |
| 216 | for (scanno = 1; scanno <= cinfo->num_scans; scanptr++, scanno++) { |
| 217 | /* Validate component indexes */ |
| 218 | ncomps = scanptr->comps_in_scan; |
| 219 | if (ncomps <= 0 || ncomps > MAX_COMPS_IN_SCAN) |
| 220 | ERREXIT2(cinfo, JERR_COMPONENT_COUNT, ncomps, MAX_COMPS_IN_SCAN); |
| 221 | for (ci = 0; ci < ncomps; ci++) { |
| 222 | thisi = scanptr->component_index[ci]; |
| 223 | if (thisi < 0 || thisi >= cinfo->num_components) |
| 224 | ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); |
| 225 | /* Components must appear in SOF order within each scan */ |
| 226 | if (ci > 0 && thisi <= scanptr->component_index[ci-1]) |
| 227 | ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno); |
| 228 | } |
| 229 | /* Validate progression parameters */ |
| 230 | Ss = scanptr->Ss; |
| 231 | Se = scanptr->Se; |
| 232 | Ah = scanptr->Ah; |
| 233 | Al = scanptr->Al; |
| 234 | if (cinfo->progressive_mode) { |
no outgoing calls
no test coverage detected