Compare commits

...
22 Commits
Author SHA1 Message Date
Nigel Tao 57bd11bf39 wuffs gen -version=0.3.2 2023-04-07 13:53:11 +10:00
Nigel Tao 67d9a68c49 Update doc/changelog.md for v0.3.2 2023-04-07 13:52:02 +10:00
Nigel Tao 17f7613262 std/{bmp,nie}: allow decode_frame to small pixbuf 2023-03-27 21:22:06 +11:00
Nigel Tao baac49dca7 script: add manual-test-truncated-input.cc
Updates #96
2023-03-27 21:15:38 +11:00
Nigel Tao a12a807d0e script/print-image-metadata: fix infinite loop
Fixes #107
2023-03-18 14:49:50 +11:00
Nigel Tao 000b0a3445 std/png: decode "truncated input" for short chunks
Updates #101
2023-03-12 19:23:41 +11:00
Nigel Tao ef74175a20 wuffs gen -version=0.3.1 2023-03-04 09:54:01 +11:00
Nigel Tao 02844cdca4 go.{mod,sum}: go get -u golang.org/x/image/draw 2023-02-24 10:04:51 +11:00
Nigel Tao 3db9e96b0d root: add .gitattributes
Fixes #100
2023-02-24 09:47:23 +11:00
Nigel Tao be37cc46c0 A+C: add sarastro-nl 2023-02-04 16:06:37 +11:00
Nigel Tao 4d4c3c4c3c floatconv: tweak Simple Decimal Conversion
This tweaks the code and comments added in commit 36d7748e "Merge pull
request #90 from sarastro-nl/improvement/optimize-SDC" and commit
d46220ca "optimize SDC". Both of those two commit messages are short but
see the discussion re algorithmic changes on PR 87 (yes, 87, not 90):
https://github.com/google/wuffs/pull/87

Also run clang-format.

Also update doc/changelog.md

Compared to before commit d46220ca "optimize SDC", when running
script/manual-test-parse-number-f64.cc and disabling both the
etc__parse_number_f64_eisel_lemire function and the "If both man and
(10 ** exp10) are exactly representable by a double" fast path, the
tests still pass but the number of etc__high_prec_dec__small_lshift and
etc__high_prec_dec__small_rshift calls drop:

Function    Before      After       Ratio
lshift      31174584    25762258    82.64% = 100% - 17.36%
rshift      21592604    20982502    97.17% = 100% -  2.83%

The time taken drops from 15.984s to 13.710s (85.77% = 100% - 14.23%).

