| 3387 | } |
| 3388 | |
| 3389 | static stbi_uc stbi__skip_jpeg_junk_at_end(stbi__jpeg *j) |
| 3390 | { |
| 3391 | // some JPEGs have junk at end, skip over it but if we find what looks |
| 3392 | // like a valid marker, resume there |
| 3393 | while (!stbi__at_eof(j->s)) { |
| 3394 | stbi_uc x = stbi__get8(j->s); |
| 3395 | while (x == 0xff) { // might be a marker |
| 3396 | if (stbi__at_eof(j->s)) return STBI__MARKER_none; |
| 3397 | x = stbi__get8(j->s); |
| 3398 | if (x != 0x00 && x != 0xff) { |
| 3399 | // not a stuffed zero or lead-in to another marker, looks |
| 3400 | // like an actual marker, return it |
| 3401 | return x; |
| 3402 | } |
| 3403 | // stuffed zero has x=0 now which ends the loop, meaning we go |
| 3404 | // back to regular scan loop. |
| 3405 | // repeated 0xff keeps trying to read the next byte of the marker. |
| 3406 | } |
| 3407 | } |
| 3408 | return STBI__MARKER_none; |
| 3409 | } |
| 3410 | |
| 3411 | // decode image to YCbCr format |
| 3412 | static int stbi__decode_jpeg_image(stbi__jpeg *j) |
no test coverage detected