| 205 | |
| 206 | |
| 207 | LOCAL(void) |
| 208 | initial_setup (j_decompress_ptr cinfo) |
| 209 | /* Called once, when first SOS marker is reached */ |
| 210 | { |
| 211 | int ci; |
| 212 | jpeg_component_info *compptr; |
| 213 | |
| 214 | /* Make sure image isn't bigger than I can handle */ |
| 215 | if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION || |
| 216 | (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION) |
| 217 | ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION); |
| 218 | |
| 219 | /* Only 8 to 12 bits data precision are supported for DCT based JPEG */ |
| 220 | if (cinfo->data_precision < 8 || cinfo->data_precision > 12) |
| 221 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
| 222 | |
| 223 | /* Check that number of components won't exceed internal array sizes */ |
| 224 | if (cinfo->num_components > MAX_COMPONENTS) |
| 225 | ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components, |
| 226 | MAX_COMPONENTS); |
| 227 | |
| 228 | /* Compute maximum sampling factors; check factor validity */ |
| 229 | cinfo->max_h_samp_factor = 1; |
| 230 | cinfo->max_v_samp_factor = 1; |
| 231 | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
| 232 | ci++, compptr++) { |
| 233 | if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR || |
| 234 | compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR) |
| 235 | ERREXIT(cinfo, JERR_BAD_SAMPLING); |
| 236 | cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor, |
| 237 | compptr->h_samp_factor); |
| 238 | cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor, |
| 239 | compptr->v_samp_factor); |
| 240 | } |
| 241 | |
| 242 | /* Derive block_size, natural_order, and lim_Se */ |
| 243 | if (cinfo->is_baseline || (cinfo->progressive_mode && |
| 244 | cinfo->comps_in_scan)) { /* no pseudo SOS marker */ |
| 245 | cinfo->block_size = DCTSIZE; |
| 246 | cinfo->natural_order = jpeg_natural_order; |
| 247 | cinfo->lim_Se = DCTSIZE2-1; |
| 248 | } else |
| 249 | switch (cinfo->Se) { |
| 250 | case (1*1-1): |
| 251 | cinfo->block_size = 1; |
| 252 | cinfo->natural_order = jpeg_natural_order; /* not needed */ |
| 253 | cinfo->lim_Se = cinfo->Se; |
| 254 | break; |
| 255 | case (2*2-1): |
| 256 | cinfo->block_size = 2; |
| 257 | cinfo->natural_order = jpeg_natural_order2; |
| 258 | cinfo->lim_Se = cinfo->Se; |
| 259 | break; |
| 260 | case (3*3-1): |
| 261 | cinfo->block_size = 3; |
| 262 | cinfo->natural_order = jpeg_natural_order3; |
| 263 | cinfo->lim_Se = cinfo->Se; |
| 264 | break; |
no test coverage detected