mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 00:52:18 +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
@@ -26,7 +26,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix) {
|
|||||||
int32_t fourcc;
|
int32_t fourcc;
|
||||||
const char* magic;
|
const char* magic;
|
||||||
} table[] = {
|
} table[] = {
|
||||||
{0x57424D50, "\x01\x00\x00"}, // WBMP
|
{0x30302020, "\x01\x00\x00"}, // '00 'be (see § below)
|
||||||
{0x424D5020, "\x01\x42\x4D"}, // BMP
|
{0x424D5020, "\x01\x42\x4D"}, // BMP
|
||||||
{0x47494620, "\x03\x47\x49\x46\x38"}, // GIF
|
{0x47494620, "\x03\x47\x49\x46\x38"}, // GIF
|
||||||
{0x54494646, "\x03\x49\x49\x2A\x00"}, // TIFF (little-endian)
|
{0x54494646, "\x03\x49\x49\x2A\x00"}, // TIFF (little-endian)
|
||||||
@@ -89,15 +89,20 @@ match:
|
|||||||
return 0x5750384C; // 'WP8L'be
|
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) {
|
if (prefix.len < 4) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if ((prefix.ptr[2] == 0x00) ||
|
} else if ((prefix.ptr[2] != 0x00) &&
|
||||||
((prefix.ptr[2] < 0x80) && (prefix.ptr[3] == 0x00))) {
|
((prefix.ptr[2] >= 0x80) || (prefix.ptr[3] != 0x00))) {
|
||||||
// Reject 0-width or 0-height WBMP images. Binary data starting with
|
// Roughly speaking, this could be a non-degenerate (non-0-width and
|
||||||
// multiple 0x00 NUL bytes is quite common.
|
// non-0-height) WBMP image.
|
||||||
return 0;
|
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;
|
return fourcc;
|
||||||
}
|
}
|
||||||
@@ -15411,7 +15411,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix) {
|
|||||||
int32_t fourcc;
|
int32_t fourcc;
|
||||||
const char* magic;
|
const char* magic;
|
||||||
} table[] = {
|
} table[] = {
|
||||||
{0x57424D50, "\x01\x00\x00"}, // WBMP
|
{0x30302020, "\x01\x00\x00"}, // '00 'be (see § below)
|
||||||
{0x424D5020, "\x01\x42\x4D"}, // BMP
|
{0x424D5020, "\x01\x42\x4D"}, // BMP
|
||||||
{0x47494620, "\x03\x47\x49\x46\x38"}, // GIF
|
{0x47494620, "\x03\x47\x49\x46\x38"}, // GIF
|
||||||
{0x54494646, "\x03\x49\x49\x2A\x00"}, // TIFF (little-endian)
|
{0x54494646, "\x03\x49\x49\x2A\x00"}, // TIFF (little-endian)
|
||||||
@@ -15474,15 +15474,20 @@ match:
|
|||||||
return 0x5750384C; // 'WP8L'be
|
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) {
|
if (prefix.len < 4) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if ((prefix.ptr[2] == 0x00) ||
|
} else if ((prefix.ptr[2] != 0x00) &&
|
||||||
((prefix.ptr[2] < 0x80) && (prefix.ptr[3] == 0x00))) {
|
((prefix.ptr[2] >= 0x80) || (prefix.ptr[3] != 0x00))) {
|
||||||
// Reject 0-width or 0-height WBMP images. Binary data starting with
|
// Roughly speaking, this could be a non-degenerate (non-0-width and
|
||||||
// multiple 0x00 NUL bytes is quite common.
|
// non-0-height) WBMP image.
|
||||||
return 0;
|
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;
|
return fourcc;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ files were generated by `script/extract-palette-indexes.go`. The `*.tokens`
|
|||||||
files were generated by `script/print-json-token-debug-format.c`.
|
files were generated by `script/print-json-token-debug-format.c`.
|
||||||
|
|
||||||
The `*.jpeg` files are usually the canonical versions of the test/data images,
|
The `*.jpeg` files are usually the canonical versions of the test/data images,
|
||||||
and other versions (`*.bmp`, `*.gif`, `*.png`, `*.tiff`) were generated by
|
and other versions (`*.bmp`, `*.gif`, `*.png` etc) were usually generated by
|
||||||
ImageMagick's `convert` command line tool. The `*.wbmp` versions were generated
|
ImageMagick's `convert` command line tool. The `*.wbmp` versions were generated
|
||||||
by the `script/convert-png-to-wbmp.go` command line tool. The `*.webp` versions
|
by the `script/convert-png-to-wbmp.go` command line tool. The `*.webp` versions
|
||||||
were generated by the cwebp command line tool. The `*.no-ancillary.png` files
|
were generated by the cwebp command line tool. The `*.no-ancillary.png` files
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Reference in new issue
Block a user