mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec71f9c6d8 | ||
|
|
a138188d57 | ||
|
|
d910658bce | ||
|
|
00d5e35865 | ||
|
|
05f0172b93 | ||
|
|
57bd11bf39 | ||
|
|
67d9a68c49 | ||
|
|
17f7613262 | ||
|
|
baac49dca7 | ||
|
|
a12a807d0e | ||
|
|
000b0a3445 | ||
|
|
ef74175a20 | ||
|
|
02844cdca4 | ||
|
|
3db9e96b0d | ||
|
|
be37cc46c0 | ||
|
|
4d4c3c4c3c | ||
|
|
36d7748ed5 | ||
|
|
43ca567205 | ||
|
|
3474af988b | ||
|
|
248bddcfd2 | ||
|
|
3705e0d93a | ||
|
|
f01f0859f0 | ||
|
|
d7c48ae76b | ||
|
|
8ad397fc93 | ||
|
|
48e69da5af | ||
|
|
5640296546 | ||
|
|
1e03a0c84f | ||
|
|
c698d81b4d | ||
|
|
95164c7a3f | ||
|
|
255d3a0a29 | ||
|
|
e915543f09 | ||
|
|
d46220ca00 | ||
|
|
dee65c0e61 | ||
|
|
c27250f52f | ||
|
|
9445c8b9d0 |
No files matched your search
@@ -0,0 +1,12 @@
|
||||
# Source code is always LF, never CRLF.
|
||||
#
|
||||
# For example, tools like the wuffs-c compiler (and its internal/cgen package)
|
||||
# look for hard-coded strings containing "\n" but not "\r\n".
|
||||
*.c text eol=lf
|
||||
*.cc text eol=lf
|
||||
*.go text eol=lf
|
||||
*.h text eol=lf
|
||||
*.hh text eol=lf
|
||||
*.rs text eol=lf
|
||||
*.sh text eol=lf
|
||||
*.wuffs text eol=lf
|
||||
@@ -18,3 +18,4 @@ Michael Mc Donnell <michael@mcdonnell.dk>
|
||||
Mike Kaufman <mkaufman@microsoft.com>
|
||||
Muhammad Aldo Firmansyah <TheCrott@users.noreply.github.com>
|
||||
Přemysl Eric Janouch <p@janouch.name>
|
||||
sarastro-nl <nlsarastro@gmail.com>
|
||||
@@ -43,3 +43,4 @@ Muhammad Aldo Firmansyah <TheCrott@users.noreply.github.com>
|
||||
Nigel Tao <nigeltao@golang.org>
|
||||
Peter Kasting <pkasting@chromium.org>
|
||||
Přemysl Eric Janouch <p@janouch.name>
|
||||
sarastro-nl <nlsarastro@gmail.com>
|
||||
@@ -1,17 +1,21 @@
|
||||