To repeat, these are the improvements after disabling the Eisel-Lemire
and other fast paths. Simple Decimal Conversion is the rarely invoked
fallback parse_number_f64 algorithm. The practical improvement (with
Eisel-Lemire etc enabled) is smaller.
2023-02-04 14:48:25 +11:00
Nigel Tao 36d7748ed5 Merge pull request #90 from sarastro-nl/improvement/optimize-SDC
optimize SDC
2023-02-04 10:30:29 +11:00
Nigel Tao 43ca567205 fuzz: check "short read" and io_reader.is_closed
Updates #96
2023-02-01 22:32:36 +11:00
Nigel Tao 3474af988b std/{cbor,json}: add test for empty input
Updates #96
2023-02-01 21:43:25 +11:00
Nigel Tao 248bddcfd2 std/*image_decoder*: add "#truncated input"
name                                                       old speed      new speed       delta

wuffs_bmp_decode_40k/clang11                               4.36GB/s ± 0%   4.48GB/s ± 0%   +2.74%  (p=0.008 n=5+5)

wuffs_bmp_decode_40k/gcc10                                 4.49GB/s ± 0%   4.50GB/s ± 0%   +0.15%  (p=0.008 n=5+5)

wuffs_gif_decode_1k_bw/clang11                              723MB/s ± 0%    742MB/s ± 0%   +2.64%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_full_init/clang11                 177MB/s ± 0%    177MB/s ± 0%     ~     (p=0.841 n=5+5)
wuffs_gif_decode_1k_color_part_init/clang11                 216MB/s ± 0%    217MB/s ± 0%   +0.66%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/clang11                           793MB/s ± 0%    785MB/s ± 0%   -1.04%  (p=0.016 n=4+5)
wuffs_gif_decode_10k_indexed/clang11                        210MB/s ± 0%    209MB/s ± 0%   -0.38%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/clang11                                254MB/s ± 0%    255MB/s ± 0%   +0.37%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/clang11                    568MB/s ± 0%    569MB/s ± 0%   +0.14%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/clang11                     221MB/s ± 0%    221MB/s ± 0%     ~     (p=0.222 n=5+5)
wuffs_gif_decode_1000k_full_init/clang11                    224MB/s ± 0%    224MB/s ± 0%     ~     (p=0.690 n=5+5)
wuffs_gif_decode_1000k_part_init/clang11                    224MB/s ± 0%    224MB/s ± 0%     ~     (p=0.841 n=5+5)
wuffs_gif_decode_anim_screencap/clang11                    1.30GB/s ± 0%   1.30GB/s ± 0%     ~     (p=0.111 n=5+5)

wuffs_gif_decode_1k_bw/gcc10                                638MB/s ± 0%    672MB/s ± 0%   +5.23%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_full_init/gcc10                   175MB/s ± 0%    181MB/s ± 0%   +3.03%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_part_init/gcc10                   203MB/s ± 0%    209MB/s ± 0%   +3.38%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/gcc10                             798MB/s ± 0%    804MB/s ± 0%   +0.70%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_indexed/gcc10                          210MB/s ± 0%    212MB/s ± 0%   +0.84%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/gcc10                                  265MB/s ± 0%    265MB/s ± 0%     ~     (p=0.222 n=5+5)
wuffs_gif_decode_100k_artificial/gcc10                      576MB/s ± 0%    577MB/s ± 0%     ~     (p=0.690 n=5+5)
wuffs_gif_decode_100k_realistic/gcc10                       226MB/s ± 0%    227MB/s ± 0%   +0.21%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_full_init/gcc10                      230MB/s ± 0%    231MB/s ± 0%   +0.32%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_part_init/gcc10                      230MB/s ± 0%    231MB/s ± 0%   +0.43%  (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/gcc10                      1.32GB/s ± 0%   1.32GB/s ± 0%   +0.18%  (p=0.008 n=5+5)

wuffs_png_decode_image_19k_8bpp/clang11                     267MB/s ± 0%    273MB/s ± 0%   +2.47%  (p=0.008 n=5+5)
wuffs_png_decode_image_40k_24bpp/clang11                    326MB/s ± 0%    327MB/s ± 0%   +0.51%  (p=0.008 n=5+5)
wuffs_png_decode_image_77k_8bpp/clang11                     954MB/s ± 0%    969MB/s ± 0%   +1.58%  (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/clang11   865MB/s ± 0%    864MB/s ± 0%   -0.18%  (p=0.016 n=5+5)
wuffs_png_decode_image_552k_32bpp_verify_checksum/clang11   832MB/s ± 0%    831MB/s ± 0%   -0.11%  (p=0.016 n=5+5)
wuffs_png_decode_image_4002k_24bpp/clang11                  331MB/s ± 0%    332MB/s ± 0%   +0.18%  (p=0.016 n=5+5)

wuffs_png_decode_image_19k_8bpp/gcc10                       298MB/s ± 0%    292MB/s ± 0%   -2.17%  (p=0.008 n=5+5)
wuffs_png_decode_image_40k_24bpp/gcc10                      352MB/s ± 0%    349MB/s ± 0%   -0.75%  (p=0.008 n=5+5)
wuffs_png_decode_image_77k_8bpp/gcc10                      1.05GB/s ± 0%   1.03GB/s ± 0%   -1.56%  (p=0.008 n=5+5)
wuffs_png_decode_image_552k_32bpp_ignore_checksum/gcc10     950MB/s ± 0%    949MB/s ± 0%     ~     (p=0.310 n=5+5)
wuffs_png_decode_image_552k_32bpp_verify_checksum/gcc10     905MB/s ± 0%    902MB/s ± 0%   -0.35%  (p=0.008 n=5+5)
wuffs_png_decode_image_4002k_24bpp/gcc10                    360MB/s ± 0%    358MB/s ± 0%   -0.40%  (p=0.008 n=5+5)

wuffs_tga_decode_19k_8bpp/clang11                          7.81GB/s ± 0%   7.90GB/s ± 0%   +1.22%  (p=0.008 n=5+5)
wuffs_tga_decode_77k_24bpp/clang11                         4.34GB/s ± 0%   4.36GB/s ± 0%   +0.59%  (p=0.008 n=5+5)

wuffs_tga_decode_19k_8bpp/gcc10                            7.10GB/s ± 0%   7.13GB/s ± 0%   +0.33%  (p=0.008 n=5+5)
wuffs_tga_decode_77k_24bpp/gcc10                           4.61GB/s ± 0%   4.60GB/s ± 0%   -0.35%  (p=0.008 n=5+5)

Updates #96
2023-02-01 16:36:56 +11:00
Nigel Tao 3705e0d93a cgen: io_reader.is_closed doesn't need derived var 2023-01-31 23:33:02 +11:00
Nigel Tao f01f0859f0 std/*io_transformer*: add "#truncated input"
name                                              old speed      new speed       delta

wuffs_bzip2_decode_10k/clang11                    58.5MB/s ± 0%   59.9MB/s ± 0%   +2.50%  (p=0.008 n=5+5)
wuffs_bzip2_decode_100k/clang11                   45.7MB/s ± 0%   50.5MB/s ± 0%  +10.66%  (p=0.008 n=5+5)

wuffs_bzip2_decode_10k/gcc10                      56.2MB/s ± 0%   61.9MB/s ± 0%  +10.01%  (p=0.008 n=5+5)
wuffs_bzip2_decode_100k/gcc10                     46.5MB/s ± 0%   50.4MB/s ± 0%   +8.41%  (p=0.016 n=4+5)

wuffs_deflate_decode_1k_full_init/clang11          195MB/s ± 0%    191MB/s ± 0%   -1.71%  (p=0.008 n=5+5)
wuffs_deflate_decode_1k_part_init/clang11          224MB/s ± 0%    225MB/s ± 0%   +0.87%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_full_init/clang11         421MB/s ± 0%    401MB/s ± 0%   -4.59%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_part_init/clang11         432MB/s ± 0%    413MB/s ± 0%   -4.49%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k_just_one_read/clang11    542MB/s ± 0%    518MB/s ± 0%   -4.43%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k_many_big_reads/clang11   338MB/s ± 0%    325MB/s ± 0%   -3.81%  (p=0.008 n=5+5)

wuffs_deflate_decode_1k_full_init/gcc10            181MB/s ± 0%    185MB/s ± 0%   +1.76%  (p=0.008 n=5+5)
wuffs_deflate_decode_1k_part_init/gcc10            209MB/s ± 0%    212MB/s ± 0%   +1.79%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_full_init/gcc10           410MB/s ± 0%    407MB/s ± 0%   -0.93%  (p=0.008 n=5+5)
wuffs_deflate_decode_10k_part_init/gcc10           421MB/s ± 0%    418MB/s ± 0%   -0.87%  (p=0.008 n=5+5)
wuffs_deflate_decode_100k_just_one_read/gcc10      533MB/s ± 0%    533MB/s ± 0%     ~     (p=0.548 n=5+5)
wuffs_deflate_decode_100k_many_big_reads/gcc10     336MB/s ± 0%    334MB/s ± 1%   -0.67%  (p=0.008 n=5+5)

wuffs_gzip_decode_10k/clang11                      401MB/s ± 0%    398MB/s ± 0%   -0.77%  (p=0.008 n=5+5)
wuffs_gzip_decode_100k/clang11                     505MB/s ± 0%    503MB/s ± 0%   -0.46%  (p=0.008 n=5+5)

wuffs_gzip_decode_10k/gcc10                        403MB/s ± 0%    410MB/s ± 0%   +1.90%  (p=0.008 n=5+5)
wuffs_gzip_decode_100k/gcc10                       522MB/s ± 0%    523MB/s ± 0%   +0.10%  (p=0.032 n=5+5)

wuffs_zlib_decode_10k/clang11                      418MB/s ± 0%    417MB/s ± 1%     ~     (p=0.310 n=5+5)
wuffs_zlib_decode_100k/clang11                     530MB/s ± 0%    529MB/s ± 0%     ~     (p=0.421 n=5+5)

wuffs_zlib_decode_10k/gcc10                        428MB/s ± 0%    434MB/s ± 0%   +1.50%  (p=0.008 n=5+5)
wuffs_zlib_decode_100k/gcc10                       551MB/s ± 0%    551MB/s ± 0%     ~     (p=0.690 n=5+5)

Fixes #96
2023-01-31 23:09:37 +11:00
Nigel Tao d7c48ae76b cgen: have io_limit update meta.closed 2023-01-31 22:05:20 +11:00
Nigel Tao 8ad397fc93 std/png: add test for multiple IDAT chunks 2023-01-31 21:37:57 +11:00
Nigel Tao 48e69da5af std/lzw: add "#truncated input" error
name                                         old speed      new speed      delta

wuffs_gif_decode_1k_bw/clang11                659MB/s ± 0%   748MB/s ± 0%  +13.43%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_full_init/clang11   182MB/s ± 0%   178MB/s ± 0%   -2.17%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_part_init/clang11   223MB/s ± 0%   219MB/s ± 0%   -2.00%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/clang11             799MB/s ± 0%   795MB/s ± 0%   -0.52%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_indexed/clang11          211MB/s ± 0%   210MB/s ± 0%   -0.47%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/clang11                  250MB/s ± 1%   254MB/s ± 0%   +1.75%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/clang11      581MB/s ± 0%   568MB/s ± 0%   -2.09%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/clang11       221MB/s ± 0%   221MB/s ± 0%     ~     (p=0.690 n=5+5)
wuffs_gif_decode_1000k_full_init/clang11      222MB/s ± 0%   224MB/s ± 0%   +0.65%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_part_init/clang11      223MB/s ± 0%   224MB/s ± 0%   +0.58%  (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/clang11      1.28GB/s ± 0%  1.30GB/s ± 0%   +1.45%  (p=0.008 n=5+5)

wuffs_gif_decode_1k_bw/gcc10                  595MB/s ± 0%   642MB/s ± 0%   +7.91%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_full_init/gcc10     168MB/s ± 0%   169MB/s ± 0%   +0.36%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_part_init/gcc10     202MB/s ± 0%   203MB/s ± 0%   +0.46%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/gcc10               790MB/s ± 0%   798MB/s ± 0%   +1.04%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_indexed/gcc10            208MB/s ± 0%   210MB/s ± 0%   +1.00%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/gcc10                    258MB/s ± 0%   266MB/s ± 0%   +3.08%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/gcc10        566MB/s ± 0%   577MB/s ± 0%   +1.83%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/gcc10         220MB/s ± 0%   227MB/s ± 0%   +3.03%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_full_init/gcc10        223MB/s ± 0%   231MB/s ± 0%   +3.23%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_part_init/gcc10        224MB/s ± 0%   231MB/s ± 0%   +3.14%  (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/gcc10        1.30GB/s ± 0%  1.32GB/s ± 0%   +1.70%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/clang11                  294MB/s ± 0%   321MB/s ± 0%   +9.11%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/clang11                 533MB/s ± 0%   560MB/s ± 0%   +5.13%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/gcc10                    271MB/s ± 0%   272MB/s ± 0%   +0.55%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/gcc10                   527MB/s ± 0%   521MB/s ± 0%   -1.31%  (p=0.008 n=5+5)

Updates #96
2023-01-31 20:18:53 +11:00
Nigel Tao 5640296546 Tweak README.md "it is fast" section 2023-01-27 10:07:25 +11:00
sarastro-nl d46220ca00 optimize SDC 2022-11-21 22:10:19 +01:00
43 changed files with 5389 additions and 1070 deletions

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# Source code is always LF, never CRLF.
#
# For example, tools like the wuffs-c compiler (and its internal/cgen package)
# look for hard-coded strings containing "\n" but not "\r\n".
*.c text eol=lf
*.cc text eol=lf
*.go text eol=lf
*.h text eol=lf
*.hh text eol=lf
*.rs text eol=lf
*.sh text eol=lf
*.wuffs text eol=lf
+1
View File
@@ -18,3 +18,4 @@ Michael Mc Donnell <michael@mcdonnell.dk>
Mike Kaufman <mkaufman@microsoft.com> Mike Kaufman <mkaufman@microsoft.com>
Muhammad Aldo Firmansyah <TheCrott@users.noreply.github.com> Muhammad Aldo Firmansyah <TheCrott@users.noreply.github.com>
Přemysl Eric Janouch <p@janouch.name> Přemysl Eric Janouch <p@janouch.name>
sarastro-nl <nlsarastro@gmail.com>
+1
View File
@@ -43,3 +43,4 @@ Muhammad Aldo Firmansyah <TheCrott@users.noreply.github.com>
Nigel Tao <nigeltao@golang.org> Nigel Tao <nigeltao@golang.org>
Peter Kasting <pkasting@chromium.org> Peter Kasting <pkasting@chromium.org>
Přemysl Eric Janouch <p@janouch.name> Přemysl Eric Janouch <p@janouch.name>
sarastro-nl <nlsarastro@gmail.com>
+6 -5
View File
@@ -5,16 +5,17 @@ written in that language) for **Wrangling Untrusted File Formats Safely**.
Wrangling includes parsing, decoding and encoding. Example file formats include Wrangling includes parsing, decoding and encoding. Example file formats include
images, audio, video, fonts and compressed archives. images, audio, video, fonts and compressed archives.
It is **fast**. Per its [benchmarks](/doc/benchmarks.md) and other docs: It is **fast**. Per its [benchmarks](/doc/benchmarks.md) and other linked-to
blog posts:
- It can decode bzip2 **[1.3x faster than `/usr/bin/bzcat` - It can decode bzip2 **[1.3x faster than `/usr/bin/bzcat`
(C)](https://nigeltao.github.io/blog/2022/wuffs-bzip2-decoder.html)**. (C)](https://nigeltao.github.io/blog/2022/wuffs-bzip2-decoder.html)**.
- It can decode deflate up to **1.4x faster [than zlib-the-library (C)**. - It can decode deflate up to **1.4x faster than zlib-the-library (C)**.
- It can decode GIF **2x-6x faster than "giflib" (C), "image/gif" (Go) and - It can decode GIF **2x-6x faster than "giflib" (C), "image/gif" (Go) and
"gif" (Rust)**. "gif" (Rust)**.
- It can decode PNG **[1.2x-2.7x faster than "libpng" - It can decode PNG **[1.2x-2.7x faster than "libpng" (C), "image/png" (Go) and
(C)](https://nigeltao.github.io/blog/2021/fastest-safest-png-decoder.html), "png"
"image/png" (Go) and "png" (Rust)**. (Rust)](https://nigeltao.github.io/blog/2021/fastest-safest-png-decoder.html)**.
## Goals and Non-Goals ## Goals and Non-Goals
+18 -1
View File
@@ -1,6 +1,23 @@
# Changelog # Changelog
## 2023-04-07 version 0.3.2
The `std/bmp` and `std/nie` image decoders' `decode_frame` method now allow
decoding to a pixel buffer that's smaller than the source image. This makes
these two image decoders consistent with the other ones in `std`.
## 2023-03-04 version 0.3.1
For a *closed* `io_reader`, the standard library now returns `"#truncated
input"` instead of `"$short read"`. Importantly, this is an error, not a
suspension.
The `wuffs_base__parse_number_f64` function's Simple Decimal Conversion
fallback algorithm has been optimized.
## 2023-01-26 version 0.3.0 ## 2023-01-26 version 0.3.0
The headline feature is that we have a production quality PNG decoder. It's The headline feature is that we have a production quality PNG decoder. It's
@@ -165,4 +182,4 @@ Wuffs version 0.1.
--- ---
Updated on January 2023. Updated on April 2023.
+32 -2
View File
@@ -27,6 +27,30 @@ intentional_segfault() {
*ptr = 0; *ptr = 0;
} }
static uint32_t //
popcount32(uint32_t x) {
static const uint8_t table[256] = {
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, //
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, //
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, //
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, //
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, //
};
return table[0xFF & (x >> 0)] + table[0xFF & (x >> 8)] +
table[0xFF & (x >> 16)] + table[0xFF & (x >> 24)];
}
// jenkins_hash_u32 implements // jenkins_hash_u32 implements
// https://en.wikipedia.org/wiki/Jenkins_hash_function // https://en.wikipedia.org/wiki/Jenkins_hash_function
static uint32_t // static uint32_t //
@@ -68,15 +92,21 @@ llvmFuzzerTestOneInput(const uint8_t* data, size_t size) {
uint32_t hash1 = jenkins_hash_u32(data + s2, size - s2); uint32_t hash1 = jenkins_hash_u32(data + s2, size - s2);
uint64_t hash = (((uint64_t)hash0) << 32) | ((uint64_t)hash1); uint64_t hash = (((uint64_t)hash0) << 32) | ((uint64_t)hash1);
// The ! means that closed will be true for (size == 0).
const bool closed = !(1 & popcount32(hash0));
wuffs_base__io_buffer src = wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader((uint8_t*)data, size, true); wuffs_base__ptr_u8__reader((uint8_t*)data, size, closed);
const char* msg = fuzz(&src, hash); const char* msg = fuzz(&src, hash);
if (msg) { if (msg) {
if (strnlen(msg, 2047) >= 2047) { if (strnlen(msg, 2047) >= 2047) {
msg = "fuzzlib: internal error: error message is too long"; msg = "fuzzlib: internal error: error message is too long";
} }
if (strstr(msg, "internal error:")) { if (closed && strstr(msg, "base: short read")) {
fprintf(stderr, "short read on a closed io_reader\n");
intentional_segfault();
} else if (strstr(msg, "internal error:")) {
fprintf(stderr, "internal errors shouldn't occur: \"%s\"\n", msg); fprintf(stderr, "internal errors shouldn't occur: \"%s\"\n", msg);
intentional_segfault(); intentional_segfault();
} }
+3 -2
View File
@@ -317,6 +317,9 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
no_progress_count = 0; no_progress_count = 0;
} else if (no_progress_count < 999) { } else if (no_progress_count < 999) {
no_progress_count++; no_progress_count++;
} else if (!full_src->meta.closed &&
(status.repr == wuffs_base__suspension__short_read)) {
return wuffs_base__status__message(&status);
} else { } else {
return "fuzz: internal error: no progress"; return "fuzz: internal error: no progress";
} }
@@ -345,8 +348,6 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
break; break;
} else if (status.repr == wuffs_base__suspension__short_read) { } else if (status.repr == wuffs_base__suspension__short_read) {
// Some Wuffs packages can yield "$short read" for a closed io_reader,
// but Wuffs' cbor package does not.
if (src.meta.closed) { if (src.meta.closed) {
return "fuzz: internal error: short read on a closed io_reader"; return "fuzz: internal error: short read on a closed io_reader";
} }
+3 -2
View File
@@ -338,6 +338,9 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
no_progress_count = 0; no_progress_count = 0;
} else if (no_progress_count < 999) { } else if (no_progress_count < 999) {
no_progress_count++; no_progress_count++;
} else if (!full_src->meta.closed &&
(status.repr == wuffs_base__suspension__short_read)) {
return wuffs_base__status__message(&status);
} else { } else {
return "fuzz: internal error: no progress"; return "fuzz: internal error: no progress";
} }
@@ -366,8 +369,6 @@ fuzz_complex(wuffs_base__io_buffer* full_src, uint64_t hash) {
break; break;
} else if (status.repr == wuffs_base__suspension__short_read) { } else if (status.repr == wuffs_base__suspension__short_read) {
// Some Wuffs packages can yield "$short read" for a closed io_reader,
// but Wuffs' json package does not.
if (src.meta.closed) { if (src.meta.closed) {
return "fuzz: internal error: short read on a closed io_reader"; return "fuzz: internal error: short read on a closed io_reader";
} }
+1 -1
View File
@@ -4,5 +4,5 @@ go 1.16
require ( require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect golang.org/x/image v0.5.0 // indirect
) )
+25
View File
@@ -1,6 +1,31 @@
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs= golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d h1:RNPAfi2nHY7C2srAV8A49jpsYr0ADedCk1wq6fTMTvs=
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM= golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+67 -20
View File
@@ -1264,6 +1264,27 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
// powers converts decimal powers of 10 to binary powers of 2. For example, // powers converts decimal powers of 10 to binary powers of 2. For example,
// (10000 >> 13) is 1. It stops before the elements exceed 60, also known // (10000 >> 13) is 1. It stops before the elements exceed 60, also known
// as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL. // as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
//
// This rounds down (1<<13 is a lower bound for 1e4). Adding 1 to the array
// element value rounds up (1<<14 is an upper bound for 1e4) while staying
// at or below WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
//
// When starting in the range [1e+1 .. 1e+2] (i.e. h->decimal_point == +2),
// powers[2] == 6 and so:
// - Right shifting by 6+0 produces the range [10/64 .. 100/64] =
// [0.156250 .. 1.56250]. The resultant h->decimal_point is +0 or +1.
// - Right shifting by 6+1 produces the range [10/128 .. 100/128] =
// [0.078125 .. 0.78125]. The resultant h->decimal_point is -1 or -0.
//
// When starting in the range [1e-3 .. 1e-2] (i.e. h->decimal_point == -2),
// powers[2] == 6 and so:
// - Left shifting by 6+0 produces the range [0.001*64 .. 0.01*64] =
// [0.064 .. 0.64]. The resultant h->decimal_point is -1 or -0.
// - Left shifting by 6+1 produces the range [0.001*128 .. 0.01*128] =
// [0.128 .. 1.28]. The resultant h->decimal_point is +0 or +1.
//
// Thus, when targeting h->decimal_point being +0 or +1, use (powers[n]+0)
// when right shifting but (powers[n]+1) when left shifting.
static const uint32_t num_powers = 19; static const uint32_t num_powers = 19;
static const uint8_t powers[19] = { static const uint8_t powers[19] = {
0, 3, 6, 9, 13, 16, 19, 23, 26, 29, // 0, 3, 6, 9, 13, 16, 19, 23, 26, 29, //
@@ -1307,12 +1328,13 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
// When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See // When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See
// https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html // https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
// //
// Scale by powers of 2 until we're in the range [½ .. 1], which gives us // Scale by powers of 2 until we're in the range [0.1 .. 10]. Equivalently,
// our exponent (in base-2). First we shift right, possibly a little too // that h->decimal_point is +0 or +1.
// far, ending with a value certainly below 1 and possibly below ½... //
// First we shift right while at or above 10...
const int32_t f64_bias = -1023; const int32_t f64_bias = -1023;
int32_t exp2 = 0; int32_t exp2 = 0;
while (h->decimal_point > 0) { while (h->decimal_point > 1) {
uint32_t n = (uint32_t)(+h->decimal_point); uint32_t n = (uint32_t)(+h->decimal_point);
uint32_t shift = uint32_t shift =
(n < num_powers) (n < num_powers)
@@ -1326,20 +1348,15 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
} }
exp2 += (int32_t)shift; exp2 += (int32_t)shift;
} }
// ...then we shift left, putting us in [½ .. 1]. // ...then we shift left while below 0.1.
while (h->decimal_point <= 0) { while (h->decimal_point < 0) {
uint32_t shift; uint32_t shift;
if (h->decimal_point == 0) { uint32_t n = (uint32_t)(-h->decimal_point);
if (h->digits[0] >= 5) { shift = (n < num_powers)
break; // The +1 is per "when targeting h->decimal_point being +0 or
} // +1... when left shifting" in the powers comment above.
shift = (h->digits[0] < 2) ? 2 : 1; ? (powers[n] + 1)
} else { : WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
uint32_t n = (uint32_t)(-h->decimal_point);
shift = (n < num_powers)
? powers[n]
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
}
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift); wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift);
if (h->decimal_point > if (h->decimal_point >
@@ -1349,8 +1366,37 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
exp2 -= (int32_t)shift; exp2 -= (int32_t)shift;
} }
// We're in the range [½ .. 1] but f64 uses [1 .. 2]. // To get from "in the range [0.1 .. 10]" to "in the range [1 .. 2]" (which
exp2--; // will give us our exponent in base-2), the mantissa's first 3 digits will
// determine the final left shift, equal to 52 (the number of explicit f64
// bits) plus an additional adjustment.
int man3 = (100 * h->digits[0]) +
((h->num_digits > 1) ? (10 * h->digits[1]) : 0) +
((h->num_digits > 2) ? h->digits[2] : 0);
int32_t additional_lshift = 0;
if (h->decimal_point == 0) { // The value is in [0.1 .. 1].
if (man3 < 125) {
additional_lshift = +4;
} else if (man3 < 250) {
additional_lshift = +3;
} else if (man3 < 500) {
additional_lshift = +2;
} else {
additional_lshift = +1;
}
} else { // The value is in [1 .. 10].
if (man3 < 200) {
additional_lshift = -0;
} else if (man3 < 400) {
additional_lshift = -1;
} else if (man3 < 800) {
additional_lshift = -2;
} else {
additional_lshift = -3;
}
}
exp2 -= additional_lshift;
uint32_t final_lshift = (uint32_t)(52 + additional_lshift);
// The minimum normal exponent is (f64_bias + 1). // The minimum normal exponent is (f64_bias + 1).
while ((f64_bias + 1) > exp2) { while ((f64_bias + 1) > exp2) {
@@ -1368,7 +1414,8 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
} }
// Extract 53 bits for the mantissa (in base-2). // Extract 53 bits for the mantissa (in base-2).
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, 53); wuffs_base__private_implementation__high_prec_dec__small_lshift(
h, final_lshift);
uint64_t man2 = uint64_t man2 =
wuffs_base__private_implementation__high_prec_dec__rounded_integer(h); wuffs_base__private_implementation__high_prec_dec__rounded_integer(h);
+21 -9
View File
@@ -305,9 +305,9 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
if e.Operator() != 0 { if e.Operator() != 0 {
prefix = aPrefix prefix = aPrefix
} }
cTyp, end, qualifier := "reader", "meta.wi", "const " cTyp, end, qualifier, isWriter := "reader", "meta.wi", "const ", false
if e.MType().QID()[1] == t.IDIOWriter { if e.MType().QID()[1] == t.IDIOWriter {
cTyp, end, qualifier = "writer", "data.len", "" cTyp, end, qualifier, isWriter = "writer", "data.len", "", true
} }
name := e.Ident().Str(g.tm) name := e.Ident().Str(g.tm)
@@ -350,6 +350,10 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
b.writes(");\n") b.writes(");\n")
} else { } else {
if !isWriter {
b.printf("const bool %s%d_closed_%s%s = %s%s->meta.closed;\n",
oPrefix, ioBindNum, prefix, name, prefix, name)
}
b.printf("%suint8_t *%s%d_%s%s%s = %s%s%s;\n", b.printf("%suint8_t *%s%d_%s%s%s = %s%s%s;\n",
qualifier, oPrefix, ioBindNum, io2Prefix, prefix, name, io2Prefix, prefix, name) qualifier, oPrefix, ioBindNum, io2Prefix, prefix, name, io2Prefix, prefix, name)
b.printf("wuffs_base__io_%s__limit(&%s%s%s, %s%s%s,\n", b.printf("wuffs_base__io_%s__limit(&%s%s%s, %s%s%s,\n",
@@ -360,11 +364,16 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
return err return err
} }
b.writes(");\n") b.writes(");\n")
b.printf("if (%s%s) {\n%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n}\n", b.printf("if (%s%s) {\n", prefix, name)
prefix, name, b.printf("size_t n = ((size_t)(%s%s%s - %s%s->data.ptr));\n",
prefix, name, end, io2Prefix, prefix, name, prefix, name)
io2Prefix, prefix, name, if !isWriter {
prefix, name) b.printf("%s%s->meta.closed = %s%s->meta.closed && (%s%s->%s <= n);\n",
prefix, name, prefix, name, prefix, name, end)
}
b.printf("%s%s->%s = n;\n",
prefix, name, end)
b.printf("}\n")
} }
} }
@@ -393,11 +402,14 @@ func (g *gen) writeStatementIOManip(b *buffer, n *a.IOManip, depth uint32) error
io2Prefix, prefix, name, io2Prefix, prefix, name,
oPrefix, ioBindNum, io2Prefix, prefix, name) oPrefix, ioBindNum, io2Prefix, prefix, name)
if n.Keyword() == t.IDIOLimit { if n.Keyword() == t.IDIOLimit {
b.printf("if (%s%s) {\n%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n}\n", b.printf("if (%s%s) {\n", prefix, name)
prefix, name, b.printf("%s%s->meta.closed = %s%d_closed_%s%s;\n",
prefix, name, oPrefix, ioBindNum, prefix, name)
b.printf("%s%s->%s = ((size_t)(%s%s%s - %s%s->data.ptr));\n",
prefix, name, end, prefix, name, end,
io2Prefix, prefix, name, io2Prefix, prefix, name,
prefix, name) prefix, name)
b.printf("}\n")
} }
} }
b.writes("}\n") b.writes("}\n")
+3
View File
@@ -50,6 +50,9 @@ func (g *gen) needDerivedVar(name t.ID) bool {
return nil return nil
} }
if recv.IsArgsDotFoo() == name { if recv.IsArgsDotFoo() == name {
if meth == t.IDIsClosed {
return nil
}
return errNeedDerivedVar return errNeedDerivedVar
} }
// Some built-in methods will also need a derived var for their // Some built-in methods will also need a derived var for their
+1941 -473
View File
@@ -6536,6 +6536,7 @@ struct wuffs_adler32__hasher__struct {
extern const char wuffs_bmp__error__bad_header[]; extern const char wuffs_bmp__error__bad_header[];
extern const char wuffs_bmp__error__bad_rle_compression[]; extern const char wuffs_bmp__error__bad_rle_compression[];
extern const char wuffs_bmp__error__truncated_input[];
extern const char wuffs_bmp__error__unsupported_bmp_file[]; extern const char wuffs_bmp__error__unsupported_bmp_file[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -6714,8 +6715,12 @@ struct wuffs_bmp__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
uint32_t p_tell_me_more[1];
uint32_t p_read_palette[1]; uint32_t p_read_palette[1];
} private_impl; } private_impl;
@@ -6725,10 +6730,10 @@ struct wuffs_bmp__decoder__struct {
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_frame[1]; } s_do_decode_frame[1];
struct { struct {
uint32_t v_i; uint32_t v_i;
uint64_t scratch; uint64_t scratch;
@@ -6893,6 +6898,7 @@ extern const char wuffs_bzip2__error__bad_block_length[];
extern const char wuffs_bzip2__error__bad_checksum[]; extern const char wuffs_bzip2__error__bad_checksum[];
extern const char wuffs_bzip2__error__bad_header[]; extern const char wuffs_bzip2__error__bad_header[];
extern const char wuffs_bzip2__error__bad_number_of_sections[]; extern const char wuffs_bzip2__error__bad_number_of_sections[];
extern const char wuffs_bzip2__error__truncated_input[];
extern const char wuffs_bzip2__error__unsupported_block_randomization[]; extern const char wuffs_bzip2__error__unsupported_block_randomization[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -7018,6 +7024,7 @@ struct wuffs_bzip2__decoder__struct {
uint32_t f_code_lengths_bitmask; uint32_t f_code_lengths_bitmask;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
uint32_t p_prepare_block[1]; uint32_t p_prepare_block[1];
uint32_t p_read_code_lengths[1]; uint32_t p_read_code_lengths[1];
uint32_t p_flush_slow[1]; uint32_t p_flush_slow[1];
@@ -7038,7 +7045,7 @@ struct wuffs_bzip2__decoder__struct {
uint32_t v_i; uint32_t v_i;
uint64_t v_tag; uint64_t v_tag;
uint32_t v_final_checksum_want; uint32_t v_final_checksum_want;
} s_transform_io[1]; } s_do_transform_io[1];
struct { struct {
uint32_t v_i; uint32_t v_i;
uint32_t v_selector; uint32_t v_selector;
@@ -7581,6 +7588,7 @@ extern const char wuffs_deflate__error__bad_literal_length_code_count[];
extern const char wuffs_deflate__error__inconsistent_stored_block_length[]; extern const char wuffs_deflate__error__inconsistent_stored_block_length[];
extern const char wuffs_deflate__error__missing_end_of_block_code[]; extern const char wuffs_deflate__error__missing_end_of_block_code[];
extern const char wuffs_deflate__error__no_huffman_codes[]; extern const char wuffs_deflate__error__no_huffman_codes[];
extern const char wuffs_deflate__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -7695,6 +7703,7 @@ struct wuffs_deflate__decoder__struct {
bool f_end_of_block; bool f_end_of_block;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
uint32_t p_decode_blocks[1]; uint32_t p_decode_blocks[1];
uint32_t p_decode_uncompressed[1]; uint32_t p_decode_uncompressed[1];
uint32_t p_init_dynamic_huffman[1]; uint32_t p_init_dynamic_huffman[1];
@@ -7843,6 +7852,7 @@ struct wuffs_deflate__decoder__struct {
// ---------------- Status Codes // ---------------- Status Codes
extern const char wuffs_lzw__error__bad_code[]; extern const char wuffs_lzw__error__bad_code[];
extern const char wuffs_lzw__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -8087,6 +8097,7 @@ extern const char wuffs_gif__error__bad_graphic_control[];
extern const char wuffs_gif__error__bad_header[]; extern const char wuffs_gif__error__bad_header[];
extern const char wuffs_gif__error__bad_literal_width[]; extern const char wuffs_gif__error__bad_literal_width[];
extern const char wuffs_gif__error__bad_palette[]; extern const char wuffs_gif__error__bad_palette[];
extern const char wuffs_gif__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -8287,10 +8298,14 @@ struct wuffs_gif__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_tell_me_more[1]; uint32_t p_tell_me_more[1];
uint32_t p_do_tell_me_more[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_skip_frame[1]; uint32_t p_skip_frame[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
uint32_t p_decode_up_to_id_part1[1]; uint32_t p_decode_up_to_id_part1[1];
uint32_t p_decode_header[1]; uint32_t p_decode_header[1];
uint32_t p_decode_lsd[1]; uint32_t p_decode_lsd[1];
@@ -8311,7 +8326,7 @@ struct wuffs_gif__decoder__struct {
struct { struct {
uint32_t v_background_color; uint32_t v_background_color;
} s_decode_frame_config[1]; } s_do_decode_frame_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_skip_frame[1]; } s_skip_frame[1];
@@ -8511,6 +8526,7 @@ extern const char wuffs_gzip__error__bad_checksum[];
extern const char wuffs_gzip__error__bad_compression_method[]; extern const char wuffs_gzip__error__bad_compression_method[];
extern const char wuffs_gzip__error__bad_encoding_flags[]; extern const char wuffs_gzip__error__bad_encoding_flags[];
extern const char wuffs_gzip__error__bad_header[]; extern const char wuffs_gzip__error__bad_header[];
extern const char wuffs_gzip__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -8615,6 +8631,7 @@ struct wuffs_gzip__decoder__struct {
bool f_ignore_checksum; bool f_ignore_checksum;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
} private_impl; } private_impl;
struct { struct {
@@ -8627,7 +8644,7 @@ struct wuffs_gzip__decoder__struct {
uint32_t v_decoded_length_got; uint32_t v_decoded_length_got;
uint32_t v_checksum_want; uint32_t v_checksum_want;
uint64_t scratch; uint64_t scratch;
} s_transform_io[1]; } s_do_transform_io[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -8996,6 +9013,7 @@ struct wuffs_json__decoder__struct {
// ---------------- Status Codes // ---------------- Status Codes
extern const char wuffs_nie__error__bad_header[]; extern const char wuffs_nie__error__bad_header[];
extern const char wuffs_nie__error__truncated_input[];
extern const char wuffs_nie__error__unsupported_nie_file[]; extern const char wuffs_nie__error__unsupported_nie_file[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -9156,14 +9174,17 @@ struct wuffs_nie__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
} private_impl; } private_impl;
struct { struct {
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -9323,6 +9344,7 @@ extern const char wuffs_zlib__error__bad_compression_method[];
extern const char wuffs_zlib__error__bad_compression_window_size[]; extern const char wuffs_zlib__error__bad_compression_window_size[];
extern const char wuffs_zlib__error__bad_parity_check[]; extern const char wuffs_zlib__error__bad_parity_check[];
extern const char wuffs_zlib__error__incorrect_dictionary[]; extern const char wuffs_zlib__error__incorrect_dictionary[];
extern const char wuffs_zlib__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -9445,6 +9467,7 @@ struct wuffs_zlib__decoder__struct {
uint32_t f_dict_id_want; uint32_t f_dict_id_want;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
} private_impl; } private_impl;
struct { struct {
@@ -9455,7 +9478,7 @@ struct wuffs_zlib__decoder__struct {
struct { struct {
uint32_t v_checksum_got; uint32_t v_checksum_got;
uint64_t scratch; uint64_t scratch;
} s_transform_io[1]; } s_do_transform_io[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -9569,6 +9592,7 @@ extern const char wuffs_png__error__bad_filter[];
extern const char wuffs_png__error__bad_header[]; extern const char wuffs_png__error__bad_header[];
extern const char wuffs_png__error__bad_text_chunk_not_latin_1[]; extern const char wuffs_png__error__bad_text_chunk_not_latin_1[];
extern const char wuffs_png__error__missing_palette[]; extern const char wuffs_png__error__missing_palette[];
extern const char wuffs_png__error__truncated_input[];
extern const char wuffs_png__error__unsupported_cgbi_extension[]; extern const char wuffs_png__error__unsupported_cgbi_extension[];
extern const char wuffs_png__error__unsupported_png_compression_method[]; extern const char wuffs_png__error__unsupported_png_compression_method[];
extern const char wuffs_png__error__unsupported_png_file[]; extern const char wuffs_png__error__unsupported_png_file[];
@@ -9805,6 +9829,7 @@ struct wuffs_png__decoder__struct {
wuffs_base__slice_u8 a_curr, wuffs_base__slice_u8 a_curr,
wuffs_base__slice_u8 a_prev); wuffs_base__slice_u8 a_prev);
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_ihdr[1]; uint32_t p_decode_ihdr[1];
uint32_t p_decode_other_chunk[1]; uint32_t p_decode_other_chunk[1];
uint32_t p_decode_actl[1]; uint32_t p_decode_actl[1];
@@ -9816,10 +9841,13 @@ struct wuffs_png__decoder__struct {
uint32_t p_decode_srgb[1]; uint32_t p_decode_srgb[1];
uint32_t p_decode_trns[1]; uint32_t p_decode_trns[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_skip_frame[1]; uint32_t p_skip_frame[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
uint32_t p_decode_pass[1]; uint32_t p_decode_pass[1];
uint32_t p_tell_me_more[1]; uint32_t p_tell_me_more[1];
uint32_t p_do_tell_me_more[1];
wuffs_base__status (*choosy_filter_and_swizzle)( wuffs_base__status (*choosy_filter_and_swizzle)(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__pixel_buffer* a_dst, wuffs_base__pixel_buffer* a_dst,
@@ -9835,7 +9863,7 @@ struct wuffs_png__decoder__struct {
struct { struct {
uint32_t v_checksum_have; uint32_t v_checksum_have;
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_ihdr[1]; } s_decode_ihdr[1];
@@ -9869,20 +9897,20 @@ struct wuffs_png__decoder__struct {
} s_decode_trns[1]; } s_decode_trns[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_frame_config[1]; } s_do_decode_frame_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_skip_frame[1]; } s_skip_frame[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_frame[1]; } s_do_decode_frame[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_pass[1]; } s_decode_pass[1];
struct { struct {
wuffs_base__status v_zlib_status; wuffs_base__status v_zlib_status;
uint64_t scratch; uint64_t scratch;
} s_tell_me_more[1]; } s_do_tell_me_more[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -10038,6 +10066,7 @@ struct wuffs_png__decoder__struct {
extern const char wuffs_tga__error__bad_header[]; extern const char wuffs_tga__error__bad_header[];
extern const char wuffs_tga__error__bad_run_length_encoding[]; extern const char wuffs_tga__error__bad_run_length_encoding[];
extern const char wuffs_tga__error__truncated_input[];
extern const char wuffs_tga__error__unsupported_tga_file[]; extern const char wuffs_tga__error__unsupported_tga_file[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -10208,8 +10237,11 @@ struct wuffs_tga__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
} private_impl; } private_impl;
struct { struct {
@@ -10220,7 +10252,7 @@ struct wuffs_tga__decoder__struct {
struct { struct {
uint32_t v_i; uint32_t v_i;
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t v_dst_bytes_per_pixel; uint64_t v_dst_bytes_per_pixel;
uint32_t v_dst_x; uint32_t v_dst_x;
@@ -10231,7 +10263,7 @@ struct wuffs_tga__decoder__struct {
uint32_t v_run_length; uint32_t v_run_length;
uint64_t v_num_dst_bytes; uint64_t v_num_dst_bytes;
uint64_t scratch; uint64_t scratch;
} s_decode_frame[1]; } s_do_decode_frame[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -10386,6 +10418,7 @@ struct wuffs_tga__decoder__struct {
// ---------------- Status Codes // ---------------- Status Codes
extern const char wuffs_wbmp__error__bad_header[]; extern const char wuffs_wbmp__error__bad_header[];
extern const char wuffs_wbmp__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -10543,22 +10576,25 @@ struct wuffs_wbmp__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
} private_impl; } private_impl;
struct { struct {
struct { struct {
uint32_t v_i; uint32_t v_i;
uint32_t v_x32; uint32_t v_x32;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t v_dst_bytes_per_pixel; uint64_t v_dst_bytes_per_pixel;
uint32_t v_dst_x; uint32_t v_dst_x;
uint32_t v_dst_y; uint32_t v_dst_y;
uint8_t v_src[1]; uint8_t v_src[1];
uint8_t v_c; uint8_t v_c;
} s_decode_frame[1]; } s_do_decode_frame[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -14745,6 +14781,27 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
// powers converts decimal powers of 10 to binary powers of 2. For example, // powers converts decimal powers of 10 to binary powers of 2. For example,
// (10000 >> 13) is 1. It stops before the elements exceed 60, also known // (10000 >> 13) is 1. It stops before the elements exceed 60, also known
// as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL. // as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
//
// This rounds down (1<<13 is a lower bound for 1e4). Adding 1 to the array
// element value rounds up (1<<14 is an upper bound for 1e4) while staying
// at or below WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
//
// When starting in the range [1e+1 .. 1e+2] (i.e. h->decimal_point == +2),
// powers[2] == 6 and so:
// - Right shifting by 6+0 produces the range [10/64 .. 100/64] =
// [0.156250 .. 1.56250]. The resultant h->decimal_point is +0 or +1.
// - Right shifting by 6+1 produces the range [10/128 .. 100/128] =
// [0.078125 .. 0.78125]. The resultant h->decimal_point is -1 or -0.
//
// When starting in the range [1e-3 .. 1e-2] (i.e. h->decimal_point == -2),
// powers[2] == 6 and so:
// - Left shifting by 6+0 produces the range [0.001*64 .. 0.01*64] =
// [0.064 .. 0.64]. The resultant h->decimal_point is -1 or -0.
// - Left shifting by 6+1 produces the range [0.001*128 .. 0.01*128] =
// [0.128 .. 1.28]. The resultant h->decimal_point is +0 or +1.
//
// Thus, when targeting h->decimal_point being +0 or +1, use (powers[n]+0)
// when right shifting but (powers[n]+1) when left shifting.
static const uint32_t num_powers = 19; static const uint32_t num_powers = 19;
static const uint8_t powers[19] = { static const uint8_t powers[19] = {
0, 3, 6, 9, 13, 16, 19, 23, 26, 29, // 0, 3, 6, 9, 13, 16, 19, 23, 26, 29, //
@@ -14788,12 +14845,13 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
// When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See // When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See
// https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html // https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
// //
// Scale by powers of 2 until we're in the range [½ .. 1], which gives us // Scale by powers of 2 until we're in the range [0.1 .. 10]. Equivalently,
// our exponent (in base-2). First we shift right, possibly a little too // that h->decimal_point is +0 or +1.
// far, ending with a value certainly below 1 and possibly below ½... //
// First we shift right while at or above 10...
const int32_t f64_bias = -1023; const int32_t f64_bias = -1023;
int32_t exp2 = 0; int32_t exp2 = 0;
while (h->decimal_point > 0) { while (h->decimal_point > 1) {
uint32_t n = (uint32_t)(+h->decimal_point); uint32_t n = (uint32_t)(+h->decimal_point);
uint32_t shift = uint32_t shift =
(n < num_powers) (n < num_powers)
@@ -14807,20 +14865,15 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
} }
exp2 += (int32_t)shift; exp2 += (int32_t)shift;
} }
// ...then we shift left, putting us in [½ .. 1]. // ...then we shift left while below 0.1.
while (h->decimal_point <= 0) { while (h->decimal_point < 0) {
uint32_t shift; uint32_t shift;
if (h->decimal_point == 0) { uint32_t n = (uint32_t)(-h->decimal_point);
if (h->digits[0] >= 5) { shift = (n < num_powers)
break; // The +1 is per "when targeting h->decimal_point being +0 or
} // +1... when left shifting" in the powers comment above.
shift = (h->digits[0] < 2) ? 2 : 1; ? (powers[n] + 1)
} else { : WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
uint32_t n = (uint32_t)(-h->decimal_point);
shift = (n < num_powers)
? powers[n]
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
}
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift); wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift);
if (h->decimal_point > if (h->decimal_point >
@@ -14830,8 +14883,37 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
exp2 -= (int32_t)shift; exp2 -= (int32_t)shift;
} }
// We're in the range [½ .. 1] but f64 uses [1 .. 2]. // To get from "in the range [0.1 .. 10]" to "in the range [1 .. 2]" (which
exp2--; // will give us our exponent in base-2), the mantissa's first 3 digits will
// determine the final left shift, equal to 52 (the number of explicit f64
// bits) plus an additional adjustment.
int man3 = (100 * h->digits[0]) +
((h->num_digits > 1) ? (10 * h->digits[1]) : 0) +
((h->num_digits > 2) ? h->digits[2] : 0);
int32_t additional_lshift = 0;
if (h->decimal_point == 0) { // The value is in [0.1 .. 1].
if (man3 < 125) {
additional_lshift = +4;
} else if (man3 < 250) {
additional_lshift = +3;
} else if (man3 < 500) {
additional_lshift = +2;
} else {
additional_lshift = +1;
}
} else { // The value is in [1 .. 10].
if (man3 < 200) {
additional_lshift = -0;
} else if (man3 < 400) {
additional_lshift = -1;
} else if (man3 < 800) {
additional_lshift = -2;
} else {
additional_lshift = -3;
}
}
exp2 -= additional_lshift;
uint32_t final_lshift = (uint32_t)(52 + additional_lshift);
// The minimum normal exponent is (f64_bias + 1). // The minimum normal exponent is (f64_bias + 1).
while ((f64_bias + 1) > exp2) { while ((f64_bias + 1) > exp2) {
@@ -14849,7 +14931,8 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
} }
// Extract 53 bits for the mantissa (in base-2). // Extract 53 bits for the mantissa (in base-2).
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, 53); wuffs_base__private_implementation__high_prec_dec__small_lshift(
h, final_lshift);
uint64_t man2 = uint64_t man2 =
wuffs_base__private_implementation__high_prec_dec__rounded_integer(h); wuffs_base__private_implementation__high_prec_dec__rounded_integer(h);
@@ -22532,6 +22615,7 @@ wuffs_adler32__hasher__up_x86_sse42(
const char wuffs_bmp__error__bad_header[] = "#bmp: bad header"; const char wuffs_bmp__error__bad_header[] = "#bmp: bad header";
const char wuffs_bmp__error__bad_rle_compression[] = "#bmp: bad RLE compression"; const char wuffs_bmp__error__bad_rle_compression[] = "#bmp: bad RLE compression";
const char wuffs_bmp__error__truncated_input[] = "#bmp: truncated input";
const char wuffs_bmp__error__unsupported_bmp_file[] = "#bmp: unsupported BMP file"; const char wuffs_bmp__error__unsupported_bmp_file[] = "#bmp: unsupported BMP file";
const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: short read"; const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: short read";
@@ -22569,6 +22653,27 @@ const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: s
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_bmp__decoder__do_decode_image_config(
wuffs_bmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame_config(
wuffs_bmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame(
wuffs_bmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__status static wuffs_base__status
wuffs_bmp__decoder__swizzle_none( wuffs_bmp__decoder__swizzle_none(
wuffs_bmp__decoder* self, wuffs_bmp__decoder* self,
@@ -22593,6 +22698,13 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
wuffs_base__pixel_buffer* a_dst, wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_bmp__decoder__do_tell_me_more(
wuffs_bmp__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_bmp__decoder__read_palette( wuffs_bmp__decoder__read_palette(
wuffs_bmp__decoder* self, wuffs_bmp__decoder* self,
@@ -22747,6 +22859,52 @@ wuffs_bmp__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_decode_image_config
static wuffs_base__status
wuffs_bmp__decoder__do_decode_image_config(
wuffs_bmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_magic = 0; uint32_t v_magic = 0;
uint32_t v_width = 0; uint32_t v_width = 0;
uint32_t v_height = 0; uint32_t v_height = 0;
@@ -22765,7 +22923,7 @@ wuffs_bmp__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -22783,14 +22941,14 @@ wuffs_bmp__decoder__decode_image_config(
t_0 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_0 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22809,15 +22967,15 @@ wuffs_bmp__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_bmp__error__bad_header); status = wuffs_base__make_status(wuffs_bmp__error__bad_header);
goto exit; goto exit;
} }
self->private_data.s_decode_image_config[0].scratch = 8; self->private_data.s_do_decode_image_config[0].scratch = 8;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
uint32_t t_1; uint32_t t_1;
@@ -22825,14 +22983,14 @@ wuffs_bmp__decoder__decode_image_config(
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22860,14 +23018,14 @@ wuffs_bmp__decoder__decode_image_config(
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22895,14 +23053,14 @@ wuffs_bmp__decoder__decode_image_config(
t_3 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_3 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22924,14 +23082,14 @@ wuffs_bmp__decoder__decode_image_config(
t_4 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_4 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22953,14 +23111,14 @@ wuffs_bmp__decoder__decode_image_config(
t_5 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_5 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_5 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_5 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22986,14 +23144,14 @@ wuffs_bmp__decoder__decode_image_config(
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23016,14 +23174,14 @@ wuffs_bmp__decoder__decode_image_config(
t_7 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_7 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(17); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(17);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23050,14 +23208,14 @@ wuffs_bmp__decoder__decode_image_config(
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(19); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(19);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23084,14 +23242,14 @@ wuffs_bmp__decoder__decode_image_config(
t_9 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_9 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(21); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(21);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23117,14 +23275,14 @@ wuffs_bmp__decoder__decode_image_config(
t_10 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_10 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(23); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(23);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23147,14 +23305,14 @@ wuffs_bmp__decoder__decode_image_config(
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(25); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(25);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23181,14 +23339,14 @@ wuffs_bmp__decoder__decode_image_config(
t_12 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_12 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(27); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(27);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23219,14 +23377,14 @@ wuffs_bmp__decoder__decode_image_config(
t_13 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_13 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(29); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(29);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_13 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_13 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23252,14 +23410,14 @@ wuffs_bmp__decoder__decode_image_config(
t_14 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_14 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(31); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(31);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_14 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_14 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23281,14 +23439,14 @@ wuffs_bmp__decoder__decode_image_config(
t_15 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_15 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(33); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(33);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_15 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_15 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23316,15 +23474,15 @@ wuffs_bmp__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file); status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit; goto exit;
} }
self->private_data.s_decode_image_config[0].scratch = 20; self->private_data.s_do_decode_image_config[0].scratch = 20;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(34); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(34);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
if (self->private_impl.f_bitmap_info_len == 40) { if (self->private_impl.f_bitmap_info_len == 40) {
if (self->private_impl.f_bits_per_pixel >= 16) { if (self->private_impl.f_bits_per_pixel >= 16) {
if (self->private_impl.f_padding >= 16) { if (self->private_impl.f_padding >= 16) {
@@ -23355,14 +23513,14 @@ wuffs_bmp__decoder__decode_image_config(
t_16 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_16 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(36); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(36);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_16 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_16 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23384,14 +23542,14 @@ wuffs_bmp__decoder__decode_image_config(
t_17 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_17 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(38); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(38);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_17 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_17 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23413,14 +23571,14 @@ wuffs_bmp__decoder__decode_image_config(
t_18 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_18 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(40); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(40);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_18 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_18 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23443,14 +23601,14 @@ wuffs_bmp__decoder__decode_image_config(
t_19 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_19 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(42); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(42);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_19 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_19 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23465,15 +23623,15 @@ wuffs_bmp__decoder__decode_image_config(
} }
self->private_impl.f_channel_masks[3] = t_19; self->private_impl.f_channel_masks[3] = t_19;
} }
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56)); self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56));
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(43); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(43);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
} }
if ((self->private_impl.f_channel_masks[0] == 255) && (self->private_impl.f_channel_masks[1] == 65280) && (self->private_impl.f_channel_masks[2] == 16711680)) { if ((self->private_impl.f_channel_masks[0] == 255) && (self->private_impl.f_channel_masks[1] == 65280) && (self->private_impl.f_channel_masks[2] == 16711680)) {
if (self->private_impl.f_bits_per_pixel == 24) { if (self->private_impl.f_bits_per_pixel == 24) {
@@ -23491,15 +23649,15 @@ wuffs_bmp__decoder__decode_image_config(
} }
} }
} else if (self->private_impl.f_bitmap_info_len >= 40) { } else if (self->private_impl.f_bitmap_info_len >= 40) {
self->private_data.s_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40); self->private_data.s_do_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
} else { } else {
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file); status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit; goto exit;
@@ -23622,14 +23780,13 @@ wuffs_bmp__decoder__decode_image_config(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
@@ -23637,9 +23794,6 @@ wuffs_bmp__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -23671,6 +23825,52 @@ wuffs_bmp__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame_config(
wuffs_bmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -23682,7 +23882,7 @@ wuffs_bmp__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -23692,7 +23892,7 @@ wuffs_bmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_bmp__decoder__decode_image_config(self, NULL, a_src); status = wuffs_bmp__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -23731,14 +23931,13 @@ wuffs_bmp__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -23746,9 +23945,6 @@ wuffs_bmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -23785,6 +23981,60 @@ wuffs_bmp__decoder__decode_frame(
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_decode_frame
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame(
wuffs_bmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -23796,7 +24046,7 @@ wuffs_bmp__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -23806,7 +24056,7 @@ wuffs_bmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_bmp__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_bmp__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -23817,15 +24067,15 @@ wuffs_bmp__decoder__decode_frame(
status = wuffs_base__make_status(wuffs_base__note__end_of_data); status = wuffs_base__make_status(wuffs_base__note__end_of_data);
goto ok; goto ok;
} }
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_padding; self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_padding;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
if ((self->private_impl.f_width > 0) && (self->private_impl.f_height > 0)) { if ((self->private_impl.f_width > 0) && (self->private_impl.f_height > 0)) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
if (self->private_impl.f_top_down) { if (self->private_impl.f_top_down) {
@@ -23901,28 +24151,27 @@ wuffs_bmp__decoder__decode_frame(
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
} }
label__0__break:; label__0__break:;
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_pending_pad; self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_pending_pad;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
self->private_impl.f_pending_pad = 0; self->private_impl.f_pending_pad = 0;
} }
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit; goto exit;
exit: exit:
@@ -23930,9 +24179,6 @@ wuffs_bmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -23949,10 +24195,12 @@ wuffs_bmp__decoder__swizzle_none(
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
uint64_t v_dst_bytes_per_pixel = 0; uint64_t v_dst_bytes_per_pixel = 0;
uint64_t v_dst_bytes_per_row = 0; uint64_t v_dst_bytes_per_row = 0;
uint32_t v_src_bytes_per_pixel = 0;
wuffs_base__slice_u8 v_dst_palette = {0}; wuffs_base__slice_u8 v_dst_palette = {0};
wuffs_base__table_u8 v_tab = {0}; wuffs_base__table_u8 v_tab = {0};
wuffs_base__slice_u8 v_dst = {0}; wuffs_base__slice_u8 v_dst = {0};
uint64_t v_i = 0; uint64_t v_i = 0;
uint64_t v_j = 0;
uint64_t v_n = 0; uint64_t v_n = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -23986,7 +24234,6 @@ wuffs_bmp__decoder__swizzle_none(
self->private_impl.f_pending_pad -= 1; self->private_impl.f_pending_pad -= 1;
iop_a_src += 1; iop_a_src += 1;
} }
label__inner__continue:;
while (true) { while (true) {
if (self->private_impl.f_dst_x == self->private_impl.f_width) { if (self->private_impl.f_dst_x == self->private_impl.f_width) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
@@ -24007,14 +24254,38 @@ wuffs_bmp__decoder__swizzle_none(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
goto label__inner__continue; if (self->private_impl.f_bits_per_pixel > 32) {
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit;
}
v_src_bytes_per_pixel = (self->private_impl.f_bits_per_pixel / 8);
if (v_src_bytes_per_pixel == 0) {
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit;
}
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
v_j = v_n;
while (v_j >= 8) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
iop_a_src += (v_src_bytes_per_pixel * 8);
}
v_j -= 8;
}
while (v_j > 0) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
iop_a_src += (v_src_bytes_per_pixel * 1);
}
v_j -= 1;
}
} else {
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
v_dst_palette,
&iop_a_src,
io2_a_src);
} }
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
v_dst_palette,
&iop_a_src,
io2_a_src);
if (v_n == 0) { if (v_n == 0) {
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read); status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
goto ok; goto ok;
@@ -24355,7 +24626,6 @@ wuffs_bmp__decoder__swizzle_bitfields(
self->private_impl.f_pending_pad -= 1; self->private_impl.f_pending_pad -= 1;
iop_a_src += 1; iop_a_src += 1;
} }
label__inner__continue:;
while (true) { while (true) {
if (self->private_impl.f_dst_x == self->private_impl.f_width) { if (self->private_impl.f_dst_x == self->private_impl.f_width) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
@@ -24414,9 +24684,10 @@ wuffs_bmp__decoder__swizzle_bitfields(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
goto label__inner__continue; v_n = ((uint64_t)(v_p0));
} else {
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
} }
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
if (v_n == 0) { if (v_n == 0) {
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read); status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
goto ok; goto ok;
@@ -24459,6 +24730,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
uint32_t v_p0 = 0; uint32_t v_p0 = 0;
uint32_t v_chunk_bits = 0; uint32_t v_chunk_bits = 0;
uint32_t v_chunk_count = 0; uint32_t v_chunk_count = 0;
uint32_t v_pixels_per_chunk = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -24496,6 +24768,35 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
if (self->private_impl.f_bits_per_pixel == 1) {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 31) / 32);
v_pixels_per_chunk = 32;
} else if (self->private_impl.f_bits_per_pixel == 2) {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 15) / 16);
v_pixels_per_chunk = 16;
} else {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
v_pixels_per_chunk = 8;
}
while ((v_chunk_count >= 64) && (((uint64_t)(io2_a_src - iop_a_src)) >= 256)) {
iop_a_src += 256;
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 64))));
v_chunk_count -= 64;
}
while ((v_chunk_count >= 8) && (((uint64_t)(io2_a_src - iop_a_src)) >= 32)) {
iop_a_src += 32;
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 8))));
v_chunk_count -= 8;
}
while (v_chunk_count > 0) {
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
goto ok;
}
iop_a_src += 4;
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 1))));
v_chunk_count -= 1;
}
goto label__loop__continue; goto label__loop__continue;
} }
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_i); v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_i);
@@ -24566,7 +24867,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
v_p0 = ((v_p0 & 511) + 16); v_p0 = ((v_p0 & 511) + 16);
v_chunk_count -= 1; v_chunk_count -= 1;
} }
} else if (self->private_impl.f_bits_per_pixel == 4) { } else {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8); v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
v_chunk_count = wuffs_base__u32__min(v_chunk_count, 64); v_chunk_count = wuffs_base__u32__min(v_chunk_count, 64);
while ((v_chunk_count > 0) && (((uint64_t)(io2_a_src - iop_a_src)) >= 4)) { while ((v_chunk_count > 0) && (((uint64_t)(io2_a_src - iop_a_src)) >= 4)) {
@@ -24747,6 +25048,53 @@ wuffs_bmp__decoder__tell_me_more(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_tell_me_more[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_tell_me_more
static wuffs_base__status
wuffs_bmp__decoder__do_tell_me_more(
wuffs_bmp__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
if (self->private_impl.f_io_redirect_fourcc <= 1) { if (self->private_impl.f_io_redirect_fourcc <= 1) {
status = wuffs_base__make_status(wuffs_base__error__no_more_information); status = wuffs_base__make_status(wuffs_base__error__no_more_information);
goto exit; goto exit;
@@ -24765,9 +25113,6 @@ wuffs_bmp__decoder__tell_me_more(
ok: ok:
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -24980,6 +25325,7 @@ const char wuffs_bzip2__error__bad_block_length[] = "#bzip2: bad block length";
const char wuffs_bzip2__error__bad_checksum[] = "#bzip2: bad checksum"; const char wuffs_bzip2__error__bad_checksum[] = "#bzip2: bad checksum";
const char wuffs_bzip2__error__bad_header[] = "#bzip2: bad header"; const char wuffs_bzip2__error__bad_header[] = "#bzip2: bad header";
const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections"; const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections";
const char wuffs_bzip2__error__truncated_input[] = "#bzip2: truncated input";
const char wuffs_bzip2__error__unsupported_block_randomization[] = "#bzip2: unsupported block randomization"; const char wuffs_bzip2__error__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"; const char wuffs_bzip2__error__internal_error_inconsistent_huffman_decoder_state[] = "#bzip2: internal error: inconsistent Huffman decoder state";
@@ -25030,6 +25376,13 @@ WUFFS_BZIP2__REV_CRC32_TABLE[256] WUFFS_BASE__POTENTIALLY_UNUSED = {
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_bzip2__decoder__do_transform_io(
wuffs_bzip2__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
static wuffs_base__status static wuffs_base__status
wuffs_bzip2__decoder__prepare_block( wuffs_bzip2__decoder__prepare_block(
wuffs_bzip2__decoder* self, wuffs_bzip2__decoder* self,
@@ -25224,6 +25577,53 @@ wuffs_bzip2__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bzip2__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bzip2__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bzip2.decoder.do_transform_io
static wuffs_base__status
wuffs_bzip2__decoder__do_transform_io(
wuffs_bzip2__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint32_t v_i = 0; uint32_t v_i = 0;
uint64_t v_tag = 0; uint64_t v_tag = 0;
@@ -25241,11 +25641,11 @@ wuffs_bzip2__decoder__transform_io(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
if (coro_susp_point) { if (coro_susp_point) {
v_i = self->private_data.s_transform_io[0].v_i; v_i = self->private_data.s_do_transform_io[0].v_i;
v_tag = self->private_data.s_transform_io[0].v_tag; v_tag = self->private_data.s_do_transform_io[0].v_tag;
v_final_checksum_want = self->private_data.s_transform_io[0].v_final_checksum_want; v_final_checksum_want = self->private_data.s_do_transform_io[0].v_final_checksum_want;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -25434,17 +25834,16 @@ wuffs_bzip2__decoder__transform_io(
goto ok; goto ok;
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_transform_io[0].v_i = v_i;
self->private_data.s_transform_io[0].v_i = v_i; self->private_data.s_do_transform_io[0].v_tag = v_tag;
self->private_data.s_transform_io[0].v_tag = v_tag; self->private_data.s_do_transform_io[0].v_final_checksum_want = v_final_checksum_want;
self->private_data.s_transform_io[0].v_final_checksum_want = v_final_checksum_want;
goto exit; goto exit;
exit: exit:
@@ -25452,9 +25851,6 @@ wuffs_bzip2__decoder__transform_io(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -28417,6 +28813,7 @@ const char wuffs_deflate__error__bad_literal_length_code_count[] = "#deflate: ba
const char wuffs_deflate__error__inconsistent_stored_block_length[] = "#deflate: inconsistent stored block length"; const char wuffs_deflate__error__inconsistent_stored_block_length[] = "#deflate: inconsistent stored block length";
const char wuffs_deflate__error__missing_end_of_block_code[] = "#deflate: missing end-of-block code"; const char wuffs_deflate__error__missing_end_of_block_code[] = "#deflate: missing end-of-block code";
const char wuffs_deflate__error__no_huffman_codes[] = "#deflate: no Huffman codes"; const char wuffs_deflate__error__no_huffman_codes[] = "#deflate: no Huffman codes";
const char wuffs_deflate__error__truncated_input[] = "#deflate: truncated input";
const char wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state[] = "#deflate: internal error: inconsistent Huffman decoder state"; const char wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state[] = "#deflate: internal error: inconsistent Huffman decoder state";
const char wuffs_deflate__error__internal_error_inconsistent_i_o[] = "#deflate: internal error: inconsistent I/O"; const char wuffs_deflate__error__internal_error_inconsistent_i_o[] = "#deflate: internal error: inconsistent I/O";
const char wuffs_deflate__error__internal_error_inconsistent_distance[] = "#deflate: internal error: inconsistent distance"; const char wuffs_deflate__error__internal_error_inconsistent_distance[] = "#deflate: internal error: inconsistent distance";
@@ -28491,6 +28888,13 @@ WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[32] WUFFS_BASE__POTENTIALLY_UNUSED = {
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_deflate__decoder__do_transform_io(
wuffs_deflate__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
static wuffs_base__status static wuffs_base__status
wuffs_deflate__decoder__decode_blocks( wuffs_deflate__decoder__decode_blocks(
wuffs_deflate__decoder* self, wuffs_deflate__decoder* self,
@@ -28734,6 +29138,53 @@ wuffs_deflate__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_deflate__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_deflate__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func deflate.decoder.do_transform_io
static wuffs_base__status
wuffs_deflate__decoder__do_transform_io(
wuffs_deflate__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint64_t v_mark = 0; uint64_t v_mark = 0;
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
@@ -28751,7 +29202,7 @@ wuffs_deflate__decoder__transform_io(
} }
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -28789,14 +29240,13 @@ wuffs_deflate__decoder__transform_io(
} }
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
@@ -28804,9 +29254,6 @@ wuffs_deflate__decoder__transform_io(
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr)); a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -30680,6 +31127,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
// ---------------- Status Codes Implementations // ---------------- Status Codes Implementations
const char wuffs_lzw__error__bad_code[] = "#lzw: bad code"; const char wuffs_lzw__error__bad_code[] = "#lzw: bad code";
const char wuffs_lzw__error__truncated_input[] = "#lzw: truncated input";
const char wuffs_lzw__error__internal_error_inconsistent_i_o[] = "#lzw: internal error: inconsistent I/O"; const char wuffs_lzw__error__internal_error_inconsistent_i_o[] = "#lzw: internal error: inconsistent I/O";
// ---------------- Private Consts // ---------------- Private Consts
@@ -30902,6 +31350,9 @@ wuffs_lzw__decoder__transform_io(
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
} else if (self->private_impl.f_read_from_return_value == 3) { } else if (self->private_impl.f_read_from_return_value == 3) {
status = wuffs_base__make_status(wuffs_lzw__error__truncated_input);
goto exit;
} else if (self->private_impl.f_read_from_return_value == 4) {
status = wuffs_base__make_status(wuffs_lzw__error__bad_code); status = wuffs_base__make_status(wuffs_lzw__error__bad_code);
goto exit; goto exit;
} else { } else {
@@ -30977,7 +31428,11 @@ wuffs_lzw__decoder__read_from(
iop_a_src += ((31 - v_n_bits) >> 3); iop_a_src += ((31 - v_n_bits) >> 3);
v_n_bits |= 24; v_n_bits |= 24;
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) { } else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
self->private_impl.f_read_from_return_value = 2; if (a_src && a_src->meta.closed) {
self->private_impl.f_read_from_return_value = 3;
} else {
self->private_impl.f_read_from_return_value = 2;
}
goto label__0__break; goto label__0__break;
} else { } else {
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits); v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
@@ -30985,14 +31440,18 @@ wuffs_lzw__decoder__read_from(
v_n_bits += 8; v_n_bits += 8;
if (v_n_bits >= v_width) { if (v_n_bits >= v_width) {
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) { } else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
self->private_impl.f_read_from_return_value = 2; if (a_src && a_src->meta.closed) {
self->private_impl.f_read_from_return_value = 3;
} else {
self->private_impl.f_read_from_return_value = 2;
}
goto label__0__break; goto label__0__break;
} else { } else {
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits); v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
iop_a_src += 1; iop_a_src += 1;
v_n_bits += 8; v_n_bits += 8;
if (v_n_bits < v_width) { if (v_n_bits < v_width) {
self->private_impl.f_read_from_return_value = 4; self->private_impl.f_read_from_return_value = 5;
goto label__0__break; goto label__0__break;
} }
} }
@@ -31070,7 +31529,7 @@ wuffs_lzw__decoder__read_from(
v_prev_code = v_code; v_prev_code = v_code;
} }
} else { } else {
self->private_impl.f_read_from_return_value = 3; self->private_impl.f_read_from_return_value = 4;
goto label__0__break; goto label__0__break;
} }
if (v_output_wi > 4095) { if (v_output_wi > 4095) {
@@ -31085,7 +31544,7 @@ wuffs_lzw__decoder__read_from(
if (iop_a_src > io1_a_src) { if (iop_a_src > io1_a_src) {
iop_a_src--; iop_a_src--;
} else { } else {
self->private_impl.f_read_from_return_value = 4; self->private_impl.f_read_from_return_value = 5;
goto label__2__break; goto label__2__break;
} }
} }
@@ -31207,6 +31666,7 @@ const char wuffs_gif__error__bad_graphic_control[] = "#gif: bad graphic control"
const char wuffs_gif__error__bad_header[] = "#gif: bad header"; const char wuffs_gif__error__bad_header[] = "#gif: bad header";
const char wuffs_gif__error__bad_literal_width[] = "#gif: bad literal width"; const char wuffs_gif__error__bad_literal_width[] = "#gif: bad literal width";
const char wuffs_gif__error__bad_palette[] = "#gif: bad palette"; const char wuffs_gif__error__bad_palette[] = "#gif: bad palette";
const char wuffs_gif__error__truncated_input[] = "#gif: truncated input";
const char wuffs_gif__error__internal_error_inconsistent_ri_wi[] = "#gif: internal error: inconsistent ri/wi"; const char wuffs_gif__error__internal_error_inconsistent_ri_wi[] = "#gif: internal error: inconsistent ri/wi";
// ---------------- Private Consts // ---------------- Private Consts
@@ -31258,11 +31718,39 @@ WUFFS_GIF__XMPDATAXMP[11] WUFFS_BASE__POTENTIALLY_UNUSED = {
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_gif__decoder__do_decode_image_config(
wuffs_gif__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_gif__decoder__do_tell_me_more(
wuffs_gif__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame_config(
wuffs_gif__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_gif__decoder__skip_frame( wuffs_gif__decoder__skip_frame(
wuffs_gif__decoder* self, wuffs_gif__decoder* self,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame(
wuffs_gif__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__empty_struct static wuffs_base__empty_struct
wuffs_gif__decoder__reset_gc( wuffs_gif__decoder__reset_gc(
wuffs_gif__decoder* self); wuffs_gif__decoder* self);
@@ -31492,12 +31980,58 @@ wuffs_gif__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
bool v_ffio = false; wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_decode_image_config
static wuffs_base__status
wuffs_gif__decoder__do_decode_image_config(
wuffs_gif__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
bool v_ffio = false;
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence != 0) { if (self->private_impl.f_call_sequence != 0) {
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
goto exit; goto exit;
@@ -31548,20 +32082,16 @@ wuffs_gif__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -31616,6 +32146,53 @@ wuffs_gif__decoder__tell_me_more(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_tell_me_more[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_tell_me_more
static wuffs_base__status
wuffs_gif__decoder__do_tell_me_more(
wuffs_gif__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint64_t v_chunk_length = 0; uint64_t v_chunk_length = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -31629,7 +32206,7 @@ wuffs_gif__decoder__tell_me_more(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0]; uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -31711,14 +32288,13 @@ wuffs_gif__decoder__tell_me_more(
goto ok; goto ok;
ok: ok:
self->private_impl.p_tell_me_more[0] = 0; self->private_impl.p_do_tell_me_more[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -31726,9 +32302,6 @@ wuffs_gif__decoder__tell_me_more(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -31881,6 +32454,52 @@ wuffs_gif__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame_config(
wuffs_gif__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_background_color = 0; uint32_t v_background_color = 0;
uint8_t v_flags = 0; uint8_t v_flags = 0;
@@ -31895,9 +32514,9 @@ wuffs_gif__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_background_color = self->private_data.s_decode_frame_config[0].v_background_color; v_background_color = self->private_data.s_do_decode_frame_config[0].v_background_color;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -31912,7 +32531,7 @@ wuffs_gif__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src); status = wuffs_gif__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -31995,15 +32614,14 @@ wuffs_gif__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0; self->private_data.s_do_decode_frame_config[0].v_background_color = v_background_color;
self->private_data.s_decode_frame_config[0].v_background_color = v_background_color;
goto exit; goto exit;
exit: exit:
@@ -32011,9 +32629,6 @@ wuffs_gif__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -32145,14 +32760,68 @@ wuffs_gif__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_decode_frame
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame(
wuffs_gif__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence == 64) { if (self->private_impl.f_call_sequence == 64) {
} else if (self->private_impl.f_call_sequence < 64) { } else if (self->private_impl.f_call_sequence < 64) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_gif__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_gif__decoder__do_decode_frame_config(self, NULL, a_src);
if (status.repr) { if (status.repr) {
goto suspend; goto suspend;
} }
@@ -32179,20 +32848,16 @@ wuffs_gif__decoder__decode_frame(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -33795,6 +34460,7 @@ const char wuffs_gzip__error__bad_checksum[] = "#gzip: bad checksum";
const char wuffs_gzip__error__bad_compression_method[] = "#gzip: bad compression method"; const char wuffs_gzip__error__bad_compression_method[] = "#gzip: bad compression method";
const char wuffs_gzip__error__bad_encoding_flags[] = "#gzip: bad encoding flags"; const char wuffs_gzip__error__bad_encoding_flags[] = "#gzip: bad encoding flags";
const char wuffs_gzip__error__bad_header[] = "#gzip: bad header"; const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
const char wuffs_gzip__error__truncated_input[] = "#gzip: truncated input";
// ---------------- Private Consts // ---------------- Private Consts
@@ -33802,6 +34468,13 @@ const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_gzip__decoder__do_transform_io(
wuffs_gzip__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
// ---------------- VTables // ---------------- VTables
const wuffs_base__io_transformer__func_ptrs const wuffs_base__io_transformer__func_ptrs
@@ -33966,6 +34639,53 @@ wuffs_gzip__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gzip__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gzip__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gzip.decoder.do_transform_io
static wuffs_base__status
wuffs_gzip__decoder__do_transform_io(
wuffs_gzip__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint8_t v_flags = 0; uint8_t v_flags = 0;
uint16_t v_xlen = 0; uint16_t v_xlen = 0;
@@ -34000,12 +34720,12 @@ wuffs_gzip__decoder__transform_io(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
if (coro_susp_point) { if (coro_susp_point) {
v_flags = self->private_data.s_transform_io[0].v_flags; v_flags = self->private_data.s_do_transform_io[0].v_flags;
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got; v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
v_decoded_length_got = self->private_data.s_transform_io[0].v_decoded_length_got; v_decoded_length_got = self->private_data.s_do_transform_io[0].v_decoded_length_got;
v_checksum_want = self->private_data.s_transform_io[0].v_checksum_want; v_checksum_want = self->private_data.s_do_transform_io[0].v_checksum_want;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -34058,15 +34778,15 @@ wuffs_gzip__decoder__transform_io(
uint8_t t_3 = *iop_a_src++; uint8_t t_3 = *iop_a_src++;
v_flags = t_3; v_flags = t_3;
} }
self->private_data.s_transform_io[0].scratch = 6; self->private_data.s_do_transform_io[0].scratch = 6;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_transform_io[0].scratch; iop_a_src += self->private_data.s_do_transform_io[0].scratch;
if ((v_flags & 4) != 0) { if ((v_flags & 4) != 0) {
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
@@ -34075,14 +34795,14 @@ wuffs_gzip__decoder__transform_io(
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src); t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -34097,15 +34817,15 @@ wuffs_gzip__decoder__transform_io(
} }
v_xlen = t_4; v_xlen = t_4;
} }
self->private_data.s_transform_io[0].scratch = ((uint32_t)(v_xlen)); self->private_data.s_do_transform_io[0].scratch = ((uint32_t)(v_xlen));
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_transform_io[0].scratch; iop_a_src += self->private_data.s_do_transform_io[0].scratch;
} }
if ((v_flags & 8) != 0) { if ((v_flags & 8) != 0) {
while (true) { while (true) {
@@ -34142,15 +34862,15 @@ wuffs_gzip__decoder__transform_io(
label__1__break:; label__1__break:;
} }
if ((v_flags & 2) != 0) { if ((v_flags & 2) != 0) {
self->private_data.s_transform_io[0].scratch = 2; self->private_data.s_do_transform_io[0].scratch = 2;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_transform_io[0].scratch; iop_a_src += self->private_data.s_do_transform_io[0].scratch;
} }
if ((v_flags & 224) != 0) { if ((v_flags & 224) != 0) {
status = wuffs_base__make_status(wuffs_gzip__error__bad_encoding_flags); status = wuffs_base__make_status(wuffs_gzip__error__bad_encoding_flags);
@@ -34192,14 +34912,14 @@ wuffs_gzip__decoder__transform_io(
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -34221,14 +34941,14 @@ wuffs_gzip__decoder__transform_io(
t_9 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_9 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -34249,18 +34969,17 @@ wuffs_gzip__decoder__transform_io(
} }
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_transform_io[0].v_flags = v_flags;
self->private_data.s_transform_io[0].v_flags = v_flags; self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got; self->private_data.s_do_transform_io[0].v_decoded_length_got = v_decoded_length_got;
self->private_data.s_transform_io[0].v_decoded_length_got = v_decoded_length_got; self->private_data.s_do_transform_io[0].v_checksum_want = v_checksum_want;
self->private_data.s_transform_io[0].v_checksum_want = v_checksum_want;
goto exit; goto exit;
exit: exit:
@@ -34271,9 +34990,6 @@ wuffs_gzip__decoder__transform_io(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -36491,6 +37207,7 @@ wuffs_json__decoder__decode_trailer(
// ---------------- Status Codes Implementations // ---------------- Status Codes Implementations
const char wuffs_nie__error__bad_header[] = "#nie: bad header"; const char wuffs_nie__error__bad_header[] = "#nie: bad header";
const char wuffs_nie__error__truncated_input[] = "#nie: truncated input";
const char wuffs_nie__error__unsupported_nie_file[] = "#nie: unsupported NIE file"; const char wuffs_nie__error__unsupported_nie_file[] = "#nie: unsupported NIE file";
const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: short read"; const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: short read";
@@ -36500,6 +37217,27 @@ const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: s
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_nie__decoder__do_decode_image_config(
wuffs_nie__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame_config(
wuffs_nie__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame(
wuffs_nie__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__status static wuffs_base__status
wuffs_nie__decoder__swizzle( wuffs_nie__decoder__swizzle(
wuffs_nie__decoder* self, wuffs_nie__decoder* self,
@@ -36651,6 +37389,52 @@ wuffs_nie__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func nie.decoder.do_decode_image_config
static wuffs_base__status
wuffs_nie__decoder__do_decode_image_config(
wuffs_nie__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_a = 0; uint32_t v_a = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -36664,7 +37448,7 @@ wuffs_nie__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -36679,14 +37463,14 @@ wuffs_nie__decoder__decode_image_config(
t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36712,14 +37496,14 @@ wuffs_nie__decoder__decode_image_config(
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36755,14 +37539,14 @@ wuffs_nie__decoder__decode_image_config(
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36789,14 +37573,14 @@ wuffs_nie__decoder__decode_image_config(
t_3 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36830,14 +37614,13 @@ wuffs_nie__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
@@ -36845,9 +37628,6 @@ wuffs_nie__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -36879,6 +37659,52 @@ wuffs_nie__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func nie.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame_config(
wuffs_nie__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -36890,7 +37716,7 @@ wuffs_nie__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -36900,7 +37726,7 @@ wuffs_nie__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_nie__decoder__decode_image_config(self, NULL, a_src); status = wuffs_nie__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -36939,14 +37765,13 @@ wuffs_nie__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -36954,9 +37779,6 @@ wuffs_nie__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -36997,10 +37819,64 @@ wuffs_nie__decoder__decode_frame(
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func nie.decoder.do_decode_frame
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame(
wuffs_nie__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence == 64) { if (self->private_impl.f_call_sequence == 64) {
} else if (self->private_impl.f_call_sequence < 64) { } else if (self->private_impl.f_call_sequence < 64) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_nie__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_nie__decoder__do_decode_frame_config(self, NULL, a_src);
if (status.repr) { if (status.repr) {
goto suspend; goto suspend;
} }
@@ -37047,20 +37923,16 @@ wuffs_nie__decoder__decode_frame(
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -37077,9 +37949,11 @@ wuffs_nie__decoder__swizzle(
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
uint64_t v_dst_bytes_per_pixel = 0; uint64_t v_dst_bytes_per_pixel = 0;
uint64_t v_dst_bytes_per_row = 0; uint64_t v_dst_bytes_per_row = 0;
uint32_t v_src_bytes_per_pixel = 0;
wuffs_base__table_u8 v_tab = {0}; wuffs_base__table_u8 v_tab = {0};
wuffs_base__slice_u8 v_dst = {0}; wuffs_base__slice_u8 v_dst = {0};
uint64_t v_i = 0; uint64_t v_i = 0;
uint64_t v_j = 0;
uint64_t v_n = 0; uint64_t v_n = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -37102,7 +37976,6 @@ wuffs_nie__decoder__swizzle(
v_dst_bytes_per_pixel = ((uint64_t)((v_dst_bits_per_pixel / 8))); v_dst_bytes_per_pixel = ((uint64_t)((v_dst_bits_per_pixel / 8)));
v_dst_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * v_dst_bytes_per_pixel); v_dst_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * v_dst_bytes_per_pixel);
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0); v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0);
label__0__continue:;
while (true) { while (true) {
if (self->private_impl.f_dst_x == self->private_impl.f_width) { if (self->private_impl.f_dst_x == self->private_impl.f_width) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
@@ -37117,14 +37990,33 @@ wuffs_nie__decoder__swizzle(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
goto label__0__continue; v_src_bytes_per_pixel = 4;
if (self->private_impl.f_pixfmt == 2164308923) {
v_src_bytes_per_pixel = 8;
}
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
v_j = v_n;
while (v_j >= 8) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
iop_a_src += (v_src_bytes_per_pixel * 8);
}
v_j -= 8;
}
while (v_j > 0) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
iop_a_src += (v_src_bytes_per_pixel * 1);
}
v_j -= 1;
}
} else {
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
wuffs_base__pixel_buffer__palette(a_dst),
&iop_a_src,
io2_a_src);
} }
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
wuffs_base__pixel_buffer__palette(a_dst),
&iop_a_src,
io2_a_src);
if (v_n == 0) { if (v_n == 0) {
status = wuffs_base__make_status(wuffs_nie__note__internal_note_short_read); status = wuffs_base__make_status(wuffs_nie__note__internal_note_short_read);
goto ok; goto ok;
@@ -37326,6 +38218,7 @@ const char wuffs_zlib__error__bad_compression_method[] = "#zlib: bad compression
const char wuffs_zlib__error__bad_compression_window_size[] = "#zlib: bad compression window size"; const char wuffs_zlib__error__bad_compression_window_size[] = "#zlib: bad compression window size";
const char wuffs_zlib__error__bad_parity_check[] = "#zlib: bad parity check"; const char wuffs_zlib__error__bad_parity_check[] = "#zlib: bad parity check";
const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect dictionary"; const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect dictionary";
const char wuffs_zlib__error__truncated_input[] = "#zlib: truncated input";
// ---------------- Private Consts // ---------------- Private Consts
@@ -37337,6 +38230,13 @@ const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect diction
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_zlib__decoder__do_transform_io(
wuffs_zlib__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
// ---------------- VTables // ---------------- VTables
const wuffs_base__io_transformer__func_ptrs const wuffs_base__io_transformer__func_ptrs
@@ -37554,6 +38454,53 @@ wuffs_zlib__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_zlib__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_zlib__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func zlib.decoder.do_transform_io
static wuffs_base__status
wuffs_zlib__decoder__do_transform_io(
wuffs_zlib__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint16_t v_x = 0; uint16_t v_x = 0;
uint32_t v_checksum_got = 0; uint32_t v_checksum_got = 0;
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
@@ -37584,9 +38531,9 @@ wuffs_zlib__decoder__transform_io(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
if (coro_susp_point) { if (coro_susp_point) {
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got; v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -37603,14 +38550,14 @@ wuffs_zlib__decoder__transform_io(
t_0 = wuffs_base__peek_u16be__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u16be__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -37647,14 +38594,14 @@ wuffs_zlib__decoder__transform_io(
t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -37720,14 +38667,14 @@ wuffs_zlib__decoder__transform_io(
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -37749,15 +38696,14 @@ wuffs_zlib__decoder__transform_io(
} }
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got;
goto exit; goto exit;
exit: exit:
@@ -37768,9 +38714,6 @@ wuffs_zlib__decoder__transform_io(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -37787,6 +38730,7 @@ const char wuffs_png__error__bad_filter[] = "#png: bad filter";
const char wuffs_png__error__bad_header[] = "#png: bad header"; const char wuffs_png__error__bad_header[] = "#png: bad header";
const char wuffs_png__error__bad_text_chunk_not_latin_1[] = "#png: bad text chunk (not Latin-1)"; const char wuffs_png__error__bad_text_chunk_not_latin_1[] = "#png: bad text chunk (not Latin-1)";
const char wuffs_png__error__missing_palette[] = "#png: missing palette"; const char wuffs_png__error__missing_palette[] = "#png: missing palette";
const char wuffs_png__error__truncated_input[] = "#png: truncated input";
const char wuffs_png__error__unsupported_cgbi_extension[] = "#png: unsupported CgBI extension"; const char wuffs_png__error__unsupported_cgbi_extension[] = "#png: unsupported CgBI extension";
const char wuffs_png__error__unsupported_png_compression_method[] = "#png: unsupported PNG compression method"; const char wuffs_png__error__unsupported_png_compression_method[] = "#png: unsupported PNG compression method";
const char wuffs_png__error__unsupported_png_file[] = "#png: unsupported PNG file"; const char wuffs_png__error__unsupported_png_file[] = "#png: unsupported PNG file";
@@ -38012,6 +38956,12 @@ wuffs_png__decoder__filter_4_distance_4_x86_sse42(
wuffs_base__slice_u8 a_prev); wuffs_base__slice_u8 a_prev);
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY) #endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
static wuffs_base__status
wuffs_png__decoder__do_decode_image_config(
wuffs_png__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__decode_ihdr( wuffs_png__decoder__decode_ihdr(
wuffs_png__decoder* self, wuffs_png__decoder* self,
@@ -38081,17 +39031,39 @@ wuffs_png__decoder__decode_trns(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_png__decoder__do_decode_frame_config(
wuffs_png__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__skip_frame( wuffs_png__decoder__skip_frame(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_png__decoder__do_decode_frame(
wuffs_png__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__decode_pass( wuffs_png__decoder__decode_pass(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__io_buffer* a_src, wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf); wuffs_base__slice_u8 a_workbuf);
static wuffs_base__status
wuffs_png__decoder__do_tell_me_more(
wuffs_png__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__filter_and_swizzle( wuffs_png__decoder__filter_and_swizzle(
wuffs_png__decoder* self, wuffs_png__decoder* self,
@@ -39686,6 +40658,52 @@ wuffs_png__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_decode_image_config
static wuffs_base__status
wuffs_png__decoder__do_decode_image_config(
wuffs_png__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint64_t v_magic = 0; uint64_t v_magic = 0;
uint64_t v_mark = 0; uint64_t v_mark = 0;
uint32_t v_checksum_have = 0; uint32_t v_checksum_have = 0;
@@ -39703,9 +40721,9 @@ wuffs_png__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_checksum_have = self->private_data.s_decode_image_config[0].v_checksum_have; v_checksum_have = self->private_data.s_do_decode_image_config[0].v_checksum_have;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -39721,14 +40739,14 @@ wuffs_png__decoder__decode_image_config(
t_0 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
iop_a_src += 8; iop_a_src += 8;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -39754,14 +40772,14 @@ wuffs_png__decoder__decode_image_config(
t_1 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
iop_a_src += 8; iop_a_src += 8;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -39820,14 +40838,14 @@ wuffs_png__decoder__decode_image_config(
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -39852,14 +40870,12 @@ wuffs_png__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_base__note__metadata_reported); status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
goto ok; goto ok;
} }
label__1__continue:;
while (true) { while (true) {
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) { if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
if (a_src && a_src->meta.closed) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit;
}
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
goto label__1__continue;
} }
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32))); self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
@@ -39919,14 +40935,14 @@ wuffs_png__decoder__decode_image_config(
t_5 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_5 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_5 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_5 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -39976,15 +40992,14 @@ wuffs_png__decoder__decode_image_config(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_decode_image_config[0].v_checksum_have = v_checksum_have;
self->private_data.s_decode_image_config[0].v_checksum_have = v_checksum_have;
goto exit; goto exit;
exit: exit:
@@ -39992,9 +41007,6 @@ wuffs_png__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -41923,6 +42935,52 @@ wuffs_png__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_png__decoder__do_decode_frame_config(
wuffs_png__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_checksum_have = 0; uint32_t v_checksum_have = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -41936,7 +42994,7 @@ wuffs_png__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -41949,7 +43007,7 @@ wuffs_png__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_png__decoder__decode_image_config(self, NULL, a_src); status = wuffs_png__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -42000,14 +43058,14 @@ wuffs_png__decoder__decode_frame_config(
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame_config[0].scratch = 0; self->private_data.s_do_decode_frame_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -42029,14 +43087,14 @@ wuffs_png__decoder__decode_frame_config(
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame_config[0].scratch = 0; self->private_data.s_do_decode_frame_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -42063,14 +43121,14 @@ wuffs_png__decoder__decode_frame_config(
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame_config[0].scratch = 0; self->private_data.s_do_decode_frame_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -42108,15 +43166,15 @@ wuffs_png__decoder__decode_frame_config(
if (status.repr) { if (status.repr) {
goto suspend; goto suspend;
} }
self->private_data.s_decode_frame_config[0].scratch = 4; self->private_data.s_do_decode_frame_config[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame_config[0].scratch; iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
goto label__0__break; goto label__0__break;
} }
if (a_src) { if (a_src) {
@@ -42135,15 +43193,15 @@ wuffs_png__decoder__decode_frame_config(
status = wuffs_base__make_status(wuffs_base__note__metadata_reported); status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
goto ok; goto ok;
} }
self->private_data.s_decode_frame_config[0].scratch = 4; self->private_data.s_do_decode_frame_config[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame_config[0].scratch; iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
self->private_impl.f_chunk_length = 0; self->private_impl.f_chunk_length = 0;
} }
label__0__break:; label__0__break:;
@@ -42168,14 +43226,13 @@ wuffs_png__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -42183,9 +43240,6 @@ wuffs_png__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -42220,13 +43274,10 @@ wuffs_png__decoder__skip_frame(
self->private_impl.f_chunk_type_array[3] = 0; self->private_impl.f_chunk_type_array[3] = 0;
label__0__continue:; label__0__continue:;
while (true) { while (true) {
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) { if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
if (a_src && a_src->meta.closed) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit;
}
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
goto label__0__continue;
} }
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32))); self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
@@ -42372,6 +43423,60 @@ wuffs_png__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_decode_frame
static wuffs_base__status
wuffs_png__decoder__do_decode_frame(
wuffs_png__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_seq_num = 0; uint32_t v_seq_num = 0;
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t v_pass_width = 0; uint32_t v_pass_width = 0;
@@ -42388,7 +43493,7 @@ wuffs_png__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -42403,7 +43508,7 @@ wuffs_png__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_png__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_png__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -42411,14 +43516,12 @@ wuffs_png__decoder__decode_frame(
goto suspend; goto suspend;
} }
} }
label__0__continue:;
while (true) { while (true) {
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) { if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
if (a_src && a_src->meta.closed) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit;
}
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
goto label__0__continue;
} }
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32))); self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
@@ -42452,14 +43555,14 @@ wuffs_png__decoder__decode_frame(
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame[0].scratch = 0; self->private_data.s_do_decode_frame[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -42487,15 +43590,15 @@ wuffs_png__decoder__decode_frame(
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
} }
self->private_data.s_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12); self->private_data.s_do_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
self->private_impl.f_chunk_length = 0; self->private_impl.f_chunk_length = 0;
} }
label__0__break:; label__0__break:;
@@ -42553,14 +43656,12 @@ wuffs_png__decoder__decode_frame(
wuffs_png__decoder__filter_and_swizzle(self, a_dst, wuffs_base__slice_u8__subslice_j(a_workbuf, self->private_impl.f_workbuf_wi)); wuffs_png__decoder__filter_and_swizzle(self, a_dst, wuffs_base__slice_u8__subslice_j(a_workbuf, self->private_impl.f_workbuf_wi));
} }
if (v_status.repr == wuffs_base__suspension__short_read) { if (v_status.repr == wuffs_base__suspension__short_read) {
while (true) { status = wuffs_base__make_status(wuffs_png__error__truncated_input);
status = wuffs_base__make_status(wuffs_base__suspension__short_read); goto exit;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
}
} }
} }
status = v_status; status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
} }
label__1__break:; label__1__break:;
v_status = wuffs_png__decoder__filter_and_swizzle(self, a_dst, a_workbuf); v_status = wuffs_png__decoder__filter_and_swizzle(self, a_dst, a_workbuf);
@@ -42593,14 +43694,13 @@ wuffs_png__decoder__decode_frame(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit; goto exit;
exit: exit:
@@ -42608,9 +43708,6 @@ wuffs_png__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -42675,11 +43772,14 @@ wuffs_png__decoder__decode_pass(
self->private_impl.f_pass_workbuf_length), self->private_impl.f_pass_workbuf_length),
((uint64_t)(self->private_impl.f_workbuf_hist_pos_base + self->private_impl.f_workbuf_wi))); ((uint64_t)(self->private_impl.f_workbuf_hist_pos_base + self->private_impl.f_workbuf_wi)));
{ {
const bool o_1_closed_a_src = a_src->meta.closed;
const uint8_t *o_1_io2_a_src = io2_a_src; const uint8_t *o_1_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w)); v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
@@ -42702,6 +43802,7 @@ wuffs_png__decoder__decode_pass(
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_workbuf_wi, wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)))); wuffs_base__u64__sat_add_indirect(&self->private_impl.f_workbuf_wi, wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w))));
io2_a_src = o_1_io2_a_src; io2_a_src = o_1_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_1_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43112,6 +44213,53 @@ wuffs_png__decoder__tell_me_more(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_tell_me_more[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_tell_me_more
static wuffs_base__status
wuffs_png__decoder__do_tell_me_more(
wuffs_png__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint16_t v_c2 = 0; uint16_t v_c2 = 0;
wuffs_base__io_buffer u_w = wuffs_base__empty_io_buffer(); wuffs_base__io_buffer u_w = wuffs_base__empty_io_buffer();
@@ -43149,9 +44297,9 @@ wuffs_png__decoder__tell_me_more(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0]; uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
if (coro_susp_point) { if (coro_susp_point) {
v_zlib_status = self->private_data.s_tell_me_more[0].v_zlib_status; v_zlib_status = self->private_data.s_do_tell_me_more[0].v_zlib_status;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -43213,11 +44361,14 @@ wuffs_png__decoder__tell_me_more(
if (self->private_impl.f_metadata_is_zlib_compressed) { if (self->private_impl.f_metadata_is_zlib_compressed) {
if (self->private_impl.f_chunk_type == 1346585449) { if (self->private_impl.f_chunk_type == 1346585449) {
{ {
const bool o_0_closed_a_src = a_src->meta.closed;
const uint8_t *o_0_io2_a_src = io2_a_src; const uint8_t *o_0_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
{ {
@@ -43239,6 +44390,7 @@ wuffs_png__decoder__tell_me_more(
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295)))); wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
io2_a_src = o_0_io2_a_src; io2_a_src = o_0_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_0_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43259,11 +44411,14 @@ wuffs_png__decoder__tell_me_more(
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
} else if (self->private_impl.f_chunk_type == 1951945833) { } else if (self->private_impl.f_chunk_type == 1951945833) {
{ {
const bool o_1_closed_a_src = a_src->meta.closed;
const uint8_t *o_1_io2_a_src = io2_a_src; const uint8_t *o_1_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
{ {
@@ -43285,6 +44440,7 @@ wuffs_png__decoder__tell_me_more(
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295)))); wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
io2_a_src = o_1_io2_a_src; io2_a_src = o_1_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_1_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43320,11 +44476,14 @@ wuffs_png__decoder__tell_me_more(
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024), wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
self->private_impl.f_ztxt_hist_pos); self->private_impl.f_ztxt_hist_pos);
{ {
const bool o_3_closed_a_src = a_src->meta.closed;
const uint8_t *o_3_io2_a_src = io2_a_src; const uint8_t *o_3_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w)); v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
@@ -43344,6 +44503,7 @@ wuffs_png__decoder__tell_me_more(
v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w))); v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)));
io2_a_src = o_3_io2_a_src; io2_a_src = o_3_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_3_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43562,15 +44722,15 @@ wuffs_png__decoder__tell_me_more(
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
} }
self->private_data.s_tell_me_more[0].scratch = 4; self->private_data.s_do_tell_me_more[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
if (self->private_data.s_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_tell_me_more[0].scratch; iop_a_src += self->private_data.s_do_tell_me_more[0].scratch;
self->private_impl.f_metadata_flavor = 0; self->private_impl.f_metadata_flavor = 0;
self->private_impl.f_metadata_fourcc = 0; self->private_impl.f_metadata_fourcc = 0;
self->private_impl.f_metadata_x = 0; self->private_impl.f_metadata_x = 0;
@@ -43581,15 +44741,14 @@ wuffs_png__decoder__tell_me_more(
goto ok; goto ok;
ok: ok:
self->private_impl.p_tell_me_more[0] = 0; self->private_impl.p_do_tell_me_more[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0; self->private_data.s_do_tell_me_more[0].v_zlib_status = v_zlib_status;
self->private_data.s_tell_me_more[0].v_zlib_status = v_zlib_status;
goto exit; goto exit;
exit: exit:
@@ -43600,9 +44759,6 @@ wuffs_png__decoder__tell_me_more(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -43993,6 +45149,7 @@ wuffs_png__decoder__filter_and_swizzle_tricky(
const char wuffs_tga__error__bad_header[] = "#tga: bad header"; const char wuffs_tga__error__bad_header[] = "#tga: bad header";
const char wuffs_tga__error__bad_run_length_encoding[] = "#tga: bad run length encoding"; const char wuffs_tga__error__bad_run_length_encoding[] = "#tga: bad run length encoding";
const char wuffs_tga__error__truncated_input[] = "#tga: truncated input";
const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA file"; const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA file";
// ---------------- Private Consts // ---------------- Private Consts
@@ -44001,6 +45158,27 @@ const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA fil
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_tga__decoder__do_decode_image_config(
wuffs_tga__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame_config(
wuffs_tga__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame(
wuffs_tga__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
// ---------------- VTables // ---------------- VTables
const wuffs_base__image_decoder__func_ptrs const wuffs_base__image_decoder__func_ptrs
@@ -44146,6 +45324,52 @@ wuffs_tga__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.do_decode_image_config
static wuffs_base__status
wuffs_tga__decoder__do_decode_image_config(
wuffs_tga__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_c = 0; uint32_t v_c = 0;
uint32_t v_c5 = 0; uint32_t v_c5 = 0;
uint32_t v_i = 0; uint32_t v_i = 0;
@@ -44161,9 +45385,9 @@ wuffs_tga__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_i = self->private_data.s_decode_image_config[0].v_i; v_i = self->private_data.s_do_decode_image_config[0].v_i;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -44220,14 +45444,14 @@ wuffs_tga__decoder__decode_image_config(
t_3 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44249,14 +45473,14 @@ wuffs_tga__decoder__decode_image_config(
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src); t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44297,15 +45521,15 @@ wuffs_tga__decoder__decode_image_config(
goto exit; goto exit;
} }
} }
self->private_data.s_decode_image_config[0].scratch = 4; self->private_data.s_do_decode_image_config[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
uint32_t t_6; uint32_t t_6;
@@ -44313,14 +45537,14 @@ wuffs_tga__decoder__decode_image_config(
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44342,14 +45566,14 @@ wuffs_tga__decoder__decode_image_config(
t_7 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_7 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44429,15 +45653,15 @@ wuffs_tga__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_tga__error__unsupported_tga_file); status = wuffs_base__make_status(wuffs_tga__error__unsupported_tga_file);
goto exit; goto exit;
} }
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length)); self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length));
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
if (self->private_impl.f_header_color_map_type != 0) { if (self->private_impl.f_header_color_map_type != 0) {
while (v_i < ((uint32_t)(self->private_impl.f_header_color_map_length))) { while (v_i < ((uint32_t)(self->private_impl.f_header_color_map_length))) {
if (self->private_impl.f_header_color_map_entry_size == 24) { if (self->private_impl.f_header_color_map_entry_size == 24) {
@@ -44448,14 +45672,14 @@ wuffs_tga__decoder__decode_image_config(
t_10 = ((uint32_t)(wuffs_base__peek_u24le__no_bounds_check(iop_a_src))); t_10 = ((uint32_t)(wuffs_base__peek_u24le__no_bounds_check(iop_a_src)));
iop_a_src += 3; iop_a_src += 3;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(18); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(18);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44482,14 +45706,14 @@ wuffs_tga__decoder__decode_image_config(
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(20); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(20);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44516,14 +45740,14 @@ wuffs_tga__decoder__decode_image_config(
t_12 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_12 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(22); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(22);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44571,15 +45795,14 @@ wuffs_tga__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_decode_image_config[0].v_i = v_i;
self->private_data.s_decode_image_config[0].v_i = v_i;
goto exit; goto exit;
exit: exit:
@@ -44587,9 +45810,6 @@ wuffs_tga__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -44621,6 +45841,52 @@ wuffs_tga__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame_config(
wuffs_tga__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -44632,7 +45898,7 @@ wuffs_tga__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -44642,7 +45908,7 @@ wuffs_tga__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_tga__decoder__decode_image_config(self, NULL, a_src); status = wuffs_tga__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -44681,14 +45947,13 @@ wuffs_tga__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -44696,9 +45961,6 @@ wuffs_tga__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -44733,6 +45995,60 @@ wuffs_tga__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.do_decode_frame
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame(
wuffs_tga__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
wuffs_base__pixel_format v_dst_pixfmt = {0}; wuffs_base__pixel_format v_dst_pixfmt = {0};
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
@@ -44765,16 +46081,16 @@ wuffs_tga__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
if (coro_susp_point) { if (coro_susp_point) {
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel; v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x; v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y; v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
v_mark = self->private_data.s_decode_frame[0].v_mark; v_mark = self->private_data.s_do_decode_frame[0].v_mark;
v_num_pixels32 = self->private_data.s_decode_frame[0].v_num_pixels32; v_num_pixels32 = self->private_data.s_do_decode_frame[0].v_num_pixels32;
v_lit_length = self->private_data.s_decode_frame[0].v_lit_length; v_lit_length = self->private_data.s_do_decode_frame[0].v_lit_length;
v_run_length = self->private_data.s_decode_frame[0].v_run_length; v_run_length = self->private_data.s_do_decode_frame[0].v_run_length;
v_num_dst_bytes = self->private_data.s_decode_frame[0].v_num_dst_bytes; v_num_dst_bytes = self->private_data.s_do_decode_frame[0].v_num_dst_bytes;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -44785,7 +46101,7 @@ wuffs_tga__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_tga__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_tga__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -44848,15 +46164,15 @@ wuffs_tga__decoder__decode_frame(
v_num_pixels32 = ((uint32_t)(wuffs_base__u64__min(v_num_pixels64, ((uint64_t)(v_lit_length))))); v_num_pixels32 = ((uint32_t)(wuffs_base__u64__min(v_num_pixels64, ((uint64_t)(v_lit_length)))));
v_num_dst_bytes = (((uint64_t)(v_num_pixels32)) * v_dst_bytes_per_pixel); v_num_dst_bytes = (((uint64_t)(v_num_pixels32)) * v_dst_bytes_per_pixel);
v_num_src_bytes = (v_num_pixels32 * self->private_impl.f_src_bytes_per_pixel); v_num_src_bytes = (v_num_pixels32 * self->private_impl.f_src_bytes_per_pixel);
self->private_data.s_decode_frame[0].scratch = v_num_src_bytes; self->private_data.s_do_decode_frame[0].scratch = v_num_src_bytes;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, v_dst_palette, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_src - io0_a_src)), io0_a_src)); wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, v_dst_palette, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_src - io0_a_src)), io0_a_src));
if (v_num_dst_bytes <= ((uint64_t)(v_dst.len))) { if (v_num_dst_bytes <= ((uint64_t)(v_dst.len))) {
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_num_dst_bytes); v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_num_dst_bytes);
@@ -45021,22 +46337,21 @@ wuffs_tga__decoder__decode_frame(
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0; self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel; self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x; self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y; self->private_data.s_do_decode_frame[0].v_mark = v_mark;
self->private_data.s_decode_frame[0].v_mark = v_mark; self->private_data.s_do_decode_frame[0].v_num_pixels32 = v_num_pixels32;
self->private_data.s_decode_frame[0].v_num_pixels32 = v_num_pixels32; self->private_data.s_do_decode_frame[0].v_lit_length = v_lit_length;
self->private_data.s_decode_frame[0].v_lit_length = v_lit_length; self->private_data.s_do_decode_frame[0].v_run_length = v_run_length;
self->private_data.s_decode_frame[0].v_run_length = v_run_length; self->private_data.s_do_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
self->private_data.s_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
goto exit; goto exit;
exit: exit:
@@ -45044,9 +46359,6 @@ wuffs_tga__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -45227,6 +46539,7 @@ wuffs_tga__decoder__workbuf_len(
// ---------------- Status Codes Implementations // ---------------- Status Codes Implementations
const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header"; const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
const char wuffs_wbmp__error__truncated_input[] = "#wbmp: truncated input";
// ---------------- Private Consts // ---------------- Private Consts
@@ -45234,6 +46547,27 @@ const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_image_config(
wuffs_wbmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame_config(
wuffs_wbmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame(
wuffs_wbmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
// ---------------- VTables // ---------------- VTables
const wuffs_base__image_decoder__func_ptrs const wuffs_base__image_decoder__func_ptrs
@@ -45379,6 +46713,52 @@ wuffs_wbmp__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func wbmp.decoder.do_decode_image_config
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_image_config(
wuffs_wbmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint32_t v_i = 0; uint32_t v_i = 0;
uint32_t v_x32 = 0; uint32_t v_x32 = 0;
@@ -45395,10 +46775,10 @@ wuffs_wbmp__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_i = self->private_data.s_decode_image_config[0].v_i; v_i = self->private_data.s_do_decode_image_config[0].v_i;
v_x32 = self->private_data.s_decode_image_config[0].v_x32; v_x32 = self->private_data.s_do_decode_image_config[0].v_x32;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -45471,16 +46851,15 @@ wuffs_wbmp__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_decode_image_config[0].v_i = v_i;
self->private_data.s_decode_image_config[0].v_i = v_i; self->private_data.s_do_decode_image_config[0].v_x32 = v_x32;
self->private_data.s_decode_image_config[0].v_x32 = v_x32;
goto exit; goto exit;
exit: exit:
@@ -45488,9 +46867,6 @@ wuffs_wbmp__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -45522,6 +46898,52 @@ wuffs_wbmp__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func wbmp.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame_config(
wuffs_wbmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -45533,7 +46955,7 @@ wuffs_wbmp__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -45543,7 +46965,7 @@ wuffs_wbmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_wbmp__decoder__decode_image_config(self, NULL, a_src); status = wuffs_wbmp__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -45582,14 +47004,13 @@ wuffs_wbmp__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -45597,9 +47018,6 @@ wuffs_wbmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -45634,6 +47052,60 @@ wuffs_wbmp__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func wbmp.decoder.do_decode_frame
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame(
wuffs_wbmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
wuffs_base__pixel_format v_dst_pixfmt = {0}; wuffs_base__pixel_format v_dst_pixfmt = {0};
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
@@ -45657,13 +47129,13 @@ wuffs_wbmp__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
if (coro_susp_point) { if (coro_susp_point) {
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel; v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x; v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y; v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
memcpy(v_src, self->private_data.s_decode_frame[0].v_src, sizeof(v_src)); memcpy(v_src, self->private_data.s_do_decode_frame[0].v_src, sizeof(v_src));
v_c = self->private_data.s_decode_frame[0].v_c; v_c = self->private_data.s_do_decode_frame[0].v_c;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -45674,7 +47146,7 @@ wuffs_wbmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_wbmp__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_wbmp__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -45746,19 +47218,18 @@ wuffs_wbmp__decoder__decode_frame(
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0; self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel; self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x; self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y; memcpy(self->private_data.s_do_decode_frame[0].v_src, v_src, sizeof(v_src));
memcpy(self->private_data.s_decode_frame[0].v_src, v_src, sizeof(v_src)); self->private_data.s_do_decode_frame[0].v_c = v_c;
self->private_data.s_decode_frame[0].v_c = v_c;
goto exit; goto exit;
exit: exit:
@@ -45766,9 +47237,6 @@ wuffs_wbmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
+1947 -479
View File
@@ -85,15 +85,15 @@ extern "C" {
// each major.minor branch, the commit count should increase monotonically. // each major.minor branch, the commit count should increase monotonically.
// //
// WUFFS_VERSION was overridden by "wuffs gen -version" based on revision // WUFFS_VERSION was overridden by "wuffs gen -version" based on revision
// c698d81b4d6868f3c5e26d2d7c3b39fe97209ec0 committed on 2023-01-26. // 67d9a68c49c01319baf3590b5695cb954a09c2c6 committed on 2023-04-07.
#define WUFFS_VERSION 0x000030000 #define WUFFS_VERSION 0x000030002
#define WUFFS_VERSION_MAJOR 0 #define WUFFS_VERSION_MAJOR 0
#define WUFFS_VERSION_MINOR 3 #define WUFFS_VERSION_MINOR 3
#define WUFFS_VERSION_PATCH 0 #define WUFFS_VERSION_PATCH 2
#define WUFFS_VERSION_PRE_RELEASE_LABEL "" #define WUFFS_VERSION_PRE_RELEASE_LABEL ""
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3374 #define WUFFS_VERSION_BUILD_METADATA_COMMIT_COUNT 3396
#define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20230126 #define WUFFS_VERSION_BUILD_METADATA_COMMIT_DATE 20230407
#define WUFFS_VERSION_STRING "0.3.0+3374.20230126" #define WUFFS_VERSION_STRING "0.3.2+3396.20230407"
// ---------------- Configuration // ---------------- Configuration
@@ -6537,6 +6537,7 @@ struct wuffs_adler32__hasher__struct {
extern const char wuffs_bmp__error__bad_header[]; extern const char wuffs_bmp__error__bad_header[];
extern const char wuffs_bmp__error__bad_rle_compression[]; extern const char wuffs_bmp__error__bad_rle_compression[];
extern const char wuffs_bmp__error__truncated_input[];
extern const char wuffs_bmp__error__unsupported_bmp_file[]; extern const char wuffs_bmp__error__unsupported_bmp_file[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -6715,8 +6716,12 @@ struct wuffs_bmp__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
uint32_t p_tell_me_more[1];
uint32_t p_read_palette[1]; uint32_t p_read_palette[1];
} private_impl; } private_impl;
@@ -6726,10 +6731,10 @@ struct wuffs_bmp__decoder__struct {
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_frame[1]; } s_do_decode_frame[1];
struct { struct {
uint32_t v_i; uint32_t v_i;
uint64_t scratch; uint64_t scratch;
@@ -6894,6 +6899,7 @@ extern const char wuffs_bzip2__error__bad_block_length[];
extern const char wuffs_bzip2__error__bad_checksum[]; extern const char wuffs_bzip2__error__bad_checksum[];
extern const char wuffs_bzip2__error__bad_header[]; extern const char wuffs_bzip2__error__bad_header[];
extern const char wuffs_bzip2__error__bad_number_of_sections[]; extern const char wuffs_bzip2__error__bad_number_of_sections[];
extern const char wuffs_bzip2__error__truncated_input[];
extern const char wuffs_bzip2__error__unsupported_block_randomization[]; extern const char wuffs_bzip2__error__unsupported_block_randomization[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -7019,6 +7025,7 @@ struct wuffs_bzip2__decoder__struct {
uint32_t f_code_lengths_bitmask; uint32_t f_code_lengths_bitmask;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
uint32_t p_prepare_block[1]; uint32_t p_prepare_block[1];
uint32_t p_read_code_lengths[1]; uint32_t p_read_code_lengths[1];
uint32_t p_flush_slow[1]; uint32_t p_flush_slow[1];
@@ -7039,7 +7046,7 @@ struct wuffs_bzip2__decoder__struct {
uint32_t v_i; uint32_t v_i;
uint64_t v_tag; uint64_t v_tag;
uint32_t v_final_checksum_want; uint32_t v_final_checksum_want;
} s_transform_io[1]; } s_do_transform_io[1];
struct { struct {
uint32_t v_i; uint32_t v_i;
uint32_t v_selector; uint32_t v_selector;
@@ -7582,6 +7589,7 @@ extern const char wuffs_deflate__error__bad_literal_length_code_count[];
extern const char wuffs_deflate__error__inconsistent_stored_block_length[]; extern const char wuffs_deflate__error__inconsistent_stored_block_length[];
extern const char wuffs_deflate__error__missing_end_of_block_code[]; extern const char wuffs_deflate__error__missing_end_of_block_code[];
extern const char wuffs_deflate__error__no_huffman_codes[]; extern const char wuffs_deflate__error__no_huffman_codes[];
extern const char wuffs_deflate__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -7696,6 +7704,7 @@ struct wuffs_deflate__decoder__struct {
bool f_end_of_block; bool f_end_of_block;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
uint32_t p_decode_blocks[1]; uint32_t p_decode_blocks[1];
uint32_t p_decode_uncompressed[1]; uint32_t p_decode_uncompressed[1];
uint32_t p_init_dynamic_huffman[1]; uint32_t p_init_dynamic_huffman[1];
@@ -7844,6 +7853,7 @@ struct wuffs_deflate__decoder__struct {
// ---------------- Status Codes // ---------------- Status Codes
extern const char wuffs_lzw__error__bad_code[]; extern const char wuffs_lzw__error__bad_code[];
extern const char wuffs_lzw__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -8088,6 +8098,7 @@ extern const char wuffs_gif__error__bad_graphic_control[];
extern const char wuffs_gif__error__bad_header[]; extern const char wuffs_gif__error__bad_header[];
extern const char wuffs_gif__error__bad_literal_width[]; extern const char wuffs_gif__error__bad_literal_width[];
extern const char wuffs_gif__error__bad_palette[]; extern const char wuffs_gif__error__bad_palette[];
extern const char wuffs_gif__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -8288,10 +8299,14 @@ struct wuffs_gif__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_tell_me_more[1]; uint32_t p_tell_me_more[1];
uint32_t p_do_tell_me_more[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_skip_frame[1]; uint32_t p_skip_frame[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
uint32_t p_decode_up_to_id_part1[1]; uint32_t p_decode_up_to_id_part1[1];
uint32_t p_decode_header[1]; uint32_t p_decode_header[1];
uint32_t p_decode_lsd[1]; uint32_t p_decode_lsd[1];
@@ -8312,7 +8327,7 @@ struct wuffs_gif__decoder__struct {
struct { struct {
uint32_t v_background_color; uint32_t v_background_color;
} s_decode_frame_config[1]; } s_do_decode_frame_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_skip_frame[1]; } s_skip_frame[1];
@@ -8512,6 +8527,7 @@ extern const char wuffs_gzip__error__bad_checksum[];
extern const char wuffs_gzip__error__bad_compression_method[]; extern const char wuffs_gzip__error__bad_compression_method[];
extern const char wuffs_gzip__error__bad_encoding_flags[]; extern const char wuffs_gzip__error__bad_encoding_flags[];
extern const char wuffs_gzip__error__bad_header[]; extern const char wuffs_gzip__error__bad_header[];
extern const char wuffs_gzip__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -8616,6 +8632,7 @@ struct wuffs_gzip__decoder__struct {
bool f_ignore_checksum; bool f_ignore_checksum;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
} private_impl; } private_impl;
struct { struct {
@@ -8628,7 +8645,7 @@ struct wuffs_gzip__decoder__struct {
uint32_t v_decoded_length_got; uint32_t v_decoded_length_got;
uint32_t v_checksum_want; uint32_t v_checksum_want;
uint64_t scratch; uint64_t scratch;
} s_transform_io[1]; } s_do_transform_io[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -8997,6 +9014,7 @@ struct wuffs_json__decoder__struct {
// ---------------- Status Codes // ---------------- Status Codes
extern const char wuffs_nie__error__bad_header[]; extern const char wuffs_nie__error__bad_header[];
extern const char wuffs_nie__error__truncated_input[];
extern const char wuffs_nie__error__unsupported_nie_file[]; extern const char wuffs_nie__error__unsupported_nie_file[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -9157,14 +9175,17 @@ struct wuffs_nie__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
} private_impl; } private_impl;
struct { struct {
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -9324,6 +9345,7 @@ extern const char wuffs_zlib__error__bad_compression_method[];
extern const char wuffs_zlib__error__bad_compression_window_size[]; extern const char wuffs_zlib__error__bad_compression_window_size[];
extern const char wuffs_zlib__error__bad_parity_check[]; extern const char wuffs_zlib__error__bad_parity_check[];
extern const char wuffs_zlib__error__incorrect_dictionary[]; extern const char wuffs_zlib__error__incorrect_dictionary[];
extern const char wuffs_zlib__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -9446,6 +9468,7 @@ struct wuffs_zlib__decoder__struct {
uint32_t f_dict_id_want; uint32_t f_dict_id_want;
uint32_t p_transform_io[1]; uint32_t p_transform_io[1];
uint32_t p_do_transform_io[1];
} private_impl; } private_impl;
struct { struct {
@@ -9456,7 +9479,7 @@ struct wuffs_zlib__decoder__struct {
struct { struct {
uint32_t v_checksum_got; uint32_t v_checksum_got;
uint64_t scratch; uint64_t scratch;
} s_transform_io[1]; } s_do_transform_io[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -9570,6 +9593,7 @@ extern const char wuffs_png__error__bad_filter[];
extern const char wuffs_png__error__bad_header[]; extern const char wuffs_png__error__bad_header[];
extern const char wuffs_png__error__bad_text_chunk_not_latin_1[]; extern const char wuffs_png__error__bad_text_chunk_not_latin_1[];
extern const char wuffs_png__error__missing_palette[]; extern const char wuffs_png__error__missing_palette[];
extern const char wuffs_png__error__truncated_input[];
extern const char wuffs_png__error__unsupported_cgbi_extension[]; extern const char wuffs_png__error__unsupported_cgbi_extension[];
extern const char wuffs_png__error__unsupported_png_compression_method[]; extern const char wuffs_png__error__unsupported_png_compression_method[];
extern const char wuffs_png__error__unsupported_png_file[]; extern const char wuffs_png__error__unsupported_png_file[];
@@ -9806,6 +9830,7 @@ struct wuffs_png__decoder__struct {
wuffs_base__slice_u8 a_curr, wuffs_base__slice_u8 a_curr,
wuffs_base__slice_u8 a_prev); wuffs_base__slice_u8 a_prev);
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_ihdr[1]; uint32_t p_decode_ihdr[1];
uint32_t p_decode_other_chunk[1]; uint32_t p_decode_other_chunk[1];
uint32_t p_decode_actl[1]; uint32_t p_decode_actl[1];
@@ -9817,10 +9842,13 @@ struct wuffs_png__decoder__struct {
uint32_t p_decode_srgb[1]; uint32_t p_decode_srgb[1];
uint32_t p_decode_trns[1]; uint32_t p_decode_trns[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_skip_frame[1]; uint32_t p_skip_frame[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
uint32_t p_decode_pass[1]; uint32_t p_decode_pass[1];
uint32_t p_tell_me_more[1]; uint32_t p_tell_me_more[1];
uint32_t p_do_tell_me_more[1];
wuffs_base__status (*choosy_filter_and_swizzle)( wuffs_base__status (*choosy_filter_and_swizzle)(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__pixel_buffer* a_dst, wuffs_base__pixel_buffer* a_dst,
@@ -9836,7 +9864,7 @@ struct wuffs_png__decoder__struct {
struct { struct {
uint32_t v_checksum_have; uint32_t v_checksum_have;
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_ihdr[1]; } s_decode_ihdr[1];
@@ -9870,20 +9898,20 @@ struct wuffs_png__decoder__struct {
} s_decode_trns[1]; } s_decode_trns[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_frame_config[1]; } s_do_decode_frame_config[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_skip_frame[1]; } s_skip_frame[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_frame[1]; } s_do_decode_frame[1];
struct { struct {
uint64_t scratch; uint64_t scratch;
} s_decode_pass[1]; } s_decode_pass[1];
struct { struct {
wuffs_base__status v_zlib_status; wuffs_base__status v_zlib_status;
uint64_t scratch; uint64_t scratch;
} s_tell_me_more[1]; } s_do_tell_me_more[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -10039,6 +10067,7 @@ struct wuffs_png__decoder__struct {
extern const char wuffs_tga__error__bad_header[]; extern const char wuffs_tga__error__bad_header[];
extern const char wuffs_tga__error__bad_run_length_encoding[]; extern const char wuffs_tga__error__bad_run_length_encoding[];
extern const char wuffs_tga__error__truncated_input[];
extern const char wuffs_tga__error__unsupported_tga_file[]; extern const char wuffs_tga__error__unsupported_tga_file[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -10209,8 +10238,11 @@ struct wuffs_tga__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
} private_impl; } private_impl;
struct { struct {
@@ -10221,7 +10253,7 @@ struct wuffs_tga__decoder__struct {
struct { struct {
uint32_t v_i; uint32_t v_i;
uint64_t scratch; uint64_t scratch;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t v_dst_bytes_per_pixel; uint64_t v_dst_bytes_per_pixel;
uint32_t v_dst_x; uint32_t v_dst_x;
@@ -10232,7 +10264,7 @@ struct wuffs_tga__decoder__struct {
uint32_t v_run_length; uint32_t v_run_length;
uint64_t v_num_dst_bytes; uint64_t v_num_dst_bytes;
uint64_t scratch; uint64_t scratch;
} s_decode_frame[1]; } s_do_decode_frame[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -10387,6 +10419,7 @@ struct wuffs_tga__decoder__struct {
// ---------------- Status Codes // ---------------- Status Codes
extern const char wuffs_wbmp__error__bad_header[]; extern const char wuffs_wbmp__error__bad_header[];
extern const char wuffs_wbmp__error__truncated_input[];
// ---------------- Public Consts // ---------------- Public Consts
@@ -10544,22 +10577,25 @@ struct wuffs_wbmp__decoder__struct {
wuffs_base__pixel_swizzler f_swizzler; wuffs_base__pixel_swizzler f_swizzler;
uint32_t p_decode_image_config[1]; uint32_t p_decode_image_config[1];
uint32_t p_do_decode_image_config[1];
uint32_t p_decode_frame_config[1]; uint32_t p_decode_frame_config[1];
uint32_t p_do_decode_frame_config[1];
uint32_t p_decode_frame[1]; uint32_t p_decode_frame[1];
uint32_t p_do_decode_frame[1];
} private_impl; } private_impl;
struct { struct {
struct { struct {
uint32_t v_i; uint32_t v_i;
uint32_t v_x32; uint32_t v_x32;
} s_decode_image_config[1]; } s_do_decode_image_config[1];
struct { struct {
uint64_t v_dst_bytes_per_pixel; uint64_t v_dst_bytes_per_pixel;
uint32_t v_dst_x; uint32_t v_dst_x;
uint32_t v_dst_y; uint32_t v_dst_y;
uint8_t v_src[1]; uint8_t v_src[1];
uint8_t v_c; uint8_t v_c;
} s_decode_frame[1]; } s_do_decode_frame[1];
} private_data; } private_data;
#ifdef __cplusplus #ifdef __cplusplus
@@ -14746,6 +14782,27 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
// powers converts decimal powers of 10 to binary powers of 2. For example, // powers converts decimal powers of 10 to binary powers of 2. For example,
// (10000 >> 13) is 1. It stops before the elements exceed 60, also known // (10000 >> 13) is 1. It stops before the elements exceed 60, also known
// as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL. // as WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
//
// This rounds down (1<<13 is a lower bound for 1e4). Adding 1 to the array
// element value rounds up (1<<14 is an upper bound for 1e4) while staying
// at or below WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL.
//
// When starting in the range [1e+1 .. 1e+2] (i.e. h->decimal_point == +2),
// powers[2] == 6 and so:
// - Right shifting by 6+0 produces the range [10/64 .. 100/64] =
// [0.156250 .. 1.56250]. The resultant h->decimal_point is +0 or +1.
// - Right shifting by 6+1 produces the range [10/128 .. 100/128] =
// [0.078125 .. 0.78125]. The resultant h->decimal_point is -1 or -0.
//
// When starting in the range [1e-3 .. 1e-2] (i.e. h->decimal_point == -2),
// powers[2] == 6 and so:
// - Left shifting by 6+0 produces the range [0.001*64 .. 0.01*64] =
// [0.064 .. 0.64]. The resultant h->decimal_point is -1 or -0.
// - Left shifting by 6+1 produces the range [0.001*128 .. 0.01*128] =
// [0.128 .. 1.28]. The resultant h->decimal_point is +0 or +1.
//
// Thus, when targeting h->decimal_point being +0 or +1, use (powers[n]+0)
// when right shifting but (powers[n]+1) when left shifting.
static const uint32_t num_powers = 19; static const uint32_t num_powers = 19;
static const uint8_t powers[19] = { static const uint8_t powers[19] = {
0, 3, 6, 9, 13, 16, 19, 23, 26, 29, // 0, 3, 6, 9, 13, 16, 19, 23, 26, 29, //
@@ -14789,12 +14846,13 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
// When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See // When Eisel-Lemire fails, fall back to Simple Decimal Conversion. See
// https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html // https://nigeltao.github.io/blog/2020/parse-number-f64-simple.html
// //
// Scale by powers of 2 until we're in the range [½ .. 1], which gives us // Scale by powers of 2 until we're in the range [0.1 .. 10]. Equivalently,
// our exponent (in base-2). First we shift right, possibly a little too // that h->decimal_point is +0 or +1.
// far, ending with a value certainly below 1 and possibly below ½... //
// First we shift right while at or above 10...
const int32_t f64_bias = -1023; const int32_t f64_bias = -1023;
int32_t exp2 = 0; int32_t exp2 = 0;
while (h->decimal_point > 0) { while (h->decimal_point > 1) {
uint32_t n = (uint32_t)(+h->decimal_point); uint32_t n = (uint32_t)(+h->decimal_point);
uint32_t shift = uint32_t shift =
(n < num_powers) (n < num_powers)
@@ -14808,20 +14866,15 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
} }
exp2 += (int32_t)shift; exp2 += (int32_t)shift;
} }
// ...then we shift left, putting us in [½ .. 1]. // ...then we shift left while below 0.1.
while (h->decimal_point <= 0) { while (h->decimal_point < 0) {
uint32_t shift; uint32_t shift;
if (h->decimal_point == 0) { uint32_t n = (uint32_t)(-h->decimal_point);
if (h->digits[0] >= 5) { shift = (n < num_powers)
break; // The +1 is per "when targeting h->decimal_point being +0 or
} // +1... when left shifting" in the powers comment above.
shift = (h->digits[0] < 2) ? 2 : 1; ? (powers[n] + 1)
} else { : WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
uint32_t n = (uint32_t)(-h->decimal_point);
shift = (n < num_powers)
? powers[n]
: WUFFS_BASE__PRIVATE_IMPLEMENTATION__HPD__SHIFT__MAX_INCL;
}
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift); wuffs_base__private_implementation__high_prec_dec__small_lshift(h, shift);
if (h->decimal_point > if (h->decimal_point >
@@ -14831,8 +14884,37 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
exp2 -= (int32_t)shift; exp2 -= (int32_t)shift;
} }
// We're in the range [½ .. 1] but f64 uses [1 .. 2]. // To get from "in the range [0.1 .. 10]" to "in the range [1 .. 2]" (which
exp2--; // will give us our exponent in base-2), the mantissa's first 3 digits will
// determine the final left shift, equal to 52 (the number of explicit f64
// bits) plus an additional adjustment.
int man3 = (100 * h->digits[0]) +
((h->num_digits > 1) ? (10 * h->digits[1]) : 0) +
((h->num_digits > 2) ? h->digits[2] : 0);
int32_t additional_lshift = 0;
if (h->decimal_point == 0) { // The value is in [0.1 .. 1].
if (man3 < 125) {
additional_lshift = +4;
} else if (man3 < 250) {
additional_lshift = +3;
} else if (man3 < 500) {
additional_lshift = +2;
} else {
additional_lshift = +1;
}
} else { // The value is in [1 .. 10].
if (man3 < 200) {
additional_lshift = -0;
} else if (man3 < 400) {
additional_lshift = -1;
} else if (man3 < 800) {
additional_lshift = -2;
} else {
additional_lshift = -3;
}
}
exp2 -= additional_lshift;
uint32_t final_lshift = (uint32_t)(52 + additional_lshift);
// The minimum normal exponent is (f64_bias + 1). // The minimum normal exponent is (f64_bias + 1).
while ((f64_bias + 1) > exp2) { while ((f64_bias + 1) > exp2) {
@@ -14850,7 +14932,8 @@ wuffs_base__private_implementation__high_prec_dec__to_f64(
} }
// Extract 53 bits for the mantissa (in base-2). // Extract 53 bits for the mantissa (in base-2).
wuffs_base__private_implementation__high_prec_dec__small_lshift(h, 53); wuffs_base__private_implementation__high_prec_dec__small_lshift(
h, final_lshift);
uint64_t man2 = uint64_t man2 =
wuffs_base__private_implementation__high_prec_dec__rounded_integer(h); wuffs_base__private_implementation__high_prec_dec__rounded_integer(h);
@@ -22533,6 +22616,7 @@ wuffs_adler32__hasher__up_x86_sse42(
const char wuffs_bmp__error__bad_header[] = "#bmp: bad header"; const char wuffs_bmp__error__bad_header[] = "#bmp: bad header";
const char wuffs_bmp__error__bad_rle_compression[] = "#bmp: bad RLE compression"; const char wuffs_bmp__error__bad_rle_compression[] = "#bmp: bad RLE compression";
const char wuffs_bmp__error__truncated_input[] = "#bmp: truncated input";
const char wuffs_bmp__error__unsupported_bmp_file[] = "#bmp: unsupported BMP file"; const char wuffs_bmp__error__unsupported_bmp_file[] = "#bmp: unsupported BMP file";
const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: short read"; const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: short read";
@@ -22570,6 +22654,27 @@ const char wuffs_bmp__note__internal_note_short_read[] = "@bmp: internal note: s
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_bmp__decoder__do_decode_image_config(
wuffs_bmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame_config(
wuffs_bmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame(
wuffs_bmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__status static wuffs_base__status
wuffs_bmp__decoder__swizzle_none( wuffs_bmp__decoder__swizzle_none(
wuffs_bmp__decoder* self, wuffs_bmp__decoder* self,
@@ -22594,6 +22699,13 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
wuffs_base__pixel_buffer* a_dst, wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_bmp__decoder__do_tell_me_more(
wuffs_bmp__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_bmp__decoder__read_palette( wuffs_bmp__decoder__read_palette(
wuffs_bmp__decoder* self, wuffs_bmp__decoder* self,
@@ -22748,6 +22860,52 @@ wuffs_bmp__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_decode_image_config
static wuffs_base__status
wuffs_bmp__decoder__do_decode_image_config(
wuffs_bmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_magic = 0; uint32_t v_magic = 0;
uint32_t v_width = 0; uint32_t v_width = 0;
uint32_t v_height = 0; uint32_t v_height = 0;
@@ -22766,7 +22924,7 @@ wuffs_bmp__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -22784,14 +22942,14 @@ wuffs_bmp__decoder__decode_image_config(
t_0 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_0 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22810,15 +22968,15 @@ wuffs_bmp__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_bmp__error__bad_header); status = wuffs_base__make_status(wuffs_bmp__error__bad_header);
goto exit; goto exit;
} }
self->private_data.s_decode_image_config[0].scratch = 8; self->private_data.s_do_decode_image_config[0].scratch = 8;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(3);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
uint32_t t_1; uint32_t t_1;
@@ -22826,14 +22984,14 @@ wuffs_bmp__decoder__decode_image_config(
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22861,14 +23019,14 @@ wuffs_bmp__decoder__decode_image_config(
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22896,14 +23054,14 @@ wuffs_bmp__decoder__decode_image_config(
t_3 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_3 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22925,14 +23083,14 @@ wuffs_bmp__decoder__decode_image_config(
t_4 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_4 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22954,14 +23112,14 @@ wuffs_bmp__decoder__decode_image_config(
t_5 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_5 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_5 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_5 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -22987,14 +23145,14 @@ wuffs_bmp__decoder__decode_image_config(
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(15);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23017,14 +23175,14 @@ wuffs_bmp__decoder__decode_image_config(
t_7 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_7 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(17); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(17);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23051,14 +23209,14 @@ wuffs_bmp__decoder__decode_image_config(
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(19); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(19);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23085,14 +23243,14 @@ wuffs_bmp__decoder__decode_image_config(
t_9 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_9 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(21); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(21);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23118,14 +23276,14 @@ wuffs_bmp__decoder__decode_image_config(
t_10 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_10 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(23); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(23);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23148,14 +23306,14 @@ wuffs_bmp__decoder__decode_image_config(
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(25); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(25);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23182,14 +23340,14 @@ wuffs_bmp__decoder__decode_image_config(
t_12 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_12 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(27); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(27);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23220,14 +23378,14 @@ wuffs_bmp__decoder__decode_image_config(
t_13 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_13 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(29); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(29);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_13 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_13 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23253,14 +23411,14 @@ wuffs_bmp__decoder__decode_image_config(
t_14 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_14 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(31); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(31);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_14 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_14 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23282,14 +23440,14 @@ wuffs_bmp__decoder__decode_image_config(
t_15 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_15 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(33); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(33);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_15 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_15 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23317,15 +23475,15 @@ wuffs_bmp__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file); status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit; goto exit;
} }
self->private_data.s_decode_image_config[0].scratch = 20; self->private_data.s_do_decode_image_config[0].scratch = 20;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(34); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(34);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
if (self->private_impl.f_bitmap_info_len == 40) { if (self->private_impl.f_bitmap_info_len == 40) {
if (self->private_impl.f_bits_per_pixel >= 16) { if (self->private_impl.f_bits_per_pixel >= 16) {
if (self->private_impl.f_padding >= 16) { if (self->private_impl.f_padding >= 16) {
@@ -23356,14 +23514,14 @@ wuffs_bmp__decoder__decode_image_config(
t_16 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_16 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(36); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(36);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_16 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_16 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23385,14 +23543,14 @@ wuffs_bmp__decoder__decode_image_config(
t_17 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_17 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(38); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(38);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_17 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_17 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23414,14 +23572,14 @@ wuffs_bmp__decoder__decode_image_config(
t_18 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_18 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(40); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(40);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_18 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_18 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23444,14 +23602,14 @@ wuffs_bmp__decoder__decode_image_config(
t_19 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_19 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(42); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(42);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_19 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_19 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -23466,15 +23624,15 @@ wuffs_bmp__decoder__decode_image_config(
} }
self->private_impl.f_channel_masks[3] = t_19; self->private_impl.f_channel_masks[3] = t_19;
} }
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56)); self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_bitmap_info_len - 56));
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(43); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(43);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
} }
if ((self->private_impl.f_channel_masks[0] == 255) && (self->private_impl.f_channel_masks[1] == 65280) && (self->private_impl.f_channel_masks[2] == 16711680)) { if ((self->private_impl.f_channel_masks[0] == 255) && (self->private_impl.f_channel_masks[1] == 65280) && (self->private_impl.f_channel_masks[2] == 16711680)) {
if (self->private_impl.f_bits_per_pixel == 24) { if (self->private_impl.f_bits_per_pixel == 24) {
@@ -23492,15 +23650,15 @@ wuffs_bmp__decoder__decode_image_config(
} }
} }
} else if (self->private_impl.f_bitmap_info_len >= 40) { } else if (self->private_impl.f_bitmap_info_len >= 40) {
self->private_data.s_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40); self->private_data.s_do_decode_image_config[0].scratch = (self->private_impl.f_bitmap_info_len - 40);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(45);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
} else { } else {
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file); status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit; goto exit;
@@ -23623,14 +23781,13 @@ wuffs_bmp__decoder__decode_image_config(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
@@ -23638,9 +23795,6 @@ wuffs_bmp__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -23672,6 +23826,52 @@ wuffs_bmp__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame_config(
wuffs_bmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -23683,7 +23883,7 @@ wuffs_bmp__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -23693,7 +23893,7 @@ wuffs_bmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_bmp__decoder__decode_image_config(self, NULL, a_src); status = wuffs_bmp__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -23732,14 +23932,13 @@ wuffs_bmp__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -23747,9 +23946,6 @@ wuffs_bmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -23786,6 +23982,60 @@ wuffs_bmp__decoder__decode_frame(
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_decode_frame
static wuffs_base__status
wuffs_bmp__decoder__do_decode_frame(
wuffs_bmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -23797,7 +24047,7 @@ wuffs_bmp__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -23807,7 +24057,7 @@ wuffs_bmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_bmp__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_bmp__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -23818,15 +24068,15 @@ wuffs_bmp__decoder__decode_frame(
status = wuffs_base__make_status(wuffs_base__note__end_of_data); status = wuffs_base__make_status(wuffs_base__note__end_of_data);
goto ok; goto ok;
} }
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_padding; self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_padding;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
if ((self->private_impl.f_width > 0) && (self->private_impl.f_height > 0)) { if ((self->private_impl.f_width > 0) && (self->private_impl.f_height > 0)) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
if (self->private_impl.f_top_down) { if (self->private_impl.f_top_down) {
@@ -23902,28 +24152,27 @@ wuffs_bmp__decoder__decode_frame(
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(3);
} }
label__0__break:; label__0__break:;
self->private_data.s_decode_frame[0].scratch = self->private_impl.f_pending_pad; self->private_data.s_do_decode_frame[0].scratch = self->private_impl.f_pending_pad;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
self->private_impl.f_pending_pad = 0; self->private_impl.f_pending_pad = 0;
} }
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit; goto exit;
exit: exit:
@@ -23931,9 +24180,6 @@ wuffs_bmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -23950,10 +24196,12 @@ wuffs_bmp__decoder__swizzle_none(
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
uint64_t v_dst_bytes_per_pixel = 0; uint64_t v_dst_bytes_per_pixel = 0;
uint64_t v_dst_bytes_per_row = 0; uint64_t v_dst_bytes_per_row = 0;
uint32_t v_src_bytes_per_pixel = 0;
wuffs_base__slice_u8 v_dst_palette = {0}; wuffs_base__slice_u8 v_dst_palette = {0};
wuffs_base__table_u8 v_tab = {0}; wuffs_base__table_u8 v_tab = {0};
wuffs_base__slice_u8 v_dst = {0}; wuffs_base__slice_u8 v_dst = {0};
uint64_t v_i = 0; uint64_t v_i = 0;
uint64_t v_j = 0;
uint64_t v_n = 0; uint64_t v_n = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -23987,7 +24235,6 @@ wuffs_bmp__decoder__swizzle_none(
self->private_impl.f_pending_pad -= 1; self->private_impl.f_pending_pad -= 1;
iop_a_src += 1; iop_a_src += 1;
} }
label__inner__continue:;
while (true) { while (true) {
if (self->private_impl.f_dst_x == self->private_impl.f_width) { if (self->private_impl.f_dst_x == self->private_impl.f_width) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
@@ -24008,14 +24255,38 @@ wuffs_bmp__decoder__swizzle_none(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
goto label__inner__continue; if (self->private_impl.f_bits_per_pixel > 32) {
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit;
}
v_src_bytes_per_pixel = (self->private_impl.f_bits_per_pixel / 8);
if (v_src_bytes_per_pixel == 0) {
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
goto exit;
}
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
v_j = v_n;
while (v_j >= 8) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
iop_a_src += (v_src_bytes_per_pixel * 8);
}
v_j -= 8;
}
while (v_j > 0) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
iop_a_src += (v_src_bytes_per_pixel * 1);
}
v_j -= 1;
}
} else {
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
v_dst_palette,
&iop_a_src,
io2_a_src);
} }
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
v_dst_palette,
&iop_a_src,
io2_a_src);
if (v_n == 0) { if (v_n == 0) {
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read); status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
goto ok; goto ok;
@@ -24356,7 +24627,6 @@ wuffs_bmp__decoder__swizzle_bitfields(
self->private_impl.f_pending_pad -= 1; self->private_impl.f_pending_pad -= 1;
iop_a_src += 1; iop_a_src += 1;
} }
label__inner__continue:;
while (true) { while (true) {
if (self->private_impl.f_dst_x == self->private_impl.f_width) { if (self->private_impl.f_dst_x == self->private_impl.f_width) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
@@ -24415,9 +24685,10 @@ wuffs_bmp__decoder__swizzle_bitfields(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
goto label__inner__continue; v_n = ((uint64_t)(v_p0));
} else {
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
} }
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, wuffs_base__slice_u8__subslice_i(v_dst, v_i), v_dst_palette, wuffs_base__make_slice_u8(self->private_data.f_scratch, (8 * v_p0)));
if (v_n == 0) { if (v_n == 0) {
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read); status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
goto ok; goto ok;
@@ -24460,6 +24731,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
uint32_t v_p0 = 0; uint32_t v_p0 = 0;
uint32_t v_chunk_bits = 0; uint32_t v_chunk_bits = 0;
uint32_t v_chunk_count = 0; uint32_t v_chunk_count = 0;
uint32_t v_pixels_per_chunk = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -24497,6 +24769,35 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
if (self->private_impl.f_bits_per_pixel == 1) {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 31) / 32);
v_pixels_per_chunk = 32;
} else if (self->private_impl.f_bits_per_pixel == 2) {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 15) / 16);
v_pixels_per_chunk = 16;
} else {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
v_pixels_per_chunk = 8;
}
while ((v_chunk_count >= 64) && (((uint64_t)(io2_a_src - iop_a_src)) >= 256)) {
iop_a_src += 256;
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 64))));
v_chunk_count -= 64;
}
while ((v_chunk_count >= 8) && (((uint64_t)(io2_a_src - iop_a_src)) >= 32)) {
iop_a_src += 32;
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 8))));
v_chunk_count -= 8;
}
while (v_chunk_count > 0) {
if (((uint64_t)(io2_a_src - iop_a_src)) < 4) {
status = wuffs_base__make_status(wuffs_bmp__note__internal_note_short_read);
goto ok;
}
iop_a_src += 4;
self->private_impl.f_dst_x = wuffs_base__u32__min(self->private_impl.f_width, ((uint32_t)(self->private_impl.f_dst_x + (v_pixels_per_chunk * 1))));
v_chunk_count -= 1;
}
goto label__loop__continue; goto label__loop__continue;
} }
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_i); v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_i);
@@ -24567,7 +24868,7 @@ wuffs_bmp__decoder__swizzle_low_bit_depth(
v_p0 = ((v_p0 & 511) + 16); v_p0 = ((v_p0 & 511) + 16);
v_chunk_count -= 1; v_chunk_count -= 1;
} }
} else if (self->private_impl.f_bits_per_pixel == 4) { } else {
v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8); v_chunk_count = ((wuffs_base__u32__sat_sub(self->private_impl.f_width, self->private_impl.f_dst_x) + 7) / 8);
v_chunk_count = wuffs_base__u32__min(v_chunk_count, 64); v_chunk_count = wuffs_base__u32__min(v_chunk_count, 64);
while ((v_chunk_count > 0) && (((uint64_t)(io2_a_src - iop_a_src)) >= 4)) { while ((v_chunk_count > 0) && (((uint64_t)(io2_a_src - iop_a_src)) >= 4)) {
@@ -24748,6 +25049,53 @@ wuffs_bmp__decoder__tell_me_more(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bmp__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_tell_me_more[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bmp.decoder.do_tell_me_more
static wuffs_base__status
wuffs_bmp__decoder__do_tell_me_more(
wuffs_bmp__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
if (self->private_impl.f_io_redirect_fourcc <= 1) { if (self->private_impl.f_io_redirect_fourcc <= 1) {
status = wuffs_base__make_status(wuffs_base__error__no_more_information); status = wuffs_base__make_status(wuffs_base__error__no_more_information);
goto exit; goto exit;
@@ -24766,9 +25114,6 @@ wuffs_bmp__decoder__tell_me_more(
ok: ok:
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -24981,6 +25326,7 @@ const char wuffs_bzip2__error__bad_block_length[] = "#bzip2: bad block length";
const char wuffs_bzip2__error__bad_checksum[] = "#bzip2: bad checksum"; const char wuffs_bzip2__error__bad_checksum[] = "#bzip2: bad checksum";
const char wuffs_bzip2__error__bad_header[] = "#bzip2: bad header"; const char wuffs_bzip2__error__bad_header[] = "#bzip2: bad header";
const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections"; const char wuffs_bzip2__error__bad_number_of_sections[] = "#bzip2: bad number of sections";
const char wuffs_bzip2__error__truncated_input[] = "#bzip2: truncated input";
const char wuffs_bzip2__error__unsupported_block_randomization[] = "#bzip2: unsupported block randomization"; const char wuffs_bzip2__error__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"; const char wuffs_bzip2__error__internal_error_inconsistent_huffman_decoder_state[] = "#bzip2: internal error: inconsistent Huffman decoder state";
@@ -25031,6 +25377,13 @@ WUFFS_BZIP2__REV_CRC32_TABLE[256] WUFFS_BASE__POTENTIALLY_UNUSED = {
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_bzip2__decoder__do_transform_io(
wuffs_bzip2__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
static wuffs_base__status static wuffs_base__status
wuffs_bzip2__decoder__prepare_block( wuffs_bzip2__decoder__prepare_block(
wuffs_bzip2__decoder* self, wuffs_bzip2__decoder* self,
@@ -25225,6 +25578,53 @@ wuffs_bzip2__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_bzip2__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_bzip2__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func bzip2.decoder.do_transform_io
static wuffs_base__status
wuffs_bzip2__decoder__do_transform_io(
wuffs_bzip2__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint32_t v_i = 0; uint32_t v_i = 0;
uint64_t v_tag = 0; uint64_t v_tag = 0;
@@ -25242,11 +25642,11 @@ wuffs_bzip2__decoder__transform_io(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
if (coro_susp_point) { if (coro_susp_point) {
v_i = self->private_data.s_transform_io[0].v_i; v_i = self->private_data.s_do_transform_io[0].v_i;
v_tag = self->private_data.s_transform_io[0].v_tag; v_tag = self->private_data.s_do_transform_io[0].v_tag;
v_final_checksum_want = self->private_data.s_transform_io[0].v_final_checksum_want; v_final_checksum_want = self->private_data.s_do_transform_io[0].v_final_checksum_want;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -25435,17 +25835,16 @@ wuffs_bzip2__decoder__transform_io(
goto ok; goto ok;
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_transform_io[0].v_i = v_i;
self->private_data.s_transform_io[0].v_i = v_i; self->private_data.s_do_transform_io[0].v_tag = v_tag;
self->private_data.s_transform_io[0].v_tag = v_tag; self->private_data.s_do_transform_io[0].v_final_checksum_want = v_final_checksum_want;
self->private_data.s_transform_io[0].v_final_checksum_want = v_final_checksum_want;
goto exit; goto exit;
exit: exit:
@@ -25453,9 +25852,6 @@ wuffs_bzip2__decoder__transform_io(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -28418,6 +28814,7 @@ const char wuffs_deflate__error__bad_literal_length_code_count[] = "#deflate: ba
const char wuffs_deflate__error__inconsistent_stored_block_length[] = "#deflate: inconsistent stored block length"; const char wuffs_deflate__error__inconsistent_stored_block_length[] = "#deflate: inconsistent stored block length";
const char wuffs_deflate__error__missing_end_of_block_code[] = "#deflate: missing end-of-block code"; const char wuffs_deflate__error__missing_end_of_block_code[] = "#deflate: missing end-of-block code";
const char wuffs_deflate__error__no_huffman_codes[] = "#deflate: no Huffman codes"; const char wuffs_deflate__error__no_huffman_codes[] = "#deflate: no Huffman codes";
const char wuffs_deflate__error__truncated_input[] = "#deflate: truncated input";
const char wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state[] = "#deflate: internal error: inconsistent Huffman decoder state"; const char wuffs_deflate__error__internal_error_inconsistent_huffman_decoder_state[] = "#deflate: internal error: inconsistent Huffman decoder state";
const char wuffs_deflate__error__internal_error_inconsistent_i_o[] = "#deflate: internal error: inconsistent I/O"; const char wuffs_deflate__error__internal_error_inconsistent_i_o[] = "#deflate: internal error: inconsistent I/O";
const char wuffs_deflate__error__internal_error_inconsistent_distance[] = "#deflate: internal error: inconsistent distance"; const char wuffs_deflate__error__internal_error_inconsistent_distance[] = "#deflate: internal error: inconsistent distance";
@@ -28492,6 +28889,13 @@ WUFFS_DEFLATE__DCODE_MAGIC_NUMBERS[32] WUFFS_BASE__POTENTIALLY_UNUSED = {
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_deflate__decoder__do_transform_io(
wuffs_deflate__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
static wuffs_base__status static wuffs_base__status
wuffs_deflate__decoder__decode_blocks( wuffs_deflate__decoder__decode_blocks(
wuffs_deflate__decoder* self, wuffs_deflate__decoder* self,
@@ -28735,6 +29139,53 @@ wuffs_deflate__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_deflate__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_deflate__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func deflate.decoder.do_transform_io
static wuffs_base__status
wuffs_deflate__decoder__do_transform_io(
wuffs_deflate__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint64_t v_mark = 0; uint64_t v_mark = 0;
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
@@ -28752,7 +29203,7 @@ wuffs_deflate__decoder__transform_io(
} }
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -28790,14 +29241,13 @@ wuffs_deflate__decoder__transform_io(
} }
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
@@ -28805,9 +29255,6 @@ wuffs_deflate__decoder__transform_io(
a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr)); a_dst->meta.wi = ((size_t)(iop_a_dst - a_dst->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -30681,6 +31128,7 @@ wuffs_deflate__decoder__decode_huffman_slow(
// ---------------- Status Codes Implementations // ---------------- Status Codes Implementations
const char wuffs_lzw__error__bad_code[] = "#lzw: bad code"; const char wuffs_lzw__error__bad_code[] = "#lzw: bad code";
const char wuffs_lzw__error__truncated_input[] = "#lzw: truncated input";
const char wuffs_lzw__error__internal_error_inconsistent_i_o[] = "#lzw: internal error: inconsistent I/O"; const char wuffs_lzw__error__internal_error_inconsistent_i_o[] = "#lzw: internal error: inconsistent I/O";
// ---------------- Private Consts // ---------------- Private Consts
@@ -30903,6 +31351,9 @@ wuffs_lzw__decoder__transform_io(
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
} else if (self->private_impl.f_read_from_return_value == 3) { } else if (self->private_impl.f_read_from_return_value == 3) {
status = wuffs_base__make_status(wuffs_lzw__error__truncated_input);
goto exit;
} else if (self->private_impl.f_read_from_return_value == 4) {
status = wuffs_base__make_status(wuffs_lzw__error__bad_code); status = wuffs_base__make_status(wuffs_lzw__error__bad_code);
goto exit; goto exit;
} else { } else {
@@ -30978,7 +31429,11 @@ wuffs_lzw__decoder__read_from(
iop_a_src += ((31 - v_n_bits) >> 3); iop_a_src += ((31 - v_n_bits) >> 3);
v_n_bits |= 24; v_n_bits |= 24;
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) { } else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
self->private_impl.f_read_from_return_value = 2; if (a_src && a_src->meta.closed) {
self->private_impl.f_read_from_return_value = 3;
} else {
self->private_impl.f_read_from_return_value = 2;
}
goto label__0__break; goto label__0__break;
} else { } else {
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits); v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
@@ -30986,14 +31441,18 @@ wuffs_lzw__decoder__read_from(
v_n_bits += 8; v_n_bits += 8;
if (v_n_bits >= v_width) { if (v_n_bits >= v_width) {
} else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) { } else if (((uint64_t)(io2_a_src - iop_a_src)) <= 0) {
self->private_impl.f_read_from_return_value = 2; if (a_src && a_src->meta.closed) {
self->private_impl.f_read_from_return_value = 3;
} else {
self->private_impl.f_read_from_return_value = 2;
}
goto label__0__break; goto label__0__break;
} else { } else {
v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits); v_bits |= (((uint32_t)(wuffs_base__peek_u8be__no_bounds_check(iop_a_src))) << v_n_bits);
iop_a_src += 1; iop_a_src += 1;
v_n_bits += 8; v_n_bits += 8;
if (v_n_bits < v_width) { if (v_n_bits < v_width) {
self->private_impl.f_read_from_return_value = 4; self->private_impl.f_read_from_return_value = 5;
goto label__0__break; goto label__0__break;
} }
} }
@@ -31071,7 +31530,7 @@ wuffs_lzw__decoder__read_from(
v_prev_code = v_code; v_prev_code = v_code;
} }
} else { } else {
self->private_impl.f_read_from_return_value = 3; self->private_impl.f_read_from_return_value = 4;
goto label__0__break; goto label__0__break;
} }
if (v_output_wi > 4095) { if (v_output_wi > 4095) {
@@ -31086,7 +31545,7 @@ wuffs_lzw__decoder__read_from(
if (iop_a_src > io1_a_src) { if (iop_a_src > io1_a_src) {
iop_a_src--; iop_a_src--;
} else { } else {
self->private_impl.f_read_from_return_value = 4; self->private_impl.f_read_from_return_value = 5;
goto label__2__break; goto label__2__break;
} }
} }
@@ -31208,6 +31667,7 @@ const char wuffs_gif__error__bad_graphic_control[] = "#gif: bad graphic control"
const char wuffs_gif__error__bad_header[] = "#gif: bad header"; const char wuffs_gif__error__bad_header[] = "#gif: bad header";
const char wuffs_gif__error__bad_literal_width[] = "#gif: bad literal width"; const char wuffs_gif__error__bad_literal_width[] = "#gif: bad literal width";
const char wuffs_gif__error__bad_palette[] = "#gif: bad palette"; const char wuffs_gif__error__bad_palette[] = "#gif: bad palette";
const char wuffs_gif__error__truncated_input[] = "#gif: truncated input";
const char wuffs_gif__error__internal_error_inconsistent_ri_wi[] = "#gif: internal error: inconsistent ri/wi"; const char wuffs_gif__error__internal_error_inconsistent_ri_wi[] = "#gif: internal error: inconsistent ri/wi";
// ---------------- Private Consts // ---------------- Private Consts
@@ -31259,11 +31719,39 @@ WUFFS_GIF__XMPDATAXMP[11] WUFFS_BASE__POTENTIALLY_UNUSED = {
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_gif__decoder__do_decode_image_config(
wuffs_gif__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_gif__decoder__do_tell_me_more(
wuffs_gif__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame_config(
wuffs_gif__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_gif__decoder__skip_frame( wuffs_gif__decoder__skip_frame(
wuffs_gif__decoder* self, wuffs_gif__decoder* self,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame(
wuffs_gif__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__empty_struct static wuffs_base__empty_struct
wuffs_gif__decoder__reset_gc( wuffs_gif__decoder__reset_gc(
wuffs_gif__decoder* self); wuffs_gif__decoder* self);
@@ -31493,12 +31981,58 @@ wuffs_gif__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
bool v_ffio = false; wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_decode_image_config
static wuffs_base__status
wuffs_gif__decoder__do_decode_image_config(
wuffs_gif__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
bool v_ffio = false;
uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence != 0) { if (self->private_impl.f_call_sequence != 0) {
status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence); status = wuffs_base__make_status(wuffs_base__error__bad_call_sequence);
goto exit; goto exit;
@@ -31549,20 +32083,16 @@ wuffs_gif__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -31617,6 +32147,53 @@ wuffs_gif__decoder__tell_me_more(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_tell_me_more[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_tell_me_more
static wuffs_base__status
wuffs_gif__decoder__do_tell_me_more(
wuffs_gif__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint64_t v_chunk_length = 0; uint64_t v_chunk_length = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -31630,7 +32207,7 @@ wuffs_gif__decoder__tell_me_more(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0]; uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -31712,14 +32289,13 @@ wuffs_gif__decoder__tell_me_more(
goto ok; goto ok;
ok: ok:
self->private_impl.p_tell_me_more[0] = 0; self->private_impl.p_do_tell_me_more[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -31727,9 +32303,6 @@ wuffs_gif__decoder__tell_me_more(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -31882,6 +32455,52 @@ wuffs_gif__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame_config(
wuffs_gif__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_background_color = 0; uint32_t v_background_color = 0;
uint8_t v_flags = 0; uint8_t v_flags = 0;
@@ -31896,9 +32515,9 @@ wuffs_gif__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_background_color = self->private_data.s_decode_frame_config[0].v_background_color; v_background_color = self->private_data.s_do_decode_frame_config[0].v_background_color;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -31913,7 +32532,7 @@ wuffs_gif__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_gif__decoder__decode_image_config(self, NULL, a_src); status = wuffs_gif__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -31996,15 +32615,14 @@ wuffs_gif__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0; self->private_data.s_do_decode_frame_config[0].v_background_color = v_background_color;
self->private_data.s_decode_frame_config[0].v_background_color = v_background_color;
goto exit; goto exit;
exit: exit:
@@ -32012,9 +32630,6 @@ wuffs_gif__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -32146,14 +32761,68 @@ wuffs_gif__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gif__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gif__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gif.decoder.do_decode_frame
static wuffs_base__status
wuffs_gif__decoder__do_decode_frame(
wuffs_gif__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence == 64) { if (self->private_impl.f_call_sequence == 64) {
} else if (self->private_impl.f_call_sequence < 64) { } else if (self->private_impl.f_call_sequence < 64) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_gif__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_gif__decoder__do_decode_frame_config(self, NULL, a_src);
if (status.repr) { if (status.repr) {
goto suspend; goto suspend;
} }
@@ -32180,20 +32849,16 @@ wuffs_gif__decoder__decode_frame(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -33796,6 +34461,7 @@ const char wuffs_gzip__error__bad_checksum[] = "#gzip: bad checksum";
const char wuffs_gzip__error__bad_compression_method[] = "#gzip: bad compression method"; const char wuffs_gzip__error__bad_compression_method[] = "#gzip: bad compression method";
const char wuffs_gzip__error__bad_encoding_flags[] = "#gzip: bad encoding flags"; const char wuffs_gzip__error__bad_encoding_flags[] = "#gzip: bad encoding flags";
const char wuffs_gzip__error__bad_header[] = "#gzip: bad header"; const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
const char wuffs_gzip__error__truncated_input[] = "#gzip: truncated input";
// ---------------- Private Consts // ---------------- Private Consts
@@ -33803,6 +34469,13 @@ const char wuffs_gzip__error__bad_header[] = "#gzip: bad header";
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_gzip__decoder__do_transform_io(
wuffs_gzip__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
// ---------------- VTables // ---------------- VTables
const wuffs_base__io_transformer__func_ptrs const wuffs_base__io_transformer__func_ptrs
@@ -33967,6 +34640,53 @@ wuffs_gzip__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_gzip__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_gzip__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func gzip.decoder.do_transform_io
static wuffs_base__status
wuffs_gzip__decoder__do_transform_io(
wuffs_gzip__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint8_t v_flags = 0; uint8_t v_flags = 0;
uint16_t v_xlen = 0; uint16_t v_xlen = 0;
@@ -34001,12 +34721,12 @@ wuffs_gzip__decoder__transform_io(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
if (coro_susp_point) { if (coro_susp_point) {
v_flags = self->private_data.s_transform_io[0].v_flags; v_flags = self->private_data.s_do_transform_io[0].v_flags;
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got; v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
v_decoded_length_got = self->private_data.s_transform_io[0].v_decoded_length_got; v_decoded_length_got = self->private_data.s_do_transform_io[0].v_decoded_length_got;
v_checksum_want = self->private_data.s_transform_io[0].v_checksum_want; v_checksum_want = self->private_data.s_do_transform_io[0].v_checksum_want;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -34059,15 +34779,15 @@ wuffs_gzip__decoder__transform_io(
uint8_t t_3 = *iop_a_src++; uint8_t t_3 = *iop_a_src++;
v_flags = t_3; v_flags = t_3;
} }
self->private_data.s_transform_io[0].scratch = 6; self->private_data.s_do_transform_io[0].scratch = 6;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_transform_io[0].scratch; iop_a_src += self->private_data.s_do_transform_io[0].scratch;
if ((v_flags & 4) != 0) { if ((v_flags & 4) != 0) {
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
@@ -34076,14 +34796,14 @@ wuffs_gzip__decoder__transform_io(
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src); t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -34098,15 +34818,15 @@ wuffs_gzip__decoder__transform_io(
} }
v_xlen = t_4; v_xlen = t_4;
} }
self->private_data.s_transform_io[0].scratch = ((uint32_t)(v_xlen)); self->private_data.s_do_transform_io[0].scratch = ((uint32_t)(v_xlen));
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_transform_io[0].scratch; iop_a_src += self->private_data.s_do_transform_io[0].scratch;
} }
if ((v_flags & 8) != 0) { if ((v_flags & 8) != 0) {
while (true) { while (true) {
@@ -34143,15 +34863,15 @@ wuffs_gzip__decoder__transform_io(
label__1__break:; label__1__break:;
} }
if ((v_flags & 2) != 0) { if ((v_flags & 2) != 0) {
self->private_data.s_transform_io[0].scratch = 2; self->private_data.s_do_transform_io[0].scratch = 2;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
if (self->private_data.s_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_transform_io[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_transform_io[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_transform_io[0].scratch; iop_a_src += self->private_data.s_do_transform_io[0].scratch;
} }
if ((v_flags & 224) != 0) { if ((v_flags & 224) != 0) {
status = wuffs_base__make_status(wuffs_gzip__error__bad_encoding_flags); status = wuffs_base__make_status(wuffs_gzip__error__bad_encoding_flags);
@@ -34193,14 +34913,14 @@ wuffs_gzip__decoder__transform_io(
t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_8 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(14);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_8 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -34222,14 +34942,14 @@ wuffs_gzip__decoder__transform_io(
t_9 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_9 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_9 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -34250,18 +34970,17 @@ wuffs_gzip__decoder__transform_io(
} }
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_transform_io[0].v_flags = v_flags;
self->private_data.s_transform_io[0].v_flags = v_flags; self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got; self->private_data.s_do_transform_io[0].v_decoded_length_got = v_decoded_length_got;
self->private_data.s_transform_io[0].v_decoded_length_got = v_decoded_length_got; self->private_data.s_do_transform_io[0].v_checksum_want = v_checksum_want;
self->private_data.s_transform_io[0].v_checksum_want = v_checksum_want;
goto exit; goto exit;
exit: exit:
@@ -34272,9 +34991,6 @@ wuffs_gzip__decoder__transform_io(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -36492,6 +37208,7 @@ wuffs_json__decoder__decode_trailer(
// ---------------- Status Codes Implementations // ---------------- Status Codes Implementations
const char wuffs_nie__error__bad_header[] = "#nie: bad header"; const char wuffs_nie__error__bad_header[] = "#nie: bad header";
const char wuffs_nie__error__truncated_input[] = "#nie: truncated input";
const char wuffs_nie__error__unsupported_nie_file[] = "#nie: unsupported NIE file"; const char wuffs_nie__error__unsupported_nie_file[] = "#nie: unsupported NIE file";
const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: short read"; const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: short read";
@@ -36501,6 +37218,27 @@ const char wuffs_nie__note__internal_note_short_read[] = "@nie: internal note: s
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_nie__decoder__do_decode_image_config(
wuffs_nie__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame_config(
wuffs_nie__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame(
wuffs_nie__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__status static wuffs_base__status
wuffs_nie__decoder__swizzle( wuffs_nie__decoder__swizzle(
wuffs_nie__decoder* self, wuffs_nie__decoder* self,
@@ -36652,6 +37390,52 @@ wuffs_nie__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func nie.decoder.do_decode_image_config
static wuffs_base__status
wuffs_nie__decoder__do_decode_image_config(
wuffs_nie__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_a = 0; uint32_t v_a = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -36665,7 +37449,7 @@ wuffs_nie__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -36680,14 +37464,14 @@ wuffs_nie__decoder__decode_image_config(
t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36713,14 +37497,14 @@ wuffs_nie__decoder__decode_image_config(
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36756,14 +37540,14 @@ wuffs_nie__decoder__decode_image_config(
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36790,14 +37574,14 @@ wuffs_nie__decoder__decode_image_config(
t_3 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -36831,14 +37615,13 @@ wuffs_nie__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit; goto exit;
exit: exit:
@@ -36846,9 +37629,6 @@ wuffs_nie__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -36880,6 +37660,52 @@ wuffs_nie__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func nie.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame_config(
wuffs_nie__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -36891,7 +37717,7 @@ wuffs_nie__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -36901,7 +37727,7 @@ wuffs_nie__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_nie__decoder__decode_image_config(self, NULL, a_src); status = wuffs_nie__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -36940,14 +37766,13 @@ wuffs_nie__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -36955,9 +37780,6 @@ wuffs_nie__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -36998,10 +37820,64 @@ wuffs_nie__decoder__decode_frame(
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_nie__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_nie__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func nie.decoder.do_decode_frame
static wuffs_base__status
wuffs_nie__decoder__do_decode_frame(
wuffs_nie__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
if (self->private_impl.f_call_sequence == 64) { if (self->private_impl.f_call_sequence == 64) {
} else if (self->private_impl.f_call_sequence < 64) { } else if (self->private_impl.f_call_sequence < 64) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_nie__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_nie__decoder__do_decode_frame_config(self, NULL, a_src);
if (status.repr) { if (status.repr) {
goto suspend; goto suspend;
} }
@@ -37048,20 +37924,16 @@ wuffs_nie__decoder__decode_frame(
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit; goto exit;
exit: exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -37078,9 +37950,11 @@ wuffs_nie__decoder__swizzle(
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
uint64_t v_dst_bytes_per_pixel = 0; uint64_t v_dst_bytes_per_pixel = 0;
uint64_t v_dst_bytes_per_row = 0; uint64_t v_dst_bytes_per_row = 0;
uint32_t v_src_bytes_per_pixel = 0;
wuffs_base__table_u8 v_tab = {0}; wuffs_base__table_u8 v_tab = {0};
wuffs_base__slice_u8 v_dst = {0}; wuffs_base__slice_u8 v_dst = {0};
uint64_t v_i = 0; uint64_t v_i = 0;
uint64_t v_j = 0;
uint64_t v_n = 0; uint64_t v_n = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -37103,7 +37977,6 @@ wuffs_nie__decoder__swizzle(
v_dst_bytes_per_pixel = ((uint64_t)((v_dst_bits_per_pixel / 8))); v_dst_bytes_per_pixel = ((uint64_t)((v_dst_bits_per_pixel / 8)));
v_dst_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * v_dst_bytes_per_pixel); v_dst_bytes_per_row = (((uint64_t)(self->private_impl.f_width)) * v_dst_bytes_per_pixel);
v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0); v_tab = wuffs_base__pixel_buffer__plane(a_dst, 0);
label__0__continue:;
while (true) { while (true) {
if (self->private_impl.f_dst_x == self->private_impl.f_width) { if (self->private_impl.f_dst_x == self->private_impl.f_width) {
self->private_impl.f_dst_x = 0; self->private_impl.f_dst_x = 0;
@@ -37118,14 +37991,33 @@ wuffs_nie__decoder__swizzle(
} }
v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel); v_i = (((uint64_t)(self->private_impl.f_dst_x)) * v_dst_bytes_per_pixel);
if (v_i >= ((uint64_t)(v_dst.len))) { if (v_i >= ((uint64_t)(v_dst.len))) {
goto label__0__continue; v_src_bytes_per_pixel = 4;
if (self->private_impl.f_pixfmt == 2164308923) {
v_src_bytes_per_pixel = 8;
}
v_n = (((uint64_t)(io2_a_src - iop_a_src)) / ((uint64_t)(v_src_bytes_per_pixel)));
v_n = wuffs_base__u64__min(v_n, ((uint64_t)(((uint32_t)(self->private_impl.f_width - self->private_impl.f_dst_x)))));
v_j = v_n;
while (v_j >= 8) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 8)))) {
iop_a_src += (v_src_bytes_per_pixel * 8);
}
v_j -= 8;
}
while (v_j > 0) {
if (((uint64_t)(io2_a_src - iop_a_src)) >= ((uint64_t)((v_src_bytes_per_pixel * 1)))) {
iop_a_src += (v_src_bytes_per_pixel * 1);
}
v_j -= 1;
}
} else {
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
wuffs_base__pixel_buffer__palette(a_dst),
&iop_a_src,
io2_a_src);
} }
v_n = wuffs_base__pixel_swizzler__swizzle_interleaved_from_reader(
&self->private_impl.f_swizzler,
wuffs_base__slice_u8__subslice_i(v_dst, v_i),
wuffs_base__pixel_buffer__palette(a_dst),
&iop_a_src,
io2_a_src);
if (v_n == 0) { if (v_n == 0) {
status = wuffs_base__make_status(wuffs_nie__note__internal_note_short_read); status = wuffs_base__make_status(wuffs_nie__note__internal_note_short_read);
goto ok; goto ok;
@@ -37327,6 +38219,7 @@ const char wuffs_zlib__error__bad_compression_method[] = "#zlib: bad compression
const char wuffs_zlib__error__bad_compression_window_size[] = "#zlib: bad compression window size"; const char wuffs_zlib__error__bad_compression_window_size[] = "#zlib: bad compression window size";
const char wuffs_zlib__error__bad_parity_check[] = "#zlib: bad parity check"; const char wuffs_zlib__error__bad_parity_check[] = "#zlib: bad parity check";
const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect dictionary"; const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect dictionary";
const char wuffs_zlib__error__truncated_input[] = "#zlib: truncated input";
// ---------------- Private Consts // ---------------- Private Consts
@@ -37338,6 +38231,13 @@ const char wuffs_zlib__error__incorrect_dictionary[] = "#zlib: incorrect diction
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_zlib__decoder__do_transform_io(
wuffs_zlib__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf);
// ---------------- VTables // ---------------- VTables
const wuffs_base__io_transformer__func_ptrs const wuffs_base__io_transformer__func_ptrs
@@ -37555,6 +38455,53 @@ wuffs_zlib__decoder__transform_io(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_transform_io[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_zlib__decoder__do_transform_io(self, a_dst, a_src, a_workbuf);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_zlib__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_transform_io[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func zlib.decoder.do_transform_io
static wuffs_base__status
wuffs_zlib__decoder__do_transform_io(
wuffs_zlib__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint16_t v_x = 0; uint16_t v_x = 0;
uint32_t v_checksum_got = 0; uint32_t v_checksum_got = 0;
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
@@ -37585,9 +38532,9 @@ wuffs_zlib__decoder__transform_io(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_transform_io[0]; uint32_t coro_susp_point = self->private_impl.p_do_transform_io[0];
if (coro_susp_point) { if (coro_susp_point) {
v_checksum_got = self->private_data.s_transform_io[0].v_checksum_got; v_checksum_got = self->private_data.s_do_transform_io[0].v_checksum_got;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -37604,14 +38551,14 @@ wuffs_zlib__decoder__transform_io(
t_0 = wuffs_base__peek_u16be__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u16be__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -37648,14 +38595,14 @@ wuffs_zlib__decoder__transform_io(
t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_1 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -37721,14 +38668,14 @@ wuffs_zlib__decoder__transform_io(
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_transform_io[0].scratch = 0; self->private_data.s_do_transform_io[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_transform_io[0].scratch; uint64_t* scratch = &self->private_data.s_do_transform_io[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -37750,15 +38697,14 @@ wuffs_zlib__decoder__transform_io(
} }
ok: ok:
self->private_impl.p_transform_io[0] = 0; self->private_impl.p_do_transform_io[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_transform_io[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_transform_io[0].v_checksum_got = v_checksum_got;
self->private_data.s_transform_io[0].v_checksum_got = v_checksum_got;
goto exit; goto exit;
exit: exit:
@@ -37769,9 +38715,6 @@ wuffs_zlib__decoder__transform_io(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -37788,6 +38731,7 @@ const char wuffs_png__error__bad_filter[] = "#png: bad filter";
const char wuffs_png__error__bad_header[] = "#png: bad header"; const char wuffs_png__error__bad_header[] = "#png: bad header";
const char wuffs_png__error__bad_text_chunk_not_latin_1[] = "#png: bad text chunk (not Latin-1)"; const char wuffs_png__error__bad_text_chunk_not_latin_1[] = "#png: bad text chunk (not Latin-1)";
const char wuffs_png__error__missing_palette[] = "#png: missing palette"; const char wuffs_png__error__missing_palette[] = "#png: missing palette";
const char wuffs_png__error__truncated_input[] = "#png: truncated input";
const char wuffs_png__error__unsupported_cgbi_extension[] = "#png: unsupported CgBI extension"; const char wuffs_png__error__unsupported_cgbi_extension[] = "#png: unsupported CgBI extension";
const char wuffs_png__error__unsupported_png_compression_method[] = "#png: unsupported PNG compression method"; const char wuffs_png__error__unsupported_png_compression_method[] = "#png: unsupported PNG compression method";
const char wuffs_png__error__unsupported_png_file[] = "#png: unsupported PNG file"; const char wuffs_png__error__unsupported_png_file[] = "#png: unsupported PNG file";
@@ -38013,6 +38957,12 @@ wuffs_png__decoder__filter_4_distance_4_x86_sse42(
wuffs_base__slice_u8 a_prev); wuffs_base__slice_u8 a_prev);
#endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY) #endif // defined(WUFFS_BASE__CPU_ARCH__X86_FAMILY)
static wuffs_base__status
wuffs_png__decoder__do_decode_image_config(
wuffs_png__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__decode_ihdr( wuffs_png__decoder__decode_ihdr(
wuffs_png__decoder* self, wuffs_png__decoder* self,
@@ -38082,17 +39032,39 @@ wuffs_png__decoder__decode_trns(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_png__decoder__do_decode_frame_config(
wuffs_png__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__skip_frame( wuffs_png__decoder__skip_frame(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__io_buffer* a_src); wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_png__decoder__do_decode_frame(
wuffs_png__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__decode_pass( wuffs_png__decoder__decode_pass(
wuffs_png__decoder* self, wuffs_png__decoder* self,
wuffs_base__io_buffer* a_src, wuffs_base__io_buffer* a_src,
wuffs_base__slice_u8 a_workbuf); wuffs_base__slice_u8 a_workbuf);
static wuffs_base__status
wuffs_png__decoder__do_tell_me_more(
wuffs_png__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src);
static wuffs_base__status static wuffs_base__status
wuffs_png__decoder__filter_and_swizzle( wuffs_png__decoder__filter_and_swizzle(
wuffs_png__decoder* self, wuffs_png__decoder* self,
@@ -39687,6 +40659,52 @@ wuffs_png__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_decode_image_config
static wuffs_base__status
wuffs_png__decoder__do_decode_image_config(
wuffs_png__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint64_t v_magic = 0; uint64_t v_magic = 0;
uint64_t v_mark = 0; uint64_t v_mark = 0;
uint32_t v_checksum_have = 0; uint32_t v_checksum_have = 0;
@@ -39704,9 +40722,9 @@ wuffs_png__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_checksum_have = self->private_data.s_decode_image_config[0].v_checksum_have; v_checksum_have = self->private_data.s_do_decode_image_config[0].v_checksum_have;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -39722,14 +40740,14 @@ wuffs_png__decoder__decode_image_config(
t_0 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
iop_a_src += 8; iop_a_src += 8;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_0 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -39755,14 +40773,14 @@ wuffs_png__decoder__decode_image_config(
t_1 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u64le__no_bounds_check(iop_a_src);
iop_a_src += 8; iop_a_src += 8;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -39821,14 +40839,14 @@ wuffs_png__decoder__decode_image_config(
t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_3 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -39853,14 +40871,12 @@ wuffs_png__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_base__note__metadata_reported); status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
goto ok; goto ok;
} }
label__1__continue:;
while (true) { while (true) {
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) { if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
if (a_src && a_src->meta.closed) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit;
}
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(8);
goto label__1__continue;
} }
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32))); self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
@@ -39920,14 +40936,14 @@ wuffs_png__decoder__decode_image_config(
t_5 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_5 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_5 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_5 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -39977,15 +40993,14 @@ wuffs_png__decoder__decode_image_config(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_decode_image_config[0].v_checksum_have = v_checksum_have;
self->private_data.s_decode_image_config[0].v_checksum_have = v_checksum_have;
goto exit; goto exit;
exit: exit:
@@ -39993,9 +41008,6 @@ wuffs_png__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -41924,6 +42936,52 @@ wuffs_png__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_png__decoder__do_decode_frame_config(
wuffs_png__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_checksum_have = 0; uint32_t v_checksum_have = 0;
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
@@ -41937,7 +42995,7 @@ wuffs_png__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -41950,7 +43008,7 @@ wuffs_png__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_png__decoder__decode_image_config(self, NULL, a_src); status = wuffs_png__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -42001,14 +43059,14 @@ wuffs_png__decoder__decode_frame_config(
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame_config[0].scratch = 0; self->private_data.s_do_decode_frame_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -42030,14 +43088,14 @@ wuffs_png__decoder__decode_frame_config(
t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_1 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame_config[0].scratch = 0; self->private_data.s_do_decode_frame_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(6);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_1 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -42064,14 +43122,14 @@ wuffs_png__decoder__decode_frame_config(
t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_2 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame_config[0].scratch = 0; self->private_data.s_do_decode_frame_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame_config[0].scratch;
uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_2 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -42109,15 +43167,15 @@ wuffs_png__decoder__decode_frame_config(
if (status.repr) { if (status.repr) {
goto suspend; goto suspend;
} }
self->private_data.s_decode_frame_config[0].scratch = 4; self->private_data.s_do_decode_frame_config[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame_config[0].scratch; iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
goto label__0__break; goto label__0__break;
} }
if (a_src) { if (a_src) {
@@ -42136,15 +43194,15 @@ wuffs_png__decoder__decode_frame_config(
status = wuffs_base__make_status(wuffs_base__note__metadata_reported); status = wuffs_base__make_status(wuffs_base__note__metadata_reported);
goto ok; goto ok;
} }
self->private_data.s_decode_frame_config[0].scratch = 4; self->private_data.s_do_decode_frame_config[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(12);
if (self->private_data.s_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame_config[0].scratch; iop_a_src += self->private_data.s_do_decode_frame_config[0].scratch;
self->private_impl.f_chunk_length = 0; self->private_impl.f_chunk_length = 0;
} }
label__0__break:; label__0__break:;
@@ -42169,14 +43227,13 @@ wuffs_png__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -42184,9 +43241,6 @@ wuffs_png__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -42221,13 +43275,10 @@ wuffs_png__decoder__skip_frame(
self->private_impl.f_chunk_type_array[3] = 0; self->private_impl.f_chunk_type_array[3] = 0;
label__0__continue:; label__0__continue:;
while (true) { while (true) {
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) { if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
if (a_src && a_src->meta.closed) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit;
}
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
goto label__0__continue;
} }
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32))); self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
@@ -42373,6 +43424,60 @@ wuffs_png__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_decode_frame
static wuffs_base__status
wuffs_png__decoder__do_decode_frame(
wuffs_png__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_seq_num = 0; uint32_t v_seq_num = 0;
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t v_pass_width = 0; uint32_t v_pass_width = 0;
@@ -42389,7 +43494,7 @@ wuffs_png__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -42404,7 +43509,7 @@ wuffs_png__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_png__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_png__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -42412,14 +43517,12 @@ wuffs_png__decoder__decode_frame(
goto suspend; goto suspend;
} }
} }
label__0__continue:;
while (true) { while (true) {
while (((uint64_t)(io2_a_src - iop_a_src)) < 8) { if (((uint64_t)(io2_a_src - iop_a_src)) < 8) {
if (a_src && a_src->meta.closed) {
status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit;
}
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
goto label__0__continue;
} }
self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); self->private_impl.f_chunk_length = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32))); self->private_impl.f_chunk_type = ((uint32_t)((wuffs_base__peek_u64le__no_bounds_check(iop_a_src) >> 32)));
@@ -42453,14 +43556,14 @@ wuffs_png__decoder__decode_frame(
t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src); t_0 = wuffs_base__peek_u32be__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_frame[0].scratch = 0; self->private_data.s_do_decode_frame[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(4);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_frame[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_frame[0].scratch;
uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF)); uint32_t num_bits_0 = ((uint32_t)(*scratch & 0xFF));
*scratch >>= 8; *scratch >>= 8;
*scratch <<= 8; *scratch <<= 8;
@@ -42488,15 +43591,15 @@ wuffs_png__decoder__decode_frame(
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
} }
self->private_data.s_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12); self->private_data.s_do_decode_frame[0].scratch = (((uint64_t)(self->private_impl.f_chunk_length)) + 12);
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
self->private_impl.f_chunk_length = 0; self->private_impl.f_chunk_length = 0;
} }
label__0__break:; label__0__break:;
@@ -42554,14 +43657,12 @@ wuffs_png__decoder__decode_frame(
wuffs_png__decoder__filter_and_swizzle(self, a_dst, wuffs_base__slice_u8__subslice_j(a_workbuf, self->private_impl.f_workbuf_wi)); wuffs_png__decoder__filter_and_swizzle(self, a_dst, wuffs_base__slice_u8__subslice_j(a_workbuf, self->private_impl.f_workbuf_wi));
} }
if (v_status.repr == wuffs_base__suspension__short_read) { if (v_status.repr == wuffs_base__suspension__short_read) {
while (true) { status = wuffs_base__make_status(wuffs_png__error__truncated_input);
status = wuffs_base__make_status(wuffs_base__suspension__short_read); goto exit;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
}
} }
} }
status = v_status; status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(6);
} }
label__1__break:; label__1__break:;
v_status = wuffs_png__decoder__filter_and_swizzle(self, a_dst, a_workbuf); v_status = wuffs_png__decoder__filter_and_swizzle(self, a_dst, a_workbuf);
@@ -42594,14 +43695,13 @@ wuffs_png__decoder__decode_frame(
self->private_impl.f_call_sequence = 32; self->private_impl.f_call_sequence = 32;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit; goto exit;
exit: exit:
@@ -42609,9 +43709,6 @@ wuffs_png__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -42676,11 +43773,14 @@ wuffs_png__decoder__decode_pass(
self->private_impl.f_pass_workbuf_length), self->private_impl.f_pass_workbuf_length),
((uint64_t)(self->private_impl.f_workbuf_hist_pos_base + self->private_impl.f_workbuf_wi))); ((uint64_t)(self->private_impl.f_workbuf_hist_pos_base + self->private_impl.f_workbuf_wi)));
{ {
const bool o_1_closed_a_src = a_src->meta.closed;
const uint8_t *o_1_io2_a_src = io2_a_src; const uint8_t *o_1_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w)); v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
@@ -42703,6 +43803,7 @@ wuffs_png__decoder__decode_pass(
wuffs_base__u64__sat_add_indirect(&self->private_impl.f_workbuf_wi, wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)))); wuffs_base__u64__sat_add_indirect(&self->private_impl.f_workbuf_wi, wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w))));
io2_a_src = o_1_io2_a_src; io2_a_src = o_1_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_1_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43113,6 +44214,53 @@ wuffs_png__decoder__tell_me_more(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_png__decoder__do_tell_me_more(self, a_dst, a_minfo, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_png__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_tell_me_more[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func png.decoder.do_tell_me_more
static wuffs_base__status
wuffs_png__decoder__do_tell_me_more(
wuffs_png__decoder* self,
wuffs_base__io_buffer* a_dst,
wuffs_base__more_information* a_minfo,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint16_t v_c2 = 0; uint16_t v_c2 = 0;
wuffs_base__io_buffer u_w = wuffs_base__empty_io_buffer(); wuffs_base__io_buffer u_w = wuffs_base__empty_io_buffer();
@@ -43150,9 +44298,9 @@ wuffs_png__decoder__tell_me_more(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_tell_me_more[0]; uint32_t coro_susp_point = self->private_impl.p_do_tell_me_more[0];
if (coro_susp_point) { if (coro_susp_point) {
v_zlib_status = self->private_data.s_tell_me_more[0].v_zlib_status; v_zlib_status = self->private_data.s_do_tell_me_more[0].v_zlib_status;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -43214,11 +44362,14 @@ wuffs_png__decoder__tell_me_more(
if (self->private_impl.f_metadata_is_zlib_compressed) { if (self->private_impl.f_metadata_is_zlib_compressed) {
if (self->private_impl.f_chunk_type == 1346585449) { if (self->private_impl.f_chunk_type == 1346585449) {
{ {
const bool o_0_closed_a_src = a_src->meta.closed;
const uint8_t *o_0_io2_a_src = io2_a_src; const uint8_t *o_0_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
{ {
@@ -43240,6 +44391,7 @@ wuffs_png__decoder__tell_me_more(
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295)))); wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
io2_a_src = o_0_io2_a_src; io2_a_src = o_0_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_0_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43260,11 +44412,14 @@ wuffs_png__decoder__tell_me_more(
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(2);
} else if (self->private_impl.f_chunk_type == 1951945833) { } else if (self->private_impl.f_chunk_type == 1951945833) {
{ {
const bool o_1_closed_a_src = a_src->meta.closed;
const uint8_t *o_1_io2_a_src = io2_a_src; const uint8_t *o_1_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
{ {
@@ -43286,6 +44441,7 @@ wuffs_png__decoder__tell_me_more(
wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295)))); wuffs_base__u32__sat_sub_indirect(&self->private_impl.f_chunk_length, ((uint32_t)((wuffs_base__io__count_since(v_r_mark, ((uint64_t)(iop_a_src - io0_a_src))) & 4294967295))));
io2_a_src = o_1_io2_a_src; io2_a_src = o_1_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_1_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43321,11 +44477,14 @@ wuffs_png__decoder__tell_me_more(
wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024), wuffs_base__make_slice_u8(self->private_data.f_dst_palette, 1024),
self->private_impl.f_ztxt_hist_pos); self->private_impl.f_ztxt_hist_pos);
{ {
const bool o_3_closed_a_src = a_src->meta.closed;
const uint8_t *o_3_io2_a_src = io2_a_src; const uint8_t *o_3_io2_a_src = io2_a_src;
wuffs_base__io_reader__limit(&io2_a_src, iop_a_src, wuffs_base__io_reader__limit(&io2_a_src, iop_a_src,
((uint64_t)(self->private_impl.f_chunk_length))); ((uint64_t)(self->private_impl.f_chunk_length)));
if (a_src) { if (a_src) {
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); size_t n = ((size_t)(io2_a_src - a_src->data.ptr));
a_src->meta.closed = a_src->meta.closed && (a_src->meta.wi <= n);
a_src->meta.wi = n;
} }
v_w_mark = ((uint64_t)(iop_v_w - io0_v_w)); v_w_mark = ((uint64_t)(iop_v_w - io0_v_w));
v_r_mark = ((uint64_t)(iop_a_src - io0_a_src)); v_r_mark = ((uint64_t)(iop_a_src - io0_a_src));
@@ -43345,6 +44504,7 @@ wuffs_png__decoder__tell_me_more(
v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w))); v_num_written = wuffs_base__io__count_since(v_w_mark, ((uint64_t)(iop_v_w - io0_v_w)));
io2_a_src = o_3_io2_a_src; io2_a_src = o_3_io2_a_src;
if (a_src) { if (a_src) {
a_src->meta.closed = o_3_closed_a_src;
a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr)); a_src->meta.wi = ((size_t)(io2_a_src - a_src->data.ptr));
} }
} }
@@ -43563,15 +44723,15 @@ wuffs_png__decoder__tell_me_more(
status = wuffs_base__make_status(wuffs_png__error__bad_chunk); status = wuffs_base__make_status(wuffs_png__error__bad_chunk);
goto exit; goto exit;
} }
self->private_data.s_tell_me_more[0].scratch = 4; self->private_data.s_do_tell_me_more[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
if (self->private_data.s_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_tell_me_more[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_tell_me_more[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_tell_me_more[0].scratch; iop_a_src += self->private_data.s_do_tell_me_more[0].scratch;
self->private_impl.f_metadata_flavor = 0; self->private_impl.f_metadata_flavor = 0;
self->private_impl.f_metadata_fourcc = 0; self->private_impl.f_metadata_fourcc = 0;
self->private_impl.f_metadata_x = 0; self->private_impl.f_metadata_x = 0;
@@ -43582,15 +44742,14 @@ wuffs_png__decoder__tell_me_more(
goto ok; goto ok;
ok: ok:
self->private_impl.p_tell_me_more[0] = 0; self->private_impl.p_do_tell_me_more[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_tell_me_more[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 4 : 0; self->private_data.s_do_tell_me_more[0].v_zlib_status = v_zlib_status;
self->private_data.s_tell_me_more[0].v_zlib_status = v_zlib_status;
goto exit; goto exit;
exit: exit:
@@ -43601,9 +44760,6 @@ wuffs_png__decoder__tell_me_more(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -43994,6 +45150,7 @@ wuffs_png__decoder__filter_and_swizzle_tricky(
const char wuffs_tga__error__bad_header[] = "#tga: bad header"; const char wuffs_tga__error__bad_header[] = "#tga: bad header";
const char wuffs_tga__error__bad_run_length_encoding[] = "#tga: bad run length encoding"; const char wuffs_tga__error__bad_run_length_encoding[] = "#tga: bad run length encoding";
const char wuffs_tga__error__truncated_input[] = "#tga: truncated input";
const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA file"; const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA file";
// ---------------- Private Consts // ---------------- Private Consts
@@ -44002,6 +45159,27 @@ const char wuffs_tga__error__unsupported_tga_file[] = "#tga: unsupported TGA fil
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_tga__decoder__do_decode_image_config(
wuffs_tga__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame_config(
wuffs_tga__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame(
wuffs_tga__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
// ---------------- VTables // ---------------- VTables
const wuffs_base__image_decoder__func_ptrs const wuffs_base__image_decoder__func_ptrs
@@ -44147,6 +45325,52 @@ wuffs_tga__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.do_decode_image_config
static wuffs_base__status
wuffs_tga__decoder__do_decode_image_config(
wuffs_tga__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint32_t v_c = 0; uint32_t v_c = 0;
uint32_t v_c5 = 0; uint32_t v_c5 = 0;
uint32_t v_i = 0; uint32_t v_i = 0;
@@ -44162,9 +45386,9 @@ wuffs_tga__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_i = self->private_data.s_decode_image_config[0].v_i; v_i = self->private_data.s_do_decode_image_config[0].v_i;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -44221,14 +45445,14 @@ wuffs_tga__decoder__decode_image_config(
t_3 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src); t_3 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(5);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_3 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44250,14 +45474,14 @@ wuffs_tga__decoder__decode_image_config(
t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src); t_4 = wuffs_base__peek_u16le__no_bounds_check(iop_a_src);
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(7);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_4 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44298,15 +45522,15 @@ wuffs_tga__decoder__decode_image_config(
goto exit; goto exit;
} }
} }
self->private_data.s_decode_image_config[0].scratch = 4; self->private_data.s_do_decode_image_config[0].scratch = 4;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(9);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
{ {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(10);
uint32_t t_6; uint32_t t_6;
@@ -44314,14 +45538,14 @@ wuffs_tga__decoder__decode_image_config(
t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_6 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(11);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_6 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44343,14 +45567,14 @@ wuffs_tga__decoder__decode_image_config(
t_7 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_7 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(13);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_7 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44430,15 +45654,15 @@ wuffs_tga__decoder__decode_image_config(
status = wuffs_base__make_status(wuffs_tga__error__unsupported_tga_file); status = wuffs_base__make_status(wuffs_tga__error__unsupported_tga_file);
goto exit; goto exit;
} }
self->private_data.s_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length)); self->private_data.s_do_decode_image_config[0].scratch = ((uint32_t)(self->private_impl.f_header_id_length));
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(16);
if (self->private_data.s_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_image_config[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_image_config[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_image_config[0].scratch; iop_a_src += self->private_data.s_do_decode_image_config[0].scratch;
if (self->private_impl.f_header_color_map_type != 0) { if (self->private_impl.f_header_color_map_type != 0) {
while (v_i < ((uint32_t)(self->private_impl.f_header_color_map_length))) { while (v_i < ((uint32_t)(self->private_impl.f_header_color_map_length))) {
if (self->private_impl.f_header_color_map_entry_size == 24) { if (self->private_impl.f_header_color_map_entry_size == 24) {
@@ -44449,14 +45673,14 @@ wuffs_tga__decoder__decode_image_config(
t_10 = ((uint32_t)(wuffs_base__peek_u24le__no_bounds_check(iop_a_src))); t_10 = ((uint32_t)(wuffs_base__peek_u24le__no_bounds_check(iop_a_src)));
iop_a_src += 3; iop_a_src += 3;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(18); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(18);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_10 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44483,14 +45707,14 @@ wuffs_tga__decoder__decode_image_config(
t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src); t_11 = wuffs_base__peek_u32le__no_bounds_check(iop_a_src);
iop_a_src += 4; iop_a_src += 4;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(20); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(20);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_11 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44517,14 +45741,14 @@ wuffs_tga__decoder__decode_image_config(
t_12 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src))); t_12 = ((uint32_t)(wuffs_base__peek_u16le__no_bounds_check(iop_a_src)));
iop_a_src += 2; iop_a_src += 2;
} else { } else {
self->private_data.s_decode_image_config[0].scratch = 0; self->private_data.s_do_decode_image_config[0].scratch = 0;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(22); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(22);
while (true) { while (true) {
if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) { if (WUFFS_BASE__UNLIKELY(iop_a_src == io2_a_src)) {
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
uint64_t* scratch = &self->private_data.s_decode_image_config[0].scratch; uint64_t* scratch = &self->private_data.s_do_decode_image_config[0].scratch;
uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56)); uint32_t num_bits_12 = ((uint32_t)(*scratch >> 56));
*scratch <<= 8; *scratch <<= 8;
*scratch >>= 8; *scratch >>= 8;
@@ -44572,15 +45796,14 @@ wuffs_tga__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_decode_image_config[0].v_i = v_i;
self->private_data.s_decode_image_config[0].v_i = v_i;
goto exit; goto exit;
exit: exit:
@@ -44588,9 +45811,6 @@ wuffs_tga__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -44622,6 +45842,52 @@ wuffs_tga__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame_config(
wuffs_tga__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -44633,7 +45899,7 @@ wuffs_tga__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -44643,7 +45909,7 @@ wuffs_tga__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_tga__decoder__decode_image_config(self, NULL, a_src); status = wuffs_tga__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -44682,14 +45948,13 @@ wuffs_tga__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -44697,9 +45962,6 @@ wuffs_tga__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -44734,6 +45996,60 @@ wuffs_tga__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_tga__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_tga__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func tga.decoder.do_decode_frame
static wuffs_base__status
wuffs_tga__decoder__do_decode_frame(
wuffs_tga__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
wuffs_base__pixel_format v_dst_pixfmt = {0}; wuffs_base__pixel_format v_dst_pixfmt = {0};
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
@@ -44766,16 +46082,16 @@ wuffs_tga__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
if (coro_susp_point) { if (coro_susp_point) {
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel; v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x; v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y; v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
v_mark = self->private_data.s_decode_frame[0].v_mark; v_mark = self->private_data.s_do_decode_frame[0].v_mark;
v_num_pixels32 = self->private_data.s_decode_frame[0].v_num_pixels32; v_num_pixels32 = self->private_data.s_do_decode_frame[0].v_num_pixels32;
v_lit_length = self->private_data.s_decode_frame[0].v_lit_length; v_lit_length = self->private_data.s_do_decode_frame[0].v_lit_length;
v_run_length = self->private_data.s_decode_frame[0].v_run_length; v_run_length = self->private_data.s_do_decode_frame[0].v_run_length;
v_num_dst_bytes = self->private_data.s_decode_frame[0].v_num_dst_bytes; v_num_dst_bytes = self->private_data.s_do_decode_frame[0].v_num_dst_bytes;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -44786,7 +46102,7 @@ wuffs_tga__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_tga__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_tga__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -44849,15 +46165,15 @@ wuffs_tga__decoder__decode_frame(
v_num_pixels32 = ((uint32_t)(wuffs_base__u64__min(v_num_pixels64, ((uint64_t)(v_lit_length))))); v_num_pixels32 = ((uint32_t)(wuffs_base__u64__min(v_num_pixels64, ((uint64_t)(v_lit_length)))));
v_num_dst_bytes = (((uint64_t)(v_num_pixels32)) * v_dst_bytes_per_pixel); v_num_dst_bytes = (((uint64_t)(v_num_pixels32)) * v_dst_bytes_per_pixel);
v_num_src_bytes = (v_num_pixels32 * self->private_impl.f_src_bytes_per_pixel); v_num_src_bytes = (v_num_pixels32 * self->private_impl.f_src_bytes_per_pixel);
self->private_data.s_decode_frame[0].scratch = v_num_src_bytes; self->private_data.s_do_decode_frame[0].scratch = v_num_src_bytes;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(2);
if (self->private_data.s_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) { if (self->private_data.s_do_decode_frame[0].scratch > ((uint64_t)(io2_a_src - iop_a_src))) {
self->private_data.s_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src)); self->private_data.s_do_decode_frame[0].scratch -= ((uint64_t)(io2_a_src - iop_a_src));
iop_a_src = io2_a_src; iop_a_src = io2_a_src;
status = wuffs_base__make_status(wuffs_base__suspension__short_read); status = wuffs_base__make_status(wuffs_base__suspension__short_read);
goto suspend; goto suspend;
} }
iop_a_src += self->private_data.s_decode_frame[0].scratch; iop_a_src += self->private_data.s_do_decode_frame[0].scratch;
wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, v_dst_palette, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_src - io0_a_src)), io0_a_src)); wuffs_base__pixel_swizzler__swizzle_interleaved_from_slice(&self->private_impl.f_swizzler, v_dst, v_dst_palette, wuffs_base__io__since(v_mark, ((uint64_t)(iop_a_src - io0_a_src)), io0_a_src));
if (v_num_dst_bytes <= ((uint64_t)(v_dst.len))) { if (v_num_dst_bytes <= ((uint64_t)(v_dst.len))) {
v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_num_dst_bytes); v_dst = wuffs_base__slice_u8__subslice_i(v_dst, v_num_dst_bytes);
@@ -45022,22 +46338,21 @@ wuffs_tga__decoder__decode_frame(
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0; self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel; self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x; self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y; self->private_data.s_do_decode_frame[0].v_mark = v_mark;
self->private_data.s_decode_frame[0].v_mark = v_mark; self->private_data.s_do_decode_frame[0].v_num_pixels32 = v_num_pixels32;
self->private_data.s_decode_frame[0].v_num_pixels32 = v_num_pixels32; self->private_data.s_do_decode_frame[0].v_lit_length = v_lit_length;
self->private_data.s_decode_frame[0].v_lit_length = v_lit_length; self->private_data.s_do_decode_frame[0].v_run_length = v_run_length;
self->private_data.s_decode_frame[0].v_run_length = v_run_length; self->private_data.s_do_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
self->private_data.s_decode_frame[0].v_num_dst_bytes = v_num_dst_bytes;
goto exit; goto exit;
exit: exit:
@@ -45045,9 +46360,6 @@ wuffs_tga__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -45228,6 +46540,7 @@ wuffs_tga__decoder__workbuf_len(
// ---------------- Status Codes Implementations // ---------------- Status Codes Implementations
const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header"; const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
const char wuffs_wbmp__error__truncated_input[] = "#wbmp: truncated input";
// ---------------- Private Consts // ---------------- Private Consts
@@ -45235,6 +46548,27 @@ const char wuffs_wbmp__error__bad_header[] = "#wbmp: bad header";
// ---------------- Private Function Prototypes // ---------------- Private Function Prototypes
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_image_config(
wuffs_wbmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame_config(
wuffs_wbmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src);
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame(
wuffs_wbmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts);
// ---------------- VTables // ---------------- VTables
const wuffs_base__image_decoder__func_ptrs const wuffs_base__image_decoder__func_ptrs
@@ -45380,6 +46714,52 @@ wuffs_wbmp__decoder__decode_image_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_image_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_image_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func wbmp.decoder.do_decode_image_config
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_image_config(
wuffs_wbmp__decoder* self,
wuffs_base__image_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
uint8_t v_c = 0; uint8_t v_c = 0;
uint32_t v_i = 0; uint32_t v_i = 0;
uint32_t v_x32 = 0; uint32_t v_x32 = 0;
@@ -45396,10 +46776,10 @@ wuffs_wbmp__decoder__decode_image_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_image_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_image_config[0];
if (coro_susp_point) { if (coro_susp_point) {
v_i = self->private_data.s_decode_image_config[0].v_i; v_i = self->private_data.s_do_decode_image_config[0].v_i;
v_x32 = self->private_data.s_decode_image_config[0].v_x32; v_x32 = self->private_data.s_do_decode_image_config[0].v_x32;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -45472,16 +46852,15 @@ wuffs_wbmp__decoder__decode_image_config(
goto ok; goto ok;
ok: ok:
self->private_impl.p_decode_image_config[0] = 0; self->private_impl.p_do_decode_image_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_image_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 1 : 0; self->private_data.s_do_decode_image_config[0].v_i = v_i;
self->private_data.s_decode_image_config[0].v_i = v_i; self->private_data.s_do_decode_image_config[0].v_x32 = v_x32;
self->private_data.s_decode_image_config[0].v_x32 = v_x32;
goto exit; goto exit;
exit: exit:
@@ -45489,9 +46868,6 @@ wuffs_wbmp__decoder__decode_image_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -45523,6 +46899,52 @@ wuffs_wbmp__decoder__decode_frame_config(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame_config(self, a_dst, a_src);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame_config[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func wbmp.decoder.do_decode_frame_config
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame_config(
wuffs_wbmp__decoder* self,
wuffs_base__frame_config* a_dst,
wuffs_base__io_buffer* a_src) {
wuffs_base__status status = wuffs_base__make_status(NULL);
const uint8_t* iop_a_src = NULL; const uint8_t* iop_a_src = NULL;
const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io0_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL; const uint8_t* io1_a_src WUFFS_BASE__POTENTIALLY_UNUSED = NULL;
@@ -45534,7 +46956,7 @@ wuffs_wbmp__decoder__decode_frame_config(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame_config[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame_config[0];
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -45544,7 +46966,7 @@ wuffs_wbmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_wbmp__decoder__decode_image_config(self, NULL, a_src); status = wuffs_wbmp__decoder__do_decode_image_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -45583,14 +47005,13 @@ wuffs_wbmp__decoder__decode_frame_config(
self->private_impl.f_call_sequence = 64; self->private_impl.f_call_sequence = 64;
ok: ok:
self->private_impl.p_decode_frame_config[0] = 0; self->private_impl.p_do_decode_frame_config[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame_config[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 2 : 0;
goto exit; goto exit;
exit: exit:
@@ -45598,9 +47019,6 @@ wuffs_wbmp__decoder__decode_frame_config(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
@@ -45635,6 +47053,60 @@ wuffs_wbmp__decoder__decode_frame(
self->private_impl.active_coroutine = 0; self->private_impl.active_coroutine = 0;
wuffs_base__status status = wuffs_base__make_status(NULL); wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL);
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0];
switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
while (true) {
{
wuffs_base__status t_0 = wuffs_wbmp__decoder__do_decode_frame(self,
a_dst,
a_src,
a_blend,
a_workbuf,
a_opts);
v_status = t_0;
}
if ((v_status.repr == wuffs_base__suspension__short_read) && (a_src && a_src->meta.closed)) {
status = wuffs_base__make_status(wuffs_wbmp__error__truncated_input);
goto exit;
}
status = v_status;
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_MAYBE_SUSPEND(1);
}
ok:
self->private_impl.p_decode_frame[0] = 0;
goto exit;
}
goto suspend;
suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0;
goto exit;
exit:
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status;
}
// -------- func wbmp.decoder.do_decode_frame
static wuffs_base__status
wuffs_wbmp__decoder__do_decode_frame(
wuffs_wbmp__decoder* self,
wuffs_base__pixel_buffer* a_dst,
wuffs_base__io_buffer* a_src,
wuffs_base__pixel_blend a_blend,
wuffs_base__slice_u8 a_workbuf,
wuffs_base__decode_frame_options* a_opts) {
wuffs_base__status status = wuffs_base__make_status(NULL);
wuffs_base__status v_status = wuffs_base__make_status(NULL); wuffs_base__status v_status = wuffs_base__make_status(NULL);
wuffs_base__pixel_format v_dst_pixfmt = {0}; wuffs_base__pixel_format v_dst_pixfmt = {0};
uint32_t v_dst_bits_per_pixel = 0; uint32_t v_dst_bits_per_pixel = 0;
@@ -45658,13 +47130,13 @@ wuffs_wbmp__decoder__decode_frame(
io2_a_src = io0_a_src + a_src->meta.wi; io2_a_src = io0_a_src + a_src->meta.wi;
} }
uint32_t coro_susp_point = self->private_impl.p_decode_frame[0]; uint32_t coro_susp_point = self->private_impl.p_do_decode_frame[0];
if (coro_susp_point) { if (coro_susp_point) {
v_dst_bytes_per_pixel = self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel; v_dst_bytes_per_pixel = self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel;
v_dst_x = self->private_data.s_decode_frame[0].v_dst_x; v_dst_x = self->private_data.s_do_decode_frame[0].v_dst_x;
v_dst_y = self->private_data.s_decode_frame[0].v_dst_y; v_dst_y = self->private_data.s_do_decode_frame[0].v_dst_y;
memcpy(v_src, self->private_data.s_decode_frame[0].v_src, sizeof(v_src)); memcpy(v_src, self->private_data.s_do_decode_frame[0].v_src, sizeof(v_src));
v_c = self->private_data.s_decode_frame[0].v_c; v_c = self->private_data.s_do_decode_frame[0].v_c;
} }
switch (coro_susp_point) { switch (coro_susp_point) {
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0; WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
@@ -45675,7 +47147,7 @@ wuffs_wbmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1); WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
status = wuffs_wbmp__decoder__decode_frame_config(self, NULL, a_src); status = wuffs_wbmp__decoder__do_decode_frame_config(self, NULL, a_src);
if (a_src) { if (a_src) {
iop_a_src = a_src->data.ptr + a_src->meta.ri; iop_a_src = a_src->data.ptr + a_src->meta.ri;
} }
@@ -45747,19 +47219,18 @@ wuffs_wbmp__decoder__decode_frame(
self->private_impl.f_call_sequence = 96; self->private_impl.f_call_sequence = 96;
ok: ok:
self->private_impl.p_decode_frame[0] = 0; self->private_impl.p_do_decode_frame[0] = 0;
goto exit; goto exit;
} }
goto suspend; goto suspend;
suspend: suspend:
self->private_impl.p_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0; self->private_impl.p_do_decode_frame[0] = wuffs_base__status__is_suspension(&status) ? coro_susp_point : 0;
self->private_impl.active_coroutine = wuffs_base__status__is_suspension(&status) ? 3 : 0; self->private_data.s_do_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel;
self->private_data.s_decode_frame[0].v_dst_bytes_per_pixel = v_dst_bytes_per_pixel; self->private_data.s_do_decode_frame[0].v_dst_x = v_dst_x;
self->private_data.s_decode_frame[0].v_dst_x = v_dst_x; self->private_data.s_do_decode_frame[0].v_dst_y = v_dst_y;
self->private_data.s_decode_frame[0].v_dst_y = v_dst_y; memcpy(self->private_data.s_do_decode_frame[0].v_src, v_src, sizeof(v_src));
memcpy(self->private_data.s_decode_frame[0].v_src, v_src, sizeof(v_src)); self->private_data.s_do_decode_frame[0].v_c = v_c;
self->private_data.s_decode_frame[0].v_c = v_c;
goto exit; goto exit;
exit: exit:
@@ -45767,9 +47238,6 @@ wuffs_wbmp__decoder__decode_frame(
a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr)); a_src->meta.ri = ((size_t)(iop_a_src - a_src->data.ptr));
} }
if (wuffs_base__status__is_error(&status)) {
self->private_impl.magic = WUFFS_BASE__DISABLED;
}
return status; return status;
} }
+439
View File
@@ -0,0 +1,439 @@
// Copyright 2023 The Wuffs Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------
// manual-test-truncated-input tests that decoding truncated versions of
// well-formed files produces a "truncated input" error.
//
// It tests every M-byte prefix of a valid N-byte file, for every positive M
// that satisfies (M < 65536) or ((N - M) <= 1024). The truncation point is
// either within 64 KiB of the start or 1 KiB of the end. It does not test
// every potential M in between, as that would take O(N**2) time.
#include <dirent.h>
#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
// Wuffs ships as a "single file C library" or "header file library" as per
// https://github.com/nothings/stb/blob/master/docs/stb_howto.txt
//
// To use that single file as a "foo.c"-like implementation, instead of a
// "foo.h"-like header, #define WUFFS_IMPLEMENTATION before #include'ing or
// compiling it.
#define WUFFS_IMPLEMENTATION
// Defining the WUFFS_CONFIG__STATIC_FUNCTIONS macro is optional, but when
// combined with WUFFS_IMPLEMENTATION, it demonstrates making all of Wuffs'
// functions have static storage.
//
// This can help the compiler ignore or discard unused code, which can produce
// faster compiles and smaller binaries. Other motivations are discussed in the
// "ALLOW STATIC IMPLEMENTATION" section of
// https://raw.githubusercontent.com/nothings/stb/master/docs/stb_howto.txt
#define WUFFS_CONFIG__STATIC_FUNCTIONS
// Defining the WUFFS_CONFIG__MODULE* macros are optional, but it lets users of
// release/c/etc.c choose which parts of Wuffs to build. That file contains the
// entire Wuffs standard library, implementing a variety of codecs and file
// formats. Without this macro definition, an optimizing compiler or linker may
// very well discard Wuffs code for unused codecs, but listing the Wuffs
// modules we use makes that process explicit. Preprocessing means that such
// code simply isn't compiled.
#define WUFFS_CONFIG__MODULES
#define WUFFS_CONFIG__MODULE__ADLER32
#define WUFFS_CONFIG__MODULE__BASE
#define WUFFS_CONFIG__MODULE__BMP
#define WUFFS_CONFIG__MODULE__BZIP2
#define WUFFS_CONFIG__MODULE__CRC32
#define WUFFS_CONFIG__MODULE__DEFLATE
#define WUFFS_CONFIG__MODULE__GIF
#define WUFFS_CONFIG__MODULE__GZIP
#define WUFFS_CONFIG__MODULE__LZW
#define WUFFS_CONFIG__MODULE__NIE
#define WUFFS_CONFIG__MODULE__PNG
#define WUFFS_CONFIG__MODULE__TGA
#define WUFFS_CONFIG__MODULE__ZLIB
// If building this program in an environment that doesn't easily accommodate
// relative includes, you can use the script/inline-c-relative-includes.go
// program to generate a stand-alone C file.
#include "../release/c/wuffs-unsupported-snapshot.c"
// ----
#ifndef DST_BUFFER_ARRAY_SIZE
#define DST_BUFFER_ARRAY_SIZE (64 * 1024 * 1024)
#endif
#ifndef WORKBUF_ARRAY_SIZE
#define WORKBUF_ARRAY_SIZE (256 * 1024 * 1024)
#endif
uint8_t g_dst_buffer_array[DST_BUFFER_ARRAY_SIZE] = {0};
uint8_t g_workbuf_array[WORKBUF_ARRAY_SIZE] = {0};
static int g_num_files_processed;
static struct {
char buf[PATH_MAX];
size_t len;
} g_relative_cwd;
// ----
static const char skipped[] = "skipped";
static const char unsupported_file_format[] = "unsupported file format";
static const char* //
handle_image_decoder(wuffs_base__io_buffer src,
int32_t fourcc,
bool full_decode) {
wuffs_base__image_decoder::unique_ptr dec(nullptr, &free);
switch (fourcc) {
case WUFFS_BASE__FOURCC__BMP:
dec = wuffs_bmp__decoder::alloc_as__wuffs_base__image_decoder();
break;
case WUFFS_BASE__FOURCC__GIF:
dec = wuffs_gif__decoder::alloc_as__wuffs_base__image_decoder();
break;
case WUFFS_BASE__FOURCC__NIE:
dec = wuffs_nie__decoder::alloc_as__wuffs_base__image_decoder();
break;
case WUFFS_BASE__FOURCC__PNG:
dec = wuffs_png__decoder::alloc_as__wuffs_base__image_decoder();
break;
case WUFFS_BASE__FOURCC__TGA:
dec = wuffs_tga__decoder::alloc_as__wuffs_base__image_decoder();
break;
case WUFFS_BASE__FOURCC__WBMP:
// Unsupported. wuffs_base__magic_number_guess_fourcc can sometimes
// return false positives for WBMP. The WBMP file format doesn't
// start with a "magic" identifier.
return unsupported_file_format;
default:
return unsupported_file_format;
}
if (!full_decode) {
while (true) {
auto dfc_status = dec->decode_frame_config(nullptr, &src);
if (dfc_status.is_ok()) {
// No-op.
} else if (dfc_status.repr == wuffs_base__note__end_of_data) {
break;
} else {
return dfc_status.message();
}
}
return nullptr;
}
wuffs_base__pixel_config pixcfg = {0};
pixcfg.set(WUFFS_BASE__PIXEL_FORMAT__BGRA_PREMUL,
WUFFS_BASE__PIXEL_SUBSAMPLING__NONE, 0, 0);
wuffs_base__pixel_buffer pixbuf = {0};
auto sfs_status =
pixbuf.set_from_slice(&pixcfg, wuffs_base__make_slice_u8(nullptr, 0));
if (!sfs_status.is_ok()) {
return sfs_status.message();
}
while (true) {
auto df_status = dec->decode_frame(
&pixbuf, &src, WUFFS_BASE__PIXEL_BLEND__SRC,
wuffs_base__make_slice_u8(g_workbuf_array, WORKBUF_ARRAY_SIZE),
nullptr);
if (df_status.is_ok()) {
// No-op.
} else if (df_status.repr == wuffs_base__note__end_of_data) {
break;
} else {
return df_status.message();
}
}
return nullptr;
}
static const char* //
handle_io_transformer(wuffs_base__io_buffer src, int32_t fourcc) {
wuffs_base__io_transformer::unique_ptr dec(nullptr, &free);
switch (fourcc) {
case WUFFS_BASE__FOURCC__BZ2:
dec = wuffs_bzip2__decoder::alloc_as__wuffs_base__io_transformer();
break;
case WUFFS_BASE__FOURCC__GZ:
dec = wuffs_gzip__decoder::alloc_as__wuffs_base__io_transformer();
break;
case WUFFS_BASE__FOURCC__ZLIB:
dec = wuffs_zlib__decoder::alloc_as__wuffs_base__io_transformer();
break;
default:
return unsupported_file_format;
}
while (true) {
auto dst = wuffs_base__ptr_u8__writer(&g_dst_buffer_array[0],
DST_BUFFER_ARRAY_SIZE);
auto df_status = dec->transform_io(
&dst, &src,
wuffs_base__make_slice_u8(g_workbuf_array, WORKBUF_ARRAY_SIZE));
if (df_status.is_ok()) {
break;
} else if (df_status.repr == wuffs_base__suspension__short_write) {
// No-op.
} else {
return df_status.message();
}
}
return nullptr;
}
static const char* //
handle_various(wuffs_base__io_buffer src, int32_t fourcc) {
const char* status_msg;
status_msg = handle_image_decoder(src, fourcc, false);
if (status_msg != unsupported_file_format) {
if ((status_msg != nullptr) && !strstr(status_msg, "truncated input")) {
return status_msg;
}
return handle_image_decoder(src, fourcc, true);
}
status_msg = handle_io_transformer(src, fourcc);
if (status_msg != unsupported_file_format) {
return status_msg;
}
return unsupported_file_format;
}
static const char* //
handle_range(wuffs_base__io_buffer src,
int32_t fourcc,
size_t wi_min_incl,
size_t wi_max_excl) {
for (size_t wi = wi_min_incl; wi < wi_max_excl; wi++) {
src.meta.wi = wi;
const char* status_msg = handle_various(src, fourcc);
if ((status_msg != nullptr) && strstr(status_msg, "truncated input")) {
continue;
}
printf("when truncated to %zu bytes: ", wi);
if (status_msg) {
return status_msg;
}
return "have ok; want \"truncated input\"";
}
return nullptr;
}
static const char* //
handle(const uint8_t* ptr, size_t len) {
auto src = wuffs_base__ptr_u8__reader(const_cast<uint8_t*>(ptr), len, true);
int32_t fourcc = wuffs_base__magic_number_guess_fourcc(src.reader_slice(),
src.meta.closed);
if (fourcc <= 0) {
return skipped;
}
// Skip any invalid or unsupported input (when decoded in its entirety).
//
// Unsupported includes ignoring wuffs_base__note__i_o_redirect. We don't
// bother testing truncated PNGs-embedded-in-BMPs because we presumably
// already test truncated PNGs.
const char* status_msg = handle_various(src, fourcc);
if (status_msg) {
return skipped;
}
size_t file_len = src.meta.wi;
if (file_len <= (65536 + 1024)) {
return handle_range(src, fourcc, 1, file_len);
}
status_msg = handle_range(src, fourcc, 1, 65536);
if (status_msg) {
return status_msg;
}
return handle_range(src, fourcc, file_len - 1024, file_len);
}
// ----
static int //
visit(char* filename);
static int //
visit_dir(int fd) {
int cwd_fd = open(".", O_RDONLY, 0);
if (fchdir(fd)) {
printf("failed\n");
fprintf(stderr, "FAIL: fchdir: %s\n", strerror(errno));
return 1;
}
DIR* d = fdopendir(fd);
if (!d) {
printf("failed\n");
fprintf(stderr, "FAIL: fdopendir: %s\n", strerror(errno));
return 1;
}
printf("dir\n");
while (true) {
struct dirent* e = readdir(d);
if (!e) {
break;
}
if ((e->d_name[0] == '\x00') || (e->d_name[0] == '.')) {
continue;
}
int v = visit(e->d_name);
if (v) {
return v;
}
}
if (closedir(d)) {
fprintf(stderr, "FAIL: closedir: %s\n", strerror(errno));
return 1;
}
if (fchdir(cwd_fd)) {
fprintf(stderr, "FAIL: fchdir: %s\n", strerror(errno));
return 1;
}
if (close(cwd_fd)) {
fprintf(stderr, "FAIL: close: %s\n", strerror(errno));
return 1;
}
return 0;
}
static int //
visit_reg(int fd, off_t size) {
if ((size < 0) || (0x7FFFFFFF < size)) {
printf("failed\n");
fprintf(stderr, "FAIL: file size out of bounds");
return 1;
}
void* data = NULL;
if (size > 0) {
data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (data == MAP_FAILED) {
printf("failed\n");
fprintf(stderr, "FAIL: mmap: %s\n", strerror(errno));
return 1;
}
}
const char* msg = handle((const uint8_t*)(data), size);
if (msg) {
printf("%s\n", msg);
} else {
printf("ok\n");
}
if ((size > 0) && munmap(data, size)) {
fprintf(stderr, "FAIL: mmap: %s\n", strerror(errno));
return 1;
}
if (close(fd)) {
fprintf(stderr, "FAIL: close: %s\n", strerror(errno));
return 1;
}
return (msg && (msg != skipped)) ? 1 : 0;
}
static int //
visit(char* filename) {
g_num_files_processed++;
if (!filename || (filename[0] == '\x00')) {
fprintf(stderr, "FAIL: invalid filename\n");
return 1;
}
int n = printf("- %s%s", g_relative_cwd.buf, filename);
printf("%*s", (60 > n) ? (60 - n) : 1, "");
fflush(stdout);
struct stat z;
int fd = open(filename, O_RDONLY, 0);
if (fd == -1) {
printf("failed\n");
fprintf(stderr, "FAIL: open: %s\n", strerror(errno));
return 1;
}
if (fstat(fd, &z)) {
printf("failed\n");
fprintf(stderr, "FAIL: fstat: %s\n", strerror(errno));
return 1;
}
if (S_ISREG(z.st_mode)) {
return visit_reg(fd, z.st_size);
} else if (!S_ISDIR(z.st_mode)) {
printf("skipped\n");
return 0;
}
size_t old_len = g_relative_cwd.len;
size_t filename_len = strlen(filename);
size_t new_len = old_len + strlen(filename);
bool slash = filename[filename_len - 1] != '/';
if (slash) {
new_len++;
}
if ((filename_len >= PATH_MAX) || (new_len >= PATH_MAX)) {
printf("failed\n");
fprintf(stderr, "FAIL: path is too long\n");
return 1;
}
memcpy(g_relative_cwd.buf + old_len, filename, filename_len);
if (slash) {
g_relative_cwd.buf[new_len - 1] = '/';
}
g_relative_cwd.buf[new_len] = '\x00';
g_relative_cwd.len = new_len;
int v = visit_dir(fd);
g_relative_cwd.buf[old_len] = '\x00';
g_relative_cwd.len = old_len;
return v;
}
int //
main(int argc, char** argv) {
g_num_files_processed = 0;
g_relative_cwd.len = 0;
for (int i = 1; i < argc; i++) {
int v = visit(argv[i]);
if (v) {
return v;
}
}
printf("PASS: %d files processed\n", g_num_files_processed);
return 0;
}
+4
View File
@@ -229,6 +229,10 @@ print_raw_passthrough(wuffs_base__io_buffer* src,
break; break;
} }
uint64_t n1 = src->reader_length(); uint64_t n1 = src->reader_length();
while (n1 == 0) {
TRY(read_buffer_from_file(src, f));
n1 = src->reader_length();
}
uint64_t n = wuffs_base__u64__min(n0, n1); uint64_t n = wuffs_base__u64__min(n0, n1);
print_hex_dump(src->reader_pointer(), n); print_hex_dump(src->reader_pointer(), n);
src->meta.ri += n; src->meta.ri += n;
+123 -23
View File
@@ -14,6 +14,7 @@
pub status "#bad header" pub status "#bad header"
pub status "#bad RLE compression" pub status "#bad RLE compression"
pub status "#truncated input"
pub status "#unsupported BMP file" pub status "#unsupported BMP file"
pri status "@internal note: short read" pri status "@internal note: short read"
@@ -49,7 +50,7 @@ pub struct decoder? implements base.image_decoder(
bitmap_info_len : base.u32, bitmap_info_len : base.u32,
padding : base.u32, padding : base.u32,
bits_per_pixel : base.u32, bits_per_pixel : base.u32[..= 0xFFFF],
compression : base.u32, compression : base.u32,
// channel_etc's indexes are: B, G, R, A. This is in Wuffs' default order, // channel_etc's indexes are: B, G, R, A. This is in Wuffs' default order,
@@ -85,6 +86,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
} }
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var magic : base.u32 var magic : base.u32
var width : base.u32 var width : base.u32
var height : base.u32 var height : base.u32
@@ -370,10 +383,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
} }
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
if this.call_sequence == 0x20 { if this.call_sequence == 0x20 {
// No-op. // No-op.
} else if this.call_sequence < 0x20 { } else if this.call_sequence < 0x20 {
this.decode_image_config?(dst: nullptr, src: args.src) this.do_decode_image_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 0x28 { } else if this.call_sequence == 0x28 {
if this.frame_config_io_position <> args.src.position() { if this.frame_config_io_position <> args.src.position() {
return base."#bad restart" return base."#bad restart"
@@ -406,10 +431,22 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status var status : base.status
while true {
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status
if this.call_sequence == 0x40 { if this.call_sequence == 0x40 {
// No-op. // No-op.
} else if this.call_sequence < 0x40 { } else if this.call_sequence < 0x40 {
this.decode_frame_config?(dst: nullptr, src: args.src) this.do_decode_frame_config?(dst: nullptr, src: args.src)
} else { } else {
return base."@end of data" return base."@end of data"
} }
@@ -467,10 +504,12 @@ pri func decoder.swizzle_none!(dst: ptr base.pixel_buffer, src: base.io_reader)
var dst_bits_per_pixel : base.u32[..= 256] var dst_bits_per_pixel : base.u32[..= 256]
var dst_bytes_per_pixel : base.u64[..= 32] var dst_bytes_per_pixel : base.u64[..= 32]
var dst_bytes_per_row : base.u64 var dst_bytes_per_row : base.u64
var src_bytes_per_pixel : base.u32[..= 4]
var dst_palette : slice base.u8 var dst_palette : slice base.u8
var tab : table base.u8 var tab : table base.u8
var dst : slice base.u8 var dst : slice base.u8
var i : base.u64 var i : base.u64
var j : base.u64
var n : base.u64 var n : base.u64
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able // TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
@@ -515,14 +554,38 @@ pri func decoder.swizzle_none!(dst: ptr base.pixel_buffer, src: base.io_reader)
} }
i = (this.dst_x as base.u64) * dst_bytes_per_pixel i = (this.dst_x as base.u64) * dst_bytes_per_pixel
if i >= dst.length() { if i >= dst.length() {
// TODO: advance args.src if the dst pixel_buffer bounds is if this.bits_per_pixel > 32 {
// smaller than this BMP's image bounds? return "#unsupported BMP file"
continue.inner }
src_bytes_per_pixel = this.bits_per_pixel / 8
if src_bytes_per_pixel == 0 {
return "#unsupported BMP file"
}
n = args.src.length() / (src_bytes_per_pixel as base.u64)
n = n.min(a: (this.width ~mod- this.dst_x) as base.u64)
j = n
while j >= 8 {
if args.src.length() >= ((src_bytes_per_pixel * 8) as base.u64) {
args.src.skip_u32_fast!(
actual: src_bytes_per_pixel * 8,
worst_case: src_bytes_per_pixel * 8)
}
j -= 8
} endwhile
while j > 0 {
if args.src.length() >= ((src_bytes_per_pixel * 1) as base.u64) {
args.src.skip_u32_fast!(
actual: src_bytes_per_pixel * 1,
worst_case: src_bytes_per_pixel * 1)
}
j -= 1
} endwhile
} else {
n = this.swizzler.swizzle_interleaved_from_reader!(
dst: dst[i ..],
dst_palette: dst_palette,
src: args.src)
} }
n = this.swizzler.swizzle_interleaved_from_reader!(
dst: dst[i ..],
dst_palette: dst_palette,
src: args.src)
if n == 0 { if n == 0 {
return "@internal note: short read" return "@internal note: short read"
} }
@@ -906,15 +969,13 @@ pri func decoder.swizzle_bitfields!(dst: ptr base.pixel_buffer, src: base.io_rea
} }
i = (this.dst_x as base.u64) * dst_bytes_per_pixel i = (this.dst_x as base.u64) * dst_bytes_per_pixel
if i >= dst.length() { if i >= dst.length() {
// TODO: advance args.src if the dst pixel_buffer bounds is n = p0 as base.u64
// smaller than this BMP's image bounds? } else {
continue.inner n = this.swizzler.swizzle_interleaved_from_slice!(
dst: dst[i ..],
dst_palette: dst_palette,
src: this.scratch[.. 8 * p0])
} }
n = this.swizzler.swizzle_interleaved_from_slice!(
dst: dst[i ..],
dst_palette: dst_palette,
src: this.scratch[.. 8 * p0])
if n == 0 { if n == 0 {
return "@internal note: short read" return "@internal note: short read"
} }
@@ -938,8 +999,9 @@ pri func decoder.swizzle_low_bit_depth!(dst: ptr base.pixel_buffer, src: base.io
var p0 : base.u32[..= 543] var p0 : base.u32[..= 543]
var chunk_bits : base.u32 var chunk_bits : base.u32
var chunk_count : base.u32 var chunk_count : base.u32
var pixels_per_chunk : base.u32[..= 32]
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able // TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
// to chain the two calls: "args.dst.pixel_format().bits_per_pixel()". // to chain the two calls: "args.dst.pixel_format().bits_per_pixel()".
@@ -968,8 +1030,34 @@ pri func decoder.swizzle_low_bit_depth!(dst: ptr base.pixel_buffer, src: base.io
} }
i = (this.dst_x as base.u64) * dst_bytes_per_pixel i = (this.dst_x as base.u64) * dst_bytes_per_pixel
if i >= dst.length() { if i >= dst.length() {
// TODO: advance args.src if the dst pixel_buffer bounds is if this.bits_per_pixel == 1 {
// smaller than this BMP's image bounds? chunk_count = ((this.width ~sat- this.dst_x) + 31) / 32
pixels_per_chunk = 32
} else if this.bits_per_pixel == 2 {
chunk_count = ((this.width ~sat- this.dst_x) + 15) / 16
pixels_per_chunk = 16
} else {
chunk_count = ((this.width ~sat- this.dst_x) + 7) / 8
pixels_per_chunk = 8
}
while (chunk_count >= 64) and (args.src.length() >= 256) {
args.src.skip_u32_fast!(actual: 256, worst_case: 256)
this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 64))
chunk_count -= 64
} endwhile
while (chunk_count >= 8) and (args.src.length() >= 32) {
args.src.skip_u32_fast!(actual: 32, worst_case: 32)
this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 8))
chunk_count -= 8
} endwhile
while chunk_count > 0 {
if args.src.length() < 4 {
return "@internal note: short read"
}
args.src.skip_u32_fast!(actual: 4, worst_case: 4)
this.dst_x = this.width.min(a: this.dst_x ~mod+ (pixels_per_chunk * 1))
chunk_count -= 1
} endwhile
continue.loop continue.loop
} }
dst = dst[i ..] dst = dst[i ..]
@@ -1047,7 +1135,7 @@ pri func decoder.swizzle_low_bit_depth!(dst: ptr base.pixel_buffer, src: base.io
chunk_count -= 1 chunk_count -= 1
} endwhile } endwhile
} else if this.bits_per_pixel == 4 { } else {
// Calculate the remaining number of 32-bit chunks. At 4 bits per // Calculate the remaining number of 32-bit chunks. At 4 bits per
// pixel there are 8 pixels per chunk. Division rounds up. // pixel there are 8 pixels per chunk. Division rounds up.
chunk_count = ((this.width ~sat- this.dst_x) + 7) / 8 chunk_count = ((this.width ~sat- this.dst_x) + 7) / 8
@@ -1125,6 +1213,18 @@ pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
} }
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) { pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_tell_me_more?(dst: args.dst, minfo: args.minfo, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
if this.io_redirect_fourcc <= 1 { if this.io_redirect_fourcc <= 1 {
return base."#no more information" return base."#no more information"
} }
+13
View File
@@ -19,6 +19,7 @@ pub status "#bad block length"
pub status "#bad checksum" pub status "#bad checksum"
pub status "#bad header" pub status "#bad header"
pub status "#bad number of sections" pub status "#bad number of sections"
pub status "#truncated input"
pub status "#unsupported block randomization" pub status "#unsupported block randomization"
pri status "#internal error: inconsistent Huffman decoder state" pri status "#internal error: inconsistent Huffman decoder state"
@@ -121,6 +122,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
} }
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) { pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var status : base.status
while true {
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var c : base.u8 var c : base.u8
var i : base.u32 var i : base.u32
var tag : base.u64 var tag : base.u64
+13
View File
@@ -25,6 +25,7 @@ pub status "#bad literal/length code count"
pub status "#inconsistent stored block length" pub status "#inconsistent stored block length"
pub status "#missing end-of-block code" pub status "#missing end-of-block code"
pub status "#no Huffman codes" pub status "#no Huffman codes"
pub status "#truncated input"
pri status "#internal error: inconsistent Huffman decoder state" pri status "#internal error: inconsistent Huffman decoder state"
pri status "#internal error: inconsistent I/O" pri status "#internal error: inconsistent I/O"
@@ -208,6 +209,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
} }
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) { pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var status : base.status
while true {
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var mark : base.u64 var mark : base.u64
var status : base.status var status : base.status
+1
View File
@@ -20,6 +20,7 @@ pub status "#bad graphic control"
pub status "#bad header" pub status "#bad header"
pub status "#bad literal width" pub status "#bad literal width"
pub status "#bad palette" pub status "#bad palette"
pub status "#truncated input"
pri status "#internal error: inconsistent ri/wi" pri status "#internal error: inconsistent ri/wi"
+51 -3
View File
@@ -98,6 +98,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
} }
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var ffio : base.bool var ffio : base.bool
if this.call_sequence <> 0x00 { if this.call_sequence <> 0x00 {
@@ -150,6 +162,18 @@ pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
} }
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) { pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_tell_me_more?(dst: args.dst, minfo: args.minfo, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
var chunk_length : base.u64 var chunk_length : base.u64
if (this.call_sequence & 0x10) == 0 { if (this.call_sequence & 0x10) == 0 {
@@ -296,6 +320,18 @@ pub func decoder.restart_frame!(index: base.u64, io_position: base.u64) base.sta
} }
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var background_color : base.u32 var background_color : base.u32
var flags : base.u8 var flags : base.u8
@@ -306,7 +342,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
} else if this.call_sequence == 0x20 { } else if this.call_sequence == 0x20 {
// No-op. // No-op.
} else if this.call_sequence < 0x20 { } else if this.call_sequence < 0x20 {
this.decode_image_config?(dst: nullptr, src: args.src) this.do_decode_image_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 0x28 { } else if this.call_sequence == 0x28 {
if this.frame_config_io_position <> args.src.position() { if this.frame_config_io_position <> args.src.position() {
return base."#bad restart" return base."#bad restart"
@@ -397,12 +433,24 @@ pri func decoder.skip_frame?(src: base.io_reader) {
this.call_sequence = 0x20 this.call_sequence = 0x20
} }
// TODO: honor args.opts.
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status
while true {
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
// TODO: honor args.opts.
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
if this.call_sequence == 0x40 { if this.call_sequence == 0x40 {
// No-op. // No-op.
} else if this.call_sequence < 0x40 { } else if this.call_sequence < 0x40 {
this.decode_frame_config?(dst: nullptr, src: args.src) this.do_decode_frame_config?(dst: nullptr, src: args.src)
} else { } else {
return base."@end of data" return base."@end of data"
} }
+13
View File
@@ -19,6 +19,7 @@ pub status "#bad checksum"
pub status "#bad compression method" pub status "#bad compression method"
pub status "#bad encoding flags" pub status "#bad encoding flags"
pub status "#bad header" pub status "#bad header"
pub status "#truncated input"
// TODO: reference deflate.DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE. // TODO: reference deflate.DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE.
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 1 pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 1
@@ -45,6 +46,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
} }
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) { pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var status : base.status
while true {
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var c : base.u8 var c : base.u8
var flags : base.u8 var flags : base.u8
var xlen : base.u16 var xlen : base.u16
+16 -5
View File
@@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
pub status "#bad code" pub status "#bad code"
pub status "#truncated input"
pri status "#internal error: inconsistent I/O" pri status "#internal error: inconsistent I/O"
@@ -119,6 +120,8 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf
} else if this.read_from_return_value == 2 { } else if this.read_from_return_value == 2 {
yield? base."$short read" yield? base."$short read"
} else if this.read_from_return_value == 3 { } else if this.read_from_return_value == 3 {
return "#truncated input"
} else if this.read_from_return_value == 4 {
return "#bad code" return "#bad code"
} else { } else {
return "#internal error: inconsistent I/O" return "#internal error: inconsistent I/O"
@@ -167,7 +170,11 @@ pri func decoder.read_from!(src: base.io_reader) {
assert width <= n_bits via "a <= b: a <= c; c <= b"(c: 12) assert width <= n_bits via "a <= b: a <= c; c <= b"(c: 12)
assert n_bits >= width via "a >= b: b <= a"() assert n_bits >= width via "a >= b: b <= a"()
} else if args.src.length() <= 0 { } else if args.src.length() <= 0 {
this.read_from_return_value = 2 if args.src.is_closed() {
this.read_from_return_value = 3
} else {
this.read_from_return_value = 2
}
break break
} else { } else {
bits |= args.src.peek_u8_as_u32() << n_bits bits |= args.src.peek_u8_as_u32() << n_bits
@@ -176,7 +183,11 @@ pri func decoder.read_from!(src: base.io_reader) {
if n_bits >= width { if n_bits >= width {
// No-op. // No-op.
} else if args.src.length() <= 0 { } else if args.src.length() <= 0 {
this.read_from_return_value = 2 if args.src.is_closed() {
this.read_from_return_value = 3
} else {
this.read_from_return_value = 2
}
break break
} else { } else {
bits |= args.src.peek_u8_as_u32() << n_bits bits |= args.src.peek_u8_as_u32() << n_bits
@@ -188,7 +199,7 @@ pri func decoder.read_from!(src: base.io_reader) {
// This if condition is always false, but for some unknown // This if condition is always false, but for some unknown
// reason, removing it worsens the benchmarks slightly. // reason, removing it worsens the benchmarks slightly.
if n_bits < width { if n_bits < width {
this.read_from_return_value = 4 this.read_from_return_value = 5
break break
} }
} }
@@ -297,7 +308,7 @@ pri func decoder.read_from!(src: base.io_reader) {
} }
} else { } else {
this.read_from_return_value = 3 this.read_from_return_value = 4
break break
} }
@@ -319,7 +330,7 @@ pri func decoder.read_from!(src: base.io_reader) {
if args.src.can_undo_byte() { if args.src.can_undo_byte() {
args.src.undo_byte!() args.src.undo_byte!()
} else { } else {
this.read_from_return_value = 4 this.read_from_return_value = 5
break break
} }
} endwhile } endwhile
+71 -9
View File
@@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
pub status "#bad header" pub status "#bad header"
pub status "#truncated input"
pub status "#unsupported NIE file" pub status "#unsupported NIE file"
pri status "@internal note: short read" pri status "@internal note: short read"
@@ -39,6 +40,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
} }
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var a : base.u32 var a : base.u32
if this.call_sequence <> 0x00 { if this.call_sequence <> 0x00 {
@@ -89,10 +102,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
} }
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
if this.call_sequence == 0x20 { if this.call_sequence == 0x20 {
// No-op. // No-op.
} else if this.call_sequence < 0x20 { } else if this.call_sequence < 0x20 {
this.decode_image_config?(dst: nullptr, src: args.src) this.do_decode_image_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 0x28 { } else if this.call_sequence == 0x28 {
if 16 <> args.src.position() { if 16 <> args.src.position() {
return base."#bad restart" return base."#bad restart"
@@ -125,10 +150,22 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status var status : base.status
while true {
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status
if this.call_sequence == 0x40 { if this.call_sequence == 0x40 {
// No-op. // No-op.
} else if this.call_sequence < 0x40 { } else if this.call_sequence < 0x40 {
this.decode_frame_config?(dst: nullptr, src: args.src) this.do_decode_frame_config?(dst: nullptr, src: args.src)
} else { } else {
return base."@end of data" return base."@end of data"
} }
@@ -164,9 +201,11 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: base.io_reader) base.
var dst_bits_per_pixel : base.u32[..= 256] var dst_bits_per_pixel : base.u32[..= 256]
var dst_bytes_per_pixel : base.u64[..= 32] var dst_bytes_per_pixel : base.u64[..= 32]
var dst_bytes_per_row : base.u64 var dst_bytes_per_row : base.u64
var src_bytes_per_pixel : base.u32[..= 8]
var tab : table base.u8 var tab : table base.u8
var dst : slice base.u8 var dst : slice base.u8
var i : base.u64 var i : base.u64
var j : base.u64
var n : base.u64 var n : base.u64
// TODO: the dst_pixfmt variable shouldn't be necessary. We should be able // TODO: the dst_pixfmt variable shouldn't be necessary. We should be able
@@ -195,14 +234,37 @@ pri func decoder.swizzle!(dst: ptr base.pixel_buffer, src: base.io_reader) base.
} }
i = (this.dst_x as base.u64) * dst_bytes_per_pixel i = (this.dst_x as base.u64) * dst_bytes_per_pixel
if i >= dst.length() { if i >= dst.length() {
// TODO: advance args.src if the dst pixel_buffer bounds is src_bytes_per_pixel = 4
// smaller than this NIE's image bounds? assert src_bytes_per_pixel > 0
continue if this.pixfmt == base.PIXEL_FORMAT__BGRA_NONPREMUL_4X16LE {
src_bytes_per_pixel = 8
assert src_bytes_per_pixel > 0
}
n = args.src.length() / (src_bytes_per_pixel as base.u64)
n = n.min(a: (this.width ~mod- this.dst_x) as base.u64)
j = n
while j >= 8 {
if args.src.length() >= ((src_bytes_per_pixel * 8) as base.u64) {
args.src.skip_u32_fast!(
actual: src_bytes_per_pixel * 8,
worst_case: src_bytes_per_pixel * 8)
}
j -= 8
} endwhile
while j > 0 {
if args.src.length() >= ((src_bytes_per_pixel * 1) as base.u64) {
args.src.skip_u32_fast!(
actual: src_bytes_per_pixel * 1,
worst_case: src_bytes_per_pixel * 1)
}
j -= 1
} endwhile
} else {
n = this.swizzler.swizzle_interleaved_from_reader!(
dst: dst[i ..],
dst_palette: args.dst.palette(),
src: args.src)
} }
n = this.swizzler.swizzle_interleaved_from_reader!(
dst: dst[i ..],
dst_palette: args.dst.palette(),
src: args.src)
if n == 0 { if n == 0 {
return "@internal note: short read" return "@internal note: short read"
} }
+1
View File
@@ -19,6 +19,7 @@ pub status "#bad filter"
pub status "#bad header" pub status "#bad header"
pub status "#bad text chunk (not Latin-1)" pub status "#bad text chunk (not Latin-1)"
pub status "#missing palette" pub status "#missing palette"
pub status "#truncated input"
pub status "#unsupported CgBI extension" pub status "#unsupported CgBI extension"
pub status "#unsupported PNG compression method" pub status "#unsupported PNG compression method"
pub status "#unsupported PNG file" pub status "#unsupported PNG file"
+62 -29
View File
@@ -163,6 +163,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
} }
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var magic : base.u64 var magic : base.u64
var mark : base.u64 var mark : base.u64
var checksum_have : base.u32 var checksum_have : base.u32
@@ -229,14 +241,10 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
// IDAT chunk breaks the loop. The only other possible critical chunk is a // IDAT chunk breaks the loop. The only other possible critical chunk is a
// PLTE chunk. We verify PLTE checksums here but ignore other checksums. // PLTE chunk. We verify PLTE checksums here but ignore other checksums.
while true { while true {
while args.src.length() < 8, if args.src.length() < 8 {
post args.src.length() >= 8,
{
if args.src.is_closed() {
return "#bad chunk"
}
yield? base."$short read" yield? base."$short read"
} endwhile continue
}
this.chunk_length = args.src.peek_u32be() this.chunk_length = args.src.peek_u32be()
this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32 this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32
@@ -934,6 +942,18 @@ pri func decoder.decode_trns?(src: base.io_reader) {
} }
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var checksum_have : base.u32 var checksum_have : base.u32
if (this.call_sequence & 0x10) <> 0 { if (this.call_sequence & 0x10) <> 0 {
@@ -941,7 +961,7 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
} else if this.call_sequence == 0x20 { } else if this.call_sequence == 0x20 {
// No-op. // No-op.
} else if this.call_sequence < 0x20 { } else if this.call_sequence < 0x20 {
this.decode_image_config?(dst: nullptr, src: args.src) this.do_decode_image_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 0x28 { } else if this.call_sequence == 0x28 {
if this.frame_config_io_position <> args.src.position() { if this.frame_config_io_position <> args.src.position() {
return base."#bad restart" return base."#bad restart"
@@ -1029,14 +1049,10 @@ pri func decoder.skip_frame?(src: base.io_reader) {
this.chunk_type_array[3] = 0 this.chunk_type_array[3] = 0
while true { while true {
while args.src.length() < 8, if args.src.length() < 8 {
post args.src.length() >= 8,
{
if args.src.is_closed() {
return "#bad chunk"
}
yield? base."$short read" yield? base."$short read"
} endwhile continue
}
this.chunk_length = args.src.peek_u32be() this.chunk_length = args.src.peek_u32be()
this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32 this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32
@@ -1091,6 +1107,18 @@ pri func decoder.skip_frame?(src: base.io_reader) {
} }
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status
while true {
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var seq_num : base.u32 var seq_num : base.u32
var status : base.status var status : base.status
var pass_width : base.u32[..= 0x00FF_FFFF] var pass_width : base.u32[..= 0x00FF_FFFF]
@@ -1101,18 +1129,14 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
} else if this.call_sequence >= 0x60 { } else if this.call_sequence >= 0x60 {
return base."@end of data" return base."@end of data"
} else if this.call_sequence <> 0x40 { } else if this.call_sequence <> 0x40 {
this.decode_frame_config?(dst: nullptr, src: args.src) this.do_decode_frame_config?(dst: nullptr, src: args.src)
} }
while true { while true {
while args.src.length() < 8, if args.src.length() < 8 {
post args.src.length() >= 8,
{
if args.src.is_closed() {
return "#bad chunk"
}
yield? base."$short read" yield? base."$short read"
} endwhile continue
}
this.chunk_length = args.src.peek_u32be() this.chunk_length = args.src.peek_u32be()
this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32 this.chunk_type = (args.src.peek_u64le() >> 32) as base.u32
@@ -1198,9 +1222,8 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
break break
} else if status.is_error() or } else if status.is_error() or
((status == base."$short read") and args.src.is_closed()) { ((status == base."$short read") and args.src.is_closed()) {
// The input was truncated or invalid. Produce whatever // The input was invalid or truncated. Produce whatever
// pixels we can and then, if truncated, generate "$short // pixels we can.
// read" forever.
if this.workbuf_wi <= args.workbuf.length() { if this.workbuf_wi <= args.workbuf.length() {
// This might return "#internal error: inconsistent // This might return "#internal error: inconsistent
// workbuf length" because of the ".. this.workbuf_wi". // workbuf length" because of the ".. this.workbuf_wi".
@@ -1208,9 +1231,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
this.filter_and_swizzle!(dst: args.dst, workbuf: args.workbuf[.. this.workbuf_wi]) this.filter_and_swizzle!(dst: args.dst, workbuf: args.workbuf[.. this.workbuf_wi])
} }
if status == base."$short read" { if status == base."$short read" {
while true { return "#truncated input"
yield? base."$short read"
} endwhile
} }
} }
yield? status yield? status
@@ -1390,6 +1411,18 @@ pub func decoder.set_report_metadata!(fourcc: base.u32, report: base.bool) {
} }
pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) { pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_tell_me_more?(dst: args.dst, minfo: args.minfo, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_tell_me_more?(dst: base.io_writer, minfo: nptr base.more_information, src: base.io_reader) {
var c : base.u8 var c : base.u8
var c2 : base.u16 var c2 : base.u16
var w : base.io_writer var w : base.io_writer
+39 -2
View File
@@ -14,6 +14,7 @@
pub status "#bad header" pub status "#bad header"
pub status "#bad run length encoding" pub status "#bad run length encoding"
pub status "#truncated input"
pub status "#unsupported TGA file" pub status "#unsupported TGA file"
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0 pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
@@ -55,6 +56,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
} }
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var c : base.u32 var c : base.u32
var c5 : base.u32[..= 0x1F] var c5 : base.u32[..= 0x1F]
var i : base.u32 var i : base.u32
@@ -226,10 +239,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
} }
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
if this.call_sequence == 0x20 { if this.call_sequence == 0x20 {
// No-op. // No-op.
} else if this.call_sequence < 0x20 { } else if this.call_sequence < 0x20 {
this.decode_image_config?(dst: nullptr, src: args.src) this.do_decode_image_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 0x28 { } else if this.call_sequence == 0x28 {
if this.frame_config_io_position <> args.src.position() { if this.frame_config_io_position <> args.src.position() {
return base."#bad restart" return base."#bad restart"
@@ -260,6 +285,18 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
} }
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status
while true {
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status var status : base.status
var dst_pixfmt : base.pixel_format var dst_pixfmt : base.pixel_format
var dst_bits_per_pixel : base.u32[..= 256] var dst_bits_per_pixel : base.u32[..= 256]
@@ -284,7 +321,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
if this.call_sequence == 0x40 { if this.call_sequence == 0x40 {
// No-op. // No-op.
} else if this.call_sequence < 0x40 { } else if this.call_sequence < 0x40 {
this.decode_frame_config?(dst: nullptr, src: args.src) this.do_decode_frame_config?(dst: nullptr, src: args.src)
} else { } else {
return base."@end of data" return base."@end of data"
} }
+39 -2
View File
@@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
pub status "#bad header" pub status "#bad header"
pub status "#truncated input"
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0 pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 0
@@ -34,6 +35,18 @@ pub func decoder.set_quirk_enabled!(quirk: base.u32, enabled: base.bool) {
} }
pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) { pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_image_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_image_config?(dst: nptr base.image_config, src: base.io_reader) {
var c : base.u8 var c : base.u8
var i : base.u32 var i : base.u32
var x32 : base.u32 var x32 : base.u32
@@ -97,10 +110,22 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
} }
pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) { pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
var status : base.status
while true {
status =? this.do_decode_frame_config?(dst: args.dst, src: args.src)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame_config?(dst: nptr base.frame_config, src: base.io_reader) {
if this.call_sequence == 0x20 { if this.call_sequence == 0x20 {
// No-op. // No-op.
} else if this.call_sequence < 0x20 { } else if this.call_sequence < 0x20 {
this.decode_image_config?(dst: nullptr, src: args.src) this.do_decode_image_config?(dst: nullptr, src: args.src)
} else if this.call_sequence == 0x28 { } else if this.call_sequence == 0x28 {
if this.frame_config_io_position <> args.src.position() { if this.frame_config_io_position <> args.src.position() {
return base."#bad restart" return base."#bad restart"
@@ -131,6 +156,18 @@ pub func decoder.decode_frame_config?(dst: nptr base.frame_config, src: base.io_
} }
pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) { pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status
while true {
status =? this.do_decode_frame?(dst: args.dst, src: args.src, blend: args.blend, workbuf: args.workbuf, opts: args.opts)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader, blend: base.pixel_blend, workbuf: slice base.u8, opts: nptr base.decode_frame_options) {
var status : base.status var status : base.status
var dst_pixfmt : base.pixel_format var dst_pixfmt : base.pixel_format
var dst_bits_per_pixel : base.u32[..= 256] var dst_bits_per_pixel : base.u32[..= 256]
@@ -146,7 +183,7 @@ pub func decoder.decode_frame?(dst: ptr base.pixel_buffer, src: base.io_reader,
if this.call_sequence == 0x40 { if this.call_sequence == 0x40 {
// No-op. // No-op.
} else if this.call_sequence < 0x40 { } else if this.call_sequence < 0x40 {
this.decode_frame_config?(dst: nullptr, src: args.src) this.do_decode_frame_config?(dst: nullptr, src: args.src)
} else { } else {
return base."@end of data" return base."@end of data"
} }
+13
View File
@@ -22,6 +22,7 @@ pub status "#bad compression method"
pub status "#bad compression window size" pub status "#bad compression window size"
pub status "#bad parity check" pub status "#bad parity check"
pub status "#incorrect dictionary" pub status "#incorrect dictionary"
pub status "#truncated input"
// TODO: reference deflate.DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE. // TODO: reference deflate.DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE.
pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 1 pub const DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE : base.u64 = 1
@@ -81,6 +82,18 @@ pub func decoder.workbuf_len() base.range_ii_u64 {
} }
pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) { pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var status : base.status
while true {
status =? this.do_transform_io?(dst: args.dst, src: args.src, workbuf: args.workbuf)
if (status == base."$short read") and args.src.is_closed() {
return "#truncated input"
}
yield? status
} endwhile
}
pri func decoder.do_transform_io?(dst: base.io_writer, src: base.io_reader, workbuf: slice base.u8) {
var x : base.u16 var x : base.u16
var checksum_got : base.u32 var checksum_got : base.u32
var status : base.status var status : base.status
+29
View File
@@ -101,6 +101,34 @@ test_wuffs_bmp_decode_interface() {
"test/data/hippopotamus.bmp", 0, SIZE_MAX, 36, 28, 0xFFF5F5F5); "test/data/hippopotamus.bmp", 0, SIZE_MAX, 36, 28, 0xFFF5F5F5);
} }
const char* //
test_wuffs_bmp_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_bmp__decoder dec;
CHECK_STATUS("initialize",
wuffs_bmp__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_bmp__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status = wuffs_bmp__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_bmp__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_bmp__error__truncated_input);
}
return NULL;
}
const char* // const char* //
test_wuffs_bmp_decode_frame_config() { test_wuffs_bmp_decode_frame_config() {
CHECK_FOCUS(__func__); CHECK_FOCUS(__func__);
@@ -213,6 +241,7 @@ proc g_tests[] = {
test_wuffs_bmp_decode_frame_config, test_wuffs_bmp_decode_frame_config,
test_wuffs_bmp_decode_interface, test_wuffs_bmp_decode_interface,
test_wuffs_bmp_decode_io_redirect, test_wuffs_bmp_decode_io_redirect,
test_wuffs_bmp_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
+31
View File
@@ -109,6 +109,36 @@ test_wuffs_bzip2_decode_interface() {
"test/data/romeo.txt.bz2", 0, SIZE_MAX, 942, 0x0A); "test/data/romeo.txt.bz2", 0, SIZE_MAX, 942, 0x0A);
} }
const char* //
test_wuffs_bzip2_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_bzip2__decoder dec;
CHECK_STATUS("initialize",
wuffs_bzip2__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_bzip2__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status =
wuffs_bzip2__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_bzip2__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_bzip2__error__truncated_input);
}
return NULL;
}
const char* // const char* //
wuffs_bzip2_decode(wuffs_base__io_buffer* dst, wuffs_bzip2_decode(wuffs_base__io_buffer* dst,
wuffs_base__io_buffer* src, wuffs_base__io_buffer* src,
@@ -262,6 +292,7 @@ proc g_tests[] = {
test_wuffs_bzip2_decode_interface, test_wuffs_bzip2_decode_interface,
test_wuffs_bzip2_decode_midsummer, test_wuffs_bzip2_decode_midsummer,
test_wuffs_bzip2_decode_pi, test_wuffs_bzip2_decode_pi,
test_wuffs_bzip2_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
+32
View File
@@ -92,6 +92,37 @@ test_wuffs_cbor_decode_interface() {
return NULL; return NULL;
} }
const char* //
test_wuffs_cbor_decode_empty_input() {
CHECK_FOCUS(__func__);
wuffs_base__token_buffer tok =
wuffs_base__slice_token__writer(g_have_slice_token);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_cbor__decoder dec;
CHECK_STATUS("initialize",
wuffs_cbor__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_cbor__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status =
wuffs_cbor__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
if (status.repr != wuffs_cbor__error__bad_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_cbor__error__bad_input);
}
return NULL;
}
const char* // const char* //
test_wuffs_cbor_decode_invalid() { test_wuffs_cbor_decode_invalid() {
CHECK_FOCUS(__func__); CHECK_FOCUS(__func__);
@@ -208,6 +239,7 @@ test_wuffs_cbor_decode_valid() {
proc g_tests[] = { proc g_tests[] = {
test_wuffs_cbor_decode_empty_input,
test_wuffs_cbor_decode_interface, test_wuffs_cbor_decode_interface,
test_wuffs_cbor_decode_invalid, test_wuffs_cbor_decode_invalid,
test_wuffs_cbor_decode_valid, test_wuffs_cbor_decode_valid,
+31
View File
@@ -166,6 +166,36 @@ test_wuffs_deflate_decode_interface() {
"test/data/romeo.txt.deflate", 0, SIZE_MAX, 942, 0x0A); "test/data/romeo.txt.deflate", 0, SIZE_MAX, 942, 0x0A);
} }
const char* //
test_wuffs_deflate_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_deflate__decoder dec;
CHECK_STATUS("initialize",
wuffs_deflate__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_deflate__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status =
wuffs_deflate__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_deflate__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_deflate__error__truncated_input);
}
return NULL;
}
const char* // const char* //
wuffs_deflate_decode(wuffs_base__io_buffer* dst, wuffs_deflate_decode(wuffs_base__io_buffer* dst,
wuffs_base__io_buffer* src, wuffs_base__io_buffer* src,
@@ -903,6 +933,7 @@ proc g_tests[] = {
test_wuffs_deflate_decode_romeo, test_wuffs_deflate_decode_romeo,
test_wuffs_deflate_decode_romeo_fixed, test_wuffs_deflate_decode_romeo_fixed,
test_wuffs_deflate_decode_split_src, test_wuffs_deflate_decode_split_src,
test_wuffs_deflate_decode_truncated_input,
test_wuffs_deflate_history_full, test_wuffs_deflate_history_full,
test_wuffs_deflate_history_partial, test_wuffs_deflate_history_partial,
test_wuffs_deflate_table_redirect, test_wuffs_deflate_table_redirect,
+32 -3
View File
@@ -182,6 +182,34 @@ test_wuffs_gif_decode_interface_image_decoder() {
"test/data/bricks-nodither.gif", 0, SIZE_MAX, 160, 120, 0xFF012463); "test/data/bricks-nodither.gif", 0, SIZE_MAX, 160, 120, 0xFF012463);
} }
const char* //
test_wuffs_gif_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_gif__decoder dec;
CHECK_STATUS("initialize",
wuffs_gif__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_gif__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status = wuffs_gif__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_gif__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_gif__error__truncated_input);
}
return NULL;
}
const char* // const char* //
wuffs_gif_decode(uint64_t* n_bytes_out, wuffs_gif_decode(uint64_t* n_bytes_out,
wuffs_base__io_buffer* dst, wuffs_base__io_buffer* dst,
@@ -1238,9 +1266,9 @@ test_wuffs_gif_decode_interlaced_truncated() {
wuffs_base__status status = wuffs_gif__decoder__decode_frame( wuffs_base__status status = wuffs_gif__decoder__decode_frame(
&dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, g_work_slice_u8, NULL); &dec, &pb, &src, WUFFS_BASE__PIXEL_BLEND__SRC, g_work_slice_u8, NULL);
if (status.repr != wuffs_base__suspension__short_read) { if (status.repr != wuffs_gif__error__truncated_input) {
RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr, RETURN_FAIL("decode_frame: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read); wuffs_gif__error__truncated_input);
} }
// Even though the source GIF data was truncated, replicating the interlaced // Even though the source GIF data was truncated, replicating the interlaced
@@ -1462,7 +1490,7 @@ test_wuffs_gif_decode_missing_two_src_bytes() {
src.meta.wi -= 2; src.meta.wi -= 2;
return do_test_wuffs_gif_decode_expecting( return do_test_wuffs_gif_decode_expecting(
src, 0, wuffs_base__suspension__short_read, false); src, 0, wuffs_gif__error__truncated_input, false);
} }
const char* // const char* //
@@ -2356,6 +2384,7 @@ proc g_tests[] = {
test_wuffs_gif_decode_pixfmt_bgra_nonpremul, test_wuffs_gif_decode_pixfmt_bgra_nonpremul,
test_wuffs_gif_decode_pixfmt_rgb, test_wuffs_gif_decode_pixfmt_rgb,
test_wuffs_gif_decode_pixfmt_rgba_nonpremul, test_wuffs_gif_decode_pixfmt_rgba_nonpremul,
test_wuffs_gif_decode_truncated_input,
test_wuffs_gif_decode_zero_width_frame, test_wuffs_gif_decode_zero_width_frame,
test_wuffs_gif_frame_dirty_rect, test_wuffs_gif_frame_dirty_rect,
test_wuffs_gif_num_decoded_frame_configs, test_wuffs_gif_num_decoded_frame_configs,
+32
View File
@@ -96,6 +96,36 @@ test_wuffs_gzip_decode_interface() {
"test/data/romeo.txt.gz", 0, SIZE_MAX, 942, 0x0A); "test/data/romeo.txt.gz", 0, SIZE_MAX, 942, 0x0A);
} }
const char* //
test_wuffs_gzip_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_gzip__decoder dec;
CHECK_STATUS("initialize",
wuffs_gzip__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_gzip__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status =
wuffs_gzip__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_gzip__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_gzip__error__truncated_input);
}
return NULL;
}
const char* // const char* //
wuffs_gzip_decode(wuffs_base__io_buffer* dst, wuffs_gzip_decode(wuffs_base__io_buffer* dst,
wuffs_base__io_buffer* src, wuffs_base__io_buffer* src,
@@ -255,6 +285,7 @@ test_wuffs_gzip_decode_infrequent_compaction() {
// Decode 5 source bytes at a time. Compact every 15 source bytes. // Decode 5 source bytes at a time. Compact every 15 source bytes.
for (size_t i = 0; i < src.data.len; i += 5) { for (size_t i = 0; i < src.data.len; i += 5) {
src.meta.wi = i; src.meta.wi = i;
src.meta.closed = false;
wuffs_base__status status = wuffs_base__status status =
wuffs_gzip__decoder__transform_io(&dec, &dst, &src, g_work_slice_u8); wuffs_gzip__decoder__transform_io(&dec, &dst, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) { if (status.repr != wuffs_base__suspension__short_read) {
@@ -361,6 +392,7 @@ proc g_tests[] = {
test_wuffs_gzip_decode_interface, test_wuffs_gzip_decode_interface,
test_wuffs_gzip_decode_midsummer, test_wuffs_gzip_decode_midsummer,
test_wuffs_gzip_decode_pi, test_wuffs_gzip_decode_pi,
test_wuffs_gzip_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
+32
View File
@@ -2579,6 +2579,37 @@ test_wuffs_json_decode_interface() {
return NULL; return NULL;
} }
const char* //
test_wuffs_json_decode_empty_input() {
CHECK_FOCUS(__func__);
wuffs_base__token_buffer tok =
wuffs_base__slice_token__writer(g_have_slice_token);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_json__decoder dec;
CHECK_STATUS("initialize",
wuffs_json__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_json__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status =
wuffs_json__decoder__decode_tokens(&dec, &tok, &src, g_work_slice_u8);
if (status.repr != wuffs_json__error__bad_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_json__error__bad_input);
}
return NULL;
}
const char* // const char* //
wuffs_json_decode(wuffs_base__token_buffer* tok, wuffs_json_decode(wuffs_base__token_buffer* tok,
wuffs_base__io_buffer* src, wuffs_base__io_buffer* src,
@@ -4198,6 +4229,7 @@ proc g_tests[] = {
test_wuffs_strconv_render_number_u64, test_wuffs_strconv_render_number_u64,
test_wuffs_strconv_utf_8_next, test_wuffs_strconv_utf_8_next,
test_wuffs_json_decode_empty_input,
test_wuffs_json_decode_end_of_data, test_wuffs_json_decode_end_of_data,
test_wuffs_json_decode_interface, test_wuffs_json_decode_interface,
test_wuffs_json_decode_long_numbers, test_wuffs_json_decode_long_numbers,
+30
View File
@@ -79,6 +79,35 @@ test_wuffs_lzw_decode_interface() {
"test/data/bricks-nodither.indexes.giflzw", 1, SIZE_MAX, 19200, 0x4F); "test/data/bricks-nodither.indexes.giflzw", 1, SIZE_MAX, 19200, 0x4F);
} }
const char* //
test_wuffs_lzw_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_lzw__decoder dec;
CHECK_STATUS("initialize",
wuffs_lzw__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_lzw__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status = wuffs_lzw__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_lzw__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_lzw__error__truncated_input);
}
return NULL;
}
const char* // const char* //
do_test_wuffs_lzw_decode(const char* src_filename, do_test_wuffs_lzw_decode(const char* src_filename,
uint64_t src_size, uint64_t src_size,
@@ -444,6 +473,7 @@ proc g_tests[] = {
test_wuffs_lzw_decode_output_bad, test_wuffs_lzw_decode_output_bad,
test_wuffs_lzw_decode_output_empty, test_wuffs_lzw_decode_output_empty,
test_wuffs_lzw_decode_pi, test_wuffs_lzw_decode_pi,
test_wuffs_lzw_decode_truncated_input,
test_wuffs_lzw_decode_width_0, test_wuffs_lzw_decode_width_0,
test_wuffs_lzw_decode_width_1, test_wuffs_lzw_decode_width_1,
+29
View File
@@ -82,6 +82,34 @@ test_wuffs_nie_decode_interface() {
"test/data/hippopotamus.nie", 0, SIZE_MAX, 36, 28, 0xFFF5F5F5); "test/data/hippopotamus.nie", 0, SIZE_MAX, 36, 28, 0xFFF5F5F5);
} }
const char* //
test_wuffs_nie_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_nie__decoder dec;
CHECK_STATUS("initialize",
wuffs_nie__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_nie__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status = wuffs_nie__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_nie__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_nie__error__truncated_input);
}
return NULL;
}
const char* // const char* //
test_wuffs_nie_decode_frame_config() { test_wuffs_nie_decode_frame_config() {
CHECK_FOCUS(__func__); CHECK_FOCUS(__func__);
@@ -134,6 +162,7 @@ proc g_tests[] = {
test_wuffs_nie_decode_frame_config, test_wuffs_nie_decode_frame_config,
test_wuffs_nie_decode_interface, test_wuffs_nie_decode_interface,
test_wuffs_nie_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
+43
View File
@@ -194,6 +194,47 @@ test_wuffs_png_decode_interface() {
"test/data/bricks-gray.png", 0, SIZE_MAX, 160, 120, 0xFF060606); "test/data/bricks-gray.png", 0, SIZE_MAX, 160, 120, 0xFF060606);
} }
const char* //
test_wuffs_png_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_png__decoder dec;
CHECK_STATUS("initialize",
wuffs_png__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_png__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status = wuffs_png__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_png__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_png__error__truncated_input);
}
return NULL;
}
const char* //
test_wuffs_png_decode_multiple_idats() {
CHECK_FOCUS(__func__);
wuffs_png__decoder dec;
CHECK_STATUS("initialize",
wuffs_png__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
return do_test__wuffs_base__image_decoder(
wuffs_png__decoder__upcast_as__wuffs_base__image_decoder(&dec),
"test/data/bricks-color.png", 0, SIZE_MAX, 160, 120, 0xFF022460);
}
const char* // const char* //
test_wuffs_png_decode_bad_crc32_checksum_critical() { test_wuffs_png_decode_bad_crc32_checksum_critical() {
CHECK_FOCUS(__func__); CHECK_FOCUS(__func__);
@@ -1273,7 +1314,9 @@ proc g_tests[] = {
test_wuffs_png_decode_metadata_exif, test_wuffs_png_decode_metadata_exif,
test_wuffs_png_decode_metadata_iccp, test_wuffs_png_decode_metadata_iccp,
test_wuffs_png_decode_metadata_kvp, test_wuffs_png_decode_metadata_kvp,
test_wuffs_png_decode_multiple_idats,
test_wuffs_png_decode_restart_frame, test_wuffs_png_decode_restart_frame,
test_wuffs_png_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
+29
View File
@@ -99,6 +99,34 @@ test_wuffs_tga_decode_interface() {
"test/data/bricks-color.tga", 0, SIZE_MAX, 160, 120, 0xFF022460); "test/data/bricks-color.tga", 0, SIZE_MAX, 160, 120, 0xFF022460);
} }
const char* //
test_wuffs_tga_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_tga__decoder dec;
CHECK_STATUS("initialize",
wuffs_tga__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_tga__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status = wuffs_tga__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_tga__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_tga__error__truncated_input);
}
return NULL;
}
// ---------------- Mimic Tests // ---------------- Mimic Tests
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
@@ -141,6 +169,7 @@ bench_wuffs_tga_decode_77k_24bpp() {
proc g_tests[] = { proc g_tests[] = {
test_wuffs_tga_decode_interface, test_wuffs_tga_decode_interface,
test_wuffs_tga_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
+29
View File
@@ -436,6 +436,34 @@ test_wuffs_wbmp_decode_interface() {
"test/data/muybridge-frame-000.wbmp", 0, SIZE_MAX, 30, 20, 0xFFFFFFFF); "test/data/muybridge-frame-000.wbmp", 0, SIZE_MAX, 30, 20, 0xFFFFFFFF);
} }
const char* //
test_wuffs_wbmp_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_wbmp__decoder dec;
CHECK_STATUS("initialize",
wuffs_wbmp__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_wbmp__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status = wuffs_wbmp__decoder__decode_image_config(&dec, NULL, &src);
if (status.repr != wuffs_wbmp__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_wbmp__error__truncated_input);
}
return NULL;
}
const char* // const char* //
test_wuffs_wbmp_decode_frame_config() { test_wuffs_wbmp_decode_frame_config() {
CHECK_FOCUS(__func__); CHECK_FOCUS(__func__);
@@ -653,6 +681,7 @@ proc g_tests[] = {
test_wuffs_wbmp_decode_frame_config, test_wuffs_wbmp_decode_frame_config,
test_wuffs_wbmp_decode_image_config, test_wuffs_wbmp_decode_image_config,
test_wuffs_wbmp_decode_interface, test_wuffs_wbmp_decode_interface,
test_wuffs_wbmp_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC
+31
View File
@@ -112,6 +112,36 @@ test_wuffs_zlib_decode_interface() {
"test/data/romeo.txt.zlib", 0, SIZE_MAX, 942, 0x0A); "test/data/romeo.txt.zlib", 0, SIZE_MAX, 942, 0x0A);
} }
const char* //
test_wuffs_zlib_decode_truncated_input() {
CHECK_FOCUS(__func__);
wuffs_base__io_buffer have = wuffs_base__ptr_u8__writer(g_have_array_u8, 1);
wuffs_base__io_buffer src =
wuffs_base__ptr_u8__reader(g_src_array_u8, 0, false);
wuffs_zlib__decoder dec;
CHECK_STATUS("initialize",
wuffs_zlib__decoder__initialize(
&dec, sizeof dec, WUFFS_VERSION,
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED));
wuffs_base__status status =
wuffs_zlib__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_base__suspension__short_read) {
RETURN_FAIL("closed=false: have \"%s\", want \"%s\"", status.repr,
wuffs_base__suspension__short_read);
}
src.meta.closed = true;
status =
wuffs_zlib__decoder__transform_io(&dec, &have, &src, g_work_slice_u8);
if (status.repr != wuffs_zlib__error__truncated_input) {
RETURN_FAIL("closed=true: have \"%s\", want \"%s\"", status.repr,
wuffs_zlib__error__truncated_input);
}
return NULL;
}
const char* // const char* //
wuffs_raw_deflate_decode(wuffs_base__io_buffer* dst, wuffs_raw_deflate_decode(wuffs_base__io_buffer* dst,
wuffs_base__io_buffer* src, wuffs_base__io_buffer* src,
@@ -426,6 +456,7 @@ proc g_tests[] = {
test_wuffs_zlib_decode_pi, test_wuffs_zlib_decode_pi,
test_wuffs_zlib_decode_raw_deflate_romeo, test_wuffs_zlib_decode_raw_deflate_romeo,
test_wuffs_zlib_decode_sheep, test_wuffs_zlib_decode_sheep,
test_wuffs_zlib_decode_truncated_input,
#ifdef WUFFS_MIMIC #ifdef WUFFS_MIMIC