MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__pic_info

Function stbi__pic_info

lite/example/cpp_example/mge/cv/stb_image.h:8121–8178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8119
8120#ifndef STBI_NO_PIC
8121static int stbi__pic_info(stbi__context* s, int* x, int* y, int* comp) {
8122 int act_comp = 0, num_packets = 0, chained, dummy;
8123 stbi__pic_packet packets[10];
8124
8125 if (!x)
8126 x = &dummy;
8127 if (!y)
8128 y = &dummy;
8129 if (!comp)
8130 comp = &dummy;
8131
8132 if (!stbi__pic_is4(s, "\x53\x80\xF6\x34")) {
8133 stbi__rewind(s);
8134 return 0;
8135 }
8136
8137 stbi__skip(s, 88);
8138
8139 *x = stbi__get16be(s);
8140 *y = stbi__get16be(s);
8141 if (stbi__at_eof(s)) {
8142 stbi__rewind(s);
8143 return 0;
8144 }
8145 if ((*x) != 0 && (1 << 28) / (*x) < (*y)) {
8146 stbi__rewind(s);
8147 return 0;
8148 }
8149
8150 stbi__skip(s, 8);
8151
8152 do {
8153 stbi__pic_packet* packet;
8154
8155 if (num_packets == sizeof(packets) / sizeof(packets[0]))
8156 return 0;
8157
8158 packet = &packets[num_packets++];
8159 chained = stbi__get8(s);
8160 packet->size = stbi__get8(s);
8161 packet->type = stbi__get8(s);
8162 packet->channel = stbi__get8(s);
8163 act_comp |= packet->channel;
8164
8165 if (stbi__at_eof(s)) {
8166 stbi__rewind(s);
8167 return 0;
8168 }
8169 if (packet->size != 8) {
8170 stbi__rewind(s);
8171 return 0;
8172 }
8173 } while (chained);
8174
8175 *comp = (act_comp & 0x10 ? 4 : 3);
8176
8177 return 1;
8178}

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