|
||||
|
||||
Wuffs (Wrangling Untrusted File Formats Safely) is [formerly known as
|
||||
Puffs](https://groups.google.com/d/topic/puffslang/ZX-ymyf8xh0/discussion)
|
||||
(Parsing Untrusted File Formats Safely).
|
||||
|
||||
Wuffs is a **memory-safe programming language** (and a **standard library**
|
||||
written in that language) for wrangling **untrusted file formats** safely.
|
||||
written in that language) for **Wrangling Untrusted File Formats Safely**.
|
||||
Wrangling includes parsing, decoding and encoding. Example file formats include
|
||||
images, audio, video, fonts and compressed archives.
|
||||
|
||||
It is also **fast**. On many of its GIF decoding
|
||||
[benchmarks](/doc/benchmarks.md), Wuffs measures **2x faster than "giflib" (C),
|
||||
3x faster than "image/gif" (Go) and 7x faster than "gif" (Rust)**.
|
||||
It is **fast**. Per its [benchmarks](/doc/benchmarks.md) and other linked-to
|
||||
blog posts:
|
||||
|
||||
- It can decode bzip2 **[1.3x faster than `/usr/bin/bzcat`
|
||||
(C)](https://nigeltao.github.io/blog/2022/wuffs-bzip2-decoder.html)**.
|
||||
- It can decode deflate up to **1.4x faster than zlib-the-library (C)**.
|
||||
- It can decode GIF **2x-6x faster than "giflib" (C), "image/gif" (Go) and
|
||||
"gif" (Rust)**.
|
||||
- It can decode PNG **[1.2x-2.7x faster than "libpng" (C), "image/png" (Go) and
|
||||
"png"
|
||||
(Rust)](https://nigeltao.github.io/blog/2021/fastest-safest-png-decoder.html)**.
|
||||
|
||||
|
||||
## Goals and Non-Goals
|
||||
@@ -44,11 +48,21 @@ the increment would otherwise overflow. Similarly, an integer arithmetic
|
||||
expression like `x / y` is a compile time error unless the compiler can also
|
||||
prove that `y` is not zero.
|
||||
|
||||
|
||||
## Hermeticity
|
||||
|
||||
Wuffs is not a general purpose programming language. **It is for writing
|
||||
libraries, not programs**. The idea isn't to write your whole program in Wuffs,
|
||||
only the **parts that are both performance-conscious and security-conscious**.
|
||||
For example, while technically possible, it is unlikely that a Wuffs compiler
|
||||
would be worth writing entirely in Wuffs.
|
||||
libraries, not programs**. Wuffs code is [hermetic](/doc/note/hermeticity.md)
|
||||
and can only compute (e.g. convert "compressed bytes" to "decompressed bytes").
|
||||
**It cannot make any syscalls** (e.g. it has no ambient authority to read your
|
||||
files), implying that it cannot allocate or free memory (and is therefore
|
||||
trivially safe against things like memory leaks, use-after-frees and
|
||||
double-frees).
|
||||
|
||||
The idea isn't to write your whole program in Wuffs, **only the parts that are
|
||||
both performance-conscious and security-conscious**. For example, while
|
||||
technically possible, it is unlikely that a Wuffs compiler would be worth
|
||||
writing entirely in Wuffs.
|
||||
|
||||
|
||||
## What Does Wuffs Code Look Like?
|
||||
@@ -187,12 +201,16 @@ The [Note](/doc/note) directory also contains various short articles.
|
||||
|
||||
# Status
|
||||
|
||||
Version 0.2. The API and ABI aren't stabilized yet. The compiler undoubtedly
|
||||
Version 0.3. The API and ABI aren't stabilized yet. The compiler undoubtedly
|
||||
has bugs. Assertion checking needs more rigor, especially around side effects
|
||||
and aliasing, and being sufficiently well specified to allow alternative
|
||||
implementations. Lots of detail needs work, but the broad brushstrokes are
|
||||
there.
|
||||
|
||||
Nonetheless, Wuffs' GIF decoder has shipped in the Google Chrome web browser
|
||||
[since June
|
||||
2021](https://chromium-review.googlesource.com/c/chromium/src/+/2940044).
|
||||
|
||||
|
||||
# Discussion
|
||||
|
||||
@@ -223,4 +241,4 @@ owned by Google.
|
||||
|
||||
---
|
||||
|
||||
Updated on December 2019.
|
||||
Updated on January 2023.
|
||||
+2
-2
@@ -28,8 +28,8 @@ LDFLAGS=${LDFLAGS:-}
|
||||
|
||||
# The "-fdata-sections -ffunction-sections -Wl,--gc-sections" produces smaller
|
||||
# binaries. See commit 41fce8a8 "Strip examples of unused data and functions".
|
||||
CFLAGS=${CFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections}
|
||||
CXXFLAGS=${CXXFLAGS:--O3 -fdata-sections -ffunction-sections -Wl,--gc-sections}
|
||||
CFLAGS=${CFLAGS:--O3 -fdata-sections -ffunction-sections -Wall -Wl,--gc-sections}
|
||||
CXXFLAGS=${CXXFLAGS:--O3 -fdata-sections -ffunction-sections -Wall -Wl,--gc-sections}
|
||||
|
||||
mkdir -p gen/bin
|
||||
|
||||
|
||||
+107
-47
@@ -3,68 +3,128 @@
|
||||
Binary size measurements of `wuffs genlib` libraries on x86\_64 are below.
|
||||
Lower is better.
|
||||
|
||||
clang8-dynamic:
|
||||
-rwxr-xr-x 1 tao tao 90488 Oct 19 05:34 libwuffs.so
|
||||
-rw-r--r-- 1 tao tao 7096 Oct 19 05:34 wuffs-base.lo
|
||||
-rw-r--r-- 1 tao tao 2192 Oct 19 05:34 wuffs-std-adler32.lo
|
||||
-rw-r--r-- 1 tao tao 19296 Oct 19 05:34 wuffs-std-crc32.lo
|
||||
-rw-r--r-- 1 tao tao 20568 Oct 19 05:34 wuffs-std-deflate.lo
|
||||
-rw-r--r-- 1 tao tao 26720 Oct 19 05:34 wuffs-std-gif.lo
|
||||
-rw-r--r-- 1 tao tao 6592 Oct 19 05:34 wuffs-std-gzip.lo
|
||||
-rw-r--r-- 1 tao tao 5808 Oct 19 05:34 wuffs-std-lzw.lo
|
||||
-rw-r--r-- 1 tao tao 6584 Oct 19 05:34 wuffs-std-zlib.lo
|
||||
clang11-dynamic:
|
||||
-rwxr-xr-x 1 tao tao 322264 Jan 26 15:33 libwuffs.so
|
||||
-rw-r--r-- 1 tao tao 5232 Jan 26 15:32 wuffs-base-core.lo
|
||||
-rw-r--r-- 1 tao tao 26976 Jan 26 15:32 wuffs-base-floatconv.lo
|
||||
-rw-r--r-- 1 tao tao 9312 Jan 26 15:32 wuffs-base-intconv.lo
|
||||
-rw-r--r-- 1 tao tao 7920 Jan 26 15:33 wuffs-base-interfaces.lo
|
||||
-rw-r--r-- 1 tao tao 3216 Jan 26 15:33 wuffs-base-magic.lo
|
||||
-rw-r--r-- 1 tao tao 56192 Jan 26 15:33 wuffs-base-pixconv.lo
|
||||
-rw-r--r-- 1 tao tao 3080 Jan 26 15:33 wuffs-base-utf8.lo
|
||||
-rw-r--r-- 1 tao tao 4056 Jan 26 15:33 wuffs-std-adler32.lo
|
||||
-rw-r--r-- 1 tao tao 28600 Jan 26 15:33 wuffs-std-bmp.lo
|
||||
-rw-r--r-- 1 tao tao 17304 Jan 26 15:33 wuffs-std-bzip2.lo
|
||||
-rw-r--r-- 1 tao tao 10168 Jan 26 15:33 wuffs-std-cbor.lo
|
||||
-rw-r--r-- 1 tao tao 22336 Jan 26 15:33 wuffs-std-crc32.lo
|
||||
-rw-r--r-- 1 tao tao 24816 Jan 26 15:33 wuffs-std-deflate.lo
|
||||
-rw-r--r-- 1 tao tao 25088 Jan 26 15:33 wuffs-std-gif.lo
|
||||
-rw-r--r-- 1 tao tao 7408 Jan 26 15:33 wuffs-std-gzip.lo
|
||||
-rw-r--r-- 1 tao tao 20136 Jan 26 15:33 wuffs-std-json.lo
|
||||
-rw-r--r-- 1 tao tao 6344 Jan 26 15:33 wuffs-std-lzw.lo
|
||||
-rw-r--r-- 1 tao tao 9928 Jan 26 15:33 wuffs-std-nie.lo
|
||||
-rw-r--r-- 1 tao tao 54760 Jan 26 15:33 wuffs-std-png.lo
|
||||
-rw-r--r-- 1 tao tao 14552 Jan 26 15:33 wuffs-std-tga.lo
|
||||
-rw-r--r-- 1 tao tao 9080 Jan 26 15:33 wuffs-std-wbmp.lo
|
||||
-rw-r--r-- 1 tao tao 7224 Jan 26 15:33 wuffs-std-zlib.lo
|
||||
|
||||
clang8-static:
|
||||
-rw-r--r-- 1 tao tao 101560 Oct 19 05:34 libwuffs.a
|
||||
-rw-r--r-- 1 tao tao 7176 Oct 19 05:34 wuffs-base.o
|
||||
-rw-r--r-- 1 tao tao 2176 Oct 19 05:34 wuffs-std-adler32.o
|
||||
-rw-r--r-- 1 tao tao 20296 Oct 19 05:34 wuffs-std-crc32.o
|
||||
-rw-r--r-- 1 tao tao 20432 Oct 19 05:34 wuffs-std-deflate.o
|
||||
-rw-r--r-- 1 tao tao 26856 Oct 19 05:34 wuffs-std-gif.o
|
||||
-rw-r--r-- 1 tao tao 6840 Oct 19 05:34 wuffs-std-gzip.o
|
||||
-rw-r--r-- 1 tao tao 5776 Oct 19 05:34 wuffs-std-lzw.o
|
||||
-rw-r--r-- 1 tao tao 6608 Oct 19 05:34 wuffs-std-zlib.o
|
||||
clang11-static:
|
||||
-rw-r--r-- 1 tao tao 398014 Jan 26 15:32 libwuffs.a
|
||||
-rw-r--r-- 1 tao tao 5232 Jan 26 15:32 wuffs-base-core.o
|
||||
-rw-r--r-- 1 tao tao 27136 Jan 26 15:32 wuffs-base-floatconv.o
|
||||
-rw-r--r-- 1 tao tao 9912 Jan 26 15:32 wuffs-base-intconv.o
|
||||
-rw-r--r-- 1 tao tao 7856 Jan 26 15:32 wuffs-base-interfaces.o
|
||||
-rw-r--r-- 1 tao tao 3112 Jan 26 15:32 wuffs-base-magic.o
|
||||
-rw-r--r-- 1 tao tao 59000 Jan 26 15:32 wuffs-base-pixconv.o
|
||||
-rw-r--r-- 1 tao tao 3080 Jan 26 15:32 wuffs-base-utf8.o
|
||||
-rw-r--r-- 1 tao tao 4088 Jan 26 15:32 wuffs-std-adler32.o
|
||||
-rw-r--r-- 1 tao tao 29384 Jan 26 15:32 wuffs-std-bmp.o
|
||||
-rw-r--r-- 1 tao tao 16784 Jan 26 15:32 wuffs-std-bzip2.o
|
||||
-rw-r--r-- 1 tao tao 10304 Jan 26 15:32 wuffs-std-cbor.o
|
||||
-rw-r--r-- 1 tao tao 23352 Jan 26 15:32 wuffs-std-crc32.o
|
||||
-rw-r--r-- 1 tao tao 25344 Jan 26 15:32 wuffs-std-deflate.o
|
||||
-rw-r--r-- 1 tao tao 25608 Jan 26 15:32 wuffs-std-gif.o
|
||||
-rw-r--r-- 1 tao tao 7000 Jan 26 15:32 wuffs-std-gzip.o
|
||||
-rw-r--r-- 1 tao tao 21000 Jan 26 15:32 wuffs-std-json.o
|
||||
-rw-r--r-- 1 tao tao 6272 Jan 26 15:32 wuffs-std-lzw.o
|
||||
-rw-r--r-- 1 tao tao 9840 Jan 26 15:32 wuffs-std-nie.o
|
||||
-rw-r--r-- 1 tao tao 56560 Jan 26 15:32 wuffs-std-png.o
|
||||
-rw-r--r-- 1 tao tao 14720 Jan 26 15:32 wuffs-std-tga.o
|
||||
-rw-r--r-- 1 tao tao 8984 Jan 26 15:32 wuffs-std-wbmp.o
|
||||
-rw-r--r-- 1 tao tao 7064 Jan 26 15:32 wuffs-std-zlib.o
|
||||
|
||||
gcc9-dynamic:
|
||||
-rwxr-xr-x 1 tao tao 94464 Oct 19 05:34 libwuffs.so
|
||||
-rw-r--r-- 1 tao tao 9784 Oct 19 05:34 wuffs-base.lo
|
||||
-rw-r--r-- 1 tao tao 2512 Oct 19 05:34 wuffs-std-adler32.lo
|
||||
-rw-r--r-- 1 tao tao 19568 Oct 19 05:34 wuffs-std-crc32.lo
|
||||
-rw-r--r-- 1 tao tao 20752 Oct 19 05:34 wuffs-std-deflate.lo
|
||||
-rw-r--r-- 1 tao tao 27936 Oct 19 05:34 wuffs-std-gif.lo
|
||||
-rw-r--r-- 1 tao tao 7232 Oct 19 05:34 wuffs-std-gzip.lo
|
||||
-rw-r--r-- 1 tao tao 6552 Oct 19 05:34 wuffs-std-lzw.lo
|
||||
-rw-r--r-- 1 tao tao 7360 Oct 19 05:34 wuffs-std-zlib.lo
|
||||
gcc10-dynamic:
|
||||
-rwxr-xr-x 1 tao tao 388712 Jan 26 15:33 libwuffs.so
|
||||
-rw-r--r-- 1 tao tao 5632 Jan 26 15:33 wuffs-base-core.lo
|
||||
-rw-r--r-- 1 tao tao 26904 Jan 26 15:33 wuffs-base-floatconv.lo
|
||||
-rw-r--r-- 1 tao tao 8584 Jan 26 15:33 wuffs-base-intconv.lo
|
||||
-rw-r--r-- 1 tao tao 7664 Jan 26 15:33 wuffs-base-interfaces.lo
|
||||
-rw-r--r-- 1 tao tao 4448 Jan 26 15:33 wuffs-base-magic.lo
|
||||
-rw-r--r-- 1 tao tao 109488 Jan 26 15:33 wuffs-base-pixconv.lo
|
||||
-rw-r--r-- 1 tao tao 3248 Jan 26 15:33 wuffs-base-utf8.lo
|
||||
-rw-r--r-- 1 tao tao 4624 Jan 26 15:33 wuffs-std-adler32.lo
|
||||
-rw-r--r-- 1 tao tao 28984 Jan 26 15:33 wuffs-std-bmp.lo
|
||||
-rw-r--r-- 1 tao tao 18920 Jan 26 15:33 wuffs-std-bzip2.lo
|
||||
-rw-r--r-- 1 tao tao 10040 Jan 26 15:33 wuffs-std-cbor.lo
|
||||
-rw-r--r-- 1 tao tao 23056 Jan 26 15:33 wuffs-std-crc32.lo
|
||||
-rw-r--r-- 1 tao tao 24264 Jan 26 15:33 wuffs-std-deflate.lo
|
||||
-rw-r--r-- 1 tao tao 29808 Jan 26 15:33 wuffs-std-gif.lo
|
||||
-rw-r--r-- 1 tao tao 8328 Jan 26 15:33 wuffs-std-gzip.lo
|
||||
-rw-r--r-- 1 tao tao 20128 Jan 26 15:33 wuffs-std-json.lo
|
||||
-rw-r--r-- 1 tao tao 7128 Jan 26 15:33 wuffs-std-lzw.lo
|
||||
-rw-r--r-- 1 tao tao 11960 Jan 26 15:33 wuffs-std-nie.lo
|
||||
-rw-r--r-- 1 tao tao 68440 Jan 26 15:33 wuffs-std-png.lo
|
||||
-rw-r--r-- 1 tao tao 15736 Jan 26 15:33 wuffs-std-tga.lo
|
||||
-rw-r--r-- 1 tao tao 10440 Jan 26 15:33 wuffs-std-wbmp.lo
|
||||
-rw-r--r-- 1 tao tao 7744 Jan 26 15:33 wuffs-std-zlib.lo
|
||||
|
||||
gcc9-static:
|
||||
-rw-r--r-- 1 tao tao 106120 Oct 19 05:34 libwuffs.a
|
||||
-rw-r--r-- 1 tao tao 9784 Oct 19 05:34 wuffs-base.o
|
||||
-rw-r--r-- 1 tao tao 2448 Oct 19 05:34 wuffs-std-adler32.o
|
||||
-rw-r--r-- 1 tao tao 19488 Oct 19 05:34 wuffs-std-crc32.o
|
||||
-rw-r--r-- 1 tao tao 20632 Oct 19 05:34 wuffs-std-deflate.o
|
||||
-rw-r--r-- 1 tao tao 27528 Oct 19 05:34 wuffs-std-gif.o
|
||||
-rw-r--r-- 1 tao tao 7144 Oct 19 05:34 wuffs-std-gzip.o
|
||||
-rw-r--r-- 1 tao tao 6448 Oct 19 05:34 wuffs-std-lzw.o
|
||||
-rw-r--r-- 1 tao tao 7248 Oct 19 05:34 wuffs-std-zlib.o
|
||||
gcc10-static:
|
||||
-rw-r--r-- 1 tao tao 480206 Jan 26 15:33 libwuffs.a
|
||||
-rw-r--r-- 1 tao tao 5632 Jan 26 15:33 wuffs-base-core.o
|
||||
-rw-r--r-- 1 tao tao 27008 Jan 26 15:33 wuffs-base-floatconv.o
|
||||
-rw-r--r-- 1 tao tao 8768 Jan 26 15:33 wuffs-base-intconv.o
|
||||
-rw-r--r-- 1 tao tao 7560 Jan 26 15:33 wuffs-base-interfaces.o
|
||||
-rw-r--r-- 1 tao tao 4448 Jan 26 15:33 wuffs-base-magic.o
|
||||
-rw-r--r-- 1 tao tao 109408 Jan 26 15:33 wuffs-base-pixconv.o
|
||||
-rw-r--r-- 1 tao tao 3824 Jan 26 15:33 wuffs-base-utf8.o
|
||||
-rw-r--r-- 1 tao tao 4680 Jan 26 15:33 wuffs-std-adler32.o
|
||||
-rw-r--r-- 1 tao tao 29512 Jan 26 15:33 wuffs-std-bmp.o
|
||||
-rw-r--r-- 1 tao tao 19000 Jan 26 15:33 wuffs-std-bzip2.o
|
||||
-rw-r--r-- 1 tao tao 10400 Jan 26 15:33 wuffs-std-cbor.o
|
||||
-rw-r--r-- 1 tao tao 23112 Jan 26 15:33 wuffs-std-crc32.o
|
||||
-rw-r--r-- 1 tao tao 24936 Jan 26 15:33 wuffs-std-deflate.o
|
||||
-rw-r--r-- 1 tao tao 30232 Jan 26 15:33 wuffs-std-gif.o
|
||||
-rw-r--r-- 1 tao tao 8424 Jan 26 15:33 wuffs-std-gzip.o
|
||||
-rw-r--r-- 1 tao tao 21456 Jan 26 15:33 wuffs-std-json.o
|
||||
-rw-r--r-- 1 tao tao 7144 Jan 26 15:33 wuffs-std-lzw.o
|
||||
-rw-r--r-- 1 tao tao 12168 Jan 26 15:33 wuffs-std-nie.o
|
||||
-rw-r--r-- 1 tao tao 71504 Jan 26 15:33 wuffs-std-png.o
|
||||
-rw-r--r-- 1 tao tao 16184 Jan 26 15:33 wuffs-std-tga.o
|
||||
-rw-r--r-- 1 tao tao 10520 Jan 26 15:33 wuffs-std-wbmp.o
|
||||
-rw-r--r-- 1 tao tao 7904 Jan 26 15:33 wuffs-std-zlib.o
|
||||
|
||||
|
||||
## Comparison
|
||||
|
||||
Below are some standard C libraries shipped as part of Debian Testing as of
|
||||
October 2019. The numbers aren't directly comparable, as these libraries have a
|
||||
Below are some standard C libraries shipped as part of Debian 11 Bullseye as of
|
||||
January 2023. The numbers aren't directly comparable, as these libraries have a
|
||||
richer API, especially in providing an encoder and not just a decoder. Still,
|
||||
it is a reference point for e.g. Wuffs (adler32 + crc32 + deflate + gzip +
|
||||
zlib) vs libz and Wuffs (gif + lzw) vs libgif.
|
||||
|
||||
dynamic:
|
||||
-rw-r--r-- 1 root root 113088 Aug 6 16:44 /lib/x86_64-linux-gnu/libz.so.1.2.11
|
||||
-rw-r--r-- 1 root root 34656 Jun 5 2018 /usr/lib/x86_64-linux-gnu/libgif.so.7.0.0
|
||||
-rw-r--r-- 1 root root 74688 Jul 20 2020 /lib/x86_64-linux-gnu/libbz2.so.1.0.4
|
||||
-rw-r--r-- 1 root root 38752 Dec 21 2020 /lib/x86_64-linux-gnu/libgif.so.7.1.0
|
||||
-rw-r--r-- 1 root root 231344 Sep 16 2020 /lib/x86_64-linux-gnu/libpng16.so.16.37.0
|
||||
-rw-r--r-- 1 root root 113088 Aug 24 04:54 /lib/x86_64-linux-gnu/libz.so.1.2.11
|
||||
|
||||
static:
|
||||
-rw-r--r-- 1 root root 50800 Jun 5 2018 /usr/lib/x86_64-linux-gnu/libgif.a
|
||||
-rw-r--r-- 1 root root 143250 Aug 6 16:44 /usr/lib/x86_64-linux-gnu/libz.a
|
||||
-rw-r--r-- 1 root root 80690 Jul 20 2020 /lib/x86_64-linux-gnu/libbz2.a
|
||||
-rw-r--r-- 1 root root 51940 Dec 21 2020 /lib/x86_64-linux-gnu/libgif.a
|
||||
-rw-r--r-- 1 root root 374338 Sep 16 2020 /lib/x86_64-linux-gnu/libpng16.a
|
||||
-rw-r--r-- 1 root root 144866 Aug 24 04:54 /lib/x86_64-linux-gnu/libz.a
|
||||
|
||||
|
||||
---
|
||||
|
||||
Updated on October 2019.
|
||||
Updated on January 2023.
|
||||
+39
-3
@@ -1,7 +1,43 @@
|
||||
# Changelog
|
||||
|
||||
|
||||
## Work In Progress
|
||||
## 2024-04-19 version 0.3.4
|
||||
|
||||
- Have `std/png` ignore tRNS chunks for color types 4 (YA) and 6 (RGBA).
|
||||
|
||||
|
||||
## 2023-04-08 version 0.3.3
|
||||
|
||||
The `wuffs_base__parse_number_f64` function has been further optimized.
|
||||
|
||||
|
||||
## 2023-04-07 version 0.3.2
|
||||
|
||||
The `std/bmp` and `std/nie` image decoders' `decode_frame` method now allow
|
||||
decoding to a pixel buffer that's smaller than the source image. This makes
|
||||
these two image decoders consistent with the other ones in `std`.
|
||||
|
||||
|
||||
## 2023-03-04 version 0.3.1
|
||||
|
||||
For a *closed* `io_reader`, the standard library now returns `"#truncated
|
||||
input"` instead of `"$short read"`. Importantly, this is an error, not a
|
||||
suspension.
|
||||
|
||||
The `wuffs_base__parse_number_f64` function's Simple Decimal Conversion
|
||||
fallback algorithm has been optimized.
|
||||
|
||||
|
||||
## 2023-01-26 version 0.3.0
|
||||
|
||||
The headline feature is that we have a production quality PNG decoder. It's
|
||||
also [the fastest, safest PNG decoder in the
|
||||
world](https://nigeltao.github.io/blog/2021/fastest-safest-png-decoder.html).
|
||||
There's also a [memory-safe, zero-allocation JSON
|
||||
decoder](https://nigeltao.github.io/blog/2020/jsonptr.html).
|
||||
|
||||
The dot points below probably aren't of interest unless you're upgrading from
|
||||
Wuffs version 0.2.
|
||||
|
||||
- Added `0b` prefixed binary numbers.
|
||||
- Added `WUFFS_BASE__PIXEL_BLEND__SRC_OVER`.
|
||||
@@ -14,6 +50,7 @@
|
||||
- Added `cpu_arch`.
|
||||
- Added `doc/logo`.
|
||||
- Added `endwhile` syntax.
|
||||
- Added `example/bzcat`.
|
||||
- Added `example/cbor-to-json`.
|
||||
- Added `example/convert-to-nia`.
|
||||
- Added `example/imageviewer`.
|
||||
@@ -37,7 +74,6 @@
|
||||
- Added double-curly blocks.
|
||||
- Added interfaces.
|
||||
- Added iterate advance parameter.
|
||||
- Added preprocessor.
|
||||
- Added single-quoted strings.
|
||||
- Added slice `uintptr_low_12_bits` method.
|
||||
- Added tokens.
|
||||
@@ -156,4 +192,4 @@ Wuffs version 0.1.
|
||||
|
||||
---
|
||||
|
||||
Updated on January 2020.
|
||||
Updated on April 2023.
|
||||
@@ -78,7 +78,7 @@ for a C compiler $CC, such as clang or gcc.
|
||||
#endif
|
||||
|
||||
#define WORK_BUFFER_ARRAY_SIZE \
|
||||
WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
WUFFS_BZIP2__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE
|
||||
|
||||
uint8_t g_dst_buffer_array[DST_BUFFER_ARRAY_SIZE];
|
||||
uint8_t g_src_buffer_array[SRC_BUFFER_ARRAY_SIZE];
|
||||
|
||||
@@ -385,10 +385,8 @@ flush_dst() {
|
||||
if (n == 0) {
|
||||
break;
|
||||
}
|
||||
ssize_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout);
|
||||
if (i >= 0) {
|
||||
g_dst.meta.ri += i;
|
||||
}
|
||||
size_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout);
|
||||
g_dst.meta.ri += i;
|
||||
if (i < n) {
|
||||
return "main: error writing to stdout";
|
||||
}
|
||||
@@ -788,6 +786,10 @@ compute_exit_code(std::string status_msg) {
|
||||
// (other non-zero exit codes). Specifically, exit code 2 for internal
|
||||
// invariant violation, exit code 139 (which is 128 + SIGSEGV on x86_64
|
||||
// linux) for a segmentation fault (e.g. null pointer dereference).
|
||||
size_t i = status_msg.find('=');
|
||||
if (i != std::string::npos) {
|
||||
status_msg = status_msg.substr(0, i);
|
||||
}
|
||||
return (status_msg.find("internal error:") != std::string::npos) ? 2 : 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,10 +215,8 @@ flush_dst() {
|
||||
if (n == 0) {
|
||||
break;
|
||||
}
|
||||
ssize_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout);
|
||||
if (i >= 0) {
|
||||
g_dst.meta.ri += i;
|
||||
}
|
||||
size_t i = fwrite(g_dst.reader_pointer(), 1, n, stdout);
|
||||
g_dst.meta.ri += i;
|
||||
if (i < n) {
|
||||
return "main: error writing to stdout";
|
||||
}
|
||||
@@ -383,6 +381,10 @@ compute_exit_code(std::string status_msg) {
|
||||
// (other non-zero exit codes). Specifically, exit code 2 for internal
|
||||
// invariant violation, exit code 139 (which is 128 + SIGSEGV on x86_64
|
||||
// linux) for a segmentation fault (e.g. null pointer dereference).
|
||||
size_t i = status_msg.find('=');
|
||||
if (i != std::string::npos) {
|
||||
status_msg = status_msg.substr(0, i);
|
||||
}
|
||||
return (status_msg.find("internal error:") != std::string::npos) ? 2 : 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ class Callbacks : public wuffs_aux::DecodeJsonCallbacks {
|
||||
top.has_map_key = false;
|
||||
auto iter = jmap.find(top.map_key);
|
||||
if (iter != jmap.end()) {
|
||||
return "main: duplicate key: " + top.map_key;
|
||||
return "main: duplicate key: key=" + top.map_key;
|
||||
}
|
||||
jmap.insert(iter, JsonMap::value_type(std::move(top.map_key),
|
||||
std::move(jvalue)));
|
||||
@@ -593,6 +593,10 @@ compute_exit_code(std::string status_msg) {
|
||||
// (other non-zero exit codes). Specifically, exit code 2 for internal
|
||||
// invariant violation, exit code 139 (which is 128 + SIGSEGV on x86_64
|
||||
// linux) for a segmentation fault (e.g. null pointer dereference).
|
||||
size_t i = status_msg.find('=');
|
||||
if (i != std::string::npos) {
|
||||
status_msg = status_msg.substr(0, i);
|
||||
}
|
||||
return (status_msg.find("internal error:") != std::string::npos) ? 2 : 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,30 @@ intentional_segfault() {
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
static uint32_t //
|
||||
popcount32(uint32_t x) {
|
||||
static const uint8_t table[256] = {
|
||||
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, //
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
|
||||
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
|
||||
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
|
||||
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
|
||||
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, //
|
||||
};
|
||||
return table[0xFF & (x >> 0)] + table[0xFF & (x >> 8)] +
|
||||
table[0xFF & (x >> 16)] + table[0xFF & (x >> 24)];
|
||||
}
|
||||
|
||||
// jenkins_hash_u32 implements
|
||||
// https://en.wikipedia.org/wiki/Jenkins_hash_function
|
||||
static uint32_t //
|
||||
@@ -68,15 +92,21 @@ llvmFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
uint32_t hash1 = jenkins_hash_u32(data + s2, size - s2);
|
||||
uint64_t hash = (((uint64_t)hash0) << 32) | ((uint64_t)hash1);
|
||||
|
||||
// The ! means that closed will be true for (size == 0).
|
||||
const bool closed = !(1 & popcount32(hash0));
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader((uint8_t*)data, size, true);
|
||||
wuffs_base__ptr_u8__reader((uint8_t*)data, size, closed);
|
||||
|
||||
const char* msg = fuzz(&src, hash);
|
||||
if (msg) {
|
||||
if (strnlen(msg, 2047) >= 2047) {
|
||||
msg = "fuzzlib: internal error: error message is too long";
|
||||
}
|
||||
if (strstr(msg, "internal error:")) {
|
||||
if (closed && strstr(msg, "base: short read")) {
|
||||
fprintf(stderr, "short read on a closed io_reader\n");
|
||||
intentional_segfault();
|
||||
} else if (strstr(msg, "internal error:")) {
|
||||
fprintf(stderr, "internal errors shouldn't occur: \"%s\"\n", msg);
|
||||
intentional_segfault();
|
||||
}
|
||||
|
||||
@@ -317,6 +317,9 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
|
||||
no_progress_count = 0;
|
||||
} else if (no_progress_count < 999) {
|
||||
no_progress_count++;
|
||||
} else if (!full_src->meta.closed &&
|
||||
(status.repr == wuffs_base__suspension__short_read)) {
|
||||
return wuffs_base__status__message(&status);
|
||||
} else {
|
||||
return "fuzz: internal error: no progress";
|
||||
}
|
||||
@@ -345,8 +348,6 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
|
||||
break;
|
||||
|
||||
} else if (status.repr == wuffs_base__suspension__short_read) {
|
||||
// Some Wuffs packages can yield "$short read" for a closed io_reader,
|
||||
// but Wuffs' cbor package does not.
|
||||
if (src.meta.closed) {
|
||||
return "fuzz: internal error: short read on a closed io_reader";
|
||||
}
|
||||
|
||||
@@ -338,6 +338,9 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
|
||||
no_progress_count = 0;
|
||||
} else if (no_progress_count < 999) {
|
||||
no_progress_count++;
|
||||
} else if (!full_src->meta.closed &&
|
||||
(status.repr == wuffs_base__suspension__short_read)) {
|
||||
return wuffs_base__status__message(&status);
|
||||
} else {
|
||||
return "fuzz: internal error: no progress";
|
||||
}
|
||||
@@ -366,8 +369,6 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
|
||||
break;
|
||||
|
||||
} else if (status.repr == wuffs_base__suspension__short_read) {
|
||||
// Some Wuffs packages can yield "$short read" for a closed io_reader,
|
||||
// but Wuffs' json package does not.
|
||||
if (src.meta.closed) {
|
||||
return "fuzz: internal error: short read on a closed io_reader";
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ go 1.16
|
||||
|
||||
require (
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
|
||||
golang.org/x/image v0.5.0 // indirect
|
||||
)
|
||||
@@ -1,6 +1,31 @@
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
|
||||
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
|
||||
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
|
||||
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@@ -1264,6 +1264,27 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
// powers converts decimal powers of 10 to binary powers of 2. For example,
|
||||
// (10000 >> 13) is 1. It stops before the elements exceed 60, also known
|
||||
// as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
|
||||
//
|
||||
// This rounds down (1<<13 is a lower bound for 1e4). Adding 1 to the array
|
||||
// element value rounds up (1<<14 is an upper bound for 1e4) while staying
|
||||
// at or below WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
|
||||
//
|
||||
// When starting in the range [1e+1 .. 1e+2] (i.e. h->decimal_point == +2),
|
||||
// powers[2] == 6 and so:
|
||||
// - Right shifting by 6+0 produces the range [10/64 .. 100/64] =
|
||||
// [0.156250 .. 1.56250]. The resultant h->decimal_point is +0 or +1.
|
||||
// - Right shifting by 6+1 produces the range [10/128 .. 100/128] =
|
||||
// [0.078125 .. 0.78125]. The resultant h->decimal_point is -1 or -0.
|
||||
//
|
||||
// When starting in the range [1e-3 .. 1e-2] (i.e. h->decimal_point == -2),
|
||||
// powers[2] == 6 and so:
|
||||
// - Left shifting by 6+0 produces the range [0.001*64 .. 0.01*64] =
|
||||
// [0.064 .. 0.64]. The resultant h->decimal_point is -1 or -0.
|
||||
// - Left shifting by 6+1 produces the range [0.001*128 .. 0.01*128] =
|
||||
// [0.128 .. 1.28]. The resultant h->decimal_point is +0 or +1.
|
||||
//
|
||||
// Thus, when targeting h->decimal_point being +0 or +1, use (powers[n]+0)
|
||||
// when right shifting but (powers[n]+1) when left shifting.
|
||||
static const uint32_t num_powers = 19;
|
||||
static const uint8_t powers[19] = {
|
||||
0, 3, 6, 9, 13, 16, 19, 23, 26, 29, //
|
||||
@@ -1283,36 +1304,54 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
// approach taken in wuffs_base__parse_number_f64. The latter is optimized
|
||||
// for the common cases (e.g. assuming no underscores or a leading '+'
|
||||
// sign) rather than the full set of cases allowed by the Wuffs API.
|
||||
if (h->num_digits <= 19) {
|
||||
//
|
||||
// When we have 19 or fewer mantissa digits, run Eisel-Lemire once (trying
|
||||
// for an exact result). When we have more than 19 mantissa digits, run it
|
||||
// twice to get a lower and upper bound. We still have an exact result
|
||||
// (within f64's rounding margin) if both bounds are equal (and valid).
|
||||
uint32_t i_max = h->num_digits;
|
||||
if (i_max > 19) {
|
||||
i_max = 19;
|
||||
}
|
||||
int32_t exp10 = h->decimal_point - ((int32_t)i_max);
|
||||
if ((-307 <= exp10) && (exp10 <= 288)) {
|
||||
uint64_t man = 0;
|
||||
uint32_t i;
|
||||
for (i = 0; i < h->num_digits; i++) {
|
||||
for (i = 0; i < i_max; i++) {
|
||||
man = (10 * man) + h->digits[i];
|
||||
}
|
||||
int32_t exp10 = h->decimal_point - ((int32_t)(h->num_digits));
|
||||
if ((man != 0) && (-307 <= exp10) && (exp10 <= 288)) {
|
||||
int64_t r =
|
||||
while (man != 0) { // The 'while' is just an 'if' that we can 'break'.
|
||||
int64_t r0 =
|
||||
wuffs_base__private_implementation__parse_number_f64_eisel_lemire(
|
||||
man, exp10);
|
||||
if (r >= 0) {
|
||||
wuffs_base__result_f64 ret;
|
||||
ret.status.repr = NULL;
|
||||
ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(
|
||||
((uint64_t)r) | (((uint64_t)(h->negative)) << 63));
|
||||
return ret;
|
||||
man + 0, exp10);
|
||||
if (r0 < 0) {
|
||||
break;
|
||||
} else if (h->num_digits > 19) {
|
||||
int64_t r1 =
|
||||
wuffs_base__private_implementation__parse_number_f64_eisel_lemire(
|
||||
man + 1, exp10);
|
||||
if (r1 != r0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
wuffs_base__result_f64 ret;
|
||||
ret.status.repr = NULL;
|
||||
ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(
|
||||
((uint64_t)r0) | (((uint64_t)(h->negative)) << 63));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See
|
||||
// https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
|
||||
//
|
||||
// Scale by powers of 2 until we're in the range [½ .. 1], which gives us
|
||||
// our exponent (in base-2). First we shift right, possibly a little too
|
||||
// far, ending with a value certainly below 1 and possibly below ½...
|
||||
// Scale by powers of 2 until we're in the range [0.1 .. 10]. Equivalently,
|
||||
// that h->decimal_point is +0 or +1.
|
||||
//
|
||||
// First we shift right while at or above 10...
|
||||
const int32_t f64_bias = -1023;
|
||||
int32_t exp2 = 0;
|
||||
while (h->decimal_point > 0) {
|
||||
while (h->decimal_point > 1) {
|
||||
uint32_t n = (uint32_t)(+h->decimal_point);
|
||||
uint32_t shift =
|
||||
(n < num_powers)
|
||||
@@ -1326,20 +1365,15 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
}
|
||||
exp2 += (int32_t)shift;
|
||||
}
|
||||
// ...then we shift left, putting us in [½ .. 1].
|
||||
while (h->decimal_point <= 0) {
|
||||
// ...then we shift left while below 0.1.
|
||||
while (h->decimal_point < 0) {
|
||||
uint32_t shift;
|
||||
if (h->decimal_point == 0) {
|
||||
if (h->digits[0] >= 5) {
|
||||
break;
|
||||
}
|
||||
shift = (h->digits[0] < 2) ? 2 : 1;
|
||||
} else {
|
||||
uint32_t n = (uint32_t)(-h->decimal_point);
|
||||
shift = (n < num_powers)
|
||||
? powers[n]
|
||||
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
|
||||
}
|
||||
uint32_t n = (uint32_t)(-h->decimal_point);
|
||||
shift = (n < num_powers)
|
||||
// The +1 is per "when targeting h->decimal_point being +0 or
|
||||
// +1... when left shifting" in the powers comment above.
|
||||
? (powers[n] + 1)
|
||||
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
|
||||
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift);
|
||||
if (h->decimal_point >
|
||||
@@ -1349,8 +1383,37 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
exp2 -= (int32_t)shift;
|
||||
}
|
||||
|
||||
// We're in the range [½ .. 1] but f64 uses [1 .. 2].
|
||||
exp2--;
|
||||
// To get from "in the range [0.1 .. 10]" to "in the range [1 .. 2]" (which
|
||||
// will give us our exponent in base-2), the mantissa's first 3 digits will
|
||||
// determine the final left shift, equal to 52 (the number of explicit f64
|
||||
// bits) plus an additional adjustment.
|
||||
int man3 = (100 * h->digits[0]) +
|
||||
((h->num_digits > 1) ? (10 * h->digits[1]) : 0) +
|
||||
((h->num_digits > 2) ? h->digits[2] : 0);
|
||||
int32_t additional_lshift = 0;
|
||||
if (h->decimal_point == 0) { // The value is in [0.1 .. 1].
|
||||
if (man3 < 125) {
|
||||
additional_lshift = +4;
|
||||
} else if (man3 < 250) {
|
||||
additional_lshift = +3;
|
||||
} else if (man3 < 500) {
|
||||
additional_lshift = +2;
|
||||
} else {
|
||||
additional_lshift = +1;
|
||||
}
|
||||
} else { // The value is in [1 .. 10].
|
||||
if (man3 < 200) {
|
||||
additional_lshift = -0;
|
||||
} else if (man3 < 400) {
|
||||
additional_lshift = -1;
|
||||
} else if (man3 < 800) {
|
||||
additional_lshift = -2;
|
||||
} else {
|
||||
additional_lshift = -3;
|
||||
}
|
||||
}
|
||||
exp2 -= additional_lshift;
|
||||
uint32_t final_lshift = (uint32_t)(52 + additional_lshift);
|
||||
|
||||
// The minimum normal exponent is (f64_bias + 1).
|
||||
while ((f64_bias + 1) > exp2) {
|
||||
@@ -1368,7 +1431,8 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
}
|
||||
|
||||
// Extract 53 bits for the mantissa (in base-2).
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, 53);
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(
|
||||
h, final_lshift);
|
||||
uint64_t man2 =
|
||||
wuffs_base__private_implementation__high_prec_dec__rounded_integer(h);
|
||||
|
||||
|
||||
+16
-10
@@ -76,15 +76,16 @@ const (
|
||||
//
|
||||
// At the start of a function, these pointers are initialized from an
|
||||
// io_buffer's fields (ptr, ri, wi, len). For an io_reader:
|
||||
// - io0_etc = ptr
|
||||
// - io1_etc = ptr + ri
|
||||
// - iop_etc = ptr + ri
|
||||
// - io2_etc = ptr + wi
|
||||
// - io0_etc = ptr
|
||||
// - io1_etc = ptr + ri
|
||||
// - iop_etc = ptr + ri
|
||||
// - io2_etc = ptr + wi
|
||||
//
|
||||
// and for an io_writer:
|
||||
// - io0_etc = ptr
|
||||
// - io1_etc = ptr + wi
|
||||
// - iop_etc = ptr + wi
|
||||
// - io2_etc = ptr + len
|
||||
// - io0_etc = ptr
|
||||
// - io1_etc = ptr + wi
|
||||
// - iop_etc = ptr + wi
|
||||
// - io2_etc = ptr + len
|
||||
const (
|
||||
io0Prefix = "io0_" // Base.
|
||||
io1Prefix = "io1_" // Lower bound.
|
||||
@@ -674,6 +675,7 @@ func (g *gen) genIncludes(b *buffer) error {
|
||||
b.writes("#if defined(WUFFS_IMPLEMENTATION) && !defined(WUFFS_CONFIG__MODULES)\n")
|
||||
b.writes("#define WUFFS_CONFIG__MODULES\n")
|
||||
b.printf("#define WUFFS_CONFIG__MODULE__%s\n", g.PKGNAME)
|
||||
b.writes("#define WUFFS_NONMONOLITHIC\n")
|
||||
b.writes("#endif\n\n")
|
||||
|
||||
usesList := []string(nil)
|
||||
@@ -709,7 +711,10 @@ func (g *gen) genIncludes(b *buffer) error {
|
||||
}
|
||||
|
||||
func (g *gen) genHeader(b *buffer) error {
|
||||
b.writes("\n")
|
||||
module := "!defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__" + g.PKGNAME +
|
||||
") || defined(WUFFS_NONMONOLITHIC)"
|
||||
b.printf("#if %s\n\n", module)
|
||||
|
||||
b.writes("// ---------------- Status Codes\n\n")
|
||||
|
||||
wroteStatus := false
|
||||
@@ -813,6 +818,7 @@ func (g *gen) genHeader(b *buffer) error {
|
||||
}
|
||||
b.writes("#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)\n\n")
|
||||
|
||||
b.printf("#endif // %s\n", module)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -872,7 +878,7 @@ func (g *gen) genImpl(b *buffer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
b.printf("#endif // %s\n\n", module)
|
||||
b.printf("#endif // %s\n", module)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -305,9 +305,9 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
|
||||
if e.Operator() != 0 {
|
||||
prefix = aPrefix
|
||||
}
|
||||
cTyp, end, qualifier := "reader", "meta.wi", "const "
|
||||
cTyp, end, qualifier, isWriter := "reader", "meta.wi", "const ", false
|
||||
if e.MType().QID()[1] == t.IDIOWriter {
|
||||
cTyp, end, qualifier = "writer", "data.len", ""
|
||||
cTyp, end, qualifier, isWriter = "writer", "data.len", "", true
|
||||
}
|
||||
name := e.Ident().Str(g.tm)
|
||||
|
||||
@@ -350,6 +350,10 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
|
||||
b.writes(");\n")
|
||||
|
||||
} else {
|
||||
if !isWriter {
|
||||
b.printf("const bool %s%d_closed_%s%s = %s%s->meta.closed;\n",
|
||||
oPrefix, ioBindNum, prefix, name, prefix, name)
|
||||
}
|
||||
b.printf("%suint8_t *%s%d_%s%s%s = %s%s%s;\n",
|
||||
qualifier, oPrefix, ioBindNum, io2Prefix, prefix, name, io2Prefix, prefix, name)
|
||||
b.printf("wuffs_base__io_%s__limit(&%s%s%s, %s%s%s,\n",
|
||||
@@ -360,11 +364,16 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
|
||||
return err
|
||||
}
|
||||
b.writes(");\n")
|
||||
b.printf("if (%s%s) {\n%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n}\n",
|
||||
prefix, name,
|
||||
prefix, name, end,
|
||||
io2Prefix, prefix, name,
|
||||
prefix, name)
|
||||
b.printf("if (%s%s) {\n", prefix, name)
|
||||
b.printf("size_t n = ((size_t)(%s%s%s - %s%s->data.ptr));\n",
|
||||
io2Prefix, prefix, name, prefix, name)
|
||||
if !isWriter {
|
||||
b.printf("%s%s->meta.closed = %s%s->meta.closed && (%s%s->%s <= n);\n",
|
||||
prefix, name, prefix, name, prefix, name, end)
|
||||
}
|
||||
b.printf("%s%s->%s = n;\n",
|
||||
prefix, name, end)
|
||||
b.printf("}\n")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,11 +402,14 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
|
||||
io2Prefix, prefix, name,
|
||||
oPrefix, ioBindNum, io2Prefix, prefix, name)
|
||||
if n.Keyword() == t.IDIOLimit {
|
||||
b.printf("if (%s%s) {\n%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n}\n",
|
||||
prefix, name,
|
||||
b.printf("if (%s%s) {\n", prefix, name)
|
||||
b.printf("%s%s->meta.closed = %s%d_closed_%s%s;\n",
|
||||
prefix, name, oPrefix, ioBindNum, prefix, name)
|
||||
b.printf("%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n",
|
||||
prefix, name, end,
|
||||
io2Prefix, prefix, name,
|
||||
prefix, name)
|
||||
b.printf("}\n")
|
||||
}
|
||||
}
|
||||
b.writes("}\n")
|
||||
|
||||
@@ -50,6 +50,9 @@ func (g *gen) needDerivedVar(name t.ID) bool {
|
||||
return nil
|
||||
}
|
||||
if recv.IsArgsDotFoo() == name {
|
||||
if meth == t.IDIsClosed {
|
||||
return nil
|
||||
}
|
||||
return errNeedDerivedVar
|
||||
}
|
||||
// Some built-in methods will also need a derived var for their
|
||||
|
||||
+2044
-497
@@ -6344,6 +6344,8 @@ struct wuffs_base__token_decoder__struct {
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ADLER32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -6526,10 +6528,15 @@ struct wuffs_adler32__hasher__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ADLER32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_bmp__error__bad_header[];
|
||||
extern const char wuffs_bmp__error__bad_rle_compression[];
|
||||
extern const char wuffs_bmp__error__truncated_input[];
|
||||
extern const char wuffs_bmp__error__unsupported_bmp_file[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -6708,8 +6715,12 @@ struct wuffs_bmp__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
uint32_t p_tell_me_more[1];
|
||||
uint32_t p_read_palette[1];
|
||||
} private_impl;
|
||||
|
||||
@@ -6719,10 +6730,10 @@ struct wuffs_bmp__decoder__struct {
|
||||
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint64_t scratch;
|
||||
@@ -6874,6 +6885,10 @@ struct wuffs_bmp__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BZIP2) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_bzip2__error__bad_huffman_code_over_subscribed[];
|
||||
@@ -6883,6 +6898,7 @@ extern const char wuffs_bzip2__error__bad_block_length[];
|
||||
extern const char wuffs_bzip2__error__bad_checksum[];
|
||||
extern const char wuffs_bzip2__error__bad_header[];
|
||||
extern const char wuffs_bzip2__error__bad_number_of_sections[];
|
||||
extern const char wuffs_bzip2__error__truncated_input[];
|
||||
extern const char wuffs_bzip2__error__unsupported_block_randomization[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -7008,6 +7024,7 @@ struct wuffs_bzip2__decoder__struct {
|
||||
uint32_t f_code_lengths_bitmask;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
uint32_t p_prepare_block[1];
|
||||
uint32_t p_read_code_lengths[1];
|
||||
uint32_t p_flush_slow[1];
|
||||
@@ -7028,7 +7045,7 @@ struct wuffs_bzip2__decoder__struct {
|
||||
uint32_t v_i;
|
||||
uint64_t v_tag;
|
||||
uint32_t v_final_checksum_want;
|
||||
} s_transform_io[1];
|
||||
} s_do_transform_io[1];
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint32_t v_selector;
|
||||
@@ -7138,6 +7155,10 @@ struct wuffs_bzip2__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BZIP2) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CBOR) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_cbor__error__bad_input[];
|
||||
@@ -7363,6 +7384,10 @@ struct wuffs_cbor__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CBOR) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CRC32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -7544,6 +7569,10 @@ struct wuffs_crc32__ieee_hasher__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CRC32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__DEFLATE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_deflate__error__bad_huffman_code_over_subscribed[];
|
||||
@@ -7559,6 +7588,7 @@ extern const char wuffs_deflate__error__bad_literal_length_code_count[];
|
||||
extern const char wuffs_deflate__error__inconsistent_stored_block_length[];
|
||||
extern const char wuffs_deflate__error__missing_end_of_block_code[];
|
||||
extern const char wuffs_deflate__error__no_huffman_codes[];
|
||||
extern const char wuffs_deflate__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -7673,6 +7703,7 @@ struct wuffs_deflate__decoder__struct {
|
||||
bool f_end_of_block;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
uint32_t p_decode_blocks[1];
|
||||
uint32_t p_decode_uncompressed[1];
|
||||
uint32_t p_init_dynamic_huffman[1];
|
||||
@@ -7814,9 +7845,14 @@ struct wuffs_deflate__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__DEFLATE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__LZW) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_lzw__error__bad_code[];
|
||||
extern const char wuffs_lzw__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -8049,6 +8085,10 @@ struct wuffs_lzw__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__LZW) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GIF) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_gif__error__bad_extension_label[];
|
||||
@@ -8057,6 +8097,7 @@ extern const char wuffs_gif__error__bad_graphic_control[];
|
||||
extern const char wuffs_gif__error__bad_header[];
|
||||
extern const char wuffs_gif__error__bad_literal_width[];
|
||||
extern const char wuffs_gif__error__bad_palette[];
|
||||
extern const char wuffs_gif__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -8257,10 +8298,14 @@ struct wuffs_gif__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_tell_me_more[1];
|
||||
uint32_t p_do_tell_me_more[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_skip_frame[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
uint32_t p_decode_up_to_id_part1[1];
|
||||
uint32_t p_decode_header[1];
|
||||
uint32_t p_decode_lsd[1];
|
||||
@@ -8281,7 +8326,7 @@ struct wuffs_gif__decoder__struct {
|
||||
|
||||
struct {
|
||||
uint32_t v_background_color;
|
||||
} s_decode_frame_config[1];
|
||||
} s_do_decode_frame_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_skip_frame[1];
|
||||
@@ -8471,12 +8516,17 @@ struct wuffs_gif__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GIF) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GZIP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_gzip__error__bad_checksum[];
|
||||
extern const char wuffs_gzip__error__bad_compression_method[];
|
||||
extern const char wuffs_gzip__error__bad_encoding_flags[];
|
||||
extern const char wuffs_gzip__error__bad_header[];
|
||||
extern const char wuffs_gzip__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -8581,6 +8631,7 @@ struct wuffs_gzip__decoder__struct {
|
||||
bool f_ignore_checksum;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
@@ -8593,7 +8644,7 @@ struct wuffs_gzip__decoder__struct {
|
||||
uint32_t v_decoded_length_got;
|
||||
uint32_t v_checksum_want;
|
||||
uint64_t scratch;
|
||||
} s_transform_io[1];
|
||||
} s_do_transform_io[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -8683,6 +8734,10 @@ struct wuffs_gzip__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GZIP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JSON) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_json__error__bad_c0_control_code[];
|
||||
@@ -8951,9 +9006,14 @@ struct wuffs_json__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JSON) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NIE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_nie__error__bad_header[];
|
||||
extern const char wuffs_nie__error__truncated_input[];
|
||||
extern const char wuffs_nie__error__unsupported_nie_file[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -9114,14 +9174,17 @@ struct wuffs_nie__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -9269,6 +9332,10 @@ struct wuffs_nie__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NIE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ZLIB) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_zlib__note__dictionary_required[];
|
||||
@@ -9277,6 +9344,7 @@ extern const char wuffs_zlib__error__bad_compression_method[];
|
||||
extern const char wuffs_zlib__error__bad_compression_window_size[];
|
||||
extern const char wuffs_zlib__error__bad_parity_check[];
|
||||
extern const char wuffs_zlib__error__incorrect_dictionary[];
|
||||
extern const char wuffs_zlib__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -9399,6 +9467,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
uint32_t f_dict_id_want;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
@@ -9409,7 +9478,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
struct {
|
||||
uint32_t v_checksum_got;
|
||||
uint64_t scratch;
|
||||
} s_transform_io[1];
|
||||
} s_do_transform_io[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -9510,6 +9579,10 @@ struct wuffs_zlib__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ZLIB) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_png__error__bad_animation_sequence_number[];
|
||||
@@ -9519,6 +9592,7 @@ extern const char wuffs_png__error__bad_filter[];
|
||||
extern const char wuffs_png__error__bad_header[];
|
||||
extern const char wuffs_png__error__bad_text_chunk_not_latin_1[];
|
||||
extern const char wuffs_png__error__missing_palette[];
|
||||
extern const char wuffs_png__error__truncated_input[];
|
||||
extern const char wuffs_png__error__unsupported_cgbi_extension[];
|
||||
extern const char wuffs_png__error__unsupported_png_compression_method[];
|
||||
extern const char wuffs_png__error__unsupported_png_file[];
|
||||
@@ -9755,6 +9829,7 @@ struct wuffs_png__decoder__struct {
|
||||
wuffs_base__slice_u8 a_curr,
|
||||
wuffs_base__slice_u8 a_prev);
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_ihdr[1];
|
||||
uint32_t p_decode_other_chunk[1];
|
||||
uint32_t p_decode_actl[1];
|
||||
@@ -9766,10 +9841,13 @@ struct wuffs_png__decoder__struct {
|
||||
uint32_t p_decode_srgb[1];
|
||||
uint32_t p_decode_trns[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_skip_frame[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
uint32_t p_decode_pass[1];
|
||||
uint32_t p_tell_me_more[1];
|
||||
uint32_t p_do_tell_me_more[1];
|
||||
wuffs_base__status (*choosy_filter_and_swizzle)(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
@@ -9785,7 +9863,7 @@ struct wuffs_png__decoder__struct {
|
||||
struct {
|
||||
uint32_t v_checksum_have;
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_ihdr[1];
|
||||
@@ -9819,20 +9897,20 @@ struct wuffs_png__decoder__struct {
|
||||
} s_decode_trns[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_frame_config[1];
|
||||
} s_do_decode_frame_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_skip_frame[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_pass[1];
|
||||
struct {
|
||||
wuffs_base__status v_zlib_status;
|
||||
uint64_t scratch;
|
||||
} s_tell_me_more[1];
|
||||
} s_do_tell_me_more[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -9980,10 +10058,15 @@ struct wuffs_png__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_tga__error__bad_header[];
|
||||
extern const char wuffs_tga__error__bad_run_length_encoding[];
|
||||
extern const char wuffs_tga__error__truncated_input[];
|
||||
extern const char wuffs_tga__error__unsupported_tga_file[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -10154,8 +10237,11 @@ struct wuffs_tga__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
@@ -10166,7 +10252,7 @@ struct wuffs_tga__decoder__struct {
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t v_dst_bytes_per_pixel;
|
||||
uint32_t v_dst_x;
|
||||
@@ -10177,7 +10263,7 @@ struct wuffs_tga__decoder__struct {
|
||||
uint32_t v_run_length;
|
||||
uint64_t v_num_dst_bytes;
|
||||
uint64_t scratch;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -10325,9 +10411,14 @@ struct wuffs_tga__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_wbmp__error__bad_header[];
|
||||
extern const char wuffs_wbmp__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -10485,22 +10576,25 @@ struct wuffs_wbmp__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint32_t v_x32;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t v_dst_bytes_per_pixel;
|
||||
uint32_t v_dst_x;
|
||||
uint32_t v_dst_y;
|
||||
uint8_t v_src[1];
|
||||
uint8_t v_c;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -10648,6 +10742,8 @@ struct wuffs_wbmp__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if defined(__cplusplus) && defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
// ---------------- Auxiliary - Base
|
||||
@@ -14685,6 +14781,27 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
// powers converts decimal powers of 10 to binary powers of 2. For example,
|
||||
// (10000 >> 13) is 1. It stops before the elements exceed 60, also known
|
||||
// as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
|
||||
//
|
||||
// This rounds down (1<<13 is a lower bound for 1e4). Adding 1 to the array
|
||||
// element value rounds up (1<<14 is an upper bound for 1e4) while staying
|
||||
// at or below WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
|
||||
//
|
||||
// When starting in the range [1e+1 .. 1e+2] (i.e. h->decimal_point == +2),
|
||||
// powers[2] == 6 and so:
|
||||
// - Right shifting by 6+0 produces the range [10/64 .. 100/64] =
|
||||
// [0.156250 .. 1.56250]. The resultant h->decimal_point is +0 or +1.
|
||||
// - Right shifting by 6+1 produces the range [10/128 .. 100/128] =
|
||||
// [0.078125 .. 0.78125]. The resultant h->decimal_point is -1 or -0.
|
||||
//
|
||||
// When starting in the range [1e-3 .. 1e-2] (i.e. h->decimal_point == -2),
|
||||
// powers[2] == 6 and so:
|
||||
// - Left shifting by 6+0 produces the range [0.001*64 .. 0.01*64] =
|
||||
// [0.064 .. 0.64]. The resultant h->decimal_point is -1 or -0.
|
||||
// - Left shifting by 6+1 produces the range [0.001*128 .. 0.01*128] =
|
||||
// [0.128 .. 1.28]. The resultant h->decimal_point is +0 or +1.
|
||||
//
|
||||
// Thus, when targeting h->decimal_point being +0 or +1, use (powers[n]+0)
|
||||
// when right shifting but (powers[n]+1) when left shifting.
|
||||
static const uint32_t num_powers = 19;
|
||||
static const uint8_t powers[19] = {
|
||||
0, 3, 6, 9, 13, 16, 19, 23, 26, 29, //
|
||||
@@ -14704,36 +14821,54 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
// approach taken in wuffs_base__parse_number_f64. The latter is optimized
|
||||
// for the common cases (e.g. assuming no underscores or a leading '+'
|
||||
// sign) rather than the full set of cases allowed by the Wuffs API.
|
||||
if (h->num_digits <= 19) {
|
||||
//
|
||||
// When we have 19 or fewer mantissa digits, run Eisel-Lemire once (trying
|
||||
// for an exact result). When we have more than 19 mantissa digits, run it
|
||||
// twice to get a lower and upper bound. We still have an exact result
|
||||
// (within f64's rounding margin) if both bounds are equal (and valid).
|
||||
uint32_t i_max = h->num_digits;
|
||||
if (i_max > 19) {
|
||||
i_max = 19;
|
||||
}
|
||||
int32_t exp10 = h->decimal_point - ((int32_t)i_max);
|
||||
if ((-307 <= exp10) && (exp10 <= 288)) {
|
||||
uint64_t man = 0;
|
||||
uint32_t i;
|
||||
for (i = 0; i < h->num_digits; i++) {
|
||||
for (i = 0; i < i_max; i++) {
|
||||
man = (10 * man) + h->digits[i];
|
||||
}
|
||||
int32_t exp10 = h->decimal_point - ((int32_t)(h->num_digits));
|
||||
if ((man != 0) && (-307 <= exp10) && (exp10 <= 288)) {
|
||||
int64_t r =
|
||||
while (man != 0) { // The 'while' is just an 'if' that we can 'break'.
|
||||
int64_t r0 =
|
||||
wuffs_base__private_implementation__parse_number_f64_eisel_lemire(
|
||||
man, exp10);
|
||||
if (r >= 0) {
|
||||
wuffs_base__result_f64 ret;
|
||||
ret.status.repr = NULL;
|
||||
ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(
|
||||
((uint64_t)r) | (((uint64_t)(h->negative)) << 63));
|
||||
return ret;
|
||||
man + 0, exp10);
|
||||
if (r0 < 0) {
|
||||
break;
|
||||
} else if (h->num_digits > 19) {
|
||||
int64_t r1 =
|
||||
wuffs_base__private_implementation__parse_number_f64_eisel_lemire(
|
||||
man + 1, exp10);
|
||||
if (r1 != r0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
wuffs_base__result_f64 ret;
|
||||
ret.status.repr = NULL;
|
||||
ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(
|
||||
((uint64_t)r0) | (((uint64_t)(h->negative)) << 63));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See
|
||||
// https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
|
||||
//
|
||||
// Scale by powers of 2 until we're in the range [½ .. 1], which gives us
|
||||
// our exponent (in base-2). First we shift right, possibly a little too
|
||||
// far, ending with a value certainly below 1 and possibly below ½...
|
||||
// Scale by powers of 2 until we're in the range [0.1 .. 10]. Equivalently,
|
||||
// that h->decimal_point is +0 or +1.
|
||||
//
|
||||
// First we shift right while at or above 10...
|
||||
const int32_t f64_bias = -1023;
|
||||
int32_t exp2 = 0;
|
||||
while (h->decimal_point > 0) {
|
||||
while (h->decimal_point > 1) {
|
||||
uint32_t n = (uint32_t)(+h->decimal_point);
|
||||
uint32_t shift =
|
||||
(n < num_powers)
|
||||
@@ -14747,20 +14882,15 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
}
|
||||
exp2 += (int32_t)shift;
|
||||
}
|
||||
// ...then we shift left, putting us in [½ .. 1].
|
||||
while (h->decimal_point <= 0) {
|
||||
// ...then we shift left while below 0.1.
|
||||
while (h->decimal_point < 0) {
|
||||
uint32_t shift;
|
||||
if (h->decimal_point == 0) {
|
||||
if (h->digits[0] >= 5) {
|
||||
break;
|
||||
}
|
||||
shift = (h->digits[0] < 2) ? 2 : 1;
|
||||
} else {
|
||||
uint32_t n = (uint32_t)(-h->decimal_point);
|
||||
shift = (n < num_powers)
|
||||
? powers[n]
|
||||
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
|
||||
}
|
||||
uint32_t n = (uint32_t)(-h->decimal_point);
|
||||
shift = (n < num_powers)
|
||||
// The +1 is per "when targeting h->decimal_point being +0 or
|
||||
// +1... when left shifting" in the powers comment above.
|
||||
? (powers[n] + 1)
|
||||
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
|
||||
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift);
|
||||
if (h->decimal_point >
|
||||
@@ -14770,8 +14900,37 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
exp2 -= (int32_t)shift;
|
||||
}
|
||||
|
||||
// We're in the range [½ .. 1] but f64 uses [1 .. 2].
|
||||
exp2--;
|
||||
// To get from "in the range [0.1 .. 10]" to "in the range [1 .. 2]" (which
|
||||
// will give us our exponent in base-2), the mantissa's first 3 digits will
|
||||
// determine the final left shift, equal to 52 (the number of explicit f64
|
||||
// bits) plus an additional adjustment.
|
||||
int man3 = (100 * h->digits[0]) +
|
||||
((h->num_digits > 1) ? (10 * h->digits[1]) : 0) +
|
||||
((h->num_digits > 2) ? h->digits[2] : 0);
|
||||
int32_t additional_lshift = 0;
|
||||
if (h->decimal_point == 0) { // The value is in [0.1 .. 1].
|
||||
if (man3 < 125) {
|
||||
additional_lshift = +4;
|
||||
} else if (man3 < 250) {
|
||||
additional_lshift = +3;
|
||||
} else if (man3 < 500) {
|
||||
additional_lshift = +2;
|
||||
} else {
|
||||
additional_lshift = +1;
|
||||
}
|
||||
} else { // The value is in [1 .. 10].
|
||||
if (man3 < 200) {
|
||||
additional_lshift = -0;
|
||||
} else if (man3 < 400) {
|
||||
additional_lshift = -1;
|
||||
} else if (man3 < 800) {
|
||||
additional_lshift = -2;
|
||||
} else {
|
||||
additional_lshift = -3;
|
||||
}
|
||||
}
|
||||
exp2 -= additional_lshift;
|
||||
uint32_t final_lshift = (uint32_t)(52 + additional_lshift);
|
||||
|
||||
// The minimum normal exponent is (f64_bias + 1).
|
||||
while ((f64_bias + 1) > exp2) {
|
||||
@@ -14789,7 +14948,8 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
}
|
||||
|
||||
// Extract 53 bits for the mantissa (in base-2).
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, 53);
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(
|
||||
h, final_lshift);
|
||||
uint64_t man2 =
|
||||
wuffs_base__private_implementation__high_prec_dec__rounded_integer(h);
|
||||
|
||||
@@ -22472,6 +22632,7 @@ wuffs_adler32__hasher__up_x86_sse42(
|
||||
|
||||
const char wuffs_bmp__error__bad_header[] = "#bmp: bad header";
|
||||
const char wuffs_bmp__error__bad_rle_compression[] = "#bmp: bad RLE compression";
|
||||
const char wuffs_bmp__error__truncated_input[] = "#bmp: truncated input";
|
||||
const char wuffs_bmp__error__unsupported_bmp_file[] = "#bmp: unsupported BMP file";
|
||||
const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: short read";
|
||||
|
||||
@@ -22509,6 +22670,27 @@ const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: s
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_image_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__swizzle_none(
|
||||
wuffs_bmp__decoder* self,
|
||||
@@ -22533,6 +22715,13 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_tell_me_more(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__read_palette(
|
||||
wuffs_bmp__decoder* self,
|
||||
@@ -22687,6 +22876,52 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_image_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_magic = 0;
|
||||
uint32_t v_width = 0;
|
||||
uint32_t v_height = 0;
|
||||
@@ -22705,7 +22940,7 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -22723,14 +22958,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_0 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22749,15 +22984,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__bad_header);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = 8;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 8;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
uint32_t t_1;
|
||||
@@ -22765,14 +23000,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22800,14 +23035,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22835,14 +23070,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_3 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22864,14 +23099,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_4 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22893,14 +23128,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_5 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_5 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22926,14 +23161,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22956,14 +23191,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_7 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(17);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22990,14 +23225,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(19);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23024,14 +23259,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_9 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(21);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23057,14 +23292,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_10 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(23);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23087,14 +23322,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(25);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23121,14 +23356,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_12 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(27);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23159,14 +23394,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_13 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(29);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_13 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23192,14 +23427,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_14 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(31);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_14 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23221,14 +23456,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_15 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(33);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_15 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23256,15 +23491,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = 20;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 20;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(34);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
if (self->private_impl.f_bitmap_info_len == 40) {
|
||||
if (self->private_impl.f_bits_per_pixel >= 16) {
|
||||
if (self->private_impl.f_padding >= 16) {
|
||||
@@ -23295,14 +23530,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_16 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(36);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_16 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23324,14 +23559,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_17 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(38);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_17 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23353,14 +23588,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_18 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(40);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_18 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23383,14 +23618,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_19 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(42);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_19 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23405,15 +23640,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
}
|
||||
self->private_impl.f_channel_masks[3] = t_19;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56));
|
||||
self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(43);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
}
|
||||
if ((self->private_impl.f_channel_masks[0] == 255) && (self->private_impl.f_channel_masks[1] == 65280) && (self->private_impl.f_channel_masks[2] == 16711680)) {
|
||||
if (self->private_impl.f_bits_per_pixel == 24) {
|
||||
@@ -23431,15 +23666,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
}
|
||||
}
|
||||
} else if (self->private_impl.f_bitmap_info_len >= 40) {
|
||||
self->private_data.s_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40);
|
||||
self->private_data.s_do_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
@@ -23562,14 +23797,13 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -23577,9 +23811,6 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -23611,6 +23842,52 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -23622,7 +23899,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -23632,7 +23909,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_bmp__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_bmp__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -23671,14 +23948,13 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -23686,9 +23962,6 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -23725,6 +23998,60 @@ wuffs_bmp__decoder__decode_frame(
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
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;
|
||||
@@ -23736,7 +24063,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -23746,7 +24073,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_bmp__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_bmp__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -23757,15 +24084,15 @@ wuffs_bmp__decoder__decode_frame(
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
}
|
||||
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_padding;
|
||||
self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_padding;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
if ((self->private_impl.f_width > 0) && (self->private_impl.f_height > 0)) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
if (self->private_impl.f_top_down) {
|
||||
@@ -23841,28 +24168,27 @@ wuffs_bmp__decoder__decode_frame(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
}
|
||||
label__0__break:;
|
||||
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_pending_pad;
|
||||
self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_pending_pad;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
self->private_impl.f_pending_pad = 0;
|
||||
}
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -23870,9 +24196,6 @@ wuffs_bmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -23889,10 +24212,12 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_row = 0;
|
||||
uint32_t v_src_bytes_per_pixel = 0;
|
||||
wuffs_base__slice_u8 v_dst_palette = {0};
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
uint64_t v_i = 0;
|
||||
uint64_t v_j = 0;
|
||||
uint64_t v_n = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -23926,7 +24251,6 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
self->private_impl.f_pending_pad -= 1;
|
||||
iop_a_src += 1;
|
||||
}
|
||||
label__inner__continue:;
|
||||
while (true) {
|
||||
if (self->private_impl.f_dst_x == self->private_impl.f_width) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
@@ -23947,14 +24271,38 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
goto label__inner__continue;
|
||||
if (self->private_impl.f_bits_per_pixel > 32) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
}
|
||||
v_src_bytes_per_pixel = (self->private_impl.f_bits_per_pixel / 8);
|
||||
if (v_src_bytes_per_pixel == 0) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
}
|
||||
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
|
||||
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
|
||||
v_j = v_n;
|
||||
while (v_j >= 8) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 8);
|
||||
}
|
||||
v_j -= 8;
|
||||
}
|
||||
while (v_j > 0) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 1);
|
||||
}
|
||||
v_j -= 1;
|
||||
}
|
||||
} else {
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
v_dst_palette,
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
}
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
v_dst_palette,
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
if (v_n == 0) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
|
||||
goto ok;
|
||||
@@ -24295,7 +24643,6 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
self->private_impl.f_pending_pad -= 1;
|
||||
iop_a_src += 1;
|
||||
}
|
||||
label__inner__continue:;
|
||||
while (true) {
|
||||
if (self->private_impl.f_dst_x == self->private_impl.f_width) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
@@ -24354,9 +24701,10 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
goto label__inner__continue;
|
||||
v_n = ((uint64_t)(v_p0));
|
||||
} else {
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
|
||||
}
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
|
||||
if (v_n == 0) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
|
||||
goto ok;
|
||||
@@ -24399,6 +24747,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
uint32_t v_p0 = 0;
|
||||
uint32_t v_chunk_bits = 0;
|
||||
uint32_t v_chunk_count = 0;
|
||||
uint32_t v_pixels_per_chunk = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -24436,6 +24785,35 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
if (self->private_impl.f_bits_per_pixel == 1) {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 31) / 32);
|
||||
v_pixels_per_chunk = 32;
|
||||
} else if (self->private_impl.f_bits_per_pixel == 2) {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 15) / 16);
|
||||
v_pixels_per_chunk = 16;
|
||||
} else {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
|
||||
v_pixels_per_chunk = 8;
|
||||
}
|
||||
while ((v_chunk_count >= 64) && (((uint64_t)(io2_a_src - iop_a_src)) >= 256)) {
|
||||
iop_a_src += 256;
|
||||
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 64))));
|
||||
v_chunk_count -= 64;
|
||||
}
|
||||
while ((v_chunk_count >= 8) && (((uint64_t)(io2_a_src - iop_a_src)) >= 32)) {
|
||||
iop_a_src += 32;
|
||||
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 8))));
|
||||
v_chunk_count -= 8;
|
||||
}
|
||||
while (v_chunk_count > 0) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
|
||||
goto ok;
|
||||
}
|
||||
iop_a_src += 4;
|
||||
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 1))));
|
||||
v_chunk_count -= 1;
|
||||
}
|
||||
goto label__loop__continue;
|
||||
}
|
||||
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_i);
|
||||
@@ -24506,7 +24884,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
v_p0 = ((v_p0 & 511) + 16);
|
||||
v_chunk_count -= 1;
|
||||
}
|
||||
} else if (self->private_impl.f_bits_per_pixel == 4) {
|
||||
} else {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
|
||||
v_chunk_count = wuffs_base__u32__min(v_chunk_count, 64);
|
||||
while ((v_chunk_count > 0) && (((uint64_t)(io2_a_src - iop_a_src)) >= 4)) {
|
||||
@@ -24687,6 +25065,53 @@ wuffs_bmp__decoder__tell_me_more(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_tell_me_more
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_tell_me_more(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
if (self->private_impl.f_io_redirect_fourcc <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__no_more_information);
|
||||
goto exit;
|
||||
@@ -24705,9 +25130,6 @@ wuffs_bmp__decoder__tell_me_more(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -24920,6 +25342,7 @@ const char wuffs_bzip2__error__bad_block_length[] = "#bzip2: bad block length";
|
||||
const char wuffs_bzip2__error__bad_checksum[] = "#bzip2: bad checksum";
|
||||
const char wuffs_bzip2__error__bad_header[] = "#bzip2: bad header";
|
||||
const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections";
|
||||
const char wuffs_bzip2__error__truncated_input[] = "#bzip2: truncated input";
|
||||
const char wuffs_bzip2__error__unsupported_block_randomization[] = "#bzip2: unsupported block randomization";
|
||||
const char wuffs_bzip2__error__internal_error_inconsistent_huffman_decoder_state[] = "#bzip2: internal error: inconsistent Huffman decoder state";
|
||||
|
||||
@@ -24970,6 +25393,13 @@ WUFFS_BZIP2__REV_CRC32_TABLE[256] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bzip2__decoder__do_transform_io(
|
||||
wuffs_bzip2__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bzip2__decoder__prepare_block(
|
||||
wuffs_bzip2__decoder* self,
|
||||
@@ -25164,6 +25594,53 @@ wuffs_bzip2__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bzip2__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bzip2.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bzip2__decoder__do_transform_io(
|
||||
wuffs_bzip2__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint32_t v_i = 0;
|
||||
uint64_t v_tag = 0;
|
||||
@@ -25181,11 +25658,11 @@ wuffs_bzip2__decoder__transform_io(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
if (coro_susp_point) {
|
||||
v_i = self->private_data.s_transform_io[0].v_i;
|
||||
v_tag = self->private_data.s_transform_io[0].v_tag;
|
||||
v_final_checksum_want = self->private_data.s_transform_io[0].v_final_checksum_want;
|
||||
v_i = self->private_data.s_do_transform_io[0].v_i;
|
||||
v_tag = self->private_data.s_do_transform_io[0].v_tag;
|
||||
v_final_checksum_want = self->private_data.s_do_transform_io[0].v_final_checksum_want;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -25374,17 +25851,16 @@ wuffs_bzip2__decoder__transform_io(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_transform_io[0].v_i = v_i;
|
||||
self->private_data.s_transform_io[0].v_tag = v_tag;
|
||||
self->private_data.s_transform_io[0].v_final_checksum_want = v_final_checksum_want;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_transform_io[0].v_i = v_i;
|
||||
self->private_data.s_do_transform_io[0].v_tag = v_tag;
|
||||
self->private_data.s_do_transform_io[0].v_final_checksum_want = v_final_checksum_want;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -25392,9 +25868,6 @@ wuffs_bzip2__decoder__transform_io(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -28357,6 +28830,7 @@ const char wuffs_deflate__error__bad_literal_length_code_count[] = "#deflate: ba
|
||||
const char wuffs_deflate__error__inconsistent_stored_block_length[] = "#deflate: inconsistent stored block length";
|
||||
const char wuffs_deflate__error__missing_end_of_block_code[] = "#deflate: missing end-of-block code";
|
||||
const char wuffs_deflate__error__no_huffman_codes[] = "#deflate: no Huffman codes";
|
||||
const char wuffs_deflate__error__truncated_input[] = "#deflate: truncated input";
|
||||
const char wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state[] = "#deflate: internal error: inconsistent Huffman decoder state";
|
||||
const char wuffs_deflate__error__internal_error_inconsistent_i_o[] = "#deflate: internal error: inconsistent I/O";
|
||||
const char wuffs_deflate__error__internal_error_inconsistent_distance[] = "#deflate: internal error: inconsistent distance";
|
||||
@@ -28431,6 +28905,13 @@ WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[32] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_deflate__decoder__do_transform_io(
|
||||
wuffs_deflate__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_deflate__decoder__decode_blocks(
|
||||
wuffs_deflate__decoder* self,
|
||||
@@ -28674,6 +29155,53 @@ wuffs_deflate__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_deflate__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func deflate.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_deflate__decoder__do_transform_io(
|
||||
wuffs_deflate__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint64_t v_mark = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
@@ -28691,7 +29219,7 @@ wuffs_deflate__decoder__transform_io(
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -28729,14 +29257,13 @@ wuffs_deflate__decoder__transform_io(
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -28744,9 +29271,6 @@ wuffs_deflate__decoder__transform_io(
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -30620,6 +31144,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_lzw__error__bad_code[] = "#lzw: bad code";
|
||||
const char wuffs_lzw__error__truncated_input[] = "#lzw: truncated input";
|
||||
const char wuffs_lzw__error__internal_error_inconsistent_i_o[] = "#lzw: internal error: inconsistent I/O";
|
||||
|
||||
// ---------------- Private Consts
|
||||
@@ -30842,6 +31367,9 @@ wuffs_lzw__decoder__transform_io(
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_read_from_return_value == 3) {
|
||||
status = wuffs_base__make_status(wuffs_lzw__error__truncated_input);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_read_from_return_value == 4) {
|
||||
status = wuffs_base__make_status(wuffs_lzw__error__bad_code);
|
||||
goto exit;
|
||||
} else {
|
||||
@@ -30917,7 +31445,11 @@ wuffs_lzw__decoder__read_from(
|
||||
iop_a_src += ((31 - v_n_bits) >> 3);
|
||||
v_n_bits |= 24;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
if (a_src && a_src->meta.closed) {
|
||||
self->private_impl.f_read_from_return_value = 3;
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
}
|
||||
goto label__0__break;
|
||||
} else {
|
||||
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
|
||||
@@ -30925,14 +31457,18 @@ wuffs_lzw__decoder__read_from(
|
||||
v_n_bits += 8;
|
||||
if (v_n_bits >= v_width) {
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
if (a_src && a_src->meta.closed) {
|
||||
self->private_impl.f_read_from_return_value = 3;
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
}
|
||||
goto label__0__break;
|
||||
} else {
|
||||
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
|
||||
iop_a_src += 1;
|
||||
v_n_bits += 8;
|
||||
if (v_n_bits < v_width) {
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
self->private_impl.f_read_from_return_value = 5;
|
||||
goto label__0__break;
|
||||
}
|
||||
}
|
||||
@@ -31010,7 +31546,7 @@ wuffs_lzw__decoder__read_from(
|
||||
v_prev_code = v_code;
|
||||
}
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 3;
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
goto label__0__break;
|
||||
}
|
||||
if (v_output_wi > 4095) {
|
||||
@@ -31025,7 +31561,7 @@ wuffs_lzw__decoder__read_from(
|
||||
if (iop_a_src > io1_a_src) {
|
||||
iop_a_src--;
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
self->private_impl.f_read_from_return_value = 5;
|
||||
goto label__2__break;
|
||||
}
|
||||
}
|
||||
@@ -31147,6 +31683,7 @@ const char wuffs_gif__error__bad_graphic_control[] = "#gif: bad graphic control"
|
||||
const char wuffs_gif__error__bad_header[] = "#gif: bad header";
|
||||
const char wuffs_gif__error__bad_literal_width[] = "#gif: bad literal width";
|
||||
const char wuffs_gif__error__bad_palette[] = "#gif: bad palette";
|
||||
const char wuffs_gif__error__truncated_input[] = "#gif: truncated input";
|
||||
const char wuffs_gif__error__internal_error_inconsistent_ri_wi[] = "#gif: internal error: inconsistent ri/wi";
|
||||
|
||||
// ---------------- Private Consts
|
||||
@@ -31198,11 +31735,39 @@ WUFFS_GIF__XMPDATAXMP[11] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_image_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_tell_me_more(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__skip_frame(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__empty_struct
|
||||
wuffs_gif__decoder__reset_gc(
|
||||
wuffs_gif__decoder* self);
|
||||
@@ -31432,12 +31997,58 @@ wuffs_gif__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
bool v_ffio = false;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_image_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
bool v_ffio = false;
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence != 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
goto exit;
|
||||
@@ -31488,20 +32099,16 @@ wuffs_gif__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -31556,6 +32163,53 @@ wuffs_gif__decoder__tell_me_more(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_tell_me_more
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_tell_me_more(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint64_t v_chunk_length = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -31569,7 +32223,7 @@ wuffs_gif__decoder__tell_me_more(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -31651,14 +32305,13 @@ wuffs_gif__decoder__tell_me_more(
|
||||
goto ok;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
self->private_impl.p_do_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -31666,9 +32319,6 @@ wuffs_gif__decoder__tell_me_more(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -31821,6 +32471,52 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_background_color = 0;
|
||||
uint8_t v_flags = 0;
|
||||
|
||||
@@ -31835,9 +32531,9 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_background_color = self->private_data.s_decode_frame_config[0].v_background_color;
|
||||
v_background_color = self->private_data.s_do_decode_frame_config[0].v_background_color;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -31852,7 +32548,7 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_gif__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -31935,15 +32631,14 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_data.s_decode_frame_config[0].v_background_color = v_background_color;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_frame_config[0].v_background_color = v_background_color;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -31951,9 +32646,6 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -32085,14 +32777,68 @@ wuffs_gif__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 64) {
|
||||
} else if (self->private_impl.f_call_sequence < 64) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_gif__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_gif__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
@@ -32119,20 +32865,16 @@ wuffs_gif__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -33735,6 +34477,7 @@ const char wuffs_gzip__error__bad_checksum[] = "#gzip: bad checksum";
|
||||
const char wuffs_gzip__error__bad_compression_method[] = "#gzip: bad compression method";
|
||||
const char wuffs_gzip__error__bad_encoding_flags[] = "#gzip: bad encoding flags";
|
||||
const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
|
||||
const char wuffs_gzip__error__truncated_input[] = "#gzip: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
@@ -33742,6 +34485,13 @@ const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gzip__decoder__do_transform_io(
|
||||
wuffs_gzip__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__io_transformer__func_ptrs
|
||||
@@ -33906,6 +34656,53 @@ wuffs_gzip__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gzip__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gzip__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gzip.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gzip__decoder__do_transform_io(
|
||||
wuffs_gzip__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint8_t v_flags = 0;
|
||||
uint16_t v_xlen = 0;
|
||||
@@ -33940,12 +34737,12 @@ wuffs_gzip__decoder__transform_io(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
if (coro_susp_point) {
|
||||
v_flags = self->private_data.s_transform_io[0].v_flags;
|
||||
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got;
|
||||
v_decoded_length_got = self->private_data.s_transform_io[0].v_decoded_length_got;
|
||||
v_checksum_want = self->private_data.s_transform_io[0].v_checksum_want;
|
||||
v_flags = self->private_data.s_do_transform_io[0].v_flags;
|
||||
v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
|
||||
v_decoded_length_got = self->private_data.s_do_transform_io[0].v_decoded_length_got;
|
||||
v_checksum_want = self->private_data.s_do_transform_io[0].v_checksum_want;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -33998,15 +34795,15 @@ wuffs_gzip__decoder__transform_io(
|
||||
uint8_t t_3 = *iop_a_src++;
|
||||
v_flags = t_3;
|
||||
}
|
||||
self->private_data.s_transform_io[0].scratch = 6;
|
||||
self->private_data.s_do_transform_io[0].scratch = 6;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_transform_io[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_transform_io[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_transform_io[0].scratch;
|
||||
if ((v_flags & 4) != 0) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
@@ -34015,14 +34812,14 @@ wuffs_gzip__decoder__transform_io(
|
||||
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -34037,15 +34834,15 @@ wuffs_gzip__decoder__transform_io(
|
||||
}
|
||||
v_xlen = t_4;
|
||||
}
|
||||
self->private_data.s_transform_io[0].scratch = ((uint32_t)(v_xlen));
|
||||
self->private_data.s_do_transform_io[0].scratch = ((uint32_t)(v_xlen));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_transform_io[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_transform_io[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_transform_io[0].scratch;
|
||||
}
|
||||
if ((v_flags & 8) != 0) {
|
||||
while (true) {
|
||||
@@ -34082,15 +34879,15 @@ wuffs_gzip__decoder__transform_io(
|
||||
label__1__break:;
|
||||
}
|
||||
if ((v_flags & 2) != 0) {
|
||||
self->private_data.s_transform_io[0].scratch = 2;
|
||||
self->private_data.s_do_transform_io[0].scratch = 2;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_transform_io[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_transform_io[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_transform_io[0].scratch;
|
||||
}
|
||||
if ((v_flags & 224) != 0) {
|
||||
status = wuffs_base__make_status(wuffs_gzip__error__bad_encoding_flags);
|
||||
@@ -34132,14 +34929,14 @@ wuffs_gzip__decoder__transform_io(
|
||||
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -34161,14 +34958,14 @@ wuffs_gzip__decoder__transform_io(
|
||||
t_9 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
|
||||
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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -34189,18 +34986,17 @@ wuffs_gzip__decoder__transform_io(
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_transform_io[0].v_flags = v_flags;
|
||||
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
self->private_data.s_transform_io[0].v_decoded_length_got = v_decoded_length_got;
|
||||
self->private_data.s_transform_io[0].v_checksum_want = v_checksum_want;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_transform_io[0].v_flags = v_flags;
|
||||
self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
self->private_data.s_do_transform_io[0].v_decoded_length_got = v_decoded_length_got;
|
||||
self->private_data.s_do_transform_io[0].v_checksum_want = v_checksum_want;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -34211,9 +35007,6 @@ wuffs_gzip__decoder__transform_io(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -36431,6 +37224,7 @@ wuffs_json__decoder__decode_trailer(
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_nie__error__bad_header[] = "#nie: bad header";
|
||||
const char wuffs_nie__error__truncated_input[] = "#nie: truncated input";
|
||||
const char wuffs_nie__error__unsupported_nie_file[] = "#nie: unsupported NIE file";
|
||||
const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: short read";
|
||||
|
||||
@@ -36440,6 +37234,27 @@ const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: s
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_image_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__swizzle(
|
||||
wuffs_nie__decoder* self,
|
||||
@@ -36591,6 +37406,52 @@ wuffs_nie__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func nie.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_image_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_a = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -36604,7 +37465,7 @@ wuffs_nie__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -36619,14 +37480,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36652,14 +37513,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36695,14 +37556,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36729,14 +37590,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_3 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36770,14 +37631,13 @@ wuffs_nie__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -36785,9 +37645,6 @@ wuffs_nie__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -36819,6 +37676,52 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func nie.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -36830,7 +37733,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -36840,7 +37743,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_nie__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_nie__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -36879,14 +37782,13 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -36894,9 +37796,6 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -36937,10 +37836,64 @@ wuffs_nie__decoder__decode_frame(
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func nie.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 64) {
|
||||
} else if (self->private_impl.f_call_sequence < 64) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_nie__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_nie__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
@@ -36987,20 +37940,16 @@ wuffs_nie__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -37017,9 +37966,11 @@ wuffs_nie__decoder__swizzle(
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_row = 0;
|
||||
uint32_t v_src_bytes_per_pixel = 0;
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
uint64_t v_i = 0;
|
||||
uint64_t v_j = 0;
|
||||
uint64_t v_n = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -37042,7 +37993,6 @@ wuffs_nie__decoder__swizzle(
|
||||
v_dst_bytes_per_pixel = ((uint64_t)((v_dst_bits_per_pixel / 8)));
|
||||
v_dst_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * v_dst_bytes_per_pixel);
|
||||
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0);
|
||||
label__0__continue:;
|
||||
while (true) {
|
||||
if (self->private_impl.f_dst_x == self->private_impl.f_width) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
@@ -37057,14 +38007,33 @@ wuffs_nie__decoder__swizzle(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
goto label__0__continue;
|
||||
v_src_bytes_per_pixel = 4;
|
||||
if (self->private_impl.f_pixfmt == 2164308923) {
|
||||
v_src_bytes_per_pixel = 8;
|
||||
}
|
||||
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
|
||||
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
|
||||
v_j = v_n;
|
||||
while (v_j >= 8) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 8);
|
||||
}
|
||||
v_j -= 8;
|
||||
}
|
||||
while (v_j > 0) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 1);
|
||||
}
|
||||
v_j -= 1;
|
||||
}
|
||||
} else {
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
wuffs_base__pixel_buffer__palette(a_dst),
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
}
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
wuffs_base__pixel_buffer__palette(a_dst),
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
if (v_n == 0) {
|
||||
status = wuffs_base__make_status(wuffs_nie__note__internal_note_short_read);
|
||||
goto ok;
|
||||
@@ -37266,6 +38235,7 @@ const char wuffs_zlib__error__bad_compression_method[] = "#zlib: bad compression
|
||||
const char wuffs_zlib__error__bad_compression_window_size[] = "#zlib: bad compression window size";
|
||||
const char wuffs_zlib__error__bad_parity_check[] = "#zlib: bad parity check";
|
||||
const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect dictionary";
|
||||
const char wuffs_zlib__error__truncated_input[] = "#zlib: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
@@ -37277,6 +38247,13 @@ const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect diction
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_zlib__decoder__do_transform_io(
|
||||
wuffs_zlib__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__io_transformer__func_ptrs
|
||||
@@ -37494,6 +38471,53 @@ wuffs_zlib__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_zlib__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_zlib__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func zlib.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_zlib__decoder__do_transform_io(
|
||||
wuffs_zlib__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint16_t v_x = 0;
|
||||
uint32_t v_checksum_got = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
@@ -37524,9 +38548,9 @@ wuffs_zlib__decoder__transform_io(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
if (coro_susp_point) {
|
||||
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got;
|
||||
v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -37543,14 +38567,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
t_0 = wuffs_base__peek_u16be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -37587,14 +38611,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -37660,14 +38684,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
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;
|
||||
self->private_data.s_do_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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -37689,15 +38713,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -37708,9 +38731,6 @@ wuffs_zlib__decoder__transform_io(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -37727,6 +38747,7 @@ const char wuffs_png__error__bad_filter[] = "#png: bad filter";
|
||||
const char wuffs_png__error__bad_header[] = "#png: bad header";
|
||||
const char wuffs_png__error__bad_text_chunk_not_latin_1[] = "#png: bad text chunk (not Latin-1)";
|
||||
const char wuffs_png__error__missing_palette[] = "#png: missing palette";
|
||||
const char wuffs_png__error__truncated_input[] = "#png: truncated input";
|
||||
const char wuffs_png__error__unsupported_cgbi_extension[] = "#png: unsupported CgBI extension";
|
||||
const char wuffs_png__error__unsupported_png_compression_method[] = "#png: unsupported PNG compression method";
|
||||
const char wuffs_png__error__unsupported_png_file[] = "#png: unsupported PNG file";
|
||||
@@ -37952,6 +38973,12 @@ wuffs_png__decoder__filter_4_distance_4_x86_sse42(
|
||||
wuffs_base__slice_u8 a_prev);
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_image_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_ihdr(
|
||||
wuffs_png__decoder* self,
|
||||
@@ -38021,17 +39048,39 @@ wuffs_png__decoder__decode_trns(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__skip_frame(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_pass(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_tell_me_more(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__filter_and_swizzle(
|
||||
wuffs_png__decoder* self,
|
||||
@@ -39626,6 +40675,52 @@ wuffs_png__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_image_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint64_t v_magic = 0;
|
||||
uint64_t v_mark = 0;
|
||||
uint32_t v_checksum_have = 0;
|
||||
@@ -39643,9 +40738,9 @@ wuffs_png__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_checksum_have = self->private_data.s_decode_image_config[0].v_checksum_have;
|
||||
v_checksum_have = self->private_data.s_do_decode_image_config[0].v_checksum_have;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -39661,14 +40756,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_0 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 8;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -39694,14 +40789,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_1 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 8;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -39760,14 +40855,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -39792,14 +40887,12 @@ wuffs_png__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
|
||||
goto ok;
|
||||
}
|
||||
label__1__continue:;
|
||||
while (true) {
|
||||
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label__1__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
|
||||
@@ -39859,14 +40952,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_5 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_5 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -39916,15 +41009,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_decode_image_config[0].v_checksum_have = v_checksum_have;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_image_config[0].v_checksum_have = v_checksum_have;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -39932,9 +41024,6 @@ wuffs_png__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -40479,20 +41568,22 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
self->private_impl.f_seen_srgb = true;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1397641844) {
|
||||
if (self->private_impl.f_seen_trns || (self->private_impl.f_color_type > 3) || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) {
|
||||
if (self->private_impl.f_seen_trns || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) {
|
||||
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(9);
|
||||
status = wuffs_png__decoder__decode_trns(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 > 3) {
|
||||
} else {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_seen_trns = true;
|
||||
}
|
||||
@@ -41863,6 +42954,52 @@ wuffs_png__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_checksum_have = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -41876,7 +43013,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -41889,7 +43026,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_png__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -41940,14 +43077,14 @@ wuffs_png__decoder__decode_frame_config(
|
||||
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -41969,14 +43106,14 @@ wuffs_png__decoder__decode_frame_config(
|
||||
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -42003,14 +43140,14 @@ wuffs_png__decoder__decode_frame_config(
|
||||
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
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_decode_frame_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -42048,15 +43185,15 @@ wuffs_png__decoder__decode_frame_config(
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
self->private_data.s_decode_frame_config[0].scratch = 4;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame_config[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_decode_frame_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
goto label__0__break;
|
||||
}
|
||||
if (a_src) {
|
||||
@@ -42075,15 +43212,15 @@ wuffs_png__decoder__decode_frame_config(
|
||||
status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
|
||||
goto ok;
|
||||
}
|
||||
self->private_data.s_decode_frame_config[0].scratch = 4;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
||||
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame_config[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_decode_frame_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
self->private_impl.f_chunk_length = 0;
|
||||
}
|
||||
label__0__break:;
|
||||
@@ -42108,14 +43245,13 @@ wuffs_png__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -42123,9 +43259,6 @@ wuffs_png__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -42160,13 +43293,10 @@ wuffs_png__decoder__skip_frame(
|
||||
self->private_impl.f_chunk_type_array[3] = 0;
|
||||
label__0__continue:;
|
||||
while (true) {
|
||||
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
goto label__0__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
|
||||
@@ -42312,6 +43442,60 @@ wuffs_png__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_seq_num = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint32_t v_pass_width = 0;
|
||||
@@ -42328,7 +43512,7 @@ wuffs_png__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -42343,7 +43527,7 @@ wuffs_png__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_png__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -42351,14 +43535,12 @@ wuffs_png__decoder__decode_frame(
|
||||
goto suspend;
|
||||
}
|
||||
}
|
||||
label__0__continue:;
|
||||
while (true) {
|
||||
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
goto label__0__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
|
||||
@@ -42392,14 +43574,14 @@ wuffs_png__decoder__decode_frame(
|
||||
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_frame[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -42427,15 +43609,15 @@ wuffs_png__decoder__decode_frame(
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12);
|
||||
self->private_data.s_do_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
self->private_impl.f_chunk_length = 0;
|
||||
}
|
||||
label__0__break:;
|
||||
@@ -42493,14 +43675,12 @@ wuffs_png__decoder__decode_frame(
|
||||
wuffs_png__decoder__filter_and_swizzle(self, a_dst, wuffs_base__slice_u8__subslice_j(a_workbuf, self->private_impl.f_workbuf_wi));
|
||||
}
|
||||
if (v_status.repr == wuffs_base__suspension__short_read) {
|
||||
while (true) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
}
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
}
|
||||
label__1__break:;
|
||||
v_status = wuffs_png__decoder__filter_and_swizzle(self, a_dst, a_workbuf);
|
||||
@@ -42533,14 +43713,13 @@ wuffs_png__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -42548,9 +43727,6 @@ wuffs_png__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -42615,11 +43791,14 @@ wuffs_png__decoder__decode_pass(
|
||||
self->private_impl.f_pass_workbuf_length),
|
||||
((uint64_t)(self->private_impl.f_workbuf_hist_pos_base + self->private_impl.f_workbuf_wi)));
|
||||
{
|
||||
const bool o_1_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
@@ -42642,6 +43821,7 @@ wuffs_png__decoder__decode_pass(
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_workbuf_wi, wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w))));
|
||||
io2_a_src = o_1_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.closed = o_1_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43052,6 +44232,53 @@ wuffs_png__decoder__tell_me_more(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_tell_me_more
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_tell_me_more(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint16_t v_c2 = 0;
|
||||
wuffs_base__io_buffer u_w = wuffs_base__empty_io_buffer();
|
||||
@@ -43089,9 +44316,9 @@ wuffs_png__decoder__tell_me_more(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
|
||||
if (coro_susp_point) {
|
||||
v_zlib_status = self->private_data.s_tell_me_more[0].v_zlib_status;
|
||||
v_zlib_status = self->private_data.s_do_tell_me_more[0].v_zlib_status;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -43153,11 +44380,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_chunk_type == 1346585449) {
|
||||
{
|
||||
const bool o_0_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
@@ -43179,6 +44409,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
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.closed = o_0_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43199,11 +44430,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
{
|
||||
const bool o_1_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
@@ -43225,6 +44459,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
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.closed = o_1_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43260,11 +44495,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
|
||||
self->private_impl.f_ztxt_hist_pos);
|
||||
{
|
||||
const bool o_3_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
@@ -43284,6 +44522,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
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.closed = o_3_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43502,15 +44741,15 @@ wuffs_png__decoder__tell_me_more(
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_tell_me_more[0].scratch = 4;
|
||||
self->private_data.s_do_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));
|
||||
if (self->private_data.s_do_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_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;
|
||||
iop_a_src += self->private_data.s_do_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;
|
||||
@@ -43521,15 +44760,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
goto ok;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
self->private_impl.p_do_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
self->private_data.s_tell_me_more[0].v_zlib_status = v_zlib_status;
|
||||
self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_tell_me_more[0].v_zlib_status = v_zlib_status;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -43540,9 +44778,6 @@ wuffs_png__decoder__tell_me_more(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -43933,6 +45168,7 @@ wuffs_png__decoder__filter_and_swizzle_tricky(
|
||||
|
||||
const char wuffs_tga__error__bad_header[] = "#tga: bad header";
|
||||
const char wuffs_tga__error__bad_run_length_encoding[] = "#tga: bad run length encoding";
|
||||
const char wuffs_tga__error__truncated_input[] = "#tga: truncated input";
|
||||
const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA file";
|
||||
|
||||
// ---------------- Private Consts
|
||||
@@ -43941,6 +45177,27 @@ const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA fil
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_image_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__image_decoder__func_ptrs
|
||||
@@ -44086,6 +45343,52 @@ wuffs_tga__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func tga.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_image_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_c = 0;
|
||||
uint32_t v_c5 = 0;
|
||||
uint32_t v_i = 0;
|
||||
@@ -44101,9 +45404,9 @@ wuffs_tga__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_i = self->private_data.s_decode_image_config[0].v_i;
|
||||
v_i = self->private_data.s_do_decode_image_config[0].v_i;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -44160,14 +45463,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_3 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44189,14 +45492,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44237,15 +45540,15 @@ wuffs_tga__decoder__decode_image_config(
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = 4;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
uint32_t t_6;
|
||||
@@ -44253,14 +45556,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44282,14 +45585,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_7 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44369,15 +45672,15 @@ wuffs_tga__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_tga__error__unsupported_tga_file);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length));
|
||||
self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
if (self->private_impl.f_header_color_map_type != 0) {
|
||||
while (v_i < ((uint32_t)(self->private_impl.f_header_color_map_length))) {
|
||||
if (self->private_impl.f_header_color_map_entry_size == 24) {
|
||||
@@ -44388,14 +45691,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_10 = ((uint32_t)(wuffs_base__peek_u24le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 3;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(18);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44422,14 +45725,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(20);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44456,14 +45759,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_12 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(22);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44511,15 +45814,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_decode_image_config[0].v_i = v_i;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_image_config[0].v_i = v_i;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -44527,9 +45829,6 @@ wuffs_tga__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -44561,6 +45860,52 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func tga.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -44572,7 +45917,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -44582,7 +45927,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_tga__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_tga__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -44621,14 +45966,13 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -44636,9 +45980,6 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -44673,6 +46014,60 @@ wuffs_tga__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func tga.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
@@ -44705,16 +46100,16 @@ wuffs_tga__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
if (coro_susp_point) {
|
||||
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y;
|
||||
v_mark = self->private_data.s_decode_frame[0].v_mark;
|
||||
v_num_pixels32 = self->private_data.s_decode_frame[0].v_num_pixels32;
|
||||
v_lit_length = self->private_data.s_decode_frame[0].v_lit_length;
|
||||
v_run_length = self->private_data.s_decode_frame[0].v_run_length;
|
||||
v_num_dst_bytes = self->private_data.s_decode_frame[0].v_num_dst_bytes;
|
||||
v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
|
||||
v_mark = self->private_data.s_do_decode_frame[0].v_mark;
|
||||
v_num_pixels32 = self->private_data.s_do_decode_frame[0].v_num_pixels32;
|
||||
v_lit_length = self->private_data.s_do_decode_frame[0].v_lit_length;
|
||||
v_run_length = self->private_data.s_do_decode_frame[0].v_run_length;
|
||||
v_num_dst_bytes = self->private_data.s_do_decode_frame[0].v_num_dst_bytes;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -44725,7 +46120,7 @@ wuffs_tga__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_tga__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_tga__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -44788,15 +46183,15 @@ wuffs_tga__decoder__decode_frame(
|
||||
v_num_pixels32 = ((uint32_t)(wuffs_base__u64__min(v_num_pixels64, ((uint64_t)(v_lit_length)))));
|
||||
v_num_dst_bytes = (((uint64_t)(v_num_pixels32)) * v_dst_bytes_per_pixel);
|
||||
v_num_src_bytes = (v_num_pixels32 * self->private_impl.f_src_bytes_per_pixel);
|
||||
self->private_data.s_decode_frame[0].scratch = v_num_src_bytes;
|
||||
self->private_data.s_do_decode_frame[0].scratch = v_num_src_bytes;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, v_dst_palette, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_src - io0_a_src)), io0_a_src));
|
||||
if (v_num_dst_bytes <= ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_num_dst_bytes);
|
||||
@@ -44961,22 +46356,21 @@ wuffs_tga__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y;
|
||||
self->private_data.s_decode_frame[0].v_mark = v_mark;
|
||||
self->private_data.s_decode_frame[0].v_num_pixels32 = v_num_pixels32;
|
||||
self->private_data.s_decode_frame[0].v_lit_length = v_lit_length;
|
||||
self->private_data.s_decode_frame[0].v_run_length = v_run_length;
|
||||
self->private_data.s_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
|
||||
self->private_data.s_do_decode_frame[0].v_mark = v_mark;
|
||||
self->private_data.s_do_decode_frame[0].v_num_pixels32 = v_num_pixels32;
|
||||
self->private_data.s_do_decode_frame[0].v_lit_length = v_lit_length;
|
||||
self->private_data.s_do_decode_frame[0].v_run_length = v_run_length;
|
||||
self->private_data.s_do_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -44984,9 +46378,6 @@ wuffs_tga__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -45167,6 +46558,7 @@ wuffs_tga__decoder__workbuf_len(
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
|
||||
const char wuffs_wbmp__error__truncated_input[] = "#wbmp: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
@@ -45174,6 +46566,27 @@ const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_image_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__image_decoder__func_ptrs
|
||||
@@ -45319,6 +46732,52 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func wbmp.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_image_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint32_t v_i = 0;
|
||||
uint32_t v_x32 = 0;
|
||||
@@ -45335,10 +46794,10 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_i = self->private_data.s_decode_image_config[0].v_i;
|
||||
v_x32 = self->private_data.s_decode_image_config[0].v_x32;
|
||||
v_i = self->private_data.s_do_decode_image_config[0].v_i;
|
||||
v_x32 = self->private_data.s_do_decode_image_config[0].v_x32;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -45411,16 +46870,15 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_decode_image_config[0].v_i = v_i;
|
||||
self->private_data.s_decode_image_config[0].v_x32 = v_x32;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_image_config[0].v_i = v_i;
|
||||
self->private_data.s_do_decode_image_config[0].v_x32 = v_x32;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -45428,9 +46886,6 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -45462,6 +46917,52 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func wbmp.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -45473,7 +46974,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -45483,7 +46984,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_wbmp__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_wbmp__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -45522,14 +47023,13 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -45537,9 +47037,6 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -45574,6 +47071,60 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func wbmp.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
@@ -45597,13 +47148,13 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
if (coro_susp_point) {
|
||||
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y;
|
||||
memcpy(v_src, self->private_data.s_decode_frame[0].v_src, sizeof(v_src));
|
||||
v_c = self->private_data.s_decode_frame[0].v_c;
|
||||
v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
|
||||
memcpy(v_src, self->private_data.s_do_decode_frame[0].v_src, sizeof(v_src));
|
||||
v_c = self->private_data.s_do_decode_frame[0].v_c;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -45614,7 +47165,7 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_wbmp__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_wbmp__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -45686,19 +47237,18 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y;
|
||||
memcpy(self->private_data.s_decode_frame[0].v_src, v_src, sizeof(v_src));
|
||||
self->private_data.s_decode_frame[0].v_c = v_c;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
|
||||
memcpy(self->private_data.s_do_decode_frame[0].v_src, v_src, sizeof(v_src));
|
||||
self->private_data.s_do_decode_frame[0].v_c = v_c;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -45706,9 +47256,6 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
+2051
-504
@@ -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
|
||||
// b0e9efff3f44dc150edb22a27297bfef668035d2 committed on 2022-10-20.
|
||||
#define WUFFS_VERSION 0x000030000
|
||||
// a138188d5742c0469de983878a430bdbe7e50e77 committed on 2024-04-19.
|
||||
#define WUFFS_VERSION 0x000030004
|
||||
#define WUFFS_VERSION_MAJOR 0
|
||||
#define WUFFS_VERSION_MINOR 3
|
||||
#define WUFFS_VERSION_PATCH 0
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL "rc.2"
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3366
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20221020
|
||||
#define WUFFS_VERSION_STRING "0.3.0-rc.2+3366.20221020"
|
||||
#define WUFFS_VERSION_PATCH 4
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL ""
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3401
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20240419
|
||||
#define WUFFS_VERSION_STRING "0.3.4+3401.20240419"
|
||||
|
||||
// ---------------- Configuration
|
||||
|
||||
@@ -6345,6 +6345,8 @@ struct wuffs_base__token_decoder__struct {
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ADLER32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -6527,10 +6529,15 @@ struct wuffs_adler32__hasher__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ADLER32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_bmp__error__bad_header[];
|
||||
extern const char wuffs_bmp__error__bad_rle_compression[];
|
||||
extern const char wuffs_bmp__error__truncated_input[];
|
||||
extern const char wuffs_bmp__error__unsupported_bmp_file[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -6709,8 +6716,12 @@ struct wuffs_bmp__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
uint32_t p_tell_me_more[1];
|
||||
uint32_t p_read_palette[1];
|
||||
} private_impl;
|
||||
|
||||
@@ -6720,10 +6731,10 @@ struct wuffs_bmp__decoder__struct {
|
||||
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint64_t scratch;
|
||||
@@ -6875,6 +6886,10 @@ struct wuffs_bmp__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BZIP2) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_bzip2__error__bad_huffman_code_over_subscribed[];
|
||||
@@ -6884,6 +6899,7 @@ extern const char wuffs_bzip2__error__bad_block_length[];
|
||||
extern const char wuffs_bzip2__error__bad_checksum[];
|
||||
extern const char wuffs_bzip2__error__bad_header[];
|
||||
extern const char wuffs_bzip2__error__bad_number_of_sections[];
|
||||
extern const char wuffs_bzip2__error__truncated_input[];
|
||||
extern const char wuffs_bzip2__error__unsupported_block_randomization[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -7009,6 +7025,7 @@ struct wuffs_bzip2__decoder__struct {
|
||||
uint32_t f_code_lengths_bitmask;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
uint32_t p_prepare_block[1];
|
||||
uint32_t p_read_code_lengths[1];
|
||||
uint32_t p_flush_slow[1];
|
||||
@@ -7029,7 +7046,7 @@ struct wuffs_bzip2__decoder__struct {
|
||||
uint32_t v_i;
|
||||
uint64_t v_tag;
|
||||
uint32_t v_final_checksum_want;
|
||||
} s_transform_io[1];
|
||||
} s_do_transform_io[1];
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint32_t v_selector;
|
||||
@@ -7139,6 +7156,10 @@ struct wuffs_bzip2__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__BZIP2) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CBOR) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_cbor__error__bad_input[];
|
||||
@@ -7364,6 +7385,10 @@ struct wuffs_cbor__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CBOR) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CRC32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -7545,6 +7570,10 @@ struct wuffs_crc32__ieee_hasher__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__CRC32) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__DEFLATE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_deflate__error__bad_huffman_code_over_subscribed[];
|
||||
@@ -7560,6 +7589,7 @@ extern const char wuffs_deflate__error__bad_literal_length_code_count[];
|
||||
extern const char wuffs_deflate__error__inconsistent_stored_block_length[];
|
||||
extern const char wuffs_deflate__error__missing_end_of_block_code[];
|
||||
extern const char wuffs_deflate__error__no_huffman_codes[];
|
||||
extern const char wuffs_deflate__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -7674,6 +7704,7 @@ struct wuffs_deflate__decoder__struct {
|
||||
bool f_end_of_block;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
uint32_t p_decode_blocks[1];
|
||||
uint32_t p_decode_uncompressed[1];
|
||||
uint32_t p_init_dynamic_huffman[1];
|
||||
@@ -7815,9 +7846,14 @@ struct wuffs_deflate__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__DEFLATE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__LZW) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_lzw__error__bad_code[];
|
||||
extern const char wuffs_lzw__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -8050,6 +8086,10 @@ struct wuffs_lzw__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__LZW) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GIF) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_gif__error__bad_extension_label[];
|
||||
@@ -8058,6 +8098,7 @@ extern const char wuffs_gif__error__bad_graphic_control[];
|
||||
extern const char wuffs_gif__error__bad_header[];
|
||||
extern const char wuffs_gif__error__bad_literal_width[];
|
||||
extern const char wuffs_gif__error__bad_palette[];
|
||||
extern const char wuffs_gif__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -8258,10 +8299,14 @@ struct wuffs_gif__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_tell_me_more[1];
|
||||
uint32_t p_do_tell_me_more[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_skip_frame[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
uint32_t p_decode_up_to_id_part1[1];
|
||||
uint32_t p_decode_header[1];
|
||||
uint32_t p_decode_lsd[1];
|
||||
@@ -8282,7 +8327,7 @@ struct wuffs_gif__decoder__struct {
|
||||
|
||||
struct {
|
||||
uint32_t v_background_color;
|
||||
} s_decode_frame_config[1];
|
||||
} s_do_decode_frame_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_skip_frame[1];
|
||||
@@ -8472,12 +8517,17 @@ struct wuffs_gif__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GIF) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GZIP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_gzip__error__bad_checksum[];
|
||||
extern const char wuffs_gzip__error__bad_compression_method[];
|
||||
extern const char wuffs_gzip__error__bad_encoding_flags[];
|
||||
extern const char wuffs_gzip__error__bad_header[];
|
||||
extern const char wuffs_gzip__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -8582,6 +8632,7 @@ struct wuffs_gzip__decoder__struct {
|
||||
bool f_ignore_checksum;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
@@ -8594,7 +8645,7 @@ struct wuffs_gzip__decoder__struct {
|
||||
uint32_t v_decoded_length_got;
|
||||
uint32_t v_checksum_want;
|
||||
uint64_t scratch;
|
||||
} s_transform_io[1];
|
||||
} s_do_transform_io[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -8684,6 +8735,10 @@ struct wuffs_gzip__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__GZIP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JSON) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_json__error__bad_c0_control_code[];
|
||||
@@ -8952,9 +9007,14 @@ struct wuffs_json__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__JSON) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NIE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_nie__error__bad_header[];
|
||||
extern const char wuffs_nie__error__truncated_input[];
|
||||
extern const char wuffs_nie__error__unsupported_nie_file[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -9115,14 +9175,17 @@ struct wuffs_nie__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -9270,6 +9333,10 @@ struct wuffs_nie__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__NIE) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ZLIB) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_zlib__note__dictionary_required[];
|
||||
@@ -9278,6 +9345,7 @@ extern const char wuffs_zlib__error__bad_compression_method[];
|
||||
extern const char wuffs_zlib__error__bad_compression_window_size[];
|
||||
extern const char wuffs_zlib__error__bad_parity_check[];
|
||||
extern const char wuffs_zlib__error__incorrect_dictionary[];
|
||||
extern const char wuffs_zlib__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -9400,6 +9468,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
uint32_t f_dict_id_want;
|
||||
|
||||
uint32_t p_transform_io[1];
|
||||
uint32_t p_do_transform_io[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
@@ -9410,7 +9479,7 @@ struct wuffs_zlib__decoder__struct {
|
||||
struct {
|
||||
uint32_t v_checksum_got;
|
||||
uint64_t scratch;
|
||||
} s_transform_io[1];
|
||||
} s_do_transform_io[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -9511,6 +9580,10 @@ struct wuffs_zlib__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__ZLIB) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_png__error__bad_animation_sequence_number[];
|
||||
@@ -9520,6 +9593,7 @@ extern const char wuffs_png__error__bad_filter[];
|
||||
extern const char wuffs_png__error__bad_header[];
|
||||
extern const char wuffs_png__error__bad_text_chunk_not_latin_1[];
|
||||
extern const char wuffs_png__error__missing_palette[];
|
||||
extern const char wuffs_png__error__truncated_input[];
|
||||
extern const char wuffs_png__error__unsupported_cgbi_extension[];
|
||||
extern const char wuffs_png__error__unsupported_png_compression_method[];
|
||||
extern const char wuffs_png__error__unsupported_png_file[];
|
||||
@@ -9756,6 +9830,7 @@ struct wuffs_png__decoder__struct {
|
||||
wuffs_base__slice_u8 a_curr,
|
||||
wuffs_base__slice_u8 a_prev);
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_ihdr[1];
|
||||
uint32_t p_decode_other_chunk[1];
|
||||
uint32_t p_decode_actl[1];
|
||||
@@ -9767,10 +9842,13 @@ struct wuffs_png__decoder__struct {
|
||||
uint32_t p_decode_srgb[1];
|
||||
uint32_t p_decode_trns[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_skip_frame[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
uint32_t p_decode_pass[1];
|
||||
uint32_t p_tell_me_more[1];
|
||||
uint32_t p_do_tell_me_more[1];
|
||||
wuffs_base__status (*choosy_filter_and_swizzle)(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
@@ -9786,7 +9864,7 @@ struct wuffs_png__decoder__struct {
|
||||
struct {
|
||||
uint32_t v_checksum_have;
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_ihdr[1];
|
||||
@@ -9820,20 +9898,20 @@ struct wuffs_png__decoder__struct {
|
||||
} s_decode_trns[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_frame_config[1];
|
||||
} s_do_decode_frame_config[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_skip_frame[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
struct {
|
||||
uint64_t scratch;
|
||||
} s_decode_pass[1];
|
||||
struct {
|
||||
wuffs_base__status v_zlib_status;
|
||||
uint64_t scratch;
|
||||
} s_tell_me_more[1];
|
||||
} s_do_tell_me_more[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -9981,10 +10059,15 @@ struct wuffs_png__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__PNG) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_tga__error__bad_header[];
|
||||
extern const char wuffs_tga__error__bad_run_length_encoding[];
|
||||
extern const char wuffs_tga__error__truncated_input[];
|
||||
extern const char wuffs_tga__error__unsupported_tga_file[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -10155,8 +10238,11 @@ struct wuffs_tga__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
@@ -10167,7 +10253,7 @@ struct wuffs_tga__decoder__struct {
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint64_t scratch;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t v_dst_bytes_per_pixel;
|
||||
uint32_t v_dst_x;
|
||||
@@ -10178,7 +10264,7 @@ struct wuffs_tga__decoder__struct {
|
||||
uint32_t v_run_length;
|
||||
uint64_t v_num_dst_bytes;
|
||||
uint64_t scratch;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -10326,9 +10412,14 @@ struct wuffs_tga__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__TGA) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
// ---------------- Status Codes
|
||||
|
||||
extern const char wuffs_wbmp__error__bad_header[];
|
||||
extern const char wuffs_wbmp__error__truncated_input[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
|
||||
@@ -10486,22 +10577,25 @@ struct wuffs_wbmp__decoder__struct {
|
||||
wuffs_base__pixel_swizzler f_swizzler;
|
||||
|
||||
uint32_t p_decode_image_config[1];
|
||||
uint32_t p_do_decode_image_config[1];
|
||||
uint32_t p_decode_frame_config[1];
|
||||
uint32_t p_do_decode_frame_config[1];
|
||||
uint32_t p_decode_frame[1];
|
||||
uint32_t p_do_decode_frame[1];
|
||||
} private_impl;
|
||||
|
||||
struct {
|
||||
struct {
|
||||
uint32_t v_i;
|
||||
uint32_t v_x32;
|
||||
} s_decode_image_config[1];
|
||||
} s_do_decode_image_config[1];
|
||||
struct {
|
||||
uint64_t v_dst_bytes_per_pixel;
|
||||
uint32_t v_dst_x;
|
||||
uint32_t v_dst_y;
|
||||
uint8_t v_src[1];
|
||||
uint8_t v_c;
|
||||
} s_decode_frame[1];
|
||||
} s_do_decode_frame[1];
|
||||
} private_data;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -10649,6 +10743,8 @@ struct wuffs_wbmp__decoder__struct {
|
||||
|
||||
#endif // defined(__cplusplus) || defined(WUFFS_IMPLEMENTATION)
|
||||
|
||||
#endif // !defined(WUFFS_CONFIG__MODULES) || defined(WUFFS_CONFIG__MODULE__WBMP) || defined(WUFFS_NONMONOLITHIC)
|
||||
|
||||
#if defined(__cplusplus) && defined(WUFFS_BASE__HAVE_UNIQUE_PTR)
|
||||
|
||||
// ---------------- Auxiliary - Base
|
||||
@@ -14686,6 +14782,27 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
// powers converts decimal powers of 10 to binary powers of 2. For example,
|
||||
// (10000 >> 13) is 1. It stops before the elements exceed 60, also known
|
||||
// as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
|
||||
//
|
||||
// This rounds down (1<<13 is a lower bound for 1e4). Adding 1 to the array
|
||||
// element value rounds up (1<<14 is an upper bound for 1e4) while staying
|
||||
// at or below WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
|
||||
//
|
||||
// When starting in the range [1e+1 .. 1e+2] (i.e. h->decimal_point == +2),
|
||||
// powers[2] == 6 and so:
|
||||
// - Right shifting by 6+0 produces the range [10/64 .. 100/64] =
|
||||
// [0.156250 .. 1.56250]. The resultant h->decimal_point is +0 or +1.
|
||||
// - Right shifting by 6+1 produces the range [10/128 .. 100/128] =
|
||||
// [0.078125 .. 0.78125]. The resultant h->decimal_point is -1 or -0.
|
||||
//
|
||||
// When starting in the range [1e-3 .. 1e-2] (i.e. h->decimal_point == -2),
|
||||
// powers[2] == 6 and so:
|
||||
// - Left shifting by 6+0 produces the range [0.001*64 .. 0.01*64] =
|
||||
// [0.064 .. 0.64]. The resultant h->decimal_point is -1 or -0.
|
||||
// - Left shifting by 6+1 produces the range [0.001*128 .. 0.01*128] =
|
||||
// [0.128 .. 1.28]. The resultant h->decimal_point is +0 or +1.
|
||||
//
|
||||
// Thus, when targeting h->decimal_point being +0 or +1, use (powers[n]+0)
|
||||
// when right shifting but (powers[n]+1) when left shifting.
|
||||
static const uint32_t num_powers = 19;
|
||||
static const uint8_t powers[19] = {
|
||||
0, 3, 6, 9, 13, 16, 19, 23, 26, 29, //
|
||||
@@ -14705,36 +14822,54 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
// approach taken in wuffs_base__parse_number_f64. The latter is optimized
|
||||
// for the common cases (e.g. assuming no underscores or a leading '+'
|
||||
// sign) rather than the full set of cases allowed by the Wuffs API.
|
||||
if (h->num_digits <= 19) {
|
||||
//
|
||||
// When we have 19 or fewer mantissa digits, run Eisel-Lemire once (trying
|
||||
// for an exact result). When we have more than 19 mantissa digits, run it
|
||||
// twice to get a lower and upper bound. We still have an exact result
|
||||
// (within f64's rounding margin) if both bounds are equal (and valid).
|
||||
uint32_t i_max = h->num_digits;
|
||||
if (i_max > 19) {
|
||||
i_max = 19;
|
||||
}
|
||||
int32_t exp10 = h->decimal_point - ((int32_t)i_max);
|
||||
if ((-307 <= exp10) && (exp10 <= 288)) {
|
||||
uint64_t man = 0;
|
||||
uint32_t i;
|
||||
for (i = 0; i < h->num_digits; i++) {
|
||||
for (i = 0; i < i_max; i++) {
|
||||
man = (10 * man) + h->digits[i];
|
||||
}
|
||||
int32_t exp10 = h->decimal_point - ((int32_t)(h->num_digits));
|
||||
if ((man != 0) && (-307 <= exp10) && (exp10 <= 288)) {
|
||||
int64_t r =
|
||||
while (man != 0) { // The 'while' is just an 'if' that we can 'break'.
|
||||
int64_t r0 =
|
||||
wuffs_base__private_implementation__parse_number_f64_eisel_lemire(
|
||||
man, exp10);
|
||||
if (r >= 0) {
|
||||
wuffs_base__result_f64 ret;
|
||||
ret.status.repr = NULL;
|
||||
ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(
|
||||
((uint64_t)r) | (((uint64_t)(h->negative)) << 63));
|
||||
return ret;
|
||||
man + 0, exp10);
|
||||
if (r0 < 0) {
|
||||
break;
|
||||
} else if (h->num_digits > 19) {
|
||||
int64_t r1 =
|
||||
wuffs_base__private_implementation__parse_number_f64_eisel_lemire(
|
||||
man + 1, exp10);
|
||||
if (r1 != r0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
wuffs_base__result_f64 ret;
|
||||
ret.status.repr = NULL;
|
||||
ret.value = wuffs_base__ieee_754_bit_representation__from_u64_to_f64(
|
||||
((uint64_t)r0) | (((uint64_t)(h->negative)) << 63));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See
|
||||
// https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
|
||||
//
|
||||
// Scale by powers of 2 until we're in the range [½ .. 1], which gives us
|
||||
// our exponent (in base-2). First we shift right, possibly a little too
|
||||
// far, ending with a value certainly below 1 and possibly below ½...
|
||||
// Scale by powers of 2 until we're in the range [0.1 .. 10]. Equivalently,
|
||||
// that h->decimal_point is +0 or +1.
|
||||
//
|
||||
// First we shift right while at or above 10...
|
||||
const int32_t f64_bias = -1023;
|
||||
int32_t exp2 = 0;
|
||||
while (h->decimal_point > 0) {
|
||||
while (h->decimal_point > 1) {
|
||||
uint32_t n = (uint32_t)(+h->decimal_point);
|
||||
uint32_t shift =
|
||||
(n < num_powers)
|
||||
@@ -14748,20 +14883,15 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
}
|
||||
exp2 += (int32_t)shift;
|
||||
}
|
||||
// ...then we shift left, putting us in [½ .. 1].
|
||||
while (h->decimal_point <= 0) {
|
||||
// ...then we shift left while below 0.1.
|
||||
while (h->decimal_point < 0) {
|
||||
uint32_t shift;
|
||||
if (h->decimal_point == 0) {
|
||||
if (h->digits[0] >= 5) {
|
||||
break;
|
||||
}
|
||||
shift = (h->digits[0] < 2) ? 2 : 1;
|
||||
} else {
|
||||
uint32_t n = (uint32_t)(-h->decimal_point);
|
||||
shift = (n < num_powers)
|
||||
? powers[n]
|
||||
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
|
||||
}
|
||||
uint32_t n = (uint32_t)(-h->decimal_point);
|
||||
shift = (n < num_powers)
|
||||
// The +1 is per "when targeting h->decimal_point being +0 or
|
||||
// +1... when left shifting" in the powers comment above.
|
||||
? (powers[n] + 1)
|
||||
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
|
||||
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift);
|
||||
if (h->decimal_point >
|
||||
@@ -14771,8 +14901,37 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
exp2 -= (int32_t)shift;
|
||||
}
|
||||
|
||||
// We're in the range [½ .. 1] but f64 uses [1 .. 2].
|
||||
exp2--;
|
||||
// To get from "in the range [0.1 .. 10]" to "in the range [1 .. 2]" (which
|
||||
// will give us our exponent in base-2), the mantissa's first 3 digits will
|
||||
// determine the final left shift, equal to 52 (the number of explicit f64
|
||||
// bits) plus an additional adjustment.
|
||||
int man3 = (100 * h->digits[0]) +
|
||||
((h->num_digits > 1) ? (10 * h->digits[1]) : 0) +
|
||||
((h->num_digits > 2) ? h->digits[2] : 0);
|
||||
int32_t additional_lshift = 0;
|
||||
if (h->decimal_point == 0) { // The value is in [0.1 .. 1].
|
||||
if (man3 < 125) {
|
||||
additional_lshift = +4;
|
||||
} else if (man3 < 250) {
|
||||
additional_lshift = +3;
|
||||
} else if (man3 < 500) {
|
||||
additional_lshift = +2;
|
||||
} else {
|
||||
additional_lshift = +1;
|
||||
}
|
||||
} else { // The value is in [1 .. 10].
|
||||
if (man3 < 200) {
|
||||
additional_lshift = -0;
|
||||
} else if (man3 < 400) {
|
||||
additional_lshift = -1;
|
||||
} else if (man3 < 800) {
|
||||
additional_lshift = -2;
|
||||
} else {
|
||||
additional_lshift = -3;
|
||||
}
|
||||
}
|
||||
exp2 -= additional_lshift;
|
||||
uint32_t final_lshift = (uint32_t)(52 + additional_lshift);
|
||||
|
||||
// The minimum normal exponent is (f64_bias + 1).
|
||||
while ((f64_bias + 1) > exp2) {
|
||||
@@ -14790,7 +14949,8 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
|
||||
}
|
||||
|
||||
// Extract 53 bits for the mantissa (in base-2).
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, 53);
|
||||
wuffs_base__private_implementation__high_prec_dec__small_lshift(
|
||||
h, final_lshift);
|
||||
uint64_t man2 =
|
||||
wuffs_base__private_implementation__high_prec_dec__rounded_integer(h);
|
||||
|
||||
@@ -22473,6 +22633,7 @@ wuffs_adler32__hasher__up_x86_sse42(
|
||||
|
||||
const char wuffs_bmp__error__bad_header[] = "#bmp: bad header";
|
||||
const char wuffs_bmp__error__bad_rle_compression[] = "#bmp: bad RLE compression";
|
||||
const char wuffs_bmp__error__truncated_input[] = "#bmp: truncated input";
|
||||
const char wuffs_bmp__error__unsupported_bmp_file[] = "#bmp: unsupported BMP file";
|
||||
const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: short read";
|
||||
|
||||
@@ -22510,6 +22671,27 @@ const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: s
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_image_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__swizzle_none(
|
||||
wuffs_bmp__decoder* self,
|
||||
@@ -22534,6 +22716,13 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_tell_me_more(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__read_palette(
|
||||
wuffs_bmp__decoder* self,
|
||||
@@ -22688,6 +22877,52 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_image_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_magic = 0;
|
||||
uint32_t v_width = 0;
|
||||
uint32_t v_height = 0;
|
||||
@@ -22706,7 +22941,7 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -22724,14 +22959,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_0 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22750,15 +22985,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__bad_header);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = 8;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 8;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
uint32_t t_1;
|
||||
@@ -22766,14 +23001,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22801,14 +23036,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22836,14 +23071,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_3 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22865,14 +23100,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_4 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22894,14 +23129,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_5 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_5 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22927,14 +23162,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22957,14 +23192,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_7 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(17);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -22991,14 +23226,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(19);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23025,14 +23260,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_9 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(21);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23058,14 +23293,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_10 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(23);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23088,14 +23323,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(25);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23122,14 +23357,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_12 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(27);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23160,14 +23395,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_13 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(29);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_13 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23193,14 +23428,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_14 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(31);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_14 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23222,14 +23457,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_15 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(33);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_15 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23257,15 +23492,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = 20;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 20;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(34);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
if (self->private_impl.f_bitmap_info_len == 40) {
|
||||
if (self->private_impl.f_bits_per_pixel >= 16) {
|
||||
if (self->private_impl.f_padding >= 16) {
|
||||
@@ -23296,14 +23531,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_16 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(36);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_16 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23325,14 +23560,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_17 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(38);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_17 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23354,14 +23589,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_18 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(40);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_18 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23384,14 +23619,14 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
t_19 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(42);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_19 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -23406,15 +23641,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
}
|
||||
self->private_impl.f_channel_masks[3] = t_19;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56));
|
||||
self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(43);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
}
|
||||
if ((self->private_impl.f_channel_masks[0] == 255) && (self->private_impl.f_channel_masks[1] == 65280) && (self->private_impl.f_channel_masks[2] == 16711680)) {
|
||||
if (self->private_impl.f_bits_per_pixel == 24) {
|
||||
@@ -23432,15 +23667,15 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
}
|
||||
}
|
||||
} else if (self->private_impl.f_bitmap_info_len >= 40) {
|
||||
self->private_data.s_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40);
|
||||
self->private_data.s_do_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
} else {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
@@ -23563,14 +23798,13 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -23578,9 +23812,6 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -23612,6 +23843,52 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame_config(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -23623,7 +23900,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -23633,7 +23910,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_bmp__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_bmp__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -23672,14 +23949,13 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -23687,9 +23963,6 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -23726,6 +23999,60 @@ wuffs_bmp__decoder__decode_frame(
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_decode_frame(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
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;
|
||||
@@ -23737,7 +24064,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -23747,7 +24074,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_bmp__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_bmp__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -23758,15 +24085,15 @@ wuffs_bmp__decoder__decode_frame(
|
||||
status = wuffs_base__make_status(wuffs_base__note__end_of_data);
|
||||
goto ok;
|
||||
}
|
||||
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_padding;
|
||||
self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_padding;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
if ((self->private_impl.f_width > 0) && (self->private_impl.f_height > 0)) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
if (self->private_impl.f_top_down) {
|
||||
@@ -23842,28 +24169,27 @@ wuffs_bmp__decoder__decode_frame(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
|
||||
}
|
||||
label__0__break:;
|
||||
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_pending_pad;
|
||||
self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_pending_pad;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
self->private_impl.f_pending_pad = 0;
|
||||
}
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -23871,9 +24197,6 @@ wuffs_bmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -23890,10 +24213,12 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_row = 0;
|
||||
uint32_t v_src_bytes_per_pixel = 0;
|
||||
wuffs_base__slice_u8 v_dst_palette = {0};
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
uint64_t v_i = 0;
|
||||
uint64_t v_j = 0;
|
||||
uint64_t v_n = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -23927,7 +24252,6 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
self->private_impl.f_pending_pad -= 1;
|
||||
iop_a_src += 1;
|
||||
}
|
||||
label__inner__continue:;
|
||||
while (true) {
|
||||
if (self->private_impl.f_dst_x == self->private_impl.f_width) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
@@ -23948,14 +24272,38 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
goto label__inner__continue;
|
||||
if (self->private_impl.f_bits_per_pixel > 32) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
}
|
||||
v_src_bytes_per_pixel = (self->private_impl.f_bits_per_pixel / 8);
|
||||
if (v_src_bytes_per_pixel == 0) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||
goto exit;
|
||||
}
|
||||
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
|
||||
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
|
||||
v_j = v_n;
|
||||
while (v_j >= 8) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 8);
|
||||
}
|
||||
v_j -= 8;
|
||||
}
|
||||
while (v_j > 0) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 1);
|
||||
}
|
||||
v_j -= 1;
|
||||
}
|
||||
} else {
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
v_dst_palette,
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
}
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
v_dst_palette,
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
if (v_n == 0) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
|
||||
goto ok;
|
||||
@@ -24296,7 +24644,6 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
self->private_impl.f_pending_pad -= 1;
|
||||
iop_a_src += 1;
|
||||
}
|
||||
label__inner__continue:;
|
||||
while (true) {
|
||||
if (self->private_impl.f_dst_x == self->private_impl.f_width) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
@@ -24355,9 +24702,10 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
goto label__inner__continue;
|
||||
v_n = ((uint64_t)(v_p0));
|
||||
} else {
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
|
||||
}
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
|
||||
if (v_n == 0) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
|
||||
goto ok;
|
||||
@@ -24400,6 +24748,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
uint32_t v_p0 = 0;
|
||||
uint32_t v_chunk_bits = 0;
|
||||
uint32_t v_chunk_count = 0;
|
||||
uint32_t v_pixels_per_chunk = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -24437,6 +24786,35 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
if (self->private_impl.f_bits_per_pixel == 1) {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 31) / 32);
|
||||
v_pixels_per_chunk = 32;
|
||||
} else if (self->private_impl.f_bits_per_pixel == 2) {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 15) / 16);
|
||||
v_pixels_per_chunk = 16;
|
||||
} else {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
|
||||
v_pixels_per_chunk = 8;
|
||||
}
|
||||
while ((v_chunk_count >= 64) && (((uint64_t)(io2_a_src - iop_a_src)) >= 256)) {
|
||||
iop_a_src += 256;
|
||||
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 64))));
|
||||
v_chunk_count -= 64;
|
||||
}
|
||||
while ((v_chunk_count >= 8) && (((uint64_t)(io2_a_src - iop_a_src)) >= 32)) {
|
||||
iop_a_src += 32;
|
||||
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 8))));
|
||||
v_chunk_count -= 8;
|
||||
}
|
||||
while (v_chunk_count > 0) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
|
||||
goto ok;
|
||||
}
|
||||
iop_a_src += 4;
|
||||
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 1))));
|
||||
v_chunk_count -= 1;
|
||||
}
|
||||
goto label__loop__continue;
|
||||
}
|
||||
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_i);
|
||||
@@ -24507,7 +24885,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
v_p0 = ((v_p0 & 511) + 16);
|
||||
v_chunk_count -= 1;
|
||||
}
|
||||
} else if (self->private_impl.f_bits_per_pixel == 4) {
|
||||
} else {
|
||||
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
|
||||
v_chunk_count = wuffs_base__u32__min(v_chunk_count, 64);
|
||||
while ((v_chunk_count > 0) && (((uint64_t)(io2_a_src - iop_a_src)) >= 4)) {
|
||||
@@ -24688,6 +25066,53 @@ wuffs_bmp__decoder__tell_me_more(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bmp__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bmp.decoder.do_tell_me_more
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bmp__decoder__do_tell_me_more(
|
||||
wuffs_bmp__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
if (self->private_impl.f_io_redirect_fourcc <= 1) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__no_more_information);
|
||||
goto exit;
|
||||
@@ -24706,9 +25131,6 @@ wuffs_bmp__decoder__tell_me_more(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -24921,6 +25343,7 @@ const char wuffs_bzip2__error__bad_block_length[] = "#bzip2: bad block length";
|
||||
const char wuffs_bzip2__error__bad_checksum[] = "#bzip2: bad checksum";
|
||||
const char wuffs_bzip2__error__bad_header[] = "#bzip2: bad header";
|
||||
const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections";
|
||||
const char wuffs_bzip2__error__truncated_input[] = "#bzip2: truncated input";
|
||||
const char wuffs_bzip2__error__unsupported_block_randomization[] = "#bzip2: unsupported block randomization";
|
||||
const char wuffs_bzip2__error__internal_error_inconsistent_huffman_decoder_state[] = "#bzip2: internal error: inconsistent Huffman decoder state";
|
||||
|
||||
@@ -24971,6 +25394,13 @@ WUFFS_BZIP2__REV_CRC32_TABLE[256] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bzip2__decoder__do_transform_io(
|
||||
wuffs_bzip2__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bzip2__decoder__prepare_block(
|
||||
wuffs_bzip2__decoder* self,
|
||||
@@ -25165,6 +25595,53 @@ wuffs_bzip2__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_bzip2__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func bzip2.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_bzip2__decoder__do_transform_io(
|
||||
wuffs_bzip2__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint32_t v_i = 0;
|
||||
uint64_t v_tag = 0;
|
||||
@@ -25182,11 +25659,11 @@ wuffs_bzip2__decoder__transform_io(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
if (coro_susp_point) {
|
||||
v_i = self->private_data.s_transform_io[0].v_i;
|
||||
v_tag = self->private_data.s_transform_io[0].v_tag;
|
||||
v_final_checksum_want = self->private_data.s_transform_io[0].v_final_checksum_want;
|
||||
v_i = self->private_data.s_do_transform_io[0].v_i;
|
||||
v_tag = self->private_data.s_do_transform_io[0].v_tag;
|
||||
v_final_checksum_want = self->private_data.s_do_transform_io[0].v_final_checksum_want;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -25375,17 +25852,16 @@ wuffs_bzip2__decoder__transform_io(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_transform_io[0].v_i = v_i;
|
||||
self->private_data.s_transform_io[0].v_tag = v_tag;
|
||||
self->private_data.s_transform_io[0].v_final_checksum_want = v_final_checksum_want;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_transform_io[0].v_i = v_i;
|
||||
self->private_data.s_do_transform_io[0].v_tag = v_tag;
|
||||
self->private_data.s_do_transform_io[0].v_final_checksum_want = v_final_checksum_want;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -25393,9 +25869,6 @@ wuffs_bzip2__decoder__transform_io(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -28358,6 +28831,7 @@ const char wuffs_deflate__error__bad_literal_length_code_count[] = "#deflate: ba
|
||||
const char wuffs_deflate__error__inconsistent_stored_block_length[] = "#deflate: inconsistent stored block length";
|
||||
const char wuffs_deflate__error__missing_end_of_block_code[] = "#deflate: missing end-of-block code";
|
||||
const char wuffs_deflate__error__no_huffman_codes[] = "#deflate: no Huffman codes";
|
||||
const char wuffs_deflate__error__truncated_input[] = "#deflate: truncated input";
|
||||
const char wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state[] = "#deflate: internal error: inconsistent Huffman decoder state";
|
||||
const char wuffs_deflate__error__internal_error_inconsistent_i_o[] = "#deflate: internal error: inconsistent I/O";
|
||||
const char wuffs_deflate__error__internal_error_inconsistent_distance[] = "#deflate: internal error: inconsistent distance";
|
||||
@@ -28432,6 +28906,13 @@ WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[32] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_deflate__decoder__do_transform_io(
|
||||
wuffs_deflate__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_deflate__decoder__decode_blocks(
|
||||
wuffs_deflate__decoder* self,
|
||||
@@ -28675,6 +29156,53 @@ wuffs_deflate__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_deflate__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_deflate__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func deflate.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_deflate__decoder__do_transform_io(
|
||||
wuffs_deflate__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint64_t v_mark = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
@@ -28692,7 +29220,7 @@ wuffs_deflate__decoder__transform_io(
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -28730,14 +29258,13 @@ wuffs_deflate__decoder__transform_io(
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -28745,9 +29272,6 @@ wuffs_deflate__decoder__transform_io(
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -30621,6 +31145,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_lzw__error__bad_code[] = "#lzw: bad code";
|
||||
const char wuffs_lzw__error__truncated_input[] = "#lzw: truncated input";
|
||||
const char wuffs_lzw__error__internal_error_inconsistent_i_o[] = "#lzw: internal error: inconsistent I/O";
|
||||
|
||||
// ---------------- Private Consts
|
||||
@@ -30843,6 +31368,9 @@ wuffs_lzw__decoder__transform_io(
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_read_from_return_value == 3) {
|
||||
status = wuffs_base__make_status(wuffs_lzw__error__truncated_input);
|
||||
goto exit;
|
||||
} else if (self->private_impl.f_read_from_return_value == 4) {
|
||||
status = wuffs_base__make_status(wuffs_lzw__error__bad_code);
|
||||
goto exit;
|
||||
} else {
|
||||
@@ -30918,7 +31446,11 @@ wuffs_lzw__decoder__read_from(
|
||||
iop_a_src += ((31 - v_n_bits) >> 3);
|
||||
v_n_bits |= 24;
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
if (a_src && a_src->meta.closed) {
|
||||
self->private_impl.f_read_from_return_value = 3;
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
}
|
||||
goto label__0__break;
|
||||
} else {
|
||||
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
|
||||
@@ -30926,14 +31458,18 @@ wuffs_lzw__decoder__read_from(
|
||||
v_n_bits += 8;
|
||||
if (v_n_bits >= v_width) {
|
||||
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
if (a_src && a_src->meta.closed) {
|
||||
self->private_impl.f_read_from_return_value = 3;
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 2;
|
||||
}
|
||||
goto label__0__break;
|
||||
} else {
|
||||
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
|
||||
iop_a_src += 1;
|
||||
v_n_bits += 8;
|
||||
if (v_n_bits < v_width) {
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
self->private_impl.f_read_from_return_value = 5;
|
||||
goto label__0__break;
|
||||
}
|
||||
}
|
||||
@@ -31011,7 +31547,7 @@ wuffs_lzw__decoder__read_from(
|
||||
v_prev_code = v_code;
|
||||
}
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 3;
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
goto label__0__break;
|
||||
}
|
||||
if (v_output_wi > 4095) {
|
||||
@@ -31026,7 +31562,7 @@ wuffs_lzw__decoder__read_from(
|
||||
if (iop_a_src > io1_a_src) {
|
||||
iop_a_src--;
|
||||
} else {
|
||||
self->private_impl.f_read_from_return_value = 4;
|
||||
self->private_impl.f_read_from_return_value = 5;
|
||||
goto label__2__break;
|
||||
}
|
||||
}
|
||||
@@ -31148,6 +31684,7 @@ const char wuffs_gif__error__bad_graphic_control[] = "#gif: bad graphic control"
|
||||
const char wuffs_gif__error__bad_header[] = "#gif: bad header";
|
||||
const char wuffs_gif__error__bad_literal_width[] = "#gif: bad literal width";
|
||||
const char wuffs_gif__error__bad_palette[] = "#gif: bad palette";
|
||||
const char wuffs_gif__error__truncated_input[] = "#gif: truncated input";
|
||||
const char wuffs_gif__error__internal_error_inconsistent_ri_wi[] = "#gif: internal error: inconsistent ri/wi";
|
||||
|
||||
// ---------------- Private Consts
|
||||
@@ -31199,11 +31736,39 @@ WUFFS_GIF__XMPDATAXMP[11] WUFFS_BASE__POTENTIALLY_UNUSED = {
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_image_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_tell_me_more(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__skip_frame(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__empty_struct
|
||||
wuffs_gif__decoder__reset_gc(
|
||||
wuffs_gif__decoder* self);
|
||||
@@ -31433,12 +31998,58 @@ wuffs_gif__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
bool v_ffio = false;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_image_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
bool v_ffio = false;
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence != 0) {
|
||||
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
|
||||
goto exit;
|
||||
@@ -31489,20 +32100,16 @@ wuffs_gif__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -31557,6 +32164,53 @@ wuffs_gif__decoder__tell_me_more(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_tell_me_more
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_tell_me_more(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint64_t v_chunk_length = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -31570,7 +32224,7 @@ wuffs_gif__decoder__tell_me_more(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -31652,14 +32306,13 @@ wuffs_gif__decoder__tell_me_more(
|
||||
goto ok;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
self->private_impl.p_do_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -31667,9 +32320,6 @@ wuffs_gif__decoder__tell_me_more(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -31822,6 +32472,52 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame_config(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_background_color = 0;
|
||||
uint8_t v_flags = 0;
|
||||
|
||||
@@ -31836,9 +32532,9 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_background_color = self->private_data.s_decode_frame_config[0].v_background_color;
|
||||
v_background_color = self->private_data.s_do_decode_frame_config[0].v_background_color;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -31853,7 +32549,7 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_gif__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -31936,15 +32632,14 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_data.s_decode_frame_config[0].v_background_color = v_background_color;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_frame_config[0].v_background_color = v_background_color;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -31952,9 +32647,6 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -32086,14 +32778,68 @@ wuffs_gif__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gif.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gif__decoder__do_decode_frame(
|
||||
wuffs_gif__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 64) {
|
||||
} else if (self->private_impl.f_call_sequence < 64) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_gif__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_gif__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
@@ -32120,20 +32866,16 @@ wuffs_gif__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -33736,6 +34478,7 @@ const char wuffs_gzip__error__bad_checksum[] = "#gzip: bad checksum";
|
||||
const char wuffs_gzip__error__bad_compression_method[] = "#gzip: bad compression method";
|
||||
const char wuffs_gzip__error__bad_encoding_flags[] = "#gzip: bad encoding flags";
|
||||
const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
|
||||
const char wuffs_gzip__error__truncated_input[] = "#gzip: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
@@ -33743,6 +34486,13 @@ const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gzip__decoder__do_transform_io(
|
||||
wuffs_gzip__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__io_transformer__func_ptrs
|
||||
@@ -33907,6 +34657,53 @@ wuffs_gzip__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_gzip__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_gzip__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func gzip.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_gzip__decoder__do_transform_io(
|
||||
wuffs_gzip__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint8_t v_flags = 0;
|
||||
uint16_t v_xlen = 0;
|
||||
@@ -33941,12 +34738,12 @@ wuffs_gzip__decoder__transform_io(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
if (coro_susp_point) {
|
||||
v_flags = self->private_data.s_transform_io[0].v_flags;
|
||||
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got;
|
||||
v_decoded_length_got = self->private_data.s_transform_io[0].v_decoded_length_got;
|
||||
v_checksum_want = self->private_data.s_transform_io[0].v_checksum_want;
|
||||
v_flags = self->private_data.s_do_transform_io[0].v_flags;
|
||||
v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
|
||||
v_decoded_length_got = self->private_data.s_do_transform_io[0].v_decoded_length_got;
|
||||
v_checksum_want = self->private_data.s_do_transform_io[0].v_checksum_want;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -33999,15 +34796,15 @@ wuffs_gzip__decoder__transform_io(
|
||||
uint8_t t_3 = *iop_a_src++;
|
||||
v_flags = t_3;
|
||||
}
|
||||
self->private_data.s_transform_io[0].scratch = 6;
|
||||
self->private_data.s_do_transform_io[0].scratch = 6;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_transform_io[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_transform_io[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_transform_io[0].scratch;
|
||||
if ((v_flags & 4) != 0) {
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
@@ -34016,14 +34813,14 @@ wuffs_gzip__decoder__transform_io(
|
||||
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -34038,15 +34835,15 @@ wuffs_gzip__decoder__transform_io(
|
||||
}
|
||||
v_xlen = t_4;
|
||||
}
|
||||
self->private_data.s_transform_io[0].scratch = ((uint32_t)(v_xlen));
|
||||
self->private_data.s_do_transform_io[0].scratch = ((uint32_t)(v_xlen));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_transform_io[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_transform_io[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_transform_io[0].scratch;
|
||||
}
|
||||
if ((v_flags & 8) != 0) {
|
||||
while (true) {
|
||||
@@ -34083,15 +34880,15 @@ wuffs_gzip__decoder__transform_io(
|
||||
label__1__break:;
|
||||
}
|
||||
if ((v_flags & 2) != 0) {
|
||||
self->private_data.s_transform_io[0].scratch = 2;
|
||||
self->private_data.s_do_transform_io[0].scratch = 2;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_transform_io[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_transform_io[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_transform_io[0].scratch;
|
||||
}
|
||||
if ((v_flags & 224) != 0) {
|
||||
status = wuffs_base__make_status(wuffs_gzip__error__bad_encoding_flags);
|
||||
@@ -34133,14 +34930,14 @@ wuffs_gzip__decoder__transform_io(
|
||||
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
|
||||
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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -34162,14 +34959,14 @@ wuffs_gzip__decoder__transform_io(
|
||||
t_9 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
|
||||
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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -34190,18 +34987,17 @@ wuffs_gzip__decoder__transform_io(
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_transform_io[0].v_flags = v_flags;
|
||||
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
self->private_data.s_transform_io[0].v_decoded_length_got = v_decoded_length_got;
|
||||
self->private_data.s_transform_io[0].v_checksum_want = v_checksum_want;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_transform_io[0].v_flags = v_flags;
|
||||
self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
self->private_data.s_do_transform_io[0].v_decoded_length_got = v_decoded_length_got;
|
||||
self->private_data.s_do_transform_io[0].v_checksum_want = v_checksum_want;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -34212,9 +35008,6 @@ wuffs_gzip__decoder__transform_io(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -36432,6 +37225,7 @@ wuffs_json__decoder__decode_trailer(
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_nie__error__bad_header[] = "#nie: bad header";
|
||||
const char wuffs_nie__error__truncated_input[] = "#nie: truncated input";
|
||||
const char wuffs_nie__error__unsupported_nie_file[] = "#nie: unsupported NIE file";
|
||||
const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: short read";
|
||||
|
||||
@@ -36441,6 +37235,27 @@ const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: s
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_image_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__swizzle(
|
||||
wuffs_nie__decoder* self,
|
||||
@@ -36592,6 +37407,52 @@ wuffs_nie__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func nie.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_image_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_a = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -36605,7 +37466,7 @@ wuffs_nie__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -36620,14 +37481,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36653,14 +37514,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36696,14 +37557,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36730,14 +37591,14 @@ wuffs_nie__decoder__decode_image_config(
|
||||
t_3 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -36771,14 +37632,13 @@ wuffs_nie__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -36786,9 +37646,6 @@ wuffs_nie__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -36820,6 +37677,52 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func nie.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame_config(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -36831,7 +37734,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -36841,7 +37744,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_nie__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_nie__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -36880,14 +37783,13 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -36895,9 +37797,6 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -36938,10 +37837,64 @@ wuffs_nie__decoder__decode_frame(
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func nie.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_nie__decoder__do_decode_frame(
|
||||
wuffs_nie__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
if (self->private_impl.f_call_sequence == 64) {
|
||||
} else if (self->private_impl.f_call_sequence < 64) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_nie__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_nie__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
@@ -36988,20 +37941,16 @@ wuffs_nie__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -37018,9 +37967,11 @@ wuffs_nie__decoder__swizzle(
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_pixel = 0;
|
||||
uint64_t v_dst_bytes_per_row = 0;
|
||||
uint32_t v_src_bytes_per_pixel = 0;
|
||||
wuffs_base__table_u8 v_tab = {0};
|
||||
wuffs_base__slice_u8 v_dst = {0};
|
||||
uint64_t v_i = 0;
|
||||
uint64_t v_j = 0;
|
||||
uint64_t v_n = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -37043,7 +37994,6 @@ wuffs_nie__decoder__swizzle(
|
||||
v_dst_bytes_per_pixel = ((uint64_t)((v_dst_bits_per_pixel / 8)));
|
||||
v_dst_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * v_dst_bytes_per_pixel);
|
||||
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0);
|
||||
label__0__continue:;
|
||||
while (true) {
|
||||
if (self->private_impl.f_dst_x == self->private_impl.f_width) {
|
||||
self->private_impl.f_dst_x = 0;
|
||||
@@ -37058,14 +38008,33 @@ wuffs_nie__decoder__swizzle(
|
||||
}
|
||||
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
|
||||
if (v_i >= ((uint64_t)(v_dst.len))) {
|
||||
goto label__0__continue;
|
||||
v_src_bytes_per_pixel = 4;
|
||||
if (self->private_impl.f_pixfmt == 2164308923) {
|
||||
v_src_bytes_per_pixel = 8;
|
||||
}
|
||||
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
|
||||
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
|
||||
v_j = v_n;
|
||||
while (v_j >= 8) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 8);
|
||||
}
|
||||
v_j -= 8;
|
||||
}
|
||||
while (v_j > 0) {
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
|
||||
iop_a_src += (v_src_bytes_per_pixel * 1);
|
||||
}
|
||||
v_j -= 1;
|
||||
}
|
||||
} else {
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
wuffs_base__pixel_buffer__palette(a_dst),
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
}
|
||||
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
|
||||
&self->private_impl.f_swizzler,
|
||||
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
|
||||
wuffs_base__pixel_buffer__palette(a_dst),
|
||||
&iop_a_src,
|
||||
io2_a_src);
|
||||
if (v_n == 0) {
|
||||
status = wuffs_base__make_status(wuffs_nie__note__internal_note_short_read);
|
||||
goto ok;
|
||||
@@ -37267,6 +38236,7 @@ const char wuffs_zlib__error__bad_compression_method[] = "#zlib: bad compression
|
||||
const char wuffs_zlib__error__bad_compression_window_size[] = "#zlib: bad compression window size";
|
||||
const char wuffs_zlib__error__bad_parity_check[] = "#zlib: bad parity check";
|
||||
const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect dictionary";
|
||||
const char wuffs_zlib__error__truncated_input[] = "#zlib: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
@@ -37278,6 +38248,13 @@ const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect diction
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_zlib__decoder__do_transform_io(
|
||||
wuffs_zlib__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__io_transformer__func_ptrs
|
||||
@@ -37495,6 +38472,53 @@ wuffs_zlib__decoder__transform_io(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_zlib__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_zlib__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func zlib.decoder.do_transform_io
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_zlib__decoder__do_transform_io(
|
||||
wuffs_zlib__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint16_t v_x = 0;
|
||||
uint32_t v_checksum_got = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
@@ -37525,9 +38549,9 @@ wuffs_zlib__decoder__transform_io(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
|
||||
if (coro_susp_point) {
|
||||
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got;
|
||||
v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -37544,14 +38568,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
t_0 = wuffs_base__peek_u16be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -37588,14 +38612,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_transform_io[0].scratch = 0;
|
||||
self->private_data.s_do_transform_io[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -37661,14 +38685,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
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;
|
||||
self->private_data.s_do_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;
|
||||
uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -37690,15 +38714,14 @@ wuffs_zlib__decoder__transform_io(
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_transform_io[0] = 0;
|
||||
self->private_impl.p_do_transform_io[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -37709,9 +38732,6 @@ wuffs_zlib__decoder__transform_io(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -37728,6 +38748,7 @@ const char wuffs_png__error__bad_filter[] = "#png: bad filter";
|
||||
const char wuffs_png__error__bad_header[] = "#png: bad header";
|
||||
const char wuffs_png__error__bad_text_chunk_not_latin_1[] = "#png: bad text chunk (not Latin-1)";
|
||||
const char wuffs_png__error__missing_palette[] = "#png: missing palette";
|
||||
const char wuffs_png__error__truncated_input[] = "#png: truncated input";
|
||||
const char wuffs_png__error__unsupported_cgbi_extension[] = "#png: unsupported CgBI extension";
|
||||
const char wuffs_png__error__unsupported_png_compression_method[] = "#png: unsupported PNG compression method";
|
||||
const char wuffs_png__error__unsupported_png_file[] = "#png: unsupported PNG file";
|
||||
@@ -37953,6 +38974,12 @@ wuffs_png__decoder__filter_4_distance_4_x86_sse42(
|
||||
wuffs_base__slice_u8 a_prev);
|
||||
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_image_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_ihdr(
|
||||
wuffs_png__decoder* self,
|
||||
@@ -38022,17 +39049,39 @@ wuffs_png__decoder__decode_trns(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__skip_frame(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__decode_pass(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__slice_u8 a_workbuf);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_tell_me_more(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__filter_and_swizzle(
|
||||
wuffs_png__decoder* self,
|
||||
@@ -39627,6 +40676,52 @@ wuffs_png__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_image_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint64_t v_magic = 0;
|
||||
uint64_t v_mark = 0;
|
||||
uint32_t v_checksum_have = 0;
|
||||
@@ -39644,9 +40739,9 @@ wuffs_png__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_checksum_have = self->private_data.s_decode_image_config[0].v_checksum_have;
|
||||
v_checksum_have = self->private_data.s_do_decode_image_config[0].v_checksum_have;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -39662,14 +40757,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_0 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 8;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -39695,14 +40790,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_1 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 8;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -39761,14 +40856,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -39793,14 +40888,12 @@ wuffs_png__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
|
||||
goto ok;
|
||||
}
|
||||
label__1__continue:;
|
||||
while (true) {
|
||||
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
|
||||
goto label__1__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
|
||||
@@ -39860,14 +40953,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
t_5 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_5 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -39917,15 +41010,14 @@ wuffs_png__decoder__decode_image_config(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_decode_image_config[0].v_checksum_have = v_checksum_have;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_image_config[0].v_checksum_have = v_checksum_have;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -39933,9 +41025,6 @@ wuffs_png__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -40480,20 +41569,22 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
self->private_impl.f_seen_srgb = true;
|
||||
}
|
||||
} else if (self->private_impl.f_chunk_type == 1397641844) {
|
||||
if (self->private_impl.f_seen_trns || (self->private_impl.f_color_type > 3) || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) {
|
||||
if (self->private_impl.f_seen_trns || ((self->private_impl.f_color_type == 3) && ! self->private_impl.f_seen_plte)) {
|
||||
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(9);
|
||||
status = wuffs_png__decoder__decode_trns(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 > 3) {
|
||||
} else {
|
||||
if (a_src) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
}
|
||||
self->private_impl.f_seen_trns = true;
|
||||
}
|
||||
@@ -41864,6 +42955,52 @@ wuffs_png__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame_config(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_checksum_have = 0;
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
@@ -41877,7 +43014,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -41890,7 +43027,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_png__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -41941,14 +43078,14 @@ wuffs_png__decoder__decode_frame_config(
|
||||
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -41970,14 +43107,14 @@ wuffs_png__decoder__decode_frame_config(
|
||||
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -42004,14 +43141,14 @@ wuffs_png__decoder__decode_frame_config(
|
||||
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||
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_decode_frame_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -42049,15 +43186,15 @@ wuffs_png__decoder__decode_frame_config(
|
||||
if (status.repr) {
|
||||
goto suspend;
|
||||
}
|
||||
self->private_data.s_decode_frame_config[0].scratch = 4;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame_config[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_decode_frame_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
goto label__0__break;
|
||||
}
|
||||
if (a_src) {
|
||||
@@ -42076,15 +43213,15 @@ wuffs_png__decoder__decode_frame_config(
|
||||
status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
|
||||
goto ok;
|
||||
}
|
||||
self->private_data.s_decode_frame_config[0].scratch = 4;
|
||||
self->private_data.s_do_decode_frame_config[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
|
||||
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame_config[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_decode_frame_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
|
||||
self->private_impl.f_chunk_length = 0;
|
||||
}
|
||||
label__0__break:;
|
||||
@@ -42109,14 +43246,13 @@ wuffs_png__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -42124,9 +43260,6 @@ wuffs_png__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -42161,13 +43294,10 @@ wuffs_png__decoder__skip_frame(
|
||||
self->private_impl.f_chunk_type_array[3] = 0;
|
||||
label__0__continue:;
|
||||
while (true) {
|
||||
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
goto label__0__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
|
||||
@@ -42313,6 +43443,60 @@ wuffs_png__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_decode_frame(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_seq_num = 0;
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
uint32_t v_pass_width = 0;
|
||||
@@ -42329,7 +43513,7 @@ wuffs_png__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -42344,7 +43528,7 @@ wuffs_png__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_png__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_png__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -42352,14 +43536,12 @@ wuffs_png__decoder__decode_frame(
|
||||
goto suspend;
|
||||
}
|
||||
}
|
||||
label__0__continue:;
|
||||
while (true) {
|
||||
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
if (a_src && a_src->meta.closed) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
goto label__0__continue;
|
||||
}
|
||||
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
|
||||
@@ -42393,14 +43575,14 @@ wuffs_png__decoder__decode_frame(
|
||||
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_frame[0].scratch = 0;
|
||||
self->private_data.s_do_decode_frame[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
|
||||
while (true) {
|
||||
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
goto suspend;
|
||||
}
|
||||
uint64_t* scratch = &self->private_data.s_decode_frame[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_frame[0].scratch;
|
||||
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
|
||||
*scratch >>= 8;
|
||||
*scratch <<= 8;
|
||||
@@ -42428,15 +43610,15 @@ wuffs_png__decoder__decode_frame(
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12);
|
||||
self->private_data.s_do_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
self->private_impl.f_chunk_length = 0;
|
||||
}
|
||||
label__0__break:;
|
||||
@@ -42494,14 +43676,12 @@ wuffs_png__decoder__decode_frame(
|
||||
wuffs_png__decoder__filter_and_swizzle(self, a_dst, wuffs_base__slice_u8__subslice_j(a_workbuf, self->private_impl.f_workbuf_wi));
|
||||
}
|
||||
if (v_status.repr == wuffs_base__suspension__short_read) {
|
||||
while (true) {
|
||||
status = wuffs_base__make_status(wuffs_base__suspension__short_read);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
}
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7);
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
|
||||
}
|
||||
label__1__break:;
|
||||
v_status = wuffs_png__decoder__filter_and_swizzle(self, a_dst, a_workbuf);
|
||||
@@ -42534,14 +43714,13 @@ wuffs_png__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 32;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -42549,9 +43728,6 @@ wuffs_png__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -42616,11 +43792,14 @@ wuffs_png__decoder__decode_pass(
|
||||
self->private_impl.f_pass_workbuf_length),
|
||||
((uint64_t)(self->private_impl.f_workbuf_hist_pos_base + self->private_impl.f_workbuf_wi)));
|
||||
{
|
||||
const bool o_1_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
@@ -42643,6 +43822,7 @@ wuffs_png__decoder__decode_pass(
|
||||
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_workbuf_wi, wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w))));
|
||||
io2_a_src = o_1_io2_a_src;
|
||||
if (a_src) {
|
||||
a_src->meta.closed = o_1_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43053,6 +44233,53 @@ wuffs_png__decoder__tell_me_more(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_png__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func png.decoder.do_tell_me_more
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_png__decoder__do_tell_me_more(
|
||||
wuffs_png__decoder* self,
|
||||
wuffs_base__io_buffer* a_dst,
|
||||
wuffs_base__more_information* a_minfo,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint16_t v_c2 = 0;
|
||||
wuffs_base__io_buffer u_w = wuffs_base__empty_io_buffer();
|
||||
@@ -43090,9 +44317,9 @@ wuffs_png__decoder__tell_me_more(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
|
||||
if (coro_susp_point) {
|
||||
v_zlib_status = self->private_data.s_tell_me_more[0].v_zlib_status;
|
||||
v_zlib_status = self->private_data.s_do_tell_me_more[0].v_zlib_status;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -43154,11 +44381,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
if (self->private_impl.f_metadata_is_zlib_compressed) {
|
||||
if (self->private_impl.f_chunk_type == 1346585449) {
|
||||
{
|
||||
const bool o_0_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
@@ -43180,6 +44410,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
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.closed = o_0_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43200,11 +44431,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
|
||||
} else if (self->private_impl.f_chunk_type == 1951945833) {
|
||||
{
|
||||
const bool o_1_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
{
|
||||
@@ -43226,6 +44460,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
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.closed = o_1_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43261,11 +44496,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
|
||||
self->private_impl.f_ztxt_hist_pos);
|
||||
{
|
||||
const bool o_3_closed_a_src = a_src->meta.closed;
|
||||
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));
|
||||
size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
|
||||
a_src->meta.wi = n;
|
||||
}
|
||||
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
|
||||
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
|
||||
@@ -43285,6 +44523,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
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.closed = o_3_closed_a_src;
|
||||
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
|
||||
}
|
||||
}
|
||||
@@ -43503,15 +44742,15 @@ wuffs_png__decoder__tell_me_more(
|
||||
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_tell_me_more[0].scratch = 4;
|
||||
self->private_data.s_do_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));
|
||||
if (self->private_data.s_do_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_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;
|
||||
iop_a_src += self->private_data.s_do_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;
|
||||
@@ -43522,15 +44761,14 @@ wuffs_png__decoder__tell_me_more(
|
||||
goto ok;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_tell_me_more[0] = 0;
|
||||
self->private_impl.p_do_tell_me_more[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
|
||||
self->private_data.s_tell_me_more[0].v_zlib_status = v_zlib_status;
|
||||
self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_tell_me_more[0].v_zlib_status = v_zlib_status;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -43541,9 +44779,6 @@ wuffs_png__decoder__tell_me_more(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -43934,6 +45169,7 @@ wuffs_png__decoder__filter_and_swizzle_tricky(
|
||||
|
||||
const char wuffs_tga__error__bad_header[] = "#tga: bad header";
|
||||
const char wuffs_tga__error__bad_run_length_encoding[] = "#tga: bad run length encoding";
|
||||
const char wuffs_tga__error__truncated_input[] = "#tga: truncated input";
|
||||
const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA file";
|
||||
|
||||
// ---------------- Private Consts
|
||||
@@ -43942,6 +45178,27 @@ const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA fil
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_image_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__image_decoder__func_ptrs
|
||||
@@ -44087,6 +45344,52 @@ wuffs_tga__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func tga.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_image_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t v_c = 0;
|
||||
uint32_t v_c5 = 0;
|
||||
uint32_t v_i = 0;
|
||||
@@ -44102,9 +45405,9 @@ wuffs_tga__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_i = self->private_data.s_decode_image_config[0].v_i;
|
||||
v_i = self->private_data.s_do_decode_image_config[0].v_i;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -44161,14 +45464,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_3 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44190,14 +45493,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44238,15 +45541,15 @@ wuffs_tga__decoder__decode_image_config(
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = 4;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 4;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
{
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
|
||||
uint32_t t_6;
|
||||
@@ -44254,14 +45557,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44283,14 +45586,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_7 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44370,15 +45673,15 @@ wuffs_tga__decoder__decode_image_config(
|
||||
status = wuffs_base__make_status(wuffs_tga__error__unsupported_tga_file);
|
||||
goto exit;
|
||||
}
|
||||
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length));
|
||||
self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length));
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
|
||||
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_image_config[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_decode_image_config[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
|
||||
if (self->private_impl.f_header_color_map_type != 0) {
|
||||
while (v_i < ((uint32_t)(self->private_impl.f_header_color_map_length))) {
|
||||
if (self->private_impl.f_header_color_map_entry_size == 24) {
|
||||
@@ -44389,14 +45692,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_10 = ((uint32_t)(wuffs_base__peek_u24le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 3;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(18);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44423,14 +45726,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
|
||||
iop_a_src += 4;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(20);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44457,14 +45760,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
t_12 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
|
||||
iop_a_src += 2;
|
||||
} else {
|
||||
self->private_data.s_decode_image_config[0].scratch = 0;
|
||||
self->private_data.s_do_decode_image_config[0].scratch = 0;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(22);
|
||||
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_decode_image_config[0].scratch;
|
||||
uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
|
||||
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
|
||||
*scratch <<= 8;
|
||||
*scratch >>= 8;
|
||||
@@ -44512,15 +45815,14 @@ wuffs_tga__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_decode_image_config[0].v_i = v_i;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_image_config[0].v_i = v_i;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -44528,9 +45830,6 @@ wuffs_tga__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -44562,6 +45861,52 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func tga.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame_config(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -44573,7 +45918,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -44583,7 +45928,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_tga__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_tga__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -44622,14 +45967,13 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -44637,9 +45981,6 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -44674,6 +46015,60 @@ wuffs_tga__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func tga.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_tga__decoder__do_decode_frame(
|
||||
wuffs_tga__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
@@ -44706,16 +46101,16 @@ wuffs_tga__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
if (coro_susp_point) {
|
||||
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y;
|
||||
v_mark = self->private_data.s_decode_frame[0].v_mark;
|
||||
v_num_pixels32 = self->private_data.s_decode_frame[0].v_num_pixels32;
|
||||
v_lit_length = self->private_data.s_decode_frame[0].v_lit_length;
|
||||
v_run_length = self->private_data.s_decode_frame[0].v_run_length;
|
||||
v_num_dst_bytes = self->private_data.s_decode_frame[0].v_num_dst_bytes;
|
||||
v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
|
||||
v_mark = self->private_data.s_do_decode_frame[0].v_mark;
|
||||
v_num_pixels32 = self->private_data.s_do_decode_frame[0].v_num_pixels32;
|
||||
v_lit_length = self->private_data.s_do_decode_frame[0].v_lit_length;
|
||||
v_run_length = self->private_data.s_do_decode_frame[0].v_run_length;
|
||||
v_num_dst_bytes = self->private_data.s_do_decode_frame[0].v_num_dst_bytes;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -44726,7 +46121,7 @@ wuffs_tga__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_tga__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_tga__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -44789,15 +46184,15 @@ wuffs_tga__decoder__decode_frame(
|
||||
v_num_pixels32 = ((uint32_t)(wuffs_base__u64__min(v_num_pixels64, ((uint64_t)(v_lit_length)))));
|
||||
v_num_dst_bytes = (((uint64_t)(v_num_pixels32)) * v_dst_bytes_per_pixel);
|
||||
v_num_src_bytes = (v_num_pixels32 * self->private_impl.f_src_bytes_per_pixel);
|
||||
self->private_data.s_decode_frame[0].scratch = v_num_src_bytes;
|
||||
self->private_data.s_do_decode_frame[0].scratch = v_num_src_bytes;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
|
||||
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
|
||||
if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
|
||||
self->private_data.s_do_decode_frame[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_decode_frame[0].scratch;
|
||||
iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
|
||||
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, v_dst_palette, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_src - io0_a_src)), io0_a_src));
|
||||
if (v_num_dst_bytes <= ((uint64_t)(v_dst.len))) {
|
||||
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_num_dst_bytes);
|
||||
@@ -44962,22 +46357,21 @@ wuffs_tga__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y;
|
||||
self->private_data.s_decode_frame[0].v_mark = v_mark;
|
||||
self->private_data.s_decode_frame[0].v_num_pixels32 = v_num_pixels32;
|
||||
self->private_data.s_decode_frame[0].v_lit_length = v_lit_length;
|
||||
self->private_data.s_decode_frame[0].v_run_length = v_run_length;
|
||||
self->private_data.s_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
|
||||
self->private_data.s_do_decode_frame[0].v_mark = v_mark;
|
||||
self->private_data.s_do_decode_frame[0].v_num_pixels32 = v_num_pixels32;
|
||||
self->private_data.s_do_decode_frame[0].v_lit_length = v_lit_length;
|
||||
self->private_data.s_do_decode_frame[0].v_run_length = v_run_length;
|
||||
self->private_data.s_do_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -44985,9 +46379,6 @@ wuffs_tga__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -45168,6 +46559,7 @@ wuffs_tga__decoder__workbuf_len(
|
||||
// ---------------- Status Codes Implementations
|
||||
|
||||
const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
|
||||
const char wuffs_wbmp__error__truncated_input[] = "#wbmp: truncated input";
|
||||
|
||||
// ---------------- Private Consts
|
||||
|
||||
@@ -45175,6 +46567,27 @@ const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
|
||||
|
||||
// ---------------- Private Function Prototypes
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_image_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src);
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts);
|
||||
|
||||
// ---------------- VTables
|
||||
|
||||
const wuffs_base__image_decoder__func_ptrs
|
||||
@@ -45320,6 +46733,52 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_image_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func wbmp.decoder.do_decode_image_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_image_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__image_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint8_t v_c = 0;
|
||||
uint32_t v_i = 0;
|
||||
uint32_t v_x32 = 0;
|
||||
@@ -45336,10 +46795,10 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
|
||||
if (coro_susp_point) {
|
||||
v_i = self->private_data.s_decode_image_config[0].v_i;
|
||||
v_x32 = self->private_data.s_decode_image_config[0].v_x32;
|
||||
v_i = self->private_data.s_do_decode_image_config[0].v_i;
|
||||
v_x32 = self->private_data.s_do_decode_image_config[0].v_x32;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -45412,16 +46871,15 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
|
||||
goto ok;
|
||||
ok:
|
||||
self->private_impl.p_decode_image_config[0] = 0;
|
||||
self->private_impl.p_do_decode_image_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
|
||||
self->private_data.s_decode_image_config[0].v_i = v_i;
|
||||
self->private_data.s_decode_image_config[0].v_x32 = v_x32;
|
||||
self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_image_config[0].v_i = v_i;
|
||||
self->private_data.s_do_decode_image_config[0].v_x32 = v_x32;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -45429,9 +46887,6 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -45463,6 +46918,52 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame_config(self, a_dst, a_src);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func wbmp.decoder.do_decode_frame_config
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame_config(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__frame_config* a_dst,
|
||||
wuffs_base__io_buffer* a_src) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
const uint8_t* iop_a_src = NULL;
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
@@ -45474,7 +46975,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
@@ -45484,7 +46985,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_wbmp__decoder__decode_image_config(self, NULL, a_src);
|
||||
status = wuffs_wbmp__decoder__do_decode_image_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -45523,14 +47024,13 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
self->private_impl.f_call_sequence = 64;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame_config[0] = 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
|
||||
self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -45538,9 +47038,6 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -45575,6 +47072,60 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
self->private_impl.active_coroutine = 0;
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
|
||||
while (true) {
|
||||
{
|
||||
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame(self,
|
||||
a_dst,
|
||||
a_src,
|
||||
a_blend,
|
||||
a_workbuf,
|
||||
a_opts);
|
||||
v_status = t_0;
|
||||
}
|
||||
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
|
||||
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
|
||||
goto exit;
|
||||
}
|
||||
status = v_status;
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
|
||||
}
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
// -------- func wbmp.decoder.do_decode_frame
|
||||
|
||||
static wuffs_base__status
|
||||
wuffs_wbmp__decoder__do_decode_frame(
|
||||
wuffs_wbmp__decoder* self,
|
||||
wuffs_base__pixel_buffer* a_dst,
|
||||
wuffs_base__io_buffer* a_src,
|
||||
wuffs_base__pixel_blend a_blend,
|
||||
wuffs_base__slice_u8 a_workbuf,
|
||||
wuffs_base__decode_frame_options* a_opts) {
|
||||
wuffs_base__status status = wuffs_base__make_status(NULL);
|
||||
|
||||
wuffs_base__status v_status = wuffs_base__make_status(NULL);
|
||||
wuffs_base__pixel_format v_dst_pixfmt = {0};
|
||||
uint32_t v_dst_bits_per_pixel = 0;
|
||||
@@ -45598,13 +47149,13 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
io2_a_src = io0_a_src + a_src->meta.wi;
|
||||
}
|
||||
|
||||
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
|
||||
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
|
||||
if (coro_susp_point) {
|
||||
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y;
|
||||
memcpy(v_src, self->private_data.s_decode_frame[0].v_src, sizeof(v_src));
|
||||
v_c = self->private_data.s_decode_frame[0].v_c;
|
||||
v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
|
||||
v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
|
||||
v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
|
||||
memcpy(v_src, self->private_data.s_do_decode_frame[0].v_src, sizeof(v_src));
|
||||
v_c = self->private_data.s_do_decode_frame[0].v_c;
|
||||
}
|
||||
switch (coro_susp_point) {
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||
@@ -45615,7 +47166,7 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||
status = wuffs_wbmp__decoder__decode_frame_config(self, NULL, a_src);
|
||||
status = wuffs_wbmp__decoder__do_decode_frame_config(self, NULL, a_src);
|
||||
if (a_src) {
|
||||
iop_a_src = a_src->data.ptr + a_src->meta.ri;
|
||||
}
|
||||
@@ -45687,19 +47238,18 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
self->private_impl.f_call_sequence = 96;
|
||||
|
||||
ok:
|
||||
self->private_impl.p_decode_frame[0] = 0;
|
||||
self->private_impl.p_do_decode_frame[0] = 0;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
goto suspend;
|
||||
suspend:
|
||||
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
|
||||
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y;
|
||||
memcpy(self->private_data.s_decode_frame[0].v_src, v_src, sizeof(v_src));
|
||||
self->private_data.s_decode_frame[0].v_c = v_c;
|
||||
self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
|
||||
self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
|
||||
memcpy(self->private_data.s_do_decode_frame[0].v_src, v_src, sizeof(v_src));
|
||||
self->private_data.s_do_decode_frame[0].v_c = v_c;
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
@@ -45707,9 +47257,6 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
if (wuffs_base__status__is_error(&status)) {
|
||||
self->private_impl.magic = WUFFS_BASE__DISABLED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
// Copyright 2023 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.
|
||||
|
||||
// ----------------
|
||||
|
||||
// manual-test-truncated-input tests that decoding truncated versions of
|
||||
// well-formed files produces a "truncated input" error.
|
||||
//
|
||||
// It tests every M-byte prefix of a valid N-byte file, for every positive M
|
||||
// that satisfies (M < 65536) or ((N - M) <= 1024). The truncation point is
|
||||
// either within 64 KiB of the start or 1 KiB of the end. It does not test
|
||||
// every potential M in between, as that would take O(N**2) time.
|
||||
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// Wuffs ships as a "single file C library" or "header file library" as per
|
||||
// https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
|
||||
//
|
||||
// To use that single file as a "foo.c"-like implementation, instead of a
|
||||
// "foo.h"-like header, #define WUFFS_IMPLEMENTATION before #include'ing or
|
||||
// compiling it.
|
||||
#define WUFFS_IMPLEMENTATION
|
||||
|
||||
// Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when
|
||||
// combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs'
|
||||
// functions have static storage.
|
||||
//
|
||||
// This can help the compiler ignore or discard unused code, which can produce
|
||||
// faster compiles and smaller binaries. Other motivations are discussed in the
|
||||
// "ALLOW STATIC IMPLEMENTATION" section of
|
||||
// https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt
|
||||
#define WUFFS_CONFIG__STATIC_FUNCTIONS
|
||||
|
||||
// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of
|
||||
// release/c/etc.c choose which parts of Wuffs to build. That file contains the
|
||||
// entire Wuffs standard library, implementing a variety of codecs and file
|
||||
// formats. Without this macro definition, an optimizing compiler or linker may
|
||||
// very well discard Wuffs code for unused codecs, but listing the Wuffs
|
||||
// modules we use makes that process explicit. Preprocessing means that such
|
||||
// code simply isn't compiled.
|
||||
#define WUFFS_CONFIG__MODULES
|
||||
#define WUFFS_CONFIG__MODULE__ADLER32
|
||||
#define WUFFS_CONFIG__MODULE__BASE
|
||||
#define WUFFS_CONFIG__MODULE__BMP
|
||||
#define WUFFS_CONFIG__MODULE__BZIP2
|
||||
#define WUFFS_CONFIG__MODULE__CRC32
|
||||
#define WUFFS_CONFIG__MODULE__DEFLATE
|
||||
#define WUFFS_CONFIG__MODULE__GIF
|
||||
#define WUFFS_CONFIG__MODULE__GZIP
|
||||
#define WUFFS_CONFIG__MODULE__LZW
|
||||
#define WUFFS_CONFIG__MODULE__NIE
|
||||
#define WUFFS_CONFIG__MODULE__PNG
|
||||
#define WUFFS_CONFIG__MODULE__TGA
|
||||
#define WUFFS_CONFIG__MODULE__WBMP
|
||||
#define WUFFS_CONFIG__MODULE__ZLIB
|
||||
|
||||
// If building this program in an environment that doesn't easily accommodate
|
||||
// relative includes, you can use the script/inline-c-relative-includes.go
|
||||
// program to generate a stand-alone C file.
|
||||
#include "../release/c/wuffs-unsupported-snapshot.c"
|
||||
|
||||
// ----
|
||||
|
||||
#ifndef DST_BUFFER_ARRAY_SIZE
|
||||
#define DST_BUFFER_ARRAY_SIZE (64 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
#ifndef WORKBUF_ARRAY_SIZE
|
||||
#define WORKBUF_ARRAY_SIZE (256 * 1024 * 1024)
|
||||
#endif
|
||||
|
||||
uint8_t g_dst_buffer_array[DST_BUFFER_ARRAY_SIZE] = {0};
|
||||
uint8_t g_workbuf_array[WORKBUF_ARRAY_SIZE] = {0};
|
||||
|
||||
static int g_num_files_processed;
|
||||
|
||||
static struct {
|
||||
char buf[PATH_MAX];
|
||||
size_t len;
|
||||
} g_relative_cwd;
|
||||
|
||||
// ----
|
||||
|
||||
static const char skipped[] = "skipped";
|
||||
static const char unsupported_file_format[] = "unsupported file format";
|
||||
|
||||
static const char* //
|
||||
handle_image_decoder(wuffs_base__io_buffer src,
|
||||
int32_t fourcc,
|
||||
bool full_decode) {
|
||||
wuffs_base__image_decoder::unique_ptr dec(nullptr, &free);
|
||||
switch (fourcc) {
|
||||
case WUFFS_BASE__FOURCC__BMP:
|
||||
dec = wuffs_bmp__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__GIF:
|
||||
dec = wuffs_gif__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__NIE:
|
||||
dec = wuffs_nie__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__PNG:
|
||||
dec = wuffs_png__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__TGA:
|
||||
dec = wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__WBMP:
|
||||
dec = wuffs_wbmp__decoder::alloc_as__wuffs_base__image_decoder();
|
||||
break;
|
||||
default:
|
||||
return unsupported_file_format;
|
||||
}
|
||||
|
||||
if (!full_decode) {
|
||||
while (true) {
|
||||
auto dfc_status = dec->decode_frame_config(nullptr, &src);
|
||||
if (dfc_status.is_ok()) {
|
||||
// No-op.
|
||||
} else if (dfc_status.repr == wuffs_base__note__end_of_data) {
|
||||
break;
|
||||
} else {
|
||||
return dfc_status.message();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
wuffs_base__pixel_config pixcfg = {0};
|
||||
pixcfg.set(WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL,
|
||||
WUFFS_BASE__PIXEL_SUBSAMPLING__NONE, 0, 0);
|
||||
|
||||
wuffs_base__pixel_buffer pixbuf = {0};
|
||||
auto sfs_status =
|
||||
pixbuf.set_from_slice(&pixcfg, wuffs_base__make_slice_u8(nullptr, 0));
|
||||
if (!sfs_status.is_ok()) {
|
||||
return sfs_status.message();
|
||||
}
|
||||
|
||||
while (true) {
|
||||
auto df_status = dec->decode_frame(
|
||||
&pixbuf, &src, WUFFS_BASE__PIXEL_BLEND__SRC,
|
||||
wuffs_base__make_slice_u8(g_workbuf_array, WORKBUF_ARRAY_SIZE),
|
||||
nullptr);
|
||||
if (df_status.is_ok()) {
|
||||
// No-op.
|
||||
} else if (df_status.repr == wuffs_base__note__end_of_data) {
|
||||
break;
|
||||
} else {
|
||||
return df_status.message();
|
||||
}
|
||||
}
|
||||
if (src.meta.ri != src.meta.wi) {
|
||||
return skipped;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* //
|
||||
handle_io_transformer(wuffs_base__io_buffer src, int32_t fourcc) {
|
||||
wuffs_base__io_transformer::unique_ptr dec(nullptr, &free);
|
||||
switch (fourcc) {
|
||||
case WUFFS_BASE__FOURCC__BZ2:
|
||||
dec = wuffs_bzip2__decoder::alloc_as__wuffs_base__io_transformer();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__GZ:
|
||||
dec = wuffs_gzip__decoder::alloc_as__wuffs_base__io_transformer();
|
||||
break;
|
||||
case WUFFS_BASE__FOURCC__ZLIB:
|
||||
dec = wuffs_zlib__decoder::alloc_as__wuffs_base__io_transformer();
|
||||
break;
|
||||
default:
|
||||
return unsupported_file_format;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
auto dst = wuffs_base__ptr_u8__writer(&g_dst_buffer_array[0],
|
||||
DST_BUFFER_ARRAY_SIZE);
|
||||
auto df_status = dec->transform_io(
|
||||
&dst, &src,
|
||||
wuffs_base__make_slice_u8(g_workbuf_array, WORKBUF_ARRAY_SIZE));
|
||||
if (df_status.is_ok()) {
|
||||
break;
|
||||
} else if (df_status.repr == wuffs_base__suspension__short_write) {
|
||||
// No-op.
|
||||
} else {
|
||||
return df_status.message();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* //
|
||||
handle_various(wuffs_base__io_buffer src, int32_t fourcc) {
|
||||
const char* status_msg;
|
||||
|
||||
status_msg = handle_image_decoder(src, fourcc, false);
|
||||
if (status_msg != unsupported_file_format) {
|
||||
if ((status_msg != nullptr) && !strstr(status_msg, "truncated input")) {
|
||||
return status_msg;
|
||||
}
|
||||
return handle_image_decoder(src, fourcc, true);
|
||||
}
|
||||
|
||||
status_msg = handle_io_transformer(src, fourcc);
|
||||
if (status_msg != unsupported_file_format) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
return unsupported_file_format;
|
||||
}
|
||||
|
||||
static const char* //
|
||||
handle_range(wuffs_base__io_buffer src,
|
||||
int32_t fourcc,
|
||||
size_t wi_min_incl,
|
||||
size_t wi_max_excl) {
|
||||
for (size_t wi = wi_min_incl; wi < wi_max_excl; wi++) {
|
||||
src.meta.wi = wi;
|
||||
const char* status_msg = handle_various(src, fourcc);
|
||||
if ((status_msg != nullptr) && strstr(status_msg, "truncated input")) {
|
||||
continue;
|
||||
}
|
||||
printf("when truncated to %zu bytes: ", wi);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
return "have ok; want \"truncated input\"";
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const char* //
|
||||
handle(const uint8_t* ptr, size_t len) {
|
||||
auto src = wuffs_base__ptr_u8__reader(const_cast<uint8_t*>(ptr), len, true);
|
||||
int32_t fourcc = wuffs_base__magic_number_guess_fourcc(src.reader_slice(),
|
||||
src.meta.closed);
|
||||
if (fourcc <= 0) {
|
||||
return skipped;
|
||||
}
|
||||
|
||||
// Skip any invalid or unsupported input (when decoded in its entirety).
|
||||
//
|
||||
// Unsupported includes ignoring wuffs_base__note__i_o_redirect. We don't
|
||||
// bother testing truncated PNGs-embedded-in-BMPs because we presumably
|
||||
// already test truncated PNGs.
|
||||
const char* status_msg = handle_various(src, fourcc);
|
||||
if (status_msg) {
|
||||
return skipped;
|
||||
}
|
||||
|
||||
size_t file_len = src.meta.wi;
|
||||
if (file_len <= (65536 + 1024)) {
|
||||
return handle_range(src, fourcc, 1, file_len);
|
||||
}
|
||||
|
||||
status_msg = handle_range(src, fourcc, 1, 65536);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
return handle_range(src, fourcc, file_len - 1024, file_len);
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
static int //
|
||||
visit(char* filename);
|
||||
|
||||
static int //
|
||||
visit_dir(int fd) {
|
||||
int cwd_fd = open(".", O_RDONLY, 0);
|
||||
if (fchdir(fd)) {
|
||||
printf("failed\n");
|
||||
fprintf(stderr, "FAIL: fchdir: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DIR* d = fdopendir(fd);
|
||||
if (!d) {
|
||||
printf("failed\n");
|
||||
fprintf(stderr, "FAIL: fdopendir: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("dir\n");
|
||||
while (true) {
|
||||
struct dirent* e = readdir(d);
|
||||
if (!e) {
|
||||
break;
|
||||
}
|
||||
if ((e->d_name[0] == '\x00') || (e->d_name[0] == '.')) {
|
||||
continue;
|
||||
}
|
||||
int v = visit(e->d_name);
|
||||
if (v) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
if (closedir(d)) {
|
||||
fprintf(stderr, "FAIL: closedir: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (fchdir(cwd_fd)) {
|
||||
fprintf(stderr, "FAIL: fchdir: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (close(cwd_fd)) {
|
||||
fprintf(stderr, "FAIL: close: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int //
|
||||
visit_reg(int fd, off_t size) {
|
||||
if ((size < 0) || (0x7FFFFFFF < size)) {
|
||||
printf("failed\n");
|
||||
fprintf(stderr, "FAIL: file size out of bounds");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void* data = NULL;
|
||||
if (size > 0) {
|
||||
data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (data == MAP_FAILED) {
|
||||
printf("failed\n");
|
||||
fprintf(stderr, "FAIL: mmap: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
const char* msg = handle((const uint8_t*)(data), size);
|
||||
if (msg) {
|
||||
printf("%s\n", msg);
|
||||
} else {
|
||||
printf("ok\n");
|
||||
}
|
||||
|
||||
if ((size > 0) && munmap(data, size)) {
|
||||
fprintf(stderr, "FAIL: mmap: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (close(fd)) {
|
||||
fprintf(stderr, "FAIL: close: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
return (msg && (msg != skipped)) ? 1 : 0;
|
||||
}
|
||||
|
||||
static int //
|
||||
visit(char* filename) {
|
||||
g_num_files_processed++;
|
||||
if (!filename || (filename[0] == '\x00')) {
|
||||
fprintf(stderr, "FAIL: invalid filename\n");
|
||||
return 1;
|
||||
}
|
||||
int n = printf("- %s%s", g_relative_cwd.buf, filename);
|
||||
printf("%*s", (60 > n) ? (60 - n) : 1, "");
|
||||
fflush(stdout);
|
||||
|
||||
struct stat z;
|
||||
int fd = open(filename, O_RDONLY, 0);
|
||||
if (fd == -1) {
|
||||
printf("failed\n");
|
||||
fprintf(stderr, "FAIL: open: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (fstat(fd, &z)) {
|
||||
printf("failed\n");
|
||||
fprintf(stderr, "FAIL: fstat: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (S_ISREG(z.st_mode)) {
|
||||
return visit_reg(fd, z.st_size);
|
||||
} else if (!S_ISDIR(z.st_mode)) {
|
||||
printf("skipped\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t old_len = g_relative_cwd.len;
|
||||
size_t filename_len = strlen(filename);
|
||||
size_t new_len = old_len + strlen(filename);
|
||||
bool slash = filename[filename_len - 1] != '/';
|
||||
if (slash) {
|
||||
new_len++;
|
||||
}
|
||||
if ((filename_len >= PATH_MAX) || (new_len >= PATH_MAX)) {
|
||||
printf("failed\n");
|
||||
fprintf(stderr, "FAIL: path is too long\n");
|
||||
return 1;
|
||||
}
|
||||
memcpy(g_relative_cwd.buf + old_len, filename, filename_len);
|
||||
|
||||
if (slash) {
|
||||
g_relative_cwd.buf[new_len - 1] = '/';
|
||||
}
|
||||
g_relative_cwd.buf[new_len] = '\x00';
|
||||
g_relative_cwd.len = new_len;
|
||||
|
||||
int v = visit_dir(fd);
|
||||
|
||||
g_relative_cwd.buf[old_len] = '\x00';
|
||||
g_relative_cwd.len = old_len;
|
||||
return v;
|
||||
}
|
||||
|
||||
int //
|
||||
main(int argc, char** argv) {
|
||||
g_num_files_processed = 0;
|
||||
g_relative_cwd.len = 0;
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
int v = visit(argv[i]);
|
||||
if (v) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
printf("PASS: %d files processed\n", g_num_files_processed);
|
||||
return 0;
|
||||
}
|
||||
@@ -229,6 +229,10 @@ print_raw_passthrough(wuffs_base__io_buffer* src,
|
||||
break;
|
||||
}
|
||||
uint64_t n1 = src->reader_length();
|
||||
while (n1 == 0) {
|
||||
TRY(read_buffer_from_file(src, f));
|
||||
n1 = src->reader_length();
|
||||
}
|
||||
uint64_t n = wuffs_base__u64__min(n0, n1);
|
||||
print_hex_dump(src->reader_pointer(), n);
|
||||
src->meta.ri += n;
|
||||
|
||||
@@ -182,6 +182,7 @@ var u64TestCases = []uint64{
|
||||
0x44B52D02C7E14AF6,
|
||||
0x46293E5939A08CEA,
|
||||
0x54B249AD2594C37D,
|
||||
0x54B2987670ADB613,
|
||||
0x7BBA44DF832B8D46,
|
||||
0x7BF06B0BB1FB384C,
|
||||
0x7C2485CE9E7A065F,
|
||||
|
||||
+123
-23
@@ -14,6 +14,7 @@
|
||||
|
||||
pub status "#bad header"
|
||||
pub status "#bad RLE compression"
|
||||
pub status "#truncated input"
|
||||
pub status "#unsupported BMP file"
|
||||
|
||||
pri status "@internal note: short read"
|
||||
@@ -49,7 +50,7 @@ pub struct decoder? implements base.image_decoder(
|
||||
bitmap_info_len : base.u32,
|
||||
padding : base.u32,
|
||||
|
||||
bits_per_pixel : base.u32,
|
||||
bits_per_pixel : base.u32[..= 0xFFFF],
|
||||
compression : base.u32,
|
||||
|
||||
// channel_etc's indexes are: B, G, R, A. This is in Wuffs' default order,
|
||||
@@ -85,6 +86,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var magic : base.u32
|
||||
var width : base.u32
|
||||
var height : base.u32
|
||||
@@ -370,10 +383,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
if this.call_sequence == 0x20 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x20 {
|
||||
this.decode_image_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_image_config?(dst: nullptr, src: args.src)
|
||||
} else if this.call_sequence == 0x28 {
|
||||
if this.frame_config_io_position <> args.src.position() {
|
||||
return base."#bad restart"
|
||||
@@ -406,10 +431,22 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
if this.call_sequence == 0x40 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x40 {
|
||||
this.decode_frame_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_frame_config?(dst: nullptr, src: args.src)
|
||||
} else {
|
||||
return base."@end of data"
|
||||
}
|
||||
@@ -467,10 +504,12 @@ pri func decoder.swizzle_none!(dst: ptr base.pixel_buffer, src: base.io_reader)
|
||||
var dst_bits_per_pixel : base.u32[..= 256]
|
||||
var dst_bytes_per_pixel : base.u64[..= 32]
|
||||
var dst_bytes_per_row : base.u64
|
||||
var src_bytes_per_pixel : base.u32[..= 4]
|
||||
var dst_palette : slice base.u8
|
||||
var tab : table base.u8
|
||||
var dst : slice base.u8
|
||||
var i : base.u64
|
||||
var j : base.u64
|
||||
var n : base.u64
|
||||
|
||||
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
|
||||
@@ -515,14 +554,38 @@ pri func decoder.swizzle_none!(dst: ptr base.pixel_buffer, src: base.io_reader)
|
||||
}
|
||||
i = (this.dst_x as base.u64) * dst_bytes_per_pixel
|
||||
if i >= dst.length() {
|
||||
// TODO: advance args.src if the dst pixel_buffer bounds is
|
||||
// smaller than this BMP's image bounds?
|
||||
continue.inner
|
||||
if this.bits_per_pixel > 32 {
|
||||
return "#unsupported BMP file"
|
||||
}
|
||||
src_bytes_per_pixel = this.bits_per_pixel / 8
|
||||
if src_bytes_per_pixel == 0 {
|
||||
return "#unsupported BMP file"
|
||||
}
|
||||
n = args.src.length() / (src_bytes_per_pixel as base.u64)
|
||||
n = n.min(a: (this.width ~mod- this.dst_x) as base.u64)
|
||||
j = n
|
||||
while j >= 8 {
|
||||
if args.src.length() >= ((src_bytes_per_pixel * 8) as base.u64) {
|
||||
args.src.skip_u32_fast!(
|
||||
actual: src_bytes_per_pixel * 8,
|
||||
worst_case: src_bytes_per_pixel * 8)
|
||||
}
|
||||
j -= 8
|
||||
} endwhile
|
||||
while j > 0 {
|
||||
if args.src.length() >= ((src_bytes_per_pixel * 1) as base.u64) {
|
||||
args.src.skip_u32_fast!(
|
||||
actual: src_bytes_per_pixel * 1,
|
||||
worst_case: src_bytes_per_pixel * 1)
|
||||
}
|
||||
j -= 1
|
||||
} endwhile
|
||||
} else {
|
||||
n = this.swizzler.swizzle_interleaved_from_reader!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: dst_palette,
|
||||
src: args.src)
|
||||
}
|
||||
n = this.swizzler.swizzle_interleaved_from_reader!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: dst_palette,
|
||||
src: args.src)
|
||||
if n == 0 {
|
||||
return "@internal note: short read"
|
||||
}
|
||||
@@ -906,15 +969,13 @@ pri func decoder.swizzle_bitfields!(dst: ptr base.pixel_buffer, src: base.io_rea
|
||||
}
|
||||
i = (this.dst_x as base.u64) * dst_bytes_per_pixel
|
||||
if i >= dst.length() {
|
||||
// TODO: advance args.src if the dst pixel_buffer bounds is
|
||||
// smaller than this BMP's image bounds?
|
||||
continue.inner
|
||||
n = p0 as base.u64
|
||||
} else {
|
||||
n = this.swizzler.swizzle_interleaved_from_slice!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: dst_palette,
|
||||
src: this.scratch[.. 8 * p0])
|
||||
}
|
||||
|
||||
n = this.swizzler.swizzle_interleaved_from_slice!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: dst_palette,
|
||||
src: this.scratch[.. 8 * p0])
|
||||
if n == 0 {
|
||||
return "@internal note: short read"
|
||||
}
|
||||
@@ -938,8 +999,9 @@ pri func decoder.swizzle_low_bit_depth!(dst: ptr base.pixel_buffer, src: base.io
|
||||
|
||||
var p0 : base.u32[..= 543]
|
||||
|
||||
var chunk_bits : base.u32
|
||||
var chunk_count : base.u32
|
||||
var chunk_bits : base.u32
|
||||
var chunk_count : base.u32
|
||||
var pixels_per_chunk : base.u32[..= 32]
|
||||
|
||||
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
|
||||
// to chain the two calls: "args.dst.pixel_format().bits_per_pixel()".
|
||||
@@ -968,8 +1030,34 @@ pri func decoder.swizzle_low_bit_depth!(dst: ptr base.pixel_buffer, src: base.io
|
||||
}
|
||||
i = (this.dst_x as base.u64) * dst_bytes_per_pixel
|
||||
if i >= dst.length() {
|
||||
// TODO: advance args.src if the dst pixel_buffer bounds is
|
||||
// smaller than this BMP's image bounds?
|
||||
if this.bits_per_pixel == 1 {
|
||||
chunk_count = ((this.width ~sat- this.dst_x) + 31) / 32
|
||||
pixels_per_chunk = 32
|
||||
} else if this.bits_per_pixel == 2 {
|
||||
chunk_count = ((this.width ~sat- this.dst_x) + 15) / 16
|
||||
pixels_per_chunk = 16
|
||||
} else {
|
||||
chunk_count = ((this.width ~sat- this.dst_x) + 7) / 8
|
||||
pixels_per_chunk = 8
|
||||
}
|
||||
while (chunk_count >= 64) and (args.src.length() >= 256) {
|
||||
args.src.skip_u32_fast!(actual: 256, worst_case: 256)
|
||||
this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 64))
|
||||
chunk_count -= 64
|
||||
} endwhile
|
||||
while (chunk_count >= 8) and (args.src.length() >= 32) {
|
||||
args.src.skip_u32_fast!(actual: 32, worst_case: 32)
|
||||
this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 8))
|
||||
chunk_count -= 8
|
||||
} endwhile
|
||||
while chunk_count > 0 {
|
||||
if args.src.length() < 4 {
|
||||
return "@internal note: short read"
|
||||
}
|
||||
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
|
||||
this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 1))
|
||||
chunk_count -= 1
|
||||
} endwhile
|
||||
continue.loop
|
||||
}
|
||||
dst = dst[i ..]
|
||||
@@ -1047,7 +1135,7 @@ pri func decoder.swizzle_low_bit_depth!(dst: ptr base.pixel_buffer, src: base.io
|
||||
chunk_count -= 1
|
||||
} endwhile
|
||||
|
||||
} else if this.bits_per_pixel == 4 {
|
||||
} else {
|
||||
// Calculate the remaining number of 32-bit chunks. At 4 bits per
|
||||
// pixel there are 8 pixels per chunk. Division rounds up.
|
||||
chunk_count = ((this.width ~sat- this.dst_x) + 7) / 8
|
||||
@@ -1125,6 +1213,18 @@ pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_tell_me_more?(dst: args.dst, minfo: args.minfo, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
|
||||
if this.io_redirect_fourcc <= 1 {
|
||||
return base."#no more information"
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ pub status "#bad block length"
|
||||
pub status "#bad checksum"
|
||||
pub status "#bad header"
|
||||
pub status "#bad number of sections"
|
||||
pub status "#truncated input"
|
||||
pub status "#unsupported block randomization"
|
||||
|
||||
pri status "#internal error: inconsistent Huffman decoder state"
|
||||
@@ -121,6 +122,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
|
||||
}
|
||||
|
||||
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var c : base.u8
|
||||
var i : base.u32
|
||||
var tag : base.u64
|
||||
|
||||
@@ -25,6 +25,7 @@ pub status "#bad literal/length code count"
|
||||
pub status "#inconsistent stored block length"
|
||||
pub status "#missing end-of-block code"
|
||||
pub status "#no Huffman codes"
|
||||
pub status "#truncated input"
|
||||
|
||||
pri status "#internal error: inconsistent Huffman decoder state"
|
||||
pri status "#internal error: inconsistent I/O"
|
||||
@@ -208,6 +209,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
|
||||
}
|
||||
|
||||
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var mark : base.u64
|
||||
var status : base.status
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ pub status "#bad graphic control"
|
||||
pub status "#bad header"
|
||||
pub status "#bad literal width"
|
||||
pub status "#bad palette"
|
||||
pub status "#truncated input"
|
||||
|
||||
pri status "#internal error: inconsistent ri/wi"
|
||||
|
||||
|
||||
@@ -98,6 +98,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var ffio : base.bool
|
||||
|
||||
if this.call_sequence <> 0x00 {
|
||||
@@ -150,6 +162,18 @@ pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_tell_me_more?(dst: args.dst, minfo: args.minfo, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
|
||||
var chunk_length : base.u64
|
||||
|
||||
if (this.call_sequence & 0x10) == 0 {
|
||||
@@ -296,6 +320,18 @@ pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.sta
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var background_color : base.u32
|
||||
var flags : base.u8
|
||||
|
||||
@@ -306,7 +342,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
||||
} else if this.call_sequence == 0x20 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x20 {
|
||||
this.decode_image_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_image_config?(dst: nullptr, src: args.src)
|
||||
} else if this.call_sequence == 0x28 {
|
||||
if this.frame_config_io_position <> args.src.position() {
|
||||
return base."#bad restart"
|
||||
@@ -397,12 +433,24 @@ pri func decoder.skip_frame?(src: base.io_reader) {
|
||||
this.call_sequence = 0x20
|
||||
}
|
||||
|
||||
// TODO: honor args.opts.
|
||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
// TODO: honor args.opts.
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
if this.call_sequence == 0x40 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x40 {
|
||||
this.decode_frame_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_frame_config?(dst: nullptr, src: args.src)
|
||||
} else {
|
||||
return base."@end of data"
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ pub status "#bad checksum"
|
||||
pub status "#bad compression method"
|
||||
pub status "#bad encoding flags"
|
||||
pub status "#bad header"
|
||||
pub status "#truncated input"
|
||||
|
||||
// TODO: reference deflate.DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE.
|
||||
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 1
|
||||
@@ -45,6 +46,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
|
||||
}
|
||||
|
||||
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var c : base.u8
|
||||
var flags : base.u8
|
||||
var xlen : base.u16
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
pub status "#bad code"
|
||||
pub status "#truncated input"
|
||||
|
||||
pri status "#internal error: inconsistent I/O"
|
||||
|
||||
@@ -119,6 +120,8 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf
|
||||
} else if this.read_from_return_value == 2 {
|
||||
yield? base."$short read"
|
||||
} else if this.read_from_return_value == 3 {
|
||||
return "#truncated input"
|
||||
} else if this.read_from_return_value == 4 {
|
||||
return "#bad code"
|
||||
} else {
|
||||
return "#internal error: inconsistent I/O"
|
||||
@@ -167,7 +170,11 @@ pri func decoder.read_from!(src: base.io_reader) {
|
||||
assert width <= n_bits via "a <= b: a <= c; c <= b"(c: 12)
|
||||
assert n_bits >= width via "a >= b: b <= a"()
|
||||
} else if args.src.length() <= 0 {
|
||||
this.read_from_return_value = 2
|
||||
if args.src.is_closed() {
|
||||
this.read_from_return_value = 3
|
||||
} else {
|
||||
this.read_from_return_value = 2
|
||||
}
|
||||
break
|
||||
} else {
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
@@ -176,7 +183,11 @@ pri func decoder.read_from!(src: base.io_reader) {
|
||||
if n_bits >= width {
|
||||
// No-op.
|
||||
} else if args.src.length() <= 0 {
|
||||
this.read_from_return_value = 2
|
||||
if args.src.is_closed() {
|
||||
this.read_from_return_value = 3
|
||||
} else {
|
||||
this.read_from_return_value = 2
|
||||
}
|
||||
break
|
||||
} else {
|
||||
bits |= args.src.peek_u8_as_u32() << n_bits
|
||||
@@ -188,7 +199,7 @@ pri func decoder.read_from!(src: base.io_reader) {
|
||||
// This if condition is always false, but for some unknown
|
||||
// reason, removing it worsens the benchmarks slightly.
|
||||
if n_bits < width {
|
||||
this.read_from_return_value = 4
|
||||
this.read_from_return_value = 5
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -297,7 +308,7 @@ pri func decoder.read_from!(src: base.io_reader) {
|
||||
}
|
||||
|
||||
} else {
|
||||
this.read_from_return_value = 3
|
||||
this.read_from_return_value = 4
|
||||
break
|
||||
}
|
||||
|
||||
@@ -319,7 +330,7 @@ pri func decoder.read_from!(src: base.io_reader) {
|
||||
if args.src.can_undo_byte() {
|
||||
args.src.undo_byte!()
|
||||
} else {
|
||||
this.read_from_return_value = 4
|
||||
this.read_from_return_value = 5
|
||||
break
|
||||
}
|
||||
} endwhile
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
pub status "#bad header"
|
||||
pub status "#truncated input"
|
||||
pub status "#unsupported NIE file"
|
||||
|
||||
pri status "@internal note: short read"
|
||||
@@ -39,6 +40,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var a : base.u32
|
||||
|
||||
if this.call_sequence <> 0x00 {
|
||||
@@ -89,10 +102,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
if this.call_sequence == 0x20 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x20 {
|
||||
this.decode_image_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_image_config?(dst: nullptr, src: args.src)
|
||||
} else if this.call_sequence == 0x28 {
|
||||
if 16 <> args.src.position() {
|
||||
return base."#bad restart"
|
||||
@@ -125,10 +150,22 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
if this.call_sequence == 0x40 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x40 {
|
||||
this.decode_frame_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_frame_config?(dst: nullptr, src: args.src)
|
||||
} else {
|
||||
return base."@end of data"
|
||||
}
|
||||
@@ -164,9 +201,11 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: base.io_reader) base.
|
||||
var dst_bits_per_pixel : base.u32[..= 256]
|
||||
var dst_bytes_per_pixel : base.u64[..= 32]
|
||||
var dst_bytes_per_row : base.u64
|
||||
var src_bytes_per_pixel : base.u32[..= 8]
|
||||
var tab : table base.u8
|
||||
var dst : slice base.u8
|
||||
var i : base.u64
|
||||
var j : base.u64
|
||||
var n : base.u64
|
||||
|
||||
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
|
||||
@@ -195,14 +234,37 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: base.io_reader) base.
|
||||
}
|
||||
i = (this.dst_x as base.u64) * dst_bytes_per_pixel
|
||||
if i >= dst.length() {
|
||||
// TODO: advance args.src if the dst pixel_buffer bounds is
|
||||
// smaller than this NIE's image bounds?
|
||||
continue
|
||||
src_bytes_per_pixel = 4
|
||||
assert src_bytes_per_pixel > 0
|
||||
if this.pixfmt == base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE {
|
||||
src_bytes_per_pixel = 8
|
||||
assert src_bytes_per_pixel > 0
|
||||
}
|
||||
n = args.src.length() / (src_bytes_per_pixel as base.u64)
|
||||
n = n.min(a: (this.width ~mod- this.dst_x) as base.u64)
|
||||
j = n
|
||||
while j >= 8 {
|
||||
if args.src.length() >= ((src_bytes_per_pixel * 8) as base.u64) {
|
||||
args.src.skip_u32_fast!(
|
||||
actual: src_bytes_per_pixel * 8,
|
||||
worst_case: src_bytes_per_pixel * 8)
|
||||
}
|
||||
j -= 8
|
||||
} endwhile
|
||||
while j > 0 {
|
||||
if args.src.length() >= ((src_bytes_per_pixel * 1) as base.u64) {
|
||||
args.src.skip_u32_fast!(
|
||||
actual: src_bytes_per_pixel * 1,
|
||||
worst_case: src_bytes_per_pixel * 1)
|
||||
}
|
||||
j -= 1
|
||||
} endwhile
|
||||
} else {
|
||||
n = this.swizzler.swizzle_interleaved_from_reader!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: args.dst.palette(),
|
||||
src: args.src)
|
||||
}
|
||||
n = this.swizzler.swizzle_interleaved_from_reader!(
|
||||
dst: dst[i ..],
|
||||
dst_palette: args.dst.palette(),
|
||||
src: args.src)
|
||||
if n == 0 {
|
||||
return "@internal note: short read"
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ pub status "#bad filter"
|
||||
pub status "#bad header"
|
||||
pub status "#bad text chunk (not Latin-1)"
|
||||
pub status "#missing palette"
|
||||
pub status "#truncated input"
|
||||
pub status "#unsupported CgBI extension"
|
||||
pub status "#unsupported PNG compression method"
|
||||
pub status "#unsupported PNG file"
|
||||
|
||||
+73
-31
@@ -163,6 +163,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var magic : base.u64
|
||||
var mark : base.u64
|
||||
var checksum_have : base.u32
|
||||
@@ -229,14 +241,10 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
// IDAT chunk breaks the loop. The only other possible critical chunk is a
|
||||
// PLTE chunk. We verify PLTE checksums here but ignore other checksums.
|
||||
while true {
|
||||
while args.src.length() < 8,
|
||||
post args.src.length() >= 8,
|
||||
{
|
||||
if args.src.is_closed() {
|
||||
return "#bad chunk"
|
||||
}
|
||||
if args.src.length() < 8 {
|
||||
yield? base."$short read"
|
||||
} endwhile
|
||||
continue
|
||||
}
|
||||
|
||||
this.chunk_length = args.src.peek_u32be()
|
||||
this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32
|
||||
@@ -607,11 +615,20 @@ pri func decoder.decode_other_chunk?(src: base.io_reader, framy: base.bool) {
|
||||
}
|
||||
|
||||
} else if this.chunk_type == 'tRNS'le {
|
||||
if this.seen_trns or (this.color_type > 3) or
|
||||
if this.seen_trns or
|
||||
((this.color_type == 3) and (not this.seen_plte)) {
|
||||
return "#bad chunk"
|
||||
} else if this.color_type > 3 {
|
||||
// No-op, ignoring the chunk. The PNG spec section "11.3.2.1
|
||||
// tRNS Transparency" says that "A tRNS chunk shall not appear
|
||||
// for colour types 4 and 6, since a full alpha channel is
|
||||
// already present in those cases." However, some real-world
|
||||
// PNG images (incorrectly) have these. libpng treats this as a
|
||||
// "benign error", not a fatal one. See
|
||||
// https://github.com/google/wuffs/issues/146
|
||||
} else {
|
||||
this.decode_trns?(src: args.src)
|
||||
}
|
||||
this.decode_trns?(src: args.src)
|
||||
this.seen_trns = true
|
||||
}
|
||||
}
|
||||
@@ -934,6 +951,18 @@ pri func decoder.decode_trns?(src: base.io_reader) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var checksum_have : base.u32
|
||||
|
||||
if (this.call_sequence & 0x10) <> 0 {
|
||||
@@ -941,7 +970,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
||||
} else if this.call_sequence == 0x20 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x20 {
|
||||
this.decode_image_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_image_config?(dst: nullptr, src: args.src)
|
||||
} else if this.call_sequence == 0x28 {
|
||||
if this.frame_config_io_position <> args.src.position() {
|
||||
return base."#bad restart"
|
||||
@@ -1029,14 +1058,10 @@ pri func decoder.skip_frame?(src: base.io_reader) {
|
||||
this.chunk_type_array[3] = 0
|
||||
|
||||
while true {
|
||||
while args.src.length() < 8,
|
||||
post args.src.length() >= 8,
|
||||
{
|
||||
if args.src.is_closed() {
|
||||
return "#bad chunk"
|
||||
}
|
||||
if args.src.length() < 8 {
|
||||
yield? base."$short read"
|
||||
} endwhile
|
||||
continue
|
||||
}
|
||||
|
||||
this.chunk_length = args.src.peek_u32be()
|
||||
this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32
|
||||
@@ -1091,6 +1116,18 @@ pri func decoder.skip_frame?(src: base.io_reader) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var seq_num : base.u32
|
||||
var status : base.status
|
||||
var pass_width : base.u32[..= 0x00FF_FFFF]
|
||||
@@ -1101,18 +1138,14 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
} else if this.call_sequence >= 0x60 {
|
||||
return base."@end of data"
|
||||
} else if this.call_sequence <> 0x40 {
|
||||
this.decode_frame_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_frame_config?(dst: nullptr, src: args.src)
|
||||
}
|
||||
|
||||
while true {
|
||||
while args.src.length() < 8,
|
||||
post args.src.length() >= 8,
|
||||
{
|
||||
if args.src.is_closed() {
|
||||
return "#bad chunk"
|
||||
}
|
||||
if args.src.length() < 8 {
|
||||
yield? base."$short read"
|
||||
} endwhile
|
||||
continue
|
||||
}
|
||||
|
||||
this.chunk_length = args.src.peek_u32be()
|
||||
this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32
|
||||
@@ -1198,9 +1231,8 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
break
|
||||
} else if status.is_error() or
|
||||
((status == base."$short read") and args.src.is_closed()) {
|
||||
// The input was truncated or invalid. Produce whatever
|
||||
// pixels we can and then, if truncated, generate "$short
|
||||
// read" forever.
|
||||
// The input was invalid or truncated. Produce whatever
|
||||
// pixels we can.
|
||||
if this.workbuf_wi <= args.workbuf.length() {
|
||||
// This might return "#internal error: inconsistent
|
||||
// workbuf length" because of the ".. this.workbuf_wi".
|
||||
@@ -1208,9 +1240,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
this.filter_and_swizzle!(dst: args.dst, workbuf: args.workbuf[.. this.workbuf_wi])
|
||||
}
|
||||
if status == base."$short read" {
|
||||
while true {
|
||||
yield? base."$short read"
|
||||
} endwhile
|
||||
return "#truncated input"
|
||||
}
|
||||
}
|
||||
yield? status
|
||||
@@ -1390,6 +1420,18 @@ pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_tell_me_more?(dst: args.dst, minfo: args.minfo, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
|
||||
var c : base.u8
|
||||
var c2 : base.u16
|
||||
var w : base.io_writer
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
pub status "#bad header"
|
||||
pub status "#bad run length encoding"
|
||||
pub status "#truncated input"
|
||||
pub status "#unsupported TGA file"
|
||||
|
||||
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
|
||||
@@ -55,6 +56,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var c : base.u32
|
||||
var c5 : base.u32[..= 0x1F]
|
||||
var i : base.u32
|
||||
@@ -226,10 +239,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
if this.call_sequence == 0x20 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x20 {
|
||||
this.decode_image_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_image_config?(dst: nullptr, src: args.src)
|
||||
} else if this.call_sequence == 0x28 {
|
||||
if this.frame_config_io_position <> args.src.position() {
|
||||
return base."#bad restart"
|
||||
@@ -260,6 +285,18 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
var dst_pixfmt : base.pixel_format
|
||||
var dst_bits_per_pixel : base.u32[..= 256]
|
||||
@@ -284,7 +321,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
if this.call_sequence == 0x40 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x40 {
|
||||
this.decode_frame_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_frame_config?(dst: nullptr, src: args.src)
|
||||
} else {
|
||||
return base."@end of data"
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
pub status "#bad header"
|
||||
pub status "#truncated input"
|
||||
|
||||
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
|
||||
|
||||
@@ -34,6 +35,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
|
||||
}
|
||||
|
||||
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
|
||||
var c : base.u8
|
||||
var i : base.u32
|
||||
var x32 : base.u32
|
||||
@@ -97,10 +110,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
|
||||
if this.call_sequence == 0x20 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x20 {
|
||||
this.decode_image_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_image_config?(dst: nullptr, src: args.src)
|
||||
} else if this.call_sequence == 0x28 {
|
||||
if this.frame_config_io_position <> args.src.position() {
|
||||
return base."#bad restart"
|
||||
@@ -131,6 +156,18 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
|
||||
}
|
||||
|
||||
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
|
||||
var status : base.status
|
||||
var dst_pixfmt : base.pixel_format
|
||||
var dst_bits_per_pixel : base.u32[..= 256]
|
||||
@@ -146,7 +183,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
|
||||
if this.call_sequence == 0x40 {
|
||||
// No-op.
|
||||
} else if this.call_sequence < 0x40 {
|
||||
this.decode_frame_config?(dst: nullptr, src: args.src)
|
||||
this.do_decode_frame_config?(dst: nullptr, src: args.src)
|
||||
} else {
|
||||
return base."@end of data"
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ pub status "#bad compression method"
|
||||
pub status "#bad compression window size"
|
||||
pub status "#bad parity check"
|
||||
pub status "#incorrect dictionary"
|
||||
pub status "#truncated input"
|
||||
|
||||
// TODO: reference deflate.DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE.
|
||||
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 1
|
||||
@@ -81,6 +82,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
|
||||
}
|
||||
|
||||
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var status : base.status
|
||||
|
||||
while true {
|
||||
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
|
||||
if (status == base."$short read") and args.src.is_closed() {
|
||||
return "#truncated input"
|
||||
}
|
||||
yield? status
|
||||
} endwhile
|
||||
}
|
||||
|
||||
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
|
||||
var x : base.u16
|
||||
var checksum_got : base.u32
|
||||
var status : base.status
|
||||
|
||||
@@ -101,6 +101,34 @@ test_wuffs_bmp_decode_interface() {
|
||||
"test/data/hippopotamus.bmp", 0, SIZE_MAX, 36, 28, 0xFFF5F5F5);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_bmp_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_bmp__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_bmp__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_bmp__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_bmp__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_bmp__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_bmp__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_bmp_decode_frame_config() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -213,6 +241,7 @@ proc g_tests[] = {
|
||||
test_wuffs_bmp_decode_frame_config,
|
||||
test_wuffs_bmp_decode_interface,
|
||||
test_wuffs_bmp_decode_io_redirect,
|
||||
test_wuffs_bmp_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
@@ -109,6 +109,36 @@ test_wuffs_bzip2_decode_interface() {
|
||||
"test/data/romeo.txt.bz2", 0, SIZE_MAX, 942, 0x0A);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_bzip2_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_bzip2__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_bzip2__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_bzip2__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status =
|
||||
wuffs_bzip2__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_bzip2__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_bzip2__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_bzip2_decode(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src,
|
||||
@@ -262,6 +292,7 @@ proc g_tests[] = {
|
||||
test_wuffs_bzip2_decode_interface,
|
||||
test_wuffs_bzip2_decode_midsummer,
|
||||
test_wuffs_bzip2_decode_pi,
|
||||
test_wuffs_bzip2_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
@@ -92,6 +92,37 @@ test_wuffs_cbor_decode_interface() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_cbor_decode_empty_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__token_buffer tok =
|
||||
wuffs_base__slice_token__writer(g_have_slice_token);
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_cbor__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_cbor__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_cbor__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status =
|
||||
wuffs_cbor__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_cbor__error__bad_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_cbor__error__bad_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_cbor_decode_invalid() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -208,6 +239,7 @@ test_wuffs_cbor_decode_valid() {
|
||||
|
||||
proc g_tests[] = {
|
||||
|
||||
test_wuffs_cbor_decode_empty_input,
|
||||
test_wuffs_cbor_decode_interface,
|
||||
test_wuffs_cbor_decode_invalid,
|
||||
test_wuffs_cbor_decode_valid,
|
||||
|
||||
@@ -166,6 +166,36 @@ test_wuffs_deflate_decode_interface() {
|
||||
"test/data/romeo.txt.deflate", 0, SIZE_MAX, 942, 0x0A);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_deflate_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_deflate__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_deflate__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_deflate__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status =
|
||||
wuffs_deflate__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_deflate__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_deflate__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_deflate_decode(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src,
|
||||
@@ -903,6 +933,7 @@ proc g_tests[] = {
|
||||
test_wuffs_deflate_decode_romeo,
|
||||
test_wuffs_deflate_decode_romeo_fixed,
|
||||
test_wuffs_deflate_decode_split_src,
|
||||
test_wuffs_deflate_decode_truncated_input,
|
||||
test_wuffs_deflate_history_full,
|
||||
test_wuffs_deflate_history_partial,
|
||||
test_wuffs_deflate_table_redirect,
|
||||
|
||||
+32
-3
@@ -182,6 +182,34 @@ test_wuffs_gif_decode_interface_image_decoder() {
|
||||
"test/data/bricks-nodither.gif", 0, SIZE_MAX, 160, 120, 0xFF012463);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_gif_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_gif__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_gif__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_gif__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_gif__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_gif__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_gif_decode(uint64_t* n_bytes_out,
|
||||
wuffs_base__io_buffer* dst,
|
||||
@@ -1238,9 +1266,9 @@ test_wuffs_gif_decode_interlaced_truncated() {
|
||||
|
||||
wuffs_base__status status = wuffs_gif__decoder__decode_frame(
|
||||
&dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, g_work_slice_u8, NULL);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
if (status.repr != wuffs_gif__error__truncated_input) {
|
||||
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
wuffs_gif__error__truncated_input);
|
||||
}
|
||||
|
||||
// Even though the source GIF data was truncated, replicating the interlaced
|
||||
@@ -1462,7 +1490,7 @@ test_wuffs_gif_decode_missing_two_src_bytes() {
|
||||
src.meta.wi -= 2;
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
src, 0, wuffs_base__suspension__short_read, false);
|
||||
src, 0, wuffs_gif__error__truncated_input, false);
|
||||
}
|
||||
|
||||
const char* //
|
||||
@@ -2356,6 +2384,7 @@ proc g_tests[] = {
|
||||
test_wuffs_gif_decode_pixfmt_bgra_nonpremul,
|
||||
test_wuffs_gif_decode_pixfmt_rgb,
|
||||
test_wuffs_gif_decode_pixfmt_rgba_nonpremul,
|
||||
test_wuffs_gif_decode_truncated_input,
|
||||
test_wuffs_gif_decode_zero_width_frame,
|
||||
test_wuffs_gif_frame_dirty_rect,
|
||||
test_wuffs_gif_num_decoded_frame_configs,
|
||||
|
||||
@@ -96,6 +96,36 @@ test_wuffs_gzip_decode_interface() {
|
||||
"test/data/romeo.txt.gz", 0, SIZE_MAX, 942, 0x0A);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_gzip_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_gzip__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_gzip__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_gzip__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status =
|
||||
wuffs_gzip__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_gzip__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_gzip__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_gzip_decode(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src,
|
||||
@@ -255,6 +285,7 @@ test_wuffs_gzip_decode_infrequent_compaction() {
|
||||
// Decode 5 source bytes at a time. Compact every 15 source bytes.
|
||||
for (size_t i = 0; i < src.data.len; i += 5) {
|
||||
src.meta.wi = i;
|
||||
src.meta.closed = false;
|
||||
wuffs_base__status status =
|
||||
wuffs_gzip__decoder__transform_io(&dec, &dst, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
@@ -361,6 +392,7 @@ proc g_tests[] = {
|
||||
test_wuffs_gzip_decode_interface,
|
||||
test_wuffs_gzip_decode_midsummer,
|
||||
test_wuffs_gzip_decode_pi,
|
||||
test_wuffs_gzip_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
@@ -1026,6 +1026,7 @@ test_wuffs_strconv_parse_number_f64_regular() {
|
||||
{.want = 0x46293E5939A08CEA, .str = "1e30"},
|
||||
{.want = 0x54B249AD2594C37D, .str = "+1E+100"},
|
||||
{.want = 0x54B249AD2594C37D, .str = "+_1_E_+_1_0_0_"},
|
||||
{.want = 0x54B2987670ADB613, .str = "1.0168286519992372611942638e+100"},
|
||||
{.want = 0x7BBA44DF832B8D46, .str = "1e+288"},
|
||||
{.want = 0x7BF06B0BB1FB384C, .str = "1e+289"},
|
||||
{.want = 0x7C2485CE9E7A065F, .str = "1e+290"},
|
||||
@@ -1943,6 +1944,19 @@ test_wuffs_strconv_render_number_f64() {
|
||||
"4.000",
|
||||
.want_4g = "1e+100",
|
||||
},
|
||||
{
|
||||
.x = 0x54B2987670ADB613,
|
||||
.want__e = "1.0168286519992373e+100",
|
||||
.want__f = "10168286519992373000000000000000000000000000000000"
|
||||
"00000000000000000000000000000000000000000000000000"
|
||||
"0",
|
||||
.want_0g = "1e+100",
|
||||
.want_2e = "1.02e+100",
|
||||
.want_3f = "10168286519992372611942638135241625267907715220891"
|
||||
"31363562982164291689352904657807934098133246961254"
|
||||
"4.000",
|
||||
.want_4g = "1.017e+100",
|
||||
},
|
||||
{
|
||||
.x = 0x7BBA44DF832B8D46,
|
||||
.want__e = "1e+288",
|
||||
@@ -2579,6 +2593,37 @@ test_wuffs_json_decode_interface() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_json_decode_empty_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__token_buffer tok =
|
||||
wuffs_base__slice_token__writer(g_have_slice_token);
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_json__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_json__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_json__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status =
|
||||
wuffs_json__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_json__error__bad_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_json__error__bad_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_json_decode(wuffs_base__token_buffer* tok,
|
||||
wuffs_base__io_buffer* src,
|
||||
@@ -4198,6 +4243,7 @@ proc g_tests[] = {
|
||||
test_wuffs_strconv_render_number_u64,
|
||||
test_wuffs_strconv_utf_8_next,
|
||||
|
||||
test_wuffs_json_decode_empty_input,
|
||||
test_wuffs_json_decode_end_of_data,
|
||||
test_wuffs_json_decode_interface,
|
||||
test_wuffs_json_decode_long_numbers,
|
||||
|
||||
@@ -79,6 +79,35 @@ test_wuffs_lzw_decode_interface() {
|
||||
"test/data/bricks-nodither.indexes.giflzw", 1, SIZE_MAX, 19200, 0x4F);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_lzw_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_lzw__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_lzw__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_lzw__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_lzw__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_lzw__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_lzw__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
uint64_t src_size,
|
||||
@@ -444,6 +473,7 @@ proc g_tests[] = {
|
||||
test_wuffs_lzw_decode_output_bad,
|
||||
test_wuffs_lzw_decode_output_empty,
|
||||
test_wuffs_lzw_decode_pi,
|
||||
test_wuffs_lzw_decode_truncated_input,
|
||||
test_wuffs_lzw_decode_width_0,
|
||||
test_wuffs_lzw_decode_width_1,
|
||||
|
||||
|
||||
@@ -82,6 +82,34 @@ test_wuffs_nie_decode_interface() {
|
||||
"test/data/hippopotamus.nie", 0, SIZE_MAX, 36, 28, 0xFFF5F5F5);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_nie_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_nie__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_nie__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_nie__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_nie__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_nie__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_nie__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_nie_decode_frame_config() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -134,6 +162,7 @@ proc g_tests[] = {
|
||||
|
||||
test_wuffs_nie_decode_frame_config,
|
||||
test_wuffs_nie_decode_interface,
|
||||
test_wuffs_nie_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
@@ -194,6 +194,47 @@ test_wuffs_png_decode_interface() {
|
||||
"test/data/bricks-gray.png", 0, SIZE_MAX, 160, 120, 0xFF060606);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_png_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_png__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_png__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_png__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_png__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_png__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_png__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_png_decode_multiple_idats() {
|
||||
CHECK_FOCUS(__func__);
|
||||
wuffs_png__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_png__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
return do_test__wuffs_base__image_decoder(
|
||||
wuffs_png__decoder__upcast_as__wuffs_base__image_decoder(&dec),
|
||||
"test/data/bricks-color.png", 0, SIZE_MAX, 160, 120, 0xFF022460);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_png_decode_bad_crc32_checksum_critical() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -1273,7 +1314,9 @@ proc g_tests[] = {
|
||||
test_wuffs_png_decode_metadata_exif,
|
||||
test_wuffs_png_decode_metadata_iccp,
|
||||
test_wuffs_png_decode_metadata_kvp,
|
||||
test_wuffs_png_decode_multiple_idats,
|
||||
test_wuffs_png_decode_restart_frame,
|
||||
test_wuffs_png_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
@@ -99,6 +99,34 @@ test_wuffs_tga_decode_interface() {
|
||||
"test/data/bricks-color.tga", 0, SIZE_MAX, 160, 120, 0xFF022460);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_tga_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_tga__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_tga__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_tga__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_tga__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_tga__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_tga__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ---------------- Mimic Tests
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
@@ -141,6 +169,7 @@ bench_wuffs_tga_decode_77k_24bpp() {
|
||||
proc g_tests[] = {
|
||||
|
||||
test_wuffs_tga_decode_interface,
|
||||
test_wuffs_tga_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
@@ -436,6 +436,34 @@ test_wuffs_wbmp_decode_interface() {
|
||||
"test/data/muybridge-frame-000.wbmp", 0, SIZE_MAX, 30, 20, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_wbmp_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_wbmp__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_wbmp__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_wbmp__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status = wuffs_wbmp__decoder__decode_image_config(&dec, NULL, &src);
|
||||
if (status.repr != wuffs_wbmp__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_wbmp__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_wbmp_decode_frame_config() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -653,6 +681,7 @@ proc g_tests[] = {
|
||||
test_wuffs_wbmp_decode_frame_config,
|
||||
test_wuffs_wbmp_decode_image_config,
|
||||
test_wuffs_wbmp_decode_interface,
|
||||
test_wuffs_wbmp_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
@@ -112,6 +112,36 @@ test_wuffs_zlib_decode_interface() {
|
||||
"test/data/romeo.txt.zlib", 0, SIZE_MAX, 942, 0x0A);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_zlib_decode_truncated_input() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
|
||||
wuffs_zlib__decoder dec;
|
||||
CHECK_STATUS("initialize",
|
||||
wuffs_zlib__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
|
||||
|
||||
wuffs_base__status status =
|
||||
wuffs_zlib__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_base__suspension__short_read) {
|
||||
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_base__suspension__short_read);
|
||||
}
|
||||
|
||||
src.meta.closed = true;
|
||||
status =
|
||||
wuffs_zlib__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
|
||||
if (status.repr != wuffs_zlib__error__truncated_input) {
|
||||
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
|
||||
wuffs_zlib__error__truncated_input);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
wuffs_raw_deflate_decode(wuffs_base__io_buffer* dst,
|
||||
wuffs_base__io_buffer* src,
|
||||
@@ -426,6 +456,7 @@ proc g_tests[] = {
|
||||
test_wuffs_zlib_decode_pi,
|
||||
test_wuffs_zlib_decode_raw_deflate_romeo,
|
||||
test_wuffs_zlib_decode_sheep,
|
||||
test_wuffs_zlib_decode_truncated_input,
|
||||
|
||||
#ifdef WUFFS_MIMIC
|
||||
|
||||
|
||||
Reference in new issue
Block a user