MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__decode_jpeg_image

Function stbi__decode_jpeg_image

Source/Utils/stb_image.h:3411–3446  ·  view source on GitHub ↗

decode image to YCbCr format

Source from the content-addressed store, hash-verified

3409
3410// decode image to YCbCr format
3411static int stbi__decode_jpeg_image(stbi__jpeg *j)
3412{
3413 int m;
3414 for (m = 0; m < 4; m++) {
3415 j->img_comp[m].raw_data = NULL;
3416 j->img_comp[m].raw_coeff = NULL;
3417 }
3418 j->restart_interval = 0;
3419 if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0;
3420 m = stbi__get_marker(j);
3421 while (!stbi__EOI(m)) {
3422 if (stbi__SOS(m)) {
3423 if (!stbi__process_scan_header(j)) return 0;
3424 if (!stbi__parse_entropy_coded_data(j)) return 0;
3425 if (j->marker == STBI__MARKER_none ) {
3426 j->marker = stbi__skip_jpeg_junk_at_end(j);
3427 // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0
3428 }
3429 m = stbi__get_marker(j);
3430 if (STBI__RESTART(m))
3431 m = stbi__get_marker(j);
3432 } else if (stbi__DNL(m)) {
3433 int Ld = stbi__get16be(j->s);
3434 stbi__uint32 NL = stbi__get16be(j->s);
3435 if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG");
3436 if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG");
3437 m = stbi__get_marker(j);
3438 } else {
3439 if (!stbi__process_marker(j, m)) return 1;
3440 m = stbi__get_marker(j);
3441 }
3442 }
3443 if (j->progressive)
3444 stbi__jpeg_finish(j);
3445 return 1;
3446}
3447
3448// static jfif-centered resampling (across block boundaries)
3449

Callers 1

load_jpeg_imageFunction · 0.85

Calls 9

stbi__decode_jpeg_headerFunction · 0.85
stbi__get_markerFunction · 0.85
stbi__get16beFunction · 0.85
stbi__errFunction · 0.85
stbi__process_markerFunction · 0.85
stbi__jpeg_finishFunction · 0.85

Tested by

no test coverage detected