mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Compare commits
43
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58608c4ee5 | ||
|
|
4aa672af48 | ||
|
|
f86c80e425 | ||
|
|
dda01f1a77 | ||
|
|
f3a7288357 | ||
|
|
0a8bded7f3 | ||
|
|
918b4e4535 | ||
|
|
92f74e91a7 | ||
|
|
bcecdef66b | ||
|
|
2f1b1a5311 | ||
|
|
425eefeb35 | ||
|
|
e1a6a7cd8c | ||
|
|
4e85543d9c | ||
|
|
4c04ac1127 | ||
|
|
8ef4c062d9 | ||
|
|
38b101d170 | ||
|
|
5d1473a2ca | ||
|
|
72d4a9e769 | ||
|
|
5f6a522563 | ||
|
|
4dedbedbbc | ||
|
|
a1aa15cacf | ||
|
|
ae6b366edb | ||
|
|
6acb5a4fdd | ||
|
|
3a9933f2a0 | ||
|
|
c2eb4f5b93 | ||
|
|
8397a35a50 | ||
|
|
e53497abe3 | ||
|
|
15285a6ab9 | ||
|
|
ac4d3e6420 | ||
|
|
8bd52a8791 | ||
|
|
1d8fb411ba | ||
|
|
ccbec18330 | ||
|
|
55cad41d6c | ||
|
|
f5c68a13cb | ||
|
|
f5d6ce3797 | ||
|
|
5e8b448c12 | ||
|
|
49a431f98d | ||
|
|
ede0590ead | ||
|
|
bb8623b472 | ||
|
|
010e0a69f4 | ||
|
|
a684928240 | ||
|
|
cdf3bbfb26 | ||
|
|
fe15c471df |
No files matched your search
@@ -13,6 +13,7 @@
|
||||
Andrew Dassonville <dassonville.andrew@gmail.com>
|
||||
Google Inc.
|
||||
Jimmy Casey <casey.jimmy@gmail.com>
|
||||
Magnus Anderson <magnus@iastate.edu>
|
||||
Mike Kaufman <mkaufman@microsoft.com>
|
||||
Muhammad Aldo Firmansyah <TheCrott@users.noreply.github.com>
|
||||
Přemysl Eric Janouch <p@janouch.name>
|
||||
@@ -36,6 +36,7 @@ Andrew Dassonville <dassonville.andrew@gmail.com>
|
||||
Chris Palmer <chris@noncombatant.org>
|
||||
Jimmy Casey <casey.jimmy@gmail.com>
|
||||
Leo Neat <lneat@google.com>
|
||||
Magnus Anderson <magnus@iastate.edu>
|
||||
Mike Kaufman <mkaufman@microsoft.com>
|
||||
Muhammad Aldo Firmansyah <TheCrott@users.noreply.github.com>
|
||||
Nigel Tao <nigeltao@golang.org>
|
||||
|
||||
@@ -27,7 +27,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
CcompilersDefault = "clang-9,gcc"
|
||||
CcompilersDefault = "clang,gcc"
|
||||
CcompilersUsage = `comma-separated list of C compilers`
|
||||
|
||||
FocusDefault = ""
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ Installation:
|
||||
|
||||
Like any other implemented-in-Go program, to install the ractool program:
|
||||
|
||||
go get github.com/google/wuffs/cmd/ractool
|
||||
go install github.com/google/wuffs/cmd/ractool
|
||||
|
||||
Extended Example:
|
||||
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ Installation:
|
||||
|
||||
Like any other implemented-in-Go program, to install the ractool program:
|
||||
|
||||
go get github.com/google/wuffs/cmd/ractool
|
||||
go install github.com/google/wuffs/cmd/ractool
|
||||
|
||||
Extended Example:
|
||||
|
||||
|
||||
+6
-1
@@ -37,7 +37,12 @@ func doGen(wuffsRoot string, args []string) error { return doGenGenlib(wuffsR
|
||||
func doGenlib(wuffsRoot string, args []string) error { return doGenGenlib(wuffsRoot, args, true) }
|
||||
|
||||
func doGenGenlib(wuffsRoot string, args []string, genlib bool) error {
|
||||
flags := flag.NewFlagSet("gen", flag.ExitOnError)
|
||||
flagSetName := `"wuffs gen <flags> std/pkg1 std/pkg2 etc"`
|
||||
if genlib {
|
||||
flagSetName = `"wuffs genlib <flags> std/pkg1 std/pkg2 etc"`
|
||||
}
|
||||
|
||||
flags := flag.NewFlagSet(flagSetName, flag.ExitOnError)
|
||||
genlinenumFlag := flags.Bool("genlinenum", cf.GenlinenumDefault, cf.GenlinenumUsage)
|
||||
langsFlag := flags.String("langs", langsDefault, langsUsage)
|
||||
skipgendepsFlag := flags.Bool("skipgendeps", skipgendepsDefault, skipgendepsUsage)
|
||||
|
||||
@@ -52,6 +52,8 @@ The commands are:
|
||||
gen generate code for packages and dependencies
|
||||
genlib generate software libraries
|
||||
test test packages
|
||||
|
||||
Use "wuffs help <command>" for more information about a command.
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -76,6 +78,13 @@ func main1() error {
|
||||
return c.do(wuffsRoot, args[1:])
|
||||
}
|
||||
}
|
||||
if (len(args) == 2) && (args[0] == "help") {
|
||||
for _, c := range commands {
|
||||
if args[1] == c.name {
|
||||
return c.do(wuffsRoot, []string{"-help"})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
usage()
|
||||
os.Exit(1)
|
||||
|
||||
+22
-10
@@ -29,16 +29,26 @@ func doBench(wuffsRoot string, args []string) error { return doBenchTest(wuffsRo
|
||||
func doTest(wuffsRoot string, args []string) error { return doBenchTest(wuffsRoot, args, false) }
|
||||
|
||||
func doBenchTest(wuffsRoot string, args []string, bench bool) error {
|
||||
flags := flag.NewFlagSet("test", flag.ExitOnError)
|
||||
flagSetName := `"wuffs test <flags> std/pkg1 std/pkg2 etc"`
|
||||
if bench {
|
||||
flagSetName = `"wuffs bench <flags> std/pkg1 std/pkg2 etc"`
|
||||
}
|
||||
|
||||
flags := flag.NewFlagSet(flagSetName, flag.ExitOnError)
|
||||
ccompilersFlag := flags.String("ccompilers", cf.CcompilersDefault, cf.CcompilersUsage)
|
||||
focusFlag := flags.String("focus", cf.FocusDefault, cf.FocusUsage)
|
||||
iterscaleFlag := flags.Int("iterscale", cf.IterscaleDefault, cf.IterscaleUsage)
|
||||
langsFlag := flags.String("langs", langsDefault, langsUsage)
|
||||
mimicFlag := flags.Bool("mimic", cf.MimicDefault, cf.MimicUsage)
|
||||
repsFlag := flags.Int("reps", cf.RepsDefault, cf.RepsUsage)
|
||||
skipgenFlag := flags.Bool("skipgen", skipgenDefault, skipgenUsage)
|
||||
skipgendepsFlag := flags.Bool("skipgendeps", skipgendepsDefault, skipgendepsUsage)
|
||||
|
||||
iterscaleFlag := (*int)(nil)
|
||||
repsFlag := (*int)(nil)
|
||||
if bench {
|
||||
iterscaleFlag = flags.Int("iterscale", cf.IterscaleDefault, cf.IterscaleUsage)
|
||||
repsFlag = flags.Int("reps", cf.RepsDefault, cf.RepsUsage)
|
||||
}
|
||||
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -53,13 +63,15 @@ func doBenchTest(wuffsRoot string, args []string, bench bool) error {
|
||||
if !cf.IsAlphaNumericIsh(*focusFlag) {
|
||||
return fmt.Errorf("bad -focus flag value %q", *focusFlag)
|
||||
}
|
||||
if *iterscaleFlag < cf.IterscaleMin || cf.IterscaleMax < *iterscaleFlag {
|
||||
return fmt.Errorf("bad -iterscale flag value %d, outside the range [%d ..= %d]",
|
||||
*iterscaleFlag, cf.IterscaleMin, cf.IterscaleMax)
|
||||
}
|
||||
if *repsFlag < cf.RepsMin || cf.RepsMax < *repsFlag {
|
||||
return fmt.Errorf("bad -reps flag value %d, outside the range [%d ..= %d]",
|
||||
*repsFlag, cf.RepsMin, cf.RepsMax)
|
||||
if bench {
|
||||
if *iterscaleFlag < cf.IterscaleMin || cf.IterscaleMax < *iterscaleFlag {
|
||||
return fmt.Errorf("bad -iterscale flag value %d, outside the range [%d ..= %d]",
|
||||
*iterscaleFlag, cf.IterscaleMin, cf.IterscaleMax)
|
||||
}
|
||||
if *repsFlag < cf.RepsMin || cf.RepsMax < *repsFlag {
|
||||
return fmt.Errorf("bad -reps flag value %d, outside the range [%d ..= %d]",
|
||||
*repsFlag, cf.RepsMin, cf.RepsMax)
|
||||
}
|
||||
}
|
||||
|
||||
args = flags.Args()
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ The output of those benchmark programs is compatible with the
|
||||
[benchstat](https://godoc.org/golang.org/x/perf/cmd/benchstat) tool. For
|
||||
example, that tool can calculate confidence intervals based on multiple
|
||||
benchmark runs, or calculate p-values when comparing numbers before and after a
|
||||
code change. To install it, first install Go, then run `go get
|
||||
code change. To install it, first install Go, then run `go install
|
||||
golang.org/x/perf/cmd/benchstat`.
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@
|
||||
- Added slice `uintptr_low_12_bits` method.
|
||||
- Added tokens.
|
||||
- Changed `gif.decoder_workbuf_len_max_incl_worst_case` from 1 to 0.
|
||||
- Changed default C compilers from `clang-5.0,gcc` to `clang-9,gcc`.
|
||||
- Changed default C compilers from `clang-5.0,gcc` to `clang,gcc`.
|
||||
- Changed the C formatting style; removed the `-cformatter` flag.
|
||||
- Changed what the `std/gif` benchmarks actually measure.
|
||||
- Made `wuffs_base__pixel_format` a struct.
|
||||
|
||||
+16
-6
@@ -22,15 +22,25 @@ test suite, you might also have to install C compilers like clang and gcc, as
|
||||
well as C libraries (and their .h files) like libjpeg and libpng, as some tests
|
||||
compare that Wuffs produces exactly the same output as these other libraries.
|
||||
|
||||
Running `go get -v github.com/google/wuffs/cmd/...` will download and install
|
||||
the Wuffs tools. Change `get` to `install` to re-install those programs without
|
||||
downloading, e.g. after you've modified their source code, or after a manually
|
||||
issued `git pull`. The Wuffs tools that you'll most often use are `wuffsfmt`
|
||||
Run `git clone https://github.com/google/wuffs.git` to get the latest Wuffs
|
||||
code, `cd` into its directory and run `go install -v ./cmd/wuffs*` to install
|
||||
the Wuffs tools. The Wuffs tools that you'll most often use are `wuffsfmt`
|
||||
(analogous to `clang-format`, `gofmt` or `rustfmt`) and `wuffs` (roughly
|
||||
analogous to `make`, `go` or `cargo`).
|
||||
|
||||
You should now be able to run `wuffs test`. If all goes well, you should see
|
||||
some output containing the word "PASS" multiple times.
|
||||
You should now be able to run `wuffs test`. If you only have the `gcc` C
|
||||
compiler installed, but not `clang`, then you can run `wuffs
|
||||
test -ccompilers=gcc` instead. If all goes well, you should see some output
|
||||
containing the word "PASS" multiple times.
|
||||
|
||||
Remember to re-run `go install etc` whenever you've modified the Wuffs *tools'*
|
||||
source code (i.e. `*.go` files) or after a manually issued `git pull`. If
|
||||
you're only modifying the Wuffs *standard library's* source code (i.e.
|
||||
`*.wuffs` files), re-running `go install etc` is unnecessary.
|
||||
|
||||
If you're modifying just one particular codec in the standard library, such as
|
||||
the `std/png/*.wuffs` files, then you can exclude unrelated tests by running
|
||||
`wuffs test std/png`.
|
||||
|
||||
|
||||
## Poking Around
|
||||
|
||||
@@ -61,3 +61,4 @@ Package-specific quirks:
|
||||
|
||||
- [GIF image decoder quirks](/std/gif/decode_quirks.wuffs)
|
||||
- [JSON decoder quirks](/std/json/decode_quirks.wuffs)
|
||||
- [ZLIB decoder quirks](/std/zlib/decode_quirks.wuffs)
|
||||
@@ -1,6 +1,6 @@
|
||||
# Naïve Image Formats: NIE, NII, NIA
|
||||
|
||||
Status: Draft (as of December 2020). There is no compatibility guarantee yet.
|
||||
Status: Draft (as of November 2021). There is no compatibility guarantee yet.
|
||||
|
||||
A companion document has further discussion of [NIE related
|
||||
work](/doc/spec/nie-related-work.md).
|
||||
@@ -18,13 +18,14 @@ images. The 16 byte header:
|
||||
is not valid UTF-8) denotes version 1. There are no other valid versions at
|
||||
this time.
|
||||
- The second byte must be an ASCII 'b'. This denotes that the payload is in
|
||||
BGRA order (in terms of the wire format, independent of CPU endianness).
|
||||
BGRA order (not RGBA), in terms of the wire format, independent of CPU
|
||||
endianness.
|
||||
- The third byte, either an ASCII 'n' or an ASCII 'p', denotes whether the
|
||||
payload contains non-premultiplied or premultiplied alpha.
|
||||
- The fourth byte, either an ASCII '4' or an ASCII '8', denotes whether there
|
||||
are 4 or 8 bytes per pixel.
|
||||
- Future format versions may allow other byte values, but in version 1, it
|
||||
must be '\xFF', then 'b' or 'r', then 'n' or 'p', then '4' or '8'.
|
||||
must be '\xFF', then 'b', then 'n' or 'p', then '4' or '8'.
|
||||
- 4 bytes little-endian `uint32` width. The high bit must not be set.
|
||||
- 4 bytes little-endian `uint32` height. The high bit must not be set.
|
||||
|
||||
@@ -369,4 +370,4 @@ in a long "E", "I" or "A" sound. It's definitely a hard "N", not a soft one.
|
||||
|
||||
---
|
||||
|
||||
Updated on December 2020.
|
||||
Updated on November 2021.
|
||||
@@ -661,7 +661,7 @@ Go programming language libraries:
|
||||
- [RAC](https://godoc.org/github.com/google/wuffs/lib/rac)
|
||||
- [RAC + Zlib](https://godoc.org/github.com/google/wuffs/lib/raczlib)
|
||||
|
||||
Command line tool, installable via `go get
|
||||
Command line tool, installable via `go install
|
||||
github.com/google/wuffs/cmd/ractool`:
|
||||
|
||||
- [ractool](https://godoc.org/github.com/google/wuffs/cmd/ractool)
|
||||
|
||||
@@ -129,6 +129,8 @@ wuffs_base__frame_config g_frame_config = {0};
|
||||
int32_t g_fourcc = 0;
|
||||
uint32_t g_width = 0;
|
||||
uint32_t g_height = 0;
|
||||
uint32_t g_num_animation_loops = 0;
|
||||
uint64_t g_num_printed_frames = 0;
|
||||
|
||||
wuffs_base__image_decoder* g_image_decoder = NULL;
|
||||
union {
|
||||
@@ -152,7 +154,7 @@ union {
|
||||
#endif
|
||||
|
||||
#ifndef WORKBUF_ARRAY_SIZE
|
||||
#define WORKBUF_ARRAY_SIZE (1024 * 1024)
|
||||
#define WORKBUF_ARRAY_SIZE (256 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
#ifndef PIXBUF_ARRAY_SIZE
|
||||
@@ -466,6 +468,7 @@ print_nia_duration(wuffs_base__flicks duration) {
|
||||
|
||||
void //
|
||||
print_nie_frame() {
|
||||
g_num_printed_frames++;
|
||||
print_nix_header(0x45AFC36E); // "nïE" as a u32le.
|
||||
wuffs_base__table_u8 tab = wuffs_base__pixel_buffer__plane(&g_pixbuf, 0);
|
||||
if (tab.width == tab.stride) {
|
||||
@@ -490,30 +493,29 @@ print_nia_padding() {
|
||||
|
||||
void //
|
||||
print_nia_footer() {
|
||||
// For still (non-animated) images, the number of animation loops has no
|
||||
// practical effect: the pixels on screen do not change over time regardless
|
||||
// of its value. In the wire format encoding, there might be no explicit
|
||||
// "number of animation loops" value listed in the source bytes. Various
|
||||
// codec implementations may therefore choose an implicit default of 0 ("loop
|
||||
// forever") or 1 ("loop exactly once"). Either is equally valid.
|
||||
//
|
||||
// However, when comparing the output of this convert-to-NIA program (backed
|
||||
// by Wuffs' image codecs) with other convert-to-NIA programs, it is useful
|
||||
// to canonicalize still images' "number of animation loops" to 0.
|
||||
uint32_t n = g_num_animation_loops;
|
||||
if (g_num_printed_frames <= 1) {
|
||||
n = 0;
|
||||
}
|
||||
|
||||
uint8_t data[8];
|
||||
wuffs_base__poke_u32le__no_bounds_check(
|
||||
data + 0x00,
|
||||
wuffs_base__image_decoder__num_animation_loops(g_image_decoder));
|
||||
wuffs_base__poke_u32le__no_bounds_check(data + 0x00, n);
|
||||
wuffs_base__poke_u32le__no_bounds_check(data + 0x04, 0x80000000);
|
||||
ignore_return_value(write(STDOUT_FD, &data[0], 8));
|
||||
}
|
||||
|
||||
const char* //
|
||||
main1(int argc, char** argv) {
|
||||
TRY(parse_flags(argc, argv));
|
||||
if (g_flags.fail_if_unsandboxed && !g_sandboxed) {
|
||||
return "main: unsandboxed";
|
||||
}
|
||||
|
||||
g_src.data.ptr = g_src_buffer_array;
|
||||
g_src.data.len = SRC_BUFFER_ARRAY_SIZE;
|
||||
|
||||
TRY(load_image_type());
|
||||
TRY(load_image_config());
|
||||
if (!g_flags.first_frame_only) {
|
||||
print_nix_header(0x41AFC36E); // "nïA" as a u32le.
|
||||
}
|
||||
|
||||
convert_frames() {
|
||||
wuffs_base__flicks total_duration = 0;
|
||||
while (true) {
|
||||
// Decode the wuffs_base__frame_config.
|
||||
@@ -524,7 +526,7 @@ main1(int argc, char** argv) {
|
||||
if (dfc_status.repr == NULL) {
|
||||
break;
|
||||
} else if (dfc_status.repr == wuffs_base__note__end_of_data) {
|
||||
goto done;
|
||||
return NULL;
|
||||
} else if (dfc_status.repr != wuffs_base__suspension__short_read) {
|
||||
return wuffs_base__status__message(&dfc_status);
|
||||
}
|
||||
@@ -539,9 +541,6 @@ main1(int argc, char** argv) {
|
||||
return "main: animation frame duration overflow";
|
||||
}
|
||||
total_duration += duration;
|
||||
if (!g_flags.first_frame_only) {
|
||||
print_nia_duration(total_duration);
|
||||
}
|
||||
|
||||
if (wuffs_base__frame_config__index(&g_frame_config) == 0) {
|
||||
fill_rectangle(
|
||||
@@ -562,6 +561,7 @@ main1(int argc, char** argv) {
|
||||
|
||||
// Decode the frame (the pixels).
|
||||
wuffs_base__status df_status;
|
||||
const char* decode_frame_io_error_message = NULL;
|
||||
while (true) {
|
||||
df_status = wuffs_base__image_decoder__decode_frame(
|
||||
g_image_decoder, &g_pixbuf, &g_src,
|
||||
@@ -572,18 +572,57 @@ main1(int argc, char** argv) {
|
||||
if (df_status.repr != wuffs_base__suspension__short_read) {
|
||||
break;
|
||||
}
|
||||
TRY(read_more_src());
|
||||
decode_frame_io_error_message = read_more_src();
|
||||
if (decode_frame_io_error_message != NULL) {
|
||||
// Neuter the "short read" df_status so that convert_frames returns the
|
||||
// I/O error message instead.
|
||||
df_status.repr = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
print_nie_frame();
|
||||
// Update g_num_animation_loops. It's rare in practice, but the animation
|
||||
// loop count can change over the course of decoding an image file.
|
||||
//
|
||||
// This program updates the global once per frame (even though the Wuffs
|
||||
// API also lets you call wuffs_base__image_decoder__num_animation_loops
|
||||
// just once, after the decoding is complete) to more closely match the
|
||||
// Chromium web browser. This program emits (via print_nia_footer) the
|
||||
// value from the final animation frame's update.
|
||||
//
|
||||
// Chromium image decoding uses two passes. (Wuffs' API lets you use a
|
||||
// single pass but Chromium also wraps other libraries). Its first pass
|
||||
// counts the number of animation frames (call it N). The second pass
|
||||
// decodes exactly N frames. In particular, if the animation loop count
|
||||
// would change between the end of frame N and the end of the file then
|
||||
// Chromium's design will not pick up that change, even if it's a valid
|
||||
// change in terms of the image file format.
|
||||
//
|
||||
// Specifically, for the test/data/artificial-gif/multiple-loop-counts.gif
|
||||
// file this program emits 31 (0x1F) to match Chromium, even though the
|
||||
// file arguably has a 41 (0x29) loop count after a complete decode.
|
||||
g_num_animation_loops =
|
||||
wuffs_base__image_decoder__num_animation_loops(g_image_decoder);
|
||||
|
||||
// Print a complete NIE frame (and surrounding bytes, for NIA).
|
||||
if (!g_flags.first_frame_only) {
|
||||
print_nia_duration(total_duration);
|
||||
}
|
||||
print_nie_frame();
|
||||
if (!g_flags.first_frame_only) {
|
||||
print_nia_padding();
|
||||
}
|
||||
|
||||
// Return early if there was an error decoding the frame.
|
||||
if (df_status.repr != NULL) {
|
||||
return wuffs_base__status__message(&df_status);
|
||||
} else if (decode_frame_io_error_message != NULL) {
|
||||
return decode_frame_io_error_message;
|
||||
} else if (g_flags.first_frame_only) {
|
||||
return NULL;
|
||||
}
|
||||
print_nia_padding();
|
||||
|
||||
// Dispose the frame.
|
||||
switch (wuffs_base__frame_config__disposal(&g_frame_config)) {
|
||||
case WUFFS_BASE__ANIMATION_DISPOSAL__RESTORE_BACKGROUND: {
|
||||
fill_rectangle(
|
||||
@@ -601,10 +640,29 @@ main1(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return "main: unreachable";
|
||||
}
|
||||
|
||||
done:
|
||||
print_nia_footer();
|
||||
return NULL;
|
||||
const char* //
|
||||
main1(int argc, char** argv) {
|
||||
TRY(parse_flags(argc, argv));
|
||||
if (g_flags.fail_if_unsandboxed && !g_sandboxed) {
|
||||
return "main: unsandboxed";
|
||||
}
|
||||
|
||||
g_src.data.ptr = g_src_buffer_array;
|
||||
g_src.data.len = SRC_BUFFER_ARRAY_SIZE;
|
||||
|
||||
TRY(load_image_type());
|
||||
TRY(load_image_config());
|
||||
if (!g_flags.first_frame_only) {
|
||||
print_nix_header(0x41AFC36E); // "nïA" as a u32le.
|
||||
}
|
||||
const char* ret = convert_frames();
|
||||
if (!g_flags.first_frame_only) {
|
||||
print_nia_footer();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int //
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
|
||||
bmp: test/data/*.bmp ../bmpsuite_corpus/*.bmp
|
||||
cbor: test/data/*.cbor
|
||||
gif: test/data/*.gif test/data/artificial/*.gif
|
||||
gzip: test/data/*.gz test/data/artificial/*.gz
|
||||
gif: test/data/*.gif test/data/artificial-gif/*.gif
|
||||
gzip: test/data/*.gz
|
||||
json: test/data/*.json ../rapidjson_corpus/* ../simdjson_corpus/* ../JSONTestSuite/test_*/*.json
|
||||
png: test/data/*.png ../pngsuite_corpus/*.png
|
||||
png: test/data/*.png test/data/artificial-png/*.png ../pngsuite_corpus/*.png
|
||||
wbmp: test/data/*.wbmp
|
||||
zlib: test/data/*.zlib
|
||||
|
||||
|
||||
@@ -20,13 +20,14 @@ pointer. Anyway, here's what the output should look like:
|
||||
|
||||
```
|
||||
$ ./run.sh
|
||||
--- C Implementation Prints ---
|
||||
0
|
||||
12
|
||||
56789
|
||||
4294967295
|
||||
0
|
||||
3197704724
|
||||
--------
|
||||
------ Wuffs Impl Prints ------
|
||||
0
|
||||
12
|
||||
56789
|
||||
|
||||
+2
-57
@@ -12,67 +12,12 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// ----------------
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef USE_WUFFS
|
||||
uint32_t parse(char* p, size_t n) {
|
||||
uint32_t ret = 0;
|
||||
for (size_t i = 0; (i < n) && p[i]; i++) {
|
||||
ret = (10 * ret) + (p[i] - '0');
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#else // #ifndef USE_WUFFS
|
||||
|
||||
// TODO: this 'rough edge' shouldn't be necessary. See
|
||||
// https://github.com/google/wuffs/issues/24
|
||||
#define WUFFS_CONFIG__MODULE__BASE
|
||||
|
||||
#define WUFFS_IMPLEMENTATION
|
||||
#include "./parse.c"
|
||||
|
||||
uint32_t parse(char* p, size_t n) {
|
||||
wuffs_base__status status;
|
||||
wuffs_demo__parser* parser =
|
||||
(wuffs_demo__parser*)(malloc(sizeof__wuffs_demo__parser()));
|
||||
if (!parser) {
|
||||
printf("malloc failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
status = wuffs_demo__parser__initialize(parser, sizeof__wuffs_demo__parser(),
|
||||
WUFFS_VERSION, 0);
|
||||
if (!wuffs_base__status__is_ok(&status)) {
|
||||
printf("initialize: %s\n", wuffs_base__status__message(&status));
|
||||
free(parser);
|
||||
return 0;
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer iobuf;
|
||||
iobuf.data.ptr = (uint8_t*)p;
|
||||
iobuf.data.len = n;
|
||||
iobuf.meta.wi = n;
|
||||
iobuf.meta.ri = 0;
|
||||
iobuf.meta.pos = 0;
|
||||
iobuf.meta.closed = true;
|
||||
|
||||
status = wuffs_demo__parser__parse(parser, &iobuf);
|
||||
if (!wuffs_base__status__is_ok(&status)) {
|
||||
printf("parse: %s\n", wuffs_base__status__message(&status));
|
||||
free(parser);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t ret = wuffs_demo__parser__value(parser);
|
||||
free(parser);
|
||||
return ret;
|
||||
}
|
||||
#endif // #ifndef USE_WUFFS
|
||||
// See naive-parse.c and wuffs-parse.c for implementations of this function.
|
||||
uint32_t parse(char*, size_t);
|
||||
|
||||
void run(char* p) {
|
||||
size_t n = strlen(p) + 1; // +1 for the trailing NUL that ends a C string.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// Copyright 2019 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
uint32_t parse(char* p, size_t n) {
|
||||
uint32_t ret = 0;
|
||||
for (size_t i = 0; (i < n) && p[i]; i++) {
|
||||
ret = (10 * ret) + (p[i] - '0');
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -18,16 +18,14 @@
|
||||
CC=${CC:-gcc}
|
||||
|
||||
# You may need to run
|
||||
# go get github.com/google/wuffs/cmd/wuffs-c
|
||||
# go install github.com/google/wuffs/cmd/wuffs-c
|
||||
# beforehand, to install the wuffs-c compiler.
|
||||
wuffs-c gen -package_name demo < parse.wuffs > parse.c
|
||||
|
||||
$CC main.c
|
||||
./a.out
|
||||
echo --- C Implementation Prints ---
|
||||
$CC main.c naive-parse.c -o n.out
|
||||
./n.out
|
||||
|
||||
echo --------
|
||||
|
||||
$CC main.c -DUSE_WUFFS
|
||||
./a.out
|
||||
|
||||
rm a.out parse.c
|
||||
echo ------ Wuffs Impl Prints ------
|
||||
$CC main.c wuffs-parse.c -o w.out
|
||||
./w.out
|
||||
@@ -0,0 +1,87 @@
|
||||
// Copyright 2019 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// TODO: this 'rough edge' shouldn't be necessary. See
|
||||
// https://github.com/google/wuffs/issues/24
|
||||
#define WUFFS_CONFIG__MODULE__BASE
|
||||
|
||||
#define WUFFS_IMPLEMENTATION
|
||||
#include "./parse.c"
|
||||
|
||||
uint32_t parse(char* p, size_t n) {
|
||||
wuffs_base__status status;
|
||||
|
||||
// This next line of code allocates a wuffs_demo__parser on the stack. Stack
|
||||
// allocation in C means uninitialized memory, so we need to call
|
||||
// wuffs_demo__parser__initialize afterwards.
|
||||
//
|
||||
// An alternative, allocating on the heap and initializing in a single
|
||||
// function call, is to say:
|
||||
//
|
||||
// wuffs_demo__parser* parser = wuffs_demo__parser__alloc();
|
||||
// if (!parser) {
|
||||
// // Out of memory.
|
||||
// return 0;
|
||||
// }
|
||||
// // No need to call wuffs_demo__parser__initialize, but don't forget to
|
||||
// // free(parser) before this function returns, taking extra care if this
|
||||
// // function has multiple return points. Wuffs has no destructor functions
|
||||
// // and Wuffs types never hold or own any resources in the RAII sense.
|
||||
// // Just free the memory.
|
||||
//
|
||||
// For stack allocation, the C compiler needs to know
|
||||
// sizeof(wuffs_demo__parser), but that compile-time value isn't guaranteed
|
||||
// to be stable across Wuffs versions. Stack allocation is therefore only
|
||||
// valid when the C file also #define's WUFFS_IMPLEMENTATION. When linking
|
||||
// against a separately built Wuffs library (and the Wuffs types in this
|
||||
// compilation are incomplete types), you'll have to use heap allocation.
|
||||
wuffs_demo__parser parser;
|
||||
|
||||
// Initialize (and check status). An error here means that bad arguments were
|
||||
// passed to wuffs_demo__parser__initialize.
|
||||
//
|
||||
// There are two other categories of not-OK status values, notes and
|
||||
// suspensions, but they won't be encountered in this example.
|
||||
status = wuffs_demo__parser__initialize(&parser, sizeof__wuffs_demo__parser(),
|
||||
WUFFS_VERSION, 0);
|
||||
if (!wuffs_base__status__is_ok(&status)) {
|
||||
printf("initialize: %s\n", wuffs_base__status__message(&status));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// True means that the wuffs_base__io_buffer is closed - we are at the end of
|
||||
// the input. False would mean that there might be additional data in the
|
||||
// byte stream (that this buffer is not large enough to hold all at once).
|
||||
//
|
||||
// In general, Wuffs' coroutine and suspension status mechanisms let it parse
|
||||
// arbitrarily large data streams using fixed sized buffers, but that won't
|
||||
// be encountered in this example.
|
||||
wuffs_base__io_buffer iobuf =
|
||||
wuffs_base__ptr_u8__reader((uint8_t*)p, n, true);
|
||||
|
||||
// Parse (and check status). An error here means that we had invalid input
|
||||
// (i.e. "#not a digit" or "#too large").
|
||||
//
|
||||
// There are two other categories of not-OK status values, notes and
|
||||
// suspensions, but they won't be encountered in this example.
|
||||
status = wuffs_demo__parser__parse(&parser, &iobuf);
|
||||
if (!wuffs_base__status__is_ok(&status)) {
|
||||
printf("parse: %s\n", wuffs_base__status__message(&status));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return wuffs_demo__parser__value(&parser);
|
||||
}
|
||||
@@ -371,6 +371,9 @@ redirect:
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_CHRM) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__CHRM, true);
|
||||
}
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_EXIF) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__EXIF, true);
|
||||
}
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_GAMA) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__GAMA, true);
|
||||
}
|
||||
|
||||
@@ -209,8 +209,8 @@ struct DecodeImageArgFlags {
|
||||
// DefaultValue returns 0.
|
||||
static DecodeImageArgFlags DefaultValue();
|
||||
|
||||
// TODO: support all of the REPORT_METADATA_ETC flags, not just CHRM, GAMA,
|
||||
// ICCP, KVP, SRGB and XMP.
|
||||
// TODO: support all of the REPORT_METADATA_ETC flags, not just CHRM, EXIF,
|
||||
// GAMA, ICCP, KVP, SRGB and XMP.
|
||||
|
||||
// Background Color.
|
||||
static constexpr uint64_t REPORT_METADATA_BGCL = 0x0001;
|
||||
|
||||
@@ -160,7 +160,7 @@ wuffs_base__io_writer__limit(uint8_t** ptr_io2_w,
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -168,7 +168,7 @@ wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
return 0;
|
||||
}
|
||||
uint8_t* p = *ptr_iop_w;
|
||||
if ((size_t)(p - io1_w) < (size_t)(distance)) {
|
||||
if ((size_t)(p - io0_w) < (size_t)(distance)) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t* q = p - distance;
|
||||
@@ -205,10 +205,10 @@ wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
// The caller needs to prove that:
|
||||
// - length <= (io2_w - *ptr_iop_w)
|
||||
// - distance >= 1
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -240,11 +240,11 @@ wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
|
||||
// The caller needs to prove that:
|
||||
// - (length + 8) <= (io2_w - *ptr_iop_w)
|
||||
// - distance == 1
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fast(
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -280,11 +280,11 @@ wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fa
|
||||
// The caller needs to prove that:
|
||||
// - (length + 8) <= (io2_w - *ptr_iop_w)
|
||||
// - distance >= 8
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast(
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
|
||||
@@ -36,6 +36,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix) {
|
||||
{+0x54494646, "\x03\x4D\x4D\x00\x2A"}, // TIFF (big-endian)
|
||||
{-0x52494646, "\x03\x52\x49\x46\x46"}, // RIFF
|
||||
{+0x4E494520, "\x02\x6E\xC3\xAF"}, // NIE
|
||||
{+0x514F4920, "\x03\x71\x6F\x69\x66"}, // QOI
|
||||
{+0x504E4720, "\x03\x89\x50\x4E\x47"}, // PNG
|
||||
{+0x4A504547, "\x01\xFF\xD8"}, // JPEG
|
||||
};
|
||||
@@ -83,17 +84,12 @@ match:
|
||||
fourcc = -fourcc;
|
||||
|
||||
if (fourcc == 0x52494646) { // 'RIFF'be
|
||||
if (prefix.len < 16) {
|
||||
if (prefix.len < 12) {
|
||||
return -1;
|
||||
}
|
||||
uint32_t x = wuffs_base__peek_u32be__no_bounds_check(prefix.ptr + 8);
|
||||
if (x == 0x57454250) { // 'WEBP'be
|
||||
uint32_t y = wuffs_base__peek_u32be__no_bounds_check(prefix.ptr + 12);
|
||||
if (y == 0x56503820) { // 'VP8 'be
|
||||
return 0x57503820; // 'WP8 'be
|
||||
} else if (y == 0x5650384C) { // 'VP8L'be
|
||||
return 0x5750384C; // 'WP8L'be
|
||||
}
|
||||
return 0x57454250; // 'WEBP'be
|
||||
}
|
||||
|
||||
} else if (fourcc == 0x30302020) { // '00 'be
|
||||
|
||||
@@ -501,14 +501,23 @@ static inline uint32_t //
|
||||
wuffs_base__composite_nonpremul_nonpremul_u32_axxx(uint32_t dst_nonpremul,
|
||||
uint32_t src_nonpremul) {
|
||||
// Extract 16-bit color components.
|
||||
//
|
||||
// If the destination is transparent then SRC_OVER is equivalent to SRC: just
|
||||
// return src_nonpremul. This isn't just an optimization (skipping the rest
|
||||
// of the function's computation). It also preserves the nonpremul
|
||||
// distinction between e.g. transparent red and transparent blue that would
|
||||
// otherwise be lost by converting from nonpremul to premul and back.
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
if (da == 0) {
|
||||
return src_nonpremul;
|
||||
}
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -545,14 +554,23 @@ static inline uint64_t //
|
||||
wuffs_base__composite_nonpremul_nonpremul_u64_axxx(uint64_t dst_nonpremul,
|
||||
uint64_t src_nonpremul) {
|
||||
// Extract components.
|
||||
//
|
||||
// If the destination is transparent then SRC_OVER is equivalent to SRC: just
|
||||
// return src_nonpremul. This isn't just an optimization (skipping the rest
|
||||
// of the function's computation). It also preserves the nonpremul
|
||||
// distinction between e.g. transparent red and transparent blue that would
|
||||
// otherwise be lost by converting from nonpremul to premul and back.
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
if (da == 0) {
|
||||
return src_nonpremul;
|
||||
}
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -583,14 +601,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_nonpremul_premul_u32_axxx(uint32_t dst_nonpremul,
|
||||
uint32_t src_premul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -627,14 +645,14 @@ static inline uint64_t //
|
||||
wuffs_base__composite_nonpremul_premul_u64_axxx(uint64_t dst_nonpremul,
|
||||
uint64_t src_premul) {
|
||||
// Extract components.
|
||||
uint64_t sa = 0xFFFF & (src_premul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_premul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_premul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_premul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_premul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_premul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_premul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_premul >> 0);
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -665,14 +683,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_premul_nonpremul_u32_axxx(uint32_t dst_premul,
|
||||
uint32_t src_nonpremul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -697,14 +715,14 @@ static inline uint64_t //
|
||||
wuffs_base__composite_premul_nonpremul_u64_axxx(uint64_t dst_premul,
|
||||
uint64_t src_nonpremul) {
|
||||
// Extract components.
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_premul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_premul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_premul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_premul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint64_t ia = 0xFFFF - sa;
|
||||
@@ -723,14 +741,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_premul_premul_u32_axxx(uint32_t dst_premul,
|
||||
uint32_t src_premul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -1790,13 +1808,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_nonpremul__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -1838,13 +1856,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_nonpremul_4x16le__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 6));
|
||||
uint32_t sr = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 4));
|
||||
uint32_t sg = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 2));
|
||||
uint32_t sb = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 0));
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -1913,13 +1931,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_premul__src_over(uint8_t* dst_ptr,
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -1991,13 +2009,13 @@ wuffs_base__pixel_swizzler__bgr__rgba_nonpremul__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -2066,13 +2084,13 @@ wuffs_base__pixel_swizzler__bgr__rgba_premul__src_over(uint8_t* dst_ptr,
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
|
||||
@@ -66,6 +66,7 @@ var FourCCs = [...][2]string{
|
||||
{"PNG ", "Portable Network Graphics"},
|
||||
{"PNM ", "Portable Anymap"},
|
||||
{"PS ", "PostScript"},
|
||||
{"QOI ", "Quite OK Image"},
|
||||
{"RAC ", "Random Access Compression"},
|
||||
{"RAW ", "Raw"},
|
||||
{"RIFF", "Resource Interchange File Format"},
|
||||
@@ -79,9 +80,8 @@ var FourCCs = [...][2]string{
|
||||
{"TOML", "Tom's Obvious Minimal Language"},
|
||||
{"WAVE", "Waveform"},
|
||||
{"WBMP", "Wireless Bitmap"},
|
||||
{"WEBP", "Web Picture"},
|
||||
{"WOFF", "Web Open Font Format"},
|
||||
{"WP8 ", "Web Picture (VP8)"},
|
||||
{"WP8L", "Web Picture (VP8 Lossless)"},
|
||||
{"XML ", "Extensible Markup Language"},
|
||||
{"XMP ", "Extensible Metadata Platform"},
|
||||
{"XZ ", "Xz"},
|
||||
|
||||
@@ -686,6 +686,9 @@ typedef struct wuffs_base__transform__output__struct {
|
||||
// PostScript.
|
||||
#define WUFFS_BASE__FOURCC__PS 0x50532020
|
||||
|
||||
// Quite OK Image.
|
||||
#define WUFFS_BASE__FOURCC__QOI 0x514F4920
|
||||
|
||||
// Random Access Compression.
|
||||
#define WUFFS_BASE__FOURCC__RAC 0x52414320
|
||||
|
||||
@@ -725,15 +728,12 @@ typedef struct wuffs_base__transform__output__struct {
|
||||
// Wireless Bitmap.
|
||||
#define WUFFS_BASE__FOURCC__WBMP 0x57424D50
|
||||
|
||||
// Web Picture.
|
||||
#define WUFFS_BASE__FOURCC__WEBP 0x57454250
|
||||
|
||||
// Web Open Font Format.
|
||||
#define WUFFS_BASE__FOURCC__WOFF 0x574F4646
|
||||
|
||||
// Web Picture (VP8).
|
||||
#define WUFFS_BASE__FOURCC__WP8 0x57503820
|
||||
|
||||
// Web Picture (VP8 Lossless).
|
||||
#define WUFFS_BASE__FOURCC__WP8L 0x5750384C
|
||||
|
||||
// Extensible Markup Language.
|
||||
#define WUFFS_BASE__FOURCC__XML 0x584D4C20
|
||||
|
||||
@@ -7361,7 +7361,6 @@ struct wuffs_deflate__decoder__struct {
|
||||
uint32_t v_length;
|
||||
uint32_t v_dist_minus_1;
|
||||
uint32_t v_hlen;
|
||||
uint32_t v_hdist;
|
||||
uint64_t scratch;
|
||||
} s_decode_huffman_slow[1];
|
||||
} private_data;
|
||||
@@ -8931,6 +8930,8 @@ extern const char wuffs_zlib__error__incorrect_dictionary[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
#define WUFFS_ZLIB__QUIRK_JUST_RAW_DEFLATE 2113790976
|
||||
|
||||
#define WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
|
||||
|
||||
// ---------------- Struct Declarations
|
||||
@@ -9042,6 +9043,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
bool f_header_complete;
|
||||
bool f_got_dictionary;
|
||||
bool f_want_dictionary;
|
||||
bool f_quirks[1];
|
||||
bool f_ignore_checksum;
|
||||
uint32_t f_dict_id_got;
|
||||
uint32_t f_dict_id_want;
|
||||
@@ -9330,6 +9332,7 @@ struct wuffs_png__decoder__struct {
|
||||
uint64_t f_pass_workbuf_length;
|
||||
uint8_t f_call_sequence;
|
||||
bool f_report_metadata_chrm;
|
||||
bool f_report_metadata_exif;
|
||||
bool f_report_metadata_gama;
|
||||
bool f_report_metadata_iccp;
|
||||
bool f_report_metadata_kvp;
|
||||
@@ -9342,6 +9345,7 @@ struct wuffs_png__decoder__struct {
|
||||
bool f_seen_actl;
|
||||
bool f_seen_chrm;
|
||||
bool f_seen_fctl;
|
||||
bool f_seen_exif;
|
||||
bool f_seen_gama;
|
||||
bool f_seen_iccp;
|
||||
bool f_seen_idat;
|
||||
@@ -10370,8 +10374,8 @@ struct DecodeImageArgFlags {
|
||||
// DefaultValue returns 0.
|
||||
static DecodeImageArgFlags DefaultValue();
|
||||
|
||||
// TODO: support all of the REPORT_METADATA_ETC flags, not just CHRM, GAMA,
|
||||
// ICCP, KVP, SRGB and XMP.
|
||||
// TODO: support all of the REPORT_METADATA_ETC flags, not just CHRM, EXIF,
|
||||
// GAMA, ICCP, KVP, SRGB and XMP.
|
||||
|
||||
// Background Color.
|
||||
static constexpr uint64_t REPORT_METADATA_BGCL = 0x0001;
|
||||
@@ -11036,7 +11040,7 @@ wuffs_base__io_writer__limit(uint8_t** ptr_io2_w,
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -11044,7 +11048,7 @@ wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
return 0;
|
||||
}
|
||||
uint8_t* p = *ptr_iop_w;
|
||||
if ((size_t)(p - io1_w) < (size_t)(distance)) {
|
||||
if ((size_t)(p - io0_w) < (size_t)(distance)) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t* q = p - distance;
|
||||
@@ -11081,10 +11085,10 @@ wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
// The caller needs to prove that:
|
||||
// - length <= (io2_w - *ptr_iop_w)
|
||||
// - distance >= 1
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -11116,11 +11120,11 @@ wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
|
||||
// The caller needs to prove that:
|
||||
// - (length + 8) <= (io2_w - *ptr_iop_w)
|
||||
// - distance == 1
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fast(
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -11156,11 +11160,11 @@ wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fa
|
||||
// The caller needs to prove that:
|
||||
// - (length + 8) <= (io2_w - *ptr_iop_w)
|
||||
// - distance >= 8
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast(
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -15590,6 +15594,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix) {
|
||||
{+0x54494646, "\x03\x4D\x4D\x00\x2A"}, // TIFF (big-endian)
|
||||
{-0x52494646, "\x03\x52\x49\x46\x46"}, // RIFF
|
||||
{+0x4E494520, "\x02\x6E\xC3\xAF"}, // NIE
|
||||
{+0x514F4920, "\x03\x71\x6F\x69\x66"}, // QOI
|
||||
{+0x504E4720, "\x03\x89\x50\x4E\x47"}, // PNG
|
||||
{+0x4A504547, "\x01\xFF\xD8"}, // JPEG
|
||||
};
|
||||
@@ -15637,17 +15642,12 @@ match:
|
||||
fourcc = -fourcc;
|
||||
|
||||
if (fourcc == 0x52494646) { // 'RIFF'be
|
||||
if (prefix.len < 16) {
|
||||
if (prefix.len < 12) {
|
||||
return -1;
|
||||
}
|
||||
uint32_t x = wuffs_base__peek_u32be__no_bounds_check(prefix.ptr + 8);
|
||||
if (x == 0x57454250) { // 'WEBP'be
|
||||
uint32_t y = wuffs_base__peek_u32be__no_bounds_check(prefix.ptr + 12);
|
||||
if (y == 0x56503820) { // 'VP8 'be
|
||||
return 0x57503820; // 'WP8 'be
|
||||
} else if (y == 0x5650384C) { // 'VP8L'be
|
||||
return 0x5750384C; // 'WP8L'be
|
||||
}
|
||||
return 0x57454250; // 'WEBP'be
|
||||
}
|
||||
|
||||
} else if (fourcc == 0x30302020) { // '00 'be
|
||||
@@ -16165,14 +16165,23 @@ static inline uint32_t //
|
||||
wuffs_base__composite_nonpremul_nonpremul_u32_axxx(uint32_t dst_nonpremul,
|
||||
uint32_t src_nonpremul) {
|
||||
// Extract 16-bit color components.
|
||||
//
|
||||
// If the destination is transparent then SRC_OVER is equivalent to SRC: just
|
||||
// return src_nonpremul. This isn't just an optimization (skipping the rest
|
||||
// of the function's computation). It also preserves the nonpremul
|
||||
// distinction between e.g. transparent red and transparent blue that would
|
||||
// otherwise be lost by converting from nonpremul to premul and back.
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
if (da == 0) {
|
||||
return src_nonpremul;
|
||||
}
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16209,14 +16218,23 @@ static inline uint64_t //
|
||||
wuffs_base__composite_nonpremul_nonpremul_u64_axxx(uint64_t dst_nonpremul,
|
||||
uint64_t src_nonpremul) {
|
||||
// Extract components.
|
||||
//
|
||||
// If the destination is transparent then SRC_OVER is equivalent to SRC: just
|
||||
// return src_nonpremul. This isn't just an optimization (skipping the rest
|
||||
// of the function's computation). It also preserves the nonpremul
|
||||
// distinction between e.g. transparent red and transparent blue that would
|
||||
// otherwise be lost by converting from nonpremul to premul and back.
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
if (da == 0) {
|
||||
return src_nonpremul;
|
||||
}
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16247,14 +16265,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_nonpremul_premul_u32_axxx(uint32_t dst_nonpremul,
|
||||
uint32_t src_premul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16291,14 +16309,14 @@ static inline uint64_t //
|
||||
wuffs_base__composite_nonpremul_premul_u64_axxx(uint64_t dst_nonpremul,
|
||||
uint64_t src_premul) {
|
||||
// Extract components.
|
||||
uint64_t sa = 0xFFFF & (src_premul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_premul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_premul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_premul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_premul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_premul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_premul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_premul >> 0);
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16329,14 +16347,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_premul_nonpremul_u32_axxx(uint32_t dst_premul,
|
||||
uint32_t src_nonpremul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -16361,14 +16379,14 @@ static inline uint64_t //
|
||||
wuffs_base__composite_premul_nonpremul_u64_axxx(uint64_t dst_premul,
|
||||
uint64_t src_nonpremul) {
|
||||
// Extract components.
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_premul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_premul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_premul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_premul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint64_t ia = 0xFFFF - sa;
|
||||
@@ -16387,14 +16405,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_premul_premul_u32_axxx(uint32_t dst_premul,
|
||||
uint32_t src_premul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17454,13 +17472,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_nonpremul__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17502,13 +17520,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_nonpremul_4x16le__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 6));
|
||||
uint32_t sr = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 4));
|
||||
uint32_t sg = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 2));
|
||||
uint32_t sb = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 0));
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17577,13 +17595,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_premul__src_over(uint8_t* dst_ptr,
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17655,13 +17673,13 @@ wuffs_base__pixel_swizzler__bgr__rgba_nonpremul__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17730,13 +17748,13 @@ wuffs_base__pixel_swizzler__bgr__rgba_premul__src_over(uint8_t* dst_ptr,
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -26990,14 +27008,17 @@ wuffs_deflate__decoder__init_huff(
|
||||
v_i += 1;
|
||||
}
|
||||
if (v_remaining != 0) {
|
||||
if ((a_which == 1) &&
|
||||
(v_counts[1] == 1) &&
|
||||
(self->private_data.f_code_lengths[a_n_codes0] == 1) &&
|
||||
((((uint32_t)(v_counts[0])) + a_n_codes0 + 1) == a_n_codes1)) {
|
||||
self->private_impl.f_n_huffs_bits[1] = 1;
|
||||
self->private_data.f_huffs[1][0] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[0] | 1);
|
||||
self->private_data.f_huffs[1][1] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[31] | 1);
|
||||
return wuffs_base__make_status(NULL);
|
||||
if ((a_which == 1) && (v_counts[1] == 1) && ((((uint32_t)(v_counts[0])) + a_n_codes0 + 1) == a_n_codes1)) {
|
||||
v_i = 0;
|
||||
while (v_i <= 29) {
|
||||
if (self->private_data.f_code_lengths[(a_n_codes0 + v_i)] == 1) {
|
||||
self->private_impl.f_n_huffs_bits[1] = 1;
|
||||
self->private_data.f_huffs[1][0] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[v_i] | 1);
|
||||
self->private_data.f_huffs[1][1] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[31] | 1);
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
v_i += 1;
|
||||
}
|
||||
}
|
||||
return wuffs_base__make_status(wuffs_deflate__error__bad_huffman_code_under_subscribed);
|
||||
}
|
||||
@@ -27335,9 +27356,8 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767)));
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -27601,9 +27621,8 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767)));
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -27814,9 +27833,8 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767)));
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -27937,7 +27955,6 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
v_length = self->private_data.s_decode_huffman_slow[0].v_length;
|
||||
v_dist_minus_1 = self->private_data.s_decode_huffman_slow[0].v_dist_minus_1;
|
||||
v_hlen = self->private_data.s_decode_huffman_slow[0].v_hlen;
|
||||
v_hdist = self->private_data.s_decode_huffman_slow[0].v_hdist;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -28134,55 +28151,29 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
v_bits >>= v_table_entry_n_bits;
|
||||
v_n_bits -= v_table_entry_n_bits;
|
||||
}
|
||||
label__inner__continue:;
|
||||
while (true) {
|
||||
if (((uint64_t)((v_dist_minus_1 + 1))) > ((uint64_t)(iop_a_dst - io0_a_dst))) {
|
||||
v_hdist = ((uint32_t)((((uint64_t)((v_dist_minus_1 + 1))) - ((uint64_t)(iop_a_dst - io0_a_dst)))));
|
||||
if (v_length > v_hdist) {
|
||||
v_length -= v_hdist;
|
||||
if (v_hdist < v_length) {
|
||||
v_hlen = v_hdist;
|
||||
} else {
|
||||
v_hlen = v_length;
|
||||
v_length = 0;
|
||||
}
|
||||
v_hdist += ((uint32_t)((((uint64_t)(self->private_impl.f_transformed_history_count - (a_dst ? a_dst->meta.pos : 0))) & 4294967295)));
|
||||
if (self->private_impl.f_history_index < v_hdist) {
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
while (true) {
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 32768), (v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
goto label__4__break;
|
||||
}
|
||||
if (v_n_copied > 0) {
|
||||
v_hlen -= v_n_copied;
|
||||
v_hdist = (((uint32_t)(v_hdist + v_n_copied)) & 32767);
|
||||
if (v_hdist == 0) {
|
||||
goto label__4__break;
|
||||
}
|
||||
}
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_n_copied < v_hlen) {
|
||||
v_length -= v_n_copied;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||
goto label__inner__continue;
|
||||
}
|
||||
label__4__break:;
|
||||
if (v_hlen > 0) {
|
||||
while (true) {
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 32768), (v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
goto label__5__break;
|
||||
}
|
||||
v_hlen -= v_n_copied;
|
||||
v_hdist += v_n_copied;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
}
|
||||
label__5__break:;
|
||||
}
|
||||
v_length -= v_hlen;
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -28190,14 +28181,12 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_history(
|
||||
&iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1));
|
||||
if (v_length <= v_n_copied) {
|
||||
v_length = 0;
|
||||
goto label__6__break;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
v_length -= v_n_copied;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(11);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
}
|
||||
label__6__break:;
|
||||
}
|
||||
label__loop__break:;
|
||||
self->private_impl.f_bits = v_bits;
|
||||
@@ -28226,7 +28215,6 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
self->private_data.s_decode_huffman_slow[0].v_length = v_length;
|
||||
self->private_data.s_decode_huffman_slow[0].v_dist_minus_1 = v_dist_minus_1;
|
||||
self->private_data.s_decode_huffman_slow[0].v_hlen = v_hlen;
|
||||
self->private_data.s_decode_huffman_slow[0].v_hdist = v_hdist;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -29314,7 +29302,10 @@ wuffs_gif__decoder__num_animation_loops(
|
||||
if (self->private_impl.f_seen_num_animation_loops_value) {
|
||||
return self->private_impl.f_num_animation_loops_value;
|
||||
}
|
||||
return 1;
|
||||
if (self->private_impl.f_num_decoded_frame_configs_value > 1) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.num_decoded_frame_configs
|
||||
@@ -34913,6 +34904,10 @@ const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect diction
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
#define WUFFS_ZLIB__QUIRKS_BASE 2113790976
|
||||
|
||||
#define WUFFS_ZLIB__QUIRKS_COUNT 1
|
||||
|
||||
// ---------------- Private Initializer Prototypes
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
@@ -35076,8 +35071,15 @@ wuffs_zlib__decoder__set_quirk_enabled(
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
if (a_quirk == 1) {
|
||||
if (self->private_impl.f_header_complete) {
|
||||
self->private_impl.f_bad_call_sequence = true;
|
||||
} else if (a_quirk == 1) {
|
||||
self->private_impl.f_ignore_checksum = a_enabled;
|
||||
} else if (a_quirk >= 2113790976) {
|
||||
a_quirk -= 2113790976;
|
||||
if (a_quirk < 1) {
|
||||
self->private_impl.f_quirks[a_quirk] = a_enabled;
|
||||
}
|
||||
}
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
@@ -35167,6 +35169,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
if (self->private_impl.f_bad_call_sequence) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_quirks[0]) {
|
||||
} else if ( ! self->private_impl.f_want_dictionary) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
@@ -35274,7 +35277,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
if ( ! self->private_impl.f_ignore_checksum) {
|
||||
if ( ! self->private_impl.f_ignore_checksum && ! self->private_impl.f_quirks[0]) {
|
||||
v_checksum_got = wuffs_adler32__hasher__update_u32(&self->private_data.f_checksum, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_dst - io0_a_dst)), io0_a_dst));
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_status)) {
|
||||
@@ -35284,38 +35287,40 @@ wuffs_zlib__decoder__transform_io(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
label__0__break:;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
uint32_t t_3;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
if ( ! self->private_impl.f_quirks[0]) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
uint32_t t_3;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
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_transform_io[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_3);
|
||||
if (num_bits_3 == 24) {
|
||||
t_3 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_3 += 8;
|
||||
*scratch |= ((uint64_t)(num_bits_3));
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_3);
|
||||
if (num_bits_3 == 24) {
|
||||
t_3 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_3 += 8;
|
||||
*scratch |= ((uint64_t)(num_bits_3));
|
||||
}
|
||||
v_checksum_want = t_3;
|
||||
}
|
||||
if ( ! self->private_impl.f_ignore_checksum && (v_checksum_got != v_checksum_want)) {
|
||||
status = wuffs_base__make_status(wuffs_zlib__error__bad_checksum);
|
||||
goto exit;
|
||||
}
|
||||
v_checksum_want = t_3;
|
||||
}
|
||||
if ( ! self->private_impl.f_ignore_checksum && (v_checksum_got != v_checksum_want)) {
|
||||
status = wuffs_base__make_status(wuffs_zlib__error__bad_checksum);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ok:
|
||||
@@ -35614,6 +35619,11 @@ wuffs_png__decoder__decode_chrm(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_exif(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_fctl(
|
||||
wuffs_png__decoder* self,
|
||||
@@ -37785,8 +37795,13 @@ wuffs_png__decoder__assign_filter_distance(
|
||||
self->private_impl.f_src_pixfmt = 536870920;
|
||||
self->private_impl.f_filter_distance = 1;
|
||||
} else if (self->private_impl.f_depth == 16) {
|
||||
self->private_impl.f_dst_pixfmt = 536870923;
|
||||
self->private_impl.f_src_pixfmt = 537919499;
|
||||
if (self->private_impl.f_interlace_pass == 0) {
|
||||
self->private_impl.f_dst_pixfmt = 536870923;
|
||||
self->private_impl.f_src_pixfmt = 537919499;
|
||||
} else {
|
||||
self->private_impl.f_dst_pixfmt = 2164308923;
|
||||
self->private_impl.f_src_pixfmt = 2164308923;
|
||||
}
|
||||
self->private_impl.f_filter_distance = 2;
|
||||
}
|
||||
} else if (self->private_impl.f_color_type == 2) {
|
||||
@@ -37927,20 +37942,25 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_chunk_type == 1163152464) {
|
||||
if (self->private_impl.f_seen_plte || (self->private_impl.f_color_type != 3)) {
|
||||
if (self->private_impl.f_seen_plte) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_color_type == 3) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_plte(self, 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_color_type == 2) || (self->private_impl.f_color_type == 6)) {
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_plte(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
self->private_impl.f_seen_plte = true;
|
||||
} else if ((self->private_impl.f_chunk_type & 32) == 0) {
|
||||
@@ -37984,6 +38004,25 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
}
|
||||
self->private_impl.f_seen_chrm = true;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1716082789) {
|
||||
if (self->private_impl.f_report_metadata_exif) {
|
||||
if (self->private_impl.f_seen_exif) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status = wuffs_png__decoder__decode_exif(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
self->private_impl.f_seen_exif = true;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1280598886) {
|
||||
if (self->private_impl.f_seen_fctl) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
@@ -37992,7 +38031,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
status = wuffs_png__decoder__decode_fctl(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38010,7 +38049,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
status = wuffs_png__decoder__decode_gama(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38029,7 +38068,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
status = wuffs_png__decoder__decode_iccp(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38048,7 +38087,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
status = wuffs_png__decoder__decode_srgb(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38066,7 +38105,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
status = wuffs_png__decoder__decode_trns(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38086,7 +38125,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
}
|
||||
if (self->private_impl.f_metadata_fourcc == 0) {
|
||||
self->private_data.s_decode_other_chunk[0].scratch = self->private_impl.f_chunk_length;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
if (self->private_data.s_decode_other_chunk[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_other_chunk[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
iop_a_src = io2_a_src;
|
||||
@@ -38525,6 +38564,47 @@ wuffs_png__decoder__decode_chrm(
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.decode_exif
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_exif(
|
||||
wuffs_png__decoder* self,
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (self->private_impl.f_chunk_length < 4) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_flavor = 3;
|
||||
self->private_impl.f_metadata_fourcc = 1163413830;
|
||||
self->private_impl.f_metadata_x = 0;
|
||||
self->private_impl.f_metadata_y = wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)));
|
||||
self->private_impl.f_metadata_z = wuffs_base__u64__sat_add(self->private_impl.f_metadata_y, ((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
self->private_impl.f_chunk_length = 0;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.decode_fctl
|
||||
|
||||
static wuffs_base__status
|
||||
@@ -40479,6 +40559,8 @@ wuffs_png__decoder__set_report_metadata(
|
||||
|
||||
if (a_fourcc == 1128813133) {
|
||||
self->private_impl.f_report_metadata_chrm = a_report;
|
||||
} else if (a_fourcc == 1163413830) {
|
||||
self->private_impl.f_report_metadata_exif = a_report;
|
||||
} else if (a_fourcc == 1195461953) {
|
||||
self->private_impl.f_report_metadata_gama = a_report;
|
||||
} else if (a_fourcc == 1229144912) {
|
||||
@@ -40572,395 +40654,422 @@ wuffs_png__decoder__tell_me_more(
|
||||
status = wuffs_base__make_status(wuffs_base__error__no_more_information);
|
||||
goto exit;
|
||||
}
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_zlib_is_dirty) {
|
||||
wuffs_base__ignore_status(wuffs_zlib__decoder__initialize(&self->private_data.f_zlib,
|
||||
sizeof (wuffs_zlib__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
if (self->private_impl.f_ignore_checksum) {
|
||||
wuffs_zlib__decoder__set_quirk_enabled(&self->private_data.f_zlib, 1, true);
|
||||
while (true) {
|
||||
if (self->private_impl.f_metadata_flavor == 3) {
|
||||
while (true) {
|
||||
if (wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src))) != self->private_impl.f_metadata_y) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_i_o_position);
|
||||
goto exit;
|
||||
} else if (a_minfo != NULL) {
|
||||
wuffs_base__more_information__set(a_minfo,
|
||||
self->private_impl.f_metadata_flavor,
|
||||
self->private_impl.f_metadata_fourcc,
|
||||
self->private_impl.f_metadata_x,
|
||||
self->private_impl.f_metadata_y,
|
||||
self->private_impl.f_metadata_z);
|
||||
}
|
||||
if (self->private_impl.f_metadata_y >= self->private_impl.f_metadata_z) {
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
self->private_impl.f_metadata_y = self->private_impl.f_metadata_z;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__even_more_information);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
}
|
||||
self->private_impl.f_zlib_is_dirty = true;
|
||||
self->private_impl.f_ztxt_hist_pos = 0;
|
||||
}
|
||||
label__loop__continue:;
|
||||
while (true) {
|
||||
if (a_minfo != NULL) {
|
||||
wuffs_base__more_information__set(a_minfo,
|
||||
self->private_impl.f_metadata_flavor,
|
||||
self->private_impl.f_metadata_fourcc,
|
||||
self->private_impl.f_metadata_x,
|
||||
self->private_impl.f_metadata_y,
|
||||
self->private_impl.f_metadata_z);
|
||||
}
|
||||
if (self->private_impl.f_metadata_flavor != 4) {
|
||||
goto label__loop__break;
|
||||
}
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_chunk_type == 1346585449) {
|
||||
{
|
||||
const uint8_t *o_0_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
if (self->private_impl.f_zlib_is_dirty) {
|
||||
wuffs_base__ignore_status(wuffs_zlib__decoder__initialize(&self->private_data.f_zlib,
|
||||
sizeof (wuffs_zlib__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
if (self->private_impl.f_ignore_checksum) {
|
||||
wuffs_zlib__decoder__set_quirk_enabled(&self->private_data.f_zlib, 1, true);
|
||||
}
|
||||
}
|
||||
self->private_impl.f_zlib_is_dirty = true;
|
||||
self->private_impl.f_ztxt_hist_pos = 0;
|
||||
}
|
||||
label__loop__continue:;
|
||||
while (true) {
|
||||
if (a_minfo != NULL) {
|
||||
wuffs_base__more_information__set(a_minfo,
|
||||
self->private_impl.f_metadata_flavor,
|
||||
self->private_impl.f_metadata_fourcc,
|
||||
self->private_impl.f_metadata_x,
|
||||
self->private_impl.f_metadata_y,
|
||||
self->private_impl.f_metadata_z);
|
||||
}
|
||||
if (self->private_impl.f_metadata_flavor != 4) {
|
||||
goto label__loop__break;
|
||||
}
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_chunk_type == 1346585449) {
|
||||
{
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
const uint8_t *o_0_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_0 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_0;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_0_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
}
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
{
|
||||
const uint8_t *o_1_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_1 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_1;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_1_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
}
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_ztxt_ri == self->private_impl.f_ztxt_wi) {
|
||||
{
|
||||
wuffs_base__io_buffer* o_2_v_w = v_w;
|
||||
uint8_t *o_2_iop_v_w = iop_v_w;
|
||||
uint8_t *o_2_io0_v_w = io0_v_w;
|
||||
uint8_t *o_2_io1_v_w = io1_v_w;
|
||||
uint8_t *o_2_io2_v_w = io2_v_w;
|
||||
v_w = wuffs_base__io_writer__set(
|
||||
&u_w,
|
||||
&iop_v_w,
|
||||
&io0_v_w,
|
||||
&io1_v_w,
|
||||
&io2_v_w,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
|
||||
self->private_impl.f_ztxt_hist_pos);
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
const uint8_t *o_3_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
u_w.meta.wi = ((size_t)(iop_v_w - u_w.data.ptr));
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, v_w, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_2;
|
||||
iop_v_w = u_w.data.ptr + u_w.meta.wi;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)));
|
||||
io2_a_src = o_3_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_0 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_0;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
v_w = o_2_v_w;
|
||||
iop_v_w = o_2_iop_v_w;
|
||||
io0_v_w = o_2_io0_v_w;
|
||||
io1_v_w = o_2_io1_v_w;
|
||||
io2_v_w = o_2_io2_v_w;
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_0_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (v_num_written > 1024) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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_ztxt_ri = 0;
|
||||
self->private_impl.f_ztxt_wi = ((uint32_t)(v_num_written));
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_ztxt_hist_pos, v_num_written);
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
{
|
||||
const uint8_t *o_1_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_1 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_1;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_1_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
}
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_ztxt_ri == self->private_impl.f_ztxt_wi) {
|
||||
{
|
||||
wuffs_base__io_buffer* o_2_v_w = v_w;
|
||||
uint8_t *o_2_iop_v_w = iop_v_w;
|
||||
uint8_t *o_2_io0_v_w = io0_v_w;
|
||||
uint8_t *o_2_io1_v_w = io1_v_w;
|
||||
uint8_t *o_2_io2_v_w = io2_v_w;
|
||||
v_w = wuffs_base__io_writer__set(
|
||||
&u_w,
|
||||
&iop_v_w,
|
||||
&io0_v_w,
|
||||
&io1_v_w,
|
||||
&io2_v_w,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
|
||||
self->private_impl.f_ztxt_hist_pos);
|
||||
{
|
||||
const uint8_t *o_3_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
u_w.meta.wi = ((size_t)(iop_v_w - u_w.data.ptr));
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, v_w, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_2;
|
||||
iop_v_w = u_w.data.ptr + u_w.meta.wi;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)));
|
||||
io2_a_src = o_3_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
v_w = o_2_v_w;
|
||||
iop_v_w = o_2_iop_v_w;
|
||||
io0_v_w = o_2_io0_v_w;
|
||||
io1_v_w = o_2_io1_v_w;
|
||||
io2_v_w = o_2_io2_v_w;
|
||||
}
|
||||
if (v_num_written > 1024) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri = 0;
|
||||
self->private_impl.f_ztxt_wi = ((uint32_t)(v_num_written));
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_ztxt_hist_pos, v_num_written);
|
||||
}
|
||||
while (self->private_impl.f_ztxt_ri < self->private_impl.f_ztxt_wi) {
|
||||
v_c2 = WUFFS_PNG__LATIN_1[self->private_data.f_dst_palette[self->private_impl.f_ztxt_ri]];
|
||||
if (v_c2 == 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_text_chunk_not_latin_1);
|
||||
goto exit;
|
||||
} else if (v_c2 <= 127) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, ((uint8_t)(v_c2))), iop_a_dst += 1);
|
||||
} else {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
(wuffs_base__poke_u16le__no_bounds_check(iop_a_dst, v_c2), iop_a_dst += 2);
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
} else if (v_zlib_status.repr != wuffs_base__suspension__short_write) {
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
}
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_chunk_type);
|
||||
goto exit;
|
||||
}
|
||||
while (self->private_impl.f_ztxt_ri < self->private_impl.f_ztxt_wi) {
|
||||
v_c2 = WUFFS_PNG__LATIN_1[self->private_data.f_dst_palette[self->private_impl.f_ztxt_ri]];
|
||||
} else if ((self->private_impl.f_chunk_type == 1951945833) && (self->private_impl.f_metadata_fourcc == 1263947862)) {
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
goto label__loop__continue;
|
||||
} else if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, v_c), iop_a_dst += 1);
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||
goto label__loop__continue;
|
||||
}
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
goto label__loop__break;
|
||||
}
|
||||
v_c2 = WUFFS_PNG__LATIN_1[v_c];
|
||||
if (v_c2 == 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_text_chunk_not_latin_1);
|
||||
goto exit;
|
||||
} else if (v_c2 <= 127) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, ((uint8_t)(v_c2))), iop_a_dst += 1);
|
||||
} else {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(11);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u16le__no_bounds_check(iop_a_dst, v_c2), iop_a_dst += 2);
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
} else if (v_zlib_status.repr != wuffs_base__suspension__short_write) {
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_chunk_type);
|
||||
goto exit;
|
||||
}
|
||||
} else if ((self->private_impl.f_chunk_type == 1951945833) && (self->private_impl.f_metadata_fourcc == 1263947862)) {
|
||||
while (true) {
|
||||
}
|
||||
label__loop__break:;
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
self->private_impl.f_metadata_fourcc = 1263947862;
|
||||
if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
if (self->private_impl.f_chunk_length <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 2;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
||||
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++;
|
||||
v_c = t_3;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
} else if (v_c == 1) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = true;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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++;
|
||||
v_c = t_4;
|
||||
}
|
||||
if ((v_c != 0) && self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_fourcc -= 2;
|
||||
while (self->private_impl.f_metadata_fourcc != 1263947862) {
|
||||
self->private_impl.f_metadata_fourcc += 1;
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
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++;
|
||||
v_c = t_5;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
goto label__0__break;
|
||||
}
|
||||
}
|
||||
label__0__break:;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
goto label__loop__continue;
|
||||
} else if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
goto label__loop__continue;
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, v_c), iop_a_dst += 1);
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label__loop__continue;
|
||||
uint8_t t_6 = *iop_a_src++;
|
||||
v_c = t_6;
|
||||
}
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
goto label__loop__break;
|
||||
}
|
||||
v_c2 = WUFFS_PNG__LATIN_1[v_c];
|
||||
if (v_c2 == 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_text_chunk_not_latin_1);
|
||||
if (v_c != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
} else if (v_c2 <= 127) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, ((uint8_t)(v_c2))), iop_a_dst += 1);
|
||||
} else {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u16le__no_bounds_check(iop_a_dst, v_c2), iop_a_dst += 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
label__loop__break:;
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
self->private_impl.f_metadata_fourcc = 1263947862;
|
||||
if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
if (self->private_impl.f_chunk_length <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 2;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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++;
|
||||
v_c = t_3;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
} else if (v_c == 1) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = true;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
||||
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++;
|
||||
v_c = t_4;
|
||||
}
|
||||
if ((v_c != 0) && self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_fourcc -= 2;
|
||||
while (self->private_impl.f_metadata_fourcc != 1263947862) {
|
||||
self->private_impl.f_metadata_fourcc += 1;
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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++;
|
||||
v_c = t_5;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
goto label__0__break;
|
||||
}
|
||||
}
|
||||
label__0__break:;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
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++;
|
||||
v_c = t_6;
|
||||
}
|
||||
if (v_c != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_is_zlib_compressed = true;
|
||||
self->private_impl.f_call_sequence = 2;
|
||||
status = wuffs_base__make_status(NULL);
|
||||
goto ok;
|
||||
}
|
||||
} else {
|
||||
if (self->private_impl.f_chunk_length != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_tell_me_more[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
|
||||
if (self->private_data.s_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
iop_a_src = io2_a_src;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
iop_a_src += self->private_data.s_tell_me_more[0].scratch;
|
||||
self->private_impl.f_metadata_flavor = 0;
|
||||
self->private_impl.f_metadata_fourcc = 0;
|
||||
self->private_impl.f_metadata_x = 0;
|
||||
self->private_impl.f_metadata_y = 0;
|
||||
self->private_impl.f_metadata_z = 0;
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
label__goto_done__break:;
|
||||
if (self->private_impl.f_chunk_length != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_tell_me_more[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
|
||||
if (self->private_data.s_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
iop_a_src = io2_a_src;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
iop_a_src += self->private_data.s_tell_me_more[0].scratch;
|
||||
self->private_impl.f_metadata_flavor = 0;
|
||||
self->private_impl.f_metadata_fourcc = 0;
|
||||
self->private_impl.f_metadata_x = 0;
|
||||
self->private_impl.f_metadata_y = 0;
|
||||
self->private_impl.f_metadata_z = 0;
|
||||
self->private_impl.f_call_sequence = 2;
|
||||
status = wuffs_base__make_status(NULL);
|
||||
goto ok;
|
||||
@@ -43131,6 +43240,9 @@ redirect:
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_CHRM) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__CHRM, true);
|
||||
}
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_EXIF) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__EXIF, true);
|
||||
}
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_GAMA) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__GAMA, true);
|
||||
}
|
||||
|
||||
+634
-522
@@ -85,15 +85,15 @@ extern "C" {
|
||||
// each major.minor branch, the commit count should increase monotonically.
|
||||
//
|
||||
// WUFFS_VERSION was overridden by "wuffs gen -version" based on revision
|
||||
// e44920d382c9b542e17287664937e547becc7148 committed on 2021-11-19.
|
||||
// 4aa672af48fd5c11ab4c0b704a4ccf8d90eb5662 committed on 2022-01-08.
|
||||
#define WUFFS_VERSION 0x000030000
|
||||
#define WUFFS_VERSION_MAJOR 0
|
||||
#define WUFFS_VERSION_MINOR 3
|
||||
#define WUFFS_VERSION_PATCH 0
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL "beta.12"
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3202
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20211119
|
||||
#define WUFFS_VERSION_STRING "0.3.0-beta.12+3202.20211119"
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL "beta.13"
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3245
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20220108
|
||||
#define WUFFS_VERSION_STRING "0.3.0-beta.13+3245.20220108"
|
||||
|
||||
// ---------------- Configuration
|
||||
|
||||
@@ -687,6 +687,9 @@ typedef struct wuffs_base__transform__output__struct {
|
||||
// PostScript.
|
||||
#define WUFFS_BASE__FOURCC__PS 0x50532020
|
||||
|
||||
// Quite OK Image.
|
||||
#define WUFFS_BASE__FOURCC__QOI 0x514F4920
|
||||
|
||||
// Random Access Compression.
|
||||
#define WUFFS_BASE__FOURCC__RAC 0x52414320
|
||||
|
||||
@@ -726,15 +729,12 @@ typedef struct wuffs_base__transform__output__struct {
|
||||
// Wireless Bitmap.
|
||||
#define WUFFS_BASE__FOURCC__WBMP 0x57424D50
|
||||
|
||||
// Web Picture.
|
||||
#define WUFFS_BASE__FOURCC__WEBP 0x57454250
|
||||
|
||||
// Web Open Font Format.
|
||||
#define WUFFS_BASE__FOURCC__WOFF 0x574F4646
|
||||
|
||||
// Web Picture (VP8).
|
||||
#define WUFFS_BASE__FOURCC__WP8 0x57503820
|
||||
|
||||
// Web Picture (VP8 Lossless).
|
||||
#define WUFFS_BASE__FOURCC__WP8L 0x5750384C
|
||||
|
||||
// Extensible Markup Language.
|
||||
#define WUFFS_BASE__FOURCC__XML 0x584D4C20
|
||||
|
||||
@@ -7362,7 +7362,6 @@ struct wuffs_deflate__decoder__struct {
|
||||
uint32_t v_length;
|
||||
uint32_t v_dist_minus_1;
|
||||
uint32_t v_hlen;
|
||||
uint32_t v_hdist;
|
||||
uint64_t scratch;
|
||||
} s_decode_huffman_slow[1];
|
||||
} private_data;
|
||||
@@ -8932,6 +8931,8 @@ extern const char wuffs_zlib__error__incorrect_dictionary[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
#define WUFFS_ZLIB__QUIRK_JUST_RAW_DEFLATE 2113790976
|
||||
|
||||
#define WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
|
||||
|
||||
// ---------------- Struct Declarations
|
||||
@@ -9043,6 +9044,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
bool f_header_complete;
|
||||
bool f_got_dictionary;
|
||||
bool f_want_dictionary;
|
||||
bool f_quirks[1];
|
||||
bool f_ignore_checksum;
|
||||
uint32_t f_dict_id_got;
|
||||
uint32_t f_dict_id_want;
|
||||
@@ -9331,6 +9333,7 @@ struct wuffs_png__decoder__struct {
|
||||
uint64_t f_pass_workbuf_length;
|
||||
uint8_t f_call_sequence;
|
||||
bool f_report_metadata_chrm;
|
||||
bool f_report_metadata_exif;
|
||||
bool f_report_metadata_gama;
|
||||
bool f_report_metadata_iccp;
|
||||
bool f_report_metadata_kvp;
|
||||
@@ -9343,6 +9346,7 @@ struct wuffs_png__decoder__struct {
|
||||
bool f_seen_actl;
|
||||
bool f_seen_chrm;
|
||||
bool f_seen_fctl;
|
||||
bool f_seen_exif;
|
||||
bool f_seen_gama;
|
||||
bool f_seen_iccp;
|
||||
bool f_seen_idat;
|
||||
@@ -10371,8 +10375,8 @@ struct DecodeImageArgFlags {
|
||||
// DefaultValue returns 0.
|
||||
static DecodeImageArgFlags DefaultValue();
|
||||
|
||||
// TODO: support all of the REPORT_METADATA_ETC flags, not just CHRM, GAMA,
|
||||
// ICCP, KVP, SRGB and XMP.
|
||||
// TODO: support all of the REPORT_METADATA_ETC flags, not just CHRM, EXIF,
|
||||
// GAMA, ICCP, KVP, SRGB and XMP.
|
||||
|
||||
// Background Color.
|
||||
static constexpr uint64_t REPORT_METADATA_BGCL = 0x0001;
|
||||
@@ -11037,7 +11041,7 @@ wuffs_base__io_writer__limit(uint8_t** ptr_io2_w,
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -11045,7 +11049,7 @@ wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
return 0;
|
||||
}
|
||||
uint8_t* p = *ptr_iop_w;
|
||||
if ((size_t)(p - io1_w) < (size_t)(distance)) {
|
||||
if ((size_t)(p - io0_w) < (size_t)(distance)) {
|
||||
return 0;
|
||||
}
|
||||
uint8_t* q = p - distance;
|
||||
@@ -11082,10 +11086,10 @@ wuffs_base__io_writer__limited_copy_u32_from_history(uint8_t** ptr_iop_w,
|
||||
// The caller needs to prove that:
|
||||
// - length <= (io2_w - *ptr_iop_w)
|
||||
// - distance >= 1
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -11117,11 +11121,11 @@ wuffs_base__io_writer__limited_copy_u32_from_history_fast(uint8_t** ptr_iop_w,
|
||||
// The caller needs to prove that:
|
||||
// - (length + 8) <= (io2_w - *ptr_iop_w)
|
||||
// - distance == 1
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fast(
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -11157,11 +11161,11 @@ wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_distance_1_fa
|
||||
// The caller needs to prove that:
|
||||
// - (length + 8) <= (io2_w - *ptr_iop_w)
|
||||
// - distance >= 8
|
||||
// - distance <= (*ptr_iop_w - io1_w)
|
||||
// - distance <= (*ptr_iop_w - io0_w)
|
||||
static inline uint32_t //
|
||||
wuffs_base__io_writer__limited_copy_u32_from_history_8_byte_chunks_fast(
|
||||
uint8_t** ptr_iop_w,
|
||||
uint8_t* io1_w,
|
||||
uint8_t* io0_w,
|
||||
uint8_t* io2_w,
|
||||
uint32_t length,
|
||||
uint32_t distance) {
|
||||
@@ -15591,6 +15595,7 @@ wuffs_base__magic_number_guess_fourcc(wuffs_base__slice_u8 prefix) {
|
||||
{+0x54494646, "\x03\x4D\x4D\x00\x2A"}, // TIFF (big-endian)
|
||||
{-0x52494646, "\x03\x52\x49\x46\x46"}, // RIFF
|
||||
{+0x4E494520, "\x02\x6E\xC3\xAF"}, // NIE
|
||||
{+0x514F4920, "\x03\x71\x6F\x69\x66"}, // QOI
|
||||
{+0x504E4720, "\x03\x89\x50\x4E\x47"}, // PNG
|
||||
{+0x4A504547, "\x01\xFF\xD8"}, // JPEG
|
||||
};
|
||||
@@ -15638,17 +15643,12 @@ match:
|
||||
fourcc = -fourcc;
|
||||
|
||||
if (fourcc == 0x52494646) { // 'RIFF'be
|
||||
if (prefix.len < 16) {
|
||||
if (prefix.len < 12) {
|
||||
return -1;
|
||||
}
|
||||
uint32_t x = wuffs_base__peek_u32be__no_bounds_check(prefix.ptr + 8);
|
||||
if (x == 0x57454250) { // 'WEBP'be
|
||||
uint32_t y = wuffs_base__peek_u32be__no_bounds_check(prefix.ptr + 12);
|
||||
if (y == 0x56503820) { // 'VP8 'be
|
||||
return 0x57503820; // 'WP8 'be
|
||||
} else if (y == 0x5650384C) { // 'VP8L'be
|
||||
return 0x5750384C; // 'WP8L'be
|
||||
}
|
||||
return 0x57454250; // 'WEBP'be
|
||||
}
|
||||
|
||||
} else if (fourcc == 0x30302020) { // '00 'be
|
||||
@@ -16166,14 +16166,23 @@ static inline uint32_t //
|
||||
wuffs_base__composite_nonpremul_nonpremul_u32_axxx(uint32_t dst_nonpremul,
|
||||
uint32_t src_nonpremul) {
|
||||
// Extract 16-bit color components.
|
||||
//
|
||||
// If the destination is transparent then SRC_OVER is equivalent to SRC: just
|
||||
// return src_nonpremul. This isn't just an optimization (skipping the rest
|
||||
// of the function's computation). It also preserves the nonpremul
|
||||
// distinction between e.g. transparent red and transparent blue that would
|
||||
// otherwise be lost by converting from nonpremul to premul and back.
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
if (da == 0) {
|
||||
return src_nonpremul;
|
||||
}
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16210,14 +16219,23 @@ static inline uint64_t //
|
||||
wuffs_base__composite_nonpremul_nonpremul_u64_axxx(uint64_t dst_nonpremul,
|
||||
uint64_t src_nonpremul) {
|
||||
// Extract components.
|
||||
//
|
||||
// If the destination is transparent then SRC_OVER is equivalent to SRC: just
|
||||
// return src_nonpremul. This isn't just an optimization (skipping the rest
|
||||
// of the function's computation). It also preserves the nonpremul
|
||||
// distinction between e.g. transparent red and transparent blue that would
|
||||
// otherwise be lost by converting from nonpremul to premul and back.
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
if (da == 0) {
|
||||
return src_nonpremul;
|
||||
}
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16248,14 +16266,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_nonpremul_premul_u32_axxx(uint32_t dst_nonpremul,
|
||||
uint32_t src_premul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_nonpremul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_nonpremul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_nonpremul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_nonpremul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16292,14 +16310,14 @@ static inline uint64_t //
|
||||
wuffs_base__composite_nonpremul_premul_u64_axxx(uint64_t dst_nonpremul,
|
||||
uint64_t src_premul) {
|
||||
// Extract components.
|
||||
uint64_t sa = 0xFFFF & (src_premul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_premul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_premul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_premul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_nonpremul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_nonpremul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_nonpremul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_nonpremul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_premul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_premul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_premul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_premul >> 0);
|
||||
|
||||
// Convert dst from nonpremul to premul.
|
||||
dr = (dr * da) / 0xFFFF;
|
||||
@@ -16330,14 +16348,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_premul_nonpremul_u32_axxx(uint32_t dst_premul,
|
||||
uint32_t src_nonpremul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_nonpremul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_nonpremul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_nonpremul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_nonpremul >> 0));
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -16362,14 +16380,14 @@ static inline uint64_t //
|
||||
wuffs_base__composite_premul_nonpremul_u64_axxx(uint64_t dst_premul,
|
||||
uint64_t src_nonpremul) {
|
||||
// Extract components.
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
uint64_t da = 0xFFFF & (dst_premul >> 48);
|
||||
uint64_t dr = 0xFFFF & (dst_premul >> 32);
|
||||
uint64_t dg = 0xFFFF & (dst_premul >> 16);
|
||||
uint64_t db = 0xFFFF & (dst_premul >> 0);
|
||||
uint64_t sa = 0xFFFF & (src_nonpremul >> 48);
|
||||
uint64_t sr = 0xFFFF & (src_nonpremul >> 32);
|
||||
uint64_t sg = 0xFFFF & (src_nonpremul >> 16);
|
||||
uint64_t sb = 0xFFFF & (src_nonpremul >> 0);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint64_t ia = 0xFFFF - sa;
|
||||
@@ -16388,14 +16406,14 @@ static inline uint32_t //
|
||||
wuffs_base__composite_premul_premul_u32_axxx(uint32_t dst_premul,
|
||||
uint32_t src_premul) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
uint32_t da = 0x101 * (0xFF & (dst_premul >> 24));
|
||||
uint32_t dr = 0x101 * (0xFF & (dst_premul >> 16));
|
||||
uint32_t dg = 0x101 * (0xFF & (dst_premul >> 8));
|
||||
uint32_t db = 0x101 * (0xFF & (dst_premul >> 0));
|
||||
uint32_t sa = 0x101 * (0xFF & (src_premul >> 24));
|
||||
uint32_t sr = 0x101 * (0xFF & (src_premul >> 16));
|
||||
uint32_t sg = 0x101 * (0xFF & (src_premul >> 8));
|
||||
uint32_t sb = 0x101 * (0xFF & (src_premul >> 0));
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17455,13 +17473,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_nonpremul__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17503,13 +17521,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_nonpremul_4x16le__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 6));
|
||||
uint32_t sr = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 4));
|
||||
uint32_t sg = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 2));
|
||||
uint32_t sb = ((uint32_t)wuffs_base__peek_u16le__no_bounds_check(s + 0));
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17578,13 +17596,13 @@ wuffs_base__pixel_swizzler__bgr__bgra_premul__src_over(uint8_t* dst_ptr,
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17656,13 +17674,13 @@ wuffs_base__pixel_swizzler__bgr__rgba_nonpremul__src_over(
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -17731,13 +17749,13 @@ wuffs_base__pixel_swizzler__bgr__rgba_premul__src_over(uint8_t* dst_ptr,
|
||||
|
||||
while (n >= 1) {
|
||||
// Extract 16-bit color components.
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
uint32_t sa = 0x101 * ((uint32_t)s[3]);
|
||||
uint32_t sb = 0x101 * ((uint32_t)s[2]);
|
||||
uint32_t sg = 0x101 * ((uint32_t)s[1]);
|
||||
uint32_t sr = 0x101 * ((uint32_t)s[0]);
|
||||
uint32_t dr = 0x101 * ((uint32_t)d[2]);
|
||||
uint32_t dg = 0x101 * ((uint32_t)d[1]);
|
||||
uint32_t db = 0x101 * ((uint32_t)d[0]);
|
||||
|
||||
// Calculate the inverse of the src-alpha: how much of the dst to keep.
|
||||
uint32_t ia = 0xFFFF - sa;
|
||||
@@ -26991,14 +27009,17 @@ wuffs_deflate__decoder__init_huff(
|
||||
v_i += 1;
|
||||
}
|
||||
if (v_remaining != 0) {
|
||||
if ((a_which == 1) &&
|
||||
(v_counts[1] == 1) &&
|
||||
(self->private_data.f_code_lengths[a_n_codes0] == 1) &&
|
||||
((((uint32_t)(v_counts[0])) + a_n_codes0 + 1) == a_n_codes1)) {
|
||||
self->private_impl.f_n_huffs_bits[1] = 1;
|
||||
self->private_data.f_huffs[1][0] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[0] | 1);
|
||||
self->private_data.f_huffs[1][1] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[31] | 1);
|
||||
return wuffs_base__make_status(NULL);
|
||||
if ((a_which == 1) && (v_counts[1] == 1) && ((((uint32_t)(v_counts[0])) + a_n_codes0 + 1) == a_n_codes1)) {
|
||||
v_i = 0;
|
||||
while (v_i <= 29) {
|
||||
if (self->private_data.f_code_lengths[(a_n_codes0 + v_i)] == 1) {
|
||||
self->private_impl.f_n_huffs_bits[1] = 1;
|
||||
self->private_data.f_huffs[1][0] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[v_i] | 1);
|
||||
self->private_data.f_huffs[1][1] = (WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[31] | 1);
|
||||
return wuffs_base__make_status(NULL);
|
||||
}
|
||||
v_i += 1;
|
||||
}
|
||||
}
|
||||
return wuffs_base__make_status(wuffs_deflate__error__bad_huffman_code_under_subscribed);
|
||||
}
|
||||
@@ -27336,9 +27357,8 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767)));
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -27602,9 +27622,8 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767)));
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -27815,9 +27834,8 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), (v_hdist & 32767)));
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -27938,7 +27956,6 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
v_length = self->private_data.s_decode_huffman_slow[0].v_length;
|
||||
v_dist_minus_1 = self->private_data.s_decode_huffman_slow[0].v_dist_minus_1;
|
||||
v_hlen = self->private_data.s_decode_huffman_slow[0].v_hlen;
|
||||
v_hdist = self->private_data.s_decode_huffman_slow[0].v_hdist;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -28135,55 +28152,29 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
v_bits >>= v_table_entry_n_bits;
|
||||
v_n_bits -= v_table_entry_n_bits;
|
||||
}
|
||||
label__inner__continue:;
|
||||
while (true) {
|
||||
if (((uint64_t)((v_dist_minus_1 + 1))) > ((uint64_t)(iop_a_dst - io0_a_dst))) {
|
||||
v_hdist = ((uint32_t)((((uint64_t)((v_dist_minus_1 + 1))) - ((uint64_t)(iop_a_dst - io0_a_dst)))));
|
||||
if (v_length > v_hdist) {
|
||||
v_length -= v_hdist;
|
||||
if (v_hdist < v_length) {
|
||||
v_hlen = v_hdist;
|
||||
} else {
|
||||
v_hlen = v_length;
|
||||
v_length = 0;
|
||||
}
|
||||
v_hdist += ((uint32_t)((((uint64_t)(self->private_impl.f_transformed_history_count - (a_dst ? a_dst->meta.pos : 0))) & 4294967295)));
|
||||
if (self->private_impl.f_history_index < v_hdist) {
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__bad_distance);
|
||||
goto exit;
|
||||
}
|
||||
v_hdist = (self->private_impl.f_history_index - v_hdist);
|
||||
while (true) {
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 32768), (v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
goto label__4__break;
|
||||
}
|
||||
if (v_n_copied > 0) {
|
||||
v_hlen -= v_n_copied;
|
||||
v_hdist = (((uint32_t)(v_hdist + v_n_copied)) & 32767);
|
||||
if (v_hdist == 0) {
|
||||
goto label__4__break;
|
||||
}
|
||||
}
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 33025), ((self->private_impl.f_history_index - v_hdist) & 32767)));
|
||||
if (v_n_copied < v_hlen) {
|
||||
v_length -= v_n_copied;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||
goto label__inner__continue;
|
||||
}
|
||||
label__4__break:;
|
||||
if (v_hlen > 0) {
|
||||
while (true) {
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_slice(
|
||||
&iop_a_dst, io2_a_dst,v_hlen, wuffs_base__slice_u8__subslice_i(wuffs_base__make_slice_u8(self->private_data.f_history, 32768), (v_hdist & 32767)));
|
||||
if (v_hlen <= v_n_copied) {
|
||||
v_hlen = 0;
|
||||
goto label__5__break;
|
||||
}
|
||||
v_hlen -= v_n_copied;
|
||||
v_hdist += v_n_copied;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
}
|
||||
label__5__break:;
|
||||
}
|
||||
v_length -= v_hlen;
|
||||
if (v_length == 0) {
|
||||
goto label__loop__continue;
|
||||
}
|
||||
@@ -28191,14 +28182,12 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
v_n_copied = wuffs_base__io_writer__limited_copy_u32_from_history(
|
||||
&iop_a_dst, io0_a_dst, io2_a_dst, v_length, (v_dist_minus_1 + 1));
|
||||
if (v_length <= v_n_copied) {
|
||||
v_length = 0;
|
||||
goto label__6__break;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
v_length -= v_n_copied;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(11);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
}
|
||||
label__6__break:;
|
||||
}
|
||||
label__loop__break:;
|
||||
self->private_impl.f_bits = v_bits;
|
||||
@@ -28227,7 +28216,6 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
self->private_data.s_decode_huffman_slow[0].v_length = v_length;
|
||||
self->private_data.s_decode_huffman_slow[0].v_dist_minus_1 = v_dist_minus_1;
|
||||
self->private_data.s_decode_huffman_slow[0].v_hlen = v_hlen;
|
||||
self->private_data.s_decode_huffman_slow[0].v_hdist = v_hdist;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -29315,7 +29303,10 @@ wuffs_gif__decoder__num_animation_loops(
|
||||
if (self->private_impl.f_seen_num_animation_loops_value) {
|
||||
return self->private_impl.f_num_animation_loops_value;
|
||||
}
|
||||
return 1;
|
||||
if (self->private_impl.f_num_decoded_frame_configs_value > 1) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.num_decoded_frame_configs
|
||||
@@ -34914,6 +34905,10 @@ const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect diction
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
#define WUFFS_ZLIB__QUIRKS_BASE 2113790976
|
||||
|
||||
#define WUFFS_ZLIB__QUIRKS_COUNT 1
|
||||
|
||||
// ---------------- Private Initializer Prototypes
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
@@ -35077,8 +35072,15 @@ wuffs_zlib__decoder__set_quirk_enabled(
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
|
||||
if (a_quirk == 1) {
|
||||
if (self->private_impl.f_header_complete) {
|
||||
self->private_impl.f_bad_call_sequence = true;
|
||||
} else if (a_quirk == 1) {
|
||||
self->private_impl.f_ignore_checksum = a_enabled;
|
||||
} else if (a_quirk >= 2113790976) {
|
||||
a_quirk -= 2113790976;
|
||||
if (a_quirk < 1) {
|
||||
self->private_impl.f_quirks[a_quirk] = a_enabled;
|
||||
}
|
||||
}
|
||||
return wuffs_base__make_empty_struct();
|
||||
}
|
||||
@@ -35168,6 +35170,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
if (self->private_impl.f_bad_call_sequence) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_quirks[0]) {
|
||||
} else if ( ! self->private_impl.f_want_dictionary) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
@@ -35275,7 +35278,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
if ( ! self->private_impl.f_ignore_checksum) {
|
||||
if ( ! self->private_impl.f_ignore_checksum && ! self->private_impl.f_quirks[0]) {
|
||||
v_checksum_got = wuffs_adler32__hasher__update_u32(&self->private_data.f_checksum, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_dst - io0_a_dst)), io0_a_dst));
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_status)) {
|
||||
@@ -35285,38 +35288,40 @@ wuffs_zlib__decoder__transform_io(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
label__0__break:;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
uint32_t t_3;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
if ( ! self->private_impl.f_quirks[0]) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
uint32_t t_3;
|
||||
if (WUFFS_BASE__LIKELY(io2_a_src - iop_a_src >= 4)) {
|
||||
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
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_transform_io[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_3);
|
||||
if (num_bits_3 == 24) {
|
||||
t_3 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_3 += 8;
|
||||
*scratch |= ((uint64_t)(num_bits_3));
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
*scratch |= ((uint64_t)(*iop_a_src++)) << (56 - num_bits_3);
|
||||
if (num_bits_3 == 24) {
|
||||
t_3 = ((uint32_t)(*scratch >> 32));
|
||||
break;
|
||||
}
|
||||
num_bits_3 += 8;
|
||||
*scratch |= ((uint64_t)(num_bits_3));
|
||||
}
|
||||
v_checksum_want = t_3;
|
||||
}
|
||||
if ( ! self->private_impl.f_ignore_checksum && (v_checksum_got != v_checksum_want)) {
|
||||
status = wuffs_base__make_status(wuffs_zlib__error__bad_checksum);
|
||||
goto exit;
|
||||
}
|
||||
v_checksum_want = t_3;
|
||||
}
|
||||
if ( ! self->private_impl.f_ignore_checksum && (v_checksum_got != v_checksum_want)) {
|
||||
status = wuffs_base__make_status(wuffs_zlib__error__bad_checksum);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ok:
|
||||
@@ -35615,6 +35620,11 @@ wuffs_png__decoder__decode_chrm(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_exif(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_fctl(
|
||||
wuffs_png__decoder* self,
|
||||
@@ -37786,8 +37796,13 @@ wuffs_png__decoder__assign_filter_distance(
|
||||
self->private_impl.f_src_pixfmt = 536870920;
|
||||
self->private_impl.f_filter_distance = 1;
|
||||
} else if (self->private_impl.f_depth == 16) {
|
||||
self->private_impl.f_dst_pixfmt = 536870923;
|
||||
self->private_impl.f_src_pixfmt = 537919499;
|
||||
if (self->private_impl.f_interlace_pass == 0) {
|
||||
self->private_impl.f_dst_pixfmt = 536870923;
|
||||
self->private_impl.f_src_pixfmt = 537919499;
|
||||
} else {
|
||||
self->private_impl.f_dst_pixfmt = 2164308923;
|
||||
self->private_impl.f_src_pixfmt = 2164308923;
|
||||
}
|
||||
self->private_impl.f_filter_distance = 2;
|
||||
}
|
||||
} else if (self->private_impl.f_color_type == 2) {
|
||||
@@ -37928,20 +37943,25 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_chunk_type == 1163152464) {
|
||||
if (self->private_impl.f_seen_plte || (self->private_impl.f_color_type != 3)) {
|
||||
if (self->private_impl.f_seen_plte) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_color_type == 3) {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_plte(self, 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_color_type == 2) || (self->private_impl.f_color_type == 6)) {
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_plte(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
self->private_impl.f_seen_plte = true;
|
||||
} else if ((self->private_impl.f_chunk_type & 32) == 0) {
|
||||
@@ -37985,6 +38005,25 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
}
|
||||
self->private_impl.f_seen_chrm = true;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1716082789) {
|
||||
if (self->private_impl.f_report_metadata_exif) {
|
||||
if (self->private_impl.f_seen_exif) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
status = wuffs_png__decoder__decode_exif(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
self->private_impl.f_seen_exif = true;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1280598886) {
|
||||
if (self->private_impl.f_seen_fctl) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
@@ -37993,7 +38032,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
status = wuffs_png__decoder__decode_fctl(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38011,7 +38050,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
status = wuffs_png__decoder__decode_gama(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38030,7 +38069,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
status = wuffs_png__decoder__decode_iccp(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38049,7 +38088,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
status = wuffs_png__decoder__decode_srgb(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38067,7 +38106,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
status = wuffs_png__decoder__decode_trns(self, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
@@ -38087,7 +38126,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
}
|
||||
if (self->private_impl.f_metadata_fourcc == 0) {
|
||||
self->private_data.s_decode_other_chunk[0].scratch = self->private_impl.f_chunk_length;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
if (self->private_data.s_decode_other_chunk[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_other_chunk[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
iop_a_src = io2_a_src;
|
||||
@@ -38526,6 +38565,47 @@ wuffs_png__decoder__decode_chrm(
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.decode_exif
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_exif(
|
||||
wuffs_png__decoder* self,
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
if (self->private_impl.f_chunk_length < 4) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_flavor = 3;
|
||||
self->private_impl.f_metadata_fourcc = 1163413830;
|
||||
self->private_impl.f_metadata_x = 0;
|
||||
self->private_impl.f_metadata_y = wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src)));
|
||||
self->private_impl.f_metadata_z = wuffs_base__u64__sat_add(self->private_impl.f_metadata_y, ((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
self->private_impl.f_chunk_length = 0;
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.decode_fctl
|
||||
|
||||
static wuffs_base__status
|
||||
@@ -40480,6 +40560,8 @@ wuffs_png__decoder__set_report_metadata(
|
||||
|
||||
if (a_fourcc == 1128813133) {
|
||||
self->private_impl.f_report_metadata_chrm = a_report;
|
||||
} else if (a_fourcc == 1163413830) {
|
||||
self->private_impl.f_report_metadata_exif = a_report;
|
||||
} else if (a_fourcc == 1195461953) {
|
||||
self->private_impl.f_report_metadata_gama = a_report;
|
||||
} else if (a_fourcc == 1229144912) {
|
||||
@@ -40573,395 +40655,422 @@ wuffs_png__decoder__tell_me_more(
|
||||
status = wuffs_base__make_status(wuffs_base__error__no_more_information);
|
||||
goto exit;
|
||||
}
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_zlib_is_dirty) {
|
||||
wuffs_base__ignore_status(wuffs_zlib__decoder__initialize(&self->private_data.f_zlib,
|
||||
sizeof (wuffs_zlib__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
if (self->private_impl.f_ignore_checksum) {
|
||||
wuffs_zlib__decoder__set_quirk_enabled(&self->private_data.f_zlib, 1, true);
|
||||
while (true) {
|
||||
if (self->private_impl.f_metadata_flavor == 3) {
|
||||
while (true) {
|
||||
if (wuffs_base__u64__sat_add((a_src ? a_src->meta.pos : 0), ((uint64_t)(iop_a_src - io0_a_src))) != self->private_impl.f_metadata_y) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_i_o_position);
|
||||
goto exit;
|
||||
} else if (a_minfo != NULL) {
|
||||
wuffs_base__more_information__set(a_minfo,
|
||||
self->private_impl.f_metadata_flavor,
|
||||
self->private_impl.f_metadata_fourcc,
|
||||
self->private_impl.f_metadata_x,
|
||||
self->private_impl.f_metadata_y,
|
||||
self->private_impl.f_metadata_z);
|
||||
}
|
||||
if (self->private_impl.f_metadata_y >= self->private_impl.f_metadata_z) {
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
self->private_impl.f_metadata_y = self->private_impl.f_metadata_z;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__even_more_information);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
}
|
||||
self->private_impl.f_zlib_is_dirty = true;
|
||||
self->private_impl.f_ztxt_hist_pos = 0;
|
||||
}
|
||||
label__loop__continue:;
|
||||
while (true) {
|
||||
if (a_minfo != NULL) {
|
||||
wuffs_base__more_information__set(a_minfo,
|
||||
self->private_impl.f_metadata_flavor,
|
||||
self->private_impl.f_metadata_fourcc,
|
||||
self->private_impl.f_metadata_x,
|
||||
self->private_impl.f_metadata_y,
|
||||
self->private_impl.f_metadata_z);
|
||||
}
|
||||
if (self->private_impl.f_metadata_flavor != 4) {
|
||||
goto label__loop__break;
|
||||
}
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_chunk_type == 1346585449) {
|
||||
{
|
||||
const uint8_t *o_0_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
if (self->private_impl.f_zlib_is_dirty) {
|
||||
wuffs_base__ignore_status(wuffs_zlib__decoder__initialize(&self->private_data.f_zlib,
|
||||
sizeof (wuffs_zlib__decoder), WUFFS_VERSION, WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
if (self->private_impl.f_ignore_checksum) {
|
||||
wuffs_zlib__decoder__set_quirk_enabled(&self->private_data.f_zlib, 1, true);
|
||||
}
|
||||
}
|
||||
self->private_impl.f_zlib_is_dirty = true;
|
||||
self->private_impl.f_ztxt_hist_pos = 0;
|
||||
}
|
||||
label__loop__continue:;
|
||||
while (true) {
|
||||
if (a_minfo != NULL) {
|
||||
wuffs_base__more_information__set(a_minfo,
|
||||
self->private_impl.f_metadata_flavor,
|
||||
self->private_impl.f_metadata_fourcc,
|
||||
self->private_impl.f_metadata_x,
|
||||
self->private_impl.f_metadata_y,
|
||||
self->private_impl.f_metadata_z);
|
||||
}
|
||||
if (self->private_impl.f_metadata_flavor != 4) {
|
||||
goto label__loop__break;
|
||||
}
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_chunk_type == 1346585449) {
|
||||
{
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
const uint8_t *o_0_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_0 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_0;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_0_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
}
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
{
|
||||
const uint8_t *o_1_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_1 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_1;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_1_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
}
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_ztxt_ri == self->private_impl.f_ztxt_wi) {
|
||||
{
|
||||
wuffs_base__io_buffer* o_2_v_w = v_w;
|
||||
uint8_t *o_2_iop_v_w = iop_v_w;
|
||||
uint8_t *o_2_io0_v_w = io0_v_w;
|
||||
uint8_t *o_2_io1_v_w = io1_v_w;
|
||||
uint8_t *o_2_io2_v_w = io2_v_w;
|
||||
v_w = wuffs_base__io_writer__set(
|
||||
&u_w,
|
||||
&iop_v_w,
|
||||
&io0_v_w,
|
||||
&io1_v_w,
|
||||
&io2_v_w,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
|
||||
self->private_impl.f_ztxt_hist_pos);
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
const uint8_t *o_3_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
u_w.meta.wi = ((size_t)(iop_v_w - u_w.data.ptr));
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, v_w, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_2;
|
||||
iop_v_w = u_w.data.ptr + u_w.meta.wi;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)));
|
||||
io2_a_src = o_3_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_0 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_0;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
v_w = o_2_v_w;
|
||||
iop_v_w = o_2_iop_v_w;
|
||||
io0_v_w = o_2_io0_v_w;
|
||||
io1_v_w = o_2_io1_v_w;
|
||||
io2_v_w = o_2_io2_v_w;
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_0_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (v_num_written > 1024) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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_ztxt_ri = 0;
|
||||
self->private_impl.f_ztxt_wi = ((uint32_t)(v_num_written));
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_ztxt_hist_pos, v_num_written);
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
{
|
||||
const uint8_t *o_1_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
if (a_dst) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_1 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, a_dst, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_1;
|
||||
if (a_dst) {
|
||||
iop_a_dst = a_dst->data.ptr + a_dst->meta.wi;
|
||||
}
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
io2_a_src = o_1_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
}
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_ztxt_ri == self->private_impl.f_ztxt_wi) {
|
||||
{
|
||||
wuffs_base__io_buffer* o_2_v_w = v_w;
|
||||
uint8_t *o_2_iop_v_w = iop_v_w;
|
||||
uint8_t *o_2_io0_v_w = io0_v_w;
|
||||
uint8_t *o_2_io1_v_w = io1_v_w;
|
||||
uint8_t *o_2_io2_v_w = io2_v_w;
|
||||
v_w = wuffs_base__io_writer__set(
|
||||
&u_w,
|
||||
&iop_v_w,
|
||||
&io0_v_w,
|
||||
&io1_v_w,
|
||||
&io2_v_w,
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
|
||||
self->private_impl.f_ztxt_hist_pos);
|
||||
{
|
||||
const uint8_t *o_3_io2_a_src = io2_a_src;
|
||||
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
|
||||
((uint64_t)(self->private_impl.f_chunk_length)));
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
u_w.meta.wi = ((size_t)(iop_v_w - u_w.data.ptr));
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
wuffs_base__status t_2 = wuffs_zlib__decoder__transform_io(&self->private_data.f_zlib, v_w, a_src, wuffs_base__utility__empty_slice_u8());
|
||||
v_zlib_status = t_2;
|
||||
iop_v_w = u_w.data.ptr + u_w.meta.wi;
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
}
|
||||
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
|
||||
v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)));
|
||||
io2_a_src = o_3_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
v_w = o_2_v_w;
|
||||
iop_v_w = o_2_iop_v_w;
|
||||
io0_v_w = o_2_io0_v_w;
|
||||
io1_v_w = o_2_io1_v_w;
|
||||
io2_v_w = o_2_io2_v_w;
|
||||
}
|
||||
if (v_num_written > 1024) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_i_o);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri = 0;
|
||||
self->private_impl.f_ztxt_wi = ((uint32_t)(v_num_written));
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_ztxt_hist_pos, v_num_written);
|
||||
}
|
||||
while (self->private_impl.f_ztxt_ri < self->private_impl.f_ztxt_wi) {
|
||||
v_c2 = WUFFS_PNG__LATIN_1[self->private_data.f_dst_palette[self->private_impl.f_ztxt_ri]];
|
||||
if (v_c2 == 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_text_chunk_not_latin_1);
|
||||
goto exit;
|
||||
} else if (v_c2 <= 127) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, ((uint8_t)(v_c2))), iop_a_dst += 1);
|
||||
} else {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
(wuffs_base__poke_u16le__no_bounds_check(iop_a_dst, v_c2), iop_a_dst += 2);
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
} else if (v_zlib_status.repr != wuffs_base__suspension__short_write) {
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
}
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_chunk_type);
|
||||
goto exit;
|
||||
}
|
||||
while (self->private_impl.f_ztxt_ri < self->private_impl.f_ztxt_wi) {
|
||||
v_c2 = WUFFS_PNG__LATIN_1[self->private_data.f_dst_palette[self->private_impl.f_ztxt_ri]];
|
||||
} else if ((self->private_impl.f_chunk_type == 1951945833) && (self->private_impl.f_metadata_fourcc == 1263947862)) {
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
goto label__loop__continue;
|
||||
} else if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, v_c), iop_a_dst += 1);
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||
goto label__loop__continue;
|
||||
}
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
goto label__loop__break;
|
||||
}
|
||||
v_c2 = WUFFS_PNG__LATIN_1[v_c];
|
||||
if (v_c2 == 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_text_chunk_not_latin_1);
|
||||
goto exit;
|
||||
} else if (v_c2 <= 127) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, ((uint8_t)(v_c2))), iop_a_dst += 1);
|
||||
} else {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(4);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(11);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_ztxt_ri += 1;
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u16le__no_bounds_check(iop_a_dst, v_c2), iop_a_dst += 2);
|
||||
}
|
||||
}
|
||||
if (wuffs_base__status__is_ok(&v_zlib_status)) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
goto label__loop__break;
|
||||
} else if ( ! wuffs_base__status__is_suspension(&v_zlib_status)) {
|
||||
status = v_zlib_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;
|
||||
} else if (v_zlib_status.repr != wuffs_base__suspension__short_write) {
|
||||
status = v_zlib_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(5);
|
||||
}
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__internal_error_inconsistent_chunk_type);
|
||||
goto exit;
|
||||
}
|
||||
} else if ((self->private_impl.f_chunk_type == 1951945833) && (self->private_impl.f_metadata_fourcc == 1263947862)) {
|
||||
while (true) {
|
||||
}
|
||||
label__loop__break:;
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
self->private_impl.f_metadata_fourcc = 1263947862;
|
||||
if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
if (self->private_impl.f_chunk_length <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 2;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
||||
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++;
|
||||
v_c = t_3;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
} else if (v_c == 1) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = true;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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++;
|
||||
v_c = t_4;
|
||||
}
|
||||
if ((v_c != 0) && self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_fourcc -= 2;
|
||||
while (self->private_impl.f_metadata_fourcc != 1263947862) {
|
||||
self->private_impl.f_metadata_fourcc += 1;
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
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++;
|
||||
v_c = t_5;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
goto label__0__break;
|
||||
}
|
||||
}
|
||||
label__0__break:;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
goto label__loop__continue;
|
||||
} else if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
goto label__loop__continue;
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, v_c), iop_a_dst += 1);
|
||||
}
|
||||
} else {
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
goto label__loop__break;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label__loop__continue;
|
||||
uint8_t t_6 = *iop_a_src++;
|
||||
v_c = t_6;
|
||||
}
|
||||
v_c = wuffs_base__peek_u8be__no_bounds_check(iop_a_src);
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
goto label__loop__break;
|
||||
}
|
||||
v_c2 = WUFFS_PNG__LATIN_1[v_c];
|
||||
if (v_c2 == 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_text_chunk_not_latin_1);
|
||||
if (v_c != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
} else if (v_c2 <= 127) {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(9);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u8be__no_bounds_check(iop_a_dst, ((uint8_t)(v_c2))), iop_a_dst += 1);
|
||||
} else {
|
||||
if (((uint64_t)(io2_a_dst - iop_a_dst)) <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_write);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(10);
|
||||
v_c2 = 0;
|
||||
goto label__loop__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
iop_a_src += 1;
|
||||
(wuffs_base__poke_u16le__no_bounds_check(iop_a_dst, v_c2), iop_a_dst += 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
label__loop__break:;
|
||||
if (self->private_impl.f_metadata_fourcc == 1263947851) {
|
||||
self->private_impl.f_metadata_fourcc = 1263947862;
|
||||
if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
if (self->private_impl.f_chunk_length <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 2;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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++;
|
||||
v_c = t_3;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = false;
|
||||
} else if (v_c == 1) {
|
||||
self->private_impl.f_metadata_is_zlib_compressed = true;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
||||
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++;
|
||||
v_c = t_4;
|
||||
}
|
||||
if ((v_c != 0) && self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_fourcc -= 2;
|
||||
while (self->private_impl.f_metadata_fourcc != 1263947862) {
|
||||
self->private_impl.f_metadata_fourcc += 1;
|
||||
while (true) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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++;
|
||||
v_c = t_5;
|
||||
}
|
||||
if (v_c == 0) {
|
||||
goto label__0__break;
|
||||
}
|
||||
}
|
||||
label__0__break:;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1951945850) {
|
||||
if (self->private_impl.f_chunk_length <= 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_chunk_length -= 1;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
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++;
|
||||
v_c = t_6;
|
||||
}
|
||||
if (v_c != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_metadata_is_zlib_compressed = true;
|
||||
self->private_impl.f_call_sequence = 2;
|
||||
status = wuffs_base__make_status(NULL);
|
||||
goto ok;
|
||||
}
|
||||
} else {
|
||||
if (self->private_impl.f_chunk_length != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_tell_me_more[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
|
||||
if (self->private_data.s_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
iop_a_src = io2_a_src;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
iop_a_src += self->private_data.s_tell_me_more[0].scratch;
|
||||
self->private_impl.f_metadata_flavor = 0;
|
||||
self->private_impl.f_metadata_fourcc = 0;
|
||||
self->private_impl.f_metadata_x = 0;
|
||||
self->private_impl.f_metadata_y = 0;
|
||||
self->private_impl.f_metadata_z = 0;
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
label__goto_done__break:;
|
||||
if (self->private_impl.f_chunk_length != 0) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_tell_me_more[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
|
||||
if (self->private_data.s_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
iop_a_src = io2_a_src;
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
iop_a_src += self->private_data.s_tell_me_more[0].scratch;
|
||||
self->private_impl.f_metadata_flavor = 0;
|
||||
self->private_impl.f_metadata_fourcc = 0;
|
||||
self->private_impl.f_metadata_x = 0;
|
||||
self->private_impl.f_metadata_y = 0;
|
||||
self->private_impl.f_metadata_z = 0;
|
||||
self->private_impl.f_call_sequence = 2;
|
||||
status = wuffs_base__make_status(NULL);
|
||||
goto ok;
|
||||
@@ -43132,6 +43241,9 @@ redirect:
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_CHRM) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__CHRM, true);
|
||||
}
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_EXIF) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__EXIF, true);
|
||||
}
|
||||
if (flags & DecodeImageArgFlags::REPORT_METADATA_GAMA) {
|
||||
image_decoder->set_report_metadata(WUFFS_BASE__FOURCC__GAMA, true);
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ main(int argc, char** argv) {
|
||||
"compatible with the\n"
|
||||
"# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install "
|
||||
"it, first\n"
|
||||
"# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n");
|
||||
"# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n");
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
msg = decode(true, true);
|
||||
|
||||
@@ -81,7 +81,7 @@ func main1() error {
|
||||
fmt.Printf("#\n")
|
||||
fmt.Printf("# The output format, including the \"Benchmark\" prefixes, is compatible with the\n")
|
||||
fmt.Printf("# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install it, first\n")
|
||||
fmt.Printf("# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n")
|
||||
fmt.Printf("# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n")
|
||||
|
||||
for i := -1; i < reps; i++ {
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -106,7 +106,7 @@ func main1() error {
|
||||
fmt.Printf("#\n")
|
||||
fmt.Printf("# The output format, including the \"Benchmark\" prefixes, is compatible with the\n")
|
||||
fmt.Printf("# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install it, first\n")
|
||||
fmt.Printf("# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n")
|
||||
fmt.Printf("# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n")
|
||||
|
||||
for i := -1; i < reps; i++ {
|
||||
for _, tc := range testCases {
|
||||
|
||||
@@ -90,7 +90,7 @@ func main1() error {
|
||||
fmt.Printf("#\n")
|
||||
fmt.Printf("# The output format, including the \"Benchmark\" prefixes, is compatible with the\n")
|
||||
fmt.Printf("# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install it, first\n")
|
||||
fmt.Printf("# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n")
|
||||
fmt.Printf("# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n")
|
||||
|
||||
for i := -1; i < reps; i++ {
|
||||
for _, tc := range testCases {
|
||||
|
||||
+12
-2
@@ -32,9 +32,19 @@ save=`git log -1 --pretty=format:"%H"`
|
||||
|
||||
i=0
|
||||
while [ $i -lt $num_commits ]; do
|
||||
this_hash=`git log -1 --pretty=format:"%h"`
|
||||
set +e
|
||||
$cc -O3 -o bench-history.out test/c/std/$package.c
|
||||
this_metric=`./bench-history.out -bench -focus=$focus -iterscale=$iterscale -reps=$reps | benchstat /dev/stdin | sed -ne '/^name.*speed$/,$ p' | grep $focus`
|
||||
if [ $? -ne 0 ]; then
|
||||
this_metric='compile_failed'
|
||||
else
|
||||
this_metric=`./bench-history.out -bench -focus=$focus -iterscale=$iterscale -reps=$reps | benchstat /dev/stdin | sed -ne '/^name.*speed$/,$ p' | grep $focus`
|
||||
if [ $? -ne 0 ]; then
|
||||
this_metric='bench_failed'
|
||||
fi
|
||||
fi
|
||||
set -e
|
||||
|
||||
this_hash=`git log -1 --pretty=format:"%h"`
|
||||
echo $this_hash $this_metric
|
||||
git checkout --quiet HEAD^
|
||||
i=$((i + 1))
|
||||
|
||||
@@ -47,7 +47,7 @@ fn main() {
|
||||
print!("#\n");
|
||||
print!("# The output format, including the \"Benchmark\" prefixes, is compatible with the\n");
|
||||
print!("# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install it, first\n");
|
||||
print!("# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n");
|
||||
print!("# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n");
|
||||
|
||||
let mut dst = vec![0u8; 64 * 1024 * 1024];
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ fn main() {
|
||||
print!("#\n");
|
||||
print!("# The output format, including the \"Benchmark\" prefixes, is compatible with the\n");
|
||||
print!("# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install it, first\n");
|
||||
print!("# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n");
|
||||
print!("# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n");
|
||||
|
||||
let mut dst = vec![0u8; 64 * 1024 * 1024];
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ fn main() {
|
||||
print!("#\n");
|
||||
print!("# The output format, including the \"Benchmark\" prefixes, is compatible with the\n");
|
||||
print!("# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install it, first\n");
|
||||
print!("# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n");
|
||||
print!("# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n");
|
||||
|
||||
let mut dst0 = vec![0u8; 64 * 1024 * 1024];
|
||||
let mut dst1 = vec![0u8; 64 * 1024 * 1024];
|
||||
|
||||
@@ -587,20 +587,20 @@ func stateDeflateDynamicHuffman(line string) (stateFunc, error) {
|
||||
return stateDeflateDynamicHuffman, nil
|
||||
|
||||
} else if l, d, ok := deflateParseLenDist(line); ok {
|
||||
if (l != 3) || (d != 2) {
|
||||
return nil, fmt.Errorf("TODO: support len/dist pairs for dynamic Huffman blocks")
|
||||
if (l > 10) || (d > 4) {
|
||||
return nil, fmt.Errorf("TODO: support len/dist ExtraBits > 0 for dynamic Huffman blocks")
|
||||
}
|
||||
// len 3 is code 257, with no extra bits.
|
||||
if s := g.huffmans[2][257]; s != "" {
|
||||
// len 3 is code 257, len 4 is code 258, etc. All with no ExtraBits.
|
||||
if s := g.huffmans[2][l+254]; s != "" {
|
||||
deflateGlobalsWriteDynamicHuffmanBits(s)
|
||||
} else {
|
||||
return nil, fmt.Errorf("no code for literal/length symbol 257")
|
||||
return nil, fmt.Errorf("no code for literal/length symbol %d", l+254)
|
||||
}
|
||||
// dist 2 is code 1, with no extra bits.
|
||||
if s := g.huffmans[3][1]; s != "" {
|
||||
// dist 1 is code 0, dist 2 is code 1, etc. All with no ExtraBits.
|
||||
if s := g.huffmans[3][d-1]; s != "" {
|
||||
deflateGlobalsWriteDynamicHuffmanBits(s)
|
||||
} else {
|
||||
return nil, fmt.Errorf("no code for distance symbol 2")
|
||||
return nil, fmt.Errorf("no code for distance symbol %d", d-1)
|
||||
}
|
||||
return stateDeflateDynamicHuffman, nil
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ for f in $sources; do
|
||||
if [ -f $f ]; then
|
||||
handle $f
|
||||
elif [ -d $f ]; then
|
||||
for g in `find $f -type f | sort`; do
|
||||
for g in `find $f -type f | LANG=C sort`; do
|
||||
handle $g
|
||||
done
|
||||
else
|
||||
|
||||
@@ -628,17 +628,21 @@ pri func decoder.init_huff!(which: base.u32[..= 1], n_codes0: base.u32[..= 288],
|
||||
} endwhile
|
||||
if remaining <> 0 {
|
||||
// As a special case, allow a degenerate H-D Huffman table, with only
|
||||
// one 1-bit code, for the smallest possible distance.
|
||||
// one 1-bit code.
|
||||
if (args.which == 1) and (counts[1] == 1) and
|
||||
(this.code_lengths[args.n_codes0] == 1) and
|
||||
(((counts[0] as base.u32) + args.n_codes0 + 1) == args.n_codes1) {
|
||||
|
||||
this.n_huffs_bits[1] = 1
|
||||
this.huffs[1][0] = DCODE_MAGIC_NUMBERS[0] | 1
|
||||
this.huffs[1][1] = DCODE_MAGIC_NUMBERS[31] | 1
|
||||
return ok
|
||||
i = 0
|
||||
while i <= 29 {
|
||||
if this.code_lengths[args.n_codes0 + i] == 1 {
|
||||
this.n_huffs_bits[1] = 1
|
||||
this.huffs[1][0] = DCODE_MAGIC_NUMBERS[i] | 1
|
||||
this.huffs[1][1] = DCODE_MAGIC_NUMBERS[31] | 1
|
||||
return ok
|
||||
}
|
||||
i += 1
|
||||
} endwhile
|
||||
}
|
||||
|
||||
return "#bad Huffman code (under-subscribed)"
|
||||
}
|
||||
|
||||
|
||||
@@ -219,18 +219,14 @@ pri func decoder.decode_huffman_bmi2!(dst: base.io_writer, src: base.io_reader)
|
||||
if this.history_index < hdist {
|
||||
return "#bad distance"
|
||||
}
|
||||
// Re-purpose the hdist variable as the this.history index to
|
||||
// start copying from.
|
||||
hdist = this.history_index - hdist
|
||||
|
||||
// Copy from hdist to the end of this.history.
|
||||
// Copy from this.history[(this.history_index - hdist) ..].
|
||||
//
|
||||
// This copying is simpler than the decode_huffman_slow version
|
||||
// because it cannot yield. We have already checked that
|
||||
// args.dst.length() is large enough.
|
||||
args.dst.limited_copy_u32_from_slice!(
|
||||
up_to: hlen, s: this.history[hdist & 0x7FFF ..])
|
||||
|
||||
up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..])
|
||||
if length == 0 {
|
||||
// No need to copy from args.dst.
|
||||
continue.loop
|
||||
|
||||
@@ -324,18 +324,14 @@ pri func decoder.decode_huffman_fast32!(dst: base.io_writer, src: base.io_reader
|
||||
if this.history_index < hdist {
|
||||
return "#bad distance"
|
||||
}
|
||||
// Re-purpose the hdist variable as the this.history index to
|
||||
// start copying from.
|
||||
hdist = this.history_index - hdist
|
||||
|
||||
// Copy from hdist to the end of this.history.
|
||||
// Copy from this.history[(this.history_index - hdist) ..].
|
||||
//
|
||||
// This copying is simpler than the decode_huffman_slow version
|
||||
// because it cannot yield. We have already checked that
|
||||
// args.dst.length() is large enough.
|
||||
args.dst.limited_copy_u32_from_slice!(
|
||||
up_to: hlen, s: this.history[hdist & 0x7FFF ..])
|
||||
|
||||
up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..])
|
||||
if length == 0 {
|
||||
// No need to copy from args.dst.
|
||||
continue.loop
|
||||
|
||||
@@ -218,18 +218,14 @@ pri func decoder.decode_huffman_fast64!(dst: base.io_writer, src: base.io_reader
|
||||
if this.history_index < hdist {
|
||||
return "#bad distance"
|
||||
}
|
||||
// Re-purpose the hdist variable as the this.history index to
|
||||
// start copying from.
|
||||
hdist = this.history_index - hdist
|
||||
|
||||
// Copy from hdist to the end of this.history.
|
||||
// Copy from this.history[(this.history_index - hdist) ..].
|
||||
//
|
||||
// This copying is simpler than the decode_huffman_slow version
|
||||
// because it cannot yield. We have already checked that
|
||||
// args.dst.length() is large enough.
|
||||
args.dst.limited_copy_u32_from_slice!(
|
||||
up_to: hlen, s: this.history[hdist & 0x7FFF ..])
|
||||
|
||||
up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..])
|
||||
if length == 0 {
|
||||
// No need to copy from args.dst.
|
||||
continue.loop
|
||||
|
||||
@@ -201,63 +201,38 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader)
|
||||
n_bits -= table_entry_n_bits
|
||||
}
|
||||
|
||||
while true {
|
||||
while.inner true {
|
||||
// Copy from this.history.
|
||||
if ((dist_minus_1 + 1) as base.u64) > args.dst.history_length() {
|
||||
// Set (hlen, hdist) to be the length-distance pair to copy
|
||||
// from this.history, and (length, distance) to be the
|
||||
// remaining length-distance pair to copy from args.dst.
|
||||
// from this.history.
|
||||
hdist = (((dist_minus_1 + 1) as base.u64) - args.dst.history_length()) as base.u32
|
||||
if length > hdist {
|
||||
assert hdist < length via "a < b: b > a"()
|
||||
if hdist < length {
|
||||
assert hdist < 0x8000 via "a < b: a < c; c <= b"(c: length)
|
||||
length -= hdist
|
||||
hlen = hdist
|
||||
assert hlen <= length via "a <= b: a == c; c <= b"(c: hdist)
|
||||
} else {
|
||||
hlen = length
|
||||
length = 0
|
||||
assert hlen <= length via "a <= b: a == b"()
|
||||
}
|
||||
|
||||
hdist ~mod+= ((this.transformed_history_count ~mod- args.dst.history_position()) & 0xFFFF_FFFF) as base.u32
|
||||
if this.history_index < hdist {
|
||||
return "#bad distance"
|
||||
}
|
||||
// Re-purpose the hdist variable as the this.history index to
|
||||
// start copying from.
|
||||
hdist = this.history_index - hdist
|
||||
|
||||
// Copy from hdist to the end of this.history.
|
||||
while true {
|
||||
n_copied = args.dst.limited_copy_u32_from_slice!(
|
||||
up_to: hlen, s: this.history[hdist & 0x7FFF .. 0x8000])
|
||||
if hlen <= n_copied {
|
||||
hlen = 0
|
||||
break
|
||||
}
|
||||
if n_copied > 0 {
|
||||
hlen -= n_copied
|
||||
hdist = (hdist ~mod+ n_copied) & 0x7FFF
|
||||
if hdist == 0 {
|
||||
// Wrap around the this.history ringbuffer.
|
||||
break
|
||||
}
|
||||
}
|
||||
// Copy from this.history[(this.history_index - hdist) ..].
|
||||
n_copied = args.dst.limited_copy_u32_from_slice!(
|
||||
up_to: hlen, s: this.history[(this.history_index - hdist) & 0x7FFF ..])
|
||||
if n_copied < hlen {
|
||||
assert n_copied < length via "a < b: a < c; c <= b"(c: hlen)
|
||||
assert length > n_copied via "a > b: b < a"()
|
||||
length -= n_copied
|
||||
yield? base."$short write"
|
||||
} endwhile
|
||||
// Copy from the start of this.history, if we wrapped around.
|
||||
if hlen > 0 {
|
||||
while true {
|
||||
n_copied = args.dst.limited_copy_u32_from_slice!(
|
||||
up_to: hlen, s: this.history[hdist & 0x7FFF .. 0x8000])
|
||||
if hlen <= n_copied {
|
||||
hlen = 0
|
||||
break
|
||||
}
|
||||
hlen -= n_copied
|
||||
hdist ~mod+= n_copied
|
||||
yield? base."$short write"
|
||||
} endwhile
|
||||
continue.inner
|
||||
}
|
||||
|
||||
assert length >= hlen via "a >= b: b <= a"()
|
||||
length -= hlen
|
||||
if length == 0 {
|
||||
// No need to copy from args.dst.
|
||||
continue.loop
|
||||
@@ -268,12 +243,11 @@ pri func decoder.decode_huffman_slow?(dst: base.io_writer, src: base.io_reader)
|
||||
n_copied = args.dst.limited_copy_u32_from_history!(
|
||||
up_to: length, distance: (dist_minus_1 + 1))
|
||||
if length <= n_copied {
|
||||
length = 0
|
||||
break
|
||||
continue.loop
|
||||
}
|
||||
length -= n_copied
|
||||
yield? base."$short write"
|
||||
} endwhile
|
||||
} endwhile.inner
|
||||
} endwhile.loop
|
||||
|
||||
// TODO: "assert n_bits < 8"? What about (bits >> n_bits)?
|
||||
|
||||
@@ -277,7 +277,21 @@ pub func decoder.num_animation_loops() base.u32 {
|
||||
if this.seen_num_animation_loops_value {
|
||||
return this.num_animation_loops_value
|
||||
}
|
||||
return 1
|
||||
// Absent an explicit animation loop count, default to 1 meaning "play each
|
||||
// frame exactly once" for animated GIFs and 0 meaning "loop forever" for
|
||||
// still (non-animated) GIFs.
|
||||
//
|
||||
// In practice, returning 1 or 0 has no difference for still GIFs, in that
|
||||
// either way, the pixels on screen do not change over time. However,
|
||||
// returning 0 here matches other Wuffs image decoders (e.g. BMP, PNG)
|
||||
// returning 0 for their still images.
|
||||
//
|
||||
// As a consequence, if a still GIF is losslessly converted to a still BMP
|
||||
// and both of those are then converted to NIA, the two NIA outputs match.
|
||||
if this.num_decoded_frame_configs_value > 1 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
pub func decoder.num_decoded_frame_configs() base.u64 {
|
||||
|
||||
@@ -56,7 +56,6 @@ pub struct decoder? implements base.image_decoder(
|
||||
|
||||
swizzler : base.pixel_swizzler,
|
||||
util : base.utility,
|
||||
)(
|
||||
)
|
||||
|
||||
pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
|
||||
+81
-17
@@ -75,6 +75,7 @@ pub struct decoder? implements base.image_decoder(
|
||||
call_sequence : base.u8,
|
||||
|
||||
report_metadata_chrm : base.bool,
|
||||
report_metadata_exif : base.bool,
|
||||
report_metadata_gama : base.bool,
|
||||
report_metadata_iccp : base.bool,
|
||||
report_metadata_kvp : base.bool,
|
||||
@@ -90,6 +91,7 @@ pub struct decoder? implements base.image_decoder(
|
||||
seen_actl : base.bool,
|
||||
seen_chrm : base.bool,
|
||||
seen_fctl : base.bool,
|
||||
seen_exif : base.bool,
|
||||
seen_gama : base.bool,
|
||||
seen_iccp : base.bool,
|
||||
seen_idat : base.bool,
|
||||
@@ -441,8 +443,14 @@ pri func decoder.assign_filter_distance!() {
|
||||
this.src_pixfmt = base.PIXEL_FORMAT__Y
|
||||
this.filter_distance = 1
|
||||
} else if this.depth == 16 {
|
||||
this.dst_pixfmt = base.PIXEL_FORMAT__Y_16LE
|
||||
this.src_pixfmt = base.PIXEL_FORMAT__Y_16BE
|
||||
if this.interlace_pass == 0 {
|
||||
this.dst_pixfmt = base.PIXEL_FORMAT__Y_16LE
|
||||
this.src_pixfmt = base.PIXEL_FORMAT__Y_16BE
|
||||
} else {
|
||||
// Interlaced means choosing filter_and_swizzle_tricky.
|
||||
this.dst_pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE
|
||||
this.src_pixfmt = base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE
|
||||
}
|
||||
this.filter_distance = 2
|
||||
}
|
||||
|
||||
@@ -535,10 +543,18 @@ pri func decoder.choose_filter_implementations!() {
|
||||
|
||||
pri func decoder.decode_other_chunk?(src: base.io_reader) {
|
||||
if this.chunk_type == 'PLTE'le {
|
||||
if this.seen_plte or (this.color_type <> 3) {
|
||||
if this.seen_plte {
|
||||
return "#bad chunk"
|
||||
} else if this.color_type == 3 {
|
||||
// Color type 3 means paletted.
|
||||
this.decode_plte?(src: args.src)
|
||||
} else if (this.color_type == 2) or (this.color_type == 6) {
|
||||
// Color types 2 and 6 means RGB and RGBA. In these cases, the PLTE
|
||||
// chunk is merely a hint, like a sPLT "suggested palette" chunk.
|
||||
// We ignore it.
|
||||
} else {
|
||||
return "#bad chunk"
|
||||
}
|
||||
this.decode_plte?(src: args.src)
|
||||
this.seen_plte = true
|
||||
|
||||
} else if (this.chunk_type & ANCILLARY_BIT) == 0 {
|
||||
@@ -562,6 +578,15 @@ pri func decoder.decode_other_chunk?(src: base.io_reader) {
|
||||
this.seen_chrm = true
|
||||
}
|
||||
|
||||
} else if this.chunk_type == 'eXIf'le {
|
||||
if this.report_metadata_exif {
|
||||
if this.seen_exif {
|
||||
return "#bad chunk"
|
||||
}
|
||||
this.decode_exif?(src: args.src)
|
||||
this.seen_exif = true
|
||||
}
|
||||
|
||||
} else if this.chunk_type == 'fcTL'le {
|
||||
if this.seen_fctl {
|
||||
return "#bad chunk"
|
||||
@@ -675,6 +700,18 @@ pri func decoder.decode_chrm?(src: base.io_reader) {
|
||||
this.metadata_z |= (0xFF_FFFF & u) << 40
|
||||
}
|
||||
|
||||
pri func decoder.decode_exif?(src: base.io_reader) {
|
||||
if this.chunk_length < 4 {
|
||||
return "#bad chunk"
|
||||
}
|
||||
this.metadata_flavor = base.MORE_INFORMATION__FLAVOR__METADATA_RAW_PASSTHROUGH
|
||||
this.metadata_fourcc = 'EXIF'be
|
||||
this.metadata_x = 0
|
||||
this.metadata_y = args.src.position()
|
||||
this.metadata_z = this.metadata_y ~sat+ (this.chunk_length as base.u64)
|
||||
this.chunk_length = 0
|
||||
}
|
||||
|
||||
pri func decoder.decode_fctl?(src: base.io_reader) {
|
||||
var x0 : base.u32
|
||||
var y0 : base.u32
|
||||
@@ -1324,6 +1361,8 @@ pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.sta
|
||||
pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
|
||||
if args.fourcc == 'CHRM'be {
|
||||
this.report_metadata_chrm = args.report
|
||||
} else if args.fourcc == 'EXIF'be {
|
||||
this.report_metadata_exif = args.report
|
||||
} else if args.fourcc == 'GAMA'be {
|
||||
this.report_metadata_gama = args.report
|
||||
} else if args.fourcc == 'ICCP'be {
|
||||
@@ -1351,6 +1390,27 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform
|
||||
return base."#no more information"
|
||||
}
|
||||
|
||||
while.goto_done true {{
|
||||
if this.metadata_flavor == base.MORE_INFORMATION__FLAVOR__METADATA_RAW_PASSTHROUGH {
|
||||
while true {
|
||||
if args.src.position() <> this.metadata_y {
|
||||
return base."#bad I/O position"
|
||||
} else if args.minfo <> nullptr {
|
||||
args.minfo.set!(
|
||||
flavor: this.metadata_flavor,
|
||||
w: this.metadata_fourcc,
|
||||
x: this.metadata_x,
|
||||
y: this.metadata_y,
|
||||
z: this.metadata_z)
|
||||
}
|
||||
if this.metadata_y >= this.metadata_z {
|
||||
break.goto_done
|
||||
}
|
||||
this.metadata_y = this.metadata_z
|
||||
yield? base."$even more information"
|
||||
} endwhile
|
||||
}
|
||||
|
||||
if this.metadata_is_zlib_compressed {
|
||||
if this.zlib_is_dirty {
|
||||
this.zlib.reset!()
|
||||
@@ -1589,20 +1649,24 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform
|
||||
this.metadata_is_zlib_compressed = true
|
||||
}
|
||||
|
||||
} else {
|
||||
if this.chunk_length <> 0 {
|
||||
return "#bad chunk"
|
||||
}
|
||||
|
||||
// Skip the ancillary chunk's CRC-32 checksum.
|
||||
args.src.skip?(n: 4)
|
||||
|
||||
this.metadata_flavor = 0
|
||||
this.metadata_fourcc = 0
|
||||
this.metadata_x = 0
|
||||
this.metadata_y = 0
|
||||
this.metadata_z = 0
|
||||
this.call_sequence = 2
|
||||
return ok
|
||||
}
|
||||
break.goto_done
|
||||
}} endwhile.goto_done
|
||||
|
||||
if this.chunk_length <> 0 {
|
||||
return "#bad chunk"
|
||||
}
|
||||
|
||||
// Skip the ancillary chunk's CRC-32 checksum.
|
||||
args.src.skip?(n: 4)
|
||||
|
||||
this.metadata_flavor = 0
|
||||
this.metadata_fourcc = 0
|
||||
this.metadata_x = 0
|
||||
this.metadata_y = 0
|
||||
this.metadata_z = 0
|
||||
|
||||
this.call_sequence = 2
|
||||
return ok
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2021 The Wuffs Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// --------
|
||||
|
||||
// Quirks are discussed in (/doc/note/quirks.md).
|
||||
//
|
||||
// The base38 encoding of "zlib" is 0x1F_7F79. Left shifting by 10 gives
|
||||
// 0x7DFD_E400.
|
||||
pri const QUIRKS_BASE : base.u32 = 0x7DFD_E400
|
||||
|
||||
// --------
|
||||
|
||||
// When this quirk is enabled, the decoder speaks just raw deflate, without
|
||||
// zlib's configuration prefix and checksum suffix wrapped around that.
|
||||
//
|
||||
// A zlib.decoder basically becomes a deflate.decoder. This is useful when the
|
||||
// caller might want to choose between the two related-but-slightly-different
|
||||
// formats at run time but would rather not allocate two separate decoders.
|
||||
pub const QUIRK_JUST_RAW_DEFLATE : base.u32 = 0x7DFD_E400 | 0x00
|
||||
|
||||
pri const QUIRKS_COUNT : base.u32 = 0x01
|
||||
@@ -33,6 +33,8 @@ pub struct decoder? implements base.io_transformer(
|
||||
got_dictionary : base.bool,
|
||||
want_dictionary : base.bool,
|
||||
|
||||
quirks : array[QUIRKS_COUNT] base.bool,
|
||||
|
||||
ignore_checksum : base.bool,
|
||||
checksum : adler32.hasher,
|
||||
|
||||
@@ -60,8 +62,15 @@ pub func decoder.add_dictionary!(dict: slice base.u8) {
|
||||
}
|
||||
|
||||
pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
if args.quirk == base.QUIRK_IGNORE_CHECKSUM {
|
||||
if this.header_complete {
|
||||
this.bad_call_sequence = true
|
||||
} else if args.quirk == base.QUIRK_IGNORE_CHECKSUM {
|
||||
this.ignore_checksum = args.enabled
|
||||
} else if args.quirk >= QUIRKS_BASE {
|
||||
args.quirk -= QUIRKS_BASE
|
||||
if args.quirk < QUIRKS_COUNT {
|
||||
this.quirks[args.quirk] = args.enabled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +89,8 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf
|
||||
|
||||
if this.bad_call_sequence {
|
||||
return base."#bad call sequence"
|
||||
} else if this.quirks[QUIRK_JUST_RAW_DEFLATE - QUIRKS_BASE] {
|
||||
// No-op.
|
||||
} else if not this.want_dictionary {
|
||||
x = args.src.read_u16be?()
|
||||
if ((x >> 8) & 0x0F) <> 0x08 {
|
||||
@@ -112,7 +123,7 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf
|
||||
while true {
|
||||
mark = args.dst.mark()
|
||||
status =? this.flate.transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
|
||||
if not this.ignore_checksum {
|
||||
if (not this.ignore_checksum) and (not this.quirks[QUIRK_JUST_RAW_DEFLATE - QUIRKS_BASE]) {
|
||||
checksum_got = this.checksum.update_u32!(x: args.dst.since(mark: mark))
|
||||
}
|
||||
if status.is_ok() {
|
||||
@@ -120,9 +131,12 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
checksum_want = args.src.read_u32be?()
|
||||
if (not this.ignore_checksum) and (checksum_got <> checksum_want) {
|
||||
return "#bad checksum"
|
||||
|
||||
if not this.quirks[QUIRK_JUST_RAW_DEFLATE - QUIRKS_BASE] {
|
||||
checksum_want = args.src.read_u32be?()
|
||||
if (not this.ignore_checksum) and (checksum_got <> checksum_want) {
|
||||
return "#bad checksum"
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: reset state (e.g. want_dictionary), so that we can read concat'ed
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Ignore everything without a dot.
|
||||
#
|
||||
# This ignores "pngsuite" but not "fetch-pngsuite.sh".
|
||||
*
|
||||
!*.*
|
||||
@@ -0,0 +1,5 @@
|
||||
This directory contains third party test data, not checked into the repository
|
||||
directly for download size and copyright reasons.
|
||||
|
||||
It also contains derived summary data files (such as `nia-checksums-of-*.txt`)
|
||||
which *are* checked into the repository, for regression testing.
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -eu
|
||||
# Copyright 2021 The Wuffs Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# ----------------
|
||||
|
||||
# This script fetches the PngSuite collection of PNG images.
|
||||
|
||||
if [ ! -e ../../wuffs-root-directory.txt ]; then
|
||||
echo "$0 should be run from the Wuffs test/3pdata directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p pngsuite
|
||||
curl --silent http://www.schaik.com/pngsuite/PngSuite-2017jul19.tgz | tar -xzf /dev/stdin -C pngsuite
|
||||
@@ -0,0 +1,29 @@
|
||||
As per [the PngSuite page](http://www.schaik.com/pngsuite/#corrupted), every
|
||||
`x*.png` file in the test suite is invalid PNG.
|
||||
|
||||
Nonetheless, `nia-checksums-of-pngsuite.txt` contains an entry for
|
||||
`xcsn0g01.png`, meaning that `convert-to-nia` decoded *some* pixels for it.
|
||||
This is working as intended, because the `xcsn0g01.png` invalidity is in its
|
||||
`IDAT` chunk's checksum (compared to `xhdn0g08.png`'s corruption in its `IHDR`
|
||||
chunk's checksum).
|
||||
|
||||
The `convert-to-nia` semantics are that, provided that it can decode a complete
|
||||
image configuration (width, height, pixel format, etc which, for PNG, comes
|
||||
from the `IHDR` chunk), it outputs *as many pixels as possible* (even if that's
|
||||
zero pixels) so that it gives a 'best effort' decoding for truncated images.
|
||||
Indeed, the NIA conversion for `xcsn0g01.png` holds all-zero pixels (and a
|
||||
"png: bad checksum" error message on stderr) but also a zero exit code.
|
||||
|
||||
```
|
||||
$ gen/bin/example-convert-to-nia < test/3pdata/pngsuite/xcsn0g01.png | hd
|
||||
00000000 6e c3 af 41 ff 62 6e 34 20 00 00 00 20 00 00 00 |n..A.bn4 ... ...|
|
||||
00000010 00 00 00 00 00 00 00 00 6e c3 af 45 ff 62 6e 34 |........n..E.bn4|
|
||||
00000020 20 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 | ... ...........|
|
||||
00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
|
||||
*
|
||||
00001020 00 00 00 00 00 00 00 00 |........|
|
||||
00001028
|
||||
png: bad checksum
|
||||
$ echo $?
|
||||
0
|
||||
```
|
||||
@@ -0,0 +1,164 @@
|
||||
# Generated by script/print-nia-checksums.sh
|
||||
aac44167 test/3pdata/pngsuite/PngSuite.png
|
||||
926d3aa2 test/3pdata/pngsuite/basi0g01.png
|
||||
8f50bdc6 test/3pdata/pngsuite/basi0g02.png
|
||||
6d612626 test/3pdata/pngsuite/basi0g04.png
|
||||
024cf410 test/3pdata/pngsuite/basi0g08.png
|
||||
bb956205 test/3pdata/pngsuite/basi0g16.png
|
||||
d1ae61d3 test/3pdata/pngsuite/basi2c08.png
|
||||
84bc9be8 test/3pdata/pngsuite/basi2c16.png
|
||||
49bc6b98 test/3pdata/pngsuite/basi3p01.png
|
||||
ad12897b test/3pdata/pngsuite/basi3p02.png
|
||||
81c22b59 test/3pdata/pngsuite/basi3p04.png
|
||||
e59ecea5 test/3pdata/pngsuite/basi3p08.png
|
||||
1b468494 test/3pdata/pngsuite/basi4a08.png
|
||||
8a6dd244 test/3pdata/pngsuite/basi4a16.png
|
||||
2b1044ce test/3pdata/pngsuite/basi6a08.png
|
||||
b039babf test/3pdata/pngsuite/basi6a16.png
|
||||
926d3aa2 test/3pdata/pngsuite/basn0g01.png
|
||||
8f50bdc6 test/3pdata/pngsuite/basn0g02.png
|
||||
6d612626 test/3pdata/pngsuite/basn0g04.png
|
||||
024cf410 test/3pdata/pngsuite/basn0g08.png
|
||||
bb956205 test/3pdata/pngsuite/basn0g16.png
|
||||
d1ae61d3 test/3pdata/pngsuite/basn2c08.png
|
||||
84bc9be8 test/3pdata/pngsuite/basn2c16.png
|
||||
49bc6b98 test/3pdata/pngsuite/basn3p01.png
|
||||
ad12897b test/3pdata/pngsuite/basn3p02.png
|
||||
81c22b59 test/3pdata/pngsuite/basn3p04.png
|
||||
e59ecea5 test/3pdata/pngsuite/basn3p08.png
|
||||
1b468494 test/3pdata/pngsuite/basn4a08.png
|
||||
8a6dd244 test/3pdata/pngsuite/basn4a16.png
|
||||
2b1044ce test/3pdata/pngsuite/basn6a08.png
|
||||
b039babf test/3pdata/pngsuite/basn6a16.png
|
||||
1b468494 test/3pdata/pngsuite/bgai4a08.png
|
||||
8a6dd244 test/3pdata/pngsuite/bgai4a16.png
|
||||
2b1044ce test/3pdata/pngsuite/bgan6a08.png
|
||||
b039babf test/3pdata/pngsuite/bgan6a16.png
|
||||
1b468494 test/3pdata/pngsuite/bgbn4a08.png
|
||||
8a6dd244 test/3pdata/pngsuite/bggn4a16.png
|
||||
2b1044ce test/3pdata/pngsuite/bgwn6a08.png
|
||||
b039babf test/3pdata/pngsuite/bgyn6a16.png
|
||||
b58985e2 test/3pdata/pngsuite/ccwn2c08.png
|
||||
b7f7127d test/3pdata/pngsuite/ccwn3p08.png
|
||||
c7b4c0fa test/3pdata/pngsuite/cdfn2c08.png
|
||||
dabf7a40 test/3pdata/pngsuite/cdhn2c08.png
|
||||
8491ddf5 test/3pdata/pngsuite/cdsn2c08.png
|
||||
d9282a90 test/3pdata/pngsuite/cdun2c08.png
|
||||
81c22b59 test/3pdata/pngsuite/ch1n3p04.png
|
||||
e59ecea5 test/3pdata/pngsuite/ch2n3p08.png
|
||||
b3334ede test/3pdata/pngsuite/cm0n0g04.png
|
||||
b3334ede test/3pdata/pngsuite/cm7n0g04.png
|
||||
b3334ede test/3pdata/pngsuite/cm9n0g04.png
|
||||
8ce6e28c test/3pdata/pngsuite/cs3n2c16.png
|
||||
d565507c test/3pdata/pngsuite/cs3n3p08.png
|
||||
2f5a21b9 test/3pdata/pngsuite/cs5n2c08.png
|
||||
2f5a21b9 test/3pdata/pngsuite/cs5n3p08.png
|
||||
8ce6e28c test/3pdata/pngsuite/cs8n2c08.png
|
||||
8ce6e28c test/3pdata/pngsuite/cs8n3p08.png
|
||||
b3334ede test/3pdata/pngsuite/ct0n0g04.png
|
||||
b3334ede test/3pdata/pngsuite/ct1n0g04.png
|
||||
1bfcb6e6 test/3pdata/pngsuite/cten0g04.png
|
||||
8e493daf test/3pdata/pngsuite/ctfn0g04.png
|
||||
417a539e test/3pdata/pngsuite/ctgn0g04.png
|
||||
28033324 test/3pdata/pngsuite/cthn0g04.png
|
||||
71a82501 test/3pdata/pngsuite/ctjn0g04.png
|
||||
b3334ede test/3pdata/pngsuite/ctzn0g04.png
|
||||
aa5328d3 test/3pdata/pngsuite/exif2c08.png
|
||||
b81f03cc test/3pdata/pngsuite/f00n0g08.png
|
||||
4a12368c test/3pdata/pngsuite/f00n2c08.png
|
||||
7fe4a9d8 test/3pdata/pngsuite/f01n0g08.png
|
||||
36758edc test/3pdata/pngsuite/f01n2c08.png
|
||||
e0ab5774 test/3pdata/pngsuite/f02n0g08.png
|
||||
5e613513 test/3pdata/pngsuite/f02n2c08.png
|
||||
0719e3fa test/3pdata/pngsuite/f03n0g08.png
|
||||
c4709cc1 test/3pdata/pngsuite/f03n2c08.png
|
||||
457f1dab test/3pdata/pngsuite/f04n0g08.png
|
||||
7ec3c986 test/3pdata/pngsuite/f04n2c08.png
|
||||
1f319e46 test/3pdata/pngsuite/f99n0g04.png
|
||||
6000bb5b test/3pdata/pngsuite/g03n0g16.png
|
||||
aa019a24 test/3pdata/pngsuite/g03n2c08.png
|
||||
8f0a3383 test/3pdata/pngsuite/g03n3p04.png
|
||||
f3a44153 test/3pdata/pngsuite/g04n0g16.png
|
||||
3e852c56 test/3pdata/pngsuite/g04n2c08.png
|
||||
edb3555b test/3pdata/pngsuite/g04n3p04.png
|
||||
6b105de1 test/3pdata/pngsuite/g05n0g16.png
|
||||
938803a0 test/3pdata/pngsuite/g05n2c08.png
|
||||
9f7ad612 test/3pdata/pngsuite/g05n3p04.png
|
||||
28816978 test/3pdata/pngsuite/g07n0g16.png
|
||||
fedb8920 test/3pdata/pngsuite/g07n2c08.png
|
||||
9373010e test/3pdata/pngsuite/g07n3p04.png
|
||||
58eb5aca test/3pdata/pngsuite/g10n0g16.png
|
||||
8c5550d0 test/3pdata/pngsuite/g10n2c08.png
|
||||
a6120550 test/3pdata/pngsuite/g10n3p04.png
|
||||
14cc7e1c test/3pdata/pngsuite/g25n0g16.png
|
||||
fd0f349f test/3pdata/pngsuite/g25n2c08.png
|
||||
eb13812a test/3pdata/pngsuite/g25n3p04.png
|
||||
bb956205 test/3pdata/pngsuite/oi1n0g16.png
|
||||
84bc9be8 test/3pdata/pngsuite/oi1n2c16.png
|
||||
bb956205 test/3pdata/pngsuite/oi2n0g16.png
|
||||
84bc9be8 test/3pdata/pngsuite/oi2n2c16.png
|
||||
bb956205 test/3pdata/pngsuite/oi4n0g16.png
|
||||
84bc9be8 test/3pdata/pngsuite/oi4n2c16.png
|
||||
bb956205 test/3pdata/pngsuite/oi9n0g16.png
|
||||
84bc9be8 test/3pdata/pngsuite/oi9n2c16.png
|
||||
84bc9be8 test/3pdata/pngsuite/pp0n2c16.png
|
||||
8ed1f246 test/3pdata/pngsuite/pp0n6a08.png
|
||||
024cf410 test/3pdata/pngsuite/ps1n0g08.png
|
||||
84bc9be8 test/3pdata/pngsuite/ps1n2c16.png
|
||||
024cf410 test/3pdata/pngsuite/ps2n0g08.png
|
||||
84bc9be8 test/3pdata/pngsuite/ps2n2c16.png
|
||||
7cf2b7b2 test/3pdata/pngsuite/s01i3p01.png
|
||||
7cf2b7b2 test/3pdata/pngsuite/s01n3p01.png
|
||||
ffa30c78 test/3pdata/pngsuite/s02i3p01.png
|
||||
ffa30c78 test/3pdata/pngsuite/s02n3p01.png
|
||||
ad298c62 test/3pdata/pngsuite/s03i3p01.png
|
||||
ad298c62 test/3pdata/pngsuite/s03n3p01.png
|
||||
2c30132c test/3pdata/pngsuite/s04i3p01.png
|
||||
2c30132c test/3pdata/pngsuite/s04n3p01.png
|
||||
5fb20358 test/3pdata/pngsuite/s05i3p02.png
|
||||
5fb20358 test/3pdata/pngsuite/s05n3p02.png
|
||||
764e90bd test/3pdata/pngsuite/s06i3p02.png
|
||||
764e90bd test/3pdata/pngsuite/s06n3p02.png
|
||||
9eebca92 test/3pdata/pngsuite/s07i3p02.png
|
||||
9eebca92 test/3pdata/pngsuite/s07n3p02.png
|
||||
d57f2e84 test/3pdata/pngsuite/s08i3p02.png
|
||||
d57f2e84 test/3pdata/pngsuite/s08n3p02.png
|
||||
7585127f test/3pdata/pngsuite/s09i3p02.png
|
||||
7585127f test/3pdata/pngsuite/s09n3p02.png
|
||||
034051a8 test/3pdata/pngsuite/s32i3p04.png
|
||||
034051a8 test/3pdata/pngsuite/s32n3p04.png
|
||||
a377dcdd test/3pdata/pngsuite/s33i3p04.png
|
||||
a377dcdd test/3pdata/pngsuite/s33n3p04.png
|
||||
5bcd998d test/3pdata/pngsuite/s34i3p04.png
|
||||
5bcd998d test/3pdata/pngsuite/s34n3p04.png
|
||||
1cefbbe2 test/3pdata/pngsuite/s35i3p04.png
|
||||
1cefbbe2 test/3pdata/pngsuite/s35n3p04.png
|
||||
97c763a3 test/3pdata/pngsuite/s36i3p04.png
|
||||
97c763a3 test/3pdata/pngsuite/s36n3p04.png
|
||||
2d6bd687 test/3pdata/pngsuite/s37i3p04.png
|
||||
2d6bd687 test/3pdata/pngsuite/s37n3p04.png
|
||||
169951e5 test/3pdata/pngsuite/s38i3p04.png
|
||||
169951e5 test/3pdata/pngsuite/s38n3p04.png
|
||||
17a92eb2 test/3pdata/pngsuite/s39i3p04.png
|
||||
17a92eb2 test/3pdata/pngsuite/s39n3p04.png
|
||||
8cc6b93d test/3pdata/pngsuite/s40i3p04.png
|
||||
8cc6b93d test/3pdata/pngsuite/s40n3p04.png
|
||||
4e406947 test/3pdata/pngsuite/tbbn0g04.png
|
||||
c6e83019 test/3pdata/pngsuite/tbbn2c16.png
|
||||
46deef3b test/3pdata/pngsuite/tbbn3p08.png
|
||||
c6e83019 test/3pdata/pngsuite/tbgn2c16.png
|
||||
46deef3b test/3pdata/pngsuite/tbgn3p08.png
|
||||
c6e83019 test/3pdata/pngsuite/tbrn2c08.png
|
||||
2289ed1e test/3pdata/pngsuite/tbwn0g16.png
|
||||
46deef3b test/3pdata/pngsuite/tbwn3p08.png
|
||||
46deef3b test/3pdata/pngsuite/tbyn3p08.png
|
||||
59b23555 test/3pdata/pngsuite/tm3n3p02.png
|
||||
f2457b64 test/3pdata/pngsuite/tp0n0g08.png
|
||||
05846c5f test/3pdata/pngsuite/tp0n2c08.png
|
||||
3d7708a8 test/3pdata/pngsuite/tp0n3p08.png
|
||||
46deef3b test/3pdata/pngsuite/tp1n3p08.png
|
||||
f286cbfc test/3pdata/pngsuite/xcsn0g01.png
|
||||
9098c4d8 test/3pdata/pngsuite/z00n2c08.png
|
||||
9098c4d8 test/3pdata/pngsuite/z03n2c08.png
|
||||
9098c4d8 test/3pdata/pngsuite/z06n2c08.png
|
||||
9098c4d8 test/3pdata/pngsuite/z09n2c08.png
|
||||
@@ -89,13 +89,13 @@ golden_test g_deflate_deflate_backref_crosses_blocks_gt = {
|
||||
"backref-crosses-blocks.deflate",
|
||||
};
|
||||
|
||||
golden_test g_deflate_deflate_degenerate_huffman_unused_gt = {
|
||||
golden_test g_deflate_deflate_degenerate_huffman_gt = {
|
||||
.want_filename =
|
||||
"test/data/artificial-deflate/"
|
||||
"degenerate-huffman-unused.deflate.decompressed",
|
||||
"degenerate-huffman.deflate.decompressed",
|
||||
.src_filename =
|
||||
"test/data/artificial-deflate/"
|
||||
"degenerate-huffman-unused.deflate",
|
||||
"degenerate-huffman.deflate",
|
||||
};
|
||||
|
||||
golden_test g_deflate_deflate_distance_32768_gt = {
|
||||
@@ -213,10 +213,10 @@ test_wuffs_deflate_decode_deflate_backref_crosses_blocks() {
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_deflate_decode_deflate_degenerate_huffman_unused() {
|
||||
test_wuffs_deflate_decode_deflate_degenerate_huffman() {
|
||||
CHECK_FOCUS(__func__);
|
||||
return do_test_io_buffers(wuffs_deflate_decode,
|
||||
&g_deflate_deflate_degenerate_huffman_unused_gt,
|
||||
&g_deflate_deflate_degenerate_huffman_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
}
|
||||
|
||||
@@ -722,10 +722,10 @@ test_mimic_deflate_decode_deflate_backref_crosses_blocks() {
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_mimic_deflate_decode_deflate_degenerate_huffman_unused() {
|
||||
test_mimic_deflate_decode_deflate_degenerate_huffman() {
|
||||
CHECK_FOCUS(__func__);
|
||||
return do_test_io_buffers(mimic_deflate_decode,
|
||||
&g_deflate_deflate_degenerate_huffman_unused_gt,
|
||||
&g_deflate_deflate_degenerate_huffman_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
}
|
||||
|
||||
@@ -890,7 +890,7 @@ proc g_tests[] = {
|
||||
|
||||
test_wuffs_deflate_decode_256_bytes,
|
||||
test_wuffs_deflate_decode_deflate_backref_crosses_blocks,
|
||||
test_wuffs_deflate_decode_deflate_degenerate_huffman_unused,
|
||||
test_wuffs_deflate_decode_deflate_degenerate_huffman,
|
||||
test_wuffs_deflate_decode_deflate_distance_32768,
|
||||
test_wuffs_deflate_decode_deflate_distance_code_31,
|
||||
test_wuffs_deflate_decode_deflate_huffman_primlen_9,
|
||||
@@ -911,7 +911,7 @@ proc g_tests[] = {
|
||||
|
||||
test_mimic_deflate_decode_256_bytes,
|
||||
test_mimic_deflate_decode_deflate_backref_crosses_blocks,
|
||||
test_mimic_deflate_decode_deflate_degenerate_huffman_unused,
|
||||
test_mimic_deflate_decode_deflate_degenerate_huffman,
|
||||
test_mimic_deflate_decode_deflate_distance_32768,
|
||||
test_mimic_deflate_decode_deflate_distance_code_31,
|
||||
test_mimic_deflate_decode_deflate_huffman_primlen_9,
|
||||
|
||||
+11
-6
@@ -252,11 +252,6 @@ do_test_wuffs_gif_decode(const char* filename,
|
||||
|
||||
CHECK_STATUS("set_from_slice", wuffs_base__pixel_buffer__set_from_slice(
|
||||
&pb, &ic.pixcfg, g_pixel_slice_u8));
|
||||
|
||||
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
if (have != 1) {
|
||||
RETURN_FAIL("num_animation_loops: have %" PRIu32 ", want 1", have);
|
||||
}
|
||||
}
|
||||
|
||||
int num_iters = 0;
|
||||
@@ -422,6 +417,16 @@ do_test_wuffs_gif_decode(const char* filename,
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
uint32_t have = wuffs_gif__decoder__num_animation_loops(&dec);
|
||||
uint32_t want =
|
||||
(wuffs_gif__decoder__num_decoded_frame_configs(&dec) > 1) ? 1 : 0;
|
||||
if (have != want) {
|
||||
RETURN_FAIL("num_animation_loops: have %" PRIu32 ", want %" PRIu32, have,
|
||||
want);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1510,7 +1515,7 @@ test_wuffs_gif_decode_multiple_loop_counts() {
|
||||
// loop counts are the number of animation loops *after* the first play
|
||||
// through, and Wuffs' are the number *including* the first play through.
|
||||
|
||||
uint32_t want_num_animation_loops[4] = {1, 1, 51, 31};
|
||||
uint32_t want_num_animation_loops[4] = {0, 1, 51, 31};
|
||||
|
||||
uint32_t i = 0;
|
||||
while (true) {
|
||||
|
||||
@@ -634,6 +634,71 @@ test_wuffs_png_decode_metadata_chrm_gama_srgb() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_png_decode_metadata_exif() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = g_src_slice_u8,
|
||||
});
|
||||
CHECK_STRING(read_file(&src, "test/data/artificial-png/exif.png"));
|
||||
|
||||
wuffs_png__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_png__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
wuffs_png__decoder__set_report_metadata(&dec, WUFFS_BASE__FOURCC__EXIF, true);
|
||||
|
||||
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||
wuffs_base__io_buffer empty = wuffs_base__empty_io_buffer();
|
||||
wuffs_base__more_information minfo = wuffs_base__empty_more_information();
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_png__decoder__decode_image_config(&dec, &ic, &src);
|
||||
if (status.repr != wuffs_base__note__metadata_reported) {
|
||||
RETURN_FAIL("decode_image_config #0: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__note__metadata_reported);
|
||||
}
|
||||
|
||||
status = wuffs_png__decoder__tell_me_more(&dec, &empty, &minfo, &src);
|
||||
if (status.repr != wuffs_base__suspension__even_more_information) {
|
||||
RETURN_FAIL("tell_me_more #0: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__even_more_information);
|
||||
}
|
||||
|
||||
// "hd test/data/artificial-png/exif.png" says 0x29..0x33 holds "LoremIpsum".
|
||||
wuffs_base__range_ie_u64 have =
|
||||
wuffs_base__more_information__metadata_raw_passthrough__range(&minfo);
|
||||
wuffs_base__range_ie_u64 want = wuffs_base__make_range_ie_u64(0x29, 0x33);
|
||||
if (!wuffs_base__range_ie_u64__equals(&have, want)) {
|
||||
RETURN_FAIL("range #0: have 0x%" PRIx64 "..0x%" PRIX64 ", want 0x%" PRIx64
|
||||
"..0x%" PRIX64,
|
||||
have.min_incl, have.max_excl, want.min_incl, want.max_excl);
|
||||
} else if ((src.meta.ri == 0x29) && (src.meta.wi >= 0x33)) {
|
||||
src.meta.ri = 0x33;
|
||||
}
|
||||
|
||||
status = wuffs_png__decoder__tell_me_more(&dec, &empty, &minfo, &src);
|
||||
if (status.repr != NULL) {
|
||||
RETURN_FAIL("tell_me_more #1: have \"%s\", want \"(null)\"", status.repr);
|
||||
}
|
||||
have = wuffs_base__more_information__metadata_raw_passthrough__range(&minfo);
|
||||
if (!wuffs_base__range_ie_u64__is_empty(&have)) {
|
||||
RETURN_FAIL("tell_me_more #1: non-empty range");
|
||||
}
|
||||
|
||||
status = wuffs_png__decoder__decode_image_config(&dec, &ic, &src);
|
||||
if (status.repr != NULL) {
|
||||
RETURN_FAIL("decode_image_config #1: have \"%s\", want \"(null)\"",
|
||||
status.repr);
|
||||
} else if (wuffs_base__pixel_config__width(&ic.pixcfg) != 1) {
|
||||
RETURN_FAIL("decode_image_config #1: have %" PRIu32 ", want 1",
|
||||
wuffs_base__pixel_config__width(&ic.pixcfg));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_png_decode_metadata_iccp() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -1201,6 +1266,7 @@ proc g_tests[] = {
|
||||
test_wuffs_png_decode_frame_config,
|
||||
test_wuffs_png_decode_interface,
|
||||
test_wuffs_png_decode_metadata_chrm_gama_srgb,
|
||||
test_wuffs_png_decode_metadata_exif,
|
||||
test_wuffs_png_decode_metadata_iccp,
|
||||
test_wuffs_png_decode_metadata_kvp,
|
||||
test_wuffs_png_decode_restart_frame,
|
||||
|
||||
@@ -71,6 +71,11 @@ the first "./a.out" with "./a.out -bench". Combine these changes with the
|
||||
|
||||
// ---------------- Golden Tests
|
||||
|
||||
golden_test g_deflate_romeo_gt = {
|
||||
.want_filename = "test/data/romeo.txt",
|
||||
.src_filename = "test/data/romeo.txt.deflate",
|
||||
};
|
||||
|
||||
golden_test g_zlib_midsummer_gt = {
|
||||
.want_filename = "test/data/midsummer.txt",
|
||||
.src_filename = "test/data/midsummer.txt.zlib",
|
||||
@@ -107,6 +112,42 @@ test_wuffs_zlib_decode_interface() {
|
||||
"test/data/romeo.txt.zlib", 0, SIZE_MAX, 942, 0x0A);
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_raw_deflate_decode(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src,
|
||||
uint32_t wuffs_initialize_flags,
|
||||
uint64_t wlimit,
|
||||
uint64_t rlimit) {
|
||||
wuffs_zlib__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_zlib__decoder__initialize(&dec, sizeof dec, WUFFS_VERSION,
|
||||
wuffs_initialize_flags));
|
||||
|
||||
// This wuffs_zlib__decoder__set_quirk_enabled call is the only difference
|
||||
// between wuffs_raw_deflate_decode and wuffs_zlib_decode immediately below.
|
||||
wuffs_zlib__decoder__set_quirk_enabled(
|
||||
&dec, WUFFS_ZLIB__QUIRK_JUST_RAW_DEFLATE, true);
|
||||
|
||||
while (true) {
|
||||
wuffs_base__io_buffer limited_dst = make_limited_writer(*dst, wlimit);
|
||||
wuffs_base__io_buffer limited_src = make_limited_reader(*src, rlimit);
|
||||
|
||||
wuffs_base__status status = wuffs_zlib__decoder__transform_io(
|
||||
&dec, &limited_dst, &limited_src, g_work_slice_u8);
|
||||
|
||||
dst->meta.wi += limited_dst.meta.wi;
|
||||
src->meta.ri += limited_src.meta.ri;
|
||||
|
||||
if (((wlimit < UINT64_MAX) &&
|
||||
(status.repr == wuffs_base__suspension__short_write)) ||
|
||||
((rlimit < UINT64_MAX) &&
|
||||
(status.repr == wuffs_base__suspension__short_read))) {
|
||||
continue;
|
||||
}
|
||||
return status.repr;
|
||||
}
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_zlib_decode(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src,
|
||||
@@ -240,6 +281,13 @@ test_wuffs_zlib_decode_pi() {
|
||||
UINT64_MAX);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_zlib_decode_raw_deflate_romeo() {
|
||||
CHECK_FOCUS(__func__);
|
||||
return do_test_io_buffers(wuffs_raw_deflate_decode, &g_deflate_romeo_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_zlib_decode_sheep() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -376,6 +424,7 @@ proc g_tests[] = {
|
||||
test_wuffs_zlib_decode_interface,
|
||||
test_wuffs_zlib_decode_midsummer,
|
||||
test_wuffs_zlib_decode_pi,
|
||||
test_wuffs_zlib_decode_raw_deflate_romeo,
|
||||
test_wuffs_zlib_decode_sheep,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
@@ -422,7 +422,7 @@ test_main(int argc, char** argv, proc* tests, proc* benches) {
|
||||
"compatible with the\n"
|
||||
"# https://godoc.org/golang.org/x/perf/cmd/benchstat tool. To install "
|
||||
"it, first\n"
|
||||
"# install Go, then run \"go get golang.org/x/perf/cmd/benchstat\".\n");
|
||||
"# install Go, then run \"go install golang.org/x/perf/cmd/benchstat\".\n");
|
||||
}
|
||||
|
||||
for (int i = 0; i < reps; i++) {
|
||||
|
||||
@@ -11,6 +11,7 @@ ImageMagick's `convert` command line tool. The `*.wbmp` versions were generated
|
||||
by the `script/convert-png-to-wbmp.go` command line tool. The `*.webp` versions
|
||||
were generated by the cwebp command line tool. The `*.no-ancillary.png` files
|
||||
were generated by the `script/strip-png-ancillary-chunks.go` command line tool.
|
||||
The `*.qoi` files were generated by the qoiconv command line tool.
|
||||
|
||||
The `*.apng` files were generated by `gif2apng`. Those with finite animation
|
||||
loop counts were manually patched to correct for a `gif2apng` bug.
|
||||
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
foo
|
||||
@@ -1,27 +0,0 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
make deflate
|
||||
|
||||
blockDynamicHuffman (final) {
|
||||
huffman CodeLength {
|
||||
1 00
|
||||
2 01
|
||||
17 10
|
||||
18 11
|
||||
}
|
||||
|
||||
huffman Literal/Length {
|
||||
# 102='f', 111='o', 256=EOB
|
||||
111 0
|
||||
102 10
|
||||
256 11
|
||||
}
|
||||
|
||||
huffman Distance {
|
||||
# Incomplete. There is no key/value pair whose value starts with "1".
|
||||
0 0
|
||||
}
|
||||
|
||||
literal "foo"
|
||||
endOfBlock
|
||||
}
|
||||
Binary file not shown.
+8
-5
@@ -1,9 +1,9 @@
|
||||
Running degenerate-huffman-unused.deflate through script/print-bits.go and
|
||||
adding commentary:
|
||||
Running degenerate-huffman.deflate through script/print-bits.go and adding
|
||||
commentary:
|
||||
|
||||
offset xoffset ASCII hex binary
|
||||
000000 0x0000 . 0x05 0b_...._.101 Dynamic Huffman block, final
|
||||
000000 0x0000 . 0x05 0b_0000_0... NumLCodes: 257
|
||||
000000 0x0000 . 0x04 0b_...._.100 Dynamic Huffman block, non-final
|
||||
000000 0x0000 . 0x04 0b_0000_0... NumLCodes: 257
|
||||
000001 0x0001 . 0xC0 0b_...0_0000 NumDCodes: 1
|
||||
000001 0x0001 . 0xC0 0b_110._.... NumCLCodeLengths: 18
|
||||
000002 0x0002 ! 0x21 0b_...._...1
|
||||
@@ -63,4 +63,7 @@ Apply H-L and H-D.
|
||||
000013 0x000D . 0x89 0b_..0._.... lcode: 111 literal 'o'
|
||||
000013 0x000D . 0x89 0b_.0.._.... lcode: 111 literal 'o'
|
||||
000013 0x000D . 0x89 0b_1..._.... lcode: 256 end of block
|
||||
000014 0x000E . 0x01 0b_...._...1
|
||||
000014 0x000E . 0x1B 0b_...._...1
|
||||
|
||||
The second Dynamic Huffman block (the final one) continues after that, but this
|
||||
commentary stops here.
|
||||
@@ -0,0 +1 @@
|
||||
fooABCDABC
|
||||
@@ -0,0 +1,64 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
make deflate
|
||||
|
||||
blockDynamicHuffman (nonFinal) {
|
||||
huffman CodeLength {
|
||||
1 00
|
||||
2 01
|
||||
17 10
|
||||
18 11
|
||||
}
|
||||
|
||||
huffman Literal/Length {
|
||||
# 102='f', 111='o', 256=EOB
|
||||
111 0
|
||||
102 10
|
||||
256 11
|
||||
}
|
||||
|
||||
huffman Distance {
|
||||
# Incomplete. There is no key/value pair whose value starts with "1".
|
||||
#
|
||||
# The sole key/value pair is also unused. (The one below is used.)
|
||||
0 0
|
||||
}
|
||||
|
||||
literal "foo"
|
||||
endOfBlock
|
||||
}
|
||||
|
||||
blockDynamicHuffman (final) {
|
||||
huffman CodeLength {
|
||||
0 00
|
||||
1 01
|
||||
2 100
|
||||
3 101
|
||||
17 110
|
||||
18 111
|
||||
}
|
||||
|
||||
huffman Literal/Length {
|
||||
# 65='A', 66='B', 67='C', 68='D', 256=EOB, 257=Length3
|
||||
65 100
|
||||
66 101
|
||||
67 110
|
||||
68 111
|
||||
256 00
|
||||
257 01
|
||||
}
|
||||
|
||||
huffman Distance {
|
||||
# Incomplete. There is no key/value pair whose value starts with "1".
|
||||
#
|
||||
# The sole key/value pair is also used. (The one above is unused.)
|
||||
#
|
||||
# Per the second table in RFC 1951 section 3.2.5. "Compressed blocks
|
||||
# (length and distance codes)", code 3 means a distance of 4.
|
||||
3 0
|
||||
}
|
||||
|
||||
literal "ABCD"
|
||||
len 3 dist 4
|
||||
endOfBlock
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 93 B |
@@ -0,0 +1,32 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
make png
|
||||
|
||||
magic
|
||||
|
||||
IHDR {
|
||||
raw {
|
||||
# Width, height.
|
||||
0x00 0x00 0x00 0x01
|
||||
0x00 0x00 0x00 0x01
|
||||
# Depth, color, compression, filter, interlace.
|
||||
0x08 0x00 0x00 0x00 0x00
|
||||
}
|
||||
}
|
||||
|
||||
eXIf {
|
||||
raw {
|
||||
# "LoremIpsum" isn't valid EXIF data. It's just a placeholder.
|
||||
0x4C 0x6F 0x72 0x65 0x6D 0x49 0x70 0x73 0x75 0x6D
|
||||
}
|
||||
}
|
||||
|
||||
IDAT {
|
||||
zlib {
|
||||
# 1x1 gray pixels (with filter bytes).
|
||||
0x00 0x80
|
||||
}
|
||||
}
|
||||
|
||||
IEND {
|
||||
}
|
||||
Binary file not shown.
@@ -9,32 +9,33 @@ e651a889 test/data/animated-red-blue.000002.nie
|
||||
f9a10dac test/data/artificial-gif/background-color.gif
|
||||
36e7d9c7 test/data/artificial-gif/empty-palette.gif
|
||||
db4c30eb test/data/artificial-gif/frame-out-of-bounds.gif
|
||||
fdcc644f test/data/artificial-gif/metadata-empty.gif
|
||||
fdcc644f test/data/artificial-gif/metadata-full.gif
|
||||
6d03b5f3 test/data/artificial-gif/multiple-graphic-controls.gif
|
||||
47c877fd test/data/artificial-gif/multiple-loop-counts.gif
|
||||
76c44866 test/data/artificial-gif/no-frames.gif
|
||||
6ec818c3 test/data/artificial-gif/pixel-data-none.gif
|
||||
5e57adb2 test/data/artificial-gif/pixel-data-not-enough.gif
|
||||
3e29f88a test/data/artificial-gif/pixel-data-too-much-bad-lzw.gif
|
||||
3e29f88a test/data/artificial-gif/pixel-data-too-much-good-lzw.gif
|
||||
f50d1d50 test/data/artificial-gif/small-frame-interlaced.gif
|
||||
f2dc2c43 test/data/artificial-gif/metadata-empty.gif
|
||||
f2dc2c43 test/data/artificial-gif/metadata-full.gif
|
||||
a1a9b56d test/data/artificial-gif/multiple-graphic-controls.gif
|
||||
046a2d07 test/data/artificial-gif/multiple-loop-counts.gif
|
||||
ba6e48f8 test/data/artificial-gif/no-frames.gif
|
||||
f33b9bc1 test/data/artificial-gif/pixel-data-none.gif
|
||||
ac9d76d8 test/data/artificial-gif/pixel-data-not-enough.gif
|
||||
2342e3fc test/data/artificial-gif/pixel-data-too-much-bad-lzw.gif
|
||||
2342e3fc test/data/artificial-gif/pixel-data-too-much-good-lzw.gif
|
||||
39a71dce test/data/artificial-gif/small-frame-interlaced.gif
|
||||
beaec397 test/data/artificial-gif/transparent-index.gif
|
||||
6ec818c3 test/data/artificial-gif/zero-width-frame.gif
|
||||
f33b9bc1 test/data/artificial-gif/zero-width-frame.gif
|
||||
0564b364 test/data/artificial-png/apng-skip-idat.png
|
||||
e08a7cc8 test/data/artificial-png/exif.png
|
||||
e08a7cc8 test/data/artificial-png/key-value-pairs.png
|
||||
076cb375 test/data/bricks-color.bmp
|
||||
076cb375 test/data/bricks-color.png
|
||||
f36c2e80 test/data/bricks-dither.bmp
|
||||
3fc62e1e test/data/bricks-dither.gif
|
||||
f36c2e80 test/data/bricks-dither.gif
|
||||
f36c2e80 test/data/bricks-dither.no-ancillary.png
|
||||
f36c2e80 test/data/bricks-dither.png
|
||||
c2bce675 test/data/bricks-gray.bmp
|
||||
0e16e6eb test/data/bricks-gray.gif
|
||||
c2bce675 test/data/bricks-gray.gif
|
||||
c2bce675 test/data/bricks-gray.no-ancillary.png
|
||||
c2bce675 test/data/bricks-gray.png
|
||||
7aebfe6c test/data/bricks-nodither.bmp
|
||||
b641fef2 test/data/bricks-nodither.gif
|
||||
7aebfe6c test/data/bricks-nodither.gif
|
||||
7aebfe6c test/data/bricks-nodither.png
|
||||
ae2e547d test/data/bricks-nodither.wbmp
|
||||
b47730a2 test/data/checkerboard.gamma1dot0.png
|
||||
@@ -42,31 +43,32 @@ b47730a2 test/data/checkerboard.gamma2dot2.png
|
||||
aa3e6c7c test/data/crude-flag.nie
|
||||
3014b4c0 test/data/gifplayer-muybridge.gif
|
||||
030f5a48 test/data/harvesters.bmp
|
||||
0d213dc4 test/data/harvesters.gif
|
||||
c18b3d5a test/data/harvesters.gif
|
||||
030f5a48 test/data/harvesters.png
|
||||
e776c90f test/data/hat.bmp
|
||||
a161a63a test/data/hat.gif
|
||||
6dcba6a4 test/data/hat.gif
|
||||
e776c90f test/data/hat.png
|
||||
d30bfe5d test/data/hat.wbmp
|
||||
33a44f22 test/data/hibiscus.primitive.bmp
|
||||
e948122d test/data/hibiscus.primitive.gif
|
||||
25e212b3 test/data/hibiscus.primitive.gif
|
||||
33a44f22 test/data/hibiscus.primitive.png
|
||||
60040742 test/data/hibiscus.regular.bmp
|
||||
7b8dda15 test/data/hibiscus.regular.gif
|
||||
b727da8b test/data/hibiscus.regular.gif
|
||||
60040742 test/data/hibiscus.regular.png
|
||||
dcbb225a test/data/hippopotamus.bmp
|
||||
21e17862 test/data/hippopotamus.interlaced.gif
|
||||
ed4b78fc test/data/hippopotamus.interlaced.gif
|
||||
dcbb225a test/data/hippopotamus.interlaced.png
|
||||
a80781a1 test/data/hippopotamus.interlaced.truncated.gif
|
||||
1f11edb9 test/data/hippopotamus.masked-with-muybridge.gif
|
||||
c3c4bd65 test/data/hippopotamus.interlaced.truncated.gif
|
||||
d3bbed27 test/data/hippopotamus.masked-with-muybridge.gif
|
||||
7e6acf01 test/data/hippopotamus.masked-with-muybridge.png
|
||||
dcbb225a test/data/hippopotamus.nie
|
||||
21e17862 test/data/hippopotamus.regular.gif
|
||||
ed4b78fc test/data/hippopotamus.regular.gif
|
||||
dcbb225a test/data/hippopotamus.regular.png
|
||||
2dccfe56 test/data/muybridge-frame-000.wbmp
|
||||
db2733f5 test/data/muybridge.apng
|
||||
db2733f5 test/data/muybridge.gif
|
||||
bf7e8c96 test/data/pjw-thumbnail.bmp
|
||||
73d48c08 test/data/pjw-thumbnail.gif
|
||||
bf7e8c96 test/data/pjw-thumbnail.gif
|
||||
bf7e8c96 test/data/pjw-thumbnail.png
|
||||
38cb4cbf test/data/red-blue-gradient.dcip3d65-no-chrm-no-gama.png
|
||||
38cb4cbf test/data/red-blue-gradient.gamma1dot0.png
|
||||
|
||||
Reference in new issue
Block a user