mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
beaf456500 | ||
|
|
5d69840f8e | ||
|
|
721e574398 | ||
|
|
c89b3bc6d8 | ||
|
|
a07eb7704b | ||
|
|
bd27cc0d9b | ||
|
|
d06700f00b | ||
|
|
870cfd18a7 | ||
|
|
ffb64df0a0 | ||
|
|
3215f6afac | ||
|
|
8a722790af | ||
|
|
d270839e3f | ||
|
|
c9fff5b207 | ||
|
|
fb769ff82f | ||
|
|
5e0b2ae0d5 | ||
|
|
a7fb1e8d69 | ||
|
|
ce1f59e9ce | ||
|
|
42b070e487 | ||
|
|
f9c384d6b2 | ||
|
|
d0603f3b94 | ||
|
|
c6aebf819f | ||
|
|
8fe987e0b2 | ||
|
|
d1a9749571 | ||
|
|
f37cfcf554 | ||
|
|
cc9ee184d0 |
No files matched your search
@@ -20,13 +20,18 @@ The LICENSE has changed from a single license (Apache 2) to a dual license
|
||||
- Added `std/lzip`.
|
||||
- Added `std/lzma`.
|
||||
- Added `std/netpbm`.
|
||||
- Added `std/qoi`.
|
||||
- Added `std/sha256`.
|
||||
- Added `std/vp8`.
|
||||
- Added `std/webp`.
|
||||
- Added `std/xxhash32`.
|
||||
- Added `std/xxhash64`.
|
||||
- Added `std/xz`.
|
||||
- Added `WUFFS_BASE__QUIRK_QUALITY`.
|
||||
- Added `WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY`.
|
||||
- Added `WUFFS_CONFIG__DST_PIXEL_FORMAT__ENABLE_ALLOWLIST`.
|
||||
- Added `WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2`.
|
||||
- Added `WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V3`.
|
||||
- Added `wuffs_base__status__is_truncated_input_error`.
|
||||
- Changed `lzw.set_literal_width` to `lzw.set_quirk`.
|
||||
- Changed `set_quirk_enabled!(quirk: u32, enabled: bool)` to `set_quirk!(key:
|
||||
|
||||
@@ -62,10 +62,21 @@ Common quirks:
|
||||
at a cost of being less able to detect data corruption and to deviate from a
|
||||
strict reading of the relevant file format specifications, accepting some
|
||||
inputs that are technically invalid (but otherwise decode fine).
|
||||
- `WUFFS_BASE__QUIRK_QUALITY` configures decoders (for a lossy format, where
|
||||
there is some leeway in "a/the correct decoding") or encoders to use lower
|
||||
than, equal to or higher than the default quality setting. Lower-than-default
|
||||
obviously produces a worse result on some measure. But, if the codec behavior
|
||||
depends on the quirk value, lowering quality can improve other measures:
|
||||
being faster (less time taken), lighter (less "work buffer" memory required),
|
||||
etc. Conversely, asking for higher quality might be a no-op (depending on the
|
||||
codec) but, if it does affect behavior, it typically trades off in the other
|
||||
direction: higher quality and/or tighter (smaller output) but also slower,
|
||||
heavier, etc.
|
||||
|
||||
Package-specific quirks:
|
||||
|
||||
- [GIF image decoder quirks](/std/gif/decode_quirks.wuffs)
|
||||
- [JPEG decoder quirks](/std/jpeg/decode_quirks.wuffs)
|
||||
- [JSON decoder quirks](/std/json/decode_quirks.wuffs)
|
||||
- [LZMA decoder quirks](/std/lzma/decode_quirks.wuffs)
|
||||
- [LZW decoder quirks](/std/lzw/decode_quirks.wuffs)
|
||||
|
||||
@@ -62,6 +62,7 @@ to enable.
|
||||
- `NETPBM: BASE`
|
||||
- `NIE: BASE`
|
||||
- `PNG: BASE, ADLER32, CRC32, DEFLATE, ZLIB`
|
||||
- `QOI: BASE`
|
||||
- `SHA256: BASE`
|
||||
- `TGA: BASE`
|
||||
- `VP8: BASE`
|
||||
|
||||
@@ -129,6 +129,7 @@ In Wuffs syntax, the `base.image_decoder` methods are:
|
||||
- [std/netpbm](/std/netpbm)
|
||||
- [std/nie](/std/nie)
|
||||
- [std/png](/std/png)
|
||||
- [std/qoi](/std/qoi)
|
||||
- [std/tga](/std/tga)
|
||||
- [std/wbmp](/std/wbmp)
|
||||
- [std/webp](/std/webp)
|
||||
|
||||
@@ -66,6 +66,7 @@ https://skia-review.googlesource.com/c/skia/+/290618
|
||||
#define WUFFS_CONFIG__MODULE__NETPBM
|
||||
#define WUFFS_CONFIG__MODULE__NIE
|
||||
#define WUFFS_CONFIG__MODULE__PNG
|
||||
#define WUFFS_CONFIG__MODULE__QOI
|
||||
#define WUFFS_CONFIG__MODULE__TGA
|
||||
#define WUFFS_CONFIG__MODULE__VP8
|
||||
#define WUFFS_CONFIG__MODULE__WBMP
|
||||
@@ -164,6 +165,7 @@ union {
|
||||
wuffs_netpbm__decoder netpbm;
|
||||
wuffs_nie__decoder nie;
|
||||
wuffs_png__decoder png;
|
||||
wuffs_qoi__decoder qoi;
|
||||
wuffs_tga__decoder tga;
|
||||
wuffs_wbmp__decoder wbmp;
|
||||
wuffs_webp__decoder webp;
|
||||
@@ -397,6 +399,16 @@ initialize_image_decoder() {
|
||||
&g_potential_decoders.png);
|
||||
return NULL;
|
||||
|
||||
case WUFFS_BASE__FOURCC__QOI:
|
||||
status = wuffs_qoi__decoder__initialize(
|
||||
&g_potential_decoders.qoi, sizeof g_potential_decoders.qoi,
|
||||
WUFFS_VERSION, WUFFS_INITIALIZE__DEFAULT_OPTIONS);
|
||||
TRY(wuffs_base__status__message(&status));
|
||||
g_image_decoder =
|
||||
wuffs_qoi__decoder__upcast_as__wuffs_base__image_decoder(
|
||||
&g_potential_decoders.qoi);
|
||||
return NULL;
|
||||
|
||||
case WUFFS_BASE__FOURCC__TGA:
|
||||
status = wuffs_tga__decoder__initialize(
|
||||
&g_potential_decoders.tga, sizeof g_potential_decoders.tga,
|
||||
|
||||
@@ -79,6 +79,7 @@ The Escape key quits.
|
||||
#define WUFFS_CONFIG__MODULE__NETPBM
|
||||
#define WUFFS_CONFIG__MODULE__NIE
|
||||
#define WUFFS_CONFIG__MODULE__PNG
|
||||
#define WUFFS_CONFIG__MODULE__QOI
|
||||
#define WUFFS_CONFIG__MODULE__TGA
|
||||
#define WUFFS_CONFIG__MODULE__VP8
|
||||
#define WUFFS_CONFIG__MODULE__WBMP
|
||||
@@ -132,6 +133,7 @@ struct {
|
||||
int remaining_argc;
|
||||
char** remaining_argv;
|
||||
|
||||
bool lower_quality;
|
||||
double screen_gamma;
|
||||
} g_flags = {0};
|
||||
|
||||
@@ -139,7 +141,8 @@ static const char* g_usage =
|
||||
"Usage: imageviewer -flags input0.gif input1.png\n"
|
||||
"\n"
|
||||
"Flags:\n"
|
||||
" -screen_gamma=N.N (default 2.2; 0 disables gamma correction)";
|
||||
" -lower-quality (exercise lower-image-quality code paths)\n"
|
||||
" -screen-gamma=N.N (default 2.2; 0 disables gamma correction)";
|
||||
|
||||
const char* //
|
||||
parse_flags(int argc, char** argv) {
|
||||
@@ -165,7 +168,11 @@ parse_flags(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!strncmp(arg, "screen_gamma=", 13)) {
|
||||
if (!strcmp(arg, "lower-quality")) {
|
||||
g_flags.lower_quality = true;
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(arg, "screen-gamma=", 13)) {
|
||||
g_flags.screen_gamma = atof(arg + 13);
|
||||
continue;
|
||||
}
|
||||
@@ -265,10 +272,17 @@ load_image(const char* filename) {
|
||||
dia_flags |= wuffs_aux::DecodeImageArgFlags::REPORT_METADATA_GAMA;
|
||||
}
|
||||
|
||||
const wuffs_aux::QuirkKeyValuePair wuffs_base__quirk_quality = {
|
||||
WUFFS_BASE__QUIRK_QUALITY,
|
||||
WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY,
|
||||
};
|
||||
|
||||
MyDecodeImageCallbacks callbacks;
|
||||
wuffs_aux::sync_io::FileInput input(file);
|
||||
wuffs_aux::DecodeImageResult res = wuffs_aux::DecodeImage(
|
||||
callbacks, input, wuffs_aux::DecodeImageArgQuirks::DefaultValue(),
|
||||
callbacks, input,
|
||||
wuffs_aux::DecodeImageArgQuirks(&wuffs_base__quirk_quality,
|
||||
g_flags.lower_quality ? 1 : 0),
|
||||
wuffs_aux::DecodeImageArgFlags(dia_flags),
|
||||
// Use PIXEL_BLEND__SRC_OVER, not the default PIXEL_BLEND__SRC, because
|
||||
// we also pass a background color.
|
||||
|
||||
@@ -139,7 +139,7 @@ static const char* g_usage =
|
||||
uint8_t g_dst_array[DST_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__io_buffer g_dst;
|
||||
|
||||
std::vector<uint32_t> g_quirks;
|
||||
std::vector<wuffs_aux::QuirkKeyValuePair> g_quirks;
|
||||
|
||||
struct {
|
||||
int remaining_argc;
|
||||
@@ -149,9 +149,9 @@ struct {
|
||||
std::string //
|
||||
parse_flags(int argc, char** argv) {
|
||||
#if defined(WUFFS_EXAMPLE_SPEAK_JWCC_NOT_JSON)
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
#endif
|
||||
|
||||
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
|
||||
@@ -175,22 +175,22 @@ parse_flags(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (!strcmp(arg, "input-allow-comments")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-extra-comma")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-inf-nan-numbers")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-jwcc") || !strcmp(arg, "jwcc")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ static const char* g_usage =
|
||||
|
||||
// ----
|
||||
|
||||
std::vector<uint32_t> g_quirks;
|
||||
std::vector<wuffs_aux::QuirkKeyValuePair> g_quirks;
|
||||
|
||||
std::string g_dst;
|
||||
|
||||
@@ -239,9 +239,9 @@ parse_flags(int argc, char** argv) {
|
||||
g_flags.max_output_depth = 0xFFFFFFFF;
|
||||
|
||||
#if defined(WUFFS_EXAMPLE_SPEAK_JWCC_NOT_JSON)
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
#endif
|
||||
|
||||
int c = (argc > 0) ? 1 : 0; // Skip argv[0], the program name.
|
||||
@@ -281,22 +281,22 @@ parse_flags(int argc, char** argv) {
|
||||
return g_usage;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-comments")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-extra-comma")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-allow-inf-nan-numbers")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_INF_NAN_NUMBERS, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "input-jwcc") || !strcmp(arg, "jwcc")) {
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE);
|
||||
g_quirks.push_back(WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA);
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_BLOCK, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_COMMENT_LINE, 1});
|
||||
g_quirks.push_back({WUFFS_JSON__QUIRK_ALLOW_EXTRA_COMMA, 1});
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(arg, "q=", 2) || !strncmp(arg, "query=", 6)) {
|
||||
@@ -547,7 +547,7 @@ main1(int argc, char** argv) {
|
||||
TRY(parse_flags(argc, argv));
|
||||
if (!g_flags.strict_json_pointer_syntax) {
|
||||
g_quirks.push_back(
|
||||
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T);
|
||||
{WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T, 1});
|
||||
}
|
||||
|
||||
FILE* in = stdin;
|
||||
|
||||
@@ -77,6 +77,7 @@ isn't otherwise doing anything.
|
||||
#define WUFFS_CONFIG__MODULE__NETPBM
|
||||
#define WUFFS_CONFIG__MODULE__NIE
|
||||
#define WUFFS_CONFIG__MODULE__PNG
|
||||
#define WUFFS_CONFIG__MODULE__QOI
|
||||
#define WUFFS_CONFIG__MODULE__TGA
|
||||
#define WUFFS_CONFIG__MODULE__VP8
|
||||
#define WUFFS_CONFIG__MODULE__WBMP
|
||||
|
||||
@@ -499,11 +499,11 @@ fuzz_cpp(const uint8_t* in_ptr, size_t in_len, uint64_t hash) {
|
||||
const char* json_pointer = json_pointers[hash & 15];
|
||||
hash = wuffs_base__u64__rotate_right(hash, 4);
|
||||
|
||||
std::vector<uint32_t> quirks;
|
||||
std::vector<wuffs_aux::QuirkKeyValuePair> quirks;
|
||||
for (uint32_t i = 0; g_quirks[i]; i++) {
|
||||
uint64_t bit = 1 << (i & 63);
|
||||
if (hash & bit) {
|
||||
quirks.push_back(g_quirks[i]);
|
||||
quirks.push_back({g_quirks[i], 1});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,13 +124,17 @@ const char* //
|
||||
fuzz_swizzle_interleaved_from_slice(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
uint8_t dst_palette_array[1024];
|
||||
uint8_t src_palette_array[1024];
|
||||
if ((src->meta.wi - src->meta.ri) < 2048) {
|
||||
return "fuzz: not enough data";
|
||||
if ((src->meta.wi - src->meta.ri) >= 2048) {
|
||||
memcpy(dst_palette_array, src->data.ptr + src->meta.ri, 1024);
|
||||
src->meta.ri += 1024;
|
||||
memcpy(src_palette_array, src->data.ptr + src->meta.ri, 1024);
|
||||
src->meta.ri += 1024;
|
||||
} else {
|
||||
for (uint32_t i = 0; i < 1024; i++) {
|
||||
dst_palette_array[i] = (uint8_t)i;
|
||||
src_palette_array[i] = (uint8_t)i;
|
||||
}
|
||||
}
|
||||
memcpy(dst_palette_array, src->data.ptr + src->meta.ri, 1024);
|
||||
src->meta.ri += 1024;
|
||||
memcpy(src_palette_array, src->data.ptr + src->meta.ri, 1024);
|
||||
src->meta.ri += 1024;
|
||||
wuffs_base__slice_u8 dst_palette =
|
||||
wuffs_base__make_slice_u8(&dst_palette_array[0], 1024);
|
||||
wuffs_base__slice_u8 src_palette =
|
||||
@@ -178,17 +182,25 @@ fuzz_swizzle_interleaved_from_slice(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
|
||||
// Position dst_slice and src_slice so that reading or writing one byte past
|
||||
// their end will cause a segmentation fault.
|
||||
if ((src->meta.wi - src->meta.ri) < (dst_len + src_len)) {
|
||||
return "fuzz: not enough data";
|
||||
}
|
||||
wuffs_base__slice_u8 dst_slice =
|
||||
wuffs_base__make_slice_u8(dst_alloc + alloc_size - dst_len, dst_len);
|
||||
memcpy(dst_slice.ptr, src->data.ptr + src->meta.ri, dst_len);
|
||||
src->meta.ri += dst_len;
|
||||
wuffs_base__slice_u8 src_slice =
|
||||
wuffs_base__make_slice_u8(src_alloc + alloc_size - src_len, src_len);
|
||||
memcpy(src_slice.ptr, src->data.ptr + src->meta.ri, src_len);
|
||||
src->meta.ri += src_len;
|
||||
|
||||
// Fill in dst_slice and src_slice.
|
||||
if ((src->meta.wi - src->meta.ri) >= (dst_len + src_len)) {
|
||||
memcpy(dst_slice.ptr, src->data.ptr + src->meta.ri, dst_len);
|
||||
src->meta.ri += dst_len;
|
||||
memcpy(src_slice.ptr, src->data.ptr + src->meta.ri, src_len);
|
||||
src->meta.ri += src_len;
|
||||
} else {
|
||||
for (size_t i = 0; i < dst_len; i++) {
|
||||
dst_slice.ptr[i] = (uint8_t)i;
|
||||
}
|
||||
for (size_t i = 0; i < src_len; i++) {
|
||||
src_slice.ptr[i] = (uint8_t)i;
|
||||
}
|
||||
}
|
||||
|
||||
// When manually testing this program, enabling this code should lead to a
|
||||
// segmentation fault.
|
||||
@@ -214,16 +226,34 @@ fuzz_swizzle_ycck(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
wuffs_base__pixel_format dst_pixfmt = wuffs_base__make_pixel_format(
|
||||
pixfmts[(0xFF & (hash >> 0)) % num_pixfmts]);
|
||||
|
||||
uint32_t width = (63 & (hash >> 8)) + 1;
|
||||
uint32_t height = (63 & (hash >> 14)) + 1;
|
||||
uint32_t x_min_incl = (63 & (hash >> 8)) + 1;
|
||||
uint32_t x_max_excl = (63 & (hash >> 14)) + 1;
|
||||
uint32_t y_min_incl = (63 & (hash >> 20)) + 1;
|
||||
uint32_t y_max_excl = (63 & (hash >> 26)) + 1;
|
||||
|
||||
uint32_t width_in_mcus = (3 & (hash >> 20)) + 1;
|
||||
uint32_t height_in_mcus = (3 & (hash >> 22)) + 1;
|
||||
uint32_t width_in_mcus = (3 & (hash >> 32)) + 1;
|
||||
uint32_t height_in_mcus = (3 & (hash >> 34)) + 1;
|
||||
|
||||
uint32_t allow_hv3 = 1 & (hash >> 24);
|
||||
bool is_rgb_or_cmyk = 1 & (hash >> 25);
|
||||
bool triangle_filter_for_2to1 = 1 & (hash >> 26);
|
||||
bool use_4th_component = 1 & (hash >> 27);
|
||||
uint32_t allow_hv3 = 1 & (hash >> 36);
|
||||
bool is_rgb_or_cmyk = 1 & (hash >> 37);
|
||||
bool triangle_filter_for_2to1 = 1 & (hash >> 38);
|
||||
bool use_4th_component = 1 & (hash >> 39);
|
||||
|
||||
if (triangle_filter_for_2to1) {
|
||||
x_min_incl = 0;
|
||||
y_min_incl = 0;
|
||||
} else {
|
||||
if (x_min_incl > x_max_excl) {
|
||||
uint32_t a = x_min_incl;
|
||||
x_min_incl = x_max_excl;
|
||||
x_max_excl = a;
|
||||
}
|
||||
if (y_min_incl > y_max_excl) {
|
||||
uint32_t a = y_min_incl;
|
||||
y_min_incl = y_max_excl;
|
||||
y_max_excl = a;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t possible_hv_values[2][4] = {
|
||||
{1, 1, 2, 4},
|
||||
@@ -253,8 +283,10 @@ fuzz_swizzle_ycck(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
h0, wuffs_base__u32__max(h1, wuffs_base__u32__max(h2, h3)));
|
||||
uint32_t vmax = wuffs_base__u32__max(
|
||||
v0, wuffs_base__u32__max(v1, wuffs_base__u32__max(v2, v3)));
|
||||
width = wuffs_base__u32__min(width, 8 * width_in_mcus * hmax);
|
||||
height = wuffs_base__u32__min(height, 8 * height_in_mcus * vmax);
|
||||
x_max_excl = x_min_incl + wuffs_base__u32__min(x_max_excl - x_min_incl,
|
||||
8 * width_in_mcus * hmax);
|
||||
y_max_excl = y_min_incl + wuffs_base__u32__min(y_max_excl - y_min_incl,
|
||||
8 * height_in_mcus * vmax);
|
||||
|
||||
static size_t dst_alloc_size = 0;
|
||||
if (dst_alloc_size == 0) {
|
||||
@@ -271,7 +303,8 @@ fuzz_swizzle_ycck(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
|
||||
wuffs_base__pixel_buffer dst_pixbuf;
|
||||
wuffs_base__pixel_config dst_pixcfg;
|
||||
wuffs_base__pixel_config__set(&dst_pixcfg, dst_pixfmt.repr, 0, width, height);
|
||||
wuffs_base__pixel_config__set(&dst_pixcfg, dst_pixfmt.repr, 0, x_max_excl,
|
||||
y_max_excl);
|
||||
uint64_t dst_pixbuf_len = wuffs_base__pixel_config__pixbuf_len(&dst_pixcfg);
|
||||
if (dst_pixbuf_len > dst_alloc_size) {
|
||||
return "fuzz: internal error: dst_alloc_size is too small";
|
||||
@@ -368,7 +401,8 @@ fuzz_swizzle_ycck(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
uint8_t scratch_buffer[2048];
|
||||
wuffs_base__status status = wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
&swizzler, &dst_pixbuf, dst_palette, //
|
||||
width, height, //
|
||||
x_min_incl, x_max_excl, //
|
||||
y_min_incl, y_max_excl, //
|
||||
src0, src1, src2, src3, //
|
||||
width0, width1, width2, width3, //
|
||||
height0, height1, height2, height3, //
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace wuffs_aux {
|
||||
|
||||
@@ -28,6 +29,8 @@ using IOBuffer = wuffs_base__io_buffer;
|
||||
// nullptr, since calling free(nullptr) is a no-op.
|
||||
using MemOwner = std::unique_ptr<void, decltype(&free)>;
|
||||
|
||||
using QuirkKeyValuePair = std::pair<uint32_t, uint64_t>;
|
||||
|
||||
namespace sync_io {
|
||||
|
||||
// --------
|
||||
|
||||
@@ -28,15 +28,13 @@ DecodeCborCallbacks::Done(DecodeCborResult& result,
|
||||
sync_io::Input& input,
|
||||
IOBuffer& buffer) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeCborArgQuirks //
|
||||
DecodeCborArgQuirks::DefaultValue() {
|
||||
return DecodeCborArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeCborArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeCborResult //
|
||||
@@ -65,8 +63,8 @@ DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
ret_error_message = "wuffs_aux::DecodeCbor: out of memory";
|
||||
goto done;
|
||||
}
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
}
|
||||
|
||||
// Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.
|
||||
|
||||
@@ -75,13 +75,14 @@ class DecodeCborCallbacks {
|
||||
|
||||
// DecodeCborArgQuirks wraps an optional argument to DecodeCbor.
|
||||
struct DecodeCborArgQuirks {
|
||||
explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeCborArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeCbor calls callbacks based on the CBOR-formatted data in input.
|
||||
|
||||
@@ -91,6 +91,11 @@ DecodeImageCallbacks::SelectDecoder(uint32_t fourcc,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI)
|
||||
case WUFFS_BASE__FOURCC__QOI:
|
||||
return wuffs_qoi__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA)
|
||||
case WUFFS_BASE__FOURCC__TGA:
|
||||
return wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
@@ -135,7 +140,7 @@ DecodeImageCallbacks::AllocPixbuf(const wuffs_base__image_config& image_config,
|
||||
return AllocPixbufResult(DecodeImage_UnsupportedPixelConfiguration);
|
||||
}
|
||||
void* ptr =
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc((size_t)len, 1);
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc(1, (size_t)len);
|
||||
if (!ptr) {
|
||||
return AllocPixbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
@@ -160,7 +165,7 @@ DecodeImageCallbacks::AllocWorkbuf(wuffs_base__range_ii_u64 len_range,
|
||||
return AllocWorkbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
void* ptr =
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc((size_t)len, 1);
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc(1, (size_t)len);
|
||||
if (!ptr) {
|
||||
return AllocWorkbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
@@ -197,15 +202,13 @@ const char DecodeImage_UnsupportedPixelConfiguration[] = //
|
||||
const char DecodeImage_UnsupportedPixelFormat[] = //
|
||||
"wuffs_aux::DecodeImage: unsupported pixel format";
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeImageArgQuirks //
|
||||
DecodeImageArgQuirks::DefaultValue() {
|
||||
return DecodeImageArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeImageArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeImageArgFlags::DecodeImageArgFlags(uint64_t repr0) : repr(repr0) {}
|
||||
@@ -303,7 +306,8 @@ DecodeImage0(wuffs_base__image_decoder::unique_ptr& image_decoder,
|
||||
DecodeImageCallbacks& callbacks,
|
||||
sync_io::Input& input,
|
||||
wuffs_base__io_buffer& io_buf,
|
||||
wuffs_base__slice_u32 quirks,
|
||||
const QuirkKeyValuePair* quirks_ptr,
|
||||
const size_t quirks_len,
|
||||
uint64_t flags,
|
||||
wuffs_base__pixel_blend pixel_blend,
|
||||
wuffs_base__color_u32_argb_premul background_color,
|
||||
@@ -386,8 +390,8 @@ redirect:
|
||||
}
|
||||
|
||||
// Apply quirks.
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
image_decoder->set_quirk(quirks.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks_len; i++) {
|
||||
image_decoder->set_quirk(quirks_ptr[i].first, quirks_ptr[i].second);
|
||||
}
|
||||
|
||||
// Apply flags.
|
||||
@@ -614,10 +618,10 @@ DecodeImage(DecodeImageCallbacks& callbacks,
|
||||
}
|
||||
|
||||
wuffs_base__image_decoder::unique_ptr image_decoder(nullptr);
|
||||
DecodeImageResult result =
|
||||
DecodeImage0(image_decoder, callbacks, input, *io_buf, quirks.repr,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
DecodeImageResult result = DecodeImage0(
|
||||
image_decoder, callbacks, input, *io_buf, quirks.ptr, quirks.len,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
callbacks.Done(result, input, *io_buf, std::move(image_decoder));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ class DecodeImageCallbacks {
|
||||
// - WUFFS_BASE__FOURCC__NIE
|
||||
// - WUFFS_BASE__FOURCC__NPBM
|
||||
// - WUFFS_BASE__FOURCC__PNG
|
||||
// - WUFFS_BASE__FOURCC__QOI
|
||||
// - WUFFS_BASE__FOURCC__TGA
|
||||
// - WUFFS_BASE__FOURCC__WBMP
|
||||
// - WUFFS_BASE__FOURCC__WEBP
|
||||
@@ -200,13 +201,14 @@ extern const char DecodeImage_UnsupportedPixelFormat[];
|
||||
|
||||
// DecodeImageArgQuirks wraps an optional argument to DecodeImage.
|
||||
struct DecodeImageArgQuirks {
|
||||
explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeImageArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeImageArgFlags wraps an optional argument to DecodeImage.
|
||||
|
||||
@@ -33,15 +33,13 @@ const char DecodeJson_BadJsonPointer[] = //
|
||||
const char DecodeJson_NoMatch[] = //
|
||||
"wuffs_aux::DecodeJson: no match";
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeJsonArgQuirks //
|
||||
DecodeJsonArgQuirks::DefaultValue() {
|
||||
return DecodeJsonArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeJsonArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeJsonArgJsonPointer::DecodeJsonArgJsonPointer(std::string repr0)
|
||||
@@ -386,11 +384,11 @@ DecodeJson(DecodeJsonCallbacks& callbacks,
|
||||
goto done;
|
||||
}
|
||||
bool allow_tilde_n_tilde_r_tilde_t = false;
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
if (quirks.repr.ptr[i] ==
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
if (quirks.ptr[i].first ==
|
||||
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) {
|
||||
allow_tilde_n_tilde_r_tilde_t = true;
|
||||
allow_tilde_n_tilde_r_tilde_t = (quirks.ptr[i].second != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,13 +76,14 @@ extern const char DecodeJson_NoMatch[];
|
||||
|
||||
// DecodeJsonArgQuirks wraps an optional argument to DecodeJson.
|
||||
struct DecodeJsonArgQuirks {
|
||||
explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeJsonArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson.
|
||||
|
||||
@@ -173,6 +173,9 @@ wuffs_private_impl__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
|
||||
|
||||
// ---------------- Numeric Types (Utility)
|
||||
|
||||
#define wuffs_base__utility__sign_extend_convert_u8_u32(a) \
|
||||
((uint32_t)(int32_t)(int8_t)(a))
|
||||
|
||||
#define wuffs_base__utility__sign_extend_convert_u16_u32(a) \
|
||||
((uint32_t)(int32_t)(int16_t)(a))
|
||||
|
||||
|
||||
@@ -119,12 +119,62 @@
|
||||
#elif defined(_MSC_VER) // (#if-chain ref AVOID_CPU_ARCH_1)
|
||||
|
||||
#if defined(_M_X64)
|
||||
// We need <intrin.h> for the __cpuid function.
|
||||
#include <intrin.h>
|
||||
|
||||
// On X86_64, Microsoft Visual C/C++ (MSVC) only supports SSE2 by default.
|
||||
// There are /arch:SSE2, /arch:AVX and /arch:AVX2 compiler flags (the AVX2 one
|
||||
// is roughly equivalent to X86_64_V3), but there is no /arch:SSE42 compiler
|
||||
// flag that's equivalent to X86_64_V2.
|
||||
//
|
||||
// For getting maximum performance with X86_64 MSVC and Wuffs, pass /arch:AVX2
|
||||
// (and then test on the oldest hardware you intend to support).
|
||||
//
|
||||
// Absent that compiler flag, either define one of the three macros listed
|
||||
// below or else the X86_64 SIMD code will be disabled and you'll get a #pragma
|
||||
// message stating this library "performs best with /arch:AVX2". This message
|
||||
// is harmless and ignorable, in that the non-SIMD code is still correct and
|
||||
// reasonably performant, but is a reminder that when combining Wuffs and MSVC,
|
||||
// some compiler configuration is required for maximum performance.
|
||||
//
|
||||
// - WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY
|
||||
// - WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2 (enables SSE4.2 and below)
|
||||
// - WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V3 (enables AVX2 and below)
|
||||
//
|
||||
// Defining the first one (WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
// or defining none of those three (the default state) are equivalent (in that
|
||||
// both disable the SIMD code paths), other than that pragma message.
|
||||
//
|
||||
// When defining these WUFFS_CONFIG__ENABLE_ETC macros with MSVC, be aware that
|
||||
// some users report it leading to ICEs (Internal Compiler Errors), but other
|
||||
// users report no problems at all (and improved performance). It's unclear
|
||||
// exactly what combination of SIMD code and MSVC configuration lead to ICEs.
|
||||
// Do your own testing with your own MSVC version and configuration.
|
||||
//
|
||||
// https://github.com/google/wuffs/issues/148
|
||||
// https://github.com/google/wuffs/issues/151
|
||||
// https://developercommunity.visualstudio.com/t/fatal--error-C1001:-Internal-compiler-er/10703305
|
||||
//
|
||||
// Clang (including clang-cl) and GCC don't need this WUFFS_CONFIG__ETC macro
|
||||
// machinery, or having the Wuffs-the-library user to fiddle with compiler
|
||||
// flags, because they support "__attribute__((target(arg)))".
|
||||
#if defined(__AVX2__) || defined(__clang__) || \
|
||||
defined(WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V3)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V2
|
||||
#if defined(__AVX2__) || defined(__clang__)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V3
|
||||
#elif defined(WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V2
|
||||
#elif !defined(WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
#pragma message("Wuffs with MSVC+X64 performs best with /arch:AVX2")
|
||||
#endif // defined(__AVX2__) || defined(__clang__) || etc
|
||||
|
||||
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
|
||||
|
||||
#if defined(WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
#error "MSVC_CPU_ARCH simultaneously enabled and disabled"
|
||||
#endif
|
||||
|
||||
#include <intrin.h>
|
||||
// intrin.h isn't enough for X64 SIMD, with clang-cl, if we want to use
|
||||
// "__attribute__((target(arg)))" without e.g. "/arch:AVX".
|
||||
//
|
||||
@@ -134,23 +184,9 @@
|
||||
#include <immintrin.h> // AVX, AVX2, FMA, POPCNT
|
||||
#include <nmmintrin.h> // SSE4.2
|
||||
#include <wmmintrin.h> // AES, PCLMUL
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V3
|
||||
|
||||
#else // defined(__AVX2__) || defined(__clang__)
|
||||
|
||||
// clang-cl (which defines both __clang__ and _MSC_VER) supports
|
||||
// "__attribute__((target(arg)))".
|
||||
//
|
||||
// For MSVC's cl.exe (unlike clang or gcc), SIMD capability is a compile-time
|
||||
// property of the source file (e.g. a /arch:AVX2 or -mavx2 compiler flag), not
|
||||
// of individual functions (that can be conditionally selected at runtime).
|
||||
#if !defined(WUFFS_CONFIG__I_KNOW_THAT_WUFFS_MSVC_PERFORMS_BEST_WITH_ARCH_AVX2)
|
||||
#pragma message("Wuffs with MSVC+IX86/X64 performs best with /arch:AVX2")
|
||||
#endif
|
||||
|
||||
#endif // defined(__AVX2__) || defined(__clang__)
|
||||
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
|
||||
#endif // defined(_M_X64)
|
||||
|
||||
#endif // (#if-chain ref AVOID_CPU_ARCH_1)
|
||||
#endif // (#if-chain ref AVOID_CPU_ARCH_0)
|
||||
|
||||
@@ -1700,3 +1736,17 @@ wuffs_base__table__flattened_length(size_t width,
|
||||
WUFFS_BASE__MAYBE_STATIC int32_t //
|
||||
wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
|
||||
bool prefix_closed);
|
||||
|
||||
// ---------------- Quirk Values
|
||||
|
||||
// These constants are the value half of a key-value pair, where the key is
|
||||
// WUFFS_BASE__QUIRK_QUALITY.
|
||||
//
|
||||
// In the Wuffs API, set_quirk takes a u64 value. These macro definitions are
|
||||
// likewise unsigned values (uint64_t) but for this particular key, they are
|
||||
// best interpreted as signed values (int64_t). "Lower-than-default quality"
|
||||
// and "higher-than-default quality", as signed values, are -1 and +1.
|
||||
//
|
||||
// See doc/note/quirks.md for some more discussion about trade-offs.
|
||||
#define WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY UINT64_MAX
|
||||
#define WUFFS_BASE__QUIRK_QUALITY__VALUE__HIGHER_QUALITY ((uint64_t)1)
|
||||
@@ -39,8 +39,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
const wuffs_base__pixel_swizzler* p,
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
wuffs_base__slice_u8 dst_palette,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
wuffs_base__slice_u8 src0,
|
||||
wuffs_base__slice_u8 src1,
|
||||
wuffs_base__slice_u8 src2,
|
||||
|
||||
@@ -651,7 +651,7 @@ wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
|
||||
}
|
||||
if (pixfmt_repr) {
|
||||
do {
|
||||
#if SIZE_MAX < UINT64_MAX
|
||||
#if SIZE_MAX < 0xFFFFFFFFFFFFFFFFull
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh > ((uint64_t)SIZE_MAX)) {
|
||||
|
||||
@@ -625,8 +625,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -648,6 +650,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) {
|
||||
if ((x_min_incl != 0) || (y_min_incl != 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
@@ -660,7 +666,7 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
// First row.
|
||||
uint32_t h1v2_bias = 1u;
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
dst, width, 0u, //
|
||||
dst, x_max_excl, 0u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, src_ptr3, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
@@ -672,10 +678,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
h1v2_bias = 2u;
|
||||
|
||||
// Middle rows.
|
||||
bool last_row = height == 2u * half_height_for_2to1;
|
||||
uint32_t y_max_excl = last_row ? (height - 1u) : height;
|
||||
bool last_row = y_max_excl == 2u * half_height_for_2to1;
|
||||
uint32_t middle_y_max_excl = last_row ? (y_max_excl - 1u) : y_max_excl;
|
||||
uint32_t y;
|
||||
for (y = 1u; y < y_max_excl; y++) {
|
||||
for (y = 1u; y < middle_y_max_excl; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src0_minor =
|
||||
(inv_v0 != 2u)
|
||||
@@ -702,11 +708,11 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
uint32_t total_src_len3 = 0u;
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
while (x < x_max_excl) {
|
||||
bool first_column = x == 0u;
|
||||
uint32_t end = x + 480u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
@@ -762,9 +768,9 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
}
|
||||
|
||||
// Last row.
|
||||
if (y_max_excl != height) {
|
||||
if (middle_y_max_excl != y_max_excl) {
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
dst, width, height - 1u, //
|
||||
dst, x_max_excl, middle_y_max_excl, //
|
||||
src_ptr0, src_ptr1, src_ptr2, src_ptr3, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
@@ -860,8 +866,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -879,6 +887,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) {
|
||||
if ((x_min_incl != 0) || (y_min_incl != 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
@@ -889,7 +901,7 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
// First row.
|
||||
uint32_t h1v2_bias = 1u;
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
dst, width, 0u, //
|
||||
dst, x_max_excl, 0u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
@@ -901,10 +913,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
h1v2_bias = 2u;
|
||||
|
||||
// Middle rows.
|
||||
bool last_row = height == 2u * half_height_for_2to1;
|
||||
uint32_t y_max_excl = last_row ? (height - 1u) : height;
|
||||
bool last_row = y_max_excl == 2u * half_height_for_2to1;
|
||||
uint32_t middle_y_max_excl = last_row ? (y_max_excl - 1u) : y_max_excl;
|
||||
uint32_t y;
|
||||
for (y = 1u; y < y_max_excl; y++) {
|
||||
for (y = 1u; y < middle_y_max_excl; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src0_minor =
|
||||
(inv_v0 != 2u)
|
||||
@@ -925,11 +937,11 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
uint32_t total_src_len2 = 0u;
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
while (x < x_max_excl) {
|
||||
bool first_column = x == 0u;
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
@@ -974,16 +986,16 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
}
|
||||
|
||||
// Last row.
|
||||
if (y_max_excl != height) {
|
||||
if (middle_y_max_excl != y_max_excl) {
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
dst, width, height - 1u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, //
|
||||
h1v2_bias, //
|
||||
scratch_buffer_2k_ptr, //
|
||||
dst, x_max_excl, middle_y_max_excl, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, //
|
||||
h1v2_bias, //
|
||||
scratch_buffer_2k_ptr, //
|
||||
upfunc0, upfunc1, upfunc2, conv3func);
|
||||
}
|
||||
}
|
||||
@@ -991,8 +1003,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -1018,41 +1032,44 @@ wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
|
||||
uint32_t y;
|
||||
for (y = 0u; y < height; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major = src_ptr1 + ((y / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major = src_ptr2 + ((y / inv_v2) * (size_t)stride2);
|
||||
for (y = y_min_incl; y < y_max_excl; y++) {
|
||||
const uint8_t* src0_major =
|
||||
src_ptr0 + (((y - y_min_incl) / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major =
|
||||
src_ptr1 + (((y - y_min_incl) / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major =
|
||||
src_ptr2 + (((y - y_min_incl) / inv_v2) * (size_t)stride2);
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
uint32_t x = x_min_incl;
|
||||
while (x < x_max_excl) {
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src_len0, //
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src_len1, //
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src_len2, //
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
(*conv3func)(dst, x, end, y, up0, up1, up2);
|
||||
@@ -1061,6 +1078,100 @@ wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
}
|
||||
}
|
||||
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycck__general__box_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
const uint8_t* src_ptr3,
|
||||
uint32_t stride0,
|
||||
uint32_t stride1,
|
||||
uint32_t stride2,
|
||||
uint32_t stride3,
|
||||
uint32_t inv_h0,
|
||||
uint32_t inv_h1,
|
||||
uint32_t inv_h2,
|
||||
uint32_t inv_h3,
|
||||
uint32_t inv_v0,
|
||||
uint32_t inv_v1,
|
||||
uint32_t inv_v2,
|
||||
uint32_t inv_v3,
|
||||
uint32_t half_width_for_2to1,
|
||||
uint32_t half_height_for_2to1,
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) {
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
(*upfuncs)[(inv_h1 - 1u) & 3u][(inv_v1 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc2 =
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc3 =
|
||||
(*upfuncs)[(inv_h3 - 1u) & 3u][(inv_v3 - 1u) & 3u];
|
||||
|
||||
uint32_t y;
|
||||
for (y = y_min_incl; y < y_max_excl; y++) {
|
||||
const uint8_t* src0_major =
|
||||
src_ptr0 + (((y - y_min_incl) / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major =
|
||||
src_ptr1 + (((y - y_min_incl) / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major =
|
||||
src_ptr2 + (((y - y_min_incl) / inv_v2) * (size_t)stride2);
|
||||
const uint8_t* src3_major =
|
||||
src_ptr3 + (((y - y_min_incl) / inv_v3) * (size_t)stride3);
|
||||
|
||||
uint32_t x = x_min_incl;
|
||||
while (x < x_max_excl) {
|
||||
uint32_t end = x + 480u;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
uint32_t src_len3 = ((end - x) + inv_h3 - 1u) / inv_h3;
|
||||
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 480u), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 480u), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 480u), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up3 = (*upfunc3)( //
|
||||
scratch_buffer_2k_ptr + (3u * 480u), //
|
||||
src3_major + ((x - x_min_incl) / inv_h3), //
|
||||
src3_major + ((x - x_min_incl) / inv_h3), //
|
||||
src_len3, //
|
||||
0u, false, false);
|
||||
|
||||
(*conv4func)(dst, x, end, y, up0, up1, up2, up3);
|
||||
x = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_private_impl__swizzle_flattened_length is like
|
||||
@@ -1085,8 +1196,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
const wuffs_base__pixel_swizzler* p,
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
wuffs_base__slice_u8 dst_palette,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
wuffs_base__slice_u8 src0,
|
||||
wuffs_base__slice_u8 src1,
|
||||
wuffs_base__slice_u8 src2,
|
||||
@@ -1116,13 +1229,18 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
wuffs_base__slice_u8 scratch_buffer_2k) {
|
||||
if (!p) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
} else if (!dst || (width > 0xFFFFu) || (height > 0xFFFFu) || //
|
||||
(4u <= ((unsigned int)h0 - 1u)) || //
|
||||
(4u <= ((unsigned int)h1 - 1u)) || //
|
||||
(4u <= ((unsigned int)h2 - 1u)) || //
|
||||
(4u <= ((unsigned int)v0 - 1u)) || //
|
||||
(4u <= ((unsigned int)v1 - 1u)) || //
|
||||
(4u <= ((unsigned int)v2 - 1u)) || //
|
||||
} else if (!dst || //
|
||||
(x_min_incl > x_max_excl) || //
|
||||
(x_max_excl > 0xFFFFu) || //
|
||||
(y_min_incl > y_max_excl) || //
|
||||
(y_max_excl > 0xFFFFu) || //
|
||||
(4u <= ((unsigned int)h0 - 1u)) || //
|
||||
(4u <= ((unsigned int)h1 - 1u)) || //
|
||||
(4u <= ((unsigned int)h2 - 1u)) || //
|
||||
(4u <= ((unsigned int)v0 - 1u)) || //
|
||||
(4u <= ((unsigned int)v1 - 1u)) || //
|
||||
(4u <= ((unsigned int)v2 - 1u)) || //
|
||||
(triangle_filter_for_2to1 && ((x_min_incl | y_min_incl) > 0u)) ||
|
||||
(scratch_buffer_2k.len < 2048u)) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
@@ -1149,21 +1267,69 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
uint32_t inv_v2 = max_incl_v / v2;
|
||||
uint32_t inv_v3 = v3 ? (max_incl_v / v3) : 0u;
|
||||
|
||||
uint32_t half_width_for_2to1 = (width + 1u) / 2u;
|
||||
uint32_t half_height_for_2to1 = (height + 1u) / 2u;
|
||||
if (x_min_incl != 0) {
|
||||
if ((x_min_incl % inv_h0) || (x_min_incl % inv_h1) ||
|
||||
(x_min_incl % inv_h2) || (inv_h3 && (x_min_incl % inv_h3))) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
}
|
||||
if (y_min_incl != 0) {
|
||||
if ((y_min_incl % inv_v0) || (y_min_incl % inv_v1) ||
|
||||
(y_min_incl % inv_v2) || (inv_v3 && (y_min_incl % inv_v3))) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
}
|
||||
|
||||
width = wuffs_private_impl__u32__min_of_5( //
|
||||
width, //
|
||||
width0 * inv_h0, //
|
||||
width1 * inv_h1, //
|
||||
width2 * inv_h2, //
|
||||
wuffs_base__pixel_config__width(&dst->pixcfg));
|
||||
height = wuffs_private_impl__u32__min_of_5( //
|
||||
height, //
|
||||
height0 * inv_v0, //
|
||||
height1 * inv_v1, //
|
||||
height2 * inv_v2, //
|
||||
wuffs_base__pixel_config__height(&dst->pixcfg));
|
||||
uint32_t half_width_for_2to1 = ((x_max_excl - x_min_incl) + 1u) / 2u;
|
||||
if (inv_h0 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width0);
|
||||
}
|
||||
if (inv_h1 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width1);
|
||||
}
|
||||
if (inv_h2 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width2);
|
||||
}
|
||||
if (inv_h3 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width3);
|
||||
}
|
||||
|
||||
uint32_t half_height_for_2to1 = ((y_max_excl - y_min_incl) + 1u) / 2u;
|
||||
if (inv_v0 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height0);
|
||||
}
|
||||
if (inv_v1 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height1);
|
||||
}
|
||||
if (inv_v2 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height2);
|
||||
}
|
||||
if (inv_v3 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height3);
|
||||
}
|
||||
|
||||
x_max_excl = wuffs_base__u32__min( //
|
||||
wuffs_base__pixel_config__width(&dst->pixcfg), //
|
||||
x_min_incl + wuffs_private_impl__u32__min_of_5( //
|
||||
x_max_excl - x_min_incl, //
|
||||
width0 * inv_h0, //
|
||||
width1 * inv_h1, //
|
||||
width2 * inv_h2, //
|
||||
inv_h3 ? (width3 * inv_h3) : 0xFFFFFFFF));
|
||||
y_max_excl = wuffs_base__u32__min( //
|
||||
wuffs_base__pixel_config__height(&dst->pixcfg), //
|
||||
y_min_incl + wuffs_private_impl__u32__min_of_5( //
|
||||
y_max_excl - y_min_incl, //
|
||||
height0 * inv_v0, //
|
||||
height1 * inv_v1, //
|
||||
height2 * inv_v2, //
|
||||
inv_v3 ? (height3 * inv_v3) : 0xFFFFFFFF));
|
||||
|
||||
if ((x_min_incl >= x_max_excl) || (y_min_incl >= y_max_excl)) {
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
uint32_t width = x_max_excl - x_min_incl;
|
||||
uint32_t height = y_max_excl - y_min_incl;
|
||||
|
||||
if (((h0 * inv_h0) != max_incl_h) || //
|
||||
((h1 * inv_h1) != max_incl_h) || //
|
||||
@@ -1264,10 +1430,6 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
|
||||
// ----
|
||||
|
||||
if ((width <= 0u) || (height <= 0u)) {
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func = NULL;
|
||||
|
||||
if (is_rgb_or_cmyk) {
|
||||
@@ -1302,28 +1464,58 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
}
|
||||
}
|
||||
|
||||
void (*func)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t width, //
|
||||
uint32_t height, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) =
|
||||
void (*func3)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t x_min_incl, //
|
||||
uint32_t x_max_excl, //
|
||||
uint32_t y_min_incl, //
|
||||
uint32_t y_max_excl, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) =
|
||||
&wuffs_private_impl__swizzle_ycc__general__box_filter;
|
||||
|
||||
void (*func4)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t x_min_incl, //
|
||||
uint32_t x_max_excl, //
|
||||
uint32_t y_min_incl, //
|
||||
uint32_t y_max_excl, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
const uint8_t* src_ptr3, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t stride3, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_h3, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t inv_v3, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) =
|
||||
&wuffs_private_impl__swizzle_ycck__general__box_filter;
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfuncs[4][4];
|
||||
memcpy(&upfuncs, &wuffs_private_impl__swizzle_ycc__upsample_funcs,
|
||||
sizeof upfuncs);
|
||||
@@ -1331,8 +1523,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
if (triangle_filter_for_2to1 &&
|
||||
(wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h0, inv_v0) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_private_impl__swizzle_ycc__general__triangle_filter;
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h2, inv_v2) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h3, inv_v3))) {
|
||||
func3 = &wuffs_private_impl__swizzle_ycc__general__triangle_filter;
|
||||
func4 = &wuffs_private_impl__swizzle_ycck__general__triangle_filter;
|
||||
|
||||
upfuncs[0][1] = wuffs_private_impl__swizzle_ycc__upsample_inv_h1v2_triangle;
|
||||
upfuncs[1][0] = wuffs_private_impl__swizzle_ycc__upsample_inv_h2v1_triangle;
|
||||
@@ -1364,23 +1558,23 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func =
|
||||
is_rgb_or_cmyk ? &wuffs_private_impl__swizzle_cmyk__convert_4_general
|
||||
: &wuffs_private_impl__swizzle_ycck__convert_4_general;
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter( //
|
||||
dst, width, height, //
|
||||
src0.ptr, src1.ptr, src2.ptr, src3.ptr, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
inv_v0, inv_v1, inv_v2, inv_v3, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
(*func4)( //
|
||||
dst, x_min_incl, x_max_excl, y_min_incl, y_max_excl, //
|
||||
src0.ptr, src1.ptr, src2.ptr, src3.ptr, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
inv_v0, inv_v1, inv_v2, inv_v3, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
scratch_buffer_2k.ptr, &upfuncs, conv4func);
|
||||
|
||||
} else {
|
||||
(*func)( //
|
||||
dst, width, height, //
|
||||
src0.ptr, src1.ptr, src2.ptr, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
(*func3)( //
|
||||
dst, x_min_incl, x_max_excl, y_min_incl, y_max_excl, //
|
||||
src0.ptr, src1.ptr, src2.ptr, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
scratch_buffer_2k.ptr, &upfuncs, conv3func);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,49 +39,53 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__NUM_BITS 46
|
||||
// clang-format off
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBC__FILLER 0
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRING 2
|
||||
#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
|
||||
#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
|
||||
#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__NUM_BITS 46
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBC__FILLER 0
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRING 2
|
||||
#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
|
||||
#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
|
||||
#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_UNSIGNED 7
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004
|
||||
|
||||
// COMMENT_ANY is a bit-wise or of COMMENT_BLOCK AND COMMENT_LINE.
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT 0x00040
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000
|
||||
|
||||
// --------
|
||||
|
||||
@@ -101,11 +105,11 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
//
|
||||
// The lack of any particular bit is conservative: it is valid for all-ASCII
|
||||
// strings, in a single- or multi-token chain, to have none of these bits set.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_UTF_8 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_ASCII 0x00040
|
||||
|
||||
// CONVERT_D_DST_S_SRC means that multiples of S source bytes (possibly padded)
|
||||
@@ -120,22 +124,22 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// When src is the empty string, multiple conversion algorithms are applicable
|
||||
// (so these bits are not necessarily mutually exclusive), all producing the
|
||||
// same empty dst string.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00400
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00800
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_HEX 0x08000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_STD 0x10000
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__UNDEFINED 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008
|
||||
|
||||
// --------
|
||||
|
||||
@@ -148,8 +152,8 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// For a source string of "+123" or "-0x9A", only the first two are valid.
|
||||
//
|
||||
// For a source string of "123.", only the first one is valid.
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_UNSIGNED 0x00004
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_INF 0x00010
|
||||
@@ -161,11 +165,15 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// "300", which are big-endian, little-endian or text. For binary formats, the
|
||||
// token length (after adjusting for FORMAT_IGNORE_ETC) discriminates
|
||||
// e.g. u16 little-endian vs u32 little-endian.
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_LITTLE_ENDIAN 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000
|
||||
|
||||
// --------
|
||||
|
||||
// clang-format on
|
||||
|
||||
// --------
|
||||
|
||||
|
||||
+11
-1
@@ -237,6 +237,16 @@ func (b *buffer) writeb(x byte) { *b = append(*b, x)
|
||||
func (b *buffer) writes(s string) { *b = append(*b, s...) }
|
||||
func (b *buffer) writex(s []byte) { *b = append(*b, s...) }
|
||||
|
||||
func (b *buffer) undoWrites(s string) bool {
|
||||
nb := len(*b)
|
||||
ns := len(s)
|
||||
if (nb < ns) || (string((*b)[nb-ns:]) != s) {
|
||||
return false
|
||||
}
|
||||
*b = (*b)[:nb-ns]
|
||||
return true
|
||||
}
|
||||
|
||||
func expandBangInsert(b *buffer, s string, m map[string]func(*buffer) error) error {
|
||||
for {
|
||||
remaining := ""
|
||||
@@ -1525,7 +1535,7 @@ func (g *gen) writeInitializerImpl(b *buffer, n *a.Struct) error {
|
||||
return err
|
||||
}
|
||||
b.writes(" {\n")
|
||||
b.printf("%s%s* x =\n(%s%s*)(calloc(sizeof(%s%s), 1));\n",
|
||||
b.printf("%s%s* x =\n(%s%s*)(calloc(1, sizeof(%s%s)));\n",
|
||||
g.pkgPrefix, structName, g.pkgPrefix, structName, g.pkgPrefix, structName)
|
||||
b.writes("if (!x) {\nreturn NULL;\n}\n")
|
||||
b.printf("if (%s%s__initialize(\nx, sizeof(%s%s), "+
|
||||
|
||||
@@ -183,14 +183,23 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const disableWconversion0 = "" +
|
||||
"#if defined(__GNUC__)\n" +
|
||||
"#pragma GCC diagnostic push\n" +
|
||||
"#pragma GCC diagnostic ignored \"-Wconversion\"\n" +
|
||||
"#endif\n"
|
||||
|
||||
const disableWconversion1 = "" +
|
||||
"#if defined(__GNUC__)\n" +
|
||||
"#pragma GCC diagnostic pop\n" +
|
||||
"#endif\n"
|
||||
|
||||
// "x += 1" triggers -Wconversion, if x is smaller than an int (i.e. a
|
||||
// uint8_t or a uint16_t). This is arguably a clang/gcc bug, but in any
|
||||
// case, we work around it in Wuffs.
|
||||
if disableWconversion {
|
||||
b.writes("#if defined(__GNUC__)\n")
|
||||
b.writes("#pragma GCC diagnostic push\n")
|
||||
b.writes("#pragma GCC diagnostic ignored \"-Wconversion\"\n")
|
||||
b.writes("#endif\n")
|
||||
if disableWconversion && !b.undoWrites(disableWconversion1) {
|
||||
b.writes(disableWconversion0)
|
||||
}
|
||||
|
||||
n := len(*b)
|
||||
@@ -213,9 +222,7 @@ func (g *gen) writeStatementAssign1(b *buffer, op t.ID, lhs *a.Expr, rhs *a.Expr
|
||||
}
|
||||
|
||||
if disableWconversion {
|
||||
b.writes("#if defined(__GNUC__)\n")
|
||||
b.writes("#pragma GCC diagnostic pop\n")
|
||||
b.writes("#endif\n")
|
||||
b.writes(disableWconversion1)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -153,6 +153,7 @@ var Consts = [...]struct {
|
||||
// ----
|
||||
|
||||
{t.IDU32, "1", "QUIRK_IGNORE_CHECKSUM"},
|
||||
{t.IDU32, "2", "QUIRK_QUALITY"},
|
||||
|
||||
// ----
|
||||
|
||||
@@ -395,6 +396,7 @@ var funcsOther = [...]string{
|
||||
"min_incl_x: u32, min_incl_y: u32, max_incl_x: u32, max_incl_y: u32) rect_ii_u32",
|
||||
"utility.make_rect_ie_u32(" +
|
||||
"min_incl_x: u32, min_incl_y: u32, max_excl_x: u32, max_excl_y: u32) rect_ie_u32",
|
||||
"utility.sign_extend_convert_u8_u32(a: u8) u32",
|
||||
"utility.sign_extend_convert_u16_u32(a: u16) u32",
|
||||
"utility.sign_extend_rshift_u32(a: u32, n: u32[..= 31]) u32",
|
||||
"utility.sign_extend_rshift_u64(a: u64, n: u32[..= 63]) u64",
|
||||
@@ -690,8 +692,10 @@ var funcsOther = [...]string{
|
||||
"pixel_swizzler.swizzle_ycck!(" +
|
||||
"dst: ptr pixel_buffer," +
|
||||
"dst_palette: slice u8," +
|
||||
"width: u32[..= 0xFFFF]," +
|
||||
"height: u32[..= 0xFFFF]," +
|
||||
"x_min_incl: u32[..= 0xFFFF]," +
|
||||
"x_max_excl: u32[..= 0xFFFF]," +
|
||||
"y_min_incl: u32[..= 0xFFFF]," +
|
||||
"y_max_excl: u32[..= 0xFFFF]," +
|
||||
"src0: slice u8," +
|
||||
"src1: slice u8," +
|
||||
"src2: slice u8," +
|
||||
|
||||
+27
-8
@@ -207,11 +207,30 @@ func invert(tm *t.Map, n *a.Expr) (*a.Expr, error) {
|
||||
return o, nil
|
||||
}
|
||||
|
||||
var errUpdateReturnsNil = errors.New("update returns nil")
|
||||
|
||||
func updateFactsForSuspension(x *a.Expr) (*a.Expr, error) {
|
||||
if x.Mentions(exprArgs) || x.Mentions(exprThis) {
|
||||
// Drop any facts involving args, this or ptr-typed local variables.
|
||||
if err := x.AsNode().Walk(func(innerNode *a.Node) error {
|
||||
if innerNode.Kind() != a.KExpr {
|
||||
return nil
|
||||
}
|
||||
n := innerNode.AsExpr()
|
||||
if n.MType().HasPointers() {
|
||||
return errUpdateReturnsNil
|
||||
} else if n.Operator() == 0 {
|
||||
switch n.Ident() {
|
||||
case t.IDArgs, t.IDThis:
|
||||
return errUpdateReturnsNil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}); err == errUpdateReturnsNil {
|
||||
return nil, nil
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// TODO: drop any facts involving ptr-typed local variables?
|
||||
|
||||
return x, nil
|
||||
}
|
||||
|
||||
@@ -463,18 +482,18 @@ func (q *checker) bcheckAssignment(lhs *a.Expr, op t.ID, rhs *a.Expr) error {
|
||||
lTyp = lhs.MType()
|
||||
}
|
||||
|
||||
if (rhs.Operator() == a.ExprOperatorCall) && rhs.Effect().Coroutine() && (op != t.IDEqQuestion) {
|
||||
if err := q.facts.update(updateFactsForSuspension); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
nb, err := q.bcheckAssignment1(lhs, lTyp, op, rhs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if (rhs.Operator() == a.ExprOperatorCall) && rhs.Effect().Impure() {
|
||||
if rhs.Effect().Coroutine() && (op != t.IDEqQuestion) {
|
||||
if err := q.facts.update(updateFactsForSuspension); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
recv := rhs.LHS().AsExpr().LHS().AsExpr()
|
||||
if err := q.facts.update(func(x *a.Expr) (*a.Expr, error) {
|
||||
if _, ok := oldFacts[x]; !ok {
|
||||
|
||||
+2517
-787
@@ -175,12 +175,62 @@ extern "C" {
|
||||
#elif defined(_MSC_VER) // (#if-chain ref AVOID_CPU_ARCH_1)
|
||||
|
||||
#if defined(_M_X64)
|
||||
// We need <intrin.h> for the __cpuid function.
|
||||
#include <intrin.h>
|
||||
|
||||
// On X86_64, Microsoft Visual C/C++ (MSVC) only supports SSE2 by default.
|
||||
// There are /arch:SSE2, /arch:AVX and /arch:AVX2 compiler flags (the AVX2 one
|
||||
// is roughly equivalent to X86_64_V3), but there is no /arch:SSE42 compiler
|
||||
// flag that's equivalent to X86_64_V2.
|
||||
//
|
||||
// For getting maximum performance with X86_64 MSVC and Wuffs, pass /arch:AVX2
|
||||
// (and then test on the oldest hardware you intend to support).
|
||||
//
|
||||
// Absent that compiler flag, either define one of the three macros listed
|
||||
// below or else the X86_64 SIMD code will be disabled and you'll get a #pragma
|
||||
// message stating this library "performs best with /arch:AVX2". This message
|
||||
// is harmless and ignorable, in that the non-SIMD code is still correct and
|
||||
// reasonably performant, but is a reminder that when combining Wuffs and MSVC,
|
||||
// some compiler configuration is required for maximum performance.
|
||||
//
|
||||
// - WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY
|
||||
// - WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2 (enables SSE4.2 and below)
|
||||
// - WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V3 (enables AVX2 and below)
|
||||
//
|
||||
// Defining the first one (WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
// or defining none of those three (the default state) are equivalent (in that
|
||||
// both disable the SIMD code paths), other than that pragma message.
|
||||
//
|
||||
// When defining these WUFFS_CONFIG__ENABLE_ETC macros with MSVC, be aware that
|
||||
// some users report it leading to ICEs (Internal Compiler Errors), but other
|
||||
// users report no problems at all (and improved performance). It's unclear
|
||||
// exactly what combination of SIMD code and MSVC configuration lead to ICEs.
|
||||
// Do your own testing with your own MSVC version and configuration.
|
||||
//
|
||||
// https://github.com/google/wuffs/issues/148
|
||||
// https://github.com/google/wuffs/issues/151
|
||||
// https://developercommunity.visualstudio.com/t/fatal--error-C1001:-Internal-compiler-er/10703305
|
||||
//
|
||||
// Clang (including clang-cl) and GCC don't need this WUFFS_CONFIG__ETC macro
|
||||
// machinery, or having the Wuffs-the-library user to fiddle with compiler
|
||||
// flags, because they support "__attribute__((target(arg)))".
|
||||
#if defined(__AVX2__) || defined(__clang__) || \
|
||||
defined(WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V3)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V2
|
||||
#if defined(__AVX2__) || defined(__clang__)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V3
|
||||
#elif defined(WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V2
|
||||
#elif !defined(WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
#pragma message("Wuffs with MSVC+X64 performs best with /arch:AVX2")
|
||||
#endif // defined(__AVX2__) || defined(__clang__) || etc
|
||||
|
||||
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
|
||||
|
||||
#if defined(WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
#error "MSVC_CPU_ARCH simultaneously enabled and disabled"
|
||||
#endif
|
||||
|
||||
#include <intrin.h>
|
||||
// intrin.h isn't enough for X64 SIMD, with clang-cl, if we want to use
|
||||
// "__attribute__((target(arg)))" without e.g. "/arch:AVX".
|
||||
//
|
||||
@@ -190,23 +240,9 @@ extern "C" {
|
||||
#include <immintrin.h> // AVX, AVX2, FMA, POPCNT
|
||||
#include <nmmintrin.h> // SSE4.2
|
||||
#include <wmmintrin.h> // AES, PCLMUL
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V3
|
||||
|
||||
#else // defined(__AVX2__) || defined(__clang__)
|
||||
|
||||
// clang-cl (which defines both __clang__ and _MSC_VER) supports
|
||||
// "__attribute__((target(arg)))".
|
||||
//
|
||||
// For MSVC's cl.exe (unlike clang or gcc), SIMD capability is a compile-time
|
||||
// property of the source file (e.g. a /arch:AVX2 or -mavx2 compiler flag), not
|
||||
// of individual functions (that can be conditionally selected at runtime).
|
||||
#if !defined(WUFFS_CONFIG__I_KNOW_THAT_WUFFS_MSVC_PERFORMS_BEST_WITH_ARCH_AVX2)
|
||||
#pragma message("Wuffs with MSVC+IX86/X64 performs best with /arch:AVX2")
|
||||
#endif
|
||||
|
||||
#endif // defined(__AVX2__) || defined(__clang__)
|
||||
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
|
||||
#endif // defined(_M_X64)
|
||||
|
||||
#endif // (#if-chain ref AVOID_CPU_ARCH_1)
|
||||
#endif // (#if-chain ref AVOID_CPU_ARCH_0)
|
||||
|
||||
@@ -913,6 +949,8 @@ typedef struct wuffs_base__transform__output__struct {
|
||||
|
||||
#define WUFFS_BASE__QUIRK_IGNORE_CHECKSUM 1
|
||||
|
||||
#define WUFFS_BASE__QUIRK_QUALITY 2
|
||||
|
||||
// --------
|
||||
|
||||
// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a
|
||||
@@ -1978,6 +2016,20 @@ WUFFS_BASE__MAYBE_STATIC int32_t //
|
||||
wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
|
||||
bool prefix_closed);
|
||||
|
||||
// ---------------- Quirk Values
|
||||
|
||||
// These constants are the value half of a key-value pair, where the key is
|
||||
// WUFFS_BASE__QUIRK_QUALITY.
|
||||
//
|
||||
// In the Wuffs API, set_quirk takes a u64 value. These macro definitions are
|
||||
// likewise unsigned values (uint64_t) but for this particular key, they are
|
||||
// best interpreted as signed values (int64_t). "Lower-than-default quality"
|
||||
// and "higher-than-default quality", as signed values, are -1 and +1.
|
||||
//
|
||||
// See doc/note/quirks.md for some more discussion about trade-offs.
|
||||
#define WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY UINT64_MAX
|
||||
#define WUFFS_BASE__QUIRK_QUALITY__VALUE__HIGHER_QUALITY ((uint64_t)1)
|
||||
|
||||
// ---------------- Ranges and Rects
|
||||
|
||||
// See https://github.com/google/wuffs/blob/main/doc/note/ranges-and-rects.md
|
||||
@@ -3350,49 +3402,53 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__NUM_BITS 46
|
||||
// clang-format off
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBC__FILLER 0
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRING 2
|
||||
#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
|
||||
#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
|
||||
#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__NUM_BITS 46
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBC__FILLER 0
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRING 2
|
||||
#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
|
||||
#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
|
||||
#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_UNSIGNED 7
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004
|
||||
|
||||
// COMMENT_ANY is a bit-wise or of COMMENT_BLOCK AND COMMENT_LINE.
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT 0x00040
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000
|
||||
|
||||
// --------
|
||||
|
||||
@@ -3412,11 +3468,11 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
//
|
||||
// The lack of any particular bit is conservative: it is valid for all-ASCII
|
||||
// strings, in a single- or multi-token chain, to have none of these bits set.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_UTF_8 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_ASCII 0x00040
|
||||
|
||||
// CONVERT_D_DST_S_SRC means that multiples of S source bytes (possibly padded)
|
||||
@@ -3431,22 +3487,22 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// When src is the empty string, multiple conversion algorithms are applicable
|
||||
// (so these bits are not necessarily mutually exclusive), all producing the
|
||||
// same empty dst string.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00400
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00800
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_HEX 0x08000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_STD 0x10000
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__UNDEFINED 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008
|
||||
|
||||
// --------
|
||||
|
||||
@@ -3459,8 +3515,8 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// For a source string of "+123" or "-0x9A", only the first two are valid.
|
||||
//
|
||||
// For a source string of "123.", only the first one is valid.
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_UNSIGNED 0x00004
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_INF 0x00010
|
||||
@@ -3472,11 +3528,15 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// "300", which are big-endian, little-endian or text. For binary formats, the
|
||||
// token length (after adjusting for FORMAT_IGNORE_ETC) discriminates
|
||||
// e.g. u16 little-endian vs u32 little-endian.
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_LITTLE_ENDIAN 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000
|
||||
|
||||
// --------
|
||||
|
||||
// clang-format on
|
||||
|
||||
// --------
|
||||
|
||||
@@ -4604,7 +4664,7 @@ wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
|
||||
}
|
||||
if (pixfmt_repr) {
|
||||
do {
|
||||
#if SIZE_MAX < UINT64_MAX
|
||||
#if SIZE_MAX < 0xFFFFFFFFFFFFFFFFull
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh > ((uint64_t)SIZE_MAX)) {
|
||||
@@ -9601,8 +9661,10 @@ extern const char wuffs_jpeg__error__bad_sof_marker[];
|
||||
extern const char wuffs_jpeg__error__bad_sos_marker[];
|
||||
extern const char wuffs_jpeg__error__bad_header[];
|
||||
extern const char wuffs_jpeg__error__bad_marker[];
|
||||
extern const char wuffs_jpeg__error__bad_scan_count[];
|
||||
extern const char wuffs_jpeg__error__missing_huffman_table[];
|
||||
extern const char wuffs_jpeg__error__missing_quantization_table[];
|
||||
extern const char wuffs_jpeg__error__rejected_progressive_jpeg[];
|
||||
extern const char wuffs_jpeg__error__truncated_input[];
|
||||
extern const char wuffs_jpeg__error__unsupported_arithmetic_coding[];
|
||||
extern const char wuffs_jpeg__error__unsupported_color_model[];
|
||||
@@ -9620,6 +9682,8 @@ extern const char wuffs_jpeg__error__unsupported_scan_count[];
|
||||
|
||||
#define WUFFS_JPEG__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 51552191232u
|
||||
|
||||
#define WUFFS_JPEG__QUIRK_REJECT_PROGRESSIVE_JPEGS 1220532224u
|
||||
|
||||
// ---------------- Struct Declarations
|
||||
|
||||
typedef struct wuffs_jpeg__decoder__struct wuffs_jpeg__decoder;
|
||||
@@ -9845,6 +9909,13 @@ struct wuffs_jpeg__decoder__struct {
|
||||
uint32_t f_bitstream_ri;
|
||||
uint32_t f_bitstream_wi;
|
||||
bool f_bitstream_is_closed;
|
||||
bool f_expect_multiple_scans;
|
||||
bool f_use_lower_quality;
|
||||
bool f_reject_progressive_jpegs;
|
||||
bool f_swizzle_immediately;
|
||||
wuffs_base__status f_swizzle_immediately_status;
|
||||
uint32_t f_swizzle_immediately_b_offsets[10];
|
||||
uint32_t f_swizzle_immediately_c_offsets[5];
|
||||
uint32_t f_bitstream_padding;
|
||||
uint16_t f_quant_tables[4][64];
|
||||
uint16_t f_saved_quant_tables[4][64];
|
||||
@@ -9880,6 +9951,7 @@ struct wuffs_jpeg__decoder__struct {
|
||||
uint32_t p_skip_past_the_next_restart_marker;
|
||||
uint32_t (*choosy_decode_mcu)(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -9888,6 +9960,7 @@ struct wuffs_jpeg__decoder__struct {
|
||||
struct {
|
||||
uint8_t f_bitstream_buffer[2048];
|
||||
uint16_t f_mcu_blocks[10][64];
|
||||
uint8_t f_swizzle_immediately_buffer[640];
|
||||
uint8_t f_swizzle_ycck_scratch_buffer_2k[2048];
|
||||
uint8_t f_dht_temp_counts[16];
|
||||
uint8_t f_dht_temp_bit_lengths[256];
|
||||
@@ -12673,6 +12746,371 @@ struct wuffs_png__decoder__struct {
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_qoi__error__bad_footer[];
|
||||
extern const char wuffs_qoi__error__bad_header[];
|
||||
extern const char wuffs_qoi__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
#define WUFFS_QOI__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0u
|
||||
|
||||
// ---------------- Struct Declarations
|
||||
|
||||
typedef struct wuffs_qoi__decoder__struct wuffs_qoi__decoder;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------- Public Initializer Prototypes
|
||||
|
||||
// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
|
||||
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
|
||||
//
|
||||
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
|
||||
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
|
||||
|
||||
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
|
||||
wuffs_qoi__decoder__initialize(
|
||||
wuffs_qoi__decoder* self,
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version,
|
||||
uint32_t options);
|
||||
|
||||
size_t
|
||||
sizeof__wuffs_qoi__decoder(void);
|
||||
|
||||
// ---------------- Allocs
|
||||
|
||||
// These functions allocate and initialize Wuffs structs. They return NULL if
|
||||
// memory allocation fails. If they return non-NULL, there is no need to call
|
||||
// wuffs_foo__bar__initialize, but the caller is responsible for eventually
|
||||
// calling free on the returned pointer. That pointer is effectively a C++
|
||||
// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
|
||||
|
||||
wuffs_qoi__decoder*
|
||||
wuffs_qoi__decoder__alloc(void);
|
||||
|
||||
static inline wuffs_base__image_decoder*
|
||||
wuffs_qoi__decoder__alloc_as__wuffs_base__image_decoder(void) {
|
||||
return (wuffs_base__image_decoder*)(wuffs_qoi__decoder__alloc());
|
||||
}
|
||||
|
||||
// ---------------- Upcasts
|
||||
|
||||
static inline wuffs_base__image_decoder*
|
||||
wuffs_qoi__decoder__upcast_as__wuffs_base__image_decoder(
|
||||
wuffs_qoi__decoder* p) {
|
||||
return (wuffs_base__image_decoder*)p;
|
||||
}
|
||||
|
||||
// ---------------- Public Function Prototypes
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__get_quirk(
|
||||
const wuffs_qoi__decoder* self,
|
||||
uint32_t a_key);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__set_quirk(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_key,
|
||||
uint64_t a_value);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
|
||||
wuffs_qoi__decoder__frame_dirty_rect(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint32_t
|
||||
wuffs_qoi__decoder__num_animation_loops(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frame_configs(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frames(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__restart_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint64_t a_index,
|
||||
uint64_t a_io_position);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
|
||||
wuffs_qoi__decoder__set_report_metadata(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_fourcc,
|
||||
bool a_report);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__tell_me_more(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
|
||||
wuffs_qoi__decoder__workbuf_len(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
// ---------------- Struct Definitions
|
||||
|
||||
// These structs' fields, and the sizeof them, are private implementation
|
||||
// details that aren't guaranteed to be stable across Wuffs versions.
|
||||
//
|
||||
// See https://en.wikipedia.org/wiki/Opaque_pointer#C
|
||||
|
||||
#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
struct wuffs_qoi__decoder__struct {
|
||||
// Do not access the private_impl's or private_data's fields directly. There
|
||||
// is no API/ABI compatibility or safety guarantee if you do so. Instead, use
|
||||
// the wuffs_foo__bar__baz functions.
|
||||
//
|
||||
// It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
|
||||
// can be stack allocated when WUFFS_IMPLEMENTATION is defined.
|
||||
|
||||
struct {
|
||||
uint32_t magic;
|
||||
uint32_t active_coroutine;
|
||||
wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
|
||||
wuffs_base__vtable null_vtable;
|
||||
|
||||
uint32_t f_pixfmt;
|
||||
uint32_t f_width;
|
||||
uint32_t f_height;
|
||||
uint64_t f_remaining_pixels_times_4;
|
||||
uint8_t f_call_sequence;
|
||||
uint32_t f_buffer_index;
|
||||
uint32_t f_dst_x;
|
||||
uint32_t f_dst_y;
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config;
|
||||
uint32_t p_do_decode_image_config;
|
||||
uint32_t p_decode_frame_config;
|
||||
uint32_t p_do_decode_frame_config;
|
||||
uint32_t p_decode_frame;
|
||||
uint32_t p_do_decode_frame;
|
||||
uint32_t p_from_src_to_buffer;
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
uint8_t f_pixel[4];
|
||||
uint8_t f_cache[256];
|
||||
uint8_t f_buffer[8196];
|
||||
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_do_decode_image_config;
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_do_decode_frame;
|
||||
struct {
|
||||
uint8_t v_dg;
|
||||
uint32_t v_bi;
|
||||
uint32_t v_bk;
|
||||
} s_from_src_to_buffer;
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_qoi__decoder, wuffs_unique_ptr_deleter>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
|
||||
static inline unique_ptr
|
||||
alloc() {
|
||||
return unique_ptr(wuffs_qoi__decoder__alloc());
|
||||
}
|
||||
|
||||
static inline wuffs_base__image_decoder::unique_ptr
|
||||
alloc_as__wuffs_base__image_decoder() {
|
||||
return wuffs_base__image_decoder::unique_ptr(
|
||||
wuffs_qoi__decoder__alloc_as__wuffs_base__image_decoder());
|
||||
}
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
|
||||
// size and field layout is not part of the public, stable, memory-safe API.
|
||||
// Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
|
||||
// call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
|
||||
// their first argument) rather than tweaking bar.private_impl.qux fields.
|
||||
//
|
||||
// In C, we can just leave wuffs_foo__bar as an incomplete type (unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
|
||||
// order to provide convenience methods. These forward on "this", so that you
|
||||
// can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
|
||||
wuffs_qoi__decoder__struct() = delete;
|
||||
wuffs_qoi__decoder__struct(const wuffs_qoi__decoder__struct&) = delete;
|
||||
wuffs_qoi__decoder__struct& operator=(
|
||||
const wuffs_qoi__decoder__struct&) = delete;
|
||||
#endif // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#if !defined(WUFFS_IMPLEMENTATION)
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
|
||||
initialize(
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version,
|
||||
uint32_t options) {
|
||||
return wuffs_qoi__decoder__initialize(
|
||||
this, sizeof_star_self, wuffs_version, options);
|
||||
}
|
||||
|
||||
inline wuffs_base__image_decoder*
|
||||
upcast_as__wuffs_base__image_decoder() {
|
||||
return (wuffs_base__image_decoder*)this;
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
get_quirk(
|
||||
uint32_t a_key) const {
|
||||
return wuffs_qoi__decoder__get_quirk(this, a_key);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
set_quirk(
|
||||
uint32_t a_key,
|
||||
uint64_t a_value) {
|
||||
return wuffs_qoi__decoder__set_quirk(this, a_key, a_value);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
decode_image_config(
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
return wuffs_qoi__decoder__decode_image_config(this, a_dst, a_src);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
decode_frame_config(
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
return wuffs_qoi__decoder__decode_frame_config(this, a_dst, a_src);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
decode_frame(
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
return wuffs_qoi__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
|
||||
}
|
||||
|
||||
inline wuffs_base__rect_ie_u32
|
||||
frame_dirty_rect() const {
|
||||
return wuffs_qoi__decoder__frame_dirty_rect(this);
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
num_animation_loops() const {
|
||||
return wuffs_qoi__decoder__num_animation_loops(this);
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
num_decoded_frame_configs() const {
|
||||
return wuffs_qoi__decoder__num_decoded_frame_configs(this);
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
num_decoded_frames() const {
|
||||
return wuffs_qoi__decoder__num_decoded_frames(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
restart_frame(
|
||||
uint64_t a_index,
|
||||
uint64_t a_io_position) {
|
||||
return wuffs_qoi__decoder__restart_frame(this, a_index, a_io_position);
|
||||
}
|
||||
|
||||
inline wuffs_base__empty_struct
|
||||
set_report_metadata(
|
||||
uint32_t a_fourcc,
|
||||
bool a_report) {
|
||||
return wuffs_qoi__decoder__set_report_metadata(this, a_fourcc, a_report);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
tell_me_more(
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
return wuffs_qoi__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
|
||||
}
|
||||
|
||||
inline wuffs_base__range_ii_u64
|
||||
workbuf_len() const {
|
||||
return wuffs_qoi__decoder__workbuf_len(this);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
}; // struct wuffs_qoi__decoder__struct
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__SHA256) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
@@ -14992,6 +15430,7 @@ struct wuffs_xz__decoder__struct {
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace wuffs_aux {
|
||||
|
||||
@@ -15004,6 +15443,8 @@ using IOBuffer = wuffs_base__io_buffer;
|
||||
// nullptr, since calling free(nullptr) is a no-op.
|
||||
using MemOwner = std::unique_ptr<void, decltype(&free)>;
|
||||
|
||||
using QuirkKeyValuePair = std::pair<uint32_t, uint64_t>;
|
||||
|
||||
namespace sync_io {
|
||||
|
||||
// --------
|
||||
@@ -15186,13 +15627,14 @@ class DecodeCborCallbacks {
|
||||
|
||||
// DecodeCborArgQuirks wraps an optional argument to DecodeCbor.
|
||||
struct DecodeCborArgQuirks {
|
||||
explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeCborArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeCbor calls callbacks based on the CBOR-formatted data in input.
|
||||
@@ -15289,6 +15731,7 @@ class DecodeImageCallbacks {
|
||||
// - WUFFS_BASE__FOURCC__NIE
|
||||
// - WUFFS_BASE__FOURCC__NPBM
|
||||
// - WUFFS_BASE__FOURCC__PNG
|
||||
// - WUFFS_BASE__FOURCC__QOI
|
||||
// - WUFFS_BASE__FOURCC__TGA
|
||||
// - WUFFS_BASE__FOURCC__WBMP
|
||||
// - WUFFS_BASE__FOURCC__WEBP
|
||||
@@ -15400,13 +15843,14 @@ extern const char DecodeImage_UnsupportedPixelFormat[];
|
||||
|
||||
// DecodeImageArgQuirks wraps an optional argument to DecodeImage.
|
||||
struct DecodeImageArgQuirks {
|
||||
explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeImageArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeImageArgFlags wraps an optional argument to DecodeImage.
|
||||
@@ -15618,13 +16062,14 @@ extern const char DecodeJson_NoMatch[];
|
||||
|
||||
// DecodeJsonArgQuirks wraps an optional argument to DecodeJson.
|
||||
struct DecodeJsonArgQuirks {
|
||||
explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeJsonArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson.
|
||||
@@ -15834,6 +16279,9 @@ wuffs_private_impl__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
|
||||
|
||||
// ---------------- Numeric Types (Utility)
|
||||
|
||||
#define wuffs_base__utility__sign_extend_convert_u8_u32(a) \
|
||||
((uint32_t)(int32_t)(int8_t)(a))
|
||||
|
||||
#define wuffs_base__utility__sign_extend_convert_u16_u32(a) \
|
||||
((uint32_t)(int32_t)(int16_t)(a))
|
||||
|
||||
@@ -16543,8 +16991,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
const wuffs_base__pixel_swizzler* p,
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
wuffs_base__slice_u8 dst_palette,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
wuffs_base__slice_u8 src0,
|
||||
wuffs_base__slice_u8 src1,
|
||||
wuffs_base__slice_u8 src2,
|
||||
@@ -28479,8 +28929,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -28502,6 +28954,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) {
|
||||
if ((x_min_incl != 0) || (y_min_incl != 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
@@ -28514,7 +28970,7 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
// First row.
|
||||
uint32_t h1v2_bias = 1u;
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
dst, width, 0u, //
|
||||
dst, x_max_excl, 0u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, src_ptr3, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
@@ -28526,10 +28982,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
h1v2_bias = 2u;
|
||||
|
||||
// Middle rows.
|
||||
bool last_row = height == 2u * half_height_for_2to1;
|
||||
uint32_t y_max_excl = last_row ? (height - 1u) : height;
|
||||
bool last_row = y_max_excl == 2u * half_height_for_2to1;
|
||||
uint32_t middle_y_max_excl = last_row ? (y_max_excl - 1u) : y_max_excl;
|
||||
uint32_t y;
|
||||
for (y = 1u; y < y_max_excl; y++) {
|
||||
for (y = 1u; y < middle_y_max_excl; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src0_minor =
|
||||
(inv_v0 != 2u)
|
||||
@@ -28556,11 +29012,11 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
uint32_t total_src_len3 = 0u;
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
while (x < x_max_excl) {
|
||||
bool first_column = x == 0u;
|
||||
uint32_t end = x + 480u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
@@ -28616,9 +29072,9 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
}
|
||||
|
||||
// Last row.
|
||||
if (y_max_excl != height) {
|
||||
if (middle_y_max_excl != y_max_excl) {
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
dst, width, height - 1u, //
|
||||
dst, x_max_excl, middle_y_max_excl, //
|
||||
src_ptr0, src_ptr1, src_ptr2, src_ptr3, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
@@ -28714,8 +29170,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -28733,6 +29191,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) {
|
||||
if ((x_min_incl != 0) || (y_min_incl != 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
@@ -28743,7 +29205,7 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
// First row.
|
||||
uint32_t h1v2_bias = 1u;
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
dst, width, 0u, //
|
||||
dst, x_max_excl, 0u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
@@ -28755,10 +29217,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
h1v2_bias = 2u;
|
||||
|
||||
// Middle rows.
|
||||
bool last_row = height == 2u * half_height_for_2to1;
|
||||
uint32_t y_max_excl = last_row ? (height - 1u) : height;
|
||||
bool last_row = y_max_excl == 2u * half_height_for_2to1;
|
||||
uint32_t middle_y_max_excl = last_row ? (y_max_excl - 1u) : y_max_excl;
|
||||
uint32_t y;
|
||||
for (y = 1u; y < y_max_excl; y++) {
|
||||
for (y = 1u; y < middle_y_max_excl; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src0_minor =
|
||||
(inv_v0 != 2u)
|
||||
@@ -28779,11 +29241,11 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
uint32_t total_src_len2 = 0u;
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
while (x < x_max_excl) {
|
||||
bool first_column = x == 0u;
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
@@ -28828,16 +29290,16 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
}
|
||||
|
||||
// Last row.
|
||||
if (y_max_excl != height) {
|
||||
if (middle_y_max_excl != y_max_excl) {
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
dst, width, height - 1u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, //
|
||||
h1v2_bias, //
|
||||
scratch_buffer_2k_ptr, //
|
||||
dst, x_max_excl, middle_y_max_excl, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, //
|
||||
h1v2_bias, //
|
||||
scratch_buffer_2k_ptr, //
|
||||
upfunc0, upfunc1, upfunc2, conv3func);
|
||||
}
|
||||
}
|
||||
@@ -28845,8 +29307,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -28872,41 +29336,44 @@ wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
|
||||
uint32_t y;
|
||||
for (y = 0u; y < height; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major = src_ptr1 + ((y / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major = src_ptr2 + ((y / inv_v2) * (size_t)stride2);
|
||||
for (y = y_min_incl; y < y_max_excl; y++) {
|
||||
const uint8_t* src0_major =
|
||||
src_ptr0 + (((y - y_min_incl) / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major =
|
||||
src_ptr1 + (((y - y_min_incl) / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major =
|
||||
src_ptr2 + (((y - y_min_incl) / inv_v2) * (size_t)stride2);
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
uint32_t x = x_min_incl;
|
||||
while (x < x_max_excl) {
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src_len0, //
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src_len1, //
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src_len2, //
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
(*conv3func)(dst, x, end, y, up0, up1, up2);
|
||||
@@ -28915,6 +29382,100 @@ wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
}
|
||||
}
|
||||
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycck__general__box_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
const uint8_t* src_ptr3,
|
||||
uint32_t stride0,
|
||||
uint32_t stride1,
|
||||
uint32_t stride2,
|
||||
uint32_t stride3,
|
||||
uint32_t inv_h0,
|
||||
uint32_t inv_h1,
|
||||
uint32_t inv_h2,
|
||||
uint32_t inv_h3,
|
||||
uint32_t inv_v0,
|
||||
uint32_t inv_v1,
|
||||
uint32_t inv_v2,
|
||||
uint32_t inv_v3,
|
||||
uint32_t half_width_for_2to1,
|
||||
uint32_t half_height_for_2to1,
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) {
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
(*upfuncs)[(inv_h1 - 1u) & 3u][(inv_v1 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc2 =
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc3 =
|
||||
(*upfuncs)[(inv_h3 - 1u) & 3u][(inv_v3 - 1u) & 3u];
|
||||
|
||||
uint32_t y;
|
||||
for (y = y_min_incl; y < y_max_excl; y++) {
|
||||
const uint8_t* src0_major =
|
||||
src_ptr0 + (((y - y_min_incl) / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major =
|
||||
src_ptr1 + (((y - y_min_incl) / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major =
|
||||
src_ptr2 + (((y - y_min_incl) / inv_v2) * (size_t)stride2);
|
||||
const uint8_t* src3_major =
|
||||
src_ptr3 + (((y - y_min_incl) / inv_v3) * (size_t)stride3);
|
||||
|
||||
uint32_t x = x_min_incl;
|
||||
while (x < x_max_excl) {
|
||||
uint32_t end = x + 480u;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
uint32_t src_len3 = ((end - x) + inv_h3 - 1u) / inv_h3;
|
||||
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 480u), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 480u), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 480u), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up3 = (*upfunc3)( //
|
||||
scratch_buffer_2k_ptr + (3u * 480u), //
|
||||
src3_major + ((x - x_min_incl) / inv_h3), //
|
||||
src3_major + ((x - x_min_incl) / inv_h3), //
|
||||
src_len3, //
|
||||
0u, false, false);
|
||||
|
||||
(*conv4func)(dst, x, end, y, up0, up1, up2, up3);
|
||||
x = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_private_impl__swizzle_flattened_length is like
|
||||
@@ -28939,8 +29500,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
const wuffs_base__pixel_swizzler* p,
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
wuffs_base__slice_u8 dst_palette,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
wuffs_base__slice_u8 src0,
|
||||
wuffs_base__slice_u8 src1,
|
||||
wuffs_base__slice_u8 src2,
|
||||
@@ -28970,13 +29533,18 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
wuffs_base__slice_u8 scratch_buffer_2k) {
|
||||
if (!p) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
} else if (!dst || (width > 0xFFFFu) || (height > 0xFFFFu) || //
|
||||
(4u <= ((unsigned int)h0 - 1u)) || //
|
||||
(4u <= ((unsigned int)h1 - 1u)) || //
|
||||
(4u <= ((unsigned int)h2 - 1u)) || //
|
||||
(4u <= ((unsigned int)v0 - 1u)) || //
|
||||
(4u <= ((unsigned int)v1 - 1u)) || //
|
||||
(4u <= ((unsigned int)v2 - 1u)) || //
|
||||
} else if (!dst || //
|
||||
(x_min_incl > x_max_excl) || //
|
||||
(x_max_excl > 0xFFFFu) || //
|
||||
(y_min_incl > y_max_excl) || //
|
||||
(y_max_excl > 0xFFFFu) || //
|
||||
(4u <= ((unsigned int)h0 - 1u)) || //
|
||||
(4u <= ((unsigned int)h1 - 1u)) || //
|
||||
(4u <= ((unsigned int)h2 - 1u)) || //
|
||||
(4u <= ((unsigned int)v0 - 1u)) || //
|
||||
(4u <= ((unsigned int)v1 - 1u)) || //
|
||||
(4u <= ((unsigned int)v2 - 1u)) || //
|
||||
(triangle_filter_for_2to1 && ((x_min_incl | y_min_incl) > 0u)) ||
|
||||
(scratch_buffer_2k.len < 2048u)) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
@@ -29003,21 +29571,69 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
uint32_t inv_v2 = max_incl_v / v2;
|
||||
uint32_t inv_v3 = v3 ? (max_incl_v / v3) : 0u;
|
||||
|
||||
uint32_t half_width_for_2to1 = (width + 1u) / 2u;
|
||||
uint32_t half_height_for_2to1 = (height + 1u) / 2u;
|
||||
if (x_min_incl != 0) {
|
||||
if ((x_min_incl % inv_h0) || (x_min_incl % inv_h1) ||
|
||||
(x_min_incl % inv_h2) || (inv_h3 && (x_min_incl % inv_h3))) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
}
|
||||
if (y_min_incl != 0) {
|
||||
if ((y_min_incl % inv_v0) || (y_min_incl % inv_v1) ||
|
||||
(y_min_incl % inv_v2) || (inv_v3 && (y_min_incl % inv_v3))) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
}
|
||||
|
||||
width = wuffs_private_impl__u32__min_of_5( //
|
||||
width, //
|
||||
width0 * inv_h0, //
|
||||
width1 * inv_h1, //
|
||||
width2 * inv_h2, //
|
||||
wuffs_base__pixel_config__width(&dst->pixcfg));
|
||||
height = wuffs_private_impl__u32__min_of_5( //
|
||||
height, //
|
||||
height0 * inv_v0, //
|
||||
height1 * inv_v1, //
|
||||
height2 * inv_v2, //
|
||||
wuffs_base__pixel_config__height(&dst->pixcfg));
|
||||
uint32_t half_width_for_2to1 = ((x_max_excl - x_min_incl) + 1u) / 2u;
|
||||
if (inv_h0 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width0);
|
||||
}
|
||||
if (inv_h1 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width1);
|
||||
}
|
||||
if (inv_h2 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width2);
|
||||
}
|
||||
if (inv_h3 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width3);
|
||||
}
|
||||
|
||||
uint32_t half_height_for_2to1 = ((y_max_excl - y_min_incl) + 1u) / 2u;
|
||||
if (inv_v0 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height0);
|
||||
}
|
||||
if (inv_v1 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height1);
|
||||
}
|
||||
if (inv_v2 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height2);
|
||||
}
|
||||
if (inv_v3 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height3);
|
||||
}
|
||||
|
||||
x_max_excl = wuffs_base__u32__min( //
|
||||
wuffs_base__pixel_config__width(&dst->pixcfg), //
|
||||
x_min_incl + wuffs_private_impl__u32__min_of_5( //
|
||||
x_max_excl - x_min_incl, //
|
||||
width0 * inv_h0, //
|
||||
width1 * inv_h1, //
|
||||
width2 * inv_h2, //
|
||||
inv_h3 ? (width3 * inv_h3) : 0xFFFFFFFF));
|
||||
y_max_excl = wuffs_base__u32__min( //
|
||||
wuffs_base__pixel_config__height(&dst->pixcfg), //
|
||||
y_min_incl + wuffs_private_impl__u32__min_of_5( //
|
||||
y_max_excl - y_min_incl, //
|
||||
height0 * inv_v0, //
|
||||
height1 * inv_v1, //
|
||||
height2 * inv_v2, //
|
||||
inv_v3 ? (height3 * inv_v3) : 0xFFFFFFFF));
|
||||
|
||||
if ((x_min_incl >= x_max_excl) || (y_min_incl >= y_max_excl)) {
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
uint32_t width = x_max_excl - x_min_incl;
|
||||
uint32_t height = y_max_excl - y_min_incl;
|
||||
|
||||
if (((h0 * inv_h0) != max_incl_h) || //
|
||||
((h1 * inv_h1) != max_incl_h) || //
|
||||
@@ -29118,10 +29734,6 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
|
||||
// ----
|
||||
|
||||
if ((width <= 0u) || (height <= 0u)) {
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func = NULL;
|
||||
|
||||
if (is_rgb_or_cmyk) {
|
||||
@@ -29156,28 +29768,58 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
}
|
||||
}
|
||||
|
||||
void (*func)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t width, //
|
||||
uint32_t height, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) =
|
||||
void (*func3)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t x_min_incl, //
|
||||
uint32_t x_max_excl, //
|
||||
uint32_t y_min_incl, //
|
||||
uint32_t y_max_excl, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) =
|
||||
&wuffs_private_impl__swizzle_ycc__general__box_filter;
|
||||
|
||||
void (*func4)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t x_min_incl, //
|
||||
uint32_t x_max_excl, //
|
||||
uint32_t y_min_incl, //
|
||||
uint32_t y_max_excl, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
const uint8_t* src_ptr3, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t stride3, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_h3, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t inv_v3, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) =
|
||||
&wuffs_private_impl__swizzle_ycck__general__box_filter;
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfuncs[4][4];
|
||||
memcpy(&upfuncs, &wuffs_private_impl__swizzle_ycc__upsample_funcs,
|
||||
sizeof upfuncs);
|
||||
@@ -29185,8 +29827,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
if (triangle_filter_for_2to1 &&
|
||||
(wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h0, inv_v0) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_private_impl__swizzle_ycc__general__triangle_filter;
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h2, inv_v2) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h3, inv_v3))) {
|
||||
func3 = &wuffs_private_impl__swizzle_ycc__general__triangle_filter;
|
||||
func4 = &wuffs_private_impl__swizzle_ycck__general__triangle_filter;
|
||||
|
||||
upfuncs[0][1] = wuffs_private_impl__swizzle_ycc__upsample_inv_h1v2_triangle;
|
||||
upfuncs[1][0] = wuffs_private_impl__swizzle_ycc__upsample_inv_h2v1_triangle;
|
||||
@@ -29218,23 +29862,23 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func =
|
||||
is_rgb_or_cmyk ? &wuffs_private_impl__swizzle_cmyk__convert_4_general
|
||||
: &wuffs_private_impl__swizzle_ycck__convert_4_general;
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter( //
|
||||
dst, width, height, //
|
||||
src0.ptr, src1.ptr, src2.ptr, src3.ptr, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
inv_v0, inv_v1, inv_v2, inv_v3, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
(*func4)( //
|
||||
dst, x_min_incl, x_max_excl, y_min_incl, y_max_excl, //
|
||||
src0.ptr, src1.ptr, src2.ptr, src3.ptr, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
inv_v0, inv_v1, inv_v2, inv_v3, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
scratch_buffer_2k.ptr, &upfuncs, conv4func);
|
||||
|
||||
} else {
|
||||
(*func)( //
|
||||
dst, width, height, //
|
||||
src0.ptr, src1.ptr, src2.ptr, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
(*func3)( //
|
||||
dst, x_min_incl, x_max_excl, y_min_incl, y_max_excl, //
|
||||
src0.ptr, src1.ptr, src2.ptr, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
scratch_buffer_2k.ptr, &upfuncs, conv3func);
|
||||
}
|
||||
|
||||
@@ -30209,7 +30853,7 @@ wuffs_adler32__hasher__initialize(
|
||||
wuffs_adler32__hasher*
|
||||
wuffs_adler32__hasher__alloc(void) {
|
||||
wuffs_adler32__hasher* x =
|
||||
(wuffs_adler32__hasher*)(calloc(sizeof(wuffs_adler32__hasher), 1));
|
||||
(wuffs_adler32__hasher*)(calloc(1, sizeof(wuffs_adler32__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -30815,7 +31459,7 @@ wuffs_bmp__decoder__initialize(
|
||||
wuffs_bmp__decoder*
|
||||
wuffs_bmp__decoder__alloc(void) {
|
||||
wuffs_bmp__decoder* x =
|
||||
(wuffs_bmp__decoder*)(calloc(sizeof(wuffs_bmp__decoder), 1));
|
||||
(wuffs_bmp__decoder*)(calloc(1, sizeof(wuffs_bmp__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -30953,6 +31597,7 @@ wuffs_bmp__decoder__do_decode_image_config(
|
||||
uint32_t v_width = 0;
|
||||
uint32_t v_height = 0;
|
||||
uint32_t v_planes = 0;
|
||||
uint32_t v_n = 0;
|
||||
uint32_t v_dst_pixfmt = 0;
|
||||
uint32_t v_byte_width = 0;
|
||||
|
||||
@@ -31710,7 +32355,8 @@ wuffs_bmp__decoder__do_decode_image_config(
|
||||
}
|
||||
}
|
||||
} else if (self->private_impl.f_bitmap_info_len >= 40u) {
|
||||
self->private_data.s_do_decode_image_config.scratch = (self->private_impl.f_bitmap_info_len - 40u);
|
||||
v_n = (self->private_impl.f_bitmap_info_len - 40u);
|
||||
self->private_data.s_do_decode_image_config.scratch = v_n;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45);
|
||||
if (self->private_data.s_do_decode_image_config.scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config.scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
@@ -33579,7 +34225,7 @@ wuffs_bzip2__decoder__initialize(
|
||||
wuffs_bzip2__decoder*
|
||||
wuffs_bzip2__decoder__alloc(void) {
|
||||
wuffs_bzip2__decoder* x =
|
||||
(wuffs_bzip2__decoder*)(calloc(sizeof(wuffs_bzip2__decoder), 1));
|
||||
(wuffs_bzip2__decoder*)(calloc(1, sizeof(wuffs_bzip2__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -35137,7 +35783,7 @@ wuffs_cbor__decoder__initialize(
|
||||
wuffs_cbor__decoder*
|
||||
wuffs_cbor__decoder__alloc(void) {
|
||||
wuffs_cbor__decoder* x =
|
||||
(wuffs_cbor__decoder*)(calloc(sizeof(wuffs_cbor__decoder), 1));
|
||||
(wuffs_cbor__decoder*)(calloc(1, sizeof(wuffs_cbor__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -36449,7 +37095,7 @@ wuffs_crc32__ieee_hasher__initialize(
|
||||
wuffs_crc32__ieee_hasher*
|
||||
wuffs_crc32__ieee_hasher__alloc(void) {
|
||||
wuffs_crc32__ieee_hasher* x =
|
||||
(wuffs_crc32__ieee_hasher*)(calloc(sizeof(wuffs_crc32__ieee_hasher), 1));
|
||||
(wuffs_crc32__ieee_hasher*)(calloc(1, sizeof(wuffs_crc32__ieee_hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -37284,7 +37930,7 @@ wuffs_crc64__ecma_hasher__initialize(
|
||||
wuffs_crc64__ecma_hasher*
|
||||
wuffs_crc64__ecma_hasher__alloc(void) {
|
||||
wuffs_crc64__ecma_hasher* x =
|
||||
(wuffs_crc64__ecma_hasher*)(calloc(sizeof(wuffs_crc64__ecma_hasher), 1));
|
||||
(wuffs_crc64__ecma_hasher*)(calloc(1, sizeof(wuffs_crc64__ecma_hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -37835,7 +38481,7 @@ wuffs_deflate__decoder__initialize(
|
||||
wuffs_deflate__decoder*
|
||||
wuffs_deflate__decoder__alloc(void) {
|
||||
wuffs_deflate__decoder* x =
|
||||
(wuffs_deflate__decoder*)(calloc(sizeof(wuffs_deflate__decoder), 1));
|
||||
(wuffs_deflate__decoder*)(calloc(1, sizeof(wuffs_deflate__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -40250,7 +40896,7 @@ wuffs_gif__decoder__initialize(
|
||||
wuffs_gif__decoder*
|
||||
wuffs_gif__decoder__alloc(void) {
|
||||
wuffs_gif__decoder* x =
|
||||
(wuffs_gif__decoder*)(calloc(sizeof(wuffs_gif__decoder), 1));
|
||||
(wuffs_gif__decoder*)(calloc(1, sizeof(wuffs_gif__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -43161,7 +43807,7 @@ wuffs_gzip__decoder__initialize(
|
||||
wuffs_gzip__decoder*
|
||||
wuffs_gzip__decoder__alloc(void) {
|
||||
wuffs_gzip__decoder* x =
|
||||
(wuffs_gzip__decoder*)(calloc(sizeof(wuffs_gzip__decoder), 1));
|
||||
(wuffs_gzip__decoder*)(calloc(1, sizeof(wuffs_gzip__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -43655,8 +44301,10 @@ const char wuffs_jpeg__error__bad_sof_marker[] = "#jpeg: bad SOF marker";
|
||||
const char wuffs_jpeg__error__bad_sos_marker[] = "#jpeg: bad SOS marker";
|
||||
const char wuffs_jpeg__error__bad_header[] = "#jpeg: bad header";
|
||||
const char wuffs_jpeg__error__bad_marker[] = "#jpeg: bad marker";
|
||||
const char wuffs_jpeg__error__bad_scan_count[] = "#jpeg: bad scan count";
|
||||
const char wuffs_jpeg__error__missing_huffman_table[] = "#jpeg: missing Huffman table";
|
||||
const char wuffs_jpeg__error__missing_quantization_table[] = "#jpeg: missing Quantization table";
|
||||
const char wuffs_jpeg__error__rejected_progressive_jpeg[] = "#jpeg: rejected progressive JPEG";
|
||||
const char wuffs_jpeg__error__truncated_input[] = "#jpeg: truncated input";
|
||||
const char wuffs_jpeg__error__unsupported_arithmetic_coding[] = "#jpeg: unsupported arithmetic coding";
|
||||
const char wuffs_jpeg__error__unsupported_color_model[] = "#jpeg: unsupported color model";
|
||||
@@ -43895,6 +44543,8 @@ WUFFS_JPEG__DEFAULT_HUFF_TABLE_AC_CHROMA[179] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
248u, 249u, 250u,
|
||||
};
|
||||
|
||||
#define WUFFS_JPEG__QUIRKS_BASE 1220532224u
|
||||
|
||||
// ---------------- Private Initializer Prototypes
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
@@ -43999,6 +44649,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_jpeg__decoder__decode_sos(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
@@ -44081,14 +44732,23 @@ static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_gray(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1,
|
||||
uint64_t a_stride);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_colorful(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static bool
|
||||
@@ -44109,6 +44769,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44117,6 +44778,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu__choosy_default(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44125,6 +44787,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44133,6 +44796,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44141,6 +44805,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44149,6 +44814,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44247,7 +44913,7 @@ wuffs_jpeg__decoder__initialize(
|
||||
wuffs_jpeg__decoder*
|
||||
wuffs_jpeg__decoder__alloc(void) {
|
||||
wuffs_jpeg__decoder* x =
|
||||
(wuffs_jpeg__decoder*)(calloc(sizeof(wuffs_jpeg__decoder), 1));
|
||||
(wuffs_jpeg__decoder*)(calloc(1, sizeof(wuffs_jpeg__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -45792,6 +46458,15 @@ wuffs_jpeg__decoder__get_quirk(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a_key == 2u) {
|
||||
if (self->private_impl.f_use_lower_quality) {
|
||||
return 18446744073709551615u;
|
||||
}
|
||||
} else if (a_key == 1220532224u) {
|
||||
if (self->private_impl.f_reject_progressive_jpegs) {
|
||||
return 1u;
|
||||
}
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
@@ -45813,6 +46488,13 @@ wuffs_jpeg__decoder__set_quirk(
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
|
||||
if (a_key == 2u) {
|
||||
self->private_impl.f_use_lower_quality = (a_value >= 9223372036854775808u);
|
||||
return wuffs_base__make_status(NULL);
|
||||
} else if (a_key == 1220532224u) {
|
||||
self->private_impl.f_reject_progressive_jpegs = (a_value != 0u);
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
|
||||
@@ -46021,7 +46703,10 @@ wuffs_jpeg__decoder__do_decode_image_config(
|
||||
goto exit;
|
||||
} else if (v_marker < 208u) {
|
||||
if (v_marker <= 194u) {
|
||||
if (self->private_impl.f_sof_marker != 0u) {
|
||||
if ((v_marker == 194u) && self->private_impl.f_reject_progressive_jpegs) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__rejected_progressive_jpeg);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_sof_marker != 0u) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__bad_sof_marker);
|
||||
goto exit;
|
||||
}
|
||||
@@ -47099,14 +47784,27 @@ wuffs_jpeg__decoder__decode_frame(
|
||||
if ((v_ddf_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
v_ddf_status = wuffs_base__make_status(wuffs_jpeg__error__truncated_input);
|
||||
}
|
||||
if (wuffs_base__status__is_error(&v_ddf_status) || (v_scan_count < self->private_impl.f_scan_count)) {
|
||||
if ( ! self->private_impl.f_swizzle_immediately && (wuffs_base__status__is_error(&v_ddf_status) || (v_scan_count < self->private_impl.f_scan_count))) {
|
||||
if (self->private_impl.f_sof_marker >= 194u) {
|
||||
wuffs_jpeg__decoder__apply_progressive_idct(self, a_workbuf);
|
||||
}
|
||||
if (self->private_impl.f_num_components == 1u) {
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_gray(self, a_dst, a_workbuf);
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_gray(self,
|
||||
a_dst,
|
||||
a_workbuf,
|
||||
0u,
|
||||
4294967295u,
|
||||
0u,
|
||||
4294967295u,
|
||||
((uint64_t)(self->private_impl.f_components_workbuf_widths[0u])));
|
||||
} else {
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_colorful(self, a_dst, a_workbuf);
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_colorful(self,
|
||||
a_dst,
|
||||
a_workbuf,
|
||||
0u,
|
||||
4294967295u,
|
||||
0u,
|
||||
4294967295u);
|
||||
}
|
||||
if (wuffs_base__status__is_error(&v_ddf_status)) {
|
||||
status = v_ddf_status;
|
||||
@@ -47211,9 +47909,14 @@ wuffs_jpeg__decoder__do_decode_frame(
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
self->private_impl.f_swizzle_immediately = false;
|
||||
if (self->private_impl.f_components_workbuf_offsets[8u] > ((uint64_t)(a_workbuf.len))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
if (self->private_impl.f_sof_marker >= 194u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_swizzle_immediately = self->private_impl.f_use_lower_quality;
|
||||
self->private_impl.f_swizzle_immediately_status = wuffs_base__make_status(NULL);
|
||||
} else if (self->private_impl.f_components_workbuf_offsets[4u] < self->private_impl.f_components_workbuf_offsets[8u]) {
|
||||
wuffs_private_impl__bulk_memset(a_workbuf.ptr + self->private_impl.f_components_workbuf_offsets[4u], (self->private_impl.f_components_workbuf_offsets[8u] - self->private_impl.f_components_workbuf_offsets[4u]), 0u);
|
||||
}
|
||||
@@ -47326,7 +48029,7 @@ wuffs_jpeg__decoder__do_decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
status = wuffs_jpeg__decoder__decode_sos(self, a_src, a_workbuf);
|
||||
status = wuffs_jpeg__decoder__decode_sos(self, a_dst, a_src, a_workbuf);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -47673,13 +48376,6 @@ wuffs_jpeg__decoder__calculate_huff_tables(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_k += 1u;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_j += 1u;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -47696,6 +48392,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_jpeg__decoder__decode_sos(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
@@ -47713,9 +48410,12 @@ wuffs_jpeg__decoder__decode_sos(
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_scan_count >= 64u) {
|
||||
if (self->private_impl.f_scan_count >= 32u) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__unsupported_scan_count);
|
||||
goto exit;
|
||||
} else if ((self->private_impl.f_scan_count > 0u) && ! self->private_impl.f_expect_multiple_scans) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__bad_scan_count);
|
||||
goto exit;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_jpeg__decoder__prepare_scan(self, a_src);
|
||||
@@ -47745,12 +48445,26 @@ wuffs_jpeg__decoder__decode_sos(
|
||||
wuffs_jpeg__decoder__load_mcu_blocks(self, v_mx, v_my, a_workbuf);
|
||||
}
|
||||
while (true) {
|
||||
v_decode_mcu_result = wuffs_jpeg__decoder__decode_mcu(self, a_workbuf, v_mx, v_my);
|
||||
v_decode_mcu_result = wuffs_jpeg__decoder__decode_mcu(self,
|
||||
a_dst,
|
||||
a_workbuf,
|
||||
v_mx,
|
||||
v_my);
|
||||
if (v_decode_mcu_result == 0u) {
|
||||
break;
|
||||
} else if (v_decode_mcu_result != 1u) {
|
||||
} else if (v_decode_mcu_result == 1u) {
|
||||
} else if (v_decode_mcu_result == 2u) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__internal_error_inconsistent_decoder_state);
|
||||
goto exit;
|
||||
} else {
|
||||
status = self->private_impl.f_swizzle_immediately_status;
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
goto exit;
|
||||
} else if (wuffs_base__status__is_suspension(&status)) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension);
|
||||
goto exit;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
while (true) {
|
||||
v_bitstream_length = ((uint32_t)(self->private_impl.f_bitstream_wi - self->private_impl.f_bitstream_ri));
|
||||
@@ -47939,6 +48653,9 @@ wuffs_jpeg__decoder__prepare_scan(
|
||||
}
|
||||
v_i += 1u;
|
||||
}
|
||||
if (self->private_impl.f_scan_count == 0u) {
|
||||
self->private_impl.f_expect_multiple_scans = ((self->private_impl.f_sof_marker >= 194u) || (self->private_impl.f_scan_num_components < self->private_impl.f_num_components));
|
||||
}
|
||||
if (self->private_impl.f_sof_marker < 194u) {
|
||||
self->private_data.s_prepare_scan.scratch = 3u;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
@@ -48188,6 +48905,7 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
uint32_t v_b = 0;
|
||||
uint32_t v_bx_offset = 0;
|
||||
uint32_t v_by_offset = 0;
|
||||
uint32_t v_sibo = 0;
|
||||
uint8_t v_ssel = 0;
|
||||
uint8_t v_csel = 0;
|
||||
|
||||
@@ -48200,6 +48918,7 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
v_h = ((uint32_t)(self->private_impl.f_components_h[self->private_impl.f_scan_comps_cselector[v_i]]));
|
||||
v_v = ((uint32_t)(self->private_impl.f_components_v[self->private_impl.f_scan_comps_cselector[v_i]]));
|
||||
v_hv = (((uint32_t)(self->private_impl.f_components_h[self->private_impl.f_scan_comps_cselector[v_i]])) * ((uint32_t)(self->private_impl.f_components_v[self->private_impl.f_scan_comps_cselector[v_i]])));
|
||||
self->private_impl.f_swizzle_immediately_c_offsets[v_i] = ((uint32_t)(64u * v_total_hv));
|
||||
v_total_hv += v_hv;
|
||||
while (v_hv > 0u) {
|
||||
self->private_impl.f_scan_comps_bx_offset[(v_b & 15u)] = ((uint8_t)((v_bx_offset & 3u)));
|
||||
@@ -48222,6 +48941,7 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
return true;
|
||||
}
|
||||
self->private_impl.f_mcu_num_blocks = v_total_hv;
|
||||
self->private_impl.f_swizzle_immediately_c_offsets[self->private_impl.f_scan_num_components] = ((uint32_t)(64u * v_total_hv));
|
||||
v_b = 0u;
|
||||
while (v_b < self->private_impl.f_mcu_num_blocks) {
|
||||
v_ssel = self->private_impl.f_mcu_blocks_sselector[v_b];
|
||||
@@ -48231,6 +48951,8 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
self->private_impl.f_mcu_blocks_my_mul[v_b] = (8u * ((uint32_t)(self->private_impl.f_components_v[v_csel])) * self->private_impl.f_components_workbuf_widths[v_csel]);
|
||||
self->private_impl.f_mcu_blocks_dc_hselector[v_b] = ((uint8_t)(0u | self->private_impl.f_scan_comps_td[v_ssel]));
|
||||
self->private_impl.f_mcu_blocks_ac_hselector[v_b] = ((uint8_t)(4u | self->private_impl.f_scan_comps_ta[v_ssel]));
|
||||
v_sibo = ((uint32_t)(self->private_impl.f_swizzle_immediately_c_offsets[v_csel] + ((8u * ((uint32_t)(self->private_impl.f_scan_comps_bx_offset[v_b]))) + (64u * ((uint32_t)(self->private_impl.f_scan_comps_by_offset[v_b])) * ((uint32_t)(self->private_impl.f_components_h[v_csel]))))));
|
||||
self->private_impl.f_swizzle_immediately_b_offsets[v_b] = wuffs_base__u32__min(v_sibo, 576u);
|
||||
v_b += 1u;
|
||||
}
|
||||
self->private_impl.f_scan_width_in_mcus = self->private_impl.f_width_in_mcus;
|
||||
@@ -48566,15 +49288,21 @@ static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_gray(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1,
|
||||
uint64_t a_stride) {
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint32_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_length = 0;
|
||||
uint64_t v_x0 = 0;
|
||||
uint64_t v_x1 = 0;
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
uint32_t v_y = 0;
|
||||
uint64_t v_stride = 0;
|
||||
uint32_t v_y1 = 0;
|
||||
|
||||
v_dst_pixfmt = wuffs_base__pixel_buffer__pixel_format(a_dst);
|
||||
v_dst_bits_per_pixel = wuffs_base__pixel_format__bits_per_pixel(&v_dst_pixfmt);
|
||||
@@ -48582,18 +49310,24 @@ wuffs_jpeg__decoder__swizzle_gray(
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
v_dst_bytes_per_pixel = (v_dst_bits_per_pixel / 8u);
|
||||
v_dst_length = ((uint64_t)((v_dst_bytes_per_pixel * self->private_impl.f_width)));
|
||||
v_x0 = ((uint64_t)((v_dst_bytes_per_pixel * wuffs_base__u32__min(a_x0, self->private_impl.f_width))));
|
||||
v_x1 = ((uint64_t)((v_dst_bytes_per_pixel * wuffs_base__u32__min(a_x1, self->private_impl.f_width))));
|
||||
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0u);
|
||||
v_y = 0u;
|
||||
while (v_y < self->private_impl.f_height) {
|
||||
v_y = a_y0;
|
||||
v_y1 = wuffs_base__u32__min(a_y1, self->private_impl.f_height);
|
||||
while (v_y < v_y1) {
|
||||
v_dst = wuffs_private_impl__table_u8__row_u32(v_tab, v_y);
|
||||
if (v_dst_length < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_j(v_dst, v_dst_length);
|
||||
if (v_x1 < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_j(v_dst, v_x1);
|
||||
}
|
||||
if (v_x0 < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_x0);
|
||||
} else {
|
||||
v_dst = wuffs_base__utility__empty_slice_u8();
|
||||
}
|
||||
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, wuffs_base__pixel_buffer__palette_or_else(a_dst, wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024)), a_workbuf);
|
||||
v_stride = ((uint64_t)(self->private_impl.f_components_workbuf_widths[0u]));
|
||||
if (v_stride <= ((uint64_t)(a_workbuf.len))) {
|
||||
a_workbuf = wuffs_base__slice_u8__subslice_i(a_workbuf, v_stride);
|
||||
if (a_stride <= ((uint64_t)(a_workbuf.len))) {
|
||||
a_workbuf = wuffs_base__slice_u8__subslice_i(a_workbuf, a_stride);
|
||||
} else {
|
||||
a_workbuf = wuffs_base__utility__empty_slice_u8();
|
||||
}
|
||||
@@ -48609,54 +49343,109 @@ static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_colorful(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1) {
|
||||
uint64_t v_i = 0;
|
||||
uint64_t v_j = 0;
|
||||
wuffs_base__slice_u8 v_src0 = {0};
|
||||
wuffs_base__slice_u8 v_src1 = {0};
|
||||
wuffs_base__slice_u8 v_src2 = {0};
|
||||
wuffs_base__slice_u8 v_src3 = {0};
|
||||
uint32_t v_width0 = 0;
|
||||
uint32_t v_width1 = 0;
|
||||
uint32_t v_width2 = 0;
|
||||
uint32_t v_width3 = 0;
|
||||
uint32_t v_height0 = 0;
|
||||
uint32_t v_height1 = 0;
|
||||
uint32_t v_height2 = 0;
|
||||
uint32_t v_height3 = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
if ((self->private_impl.f_components_workbuf_offsets[0u] <= self->private_impl.f_components_workbuf_offsets[1u]) && (self->private_impl.f_components_workbuf_offsets[1u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src0 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[0u],
|
||||
self->private_impl.f_components_workbuf_offsets[1u]);
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[1u] <= self->private_impl.f_components_workbuf_offsets[2u]) && (self->private_impl.f_components_workbuf_offsets[2u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src1 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[1u],
|
||||
self->private_impl.f_components_workbuf_offsets[2u]);
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[2u] <= self->private_impl.f_components_workbuf_offsets[3u]) && (self->private_impl.f_components_workbuf_offsets[3u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src2 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[2u],
|
||||
self->private_impl.f_components_workbuf_offsets[3u]);
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[3u] <= self->private_impl.f_components_workbuf_offsets[4u]) && (self->private_impl.f_components_workbuf_offsets[4u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src3 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[3u],
|
||||
self->private_impl.f_components_workbuf_offsets[4u]);
|
||||
if (self->private_impl.f_swizzle_immediately) {
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[0u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[1u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src0 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width0 = (8u * ((uint32_t)(self->private_impl.f_components_h[0u])));
|
||||
v_height0 = (8u * ((uint32_t)(self->private_impl.f_components_v[0u])));
|
||||
}
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[1u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[2u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src1 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width1 = (8u * ((uint32_t)(self->private_impl.f_components_h[1u])));
|
||||
v_height1 = (8u * ((uint32_t)(self->private_impl.f_components_v[1u])));
|
||||
}
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[2u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[3u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src2 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width2 = (8u * ((uint32_t)(self->private_impl.f_components_h[2u])));
|
||||
v_height2 = (8u * ((uint32_t)(self->private_impl.f_components_v[2u])));
|
||||
}
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[3u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[4u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src3 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width3 = (8u * ((uint32_t)(self->private_impl.f_components_h[3u])));
|
||||
v_height3 = (8u * ((uint32_t)(self->private_impl.f_components_v[3u])));
|
||||
}
|
||||
} else {
|
||||
if ((self->private_impl.f_components_workbuf_offsets[0u] <= self->private_impl.f_components_workbuf_offsets[1u]) && (self->private_impl.f_components_workbuf_offsets[1u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src0 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[0u],
|
||||
self->private_impl.f_components_workbuf_offsets[1u]);
|
||||
v_width0 = self->private_impl.f_components_workbuf_widths[0u];
|
||||
v_height0 = self->private_impl.f_components_workbuf_heights[0u];
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[1u] <= self->private_impl.f_components_workbuf_offsets[2u]) && (self->private_impl.f_components_workbuf_offsets[2u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src1 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[1u],
|
||||
self->private_impl.f_components_workbuf_offsets[2u]);
|
||||
v_width1 = self->private_impl.f_components_workbuf_widths[1u];
|
||||
v_height1 = self->private_impl.f_components_workbuf_heights[1u];
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[2u] <= self->private_impl.f_components_workbuf_offsets[3u]) && (self->private_impl.f_components_workbuf_offsets[3u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src2 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[2u],
|
||||
self->private_impl.f_components_workbuf_offsets[3u]);
|
||||
v_width2 = self->private_impl.f_components_workbuf_widths[2u];
|
||||
v_height2 = self->private_impl.f_components_workbuf_heights[2u];
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[3u] <= self->private_impl.f_components_workbuf_offsets[4u]) && (self->private_impl.f_components_workbuf_offsets[4u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src3 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[3u],
|
||||
self->private_impl.f_components_workbuf_offsets[4u]);
|
||||
v_width3 = self->private_impl.f_components_workbuf_widths[3u];
|
||||
v_height3 = self->private_impl.f_components_workbuf_heights[3u];
|
||||
}
|
||||
}
|
||||
v_status = wuffs_base__pixel_swizzler__swizzle_ycck(&self->private_impl.f_swizzler,
|
||||
a_dst,
|
||||
wuffs_base__pixel_buffer__palette_or_else(a_dst, wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024)),
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height,
|
||||
(a_x0 & 65535u),
|
||||
wuffs_base__u32__min(a_x1, self->private_impl.f_width),
|
||||
(a_y0 & 65535u),
|
||||
wuffs_base__u32__min(a_y1, self->private_impl.f_height),
|
||||
v_src0,
|
||||
v_src1,
|
||||
v_src2,
|
||||
v_src3,
|
||||
self->private_impl.f_components_workbuf_widths[0u],
|
||||
self->private_impl.f_components_workbuf_widths[1u],
|
||||
self->private_impl.f_components_workbuf_widths[2u],
|
||||
self->private_impl.f_components_workbuf_widths[3u],
|
||||
self->private_impl.f_components_workbuf_heights[0u],
|
||||
self->private_impl.f_components_workbuf_heights[1u],
|
||||
self->private_impl.f_components_workbuf_heights[2u],
|
||||
self->private_impl.f_components_workbuf_heights[3u],
|
||||
self->private_impl.f_components_workbuf_widths[0u],
|
||||
self->private_impl.f_components_workbuf_widths[1u],
|
||||
self->private_impl.f_components_workbuf_widths[2u],
|
||||
self->private_impl.f_components_workbuf_widths[3u],
|
||||
v_width0,
|
||||
v_width1,
|
||||
v_width2,
|
||||
v_width3,
|
||||
v_height0,
|
||||
v_height1,
|
||||
v_height2,
|
||||
v_height3,
|
||||
v_width0,
|
||||
v_width1,
|
||||
v_width2,
|
||||
v_width3,
|
||||
self->private_impl.f_components_h[0u],
|
||||
self->private_impl.f_components_h[1u],
|
||||
self->private_impl.f_components_h[2u],
|
||||
@@ -48666,7 +49455,7 @@ wuffs_jpeg__decoder__swizzle_colorful(
|
||||
self->private_impl.f_components_v[2u],
|
||||
self->private_impl.f_components_v[3u],
|
||||
self->private_impl.f_is_rgb_or_cmyk,
|
||||
true,
|
||||
! self->private_impl.f_use_lower_quality,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_swizzle_ycck_scratch_buffer_2k, 2048));
|
||||
return wuffs_private_impl__status__ensure_not_a_suspension(v_status);
|
||||
}
|
||||
@@ -48778,6 +49567,7 @@ wuffs_jpeg__decoder__restart_frame(
|
||||
}
|
||||
self->private_impl.f_call_sequence = 40u;
|
||||
self->private_impl.f_bitstream_is_closed = false;
|
||||
self->private_impl.f_expect_multiple_scans = false;
|
||||
self->private_impl.f_frame_config_io_position = a_io_position;
|
||||
self->private_impl.f_scan_count = 0u;
|
||||
self->private_impl.f_restart_interval = self->private_impl.f_saved_restart_interval;
|
||||
@@ -48876,6 +49666,9 @@ wuffs_jpeg__decoder__workbuf_len(
|
||||
return wuffs_base__utility__empty_range_ii_u64();
|
||||
}
|
||||
|
||||
if (self->private_impl.f_use_lower_quality && (self->private_impl.f_sof_marker < 194u)) {
|
||||
return wuffs_base__utility__make_range_ii_u64(0u, self->private_impl.f_components_workbuf_offsets[8u]);
|
||||
}
|
||||
return wuffs_base__utility__make_range_ii_u64(self->private_impl.f_components_workbuf_offsets[8u], self->private_impl.f_components_workbuf_offsets[8u]);
|
||||
}
|
||||
|
||||
@@ -49512,16 +50305,18 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
return (*self->private_impl.choosy_decode_mcu)(self, a_workbuf, a_mx, a_my);
|
||||
return (*self->private_impl.choosy_decode_mcu)(self, a_dst, a_workbuf, a_mx, a_my);
|
||||
}
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu__choosy_default(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -49721,11 +50516,47 @@ wuffs_jpeg__decoder__decode_mcu__choosy_default(
|
||||
if (self->private_impl.f_test_only_interrupt_decode_mcu) {
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
v_csel = self->private_impl.f_scan_comps_cselector[self->private_impl.f_mcu_blocks_sselector[v_mcb]];
|
||||
v_stride = ((uint64_t)(self->private_impl.f_components_workbuf_widths[v_csel]));
|
||||
v_offset = (self->private_impl.f_mcu_blocks_offset[v_mcb] + (((uint64_t)(self->private_impl.f_mcu_blocks_mx_mul[v_mcb])) * ((uint64_t)(a_mx))) + (((uint64_t)(self->private_impl.f_mcu_blocks_my_mul[v_mcb])) * ((uint64_t)(a_my))));
|
||||
if (v_offset <= ((uint64_t)(a_workbuf.len))) {
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__slice_u8__subslice_i(a_workbuf, v_offset), v_stride, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
if ( ! self->private_impl.f_swizzle_immediately) {
|
||||
v_csel = self->private_impl.f_scan_comps_cselector[self->private_impl.f_mcu_blocks_sselector[v_mcb]];
|
||||
v_stride = ((uint64_t)(self->private_impl.f_components_workbuf_widths[v_csel]));
|
||||
v_offset = (self->private_impl.f_mcu_blocks_offset[v_mcb] + (((uint64_t)(self->private_impl.f_mcu_blocks_mx_mul[v_mcb])) * ((uint64_t)(a_mx))) + (((uint64_t)(self->private_impl.f_mcu_blocks_my_mul[v_mcb])) * ((uint64_t)(a_my))));
|
||||
if (v_offset <= ((uint64_t)(a_workbuf.len))) {
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__slice_u8__subslice_i(a_workbuf, v_offset), v_stride, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
}
|
||||
} else if (self->private_impl.f_num_components == 1u) {
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__make_slice_u8(self->private_data.f_swizzle_immediately_buffer, 64), 8u, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
self->private_impl.f_swizzle_immediately_status = wuffs_jpeg__decoder__swizzle_gray(self,
|
||||
a_dst,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_swizzle_immediately_buffer, 64),
|
||||
((a_mx + 0u) * 8u),
|
||||
((a_mx + 1u) * 8u),
|
||||
((a_my + 0u) * 8u),
|
||||
((a_my + 1u) * 8u),
|
||||
8u);
|
||||
if ( ! wuffs_base__status__is_ok(&self->private_impl.f_swizzle_immediately_status)) {
|
||||
v_ret = 3u;
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
v_csel = self->private_impl.f_scan_comps_cselector[self->private_impl.f_mcu_blocks_sselector[v_mcb]];
|
||||
v_stride = (8u * ((uint64_t)(self->private_impl.f_components_h[v_csel])));
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, self->private_impl.f_swizzle_immediately_b_offsets[v_mcb], 640), v_stride, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
if (self->private_impl.f_mcu_current_block < self->private_impl.f_mcu_num_blocks) {
|
||||
continue;
|
||||
}
|
||||
self->private_impl.f_swizzle_immediately_status = wuffs_jpeg__decoder__swizzle_colorful(self,
|
||||
a_dst,
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
((a_mx + 0u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_h))),
|
||||
((a_mx + 1u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_h))),
|
||||
((a_my + 0u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_v))),
|
||||
((a_my + 1u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_v))));
|
||||
if ( ! wuffs_base__status__is_ok(&self->private_impl.f_swizzle_immediately_status)) {
|
||||
v_ret = 3u;
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_mcu_current_block = 0u;
|
||||
@@ -49754,6 +50585,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -49921,6 +50753,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -50182,6 +51015,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -50322,6 +51156,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -50770,7 +51605,7 @@ wuffs_json__decoder__initialize(
|
||||
wuffs_json__decoder*
|
||||
wuffs_json__decoder__alloc(void) {
|
||||
wuffs_json__decoder* x =
|
||||
(wuffs_json__decoder*)(calloc(sizeof(wuffs_json__decoder), 1));
|
||||
(wuffs_json__decoder*)(calloc(1, sizeof(wuffs_json__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -52828,7 +53663,7 @@ wuffs_lzma__decoder__initialize(
|
||||
wuffs_lzma__decoder*
|
||||
wuffs_lzma__decoder__alloc(void) {
|
||||
wuffs_lzma__decoder* x =
|
||||
(wuffs_lzma__decoder*)(calloc(sizeof(wuffs_lzma__decoder), 1));
|
||||
(wuffs_lzma__decoder*)(calloc(1, sizeof(wuffs_lzma__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -56019,7 +56854,7 @@ wuffs_lzip__decoder__initialize(
|
||||
wuffs_lzip__decoder*
|
||||
wuffs_lzip__decoder__alloc(void) {
|
||||
wuffs_lzip__decoder* x =
|
||||
(wuffs_lzip__decoder*)(calloc(sizeof(wuffs_lzip__decoder), 1));
|
||||
(wuffs_lzip__decoder*)(calloc(1, sizeof(wuffs_lzip__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -56568,7 +57403,7 @@ wuffs_lzw__decoder__initialize(
|
||||
wuffs_lzw__decoder*
|
||||
wuffs_lzw__decoder__alloc(void) {
|
||||
wuffs_lzw__decoder* x =
|
||||
(wuffs_lzw__decoder*)(calloc(sizeof(wuffs_lzw__decoder), 1));
|
||||
(wuffs_lzw__decoder*)(calloc(1, sizeof(wuffs_lzw__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -57184,7 +58019,7 @@ wuffs_netpbm__decoder__initialize(
|
||||
wuffs_netpbm__decoder*
|
||||
wuffs_netpbm__decoder__alloc(void) {
|
||||
wuffs_netpbm__decoder* x =
|
||||
(wuffs_netpbm__decoder*)(calloc(sizeof(wuffs_netpbm__decoder), 1));
|
||||
(wuffs_netpbm__decoder*)(calloc(1, sizeof(wuffs_netpbm__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -58324,7 +59159,7 @@ wuffs_nie__decoder__initialize(
|
||||
wuffs_nie__decoder*
|
||||
wuffs_nie__decoder__alloc(void) {
|
||||
wuffs_nie__decoder* x =
|
||||
(wuffs_nie__decoder*)(calloc(sizeof(wuffs_nie__decoder), 1));
|
||||
(wuffs_nie__decoder*)(calloc(1, sizeof(wuffs_nie__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -59368,7 +60203,7 @@ wuffs_zlib__decoder__initialize(
|
||||
wuffs_zlib__decoder*
|
||||
wuffs_zlib__decoder__alloc(void) {
|
||||
wuffs_zlib__decoder* x =
|
||||
(wuffs_zlib__decoder*)(calloc(sizeof(wuffs_zlib__decoder), 1));
|
||||
(wuffs_zlib__decoder*)(calloc(1, sizeof(wuffs_zlib__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -60336,7 +61171,7 @@ wuffs_png__decoder__initialize(
|
||||
wuffs_png__decoder*
|
||||
wuffs_png__decoder__alloc(void) {
|
||||
wuffs_png__decoder* x =
|
||||
(wuffs_png__decoder*)(calloc(sizeof(wuffs_png__decoder), 1));
|
||||
(wuffs_png__decoder*)(calloc(1, sizeof(wuffs_png__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -66346,6 +67181,1282 @@ wuffs_png__decoder__filter_and_swizzle_tricky(
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI)
|
||||
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_qoi__error__bad_footer[] = "#qoi: bad footer";
|
||||
const char wuffs_qoi__error__bad_header[] = "#qoi: bad header";
|
||||
const char wuffs_qoi__error__truncated_input[] = "#qoi: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
// ---------------- Private Initializer Prototypes
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_src_to_buffer(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_buffer_to_dst(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__image_decoder__func_ptrs
|
||||
wuffs_qoi__decoder__func_ptrs_for__wuffs_base__image_decoder = {
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__pixel_buffer*,
|
||||
wuffs_base__io_buffer*,
|
||||
wuffs_base__pixel_blend,
|
||||
wuffs_base__slice_u8,
|
||||
wuffs_base__decode_frame_options*))(&wuffs_qoi__decoder__decode_frame),
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__frame_config*,
|
||||
wuffs_base__io_buffer*))(&wuffs_qoi__decoder__decode_frame_config),
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__image_config*,
|
||||
wuffs_base__io_buffer*))(&wuffs_qoi__decoder__decode_image_config),
|
||||
(wuffs_base__rect_ie_u32(*)(const void*))(&wuffs_qoi__decoder__frame_dirty_rect),
|
||||
(uint64_t(*)(const void*,
|
||||
uint32_t))(&wuffs_qoi__decoder__get_quirk),
|
||||
(uint32_t(*)(const void*))(&wuffs_qoi__decoder__num_animation_loops),
|
||||
(uint64_t(*)(const void*))(&wuffs_qoi__decoder__num_decoded_frame_configs),
|
||||
(uint64_t(*)(const void*))(&wuffs_qoi__decoder__num_decoded_frames),
|
||||
(wuffs_base__status(*)(void*,
|
||||
uint64_t,
|
||||
uint64_t))(&wuffs_qoi__decoder__restart_frame),
|
||||
(wuffs_base__status(*)(void*,
|
||||
uint32_t,
|
||||
uint64_t))(&wuffs_qoi__decoder__set_quirk),
|
||||
(wuffs_base__empty_struct(*)(void*,
|
||||
uint32_t,
|
||||
bool))(&wuffs_qoi__decoder__set_report_metadata),
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__io_buffer*,
|
||||
wuffs_base__more_information*,
|
||||
wuffs_base__io_buffer*))(&wuffs_qoi__decoder__tell_me_more),
|
||||
(wuffs_base__range_ii_u64(*)(const void*))(&wuffs_qoi__decoder__workbuf_len),
|
||||
};
|
||||
|
||||
// ---------------- Initializer Implementations
|
||||
|
||||
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
|
||||
wuffs_qoi__decoder__initialize(
|
||||
wuffs_qoi__decoder* self,
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version,
|
||||
uint32_t options){
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (sizeof(*self) != sizeof_star_self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_sizeof_receiver);
|
||||
}
|
||||
if (((wuffs_version >> 32) != WUFFS_VERSION_MAJOR) ||
|
||||
(((wuffs_version >> 16) & 0xFFFF) > WUFFS_VERSION_MINOR)) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
|
||||
}
|
||||
|
||||
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
|
||||
// The whole point of this if-check is to detect an uninitialized *self.
|
||||
// We disable the warning on GCC. Clang-5.0 does not have this warning.
|
||||
#if !defined(__clang__) && defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
if (self->private_impl.magic != 0) {
|
||||
return wuffs_base__make_status(wuffs_base__error__initialize_falsely_claimed_already_zeroed);
|
||||
}
|
||||
#if !defined(__clang__) && defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} else {
|
||||
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
|
||||
memset(self, 0, sizeof(*self));
|
||||
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
|
||||
} else {
|
||||
memset(&(self->private_impl), 0, sizeof(self->private_impl));
|
||||
}
|
||||
}
|
||||
|
||||
self->private_impl.magic = WUFFS_BASE__MAGIC;
|
||||
self->private_impl.vtable_for__wuffs_base__image_decoder.vtable_name =
|
||||
wuffs_base__image_decoder__vtable_name;
|
||||
self->private_impl.vtable_for__wuffs_base__image_decoder.function_pointers =
|
||||
(const void*)(&wuffs_qoi__decoder__func_ptrs_for__wuffs_base__image_decoder);
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
wuffs_qoi__decoder*
|
||||
wuffs_qoi__decoder__alloc(void) {
|
||||
wuffs_qoi__decoder* x =
|
||||
(wuffs_qoi__decoder*)(calloc(1, sizeof(wuffs_qoi__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
if (wuffs_qoi__decoder__initialize(
|
||||
x, sizeof(wuffs_qoi__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__ALREADY_ZEROED).repr) {
|
||||
free(x);
|
||||
return NULL;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
size_t
|
||||
sizeof__wuffs_qoi__decoder(void) {
|
||||
return sizeof(wuffs_qoi__decoder);
|
||||
}
|
||||
|
||||
// ---------------- Function Implementations
|
||||
|
||||
// -------- func qoi.decoder.get_quirk
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__get_quirk(
|
||||
const wuffs_qoi__decoder* self,
|
||||
uint32_t a_key) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.set_quirk
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__set_quirk(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_key,
|
||||
uint64_t a_value) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.decode_image_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 1)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_qoi__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.do_decode_image_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_a = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence != 0u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
uint32_t t_0;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_do_decode_image_config.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config.scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_0;
|
||||
if (num_bits_0 == 24) {
|
||||
t_0 = ((uint32_t)(*scratch));
|
||||
break;
|
||||
}
|
||||
num_bits_0 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_0)) << 56;
|
||||
}
|
||||
}
|
||||
v_a = t_0;
|
||||
}
|
||||
if (v_a != 1718185841u) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__bad_header);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
uint32_t t_1;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_do_decode_image_config.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config.scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFFu));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_1);
|
||||
if (num_bits_1 == 24) {
|
||||
t_1 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_1 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_1));
|
||||
}
|
||||
}
|
||||
v_a = t_1;
|
||||
}
|
||||
if (v_a > 16777215u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__unsupported_image_dimension);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_width = v_a;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
uint32_t t_2;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_2 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_do_decode_image_config.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config.scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch & 0xFFu));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_2);
|
||||
if (num_bits_2 == 24) {
|
||||
t_2 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_2 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_2));
|
||||
}
|
||||
}
|
||||
v_a = t_2;
|
||||
}
|
||||
if (v_a > 16777215u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__unsupported_image_dimension);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_height = v_a;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint32_t t_3 = *iop_a_src++;
|
||||
v_a = t_3;
|
||||
}
|
||||
if (v_a == 3u) {
|
||||
self->private_impl.f_pixfmt = 2415954056u;
|
||||
} else if (v_a == 4u) {
|
||||
self->private_impl.f_pixfmt = 2164295816u;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__bad_header);
|
||||
goto exit;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
iop_a_src++;
|
||||
if (a_dst != NULL) {
|
||||
wuffs_base__image_config__set(
|
||||
a_dst,
|
||||
self->private_impl.f_pixfmt,
|
||||
0u,
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height,
|
||||
14u,
|
||||
(self->private_impl.f_pixfmt == 2415954056u));
|
||||
}
|
||||
self->private_impl.f_call_sequence = 32u;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_do_decode_image_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_do_decode_image_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.decode_frame_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 2)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_qoi__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.do_decode_frame_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 32u) {
|
||||
} else if (self->private_impl.f_call_sequence < 32u) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_qoi__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
} else if (self->private_impl.f_call_sequence == 40u) {
|
||||
if (16u != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_restart);
|
||||
goto exit;
|
||||
}
|
||||
} else if (self->private_impl.f_call_sequence == 64u) {
|
||||
self->private_impl.f_call_sequence = 96u;
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
}
|
||||
if (a_dst != NULL) {
|
||||
wuffs_base__frame_config__set(
|
||||
a_dst,
|
||||
wuffs_base__utility__make_rect_ie_u32(
|
||||
0u,
|
||||
0u,
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height),
|
||||
((wuffs_base__flicks)(0u)),
|
||||
0u,
|
||||
14u,
|
||||
0u,
|
||||
(self->private_impl.f_pixfmt == 2415954056u),
|
||||
false,
|
||||
0u);
|
||||
}
|
||||
self->private_impl.f_call_sequence = 64u;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_do_decode_frame_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_do_decode_frame_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.decode_frame
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_dst || !a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 3)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_qoi__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.do_decode_frame
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint64_t v_c64 = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 64u) {
|
||||
} else if (self->private_impl.f_call_sequence < 64u) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_qoi__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
}
|
||||
v_status = wuffs_base__pixel_swizzler__prepare(&self->private_impl.f_swizzler,
|
||||
wuffs_base__pixel_buffer__pixel_format(a_dst),
|
||||
wuffs_base__pixel_buffer__palette(a_dst),
|
||||
wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
a_blend);
|
||||
if ( ! wuffs_base__status__is_ok(&v_status)) {
|
||||
status = v_status;
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
goto exit;
|
||||
} else if (wuffs_base__status__is_suspension(&status)) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension);
|
||||
goto exit;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
self->private_impl.f_dst_x = 0u;
|
||||
self->private_impl.f_dst_y = 0u;
|
||||
self->private_data.f_pixel[0u] = 0u;
|
||||
self->private_data.f_pixel[1u] = 0u;
|
||||
self->private_data.f_pixel[2u] = 0u;
|
||||
self->private_data.f_pixel[3u] = 255u;
|
||||
wuffs_private_impl__bulk_memset(&self->private_data.f_cache[0], 256u, 0u);
|
||||
self->private_impl.f_remaining_pixels_times_4 = (((uint64_t)(self->private_impl.f_width)) * ((uint64_t)(self->private_impl.f_height)) * 4u);
|
||||
while (self->private_impl.f_remaining_pixels_times_4 > 0u) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
status = wuffs_qoi__decoder__from_src_to_buffer(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
if (self->private_impl.f_remaining_pixels_times_4 < ((uint64_t)(self->private_impl.f_buffer_index))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__too_much_data);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_remaining_pixels_times_4 -= ((uint64_t)(self->private_impl.f_buffer_index));
|
||||
v_status = wuffs_qoi__decoder__from_buffer_to_dst(self, a_dst);
|
||||
if ( ! wuffs_base__status__is_ok(&v_status)) {
|
||||
status = v_status;
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
goto exit;
|
||||
} else if (wuffs_base__status__is_suspension(&status)) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension);
|
||||
goto exit;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
uint64_t t_0;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 8)) {
|
||||
t_0 = wuffs_base__peek_u64be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 8;
|
||||
} else {
|
||||
self->private_data.s_do_decode_frame.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame.scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFFu));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_0);
|
||||
if (num_bits_0 == 56) {
|
||||
t_0 = ((uint64_t)(*scratch >> 0));
|
||||
break;
|
||||
}
|
||||
num_bits_0 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_0));
|
||||
}
|
||||
}
|
||||
v_c64 = t_0;
|
||||
}
|
||||
if (v_c64 != 1u) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__bad_footer);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_call_sequence = 96u;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_do_decode_frame = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_do_decode_frame = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.from_src_to_buffer
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_src_to_buffer(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c8 = 0;
|
||||
uint8_t v_dg = 0;
|
||||
uint32_t v_bi = 0;
|
||||
uint32_t v_bj = 0;
|
||||
uint32_t v_bk = 0;
|
||||
uint32_t v_ci = 0;
|
||||
uint32_t v_hash4 = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_from_src_to_buffer;
|
||||
if (coro_susp_point) {
|
||||
v_dg = self->private_data.s_from_src_to_buffer.v_dg;
|
||||
v_bi = self->private_data.s_from_src_to_buffer.v_bi;
|
||||
v_bk = self->private_data.s_from_src_to_buffer.v_bk;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
v_bk = 7936u;
|
||||
if (self->private_impl.f_remaining_pixels_times_4 < 7936u) {
|
||||
v_bk = ((uint32_t)(self->private_impl.f_remaining_pixels_times_4));
|
||||
}
|
||||
while (v_bi < v_bk) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_0 = *iop_a_src++;
|
||||
v_c8 = t_0;
|
||||
}
|
||||
if (v_c8 == 254u) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_1 = *iop_a_src++;
|
||||
self->private_data.f_pixel[2u] = t_1;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_2 = *iop_a_src++;
|
||||
self->private_data.f_pixel[1u] = t_2;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_3 = *iop_a_src++;
|
||||
self->private_data.f_pixel[0u] = t_3;
|
||||
}
|
||||
} else if (v_c8 == 255u) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_4 = *iop_a_src++;
|
||||
self->private_data.f_pixel[2u] = t_4;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_5 = *iop_a_src++;
|
||||
self->private_data.f_pixel[1u] = t_5;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_6 = *iop_a_src++;
|
||||
self->private_data.f_pixel[0u] = t_6;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_7 = *iop_a_src++;
|
||||
self->private_data.f_pixel[3u] = t_7;
|
||||
}
|
||||
} else if (((uint8_t)(v_c8 >> 6u)) == 0u) {
|
||||
v_ci = (4u * ((uint32_t)(((uint8_t)(v_c8 & 63u)))));
|
||||
self->private_data.f_pixel[0u] = self->private_data.f_cache[(v_ci + 0u)];
|
||||
self->private_data.f_pixel[1u] = self->private_data.f_cache[(v_ci + 1u)];
|
||||
self->private_data.f_pixel[2u] = self->private_data.f_cache[(v_ci + 2u)];
|
||||
self->private_data.f_pixel[3u] = self->private_data.f_cache[(v_ci + 3u)];
|
||||
self->private_data.f_buffer[(v_bi + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_buffer[(v_bi + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_buffer[(v_bi + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_buffer[(v_bi + 3u)] = self->private_data.f_pixel[3u];
|
||||
v_bi += 4u;
|
||||
continue;
|
||||
} else if (((uint8_t)(v_c8 >> 6u)) == 1u) {
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
self->private_data.f_pixel[2u] += ((uint8_t)(((uint8_t)(((uint8_t)(v_c8 >> 4u)) & 3u)) + 254u));
|
||||
self->private_data.f_pixel[1u] += ((uint8_t)(((uint8_t)(((uint8_t)(v_c8 >> 2u)) & 3u)) + 254u));
|
||||
self->private_data.f_pixel[0u] += ((uint8_t)(((uint8_t)(((uint8_t)(v_c8 >> 0u)) & 3u)) + 254u));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} else if (((uint8_t)(v_c8 >> 6u)) == 2u) {
|
||||
v_dg = ((uint8_t)(((uint8_t)(v_c8 & 63u)) + 224u));
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_8 = *iop_a_src++;
|
||||
v_c8 = t_8;
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
self->private_data.f_pixel[2u] += ((uint8_t)(((uint8_t)(v_dg + 248u)) + ((uint8_t)(15u & ((uint8_t)(v_c8 >> 4u))))));
|
||||
self->private_data.f_pixel[1u] += v_dg;
|
||||
self->private_data.f_pixel[0u] += ((uint8_t)(((uint8_t)(v_dg + 248u)) + ((uint8_t)(15u & ((uint8_t)(v_c8 >> 0u))))));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} else {
|
||||
v_bj = (v_bi + (4u * (63u & (1u + ((uint32_t)(v_c8))))));
|
||||
while (v_bi < v_bj) {
|
||||
self->private_data.f_buffer[(v_bi + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_buffer[(v_bi + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_buffer[(v_bi + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_buffer[(v_bi + 3u)] = self->private_data.f_pixel[3u];
|
||||
v_bi += 4u;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
v_hash4 = (4u * (63u & ((((uint32_t)(self->private_data.f_pixel[2u])) * 3u) +
|
||||
(((uint32_t)(self->private_data.f_pixel[1u])) * 5u) +
|
||||
(((uint32_t)(self->private_data.f_pixel[0u])) * 7u) +
|
||||
(((uint32_t)(self->private_data.f_pixel[3u])) * 11u))));
|
||||
self->private_data.f_cache[(v_hash4 + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_cache[(v_hash4 + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_cache[(v_hash4 + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_cache[(v_hash4 + 3u)] = self->private_data.f_pixel[3u];
|
||||
self->private_data.f_buffer[(v_bi + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_buffer[(v_bi + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_buffer[(v_bi + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_buffer[(v_bi + 3u)] = self->private_data.f_pixel[3u];
|
||||
v_bi += 4u;
|
||||
}
|
||||
self->private_impl.f_buffer_index = v_bi;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_from_src_to_buffer = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_from_src_to_buffer = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_from_src_to_buffer.v_dg = v_dg;
|
||||
self->private_data.s_from_src_to_buffer.v_bi = v_bi;
|
||||
self->private_data.s_from_src_to_buffer.v_bk = v_bk;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.from_buffer_to_dst
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_buffer_to_dst(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst) {
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint32_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_row = 0;
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
uint32_t v_bi = 0;
|
||||
uint32_t v_rem_x = 0;
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
wuffs_base__slice_u8 v_src = {0};
|
||||
uint32_t v_src_length = 0;
|
||||
uint64_t v_i = 0;
|
||||
|
||||
v_dst_pixfmt = wuffs_base__pixel_buffer__pixel_format(a_dst);
|
||||
v_dst_bits_per_pixel = wuffs_base__pixel_format__bits_per_pixel(&v_dst_pixfmt);
|
||||
if ((v_dst_bits_per_pixel & 7u) != 0u) {
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
v_dst_bytes_per_pixel = (v_dst_bits_per_pixel / 8u);
|
||||
v_dst_bytes_per_row = ((uint64_t)((self->private_impl.f_width * v_dst_bytes_per_pixel)));
|
||||
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0u);
|
||||
while (v_bi < self->private_impl.f_buffer_index) {
|
||||
if (self->private_impl.f_width <= self->private_impl.f_dst_x) {
|
||||
self->private_impl.f_dst_x = 0u;
|
||||
self->private_impl.f_dst_y += 1u;
|
||||
if (self->private_impl.f_dst_y >= self->private_impl.f_height) {
|
||||
break;
|
||||
}
|
||||
v_rem_x = self->private_impl.f_width;
|
||||
} else {
|
||||
v_rem_x = (self->private_impl.f_width - self->private_impl.f_dst_x);
|
||||
}
|
||||
v_src = wuffs_base__make_slice_u8_ij(self->private_data.f_buffer, v_bi, self->private_impl.f_buffer_index);
|
||||
if (((uint64_t)((4u * v_rem_x))) < ((uint64_t)(v_src.len))) {
|
||||
v_src = wuffs_base__slice_u8__subslice_j(v_src, ((uint64_t)((4u * v_rem_x))));
|
||||
}
|
||||
v_src_length = ((uint32_t)(((uint64_t)(v_src.len))));
|
||||
v_bi += v_src_length;
|
||||
v_dst = wuffs_private_impl__table_u8__row_u32(v_tab, self->private_impl.f_dst_y);
|
||||
if (v_dst_bytes_per_row < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_j(v_dst, v_dst_bytes_per_row);
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * ((uint64_t)(v_dst_bytes_per_pixel)));
|
||||
self->private_impl.f_dst_x += (v_src_length / 4u);
|
||||
if (v_i < ((uint64_t)(v_dst.len))) {
|
||||
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), wuffs_base__pixel_buffer__palette(a_dst), v_src);
|
||||
}
|
||||
}
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.frame_dirty_rect
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
|
||||
wuffs_qoi__decoder__frame_dirty_rect(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return wuffs_base__utility__empty_rect_ie_u32();
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return wuffs_base__utility__empty_rect_ie_u32();
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_rect_ie_u32(
|
||||
0u,
|
||||
0u,
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.num_animation_loops
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint32_t
|
||||
wuffs_qoi__decoder__num_animation_loops(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.num_decoded_frame_configs
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frame_configs(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self->private_impl.f_call_sequence > 32u) {
|
||||
return 1u;
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.num_decoded_frames
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frames(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self->private_impl.f_call_sequence > 64u) {
|
||||
return 1u;
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.restart_frame
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__restart_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint64_t a_index,
|
||||
uint64_t a_io_position) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
|
||||
if (self->private_impl.f_call_sequence < 32u) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
}
|
||||
if ((a_index != 0u) || (a_io_position != 14u)) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
self->private_impl.f_call_sequence = 40u;
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.set_report_metadata
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
|
||||
wuffs_qoi__decoder__set_report_metadata(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_fourcc,
|
||||
bool a_report) {
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.tell_me_more
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__tell_me_more(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_dst || !a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 4)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
status = wuffs_base__make_status(wuffs_base__error__no_more_information);
|
||||
goto exit;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.workbuf_len
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
|
||||
wuffs_qoi__decoder__workbuf_len(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return wuffs_base__utility__empty_range_ii_u64();
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return wuffs_base__utility__empty_range_ii_u64();
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_range_ii_u64(0u, 0u);
|
||||
}
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__SHA256)
|
||||
|
||||
// ---------------- Status Codes Implementations
|
||||
@@ -66447,7 +68558,7 @@ wuffs_sha256__hasher__initialize(
|
||||
wuffs_sha256__hasher*
|
||||
wuffs_sha256__hasher__alloc(void) {
|
||||
wuffs_sha256__hasher* x =
|
||||
(wuffs_sha256__hasher*)(calloc(sizeof(wuffs_sha256__hasher), 1));
|
||||
(wuffs_sha256__hasher*)(calloc(1, sizeof(wuffs_sha256__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -67080,7 +69191,7 @@ wuffs_tga__decoder__initialize(
|
||||
wuffs_tga__decoder*
|
||||
wuffs_tga__decoder__alloc(void) {
|
||||
wuffs_tga__decoder* x =
|
||||
(wuffs_tga__decoder*)(calloc(sizeof(wuffs_tga__decoder), 1));
|
||||
(wuffs_tga__decoder*)(calloc(1, sizeof(wuffs_tga__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -68449,7 +70560,7 @@ wuffs_vp8__placeholder__initialize(
|
||||
wuffs_vp8__placeholder*
|
||||
wuffs_vp8__placeholder__alloc(void) {
|
||||
wuffs_vp8__placeholder* x =
|
||||
(wuffs_vp8__placeholder*)(calloc(sizeof(wuffs_vp8__placeholder), 1));
|
||||
(wuffs_vp8__placeholder*)(calloc(1, sizeof(wuffs_vp8__placeholder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -68597,7 +70708,7 @@ wuffs_wbmp__decoder__initialize(
|
||||
wuffs_wbmp__decoder*
|
||||
wuffs_wbmp__decoder__alloc(void) {
|
||||
wuffs_wbmp__decoder* x =
|
||||
(wuffs_wbmp__decoder*)(calloc(sizeof(wuffs_wbmp__decoder), 1));
|
||||
(wuffs_wbmp__decoder*)(calloc(1, sizeof(wuffs_wbmp__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -69436,42 +71547,6 @@ WUFFS_WEBP__HUFFMAN_TABLE_BASE_OFFSETS[5] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
1612u, 0u, 511u, 1022u, 1533u,
|
||||
};
|
||||
|
||||
static const uint32_t
|
||||
WUFFS_WEBP__SIGN_EXTEND_I8_I32[256] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u,
|
||||
8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u,
|
||||
16u, 17u, 18u, 19u, 20u, 21u, 22u, 23u,
|
||||
24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u,
|
||||
32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u,
|
||||
40u, 41u, 42u, 43u, 44u, 45u, 46u, 47u,
|
||||
48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u,
|
||||
56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u,
|
||||
64u, 65u, 66u, 67u, 68u, 69u, 70u, 71u,
|
||||
72u, 73u, 74u, 75u, 76u, 77u, 78u, 79u,
|
||||
80u, 81u, 82u, 83u, 84u, 85u, 86u, 87u,
|
||||
88u, 89u, 90u, 91u, 92u, 93u, 94u, 95u,
|
||||
96u, 97u, 98u, 99u, 100u, 101u, 102u, 103u,
|
||||
104u, 105u, 106u, 107u, 108u, 109u, 110u, 111u,
|
||||
112u, 113u, 114u, 115u, 116u, 117u, 118u, 119u,
|
||||
120u, 121u, 122u, 123u, 124u, 125u, 126u, 127u,
|
||||
4294967168u, 4294967169u, 4294967170u, 4294967171u, 4294967172u, 4294967173u, 4294967174u, 4294967175u,
|
||||
4294967176u, 4294967177u, 4294967178u, 4294967179u, 4294967180u, 4294967181u, 4294967182u, 4294967183u,
|
||||
4294967184u, 4294967185u, 4294967186u, 4294967187u, 4294967188u, 4294967189u, 4294967190u, 4294967191u,
|
||||
4294967192u, 4294967193u, 4294967194u, 4294967195u, 4294967196u, 4294967197u, 4294967198u, 4294967199u,
|
||||
4294967200u, 4294967201u, 4294967202u, 4294967203u, 4294967204u, 4294967205u, 4294967206u, 4294967207u,
|
||||
4294967208u, 4294967209u, 4294967210u, 4294967211u, 4294967212u, 4294967213u, 4294967214u, 4294967215u,
|
||||
4294967216u, 4294967217u, 4294967218u, 4294967219u, 4294967220u, 4294967221u, 4294967222u, 4294967223u,
|
||||
4294967224u, 4294967225u, 4294967226u, 4294967227u, 4294967228u, 4294967229u, 4294967230u, 4294967231u,
|
||||
4294967232u, 4294967233u, 4294967234u, 4294967235u, 4294967236u, 4294967237u, 4294967238u, 4294967239u,
|
||||
4294967240u, 4294967241u, 4294967242u, 4294967243u, 4294967244u, 4294967245u, 4294967246u, 4294967247u,
|
||||
4294967248u, 4294967249u, 4294967250u, 4294967251u, 4294967252u, 4294967253u, 4294967254u, 4294967255u,
|
||||
4294967256u, 4294967257u, 4294967258u, 4294967259u, 4294967260u, 4294967261u, 4294967262u, 4294967263u,
|
||||
4294967264u, 4294967265u, 4294967266u, 4294967267u, 4294967268u, 4294967269u, 4294967270u, 4294967271u,
|
||||
4294967272u, 4294967273u, 4294967274u, 4294967275u, 4294967276u, 4294967277u, 4294967278u, 4294967279u,
|
||||
4294967280u, 4294967281u, 4294967282u, 4294967283u, 4294967284u, 4294967285u, 4294967286u, 4294967287u,
|
||||
4294967288u, 4294967289u, 4294967290u, 4294967291u, 4294967292u, 4294967293u, 4294967294u, 4294967295u,
|
||||
};
|
||||
|
||||
static const uint8_t
|
||||
WUFFS_WEBP__DISTANCE_MAP[120] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
24u, 7u, 23u, 25u, 40u, 6u, 39u, 41u,
|
||||
@@ -69768,7 +71843,7 @@ wuffs_webp__decoder__initialize(
|
||||
wuffs_webp__decoder*
|
||||
wuffs_webp__decoder__alloc(void) {
|
||||
wuffs_webp__decoder* x =
|
||||
(wuffs_webp__decoder*)(calloc(sizeof(wuffs_webp__decoder), 1));
|
||||
(wuffs_webp__decoder*)(calloc(1, sizeof(wuffs_webp__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -71022,29 +73097,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_curr_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_curr_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_curr_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_curr_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71076,29 +73130,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[0u] += v_prev_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[1u] += v_prev_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[2u] += v_prev_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[3u] += v_prev_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71128,29 +73161,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_curr_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_curr_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_curr_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_curr_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71161,29 +73173,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_prev_row.ptr[4u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_prev_row.ptr[5u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_prev_row.ptr[6u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_prev_row.ptr[7u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71194,29 +73185,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_prev_row.ptr[8u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_prev_row.ptr[9u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_prev_row.ptr[10u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_prev_row.ptr[11u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71227,29 +73197,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_prev_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_prev_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_prev_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_prev_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71264,29 +73213,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((v_l0 + ((uint32_t)(v_prev_row.ptr[4u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((v_l1 + ((uint32_t)(v_prev_row.ptr[5u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((v_l2 + ((uint32_t)(v_prev_row.ptr[6u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((v_l3 + ((uint32_t)(v_prev_row.ptr[7u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71297,29 +73225,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[0u])) + ((uint32_t)(v_prev_row.ptr[0u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[1u])) + ((uint32_t)(v_prev_row.ptr[1u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[2u])) + ((uint32_t)(v_prev_row.ptr[2u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[3u])) + ((uint32_t)(v_prev_row.ptr[3u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71330,29 +73237,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[0u])) + ((uint32_t)(v_prev_row.ptr[4u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[1u])) + ((uint32_t)(v_prev_row.ptr[5u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[2u])) + ((uint32_t)(v_prev_row.ptr[6u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[3u])) + ((uint32_t)(v_prev_row.ptr[7u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71363,29 +73249,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[0u])) + ((uint32_t)(v_prev_row.ptr[4u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[1u])) + ((uint32_t)(v_prev_row.ptr[5u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[2u])) + ((uint32_t)(v_prev_row.ptr[6u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[3u])) + ((uint32_t)(v_prev_row.ptr[7u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71396,29 +73261,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[4u])) + ((uint32_t)(v_prev_row.ptr[8u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[5u])) + ((uint32_t)(v_prev_row.ptr[9u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[6u])) + ((uint32_t)(v_prev_row.ptr[10u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[7u])) + ((uint32_t)(v_prev_row.ptr[11u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71437,29 +73281,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((v_l0 + v_t0) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((v_l1 + v_t1) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((v_l2 + v_t2) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((v_l3 + v_t3) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71491,29 +73314,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(v_l0));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(v_l1));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(v_l2));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(v_l3));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71524,29 +73326,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(v_t0));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(v_t1));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(v_t2));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(v_t3));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71558,29 +73339,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[0u], v_prev_row.ptr[4u], v_prev_row.ptr[0u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[1u], v_prev_row.ptr[5u], v_prev_row.ptr[1u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[2u], v_prev_row.ptr[6u], v_prev_row.ptr[2u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[3u], v_prev_row.ptr[7u], v_prev_row.ptr[3u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71591,29 +73351,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[0u], v_prev_row.ptr[4u], v_prev_row.ptr[0u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[1u], v_prev_row.ptr[5u], v_prev_row.ptr[1u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[2u], v_prev_row.ptr[6u], v_prev_row.ptr[2u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[3u], v_prev_row.ptr[7u], v_prev_row.ptr[3u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71723,9 +73462,9 @@ wuffs_webp__decoder__apply_transform_cross_color(
|
||||
v_x = 0u;
|
||||
while (v_x < self->private_impl.f_width) {
|
||||
if (((v_x & v_mask) == 0u) && (((uint64_t)(v_tile_data.len)) >= 4u)) {
|
||||
v_g2r = WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_tile_data.ptr[0u]];
|
||||
v_g2b = WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_tile_data.ptr[1u]];
|
||||
v_r2b = WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_tile_data.ptr[2u]];
|
||||
v_g2r = wuffs_base__utility__sign_extend_convert_u8_u32(v_tile_data.ptr[0u]);
|
||||
v_g2b = wuffs_base__utility__sign_extend_convert_u8_u32(v_tile_data.ptr[1u]);
|
||||
v_r2b = wuffs_base__utility__sign_extend_convert_u8_u32(v_tile_data.ptr[2u]);
|
||||
v_tile_data = wuffs_base__slice_u8__subslice_i(v_tile_data, 4u);
|
||||
}
|
||||
if (((uint64_t)(a_pix.len)) >= 4u) {
|
||||
@@ -71736,23 +73475,9 @@ wuffs_webp__decoder__apply_transform_cross_color(
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_r += ((uint8_t)((((uint32_t)(WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_g] * v_g2r)) >> 5u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_b += ((uint8_t)((((uint32_t)(WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_g] * v_g2b)) >> 5u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_b += ((uint8_t)((((uint32_t)(WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_r] * v_r2b)) >> 5u)));
|
||||
v_r += ((uint8_t)((((uint32_t)(wuffs_base__utility__sign_extend_convert_u8_u32(v_g) * v_g2r)) >> 5u)));
|
||||
v_b += ((uint8_t)((((uint32_t)(wuffs_base__utility__sign_extend_convert_u8_u32(v_g) * v_g2b)) >> 5u)));
|
||||
v_b += ((uint8_t)((((uint32_t)(wuffs_base__utility__sign_extend_convert_u8_u32(v_r) * v_r2b)) >> 5u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
@@ -71789,13 +73514,6 @@ wuffs_webp__decoder__apply_transform_subtract_green(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[0u] += v_g;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[2u] += v_g;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71833,6 +73551,26 @@ wuffs_webp__decoder__apply_transform_color_indexing(
|
||||
|
||||
v_tile_size_log2 = ((uint32_t)(self->private_impl.f_transform_tile_size_log2[3u]));
|
||||
if (v_tile_size_log2 == 0u) {
|
||||
{
|
||||
wuffs_base__slice_u8 i_slice_dst = a_pix;
|
||||
v_dst.ptr = i_slice_dst.ptr;
|
||||
v_dst.len = 4;
|
||||
const uint8_t* i_end0_dst = wuffs_private_impl__ptr_u8_plus_len(v_dst.ptr, (((i_slice_dst.len - (size_t)(v_dst.ptr - i_slice_dst.ptr)) / 4) * 4));
|
||||
while (v_dst.ptr < i_end0_dst) {
|
||||
v_p = (((uint32_t)(v_dst.ptr[1u])) * 4u);
|
||||
v_p0 = self->private_data.f_palette[(v_p + 0u)];
|
||||
v_p1 = self->private_data.f_palette[(v_p + 1u)];
|
||||
v_p2 = self->private_data.f_palette[(v_p + 2u)];
|
||||
v_p3 = self->private_data.f_palette[(v_p + 3u)];
|
||||
v_dst.ptr[0u] = v_p0;
|
||||
v_dst.ptr[1u] = v_p1;
|
||||
v_dst.ptr[2u] = v_p2;
|
||||
v_dst.ptr[3u] = v_p3;
|
||||
v_dst.ptr += 4;
|
||||
}
|
||||
v_dst.len = 0;
|
||||
}
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
v_bits_per_pixel = (((uint32_t)(8u)) >> v_tile_size_log2);
|
||||
v_x_mask = ((((uint32_t)(1u)) << v_tile_size_log2) - 1u);
|
||||
@@ -72929,6 +74667,7 @@ wuffs_webp__decoder__decode_transform(
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint8_t v_c8 = 0;
|
||||
uint32_t v_transform_type = 0;
|
||||
uint32_t v_tile_size_log2 = 0;
|
||||
@@ -73027,28 +74766,34 @@ wuffs_webp__decoder__decode_transform(
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
status = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))),
|
||||
a_src,
|
||||
((self->private_impl.f_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
while (true) {
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))),
|
||||
a_src,
|
||||
((self->private_impl.f_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
v_status = t_2;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_status)) {
|
||||
break;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
} else if (v_transform_type == 2u) {
|
||||
} else {
|
||||
@@ -73059,8 +74804,8 @@ wuffs_webp__decoder__decode_transform(
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_2 = *iop_a_src++;
|
||||
v_c8 = t_2;
|
||||
uint8_t t_3 = *iop_a_src++;
|
||||
v_c8 = t_3;
|
||||
}
|
||||
if (self->private_impl.f_n_bits >= 8u) {
|
||||
status = wuffs_base__make_status(wuffs_webp__error__internal_error_inconsistent_n_bits);
|
||||
@@ -73135,29 +74880,8 @@ wuffs_webp__decoder__decode_transform(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[4u] += v_p.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[5u] += v_p.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[6u] += v_p.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[7u] += v_p.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -73166,7 +74890,6 @@ wuffs_webp__decoder__decode_transform(
|
||||
}
|
||||
}
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_transform = 0;
|
||||
goto exit;
|
||||
@@ -73290,6 +75013,7 @@ wuffs_webp__decoder__decode_hg_table(
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint8_t v_c8 = 0;
|
||||
uint32_t v_use_hg_table = 0;
|
||||
uint32_t v_tile_size_log2 = 0;
|
||||
@@ -73394,28 +75118,34 @@ wuffs_webp__decoder__decode_hg_table(
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
status = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))),
|
||||
a_src,
|
||||
((a_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
while (true) {
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))),
|
||||
a_src,
|
||||
((a_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
v_status = t_2;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_status)) {
|
||||
break;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
self->private_impl.f_overall_n_huffman_groups = 1u;
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
@@ -73848,7 +75578,7 @@ wuffs_xxhash32__hasher__initialize(
|
||||
wuffs_xxhash32__hasher*
|
||||
wuffs_xxhash32__hasher__alloc(void) {
|
||||
wuffs_xxhash32__hasher* x =
|
||||
(wuffs_xxhash32__hasher*)(calloc(sizeof(wuffs_xxhash32__hasher), 1));
|
||||
(wuffs_xxhash32__hasher*)(calloc(1, sizeof(wuffs_xxhash32__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -74261,7 +75991,7 @@ wuffs_xxhash64__hasher__initialize(
|
||||
wuffs_xxhash64__hasher*
|
||||
wuffs_xxhash64__hasher__alloc(void) {
|
||||
wuffs_xxhash64__hasher* x =
|
||||
(wuffs_xxhash64__hasher*)(calloc(sizeof(wuffs_xxhash64__hasher), 1));
|
||||
(wuffs_xxhash64__hasher*)(calloc(1, sizeof(wuffs_xxhash64__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -74902,7 +76632,7 @@ wuffs_xz__decoder__initialize(
|
||||
wuffs_xz__decoder*
|
||||
wuffs_xz__decoder__alloc(void) {
|
||||
wuffs_xz__decoder* x =
|
||||
(wuffs_xz__decoder*)(calloc(sizeof(wuffs_xz__decoder), 1));
|
||||
(wuffs_xz__decoder*)(calloc(1, sizeof(wuffs_xz__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -77457,15 +79187,13 @@ DecodeCborCallbacks::Done(DecodeCborResult& result,
|
||||
sync_io::Input& input,
|
||||
IOBuffer& buffer) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeCborArgQuirks //
|
||||
DecodeCborArgQuirks::DefaultValue() {
|
||||
return DecodeCborArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeCborArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeCborResult //
|
||||
@@ -77494,8 +79222,8 @@ DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
ret_error_message = "wuffs_aux::DecodeCbor: out of memory";
|
||||
goto done;
|
||||
}
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
}
|
||||
|
||||
// Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.
|
||||
@@ -77882,6 +79610,11 @@ DecodeImageCallbacks::SelectDecoder(uint32_t fourcc,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI)
|
||||
case WUFFS_BASE__FOURCC__QOI:
|
||||
return wuffs_qoi__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA)
|
||||
case WUFFS_BASE__FOURCC__TGA:
|
||||
return wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
@@ -77926,7 +79659,7 @@ DecodeImageCallbacks::AllocPixbuf(const wuffs_base__image_config& image_config,
|
||||
return AllocPixbufResult(DecodeImage_UnsupportedPixelConfiguration);
|
||||
}
|
||||
void* ptr =
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc((size_t)len, 1);
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc(1, (size_t)len);
|
||||
if (!ptr) {
|
||||
return AllocPixbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
@@ -77951,7 +79684,7 @@ DecodeImageCallbacks::AllocWorkbuf(wuffs_base__range_ii_u64 len_range,
|
||||
return AllocWorkbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
void* ptr =
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc((size_t)len, 1);
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc(1, (size_t)len);
|
||||
if (!ptr) {
|
||||
return AllocWorkbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
@@ -77988,15 +79721,13 @@ const char DecodeImage_UnsupportedPixelConfiguration[] = //
|
||||
const char DecodeImage_UnsupportedPixelFormat[] = //
|
||||
"wuffs_aux::DecodeImage: unsupported pixel format";
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeImageArgQuirks //
|
||||
DecodeImageArgQuirks::DefaultValue() {
|
||||
return DecodeImageArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeImageArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeImageArgFlags::DecodeImageArgFlags(uint64_t repr0) : repr(repr0) {}
|
||||
@@ -78094,7 +79825,8 @@ DecodeImage0(wuffs_base__image_decoder::unique_ptr& image_decoder,
|
||||
DecodeImageCallbacks& callbacks,
|
||||
sync_io::Input& input,
|
||||
wuffs_base__io_buffer& io_buf,
|
||||
wuffs_base__slice_u32 quirks,
|
||||
const QuirkKeyValuePair* quirks_ptr,
|
||||
const size_t quirks_len,
|
||||
uint64_t flags,
|
||||
wuffs_base__pixel_blend pixel_blend,
|
||||
wuffs_base__color_u32_argb_premul background_color,
|
||||
@@ -78177,8 +79909,8 @@ redirect:
|
||||
}
|
||||
|
||||
// Apply quirks.
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
image_decoder->set_quirk(quirks.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks_len; i++) {
|
||||
image_decoder->set_quirk(quirks_ptr[i].first, quirks_ptr[i].second);
|
||||
}
|
||||
|
||||
// Apply flags.
|
||||
@@ -78405,10 +80137,10 @@ DecodeImage(DecodeImageCallbacks& callbacks,
|
||||
}
|
||||
|
||||
wuffs_base__image_decoder::unique_ptr image_decoder(nullptr);
|
||||
DecodeImageResult result =
|
||||
DecodeImage0(image_decoder, callbacks, input, *io_buf, quirks.repr,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
DecodeImageResult result = DecodeImage0(
|
||||
image_decoder, callbacks, input, *io_buf, quirks.ptr, quirks.len,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
callbacks.Done(result, input, *io_buf, std::move(image_decoder));
|
||||
return result;
|
||||
}
|
||||
@@ -78443,15 +80175,13 @@ const char DecodeJson_BadJsonPointer[] = //
|
||||
const char DecodeJson_NoMatch[] = //
|
||||
"wuffs_aux::DecodeJson: no match";
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeJsonArgQuirks //
|
||||
DecodeJsonArgQuirks::DefaultValue() {
|
||||
return DecodeJsonArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeJsonArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeJsonArgJsonPointer::DecodeJsonArgJsonPointer(std::string repr0)
|
||||
@@ -78796,11 +80526,11 @@ DecodeJson(DecodeJsonCallbacks& callbacks,
|
||||
goto done;
|
||||
}
|
||||
bool allow_tilde_n_tilde_r_tilde_t = false;
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
if (quirks.repr.ptr[i] ==
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
if (quirks.ptr[i].first ==
|
||||
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) {
|
||||
allow_tilde_n_tilde_r_tilde_t = true;
|
||||
allow_tilde_n_tilde_r_tilde_t = (quirks.ptr[i].second != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2522
-792
@@ -81,15 +81,15 @@ extern "C" {
|
||||
// each major.minor branch, the commit count should increase monotonically.
|
||||
//
|
||||
// WUFFS_VERSION was overridden by "wuffs gen -version" based on revision
|
||||
// 3be81643cc77e83e0125b150502ea273bf02839d committed on 2024-07-09.
|
||||
// 5d69840f8e7ca481551b02c7e8d4c5fb69521bb9 committed on 2024-08-12.
|
||||
#define WUFFS_VERSION 0x000040000
|
||||
#define WUFFS_VERSION_MAJOR 0
|
||||
#define WUFFS_VERSION_MINOR 4
|
||||
#define WUFFS_VERSION_PATCH 0
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL "alpha.5"
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3771
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20240709
|
||||
#define WUFFS_VERSION_STRING "0.4.0-alpha.5+3771.20240709"
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL "alpha.8"
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3796
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20240812
|
||||
#define WUFFS_VERSION_STRING "0.4.0-alpha.8+3796.20240812"
|
||||
|
||||
// ---------------- Private Implementation Macros Re-definition Check
|
||||
|
||||
@@ -176,12 +176,62 @@ extern "C" {
|
||||
#elif defined(_MSC_VER) // (#if-chain ref AVOID_CPU_ARCH_1)
|
||||
|
||||
#if defined(_M_X64)
|
||||
// We need <intrin.h> for the __cpuid function.
|
||||
#include <intrin.h>
|
||||
|
||||
// On X86_64, Microsoft Visual C/C++ (MSVC) only supports SSE2 by default.
|
||||
// There are /arch:SSE2, /arch:AVX and /arch:AVX2 compiler flags (the AVX2 one
|
||||
// is roughly equivalent to X86_64_V3), but there is no /arch:SSE42 compiler
|
||||
// flag that's equivalent to X86_64_V2.
|
||||
//
|
||||
// For getting maximum performance with X86_64 MSVC and Wuffs, pass /arch:AVX2
|
||||
// (and then test on the oldest hardware you intend to support).
|
||||
//
|
||||
// Absent that compiler flag, either define one of the three macros listed
|
||||
// below or else the X86_64 SIMD code will be disabled and you'll get a #pragma
|
||||
// message stating this library "performs best with /arch:AVX2". This message
|
||||
// is harmless and ignorable, in that the non-SIMD code is still correct and
|
||||
// reasonably performant, but is a reminder that when combining Wuffs and MSVC,
|
||||
// some compiler configuration is required for maximum performance.
|
||||
//
|
||||
// - WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY
|
||||
// - WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2 (enables SSE4.2 and below)
|
||||
// - WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V3 (enables AVX2 and below)
|
||||
//
|
||||
// Defining the first one (WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
// or defining none of those three (the default state) are equivalent (in that
|
||||
// both disable the SIMD code paths), other than that pragma message.
|
||||
//
|
||||
// When defining these WUFFS_CONFIG__ENABLE_ETC macros with MSVC, be aware that
|
||||
// some users report it leading to ICEs (Internal Compiler Errors), but other
|
||||
// users report no problems at all (and improved performance). It's unclear
|
||||
// exactly what combination of SIMD code and MSVC configuration lead to ICEs.
|
||||
// Do your own testing with your own MSVC version and configuration.
|
||||
//
|
||||
// https://github.com/google/wuffs/issues/148
|
||||
// https://github.com/google/wuffs/issues/151
|
||||
// https://developercommunity.visualstudio.com/t/fatal--error-C1001:-Internal-compiler-er/10703305
|
||||
//
|
||||
// Clang (including clang-cl) and GCC don't need this WUFFS_CONFIG__ETC macro
|
||||
// machinery, or having the Wuffs-the-library user to fiddle with compiler
|
||||
// flags, because they support "__attribute__((target(arg)))".
|
||||
#if defined(__AVX2__) || defined(__clang__) || \
|
||||
defined(WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V3)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V2
|
||||
#if defined(__AVX2__) || defined(__clang__)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V3
|
||||
#elif defined(WUFFS_CONFIG__ENABLE_MSVC_CPU_ARCH__X86_64_V2)
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V2
|
||||
#elif !defined(WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
#pragma message("Wuffs with MSVC+X64 performs best with /arch:AVX2")
|
||||
#endif // defined(__AVX2__) || defined(__clang__) || etc
|
||||
|
||||
#if defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
|
||||
|
||||
#if defined(WUFFS_CONFIG__DISABLE_MSVC_CPU_ARCH__X86_64_FAMILY)
|
||||
#error "MSVC_CPU_ARCH simultaneously enabled and disabled"
|
||||
#endif
|
||||
|
||||
#include <intrin.h>
|
||||
// intrin.h isn't enough for X64 SIMD, with clang-cl, if we want to use
|
||||
// "__attribute__((target(arg)))" without e.g. "/arch:AVX".
|
||||
//
|
||||
@@ -191,23 +241,9 @@ extern "C" {
|
||||
#include <immintrin.h> // AVX, AVX2, FMA, POPCNT
|
||||
#include <nmmintrin.h> // SSE4.2
|
||||
#include <wmmintrin.h> // AES, PCLMUL
|
||||
#define WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64_V3
|
||||
|
||||
#else // defined(__AVX2__) || defined(__clang__)
|
||||
|
||||
// clang-cl (which defines both __clang__ and _MSC_VER) supports
|
||||
// "__attribute__((target(arg)))".
|
||||
//
|
||||
// For MSVC's cl.exe (unlike clang or gcc), SIMD capability is a compile-time
|
||||
// property of the source file (e.g. a /arch:AVX2 or -mavx2 compiler flag), not
|
||||
// of individual functions (that can be conditionally selected at runtime).
|
||||
#if !defined(WUFFS_CONFIG__I_KNOW_THAT_WUFFS_MSVC_PERFORMS_BEST_WITH_ARCH_AVX2)
|
||||
#pragma message("Wuffs with MSVC+IX86/X64 performs best with /arch:AVX2")
|
||||
#endif
|
||||
|
||||
#endif // defined(__AVX2__) || defined(__clang__)
|
||||
#endif // defined(WUFFS_PRIVATE_IMPL__CPU_ARCH__X86_64)
|
||||
#endif // defined(_M_X64)
|
||||
|
||||
#endif // (#if-chain ref AVOID_CPU_ARCH_1)
|
||||
#endif // (#if-chain ref AVOID_CPU_ARCH_0)
|
||||
|
||||
@@ -914,6 +950,8 @@ typedef struct wuffs_base__transform__output__struct {
|
||||
|
||||
#define WUFFS_BASE__QUIRK_IGNORE_CHECKSUM 1
|
||||
|
||||
#define WUFFS_BASE__QUIRK_QUALITY 2
|
||||
|
||||
// --------
|
||||
|
||||
// Flicks are a unit of time. One flick (frame-tick) is 1 / 705_600_000 of a
|
||||
@@ -1979,6 +2017,20 @@ WUFFS_BASE__MAYBE_STATIC int32_t //
|
||||
wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix_data,
|
||||
bool prefix_closed);
|
||||
|
||||
// ---------------- Quirk Values
|
||||
|
||||
// These constants are the value half of a key-value pair, where the key is
|
||||
// WUFFS_BASE__QUIRK_QUALITY.
|
||||
//
|
||||
// In the Wuffs API, set_quirk takes a u64 value. These macro definitions are
|
||||
// likewise unsigned values (uint64_t) but for this particular key, they are
|
||||
// best interpreted as signed values (int64_t). "Lower-than-default quality"
|
||||
// and "higher-than-default quality", as signed values, are -1 and +1.
|
||||
//
|
||||
// See doc/note/quirks.md for some more discussion about trade-offs.
|
||||
#define WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY UINT64_MAX
|
||||
#define WUFFS_BASE__QUIRK_QUALITY__VALUE__HIGHER_QUALITY ((uint64_t)1)
|
||||
|
||||
// ---------------- Ranges and Rects
|
||||
|
||||
// See https://github.com/google/wuffs/blob/main/doc/note/ranges-and-rects.md
|
||||
@@ -3351,49 +3403,53 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__NUM_BITS 46
|
||||
// clang-format off
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBC__FILLER 0
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRING 2
|
||||
#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
|
||||
#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
|
||||
#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__MAX_INCL 0xFFFF
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MAJOR__SHIFT 42
|
||||
#define WUFFS_BASE__TOKEN__VALUE_MINOR__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_CATEGORY__SHIFT 38
|
||||
#define WUFFS_BASE__TOKEN__VALUE_BASE_DETAIL__SHIFT 17
|
||||
#define WUFFS_BASE__TOKEN__CONTINUED__SHIFT 16
|
||||
#define WUFFS_BASE__TOKEN__LENGTH__SHIFT 0
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VALUE_EXTENSION__NUM_BITS 46
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBC__FILLER 0
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRUCTURE 1
|
||||
#define WUFFS_BASE__TOKEN__VBC__STRING 2
|
||||
#define WUFFS_BASE__TOKEN__VBC__UNICODE_CODE_POINT 3
|
||||
#define WUFFS_BASE__TOKEN__VBC__LITERAL 4
|
||||
#define WUFFS_BASE__TOKEN__VBC__NUMBER 5
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_SIGNED 6
|
||||
#define WUFFS_BASE__TOKEN__VBC__INLINE_INTEGER_UNSIGNED 7
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__PUNCTUATION 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_BLOCK 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_LINE 0x00004
|
||||
|
||||
// COMMENT_ANY is a bit-wise or of COMMENT_BLOCK AND COMMENT_LINE.
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006
|
||||
#define WUFFS_BASE__TOKEN__VBD__FILLER__COMMENT_ANY 0x00006
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__PUSH 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__POP 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_NONE 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_LIST 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__FROM_DICT 0x00040
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_NONE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_LIST 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRUCTURE__TO_DICT 0x04000
|
||||
|
||||
// --------
|
||||
|
||||
@@ -3413,11 +3469,11 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
//
|
||||
// The lack of any particular bit is conservative: it is valid for all-ASCII
|
||||
// strings, in a single- or multi-token chain, to have none of these bits set.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_UTF_8 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_UTF_8 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_UTF_8 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__DEFINITELY_ASCII 0x00010
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_MUST_BE_ASCII 0x00020
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CHAIN_SHOULD_BE_ASCII 0x00040
|
||||
|
||||
// CONVERT_D_DST_S_SRC means that multiples of S source bytes (possibly padded)
|
||||
@@ -3432,22 +3488,22 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// When src is the empty string, multiple conversion algorithms are applicable
|
||||
// (so these bits are not necessarily mutually exclusive), all producing the
|
||||
// same empty dst string.
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_0_DST_1_SRC_DROP 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_1_SRC_COPY 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_2_SRC_HEXADECIMAL 0x00400
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_1_DST_4_SRC_BACKSLASH_X 0x00800
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_STD 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_3_DST_4_SRC_BASE_64_URL 0x02000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_4_DST_5_SRC_ASCII_85 0x04000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_HEX 0x08000
|
||||
#define WUFFS_BASE__TOKEN__VBD__STRING__CONVERT_5_DST_8_SRC_BASE_32_STD 0x10000
|
||||
|
||||
// --------
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__UNDEFINED 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__NULL 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__FALSE 0x00004
|
||||
#define WUFFS_BASE__TOKEN__VBD__LITERAL__TRUE 0x00008
|
||||
|
||||
// --------
|
||||
|
||||
@@ -3460,8 +3516,8 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// For a source string of "+123" or "-0x9A", only the first two are valid.
|
||||
//
|
||||
// For a source string of "123.", only the first one is valid.
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_FLOATING_POINT 0x00001
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_SIGNED 0x00002
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_INTEGER_UNSIGNED 0x00004
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__CONTENT_NEG_INF 0x00010
|
||||
@@ -3473,11 +3529,15 @@ wuffs_base__make_token(uint64_t repr) {
|
||||
// "300", which are big-endian, little-endian or text. For binary formats, the
|
||||
// token length (after adjusting for FORMAT_IGNORE_ETC) discriminates
|
||||
// e.g. u16 little-endian vs u32 little-endian.
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_BIG_ENDIAN 0x00100
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_BINARY_LITTLE_ENDIAN 0x00200
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_TEXT 0x00400
|
||||
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000
|
||||
#define WUFFS_BASE__TOKEN__VBD__NUMBER__FORMAT_IGNORE_FIRST_BYTE 0x01000
|
||||
|
||||
// --------
|
||||
|
||||
// clang-format on
|
||||
|
||||
// --------
|
||||
|
||||
@@ -4605,7 +4665,7 @@ wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
|
||||
}
|
||||
if (pixfmt_repr) {
|
||||
do {
|
||||
#if SIZE_MAX < UINT64_MAX
|
||||
#if SIZE_MAX < 0xFFFFFFFFFFFFFFFFull
|
||||
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
|
||||
// TODO: handle things other than 1 byte per pixel.
|
||||
if (wh > ((uint64_t)SIZE_MAX)) {
|
||||
@@ -9602,8 +9662,10 @@ extern const char wuffs_jpeg__error__bad_sof_marker[];
|
||||
extern const char wuffs_jpeg__error__bad_sos_marker[];
|
||||
extern const char wuffs_jpeg__error__bad_header[];
|
||||
extern const char wuffs_jpeg__error__bad_marker[];
|
||||
extern const char wuffs_jpeg__error__bad_scan_count[];
|
||||
extern const char wuffs_jpeg__error__missing_huffman_table[];
|
||||
extern const char wuffs_jpeg__error__missing_quantization_table[];
|
||||
extern const char wuffs_jpeg__error__rejected_progressive_jpeg[];
|
||||
extern const char wuffs_jpeg__error__truncated_input[];
|
||||
extern const char wuffs_jpeg__error__unsupported_arithmetic_coding[];
|
||||
extern const char wuffs_jpeg__error__unsupported_color_model[];
|
||||
@@ -9621,6 +9683,8 @@ extern const char wuffs_jpeg__error__unsupported_scan_count[];
|
||||
|
||||
#define WUFFS_JPEG__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 51552191232u
|
||||
|
||||
#define WUFFS_JPEG__QUIRK_REJECT_PROGRESSIVE_JPEGS 1220532224u
|
||||
|
||||
// ---------------- Struct Declarations
|
||||
|
||||
typedef struct wuffs_jpeg__decoder__struct wuffs_jpeg__decoder;
|
||||
@@ -9846,6 +9910,13 @@ struct wuffs_jpeg__decoder__struct {
|
||||
uint32_t f_bitstream_ri;
|
||||
uint32_t f_bitstream_wi;
|
||||
bool f_bitstream_is_closed;
|
||||
bool f_expect_multiple_scans;
|
||||
bool f_use_lower_quality;
|
||||
bool f_reject_progressive_jpegs;
|
||||
bool f_swizzle_immediately;
|
||||
wuffs_base__status f_swizzle_immediately_status;
|
||||
uint32_t f_swizzle_immediately_b_offsets[10];
|
||||
uint32_t f_swizzle_immediately_c_offsets[5];
|
||||
uint32_t f_bitstream_padding;
|
||||
uint16_t f_quant_tables[4][64];
|
||||
uint16_t f_saved_quant_tables[4][64];
|
||||
@@ -9881,6 +9952,7 @@ struct wuffs_jpeg__decoder__struct {
|
||||
uint32_t p_skip_past_the_next_restart_marker;
|
||||
uint32_t (*choosy_decode_mcu)(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -9889,6 +9961,7 @@ struct wuffs_jpeg__decoder__struct {
|
||||
struct {
|
||||
uint8_t f_bitstream_buffer[2048];
|
||||
uint16_t f_mcu_blocks[10][64];
|
||||
uint8_t f_swizzle_immediately_buffer[640];
|
||||
uint8_t f_swizzle_ycck_scratch_buffer_2k[2048];
|
||||
uint8_t f_dht_temp_counts[16];
|
||||
uint8_t f_dht_temp_bit_lengths[256];
|
||||
@@ -12674,6 +12747,371 @@ struct wuffs_png__decoder__struct {
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_qoi__error__bad_footer[];
|
||||
extern const char wuffs_qoi__error__bad_header[];
|
||||
extern const char wuffs_qoi__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
#define WUFFS_QOI__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 0u
|
||||
|
||||
// ---------------- Struct Declarations
|
||||
|
||||
typedef struct wuffs_qoi__decoder__struct wuffs_qoi__decoder;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// ---------------- Public Initializer Prototypes
|
||||
|
||||
// For any given "wuffs_foo__bar* self", "wuffs_foo__bar__initialize(self,
|
||||
// etc)" should be called before any other "wuffs_foo__bar__xxx(self, etc)".
|
||||
//
|
||||
// Pass sizeof(*self) and WUFFS_VERSION for sizeof_star_self and wuffs_version.
|
||||
// Pass 0 (or some combination of WUFFS_INITIALIZE__XXX) for options.
|
||||
|
||||
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
|
||||
wuffs_qoi__decoder__initialize(
|
||||
wuffs_qoi__decoder* self,
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version,
|
||||
uint32_t options);
|
||||
|
||||
size_t
|
||||
sizeof__wuffs_qoi__decoder(void);
|
||||
|
||||
// ---------------- Allocs
|
||||
|
||||
// These functions allocate and initialize Wuffs structs. They return NULL if
|
||||
// memory allocation fails. If they return non-NULL, there is no need to call
|
||||
// wuffs_foo__bar__initialize, but the caller is responsible for eventually
|
||||
// calling free on the returned pointer. That pointer is effectively a C++
|
||||
// std::unique_ptr<T, wuffs_unique_ptr_deleter>.
|
||||
|
||||
wuffs_qoi__decoder*
|
||||
wuffs_qoi__decoder__alloc(void);
|
||||
|
||||
static inline wuffs_base__image_decoder*
|
||||
wuffs_qoi__decoder__alloc_as__wuffs_base__image_decoder(void) {
|
||||
return (wuffs_base__image_decoder*)(wuffs_qoi__decoder__alloc());
|
||||
}
|
||||
|
||||
// ---------------- Upcasts
|
||||
|
||||
static inline wuffs_base__image_decoder*
|
||||
wuffs_qoi__decoder__upcast_as__wuffs_base__image_decoder(
|
||||
wuffs_qoi__decoder* p) {
|
||||
return (wuffs_base__image_decoder*)p;
|
||||
}
|
||||
|
||||
// ---------------- Public Function Prototypes
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__get_quirk(
|
||||
const wuffs_qoi__decoder* self,
|
||||
uint32_t a_key);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__set_quirk(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_key,
|
||||
uint64_t a_value);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
|
||||
wuffs_qoi__decoder__frame_dirty_rect(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint32_t
|
||||
wuffs_qoi__decoder__num_animation_loops(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frame_configs(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frames(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__restart_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint64_t a_index,
|
||||
uint64_t a_io_position);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
|
||||
wuffs_qoi__decoder__set_report_metadata(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_fourcc,
|
||||
bool a_report);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__tell_me_more(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
|
||||
wuffs_qoi__decoder__workbuf_len(
|
||||
const wuffs_qoi__decoder* self);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
// ---------------- Struct Definitions
|
||||
|
||||
// These structs' fields, and the sizeof them, are private implementation
|
||||
// details that aren't guaranteed to be stable across Wuffs versions.
|
||||
//
|
||||
// See https://en.wikipedia.org/wiki/Opaque_pointer#C
|
||||
|
||||
#if defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
struct wuffs_qoi__decoder__struct {
|
||||
// Do not access the private_impl's or private_data's fields directly. There
|
||||
// is no API/ABI compatibility or safety guarantee if you do so. Instead, use
|
||||
// the wuffs_foo__bar__baz functions.
|
||||
//
|
||||
// It is a struct, not a struct*, so that the outermost wuffs_foo__bar struct
|
||||
// can be stack allocated when WUFFS_IMPLEMENTATION is defined.
|
||||
|
||||
struct {
|
||||
uint32_t magic;
|
||||
uint32_t active_coroutine;
|
||||
wuffs_base__vtable vtable_for__wuffs_base__image_decoder;
|
||||
wuffs_base__vtable null_vtable;
|
||||
|
||||
uint32_t f_pixfmt;
|
||||
uint32_t f_width;
|
||||
uint32_t f_height;
|
||||
uint64_t f_remaining_pixels_times_4;
|
||||
uint8_t f_call_sequence;
|
||||
uint32_t f_buffer_index;
|
||||
uint32_t f_dst_x;
|
||||
uint32_t f_dst_y;
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config;
|
||||
uint32_t p_do_decode_image_config;
|
||||
uint32_t p_decode_frame_config;
|
||||
uint32_t p_do_decode_frame_config;
|
||||
uint32_t p_decode_frame;
|
||||
uint32_t p_do_decode_frame;
|
||||
uint32_t p_from_src_to_buffer;
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
uint8_t f_pixel[4];
|
||||
uint8_t f_cache[256];
|
||||
uint8_t f_buffer[8196];
|
||||
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_do_decode_image_config;
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_do_decode_frame;
|
||||
struct {
|
||||
uint8_t v_dg;
|
||||
uint32_t v_bi;
|
||||
uint32_t v_bk;
|
||||
} s_from_src_to_buffer;
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
using unique_ptr = std::unique_ptr<wuffs_qoi__decoder, wuffs_unique_ptr_deleter>;
|
||||
|
||||
// On failure, the alloc_etc functions return nullptr. They don't throw.
|
||||
|
||||
static inline unique_ptr
|
||||
alloc() {
|
||||
return unique_ptr(wuffs_qoi__decoder__alloc());
|
||||
}
|
||||
|
||||
static inline wuffs_base__image_decoder::unique_ptr
|
||||
alloc_as__wuffs_base__image_decoder() {
|
||||
return wuffs_base__image_decoder::unique_ptr(
|
||||
wuffs_qoi__decoder__alloc_as__wuffs_base__image_decoder());
|
||||
}
|
||||
#endif // defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
#if defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
|
||||
// Disallow constructing or copying an object via standard C++ mechanisms,
|
||||
// e.g. the "new" operator, as this struct is intentionally opaque. Its total
|
||||
// size and field layout is not part of the public, stable, memory-safe API.
|
||||
// Use malloc or memcpy and the sizeof__wuffs_foo__bar function instead, and
|
||||
// call wuffs_foo__bar__baz methods (which all take a "this"-like pointer as
|
||||
// their first argument) rather than tweaking bar.private_impl.qux fields.
|
||||
//
|
||||
// In C, we can just leave wuffs_foo__bar as an incomplete type (unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd). In C++, we define a complete type in
|
||||
// order to provide convenience methods. These forward on "this", so that you
|
||||
// can write "bar->baz(etc)" instead of "wuffs_foo__bar__baz(bar, etc)".
|
||||
wuffs_qoi__decoder__struct() = delete;
|
||||
wuffs_qoi__decoder__struct(const wuffs_qoi__decoder__struct&) = delete;
|
||||
wuffs_qoi__decoder__struct& operator=(
|
||||
const wuffs_qoi__decoder__struct&) = delete;
|
||||
#endif // defined(WUFFS_BASE__HAVE_EQ_DELETE) && !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#if !defined(WUFFS_IMPLEMENTATION)
|
||||
// As above, the size of the struct is not part of the public API, and unless
|
||||
// WUFFS_IMPLEMENTATION is #define'd, this struct type T should be heap
|
||||
// allocated, not stack allocated. Its size is not intended to be known at
|
||||
// compile time, but it is unfortunately divulged as a side effect of
|
||||
// defining C++ convenience methods. Use "sizeof__T()", calling the function,
|
||||
// instead of "sizeof T", invoking the operator. To make the two values
|
||||
// different, so that passing the latter will be rejected by the initialize
|
||||
// function, we add an arbitrary amount of dead weight.
|
||||
uint8_t dead_weight[123000000]; // 123 MB.
|
||||
#endif // !defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
inline wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
|
||||
initialize(
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version,
|
||||
uint32_t options) {
|
||||
return wuffs_qoi__decoder__initialize(
|
||||
this, sizeof_star_self, wuffs_version, options);
|
||||
}
|
||||
|
||||
inline wuffs_base__image_decoder*
|
||||
upcast_as__wuffs_base__image_decoder() {
|
||||
return (wuffs_base__image_decoder*)this;
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
get_quirk(
|
||||
uint32_t a_key) const {
|
||||
return wuffs_qoi__decoder__get_quirk(this, a_key);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
set_quirk(
|
||||
uint32_t a_key,
|
||||
uint64_t a_value) {
|
||||
return wuffs_qoi__decoder__set_quirk(this, a_key, a_value);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
decode_image_config(
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
return wuffs_qoi__decoder__decode_image_config(this, a_dst, a_src);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
decode_frame_config(
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
return wuffs_qoi__decoder__decode_frame_config(this, a_dst, a_src);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
decode_frame(
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
return wuffs_qoi__decoder__decode_frame(this, a_dst, a_src, a_blend, a_workbuf, a_opts);
|
||||
}
|
||||
|
||||
inline wuffs_base__rect_ie_u32
|
||||
frame_dirty_rect() const {
|
||||
return wuffs_qoi__decoder__frame_dirty_rect(this);
|
||||
}
|
||||
|
||||
inline uint32_t
|
||||
num_animation_loops() const {
|
||||
return wuffs_qoi__decoder__num_animation_loops(this);
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
num_decoded_frame_configs() const {
|
||||
return wuffs_qoi__decoder__num_decoded_frame_configs(this);
|
||||
}
|
||||
|
||||
inline uint64_t
|
||||
num_decoded_frames() const {
|
||||
return wuffs_qoi__decoder__num_decoded_frames(this);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
restart_frame(
|
||||
uint64_t a_index,
|
||||
uint64_t a_io_position) {
|
||||
return wuffs_qoi__decoder__restart_frame(this, a_index, a_io_position);
|
||||
}
|
||||
|
||||
inline wuffs_base__empty_struct
|
||||
set_report_metadata(
|
||||
uint32_t a_fourcc,
|
||||
bool a_report) {
|
||||
return wuffs_qoi__decoder__set_report_metadata(this, a_fourcc, a_report);
|
||||
}
|
||||
|
||||
inline wuffs_base__status
|
||||
tell_me_more(
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
return wuffs_qoi__decoder__tell_me_more(this, a_dst, a_minfo, a_src);
|
||||
}
|
||||
|
||||
inline wuffs_base__range_ii_u64
|
||||
workbuf_len() const {
|
||||
return wuffs_qoi__decoder__workbuf_len(this);
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
}; // struct wuffs_qoi__decoder__struct
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__SHA256) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
@@ -14993,6 +15431,7 @@ struct wuffs_xz__decoder__struct {
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace wuffs_aux {
|
||||
|
||||
@@ -15005,6 +15444,8 @@ using IOBuffer = wuffs_base__io_buffer;
|
||||
// nullptr, since calling free(nullptr) is a no-op.
|
||||
using MemOwner = std::unique_ptr<void, decltype(&free)>;
|
||||
|
||||
using QuirkKeyValuePair = std::pair<uint32_t, uint64_t>;
|
||||
|
||||
namespace sync_io {
|
||||
|
||||
// --------
|
||||
@@ -15187,13 +15628,14 @@ class DecodeCborCallbacks {
|
||||
|
||||
// DecodeCborArgQuirks wraps an optional argument to DecodeCbor.
|
||||
struct DecodeCborArgQuirks {
|
||||
explicit DecodeCborArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeCborArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeCborArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeCbor calls callbacks based on the CBOR-formatted data in input.
|
||||
@@ -15290,6 +15732,7 @@ class DecodeImageCallbacks {
|
||||
// - WUFFS_BASE__FOURCC__NIE
|
||||
// - WUFFS_BASE__FOURCC__NPBM
|
||||
// - WUFFS_BASE__FOURCC__PNG
|
||||
// - WUFFS_BASE__FOURCC__QOI
|
||||
// - WUFFS_BASE__FOURCC__TGA
|
||||
// - WUFFS_BASE__FOURCC__WBMP
|
||||
// - WUFFS_BASE__FOURCC__WEBP
|
||||
@@ -15401,13 +15844,14 @@ extern const char DecodeImage_UnsupportedPixelFormat[];
|
||||
|
||||
// DecodeImageArgQuirks wraps an optional argument to DecodeImage.
|
||||
struct DecodeImageArgQuirks {
|
||||
explicit DecodeImageArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeImageArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeImageArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeImageArgFlags wraps an optional argument to DecodeImage.
|
||||
@@ -15619,13 +16063,14 @@ extern const char DecodeJson_NoMatch[];
|
||||
|
||||
// DecodeJsonArgQuirks wraps an optional argument to DecodeJson.
|
||||
struct DecodeJsonArgQuirks {
|
||||
explicit DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0);
|
||||
explicit DecodeJsonArgQuirks(uint32_t* ptr, size_t len);
|
||||
explicit DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0);
|
||||
|
||||
// DefaultValue returns an empty slice.
|
||||
static DecodeJsonArgQuirks DefaultValue();
|
||||
|
||||
wuffs_base__slice_u32 repr;
|
||||
const QuirkKeyValuePair* ptr;
|
||||
const size_t len;
|
||||
};
|
||||
|
||||
// DecodeJsonArgJsonPointer wraps an optional argument to DecodeJson.
|
||||
@@ -15835,6 +16280,9 @@ wuffs_private_impl__u64__sat_sub_indirect(uint64_t* x, uint64_t y) {
|
||||
|
||||
// ---------------- Numeric Types (Utility)
|
||||
|
||||
#define wuffs_base__utility__sign_extend_convert_u8_u32(a) \
|
||||
((uint32_t)(int32_t)(int8_t)(a))
|
||||
|
||||
#define wuffs_base__utility__sign_extend_convert_u16_u32(a) \
|
||||
((uint32_t)(int32_t)(int16_t)(a))
|
||||
|
||||
@@ -16544,8 +16992,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
const wuffs_base__pixel_swizzler* p,
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
wuffs_base__slice_u8 dst_palette,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
wuffs_base__slice_u8 src0,
|
||||
wuffs_base__slice_u8 src1,
|
||||
wuffs_base__slice_u8 src2,
|
||||
@@ -28480,8 +28930,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -28503,6 +28955,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) {
|
||||
if ((x_min_incl != 0) || (y_min_incl != 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
@@ -28515,7 +28971,7 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
// First row.
|
||||
uint32_t h1v2_bias = 1u;
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
dst, width, 0u, //
|
||||
dst, x_max_excl, 0u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, src_ptr3, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
@@ -28527,10 +28983,10 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
h1v2_bias = 2u;
|
||||
|
||||
// Middle rows.
|
||||
bool last_row = height == 2u * half_height_for_2to1;
|
||||
uint32_t y_max_excl = last_row ? (height - 1u) : height;
|
||||
bool last_row = y_max_excl == 2u * half_height_for_2to1;
|
||||
uint32_t middle_y_max_excl = last_row ? (y_max_excl - 1u) : y_max_excl;
|
||||
uint32_t y;
|
||||
for (y = 1u; y < y_max_excl; y++) {
|
||||
for (y = 1u; y < middle_y_max_excl; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src0_minor =
|
||||
(inv_v0 != 2u)
|
||||
@@ -28557,11 +29013,11 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
uint32_t total_src_len3 = 0u;
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
while (x < x_max_excl) {
|
||||
bool first_column = x == 0u;
|
||||
uint32_t end = x + 480u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
@@ -28617,9 +29073,9 @@ wuffs_private_impl__swizzle_ycck__general__triangle_filter(
|
||||
}
|
||||
|
||||
// Last row.
|
||||
if (y_max_excl != height) {
|
||||
if (middle_y_max_excl != y_max_excl) {
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter_edge_row(
|
||||
dst, width, height - 1u, //
|
||||
dst, x_max_excl, middle_y_max_excl, //
|
||||
src_ptr0, src_ptr1, src_ptr2, src_ptr3, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
@@ -28715,8 +29171,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -28734,6 +29192,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) {
|
||||
if ((x_min_incl != 0) || (y_min_incl != 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
@@ -28744,7 +29206,7 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
// First row.
|
||||
uint32_t h1v2_bias = 1u;
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
dst, width, 0u, //
|
||||
dst, x_max_excl, 0u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
@@ -28756,10 +29218,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
h1v2_bias = 2u;
|
||||
|
||||
// Middle rows.
|
||||
bool last_row = height == 2u * half_height_for_2to1;
|
||||
uint32_t y_max_excl = last_row ? (height - 1u) : height;
|
||||
bool last_row = y_max_excl == 2u * half_height_for_2to1;
|
||||
uint32_t middle_y_max_excl = last_row ? (y_max_excl - 1u) : y_max_excl;
|
||||
uint32_t y;
|
||||
for (y = 1u; y < y_max_excl; y++) {
|
||||
for (y = 1u; y < middle_y_max_excl; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src0_minor =
|
||||
(inv_v0 != 2u)
|
||||
@@ -28780,11 +29242,11 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
uint32_t total_src_len2 = 0u;
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
while (x < x_max_excl) {
|
||||
bool first_column = x == 0u;
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
@@ -28829,16 +29291,16 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
}
|
||||
|
||||
// Last row.
|
||||
if (y_max_excl != height) {
|
||||
if (middle_y_max_excl != y_max_excl) {
|
||||
wuffs_private_impl__swizzle_ycc__general__triangle_filter_edge_row(
|
||||
dst, width, height - 1u, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, //
|
||||
h1v2_bias, //
|
||||
scratch_buffer_2k_ptr, //
|
||||
dst, x_max_excl, middle_y_max_excl, //
|
||||
src_ptr0, src_ptr1, src_ptr2, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, //
|
||||
h1v2_bias, //
|
||||
scratch_buffer_2k_ptr, //
|
||||
upfunc0, upfunc1, upfunc2, conv3func);
|
||||
}
|
||||
}
|
||||
@@ -28846,8 +29308,10 @@ wuffs_private_impl__swizzle_ycc__general__triangle_filter(
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
@@ -28873,41 +29337,44 @@ wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
|
||||
uint32_t y;
|
||||
for (y = 0u; y < height; y++) {
|
||||
const uint8_t* src0_major = src_ptr0 + ((y / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major = src_ptr1 + ((y / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major = src_ptr2 + ((y / inv_v2) * (size_t)stride2);
|
||||
for (y = y_min_incl; y < y_max_excl; y++) {
|
||||
const uint8_t* src0_major =
|
||||
src_ptr0 + (((y - y_min_incl) / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major =
|
||||
src_ptr1 + (((y - y_min_incl) / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major =
|
||||
src_ptr2 + (((y - y_min_incl) / inv_v2) * (size_t)stride2);
|
||||
|
||||
uint32_t x = 0u;
|
||||
while (x < width) {
|
||||
uint32_t x = x_min_incl;
|
||||
while (x < x_max_excl) {
|
||||
uint32_t end = x + 672u;
|
||||
if (end > width) {
|
||||
end = width;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src0_major + (x / inv_h0), //
|
||||
src_len0, //
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 672u), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src1_major + (x / inv_h1), //
|
||||
src_len1, //
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 672u), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src2_major + (x / inv_h2), //
|
||||
src_len2, //
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 672u), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
(*conv3func)(dst, x, end, y, up0, up1, up2);
|
||||
@@ -28916,6 +29383,100 @@ wuffs_private_impl__swizzle_ycc__general__box_filter(
|
||||
}
|
||||
}
|
||||
|
||||
static void //
|
||||
wuffs_private_impl__swizzle_ycck__general__box_filter(
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
const uint8_t* src_ptr0,
|
||||
const uint8_t* src_ptr1,
|
||||
const uint8_t* src_ptr2,
|
||||
const uint8_t* src_ptr3,
|
||||
uint32_t stride0,
|
||||
uint32_t stride1,
|
||||
uint32_t stride2,
|
||||
uint32_t stride3,
|
||||
uint32_t inv_h0,
|
||||
uint32_t inv_h1,
|
||||
uint32_t inv_h2,
|
||||
uint32_t inv_h3,
|
||||
uint32_t inv_v0,
|
||||
uint32_t inv_v1,
|
||||
uint32_t inv_v2,
|
||||
uint32_t inv_v3,
|
||||
uint32_t half_width_for_2to1,
|
||||
uint32_t half_height_for_2to1,
|
||||
uint8_t* scratch_buffer_2k_ptr,
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func (*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) {
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc0 =
|
||||
(*upfuncs)[(inv_h0 - 1u) & 3u][(inv_v0 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc1 =
|
||||
(*upfuncs)[(inv_h1 - 1u) & 3u][(inv_v1 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc2 =
|
||||
(*upfuncs)[(inv_h2 - 1u) & 3u][(inv_v2 - 1u) & 3u];
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfunc3 =
|
||||
(*upfuncs)[(inv_h3 - 1u) & 3u][(inv_v3 - 1u) & 3u];
|
||||
|
||||
uint32_t y;
|
||||
for (y = y_min_incl; y < y_max_excl; y++) {
|
||||
const uint8_t* src0_major =
|
||||
src_ptr0 + (((y - y_min_incl) / inv_v0) * (size_t)stride0);
|
||||
const uint8_t* src1_major =
|
||||
src_ptr1 + (((y - y_min_incl) / inv_v1) * (size_t)stride1);
|
||||
const uint8_t* src2_major =
|
||||
src_ptr2 + (((y - y_min_incl) / inv_v2) * (size_t)stride2);
|
||||
const uint8_t* src3_major =
|
||||
src_ptr3 + (((y - y_min_incl) / inv_v3) * (size_t)stride3);
|
||||
|
||||
uint32_t x = x_min_incl;
|
||||
while (x < x_max_excl) {
|
||||
uint32_t end = x + 480u;
|
||||
if (end > x_max_excl) {
|
||||
end = x_max_excl;
|
||||
}
|
||||
|
||||
uint32_t src_len0 = ((end - x) + inv_h0 - 1u) / inv_h0;
|
||||
uint32_t src_len1 = ((end - x) + inv_h1 - 1u) / inv_h1;
|
||||
uint32_t src_len2 = ((end - x) + inv_h2 - 1u) / inv_h2;
|
||||
uint32_t src_len3 = ((end - x) + inv_h3 - 1u) / inv_h3;
|
||||
|
||||
const uint8_t* up0 = (*upfunc0)( //
|
||||
scratch_buffer_2k_ptr + (0u * 480u), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src0_major + ((x - x_min_incl) / inv_h0), //
|
||||
src_len0, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up1 = (*upfunc1)( //
|
||||
scratch_buffer_2k_ptr + (1u * 480u), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src1_major + ((x - x_min_incl) / inv_h1), //
|
||||
src_len1, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up2 = (*upfunc2)( //
|
||||
scratch_buffer_2k_ptr + (2u * 480u), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src2_major + ((x - x_min_incl) / inv_h2), //
|
||||
src_len2, //
|
||||
0u, false, false);
|
||||
|
||||
const uint8_t* up3 = (*upfunc3)( //
|
||||
scratch_buffer_2k_ptr + (3u * 480u), //
|
||||
src3_major + ((x - x_min_incl) / inv_h3), //
|
||||
src3_major + ((x - x_min_incl) / inv_h3), //
|
||||
src_len3, //
|
||||
0u, false, false);
|
||||
|
||||
(*conv4func)(dst, x, end, y, up0, up1, up2, up3);
|
||||
x = end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --------
|
||||
|
||||
// wuffs_private_impl__swizzle_flattened_length is like
|
||||
@@ -28940,8 +29501,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
const wuffs_base__pixel_swizzler* p,
|
||||
wuffs_base__pixel_buffer* dst,
|
||||
wuffs_base__slice_u8 dst_palette,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t x_min_incl,
|
||||
uint32_t x_max_excl,
|
||||
uint32_t y_min_incl,
|
||||
uint32_t y_max_excl,
|
||||
wuffs_base__slice_u8 src0,
|
||||
wuffs_base__slice_u8 src1,
|
||||
wuffs_base__slice_u8 src2,
|
||||
@@ -28971,13 +29534,18 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
wuffs_base__slice_u8 scratch_buffer_2k) {
|
||||
if (!p) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
} else if (!dst || (width > 0xFFFFu) || (height > 0xFFFFu) || //
|
||||
(4u <= ((unsigned int)h0 - 1u)) || //
|
||||
(4u <= ((unsigned int)h1 - 1u)) || //
|
||||
(4u <= ((unsigned int)h2 - 1u)) || //
|
||||
(4u <= ((unsigned int)v0 - 1u)) || //
|
||||
(4u <= ((unsigned int)v1 - 1u)) || //
|
||||
(4u <= ((unsigned int)v2 - 1u)) || //
|
||||
} else if (!dst || //
|
||||
(x_min_incl > x_max_excl) || //
|
||||
(x_max_excl > 0xFFFFu) || //
|
||||
(y_min_incl > y_max_excl) || //
|
||||
(y_max_excl > 0xFFFFu) || //
|
||||
(4u <= ((unsigned int)h0 - 1u)) || //
|
||||
(4u <= ((unsigned int)h1 - 1u)) || //
|
||||
(4u <= ((unsigned int)h2 - 1u)) || //
|
||||
(4u <= ((unsigned int)v0 - 1u)) || //
|
||||
(4u <= ((unsigned int)v1 - 1u)) || //
|
||||
(4u <= ((unsigned int)v2 - 1u)) || //
|
||||
(triangle_filter_for_2to1 && ((x_min_incl | y_min_incl) > 0u)) ||
|
||||
(scratch_buffer_2k.len < 2048u)) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
@@ -29004,21 +29572,69 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
uint32_t inv_v2 = max_incl_v / v2;
|
||||
uint32_t inv_v3 = v3 ? (max_incl_v / v3) : 0u;
|
||||
|
||||
uint32_t half_width_for_2to1 = (width + 1u) / 2u;
|
||||
uint32_t half_height_for_2to1 = (height + 1u) / 2u;
|
||||
if (x_min_incl != 0) {
|
||||
if ((x_min_incl % inv_h0) || (x_min_incl % inv_h1) ||
|
||||
(x_min_incl % inv_h2) || (inv_h3 && (x_min_incl % inv_h3))) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
}
|
||||
if (y_min_incl != 0) {
|
||||
if ((y_min_incl % inv_v0) || (y_min_incl % inv_v1) ||
|
||||
(y_min_incl % inv_v2) || (inv_v3 && (y_min_incl % inv_v3))) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
}
|
||||
|
||||
width = wuffs_private_impl__u32__min_of_5( //
|
||||
width, //
|
||||
width0 * inv_h0, //
|
||||
width1 * inv_h1, //
|
||||
width2 * inv_h2, //
|
||||
wuffs_base__pixel_config__width(&dst->pixcfg));
|
||||
height = wuffs_private_impl__u32__min_of_5( //
|
||||
height, //
|
||||
height0 * inv_v0, //
|
||||
height1 * inv_v1, //
|
||||
height2 * inv_v2, //
|
||||
wuffs_base__pixel_config__height(&dst->pixcfg));
|
||||
uint32_t half_width_for_2to1 = ((x_max_excl - x_min_incl) + 1u) / 2u;
|
||||
if (inv_h0 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width0);
|
||||
}
|
||||
if (inv_h1 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width1);
|
||||
}
|
||||
if (inv_h2 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width2);
|
||||
}
|
||||
if (inv_h3 == 2) {
|
||||
half_width_for_2to1 = wuffs_base__u32__min(half_width_for_2to1, width3);
|
||||
}
|
||||
|
||||
uint32_t half_height_for_2to1 = ((y_max_excl - y_min_incl) + 1u) / 2u;
|
||||
if (inv_v0 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height0);
|
||||
}
|
||||
if (inv_v1 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height1);
|
||||
}
|
||||
if (inv_v2 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height2);
|
||||
}
|
||||
if (inv_v3 == 2) {
|
||||
half_height_for_2to1 = wuffs_base__u32__min(half_height_for_2to1, height3);
|
||||
}
|
||||
|
||||
x_max_excl = wuffs_base__u32__min( //
|
||||
wuffs_base__pixel_config__width(&dst->pixcfg), //
|
||||
x_min_incl + wuffs_private_impl__u32__min_of_5( //
|
||||
x_max_excl - x_min_incl, //
|
||||
width0 * inv_h0, //
|
||||
width1 * inv_h1, //
|
||||
width2 * inv_h2, //
|
||||
inv_h3 ? (width3 * inv_h3) : 0xFFFFFFFF));
|
||||
y_max_excl = wuffs_base__u32__min( //
|
||||
wuffs_base__pixel_config__height(&dst->pixcfg), //
|
||||
y_min_incl + wuffs_private_impl__u32__min_of_5( //
|
||||
y_max_excl - y_min_incl, //
|
||||
height0 * inv_v0, //
|
||||
height1 * inv_v1, //
|
||||
height2 * inv_v2, //
|
||||
inv_v3 ? (height3 * inv_v3) : 0xFFFFFFFF));
|
||||
|
||||
if ((x_min_incl >= x_max_excl) || (y_min_incl >= y_max_excl)) {
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
uint32_t width = x_max_excl - x_min_incl;
|
||||
uint32_t height = y_max_excl - y_min_incl;
|
||||
|
||||
if (((h0 * inv_h0) != max_incl_h) || //
|
||||
((h1 * inv_h1) != max_incl_h) || //
|
||||
@@ -29119,10 +29735,6 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
|
||||
// ----
|
||||
|
||||
if ((width <= 0u) || (height <= 0u)) {
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func = NULL;
|
||||
|
||||
if (is_rgb_or_cmyk) {
|
||||
@@ -29157,28 +29769,58 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
}
|
||||
}
|
||||
|
||||
void (*func)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t width, //
|
||||
uint32_t height, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) =
|
||||
void (*func3)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t x_min_incl, //
|
||||
uint32_t x_max_excl, //
|
||||
uint32_t y_min_incl, //
|
||||
uint32_t y_max_excl, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_3_func conv3func) =
|
||||
&wuffs_private_impl__swizzle_ycc__general__box_filter;
|
||||
|
||||
void (*func4)(wuffs_base__pixel_buffer * dst, //
|
||||
uint32_t x_min_incl, //
|
||||
uint32_t x_max_excl, //
|
||||
uint32_t y_min_incl, //
|
||||
uint32_t y_max_excl, //
|
||||
const uint8_t* src_ptr0, //
|
||||
const uint8_t* src_ptr1, //
|
||||
const uint8_t* src_ptr2, //
|
||||
const uint8_t* src_ptr3, //
|
||||
uint32_t stride0, //
|
||||
uint32_t stride1, //
|
||||
uint32_t stride2, //
|
||||
uint32_t stride3, //
|
||||
uint32_t inv_h0, //
|
||||
uint32_t inv_h1, //
|
||||
uint32_t inv_h2, //
|
||||
uint32_t inv_h3, //
|
||||
uint32_t inv_v0, //
|
||||
uint32_t inv_v1, //
|
||||
uint32_t inv_v2, //
|
||||
uint32_t inv_v3, //
|
||||
uint32_t half_width_for_2to1, //
|
||||
uint32_t half_height_for_2to1, //
|
||||
uint8_t* scratch_buffer_2k_ptr, //
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func(*upfuncs)[4][4],
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func) =
|
||||
&wuffs_private_impl__swizzle_ycck__general__box_filter;
|
||||
|
||||
wuffs_private_impl__swizzle_ycc__upsample_func upfuncs[4][4];
|
||||
memcpy(&upfuncs, &wuffs_private_impl__swizzle_ycc__upsample_funcs,
|
||||
sizeof upfuncs);
|
||||
@@ -29186,8 +29828,10 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
if (triangle_filter_for_2to1 &&
|
||||
(wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h0, inv_v0) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h1, inv_v1) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h2, inv_v2))) {
|
||||
func = &wuffs_private_impl__swizzle_ycc__general__triangle_filter;
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h2, inv_v2) ||
|
||||
wuffs_private_impl__swizzle_has_triangle_upsampler(inv_h3, inv_v3))) {
|
||||
func3 = &wuffs_private_impl__swizzle_ycc__general__triangle_filter;
|
||||
func4 = &wuffs_private_impl__swizzle_ycck__general__triangle_filter;
|
||||
|
||||
upfuncs[0][1] = wuffs_private_impl__swizzle_ycc__upsample_inv_h1v2_triangle;
|
||||
upfuncs[1][0] = wuffs_private_impl__swizzle_ycc__upsample_inv_h2v1_triangle;
|
||||
@@ -29219,23 +29863,23 @@ wuffs_base__pixel_swizzler__swizzle_ycck(
|
||||
wuffs_private_impl__swizzle_ycc__convert_4_func conv4func =
|
||||
is_rgb_or_cmyk ? &wuffs_private_impl__swizzle_cmyk__convert_4_general
|
||||
: &wuffs_private_impl__swizzle_ycck__convert_4_general;
|
||||
wuffs_private_impl__swizzle_ycck__general__triangle_filter( //
|
||||
dst, width, height, //
|
||||
src0.ptr, src1.ptr, src2.ptr, src3.ptr, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
inv_v0, inv_v1, inv_v2, inv_v3, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
(*func4)( //
|
||||
dst, x_min_incl, x_max_excl, y_min_incl, y_max_excl, //
|
||||
src0.ptr, src1.ptr, src2.ptr, src3.ptr, //
|
||||
stride0, stride1, stride2, stride3, //
|
||||
inv_h0, inv_h1, inv_h2, inv_h3, //
|
||||
inv_v0, inv_v1, inv_v2, inv_v3, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
scratch_buffer_2k.ptr, &upfuncs, conv4func);
|
||||
|
||||
} else {
|
||||
(*func)( //
|
||||
dst, width, height, //
|
||||
src0.ptr, src1.ptr, src2.ptr, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
(*func3)( //
|
||||
dst, x_min_incl, x_max_excl, y_min_incl, y_max_excl, //
|
||||
src0.ptr, src1.ptr, src2.ptr, //
|
||||
stride0, stride1, stride2, //
|
||||
inv_h0, inv_h1, inv_h2, //
|
||||
inv_v0, inv_v1, inv_v2, //
|
||||
half_width_for_2to1, half_height_for_2to1, //
|
||||
scratch_buffer_2k.ptr, &upfuncs, conv3func);
|
||||
}
|
||||
|
||||
@@ -30210,7 +30854,7 @@ wuffs_adler32__hasher__initialize(
|
||||
wuffs_adler32__hasher*
|
||||
wuffs_adler32__hasher__alloc(void) {
|
||||
wuffs_adler32__hasher* x =
|
||||
(wuffs_adler32__hasher*)(calloc(sizeof(wuffs_adler32__hasher), 1));
|
||||
(wuffs_adler32__hasher*)(calloc(1, sizeof(wuffs_adler32__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -30816,7 +31460,7 @@ wuffs_bmp__decoder__initialize(
|
||||
wuffs_bmp__decoder*
|
||||
wuffs_bmp__decoder__alloc(void) {
|
||||
wuffs_bmp__decoder* x =
|
||||
(wuffs_bmp__decoder*)(calloc(sizeof(wuffs_bmp__decoder), 1));
|
||||
(wuffs_bmp__decoder*)(calloc(1, sizeof(wuffs_bmp__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -30954,6 +31598,7 @@ wuffs_bmp__decoder__do_decode_image_config(
|
||||
uint32_t v_width = 0;
|
||||
uint32_t v_height = 0;
|
||||
uint32_t v_planes = 0;
|
||||
uint32_t v_n = 0;
|
||||
uint32_t v_dst_pixfmt = 0;
|
||||
uint32_t v_byte_width = 0;
|
||||
|
||||
@@ -31711,7 +32356,8 @@ wuffs_bmp__decoder__do_decode_image_config(
|
||||
}
|
||||
}
|
||||
} else if (self->private_impl.f_bitmap_info_len >= 40u) {
|
||||
self->private_data.s_do_decode_image_config.scratch = (self->private_impl.f_bitmap_info_len - 40u);
|
||||
v_n = (self->private_impl.f_bitmap_info_len - 40u);
|
||||
self->private_data.s_do_decode_image_config.scratch = v_n;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45);
|
||||
if (self->private_data.s_do_decode_image_config.scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config.scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
@@ -33580,7 +34226,7 @@ wuffs_bzip2__decoder__initialize(
|
||||
wuffs_bzip2__decoder*
|
||||
wuffs_bzip2__decoder__alloc(void) {
|
||||
wuffs_bzip2__decoder* x =
|
||||
(wuffs_bzip2__decoder*)(calloc(sizeof(wuffs_bzip2__decoder), 1));
|
||||
(wuffs_bzip2__decoder*)(calloc(1, sizeof(wuffs_bzip2__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -35138,7 +35784,7 @@ wuffs_cbor__decoder__initialize(
|
||||
wuffs_cbor__decoder*
|
||||
wuffs_cbor__decoder__alloc(void) {
|
||||
wuffs_cbor__decoder* x =
|
||||
(wuffs_cbor__decoder*)(calloc(sizeof(wuffs_cbor__decoder), 1));
|
||||
(wuffs_cbor__decoder*)(calloc(1, sizeof(wuffs_cbor__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -36450,7 +37096,7 @@ wuffs_crc32__ieee_hasher__initialize(
|
||||
wuffs_crc32__ieee_hasher*
|
||||
wuffs_crc32__ieee_hasher__alloc(void) {
|
||||
wuffs_crc32__ieee_hasher* x =
|
||||
(wuffs_crc32__ieee_hasher*)(calloc(sizeof(wuffs_crc32__ieee_hasher), 1));
|
||||
(wuffs_crc32__ieee_hasher*)(calloc(1, sizeof(wuffs_crc32__ieee_hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -37285,7 +37931,7 @@ wuffs_crc64__ecma_hasher__initialize(
|
||||
wuffs_crc64__ecma_hasher*
|
||||
wuffs_crc64__ecma_hasher__alloc(void) {
|
||||
wuffs_crc64__ecma_hasher* x =
|
||||
(wuffs_crc64__ecma_hasher*)(calloc(sizeof(wuffs_crc64__ecma_hasher), 1));
|
||||
(wuffs_crc64__ecma_hasher*)(calloc(1, sizeof(wuffs_crc64__ecma_hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -37836,7 +38482,7 @@ wuffs_deflate__decoder__initialize(
|
||||
wuffs_deflate__decoder*
|
||||
wuffs_deflate__decoder__alloc(void) {
|
||||
wuffs_deflate__decoder* x =
|
||||
(wuffs_deflate__decoder*)(calloc(sizeof(wuffs_deflate__decoder), 1));
|
||||
(wuffs_deflate__decoder*)(calloc(1, sizeof(wuffs_deflate__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -40251,7 +40897,7 @@ wuffs_gif__decoder__initialize(
|
||||
wuffs_gif__decoder*
|
||||
wuffs_gif__decoder__alloc(void) {
|
||||
wuffs_gif__decoder* x =
|
||||
(wuffs_gif__decoder*)(calloc(sizeof(wuffs_gif__decoder), 1));
|
||||
(wuffs_gif__decoder*)(calloc(1, sizeof(wuffs_gif__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -43162,7 +43808,7 @@ wuffs_gzip__decoder__initialize(
|
||||
wuffs_gzip__decoder*
|
||||
wuffs_gzip__decoder__alloc(void) {
|
||||
wuffs_gzip__decoder* x =
|
||||
(wuffs_gzip__decoder*)(calloc(sizeof(wuffs_gzip__decoder), 1));
|
||||
(wuffs_gzip__decoder*)(calloc(1, sizeof(wuffs_gzip__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -43656,8 +44302,10 @@ const char wuffs_jpeg__error__bad_sof_marker[] = "#jpeg: bad SOF marker";
|
||||
const char wuffs_jpeg__error__bad_sos_marker[] = "#jpeg: bad SOS marker";
|
||||
const char wuffs_jpeg__error__bad_header[] = "#jpeg: bad header";
|
||||
const char wuffs_jpeg__error__bad_marker[] = "#jpeg: bad marker";
|
||||
const char wuffs_jpeg__error__bad_scan_count[] = "#jpeg: bad scan count";
|
||||
const char wuffs_jpeg__error__missing_huffman_table[] = "#jpeg: missing Huffman table";
|
||||
const char wuffs_jpeg__error__missing_quantization_table[] = "#jpeg: missing Quantization table";
|
||||
const char wuffs_jpeg__error__rejected_progressive_jpeg[] = "#jpeg: rejected progressive JPEG";
|
||||
const char wuffs_jpeg__error__truncated_input[] = "#jpeg: truncated input";
|
||||
const char wuffs_jpeg__error__unsupported_arithmetic_coding[] = "#jpeg: unsupported arithmetic coding";
|
||||
const char wuffs_jpeg__error__unsupported_color_model[] = "#jpeg: unsupported color model";
|
||||
@@ -43896,6 +44544,8 @@ WUFFS_JPEG__DEFAULT_HUFF_TABLE_AC_CHROMA[179] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
248u, 249u, 250u,
|
||||
};
|
||||
|
||||
#define WUFFS_JPEG__QUIRKS_BASE 1220532224u
|
||||
|
||||
// ---------------- Private Initializer Prototypes
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
@@ -44000,6 +44650,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_jpeg__decoder__decode_sos(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
@@ -44082,14 +44733,23 @@ static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_gray(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1,
|
||||
uint64_t a_stride);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_colorful(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static bool
|
||||
@@ -44110,6 +44770,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44118,6 +44779,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu__choosy_default(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44126,6 +44788,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44134,6 +44797,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44142,6 +44806,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44150,6 +44815,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my);
|
||||
@@ -44248,7 +44914,7 @@ wuffs_jpeg__decoder__initialize(
|
||||
wuffs_jpeg__decoder*
|
||||
wuffs_jpeg__decoder__alloc(void) {
|
||||
wuffs_jpeg__decoder* x =
|
||||
(wuffs_jpeg__decoder*)(calloc(sizeof(wuffs_jpeg__decoder), 1));
|
||||
(wuffs_jpeg__decoder*)(calloc(1, sizeof(wuffs_jpeg__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -45793,6 +46459,15 @@ wuffs_jpeg__decoder__get_quirk(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (a_key == 2u) {
|
||||
if (self->private_impl.f_use_lower_quality) {
|
||||
return 18446744073709551615u;
|
||||
}
|
||||
} else if (a_key == 1220532224u) {
|
||||
if (self->private_impl.f_reject_progressive_jpegs) {
|
||||
return 1u;
|
||||
}
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
@@ -45814,6 +46489,13 @@ wuffs_jpeg__decoder__set_quirk(
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
|
||||
if (a_key == 2u) {
|
||||
self->private_impl.f_use_lower_quality = (a_value >= 9223372036854775808u);
|
||||
return wuffs_base__make_status(NULL);
|
||||
} else if (a_key == 1220532224u) {
|
||||
self->private_impl.f_reject_progressive_jpegs = (a_value != 0u);
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
|
||||
@@ -46022,7 +46704,10 @@ wuffs_jpeg__decoder__do_decode_image_config(
|
||||
goto exit;
|
||||
} else if (v_marker < 208u) {
|
||||
if (v_marker <= 194u) {
|
||||
if (self->private_impl.f_sof_marker != 0u) {
|
||||
if ((v_marker == 194u) && self->private_impl.f_reject_progressive_jpegs) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__rejected_progressive_jpeg);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_sof_marker != 0u) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__bad_sof_marker);
|
||||
goto exit;
|
||||
}
|
||||
@@ -47100,14 +47785,27 @@ wuffs_jpeg__decoder__decode_frame(
|
||||
if ((v_ddf_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
v_ddf_status = wuffs_base__make_status(wuffs_jpeg__error__truncated_input);
|
||||
}
|
||||
if (wuffs_base__status__is_error(&v_ddf_status) || (v_scan_count < self->private_impl.f_scan_count)) {
|
||||
if ( ! self->private_impl.f_swizzle_immediately && (wuffs_base__status__is_error(&v_ddf_status) || (v_scan_count < self->private_impl.f_scan_count))) {
|
||||
if (self->private_impl.f_sof_marker >= 194u) {
|
||||
wuffs_jpeg__decoder__apply_progressive_idct(self, a_workbuf);
|
||||
}
|
||||
if (self->private_impl.f_num_components == 1u) {
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_gray(self, a_dst, a_workbuf);
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_gray(self,
|
||||
a_dst,
|
||||
a_workbuf,
|
||||
0u,
|
||||
4294967295u,
|
||||
0u,
|
||||
4294967295u,
|
||||
((uint64_t)(self->private_impl.f_components_workbuf_widths[0u])));
|
||||
} else {
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_colorful(self, a_dst, a_workbuf);
|
||||
v_swizzle_status = wuffs_jpeg__decoder__swizzle_colorful(self,
|
||||
a_dst,
|
||||
a_workbuf,
|
||||
0u,
|
||||
4294967295u,
|
||||
0u,
|
||||
4294967295u);
|
||||
}
|
||||
if (wuffs_base__status__is_error(&v_ddf_status)) {
|
||||
status = v_ddf_status;
|
||||
@@ -47212,9 +47910,14 @@ wuffs_jpeg__decoder__do_decode_frame(
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
self->private_impl.f_swizzle_immediately = false;
|
||||
if (self->private_impl.f_components_workbuf_offsets[8u] > ((uint64_t)(a_workbuf.len))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
if (self->private_impl.f_sof_marker >= 194u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_swizzle_immediately = self->private_impl.f_use_lower_quality;
|
||||
self->private_impl.f_swizzle_immediately_status = wuffs_base__make_status(NULL);
|
||||
} else if (self->private_impl.f_components_workbuf_offsets[4u] < self->private_impl.f_components_workbuf_offsets[8u]) {
|
||||
wuffs_private_impl__bulk_memset(a_workbuf.ptr + self->private_impl.f_components_workbuf_offsets[4u], (self->private_impl.f_components_workbuf_offsets[8u] - self->private_impl.f_components_workbuf_offsets[4u]), 0u);
|
||||
}
|
||||
@@ -47327,7 +48030,7 @@ wuffs_jpeg__decoder__do_decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
status = wuffs_jpeg__decoder__decode_sos(self, a_src, a_workbuf);
|
||||
status = wuffs_jpeg__decoder__decode_sos(self, a_dst, a_src, a_workbuf);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -47674,13 +48377,6 @@ wuffs_jpeg__decoder__calculate_huff_tables(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_k += 1u;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_j += 1u;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -47697,6 +48393,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_jpeg__decoder__decode_sos(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
@@ -47714,9 +48411,12 @@ wuffs_jpeg__decoder__decode_sos(
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_scan_count >= 64u) {
|
||||
if (self->private_impl.f_scan_count >= 32u) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__unsupported_scan_count);
|
||||
goto exit;
|
||||
} else if ((self->private_impl.f_scan_count > 0u) && ! self->private_impl.f_expect_multiple_scans) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__bad_scan_count);
|
||||
goto exit;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_jpeg__decoder__prepare_scan(self, a_src);
|
||||
@@ -47746,12 +48446,26 @@ wuffs_jpeg__decoder__decode_sos(
|
||||
wuffs_jpeg__decoder__load_mcu_blocks(self, v_mx, v_my, a_workbuf);
|
||||
}
|
||||
while (true) {
|
||||
v_decode_mcu_result = wuffs_jpeg__decoder__decode_mcu(self, a_workbuf, v_mx, v_my);
|
||||
v_decode_mcu_result = wuffs_jpeg__decoder__decode_mcu(self,
|
||||
a_dst,
|
||||
a_workbuf,
|
||||
v_mx,
|
||||
v_my);
|
||||
if (v_decode_mcu_result == 0u) {
|
||||
break;
|
||||
} else if (v_decode_mcu_result != 1u) {
|
||||
} else if (v_decode_mcu_result == 1u) {
|
||||
} else if (v_decode_mcu_result == 2u) {
|
||||
status = wuffs_base__make_status(wuffs_jpeg__error__internal_error_inconsistent_decoder_state);
|
||||
goto exit;
|
||||
} else {
|
||||
status = self->private_impl.f_swizzle_immediately_status;
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
goto exit;
|
||||
} else if (wuffs_base__status__is_suspension(&status)) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension);
|
||||
goto exit;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
while (true) {
|
||||
v_bitstream_length = ((uint32_t)(self->private_impl.f_bitstream_wi - self->private_impl.f_bitstream_ri));
|
||||
@@ -47940,6 +48654,9 @@ wuffs_jpeg__decoder__prepare_scan(
|
||||
}
|
||||
v_i += 1u;
|
||||
}
|
||||
if (self->private_impl.f_scan_count == 0u) {
|
||||
self->private_impl.f_expect_multiple_scans = ((self->private_impl.f_sof_marker >= 194u) || (self->private_impl.f_scan_num_components < self->private_impl.f_num_components));
|
||||
}
|
||||
if (self->private_impl.f_sof_marker < 194u) {
|
||||
self->private_data.s_prepare_scan.scratch = 3u;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
@@ -48189,6 +48906,7 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
uint32_t v_b = 0;
|
||||
uint32_t v_bx_offset = 0;
|
||||
uint32_t v_by_offset = 0;
|
||||
uint32_t v_sibo = 0;
|
||||
uint8_t v_ssel = 0;
|
||||
uint8_t v_csel = 0;
|
||||
|
||||
@@ -48201,6 +48919,7 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
v_h = ((uint32_t)(self->private_impl.f_components_h[self->private_impl.f_scan_comps_cselector[v_i]]));
|
||||
v_v = ((uint32_t)(self->private_impl.f_components_v[self->private_impl.f_scan_comps_cselector[v_i]]));
|
||||
v_hv = (((uint32_t)(self->private_impl.f_components_h[self->private_impl.f_scan_comps_cselector[v_i]])) * ((uint32_t)(self->private_impl.f_components_v[self->private_impl.f_scan_comps_cselector[v_i]])));
|
||||
self->private_impl.f_swizzle_immediately_c_offsets[v_i] = ((uint32_t)(64u * v_total_hv));
|
||||
v_total_hv += v_hv;
|
||||
while (v_hv > 0u) {
|
||||
self->private_impl.f_scan_comps_bx_offset[(v_b & 15u)] = ((uint8_t)((v_bx_offset & 3u)));
|
||||
@@ -48223,6 +48942,7 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
return true;
|
||||
}
|
||||
self->private_impl.f_mcu_num_blocks = v_total_hv;
|
||||
self->private_impl.f_swizzle_immediately_c_offsets[self->private_impl.f_scan_num_components] = ((uint32_t)(64u * v_total_hv));
|
||||
v_b = 0u;
|
||||
while (v_b < self->private_impl.f_mcu_num_blocks) {
|
||||
v_ssel = self->private_impl.f_mcu_blocks_sselector[v_b];
|
||||
@@ -48232,6 +48952,8 @@ wuffs_jpeg__decoder__calculate_multiple_component_scan_fields(
|
||||
self->private_impl.f_mcu_blocks_my_mul[v_b] = (8u * ((uint32_t)(self->private_impl.f_components_v[v_csel])) * self->private_impl.f_components_workbuf_widths[v_csel]);
|
||||
self->private_impl.f_mcu_blocks_dc_hselector[v_b] = ((uint8_t)(0u | self->private_impl.f_scan_comps_td[v_ssel]));
|
||||
self->private_impl.f_mcu_blocks_ac_hselector[v_b] = ((uint8_t)(4u | self->private_impl.f_scan_comps_ta[v_ssel]));
|
||||
v_sibo = ((uint32_t)(self->private_impl.f_swizzle_immediately_c_offsets[v_csel] + ((8u * ((uint32_t)(self->private_impl.f_scan_comps_bx_offset[v_b]))) + (64u * ((uint32_t)(self->private_impl.f_scan_comps_by_offset[v_b])) * ((uint32_t)(self->private_impl.f_components_h[v_csel]))))));
|
||||
self->private_impl.f_swizzle_immediately_b_offsets[v_b] = wuffs_base__u32__min(v_sibo, 576u);
|
||||
v_b += 1u;
|
||||
}
|
||||
self->private_impl.f_scan_width_in_mcus = self->private_impl.f_width_in_mcus;
|
||||
@@ -48567,15 +49289,21 @@ static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_gray(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1,
|
||||
uint64_t a_stride) {
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint32_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_length = 0;
|
||||
uint64_t v_x0 = 0;
|
||||
uint64_t v_x1 = 0;
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
uint32_t v_y = 0;
|
||||
uint64_t v_stride = 0;
|
||||
uint32_t v_y1 = 0;
|
||||
|
||||
v_dst_pixfmt = wuffs_base__pixel_buffer__pixel_format(a_dst);
|
||||
v_dst_bits_per_pixel = wuffs_base__pixel_format__bits_per_pixel(&v_dst_pixfmt);
|
||||
@@ -48583,18 +49311,24 @@ wuffs_jpeg__decoder__swizzle_gray(
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
v_dst_bytes_per_pixel = (v_dst_bits_per_pixel / 8u);
|
||||
v_dst_length = ((uint64_t)((v_dst_bytes_per_pixel * self->private_impl.f_width)));
|
||||
v_x0 = ((uint64_t)((v_dst_bytes_per_pixel * wuffs_base__u32__min(a_x0, self->private_impl.f_width))));
|
||||
v_x1 = ((uint64_t)((v_dst_bytes_per_pixel * wuffs_base__u32__min(a_x1, self->private_impl.f_width))));
|
||||
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0u);
|
||||
v_y = 0u;
|
||||
while (v_y < self->private_impl.f_height) {
|
||||
v_y = a_y0;
|
||||
v_y1 = wuffs_base__u32__min(a_y1, self->private_impl.f_height);
|
||||
while (v_y < v_y1) {
|
||||
v_dst = wuffs_private_impl__table_u8__row_u32(v_tab, v_y);
|
||||
if (v_dst_length < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_j(v_dst, v_dst_length);
|
||||
if (v_x1 < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_j(v_dst, v_x1);
|
||||
}
|
||||
if (v_x0 < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_x0);
|
||||
} else {
|
||||
v_dst = wuffs_base__utility__empty_slice_u8();
|
||||
}
|
||||
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, wuffs_base__pixel_buffer__palette_or_else(a_dst, wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024)), a_workbuf);
|
||||
v_stride = ((uint64_t)(self->private_impl.f_components_workbuf_widths[0u]));
|
||||
if (v_stride <= ((uint64_t)(a_workbuf.len))) {
|
||||
a_workbuf = wuffs_base__slice_u8__subslice_i(a_workbuf, v_stride);
|
||||
if (a_stride <= ((uint64_t)(a_workbuf.len))) {
|
||||
a_workbuf = wuffs_base__slice_u8__subslice_i(a_workbuf, a_stride);
|
||||
} else {
|
||||
a_workbuf = wuffs_base__utility__empty_slice_u8();
|
||||
}
|
||||
@@ -48610,54 +49344,109 @@ static wuffs_base__status
|
||||
wuffs_jpeg__decoder__swizzle_colorful(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_x0,
|
||||
uint32_t a_x1,
|
||||
uint32_t a_y0,
|
||||
uint32_t a_y1) {
|
||||
uint64_t v_i = 0;
|
||||
uint64_t v_j = 0;
|
||||
wuffs_base__slice_u8 v_src0 = {0};
|
||||
wuffs_base__slice_u8 v_src1 = {0};
|
||||
wuffs_base__slice_u8 v_src2 = {0};
|
||||
wuffs_base__slice_u8 v_src3 = {0};
|
||||
uint32_t v_width0 = 0;
|
||||
uint32_t v_width1 = 0;
|
||||
uint32_t v_width2 = 0;
|
||||
uint32_t v_width3 = 0;
|
||||
uint32_t v_height0 = 0;
|
||||
uint32_t v_height1 = 0;
|
||||
uint32_t v_height2 = 0;
|
||||
uint32_t v_height3 = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
if ((self->private_impl.f_components_workbuf_offsets[0u] <= self->private_impl.f_components_workbuf_offsets[1u]) && (self->private_impl.f_components_workbuf_offsets[1u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src0 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[0u],
|
||||
self->private_impl.f_components_workbuf_offsets[1u]);
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[1u] <= self->private_impl.f_components_workbuf_offsets[2u]) && (self->private_impl.f_components_workbuf_offsets[2u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src1 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[1u],
|
||||
self->private_impl.f_components_workbuf_offsets[2u]);
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[2u] <= self->private_impl.f_components_workbuf_offsets[3u]) && (self->private_impl.f_components_workbuf_offsets[3u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src2 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[2u],
|
||||
self->private_impl.f_components_workbuf_offsets[3u]);
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[3u] <= self->private_impl.f_components_workbuf_offsets[4u]) && (self->private_impl.f_components_workbuf_offsets[4u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src3 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[3u],
|
||||
self->private_impl.f_components_workbuf_offsets[4u]);
|
||||
if (self->private_impl.f_swizzle_immediately) {
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[0u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[1u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src0 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width0 = (8u * ((uint32_t)(self->private_impl.f_components_h[0u])));
|
||||
v_height0 = (8u * ((uint32_t)(self->private_impl.f_components_v[0u])));
|
||||
}
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[1u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[2u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src1 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width1 = (8u * ((uint32_t)(self->private_impl.f_components_h[1u])));
|
||||
v_height1 = (8u * ((uint32_t)(self->private_impl.f_components_v[1u])));
|
||||
}
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[2u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[3u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src2 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width2 = (8u * ((uint32_t)(self->private_impl.f_components_h[2u])));
|
||||
v_height2 = (8u * ((uint32_t)(self->private_impl.f_components_v[2u])));
|
||||
}
|
||||
v_i = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[3u]));
|
||||
v_j = ((uint64_t)(self->private_impl.f_swizzle_immediately_c_offsets[4u]));
|
||||
if ((v_i <= v_j) && (v_j <= 640u)) {
|
||||
v_src3 = wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, v_i, v_j);
|
||||
v_width3 = (8u * ((uint32_t)(self->private_impl.f_components_h[3u])));
|
||||
v_height3 = (8u * ((uint32_t)(self->private_impl.f_components_v[3u])));
|
||||
}
|
||||
} else {
|
||||
if ((self->private_impl.f_components_workbuf_offsets[0u] <= self->private_impl.f_components_workbuf_offsets[1u]) && (self->private_impl.f_components_workbuf_offsets[1u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src0 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[0u],
|
||||
self->private_impl.f_components_workbuf_offsets[1u]);
|
||||
v_width0 = self->private_impl.f_components_workbuf_widths[0u];
|
||||
v_height0 = self->private_impl.f_components_workbuf_heights[0u];
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[1u] <= self->private_impl.f_components_workbuf_offsets[2u]) && (self->private_impl.f_components_workbuf_offsets[2u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src1 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[1u],
|
||||
self->private_impl.f_components_workbuf_offsets[2u]);
|
||||
v_width1 = self->private_impl.f_components_workbuf_widths[1u];
|
||||
v_height1 = self->private_impl.f_components_workbuf_heights[1u];
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[2u] <= self->private_impl.f_components_workbuf_offsets[3u]) && (self->private_impl.f_components_workbuf_offsets[3u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src2 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[2u],
|
||||
self->private_impl.f_components_workbuf_offsets[3u]);
|
||||
v_width2 = self->private_impl.f_components_workbuf_widths[2u];
|
||||
v_height2 = self->private_impl.f_components_workbuf_heights[2u];
|
||||
}
|
||||
if ((self->private_impl.f_components_workbuf_offsets[3u] <= self->private_impl.f_components_workbuf_offsets[4u]) && (self->private_impl.f_components_workbuf_offsets[4u] <= ((uint64_t)(a_workbuf.len)))) {
|
||||
v_src3 = wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
self->private_impl.f_components_workbuf_offsets[3u],
|
||||
self->private_impl.f_components_workbuf_offsets[4u]);
|
||||
v_width3 = self->private_impl.f_components_workbuf_widths[3u];
|
||||
v_height3 = self->private_impl.f_components_workbuf_heights[3u];
|
||||
}
|
||||
}
|
||||
v_status = wuffs_base__pixel_swizzler__swizzle_ycck(&self->private_impl.f_swizzler,
|
||||
a_dst,
|
||||
wuffs_base__pixel_buffer__palette_or_else(a_dst, wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024)),
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height,
|
||||
(a_x0 & 65535u),
|
||||
wuffs_base__u32__min(a_x1, self->private_impl.f_width),
|
||||
(a_y0 & 65535u),
|
||||
wuffs_base__u32__min(a_y1, self->private_impl.f_height),
|
||||
v_src0,
|
||||
v_src1,
|
||||
v_src2,
|
||||
v_src3,
|
||||
self->private_impl.f_components_workbuf_widths[0u],
|
||||
self->private_impl.f_components_workbuf_widths[1u],
|
||||
self->private_impl.f_components_workbuf_widths[2u],
|
||||
self->private_impl.f_components_workbuf_widths[3u],
|
||||
self->private_impl.f_components_workbuf_heights[0u],
|
||||
self->private_impl.f_components_workbuf_heights[1u],
|
||||
self->private_impl.f_components_workbuf_heights[2u],
|
||||
self->private_impl.f_components_workbuf_heights[3u],
|
||||
self->private_impl.f_components_workbuf_widths[0u],
|
||||
self->private_impl.f_components_workbuf_widths[1u],
|
||||
self->private_impl.f_components_workbuf_widths[2u],
|
||||
self->private_impl.f_components_workbuf_widths[3u],
|
||||
v_width0,
|
||||
v_width1,
|
||||
v_width2,
|
||||
v_width3,
|
||||
v_height0,
|
||||
v_height1,
|
||||
v_height2,
|
||||
v_height3,
|
||||
v_width0,
|
||||
v_width1,
|
||||
v_width2,
|
||||
v_width3,
|
||||
self->private_impl.f_components_h[0u],
|
||||
self->private_impl.f_components_h[1u],
|
||||
self->private_impl.f_components_h[2u],
|
||||
@@ -48667,7 +49456,7 @@ wuffs_jpeg__decoder__swizzle_colorful(
|
||||
self->private_impl.f_components_v[2u],
|
||||
self->private_impl.f_components_v[3u],
|
||||
self->private_impl.f_is_rgb_or_cmyk,
|
||||
true,
|
||||
! self->private_impl.f_use_lower_quality,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_swizzle_ycck_scratch_buffer_2k, 2048));
|
||||
return wuffs_private_impl__status__ensure_not_a_suspension(v_status);
|
||||
}
|
||||
@@ -48779,6 +49568,7 @@ wuffs_jpeg__decoder__restart_frame(
|
||||
}
|
||||
self->private_impl.f_call_sequence = 40u;
|
||||
self->private_impl.f_bitstream_is_closed = false;
|
||||
self->private_impl.f_expect_multiple_scans = false;
|
||||
self->private_impl.f_frame_config_io_position = a_io_position;
|
||||
self->private_impl.f_scan_count = 0u;
|
||||
self->private_impl.f_restart_interval = self->private_impl.f_saved_restart_interval;
|
||||
@@ -48877,6 +49667,9 @@ wuffs_jpeg__decoder__workbuf_len(
|
||||
return wuffs_base__utility__empty_range_ii_u64();
|
||||
}
|
||||
|
||||
if (self->private_impl.f_use_lower_quality && (self->private_impl.f_sof_marker < 194u)) {
|
||||
return wuffs_base__utility__make_range_ii_u64(0u, self->private_impl.f_components_workbuf_offsets[8u]);
|
||||
}
|
||||
return wuffs_base__utility__make_range_ii_u64(self->private_impl.f_components_workbuf_offsets[8u], self->private_impl.f_components_workbuf_offsets[8u]);
|
||||
}
|
||||
|
||||
@@ -49513,16 +50306,18 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
return (*self->private_impl.choosy_decode_mcu)(self, a_workbuf, a_mx, a_my);
|
||||
return (*self->private_impl.choosy_decode_mcu)(self, a_dst, a_workbuf, a_mx, a_my);
|
||||
}
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu__choosy_default(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -49722,11 +50517,47 @@ wuffs_jpeg__decoder__decode_mcu__choosy_default(
|
||||
if (self->private_impl.f_test_only_interrupt_decode_mcu) {
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
v_csel = self->private_impl.f_scan_comps_cselector[self->private_impl.f_mcu_blocks_sselector[v_mcb]];
|
||||
v_stride = ((uint64_t)(self->private_impl.f_components_workbuf_widths[v_csel]));
|
||||
v_offset = (self->private_impl.f_mcu_blocks_offset[v_mcb] + (((uint64_t)(self->private_impl.f_mcu_blocks_mx_mul[v_mcb])) * ((uint64_t)(a_mx))) + (((uint64_t)(self->private_impl.f_mcu_blocks_my_mul[v_mcb])) * ((uint64_t)(a_my))));
|
||||
if (v_offset <= ((uint64_t)(a_workbuf.len))) {
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__slice_u8__subslice_i(a_workbuf, v_offset), v_stride, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
if ( ! self->private_impl.f_swizzle_immediately) {
|
||||
v_csel = self->private_impl.f_scan_comps_cselector[self->private_impl.f_mcu_blocks_sselector[v_mcb]];
|
||||
v_stride = ((uint64_t)(self->private_impl.f_components_workbuf_widths[v_csel]));
|
||||
v_offset = (self->private_impl.f_mcu_blocks_offset[v_mcb] + (((uint64_t)(self->private_impl.f_mcu_blocks_mx_mul[v_mcb])) * ((uint64_t)(a_mx))) + (((uint64_t)(self->private_impl.f_mcu_blocks_my_mul[v_mcb])) * ((uint64_t)(a_my))));
|
||||
if (v_offset <= ((uint64_t)(a_workbuf.len))) {
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__slice_u8__subslice_i(a_workbuf, v_offset), v_stride, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
}
|
||||
} else if (self->private_impl.f_num_components == 1u) {
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__make_slice_u8(self->private_data.f_swizzle_immediately_buffer, 64), 8u, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
self->private_impl.f_swizzle_immediately_status = wuffs_jpeg__decoder__swizzle_gray(self,
|
||||
a_dst,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_swizzle_immediately_buffer, 64),
|
||||
((a_mx + 0u) * 8u),
|
||||
((a_mx + 1u) * 8u),
|
||||
((a_my + 0u) * 8u),
|
||||
((a_my + 1u) * 8u),
|
||||
8u);
|
||||
if ( ! wuffs_base__status__is_ok(&self->private_impl.f_swizzle_immediately_status)) {
|
||||
v_ret = 3u;
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
v_csel = self->private_impl.f_scan_comps_cselector[self->private_impl.f_mcu_blocks_sselector[v_mcb]];
|
||||
v_stride = (8u * ((uint64_t)(self->private_impl.f_components_h[v_csel])));
|
||||
wuffs_jpeg__decoder__decode_idct(self, wuffs_base__make_slice_u8_ij(self->private_data.f_swizzle_immediately_buffer, self->private_impl.f_swizzle_immediately_b_offsets[v_mcb], 640), v_stride, ((uint32_t)(self->private_impl.f_components_tq[v_csel])));
|
||||
if (self->private_impl.f_mcu_current_block < self->private_impl.f_mcu_num_blocks) {
|
||||
continue;
|
||||
}
|
||||
self->private_impl.f_swizzle_immediately_status = wuffs_jpeg__decoder__swizzle_colorful(self,
|
||||
a_dst,
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
((a_mx + 0u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_h))),
|
||||
((a_mx + 1u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_h))),
|
||||
((a_my + 0u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_v))),
|
||||
((a_my + 1u) * 8u * ((uint32_t)(self->private_impl.f_max_incl_components_v))));
|
||||
if ( ! wuffs_base__status__is_ok(&self->private_impl.f_swizzle_immediately_status)) {
|
||||
v_ret = 3u;
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_mcu_current_block = 0u;
|
||||
@@ -49755,6 +50586,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -49922,6 +50754,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_ac_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -50183,6 +51016,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_high_bits(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -50323,6 +51157,7 @@ WUFFS_BASE__GENERATED_C_CODE
|
||||
static uint32_t
|
||||
wuffs_jpeg__decoder__decode_mcu_progressive_dc_low_bit(
|
||||
wuffs_jpeg__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
uint32_t a_mx,
|
||||
uint32_t a_my) {
|
||||
@@ -50771,7 +51606,7 @@ wuffs_json__decoder__initialize(
|
||||
wuffs_json__decoder*
|
||||
wuffs_json__decoder__alloc(void) {
|
||||
wuffs_json__decoder* x =
|
||||
(wuffs_json__decoder*)(calloc(sizeof(wuffs_json__decoder), 1));
|
||||
(wuffs_json__decoder*)(calloc(1, sizeof(wuffs_json__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -52829,7 +53664,7 @@ wuffs_lzma__decoder__initialize(
|
||||
wuffs_lzma__decoder*
|
||||
wuffs_lzma__decoder__alloc(void) {
|
||||
wuffs_lzma__decoder* x =
|
||||
(wuffs_lzma__decoder*)(calloc(sizeof(wuffs_lzma__decoder), 1));
|
||||
(wuffs_lzma__decoder*)(calloc(1, sizeof(wuffs_lzma__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -56020,7 +56855,7 @@ wuffs_lzip__decoder__initialize(
|
||||
wuffs_lzip__decoder*
|
||||
wuffs_lzip__decoder__alloc(void) {
|
||||
wuffs_lzip__decoder* x =
|
||||
(wuffs_lzip__decoder*)(calloc(sizeof(wuffs_lzip__decoder), 1));
|
||||
(wuffs_lzip__decoder*)(calloc(1, sizeof(wuffs_lzip__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -56569,7 +57404,7 @@ wuffs_lzw__decoder__initialize(
|
||||
wuffs_lzw__decoder*
|
||||
wuffs_lzw__decoder__alloc(void) {
|
||||
wuffs_lzw__decoder* x =
|
||||
(wuffs_lzw__decoder*)(calloc(sizeof(wuffs_lzw__decoder), 1));
|
||||
(wuffs_lzw__decoder*)(calloc(1, sizeof(wuffs_lzw__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -57185,7 +58020,7 @@ wuffs_netpbm__decoder__initialize(
|
||||
wuffs_netpbm__decoder*
|
||||
wuffs_netpbm__decoder__alloc(void) {
|
||||
wuffs_netpbm__decoder* x =
|
||||
(wuffs_netpbm__decoder*)(calloc(sizeof(wuffs_netpbm__decoder), 1));
|
||||
(wuffs_netpbm__decoder*)(calloc(1, sizeof(wuffs_netpbm__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -58325,7 +59160,7 @@ wuffs_nie__decoder__initialize(
|
||||
wuffs_nie__decoder*
|
||||
wuffs_nie__decoder__alloc(void) {
|
||||
wuffs_nie__decoder* x =
|
||||
(wuffs_nie__decoder*)(calloc(sizeof(wuffs_nie__decoder), 1));
|
||||
(wuffs_nie__decoder*)(calloc(1, sizeof(wuffs_nie__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -59369,7 +60204,7 @@ wuffs_zlib__decoder__initialize(
|
||||
wuffs_zlib__decoder*
|
||||
wuffs_zlib__decoder__alloc(void) {
|
||||
wuffs_zlib__decoder* x =
|
||||
(wuffs_zlib__decoder*)(calloc(sizeof(wuffs_zlib__decoder), 1));
|
||||
(wuffs_zlib__decoder*)(calloc(1, sizeof(wuffs_zlib__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -60337,7 +61172,7 @@ wuffs_png__decoder__initialize(
|
||||
wuffs_png__decoder*
|
||||
wuffs_png__decoder__alloc(void) {
|
||||
wuffs_png__decoder* x =
|
||||
(wuffs_png__decoder*)(calloc(sizeof(wuffs_png__decoder), 1));
|
||||
(wuffs_png__decoder*)(calloc(1, sizeof(wuffs_png__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -66347,6 +67182,1282 @@ wuffs_png__decoder__filter_and_swizzle_tricky(
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI)
|
||||
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_qoi__error__bad_footer[] = "#qoi: bad footer";
|
||||
const char wuffs_qoi__error__bad_header[] = "#qoi: bad header";
|
||||
const char wuffs_qoi__error__truncated_input[] = "#qoi: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
// ---------------- Private Initializer Prototypes
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_src_to_buffer(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_buffer_to_dst(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__image_decoder__func_ptrs
|
||||
wuffs_qoi__decoder__func_ptrs_for__wuffs_base__image_decoder = {
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__pixel_buffer*,
|
||||
wuffs_base__io_buffer*,
|
||||
wuffs_base__pixel_blend,
|
||||
wuffs_base__slice_u8,
|
||||
wuffs_base__decode_frame_options*))(&wuffs_qoi__decoder__decode_frame),
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__frame_config*,
|
||||
wuffs_base__io_buffer*))(&wuffs_qoi__decoder__decode_frame_config),
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__image_config*,
|
||||
wuffs_base__io_buffer*))(&wuffs_qoi__decoder__decode_image_config),
|
||||
(wuffs_base__rect_ie_u32(*)(const void*))(&wuffs_qoi__decoder__frame_dirty_rect),
|
||||
(uint64_t(*)(const void*,
|
||||
uint32_t))(&wuffs_qoi__decoder__get_quirk),
|
||||
(uint32_t(*)(const void*))(&wuffs_qoi__decoder__num_animation_loops),
|
||||
(uint64_t(*)(const void*))(&wuffs_qoi__decoder__num_decoded_frame_configs),
|
||||
(uint64_t(*)(const void*))(&wuffs_qoi__decoder__num_decoded_frames),
|
||||
(wuffs_base__status(*)(void*,
|
||||
uint64_t,
|
||||
uint64_t))(&wuffs_qoi__decoder__restart_frame),
|
||||
(wuffs_base__status(*)(void*,
|
||||
uint32_t,
|
||||
uint64_t))(&wuffs_qoi__decoder__set_quirk),
|
||||
(wuffs_base__empty_struct(*)(void*,
|
||||
uint32_t,
|
||||
bool))(&wuffs_qoi__decoder__set_report_metadata),
|
||||
(wuffs_base__status(*)(void*,
|
||||
wuffs_base__io_buffer*,
|
||||
wuffs_base__more_information*,
|
||||
wuffs_base__io_buffer*))(&wuffs_qoi__decoder__tell_me_more),
|
||||
(wuffs_base__range_ii_u64(*)(const void*))(&wuffs_qoi__decoder__workbuf_len),
|
||||
};
|
||||
|
||||
// ---------------- Initializer Implementations
|
||||
|
||||
wuffs_base__status WUFFS_BASE__WARN_UNUSED_RESULT
|
||||
wuffs_qoi__decoder__initialize(
|
||||
wuffs_qoi__decoder* self,
|
||||
size_t sizeof_star_self,
|
||||
uint64_t wuffs_version,
|
||||
uint32_t options){
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (sizeof(*self) != sizeof_star_self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_sizeof_receiver);
|
||||
}
|
||||
if (((wuffs_version >> 32) != WUFFS_VERSION_MAJOR) ||
|
||||
(((wuffs_version >> 16) & 0xFFFF) > WUFFS_VERSION_MINOR)) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_wuffs_version);
|
||||
}
|
||||
|
||||
if ((options & WUFFS_INITIALIZE__ALREADY_ZEROED) != 0) {
|
||||
// The whole point of this if-check is to detect an uninitialized *self.
|
||||
// We disable the warning on GCC. Clang-5.0 does not have this warning.
|
||||
#if !defined(__clang__) && defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
if (self->private_impl.magic != 0) {
|
||||
return wuffs_base__make_status(wuffs_base__error__initialize_falsely_claimed_already_zeroed);
|
||||
}
|
||||
#if !defined(__clang__) && defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} else {
|
||||
if ((options & WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED) == 0) {
|
||||
memset(self, 0, sizeof(*self));
|
||||
options |= WUFFS_INITIALIZE__ALREADY_ZEROED;
|
||||
} else {
|
||||
memset(&(self->private_impl), 0, sizeof(self->private_impl));
|
||||
}
|
||||
}
|
||||
|
||||
self->private_impl.magic = WUFFS_BASE__MAGIC;
|
||||
self->private_impl.vtable_for__wuffs_base__image_decoder.vtable_name =
|
||||
wuffs_base__image_decoder__vtable_name;
|
||||
self->private_impl.vtable_for__wuffs_base__image_decoder.function_pointers =
|
||||
(const void*)(&wuffs_qoi__decoder__func_ptrs_for__wuffs_base__image_decoder);
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
wuffs_qoi__decoder*
|
||||
wuffs_qoi__decoder__alloc(void) {
|
||||
wuffs_qoi__decoder* x =
|
||||
(wuffs_qoi__decoder*)(calloc(1, sizeof(wuffs_qoi__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
if (wuffs_qoi__decoder__initialize(
|
||||
x, sizeof(wuffs_qoi__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__ALREADY_ZEROED).repr) {
|
||||
free(x);
|
||||
return NULL;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
size_t
|
||||
sizeof__wuffs_qoi__decoder(void) {
|
||||
return sizeof(wuffs_qoi__decoder);
|
||||
}
|
||||
|
||||
// ---------------- Function Implementations
|
||||
|
||||
// -------- func qoi.decoder.get_quirk
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__get_quirk(
|
||||
const wuffs_qoi__decoder* self,
|
||||
uint32_t a_key) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.set_quirk
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__set_quirk(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_key,
|
||||
uint64_t a_value) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.decode_image_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 1)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_qoi__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.do_decode_image_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_image_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_a = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence != 0u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
uint32_t t_0;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_do_decode_image_config.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config.scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << num_bits_0;
|
||||
if (num_bits_0 == 24) {
|
||||
t_0 = ((uint32_t)(*scratch));
|
||||
break;
|
||||
}
|
||||
num_bits_0 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_0)) << 56;
|
||||
}
|
||||
}
|
||||
v_a = t_0;
|
||||
}
|
||||
if (v_a != 1718185841u) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__bad_header);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
uint32_t t_1;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_do_decode_image_config.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config.scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFFu));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_1);
|
||||
if (num_bits_1 == 24) {
|
||||
t_1 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_1 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_1));
|
||||
}
|
||||
}
|
||||
v_a = t_1;
|
||||
}
|
||||
if (v_a > 16777215u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__unsupported_image_dimension);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_width = v_a;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
uint32_t t_2;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_2 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_do_decode_image_config.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config.scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch & 0xFFu));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_2);
|
||||
if (num_bits_2 == 24) {
|
||||
t_2 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_2 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_2));
|
||||
}
|
||||
}
|
||||
v_a = t_2;
|
||||
}
|
||||
if (v_a > 16777215u) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__unsupported_image_dimension);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_height = v_a;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint32_t t_3 = *iop_a_src++;
|
||||
v_a = t_3;
|
||||
}
|
||||
if (v_a == 3u) {
|
||||
self->private_impl.f_pixfmt = 2415954056u;
|
||||
} else if (v_a == 4u) {
|
||||
self->private_impl.f_pixfmt = 2164295816u;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__bad_header);
|
||||
goto exit;
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
iop_a_src++;
|
||||
if (a_dst != NULL) {
|
||||
wuffs_base__image_config__set(
|
||||
a_dst,
|
||||
self->private_impl.f_pixfmt,
|
||||
0u,
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height,
|
||||
14u,
|
||||
(self->private_impl.f_pixfmt == 2415954056u));
|
||||
}
|
||||
self->private_impl.f_call_sequence = 32u;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_do_decode_image_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_do_decode_image_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.decode_frame_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 2)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_qoi__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.do_decode_frame_config
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame_config(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 32u) {
|
||||
} else if (self->private_impl.f_call_sequence < 32u) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_qoi__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
} else if (self->private_impl.f_call_sequence == 40u) {
|
||||
if (16u != wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_restart);
|
||||
goto exit;
|
||||
}
|
||||
} else if (self->private_impl.f_call_sequence == 64u) {
|
||||
self->private_impl.f_call_sequence = 96u;
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
}
|
||||
if (a_dst != NULL) {
|
||||
wuffs_base__frame_config__set(
|
||||
a_dst,
|
||||
wuffs_base__utility__make_rect_ie_u32(
|
||||
0u,
|
||||
0u,
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height),
|
||||
((wuffs_base__flicks)(0u)),
|
||||
0u,
|
||||
14u,
|
||||
0u,
|
||||
(self->private_impl.f_pixfmt == 2415954056u),
|
||||
false,
|
||||
0u);
|
||||
}
|
||||
self->private_impl.f_call_sequence = 64u;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_do_decode_frame_config = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_do_decode_frame_config = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.decode_frame
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_dst || !a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 3)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_qoi__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.do_decode_frame
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__do_decode_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint64_t v_c64 = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame;
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 64u) {
|
||||
} else if (self->private_impl.f_call_sequence < 64u) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_qoi__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
}
|
||||
v_status = wuffs_base__pixel_swizzler__prepare(&self->private_impl.f_swizzler,
|
||||
wuffs_base__pixel_buffer__pixel_format(a_dst),
|
||||
wuffs_base__pixel_buffer__palette(a_dst),
|
||||
wuffs_base__utility__make_pixel_format(self->private_impl.f_pixfmt),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
a_blend);
|
||||
if ( ! wuffs_base__status__is_ok(&v_status)) {
|
||||
status = v_status;
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
goto exit;
|
||||
} else if (wuffs_base__status__is_suspension(&status)) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension);
|
||||
goto exit;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
self->private_impl.f_dst_x = 0u;
|
||||
self->private_impl.f_dst_y = 0u;
|
||||
self->private_data.f_pixel[0u] = 0u;
|
||||
self->private_data.f_pixel[1u] = 0u;
|
||||
self->private_data.f_pixel[2u] = 0u;
|
||||
self->private_data.f_pixel[3u] = 255u;
|
||||
wuffs_private_impl__bulk_memset(&self->private_data.f_cache[0], 256u, 0u);
|
||||
self->private_impl.f_remaining_pixels_times_4 = (((uint64_t)(self->private_impl.f_width)) * ((uint64_t)(self->private_impl.f_height)) * 4u);
|
||||
while (self->private_impl.f_remaining_pixels_times_4 > 0u) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
status = wuffs_qoi__decoder__from_src_to_buffer(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
if (self->private_impl.f_remaining_pixels_times_4 < ((uint64_t)(self->private_impl.f_buffer_index))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__too_much_data);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_remaining_pixels_times_4 -= ((uint64_t)(self->private_impl.f_buffer_index));
|
||||
v_status = wuffs_qoi__decoder__from_buffer_to_dst(self, a_dst);
|
||||
if ( ! wuffs_base__status__is_ok(&v_status)) {
|
||||
status = v_status;
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
goto exit;
|
||||
} else if (wuffs_base__status__is_suspension(&status)) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__cannot_return_a_suspension);
|
||||
goto exit;
|
||||
}
|
||||
goto ok;
|
||||
}
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
uint64_t t_0;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 8)) {
|
||||
t_0 = wuffs_base__peek_u64be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 8;
|
||||
} else {
|
||||
self->private_data.s_do_decode_frame.scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame.scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFFu));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_0);
|
||||
if (num_bits_0 == 56) {
|
||||
t_0 = ((uint64_t)(*scratch >> 0));
|
||||
break;
|
||||
}
|
||||
num_bits_0 += 8u;
|
||||
*scratch |= ((uint64_t)(num_bits_0));
|
||||
}
|
||||
}
|
||||
v_c64 = t_0;
|
||||
}
|
||||
if (v_c64 != 1u) {
|
||||
status = wuffs_base__make_status(wuffs_qoi__error__bad_footer);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_call_sequence = 96u;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_do_decode_frame = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_do_decode_frame = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.from_src_to_buffer
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_src_to_buffer(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c8 = 0;
|
||||
uint8_t v_dg = 0;
|
||||
uint32_t v_bi = 0;
|
||||
uint32_t v_bj = 0;
|
||||
uint32_t v_bk = 0;
|
||||
uint32_t v_ci = 0;
|
||||
uint32_t v_hash4 = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_from_src_to_buffer;
|
||||
if (coro_susp_point) {
|
||||
v_dg = self->private_data.s_from_src_to_buffer.v_dg;
|
||||
v_bi = self->private_data.s_from_src_to_buffer.v_bi;
|
||||
v_bk = self->private_data.s_from_src_to_buffer.v_bk;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
v_bk = 7936u;
|
||||
if (self->private_impl.f_remaining_pixels_times_4 < 7936u) {
|
||||
v_bk = ((uint32_t)(self->private_impl.f_remaining_pixels_times_4));
|
||||
}
|
||||
while (v_bi < v_bk) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_0 = *iop_a_src++;
|
||||
v_c8 = t_0;
|
||||
}
|
||||
if (v_c8 == 254u) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_1 = *iop_a_src++;
|
||||
self->private_data.f_pixel[2u] = t_1;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_2 = *iop_a_src++;
|
||||
self->private_data.f_pixel[1u] = t_2;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_3 = *iop_a_src++;
|
||||
self->private_data.f_pixel[0u] = t_3;
|
||||
}
|
||||
} else if (v_c8 == 255u) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_4 = *iop_a_src++;
|
||||
self->private_data.f_pixel[2u] = t_4;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_5 = *iop_a_src++;
|
||||
self->private_data.f_pixel[1u] = t_5;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_6 = *iop_a_src++;
|
||||
self->private_data.f_pixel[0u] = t_6;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_7 = *iop_a_src++;
|
||||
self->private_data.f_pixel[3u] = t_7;
|
||||
}
|
||||
} else if (((uint8_t)(v_c8 >> 6u)) == 0u) {
|
||||
v_ci = (4u * ((uint32_t)(((uint8_t)(v_c8 & 63u)))));
|
||||
self->private_data.f_pixel[0u] = self->private_data.f_cache[(v_ci + 0u)];
|
||||
self->private_data.f_pixel[1u] = self->private_data.f_cache[(v_ci + 1u)];
|
||||
self->private_data.f_pixel[2u] = self->private_data.f_cache[(v_ci + 2u)];
|
||||
self->private_data.f_pixel[3u] = self->private_data.f_cache[(v_ci + 3u)];
|
||||
self->private_data.f_buffer[(v_bi + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_buffer[(v_bi + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_buffer[(v_bi + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_buffer[(v_bi + 3u)] = self->private_data.f_pixel[3u];
|
||||
v_bi += 4u;
|
||||
continue;
|
||||
} else if (((uint8_t)(v_c8 >> 6u)) == 1u) {
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
self->private_data.f_pixel[2u] += ((uint8_t)(((uint8_t)(((uint8_t)(v_c8 >> 4u)) & 3u)) + 254u));
|
||||
self->private_data.f_pixel[1u] += ((uint8_t)(((uint8_t)(((uint8_t)(v_c8 >> 2u)) & 3u)) + 254u));
|
||||
self->private_data.f_pixel[0u] += ((uint8_t)(((uint8_t)(((uint8_t)(v_c8 >> 0u)) & 3u)) + 254u));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} else if (((uint8_t)(v_c8 >> 6u)) == 2u) {
|
||||
v_dg = ((uint8_t)(((uint8_t)(v_c8 & 63u)) + 224u));
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_8 = *iop_a_src++;
|
||||
v_c8 = t_8;
|
||||
}
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
self->private_data.f_pixel[2u] += ((uint8_t)(((uint8_t)(v_dg + 248u)) + ((uint8_t)(15u & ((uint8_t)(v_c8 >> 4u))))));
|
||||
self->private_data.f_pixel[1u] += v_dg;
|
||||
self->private_data.f_pixel[0u] += ((uint8_t)(((uint8_t)(v_dg + 248u)) + ((uint8_t)(15u & ((uint8_t)(v_c8 >> 0u))))));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
} else {
|
||||
v_bj = (v_bi + (4u * (63u & (1u + ((uint32_t)(v_c8))))));
|
||||
while (v_bi < v_bj) {
|
||||
self->private_data.f_buffer[(v_bi + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_buffer[(v_bi + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_buffer[(v_bi + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_buffer[(v_bi + 3u)] = self->private_data.f_pixel[3u];
|
||||
v_bi += 4u;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
v_hash4 = (4u * (63u & ((((uint32_t)(self->private_data.f_pixel[2u])) * 3u) +
|
||||
(((uint32_t)(self->private_data.f_pixel[1u])) * 5u) +
|
||||
(((uint32_t)(self->private_data.f_pixel[0u])) * 7u) +
|
||||
(((uint32_t)(self->private_data.f_pixel[3u])) * 11u))));
|
||||
self->private_data.f_cache[(v_hash4 + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_cache[(v_hash4 + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_cache[(v_hash4 + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_cache[(v_hash4 + 3u)] = self->private_data.f_pixel[3u];
|
||||
self->private_data.f_buffer[(v_bi + 0u)] = self->private_data.f_pixel[0u];
|
||||
self->private_data.f_buffer[(v_bi + 1u)] = self->private_data.f_pixel[1u];
|
||||
self->private_data.f_buffer[(v_bi + 2u)] = self->private_data.f_pixel[2u];
|
||||
self->private_data.f_buffer[(v_bi + 3u)] = self->private_data.f_pixel[3u];
|
||||
v_bi += 4u;
|
||||
}
|
||||
self->private_impl.f_buffer_index = v_bi;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_from_src_to_buffer = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_from_src_to_buffer = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_from_src_to_buffer.v_dg = v_dg;
|
||||
self->private_data.s_from_src_to_buffer.v_bi = v_bi;
|
||||
self->private_data.s_from_src_to_buffer.v_bk = v_bk;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.from_buffer_to_dst
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
static wuffs_base__status
|
||||
wuffs_qoi__decoder__from_buffer_to_dst(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst) {
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint32_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_row = 0;
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
uint32_t v_bi = 0;
|
||||
uint32_t v_rem_x = 0;
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
wuffs_base__slice_u8 v_src = {0};
|
||||
uint32_t v_src_length = 0;
|
||||
uint64_t v_i = 0;
|
||||
|
||||
v_dst_pixfmt = wuffs_base__pixel_buffer__pixel_format(a_dst);
|
||||
v_dst_bits_per_pixel = wuffs_base__pixel_format__bits_per_pixel(&v_dst_pixfmt);
|
||||
if ((v_dst_bits_per_pixel & 7u) != 0u) {
|
||||
return wuffs_base__make_status(wuffs_base__error__unsupported_option);
|
||||
}
|
||||
v_dst_bytes_per_pixel = (v_dst_bits_per_pixel / 8u);
|
||||
v_dst_bytes_per_row = ((uint64_t)((self->private_impl.f_width * v_dst_bytes_per_pixel)));
|
||||
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0u);
|
||||
while (v_bi < self->private_impl.f_buffer_index) {
|
||||
if (self->private_impl.f_width <= self->private_impl.f_dst_x) {
|
||||
self->private_impl.f_dst_x = 0u;
|
||||
self->private_impl.f_dst_y += 1u;
|
||||
if (self->private_impl.f_dst_y >= self->private_impl.f_height) {
|
||||
break;
|
||||
}
|
||||
v_rem_x = self->private_impl.f_width;
|
||||
} else {
|
||||
v_rem_x = (self->private_impl.f_width - self->private_impl.f_dst_x);
|
||||
}
|
||||
v_src = wuffs_base__make_slice_u8_ij(self->private_data.f_buffer, v_bi, self->private_impl.f_buffer_index);
|
||||
if (((uint64_t)((4u * v_rem_x))) < ((uint64_t)(v_src.len))) {
|
||||
v_src = wuffs_base__slice_u8__subslice_j(v_src, ((uint64_t)((4u * v_rem_x))));
|
||||
}
|
||||
v_src_length = ((uint32_t)(((uint64_t)(v_src.len))));
|
||||
v_bi += v_src_length;
|
||||
v_dst = wuffs_private_impl__table_u8__row_u32(v_tab, self->private_impl.f_dst_y);
|
||||
if (v_dst_bytes_per_row < ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_j(v_dst, v_dst_bytes_per_row);
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * ((uint64_t)(v_dst_bytes_per_pixel)));
|
||||
self->private_impl.f_dst_x += (v_src_length / 4u);
|
||||
if (v_i < ((uint64_t)(v_dst.len))) {
|
||||
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), wuffs_base__pixel_buffer__palette(a_dst), v_src);
|
||||
}
|
||||
}
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.frame_dirty_rect
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__rect_ie_u32
|
||||
wuffs_qoi__decoder__frame_dirty_rect(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return wuffs_base__utility__empty_rect_ie_u32();
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return wuffs_base__utility__empty_rect_ie_u32();
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_rect_ie_u32(
|
||||
0u,
|
||||
0u,
|
||||
self->private_impl.f_width,
|
||||
self->private_impl.f_height);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.num_animation_loops
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint32_t
|
||||
wuffs_qoi__decoder__num_animation_loops(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.num_decoded_frame_configs
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frame_configs(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self->private_impl.f_call_sequence > 32u) {
|
||||
return 1u;
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.num_decoded_frames
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC uint64_t
|
||||
wuffs_qoi__decoder__num_decoded_frames(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (self->private_impl.f_call_sequence > 64u) {
|
||||
return 1u;
|
||||
}
|
||||
return 0u;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.restart_frame
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__restart_frame(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint64_t a_index,
|
||||
uint64_t a_io_position) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
|
||||
if (self->private_impl.f_call_sequence < 32u) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
}
|
||||
if ((a_index != 0u) || (a_io_position != 14u)) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
self->private_impl.f_call_sequence = 40u;
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.set_report_metadata
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__empty_struct
|
||||
wuffs_qoi__decoder__set_report_metadata(
|
||||
wuffs_qoi__decoder* self,
|
||||
uint32_t a_fourcc,
|
||||
bool a_report) {
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.tell_me_more
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__status
|
||||
wuffs_qoi__decoder__tell_me_more(
|
||||
wuffs_qoi__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
if (!self) {
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_receiver);
|
||||
}
|
||||
if (self->private_impl.magic != WUFFS_BASE__MAGIC) {
|
||||
return wuffs_base__make_status(
|
||||
(self->private_impl.magic == WUFFS_BASE__DISABLED)
|
||||
? wuffs_base__error__disabled_by_previous_error
|
||||
: wuffs_base__error__initialize_not_called);
|
||||
}
|
||||
if (!a_dst || !a_src) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__bad_argument);
|
||||
}
|
||||
if ((self->private_impl.active_coroutine != 0) &&
|
||||
(self->private_impl.active_coroutine != 4)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
return wuffs_base__make_status(wuffs_base__error__interleaved_coroutine_calls);
|
||||
}
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
status = wuffs_base__make_status(wuffs_base__error__no_more_information);
|
||||
goto exit;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func qoi.decoder.workbuf_len
|
||||
|
||||
WUFFS_BASE__GENERATED_C_CODE
|
||||
WUFFS_BASE__MAYBE_STATIC wuffs_base__range_ii_u64
|
||||
wuffs_qoi__decoder__workbuf_len(
|
||||
const wuffs_qoi__decoder* self) {
|
||||
if (!self) {
|
||||
return wuffs_base__utility__empty_range_ii_u64();
|
||||
}
|
||||
if ((self->private_impl.magic != WUFFS_BASE__MAGIC) &&
|
||||
(self->private_impl.magic != WUFFS_BASE__DISABLED)) {
|
||||
return wuffs_base__utility__empty_range_ii_u64();
|
||||
}
|
||||
|
||||
return wuffs_base__utility__make_range_ii_u64(0u, 0u);
|
||||
}
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__SHA256)
|
||||
|
||||
// ---------------- Status Codes Implementations
|
||||
@@ -66448,7 +68559,7 @@ wuffs_sha256__hasher__initialize(
|
||||
wuffs_sha256__hasher*
|
||||
wuffs_sha256__hasher__alloc(void) {
|
||||
wuffs_sha256__hasher* x =
|
||||
(wuffs_sha256__hasher*)(calloc(sizeof(wuffs_sha256__hasher), 1));
|
||||
(wuffs_sha256__hasher*)(calloc(1, sizeof(wuffs_sha256__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -67081,7 +69192,7 @@ wuffs_tga__decoder__initialize(
|
||||
wuffs_tga__decoder*
|
||||
wuffs_tga__decoder__alloc(void) {
|
||||
wuffs_tga__decoder* x =
|
||||
(wuffs_tga__decoder*)(calloc(sizeof(wuffs_tga__decoder), 1));
|
||||
(wuffs_tga__decoder*)(calloc(1, sizeof(wuffs_tga__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -68450,7 +70561,7 @@ wuffs_vp8__placeholder__initialize(
|
||||
wuffs_vp8__placeholder*
|
||||
wuffs_vp8__placeholder__alloc(void) {
|
||||
wuffs_vp8__placeholder* x =
|
||||
(wuffs_vp8__placeholder*)(calloc(sizeof(wuffs_vp8__placeholder), 1));
|
||||
(wuffs_vp8__placeholder*)(calloc(1, sizeof(wuffs_vp8__placeholder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -68598,7 +70709,7 @@ wuffs_wbmp__decoder__initialize(
|
||||
wuffs_wbmp__decoder*
|
||||
wuffs_wbmp__decoder__alloc(void) {
|
||||
wuffs_wbmp__decoder* x =
|
||||
(wuffs_wbmp__decoder*)(calloc(sizeof(wuffs_wbmp__decoder), 1));
|
||||
(wuffs_wbmp__decoder*)(calloc(1, sizeof(wuffs_wbmp__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -69437,42 +71548,6 @@ WUFFS_WEBP__HUFFMAN_TABLE_BASE_OFFSETS[5] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
1612u, 0u, 511u, 1022u, 1533u,
|
||||
};
|
||||
|
||||
static const uint32_t
|
||||
WUFFS_WEBP__SIGN_EXTEND_I8_I32[256] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
0u, 1u, 2u, 3u, 4u, 5u, 6u, 7u,
|
||||
8u, 9u, 10u, 11u, 12u, 13u, 14u, 15u,
|
||||
16u, 17u, 18u, 19u, 20u, 21u, 22u, 23u,
|
||||
24u, 25u, 26u, 27u, 28u, 29u, 30u, 31u,
|
||||
32u, 33u, 34u, 35u, 36u, 37u, 38u, 39u,
|
||||
40u, 41u, 42u, 43u, 44u, 45u, 46u, 47u,
|
||||
48u, 49u, 50u, 51u, 52u, 53u, 54u, 55u,
|
||||
56u, 57u, 58u, 59u, 60u, 61u, 62u, 63u,
|
||||
64u, 65u, 66u, 67u, 68u, 69u, 70u, 71u,
|
||||
72u, 73u, 74u, 75u, 76u, 77u, 78u, 79u,
|
||||
80u, 81u, 82u, 83u, 84u, 85u, 86u, 87u,
|
||||
88u, 89u, 90u, 91u, 92u, 93u, 94u, 95u,
|
||||
96u, 97u, 98u, 99u, 100u, 101u, 102u, 103u,
|
||||
104u, 105u, 106u, 107u, 108u, 109u, 110u, 111u,
|
||||
112u, 113u, 114u, 115u, 116u, 117u, 118u, 119u,
|
||||
120u, 121u, 122u, 123u, 124u, 125u, 126u, 127u,
|
||||
4294967168u, 4294967169u, 4294967170u, 4294967171u, 4294967172u, 4294967173u, 4294967174u, 4294967175u,
|
||||
4294967176u, 4294967177u, 4294967178u, 4294967179u, 4294967180u, 4294967181u, 4294967182u, 4294967183u,
|
||||
4294967184u, 4294967185u, 4294967186u, 4294967187u, 4294967188u, 4294967189u, 4294967190u, 4294967191u,
|
||||
4294967192u, 4294967193u, 4294967194u, 4294967195u, 4294967196u, 4294967197u, 4294967198u, 4294967199u,
|
||||
4294967200u, 4294967201u, 4294967202u, 4294967203u, 4294967204u, 4294967205u, 4294967206u, 4294967207u,
|
||||
4294967208u, 4294967209u, 4294967210u, 4294967211u, 4294967212u, 4294967213u, 4294967214u, 4294967215u,
|
||||
4294967216u, 4294967217u, 4294967218u, 4294967219u, 4294967220u, 4294967221u, 4294967222u, 4294967223u,
|
||||
4294967224u, 4294967225u, 4294967226u, 4294967227u, 4294967228u, 4294967229u, 4294967230u, 4294967231u,
|
||||
4294967232u, 4294967233u, 4294967234u, 4294967235u, 4294967236u, 4294967237u, 4294967238u, 4294967239u,
|
||||
4294967240u, 4294967241u, 4294967242u, 4294967243u, 4294967244u, 4294967245u, 4294967246u, 4294967247u,
|
||||
4294967248u, 4294967249u, 4294967250u, 4294967251u, 4294967252u, 4294967253u, 4294967254u, 4294967255u,
|
||||
4294967256u, 4294967257u, 4294967258u, 4294967259u, 4294967260u, 4294967261u, 4294967262u, 4294967263u,
|
||||
4294967264u, 4294967265u, 4294967266u, 4294967267u, 4294967268u, 4294967269u, 4294967270u, 4294967271u,
|
||||
4294967272u, 4294967273u, 4294967274u, 4294967275u, 4294967276u, 4294967277u, 4294967278u, 4294967279u,
|
||||
4294967280u, 4294967281u, 4294967282u, 4294967283u, 4294967284u, 4294967285u, 4294967286u, 4294967287u,
|
||||
4294967288u, 4294967289u, 4294967290u, 4294967291u, 4294967292u, 4294967293u, 4294967294u, 4294967295u,
|
||||
};
|
||||
|
||||
static const uint8_t
|
||||
WUFFS_WEBP__DISTANCE_MAP[120] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
24u, 7u, 23u, 25u, 40u, 6u, 39u, 41u,
|
||||
@@ -69769,7 +71844,7 @@ wuffs_webp__decoder__initialize(
|
||||
wuffs_webp__decoder*
|
||||
wuffs_webp__decoder__alloc(void) {
|
||||
wuffs_webp__decoder* x =
|
||||
(wuffs_webp__decoder*)(calloc(sizeof(wuffs_webp__decoder), 1));
|
||||
(wuffs_webp__decoder*)(calloc(1, sizeof(wuffs_webp__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -71023,29 +73098,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_curr_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_curr_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_curr_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_curr_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71077,29 +73131,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[0u] += v_prev_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[1u] += v_prev_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[2u] += v_prev_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[3u] += v_prev_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71129,29 +73162,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_curr_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_curr_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_curr_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_curr_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71162,29 +73174,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_prev_row.ptr[4u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_prev_row.ptr[5u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_prev_row.ptr[6u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_prev_row.ptr[7u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71195,29 +73186,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_prev_row.ptr[8u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_prev_row.ptr[9u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_prev_row.ptr[10u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_prev_row.ptr[11u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71228,29 +73198,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += v_prev_row.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += v_prev_row.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += v_prev_row.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += v_prev_row.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71265,29 +73214,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((v_l0 + ((uint32_t)(v_prev_row.ptr[4u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((v_l1 + ((uint32_t)(v_prev_row.ptr[5u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((v_l2 + ((uint32_t)(v_prev_row.ptr[6u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((v_l3 + ((uint32_t)(v_prev_row.ptr[7u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71298,29 +73226,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[0u])) + ((uint32_t)(v_prev_row.ptr[0u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[1u])) + ((uint32_t)(v_prev_row.ptr[1u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[2u])) + ((uint32_t)(v_prev_row.ptr[2u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[3u])) + ((uint32_t)(v_prev_row.ptr[3u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71331,29 +73238,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[0u])) + ((uint32_t)(v_prev_row.ptr[4u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[1u])) + ((uint32_t)(v_prev_row.ptr[5u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[2u])) + ((uint32_t)(v_prev_row.ptr[6u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_curr_row.ptr[3u])) + ((uint32_t)(v_prev_row.ptr[7u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71364,29 +73250,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[0u])) + ((uint32_t)(v_prev_row.ptr[4u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[1u])) + ((uint32_t)(v_prev_row.ptr[5u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[2u])) + ((uint32_t)(v_prev_row.ptr[6u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[3u])) + ((uint32_t)(v_prev_row.ptr[7u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71397,29 +73262,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[4u])) + ((uint32_t)(v_prev_row.ptr[8u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[5u])) + ((uint32_t)(v_prev_row.ptr[9u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[6u])) + ((uint32_t)(v_prev_row.ptr[10u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((((uint32_t)(v_prev_row.ptr[7u])) + ((uint32_t)(v_prev_row.ptr[11u]))) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71438,29 +73282,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(((v_l0 + v_t0) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(((v_l1 + v_t1) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(((v_l2 + v_t2) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(((v_l3 + v_t3) / 2u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71492,29 +73315,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(v_l0));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(v_l1));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(v_l2));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(v_l3));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71525,29 +73327,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += ((uint8_t)(v_t0));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += ((uint8_t)(v_t1));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += ((uint8_t)(v_t2));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += ((uint8_t)(v_t3));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71559,29 +73340,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[0u], v_prev_row.ptr[4u], v_prev_row.ptr[0u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[1u], v_prev_row.ptr[5u], v_prev_row.ptr[1u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[2u], v_prev_row.ptr[6u], v_prev_row.ptr[2u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += wuffs_webp__decoder__mode12(self, v_curr_row.ptr[3u], v_prev_row.ptr[7u], v_prev_row.ptr[3u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71592,29 +73352,8 @@ wuffs_webp__decoder__apply_transform_predictor(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[4u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[0u], v_prev_row.ptr[4u], v_prev_row.ptr[0u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[5u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[1u], v_prev_row.ptr[5u], v_prev_row.ptr[1u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[6u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[2u], v_prev_row.ptr[6u], v_prev_row.ptr[2u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_curr_row.ptr[7u] += wuffs_webp__decoder__mode13(self, v_curr_row.ptr[3u], v_prev_row.ptr[7u], v_prev_row.ptr[3u]);
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71724,9 +73463,9 @@ wuffs_webp__decoder__apply_transform_cross_color(
|
||||
v_x = 0u;
|
||||
while (v_x < self->private_impl.f_width) {
|
||||
if (((v_x & v_mask) == 0u) && (((uint64_t)(v_tile_data.len)) >= 4u)) {
|
||||
v_g2r = WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_tile_data.ptr[0u]];
|
||||
v_g2b = WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_tile_data.ptr[1u]];
|
||||
v_r2b = WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_tile_data.ptr[2u]];
|
||||
v_g2r = wuffs_base__utility__sign_extend_convert_u8_u32(v_tile_data.ptr[0u]);
|
||||
v_g2b = wuffs_base__utility__sign_extend_convert_u8_u32(v_tile_data.ptr[1u]);
|
||||
v_r2b = wuffs_base__utility__sign_extend_convert_u8_u32(v_tile_data.ptr[2u]);
|
||||
v_tile_data = wuffs_base__slice_u8__subslice_i(v_tile_data, 4u);
|
||||
}
|
||||
if (((uint64_t)(a_pix.len)) >= 4u) {
|
||||
@@ -71737,23 +73476,9 @@ wuffs_webp__decoder__apply_transform_cross_color(
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_r += ((uint8_t)((((uint32_t)(WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_g] * v_g2r)) >> 5u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_b += ((uint8_t)((((uint32_t)(WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_g] * v_g2b)) >> 5u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_b += ((uint8_t)((((uint32_t)(WUFFS_WEBP__SIGN_EXTEND_I8_I32[v_r] * v_r2b)) >> 5u)));
|
||||
v_r += ((uint8_t)((((uint32_t)(wuffs_base__utility__sign_extend_convert_u8_u32(v_g) * v_g2r)) >> 5u)));
|
||||
v_b += ((uint8_t)((((uint32_t)(wuffs_base__utility__sign_extend_convert_u8_u32(v_g) * v_g2b)) >> 5u)));
|
||||
v_b += ((uint8_t)((((uint32_t)(wuffs_base__utility__sign_extend_convert_u8_u32(v_r) * v_r2b)) >> 5u)));
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
@@ -71790,13 +73515,6 @@ wuffs_webp__decoder__apply_transform_subtract_green(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[0u] += v_g;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[2u] += v_g;
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -71834,6 +73552,26 @@ wuffs_webp__decoder__apply_transform_color_indexing(
|
||||
|
||||
v_tile_size_log2 = ((uint32_t)(self->private_impl.f_transform_tile_size_log2[3u]));
|
||||
if (v_tile_size_log2 == 0u) {
|
||||
{
|
||||
wuffs_base__slice_u8 i_slice_dst = a_pix;
|
||||
v_dst.ptr = i_slice_dst.ptr;
|
||||
v_dst.len = 4;
|
||||
const uint8_t* i_end0_dst = wuffs_private_impl__ptr_u8_plus_len(v_dst.ptr, (((i_slice_dst.len - (size_t)(v_dst.ptr - i_slice_dst.ptr)) / 4) * 4));
|
||||
while (v_dst.ptr < i_end0_dst) {
|
||||
v_p = (((uint32_t)(v_dst.ptr[1u])) * 4u);
|
||||
v_p0 = self->private_data.f_palette[(v_p + 0u)];
|
||||
v_p1 = self->private_data.f_palette[(v_p + 1u)];
|
||||
v_p2 = self->private_data.f_palette[(v_p + 2u)];
|
||||
v_p3 = self->private_data.f_palette[(v_p + 3u)];
|
||||
v_dst.ptr[0u] = v_p0;
|
||||
v_dst.ptr[1u] = v_p1;
|
||||
v_dst.ptr[2u] = v_p2;
|
||||
v_dst.ptr[3u] = v_p3;
|
||||
v_dst.ptr += 4;
|
||||
}
|
||||
v_dst.len = 0;
|
||||
}
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
v_bits_per_pixel = (((uint32_t)(8u)) >> v_tile_size_log2);
|
||||
v_x_mask = ((((uint32_t)(1u)) << v_tile_size_log2) - 1u);
|
||||
@@ -72930,6 +74668,7 @@ wuffs_webp__decoder__decode_transform(
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint8_t v_c8 = 0;
|
||||
uint32_t v_transform_type = 0;
|
||||
uint32_t v_tile_size_log2 = 0;
|
||||
@@ -73028,28 +74767,34 @@ wuffs_webp__decoder__decode_transform(
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
status = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))),
|
||||
a_src,
|
||||
((self->private_impl.f_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
while (true) {
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 1u)])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[(v_transform_type + 2u)]))),
|
||||
a_src,
|
||||
((self->private_impl.f_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
v_status = t_2;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_status)) {
|
||||
break;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
} else if (v_transform_type == 2u) {
|
||||
} else {
|
||||
@@ -73060,8 +74805,8 @@ wuffs_webp__decoder__decode_transform(
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint8_t t_2 = *iop_a_src++;
|
||||
v_c8 = t_2;
|
||||
uint8_t t_3 = *iop_a_src++;
|
||||
v_c8 = t_3;
|
||||
}
|
||||
if (self->private_impl.f_n_bits >= 8u) {
|
||||
status = wuffs_base__make_status(wuffs_webp__error__internal_error_inconsistent_n_bits);
|
||||
@@ -73136,29 +74881,8 @@ wuffs_webp__decoder__decode_transform(
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[4u] += v_p.ptr[0u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[5u] += v_p.ptr[1u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[6u] += v_p.ptr[2u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
v_p.ptr[7u] += v_p.ptr[3u];
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -73167,7 +74891,6 @@ wuffs_webp__decoder__decode_transform(
|
||||
}
|
||||
}
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_transform = 0;
|
||||
goto exit;
|
||||
@@ -73291,6 +75014,7 @@ wuffs_webp__decoder__decode_hg_table(
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint8_t v_c8 = 0;
|
||||
uint32_t v_use_hg_table = 0;
|
||||
uint32_t v_tile_size_log2 = 0;
|
||||
@@ -73395,28 +75119,34 @@ wuffs_webp__decoder__decode_hg_table(
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
status = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))),
|
||||
a_src,
|
||||
((a_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
while (true) {
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_webp__decoder__decode_pixels(self,
|
||||
wuffs_base__slice_u8__subslice_ij(a_workbuf,
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])),
|
||||
((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))),
|
||||
a_src,
|
||||
((a_width + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
((self->private_impl.f_height + ((((uint32_t)(1u)) << v_tile_size_log2) - 1u)) >> v_tile_size_log2),
|
||||
wuffs_base__utility__empty_slice_u8(),
|
||||
0u);
|
||||
v_status = t_2;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_status)) {
|
||||
break;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
self->private_impl.f_overall_n_huffman_groups = 1u;
|
||||
if ((((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[0u])) > ((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u]))) || (((uint64_t)(self->private_impl.f_workbuf_offset_for_transform[1u])) > ((uint64_t)(a_workbuf.len)))) {
|
||||
@@ -73849,7 +75579,7 @@ wuffs_xxhash32__hasher__initialize(
|
||||
wuffs_xxhash32__hasher*
|
||||
wuffs_xxhash32__hasher__alloc(void) {
|
||||
wuffs_xxhash32__hasher* x =
|
||||
(wuffs_xxhash32__hasher*)(calloc(sizeof(wuffs_xxhash32__hasher), 1));
|
||||
(wuffs_xxhash32__hasher*)(calloc(1, sizeof(wuffs_xxhash32__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -74262,7 +75992,7 @@ wuffs_xxhash64__hasher__initialize(
|
||||
wuffs_xxhash64__hasher*
|
||||
wuffs_xxhash64__hasher__alloc(void) {
|
||||
wuffs_xxhash64__hasher* x =
|
||||
(wuffs_xxhash64__hasher*)(calloc(sizeof(wuffs_xxhash64__hasher), 1));
|
||||
(wuffs_xxhash64__hasher*)(calloc(1, sizeof(wuffs_xxhash64__hasher)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -74903,7 +76633,7 @@ wuffs_xz__decoder__initialize(
|
||||
wuffs_xz__decoder*
|
||||
wuffs_xz__decoder__alloc(void) {
|
||||
wuffs_xz__decoder* x =
|
||||
(wuffs_xz__decoder*)(calloc(sizeof(wuffs_xz__decoder), 1));
|
||||
(wuffs_xz__decoder*)(calloc(1, sizeof(wuffs_xz__decoder)));
|
||||
if (!x) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -77458,15 +79188,13 @@ DecodeCborCallbacks::Done(DecodeCborResult& result,
|
||||
sync_io::Input& input,
|
||||
IOBuffer& buffer) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeCborArgQuirks::DecodeCborArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeCborArgQuirks //
|
||||
DecodeCborArgQuirks::DefaultValue() {
|
||||
return DecodeCborArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeCborArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeCborResult //
|
||||
@@ -77495,8 +79223,8 @@ DecodeCbor(DecodeCborCallbacks& callbacks,
|
||||
ret_error_message = "wuffs_aux::DecodeCbor: out of memory";
|
||||
goto done;
|
||||
}
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
}
|
||||
|
||||
// Prepare the wuffs_base__tok_buffer. 256 tokens is 2KiB.
|
||||
@@ -77883,6 +79611,11 @@ DecodeImageCallbacks::SelectDecoder(uint32_t fourcc,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__QOI)
|
||||
case WUFFS_BASE__FOURCC__QOI:
|
||||
return wuffs_qoi__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA)
|
||||
case WUFFS_BASE__FOURCC__TGA:
|
||||
return wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
@@ -77927,7 +79660,7 @@ DecodeImageCallbacks::AllocPixbuf(const wuffs_base__image_config& image_config,
|
||||
return AllocPixbufResult(DecodeImage_UnsupportedPixelConfiguration);
|
||||
}
|
||||
void* ptr =
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc((size_t)len, 1);
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc(1, (size_t)len);
|
||||
if (!ptr) {
|
||||
return AllocPixbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
@@ -77952,7 +79685,7 @@ DecodeImageCallbacks::AllocWorkbuf(wuffs_base__range_ii_u64 len_range,
|
||||
return AllocWorkbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
void* ptr =
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc((size_t)len, 1);
|
||||
allow_uninitialized_memory ? malloc((size_t)len) : calloc(1, (size_t)len);
|
||||
if (!ptr) {
|
||||
return AllocWorkbufResult(DecodeImage_OutOfMemory);
|
||||
}
|
||||
@@ -77989,15 +79722,13 @@ const char DecodeImage_UnsupportedPixelConfiguration[] = //
|
||||
const char DecodeImage_UnsupportedPixelFormat[] = //
|
||||
"wuffs_aux::DecodeImage: unsupported pixel format";
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeImageArgQuirks::DecodeImageArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeImageArgQuirks //
|
||||
DecodeImageArgQuirks::DefaultValue() {
|
||||
return DecodeImageArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeImageArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeImageArgFlags::DecodeImageArgFlags(uint64_t repr0) : repr(repr0) {}
|
||||
@@ -78095,7 +79826,8 @@ DecodeImage0(wuffs_base__image_decoder::unique_ptr& image_decoder,
|
||||
DecodeImageCallbacks& callbacks,
|
||||
sync_io::Input& input,
|
||||
wuffs_base__io_buffer& io_buf,
|
||||
wuffs_base__slice_u32 quirks,
|
||||
const QuirkKeyValuePair* quirks_ptr,
|
||||
const size_t quirks_len,
|
||||
uint64_t flags,
|
||||
wuffs_base__pixel_blend pixel_blend,
|
||||
wuffs_base__color_u32_argb_premul background_color,
|
||||
@@ -78178,8 +79910,8 @@ redirect:
|
||||
}
|
||||
|
||||
// Apply quirks.
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
image_decoder->set_quirk(quirks.ptr[i], 1);
|
||||
for (size_t i = 0; i < quirks_len; i++) {
|
||||
image_decoder->set_quirk(quirks_ptr[i].first, quirks_ptr[i].second);
|
||||
}
|
||||
|
||||
// Apply flags.
|
||||
@@ -78406,10 +80138,10 @@ DecodeImage(DecodeImageCallbacks& callbacks,
|
||||
}
|
||||
|
||||
wuffs_base__image_decoder::unique_ptr image_decoder(nullptr);
|
||||
DecodeImageResult result =
|
||||
DecodeImage0(image_decoder, callbacks, input, *io_buf, quirks.repr,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
DecodeImageResult result = DecodeImage0(
|
||||
image_decoder, callbacks, input, *io_buf, quirks.ptr, quirks.len,
|
||||
flags.repr, pixel_blend.repr, background_color.repr,
|
||||
max_incl_dimension.repr, max_incl_metadata_length.repr);
|
||||
callbacks.Done(result, input, *io_buf, std::move(image_decoder));
|
||||
return result;
|
||||
}
|
||||
@@ -78444,15 +80176,13 @@ const char DecodeJson_BadJsonPointer[] = //
|
||||
const char DecodeJson_NoMatch[] = //
|
||||
"wuffs_aux::DecodeJson: no match";
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(wuffs_base__slice_u32 repr0)
|
||||
: repr(repr0) {}
|
||||
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(uint32_t* ptr0, size_t len0)
|
||||
: repr(wuffs_base__make_slice_u32(ptr0, len0)) {}
|
||||
DecodeJsonArgQuirks::DecodeJsonArgQuirks(const QuirkKeyValuePair* ptr0,
|
||||
const size_t len0)
|
||||
: ptr(ptr0), len(len0) {}
|
||||
|
||||
DecodeJsonArgQuirks //
|
||||
DecodeJsonArgQuirks::DefaultValue() {
|
||||
return DecodeJsonArgQuirks(wuffs_base__empty_slice_u32());
|
||||
return DecodeJsonArgQuirks(nullptr, 0);
|
||||
}
|
||||
|
||||
DecodeJsonArgJsonPointer::DecodeJsonArgJsonPointer(std::string repr0)
|
||||
@@ -78797,11 +80527,11 @@ DecodeJson(DecodeJsonCallbacks& callbacks,
|
||||
goto done;
|
||||
}
|
||||
bool allow_tilde_n_tilde_r_tilde_t = false;
|
||||
for (size_t i = 0; i < quirks.repr.len; i++) {
|
||||
dec->set_quirk(quirks.repr.ptr[i], 1);
|
||||
if (quirks.repr.ptr[i] ==
|
||||
for (size_t i = 0; i < quirks.len; i++) {
|
||||
dec->set_quirk(quirks.ptr[i].first, quirks.ptr[i].second);
|
||||
if (quirks.ptr[i].first ==
|
||||
WUFFS_JSON__QUIRK_JSON_POINTER_ALLOW_TILDE_N_TILDE_R_TILDE_T) {
|
||||
allow_tilde_n_tilde_r_tilde_t = true;
|
||||
allow_tilde_n_tilde_r_tilde_t = (quirks.ptr[i].second != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@
|
||||
#define WUFFS_CONFIG__MODULE__NETPBM
|
||||
#define WUFFS_CONFIG__MODULE__NIE
|
||||
#define WUFFS_CONFIG__MODULE__PNG
|
||||
#define WUFFS_CONFIG__MODULE__QOI
|
||||
#define WUFFS_CONFIG__MODULE__TGA
|
||||
#define WUFFS_CONFIG__MODULE__VP8
|
||||
#define WUFFS_CONFIG__MODULE__WBMP
|
||||
@@ -125,6 +126,9 @@ handle_image_decoder(wuffs_base__io_buffer src,
|
||||
case WUFFS_BASE__FOURCC__PNG:
|
||||
dec = wuffs_png__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__QOI:
|
||||
dec = wuffs_qoi__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__TGA:
|
||||
dec = wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
|
||||
@@ -57,6 +57,7 @@ to use the wuffs_aux C++ API to decode an image and iterate over its pixels.
|
||||
#define WUFFS_CONFIG__MODULE__NETPBM
|
||||
#define WUFFS_CONFIG__MODULE__NIE
|
||||
#define WUFFS_CONFIG__MODULE__PNG
|
||||
#define WUFFS_CONFIG__MODULE__QOI
|
||||
#define WUFFS_CONFIG__MODULE__TGA
|
||||
#define WUFFS_CONFIG__MODULE__WBMP
|
||||
#define WUFFS_CONFIG__MODULE__ZLIB
|
||||
|
||||
@@ -53,6 +53,7 @@ print-image-metadata prints images' metadata.
|
||||
#define WUFFS_CONFIG__MODULE__NETPBM
|
||||
#define WUFFS_CONFIG__MODULE__NIE
|
||||
#define WUFFS_CONFIG__MODULE__PNG
|
||||
#define WUFFS_CONFIG__MODULE__QOI
|
||||
#define WUFFS_CONFIG__MODULE__TGA
|
||||
#define WUFFS_CONFIG__MODULE__VP8
|
||||
#define WUFFS_CONFIG__MODULE__WBMP
|
||||
@@ -387,6 +388,9 @@ redirect:
|
||||
case WUFFS_BASE__FOURCC__PNG:
|
||||
dec = wuffs_png__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__QOI:
|
||||
dec = wuffs_qoi__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__TGA:
|
||||
dec = wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
|
||||
@@ -46,6 +46,11 @@
|
||||
//
|
||||
// Pass -a (--all-tokens) to print all tokens, including whitespace.
|
||||
//
|
||||
// Pass -i=cbor (--input-format=cbor) to parse CBOR instead of JSON.
|
||||
//
|
||||
// Pass -q (--quirks) to enable all of a pre-defined set of various parser
|
||||
// quirks. For example, allowing JSON comments or JSON "inf" numbers.
|
||||
//
|
||||
// If the input or output is larger than the program's buffers (64 MiB and
|
||||
// 131072 tokens by default), there may be multiple valid tokenizations of any
|
||||
// given input. For example, if a source string "abcde" straddles an I/O
|
||||
@@ -418,7 +423,7 @@ compute_exit_code(const char* status_msg) {
|
||||
size_t n = strnlen(status_msg, 2047);
|
||||
if (n >= 2047) {
|
||||
status_msg = "main: internal error: error message is too long";
|
||||
n = strnlen(status_msg, 2047);
|
||||
n = strlen(status_msg);
|
||||
}
|
||||
fprintf(stderr, "%s\n", status_msg);
|
||||
// Return an exit code of 1 for regular (foreseen) errors, e.g. badly
|
||||
|
||||
@@ -307,7 +307,7 @@ compute_exit_code(const char* status_msg) {
|
||||
size_t n = strnlen(status_msg, 2047);
|
||||
if (n >= 2047) {
|
||||
status_msg = "main: internal error: error message is too long";
|
||||
n = strnlen(status_msg, 2047);
|
||||
n = strlen(status_msg);
|
||||
}
|
||||
fprintf(stderr, "%s\n", status_msg);
|
||||
// Return an exit code of 1 for regular (foreseen) errors, e.g. badly
|
||||
|
||||
@@ -103,6 +103,7 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
|
||||
var width : base.u32
|
||||
var height : base.u32
|
||||
var planes : base.u32
|
||||
var n : base.u32
|
||||
var dst_pixfmt : base.u32
|
||||
var byte_width : base.u32
|
||||
|
||||
@@ -275,7 +276,8 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
|
||||
}
|
||||
} else if this.bitmap_info_len >= 40 {
|
||||
// Skip the rest of the BITMAPINFOHEADER.
|
||||
args.src.skip_u32?(n: this.bitmap_info_len - 40)
|
||||
n = this.bitmap_info_len - 40
|
||||
args.src.skip_u32?(n: n)
|
||||
} else {
|
||||
return "#unsupported BMP file"
|
||||
}
|
||||
|
||||
+200
-59
@@ -15,8 +15,10 @@ pub status "#bad SOF marker"
|
||||
pub status "#bad SOS marker"
|
||||
pub status "#bad header"
|
||||
pub status "#bad marker"
|
||||
pub status "#bad scan count"
|
||||
pub status "#missing Huffman table"
|
||||
pub status "#missing Quantization table"
|
||||
pub status "#rejected progressive JPEG"
|
||||
pub status "#truncated input"
|
||||
pub status "#unsupported arithmetic coding"
|
||||
pub status "#unsupported color model"
|
||||
@@ -278,6 +280,16 @@ pub struct decoder? implements base.image_decoder(
|
||||
|
||||
bitstream_is_closed : base.bool,
|
||||
|
||||
expect_multiple_scans : base.bool,
|
||||
|
||||
use_lower_quality : base.bool,
|
||||
reject_progressive_jpegs : base.bool,
|
||||
|
||||
swizzle_immediately : base.bool,
|
||||
swizzle_immediately_status : base.status,
|
||||
swizzle_immediately_b_offsets : array[10] base.u32[..= 576],
|
||||
swizzle_immediately_c_offsets : array[5] base.u32,
|
||||
|
||||
// bitstream_padding is the number (per restart) of implicit zeroes
|
||||
// remaining at the end of the bitstream. Its initial 12345 value is
|
||||
// arbitrary.
|
||||
@@ -311,6 +323,8 @@ pub struct decoder? implements base.image_decoder(
|
||||
// Decoding progressive JPEGs can use all of it.
|
||||
mcu_blocks : array[10] array[64] base.u16,
|
||||
|
||||
swizzle_immediately_buffer : array[640] base.u8,
|
||||
|
||||
swizzle_ycck_scratch_buffer_2k : array[2048] base.u8,
|
||||
|
||||
// The dht_temp_etc fields are decode_dht temporary values.
|
||||
@@ -326,10 +340,26 @@ pub struct decoder? implements base.image_decoder(
|
||||
)
|
||||
|
||||
pub func decoder.get_quirk(key: base.u32) base.u64 {
|
||||
if args.key == base.QUIRK_QUALITY {
|
||||
if this.use_lower_quality {
|
||||
return 0xFFFF_FFFF_FFFF_FFFF
|
||||
}
|
||||
} else if args.key == QUIRK_REJECT_PROGRESSIVE_JPEGS {
|
||||
if this.reject_progressive_jpegs {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
pub func decoder.set_quirk!(key: base.u32, value: base.u64) base.status {
|
||||
if args.key == base.QUIRK_QUALITY {
|
||||
this.use_lower_quality = args.value >= 0x8000_0000_0000_0000
|
||||
return ok
|
||||
} else if args.key == QUIRK_REJECT_PROGRESSIVE_JPEGS {
|
||||
this.reject_progressive_jpegs = args.value <> 0
|
||||
return ok
|
||||
}
|
||||
return base."#unsupported option"
|
||||
}
|
||||
|
||||
@@ -407,7 +437,9 @@ pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.
|
||||
|
||||
} else if marker < 0xD0 { // SOFn (Start of Frame) and friends.
|
||||
if marker <= 0xC2 {
|
||||
if this.sof_marker <> 0 {
|
||||
if (marker == 0xC2) and this.reject_progressive_jpegs {
|
||||
return "#rejected progressive JPEG"
|
||||
} else if this.sof_marker <> 0 {
|
||||
return "#bad SOF marker"
|
||||
}
|
||||
this.sof_marker = marker
|
||||
@@ -878,15 +910,29 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
ddf_status = "#truncated input"
|
||||
}
|
||||
|
||||
if ddf_status.is_error() or (scan_count < this.scan_count) {
|
||||
if (not this.swizzle_immediately) and
|
||||
(ddf_status.is_error() or (scan_count < this.scan_count)) {
|
||||
if this.sof_marker >= 0xC2 {
|
||||
this.apply_progressive_idct!(workbuf: args.workbuf)
|
||||
}
|
||||
|
||||
if this.num_components == 1 {
|
||||
swizzle_status = this.swizzle_gray!(dst: args.dst, workbuf: args.workbuf)
|
||||
swizzle_status = this.swizzle_gray!(
|
||||
dst: args.dst,
|
||||
workbuf: args.workbuf,
|
||||
x0: 0,
|
||||
x1: 0xFFFF_FFFF,
|
||||
y0: 0,
|
||||
y1: 0xFFFF_FFFF,
|
||||
stride: this.components_workbuf_widths[0] as base.u64)
|
||||
} else {
|
||||
swizzle_status = this.swizzle_colorful!(dst: args.dst, workbuf: args.workbuf)
|
||||
swizzle_status = this.swizzle_colorful!(
|
||||
dst: args.dst,
|
||||
workbuf: args.workbuf,
|
||||
x0: 0,
|
||||
x1: 0xFFFF_FFFF,
|
||||
y0: 0,
|
||||
y1: 0xFFFF_FFFF)
|
||||
}
|
||||
if ddf_status.is_error() {
|
||||
return ddf_status
|
||||
@@ -929,9 +975,14 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
|
||||
// For progressive JPEGs, zero-initialize the saved pre-IDCT blocks. For
|
||||
// sequential JPEGs, this is a no-op, other than checking that args.workbuf
|
||||
// is long enough.
|
||||
// is long enough and setting this.swizzle_immediately.
|
||||
this.swizzle_immediately = false
|
||||
if this.components_workbuf_offsets[8] > args.workbuf.length() {
|
||||
return base."#bad workbuf length"
|
||||
if this.sof_marker >= 0xC2 {
|
||||
return base."#bad workbuf length"
|
||||
}
|
||||
this.swizzle_immediately = this.use_lower_quality
|
||||
this.swizzle_immediately_status = ok
|
||||
} else if this.components_workbuf_offsets[4] < this.components_workbuf_offsets[8] {
|
||||
args.workbuf[this.components_workbuf_offsets[4] .. this.components_workbuf_offsets[8]].bulk_memset!(byte_value: 0)
|
||||
}
|
||||
@@ -1006,7 +1057,7 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
break
|
||||
|
||||
} else if marker == 0xDA { // SOS (Start Of Scan).
|
||||
this.decode_sos?(src: args.src, workbuf: args.workbuf)
|
||||
this.decode_sos?(dst: args.dst, src: args.src, workbuf: args.workbuf)
|
||||
continue
|
||||
|
||||
} else if marker == 0xDB { // DQT (Define Quantization Table).
|
||||
@@ -1247,15 +1298,17 @@ pri func decoder.calculate_huff_tables!(tc4_th: base.u8[..= 7], total_count: bas
|
||||
return false
|
||||
}
|
||||
|
||||
pri func decoder.decode_sos?(src: base.io_reader, workbuf: slice base.u8) {
|
||||
pri func decoder.decode_sos?(dst: ptr base.pixel_buffer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var my : base.u32
|
||||
var mx : base.u32
|
||||
|
||||
var decode_mcu_result : base.u32
|
||||
var bitstream_length : base.u32
|
||||
|
||||
if this.scan_count >= 64 {
|
||||
if this.scan_count >= 32 {
|
||||
return "#unsupported scan count"
|
||||
} else if (this.scan_count > 0) and (not this.expect_multiple_scans) {
|
||||
return "#bad scan count"
|
||||
}
|
||||
|
||||
this.prepare_scan?(src: args.src)
|
||||
@@ -1294,11 +1347,15 @@ pri func decoder.decode_sos?(src: base.io_reader, workbuf: slice base.u8) {
|
||||
inv my < 0x2000,
|
||||
inv mx < 0x2000,
|
||||
{
|
||||
decode_mcu_result = this.decode_mcu!(workbuf: args.workbuf, mx: mx, my: my)
|
||||
decode_mcu_result = this.decode_mcu!(dst: args.dst, workbuf: args.workbuf, mx: mx, my: my)
|
||||
if decode_mcu_result == 0 {
|
||||
break.decode_mcu
|
||||
} else if decode_mcu_result <> 1 {
|
||||
} else if decode_mcu_result == 1 {
|
||||
// No-op.
|
||||
} else if decode_mcu_result == 2 {
|
||||
return "#internal error: inconsistent decoder state"
|
||||
} else {
|
||||
return this.swizzle_immediately_status
|
||||
}
|
||||
|
||||
while.fill_bitstream true,
|
||||
@@ -1431,6 +1488,12 @@ pri func decoder.prepare_scan?(src: base.io_reader) {
|
||||
i += 1
|
||||
}
|
||||
|
||||
if this.scan_count == 0 {
|
||||
this.expect_multiple_scans =
|
||||
(this.sof_marker >= 0xC2) or
|
||||
(this.scan_num_components < this.num_components)
|
||||
}
|
||||
|
||||
if this.sof_marker < 0xC2 {
|
||||
// At this point, for sequential (not progressive) JPEGs, we should
|
||||
// check that (Ss, Se, Ah, Al) is (0, 63, 0, 0) but libjpeg treats
|
||||
@@ -1575,6 +1638,7 @@ pri func decoder.calculate_multiple_component_scan_fields!() base.bool {
|
||||
var b : base.u32
|
||||
var bx_offset : base.u32
|
||||
var by_offset : base.u32
|
||||
var sibo : base.u32
|
||||
var ssel : base.u8[..= 3]
|
||||
var csel : base.u8[..= 3]
|
||||
|
||||
@@ -1589,6 +1653,7 @@ pri func decoder.calculate_multiple_component_scan_fields!() base.bool {
|
||||
v = this.components_v[this.scan_comps_cselector[i]] as base.u32
|
||||
hv = ((this.components_h[this.scan_comps_cselector[i]] as base.u32) *
|
||||
(this.components_v[this.scan_comps_cselector[i]] as base.u32))
|
||||
this.swizzle_immediately_c_offsets[i] = 64 ~mod* total_hv
|
||||
total_hv ~mod+= hv
|
||||
|
||||
while hv > 0,
|
||||
@@ -1615,6 +1680,7 @@ pri func decoder.calculate_multiple_component_scan_fields!() base.bool {
|
||||
return true
|
||||
}
|
||||
this.mcu_num_blocks = total_hv
|
||||
this.swizzle_immediately_c_offsets[this.scan_num_components] = 64 ~mod* total_hv
|
||||
|
||||
b = 0
|
||||
while b < this.mcu_num_blocks {
|
||||
@@ -1628,6 +1694,10 @@ pri func decoder.calculate_multiple_component_scan_fields!() base.bool {
|
||||
this.mcu_blocks_my_mul[b] = 8 * (this.components_v[csel] as base.u32) * this.components_workbuf_widths[csel]
|
||||
this.mcu_blocks_dc_hselector[b] = 0 | this.scan_comps_td[ssel]
|
||||
this.mcu_blocks_ac_hselector[b] = 4 | this.scan_comps_ta[ssel]
|
||||
sibo = this.swizzle_immediately_c_offsets[csel] ~mod+ (
|
||||
(8 * (this.scan_comps_bx_offset[b] as base.u32)) +
|
||||
(64 * (this.scan_comps_by_offset[b] as base.u32) * (this.components_h[csel] as base.u32)))
|
||||
this.swizzle_immediately_b_offsets[b] = sibo.min(no_more_than: 576)
|
||||
b += 1
|
||||
}
|
||||
|
||||
@@ -1916,15 +1986,16 @@ pri func decoder.apply_progressive_idct!(workbuf: slice base.u8) {
|
||||
this.mcu_blocks[.. 1].bulk_load_host_endian!(src: stashed_mcu_blocks_0[..])
|
||||
}
|
||||
|
||||
pri func decoder.swizzle_gray!(dst: ptr base.pixel_buffer, workbuf: slice base.u8) base.status {
|
||||
pri func decoder.swizzle_gray!(dst: ptr base.pixel_buffer, workbuf: slice base.u8, x0: base.u32, x1: base.u32, y0: base.u32, y1: base.u32, stride: base.u64) base.status {
|
||||
var dst_pixfmt : base.pixel_format
|
||||
var dst_bits_per_pixel : base.u32[..= 256]
|
||||
var dst_bytes_per_pixel : base.u32[..= 32]
|
||||
var dst_length : base.u64
|
||||
var x0 : base.u64
|
||||
var x1 : base.u64
|
||||
var tab : table base.u8
|
||||
var dst : slice base.u8
|
||||
var y : base.u32
|
||||
var stride : base.u64[..= 0x4_0000]
|
||||
var y1 : base.u32[..= 0xFFFF]
|
||||
|
||||
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
|
||||
// to chain the two calls: "args.dst.pixel_format().bits_per_pixel()".
|
||||
@@ -1934,79 +2005,143 @@ pri func decoder.swizzle_gray!(dst: ptr base.pixel_buffer, workbuf: slice base.u
|
||||
return base."#unsupported option"
|
||||
}
|
||||
dst_bytes_per_pixel = dst_bits_per_pixel / 8
|
||||
dst_length = (dst_bytes_per_pixel * this.width) as base.u64
|
||||
x0 = (dst_bytes_per_pixel * args.x0.min(no_more_than: this.width)) as base.u64
|
||||
x1 = (dst_bytes_per_pixel * args.x1.min(no_more_than: this.width)) as base.u64
|
||||
|
||||
tab = args.dst.plane(p: 0)
|
||||
y = 0
|
||||
while y < this.height {
|
||||
assert y < 0xFFFF via "a < b: a < c; c <= b"(c: this.height)
|
||||
y = args.y0
|
||||
y1 = args.y1.min(no_more_than: this.height)
|
||||
while y < y1 {
|
||||
assert y < 0xFFFF via "a < b: a < c; c <= b"(c: y1)
|
||||
dst = tab.row_u32(y: y)
|
||||
if dst_length < dst.length() {
|
||||
dst = dst[.. dst_length]
|
||||
if x1 < dst.length() {
|
||||
dst = dst[.. x1]
|
||||
}
|
||||
if x0 < dst.length() {
|
||||
dst = dst[x0 ..]
|
||||
} else {
|
||||
dst = this.util.empty_slice_u8()
|
||||
}
|
||||
|
||||
this.swizzler.swizzle_interleaved_from_slice!(
|
||||
dst: dst,
|
||||
dst_palette: args.dst.palette_or_else(fallback: this.dst_palette[..]),
|
||||
src: args.workbuf)
|
||||
stride = this.components_workbuf_widths[0] as base.u64
|
||||
if stride <= args.workbuf.length() {
|
||||
args.workbuf = args.workbuf[stride ..]
|
||||
|
||||
if args.stride <= args.workbuf.length() {
|
||||
args.workbuf = args.workbuf[args.stride ..]
|
||||
} else {
|
||||
args.workbuf = this.util.empty_slice_u8()
|
||||
}
|
||||
|
||||
y += 1
|
||||
}
|
||||
return ok
|
||||
}
|
||||
|
||||
pri func decoder.swizzle_colorful!(dst: ptr base.pixel_buffer, workbuf: slice base.u8) base.status {
|
||||
var src0 : slice base.u8
|
||||
var src1 : slice base.u8
|
||||
var src2 : slice base.u8
|
||||
var src3 : slice base.u8
|
||||
var status : base.status
|
||||
pri func decoder.swizzle_colorful!(dst: ptr base.pixel_buffer, workbuf: slice base.u8, x0: base.u32, x1: base.u32, y0: base.u32, y1: base.u32) base.status {
|
||||
var i : base.u64
|
||||
var j : base.u64
|
||||
var src0 : slice base.u8
|
||||
var src1 : slice base.u8
|
||||
var src2 : slice base.u8
|
||||
var src3 : slice base.u8
|
||||
var width0 : base.u32[..= 0x1_0008]
|
||||
var width1 : base.u32[..= 0x1_0008]
|
||||
var width2 : base.u32[..= 0x1_0008]
|
||||
var width3 : base.u32[..= 0x1_0008]
|
||||
var height0 : base.u32[..= 0x1_0008]
|
||||
var height1 : base.u32[..= 0x1_0008]
|
||||
var height2 : base.u32[..= 0x1_0008]
|
||||
var height3 : base.u32[..= 0x1_0008]
|
||||
var status : base.status
|
||||
|
||||
if (this.components_workbuf_offsets[0] <= this.components_workbuf_offsets[1]) and
|
||||
(this.components_workbuf_offsets[1] <= args.workbuf.length()) {
|
||||
src0 = args.workbuf[this.components_workbuf_offsets[0] .. this.components_workbuf_offsets[1]]
|
||||
}
|
||||
if this.swizzle_immediately {
|
||||
i = this.swizzle_immediately_c_offsets[0] as base.u64
|
||||
j = this.swizzle_immediately_c_offsets[1] as base.u64
|
||||
if (i <= j) and (j <= 640) {
|
||||
src0 = this.swizzle_immediately_buffer[i .. j]
|
||||
width0 = 8 * (this.components_h[0] as base.u32)
|
||||
height0 = 8 * (this.components_v[0] as base.u32)
|
||||
}
|
||||
|
||||
if (this.components_workbuf_offsets[1] <= this.components_workbuf_offsets[2]) and
|
||||
(this.components_workbuf_offsets[2] <= args.workbuf.length()) {
|
||||
src1 = args.workbuf[this.components_workbuf_offsets[1] .. this.components_workbuf_offsets[2]]
|
||||
}
|
||||
i = this.swizzle_immediately_c_offsets[1] as base.u64
|
||||
j = this.swizzle_immediately_c_offsets[2] as base.u64
|
||||
if (i <= j) and (j <= 640) {
|
||||
src1 = this.swizzle_immediately_buffer[i .. j]
|
||||
width1 = 8 * (this.components_h[1] as base.u32)
|
||||
height1 = 8 * (this.components_v[1] as base.u32)
|
||||
}
|
||||
|
||||
if (this.components_workbuf_offsets[2] <= this.components_workbuf_offsets[3]) and
|
||||
(this.components_workbuf_offsets[3] <= args.workbuf.length()) {
|
||||
src2 = args.workbuf[this.components_workbuf_offsets[2] .. this.components_workbuf_offsets[3]]
|
||||
}
|
||||
i = this.swizzle_immediately_c_offsets[2] as base.u64
|
||||
j = this.swizzle_immediately_c_offsets[3] as base.u64
|
||||
if (i <= j) and (j <= 640) {
|
||||
src2 = this.swizzle_immediately_buffer[i .. j]
|
||||
width2 = 8 * (this.components_h[2] as base.u32)
|
||||
height2 = 8 * (this.components_v[2] as base.u32)
|
||||
}
|
||||
|
||||
if (this.components_workbuf_offsets[3] <= this.components_workbuf_offsets[4]) and
|
||||
(this.components_workbuf_offsets[4] <= args.workbuf.length()) {
|
||||
src3 = args.workbuf[this.components_workbuf_offsets[3] .. this.components_workbuf_offsets[4]]
|
||||
i = this.swizzle_immediately_c_offsets[3] as base.u64
|
||||
j = this.swizzle_immediately_c_offsets[4] as base.u64
|
||||
if (i <= j) and (j <= 640) {
|
||||
src3 = this.swizzle_immediately_buffer[i .. j]
|
||||
width3 = 8 * (this.components_h[3] as base.u32)
|
||||
height3 = 8 * (this.components_v[3] as base.u32)
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this.components_workbuf_offsets[0] <= this.components_workbuf_offsets[1]) and
|
||||
(this.components_workbuf_offsets[1] <= args.workbuf.length()) {
|
||||
src0 = args.workbuf[this.components_workbuf_offsets[0] .. this.components_workbuf_offsets[1]]
|
||||
width0 = this.components_workbuf_widths[0]
|
||||
height0 = this.components_workbuf_heights[0]
|
||||
}
|
||||
|
||||
if (this.components_workbuf_offsets[1] <= this.components_workbuf_offsets[2]) and
|
||||
(this.components_workbuf_offsets[2] <= args.workbuf.length()) {
|
||||
src1 = args.workbuf[this.components_workbuf_offsets[1] .. this.components_workbuf_offsets[2]]
|
||||
width1 = this.components_workbuf_widths[1]
|
||||
height1 = this.components_workbuf_heights[1]
|
||||
}
|
||||
|
||||
if (this.components_workbuf_offsets[2] <= this.components_workbuf_offsets[3]) and
|
||||
(this.components_workbuf_offsets[3] <= args.workbuf.length()) {
|
||||
src2 = args.workbuf[this.components_workbuf_offsets[2] .. this.components_workbuf_offsets[3]]
|
||||
width2 = this.components_workbuf_widths[2]
|
||||
height2 = this.components_workbuf_heights[2]
|
||||
}
|
||||
|
||||
if (this.components_workbuf_offsets[3] <= this.components_workbuf_offsets[4]) and
|
||||
(this.components_workbuf_offsets[4] <= args.workbuf.length()) {
|
||||
src3 = args.workbuf[this.components_workbuf_offsets[3] .. this.components_workbuf_offsets[4]]
|
||||
width3 = this.components_workbuf_widths[3]
|
||||
height3 = this.components_workbuf_heights[3]
|
||||
}
|
||||
}
|
||||
|
||||
status = this.swizzler.swizzle_ycck!(
|
||||
dst: args.dst,
|
||||
dst_palette: args.dst.palette_or_else(fallback: this.dst_palette[..]),
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
x_min_incl: args.x0 & 0xFFFF,
|
||||
x_max_excl: args.x1.min(no_more_than: this.width),
|
||||
y_min_incl: args.y0 & 0xFFFF,
|
||||
y_max_excl: args.y1.min(no_more_than: this.height),
|
||||
src0: src0,
|
||||
src1: src1,
|
||||
src2: src2,
|
||||
src3: src3,
|
||||
width0: this.components_workbuf_widths[0],
|
||||
width1: this.components_workbuf_widths[1],
|
||||
width2: this.components_workbuf_widths[2],
|
||||
width3: this.components_workbuf_widths[3],
|
||||
height0: this.components_workbuf_heights[0],
|
||||
height1: this.components_workbuf_heights[1],
|
||||
height2: this.components_workbuf_heights[2],
|
||||
height3: this.components_workbuf_heights[3],
|
||||
stride0: this.components_workbuf_widths[0],
|
||||
stride1: this.components_workbuf_widths[1],
|
||||
stride2: this.components_workbuf_widths[2],
|
||||
stride3: this.components_workbuf_widths[3],
|
||||
width0: width0,
|
||||
width1: width1,
|
||||
width2: width2,
|
||||
width3: width3,
|
||||
height0: height0,
|
||||
height1: height1,
|
||||
height2: height2,
|
||||
height3: height3,
|
||||
stride0: width0,
|
||||
stride1: width1,
|
||||
stride2: width2,
|
||||
stride3: width3,
|
||||
h0: this.components_h[0],
|
||||
h1: this.components_h[1],
|
||||
h2: this.components_h[2],
|
||||
@@ -2016,7 +2151,7 @@ pri func decoder.swizzle_colorful!(dst: ptr base.pixel_buffer, workbuf: slice ba
|
||||
v2: this.components_v[2],
|
||||
v3: this.components_v[3],
|
||||
is_rgb_or_cmyk: this.is_rgb_or_cmyk,
|
||||
triangle_filter_for_2to1: true,
|
||||
triangle_filter_for_2to1: not this.use_lower_quality,
|
||||
scratch_buffer_2k: this.swizzle_ycck_scratch_buffer_2k[..])
|
||||
return status
|
||||
}
|
||||
@@ -2060,6 +2195,7 @@ pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.sta
|
||||
|
||||
this.call_sequence = 0x28
|
||||
this.bitstream_is_closed = false
|
||||
this.expect_multiple_scans = false
|
||||
this.frame_config_io_position = args.io_position
|
||||
this.scan_count = 0
|
||||
this.restart_interval = this.saved_restart_interval
|
||||
@@ -2107,6 +2243,11 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform
|
||||
}
|
||||
|
||||
pub func decoder.workbuf_len() base.range_ii_u64 {
|
||||
if this.use_lower_quality and (this.sof_marker < 0xC2) {
|
||||
return this.util.make_range_ii_u64(
|
||||
min_incl: 0,
|
||||
max_incl: this.components_workbuf_offsets[8])
|
||||
}
|
||||
return this.util.make_range_ii_u64(
|
||||
min_incl: this.components_workbuf_offsets[8],
|
||||
max_incl: this.components_workbuf_offsets[8])
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
pri func decoder.decode_mcu!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32,
|
||||
pri func decoder.decode_mcu!(dst: ptr base.pixel_buffer, workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32,
|
||||
choosy,
|
||||
{
|
||||
var ret : base.u32
|
||||
@@ -266,17 +266,62 @@ pri func decoder.decode_mcu!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], m
|
||||
}
|
||||
|
||||
// Apply IDCT.
|
||||
csel = this.scan_comps_cselector[this.mcu_blocks_sselector[mcb]]
|
||||
stride = this.components_workbuf_widths[csel] as base.u64
|
||||
offset = this.mcu_blocks_offset[mcb] +
|
||||
((this.mcu_blocks_mx_mul[mcb] as base.u64) * (args.mx as base.u64)) +
|
||||
((this.mcu_blocks_my_mul[mcb] as base.u64) * (args.my as base.u64))
|
||||
if offset <= args.workbuf.length() {
|
||||
|
||||
if not this.swizzle_immediately {
|
||||
csel = this.scan_comps_cselector[this.mcu_blocks_sselector[mcb]]
|
||||
stride = this.components_workbuf_widths[csel] as base.u64
|
||||
offset = this.mcu_blocks_offset[mcb] +
|
||||
((this.mcu_blocks_mx_mul[mcb] as base.u64) * (args.mx as base.u64)) +
|
||||
((this.mcu_blocks_my_mul[mcb] as base.u64) * (args.my as base.u64))
|
||||
if offset <= args.workbuf.length() {
|
||||
this.decode_idct!(
|
||||
dst_buffer: args.workbuf[offset ..],
|
||||
dst_stride: stride,
|
||||
q: this.components_tq[csel] as base.u32)
|
||||
|
||||
}
|
||||
|
||||
} else if this.num_components == 1 {
|
||||
this.decode_idct!(
|
||||
dst_buffer: args.workbuf[offset ..],
|
||||
dst_buffer: this.swizzle_immediately_buffer[.. 64],
|
||||
dst_stride: 8,
|
||||
q: this.components_tq[csel] as base.u32)
|
||||
this.swizzle_immediately_status = this.swizzle_gray!(
|
||||
dst: args.dst,
|
||||
workbuf: this.swizzle_immediately_buffer[.. 64],
|
||||
x0: (args.mx + 0) * 8,
|
||||
x1: (args.mx + 1) * 8,
|
||||
y0: (args.my + 0) * 8,
|
||||
y1: (args.my + 1) * 8,
|
||||
stride: 8)
|
||||
if not this.swizzle_immediately_status.is_ok() {
|
||||
ret = 3 // Swizzling failure.
|
||||
break.goto_done
|
||||
}
|
||||
break.block
|
||||
|
||||
} else {
|
||||
csel = this.scan_comps_cselector[this.mcu_blocks_sselector[mcb]]
|
||||
stride = 8 * (this.components_h[csel] as base.u64)
|
||||
this.decode_idct!(
|
||||
dst_buffer: this.swizzle_immediately_buffer[this.swizzle_immediately_b_offsets[mcb] ..],
|
||||
dst_stride: stride,
|
||||
q: this.components_tq[csel] as base.u32)
|
||||
|
||||
if this.mcu_current_block < this.mcu_num_blocks {
|
||||
continue.block
|
||||
}
|
||||
this.swizzle_immediately_status = this.swizzle_colorful!(
|
||||
dst: args.dst,
|
||||
workbuf: this.util.empty_slice_u8(),
|
||||
x0: (args.mx + 0) * 8 * (this.max_incl_components_h as base.u32),
|
||||
x1: (args.mx + 1) * 8 * (this.max_incl_components_h as base.u32),
|
||||
y0: (args.my + 0) * 8 * (this.max_incl_components_v as base.u32),
|
||||
y1: (args.my + 1) * 8 * (this.max_incl_components_v as base.u32))
|
||||
if not this.swizzle_immediately_status.is_ok() {
|
||||
ret = 3 // Swizzling failure.
|
||||
break.goto_done
|
||||
}
|
||||
break.block
|
||||
}
|
||||
}.block
|
||||
this.mcu_current_block = 0
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
pri func decoder.decode_mcu_progressive_ac_high_bits!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
pri func decoder.decode_mcu_progressive_ac_high_bits!(dst: ptr base.pixel_buffer, workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
var ret : base.u32
|
||||
|
||||
var bits : base.u64
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
pri func decoder.decode_mcu_progressive_ac_low_bit!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
pri func decoder.decode_mcu_progressive_ac_low_bit!(dst: ptr base.pixel_buffer, workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
var ret : base.u32
|
||||
|
||||
var bits : base.u64
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
pri func decoder.decode_mcu_progressive_dc_high_bits!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
pri func decoder.decode_mcu_progressive_dc_high_bits!(dst: ptr base.pixel_buffer, workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
var ret : base.u32
|
||||
|
||||
var bits : base.u64
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
pri func decoder.decode_mcu_progressive_dc_low_bit!(workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
pri func decoder.decode_mcu_progressive_dc_low_bit!(dst: ptr base.pixel_buffer, workbuf: slice base.u8, mx: base.u32[..= 0x1FFF], my: base.u32[..= 0x1FFF]) base.u32 {
|
||||
var ret : base.u32
|
||||
|
||||
var bits : base.u64
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright 2024 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
// --------
|
||||
|
||||
// Quirks are discussed in (/doc/note/quirks.md).
|
||||
//
|
||||
// The base38 encoding of "jpeg" is 0x122FF6. Left shifting by 10 gives
|
||||
// 0x48BF_D800.
|
||||
pri const QUIRKS_BASE : base.u32 = 0x48BF_D800
|
||||
|
||||
// --------
|
||||
|
||||
// When this quirk value is non-zero, the decoder will not support progressive
|
||||
// JPEG images. When combined with setting base.QUIRK_QUALITY to "lower
|
||||
// quality", this means that decoding will never require any temporary "work
|
||||
// buffer" memory: decoder.workbuf_len will always return a range (a min and
|
||||
// max pair) whose minimum value is zero.
|
||||
//
|
||||
// The maximum value can still be positive, as using more memory might lead to
|
||||
// faster decoding, but a zero minimum means that it's valid for the caller to
|
||||
// not allocate any memory for a work buffer.
|
||||
//
|
||||
// When opted into lower quality decoding, the workbuf_len minimum will be zero
|
||||
// and positive for sequential and progressive JPEGs respectively, regardless
|
||||
// of this QUIRK_REJECT_PROGRESSIVE_JPEGS key's value. But setting this quirk
|
||||
// explicitly will produce a "#rejected progressive JPEG" error when
|
||||
// encountering a progressive JPEG. This results in more readable calling code,
|
||||
// instead of commenting about "positive work buffer minimum length implies a
|
||||
// progressive JPEG".
|
||||
pub const QUIRK_REJECT_PROGRESSIVE_JPEGS : base.u32 = 0x48BF_D800 | 0x00
|
||||
|
||||
// --------
|
||||
|
||||
// The base.QUIRK_QUALITY key is defined in the base package, not this package.
|
||||
// Still, here's some documentation on how this package responds to that (key,
|
||||
// value) quirk pair.
|
||||
//
|
||||
// If decoder.set_quirk is passed a base.QUIRK_QUALITY as the key argument
|
||||
// then, when re-interpreting the u64 value argument as a signed i64 number, a
|
||||
// negative number opts the decoder in to a slightly worse quality but leaner
|
||||
// (less memory required) chroma upsampling algorithm.
|
||||
//
|
||||
// Negative (in i64 space) means >= 0x8000_0000_0000_0000 (in u64 space).
|
||||
// base.QUIRK_QUALITY__VALUE__LOWER_QUALITY is one such value.
|
||||
//
|
||||
// Specifically, a negative quirk value uses a box filter. A non-negative quirk
|
||||
// value (including the default value, zero) uses the same triangle filter that
|
||||
// libjpeg-turbo also uses by default, which requires chroma upsampling on the
|
||||
// edges of a MCU (Minimum Coded Unit) to remember adjacent MCU's values.
|
||||
//
|
||||
// Leaner means that for common (sequential) JPEG images, the range returned by
|
||||
// decoder.workbuf_len will have a minimum value of zero, meaning that no work
|
||||
// buffer memory needs to be allocated. Decoding rarer (progressive) JPEGs will
|
||||
// still always require a positive amount of work buffer memory, for reasons
|
||||
// unrelated to chroma upsampling. The exact amount required depends on factors
|
||||
// like the JPEG image's width, height, component count and subsampling ratios.
|
||||
//
|
||||
// Regardless of the quirk value, as always, the workbuf_len method returns a
|
||||
// range, whose min and max can be different. The caller is able to choose
|
||||
// between providing the minimal amount of work buffer memory (for slightly
|
||||
// slower decoding) or the maximal amount (for slightly faster decoding).
|
||||
//
|
||||
// Callers that never wish to allocate work buffer memory can simply reject
|
||||
// progressive JPEGs (where "workbuf_len().min_incl > 0" despite setting the
|
||||
// base.QUIRK_QUALITY key to a negative quirk value) as unsupported. See also
|
||||
// QUIRK_REJECT_PROGRESSIVE_JPEGS.
|
||||
//
|
||||
// For some pictures comparing box and triangle filter decodings, see
|
||||
// https://nigeltao.github.io/blog/2024/jpeg-chroma-upsampling.html
|
||||
@@ -0,0 +1,414 @@
|
||||
// Copyright 2024 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
pub status "#bad footer"
|
||||
pub status "#bad header"
|
||||
pub status "#truncated input"
|
||||
|
||||
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
|
||||
|
||||
pub struct decoder? implements base.image_decoder(
|
||||
pixfmt : base.u32,
|
||||
width : base.u32[..= 0xFF_FFFF],
|
||||
height : base.u32[..= 0xFF_FFFF],
|
||||
|
||||
remaining_pixels_times_4 : base.u64,
|
||||
|
||||
// The call sequence state machine is discussed in
|
||||
// (/doc/std/image-decoders-call-sequence.md).
|
||||
call_sequence : base.u8,
|
||||
|
||||
buffer_index : base.u32[..= 8192],
|
||||
|
||||
dst_x : base.u32,
|
||||
dst_y : base.u32,
|
||||
|
||||
swizzler : base.pixel_swizzler,
|
||||
util : base.utility,
|
||||
) + (
|
||||
pixel : array[4] base.u8,
|
||||
cache : array[256] base.u8,
|
||||
buffer : array[8192 + 4] base.u8,
|
||||
)
|
||||
|
||||
pub func decoder.get_quirk(key: base.u32) base.u64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
pub func decoder.set_quirk!(key: base.u32, value: base.u64) base.status {
|
||||
return base."#unsupported option"
|
||||
}
|
||||
|
||||
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var a : base.u32
|
||||
|
||||
if this.call_sequence <> 0x00 {
|
||||
return base."#bad call sequence"
|
||||
}
|
||||
|
||||
a = args.src.read_u32le?()
|
||||
if a <> 'qoif'le {
|
||||
return "#bad header"
|
||||
}
|
||||
|
||||
a = args.src.read_u32be?()
|
||||
if a > 0xFF_FFFF {
|
||||
return base."#unsupported image dimension"
|
||||
}
|
||||
this.width = a
|
||||
|
||||
a = args.src.read_u32be?()
|
||||
if a > 0xFF_FFFF {
|
||||
return base."#unsupported image dimension"
|
||||
}
|
||||
this.height = a
|
||||
|
||||
a = args.src.read_u8_as_u32?()
|
||||
if a == 3 {
|
||||
this.pixfmt = base.PIXEL_FORMAT__BGRX
|
||||
} else if a == 4 {
|
||||
this.pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL
|
||||
} else {
|
||||
return "#bad header"
|
||||
}
|
||||
|
||||
args.src.skip?(n: 1)
|
||||
|
||||
if args.dst <> nullptr {
|
||||
args.dst.set!(
|
||||
pixfmt: this.pixfmt,
|
||||
pixsub: 0,
|
||||
width: this.width,
|
||||
height: this.height,
|
||||
first_frame_io_position: 14,
|
||||
first_frame_is_opaque: this.pixfmt == base.PIXEL_FORMAT__BGRX)
|
||||
}
|
||||
|
||||
this.call_sequence = 0x20
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
if this.call_sequence == 0x20 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x20 {
|
||||
this.do_decode_image_config?(dst: nullptr, src: args.src)
|
||||
} else if this.call_sequence == 0x28 {
|
||||
if 16 <> args.src.position() {
|
||||
return base."#bad restart"
|
||||
}
|
||||
} else if this.call_sequence == 0x40 {
|
||||
this.call_sequence = 0x60
|
||||
return base."@end of data"
|
||||
} else {
|
||||
return base."@end of data"
|
||||
}
|
||||
|
||||
if args.dst <> nullptr {
|
||||
args.dst.set!(bounds: this.util.make_rect_ie_u32(
|
||||
min_incl_x: 0,
|
||||
min_incl_y: 0,
|
||||
max_excl_x: this.width,
|
||||
max_excl_y: this.height),
|
||||
duration: 0,
|
||||
index: 0,
|
||||
io_position: 14,
|
||||
disposal: 0,
|
||||
opaque_within_bounds: this.pixfmt == base.PIXEL_FORMAT__BGRX,
|
||||
overwrite_instead_of_blend: false,
|
||||
background_color: 0x0000_0000)
|
||||
}
|
||||
|
||||
this.call_sequence = 0x40
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
}
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
var c64 : base.u64
|
||||
|
||||
if this.call_sequence == 0x40 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x40 {
|
||||
this.do_decode_frame_config?(dst: nullptr, src: args.src)
|
||||
} else {
|
||||
return base."@end of data"
|
||||
}
|
||||
|
||||
status = this.swizzler.prepare!(
|
||||
dst_pixfmt: args.dst.pixel_format(),
|
||||
dst_palette: args.dst.palette(),
|
||||
src_pixfmt: this.util.make_pixel_format(repr: this.pixfmt),
|
||||
src_palette: this.util.empty_slice_u8(),
|
||||
blend: args.blend)
|
||||
if not status.is_ok() {
|
||||
return status
|
||||
}
|
||||
|
||||
this.dst_x = 0
|
||||
this.dst_y = 0
|
||||
this.pixel[0] = 0x00
|
||||
this.pixel[1] = 0x00
|
||||
this.pixel[2] = 0x00
|
||||
this.pixel[3] = 0xFF
|
||||
this.cache[.. 256].bulk_memset!(byte_value: 0)
|
||||
|
||||
this.remaining_pixels_times_4 = (this.width as base.u64) * (this.height as base.u64) * 4
|
||||
while this.remaining_pixels_times_4 > 0 {
|
||||
this.from_src_to_buffer?(src: args.src)
|
||||
if this.remaining_pixels_times_4 < (this.buffer_index as base.u64) {
|
||||
return base."#too much data"
|
||||
}
|
||||
this.remaining_pixels_times_4 -= this.buffer_index as base.u64
|
||||
status = this.from_buffer_to_dst!(dst: args.dst)
|
||||
if not status.is_ok() {
|
||||
return status
|
||||
}
|
||||
}
|
||||
|
||||
c64 = args.src.read_u64be?()
|
||||
if c64 <> 1 {
|
||||
return "#bad footer"
|
||||
}
|
||||
|
||||
this.call_sequence = 0x60
|
||||
}
|
||||
|
||||
pri func decoder.from_src_to_buffer?(src: base.io_reader) {
|
||||
var c8 : base.u8
|
||||
var dg : base.u8
|
||||
var bi : base.u32[..= 8192]
|
||||
var bj : base.u32[..= 8188]
|
||||
var bk : base.u32[..= 7936]
|
||||
var ci : base.u32[..= 252]
|
||||
var hash4 : base.u32[..= 252]
|
||||
|
||||
bk = 7936 // 4 * (2048 - 64), so we always have room for a QOI_OP_RUN.
|
||||
if this.remaining_pixels_times_4 < 7936 {
|
||||
bk = this.remaining_pixels_times_4 as base.u32
|
||||
}
|
||||
|
||||
while bi < bk {
|
||||
assert bi < 7936 via "a < b: a < c; c <= b"(c: bk)
|
||||
c8 = args.src.read_u8?()
|
||||
if c8 == 0xFE { // QOI_OP_RGB.
|
||||
this.pixel[2] = args.src.read_u8?()
|
||||
this.pixel[1] = args.src.read_u8?()
|
||||
this.pixel[0] = args.src.read_u8?()
|
||||
|
||||
} else if c8 == 0xFF { // QOI_OP_RGBA.
|
||||
this.pixel[2] = args.src.read_u8?()
|
||||
this.pixel[1] = args.src.read_u8?()
|
||||
this.pixel[0] = args.src.read_u8?()
|
||||
this.pixel[3] = args.src.read_u8?()
|
||||
|
||||
} else if (c8 >> 6) == 0 { // QOI_OP_INDEX.
|
||||
ci = 4 * ((c8 & 0x3F) as base.u32)
|
||||
this.pixel[0] = this.cache[ci + 0]
|
||||
this.pixel[1] = this.cache[ci + 1]
|
||||
this.pixel[2] = this.cache[ci + 2]
|
||||
this.pixel[3] = this.cache[ci + 3]
|
||||
this.buffer[bi + 0] = this.pixel[0]
|
||||
this.buffer[bi + 1] = this.pixel[1]
|
||||
this.buffer[bi + 2] = this.pixel[2]
|
||||
this.buffer[bi + 3] = this.pixel[3]
|
||||
bi += 4
|
||||
continue
|
||||
|
||||
} else if (c8 >> 6) == 1 { // QOI_OP_DIFF.
|
||||
this.pixel[2] ~mod+= ((c8 >> 4) & 0x03) ~mod+ 0xFE
|
||||
this.pixel[1] ~mod+= ((c8 >> 2) & 0x03) ~mod+ 0xFE
|
||||
this.pixel[0] ~mod+= ((c8 >> 0) & 0x03) ~mod+ 0xFE
|
||||
|
||||
} else if (c8 >> 6) == 2 { // QOI_OP_LUMA.
|
||||
dg = (c8 & 0x3F) ~mod+ 0xE0
|
||||
c8 = args.src.read_u8?()
|
||||
this.pixel[2] ~mod+= (dg ~mod+ 0xF8) ~mod+ (0x0F & (c8 >> 4))
|
||||
this.pixel[1] ~mod+= dg
|
||||
this.pixel[0] ~mod+= (dg ~mod+ 0xF8) ~mod+ (0x0F & (c8 >> 0))
|
||||
|
||||
} else { // QOI_OP_RUN.
|
||||
bj = bi + (4 * (0x3F & (1 + (c8 as base.u32))))
|
||||
while bi < bj {
|
||||
assert bi < 8188 via "a < b: a < c; c <= b"(c: bj)
|
||||
this.buffer[bi + 0] = this.pixel[0]
|
||||
this.buffer[bi + 1] = this.pixel[1]
|
||||
this.buffer[bi + 2] = this.pixel[2]
|
||||
this.buffer[bi + 3] = this.pixel[3]
|
||||
bi += 4
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
hash4 = 4 * (63 & (
|
||||
((this.pixel[2] as base.u32) * 3) +
|
||||
((this.pixel[1] as base.u32) * 5) +
|
||||
((this.pixel[0] as base.u32) * 7) +
|
||||
((this.pixel[3] as base.u32) * 11)))
|
||||
this.cache[hash4 + 0] = this.pixel[0]
|
||||
this.cache[hash4 + 1] = this.pixel[1]
|
||||
this.cache[hash4 + 2] = this.pixel[2]
|
||||
this.cache[hash4 + 3] = this.pixel[3]
|
||||
|
||||
this.buffer[bi + 0] = this.pixel[0]
|
||||
this.buffer[bi + 1] = this.pixel[1]
|
||||
this.buffer[bi + 2] = this.pixel[2]
|
||||
this.buffer[bi + 3] = this.pixel[3]
|
||||
bi += 4
|
||||
}
|
||||
|
||||
this.buffer_index = bi
|
||||
}
|
||||
|
||||
pri func decoder.from_buffer_to_dst!(dst: ptr base.pixel_buffer) base.status {
|
||||
var dst_pixfmt : base.pixel_format
|
||||
var dst_bits_per_pixel : base.u32[..= 256]
|
||||
var dst_bytes_per_pixel : base.u32[..= 32]
|
||||
var dst_bytes_per_row : base.u64
|
||||
var tab : table base.u8
|
||||
var bi : base.u32
|
||||
var rem_x : base.u32[..= 0xFF_FFFF]
|
||||
var dst : slice base.u8
|
||||
var src : slice base.u8
|
||||
var src_length : base.u32
|
||||
var i : base.u64
|
||||
|
||||
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
|
||||
// to chain the two calls: "args.dst.pixel_format().bits_per_pixel()".
|
||||
dst_pixfmt = args.dst.pixel_format()
|
||||
dst_bits_per_pixel = dst_pixfmt.bits_per_pixel()
|
||||
if (dst_bits_per_pixel & 7) <> 0 {
|
||||
return base."#unsupported option"
|
||||
}
|
||||
dst_bytes_per_pixel = dst_bits_per_pixel / 8
|
||||
dst_bytes_per_row = (this.width * dst_bytes_per_pixel) as base.u64
|
||||
tab = args.dst.plane(p: 0)
|
||||
|
||||
while bi < this.buffer_index {
|
||||
assert bi < 8192 via "a < b: a < c; c <= b"(c: this.buffer_index)
|
||||
|
||||
if this.width <= this.dst_x {
|
||||
this.dst_x = 0
|
||||
this.dst_y ~mod+= 1
|
||||
if this.dst_y >= this.height {
|
||||
break
|
||||
}
|
||||
rem_x = this.width
|
||||
} else {
|
||||
rem_x = this.width - this.dst_x
|
||||
}
|
||||
|
||||
src = this.buffer[bi .. this.buffer_index]
|
||||
if ((4 * rem_x) as base.u64) < src.length() {
|
||||
src = src[.. (4 * rem_x) as base.u64]
|
||||
}
|
||||
src_length = (src.length() & 0xFFFF_FFFF) as base.u32
|
||||
bi ~mod+= src_length
|
||||
|
||||
dst = tab.row_u32(y: this.dst_y)
|
||||
if dst_bytes_per_row < dst.length() {
|
||||
dst = dst[.. dst_bytes_per_row]
|
||||
}
|
||||
|
||||
i = (this.dst_x as base.u64) * (dst_bytes_per_pixel as base.u64)
|
||||
this.dst_x ~mod+= src_length / 4
|
||||
if i < dst.length() {
|
||||
this.swizzler.swizzle_interleaved_from_slice!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: args.dst.palette(),
|
||||
src: src)
|
||||
}
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
|
||||
return this.util.make_rect_ie_u32(
|
||||
min_incl_x: 0,
|
||||
min_incl_y: 0,
|
||||
max_excl_x: this.width,
|
||||
max_excl_y: this.height)
|
||||
}
|
||||
|
||||
pub func decoder.num_animation_loops() base.u32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
pub func decoder.num_decoded_frame_configs() base.u64 {
|
||||
if this.call_sequence > 0x20 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
pub func decoder.num_decoded_frames() base.u64 {
|
||||
if this.call_sequence > 0x40 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.status {
|
||||
if this.call_sequence < 0x20 {
|
||||
return base."#bad call sequence"
|
||||
}
|
||||
if (args.index <> 0) or (args.io_position <> 14) {
|
||||
return base."#bad argument"
|
||||
}
|
||||
this.call_sequence = 0x28
|
||||
return ok
|
||||
}
|
||||
|
||||
pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
|
||||
// No-op. QOI doesn't support metadata.
|
||||
}
|
||||
|
||||
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
|
||||
return base."#no more information"
|
||||
}
|
||||
|
||||
pub func decoder.workbuf_len() base.range_ii_u64 {
|
||||
return this.util.make_range_ii_u64(min_incl: 0, max_incl: 0)
|
||||
}
|
||||
@@ -321,9 +321,9 @@ pri func decoder.apply_transform_cross_color!(pix: slice base.u8, tile_data: ros
|
||||
assert x < 0x4000 via "a < b: a < c; c <= b"(c: this.width)
|
||||
|
||||
if ((x & mask) == 0) and (tile_data.length() >= 4) {
|
||||
g2r = SIGN_EXTEND_I8_I32[tile_data[0]]
|
||||
g2b = SIGN_EXTEND_I8_I32[tile_data[1]]
|
||||
r2b = SIGN_EXTEND_I8_I32[tile_data[2]]
|
||||
g2r = this.util.sign_extend_convert_u8_u32(a: tile_data[0])
|
||||
g2b = this.util.sign_extend_convert_u8_u32(a: tile_data[1])
|
||||
r2b = this.util.sign_extend_convert_u8_u32(a: tile_data[2])
|
||||
tile_data = tile_data[4 ..]
|
||||
}
|
||||
|
||||
@@ -331,9 +331,9 @@ pri func decoder.apply_transform_cross_color!(pix: slice base.u8, tile_data: ros
|
||||
b = args.pix[0]
|
||||
g = args.pix[1]
|
||||
r = args.pix[2]
|
||||
r ~mod+= (((SIGN_EXTEND_I8_I32[g] ~mod* g2r) >> 5) & 0xFF) as base.u8
|
||||
b ~mod+= (((SIGN_EXTEND_I8_I32[g] ~mod* g2b) >> 5) & 0xFF) as base.u8
|
||||
b ~mod+= (((SIGN_EXTEND_I8_I32[r] ~mod* r2b) >> 5) & 0xFF) as base.u8
|
||||
r ~mod+= (((this.util.sign_extend_convert_u8_u32(a: g) ~mod* g2r) >> 5) & 0xFF) as base.u8
|
||||
b ~mod+= (((this.util.sign_extend_convert_u8_u32(a: g) ~mod* g2b) >> 5) & 0xFF) as base.u8
|
||||
b ~mod+= (((this.util.sign_extend_convert_u8_u32(a: r) ~mod* r2b) >> 5) & 0xFF) as base.u8
|
||||
args.pix[0] = b
|
||||
args.pix[2] = r
|
||||
args.pix = args.pix[4 ..]
|
||||
@@ -379,8 +379,18 @@ pri func decoder.apply_transform_color_indexing!(pix: slice base.u8) {
|
||||
|
||||
tile_size_log2 = this.transform_tile_size_log2[3] as base.u32
|
||||
if tile_size_log2 == 0 {
|
||||
// TODO: the code below is correct, but we could possibly simplify the
|
||||
// case where the src and dst pixel counts are 1:1.
|
||||
iterate (dst = args.pix)(length: 4, advance: 4, unroll: 1) {
|
||||
p = (dst[1] as base.u32) * 4
|
||||
p0 = this.palette[p + 0]
|
||||
p1 = this.palette[p + 1]
|
||||
p2 = this.palette[p + 2]
|
||||
p3 = this.palette[p + 3]
|
||||
dst[0] = p0
|
||||
dst[1] = p1
|
||||
dst[2] = p2
|
||||
dst[3] = p3
|
||||
}
|
||||
return nothing
|
||||
}
|
||||
|
||||
bits_per_pixel = (8 as base.u32) >> tile_size_log2
|
||||
@@ -426,39 +436,3 @@ pri func decoder.apply_transform_color_indexing!(pix: slice base.u8) {
|
||||
y += 1
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: we shouldn't need a lookup table for converting i8 to i32.
|
||||
pri const SIGN_EXTEND_I8_I32 : roarray[256] base.u32 = [
|
||||
0x0000_0000, 0x0000_0001, 0x0000_0002, 0x0000_0003, 0x0000_0004, 0x0000_0005, 0x0000_0006, 0x0000_0007,
|
||||
0x0000_0008, 0x0000_0009, 0x0000_000A, 0x0000_000B, 0x0000_000C, 0x0000_000D, 0x0000_000E, 0x0000_000F,
|
||||
0x0000_0010, 0x0000_0011, 0x0000_0012, 0x0000_0013, 0x0000_0014, 0x0000_0015, 0x0000_0016, 0x0000_0017,
|
||||
0x0000_0018, 0x0000_0019, 0x0000_001A, 0x0000_001B, 0x0000_001C, 0x0000_001D, 0x0000_001E, 0x0000_001F,
|
||||
0x0000_0020, 0x0000_0021, 0x0000_0022, 0x0000_0023, 0x0000_0024, 0x0000_0025, 0x0000_0026, 0x0000_0027,
|
||||
0x0000_0028, 0x0000_0029, 0x0000_002A, 0x0000_002B, 0x0000_002C, 0x0000_002D, 0x0000_002E, 0x0000_002F,
|
||||
0x0000_0030, 0x0000_0031, 0x0000_0032, 0x0000_0033, 0x0000_0034, 0x0000_0035, 0x0000_0036, 0x0000_0037,
|
||||
0x0000_0038, 0x0000_0039, 0x0000_003A, 0x0000_003B, 0x0000_003C, 0x0000_003D, 0x0000_003E, 0x0000_003F,
|
||||
0x0000_0040, 0x0000_0041, 0x0000_0042, 0x0000_0043, 0x0000_0044, 0x0000_0045, 0x0000_0046, 0x0000_0047,
|
||||
0x0000_0048, 0x0000_0049, 0x0000_004A, 0x0000_004B, 0x0000_004C, 0x0000_004D, 0x0000_004E, 0x0000_004F,
|
||||
0x0000_0050, 0x0000_0051, 0x0000_0052, 0x0000_0053, 0x0000_0054, 0x0000_0055, 0x0000_0056, 0x0000_0057,
|
||||
0x0000_0058, 0x0000_0059, 0x0000_005A, 0x0000_005B, 0x0000_005C, 0x0000_005D, 0x0000_005E, 0x0000_005F,
|
||||
0x0000_0060, 0x0000_0061, 0x0000_0062, 0x0000_0063, 0x0000_0064, 0x0000_0065, 0x0000_0066, 0x0000_0067,
|
||||
0x0000_0068, 0x0000_0069, 0x0000_006A, 0x0000_006B, 0x0000_006C, 0x0000_006D, 0x0000_006E, 0x0000_006F,
|
||||
0x0000_0070, 0x0000_0071, 0x0000_0072, 0x0000_0073, 0x0000_0074, 0x0000_0075, 0x0000_0076, 0x0000_0077,
|
||||
0x0000_0078, 0x0000_0079, 0x0000_007A, 0x0000_007B, 0x0000_007C, 0x0000_007D, 0x0000_007E, 0x0000_007F,
|
||||
0xFFFF_FF80, 0xFFFF_FF81, 0xFFFF_FF82, 0xFFFF_FF83, 0xFFFF_FF84, 0xFFFF_FF85, 0xFFFF_FF86, 0xFFFF_FF87,
|
||||
0xFFFF_FF88, 0xFFFF_FF89, 0xFFFF_FF8A, 0xFFFF_FF8B, 0xFFFF_FF8C, 0xFFFF_FF8D, 0xFFFF_FF8E, 0xFFFF_FF8F,
|
||||
0xFFFF_FF90, 0xFFFF_FF91, 0xFFFF_FF92, 0xFFFF_FF93, 0xFFFF_FF94, 0xFFFF_FF95, 0xFFFF_FF96, 0xFFFF_FF97,
|
||||
0xFFFF_FF98, 0xFFFF_FF99, 0xFFFF_FF9A, 0xFFFF_FF9B, 0xFFFF_FF9C, 0xFFFF_FF9D, 0xFFFF_FF9E, 0xFFFF_FF9F,
|
||||
0xFFFF_FFA0, 0xFFFF_FFA1, 0xFFFF_FFA2, 0xFFFF_FFA3, 0xFFFF_FFA4, 0xFFFF_FFA5, 0xFFFF_FFA6, 0xFFFF_FFA7,
|
||||
0xFFFF_FFA8, 0xFFFF_FFA9, 0xFFFF_FFAA, 0xFFFF_FFAB, 0xFFFF_FFAC, 0xFFFF_FFAD, 0xFFFF_FFAE, 0xFFFF_FFAF,
|
||||
0xFFFF_FFB0, 0xFFFF_FFB1, 0xFFFF_FFB2, 0xFFFF_FFB3, 0xFFFF_FFB4, 0xFFFF_FFB5, 0xFFFF_FFB6, 0xFFFF_FFB7,
|
||||
0xFFFF_FFB8, 0xFFFF_FFB9, 0xFFFF_FFBA, 0xFFFF_FFBB, 0xFFFF_FFBC, 0xFFFF_FFBD, 0xFFFF_FFBE, 0xFFFF_FFBF,
|
||||
0xFFFF_FFC0, 0xFFFF_FFC1, 0xFFFF_FFC2, 0xFFFF_FFC3, 0xFFFF_FFC4, 0xFFFF_FFC5, 0xFFFF_FFC6, 0xFFFF_FFC7,
|
||||
0xFFFF_FFC8, 0xFFFF_FFC9, 0xFFFF_FFCA, 0xFFFF_FFCB, 0xFFFF_FFCC, 0xFFFF_FFCD, 0xFFFF_FFCE, 0xFFFF_FFCF,
|
||||
0xFFFF_FFD0, 0xFFFF_FFD1, 0xFFFF_FFD2, 0xFFFF_FFD3, 0xFFFF_FFD4, 0xFFFF_FFD5, 0xFFFF_FFD6, 0xFFFF_FFD7,
|
||||
0xFFFF_FFD8, 0xFFFF_FFD9, 0xFFFF_FFDA, 0xFFFF_FFDB, 0xFFFF_FFDC, 0xFFFF_FFDD, 0xFFFF_FFDE, 0xFFFF_FFDF,
|
||||
0xFFFF_FFE0, 0xFFFF_FFE1, 0xFFFF_FFE2, 0xFFFF_FFE3, 0xFFFF_FFE4, 0xFFFF_FFE5, 0xFFFF_FFE6, 0xFFFF_FFE7,
|
||||
0xFFFF_FFE8, 0xFFFF_FFE9, 0xFFFF_FFEA, 0xFFFF_FFEB, 0xFFFF_FFEC, 0xFFFF_FFED, 0xFFFF_FFEE, 0xFFFF_FFEF,
|
||||
0xFFFF_FFF0, 0xFFFF_FFF1, 0xFFFF_FFF2, 0xFFFF_FFF3, 0xFFFF_FFF4, 0xFFFF_FFF5, 0xFFFF_FFF6, 0xFFFF_FFF7,
|
||||
0xFFFF_FFF8, 0xFFFF_FFF9, 0xFFFF_FFFA, 0xFFFF_FFFB, 0xFFFF_FFFC, 0xFFFF_FFFD, 0xFFFF_FFFE, 0xFFFF_FFFF,
|
||||
]
|
||||
+44
-24
@@ -466,6 +466,7 @@ pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reade
|
||||
}
|
||||
|
||||
pri func decoder.decode_transform?(src: base.io_reader, workbuf: slice base.u8) {
|
||||
var status : base.status
|
||||
var c8 : base.u8
|
||||
var transform_type : base.u32[..= 3]
|
||||
var tile_size_log2 : base.u32[..= 9]
|
||||
@@ -510,19 +511,29 @@ pri func decoder.decode_transform?(src: base.io_reader, workbuf: slice base.u8)
|
||||
|
||||
this.decode_color_cache_parameters?(src: args.src)
|
||||
this.decode_huffman_groups?(src: args.src, n_huffman_groups: 1)
|
||||
if ((this.workbuf_offset_for_transform[transform_type + 1] as base.u64) > (this.workbuf_offset_for_transform[transform_type + 2] as base.u64)) or
|
||||
((this.workbuf_offset_for_transform[transform_type + 2] as base.u64) > args.workbuf.length()) {
|
||||
return base."#bad workbuf length"
|
||||
|
||||
while true,
|
||||
inv transform_type < 2,
|
||||
inv tile_size_log2 >= 2,
|
||||
{
|
||||
if ((this.workbuf_offset_for_transform[transform_type + 1] as base.u64) > (this.workbuf_offset_for_transform[transform_type + 2] as base.u64)) or
|
||||
((this.workbuf_offset_for_transform[transform_type + 2] as base.u64) > args.workbuf.length()) {
|
||||
return base."#bad workbuf length"
|
||||
}
|
||||
status =? this.decode_pixels?(
|
||||
dst: args.workbuf[
|
||||
(this.workbuf_offset_for_transform[transform_type + 1] as base.u64) ..
|
||||
(this.workbuf_offset_for_transform[transform_type + 2] as base.u64)],
|
||||
src: args.src,
|
||||
width: (this.width + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
height: (this.height + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
tile_data: this.util.empty_slice_u8(),
|
||||
tile_size_log2: 0)
|
||||
if status.is_ok() {
|
||||
break
|
||||
}
|
||||
yield? status
|
||||
}
|
||||
this.decode_pixels?(
|
||||
dst: args.workbuf[
|
||||
(this.workbuf_offset_for_transform[transform_type + 1] as base.u64) ..
|
||||
(this.workbuf_offset_for_transform[transform_type + 2] as base.u64)],
|
||||
src: args.src,
|
||||
width: (this.width + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
height: (this.height + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
tile_data: this.util.empty_slice_u8(),
|
||||
tile_size_log2: 0)
|
||||
|
||||
} else if transform_type == 2 { // Subtract Green transform.
|
||||
// No-op.
|
||||
@@ -620,6 +631,7 @@ pri func decoder.decode_color_cache_parameters?(src: base.io_reader) {
|
||||
}
|
||||
|
||||
pri func decoder.decode_hg_table?(src: base.io_reader, width: base.u32[..= 0x4000], workbuf: slice base.u8) {
|
||||
var status : base.status
|
||||
var c8 : base.u8
|
||||
var use_hg_table : base.u32[..= 1]
|
||||
var tile_size_log2 : base.u32[..= 9]
|
||||
@@ -674,19 +686,27 @@ pri func decoder.decode_hg_table?(src: base.io_reader, width: base.u32[..= 0x400
|
||||
|
||||
this.decode_color_cache_parameters?(src: args.src)
|
||||
this.decode_huffman_groups?(src: args.src, n_huffman_groups: 1)
|
||||
if ((this.workbuf_offset_for_transform[0] as base.u64) > (this.workbuf_offset_for_transform[1] as base.u64)) or
|
||||
((this.workbuf_offset_for_transform[1] as base.u64) > args.workbuf.length()) {
|
||||
return base."#bad workbuf length"
|
||||
while true,
|
||||
inv tile_size_log2 >= 2,
|
||||
{
|
||||
if ((this.workbuf_offset_for_transform[0] as base.u64) > (this.workbuf_offset_for_transform[1] as base.u64)) or
|
||||
((this.workbuf_offset_for_transform[1] as base.u64) > args.workbuf.length()) {
|
||||
return base."#bad workbuf length"
|
||||
}
|
||||
status =? this.decode_pixels?(
|
||||
dst: args.workbuf[
|
||||
(this.workbuf_offset_for_transform[0] as base.u64) ..
|
||||
(this.workbuf_offset_for_transform[1] as base.u64)],
|
||||
src: args.src,
|
||||
width: (args.width + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
height: (this.height + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
tile_data: this.util.empty_slice_u8(),
|
||||
tile_size_log2: 0)
|
||||
if status.is_ok() {
|
||||
break
|
||||
}
|
||||
yield? status
|
||||
}
|
||||
this.decode_pixels?(
|
||||
dst: args.workbuf[
|
||||
(this.workbuf_offset_for_transform[0] as base.u64) ..
|
||||
(this.workbuf_offset_for_transform[1] as base.u64)],
|
||||
src: args.src,
|
||||
width: (args.width + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
height: (this.height + (((1 as base.u32) << tile_size_log2) - 1)) >> tile_size_log2,
|
||||
tile_data: this.util.empty_slice_u8(),
|
||||
tile_size_log2: 0)
|
||||
|
||||
this.overall_n_huffman_groups = 1
|
||||
if ((this.workbuf_offset_for_transform[0] as base.u64) > (this.workbuf_offset_for_transform[1] as base.u64)) or
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash -eu
|
||||
# Copyright 2024 The Wuffs Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
# ----------------
|
||||
|
||||
# This script fetches libwebp's test data suite.
|
||||
|
||||
if [ ! -e ../../wuffs-root-directory.txt ]; then
|
||||
echo "$0 should be run from the Wuffs test/3pdata directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check out a specific commit (from July 2024).
|
||||
git clone --quiet https://github.com/webmproject/libwebp-test-data.git webpsuite
|
||||
cd webpsuite
|
||||
git reset --quiet --hard 260804d686f0491e0326a50eef491829dae09e9e
|
||||
@@ -0,0 +1,55 @@
|
||||
# Generated by script/print-nia-checksums.sh
|
||||
OK. ca4c0038 test/3pdata/webpsuite/bad_palette_index.webp
|
||||
OK. 6fbda804 test/3pdata/webpsuite/color_cache_bits_11.webp
|
||||
BAD d338aed8 test/3pdata/webpsuite/dual_transform.webp
|
||||
OK. 1ef61f19 test/3pdata/webpsuite/grid.bmp
|
||||
OK. 33b7a1f3 test/3pdata/webpsuite/grid.pgm
|
||||
OK. f79224e7 test/3pdata/webpsuite/grid.png
|
||||
OK. 06b07a30 test/3pdata/webpsuite/grid.ppm
|
||||
OK. fce8fc76 test/3pdata/webpsuite/lossless1.webp
|
||||
OK. fce8fc76 test/3pdata/webpsuite/lossless2.webp
|
||||
OK. fce8fc76 test/3pdata/webpsuite/lossless3.webp
|
||||
OK. 4cbe795c test/3pdata/webpsuite/lossless4.webp
|
||||
OK. f8e3adf4 test/3pdata/webpsuite/lossless_big_random_alpha.webp
|
||||
OK. 289af407 test/3pdata/webpsuite/lossless_color_transform.bmp
|
||||
OK. 7b7c1ae6 test/3pdata/webpsuite/lossless_color_transform.pgm
|
||||
OK. 289af407 test/3pdata/webpsuite/lossless_color_transform.ppm
|
||||
OK. 289af407 test/3pdata/webpsuite/lossless_color_transform.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_0.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_1.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_10.webp
|
||||
BAD df11692d test/3pdata/webpsuite/lossless_vec_1_11.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_12.webp
|
||||
BAD df11692d test/3pdata/webpsuite/lossless_vec_1_13.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_14.webp
|
||||
BAD df11692d test/3pdata/webpsuite/lossless_vec_1_15.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_2.webp
|
||||
BAD df11692d test/3pdata/webpsuite/lossless_vec_1_3.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_4.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_5.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_6.webp
|
||||
BAD df11692d test/3pdata/webpsuite/lossless_vec_1_7.webp
|
||||
OK. f79224e7 test/3pdata/webpsuite/lossless_vec_1_8.webp
|
||||
BAD df11692d test/3pdata/webpsuite/lossless_vec_1_9.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_0.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_1.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_10.webp
|
||||
BAD 62adeb37 test/3pdata/webpsuite/lossless_vec_2_11.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_12.webp
|
||||
BAD 62adeb37 test/3pdata/webpsuite/lossless_vec_2_13.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_14.webp
|
||||
BAD 62adeb37 test/3pdata/webpsuite/lossless_vec_2_15.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_2.webp
|
||||
BAD 62adeb37 test/3pdata/webpsuite/lossless_vec_2_3.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_4.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_5.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_6.webp
|
||||
BAD 62adeb37 test/3pdata/webpsuite/lossless_vec_2_7.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/lossless_vec_2_8.webp
|
||||
BAD 62adeb37 test/3pdata/webpsuite/lossless_vec_2_9.webp
|
||||
OK. 6957defa test/3pdata/webpsuite/near_lossless_75.webp
|
||||
OK. 7c80a001 test/3pdata/webpsuite/one_color_no_palette.webp
|
||||
OK. 6706e719 test/3pdata/webpsuite/peak.bmp
|
||||
OK. 315bbd77 test/3pdata/webpsuite/peak.pgm
|
||||
OK. 6706e719 test/3pdata/webpsuite/peak.png
|
||||
OK. 6706e719 test/3pdata/webpsuite/peak.ppm
|
||||
+46
-2
@@ -95,6 +95,48 @@ test_wuffs_jpeg_decode_interface() {
|
||||
"test/data/bricks-color.jpeg", 0, SIZE_MAX, 160, 120, 0xFF012466);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_jpeg_decode_lower_quality() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_jpeg__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_jpeg__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
wuffs_jpeg__decoder__set_quirk(
|
||||
&dec, WUFFS_BASE__QUIRK_QUALITY,
|
||||
WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY);
|
||||
CHECK_STRING(do_test__wuffs_base__image_decoder(
|
||||
wuffs_jpeg__decoder__upcast_as__wuffs_base__image_decoder(&dec),
|
||||
"test/data/bricks-color.jpeg", 0, SIZE_MAX, 160, 120, 0xFF012466));
|
||||
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = g_src_slice_u8,
|
||||
});
|
||||
CHECK_STRING(read_file(&src, "test/data/bricks-color.jpeg"));
|
||||
CHECK_STATUS("initialize", wuffs_jpeg__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__DEFAULT_OPTIONS));
|
||||
CHECK_STATUS("decode_image_config",
|
||||
wuffs_jpeg__decoder__decode_image_config(&dec, NULL, &src));
|
||||
|
||||
for (int q = 0; q < 2; q++) {
|
||||
if (q) {
|
||||
wuffs_jpeg__decoder__set_quirk(
|
||||
&dec, WUFFS_BASE__QUIRK_QUALITY,
|
||||
WUFFS_BASE__QUIRK_QUALITY__VALUE__LOWER_QUALITY);
|
||||
}
|
||||
uint64_t m = wuffs_jpeg__decoder__workbuf_len(&dec).min_incl;
|
||||
if ((q == 0) && (m == 0)) {
|
||||
RETURN_FAIL("q=%d: have %" PRIu64 ", want non-zero", q, m);
|
||||
} else if ((q != 0) && (m != 0)) {
|
||||
RETURN_FAIL("q=%d: have %" PRIu64 ", want zero", q, m);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_jpeg_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -739,8 +781,9 @@ test_wuffs_jpeg_decode_mcu() {
|
||||
for (int b = 0; b < 6; b++) {
|
||||
const uint32_t mx = 0;
|
||||
const uint32_t my = 0;
|
||||
if (wuffs_jpeg__decoder__decode_mcu(&dec, wuffs_base__empty_slice_u8(), mx,
|
||||
my)) {
|
||||
wuffs_base__pixel_buffer dst = {0};
|
||||
if (wuffs_jpeg__decoder__decode_mcu(&dec, &dst,
|
||||
wuffs_base__empty_slice_u8(), mx, my)) {
|
||||
RETURN_FAIL("decode_mcu failed");
|
||||
}
|
||||
|
||||
@@ -988,6 +1031,7 @@ proc g_tests[] = {
|
||||
test_wuffs_jpeg_decode_idct,
|
||||
test_wuffs_jpeg_decode_mcu,
|
||||
test_wuffs_jpeg_decode_interface,
|
||||
test_wuffs_jpeg_decode_lower_quality,
|
||||
test_wuffs_jpeg_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
// Copyright 2024 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
|
||||
// ----------------
|
||||
|
||||
/*
|
||||
This test program is typically run indirectly, by the "wuffs test" or "wuffs
|
||||
bench" commands. These commands take an optional "-mimic" flag to check that
|
||||
Wuffs' output mimics (i.e. exactly matches) other libraries' output, such as
|
||||
giflib for GIF, libpng for PNG, etc.
|
||||
|
||||
To manually run this test:
|
||||
|
||||
for CC in clang gcc; do
|
||||
$CC -std=c99 -Wall -Werror qoi.c && ./a.out
|
||||
rm -f a.out
|
||||
done
|
||||
|
||||
Each edition should print "PASS", amongst other information, and exit(0).
|
||||
|
||||
Add the "wuffs mimic cflags" (everything after the colon below) to the C
|
||||
compiler flags (after the .c file) to run the mimic tests.
|
||||
|
||||
To manually run the benchmarks, replace "-Wall -Werror" with "-O3" and replace
|
||||
the first "./a.out" with "./a.out -bench". Combine these changes with the
|
||||
"wuffs mimic cflags" to run the mimic benchmarks.
|
||||
*/
|
||||
|
||||
// ¿ wuffs mimic cflags: -DWUFFS_MIMIC
|
||||
|
||||
// Wuffs ships as a "single file C library" or "header file library" as per
|
||||
// https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
|
||||
//
|
||||
// To use that single file as a "foo.c"-like implementation, instead of a
|
||||
// "foo.h"-like header, #define WUFFS_IMPLEMENTATION before #include'ing or
|
||||
// compiling it.
|
||||
#define WUFFS_IMPLEMENTATION
|
||||
|
||||
// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of
|
||||
// release/c/etc.c choose which parts of Wuffs to build. That file contains the
|
||||
// entire Wuffs standard library, implementing a variety of codecs and file
|
||||
// formats. Without this macro definition, an optimizing compiler or linker may
|
||||
// very well discard Wuffs code for unused codecs, but listing the Wuffs
|
||||
// modules we use makes that process explicit. Preprocessing means that such
|
||||
// code simply isn't compiled.
|
||||
#define WUFFS_CONFIG__MODULES
|
||||
#define WUFFS_CONFIG__MODULE__BASE
|
||||
#define WUFFS_CONFIG__MODULE__QOI
|
||||
|
||||
// If building this program in an environment that doesn't easily accommodate
|
||||
// relative includes, you can use the script/inline-c-relative-includes.go
|
||||
// program to generate a stand-alone C file.
|
||||
#include "../../../release/c/wuffs-unsupported-snapshot.c"
|
||||
#include "../testlib/testlib.c"
|
||||
#ifdef WUFFS_MIMIC
|
||||
// No mimic library.
|
||||
#endif
|
||||
|
||||
// ---------------- QOI Tests
|
||||
|
||||
const char* //
|
||||
test_wuffs_qoi_decode_interface() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_qoi__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_qoi__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
return do_test__wuffs_base__image_decoder(
|
||||
wuffs_qoi__decoder__upcast_as__wuffs_base__image_decoder(&dec),
|
||||
"test/data/bricks-color.qoi", 0, SIZE_MAX, 160, 120, 0xFF022460);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_qoi_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_qoi__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_qoi__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_qoi__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_qoi__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_qoi__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_qoi__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_qoi_decode_frame_config() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_qoi__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_qoi__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = g_src_slice_u8,
|
||||
});
|
||||
CHECK_STRING(read_file(&src, "test/data/bricks-color.qoi"));
|
||||
CHECK_STATUS("decode_frame_config #0",
|
||||
wuffs_qoi__decoder__decode_frame_config(&dec, &fc, &src));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_qoi__decoder__decode_frame_config(&dec, &fc, &src);
|
||||
if (status.repr != wuffs_base__note__end_of_data) {
|
||||
RETURN_FAIL("decode_frame_config #1: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__note__end_of_data);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------- Mimic Tests
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
// No mimic tests.
|
||||
|
||||
#endif // WUFFS_MIMIC
|
||||
|
||||
// ---------------- QOI Benches
|
||||
|
||||
// No QOI benches.
|
||||
|
||||
// ---------------- Mimic Benches
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
// No mimic benches.
|
||||
|
||||
#endif // WUFFS_MIMIC
|
||||
|
||||
// ---------------- Manifest
|
||||
|
||||
proc g_tests[] = {
|
||||
|
||||
test_wuffs_qoi_decode_frame_config,
|
||||
test_wuffs_qoi_decode_interface,
|
||||
test_wuffs_qoi_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
// No mimic tests.
|
||||
|
||||
#endif // WUFFS_MIMIC
|
||||
|
||||
NULL,
|
||||
};
|
||||
|
||||
proc g_benches[] = {
|
||||
|
||||
// No QOI benches.
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
// No mimic benches.
|
||||
|
||||
#endif // WUFFS_MIMIC
|
||||
|
||||
NULL,
|
||||
};
|
||||
|
||||
int //
|
||||
main(int argc, char** argv) {
|
||||
g_proc_package_name = "std/qoi";
|
||||
return test_main(argc, argv, g_tests, g_benches);
|
||||
}
|
||||
@@ -28,6 +28,7 @@ OK. 076cb375 test/data/bricks-color.bmp
|
||||
OK. 72a1f9cc test/data/bricks-color.jpeg
|
||||
OK. 076cb375 test/data/bricks-color.lossless.webp
|
||||
OK. 076cb375 test/data/bricks-color.png
|
||||
OK. 076cb375 test/data/bricks-color.qoi
|
||||
OK. 076cb375 test/data/bricks-color.tga
|
||||
OK. f36c2e80 test/data/bricks-dither.bmp
|
||||
OK. f36c2e80 test/data/bricks-dither.gif
|
||||
|
||||
Reference in new issue
Block a user