MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__skip_jpeg_junk_at_end

Function stbi__skip_jpeg_junk_at_end

include/stb/stb_image.h:3389–3409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3387}
3388
3389static 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
3412static int stbi__decode_jpeg_image(stbi__jpeg *j)

Callers 1

stbi__decode_jpeg_imageFunction · 0.85

Calls 2

stbi__at_eofFunction · 0.85
stbi__get8Function · 0.85

Tested by

no test coverage detected