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

Function stbi__pic_info

Source/Utils/stb_image.h:7420–7475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7418
7419#ifndef STBI_NO_PIC
7420static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp)
7421{
7422 int act_comp=0,num_packets=0,chained,dummy;
7423 stbi__pic_packet packets[10];
7424
7425 if (!x) x = &dummy;
7426 if (!y) y = &dummy;
7427 if (!comp) comp = &dummy;
7428
7429 if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) {
7430 stbi__rewind(s);
7431 return 0;
7432 }
7433
7434 stbi__skip(s, 88);
7435
7436 *x = stbi__get16be(s);
7437 *y = stbi__get16be(s);
7438 if (stbi__at_eof(s)) {
7439 stbi__rewind( s);
7440 return 0;
7441 }
7442 if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) {
7443 stbi__rewind( s );
7444 return 0;
7445 }
7446
7447 stbi__skip(s, 8);
7448
7449 do {
7450 stbi__pic_packet *packet;
7451
7452 if (num_packets==sizeof(packets)/sizeof(packets[0]))
7453 return 0;
7454
7455 packet = &packets[num_packets++];
7456 chained = stbi__get8(s);
7457 packet->size = stbi__get8(s);
7458 packet->type = stbi__get8(s);
7459 packet->channel = stbi__get8(s);
7460 act_comp |= packet->channel;
7461
7462 if (stbi__at_eof(s)) {
7463 stbi__rewind( s );
7464 return 0;
7465 }
7466 if (packet->size != 8) {
7467 stbi__rewind( s );
7468 return 0;
7469 }
7470 } while (chained);
7471
7472 *comp = (act_comp & 0x10 ? 4 : 3);
7473
7474 return 1;
7475}
7476#endif
7477

Callers 1

stbi__info_mainFunction · 0.85

Calls 6

stbi__pic_is4Function · 0.85
stbi__rewindFunction · 0.85
stbi__skipFunction · 0.85
stbi__get16beFunction · 0.85
stbi__at_eofFunction · 0.85
stbi__get8Function · 0.85

Tested by

no test coverage detected