mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 00:47:28 +01:00
Have etc__magic_number_guess_fourcc find ICO
This commit is contained in:
1 parent
d557bc3836
commit
a9a6332be2
4 files changed
+25
-15
No files matched your search
@@ -15411,7 +15411,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix) {
|
||||
int32_t fourcc;
|
||||
const char* magic;
|
||||
} table[] = {
|
||||
{0x57424D50, "\x01\x00\x00"}, // WBMP
|
||||
{0x30302020, "\x01\x00\x00"}, // '00 'be (see § below)
|
||||
{0x424D5020, "\x01\x42\x4D"}, // BMP
|
||||
{0x47494620, "\x03\x47\x49\x46\x38"}, // GIF
|
||||
{0x54494646, "\x03\x49\x49\x2A\x00"}, // TIFF (little-endian)
|
||||
@@ -15474,15 +15474,20 @@ match:
|
||||
return 0x5750384C; // 'WP8L'be
|
||||
}
|
||||
}
|
||||
} else if (fourcc == 0x57424D50) { // 'WBMP'be
|
||||
} else if (fourcc == 0x30302020) { // '00 'be
|
||||
// Binary data starting with multiple 0x00 NUL bytes is quite common.
|
||||
if (prefix.len < 4) {
|
||||
return -1;
|
||||
} else if ((prefix.ptr[2] == 0x00) ||
|
||||
((prefix.ptr[2] < 0x80) && (prefix.ptr[3] == 0x00))) {
|
||||
// Reject 0-width or 0-height WBMP images. Binary data starting with
|
||||
// multiple 0x00 NUL bytes is quite common.
|
||||
return 0;
|
||||
} else if ((prefix.ptr[2] != 0x00) &&
|
||||
((prefix.ptr[2] >= 0x80) || (prefix.ptr[3] != 0x00))) {
|
||||
// Roughly speaking, this could be a non-degenerate (non-0-width and
|
||||
// non-0-height) WBMP image.
|
||||
return 0x57424D50; // 'WBMP'be
|
||||
} else if (((prefix.ptr[2] == 0x01) || (prefix.ptr[2] == 0x02)) &&
|
||||
(prefix.ptr[3] == 0x00)) {
|
||||
return 0x49434F20; // 'ICO 'be
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return fourcc;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user