mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dee65c0e61 | ||
|
|
c27250f52f | ||
|
|
9445c8b9d0 | ||
|
|
b5ccd9e8e7 | ||
|
|
b0e9efff3f | ||
|
|
8b7f82142c | ||
|
|
b245252e1e | ||
|
|
bad2693efb | ||
|
|
be1f605108 | ||
|
|
315b2e5262 | ||
|
|
fac934b272 | ||
|
|
b8d44be783 | ||
|
|
d0f0591f64 | ||
|
|
c1283e4989 | ||
|
|
c226ed60f5 | ||
|
|
45a79923e6 | ||
|
|
67aa63297c | ||
|
|
8c33dd503b | ||
|
|
5d7b113172 | ||
|
|
886e7f3e8f | ||
|
|
fbc686f9b7 | ||
|
|
9256fe5e54 | ||
|
|
e1b43cd767 | ||
|
|
d90dde4049 |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
# Allstar (https://github.com/ossf/allstar/) is a GitHub App to set and enforce
|
||||
# security policies.
|
||||
|
||||
# test/data/archive.iso is test data, not a binary to be executed.
|
||||
ignorePaths:
|
||||
- test/data/archive.iso
|
||||
+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
|
||||
|
||||
|
||||
+14
-14
@@ -35,20 +35,20 @@
|
||||
// To quantify "much faster", on this one C file, this program was 80 times
|
||||
// faster than `clang-format`, even without a column limit:
|
||||
//
|
||||
// $ wc release/c/wuffs-v0.2.c
|
||||
// 11858 35980 431885 release/c/wuffs-v0.2.c
|
||||
// $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.008s
|
||||
// user 0m0.005s
|
||||
// sys 0m0.005s
|
||||
// $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.668s
|
||||
// user 0m0.618s
|
||||
// sys 0m0.032s
|
||||
// $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.641s
|
||||
// user 0m0.585s
|
||||
// sys 0m0.037s
|
||||
// $ wc release/c/wuffs-v0.2.c
|
||||
// 11858 35980 431885 release/c/wuffs-v0.2.c
|
||||
// $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.008s
|
||||
// user 0m0.005s
|
||||
// sys 0m0.005s
|
||||
// $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.668s
|
||||
// user 0m0.618s
|
||||
// sys 0m0.032s
|
||||
// $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.641s
|
||||
// user 0m0.585s
|
||||
// sys 0m0.037s
|
||||
//
|
||||
// More commentary is at:
|
||||
// https://godoc.org/github.com/google/wuffs/lib/dumbindent
|
||||
|
||||
+137
-137
@@ -33,7 +33,7 @@ https://github.com/google/wuffs/blob/main/doc/spec/rac-spec.md
|
||||
|
||||
Usage:
|
||||
|
||||
ractool [flags] [input_filename]
|
||||
ractool [flags] [input_filename]
|
||||
|
||||
If no input_filename is given, stdin is used. Either way, output is written to
|
||||
stdout.
|
||||
@@ -63,10 +63,10 @@ or temporary disk space.
|
||||
|
||||
Examples:
|
||||
|
||||
ractool -decode foo.rac | sha256sum
|
||||
ractool -decode -drange=400..500 foo.rac
|
||||
ractool -encode foo.dat > foo.rac
|
||||
ractool -encode -codec=zlib -dchunksize=256k foo.dat > foo.rac
|
||||
ractool -decode foo.rac | sha256sum
|
||||
ractool -decode -drange=400..500 foo.rac
|
||||
ractool -encode foo.dat > foo.rac
|
||||
ractool -encode -codec=zlib -dchunksize=256k foo.dat > foo.rac
|
||||
|
||||
The "400..500" flag value means the 100 bytes ranging from a DSpace offset
|
||||
(offset in terms of decompressed bytes, not compressed bytes) of 400
|
||||
@@ -79,42 +79,42 @@ Similarly, "1m" and "1M" both mean 1 mebibyte (1048576 bytes).
|
||||
|
||||
General Flags:
|
||||
|
||||
-decode
|
||||
whether to decode the input
|
||||
-encode
|
||||
whether to encode the input
|
||||
-quiet
|
||||
whether to suppress messages
|
||||
-decode
|
||||
whether to decode the input
|
||||
-encode
|
||||
whether to encode the input
|
||||
-quiet
|
||||
whether to suppress messages
|
||||
|
||||
Decode-Related Flags:
|
||||
|
||||
-drange
|
||||
the "i..j" range to decompress, "..8" means the first 8 bytes
|
||||
-singlethreaded
|
||||
whether to decode on a single execution thread
|
||||
-drange
|
||||
the "i..j" range to decompress, "..8" means the first 8 bytes
|
||||
-singlethreaded
|
||||
whether to decode on a single execution thread
|
||||
|
||||
Encode-Related Flags:
|
||||
|
||||
-cchunksize
|
||||
the chunk size (in CSpace)
|
||||
-codec
|
||||
the compression codec (default "zstd")
|
||||
-cpagesize
|
||||
the page size (in CSpace)
|
||||
-dchunksize
|
||||
the chunk size (in DSpace)
|
||||
-indexlocation
|
||||
the index location, "start" or "end" (default "start")
|
||||
-resources
|
||||
comma-separated list of resource files, such as shared dictionaries
|
||||
-tmpdir
|
||||
directory (e.g. $TMPDIR) for intermediate work; empty means in-memory
|
||||
-cchunksize
|
||||
the chunk size (in CSpace)
|
||||
-codec
|
||||
the compression codec (default "zstd")
|
||||
-cpagesize
|
||||
the page size (in CSpace)
|
||||
-dchunksize
|
||||
the chunk size (in DSpace)
|
||||
-indexlocation
|
||||
the index location, "start" or "end" (default "start")
|
||||
-resources
|
||||
comma-separated list of resource files, such as shared dictionaries
|
||||
-tmpdir
|
||||
directory (e.g. $TMPDIR) for intermediate work; empty means in-memory
|
||||
|
||||
Codecs:
|
||||
|
||||
lz4
|
||||
zlib
|
||||
zstd
|
||||
lz4
|
||||
zlib
|
||||
zstd
|
||||
|
||||
Only zlib is fully supported. The others will work for the flags' default
|
||||
values, but they (1) don't support -cchunksize, only -dchunksize, and (2) don't
|
||||
@@ -125,123 +125,123 @@ Installation:
|
||||
|
||||
Like any other implemented-in-Go program, to install the ractool program:
|
||||
|
||||
go install github.com/google/wuffs/cmd/ractool
|
||||
go install github.com/google/wuffs/cmd/ractool
|
||||
|
||||
Extended Example:
|
||||
|
||||
--------
|
||||
$ # Fetch and unzip the enwik8 test file, a sample of Wikipedia.
|
||||
$ wget http://mattmahoney.net/dc/enwik8.zip
|
||||
$ unzip enwik8.zip
|
||||
--------
|
||||
$ # Fetch and unzip the enwik8 test file, a sample of Wikipedia.
|
||||
$ wget http://mattmahoney.net/dc/enwik8.zip
|
||||
$ unzip enwik8.zip
|
||||
|
||||
$ # Also zstd-encode it, as a reference point. Using compression level 15,
|
||||
$ # instead of the default of 3, matches what ractool uses.
|
||||
$ zstd -15 enwik8
|
||||
$ # Also zstd-encode it, as a reference point. Using compression level 15,
|
||||
$ # instead of the default of 3, matches what ractool uses.
|
||||
$ zstd -15 enwik8
|
||||
|
||||
$ # Create a shared dictionary. Using zstd-the-program produces a
|
||||
$ # dictionary that is especially useful for zstd-the-format, but it can
|
||||
$ # also be used by other formats as a 'raw' prefix dictionary.
|
||||
$ zstd -15 --train -B64K --maxdict=32K -o dict.dat enwik8
|
||||
$ # Create a shared dictionary. Using zstd-the-program produces a
|
||||
$ # dictionary that is especially useful for zstd-the-format, but it can
|
||||
$ # also be used by other formats as a 'raw' prefix dictionary.
|
||||
$ zstd -15 --train -B64K --maxdict=32K -o dict.dat enwik8
|
||||
|
||||
$ # RAC-encode it with various codecs, with and without that dictionary.
|
||||
$ ractool -encode -codec=zlib -resources=dict.dat enwik8 > zlib.withdict.rac
|
||||
$ ractool -encode -codec=zlib enwik8 > zlib.sansdict.rac
|
||||
$ ractool -encode -codec=zstd -resources=dict.dat enwik8 > zstd.withdict.rac
|
||||
$ ractool -encode -codec=zstd enwik8 > zstd.sansdict.rac
|
||||
$ ractool -encode -codec=lz4 enwik8 > lz4.sansdict.rac
|
||||
$ # RAC-encode it with various codecs, with and without that dictionary.
|
||||
$ ractool -encode -codec=zlib -resources=dict.dat enwik8 > zlib.withdict.rac
|
||||
$ ractool -encode -codec=zlib enwik8 > zlib.sansdict.rac
|
||||
$ ractool -encode -codec=zstd -resources=dict.dat enwik8 > zstd.withdict.rac
|
||||
$ ractool -encode -codec=zstd enwik8 > zstd.sansdict.rac
|
||||
$ ractool -encode -codec=lz4 enwik8 > lz4.sansdict.rac
|
||||
|
||||
$ # The size overhead (comparing RAC+Xxx to Xxx) is about 0.2% (with) or
|
||||
$ # 4.8% (sans) for zlib/zip and about 13% (with) or 28% (sans) for zstd,
|
||||
$ # depending on whether we used a shared dictionary (with or sans).
|
||||
$ ls -l
|
||||
total 362080
|
||||
-rw-r----- 1 tao tao 32768 Oct 25 10:10 dict.dat
|
||||
-rw-r----- 1 tao tao 100000000 Jun 2 2011 enwik8
|
||||
-rw-r----- 1 tao tao 36445475 Sep 2 2011 enwik8.zip
|
||||
-rw-r----- 1 tao tao 29563109 Jun 2 2011 enwik8.zst
|
||||
-rw-r----- 1 tao tao 58813316 Oct 25 10:17 lz4.sansdict.rac
|
||||
-rw-r----- 1 tao tao 38185178 Oct 25 10:16 zlib.sansdict.rac
|
||||
-rw-r----- 1 tao tao 36505786 Oct 25 10:16 zlib.withdict.rac
|
||||
-rw-r----- 1 tao tao 37820491 Oct 25 10:17 zstd.sansdict.rac
|
||||
-rw-r----- 1 tao tao 33386395 Oct 25 10:17 zstd.withdict.rac
|
||||
$ # The size overhead (comparing RAC+Xxx to Xxx) is about 0.2% (with) or
|
||||
$ # 4.8% (sans) for zlib/zip and about 13% (with) or 28% (sans) for zstd,
|
||||
$ # depending on whether we used a shared dictionary (with or sans).
|
||||
$ ls -l
|
||||
total 362080
|
||||
-rw-r----- 1 tao tao 32768 Oct 25 10:10 dict.dat
|
||||
-rw-r----- 1 tao tao 100000000 Jun 2 2011 enwik8
|
||||
-rw-r----- 1 tao tao 36445475 Sep 2 2011 enwik8.zip
|
||||
-rw-r----- 1 tao tao 29563109 Jun 2 2011 enwik8.zst
|
||||
-rw-r----- 1 tao tao 58813316 Oct 25 10:17 lz4.sansdict.rac
|
||||
-rw-r----- 1 tao tao 38185178 Oct 25 10:16 zlib.sansdict.rac
|
||||
-rw-r----- 1 tao tao 36505786 Oct 25 10:16 zlib.withdict.rac
|
||||
-rw-r----- 1 tao tao 37820491 Oct 25 10:17 zstd.sansdict.rac
|
||||
-rw-r----- 1 tao tao 33386395 Oct 25 10:17 zstd.withdict.rac
|
||||
|
||||
$ # Check that the decompressed forms all match.
|
||||
$ cat enwik8 | sha256sum
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
$ unzip -p enwik8.zip | sha256sum
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
$ unzstd --stdout enwik8.zst | sha256sum
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
$ for f in *.rac; do ractool -decode $f | sha256sum; done
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
$ # Check that the decompressed forms all match.
|
||||
$ cat enwik8 | sha256sum
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
$ unzip -p enwik8.zip | sha256sum
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
$ unzstd --stdout enwik8.zst | sha256sum
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
$ for f in *.rac; do ractool -decode $f | sha256sum; done
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
2b49720ec4d78c3c9fabaee6e4179a5e997302b3a70029f30f2d582218c024a8 -
|
||||
|
||||
$ # Compare how long it takes to produce 8 bytes from the middle of
|
||||
$ # the decompressed file, which happens to be the word "Business".
|
||||
$ time unzip -p enwik8.zip | dd if=/dev/stdin status=none \
|
||||
> iflag=skip_bytes,count_bytes skip=50000000 count=8
|
||||
Business
|
||||
real 0m0.379s
|
||||
user 0m0.410s
|
||||
sys 0m0.080s
|
||||
$ time unzstd --stdout enwik8.zst | dd if=/dev/stdin status=none \
|
||||
> iflag=skip_bytes,count_bytes skip=50000000 count=8
|
||||
Business
|
||||
real 0m0.172s
|
||||
user 0m0.141s
|
||||
sys 0m0.103s
|
||||
$ time ractool -decode -drange=50000000..50000008 zstd.withdict.rac
|
||||
Business
|
||||
real 0m0.004s
|
||||
user 0m0.005s
|
||||
sys 0m0.001s
|
||||
$ # Compare how long it takes to produce 8 bytes from the middle of
|
||||
$ # the decompressed file, which happens to be the word "Business".
|
||||
$ time unzip -p enwik8.zip | dd if=/dev/stdin status=none \
|
||||
> iflag=skip_bytes,count_bytes skip=50000000 count=8
|
||||
Business
|
||||
real 0m0.379s
|
||||
user 0m0.410s
|
||||
sys 0m0.080s
|
||||
$ time unzstd --stdout enwik8.zst | dd if=/dev/stdin status=none \
|
||||
> iflag=skip_bytes,count_bytes skip=50000000 count=8
|
||||
Business
|
||||
real 0m0.172s
|
||||
user 0m0.141s
|
||||
sys 0m0.103s
|
||||
$ time ractool -decode -drange=50000000..50000008 zstd.withdict.rac
|
||||
Business
|
||||
real 0m0.004s
|
||||
user 0m0.005s
|
||||
sys 0m0.001s
|
||||
|
||||
$ # A RAC file's chunks can be decoded in parallel, unlike ZIP,
|
||||
$ # substantially reducing the real (wall clock) time taken even
|
||||
$ # though both of these files use DEFLATE (RFC 1951) compression.
|
||||
$ #
|
||||
$ # Comparing the -singlethreaded time suggests that zlib-the-library's
|
||||
$ # DEFLATE implementation is faster than unzip's.
|
||||
$ time unzip -p enwik8.zip > /dev/null
|
||||
real 0m0.711s
|
||||
user 0m0.690s
|
||||
sys 0m0.021s
|
||||
$ time ractool -decode -singlethreaded zlib.withdict.rac > /dev/null
|
||||
real 0m0.519s
|
||||
user 0m0.513s
|
||||
sys 0m0.017s
|
||||
$ time ractool -decode zlib.withdict.rac > /dev/null
|
||||
real 0m0.052s
|
||||
user 0m0.678s
|
||||
sys 0m0.036s
|
||||
$ # A RAC file's chunks can be decoded in parallel, unlike ZIP,
|
||||
$ # substantially reducing the real (wall clock) time taken even
|
||||
$ # though both of these files use DEFLATE (RFC 1951) compression.
|
||||
$ #
|
||||
$ # Comparing the -singlethreaded time suggests that zlib-the-library's
|
||||
$ # DEFLATE implementation is faster than unzip's.
|
||||
$ time unzip -p enwik8.zip > /dev/null
|
||||
real 0m0.711s
|
||||
user 0m0.690s
|
||||
sys 0m0.021s
|
||||
$ time ractool -decode -singlethreaded zlib.withdict.rac > /dev/null
|
||||
real 0m0.519s
|
||||
user 0m0.513s
|
||||
sys 0m0.017s
|
||||
$ time ractool -decode zlib.withdict.rac > /dev/null
|
||||
real 0m0.052s
|
||||
user 0m0.678s
|
||||
sys 0m0.036s
|
||||
|
||||
$ # A similar comparison can be made for Zstandard.
|
||||
$ time unzstd --stdout enwik8.zst > /dev/null
|
||||
real 0m0.203s
|
||||
user 0m0.187s
|
||||
sys 0m0.016s
|
||||
$ time ractool -decode -singlethreaded zstd.withdict.rac > /dev/null
|
||||
real 0m0.235s
|
||||
user 0m0.206s
|
||||
sys 0m0.033s
|
||||
$ time ractool -decode zstd.withdict.rac > /dev/null
|
||||
real 0m0.037s
|
||||
user 0m0.374s
|
||||
sys 0m0.080s
|
||||
$ # A similar comparison can be made for Zstandard.
|
||||
$ time unzstd --stdout enwik8.zst > /dev/null
|
||||
real 0m0.203s
|
||||
user 0m0.187s
|
||||
sys 0m0.016s
|
||||
$ time ractool -decode -singlethreaded zstd.withdict.rac > /dev/null
|
||||
real 0m0.235s
|
||||
user 0m0.206s
|
||||
sys 0m0.033s
|
||||
$ time ractool -decode zstd.withdict.rac > /dev/null
|
||||
real 0m0.037s
|
||||
user 0m0.374s
|
||||
sys 0m0.080s
|
||||
|
||||
$ # For reference, LZ4 numbers.
|
||||
$ time ractool -decode -singlethreaded lz4.sansdict.rac > /dev/null
|
||||
real 0m0.072s
|
||||
user 0m0.053s
|
||||
sys 0m0.021s
|
||||
$ time ractool -decode lz4.sansdict.rac > /dev/null
|
||||
real 0m0.024s
|
||||
user 0m0.097s
|
||||
sys 0m0.034s
|
||||
--------
|
||||
$ # For reference, LZ4 numbers.
|
||||
$ time ractool -decode -singlethreaded lz4.sansdict.rac > /dev/null
|
||||
real 0m0.072s
|
||||
user 0m0.053s
|
||||
sys 0m0.021s
|
||||
$ time ractool -decode lz4.sansdict.rac > /dev/null
|
||||
real 0m0.024s
|
||||
user 0m0.097s
|
||||
sys 0m0.034s
|
||||
--------
|
||||
*/
|
||||
package main
|
||||
|
||||
|
||||
+262
-204
@@ -5,20 +5,34 @@ below. Higher is better.
|
||||
|
||||
"Mimic" tests check that Wuffs' output mimics (i.e. exactly matches) other
|
||||
libraries' output. "Mimic" benchmarks give the numbers for those other
|
||||
libraries, as shipped with Debian. These were measured on a Debian Testing
|
||||
system as of October 2019, which meant these compiler versions:
|
||||
libraries, as shipped with Debian. These were measured on a Debian Bullseye
|
||||
system as of September 2022, which meant these compiler versions:
|
||||
|
||||
- clang/llvm 8.0.1
|
||||
- gcc 9.2.1
|
||||
- clang/llvm 11.0.1
|
||||
- gcc 10.2.1
|
||||
|
||||
and these "mimic" library versions, all written in C:
|
||||
and these popular "mimic" library versions, all written in C:
|
||||
|
||||
- libgif 5.1.4
|
||||
- zlib 1.2.11
|
||||
- libbz2 1.0.8
|
||||
- libgif 5.1.9
|
||||
- libpng 1.6.37
|
||||
- zlib 1.2.11 (we'll call this "ztl" or "zlib the library", as opposed to "zlib
|
||||
the format")
|
||||
|
||||
Unless otherwise stated, the numbers below were measured on an Intel x86\_64
|
||||
Broadwell, and were taken as of Wuffs git commit ffdce5ef "Have bench-rust-gif
|
||||
process animated / RGBA images".
|
||||
and these alternative "mimic" library versions, again all written in C:
|
||||
|
||||
- [libdeflate](https://github.com/ebiggers/libdeflate) 1.7.1
|
||||
- [libspng](https://github.com/randy408/libspng) 0.7.3
|
||||
- [lodepng](https://github.com/lvandeve/lodepng) 20220717
|
||||
- [miniz](https://github.com/richgel999/miniz) 2.2.0
|
||||
- [stb](https://github.com/nothings/stb) 2.27
|
||||
|
||||
Unless otherwise stated, the numbers below were taken as of Wuffs git commit
|
||||
315b2e52 "wuffs gen -version=0.3.0-rc.1", the first Wuffs v0.3 release
|
||||
candidate. As for the CPU model:
|
||||
|
||||
$ cat /proc/cpuinfo | grep model.name | uniq
|
||||
model name: Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
|
||||
|
||||
|
||||
## Reproducing
|
||||
@@ -89,65 +103,110 @@ power management can be controlled with:
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes are hashed.
|
||||
|
||||
name speed vs_mimic
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_adler32_10k/clang8 2.41GB/s 0.84x
|
||||
wuffs_adler32_100k/clang8 2.42GB/s 0.84x
|
||||
wuffs_adler32_10k/clang11 22.3 GB/s 6.4x
|
||||
wuffs_adler32_100k/clang11 26.4 GB/s 7.5x
|
||||
|
||||
wuffs_adler32_10k/gcc9 3.24GB/s 1.13x
|
||||
wuffs_adler32_100k/gcc9 3.24GB/s 1.12x
|
||||
wuffs_adler32_10k/gcc10 21.9 GB/s 6.3x
|
||||
wuffs_adler32_100k/gcc10 22.4 GB/s 6.4x
|
||||
|
||||
mimic_adler32_10k 2.87GB/s 1.00x
|
||||
mimic_adler32_100k 2.90GB/s 1.00x
|
||||
mimicztl_adler32_10k 3.50 GB/s 1.0x
|
||||
mimicztl_adler32_100k 3.52 GB/s 1.0x
|
||||
|
||||
mimiclibdeflate_adler32_10k 50.4 GB/s 14.4x
|
||||
mimiclibdeflate_adler32_100k 49.4 GB/s 14.0x
|
||||
|
||||
|
||||
# Bzip2
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there are in the
|
||||
decoded output.
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_bzip2_decode_10k/clang11 63.0 MB/s 1.86x
|
||||
wuffs_bzip2_decode_100k/clang11 48.9 MB/s 1.62x
|
||||
|
||||
wuffs_bzip2_decode_10k/gcc10 61.1 MB/s 1.81x
|
||||
wuffs_bzip2_decode_100k/gcc10 49.1 MB/s 1.62x
|
||||
|
||||
mimic_bzip2_decode_10k 33.8 MB/s 1.00x
|
||||
mimic_bzip2_decode_100k 30.2 MB/s 1.00x
|
||||
|
||||
|
||||
# CRC-32
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes are hashed.
|
||||
|
||||
name speed vs_mimic
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_crc32_ieee_10k/clang8 2.85GB/s 2.11x
|
||||
wuffs_crc32_ieee_100k/clang8 2.87GB/s 2.13x
|
||||
wuffs_crc32_ieee_10k/clang11 14.7 GB/s 9.1x
|
||||
wuffs_crc32_ieee_100k/clang11 21.6 GB/s 13.3x
|
||||
|
||||
wuffs_crc32_ieee_10k/gcc9 3.38GB/s 2.50x
|
||||
wuffs_crc32_ieee_100k/gcc9 3.40GB/s 2.52x
|
||||
wuffs_crc32_ieee_10k/gcc10 14.9 GB/s 9.2x
|
||||
wuffs_crc32_ieee_100k/gcc10 23.8 GB/s 14.7x
|
||||
|
||||
mimic_crc32_ieee_10k 1.35GB/s 1.00x
|
||||
mimic_crc32_ieee_100k 1.35GB/s 1.00x
|
||||
mimicztl_crc32_ieee_10k 1.62 GB/s 1.0x
|
||||
mimicztl_crc32_ieee_100k 1.62 GB/s 1.0x
|
||||
|
||||
mimiclibdeflate_crc32_ieee_10k 24.6 GB/s 15.2x
|
||||
mimiclibdeflate_crc32_ieee_100k 25.4 GB/s 15.7x
|
||||
|
||||
|
||||
# Deflate
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there in the
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there are in the
|
||||
decoded output.
|
||||
|
||||
The `full_init` vs `part_init` suffixes are whether
|
||||
[`WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED`](/doc/note/initialization.md#partial-zero-initialization)
|
||||
is unset or set.
|
||||
|
||||
name speed vs_mimic
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_deflate_decode_1k_full_init/clang8 160MB/s 0.74x
|
||||
wuffs_deflate_decode_1k_part_init/clang8 199MB/s 0.92x
|
||||
wuffs_deflate_decode_10k_full_init/clang8 255MB/s 0.94x
|
||||
wuffs_deflate_decode_10k_part_init/clang8 263MB/s 0.97x
|
||||
wuffs_deflate_decode_100k_just_one_read/clang8 306MB/s 0.93x
|
||||
wuffs_deflate_decode_100k_many_big_reads/clang8 250MB/s 0.98x
|
||||
wuffs_deflate_decode_1k_full_init/clang11 195 MB/s 0.81x
|
||||
wuffs_deflate_decode_1k_part_init/clang11 226 MB/s 0.93x
|
||||
wuffs_deflate_decode_10k_full_init/clang11 409 MB/s 1.41x
|
||||
wuffs_deflate_decode_10k_part_init/clang11 418 MB/s 1.47x
|
||||
wuffs_deflate_decode_100k_just_one_read/clang11 521 MB/s 1.48x
|
||||
wuffs_deflate_decode_100k_many_big_reads/clang11 330 MB/s 1.19x
|
||||
|
||||
wuffs_deflate_decode_1k_full_init/gcc9 164MB/s 0.76x
|
||||
wuffs_deflate_decode_1k_part_init/gcc9 207MB/s 0.95x
|
||||
wuffs_deflate_decode_10k_full_init/gcc9 247MB/s 0.91x
|
||||
wuffs_deflate_decode_10k_part_init/gcc9 254MB/s 0.94x
|
||||
wuffs_deflate_decode_100k_just_one_read/gcc9 333MB/s 1.01x
|
||||
wuffs_deflate_decode_100k_many_big_reads/gcc9 261MB/s 1.02x
|
||||
wuffs_deflate_decode_1k_full_init/gcc10 183 MB/s 0.76x
|
||||
wuffs_deflate_decode_1k_part_init/gcc10 217 MB/s 0.90x
|
||||
wuffs_deflate_decode_10k_full_init/gcc10 402 MB/s 1.39x
|
||||
wuffs_deflate_decode_10k_part_init/gcc10 414 MB/s 1.43x
|
||||
wuffs_deflate_decode_100k_just_one_read/gcc10 522 MB/s 1.48x
|
||||
wuffs_deflate_decode_100k_many_big_reads/gcc10 330 MB/s 1.19x
|
||||
|
||||
mimic_deflate_decode_1k 217MB/s 1.00x
|
||||
mimic_deflate_decode_10k 270MB/s 1.00x
|
||||
mimic_deflate_decode_100k_just_one_read 329MB/s 1.00x
|
||||
mimic_deflate_decode_100k_many_big_reads 256MB/s 1.00x
|
||||
mimicztl_deflate_decode_1k_full_init 241 MB/s 1.00x
|
||||
mimicztl_deflate_decode_10k_full_init 289 MB/s 1.00x
|
||||
mimicztl_deflate_decode_100k_just_one_read 352 MB/s 1.00x
|
||||
mimicztl_deflate_decode_100k_many_big_reads 277 MB/s 1.00x
|
||||
|
||||
32-bit ARMv7 (2012 era Samsung Exynos 5 Chromebook), Debian Stretch (2017):
|
||||
mimiclibdeflate_deflate_decode_1k_full_init 326 MB/s 1.35x
|
||||
mimiclibdeflate_deflate_decode_10k_full_init 503 MB/s 1.74x
|
||||
mimiclibdeflate_deflate_decode_100k_just_one_read 507 MB/s 1.44x
|
||||
|
||||
mimicminiz_deflate_decode_1k_full_init 204 MB/s 0.85x
|
||||
mimicminiz_deflate_decode_10k_full_init 252 MB/s 0.87x
|
||||
mimicminiz_deflate_decode_100k_just_one_read 287 MB/s 0.82x
|
||||
|
||||
go_deflate_decode_1k_full_init 71 MB/s 0.29x
|
||||
go_deflate_decode_10k_full_init 120 MB/s 0.42x
|
||||
go_deflate_decode_100k_just_one_read 135 MB/s 0.38x
|
||||
|
||||
rust_deflate_decode_1k_full_init 165 MB/s 0.68x
|
||||
rust_deflate_decode_10k_full_init 259 MB/s 0.90x
|
||||
rust_deflate_decode_100k_just_one_read 272 MB/s 0.77x
|
||||
|
||||
To reproduce the libdeflate or miniz numbers, look in
|
||||
`test/c/mimiclib/deflate-gzip-zlib.c`. For Go 1.19, run `go run main.go` in
|
||||
`script/bench-go-deflate`. For Rust 1.48 / flate2 1.0.24 / miniz\_oxide 0.5.3,
|
||||
run `cargo run --release` in `script/bench-rust-deflate`.
|
||||
|
||||
Historical (Wuffs v0.2; 2019) numbers for 32-bit ARMv7 (2012 era Samsung Exynos
|
||||
5 Chromebook), Debian Stretch (2017):
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
@@ -171,63 +230,6 @@ is unset or set.
|
||||
mimic_deflate_decode_100k_many_big_reads 90.0MB/s 1.00x
|
||||
|
||||
|
||||
## Deflate (C, miniz)
|
||||
|
||||
For comparison, here are [miniz](https://github.com/richgel999/miniz) 2.1.0's
|
||||
numbers.
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
miniz_deflate_decode_1k/clang8 174MB/s 0.80x
|
||||
miniz_deflate_decode_10k/clang8 245MB/s 0.91x
|
||||
miniz_deflate_decode_100k_just_one_read/clang8 309MB/s 0.94x
|
||||
|
||||
miniz_deflate_decode_1k/gcc9 158MB/s 0.73x
|
||||
miniz_deflate_decode_10k/gcc9 221MB/s 0.82x
|
||||
miniz_deflate_decode_100k_just_one_read/gcc9 250MB/s 0.76x
|
||||
|
||||
To reproduce these numbers, look in `test/c/mimiclib/deflate-gzip-zlib.c`.
|
||||
|
||||
|
||||
## Deflate (Go)
|
||||
|
||||
For comparison, here are Go 1.12.10's numbers, using Go's standard library's
|
||||
`compress/flate` package.
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
go_deflate_decode_1k 45.4MB/s 0.21x
|
||||
go_deflate_decode_10k 82.5MB/s 0.31x
|
||||
go_deflate_decode_100k 94.0MB/s 0.29x
|
||||
|
||||
To reproduce these numbers:
|
||||
|
||||
git clone https://github.com/google/wuffs.git
|
||||
cd wuffs/script/bench-go-deflate/
|
||||
go run main.go
|
||||
|
||||
|
||||
## Deflate (Rust)
|
||||
|
||||
For comparison, here are Rust 1.37.0's numbers, using the
|
||||
[alexcrichton/flate2-rs](https://github.com/alexcrichton/flate2-rs) and
|
||||
[Frommi/miniz_oxide](https://github.com/Frommi/miniz_oxide) crates, which [this
|
||||
file](https://github.com/sile/libflate/blob/77a1004edf6518a0badab7ce8837bc5338ff9bc3/README.md#an-informal-benchmark)
|
||||
suggests is the fastest pure-Rust Deflate decoder.
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
rust_deflate_decode_1k 104MB/s 0.48x
|
||||
rust_deflate_decode_10k 202MB/s 0.75x
|
||||
rust_deflate_decode_100k 218MB/s 0.66x
|
||||
|
||||
To reproduce these numbers:
|
||||
|
||||
git clone https://github.com/google/wuffs.git
|
||||
cd wuffs/script/bench-rust-deflate/
|
||||
cargo run --release
|
||||
|
||||
|
||||
# GIF
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many pixels there are in
|
||||
@@ -245,42 +247,67 @@ is unset or set.
|
||||
The libgif library doesn't export any API for decode-to-BGRA or decode-to-RGBA,
|
||||
so there are no mimic numbers to compare to for the `bgra` suffix.
|
||||
|
||||
name speed vs_mimic
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_gif_decode_1k_bw/clang8 461MB/s 3.18x
|
||||
wuffs_gif_decode_1k_color_full_init/clang8 141MB/s 1.85x
|
||||
wuffs_gif_decode_1k_color_part_init/clang8 189MB/s 2.48x
|
||||
wuffs_gif_decode_10k_bgra/clang8 743MB/s n/a
|
||||
wuffs_gif_decode_10k_indexed/clang8 200MB/s 2.11x
|
||||
wuffs_gif_decode_20k/clang8 245MB/s 2.50x
|
||||
wuffs_gif_decode_100k_artificial/clang8 531MB/s 3.43x
|
||||
wuffs_gif_decode_100k_realistic/clang8 218MB/s 2.27x
|
||||
wuffs_gif_decode_1000k_full_init/clang8 221MB/s 2.25x
|
||||
wuffs_gif_decode_1000k_part_init/clang8 221MB/s 2.25x
|
||||
wuffs_gif_decode_anim_screencap/clang8 1.07GB/s 6.01x
|
||||
wuffs_gif_decode_1k_bw/clang11 758 MB/s 4.38x
|
||||
wuffs_gif_decode_1k_color_full_init/clang11 176 MB/s 1.96x
|
||||
wuffs_gif_decode_1k_color_part_init/clang11 213 MB/s 2.37x
|
||||
wuffs_gif_decode_10k_bgra/clang11 786 MB/s n/a
|
||||
wuffs_gif_decode_10k_indexed/clang11 208 MB/s 1.98x
|
||||
wuffs_gif_decode_20k/clang11 262 MB/s 2.47x
|
||||
wuffs_gif_decode_100k_artificial/clang11 580 MB/s 3.52x
|
||||
wuffs_gif_decode_100k_realistic/clang11 225 MB/s 2.18x
|
||||
wuffs_gif_decode_1000k_full_init/clang11 229 MB/s 2.16x
|
||||
wuffs_gif_decode_1000k_part_init/clang11 229 MB/s 2.16x
|
||||
wuffs_gif_decode_anim_screencap/clang11 1.31 GB/s 6.58x
|
||||
|
||||
wuffs_gif_decode_1k_bw/gcc9 478MB/s 3.30x
|
||||
wuffs_gif_decode_1k_color_full_init/gcc9 148MB/s 1.94x
|
||||
wuffs_gif_decode_1k_color_part_init/gcc9 194MB/s 2.54x
|
||||
wuffs_gif_decode_10k_bgra/gcc9 645MB/s n/a
|
||||
wuffs_gif_decode_10k_indexed/gcc9 203MB/s 2.14x
|
||||
wuffs_gif_decode_20k/gcc9 244MB/s 2.49x
|
||||
wuffs_gif_decode_100k_artificial/gcc9 532MB/s 3.43x
|
||||
wuffs_gif_decode_100k_realistic/gcc9 214MB/s 2.23x
|
||||
wuffs_gif_decode_1000k_full_init/gcc9 217MB/s 2.21x
|
||||
wuffs_gif_decode_1000k_part_init/gcc9 218MB/s 2.22x
|
||||
wuffs_gif_decode_anim_screencap/gcc9 1.11GB/s 6.24x
|
||||
wuffs_gif_decode_1k_bw/gcc10 659 MB/s 3.80x
|
||||
wuffs_gif_decode_1k_color_full_init/gcc10 175 MB/s 1.94x
|
||||
wuffs_gif_decode_1k_color_part_init/gcc10 202 MB/s 2.24x
|
||||
wuffs_gif_decode_10k_bgra/gcc10 768 MB/s n/a
|
||||
wuffs_gif_decode_10k_indexed/gcc10 202 MB/s 1.92x
|
||||
wuffs_gif_decode_20k/gcc10 250 MB/s 2.36x
|
||||
wuffs_gif_decode_100k_artificial/gcc10 564 MB/s 3.42x
|
||||
wuffs_gif_decode_100k_realistic/gcc10 217 MB/s 2.11x
|
||||
wuffs_gif_decode_1000k_full_init/gcc10 221 MB/s 2.08x
|
||||
wuffs_gif_decode_1000k_part_init/gcc10 221 MB/s 2.08x
|
||||
wuffs_gif_decode_anim_screencap/gcc10 1.31 GB/s 6.58x
|
||||
|
||||
mimic_gif_decode_1k_bw 145MB/s 1.00x
|
||||
mimic_gif_decode_1k_color 76.3MB/s 1.00x
|
||||
mimic_gif_decode_10k_indexed 94.9MB/s 1.00x
|
||||
mimic_gif_decode_20k 98.1MB/s 1.00x
|
||||
mimic_gif_decode_100k_artificial 155MB/s 1.00x
|
||||
mimic_gif_decode_100k_realistic 96.1MB/s 1.00x
|
||||
mimic_gif_decode_1000k 98.4MB/s 1.00x
|
||||
mimic_gif_decode_anim_screencap 178MB/s 1.00x
|
||||
mimic_gif_decode_1k_bw 173 MB/s 1.00x
|
||||
mimic_gif_decode_1k_color_full_init 90 MB/s 1.00x
|
||||
mimic_gif_decode_10k_indexed 105 MB/s 1.00x
|
||||
mimic_gif_decode_20k 106 MB/s 1.00x
|
||||
mimic_gif_decode_100k_artificial 165 MB/s 1.00x
|
||||
mimic_gif_decode_100k_realistic 103 MB/s 1.00x
|
||||
mimic_gif_decode_1000k_full_init 106 MB/s 1.00x
|
||||
mimic_gif_decode_anim_screencap 199 MB/s 1.00x
|
||||
|
||||
32-bit ARMv7 (2012 era Samsung Exynos 5 Chromebook), Debian Stretch (2017):
|
||||
go_gif_decode_1k_bw 167 MB/s 0.97x
|
||||
go_gif_decode_1k_color_full_init 63 MB/s 0.70x
|
||||
go_gif_decode_10k_bgra 216 MB/s n/a
|
||||
go_gif_decode_10k_indexed 92 MB/s 0.88x
|
||||
go_gif_decode_20k 102 MB/s 0.96x
|
||||
go_gif_decode_100k_artificial 202 MB/s 1.22x
|
||||
go_gif_decode_100k_realistic 102 MB/s 0.99x
|
||||
go_gif_decode_1000k_full_init 103 MB/s 0.97x
|
||||
go_gif_decode_anim_screencap 237 MB/s 1.19x
|
||||
|
||||
rust_gif_decode_1k_bw 362 MB/s 2.09x
|
||||
rust_gif_decode_1k_color_full_init 113 MB/s 1.26x
|
||||
rust_gif_decode_10k_bgra 333 MB/s n/a
|
||||
rust_gif_decode_10k_indexed 101 MB/s 0.96x
|
||||
rust_gif_decode_20k 119 MB/s 1.12x
|
||||
rust_gif_decode_100k_artificial 248 MB/s 1.50x
|
||||
rust_gif_decode_100k_realistic 113 MB/s 1.10x
|
||||
rust_gif_decode_1000k_full_init 115 MB/s 1.08x
|
||||
rust_gif_decode_anim_screencap 513 MB/s 2.58x
|
||||
|
||||
To reproduce the Go 1.19 numbers, run `go run main.go` in
|
||||
`script/bench-go-gif`. For Rust 1.48 / gif 0.11.4, run `cargo run --release` in
|
||||
`script/bench-rust-gif`.
|
||||
|
||||
Historical (Wuffs v0.2; 2019) numbers for 32-bit ARMv7 (2012 era Samsung Exynos
|
||||
5 Chromebook), Debian Stretch (2017):
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
@@ -318,106 +345,137 @@ so there are no mimic numbers to compare to for the `bgra` suffix.
|
||||
mimic_gif_decode_anim_screencap 60.3MB/s 1.00x
|
||||
|
||||
|
||||
## GIF (Go)
|
||||
|
||||
For comparison, here are Go 1.12.10's numbers, using Go's standard library's
|
||||
`image/gif` package.
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
go_gif_decode_1k_bw 107MB/s 0.74x
|
||||
go_gif_decode_1k_color 39.2MB/s 0.51x
|
||||
go_gif_decode_10k_bgra 117MB/s n/a
|
||||
go_gif_decode_10k_indexed 57.8MB/s 0.61x
|
||||
go_gif_decode_20k 67.2MB/s 0.69x
|
||||
go_gif_decode_100k_artificial 151MB/s 0.97x
|
||||
go_gif_decode_100k_realistic 67.2MB/s 0.70x
|
||||
go_gif_decode_1000k 68.1MB/s 0.69x
|
||||
go_gif_decode_anim_screencap 206MB/s 1.16x
|
||||
|
||||
To reproduce these numbers:
|
||||
|
||||
git clone https://github.com/google/wuffs.git
|
||||
cd wuffs/script/bench-go-gif/
|
||||
go run main.go
|
||||
|
||||
|
||||
## GIF (Rust)
|
||||
|
||||
For comparison, here are Rust 1.37.0's numbers, using the
|
||||
[image-rs/image-gif](https://github.com/image-rs/image-gif) crate, easily the
|
||||
top `crates.io` result for ["gif"](https://crates.io/search?q=gif).
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
rust_gif_decode_1k_bw 89.2MB/s 0.62x
|
||||
rust_gif_decode_1k_color 20.7MB/s 0.27x
|
||||
rust_gif_decode_10k_bgra 74.5MB/s n/a
|
||||
rust_gif_decode_10k_indexed 20.4MB/s 0.21x
|
||||
rust_gif_decode_20k 28.9MB/s 0.29x
|
||||
rust_gif_decode_100k_artificial 79.1MB/s 0.51x
|
||||
rust_gif_decode_100k_realistic 27.9MB/s 0.29x
|
||||
rust_gif_decode_1000k 27.9MB/s 0.28x
|
||||
rust_gif_decode_anim_screencap 144MB/s 0.81x
|
||||
|
||||
To reproduce these numbers:
|
||||
|
||||
git clone https://github.com/google/wuffs.git
|
||||
cd wuffs/script/bench-rust-gif/
|
||||
cargo run --release
|
||||
|
||||
|
||||
# Gzip (Deflate + CRC-32)
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there in the
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there are in the
|
||||
decoded output.
|
||||
|
||||
name speed vs_mimic
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_gzip_decode_10k/clang8 238MB/s 1.05x
|
||||
wuffs_gzip_decode_100k/clang8 273MB/s 1.03x
|
||||
wuffs_gzip_decode_10k/clang11 420 MB/s 1.71x
|
||||
wuffs_gzip_decode_100k/clang11 527 MB/s 1.81x
|
||||
|
||||
wuffs_gzip_decode_10k/gcc9 239MB/s 1.06x
|
||||
wuffs_gzip_decode_100k/gcc9 297MB/s 1.12x
|
||||
wuffs_gzip_decode_10k/gcc10 427 MB/s 1.74x
|
||||
wuffs_gzip_decode_100k/gcc10 550 MB/s 1.89x
|
||||
|
||||
mimic_gzip_decode_10k 226MB/s 1.00x
|
||||
mimic_gzip_decode_100k 265MB/s 1.00x
|
||||
mimicztl_gzip_decode_10k 246 MB/s 1.00x
|
||||
mimicztl_gzip_decode_100k 291 MB/s 1.00x
|
||||
|
||||
mimiclibdeflate_gzip_decode_10k 494 MB/s 2.01x
|
||||
mimiclibdeflate_gzip_decode_100k 496 MB/s 1.70x
|
||||
|
||||
|
||||
# LZW
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there in the
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there are in the
|
||||
decoded output.
|
||||
|
||||
The libgif library doesn't export its LZW decoder in its API, so there are no
|
||||
mimic numbers to compare to.
|
||||
|
||||
name speed vs_mimic
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_lzw_decode_20k/clang8 263MB/s n/a
|
||||
wuffs_lzw_decode_100k/clang8 438MB/s n/a
|
||||
wuffs_lzw_decode_20k/clang11 293 MB/s n/a
|
||||
wuffs_lzw_decode_100k/clang11 489 MB/s n/a
|
||||
|
||||
wuffs_lzw_decode_20k/gcc9 266MB/s n/a
|
||||
wuffs_lzw_decode_100k/gcc9 450MB/s n/a
|
||||
wuffs_lzw_decode_20k/gcc10 259 MB/s n/a
|
||||
wuffs_lzw_decode_100k/gcc10 516 MB/s n/a
|
||||
|
||||
|
||||
# PNG
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there are in the
|
||||
decoded image. For example, the `test/data/harvesters.*` images are 1165 × 859,
|
||||
approximately 1000k pixels and hence 4000k bytes at 4 bytes per pixel.
|
||||
|
||||
The `full_init` vs `part_init` suffixes are whether
|
||||
[`WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED`](/doc/note/initialization.md#partial-zero-initialization)
|
||||
is unset or set.
|
||||
|
||||
libpng's "simplified API" doesn't provide a way to ignore the checksum. We copy
|
||||
the `verify_checksum` numbers for a 1.00x baseline.
|
||||
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_png_decode_image_19k_8bpp/clang11 279 MB/s 2.29x
|
||||
wuffs_png_decode_image_40k_24bpp/clang11 323 MB/s 2.20x
|
||||
wuffs_png_decode_image_77k_8bpp/clang11 984 MB/s 2.66x
|
||||
wuffs_png_decode_image_552k_32bpp_ignore_checksum/clang11 871 MB/s 3.01x
|
||||
wuffs_png_decode_image_552k_32bpp_verify_checksum/clang11 837 MB/s 2.90x
|
||||
wuffs_png_decode_image_4002k_24bpp/clang11 331 MB/s 1.55x
|
||||
|
||||
wuffs_png_decode_image_19k_8bpp/gcc10 277 MB/s 2.27x
|
||||
wuffs_png_decode_image_40k_24bpp/gcc10 343 MB/s 2.33x
|
||||
wuffs_png_decode_image_77k_8bpp/gcc10 1.00 GB/s 2.70x
|
||||
wuffs_png_decode_image_552k_32bpp_ignore_checksum/gcc10 914 MB/s 3.16x
|
||||
wuffs_png_decode_image_552k_32bpp_verify_checksum/gcc10 870 MB/s 3.01x
|
||||
wuffs_png_decode_image_4002k_24bpp/gcc10 353 MB/s 1.65x
|
||||
|
||||
mimiclibpng_png_decode_image_19k_8bpp 122 MB/s 1.00x
|
||||
mimiclibpng_png_decode_image_40k_24bpp 147 MB/s 1.00x
|
||||
mimiclibpng_png_decode_image_77k_8bpp 370 MB/s 1.00x
|
||||
mimiclibpng_png_decode_image_552k_32bpp_verify_checksum 289 MB/s 1.00x
|
||||
mimiclibpng_png_decode_image_4002k_24bpp 214 MB/s 1.00x
|
||||
|
||||
mimiclibspng_png_decode_image_19k_8bpp 125 MB/s 1.02x
|
||||
mimiclibspng_png_decode_image_40k_24bpp 155 MB/s 1.05x
|
||||
mimiclibspng_png_decode_image_77k_8bpp 384 MB/s 1.04x
|
||||
mimiclibspng_png_decode_image_552k_32bpp_ignore_checksum 461 MB/s 1.60x
|
||||
mimiclibspng_png_decode_image_552k_32bpp_verify_checksum 392 MB/s 1.36x
|
||||
mimiclibspng_png_decode_image_4002k_24bpp 225 MB/s 1.05x
|
||||
|
||||
mimiclodepng_png_decode_image_19k_8bpp 138 MB/s 1.13x
|
||||
mimiclodepng_png_decode_image_40k_24bpp 166 MB/s 1.13x
|
||||
mimiclodepng_png_decode_image_77k_8bpp 404 MB/s 1.09x
|
||||
mimiclodepng_png_decode_image_552k_32bpp_verify_checksum 258 MB/s 0.89x
|
||||
mimiclodepng_png_decode_image_4002k_24bpp 165 MB/s 0.77x
|
||||
|
||||
mimicstb_png_decode_image_19k_8bpp 150 MB/s 1.23x
|
||||
mimicstb_png_decode_image_40k_24bpp 166 MB/s 1.13x
|
||||
mimicstb_png_decode_image_77k_8bpp 443 MB/s 1.20x
|
||||
mimicstb_png_decode_image_552k_32bpp_ignore_checksum 288 MB/s 1.00x
|
||||
mimicstb_png_decode_image_4002k_24bpp 163 MB/s 0.76x
|
||||
|
||||
go_png_decode_image_19k_8bpp 92 MB/s 0.75x
|
||||
go_png_decode_image_40k_24bpp 107 MB/s 0.73x
|
||||
go_png_decode_image_77k_8bpp 207 MB/s 0.56x
|
||||
go_png_decode_image_552k_32bpp_verify_checksum 246 MB/s 0.85x
|
||||
go_png_decode_image_4002k_24bpp 116 MB/s 0.54x
|
||||
|
||||
rust_png_decode_image_19k_8bpp 187 MB/s 1.53x
|
||||
rust_png_decode_image_40k_24bpp 260 MB/s 1.77x
|
||||
rust_png_decode_image_77k_8bpp 330 MB/s 0.89x
|
||||
rust_png_decode_image_552k_32bpp_verify_checksum 299 MB/s 1.03x
|
||||
rust_png_decode_image_4002k_24bpp 264 MB/s 1.23x
|
||||
|
||||
To reproduce the Go 1.19 numbers, run `go run main.go` in
|
||||
`script/bench-go-png`. For Rust 1.48 / png 0.17.5 / deflate 1.0.0 /
|
||||
miniz\_oxide 0.5.3, run `cargo run --release` in `script/bench-rust-png`.
|
||||
|
||||
|
||||
# Zlib (Deflate + Adler-32)
|
||||
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there in the
|
||||
The `1k`, `10k`, etc. numbers are approximately how many bytes there are in the
|
||||
decoded output.
|
||||
|
||||
name speed vs_mimic
|
||||
name speed vs_mimic
|
||||
|
||||
wuffs_zlib_decode_10k/clang8 237MB/s 0.96x
|
||||
wuffs_zlib_decode_100k/clang8 272MB/s 0.92x
|
||||
wuffs_zlib_decode_10k/clang11 410 MB/s 1.53x
|
||||
wuffs_zlib_decode_100k/clang11 505 MB/s 1.56x
|
||||
|
||||
wuffs_zlib_decode_10k/gcc9 242MB/s 0.98x
|
||||
wuffs_zlib_decode_100k/gcc9 294MB/s 0.99x
|
||||
wuffs_zlib_decode_10k/gcc10 431 MB/s 1.61x
|
||||
wuffs_zlib_decode_100k/gcc10 548 MB/s 1.70x
|
||||
|
||||
mimic_zlib_decode_10k 247MB/s 1.00x
|
||||
mimic_zlib_decode_100k 296MB/s 1.00x
|
||||
mimicztl_zlib_decode_10k 268 MB/s 1.00x
|
||||
mimicztl_zlib_decode_100k 323 MB/s 1.00x
|
||||
|
||||
mimiclibdeflate_zlib_decode_10k 497 MB/s 1.85x
|
||||
mimiclibdeflate_zlib_decode_100k 499 MB/s 1.54x
|
||||
|
||||
mimicminiz_zlib_decode_10k 237 MB/s 0.88x
|
||||
mimicminiz_zlib_decode_100k 272 MB/s 0.84x
|
||||
|
||||
|
||||
---
|
||||
|
||||
Updated on December 2019.
|
||||
Updated on September 2022.
|
||||
+1
-4
@@ -2,11 +2,8 @@
|
||||
|
||||
Short term:
|
||||
|
||||
- [Image decode API for color spaces and gamma
|
||||
correction.](https://github.com/google/wuffs/issues/39)
|
||||
- [Image decode API for Region of
|
||||
Interest.](https://github.com/google/wuffs/issues/40)
|
||||
- [Decode APNG.](https://github.com/google/wuffs/issues/41)
|
||||
- [Decode JPEG.](https://github.com/google/wuffs/issues/42)
|
||||
- [Decode LZ4.](https://github.com/google/wuffs/issues/43)
|
||||
- [Decode RAC.](https://github.com/google/wuffs/issues/22)
|
||||
@@ -41,4 +38,4 @@ Long term:
|
||||
|
||||
---
|
||||
|
||||
Updated on March 2021.
|
||||
Updated on October 2022.
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -490,11 +490,35 @@ load(xcb_connection_t* c, xcb_window_t w, const char* filename) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool //
|
||||
intersects(int32_t old_x,
|
||||
int32_t old_y,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t new_x,
|
||||
int32_t new_y) {
|
||||
if ((width <= 0) || (height <= 0)) {
|
||||
return false;
|
||||
} else if ((old_x > new_x) && ((old_x - new_x) >= width)) {
|
||||
return false;
|
||||
} else if ((new_x > old_x) && ((new_x - old_x) >= width)) {
|
||||
return false;
|
||||
} else if ((old_y > new_y) && ((old_y - new_y) >= height)) {
|
||||
return false;
|
||||
} else if ((new_y > old_y) && ((new_y - old_y) >= height)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// clear_area clears the L-shaped difference between old and new rectangles (of
|
||||
// equal width and height). It does this in up to two xcb_clear_area calls,
|
||||
// labeled A and B in the example below (with old_x=0, old_y=0, width=5,
|
||||
// height=4, new_x=2, new_y=2).
|
||||
//
|
||||
// If the old and new rectangles do not intersect then the old rectangle (not
|
||||
// an L-shape) will be cleared.
|
||||
//
|
||||
// AAAAA
|
||||
// AAAAA
|
||||
// BB+---+
|
||||
@@ -510,6 +534,13 @@ clear_area(xcb_connection_t* c,
|
||||
int32_t height,
|
||||
int32_t new_x,
|
||||
int32_t new_y) {
|
||||
if ((width <= 0) || (height <= 0)) {
|
||||
return;
|
||||
} else if (!intersects(old_x, old_y, width, height, new_x, new_y)) {
|
||||
xcb_clear_area(c, 1, w, old_x, old_y, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t dy = new_y - old_y;
|
||||
if (dy < 0) {
|
||||
xcb_clear_area(c, 1, w, old_x, old_y + height + dy, width, -dy);
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
+15
-12
@@ -44,6 +44,19 @@ jenkins_hash_u32(const uint8_t* data, size_t size) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
// memrandomize is like memcpy or memset but it writes pseudo-random values.
|
||||
static void* //
|
||||
memrandomize(void* dest, uint64_t seed, size_t n) {
|
||||
unsigned short xsubi[3]; // See "man 3 nrand48".
|
||||
xsubi[0] = (seed >> 0) ^ (seed >> 48);
|
||||
xsubi[1] = (seed >> 16);
|
||||
xsubi[2] = (seed >> 32);
|
||||
for (uint8_t* ptr = (uint8_t*)dest; n--;) {
|
||||
*ptr++ = nrand48(xsubi);
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
const char* //
|
||||
fuzz(wuffs_base__io_buffer* src, uint64_t hash);
|
||||
|
||||
@@ -55,18 +68,8 @@ 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);
|
||||
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = (uint8_t*)(data),
|
||||
.len = size,
|
||||
}),
|
||||
.meta = ((wuffs_base__io_buffer_meta){
|
||||
.wi = size,
|
||||
.ri = 0,
|
||||
.pos = 0,
|
||||
.closed = true,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer src =
|
||||
wuffs_base__ptr_u8__reader((uint8_t*)data, size, true);
|
||||
|
||||
const char* msg = fuzz(&src, hash);
|
||||
if (msg) {
|
||||
|
||||
@@ -101,12 +101,8 @@ fuzz(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
&dec, WUFFS_BASE__QUIRK_IGNORE_CHECKSUM, hash & 0xFFFE);
|
||||
|
||||
uint8_t dst_buffer[DST_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = dst_buffer,
|
||||
.len = DST_BUFFER_ARRAY_SIZE,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer dst =
|
||||
wuffs_base__ptr_u8__writer(&dst_buffer[0], DST_BUFFER_ARRAY_SIZE);
|
||||
|
||||
while (true) {
|
||||
dst.meta.wi = 0;
|
||||
|
||||
@@ -103,12 +103,8 @@ fuzz(wuffs_base__io_buffer* src, uint64_t hash) {
|
||||
&dec, WUFFS_BASE__QUIRK_IGNORE_CHECKSUM, hash & 0xFFFE);
|
||||
|
||||
uint8_t dst_buffer[DST_BUFFER_ARRAY_SIZE];
|
||||
wuffs_base__io_buffer dst = ((wuffs_base__io_buffer){
|
||||
.data = ((wuffs_base__slice_u8){
|
||||
.ptr = dst_buffer,
|
||||
.len = DST_BUFFER_ARRAY_SIZE,
|
||||
}),
|
||||
});
|
||||
wuffs_base__io_buffer dst =
|
||||
wuffs_base__ptr_u8__writer(&dst_buffer[0], DST_BUFFER_ARRAY_SIZE);
|
||||
|
||||
while (true) {
|
||||
dst.meta.wi = 0;
|
||||
|
||||
@@ -797,6 +797,22 @@ wuffs_base__count_leading_zeroes_u64(uint64_t u) {
|
||||
|
||||
// --------
|
||||
|
||||
// Normally, the wuffs_base__peek_etc and wuffs_base__poke_etc implementations
|
||||
// are both (1) correct regardless of CPU endianness and (2) very fast (e.g. an
|
||||
// inlined wuffs_base__peek_u32le__no_bounds_check call, in an optimized clang
|
||||
// or gcc build, is a single MOV instruction on x86_64).
|
||||
//
|
||||
// However, the endian-agnostic implementations are slow on Microsoft's C
|
||||
// compiler (MSC). Alternative memcpy-based implementations restore speed, but
|
||||
// they are only correct on little-endian CPU architectures. Defining
|
||||
// WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE opts in to these implementations.
|
||||
//
|
||||
// https://godbolt.org/z/q4MfjzTPh
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && \
|
||||
(defined(_M_ARM64) || defined(_M_X64))
|
||||
#define WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE
|
||||
#endif
|
||||
|
||||
#define wuffs_base__peek_u8be__no_bounds_check \
|
||||
wuffs_base__peek_u8__no_bounds_check
|
||||
#define wuffs_base__peek_u8le__no_bounds_check \
|
||||
@@ -809,12 +825,24 @@ wuffs_base__peek_u8__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__peek_u16be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint16_t x;
|
||||
memcpy(&x, p, 2);
|
||||
return _byteswap_ushort(x);
|
||||
#else
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__peek_u16le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint16_t x;
|
||||
memcpy(&x, p, 2);
|
||||
return x;
|
||||
#else
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -831,14 +859,26 @@ wuffs_base__peek_u24le__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__peek_u32be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint32_t x;
|
||||
memcpy(&x, p, 4);
|
||||
return _byteswap_ulong(x);
|
||||
#else
|
||||
return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |
|
||||
((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__peek_u32le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint32_t x;
|
||||
memcpy(&x, p, 4);
|
||||
return x;
|
||||
#else
|
||||
return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |
|
||||
((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
@@ -887,18 +927,30 @@ wuffs_base__peek_u56le__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__peek_u64be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint64_t x;
|
||||
memcpy(&x, p, 8);
|
||||
return _byteswap_uint64(x);
|
||||
#else
|
||||
return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |
|
||||
((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |
|
||||
((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |
|
||||
((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__peek_u64le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint64_t x;
|
||||
memcpy(&x, p, 8);
|
||||
return x;
|
||||
#else
|
||||
return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |
|
||||
((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
|
||||
((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |
|
||||
((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------
|
||||
@@ -921,7 +973,8 @@ wuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 2);
|
||||
@@ -955,7 +1008,8 @@ wuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 4);
|
||||
@@ -1041,7 +1095,8 @@ wuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 8);
|
||||
|
||||
+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
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ func (g *gen) writeInitialLoadDerivedVar(b *buffer, n *a.Field) error {
|
||||
b.printf("%s%s* %s%s WUFFS_BASE__POTENTIALLY_UNUSED = NULL;\n", c, elem, io1Prefix, preName)
|
||||
b.printf("%s%s* %s%s WUFFS_BASE__POTENTIALLY_UNUSED = NULL;\n", c, elem, io2Prefix, preName)
|
||||
|
||||
b.printf("if (%s) {\n", preName)
|
||||
b.printf("if (%s && %s->data.ptr) {\n", preName, preName)
|
||||
|
||||
b.printf("%s%s = %s->data.ptr;\n", io0Prefix, preName, preName)
|
||||
b.printf("%s%s = %s%s + %s->%s;\n", io1Prefix, preName, io0Prefix, preName, preName, i1)
|
||||
@@ -149,8 +149,8 @@ func (g *gen) writeFinalSaveDerivedVar(b *buffer, n *a.Field) error {
|
||||
}
|
||||
preName := aPrefix + n.Name().Str(g.tm)
|
||||
|
||||
b.printf("if (%s) {\n%s->%s = ((size_t)(%s%s - %s->data.ptr));\n}\n",
|
||||
preName, preName, i1, iopPrefix, preName, preName)
|
||||
b.printf("if (%s && %s->data.ptr) {\n%s->%s = ((size_t)(%s%s - %s->data.ptr));\n}\n",
|
||||
preName, preName, preName, i1, iopPrefix, preName, preName)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
+82
-82
@@ -328,12 +328,12 @@ func (n *Raw) SetPackage(tm *t.Map, pkg t.ID) error {
|
||||
const MaxExprDepth = 255
|
||||
|
||||
// Expr is an expression, such as "i", "+j" or "k + l[m(n, o)].p":
|
||||
// - ID0: <0|operator|IDOpenParen|IDOpenBracket|IDDotDot|IDDot>
|
||||
// - ID2: <0|literal|ident>
|
||||
// - LHS: <nil|Expr>
|
||||
// - MHS: <nil|Expr>
|
||||
// - RHS: <nil|Expr|TypeExpr>
|
||||
// - List0: <Arg|Expr> function call args, assoc. op args or list members.
|
||||
// - ID0: <0|operator|IDOpenParen|IDOpenBracket|IDDotDot|IDDot>
|
||||
// - ID2: <0|literal|ident>
|
||||
// - LHS: <nil|Expr>
|
||||
// - MHS: <nil|Expr>
|
||||
// - RHS: <nil|Expr|TypeExpr>
|
||||
// - List0: <Arg|Expr> function call args, assoc. op args or list members.
|
||||
//
|
||||
// A zero ID0 means an identifier or literal in ID2, like `foo`, `42` or a
|
||||
// status literal like `"#foo"`.
|
||||
@@ -468,10 +468,10 @@ func NewExpr(flags Flags, operator t.ID, ident t.ID, lhs *Node, mhs *Node, rhs *
|
||||
|
||||
// Assert is "assert RHS via ID2(args)", "choose etc", "pre etc", "inv etc" or
|
||||
// "post etc":
|
||||
// - ID0: <IDAssert|IDChoose|IDPre|IDInv|IDPost>
|
||||
// - ID2: <"-string literal> reason
|
||||
// - RHS: <Expr>
|
||||
// - List0: <Arg> reason arguments
|
||||
// - ID0: <IDAssert|IDChoose|IDPre|IDInv|IDPost>
|
||||
// - ID2: <"-string literal> reason
|
||||
// - RHS: <Expr>
|
||||
// - List0: <Arg> reason arguments
|
||||
type Assert Node
|
||||
|
||||
func (n *Assert) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -513,8 +513,8 @@ func NewAssert(keyword t.ID, condition *Expr, reason t.ID, args []*Node) *Assert
|
||||
}
|
||||
|
||||
// Arg is "name:value".
|
||||
// - ID2: <ident> name
|
||||
// - RHS: <Expr> value
|
||||
// - ID2: <ident> name
|
||||
// - RHS: <Expr> value
|
||||
type Arg Node
|
||||
|
||||
func (n *Arg) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -530,9 +530,9 @@ func NewArg(name t.ID, value *Expr) *Arg {
|
||||
}
|
||||
|
||||
// Assign is "LHS = RHS" or "LHS op= RHS" or "RHS":
|
||||
// - ID0: operator
|
||||
// - LHS: <nil|Expr>
|
||||
// - RHS: <Expr>
|
||||
// - ID0: operator
|
||||
// - LHS: <nil|Expr>
|
||||
// - RHS: <Expr>
|
||||
type Assign Node
|
||||
|
||||
func (n *Assign) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -550,8 +550,8 @@ func NewAssign(operator t.ID, lhs *Expr, rhs *Expr) *Assign {
|
||||
}
|
||||
|
||||
// Var is "var ID2 LHS":
|
||||
// - ID2: name
|
||||
// - LHS: <TypeExpr>
|
||||
// - ID2: name
|
||||
// - LHS: <TypeExpr>
|
||||
type Var Node
|
||||
|
||||
func (n *Var) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -569,9 +569,9 @@ func NewVar(name t.ID, xType *TypeExpr) *Var {
|
||||
}
|
||||
|
||||
// Field is a "name : type" struct field:
|
||||
// - FlagsPrivateData is the initializer need not explicitly memset to zero.
|
||||
// - ID2: name
|
||||
// - LHS: <TypeExpr>
|
||||
// - FlagsPrivateData is the initializer need not explicitly memset to zero.
|
||||
// - ID2: name
|
||||
// - LHS: <TypeExpr>
|
||||
type Field Node
|
||||
|
||||
func (n *Field) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -590,11 +590,11 @@ func NewField(flags Flags, name t.ID, xType *TypeExpr) *Field {
|
||||
|
||||
// IOManip is "io_bind (io:LHS, data:MHS, history_position:RHS) { List2 }" or
|
||||
// "io_limit (io:LHS, limit:MHS) { List2 }":
|
||||
// - ID0: <IDIOBind|IDIOLimit>
|
||||
// - LHS: <Expr>
|
||||
// - MHS: <Expr>
|
||||
// - RHS: <Expr>
|
||||
// - List2: <Statement> body
|
||||
// - ID0: <IDIOBind|IDIOLimit>
|
||||
// - LHS: <Expr>
|
||||
// - MHS: <Expr>
|
||||
// - RHS: <Expr>
|
||||
// - List2: <Statement> body
|
||||
type IOManip Node
|
||||
|
||||
func (n *IOManip) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -617,16 +617,16 @@ func NewIOManip(keyword t.ID, io *Expr, arg1 *Expr, historyPosition *Expr, body
|
||||
|
||||
// Iterate is
|
||||
// "iterate.ID1 (assigns)(length:ID2, advance:ID0, unroll:LHS), List1 { List2 } else RHS":
|
||||
// - FlagsHasBreak is the iterate has an explicit break
|
||||
// - FlagsHasContinue is the iterate has an explicit continue
|
||||
// - ID0: advance
|
||||
// - ID1: <0|label>
|
||||
// - ID2: length
|
||||
// - LHS: <Expr> unroll
|
||||
// - RHS: <nil|Iterate>
|
||||
// - List0: <Assign> assigns
|
||||
// - List1: <Assert> asserts
|
||||
// - List2: <Statement> body
|
||||
// - FlagsHasBreak is the iterate has an explicit break
|
||||
// - FlagsHasContinue is the iterate has an explicit continue
|
||||
// - ID0: advance
|
||||
// - ID1: <0|label>
|
||||
// - ID2: length
|
||||
// - LHS: <Expr> unroll
|
||||
// - RHS: <nil|Iterate>
|
||||
// - List0: <Assign> assigns
|
||||
// - List1: <Assert> asserts
|
||||
// - List2: <Statement> body
|
||||
type Iterate Node
|
||||
|
||||
func (n *Iterate) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -661,12 +661,12 @@ func NewIterate(label t.ID, assigns []*Node, length t.ID, advance t.ID, unroll t
|
||||
}
|
||||
|
||||
// While is "while.ID1 MHS, List1 { List2 } endwhile.ID1":
|
||||
// - FlagsHasBreak is the while has an explicit break
|
||||
// - FlagsHasContinue is the while has an explicit continue
|
||||
// - ID1: <0|label>
|
||||
// - MHS: <Expr>
|
||||
// - List1: <Assert> asserts
|
||||
// - List2: <Statement> body
|
||||
// - FlagsHasBreak is the while has an explicit break
|
||||
// - FlagsHasContinue is the while has an explicit continue
|
||||
// - ID1: <0|label>
|
||||
// - MHS: <Expr>
|
||||
// - List1: <Assert> asserts
|
||||
// - List2: <Statement> body
|
||||
//
|
||||
// TODO: should we be able to unroll while loops too?
|
||||
type While Node
|
||||
@@ -699,10 +699,10 @@ func NewWhile(label t.ID, condition *Expr, asserts []*Node) *While {
|
||||
}
|
||||
|
||||
// If is "if MHS { List2 } else RHS" or "if MHS { List2 } else { List1 }":
|
||||
// - MHS: <Expr>
|
||||
// - RHS: <nil|If>
|
||||
// - List1: <Statement> if-false body
|
||||
// - List2: <Statement> if-true body
|
||||
// - MHS: <Expr>
|
||||
// - RHS: <nil|If>
|
||||
// - List1: <Statement> if-false body
|
||||
// - List2: <Statement> if-true body
|
||||
type If Node
|
||||
|
||||
func (n *If) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -722,8 +722,8 @@ func NewIf(condition *Expr, bodyIfTrue []*Node, bodyIfFalse []*Node, elseIf *If)
|
||||
}
|
||||
|
||||
// Choose is "choose ID2: List0":
|
||||
// - ID2: name
|
||||
// - List0: <Expr> method names.
|
||||
// - ID2: name
|
||||
// - List0: <Expr> method names.
|
||||
type Choose Node
|
||||
|
||||
func (n *Choose) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -739,9 +739,9 @@ func NewChoose(name t.ID, args []*Node) *Choose {
|
||||
}
|
||||
|
||||
// Ret is "return LHS" or "yield LHS":
|
||||
// - FlagsReturnsError LHS is an error status
|
||||
// - ID0: <IDReturn|IDYield>
|
||||
// - LHS: <Expr>
|
||||
// - FlagsReturnsError LHS is an error status
|
||||
// - ID0: <IDReturn|IDYield>
|
||||
// - LHS: <Expr>
|
||||
type Ret Node
|
||||
|
||||
func (n *Ret) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -760,8 +760,8 @@ func NewRet(keyword t.ID, value *Expr) *Ret {
|
||||
}
|
||||
|
||||
// Jump is "break" or "continue", with an optional label, "break.label":
|
||||
// - ID0: <IDBreak|IDContinue>
|
||||
// - ID1: <0|label>
|
||||
// - ID0: <IDBreak|IDContinue>
|
||||
// - ID1: <0|label>
|
||||
type Jump Node
|
||||
|
||||
func (n *Jump) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -784,12 +784,12 @@ const MaxTypeExprDepth = 63
|
||||
|
||||
// TypeExpr is a type expression, such as "base.u32", "base.u32[..= 8]", "foo",
|
||||
// "pkg.bar", "ptr T", "array[8] T", "slice T" or "table T":
|
||||
// - ID0: <0|IDArray|IDFunc|IDNptr|IDPtr|IDSlice|IDTable>
|
||||
// - ID1: <0|pkg>
|
||||
// - ID2: <0|type name>
|
||||
// - LHS: <nil|Expr>
|
||||
// - MHS: <nil|Expr>
|
||||
// - RHS: <nil|TypeExpr>
|
||||
// - ID0: <0|IDArray|IDFunc|IDNptr|IDPtr|IDSlice|IDTable>
|
||||
// - ID1: <0|pkg>
|
||||
// - ID2: <0|type name>
|
||||
// - LHS: <nil|Expr>
|
||||
// - MHS: <nil|Expr>
|
||||
// - RHS: <nil|TypeExpr>
|
||||
//
|
||||
// An IDNptr or IDPtr ID0 means "nptr RHS" or "ptr RHS". RHS is the inner type.
|
||||
//
|
||||
@@ -958,14 +958,14 @@ func NewTypeExpr(decorator t.ID, pkg t.ID, name t.ID, alenRecvMin *Node, max *Ex
|
||||
const MaxBodyDepth = 255
|
||||
|
||||
// Func is "func ID2.ID0(LHS)(RHS) { List2 }":
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - ID0: funcName
|
||||
// - ID1: <0|receiverPkg> (set by calling SetPackage)
|
||||
// - ID2: <0|receiverName>
|
||||
// - LHS: <Struct> in-parameters
|
||||
// - RHS: <Struct> out-parameters
|
||||
// - List1: <Assert> asserts
|
||||
// - List2: <Statement> body
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - ID0: funcName
|
||||
// - ID1: <0|receiverPkg> (set by calling SetPackage)
|
||||
// - ID2: <0|receiverName>
|
||||
// - LHS: <Struct> in-parameters
|
||||
// - RHS: <Struct> out-parameters
|
||||
// - List1: <Assert> asserts
|
||||
// - List2: <Statement> body
|
||||
type Func Node
|
||||
|
||||
func (n *Func) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -1033,9 +1033,9 @@ func NewFunc(flags Flags, filename string, line uint32, receiverName t.ID, funcN
|
||||
}
|
||||
|
||||
// Status is "error (RHS) ID2" or "suspension (RHS) ID2":
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - ID1: <0|pkg> (set by calling SetPackage)
|
||||
// - ID2: message
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - ID1: <0|pkg> (set by calling SetPackage)
|
||||
// - ID2: message
|
||||
type Status Node
|
||||
|
||||
func (n *Status) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -1055,11 +1055,11 @@ func NewStatus(flags Flags, filename string, line uint32, message t.ID) *Status
|
||||
}
|
||||
|
||||
// Const is "const ID2 LHS = RHS":
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - ID1: <0|pkg> (set by calling SetPackage)
|
||||
// - ID2: name
|
||||
// - LHS: <TypeExpr>
|
||||
// - RHS: <Expr>
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - ID1: <0|pkg> (set by calling SetPackage)
|
||||
// - ID2: name
|
||||
// - LHS: <TypeExpr>
|
||||
// - RHS: <Expr>
|
||||
type Const Node
|
||||
|
||||
func (n *Const) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -1087,12 +1087,12 @@ func NewConst(flags Flags, filename string, line uint32, name t.ID, xType *TypeE
|
||||
const MaxImplements = 63
|
||||
|
||||
// Struct is "struct ID2? implements List0 (List1)":
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - FlagsClassy is "ID2" vs "ID2?"
|
||||
// - ID1: <0|pkg> (set by calling SetPackage)
|
||||
// - ID2: name
|
||||
// - List0: <TypeExpr> implements
|
||||
// - List1: <Field> fields
|
||||
// - FlagsPublic is "pub" vs "pri"
|
||||
// - FlagsClassy is "ID2" vs "ID2?"
|
||||
// - ID1: <0|pkg> (set by calling SetPackage)
|
||||
// - ID2: name
|
||||
// - List0: <TypeExpr> implements
|
||||
// - List1: <Field> fields
|
||||
//
|
||||
// The question mark indicates a classy struct - one that supports methods,
|
||||
// especially coroutines.
|
||||
@@ -1120,7 +1120,7 @@ func NewStruct(flags Flags, filename string, line uint32, name t.ID, implements
|
||||
}
|
||||
|
||||
// Use is "use ID2":
|
||||
// - ID2: <"-string literal> package path
|
||||
// - ID2: <"-string literal> package path
|
||||
type Use Node
|
||||
|
||||
func (n *Use) AsNode() *Node { return (*Node)(n) }
|
||||
@@ -1138,7 +1138,7 @@ func NewUse(filename string, line uint32, path t.ID) *Use {
|
||||
}
|
||||
|
||||
// File is a file of source code:
|
||||
// - List0: <Const|Func|Status|Struct|Use> top-level declarations
|
||||
// - List0: <Const|Func|Status|Struct|Use> top-level declarations
|
||||
type File Node
|
||||
|
||||
func (n *File) AsNode() *Node { return (*Node)(n) }
|
||||
|
||||
+15
-12
@@ -201,16 +201,16 @@ type Token struct {
|
||||
}
|
||||
|
||||
// nBuiltInIDs is the number of built-in IDs. The packing is:
|
||||
// - 0x00 is invalid.
|
||||
// - 0x01 ..= 0x0F are squiggly punctuation, such as ";", "." and "?".
|
||||
// - 0x10 ..= 0x1F are squiggly bookends, such as "(", ")" and "]".
|
||||
// - 0x20 ..= 0x3F are squiggly assignments, such as "=" and "+=".
|
||||
// - 0x40 ..= 0x6F are operators, such as "+", "==" and "not".
|
||||
// - 0x70 ..= 0xAF are x-ops (disambiguation forms): unary vs binary "+".
|
||||
// - 0xB0 ..= 0xCF are keywords, such as "if" and "return".
|
||||
// - 0xD0 ..= 0xDF are type modifiers, such as "ptr" and "slice".
|
||||
// - 0xE0 ..= 0xFF are literals, such as "ok" and "true".
|
||||
// - 0x100 ..= 0x3FF are identifiers, such as "bool", "u32" and "read_u8".
|
||||
// - 0x00 is invalid.
|
||||
// - 0x01 ..= 0x0F are squiggly punctuation, such as ";", "." and "?".
|
||||
// - 0x10 ..= 0x1F are squiggly bookends, such as "(", ")" and "]".
|
||||
// - 0x20 ..= 0x3F are squiggly assignments, such as "=" and "+=".
|
||||
// - 0x40 ..= 0x6F are operators, such as "+", "==" and "not".
|
||||
// - 0x70 ..= 0xAF are x-ops (disambiguation forms): unary vs binary "+".
|
||||
// - 0xB0 ..= 0xCF are keywords, such as "if" and "return".
|
||||
// - 0xD0 ..= 0xDF are type modifiers, such as "ptr" and "slice".
|
||||
// - 0xE0 ..= 0xFF are literals, such as "ok" and "true".
|
||||
// - 0x100 ..= 0x3FF are identifiers, such as "bool", "u32" and "read_u8".
|
||||
//
|
||||
// Squiggly means a sequence of non-alpha-numeric bytes, such as "+" and "&=".
|
||||
const (
|
||||
@@ -1299,9 +1299,12 @@ func init() {
|
||||
// addXForms modifies table so that, if table[x] == y, then table[y] = y.
|
||||
//
|
||||
// For example, for the unaryForms table, the explicit entries are like:
|
||||
// IDPlus: IDXUnaryPlus,
|
||||
//
|
||||
// IDPlus: IDXUnaryPlus,
|
||||
//
|
||||
// and this function implicitly addes entries like:
|
||||
// IDXUnaryPlus: IDXUnaryPlus,
|
||||
//
|
||||
// IDXUnaryPlus: IDXUnaryPlus,
|
||||
func addXForms(table *[nBuiltInSymbolicIDs]ID) {
|
||||
implicitEntries := [nBuiltInSymbolicIDs]bool{}
|
||||
for _, y := range table {
|
||||
|
||||
@@ -27,57 +27,57 @@
|
||||
// repository was 80 times faster than `clang-format`, even without a column
|
||||
// limit:
|
||||
//
|
||||
// $ wc release/c/wuffs-v0.2.c
|
||||
// 11858 35980 431885 release/c/wuffs-v0.2.c
|
||||
// $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.008s
|
||||
// user 0m0.005s
|
||||
// sys 0m0.005s
|
||||
// $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.668s
|
||||
// user 0m0.618s
|
||||
// sys 0m0.032s
|
||||
// $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.641s
|
||||
// user 0m0.585s
|
||||
// sys 0m0.037s
|
||||
// $ wc release/c/wuffs-v0.2.c
|
||||
// 11858 35980 431885 release/c/wuffs-v0.2.c
|
||||
// $ time dumbindent < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.008s
|
||||
// user 0m0.005s
|
||||
// sys 0m0.005s
|
||||
// $ time clang-format-9 < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.668s
|
||||
// user 0m0.618s
|
||||
// sys 0m0.032s
|
||||
// $ time clang-format-9 -style='{ColumnLimit: 0}' < release/c/wuffs-v0.2.c > /dev/null
|
||||
// real 0m0.641s
|
||||
// user 0m0.585s
|
||||
// sys 0m0.037s
|
||||
//
|
||||
// Apart from some rare and largely uninteresting exceptions, the dumbindent
|
||||
// algorithm only considers:
|
||||
//
|
||||
// ∙ '{' and '}' curly braces,
|
||||
// ∙ '(' and ')' round parentheses,
|
||||
// ∙ '\n' line breaks,
|
||||
// ∙ ' ' spaces and '\t' tabs that start or end a line, and
|
||||
// ∙ strings, comments and preprocessor directives (in order to ignore any of
|
||||
// the above special characters within them),
|
||||
// ∙ '{' and '}' curly braces,
|
||||
// ∙ '(' and ')' round parentheses,
|
||||
// ∙ '\n' line breaks,
|
||||
// ∙ ' ' spaces and '\t' tabs that start or end a line, and
|
||||
// ∙ strings, comments and preprocessor directives (in order to ignore any of
|
||||
// the above special characters within them),
|
||||
//
|
||||
// Everything else is an opaque byte. Consider this input:
|
||||
//
|
||||
// for (i = 0; i < 3; i++) {
|
||||
// j = 0; // Ignore { in a comment.
|
||||
// if (i < j) { foo(); }
|
||||
// u = (v +
|
||||
// w);
|
||||
// }
|
||||
// for (i = 0; i < 3; i++) {
|
||||
// j = 0; // Ignore { in a comment.
|
||||
// if (i < j) { foo(); }
|
||||
// u = (v +
|
||||
// w);
|
||||
// }
|
||||
//
|
||||
// From the algorithm's point of view, this input is equivalent to:
|
||||
//
|
||||
// ....(.................).{
|
||||
// .................................
|
||||
// ...(.....).{....()..}
|
||||
// ....(...
|
||||
// .);
|
||||
// }
|
||||
// ....(.................).{
|
||||
// .................................
|
||||
// ...(.....).{....()..}
|
||||
// ....(...
|
||||
// .);
|
||||
// }
|
||||
//
|
||||
// The formatted output (using the default of 2 spaces per indent level) is:
|
||||
//
|
||||
// ....(.................).{
|
||||
// .................................
|
||||
// ...(.....).{....()..}
|
||||
// ....(...
|
||||
// .);
|
||||
// }
|
||||
// ....(.................).{
|
||||
// .................................
|
||||
// ...(.....).{....()..}
|
||||
// ....(...
|
||||
// .);
|
||||
// }
|
||||
//
|
||||
// Dumbindent adjusts lines horizontally (indenting) but not vertically (it
|
||||
// does not break or un-break lines, or collapse consecutive blank lines),
|
||||
@@ -103,9 +103,9 @@
|
||||
//
|
||||
// Similarly, dumbindent will not correct this mis-indentation:
|
||||
//
|
||||
// if (condition)
|
||||
// goto fail;
|
||||
// goto fail;
|
||||
// if (condition)
|
||||
// goto fail;
|
||||
// goto fail;
|
||||
//
|
||||
// Instead, when automatically or manually generating the input for dumbindent,
|
||||
// it is recommended to always emit curly braces (again, similar to `gofmt`
|
||||
|
||||
+14
-14
@@ -130,23 +130,23 @@ func (b *bitstream) take(nBits uint32) int32 {
|
||||
// 4, 4)" example from RFC 1951 section 3.2.2, the huffman struct is
|
||||
// initialized by calling:
|
||||
//
|
||||
// h.construct([]uint32{
|
||||
// 'A': 3, 'B': 3, 'C': 3, 'D': 3, 'E': 3, 'F': 2, 'G': 4, 'H': 4,
|
||||
// })
|
||||
// h.construct([]uint32{
|
||||
// 'A': 3, 'B': 3, 'C': 3, 'D': 3, 'E': 3, 'F': 2, 'G': 4, 'H': 4,
|
||||
// })
|
||||
//
|
||||
// which results in:
|
||||
//
|
||||
// huffman{
|
||||
// counts: [maxCodeBits + 1]uint32{
|
||||
// 2: 1, 3: 5, 4: 2,
|
||||
// },
|
||||
// symbols: [maxNumCodes]int32{
|
||||
// 0: 'F', 1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'G', 7: 'H',
|
||||
// },
|
||||
// lookUpTable: [256]uint32{
|
||||
// etc,
|
||||
// },
|
||||
// }
|
||||
// huffman{
|
||||
// counts: [maxCodeBits + 1]uint32{
|
||||
// 2: 1, 3: 5, 4: 2,
|
||||
// },
|
||||
// symbols: [maxNumCodes]int32{
|
||||
// 0: 'F', 1: 'A', 2: 'B', 3: 'C', 4: 'D', 5: 'E', 6: 'G', 7: 'H',
|
||||
// },
|
||||
// lookUpTable: [256]uint32{
|
||||
// etc,
|
||||
// },
|
||||
// }
|
||||
//
|
||||
// Continuing the example from the RFC, decoding "1110" from the bitstream will
|
||||
// produce the 'G' symbol.
|
||||
|
||||
+31
-28
@@ -1057,18 +1057,19 @@ func orOneNegOneNonNeg(neg IntRange, non IntRange) (z IntRange) {
|
||||
// possible xx in x and yy in y.
|
||||
//
|
||||
// Algorithm:
|
||||
// // If the two intervals overlap, the result is the minimum of the two
|
||||
// // intervals' maxima.
|
||||
// //
|
||||
// // This overlaps code path is just an optimization.
|
||||
// if overlaps(x, y) {
|
||||
// return min(xMax, yMax)
|
||||
// }
|
||||
// xFlip = bitFillRight(bitFillRight(xMax & ~xMin) & xMax & ~yMax)
|
||||
// xResult = yMax & ((xMax & ~xFlip) | (xFlip >> 1))
|
||||
// yFlip = bitFillRight(bitFillRight(yMax & ~yMin) & yMax & ~xMax)
|
||||
// yResult = xMax & ((yMax & ~yFlip) | (yFlip >> 1))
|
||||
// return max(xResult, yResult)
|
||||
//
|
||||
// // If the two intervals overlap, the result is the minimum of the two
|
||||
// // intervals' maxima.
|
||||
// //
|
||||
// // This overlaps code path is just an optimization.
|
||||
// if overlaps(x, y) {
|
||||
// return min(xMax, yMax)
|
||||
// }
|
||||
// xFlip = bitFillRight(bitFillRight(xMax & ~xMin) & xMax & ~yMax)
|
||||
// xResult = yMax & ((xMax & ~xFlip) | (xFlip >> 1))
|
||||
// yFlip = bitFillRight(bitFillRight(yMax & ~yMin) & yMax & ~xMax)
|
||||
// yResult = xMax & ((yMax & ~yFlip) | (yFlip >> 1))
|
||||
// return max(xResult, yResult)
|
||||
//
|
||||
// If xMin and yMin are both zero, the overlaps branch is taken.
|
||||
//
|
||||
@@ -1189,13 +1190,15 @@ func (x IntRange) andMax(y IntRange) *big.Int {
|
||||
// possible xx in x and yy in y.
|
||||
//
|
||||
// Algorithm:
|
||||
// droppable = bitFillRight((xMax & ~xMin) | (yMax & ~yMin))
|
||||
// available = xMax & yMax & droppable
|
||||
// return xMax | yMax | (bitFillRight(available) >> 1)
|
||||
//
|
||||
// droppable = bitFillRight((xMax & ~xMin) | (yMax & ~yMin))
|
||||
// available = xMax & yMax & droppable
|
||||
// return xMax | yMax | (bitFillRight(available) >> 1)
|
||||
//
|
||||
// If xMin and yMin are both zero, this simplifies to:
|
||||
// available = xMax & yMax
|
||||
// return xMax | yMax | (bitFillRight(available) >> 1)
|
||||
//
|
||||
// available = xMax & yMax
|
||||
// return xMax | yMax | (bitFillRight(available) >> 1)
|
||||
func (x IntRange) orMax(y IntRange) *big.Int {
|
||||
if x[0].Sign() == 0 && y[0].Sign() == 0 {
|
||||
i := big.NewInt(0)
|
||||
@@ -1257,17 +1260,17 @@ func (x IntRange) orMax(y IntRange) *big.Int {
|
||||
}
|
||||
|
||||
// bitFillRight modifies i to round up to the next power of 2 minus 1:
|
||||
// - If i is +0 then bitFillRight(i) sets i to 0.
|
||||
// - If i is +1 then bitFillRight(i) sets i to 1.
|
||||
// - If i is +2 then bitFillRight(i) sets i to 3.
|
||||
// - If i is +3 then bitFillRight(i) sets i to 3.
|
||||
// - If i is +4 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +5 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +6 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +7 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +8 then bitFillRight(i) sets i to 15.
|
||||
// - If i is +9 then bitFillRight(i) sets i to 15.
|
||||
// - Etc.
|
||||
// - If i is +0 then bitFillRight(i) sets i to 0.
|
||||
// - If i is +1 then bitFillRight(i) sets i to 1.
|
||||
// - If i is +2 then bitFillRight(i) sets i to 3.
|
||||
// - If i is +3 then bitFillRight(i) sets i to 3.
|
||||
// - If i is +4 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +5 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +6 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +7 then bitFillRight(i) sets i to 7.
|
||||
// - If i is +8 then bitFillRight(i) sets i to 15.
|
||||
// - If i is +9 then bitFillRight(i) sets i to 15.
|
||||
// - Etc.
|
||||
func bitFillRight(i *big.Int) {
|
||||
if s := i.Sign(); s < 0 {
|
||||
panic("pre-condition failure")
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
package litonlylzma_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/google/wuffs/lib/litonlylzma"
|
||||
)
|
||||
|
||||
func ExampleRoundTripLZMA() {
|
||||
original := []byte("Hello world.\n")
|
||||
compressed, err := litonlylzma.FileFormatLZMA.Encode(nil, original)
|
||||
if err != nil {
|
||||
log.Fatalf("Encode: %v", err)
|
||||
}
|
||||
recovered, _, err := litonlylzma.FileFormatLZMA.Decode(nil, compressed)
|
||||
if err != nil {
|
||||
log.Fatalf("Decode: %v", err)
|
||||
}
|
||||
|
||||
for i, c := range compressed {
|
||||
if (i & 15) > 0 {
|
||||
fmt.Printf(" ")
|
||||
}
|
||||
fmt.Printf("%02X", c)
|
||||
if ((i & 15) == 15) || ((i + 1) == len(compressed)) {
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
fmt.Printf("%s", recovered)
|
||||
|
||||
// Output:
|
||||
// 5D 00 10 00 00 0D 00 00 00 00 00 00 00 00 24 19
|
||||
// 49 86 E7 D5 E5 E2 56 ED 6A E6 0E 81 FE B8 00 00
|
||||
// Hello world.
|
||||
}
|
||||
|
||||
func ExampleRoundTripXz() {
|
||||
original := []byte("Hello world.\n")
|
||||
compressed, err := litonlylzma.FileFormatXz.Encode(nil, original)
|
||||
if err != nil {
|
||||
log.Fatalf("Encode: %v", err)
|
||||
}
|
||||
recovered, _, err := litonlylzma.FileFormatXz.Decode(nil, compressed)
|
||||
if err != nil {
|
||||
log.Fatalf("Decode: %v", err)
|
||||
}
|
||||
|
||||
for i, c := range compressed {
|
||||
if (i & 15) > 0 {
|
||||
fmt.Printf(" ")
|
||||
}
|
||||
fmt.Printf("%02X", c)
|
||||
if ((i & 15) == 15) || ((i + 1) == len(compressed)) {
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
fmt.Printf("%s", recovered)
|
||||
|
||||
// Output:
|
||||
// FD 37 7A 58 5A 00 00 01 69 22 DE 36 02 00 21 01
|
||||
// 00 00 00 00 37 27 97 D6 01 00 0C 48 65 6C 6C 6F
|
||||
// 20 77 6F 72 6C 64 2E 0A 00 00 00 00 8E F8 31 35
|
||||
// 00 01 21 0D 75 DC A8 D2 90 42 99 0D 01 00 00 00
|
||||
// 00 01 59 5A
|
||||
// Hello world.
|
||||
}
|
||||
@@ -0,0 +1,779 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
// ----------------
|
||||
|
||||
// Package litonlylzma provides a decoder and encoder for Literal Only LZMA (or
|
||||
// Literal Only Xz), a subset of the LZMA (or Xz) compressed file formats.
|
||||
//
|
||||
// Subset means that:
|
||||
// - the Encode methods' output is a valid LZMA/Xz file and can be
|
||||
// decompressed by the tools available at https://www.7-zip.org/sdk.html or
|
||||
// https://tukaani.org/xz/ (and available as /usr/bin/lzma or /usr/bin/xz
|
||||
// on a Debian system).
|
||||
// - the Decode methods supports the Encode methods' output but they do not
|
||||
// support the full set of valid LZMA/Xz files.
|
||||
// - this codec's compression ratios are not as good as full LZMA/Xz
|
||||
// (although compression times are much faster). Moderate compression is
|
||||
// still achieved, through range coding, but there are no Lempel Ziv
|
||||
// back-references.
|
||||
//
|
||||
// The main benefit, compared to full LZMA/Xz, is that this implementation is
|
||||
// much simpler and hence easier to study. It is around 800 lines of code.
|
||||
//
|
||||
// Example compression numbers on a small English text file (at
|
||||
// https://github.com/google/wuffs/blob/main/test/data/romeo.txt):
|
||||
// - romeo.txt is 942 bytes (100%).
|
||||
// - romeo.txt.litonlyxz is 708 bytes (75%).
|
||||
// - romeo.txt.litonlylzma is 659 bytes (70%).
|
||||
// - romeo.txt.xz is 644 bytes (68%).
|
||||
// - romeo.txt.lzma is 598 bytes (63%).
|
||||
// - romeo.txt.bz2 is 568 bytes (60%).
|
||||
// - romeo.txt.zst is 559 bytes (59%).
|
||||
// - romeo.txt.gz is 558 bytes (59%).
|
||||
//
|
||||
// Example compression numbers on a large archive of source code (at
|
||||
// https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.0.1.tar.xz):
|
||||
// - linux-5.0.1.tar is 863313920 bytes (100%).
|
||||
// - linux-5.0.1.tar.litonlyxz is 454480932 bytes (53%).
|
||||
// - linux-5.0.1.tar.litonlylzma is 449726070 bytes (52%).
|
||||
// - linux-5.0.1.tar.gz is 164575959 bytes (19%).
|
||||
// - linux-5.0.1.tar.zst is 156959897 bytes (18%).
|
||||
// - linux-5.0.1.tar.bz2 is 125873134 bytes (15%).
|
||||
// - linux-5.0.1.tar.xz is 108233572 bytes (13%).
|
||||
// - linux-5.0.1.tar.lzma is 108216601 bytes (13%).
|
||||
//
|
||||
// The various tools (/usr/bin/gzip, /usr/bin/xz, etc) were all ran with their
|
||||
// default settings, not their "maximum compression" settings. This is why the
|
||||
// linux-5.0.1.tar.xz file size above differs from what cdn.kernel.org served.
|
||||
package litonlylzma
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"hash/crc32"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrUnsupportedXxxData is potentially returned by Decode.
|
||||
ErrUnsupportedLZMAData = errors.New("litonlylzma: unsupported LZMA data")
|
||||
ErrUnsupportedXzData = errors.New("litonlylzma: unsupported Xz data")
|
||||
|
||||
errInvalidLZMAData = errors.New("litonlylzma: invalid LZMA data")
|
||||
errInvalidXzData = errors.New("litonlylzma: invalid Xz data")
|
||||
errUnexpectedEOF = errors.New("litonlylzma: unexpected EOF")
|
||||
errUnsupportedFileFormat = errors.New("litonlylzma: unsupported FileFormat")
|
||||
)
|
||||
|
||||
const (
|
||||
// LZMA has a few configuration knobs but our subset-of-LZMA hard codes
|
||||
// these to LZMA's default values:
|
||||
// https://github.com/jljusten/LZMA-SDK/blob/781863cdf592da3e97420f50de5dac056ad352a5/C/LzmaEnc.h#L19-L21
|
||||
// https://github.com/jljusten/LZMA-SDK/blob/781863cdf592da3e97420f50de5dac056ad352a5/DOC/lzma-specification.txt#L43-L45
|
||||
lc = 3 // The number of Literal Context bits.
|
||||
lp = 0 // The number of Literal Position bits.
|
||||
pb = 2 // The number of Position Bits.
|
||||
|
||||
lpMask = (1 << lp) - 1
|
||||
pbMask = (1 << pb) - 1
|
||||
)
|
||||
|
||||
// lzmaHeader5 is the first 5 bytes of an LZMA file using the hard-coded
|
||||
// configuration for the subset-of-LZMA that this package supports.
|
||||
//
|
||||
// 0x5D encodes the (lc, lp, pb) triple and the next four bytes hold the u32le
|
||||
// dictionary size. 0x00001000 is LZMA's minimum dictionary size, although our
|
||||
// subset-of-LZMA does not use a dictionary (also called a "sliding window").
|
||||
const lzmaHeader5 = "\x5D\x00\x10\x00\x00"
|
||||
|
||||
// xzHeader24 is the first 24 bytes of an Xz file using the hard-coded
|
||||
// configuration for the subset-of-Xz that this package supports.
|
||||
const xzHeader24 = "" +
|
||||
"\xFD\x37\x7A\x58\x5A\x00" + // Stream Header Magic Bytes.
|
||||
// ----
|
||||
"\x00\x01" + // Stream Flags (0x01 means CRC-32).
|
||||
"\x69\x22\xDE\x36" + // CRC-32 of the previous 2 bytes.
|
||||
// ----
|
||||
"\x02" + // Block Header Size (0x02 * 4 = 8 bytes).
|
||||
"\x00" + // Block Flags.
|
||||
"\x21" + // Filter ID (0x21 means LZMA2).
|
||||
"\x01" + // Size of Filter Properties (size of the next line).
|
||||
"\x00" + // Filter Properties (0x00 means an 0x1000 dictionary size).
|
||||
"\x00\x00\x00" + // Padding to 4-byte alignment.
|
||||
"\x37\x27\x97\xD6" // CRC-32 of the previous 8 bytes.
|
||||
|
||||
// rangeDecoder and rangeEncoder hold the state for range coding (also known as
|
||||
// arithmetic coding, roughly speaking). "range" is a keyword in Go, so in this
|
||||
// implementation, what's traditionally called the "range" fields are called
|
||||
// "width" instead.
|
||||
//
|
||||
// Conceptually, the encoded bitstream holds a high precision number (a binary
|
||||
// fraction) in the range from zero to one. High precision could mean thousands
|
||||
// or millions of bits, but when decoding, only 32 of these are 'paged in' at a
|
||||
// time - this is the rangeDecoder.bits field. The encoder similarly works on
|
||||
// only a small, fixed number of bits.
|
||||
//
|
||||
// When encoding, that high precision *number* isn't fully known until the end
|
||||
// of the input is reached. *During* the encoding process, what's known is a
|
||||
// high precision *interval* that gets narrowed down as the input bytes are
|
||||
// consumed. That interval is represented by the rangeEncoder.low and
|
||||
// rangeEncoder.width fields (the width is the difference between the
|
||||
// interval's upper and lower bound). Both low and width are, conceptually,
|
||||
// 32-bit values - they operate at the same scale - but low is an uint64
|
||||
// because of potential overflow. We'll revisit that below.
|
||||
//
|
||||
// Width is initialized to 0xFFFF_FFFF and shrinks every time a bit is decoded
|
||||
// or encoded. Similarly, low can only increase or stay the same on each bit
|
||||
// step. When width drops below (1 << 24), the rangeDecoder or rangeEncoder
|
||||
// 'zooms in', left-shifting (with truncation) by 8 the bits, low and width
|
||||
// fields and reading a src byte or writing a dst byte of compressed data.
|
||||
//
|
||||
// Writing a byte may be delayed because the encoding interval could span
|
||||
// multiple possible digits. To use a decimal fraction analogy, suppose that
|
||||
// our interval is [0.7138872, 0.7146055] and the low field nominally holds 4
|
||||
// digits. We could emit '7' and '1' but we have to hold back on emitting
|
||||
// either '3' or '4' until we can narrow down the interval further. That '3'
|
||||
// digit is stashed as the pendingHead field. low is set to 8872, width is set
|
||||
// to (46055 - 38872) = 7183 and we progress until the width drops below 1000,
|
||||
// causing a 'zoom in' event. There are three cases:
|
||||
// - if low is less than 9000 (but starts with an '8'), we can emit the '3'
|
||||
// with confidence (and then stash '8' in the pendingHead field).
|
||||
// - if low overflows 9999, we can emit the '4' with confidence (and then
|
||||
// stash low's 'thousands digit' in the pendingHead field).
|
||||
// - if low is in 9000 ..= 9999 then we could still be unsure. Keep the '3'
|
||||
// pending but extend it so that there are two pending digits: '39'. If
|
||||
// this occurs again: '399', and so on.
|
||||
//
|
||||
// In all three cases, 'zooming in' causes us to shift out the most significant
|
||||
// digit of the low field. This method is therefore named shiftLow here, the
|
||||
// same name used in other range coding implementations, such as
|
||||
// https://github.com/jljusten/LZMA-SDK/blob/781863cdf592da3e97420f50de5dac056ad352a5/C/LzmaEnc.c#L572-L602
|
||||
//
|
||||
// The pendingEtc fields combine to hold one or more digits ('0' ..= '9'
|
||||
// decimal digits in our analogy, 0x00 ..= 0xFF bytes in our actual
|
||||
// implementation). There are (1 + pendingExtra) digits in total and while the
|
||||
// head digit might be any value, the extra digits must be all '9' (in the
|
||||
// decimal analogy) or 0xFF (in our actual implementation).
|
||||
//
|
||||
// Some other implementations use the name "cache" instead of "pending", and
|
||||
// store a "cacheSize" field equivalent to our (1 + pendingExtra).
|
||||
//
|
||||
// As above, the low field is conceptually a uint32, but it is a uint64 because
|
||||
// of this potential overflow. Its high 32 bits are usually zero, rarely one
|
||||
// and never anything higher. The high 32 bits essentially hold an overflow
|
||||
// carry bit. If set, it flips "3999etc" to "4000etc".
|
||||
//
|
||||
// "Low is conceptually 4 bytes; pendingHead holds another byte" is why the
|
||||
// shortest LZMA payload is 5 bytes even though the first byte is always 0x00
|
||||
// and seems redundant.
|
||||
|
||||
type rangeDecoder struct {
|
||||
src []byte
|
||||
bits uint32
|
||||
width uint32
|
||||
}
|
||||
|
||||
type rangeEncoder struct {
|
||||
dst []byte
|
||||
low uint64
|
||||
width uint32
|
||||
pendingHead uint8
|
||||
pendingExtra uint64
|
||||
}
|
||||
|
||||
// Precondition: (rEnc.width < (1 << 24)) or we are at the end of our input
|
||||
// (and are flushing the rangeEncoder).
|
||||
func (rEnc *rangeEncoder) shiftLow() {
|
||||
if rEnc.low < 0x0_FF00_0000 {
|
||||
rEnc.dst = append(rEnc.dst, rEnc.pendingHead+0x00)
|
||||
for ; rEnc.pendingExtra > 0; rEnc.pendingExtra-- {
|
||||
rEnc.dst = append(rEnc.dst, 0xFF)
|
||||
}
|
||||
rEnc.pendingHead = uint8(rEnc.low >> 24)
|
||||
rEnc.pendingExtra = 0
|
||||
rEnc.low = (rEnc.low << 8) & 0xFFFF_FFFF
|
||||
|
||||
} else if rEnc.low < 0x1_0000_0000 {
|
||||
rEnc.pendingExtra++
|
||||
rEnc.low = (rEnc.low << 8) & 0xFFFF_FFFF
|
||||
|
||||
} else {
|
||||
rEnc.dst = append(rEnc.dst, rEnc.pendingHead+0x01)
|
||||
for ; rEnc.pendingExtra > 0; rEnc.pendingExtra-- {
|
||||
rEnc.dst = append(rEnc.dst, 0x00)
|
||||
}
|
||||
rEnc.pendingHead = uint8(rEnc.low >> 24)
|
||||
rEnc.pendingExtra = 0
|
||||
rEnc.low = (rEnc.low << 8) & 0xFFFF_FFFF
|
||||
}
|
||||
}
|
||||
|
||||
// prob is a probability (out of 100%) whose uint16 value ranges from 0 to
|
||||
// (1 << 11) = 2048 inclusive. For example, prob(1024) means a 50% probability
|
||||
// and prob(384) means a (384 / 2048) = 18.75% probability.
|
||||
//
|
||||
// Specifically, it is the probability that the next bit is 0 (instead of 1).
|
||||
type prob uint16
|
||||
|
||||
const (
|
||||
// probBits is such that prob(1 << probBits) means a 100% probability.
|
||||
probBits = 11
|
||||
minProb = 0
|
||||
maxProb = 1 << probBits
|
||||
)
|
||||
|
||||
func setProbsToOneHalf(p []prob) {
|
||||
for i := range p {
|
||||
p[i] = 1 << (probBits - 1)
|
||||
}
|
||||
}
|
||||
|
||||
// adaptShift scales how much to adjust "the probability that the next bit is
|
||||
// 0" after seeing the current bit. The probability is adaptive in that the
|
||||
// current bit being 0 (or 1) increases (or decreases) the probability that the
|
||||
// next bit is 0. The larger adaptShift is, the slower the adaptation.
|
||||
const adaptShift = 5
|
||||
|
||||
func (p *prob) decodeBit(rDec *rangeDecoder) (bitValue uint32, retErr error) {
|
||||
threshold := (rDec.width >> probBits) * uint32(*p)
|
||||
if rDec.bits < threshold {
|
||||
bitValue = 0
|
||||
rDec.width = threshold
|
||||
*p += (maxProb - *p) >> adaptShift
|
||||
} else {
|
||||
bitValue = 1
|
||||
rDec.bits -= threshold
|
||||
rDec.width -= threshold
|
||||
*p -= (*p - minProb) >> adaptShift
|
||||
}
|
||||
|
||||
if rDec.width < (1 << 24) {
|
||||
if len(rDec.src) <= 0 {
|
||||
return 0, errUnexpectedEOF
|
||||
}
|
||||
rDec.bits = rDec.bits<<8 | uint32(rDec.src[0])
|
||||
rDec.width <<= 8
|
||||
rDec.src = rDec.src[1:]
|
||||
}
|
||||
return bitValue, retErr
|
||||
}
|
||||
|
||||
func (p *prob) encodeBit(rEnc *rangeEncoder, bitValue uint32) {
|
||||
threshold := (rEnc.width >> probBits) * uint32(*p)
|
||||
if bitValue == 0 {
|
||||
rEnc.width = threshold
|
||||
*p += (maxProb - *p) >> adaptShift
|
||||
} else {
|
||||
rEnc.low += uint64(threshold)
|
||||
rEnc.width -= threshold
|
||||
*p -= (*p - minProb) >> adaptShift
|
||||
}
|
||||
if rEnc.width < (1 << 24) {
|
||||
rEnc.width <<= 8
|
||||
rEnc.shiftLow()
|
||||
}
|
||||
}
|
||||
|
||||
// byteProbs hold probabilities for coding 8 bits (1 byte) of data. It is a 256
|
||||
// element array such that:
|
||||
// - The 0th element is unused.
|
||||
// - The 1st element holds the probability that the 7th bit (the highest, most
|
||||
// significant bit) is 0.
|
||||
// - The 2nd element holds the probability that the 6th bit is 0, conditional
|
||||
// on the high bit being 0.
|
||||
// - The 3rd element holds the probability that the 6th bit is 0, conditional
|
||||
// on the high bit being 1.
|
||||
// - The 4th element holds the probability that the 5th bit is 0, conditional
|
||||
// on the high two bits being 00.
|
||||
// - The 5th element holds the probability that the 5th bit is 0, conditional
|
||||
// on the high two bits being 01.
|
||||
// - The 6th element holds the probability that the 5th bit is 0, conditional
|
||||
// on the high two bits being 10.
|
||||
// - The 7th element holds the probability that the 5th bit is 0, conditional
|
||||
// on the high two bits being 11.
|
||||
// - The 8th element holds the probability that the 4th bit is 0, conditional
|
||||
// on the high three bits being 000.
|
||||
// - etc
|
||||
// - The 255th element holds the probability that the 0th bit (the lowest,
|
||||
// least significant bit) is 0, conditional on the high seven bits being
|
||||
// 1111111.
|
||||
//
|
||||
// Put another way, the 256 elements' value of N, as in "it's a probability for
|
||||
// the Nth bit", looks like this (when arranged in 8 rows of 32 elements):
|
||||
//
|
||||
// u7665555444444443333333333333333
|
||||
// 22222222222222222222222222222222
|
||||
// 11111111111111111111111111111111
|
||||
// 11111111111111111111111111111111
|
||||
// 00000000000000000000000000000000
|
||||
// 00000000000000000000000000000000
|
||||
// 00000000000000000000000000000000
|
||||
// 00000000000000000000000000000000
|
||||
//
|
||||
// The 'u' means that the 0th element is unused.
|
||||
type byteProbs [0x100]prob
|
||||
|
||||
func (p *byteProbs) decodeByte(rDec *rangeDecoder) (byteValue byte, retErr error) {
|
||||
index := uint32(1)
|
||||
for index < 0x100 {
|
||||
if bitValue, err := p[index].decodeBit(rDec); err != nil {
|
||||
return 0, err
|
||||
} else {
|
||||
index = index<<1 | bitValue
|
||||
}
|
||||
}
|
||||
return byte(index), nil
|
||||
}
|
||||
|
||||
func (p *byteProbs) encodeByte(rEnc *rangeEncoder, byteValue byte) {
|
||||
b := uint32(byteValue)
|
||||
index := uint32(1)
|
||||
for i := 7; i >= 0; i-- {
|
||||
bitValue := (b >> uint(i)) & 1
|
||||
p[index].encodeBit(rEnc, bitValue)
|
||||
index = index<<1 | bitValue
|
||||
}
|
||||
}
|
||||
|
||||
// FileFormat is a compressed file format, either the original LZMA format
|
||||
// itself or something like Xz that builds on or varies that.
|
||||
//
|
||||
// Each valid FileFormatXxx value does not distinguish between the full file
|
||||
// format (as spoken by numerous Xxx software tools) and the subset-of-Xxx
|
||||
// implemented by this package. Specifically, FileFormatLZMA.Encode will
|
||||
// produce compressed data that is valid full-LZMA (and is also valid
|
||||
// subset-of-LZMA). FileFormatLZMA.Decode can decode subset-of-LZMA (but not
|
||||
// full-LZMA).
|
||||
type FileFormat uint32
|
||||
|
||||
const (
|
||||
FileFormatInvalid = FileFormat(0)
|
||||
FileFormatLZMA = FileFormat(1)
|
||||
FileFormatXz = FileFormat(2)
|
||||
)
|
||||
|
||||
func (f FileFormat) String() string {
|
||||
switch f {
|
||||
case FileFormatLZMA:
|
||||
return "FileFormatLZMA"
|
||||
case FileFormatXz:
|
||||
return "FileFormatXz"
|
||||
}
|
||||
return "FileFormatInvalid"
|
||||
}
|
||||
|
||||
// Decode converts src from the Literal Only LZMA/Xz compressed file format,
|
||||
// appending the decoding to dst.
|
||||
//
|
||||
// It is valid to pass a nil dst, like the way it's valid to pass nil to the
|
||||
// built-in append function.
|
||||
//
|
||||
// Decode also returns the suffix of src that was not used during decoding.
|
||||
//
|
||||
// It can also return partial results. The appendedDst and remainingSrc return
|
||||
// values may be non-zero even if retErr is non-zero.
|
||||
//
|
||||
// It returns ErrUnsupportedXxxData if the source bytes look like Xxx formatted
|
||||
// data that is outside the subset-of-Xxx that this package implements.
|
||||
func (f FileFormat) Decode(dst []byte, src []byte) (appendedDst []byte, remainingSrc []byte, retErr error) {
|
||||
switch f {
|
||||
case FileFormatLZMA:
|
||||
return decodeLZMA(dst, src)
|
||||
case FileFormatXz:
|
||||
return decodeXz(dst, src)
|
||||
}
|
||||
return nil, nil, errUnsupportedFileFormat
|
||||
}
|
||||
|
||||
func decodeLZMA(dst []byte, src []byte) (appendedDst []byte, remainingSrc []byte, retErr error) {
|
||||
// LZMA consists of a 13 byte header and then at least a 5 byte payload
|
||||
// (range coded data). The 13 byte header is:
|
||||
// - 1 byte for the (lc, lp, pb) triple with max values (8, 4, 4),
|
||||
// - 4 bytes u32le dictionary size and
|
||||
// - 8 bytes i64le uncompressed size.
|
||||
if (len(src) < 18) || (src[0] >= (9 * 5 * 5)) {
|
||||
return dst, nil, errInvalidLZMAData
|
||||
} else if string(src[:5]) != lzmaHeader5 {
|
||||
return dst, nil, ErrUnsupportedLZMAData
|
||||
}
|
||||
|
||||
size := uint64(0)
|
||||
for i := 0; i < 8; i++ {
|
||||
size |= uint64(src[5+i]) << uint(8*i)
|
||||
}
|
||||
if int64(size) < -1 {
|
||||
return dst, nil, errInvalidLZMAData
|
||||
} else if int64(size) == -1 {
|
||||
return dst, nil, ErrUnsupportedLZMAData
|
||||
}
|
||||
|
||||
return decodeRaw(dst, src[13:], size, ErrUnsupportedLZMAData)
|
||||
}
|
||||
|
||||
func decodeXz(dst []byte, src []byte) (appendedDst []byte, remainingSrc []byte, retErr error) {
|
||||
originalDstLen := len(dst)
|
||||
originalSrcLen := len(src)
|
||||
|
||||
// Decode the headers.
|
||||
if (len(src) < 24) || (string(src[:6]) != xzHeader24[:6]) {
|
||||
return dst, src, errInvalidXzData
|
||||
} else if string(src[6:24]) != xzHeader24[6:24] {
|
||||
return dst, src, ErrUnsupportedXzData
|
||||
}
|
||||
src = src[24:]
|
||||
|
||||
// Decode the payload as multiple chunks.
|
||||
for {
|
||||
if len(src) == 0 {
|
||||
return dst, src, errInvalidXzData
|
||||
|
||||
} else if src[0] == 0x00 { // No more chunks.
|
||||
src = src[1:]
|
||||
break
|
||||
|
||||
} else if src[0] == 0x01 { // Independent uncompressed chunk.
|
||||
if len(src) < 3 {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
uncompressedSize := (uint32(src[1]) << 8) + (uint32(src[2]) << 0) + 1
|
||||
src = src[3:]
|
||||
if uint64(uncompressedSize) > uint64(len(src)) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
dst = append(dst, src[:uncompressedSize]...)
|
||||
src = src[uncompressedSize:]
|
||||
|
||||
} else if src[0] == 0xE0 { // Independent LZMA chunk.
|
||||
if len(src) < 6 {
|
||||
return dst, src, errInvalidXzData
|
||||
} else if src[5] != 0x5D { // Like lzmaHeader5[0], this encodes lc=3, lp=0, pb=2.
|
||||
return dst, src, ErrUnsupportedXzData
|
||||
}
|
||||
uncompressedSize := (uint32(src[1]) << 8) + (uint32(src[2]) << 0) + 1
|
||||
compressedSize := (uint32(src[3]) << 8) + (uint32(src[4]) << 0) + 1
|
||||
src = src[6:]
|
||||
if uint64(compressedSize) > uint64(len(src)) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
lenSrc := len(src)
|
||||
dst, src, retErr = decodeRaw(dst, src, uint64(uncompressedSize), ErrUnsupportedXzData)
|
||||
if retErr != nil {
|
||||
return dst, src, retErr
|
||||
} else if lenSrc != (len(src) + int(compressedSize)) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
|
||||
} else {
|
||||
return dst, src, ErrUnsupportedXzData
|
||||
}
|
||||
}
|
||||
unpaddedSizeWant := uint64((originalSrcLen - 12) - len(src) + 4)
|
||||
for i := unpaddedSizeWant & 3; (i & 3) != 0; i++ {
|
||||
if (len(src) == 0) || (src[0] != 0x00) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
src = src[1:]
|
||||
}
|
||||
if len(src) < 4 {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
checksum := crc32.ChecksumIEEE(dst[originalDstLen:])
|
||||
if (src[0] != uint8(checksum>>0)) ||
|
||||
(src[1] != uint8(checksum>>8)) ||
|
||||
(src[2] != uint8(checksum>>16)) ||
|
||||
(src[3] != uint8(checksum>>24)) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
src = src[4:]
|
||||
|
||||
// Decode the index.
|
||||
srcCheckpoint1 := src
|
||||
if (len(src) < 2) || (src[0] != 0x00) || (src[1] != 0x01) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
src = src[2:]
|
||||
src, unpaddedSizeHave, ok := decodeUvarint(src)
|
||||
if !ok || (unpaddedSizeHave != unpaddedSizeWant) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
src, uncompressedSize, ok := decodeUvarint(src)
|
||||
if !ok || (uncompressedSize != uint64(len(dst)-originalDstLen)) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
for i := (len(srcCheckpoint1) - len(src)) & 3; (i & 3) != 0; i++ {
|
||||
if (len(src) == 0) || (src[0] != 0x00) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
src = src[1:]
|
||||
}
|
||||
backwardSize := (len(srcCheckpoint1) - len(src)) >> 2
|
||||
if len(src) < 4 {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
checksum = crc32.ChecksumIEEE(srcCheckpoint1[:len(srcCheckpoint1)-len(src)])
|
||||
if (src[0] != uint8(checksum>>0)) ||
|
||||
(src[1] != uint8(checksum>>8)) ||
|
||||
(src[2] != uint8(checksum>>16)) ||
|
||||
(src[3] != uint8(checksum>>24)) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
src = src[4:]
|
||||
|
||||
// Decode the footer.
|
||||
if len(src) < 12 {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
checksum = crc32.ChecksumIEEE(src[4:10])
|
||||
if (src[0] != uint8(checksum>>0)) || // Checksum.
|
||||
(src[1] != uint8(checksum>>8)) ||
|
||||
(src[2] != uint8(checksum>>16)) ||
|
||||
(src[3] != uint8(checksum>>24)) ||
|
||||
(src[4] != uint8(backwardSize>>0)) || // Backward Size.
|
||||
(src[5] != uint8(backwardSize>>8)) ||
|
||||
(src[6] != uint8(backwardSize>>16)) ||
|
||||
(src[7] != uint8(backwardSize>>24)) ||
|
||||
(src[8] != xzHeader24[6]) || // Stream Flags again.
|
||||
(src[9] != xzHeader24[7]) ||
|
||||
(src[10] != 0x59) || // Stream Footer Magic Bytes.
|
||||
(src[11] != 0x5A) {
|
||||
return dst, src, errInvalidXzData
|
||||
}
|
||||
return dst, src[12:], nil
|
||||
}
|
||||
|
||||
func decodeRaw(dst []byte, src []byte, size uint64, errUnsupported error) (appendedDst []byte, remainingSrc []byte, retErr error) {
|
||||
if (len(src) < 5) || (src[0] != 0x00) {
|
||||
return dst, src, errUnsupported
|
||||
}
|
||||
|
||||
rDec := rangeDecoder{
|
||||
src: src[5:],
|
||||
bits: (uint32(src[1]) << 24) |
|
||||
(uint32(src[2]) << 16) |
|
||||
(uint32(src[3]) << 8) |
|
||||
(uint32(src[4]) << 0),
|
||||
width: 0xFFFF_FFFF,
|
||||
}
|
||||
|
||||
posProbs := [1 << pb]prob{}
|
||||
setProbsToOneHalf(posProbs[:])
|
||||
|
||||
litProbs := [1 << (lc + lp)]byteProbs{}
|
||||
for ij := range litProbs {
|
||||
setProbsToOneHalf(litProbs[ij][:])
|
||||
}
|
||||
|
||||
pos := uint32(0)
|
||||
prev := byte(0)
|
||||
curr := byte(0)
|
||||
for ; size > 0; size-- {
|
||||
if bitValue, err := posProbs[pos&pbMask].decodeBit(&rDec); err != nil {
|
||||
return dst, rDec.src, err
|
||||
} else if bitValue != 0 {
|
||||
// A full-LZMA decoder would implement Lempel Ziv matches (or the
|
||||
// End of Stream marker) here. Our simpler subset-of-LZMA decoder
|
||||
// only uses literals.
|
||||
return dst, rDec.src, errUnsupported
|
||||
}
|
||||
|
||||
i := (pos & lpMask) << lc
|
||||
j := uint32(prev) >> (8 - lc)
|
||||
if curr, retErr = litProbs[i|j].decodeByte(&rDec); retErr != nil {
|
||||
return dst, rDec.src, retErr
|
||||
}
|
||||
dst = append(dst, curr)
|
||||
pos++
|
||||
prev = curr
|
||||
}
|
||||
|
||||
return dst, rDec.src, nil
|
||||
}
|
||||
|
||||
func decodeUvarint(src []byte) (remainingSrc []byte, x uint64, ok bool) {
|
||||
for i := uint32(0); (i < 63) && (len(src) > 0); i += 7 {
|
||||
s := src[0]
|
||||
src = src[1:]
|
||||
x |= uint64(s&0x7F) << i
|
||||
if (s & 0x80) == 0 {
|
||||
return src, x, true
|
||||
}
|
||||
}
|
||||
return src, 0, false
|
||||
}
|
||||
|
||||
// Encode converts src to the Literal Only LZMA compressed file format,
|
||||
// appending the encoding to dst.
|
||||
//
|
||||
// It is valid to pass a nil dst, like the way it's valid to pass nil to the
|
||||
// built-in append function.
|
||||
func (f FileFormat) Encode(dst []byte, src []byte) (appendedDst []byte, retErr error) {
|
||||
switch f {
|
||||
case FileFormatLZMA:
|
||||
return encodeLZMA(dst, src)
|
||||
case FileFormatXz:
|
||||
return encodeXz(dst, src)
|
||||
}
|
||||
return nil, errUnsupportedFileFormat
|
||||
}
|
||||
|
||||
func encodeLZMA(dst []byte, src []byte) (appendedDst []byte, retErr error) {
|
||||
dst = append(dst, lzmaHeader5...)
|
||||
size := len(src)
|
||||
for i := 0; i < 8; i++ {
|
||||
dst = append(dst, byte(size))
|
||||
size >>= 8
|
||||
}
|
||||
return encodeRaw(dst, src), nil
|
||||
}
|
||||
|
||||
func encodeXz(dst []byte, src []byte) (appendedDst []byte, retErr error) {
|
||||
// Encode the headers (12 byte stream header then 12 byte block header).
|
||||
// The block's unpaddedSize calculation ignores the stream header.
|
||||
dstLen0 := len(dst) + 12
|
||||
dst = append(dst, xzHeader24...)
|
||||
|
||||
// Encode the payload as multiple chunks.
|
||||
//
|
||||
// Later XZ chunks can depend on earlier ones (and doing so can help
|
||||
// compression ratios) but for simplicity, this encoder emits independent
|
||||
// chunks. Each chunk's maximum compressed and uncompressed size are both
|
||||
// equal to 0x10000 = 65536 bytes, roughly speaking. The encoder partitions
|
||||
// the src into 65536 byte sub-slices. If a sub-slice's LZMA-compressed
|
||||
// form would be longer, the encoder emits an uncompressed chunk instead.
|
||||
rawLZMA := []byte(nil)
|
||||
for remaining := src; len(remaining) > 0; {
|
||||
srcChunk := []byte(nil)
|
||||
if len(remaining) > 0x10000 {
|
||||
srcChunk, remaining = remaining[:0x10000], remaining[0x10000:]
|
||||
} else {
|
||||
srcChunk, remaining = remaining, nil
|
||||
}
|
||||
|
||||
rawLZMA = encodeRaw(rawLZMA[:0], srcChunk)
|
||||
if (len(srcChunk) + 3) <= (len(rawLZMA) + 6) {
|
||||
dst = append(dst,
|
||||
0x01, // Independent uncompressed chunk.
|
||||
uint8((len(srcChunk)-1)>>8),
|
||||
uint8((len(srcChunk)-1)>>0),
|
||||
)
|
||||
dst = append(dst, srcChunk...)
|
||||
} else {
|
||||
dst = append(dst,
|
||||
0xE0, // Independent LZMA chunk.
|
||||
uint8((len(srcChunk)-1)>>8),
|
||||
uint8((len(srcChunk)-1)>>0),
|
||||
uint8((len(rawLZMA)-1)>>8),
|
||||
uint8((len(rawLZMA)-1)>>0),
|
||||
0x5D, // Like lzmaHeader5[0], this encodes lc=3, lp=0, pb=2.
|
||||
)
|
||||
dst = append(dst, rawLZMA...)
|
||||
}
|
||||
}
|
||||
dst = append(dst, 0x00) // No more chunks.
|
||||
unpaddedSize := uint64(len(dst)-dstLen0) + 4 // +4 for the upcoming checksum.
|
||||
for 0 != 3&(len(dst)-dstLen0) {
|
||||
dst = append(dst, 0x00) // Padding
|
||||
}
|
||||
checksum := crc32.ChecksumIEEE(src)
|
||||
dst = append(dst,
|
||||
uint8(checksum>>0),
|
||||
uint8(checksum>>8),
|
||||
uint8(checksum>>16),
|
||||
uint8(checksum>>24),
|
||||
)
|
||||
|
||||
// Encode the index.
|
||||
dstLen1 := len(dst)
|
||||
dst = append(dst,
|
||||
0x00, // Index Indicator.
|
||||
0x01, // Number of Records.
|
||||
)
|
||||
dst = encodeUvarint(dst, unpaddedSize)
|
||||
dst = encodeUvarint(dst, uint64(len(src)))
|
||||
for 0 != 3&(len(dst)-dstLen1) {
|
||||
dst = append(dst, 0x00) // Padding
|
||||
}
|
||||
backwardSize := (len(dst) - dstLen1) >> 2
|
||||
checksum = crc32.ChecksumIEEE(dst[dstLen1:])
|
||||
dst = append(dst,
|
||||
uint8(checksum>>0),
|
||||
uint8(checksum>>8),
|
||||
uint8(checksum>>16),
|
||||
uint8(checksum>>24),
|
||||
)
|
||||
|
||||
// Encode the footer.
|
||||
dstLen2 := len(dst)
|
||||
dst = append(dst,
|
||||
0, 0, 0, 0, // Space for the checksum.
|
||||
uint8(backwardSize>>0), // Backward Size.
|
||||
uint8(backwardSize>>8),
|
||||
uint8(backwardSize>>16),
|
||||
uint8(backwardSize>>24),
|
||||
xzHeader24[6], // Stream Flags again.
|
||||
xzHeader24[7],
|
||||
0x59, // Stream Footer Magic Bytes.
|
||||
0x5A,
|
||||
)
|
||||
checksum = crc32.ChecksumIEEE(dst[dstLen2+4 : dstLen2+10])
|
||||
dst[dstLen2+0] = uint8(checksum >> 0)
|
||||
dst[dstLen2+1] = uint8(checksum >> 8)
|
||||
dst[dstLen2+2] = uint8(checksum >> 16)
|
||||
dst[dstLen2+3] = uint8(checksum >> 24)
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
func encodeRaw(dst []byte, src []byte) (appendedDst []byte) {
|
||||
rEnc := rangeEncoder{
|
||||
dst: dst,
|
||||
width: 0xFFFF_FFFF,
|
||||
}
|
||||
|
||||
posProbs := [1 << pb]prob{}
|
||||
setProbsToOneHalf(posProbs[:])
|
||||
|
||||
litProbs := [1 << (lc + lp)]byteProbs{}
|
||||
for ij := range litProbs {
|
||||
setProbsToOneHalf(litProbs[ij][:])
|
||||
}
|
||||
|
||||
pos := uint32(0)
|
||||
prev := byte(0)
|
||||
for _, curr := range src {
|
||||
// A full-LZMA encoder would choose between Lempel Ziv literals and
|
||||
// matches. Our simpler subset-of-LZMA encoder only uses literals, and
|
||||
// it is not a streaming encoder (it does not need to emit an End of
|
||||
// Stream marker), so we always encode a 0 bit here.
|
||||
posProbs[pos&pbMask].encodeBit(&rEnc, 0)
|
||||
|
||||
i := (pos & lpMask) << lc
|
||||
j := uint32(prev) >> (8 - lc)
|
||||
litProbs[i|j].encodeByte(&rEnc, curr)
|
||||
pos++
|
||||
prev = curr
|
||||
}
|
||||
|
||||
// Flush the rangeEncoder.
|
||||
for i := 0; i < 5; i++ {
|
||||
rEnc.shiftLow()
|
||||
}
|
||||
|
||||
return rEnc.dst
|
||||
}
|
||||
|
||||
func encodeUvarint(dst []byte, x uint64) []byte {
|
||||
for ; x >= 0x80; x >>= 7 {
|
||||
dst = append(dst, byte(x)|0x80)
|
||||
}
|
||||
return append(dst, byte(x))
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
package litonlylzma
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
const (
|
||||
oneThousand0x00s = "oneThousand0x00s"
|
||||
oneThousand0xFFs = "oneThousand0xFFs"
|
||||
)
|
||||
|
||||
func testRoundTrip(tt *testing.T, filename string) {
|
||||
original := []byte(nil)
|
||||
switch filename {
|
||||
case oneThousand0x00s:
|
||||
original = make([]byte, 1000)
|
||||
case oneThousand0xFFs:
|
||||
original = make([]byte, 1000)
|
||||
for i := range original {
|
||||
original[i] = 0xFF
|
||||
}
|
||||
default:
|
||||
o, err := os.ReadFile("../../test/data/" + filename)
|
||||
if err != nil {
|
||||
tt.Fatalf("ReadFile: %v", err)
|
||||
}
|
||||
original = o
|
||||
}
|
||||
|
||||
fileFormats := [...]FileFormat{
|
||||
FileFormatLZMA,
|
||||
FileFormatXz,
|
||||
}
|
||||
|
||||
for _, f := range fileFormats {
|
||||
compressed, err := f.Encode(nil, original)
|
||||
if err != nil {
|
||||
tt.Fatalf("%v.Encode: %v", f, err)
|
||||
}
|
||||
recovered, _, err := f.Decode(nil, compressed)
|
||||
if err != nil {
|
||||
tt.Fatalf("%v.Decode: %v", f, err)
|
||||
}
|
||||
if !bytes.Equal(original, recovered) {
|
||||
tt.Fatalf("%v: round trip produced different bytes", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRoundTrip0Bytes(tt *testing.T) { testRoundTrip(tt, "0.bytes") }
|
||||
func TestRoundTripArchiveTar(tt *testing.T) { testRoundTrip(tt, "archive.tar") }
|
||||
func TestRoundTripOneThousand0x00s(tt *testing.T) { testRoundTrip(tt, oneThousand0x00s) }
|
||||
func TestRoundTripOneThousand0xFFs(tt *testing.T) { testRoundTrip(tt, oneThousand0xFFs) }
|
||||
func TestRoundTripPiTxt(tt *testing.T) { testRoundTrip(tt, "pi.txt") }
|
||||
func TestRoundTripRomeoTxt(tt *testing.T) { testRoundTrip(tt, "romeo.txt") }
|
||||
@@ -87,7 +87,7 @@ func (r *ReadSeeker) Seek(offset int64, whence int) (int64, error) {
|
||||
return 0, errSeekToInvalidWhence
|
||||
}
|
||||
|
||||
if r.offset < 0 {
|
||||
if offset < 0 {
|
||||
return 0, errSeekToNegativePosition
|
||||
}
|
||||
r.offset = offset
|
||||
|
||||
@@ -1064,6 +1064,22 @@ wuffs_base__count_leading_zeroes_u64(uint64_t u) {
|
||||
|
||||
// --------
|
||||
|
||||
// Normally, the wuffs_base__peek_etc and wuffs_base__poke_etc implementations
|
||||
// are both (1) correct regardless of CPU endianness and (2) very fast (e.g. an
|
||||
// inlined wuffs_base__peek_u32le__no_bounds_check call, in an optimized clang
|
||||
// or gcc build, is a single MOV instruction on x86_64).
|
||||
//
|
||||
// However, the endian-agnostic implementations are slow on Microsoft's C
|
||||
// compiler (MSC). Alternative memcpy-based implementations restore speed, but
|
||||
// they are only correct on little-endian CPU architectures. Defining
|
||||
// WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE opts in to these implementations.
|
||||
//
|
||||
// https://godbolt.org/z/q4MfjzTPh
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && \
|
||||
(defined(_M_ARM64) || defined(_M_X64))
|
||||
#define WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE
|
||||
#endif
|
||||
|
||||
#define wuffs_base__peek_u8be__no_bounds_check \
|
||||
wuffs_base__peek_u8__no_bounds_check
|
||||
#define wuffs_base__peek_u8le__no_bounds_check \
|
||||
@@ -1076,12 +1092,24 @@ wuffs_base__peek_u8__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__peek_u16be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint16_t x;
|
||||
memcpy(&x, p, 2);
|
||||
return _byteswap_ushort(x);
|
||||
#else
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__peek_u16le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint16_t x;
|
||||
memcpy(&x, p, 2);
|
||||
return x;
|
||||
#else
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -1098,14 +1126,26 @@ wuffs_base__peek_u24le__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__peek_u32be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint32_t x;
|
||||
memcpy(&x, p, 4);
|
||||
return _byteswap_ulong(x);
|
||||
#else
|
||||
return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |
|
||||
((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__peek_u32le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint32_t x;
|
||||
memcpy(&x, p, 4);
|
||||
return x;
|
||||
#else
|
||||
return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |
|
||||
((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
@@ -1154,18 +1194,30 @@ wuffs_base__peek_u56le__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__peek_u64be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint64_t x;
|
||||
memcpy(&x, p, 8);
|
||||
return _byteswap_uint64(x);
|
||||
#else
|
||||
return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |
|
||||
((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |
|
||||
((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |
|
||||
((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__peek_u64le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint64_t x;
|
||||
memcpy(&x, p, 8);
|
||||
return x;
|
||||
#else
|
||||
return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |
|
||||
((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
|
||||
((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |
|
||||
((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------
|
||||
@@ -1188,7 +1240,8 @@ wuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 2);
|
||||
@@ -1222,7 +1275,8 @@ wuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 4);
|
||||
@@ -1308,7 +1362,8 @@ wuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 8);
|
||||
@@ -6289,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
|
||||
@@ -6471,6 +6528,10 @@ 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[];
|
||||
@@ -6819,6 +6880,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[];
|
||||
@@ -6827,9 +6892,7 @@ extern const char wuffs_bzip2__error__bad_block_header[];
|
||||
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_huffman_codes[];
|
||||
extern const char wuffs_bzip2__error__bad_number_of_sections[];
|
||||
extern const char wuffs_bzip2__error__unsupported_huffman_code[];
|
||||
extern const char wuffs_bzip2__error__unsupported_block_randomization[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -6967,7 +7030,7 @@ struct wuffs_bzip2__decoder__struct {
|
||||
uint8_t f_presence[256];
|
||||
uint8_t f_mtft[256];
|
||||
uint8_t f_huffman_selectors[32768];
|
||||
uint16_t f_huffman_trees[6][1024][2];
|
||||
uint16_t f_huffman_trees[6][257][2];
|
||||
uint16_t f_huffman_tables[6][256];
|
||||
uint32_t f_bwt[1048576];
|
||||
|
||||
@@ -7085,6 +7148,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[];
|
||||
@@ -7310,6 +7377,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
|
||||
@@ -7491,6 +7562,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[];
|
||||
@@ -7761,6 +7836,10 @@ 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[];
|
||||
@@ -7996,6 +8075,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[];
|
||||
@@ -8418,6 +8501,10 @@ 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[];
|
||||
@@ -8630,6 +8717,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[];
|
||||
@@ -8898,6 +8989,10 @@ 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[];
|
||||
@@ -9216,6 +9311,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[];
|
||||
@@ -9457,6 +9556,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[];
|
||||
@@ -9927,6 +10030,10 @@ 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[];
|
||||
@@ -10272,6 +10379,10 @@ 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[];
|
||||
@@ -10595,6 +10706,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
|
||||
@@ -22645,7 +22758,7 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23520,7 +23633,7 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23562,7 +23675,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23629,7 +23742,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23676,7 +23789,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23813,7 +23926,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23846,7 +23959,7 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23916,7 +24029,7 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23953,7 +24066,7 @@ wuffs_bmp__decoder__swizzle_rle(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24178,7 +24291,7 @@ wuffs_bmp__decoder__swizzle_rle(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24215,7 +24328,7 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24318,7 +24431,7 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24351,7 +24464,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24486,7 +24599,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24689,7 +24802,7 @@ wuffs_bmp__decoder__read_palette(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24803,7 +24916,7 @@ wuffs_bmp__decoder__read_palette(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24866,9 +24979,7 @@ const char wuffs_bzip2__error__bad_block_header[] = "#bzip2: bad block header";
|
||||
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_huffman_codes[] = "#bzip2: bad number of Huffman codes";
|
||||
const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections";
|
||||
const char wuffs_bzip2__error__unsupported_huffman_code[] = "#bzip2: unsupported Huffman code";
|
||||
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";
|
||||
|
||||
@@ -25123,7 +25234,7 @@ wuffs_bzip2__decoder__transform_io(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -25337,7 +25448,7 @@ wuffs_bzip2__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -25367,7 +25478,7 @@ wuffs_bzip2__decoder__prepare_block(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -25661,7 +25772,7 @@ wuffs_bzip2__decoder__prepare_block(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -25684,7 +25795,7 @@ wuffs_bzip2__decoder__read_code_lengths(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -25789,7 +25900,7 @@ wuffs_bzip2__decoder__read_code_lengths(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -25804,7 +25915,7 @@ wuffs_bzip2__decoder__build_huffman_tree(
|
||||
uint32_t a_which) {
|
||||
uint32_t v_code_length = 0;
|
||||
uint32_t v_symbol_index = 0;
|
||||
uint32_t v_num_nodes = 0;
|
||||
uint32_t v_num_branch_nodes = 0;
|
||||
uint32_t v_stack_height = 0;
|
||||
uint32_t v_stack_values[21] = {0};
|
||||
uint32_t v_node_index = 0;
|
||||
@@ -25812,7 +25923,7 @@ wuffs_bzip2__decoder__build_huffman_tree(
|
||||
|
||||
self->private_data.f_huffman_trees[a_which][0][0] = 0;
|
||||
self->private_data.f_huffman_trees[a_which][0][1] = 0;
|
||||
v_num_nodes = 1;
|
||||
v_num_branch_nodes = 1;
|
||||
v_stack_height = 1;
|
||||
v_stack_values[0] = 0;
|
||||
v_code_length = 1;
|
||||
@@ -25837,27 +25948,27 @@ wuffs_bzip2__decoder__build_huffman_tree(
|
||||
}
|
||||
v_node_index = v_stack_values[(v_stack_height - 1)];
|
||||
if (self->private_data.f_huffman_trees[a_which][v_node_index][0] == 0) {
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][0] = ((uint16_t)(v_num_nodes));
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][0] = ((uint16_t)(v_num_branch_nodes));
|
||||
} else {
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][1] = ((uint16_t)(v_num_nodes));
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][1] = ((uint16_t)(v_num_branch_nodes));
|
||||
}
|
||||
if (v_num_nodes >= 1023) {
|
||||
return wuffs_base__make_status(wuffs_bzip2__error__unsupported_huffman_code);
|
||||
if (v_num_branch_nodes >= 257) {
|
||||
return wuffs_base__make_status(wuffs_bzip2__error__bad_huffman_code_under_subscribed);
|
||||
}
|
||||
v_stack_values[v_stack_height] = v_num_nodes;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_nodes][0] = 0;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_nodes][1] = 0;
|
||||
v_num_nodes += 1;
|
||||
v_stack_values[v_stack_height] = v_num_branch_nodes;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_branch_nodes][0] = 0;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_branch_nodes][1] = 0;
|
||||
v_num_branch_nodes += 1;
|
||||
v_stack_height += 1;
|
||||
}
|
||||
label__2__break:;
|
||||
v_node_index = v_stack_values[(v_stack_height - 1)];
|
||||
if (v_symbol_index < 2) {
|
||||
v_leaf_value = ((uint16_t)((1280 + v_symbol_index)));
|
||||
v_leaf_value = ((uint16_t)((769 + v_symbol_index)));
|
||||
} else if ((v_symbol_index + 1) < self->private_impl.f_num_symbols) {
|
||||
v_leaf_value = ((uint16_t)((1023 + v_symbol_index)));
|
||||
v_leaf_value = ((uint16_t)((511 + v_symbol_index)));
|
||||
} else {
|
||||
v_leaf_value = 2047;
|
||||
v_leaf_value = 768;
|
||||
}
|
||||
if (self->private_data.f_huffman_trees[a_which][v_node_index][0] == 0) {
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][0] = v_leaf_value;
|
||||
@@ -25898,7 +26009,7 @@ wuffs_bzip2__decoder__build_huffman_table(
|
||||
v_bits = (v_i << 24);
|
||||
v_n_bits = 0;
|
||||
v_child = 0;
|
||||
while ((v_child < 1024) && (v_n_bits < 8)) {
|
||||
while ((v_child < 257) && (v_n_bits < 8)) {
|
||||
v_child = self->private_data.f_huffman_trees[a_which][v_child][(v_bits >> 31)];
|
||||
v_bits <<= 1;
|
||||
#if defined(__GNUC__)
|
||||
@@ -25962,7 +26073,7 @@ wuffs_bzip2__decoder__flush_fast(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -26015,7 +26126,7 @@ wuffs_bzip2__decoder__flush_fast(
|
||||
if (v_block_size <= 900000) {
|
||||
self->private_impl.f_block_size = v_block_size;
|
||||
}
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26042,7 +26153,7 @@ wuffs_bzip2__decoder__flush_slow(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -26136,7 +26247,7 @@ wuffs_bzip2__decoder__flush_slow(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26171,7 +26282,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -26192,6 +26303,10 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
} else {
|
||||
v_ticks = 49;
|
||||
v_section += 1;
|
||||
if (v_section >= self->private_impl.f_num_sections) {
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_number_of_sections);
|
||||
goto exit;
|
||||
}
|
||||
v_which = WUFFS_BZIP2__CLAMP_TO_5[(self->private_data.f_huffman_selectors[(v_section & 32767)] & 7)];
|
||||
}
|
||||
v_bits |= (wuffs_base__peek_u32be__no_bounds_check(iop_a_src) >> v_n_bits);
|
||||
@@ -26200,8 +26315,8 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
v_table_entry = self->private_data.f_huffman_tables[v_which][(v_bits >> 24)];
|
||||
v_bits <<= (v_table_entry >> 12);
|
||||
v_n_bits -= ((uint32_t)((v_table_entry >> 12)));
|
||||
v_child = (v_table_entry & 2047);
|
||||
while (v_child < 1024) {
|
||||
v_child = (v_table_entry & 1023);
|
||||
while (v_child < 257) {
|
||||
v_child = self->private_data.f_huffman_trees[v_which][v_child][(v_bits >> 31)];
|
||||
v_bits <<= 1;
|
||||
if (v_n_bits <= 0) {
|
||||
@@ -26210,7 +26325,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
}
|
||||
v_n_bits -= 1;
|
||||
}
|
||||
if (v_child < 1280) {
|
||||
if (v_child < 768) {
|
||||
v_child_ff = ((uint32_t)((v_child & 255)));
|
||||
v_output = ((uint32_t)(self->private_data.f_mtft[v_child_ff]));
|
||||
wuffs_base__slice_u8__copy_from_slice(wuffs_base__make_slice_u8_ij(self->private_data.f_mtft, 1, (1 + v_child_ff)), wuffs_base__make_slice_u8(self->private_data.f_mtft, v_child_ff));
|
||||
@@ -26224,7 +26339,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
v_block_size += 1;
|
||||
v_run_shift = 0;
|
||||
goto label__outer__continue;
|
||||
} else if (v_child > 1281) {
|
||||
} else if (v_child == 768) {
|
||||
self->private_impl.f_decode_huffman_finished = true;
|
||||
goto label__outer__break;
|
||||
}
|
||||
@@ -26232,7 +26347,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_block_length);
|
||||
goto exit;
|
||||
}
|
||||
v_run = (((uint32_t)((v_child - 1279))) << v_run_shift);
|
||||
v_run = ((((uint32_t)(v_child)) & 3) << v_run_shift);
|
||||
v_run_shift += 1;
|
||||
v_i = v_block_size;
|
||||
v_j = (v_run + v_block_size);
|
||||
@@ -26262,7 +26377,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26291,7 +26406,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -26311,6 +26426,10 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
} else {
|
||||
self->private_impl.f_decode_huffman_ticks = 49;
|
||||
self->private_impl.f_decode_huffman_section += 1;
|
||||
if (self->private_impl.f_decode_huffman_section >= self->private_impl.f_num_sections) {
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_number_of_sections);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_decode_huffman_which = WUFFS_BZIP2__CLAMP_TO_5[(self->private_data.f_huffman_selectors[(self->private_impl.f_decode_huffman_section & 32767)] & 7)];
|
||||
}
|
||||
v_node_index = 0;
|
||||
@@ -26332,10 +26451,10 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
v_child = self->private_data.f_huffman_trees[self->private_impl.f_decode_huffman_which][v_node_index][(self->private_impl.f_bits >> 31)];
|
||||
self->private_impl.f_bits <<= 1;
|
||||
self->private_impl.f_n_bits -= 1;
|
||||
if (v_child < 1024) {
|
||||
if (v_child < 257) {
|
||||
v_node_index = ((uint32_t)(v_child));
|
||||
goto label__0__continue;
|
||||
} else if (v_child < 1280) {
|
||||
} else if (v_child < 768) {
|
||||
v_child_ff = ((uint32_t)((v_child & 255)));
|
||||
v_output = ((uint32_t)(self->private_data.f_mtft[v_child_ff]));
|
||||
wuffs_base__slice_u8__copy_from_slice(wuffs_base__make_slice_u8_ij(self->private_data.f_mtft, 1, (1 + v_child_ff)), wuffs_base__make_slice_u8(self->private_data.f_mtft, v_child_ff));
|
||||
@@ -26349,7 +26468,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
self->private_impl.f_block_size += 1;
|
||||
self->private_impl.f_decode_huffman_run_shift = 0;
|
||||
goto label__0__break;
|
||||
} else if (v_child > 1281) {
|
||||
} else if (v_child == 768) {
|
||||
self->private_impl.f_decode_huffman_finished = true;
|
||||
goto label__outer__break;
|
||||
}
|
||||
@@ -26357,7 +26476,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_block_length);
|
||||
goto exit;
|
||||
}
|
||||
v_run = (((uint32_t)((v_child - 1279))) << self->private_impl.f_decode_huffman_run_shift);
|
||||
v_run = ((((uint32_t)(v_child)) & 3) << self->private_impl.f_decode_huffman_run_shift);
|
||||
self->private_impl.f_decode_huffman_run_shift += 1;
|
||||
v_i = self->private_impl.f_block_size;
|
||||
v_j = (v_run + self->private_impl.f_block_size);
|
||||
@@ -26391,7 +26510,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26588,7 +26707,7 @@ wuffs_cbor__decoder__decode_tokens(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -26601,7 +26720,7 @@ wuffs_cbor__decoder__decode_tokens(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -27125,10 +27244,10 @@ wuffs_cbor__decoder__decode_tokens(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -28622,7 +28741,7 @@ wuffs_deflate__decoder__transform_io(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -28681,7 +28800,7 @@ wuffs_deflate__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -28709,7 +28828,7 @@ wuffs_deflate__decoder__decode_blocks(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -28838,7 +28957,7 @@ wuffs_deflate__decoder__decode_blocks(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -28861,7 +28980,7 @@ wuffs_deflate__decoder__decode_uncompressed(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -28874,7 +28993,7 @@ wuffs_deflate__decoder__decode_uncompressed(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -28957,10 +29076,10 @@ wuffs_deflate__decoder__decode_uncompressed(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -29044,7 +29163,7 @@ wuffs_deflate__decoder__init_dynamic_huffman(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -29265,7 +29384,7 @@ wuffs_deflate__decoder__init_dynamic_huffman(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -29558,7 +29677,7 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -29571,7 +29690,7 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -29732,10 +29851,10 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -29771,7 +29890,7 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -29784,7 +29903,7 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -29990,10 +30109,10 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -30035,7 +30154,7 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -30048,7 +30167,7 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -30209,10 +30328,10 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -30252,7 +30371,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -30265,7 +30384,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -30544,10 +30663,10 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -30836,7 +30955,7 @@ wuffs_lzw__decoder__read_from(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -30978,7 +31097,7 @@ wuffs_lzw__decoder__read_from(
|
||||
self->private_impl.f_bits = v_bits;
|
||||
self->private_impl.f_n_bits = v_n_bits;
|
||||
self->private_impl.f_output_wi = v_output_wi;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31000,7 +31119,7 @@ wuffs_lzw__decoder__write_to(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -31045,7 +31164,7 @@ wuffs_lzw__decoder__write_to(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31503,7 +31622,7 @@ wuffs_gif__decoder__tell_me_more(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -31603,7 +31722,7 @@ wuffs_gif__decoder__tell_me_more(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31769,7 +31888,7 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -31888,7 +32007,7 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31913,7 +32032,7 @@ wuffs_gif__decoder__skip_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -31988,7 +32107,7 @@ wuffs_gif__decoder__skip_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32103,7 +32222,7 @@ wuffs_gif__decoder__decode_up_to_id_part1(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32179,7 +32298,7 @@ wuffs_gif__decoder__decode_up_to_id_part1(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32201,7 +32320,7 @@ wuffs_gif__decoder__decode_header(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32252,7 +32371,7 @@ wuffs_gif__decoder__decode_header(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32278,7 +32397,7 @@ wuffs_gif__decoder__decode_lsd(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32454,7 +32573,7 @@ wuffs_gif__decoder__decode_lsd(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32475,7 +32594,7 @@ wuffs_gif__decoder__decode_extension(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32547,7 +32666,7 @@ wuffs_gif__decoder__decode_extension(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32568,7 +32687,7 @@ wuffs_gif__decoder__skip_blocks(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32615,7 +32734,7 @@ wuffs_gif__decoder__skip_blocks(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32641,7 +32760,7 @@ wuffs_gif__decoder__decode_ae(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32838,7 +32957,7 @@ wuffs_gif__decoder__decode_ae(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32861,7 +32980,7 @@ wuffs_gif__decoder__decode_gc(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32968,7 +33087,7 @@ wuffs_gif__decoder__decode_gc(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32987,7 +33106,7 @@ wuffs_gif__decoder__decode_id_part0(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -33135,7 +33254,7 @@ wuffs_gif__decoder__decode_id_part0(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -33164,7 +33283,7 @@ wuffs_gif__decoder__decode_id_part1(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -33306,7 +33425,7 @@ wuffs_gif__decoder__decode_id_part1(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -33344,7 +33463,7 @@ wuffs_gif__decoder__decode_id_part2(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -33534,7 +33653,7 @@ wuffs_gif__decoder__decode_id_part2(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -33861,7 +33980,7 @@ wuffs_gzip__decoder__transform_io(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -33874,7 +33993,7 @@ wuffs_gzip__decoder__transform_io(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -34145,10 +34264,10 @@ wuffs_gzip__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -34638,7 +34757,7 @@ wuffs_json__decoder__decode_tokens(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -34651,7 +34770,7 @@ wuffs_json__decoder__decode_tokens(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35581,10 +35700,10 @@ wuffs_json__decoder__decode_tokens(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -35608,7 +35727,7 @@ wuffs_json__decoder__decode_number(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35723,7 +35842,7 @@ wuffs_json__decoder__decode_number(
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
label__goto_done__break:;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
return (v_n | v_floating_point);
|
||||
@@ -35743,7 +35862,7 @@ wuffs_json__decoder__decode_digits(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35773,7 +35892,7 @@ wuffs_json__decoder__decode_digits(
|
||||
if (v_n == a_n) {
|
||||
v_n |= 256;
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
return v_n;
|
||||
@@ -35795,7 +35914,7 @@ wuffs_json__decoder__decode_leading(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -35808,7 +35927,7 @@ wuffs_json__decoder__decode_leading(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35878,10 +35997,10 @@ wuffs_json__decoder__decode_leading(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -35905,7 +36024,7 @@ wuffs_json__decoder__decode_comment(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -35918,7 +36037,7 @@ wuffs_json__decoder__decode_comment(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36060,10 +36179,10 @@ wuffs_json__decoder__decode_comment(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36086,7 +36205,7 @@ wuffs_json__decoder__decode_inf_nan(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -36099,7 +36218,7 @@ wuffs_json__decoder__decode_inf_nan(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36217,10 +36336,10 @@ wuffs_json__decoder__decode_inf_nan(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36243,7 +36362,7 @@ wuffs_json__decoder__decode_trailer(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -36256,7 +36375,7 @@ wuffs_json__decoder__decode_trailer(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36355,10 +36474,10 @@ wuffs_json__decoder__decode_trailer(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36538,7 +36657,7 @@ wuffs_nie__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36722,7 +36841,7 @@ wuffs_nie__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36764,7 +36883,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36831,7 +36950,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36967,7 +37086,7 @@ wuffs_nie__decoder__swizzle(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -37019,7 +37138,7 @@ wuffs_nie__decoder__swizzle(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -37445,7 +37564,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -37458,7 +37577,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -37642,10 +37761,10 @@ wuffs_zlib__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -39577,7 +39696,7 @@ wuffs_png__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -39869,7 +39988,7 @@ wuffs_png__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -39894,7 +40013,7 @@ wuffs_png__decoder__decode_ihdr(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40073,7 +40192,7 @@ wuffs_png__decoder__decode_ihdr(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40242,7 +40361,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40462,7 +40581,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40481,7 +40600,7 @@ wuffs_png__decoder__decode_actl(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40575,7 +40694,7 @@ wuffs_png__decoder__decode_actl(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40596,7 +40715,7 @@ wuffs_png__decoder__decode_chrm(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40872,7 +40991,7 @@ wuffs_png__decoder__decode_chrm(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40891,7 +41010,7 @@ wuffs_png__decoder__decode_exif(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40913,7 +41032,7 @@ wuffs_png__decoder__decode_exif(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40937,7 +41056,7 @@ wuffs_png__decoder__decode_fctl(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41250,7 +41369,7 @@ wuffs_png__decoder__decode_fctl(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41269,7 +41388,7 @@ wuffs_png__decoder__decode_gama(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41331,7 +41450,7 @@ wuffs_png__decoder__decode_gama(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41352,7 +41471,7 @@ wuffs_png__decoder__decode_iccp(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41420,7 +41539,7 @@ wuffs_png__decoder__decode_iccp(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41443,7 +41562,7 @@ wuffs_png__decoder__decode_plte(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41523,7 +41642,7 @@ wuffs_png__decoder__decode_plte(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41542,7 +41661,7 @@ wuffs_png__decoder__decode_srgb(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41584,7 +41703,7 @@ wuffs_png__decoder__decode_srgb(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41607,7 +41726,7 @@ wuffs_png__decoder__decode_trns(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41769,7 +41888,7 @@ wuffs_png__decoder__decode_trns(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41810,7 +41929,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42060,7 +42179,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -42084,7 +42203,7 @@ wuffs_png__decoder__skip_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42215,7 +42334,7 @@ wuffs_png__decoder__skip_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -42262,7 +42381,7 @@ wuffs_png__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42485,7 +42604,7 @@ wuffs_png__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -42521,7 +42640,7 @@ wuffs_png__decoder__decode_pass(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42827,7 +42946,7 @@ wuffs_png__decoder__decode_pass(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -43010,7 +43129,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -43023,7 +43142,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -43474,10 +43593,10 @@ wuffs_png__decoder__tell_me_more(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -44035,7 +44154,7 @@ wuffs_tga__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -44464,7 +44583,7 @@ wuffs_tga__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -44506,7 +44625,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -44573,7 +44692,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -44639,7 +44758,7 @@ wuffs_tga__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -44921,7 +45040,7 @@ wuffs_tga__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -45269,7 +45388,7 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -45365,7 +45484,7 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -45407,7 +45526,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -45474,7 +45593,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -45531,7 +45650,7 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -45643,7 +45762,7 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
|
||||
+331
-212
@@ -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
|
||||
// 3ff4bf46746fff230d4704f8c5a35a1665ddbd56 committed on 2022-06-03.
|
||||
// c27250f52fcfb936d4f0410d1199fe24c04b9713 committed on 2022-10-28.
|
||||
#define WUFFS_VERSION 0x000030000
|
||||
#define WUFFS_VERSION_MAJOR 0
|
||||
#define WUFFS_VERSION_MINOR 3
|
||||
#define WUFFS_VERSION_PATCH 0
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL "beta.15"
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3345
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20220603
|
||||
#define WUFFS_VERSION_STRING "0.3.0-beta.15+3345.20220603"
|
||||
#define WUFFS_VERSION_PRE_RELEASE_LABEL "rc.3"
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3369
|
||||
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20221028
|
||||
#define WUFFS_VERSION_STRING "0.3.0-rc.3+3369.20221028"
|
||||
|
||||
// ---------------- Configuration
|
||||
|
||||
@@ -1065,6 +1065,22 @@ wuffs_base__count_leading_zeroes_u64(uint64_t u) {
|
||||
|
||||
// --------
|
||||
|
||||
// Normally, the wuffs_base__peek_etc and wuffs_base__poke_etc implementations
|
||||
// are both (1) correct regardless of CPU endianness and (2) very fast (e.g. an
|
||||
// inlined wuffs_base__peek_u32le__no_bounds_check call, in an optimized clang
|
||||
// or gcc build, is a single MOV instruction on x86_64).
|
||||
//
|
||||
// However, the endian-agnostic implementations are slow on Microsoft's C
|
||||
// compiler (MSC). Alternative memcpy-based implementations restore speed, but
|
||||
// they are only correct on little-endian CPU architectures. Defining
|
||||
// WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE opts in to these implementations.
|
||||
//
|
||||
// https://godbolt.org/z/q4MfjzTPh
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && \
|
||||
(defined(_M_ARM64) || defined(_M_X64))
|
||||
#define WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE
|
||||
#endif
|
||||
|
||||
#define wuffs_base__peek_u8be__no_bounds_check \
|
||||
wuffs_base__peek_u8__no_bounds_check
|
||||
#define wuffs_base__peek_u8le__no_bounds_check \
|
||||
@@ -1077,12 +1093,24 @@ wuffs_base__peek_u8__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__peek_u16be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint16_t x;
|
||||
memcpy(&x, p, 2);
|
||||
return _byteswap_ushort(x);
|
||||
#else
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 8) | ((uint16_t)(p[1]) << 0));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__peek_u16le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint16_t x;
|
||||
memcpy(&x, p, 2);
|
||||
return x;
|
||||
#else
|
||||
return (uint16_t)(((uint16_t)(p[0]) << 0) | ((uint16_t)(p[1]) << 8));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
@@ -1099,14 +1127,26 @@ wuffs_base__peek_u24le__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__peek_u32be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint32_t x;
|
||||
memcpy(&x, p, 4);
|
||||
return _byteswap_ulong(x);
|
||||
#else
|
||||
return ((uint32_t)(p[0]) << 24) | ((uint32_t)(p[1]) << 16) |
|
||||
((uint32_t)(p[2]) << 8) | ((uint32_t)(p[3]) << 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t //
|
||||
wuffs_base__peek_u32le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint32_t x;
|
||||
memcpy(&x, p, 4);
|
||||
return x;
|
||||
#else
|
||||
return ((uint32_t)(p[0]) << 0) | ((uint32_t)(p[1]) << 8) |
|
||||
((uint32_t)(p[2]) << 16) | ((uint32_t)(p[3]) << 24);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
@@ -1155,18 +1195,30 @@ wuffs_base__peek_u56le__no_bounds_check(const uint8_t* p) {
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__peek_u64be__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint64_t x;
|
||||
memcpy(&x, p, 8);
|
||||
return _byteswap_uint64(x);
|
||||
#else
|
||||
return ((uint64_t)(p[0]) << 56) | ((uint64_t)(p[1]) << 48) |
|
||||
((uint64_t)(p[2]) << 40) | ((uint64_t)(p[3]) << 32) |
|
||||
((uint64_t)(p[4]) << 24) | ((uint64_t)(p[5]) << 16) |
|
||||
((uint64_t)(p[6]) << 8) | ((uint64_t)(p[7]) << 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint64_t //
|
||||
wuffs_base__peek_u64le__no_bounds_check(const uint8_t* p) {
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE)
|
||||
uint64_t x;
|
||||
memcpy(&x, p, 8);
|
||||
return x;
|
||||
#else
|
||||
return ((uint64_t)(p[0]) << 0) | ((uint64_t)(p[1]) << 8) |
|
||||
((uint64_t)(p[2]) << 16) | ((uint64_t)(p[3]) << 24) |
|
||||
((uint64_t)(p[4]) << 32) | ((uint64_t)(p[5]) << 40) |
|
||||
((uint64_t)(p[6]) << 48) | ((uint64_t)(p[7]) << 56);
|
||||
#endif
|
||||
}
|
||||
|
||||
// --------
|
||||
@@ -1189,7 +1241,8 @@ wuffs_base__poke_u16be__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u16le__no_bounds_check(uint8_t* p, uint16_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 2);
|
||||
@@ -1223,7 +1276,8 @@ wuffs_base__poke_u32be__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u32le__no_bounds_check(uint8_t* p, uint32_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 4);
|
||||
@@ -1309,7 +1363,8 @@ wuffs_base__poke_u64be__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||
|
||||
static inline void //
|
||||
wuffs_base__poke_u64le__no_bounds_check(uint8_t* p, uint64_t x) {
|
||||
#if defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__)
|
||||
#if defined(WUFFS_BASE__USE_MEMCPY_LE_PEEK_POKE) || \
|
||||
(defined(__GNUC__) && !defined(__clang__) && defined(__x86_64__))
|
||||
// This seems to perform better on gcc 10 (but not clang 9). Clang also
|
||||
// defines "__GNUC__".
|
||||
memcpy(p, &x, 8);
|
||||
@@ -6290,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
|
||||
@@ -6472,6 +6529,10 @@ 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[];
|
||||
@@ -6820,6 +6881,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[];
|
||||
@@ -6828,9 +6893,7 @@ extern const char wuffs_bzip2__error__bad_block_header[];
|
||||
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_huffman_codes[];
|
||||
extern const char wuffs_bzip2__error__bad_number_of_sections[];
|
||||
extern const char wuffs_bzip2__error__unsupported_huffman_code[];
|
||||
extern const char wuffs_bzip2__error__unsupported_block_randomization[];
|
||||
|
||||
// ---------------- Public Consts
|
||||
@@ -6968,7 +7031,7 @@ struct wuffs_bzip2__decoder__struct {
|
||||
uint8_t f_presence[256];
|
||||
uint8_t f_mtft[256];
|
||||
uint8_t f_huffman_selectors[32768];
|
||||
uint16_t f_huffman_trees[6][1024][2];
|
||||
uint16_t f_huffman_trees[6][257][2];
|
||||
uint16_t f_huffman_tables[6][256];
|
||||
uint32_t f_bwt[1048576];
|
||||
|
||||
@@ -7086,6 +7149,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[];
|
||||
@@ -7311,6 +7378,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
|
||||
@@ -7492,6 +7563,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[];
|
||||
@@ -7762,6 +7837,10 @@ 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[];
|
||||
@@ -7997,6 +8076,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[];
|
||||
@@ -8419,6 +8502,10 @@ 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[];
|
||||
@@ -8631,6 +8718,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[];
|
||||
@@ -8899,6 +8990,10 @@ 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[];
|
||||
@@ -9217,6 +9312,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[];
|
||||
@@ -9458,6 +9557,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[];
|
||||
@@ -9928,6 +10031,10 @@ 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[];
|
||||
@@ -10273,6 +10380,10 @@ 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[];
|
||||
@@ -10596,6 +10707,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
|
||||
@@ -22646,7 +22759,7 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23521,7 +23634,7 @@ wuffs_bmp__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23563,7 +23676,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23630,7 +23743,7 @@ wuffs_bmp__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23677,7 +23790,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23814,7 +23927,7 @@ wuffs_bmp__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23847,7 +23960,7 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -23917,7 +24030,7 @@ wuffs_bmp__decoder__swizzle_none(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -23954,7 +24067,7 @@ wuffs_bmp__decoder__swizzle_rle(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24179,7 +24292,7 @@ wuffs_bmp__decoder__swizzle_rle(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24216,7 +24329,7 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24319,7 +24432,7 @@ wuffs_bmp__decoder__swizzle_bitfields(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24352,7 +24465,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24487,7 +24600,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24690,7 +24803,7 @@ wuffs_bmp__decoder__read_palette(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -24804,7 +24917,7 @@ wuffs_bmp__decoder__read_palette(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -24867,9 +24980,7 @@ const char wuffs_bzip2__error__bad_block_header[] = "#bzip2: bad block header";
|
||||
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_huffman_codes[] = "#bzip2: bad number of Huffman codes";
|
||||
const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections";
|
||||
const char wuffs_bzip2__error__unsupported_huffman_code[] = "#bzip2: unsupported Huffman code";
|
||||
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";
|
||||
|
||||
@@ -25124,7 +25235,7 @@ wuffs_bzip2__decoder__transform_io(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -25338,7 +25449,7 @@ wuffs_bzip2__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -25368,7 +25479,7 @@ wuffs_bzip2__decoder__prepare_block(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -25662,7 +25773,7 @@ wuffs_bzip2__decoder__prepare_block(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -25685,7 +25796,7 @@ wuffs_bzip2__decoder__read_code_lengths(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -25790,7 +25901,7 @@ wuffs_bzip2__decoder__read_code_lengths(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -25805,7 +25916,7 @@ wuffs_bzip2__decoder__build_huffman_tree(
|
||||
uint32_t a_which) {
|
||||
uint32_t v_code_length = 0;
|
||||
uint32_t v_symbol_index = 0;
|
||||
uint32_t v_num_nodes = 0;
|
||||
uint32_t v_num_branch_nodes = 0;
|
||||
uint32_t v_stack_height = 0;
|
||||
uint32_t v_stack_values[21] = {0};
|
||||
uint32_t v_node_index = 0;
|
||||
@@ -25813,7 +25924,7 @@ wuffs_bzip2__decoder__build_huffman_tree(
|
||||
|
||||
self->private_data.f_huffman_trees[a_which][0][0] = 0;
|
||||
self->private_data.f_huffman_trees[a_which][0][1] = 0;
|
||||
v_num_nodes = 1;
|
||||
v_num_branch_nodes = 1;
|
||||
v_stack_height = 1;
|
||||
v_stack_values[0] = 0;
|
||||
v_code_length = 1;
|
||||
@@ -25838,27 +25949,27 @@ wuffs_bzip2__decoder__build_huffman_tree(
|
||||
}
|
||||
v_node_index = v_stack_values[(v_stack_height - 1)];
|
||||
if (self->private_data.f_huffman_trees[a_which][v_node_index][0] == 0) {
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][0] = ((uint16_t)(v_num_nodes));
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][0] = ((uint16_t)(v_num_branch_nodes));
|
||||
} else {
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][1] = ((uint16_t)(v_num_nodes));
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][1] = ((uint16_t)(v_num_branch_nodes));
|
||||
}
|
||||
if (v_num_nodes >= 1023) {
|
||||
return wuffs_base__make_status(wuffs_bzip2__error__unsupported_huffman_code);
|
||||
if (v_num_branch_nodes >= 257) {
|
||||
return wuffs_base__make_status(wuffs_bzip2__error__bad_huffman_code_under_subscribed);
|
||||
}
|
||||
v_stack_values[v_stack_height] = v_num_nodes;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_nodes][0] = 0;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_nodes][1] = 0;
|
||||
v_num_nodes += 1;
|
||||
v_stack_values[v_stack_height] = v_num_branch_nodes;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_branch_nodes][0] = 0;
|
||||
self->private_data.f_huffman_trees[a_which][v_num_branch_nodes][1] = 0;
|
||||
v_num_branch_nodes += 1;
|
||||
v_stack_height += 1;
|
||||
}
|
||||
label__2__break:;
|
||||
v_node_index = v_stack_values[(v_stack_height - 1)];
|
||||
if (v_symbol_index < 2) {
|
||||
v_leaf_value = ((uint16_t)((1280 + v_symbol_index)));
|
||||
v_leaf_value = ((uint16_t)((769 + v_symbol_index)));
|
||||
} else if ((v_symbol_index + 1) < self->private_impl.f_num_symbols) {
|
||||
v_leaf_value = ((uint16_t)((1023 + v_symbol_index)));
|
||||
v_leaf_value = ((uint16_t)((511 + v_symbol_index)));
|
||||
} else {
|
||||
v_leaf_value = 2047;
|
||||
v_leaf_value = 768;
|
||||
}
|
||||
if (self->private_data.f_huffman_trees[a_which][v_node_index][0] == 0) {
|
||||
self->private_data.f_huffman_trees[a_which][v_node_index][0] = v_leaf_value;
|
||||
@@ -25899,7 +26010,7 @@ wuffs_bzip2__decoder__build_huffman_table(
|
||||
v_bits = (v_i << 24);
|
||||
v_n_bits = 0;
|
||||
v_child = 0;
|
||||
while ((v_child < 1024) && (v_n_bits < 8)) {
|
||||
while ((v_child < 257) && (v_n_bits < 8)) {
|
||||
v_child = self->private_data.f_huffman_trees[a_which][v_child][(v_bits >> 31)];
|
||||
v_bits <<= 1;
|
||||
#if defined(__GNUC__)
|
||||
@@ -25963,7 +26074,7 @@ wuffs_bzip2__decoder__flush_fast(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -26016,7 +26127,7 @@ wuffs_bzip2__decoder__flush_fast(
|
||||
if (v_block_size <= 900000) {
|
||||
self->private_impl.f_block_size = v_block_size;
|
||||
}
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26043,7 +26154,7 @@ wuffs_bzip2__decoder__flush_slow(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -26137,7 +26248,7 @@ wuffs_bzip2__decoder__flush_slow(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26172,7 +26283,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -26193,6 +26304,10 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
} else {
|
||||
v_ticks = 49;
|
||||
v_section += 1;
|
||||
if (v_section >= self->private_impl.f_num_sections) {
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_number_of_sections);
|
||||
goto exit;
|
||||
}
|
||||
v_which = WUFFS_BZIP2__CLAMP_TO_5[(self->private_data.f_huffman_selectors[(v_section & 32767)] & 7)];
|
||||
}
|
||||
v_bits |= (wuffs_base__peek_u32be__no_bounds_check(iop_a_src) >> v_n_bits);
|
||||
@@ -26201,8 +26316,8 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
v_table_entry = self->private_data.f_huffman_tables[v_which][(v_bits >> 24)];
|
||||
v_bits <<= (v_table_entry >> 12);
|
||||
v_n_bits -= ((uint32_t)((v_table_entry >> 12)));
|
||||
v_child = (v_table_entry & 2047);
|
||||
while (v_child < 1024) {
|
||||
v_child = (v_table_entry & 1023);
|
||||
while (v_child < 257) {
|
||||
v_child = self->private_data.f_huffman_trees[v_which][v_child][(v_bits >> 31)];
|
||||
v_bits <<= 1;
|
||||
if (v_n_bits <= 0) {
|
||||
@@ -26211,7 +26326,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
}
|
||||
v_n_bits -= 1;
|
||||
}
|
||||
if (v_child < 1280) {
|
||||
if (v_child < 768) {
|
||||
v_child_ff = ((uint32_t)((v_child & 255)));
|
||||
v_output = ((uint32_t)(self->private_data.f_mtft[v_child_ff]));
|
||||
wuffs_base__slice_u8__copy_from_slice(wuffs_base__make_slice_u8_ij(self->private_data.f_mtft, 1, (1 + v_child_ff)), wuffs_base__make_slice_u8(self->private_data.f_mtft, v_child_ff));
|
||||
@@ -26225,7 +26340,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
v_block_size += 1;
|
||||
v_run_shift = 0;
|
||||
goto label__outer__continue;
|
||||
} else if (v_child > 1281) {
|
||||
} else if (v_child == 768) {
|
||||
self->private_impl.f_decode_huffman_finished = true;
|
||||
goto label__outer__break;
|
||||
}
|
||||
@@ -26233,7 +26348,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_block_length);
|
||||
goto exit;
|
||||
}
|
||||
v_run = (((uint32_t)((v_child - 1279))) << v_run_shift);
|
||||
v_run = ((((uint32_t)(v_child)) & 3) << v_run_shift);
|
||||
v_run_shift += 1;
|
||||
v_i = v_block_size;
|
||||
v_j = (v_run + v_block_size);
|
||||
@@ -26263,7 +26378,7 @@ wuffs_bzip2__decoder__decode_huffman_fast(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26292,7 +26407,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -26312,6 +26427,10 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
} else {
|
||||
self->private_impl.f_decode_huffman_ticks = 49;
|
||||
self->private_impl.f_decode_huffman_section += 1;
|
||||
if (self->private_impl.f_decode_huffman_section >= self->private_impl.f_num_sections) {
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_number_of_sections);
|
||||
goto exit;
|
||||
}
|
||||
self->private_impl.f_decode_huffman_which = WUFFS_BZIP2__CLAMP_TO_5[(self->private_data.f_huffman_selectors[(self->private_impl.f_decode_huffman_section & 32767)] & 7)];
|
||||
}
|
||||
v_node_index = 0;
|
||||
@@ -26333,10 +26452,10 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
v_child = self->private_data.f_huffman_trees[self->private_impl.f_decode_huffman_which][v_node_index][(self->private_impl.f_bits >> 31)];
|
||||
self->private_impl.f_bits <<= 1;
|
||||
self->private_impl.f_n_bits -= 1;
|
||||
if (v_child < 1024) {
|
||||
if (v_child < 257) {
|
||||
v_node_index = ((uint32_t)(v_child));
|
||||
goto label__0__continue;
|
||||
} else if (v_child < 1280) {
|
||||
} else if (v_child < 768) {
|
||||
v_child_ff = ((uint32_t)((v_child & 255)));
|
||||
v_output = ((uint32_t)(self->private_data.f_mtft[v_child_ff]));
|
||||
wuffs_base__slice_u8__copy_from_slice(wuffs_base__make_slice_u8_ij(self->private_data.f_mtft, 1, (1 + v_child_ff)), wuffs_base__make_slice_u8(self->private_data.f_mtft, v_child_ff));
|
||||
@@ -26350,7 +26469,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
self->private_impl.f_block_size += 1;
|
||||
self->private_impl.f_decode_huffman_run_shift = 0;
|
||||
goto label__0__break;
|
||||
} else if (v_child > 1281) {
|
||||
} else if (v_child == 768) {
|
||||
self->private_impl.f_decode_huffman_finished = true;
|
||||
goto label__outer__break;
|
||||
}
|
||||
@@ -26358,7 +26477,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
status = wuffs_base__make_status(wuffs_bzip2__error__bad_block_length);
|
||||
goto exit;
|
||||
}
|
||||
v_run = (((uint32_t)((v_child - 1279))) << self->private_impl.f_decode_huffman_run_shift);
|
||||
v_run = ((((uint32_t)(v_child)) & 3) << self->private_impl.f_decode_huffman_run_shift);
|
||||
self->private_impl.f_decode_huffman_run_shift += 1;
|
||||
v_i = self->private_impl.f_block_size;
|
||||
v_j = (v_run + self->private_impl.f_block_size);
|
||||
@@ -26392,7 +26511,7 @@ wuffs_bzip2__decoder__decode_huffman_slow(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -26589,7 +26708,7 @@ wuffs_cbor__decoder__decode_tokens(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -26602,7 +26721,7 @@ wuffs_cbor__decoder__decode_tokens(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -27126,10 +27245,10 @@ wuffs_cbor__decoder__decode_tokens(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -28623,7 +28742,7 @@ wuffs_deflate__decoder__transform_io(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -28682,7 +28801,7 @@ wuffs_deflate__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -28710,7 +28829,7 @@ wuffs_deflate__decoder__decode_blocks(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -28839,7 +28958,7 @@ wuffs_deflate__decoder__decode_blocks(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -28862,7 +28981,7 @@ wuffs_deflate__decoder__decode_uncompressed(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -28875,7 +28994,7 @@ wuffs_deflate__decoder__decode_uncompressed(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -28958,10 +29077,10 @@ wuffs_deflate__decoder__decode_uncompressed(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -29045,7 +29164,7 @@ wuffs_deflate__decoder__init_dynamic_huffman(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -29266,7 +29385,7 @@ wuffs_deflate__decoder__init_dynamic_huffman(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -29559,7 +29678,7 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -29572,7 +29691,7 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -29733,10 +29852,10 @@ wuffs_deflate__decoder__decode_huffman_bmi2(
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -29772,7 +29891,7 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -29785,7 +29904,7 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -29991,10 +30110,10 @@ wuffs_deflate__decoder__decode_huffman_fast32(
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -30036,7 +30155,7 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -30049,7 +30168,7 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -30210,10 +30329,10 @@ wuffs_deflate__decoder__decode_huffman_fast64__choosy_default(
|
||||
}
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -30253,7 +30372,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -30266,7 +30385,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -30545,10 +30664,10 @@ wuffs_deflate__decoder__decode_huffman_slow(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -30837,7 +30956,7 @@ wuffs_lzw__decoder__read_from(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -30979,7 +31098,7 @@ wuffs_lzw__decoder__read_from(
|
||||
self->private_impl.f_bits = v_bits;
|
||||
self->private_impl.f_n_bits = v_n_bits;
|
||||
self->private_impl.f_output_wi = v_output_wi;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31001,7 +31120,7 @@ wuffs_lzw__decoder__write_to(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -31046,7 +31165,7 @@ wuffs_lzw__decoder__write_to(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31504,7 +31623,7 @@ wuffs_gif__decoder__tell_me_more(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -31604,7 +31723,7 @@ wuffs_gif__decoder__tell_me_more(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31770,7 +31889,7 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -31889,7 +32008,7 @@ wuffs_gif__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -31914,7 +32033,7 @@ wuffs_gif__decoder__skip_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -31989,7 +32108,7 @@ wuffs_gif__decoder__skip_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32104,7 +32223,7 @@ wuffs_gif__decoder__decode_up_to_id_part1(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32180,7 +32299,7 @@ wuffs_gif__decoder__decode_up_to_id_part1(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32202,7 +32321,7 @@ wuffs_gif__decoder__decode_header(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32253,7 +32372,7 @@ wuffs_gif__decoder__decode_header(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32279,7 +32398,7 @@ wuffs_gif__decoder__decode_lsd(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32455,7 +32574,7 @@ wuffs_gif__decoder__decode_lsd(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32476,7 +32595,7 @@ wuffs_gif__decoder__decode_extension(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32548,7 +32667,7 @@ wuffs_gif__decoder__decode_extension(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32569,7 +32688,7 @@ wuffs_gif__decoder__skip_blocks(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32616,7 +32735,7 @@ wuffs_gif__decoder__skip_blocks(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32642,7 +32761,7 @@ wuffs_gif__decoder__decode_ae(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32839,7 +32958,7 @@ wuffs_gif__decoder__decode_ae(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32862,7 +32981,7 @@ wuffs_gif__decoder__decode_gc(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -32969,7 +33088,7 @@ wuffs_gif__decoder__decode_gc(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -32988,7 +33107,7 @@ wuffs_gif__decoder__decode_id_part0(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -33136,7 +33255,7 @@ wuffs_gif__decoder__decode_id_part0(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -33165,7 +33284,7 @@ wuffs_gif__decoder__decode_id_part1(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -33307,7 +33426,7 @@ wuffs_gif__decoder__decode_id_part1(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -33345,7 +33464,7 @@ wuffs_gif__decoder__decode_id_part2(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -33535,7 +33654,7 @@ wuffs_gif__decoder__decode_id_part2(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -33862,7 +33981,7 @@ wuffs_gzip__decoder__transform_io(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -33875,7 +33994,7 @@ wuffs_gzip__decoder__transform_io(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -34146,10 +34265,10 @@ wuffs_gzip__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -34639,7 +34758,7 @@ wuffs_json__decoder__decode_tokens(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -34652,7 +34771,7 @@ wuffs_json__decoder__decode_tokens(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35582,10 +35701,10 @@ wuffs_json__decoder__decode_tokens(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -35609,7 +35728,7 @@ wuffs_json__decoder__decode_number(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35724,7 +35843,7 @@ wuffs_json__decoder__decode_number(
|
||||
goto label__goto_done__break;
|
||||
}
|
||||
label__goto_done__break:;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
return (v_n | v_floating_point);
|
||||
@@ -35744,7 +35863,7 @@ wuffs_json__decoder__decode_digits(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35774,7 +35893,7 @@ wuffs_json__decoder__decode_digits(
|
||||
if (v_n == a_n) {
|
||||
v_n |= 256;
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
return v_n;
|
||||
@@ -35796,7 +35915,7 @@ wuffs_json__decoder__decode_leading(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -35809,7 +35928,7 @@ wuffs_json__decoder__decode_leading(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -35879,10 +35998,10 @@ wuffs_json__decoder__decode_leading(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -35906,7 +36025,7 @@ wuffs_json__decoder__decode_comment(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -35919,7 +36038,7 @@ wuffs_json__decoder__decode_comment(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36061,10 +36180,10 @@ wuffs_json__decoder__decode_comment(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36087,7 +36206,7 @@ wuffs_json__decoder__decode_inf_nan(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -36100,7 +36219,7 @@ wuffs_json__decoder__decode_inf_nan(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36218,10 +36337,10 @@ wuffs_json__decoder__decode_inf_nan(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36244,7 +36363,7 @@ wuffs_json__decoder__decode_trailer(
|
||||
wuffs_base__token* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
wuffs_base__token* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -36257,7 +36376,7 @@ wuffs_json__decoder__decode_trailer(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36356,10 +36475,10 @@ wuffs_json__decoder__decode_trailer(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36539,7 +36658,7 @@ wuffs_nie__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36723,7 +36842,7 @@ wuffs_nie__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36765,7 +36884,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -36832,7 +36951,7 @@ wuffs_nie__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -36968,7 +37087,7 @@ wuffs_nie__decoder__swizzle(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -37020,7 +37139,7 @@ wuffs_nie__decoder__swizzle(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -37446,7 +37565,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -37459,7 +37578,7 @@ wuffs_zlib__decoder__transform_io(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -37643,10 +37762,10 @@ wuffs_zlib__decoder__transform_io(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -39578,7 +39697,7 @@ wuffs_png__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -39870,7 +39989,7 @@ wuffs_png__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -39895,7 +40014,7 @@ wuffs_png__decoder__decode_ihdr(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40074,7 +40193,7 @@ wuffs_png__decoder__decode_ihdr(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40243,7 +40362,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40463,7 +40582,7 @@ wuffs_png__decoder__decode_other_chunk(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40482,7 +40601,7 @@ wuffs_png__decoder__decode_actl(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40576,7 +40695,7 @@ wuffs_png__decoder__decode_actl(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40597,7 +40716,7 @@ wuffs_png__decoder__decode_chrm(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40873,7 +40992,7 @@ wuffs_png__decoder__decode_chrm(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40892,7 +41011,7 @@ wuffs_png__decoder__decode_exif(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -40914,7 +41033,7 @@ wuffs_png__decoder__decode_exif(
|
||||
ok:
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -40938,7 +41057,7 @@ wuffs_png__decoder__decode_fctl(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41251,7 +41370,7 @@ wuffs_png__decoder__decode_fctl(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41270,7 +41389,7 @@ wuffs_png__decoder__decode_gama(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41332,7 +41451,7 @@ wuffs_png__decoder__decode_gama(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41353,7 +41472,7 @@ wuffs_png__decoder__decode_iccp(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41421,7 +41540,7 @@ wuffs_png__decoder__decode_iccp(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41444,7 +41563,7 @@ wuffs_png__decoder__decode_plte(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41524,7 +41643,7 @@ wuffs_png__decoder__decode_plte(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41543,7 +41662,7 @@ wuffs_png__decoder__decode_srgb(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41585,7 +41704,7 @@ wuffs_png__decoder__decode_srgb(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41608,7 +41727,7 @@ wuffs_png__decoder__decode_trns(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -41770,7 +41889,7 @@ wuffs_png__decoder__decode_trns(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -41811,7 +41930,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42061,7 +42180,7 @@ wuffs_png__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -42085,7 +42204,7 @@ wuffs_png__decoder__skip_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42216,7 +42335,7 @@ wuffs_png__decoder__skip_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -42263,7 +42382,7 @@ wuffs_png__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42486,7 +42605,7 @@ wuffs_png__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -42522,7 +42641,7 @@ wuffs_png__decoder__decode_pass(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -42828,7 +42947,7 @@ wuffs_png__decoder__decode_pass(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -43011,7 +43130,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
uint8_t* io0_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io1_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
uint8_t* io2_a_dst WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
io0_a_dst = a_dst->data.ptr;
|
||||
io1_a_dst = io0_a_dst + a_dst->meta.wi;
|
||||
iop_a_dst = io1_a_dst;
|
||||
@@ -43024,7 +43143,7 @@ wuffs_png__decoder__tell_me_more(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -43475,10 +43594,10 @@ wuffs_png__decoder__tell_me_more(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_dst) {
|
||||
if (a_dst && a_dst->data.ptr) {
|
||||
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
|
||||
}
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -44036,7 +44155,7 @@ wuffs_tga__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -44465,7 +44584,7 @@ wuffs_tga__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -44507,7 +44626,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -44574,7 +44693,7 @@ wuffs_tga__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -44640,7 +44759,7 @@ wuffs_tga__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -44922,7 +45041,7 @@ wuffs_tga__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -45270,7 +45389,7 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -45366,7 +45485,7 @@ wuffs_wbmp__decoder__decode_image_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -45408,7 +45527,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -45475,7 +45594,7 @@ wuffs_wbmp__decoder__decode_frame_config(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
@@ -45532,7 +45651,7 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
const uint8_t* io2_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
io0_a_src = a_src->data.ptr;
|
||||
io1_a_src = io0_a_src + a_src->meta.ri;
|
||||
iop_a_src = io1_a_src;
|
||||
@@ -45644,7 +45763,7 @@ wuffs_wbmp__decoder__decode_frame(
|
||||
|
||||
goto exit;
|
||||
exit:
|
||||
if (a_src) {
|
||||
if (a_src && a_src->data.ptr) {
|
||||
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright 2022 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.
|
||||
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
// litonlylzma.go converts to and from the Literal Only LZMA compressed file
|
||||
// format, a subset of the LZMA compressed file format (e.g. as spoken by
|
||||
// /usr/bin/lzma on a Debian system).
|
||||
//
|
||||
// Usage:
|
||||
// go run litonlylzma.go -encode < foo.txt > foo.txt.litonlylzma
|
||||
// go run litonlylzma.go -decode < foo.txt.litonlylzma
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/google/wuffs/lib/litonlylzma"
|
||||
)
|
||||
|
||||
var (
|
||||
decode = flag.Bool("decode", false, "decode from LZMA")
|
||||
encode = flag.Bool("encode", false, "encode to LZMA")
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := main1(); err != nil {
|
||||
os.Stderr.WriteString(err.Error() + "\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func main1() error {
|
||||
flag.Parse()
|
||||
if *decode == *encode {
|
||||
return fmt.Errorf("exactly one of -decode and -encode needed")
|
||||
}
|
||||
src, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dst, err := []byte(nil), error(nil)
|
||||
if *decode {
|
||||
dst, _, err = litonlylzma.FileFormatLZMA.Decode(nil, src)
|
||||
} else {
|
||||
dst, err = litonlylzma.FileFormatLZMA.Encode(nil, src)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = os.Stdout.Write(dst)
|
||||
return err
|
||||
}
|
||||
+112
-28
@@ -88,7 +88,7 @@ func main1() error {
|
||||
const rep = "repeat "
|
||||
if strings.HasPrefix(s, rep) {
|
||||
args := s[len(rep):]
|
||||
count, args, ok := parseNum(args)
|
||||
count, args, ok := parseNum32(args)
|
||||
if !ok || count <= 0 || args != "[" {
|
||||
return fmt.Errorf("bad repeat command: %q", s)
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func log2(u uint32) (i int32) {
|
||||
return -1
|
||||
}
|
||||
|
||||
func parseHex(s string) (num uint32, remaining string, ok bool) {
|
||||
func parseHex32(s string) (num uint32, remaining string, ok bool) {
|
||||
if i := strings.IndexByte(s, ' '); i >= 0 {
|
||||
s, remaining = s[:i], s[i+1:]
|
||||
for len(remaining) > 0 && remaining[0] == ' ' {
|
||||
@@ -177,7 +177,27 @@ func parseHex(s string) (num uint32, remaining string, ok bool) {
|
||||
return uint32(u), remaining, true
|
||||
}
|
||||
|
||||
func parseNum(s string) (num uint32, remaining string, ok bool) {
|
||||
func parseHex64(s string) (num uint64, remaining string, ok bool) {
|
||||
if i := strings.IndexByte(s, ' '); i >= 0 {
|
||||
s, remaining = s[:i], s[i+1:]
|
||||
for len(remaining) > 0 && remaining[0] == ' ' {
|
||||
remaining = remaining[1:]
|
||||
}
|
||||
}
|
||||
|
||||
if len(s) < 2 || s[0] != '0' || s[1] != 'x' {
|
||||
return 0, "", false
|
||||
}
|
||||
s = s[2:]
|
||||
|
||||
u, err := strconv.ParseUint(s, 16, 64)
|
||||
if err != nil {
|
||||
return 0, "", false
|
||||
}
|
||||
return u, remaining, true
|
||||
}
|
||||
|
||||
func parseNum32(s string) (num uint32, remaining string, ok bool) {
|
||||
if i := strings.IndexByte(s, ' '); i >= 0 {
|
||||
s, remaining = s[:i], s[i+1:]
|
||||
for len(remaining) > 0 && remaining[0] == ' ' {
|
||||
@@ -237,6 +257,70 @@ var reverse8 = [256]byte{
|
||||
|
||||
// ----
|
||||
|
||||
func init() {
|
||||
formats["bzip2"] = stateBzip2
|
||||
}
|
||||
|
||||
var bzip2Globals struct {
|
||||
stream bzip2BitStream
|
||||
}
|
||||
|
||||
func stateBzip2(line string) (stateFunc, error) {
|
||||
g := &bzip2Globals
|
||||
const (
|
||||
cmdB = "bits "
|
||||
)
|
||||
switch {
|
||||
case line == "":
|
||||
g.stream.flush()
|
||||
return stateBzip2, nil
|
||||
|
||||
case strings.HasPrefix(line, cmdB):
|
||||
s := strings.TrimSpace(line[len(cmdB):])
|
||||
n, s, ok := parseNum32(s)
|
||||
if !ok || s == "" {
|
||||
break
|
||||
}
|
||||
x, s, ok := parseHex64(s)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
g.stream.writeBits64(x, n)
|
||||
return stateBzip2, nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("bad stateBzip2 command: %q", line)
|
||||
}
|
||||
|
||||
type bzip2BitStream struct {
|
||||
bits uint64
|
||||
nBits uint32 // Always within [0, 7].
|
||||
}
|
||||
|
||||
// writeBits64 writes the low n bits of b to z.
|
||||
func (z *bzip2BitStream) writeBits64(b uint64, n uint32) {
|
||||
if n > 56 {
|
||||
panic("writeBits64: n is too large")
|
||||
}
|
||||
z.bits |= b << (64 - n - z.nBits)
|
||||
z.nBits += n
|
||||
for z.nBits >= 8 {
|
||||
out = append(out, uint8(z.bits>>56))
|
||||
z.bits <<= 8
|
||||
z.nBits -= 8
|
||||
}
|
||||
}
|
||||
|
||||
func (z *bzip2BitStream) flush() {
|
||||
if z.nBits > 0 {
|
||||
out = append(out, uint8(z.bits>>56))
|
||||
z.bits = 0
|
||||
z.nBits = 0
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
|
||||
func init() {
|
||||
formats["deflate"] = stateDeflate
|
||||
}
|
||||
@@ -529,7 +613,7 @@ func stateDeflate(line string) (stateFunc, error) {
|
||||
s := line[len(cmdB):]
|
||||
for s != "" {
|
||||
x, ok := uint32(0), false
|
||||
x, s, ok = parseHex(s)
|
||||
x, s, ok = parseHex32(s)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("bad stateDeflate command: %q", line)
|
||||
}
|
||||
@@ -728,7 +812,7 @@ outer:
|
||||
|
||||
default:
|
||||
s := line
|
||||
n, s, ok := parseNum(s)
|
||||
n, s, ok := parseNum32(s)
|
||||
if !ok || s == "" {
|
||||
break
|
||||
}
|
||||
@@ -743,7 +827,7 @@ outer:
|
||||
|
||||
if g.etcetera {
|
||||
g.etcetera = false
|
||||
n0, s0, ok := parseNum(g.prevLine)
|
||||
n0, s0, ok := parseNum32(g.prevLine)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("bad etcetera command")
|
||||
}
|
||||
@@ -965,10 +1049,10 @@ func deflateParseLenDist(line string) (l uint32, d uint32, ok bool) {
|
||||
s := line
|
||||
if strings.HasPrefix(s, lStr) {
|
||||
s = s[len(lStr):]
|
||||
if l, s, ok := parseNum(s); ok && 3 <= l && l <= 258 {
|
||||
if l, s, ok := parseNum32(s); ok && 3 <= l && l <= 258 {
|
||||
if strings.HasPrefix(s, dStr) {
|
||||
s = s[len(dStr):]
|
||||
if d, s, ok := parseNum(s); ok && 1 <= d && d <= 32768 && s == "" {
|
||||
if d, s, ok := parseNum32(s); ok && 1 <= d && d <= 32768 && s == "" {
|
||||
return l, d, true
|
||||
}
|
||||
}
|
||||
@@ -1035,7 +1119,7 @@ outer:
|
||||
s := line[len(cmdB):]
|
||||
for s != "" {
|
||||
x, ok := uint32(0), false
|
||||
x, s, ok = parseHex(s)
|
||||
x, s, ok = parseHex32(s)
|
||||
if !ok {
|
||||
break outer
|
||||
}
|
||||
@@ -1076,7 +1160,7 @@ outer:
|
||||
flags |= 0x01
|
||||
transparentIndex = uint8(num)
|
||||
case strings.HasSuffix(term, ms):
|
||||
num, remaining, ok := parseNum(term[:len(term)-len(ms)])
|
||||
num, remaining, ok := parseNum32(term[:len(term)-len(ms)])
|
||||
if !ok || remaining != "" {
|
||||
break outer
|
||||
}
|
||||
@@ -1098,7 +1182,7 @@ outer:
|
||||
|
||||
case strings.HasPrefix(line, cmdL):
|
||||
s := line[len(cmdL):]
|
||||
litWidth, s, ok := parseNum(s)
|
||||
litWidth, s, ok := parseNum32(s)
|
||||
if !ok || litWidth < 2 || 8 < litWidth {
|
||||
break
|
||||
}
|
||||
@@ -1107,7 +1191,7 @@ outer:
|
||||
uncompressed := []byte(nil)
|
||||
for s != "" {
|
||||
x := uint32(0)
|
||||
x, s, ok = parseHex(s)
|
||||
x, s, ok = parseHex32(s)
|
||||
if !ok {
|
||||
break outer
|
||||
}
|
||||
@@ -1140,7 +1224,7 @@ outer:
|
||||
|
||||
case strings.HasPrefix(line, cmdLC):
|
||||
s := line[len(cmdLC):]
|
||||
loopCount, _, ok := parseNum(s)
|
||||
loopCount, _, ok := parseNum32(s)
|
||||
if !ok || 0xFFFF < loopCount {
|
||||
break
|
||||
}
|
||||
@@ -1191,15 +1275,15 @@ func stateGifImage(line string) (stateFunc, error) {
|
||||
switch {
|
||||
case strings.HasPrefix(line, cmdBCI):
|
||||
s := line[len(cmdBCI):]
|
||||
if i, _, ok := parseNum(s); ok {
|
||||
if i, _, ok := parseNum32(s); ok {
|
||||
g.imageBackgroundColorIndex = i
|
||||
}
|
||||
return stateGifImage, nil
|
||||
|
||||
case strings.HasPrefix(line, cmdIWH):
|
||||
s := line[len(cmdIWH):]
|
||||
if w, s, ok := parseNum(s); ok {
|
||||
if h, _, ok := parseNum(s); ok {
|
||||
if w, s, ok := parseNum32(s); ok {
|
||||
if h, _, ok := parseNum32(s); ok {
|
||||
g.imageWidth = w
|
||||
g.imageHeight = h
|
||||
return stateGifImage, nil
|
||||
@@ -1248,10 +1332,10 @@ func stateGifFrame(line string) (stateFunc, error) {
|
||||
|
||||
case strings.HasPrefix(line, cmdFLTWH):
|
||||
s := line[len(cmdFLTWH):]
|
||||
if l, s, ok := parseNum(s); ok {
|
||||
if t, s, ok := parseNum(s); ok {
|
||||
if w, s, ok := parseNum(s); ok {
|
||||
if h, _, ok := parseNum(s); ok {
|
||||
if l, s, ok := parseNum32(s); ok {
|
||||
if t, s, ok := parseNum32(s); ok {
|
||||
if w, s, ok := parseNum32(s); ok {
|
||||
if h, _, ok := parseNum32(s); ok {
|
||||
g.frameLeft = l
|
||||
g.frameTop = t
|
||||
g.frameWidth = w
|
||||
@@ -1276,9 +1360,9 @@ func stateGifImagePalette(line string) (stateFunc, error) {
|
||||
}
|
||||
|
||||
s := line
|
||||
if rgb0, s, ok := parseHex(s); ok {
|
||||
if rgb1, s, ok := parseHex(s); ok {
|
||||
if rgb2, _, ok := parseHex(s); ok {
|
||||
if rgb0, s, ok := parseHex32(s); ok {
|
||||
if rgb1, s, ok := parseHex32(s); ok {
|
||||
if rgb2, _, ok := parseHex32(s); ok {
|
||||
g.globalPalette = append(g.globalPalette,
|
||||
[4]uint8{uint8(rgb0), uint8(rgb1), uint8(rgb2), 0xFF})
|
||||
return stateGifImagePalette, nil
|
||||
@@ -1296,9 +1380,9 @@ func stateGifFramePalette(line string) (stateFunc, error) {
|
||||
}
|
||||
|
||||
s := line
|
||||
if rgb0, s, ok := parseHex(s); ok {
|
||||
if rgb1, s, ok := parseHex(s); ok {
|
||||
if rgb2, _, ok := parseHex(s); ok {
|
||||
if rgb0, s, ok := parseHex32(s); ok {
|
||||
if rgb1, s, ok := parseHex32(s); ok {
|
||||
if rgb2, _, ok := parseHex32(s); ok {
|
||||
g.localPalette = append(g.localPalette,
|
||||
[4]uint8{uint8(rgb0), uint8(rgb1), uint8(rgb2), 0xFF})
|
||||
return stateGifFramePalette, nil
|
||||
@@ -1381,7 +1465,7 @@ func statePngRaw(line string) (stateFunc, error) {
|
||||
}
|
||||
|
||||
for s := line; s != ""; {
|
||||
if x, remaining, ok := parseHex(s); ok {
|
||||
if x, remaining, ok := parseHex32(s); ok {
|
||||
g.chunkData.WriteByte(byte(x))
|
||||
s = remaining
|
||||
} else {
|
||||
@@ -1401,7 +1485,7 @@ func statePngZlib(line string) (stateFunc, error) {
|
||||
}
|
||||
|
||||
for s := line; s != ""; {
|
||||
if x, remaining, ok := parseHex(s); ok {
|
||||
if x, remaining, ok := parseHex32(s); ok {
|
||||
g.scratch[0] = byte(x)
|
||||
g.zlibWriter.Write(g.scratch[:1])
|
||||
s = remaining
|
||||
|
||||
@@ -365,7 +365,7 @@ type bitVector []uint8
|
||||
// zig packs a pair of non-negative integers (i, j) into a single unique
|
||||
// non-negative integer, in a zig-zagging pattern:
|
||||
//
|
||||
// i=0 i=1 i=2 i=3 i=4 etc
|
||||
// . i=0 i=1 i=2 i=3 i=4 etc
|
||||
// j=0: 0 1 3 6 10 ...
|
||||
// j=1: 2 4 7 11 16 ...
|
||||
// j=2: 5 8 12 17 23 ...
|
||||
|
||||
@@ -18,9 +18,7 @@ pub status "#bad block header"
|
||||
pub status "#bad block length"
|
||||
pub status "#bad checksum"
|
||||
pub status "#bad header"
|
||||
pub status "#bad number of Huffman codes"
|
||||
pub status "#bad number of sections"
|
||||
pub status "#unsupported Huffman code"
|
||||
pub status "#unsupported block randomization"
|
||||
|
||||
pri status "#internal error: inconsistent Huffman decoder state"
|
||||
@@ -74,20 +72,30 @@ pub struct decoder? implements base.io_transformer(
|
||||
// 50-symbol section.
|
||||
huffman_selectors : array[32768] base.u8,
|
||||
|
||||
// Each array[2] base.u16 is a Huffman tree node. The build_huffman_tree
|
||||
// method comment details what the base.u16 values mean.
|
||||
// Each array[2] base.u16 is a branch node in the Huffman tree. The
|
||||
// build_huffman_tree method comment details what the base.u16 values mean.
|
||||
//
|
||||
// 1024 is just a guess for the worst case number of nodes needed. TODO: be
|
||||
// more rigorous about deriving this upper bound.
|
||||
huffman_trees : array[6] array[1024] array[2] base.u16,
|
||||
// Each Huffman tree has num_symbols leaf nodes and hence (num_symbols - 1)
|
||||
// branch nodes, also called internal nodes, as per
|
||||
// https://stackoverflow.com/questions/69399994/maximum-number-of-nodes-in-a-huffman-tree/69401083#69401083
|
||||
//
|
||||
// This can be proven inductively. The base case Huffman code (two symbols)
|
||||
// has one branch node (the root node). The inductive case, adding one
|
||||
// symbol to a (complete but possibly non-canonical) Huffman code replaces
|
||||
// one leaf node with one branch node (and two leaf nodes). The net gain in
|
||||
// branch nodes is +1.
|
||||
//
|
||||
// Since num_symbols' inclusive maximum is 258 (for RUNA, RUNB, 255 × mXYZ,
|
||||
// EOB), there are at most 257 branch nodes.
|
||||
huffman_trees : array[6] array[257] array[2] base.u16,
|
||||
|
||||
// huffman_tables[which] caches the result of walking huffman_trees[which]
|
||||
// for each possible 8-bit input. The base.u16 value decomposes as:
|
||||
// - The low 11 bits are the final node, where finality comes either from
|
||||
// - The low 10 bits are the final node, where finality comes either from
|
||||
// hitting a leaf node or from spending all 8 bits of the input. As per
|
||||
// the build_huffman_tree method, a value of 0x3FF = 1023 or less means
|
||||
// a branch node and 0x400 = 1024 or more means a leaf node.
|
||||
// - The middle bit is unused.
|
||||
// the build_huffman_tree method, a value of 0x100 = 256 or less means
|
||||
// a branch node and 0x201 = 513 or more means a leaf node.
|
||||
// - The middle 2 bits are unused.
|
||||
// - The high 4 bits are the number of input bits spent.
|
||||
huffman_tables : array[6] array[256] base.u16,
|
||||
|
||||
@@ -536,29 +544,31 @@ pri func decoder.read_code_lengths?(src: base.io_reader) {
|
||||
|
||||
// build_huffman_tree builds a canonical Huffman tree given the symbols' code
|
||||
// lengths. For the "abraca.txt.bz2" example, the code lengths are:
|
||||
// - symbol=0x500 (RUNA) cl=3
|
||||
// - symbol=0x501 (RUNB) cl=3
|
||||
// - symbol=0x401 (m01) cl=2
|
||||
// - symbol=0x402 (m02) cl=3
|
||||
// - symbol=0x403 (m03) cl=2
|
||||
// - symbol=0x7FF (EOB) cl=3
|
||||
// - symbol=0x301 (RUNA) cl=3
|
||||
// - symbol=0x302 (RUNB) cl=3
|
||||
// - symbol=0x201 (m01) cl=2
|
||||
// - symbol=0x202 (m02) cl=3
|
||||
// - symbol=0x203 (m03) cl=2
|
||||
// - symbol=0x300 (EOB) cl=3
|
||||
//
|
||||
// The bitstring mapping is:
|
||||
// - "00" 0x401 (m01)
|
||||
// - "01" 0x403 (m03)
|
||||
// - "100" 0x500 (RUNA)
|
||||
// - "101" 0x501 (RUNB)
|
||||
// - "110" 0x402 (m02)
|
||||
// - "111" 0x7FF (EOB)
|
||||
// - "00" 0x201 (m01)
|
||||
// - "01" 0x203 (m03)
|
||||
// - "100" 0x301 (RUNA)
|
||||
// - "101" 0x302 (RUNB)
|
||||
// - "110" 0x202 (m02)
|
||||
// - "111" 0x300 (EOB)
|
||||
//
|
||||
// The Huffman tree has 5 nodes. Each node has two children, represented by a
|
||||
// base.u16 value. 1023 or less means that the child is a branch node. 1024 =
|
||||
// 0x400 or above means a leaf node (with the symbol values as above).
|
||||
// The Huffman tree has 5 branch nodes (where 5+1 is both the number of leaf
|
||||
// nodes and the number of symbols). Each branch node has two children,
|
||||
// represented by a base.u16 value. 0x100 = 256 or less means that the child is
|
||||
// a branch node. 0x201 ..= 0x2FF means an mNN leaf node. 0x300, 0x301 and
|
||||
// 0x302 mean EOB, RUNA and RUNB leaf nodes.
|
||||
// - node0 = [0x001 (node1), 0x002 (node2)]
|
||||
// - node1 = [0x401 (m01) , 0x403 (m03) ]
|
||||
// - node1 = [0x201 (m01) , 0x203 (m03) ]
|
||||
// - node2 = [0x003 (node3), 0x004 (node4)]
|
||||
// - node3 = [0x500 (RUNA) , 0x501 (RUNB) ]
|
||||
// - node4 = [0x402 (m02) , 0x7FF (EOB) ]
|
||||
// - node3 = [0x301 (RUNA) , 0x302 (RUNB) ]
|
||||
// - node4 = [0x202 (m02) , 0x300 (EOB) ]
|
||||
//
|
||||
// For example, the tree walk from node0 right (1) to node2 left (0) to node3
|
||||
// left (0) to RUNA means that the RUNA bitstring is "100".
|
||||
@@ -567,30 +577,30 @@ pri func decoder.read_code_lengths?(src: base.io_reader) {
|
||||
// length order, maintaining a stack of nodes that's the path from the root
|
||||
// (node0) to the latest created-but-unfinished node. Created means that their
|
||||
// left child is assigned (non-zero). Unfinished means that their right child
|
||||
// is pending (zero). For example, after adding the 0x401, 0x403 and 0x500
|
||||
// is pending (zero). For example, after adding the 0x201, 0x203 and 0x301
|
||||
// symbols, we would have this (in-progress) tree:
|
||||
// - node0 = [0x001 (node1), 0x002 (node2)]
|
||||
// - node1 = [0x401 (m01) , 0x403 (m03) ]
|
||||
// - node1 = [0x201 (m01) , 0x203 (m03) ]
|
||||
// - node2 = [0x003 (node3), 0 ]
|
||||
// - node3 = [0x500 (RUNA) , 0 ]
|
||||
// - node3 = [0x301 (RUNA) , 0 ]
|
||||
//
|
||||
// The stack would be [node0, node2, node3]. The next symbol would fill in the
|
||||
// top of the stack, node3. If that symbol's code length matches the stack
|
||||
// height (here, 3) then it would pop the stack. Otherwise it would push new
|
||||
// nodes onto the stack until the stack height matched that code length.
|
||||
pri func decoder.build_huffman_tree!(which: base.u32[..= 5]) base.status {
|
||||
var code_length : base.u32
|
||||
var symbol_index : base.u32
|
||||
var num_nodes : base.u32[..= 1023]
|
||||
var stack_height : base.u32[..= 21]
|
||||
var stack_values : array[21] base.u32[..= 1023]
|
||||
var node_index : base.u32[..= 1023]
|
||||
var leaf_value : base.u16
|
||||
var code_length : base.u32
|
||||
var symbol_index : base.u32
|
||||
var num_branch_nodes : base.u32[..= 257]
|
||||
var stack_height : base.u32[..= 21]
|
||||
var stack_values : array[21] base.u32[..= 256]
|
||||
var node_index : base.u32[..= 256]
|
||||
var leaf_value : base.u16
|
||||
|
||||
// Push a root node.
|
||||
this.huffman_trees[args.which][0][0] = 0
|
||||
this.huffman_trees[args.which][0][1] = 0
|
||||
num_nodes = 1
|
||||
num_branch_nodes = 1
|
||||
stack_height = 1
|
||||
stack_values[0] = 0
|
||||
|
||||
@@ -624,27 +634,27 @@ pri func decoder.build_huffman_tree!(which: base.u32[..= 5]) base.status {
|
||||
|
||||
node_index = stack_values[stack_height - 1]
|
||||
if this.huffman_trees[args.which][node_index][0] == 0 {
|
||||
this.huffman_trees[args.which][node_index][0] = num_nodes as base.u16
|
||||
this.huffman_trees[args.which][node_index][0] = num_branch_nodes as base.u16
|
||||
} else {
|
||||
this.huffman_trees[args.which][node_index][1] = num_nodes as base.u16
|
||||
this.huffman_trees[args.which][node_index][1] = num_branch_nodes as base.u16
|
||||
}
|
||||
if num_nodes >= 1023 {
|
||||
return "#unsupported Huffman code"
|
||||
if num_branch_nodes >= 257 {
|
||||
return "#bad Huffman code (under-subscribed)"
|
||||
}
|
||||
stack_values[stack_height] = num_nodes
|
||||
this.huffman_trees[args.which][num_nodes][0] = 0
|
||||
this.huffman_trees[args.which][num_nodes][1] = 0
|
||||
num_nodes += 1
|
||||
stack_values[stack_height] = num_branch_nodes
|
||||
this.huffman_trees[args.which][num_branch_nodes][0] = 0
|
||||
this.huffman_trees[args.which][num_branch_nodes][1] = 0
|
||||
num_branch_nodes += 1
|
||||
stack_height += 1
|
||||
} endwhile
|
||||
|
||||
node_index = stack_values[stack_height - 1]
|
||||
if symbol_index < 2 {
|
||||
leaf_value = (0x500 + symbol_index) as base.u16
|
||||
leaf_value = (0x301 + symbol_index) as base.u16
|
||||
} else if (symbol_index + 1) < this.num_symbols {
|
||||
leaf_value = (0x3FF + symbol_index) as base.u16
|
||||
leaf_value = (0x1FF + symbol_index) as base.u16
|
||||
} else {
|
||||
leaf_value = 0x7FF
|
||||
leaf_value = 0x300
|
||||
}
|
||||
|
||||
if this.huffman_trees[args.which][node_index][0] == 0 {
|
||||
@@ -685,7 +695,7 @@ pri func decoder.build_huffman_table!(which: base.u32[..= 5]) {
|
||||
bits = i << 24
|
||||
n_bits = 0
|
||||
child = 0
|
||||
while (child < 1024) and (n_bits < 8),
|
||||
while (child < 257) and (n_bits < 8),
|
||||
inv i < 256,
|
||||
{
|
||||
child = this.huffman_trees[args.which][child][bits >> 31]
|
||||
|
||||
@@ -27,7 +27,7 @@ pri func decoder.decode_huffman_fast!(src: base.io_reader) base.status {
|
||||
var i : base.u32
|
||||
var j : base.u32
|
||||
var output : base.u32[..= 255]
|
||||
var run : base.u32[..= 16_777216] // 16_777216 = (2 << 23)
|
||||
var run : base.u32[..= 12_582912] // 12_582912 = (3 << 22)
|
||||
var mtft0 : base.u32[..= 255]
|
||||
|
||||
bits = this.bits
|
||||
@@ -45,6 +45,9 @@ pri func decoder.decode_huffman_fast!(src: base.io_reader) base.status {
|
||||
} else {
|
||||
ticks = 49
|
||||
section ~mod+= 1
|
||||
if section >= this.num_sections {
|
||||
return "#bad number of sections"
|
||||
}
|
||||
which = CLAMP_TO_5[this.huffman_selectors[section & 32767] & 7]
|
||||
}
|
||||
|
||||
@@ -55,8 +58,8 @@ pri func decoder.decode_huffman_fast!(src: base.io_reader) base.status {
|
||||
table_entry = this.huffman_tables[which][bits >> 24]
|
||||
bits ~mod<<= table_entry >> 12
|
||||
n_bits -= (table_entry >> 12) as base.u32
|
||||
child = table_entry & 0x7FF
|
||||
while child < 1024 {
|
||||
child = table_entry & 0x3FF
|
||||
while child < 257 {
|
||||
child = this.huffman_trees[which][child][bits >> 31]
|
||||
bits ~mod<<= 1
|
||||
if n_bits <= 0 {
|
||||
@@ -65,7 +68,7 @@ pri func decoder.decode_huffman_fast!(src: base.io_reader) base.status {
|
||||
n_bits -= 1
|
||||
} endwhile
|
||||
|
||||
if child < 1280 { // mNN symbol.
|
||||
if child < 0x300 { // mNN symbol.
|
||||
// Move to front.
|
||||
child_ff = (child & 0xFF) as base.u32
|
||||
output = this.mtft[child_ff] as base.u32
|
||||
@@ -82,7 +85,7 @@ pri func decoder.decode_huffman_fast!(src: base.io_reader) base.status {
|
||||
block_size += 1
|
||||
run_shift = 0
|
||||
continue.outer
|
||||
} else if child > 1281 { // EOB symbol.
|
||||
} else if child == 0x300 { // EOB symbol.
|
||||
this.decode_huffman_finished = true
|
||||
break.outer
|
||||
}
|
||||
@@ -91,7 +94,7 @@ pri func decoder.decode_huffman_fast!(src: base.io_reader) base.status {
|
||||
if run_shift >= 23 {
|
||||
return "#bad block length"
|
||||
}
|
||||
run = ((child - 1279) as base.u32) << run_shift
|
||||
run = ((child as base.u32) & 3) << run_shift
|
||||
run_shift += 1
|
||||
i = block_size
|
||||
j = run + block_size
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
pri func decoder.decode_huffman_slow?(src: base.io_reader) {
|
||||
var c : base.u8
|
||||
var node_index : base.u32[..= 1023]
|
||||
var node_index : base.u32[..= 256]
|
||||
|
||||
var child : base.u16
|
||||
var child_ff : base.u32[..= 255]
|
||||
var i : base.u32
|
||||
var j : base.u32
|
||||
var output : base.u32[..= 255]
|
||||
var run : base.u32[..= 16_777216] // 16_777216 = (2 << 23)
|
||||
var run : base.u32[..= 12_582912] // 12_582912 = (3 << 22)
|
||||
var mtft0 : base.u32[..= 255]
|
||||
|
||||
// Apply the Huffman trees.
|
||||
@@ -31,6 +31,9 @@ pri func decoder.decode_huffman_slow?(src: base.io_reader) {
|
||||
} else {
|
||||
this.decode_huffman_ticks = 49
|
||||
this.decode_huffman_section ~mod+= 1
|
||||
if this.decode_huffman_section >= this.num_sections {
|
||||
return "#bad number of sections"
|
||||
}
|
||||
this.decode_huffman_which = CLAMP_TO_5[this.huffman_selectors[this.decode_huffman_section & 32767] & 7]
|
||||
}
|
||||
|
||||
@@ -46,11 +49,11 @@ pri func decoder.decode_huffman_slow?(src: base.io_reader) {
|
||||
this.bits ~mod<<= 1
|
||||
this.n_bits -= 1
|
||||
|
||||
if child < 1024 { // Branch node.
|
||||
if child < 257 { // Branch node.
|
||||
node_index = child as base.u32
|
||||
continue
|
||||
|
||||
} else if child < 1280 { // mNN symbol.
|
||||
} else if child < 0x300 { // mNN symbol.
|
||||
// Move to front.
|
||||
child_ff = (child & 0xFF) as base.u32
|
||||
output = this.mtft[child_ff] as base.u32
|
||||
@@ -68,7 +71,7 @@ pri func decoder.decode_huffman_slow?(src: base.io_reader) {
|
||||
this.decode_huffman_run_shift = 0
|
||||
break
|
||||
|
||||
} else if child > 1281 { // EOB symbol.
|
||||
} else if child == 0x300 { // EOB symbol.
|
||||
this.decode_huffman_finished = true
|
||||
break.outer
|
||||
}
|
||||
@@ -77,7 +80,7 @@ pri func decoder.decode_huffman_slow?(src: base.io_reader) {
|
||||
if this.decode_huffman_run_shift >= 23 {
|
||||
return "#bad block length"
|
||||
}
|
||||
run = ((child - 1279) as base.u32) << this.decode_huffman_run_shift
|
||||
run = ((child as base.u32) & 3) << this.decode_huffman_run_shift
|
||||
this.decode_huffman_run_shift += 1
|
||||
i = this.block_size
|
||||
j = run + this.block_size
|
||||
|
||||
@@ -74,6 +74,16 @@ golden_test g_bzip2_256_bytes_gt = {
|
||||
.src_filename = "test/data/256.bytes.bz2",
|
||||
};
|
||||
|
||||
golden_test g_bzip2_bad_number_of_sections_gt = {
|
||||
.want_filename = "test/data/0.bytes",
|
||||
.src_filename = "test/data/artificial-bzip2/bad-number-of-sections.bz2",
|
||||
};
|
||||
|
||||
golden_test g_bzip2_huffman_258_gt = {
|
||||
.want_filename = "test/data/abraca.txt",
|
||||
.src_filename = "test/data/artificial-bzip2/huffman-258.bz2",
|
||||
};
|
||||
|
||||
golden_test g_bzip2_midsummer_gt = {
|
||||
.want_filename = "test/data/midsummer.txt",
|
||||
.src_filename = "test/data/midsummer.txt.bz2",
|
||||
@@ -137,6 +147,26 @@ test_wuffs_bzip2_decode_256_bytes() {
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_bzip2_decode_bad_number_of_sections() {
|
||||
CHECK_FOCUS(__func__);
|
||||
const char* have =
|
||||
do_test_io_buffers(wuffs_bzip2_decode, &g_bzip2_bad_number_of_sections_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
const char* want = wuffs_bzip2__error__bad_number_of_sections;
|
||||
if (have != want) {
|
||||
RETURN_FAIL("have \"%s\", want \"%s\"", have, want);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_bzip2_decode_huffman_258() {
|
||||
CHECK_FOCUS(__func__);
|
||||
return do_test_io_buffers(wuffs_bzip2_decode, &g_bzip2_huffman_258_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
}
|
||||
|
||||
const char* //
|
||||
test_wuffs_bzip2_decode_midsummer() {
|
||||
CHECK_FOCUS(__func__);
|
||||
@@ -227,6 +257,8 @@ bench_mimic_bzip2_decode_100k() {
|
||||
proc g_tests[] = {
|
||||
|
||||
test_wuffs_bzip2_decode_256_bytes,
|
||||
test_wuffs_bzip2_decode_bad_number_of_sections,
|
||||
test_wuffs_bzip2_decode_huffman_258,
|
||||
test_wuffs_bzip2_decode_interface,
|
||||
test_wuffs_bzip2_decode_midsummer,
|
||||
test_wuffs_bzip2_decode_pi,
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,49 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
# This script generates test/data/abraca.txt.bz2 exactly, following the
|
||||
# description in std/bzip2/README.md and its bitslices (a) ..= (s).
|
||||
#
|
||||
# By itself, this isn't a very interesting foo.make-artificial.txt file, in
|
||||
# that it doesn't make *artificial* bzip2 test data (as opposed to test data
|
||||
# *naturally* created by the /usr/bin/bzip2 tool). But this file is a useful
|
||||
# diff-base for other bar.make-artificial.txt files in the same directory.
|
||||
|
||||
make bzip2
|
||||
|
||||
# Bitslices (a) ..= (g)
|
||||
bits 16 0x425A
|
||||
bits 8 0x68
|
||||
bits 8 0x39
|
||||
bits 48 0x314159265359
|
||||
bits 32 0x76A70995
|
||||
bits 1 0x0
|
||||
bits 24 0x000001
|
||||
|
||||
# Bitslices (h) ..= (j)
|
||||
bits 16 0x0300
|
||||
bits 16 0x7000
|
||||
bits 16 0x2000
|
||||
|
||||
# Bitslices (k) ..= (m)
|
||||
bits 3 0x2
|
||||
bits 15 0x0001
|
||||
bits 1 0x0
|
||||
|
||||
# Bitslices (n) ..= (o)
|
||||
repeat 2 [
|
||||
bits 19 0x0CD34
|
||||
]
|
||||
|
||||
# Bitslice (p)
|
||||
bits 3 0x6
|
||||
bits 2 0x0
|
||||
bits 2 0x1
|
||||
bits 2 0x0
|
||||
bits 3 0x4
|
||||
bits 2 0x1
|
||||
bits 3 0x7
|
||||
|
||||
# Bitslices (q) ..= (s)
|
||||
bits 48 0x177245385090
|
||||
bits 32 0x76A70995
|
||||
bits 5 0x00
|
||||
Binary file not shown.
@@ -0,0 +1,42 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
# This modifies abraca.txt.bz2.make-artificial.txt to have 51 Huffman-coded
|
||||
# symbols (bitslice (p)) but only 1 section (bitslice (l)). At 50 symbols per
|
||||
# section, this should be invalid.
|
||||
|
||||
make bzip2
|
||||
|
||||
# Bitslices (a) ..= (g)
|
||||
bits 16 0x425A
|
||||
bits 8 0x68
|
||||
bits 8 0x39
|
||||
bits 48 0x314159265359
|
||||
bits 32 0x76A70995
|
||||
bits 1 0x0
|
||||
bits 24 0x000001
|
||||
|
||||
# Bitslices (h) ..= (j)
|
||||
bits 16 0x0300
|
||||
bits 16 0x7000
|
||||
bits 16 0x2000
|
||||
|
||||
# Bitslices (k) ..= (m)
|
||||
bits 3 0x2
|
||||
bits 15 0x0001
|
||||
bits 1 0x0
|
||||
|
||||
# Bitslices (n) ..= (o)
|
||||
repeat 2 [
|
||||
bits 19 0x0CD34
|
||||
]
|
||||
|
||||
# Bitslice (p)
|
||||
repeat 50 [
|
||||
bits 2 0x0
|
||||
]
|
||||
bits 3 0x7
|
||||
|
||||
# Bitslices (q) ..= (s)
|
||||
bits 48 0x177245385090
|
||||
bits 32 0x76A70995
|
||||
bits 5 0x00
|
||||
Binary file not shown.
@@ -0,0 +1,83 @@
|
||||
# Feed this file to script/make-artificial.go
|
||||
|
||||
# This modifies abraca.txt.bz2.make-artificial.txt to produce the same
|
||||
# decompressed output, "abraca", but in a more elaborate way. The Huffman codes
|
||||
# here have the full 258 symbols instead of just 6.
|
||||
|
||||
make bzip2
|
||||
|
||||
# Bitslices (a) ..= (g)
|
||||
bits 16 0x425A
|
||||
bits 8 0x68
|
||||
bits 8 0x39
|
||||
bits 48 0x314159265359
|
||||
bits 32 0x76A70995
|
||||
bits 1 0x0
|
||||
bits 24 0x000001
|
||||
|
||||
# Bitslices (h) ..= (j)
|
||||
bits 16 0xFFFF
|
||||
repeat 16 [
|
||||
bits 16 0xFFFF
|
||||
]
|
||||
|
||||
# Bitslices (k) ..= (m)
|
||||
bits 3 0x2
|
||||
bits 15 0x0001
|
||||
bits 1 0x0
|
||||
|
||||
# Bitslices (n) ..= (o)
|
||||
#
|
||||
# Both Huffman codes have 258 symbols: 254 × 8-bit symbols and then 4 × 9-bit
|
||||
# symbols.
|
||||
#
|
||||
# For small XYZ (where XYZ < 253), the mXYZ symbol's bitstring is (XYZ+1) in
|
||||
# binary. For example, the m099 symbol's bitstring is "01100100", because the
|
||||
# binary representation of 0d099+1 = 0d100 = 0x64 = 0b01100100.
|
||||
#
|
||||
# RUNA is the 8-bit bitstring "00000000".
|
||||
# RUNB is the 8-bit bitstring "00000001".
|
||||
# m001 is the 8-bit bitstring "00000010".
|
||||
# m002 is the 8-bit bitstring "00000011".
|
||||
# m003 is the 8-bit bitstring "00000100".
|
||||
# etc
|
||||
# m250 is the 8-bit bitstring "11111011".
|
||||
# m251 is the 8-bit bitstring "11111100".
|
||||
# m252 is the 8-bit bitstring "11111101".
|
||||
# m253 is the 9-bit bitstring "111111100".
|
||||
# m254 is the 9-bit bitstring "111111101".
|
||||
# m255 is the 9-bit bitstring "111111110".
|
||||
# EOB is the 9-bit bitstring "111111111".
|
||||
repeat 2 [
|
||||
bits 5 0x08
|
||||
repeat 254 [
|
||||
bits 1 0x0
|
||||
]
|
||||
bits 3 0x4
|
||||
bits 1 0x0
|
||||
bits 1 0x0
|
||||
bits 1 0x0
|
||||
]
|
||||
|
||||
# Bitslice (p)
|
||||
#
|
||||
# There are 7 symbols.
|
||||
# Order = [0x00, 0x01, 0x02, 0x03, ... 0xFF] m099 picks 'c'. 0d099+1 = 0x64.
|
||||
# Order = ['c', 0x00, 0x01, 0x02, ... 0xFF] m098 picks 'a'. 0d098+1 = 0x63.
|
||||
# Order = ['a', 'c', 0x00, 0x01, ... 0xFF] m114 picks 'r'. 0d114+1 = 0x73.
|
||||
# Order = ['r', 'a', 'c', 0x00, ... 0xFF] m001 picks 'a'. 0d001+1 = 0x02.
|
||||
# Order = ['a', 'r', 'c', 0x00, ... 0xFF] RUNA picks 'a'.
|
||||
# Order = ['a', 'r', 'c', 0x00, ... 0xFF] m100 picks 'b'. 0d100+1 = 0x65.
|
||||
# Order = ['b', 'a', 'r', 'c', ... 0xFF] EOB.
|
||||
bits 8 0x64
|
||||
bits 8 0x63
|
||||
bits 8 0x73
|
||||
bits 8 0x02
|
||||
bits 8 0x00
|
||||
bits 8 0x65
|
||||
bits 9 0x1FF
|
||||
|
||||
# Bitslices (q) ..= (s)
|
||||
bits 48 0x177245385090
|
||||
bits 32 0x76A70995
|
||||
bits 1 0x0
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in new issue
Block a user