| 3362 | #define stbi__SOF_progressive(x) ((x) == 0xc2) |
| 3363 | |
| 3364 | static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) |
| 3365 | { |
| 3366 | int m; |
| 3367 | z->jfif = 0; |
| 3368 | z->app14_color_transform = -1; // valid values are 0,1,2 |
| 3369 | z->marker = STBI__MARKER_none; // initialize cached marker to empty |
| 3370 | m = stbi__get_marker(z); |
| 3371 | if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); |
| 3372 | if (scan == STBI__SCAN_type) return 1; |
| 3373 | m = stbi__get_marker(z); |
| 3374 | while (!stbi__SOF(m)) { |
| 3375 | if (!stbi__process_marker(z,m)) return 0; |
| 3376 | m = stbi__get_marker(z); |
| 3377 | while (m == STBI__MARKER_none) { |
| 3378 | // some files have extra padding after their blocks, so ok, we'll scan |
| 3379 | if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); |
| 3380 | m = stbi__get_marker(z); |
| 3381 | } |
| 3382 | } |
| 3383 | z->progressive = stbi__SOF_progressive(m); |
| 3384 | if (!stbi__process_frame_header(z, scan)) return 0; |
| 3385 | return 1; |
| 3386 | } |
| 3387 | |
| 3388 | static stbi_uc stbi__skip_jpeg_junk_at_end(stbi__jpeg *j) |
| 3389 | { |
no test coverage detected