Compare commits

...

147 Commits

Author SHA1 Message Date
4768bc17ba 1.12.0 2020-08-26 12:57:35 +01:00
0934c6c00f Merge pull request #804 from GoogleChromeLabs/avif-options 2020-08-26 12:53:37 +01:00
9d81a9cd57 Merge branch 'dev' into avif-options 2020-08-26 12:39:40 +01:00
239ffeb7a7 Comment out grayscale and 4:2:0 for now 2020-08-26 12:36:59 +01:00
95570c8b3c Revert "Merge pull request #800 from GoogleChromeLabs/mozjpeg_dec"
This reverts commit 5715fb7b1b, reversing
changes made to 2c923e5239.
2020-08-26 12:28:06 +01:00
6e52ac2a73 Simpler canDecode check 2020-08-26 11:41:21 +01:00
fd5c557065 Cheeky smaller wasms 2020-08-26 11:09:15 +01:00
0abb6f18ba Update options when updating state. 2020-08-25 16:54:01 +01:00
4e5a810770 Avoid caching the decoder if the browser already supports it 2020-08-25 14:31:20 +01:00
8a81792bd5 Finger-in-the-air defaults 2020-08-25 14:13:37 +01:00
3f57f9fef1 Feature test decoding capability 2020-08-25 14:13:21 +01:00
549e1fc50a Use bt709 if not lossless so colour is correct 2020-08-25 14:12:26 +01:00
f3749a4e24 Ensure that mins can't be greater than maxs 2020-08-25 13:39:28 +01:00
e316b0d667 Use identity coefficients for true lossless 2020-08-25 13:39:01 +01:00
8f2dcb5f48 Options mostly working 2020-08-25 13:11:10 +01:00
5715fb7b1b Merge pull request #800 from GoogleChromeLabs/mozjpeg_dec 2020-08-24 14:25:37 +01:00
cd33a2f759 Fine. Count the lines. 2020-08-24 14:21:35 +01:00
ee561bb00e Allow more than one scanline at a time 2020-08-24 14:03:44 +01:00
75275a5596 Update codecs/mozjpeg/dec/mozjpeg_dec.cpp
Co-authored-by: Ingvar Stepanyan <rreverser@google.com>
2020-08-24 14:00:38 +01:00
8cd811cafd Review 2020-08-24 12:43:12 +01:00
4e090ea2f8 Remove unnecessary includes 2020-08-21 16:43:36 +01:00
6b007a0235 Update paths for Squoosh PWA 2020-08-21 16:33:58 +01:00
c23d1091e7 Implement decoder 2020-08-21 16:31:04 +01:00
d4f8b7f38b Add LICENSES to codecs 2020-08-21 13:44:36 +01:00
2c923e5239 Merge pull request #722 from GoogleChromeLabs/avif 2020-08-12 11:15:45 +01:00
fe52c9b307 Fix Makefile 2020-08-11 18:49:07 +01:00
3745a3fff1 Revert "Enable address sanitizer"
This reverts commit d89e846896.
2020-08-11 18:41:42 +01:00
d89e846896 Enable address sanitizer 2020-08-11 18:41:09 +01:00
db6dea846a AVIF Makefile improvements 2020-08-05 15:56:36 +01:00
8036579a3c RawImage -> ImageData; report errors with null 2020-08-05 15:10:33 +01:00
0807fa4b9a Remove obsolete free_result refs 2020-08-05 14:40:15 +01:00
3cda8285a1 Update src/lib/util.ts
Co-authored-by: Ingvar Stepanyan <rreverser@google.com>
2020-08-05 14:40:09 +01:00
0218d0aac5 Avoid leaks during encoding 2020-08-05 14:40:04 +01:00
cfba6e7bd5 Disable examples 2020-08-05 14:39:58 +01:00
c6015e2e8d Don't copy dem pixels 2020-08-05 14:39:54 +01:00
94a2a7b32f Free pixels 2020-08-05 14:39:50 +01:00
03f33847a3 Code review 2020-08-05 14:39:46 +01:00
563b558204 Remove free() method 2020-08-05 14:39:41 +01:00
3c92f2d531 Download sources as tar.gz 2020-08-05 14:39:35 +01:00
f5ab9a9a59 Remove CFLAGS and improve git folder targets 2020-08-05 14:39:30 +01:00
7893660679 Fix alpha channel in encoder 2020-08-05 14:39:26 +01:00
15dac42a7f Remove stray files 2020-08-05 14:39:21 +01:00
53298a23ad Remove package.json and move git to Makefile 2020-08-05 14:39:14 +01:00
7ffa45ba86 Update libavif and libaom 2020-08-05 14:39:07 +01:00
ee99cf6e0b Move to makefile for AVIF 2020-08-05 14:39:01 +01:00
2edb8cbd7e Upgrade AVIF decoding code
- Update to newer APIs.
 - Avoid manual pixel-by-pixel copy in favour of decoding directly to desired format & bit depth.
 - Avoid use-after-free by cloning the Uint8Array Wasm memory view into a JS-owned Uint8Array right away.
2020-08-05 14:38:56 +01:00
0ac3d17969 Move AOM cloning to napa 2020-08-05 14:38:51 +01:00
1baa823d77 Upgrade libavif 2020-08-05 14:38:48 +01:00
368ad9505e Use make -j in AVIF 2020-08-05 14:38:42 +01:00
08c267a98b Add LTO to AVIF 2020-08-05 14:38:37 +01:00
0c3ef3fdf5 Migrate AVIF to Emscripten upstream 2020-08-05 14:38:33 +01:00
17dcc9c7d4 Update AVIF encoder README 2020-08-05 14:38:31 +01:00
ac9a7767d2 Expose some options for AVIF 2020-08-05 14:38:29 +01:00
c29006d593 Add AVIF encoder without options 2020-08-05 14:38:26 +01:00
e1ab43b76f Add AVIF encoder 2020-08-05 14:38:23 +01:00
409df481db Fix HDR image support in AVIF decoder 2020-08-05 14:38:19 +01:00
02807aab32 Add AVIF decoder to squoosh 2020-08-05 14:38:13 +01:00
34cb55978f Add avif decoder binaries 2020-08-05 14:36:21 +01:00
d0f5d5a644 Make build-cpp.sh executable 2020-08-04 13:35:58 +01:00
37f09245a6 Merge pull request #790 from GoogleChromeLabs/button-position 2020-08-04 09:51:26 +01:00
c43f75f1f2 Merge branch 'dev' into button-position 2020-07-31 19:49:14 +01:00
227d32be7b Fix install button position
Add `position: relative` to the parent `div` that owns the scrollbar, so that Install button positions itself relative to it and not to the whole document.

Fixes a bug where button would get rendered on top of a scrollbar.
2020-07-31 18:33:20 +01:00
87955ab9a0 Merge pull request #784 from petele/analytics-update-3
Don't fire install analytics on hidden pages
2020-07-31 10:43:40 -04:00
ecb0b15cdc Merge branch 'dev' into analytics-update-3 2020-07-31 10:28:23 -04:00
ed451e4dfa "native" to "builtin" (#788) 2020-07-30 14:43:46 +01:00
1a26057452 Switch from napa to curl
Instead of using 127 deps brought by napa just to download the one dependency we actually care about, just use curl & tar directly from Makefile.
2020-07-30 13:28:41 +01:00
98b930abde Switch from napa to curl
Instead of using 127 deps brought by napa just to download the one dependency we actually care about, just use curl & tar directly from Makefile.
2020-07-30 12:31:20 +01:00
ddbeaa0870 Merge branch 'dev' into analytics-update-3 2020-07-29 11:52:24 +01:00
b69dc4c7f4 Merge pull request #773 from petele/maskable-icon
Adds a maskable icon
2020-07-28 13:56:23 -04:00
ed6b8b89c6 Merge branch 'dev' into maskable-icon 2020-07-28 13:52:20 -04:00
2580f1e292 Merge pull request #785 from GoogleChromeLabs/hqx-build 2020-07-28 18:50:43 +01:00
2ac684f98f Merge branch 'dev' into maskable-icon 2020-07-28 13:45:52 -04:00
b8d921ec16 Merge branch 'dev' into analytics-update-3 2020-07-28 13:45:20 -04:00
9c0a375f01 Fixup HQX build
Porting over few more improvements from #777 that can be applied to HQX despite the older Rust version:

 - Removed Cargo.lock from .gitignore (the file itself was added in the original PR, but is still ignored and wouldn't get committed on changes).
 - Removed couple of stray .DS_Store accidentally added in that PR.
 - Added a `--locked` to `wasm-pack` build to make sure we rebuild HQX with the same versions from Cargo.lock.
 - Removed separate `wasm-strip` and `wasm-opt -Os` steps from build.sh in HQX because they're already included in wasm-pack, and running twice only makes build slower.
2020-07-28 18:37:17 +01:00
d1cff7d84e Consolidate C++ builds
Use a shared base image with fixed Emscripten version, autotools and optimisation flags for all C++ codecs.

Additionally, move build commands for codecs themselves to Makefile - they're already platform-specific, and Make allows for better caching and parallelisation that custom ad-hoc scripts.

This is essentially same as #777 but for C++.
2020-07-28 18:05:09 +01:00
9c2b582986 Merge branch 'dev' into maskable-icon 2020-07-28 18:03:09 +01:00
e342766cbf Switch vals to thread_locals
It's not possible to share them across threads, so in case we decide to use multithreading in the future, it's best to mark them as thread_local right away, even if it's a no-op right now.
2020-07-28 16:35:00 +01:00
f1cd6a87da Update JS/Wasm 2020-07-28 16:35:00 +01:00
39e5741cb2 Fix few more issues detected in MozJPEG wrapper 2020-07-28 16:35:00 +01:00
93cbe557cd Simplify memory management for other C++ codecs 2020-07-28 16:35:00 +01:00
97931bad22 C++ify imagequant memory management 2020-07-28 16:35:00 +01:00
1f35c40d3f Create Uint8ClampedArray from C++ 2020-07-28 16:35:00 +01:00
c39383333f Localize variables in imagequant 2020-07-28 16:35:00 +01:00
4fc18de5f9 Fix use-after-free in imagequant 2020-07-28 16:35:00 +01:00
aac30e6fd3 Don't fire install analytics on hidden pages 2020-07-27 12:46:15 -04:00
45785bcca3 1.11.4 2020-07-24 14:59:47 +01:00
f36cb5d3ef Merge pull request #777 from GoogleChromeLabs/consolidate-rust 2020-07-24 14:57:55 +01:00
b7f7a5ac0a Rebuild resize wasm 2020-07-24 14:52:24 +01:00
dd895f026b Remove old wasm files 2020-07-24 14:25:55 +01:00
548c126521 Merge remote-tracking branch 'origin/dev' into consolidate-rust 2020-07-24 13:30:16 +01:00
ca00a22303 Reset HQX to old build system 2020-07-24 13:29:40 +01:00
1ce6dd73d8 Fix clamping. Fixes #782. Fixes #711. 2020-07-24 12:52:21 +01:00
ff7dc2c4cf Merge pull request #725 from almandsky/fix_hml 2020-07-20 11:45:10 +01:00
117b87132e Merge branch 'dev' into fix_hml 2020-07-20 11:35:28 +01:00
42e7a7e165 Merge branch 'dev' into consolidate-rust 2020-07-15 17:48:35 +01:00
796324ad71 Update webpack configuration for Webpack 4 2020-07-15 17:37:00 +01:00
cf1a718534 Fix windows builds breaking due to mixed paths 2020-07-15 17:37:00 +01:00
718427badb Use lockfiles & update Rust deps 2020-07-14 17:23:31 +01:00
c5c520a71d Consolidate Rust builds
This consolidates Rust build process for various codecs into a single top-level image that is built once and reused.

This ensures that we use same version of tools across codecs (now controlled from a single place), simplifies build configs and commands, speeds up common builds and reduces disk space taken by Docker images by reusing same one.

Additionally, this PR renames all codecs to squoosh-* to work around the https://github.com/rustwasm/wasm-pack/issues/829 (which has been already fixed on master of wasm-pack but not released in a while), as well as adds `publish = false` to Cargo.toml to avoid accidental publishing for now.

I'm planning to do similar for Emscripten in a separate PR, although abilities to share configs there are much more limited due to lack of package manager in C++.
2020-07-14 17:20:40 +01:00
17ffa57a8b Updating oxi build & enabling alpha optimisations (#776)
* Updating oxi build & enabling alpha optimisations

* Renaming package
2020-07-14 16:19:35 +01:00
005d5180b4 Merge branch 'dev' into fix_hml 2020-07-13 21:52:43 -04:00
ce9b96994c Merge branch 'dev' into maskable-icon 2020-07-08 10:29:27 -04:00
a1fb445b06 1.11.3 2020-07-08 14:55:39 +01:00
8a516131ea Updates to analytics for PWAs (#772)
* Updates to analytics experiments

* adjust hover color on install button

* adjust event action names

* adjust utm_source for share_target launches

Co-authored-by: Jake Archibald <jaffathecake@gmail.com>
2020-07-08 14:53:36 +01:00
9816be83ab Add Windows to Travis config (#775)
This will help to catch somewhat frequent Windows-specific issues in the future (latest example: #774).
2020-07-08 14:28:31 +01:00
63f607a3ea Adds a maskable icon 2020-07-07 14:01:18 -04:00
57418034c4 1.11.2 2020-07-07 16:08:26 +01:00
3892490023 Update size report branch 2020-07-07 16:08:13 +01:00
5bedff583b Update privacy link (#771)
The link doesn't work, as the default branch has been renamed
2020-07-07 16:06:33 +01:00
d94835402f 1.11.1 2020-07-02 14:29:00 +01:00
b7e45ab843 Bringing live back in sync 2020-07-02 14:28:40 +01:00
8313246fd1 Fix typo for "spatial" (#768) 2020-07-02 14:25:51 +01:00
2b3cafb1f4 1.11.0 2020-06-24 16:22:06 +01:00
d52698f005 Merge remote-tracking branch 'origin/dev' into live 2020-06-24 16:21:49 +01:00
6ad28c0b5c Merge pull request #765 from petele/dimension 2020-06-24 16:15:16 +01:00
c76dabf063 Merge branch 'dev' into dimension 2020-06-24 16:12:59 +01:00
e6d8bac9c5 Merge pull request #764 from petele/install-prompt 2020-06-24 16:12:48 +01:00
42e43730c8 Naming changes 2020-06-24 15:16:38 +01:00
5c17fba349 Minor tweaks 2020-06-24 15:12:48 +01:00
85eb94b725 Set the dimension value 2020-06-24 09:54:54 -04:00
4fa73be842 Apply suggestions from code review
Co-authored-by: Surma <surma@surma.dev>
2020-06-24 09:40:56 -04:00
7c89d09139 Add missing prop to navigator 2020-06-24 14:08:52 +01:00
079e56f1e1 Use a dimension to note how the user opened squoosh 2020-06-23 16:34:47 -04:00
6065ceabfe update readme 2020-06-23 16:16:32 -04:00
265e6db2bd Adds install button to Squoosh 2020-06-23 16:10:40 -04:00
3a5c0aa30c Merge pull request #757 from GoogleChromeLabs/fixup-clang-format 2020-05-14 17:02:50 +01:00
f0c3ec9d51 Fixup clang-format
I've actually comitted files formatted with column limit of 100, but forgot to include updated .clang-format 🤦🏻‍♂️
2020-05-14 16:30:12 +01:00
1ae93b527c Revert docker run --rm change 2020-05-13 19:39:27 +01:00
a95cb740bf Format C / C++ with Chromium style 2020-05-13 19:39:27 +01:00
de543b3206 Further speed improvements
- Store Emscripten cache inside node_modules/.em_cache. Docker image ships without LTO libs, so Emscripten has to rebuild stdlibs on every build otherwise.
 - Merge webp_enc + webp_dec build scripts. Core libwebp library is same in both cases, so there's no point in storing and building two copies of it.
2020-05-13 19:39:27 +01:00
1542bfb7fd Tweak up compile flags
- Remove unnecessary `-x c++`.
 - Improve rebuild speed by caching:
   - Remove `-f` from `autoreconf` to reuse generated configure scripts.
   - Remove `--rm` from `docker run` to avoid rebuilding Emscripten stdlib.
   - Add `-C` to `./configure` to reuse stored information about `emcc`.
   - Remove `rm -rf build` from WebP encoder/decoder.
2020-05-13 19:39:27 +01:00
f95954a9f1 Merge branch 'master' into fix_hml 2020-05-05 15:03:25 -07:00
bc8d75128f Remove libpng-dev dependency from WebP (#752)
It's unnecessary as we disable PNG support via ./configure anyway.

Co-authored-by: Surma <surma@surma.dev>
2020-05-05 13:23:12 +01:00
d3252bb1bb Add LTO for C++ builds (#755)
* Add LTO for C++ builds

This didn't have much effect on fastcomp builds, but provides further size savings with new LLVM backend we switched to in #750 (and fixes the MozJPEG size regression from the same PR).

In the future we won't need to pass `--llvm-lto 1` explicitly, but latest Emscripten Docker image doesn't contain the Emscripten version with the necessary fixes for this.

* Delete build.log

Co-authored-by: Jake Archibald <jaffathecake@gmail.com>
2020-05-05 11:54:28 +01:00
83d9d2c764 Disable renovate 2020-05-05 11:19:40 +01:00
eeb3d3562a 1.10.3 2020-04-22 17:35:39 +01:00
2d73c24e09 Merge remote-tracking branch 'origin/master' into live 2020-04-22 17:34:10 +01:00
f4a16022ef 1.10.2 2020-04-16 20:07:42 +01:00
12153c72dc Merge remote-tracking branch 'origin/master' into live 2020-04-16 20:07:08 +01:00
62c53c9fed 1.10.1 2020-04-16 11:52:59 +01:00
53a38b2ba1 Merge remote-tracking branch 'origin/master' into live 2020-04-16 11:52:34 +01:00
22b7e36c01 1.10.0 2020-04-14 13:29:05 +01:00
a0e6a377cd Merge remote-tracking branch 'origin/master' into live 2020-04-14 13:28:27 +01:00
5b496ad85f Merge branch 'master' into fix_hml 2020-04-09 13:02:09 -07:00
bc1bf8542c Merge branch 'master' into fix_hml 2020-02-28 11:36:07 -08:00
e8f4e82cf8 Merge branch 'master' into fix_hml 2020-02-27 08:42:27 -08:00
9a838f1d55 Only extract the inline javascript for production mode 2020-02-11 23:49:09 -08:00
158 changed files with 3917 additions and 6021 deletions

2
.clang-format Normal file
View File

@ -0,0 +1,2 @@
BasedOnStyle: Chromium
ColumnLimit: 100

View File

@ -2,3 +2,6 @@ language: node_js
cache: npm
script: npm run build
after_success: npm run sizereport
os:
- linux
- windows

View File

@ -10,6 +10,7 @@ Google Analytics is used to record the following:
* [Basic visit data](https://support.google.com/analytics/answer/6004245?ref_topic=2919631).
* Before and after image size once an image is downloaded. These values are rounded to the nearest
kilobyte.
* If install is available, when Squoosh is installed, and what method was used to install Squoosh.
Image compression is handled locally; no additional data is sent to the server.

76
codecs/avif/Makefile Normal file
View File

@ -0,0 +1,76 @@
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/v0.8.1.tar.gz
CODEC_DIR = node_modules/libavif
CODEC_BUILD_DIR := $(CODEC_DIR)/build
CODEC_OUT := $(CODEC_BUILD_DIR)/libavif.a
LIBAOM_URL = https://aomedia.googlesource.com/aom/+archive/v2.0.0.tar.gz
LIBAOM_DIR := $(CODEC_DIR)/ext/aom
LIBAOM_BUILD_DIR := $(LIBAOM_DIR)/build.libavif
LIBAOM_OUT := $(LIBAOM_BUILD_DIR)/libaom.a
OUT_JS = enc/avif_enc.js dec/avif_dec.js
OUT_WASM = $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(LIBAOM_OUT) $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR)/include \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt $(LIBAOM_OUT)
mkdir -p $(CODEC_BUILD_DIR)
cd $(CODEC_BUILD_DIR) && \
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=0 \
-DAVIF_CODEC_AOM=1 \
-DAVIF_LOCAL_AOM=1 \
../ && \
$(MAKE)
$(LIBAOM_OUT): $(LIBAOM_DIR)/CMakeLists.txt
mkdir -p $(LIBAOM_BUILD_DIR)
cd $(LIBAOM_BUILD_DIR) && \
emcmake cmake \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_CCACHE=0 \
-DAOM_TARGET_CPU=generic \
-DENABLE_DOCS=0 \
-DENABLE_TESTS=0 \
-DENABLE_EXAMPLES=0 \
-DENABLE_TOOLS=0 \
-DCONFIG_ACCOUNTING=1 \
-DCONFIG_INSPECTION=0 \
-DCONFIG_MULTITHREAD=0 \
-DCONFIG_RUNTIME_CPU_DETECT=0 \
-DCONFIG_WEBM_IO=0 \
../ && \
$(MAKE)
$(CODEC_DIR)/CMakeLists.txt: $(CODEC_DIR)
$(LIBAOM_DIR)/CMakeLists.txt: $(LIBAOM_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
$(LIBAOM_DIR):
mkdir -p $@
curl -sL $(LIBAOM_URL) | tar xz -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_BUILD_DIR) clean
$(MAKE) -C $(LIBAOM_BUILD_DIR) clean

14
codecs/avif/dec/README.md Normal file
View File

@ -0,0 +1,14 @@
# AVIF decoder
- Source: <https://github.com/AOMediaCodec/libavif>
- Version: v0.5.4
## Example
See `example.html`
## API
### `RawImage decode(std::string buffer)`
Decodes the given avif buffer into raw RGBA. `RawImage` is a class with 3 fields: `buffer`, `width`, and `height`.

View File

@ -0,0 +1,50 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "avif/avif.h"
using namespace emscripten;
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
thread_local const val ImageData = val::global("ImageData");
val decode(std::string avifimage) {
// point raw.data and raw.size to the contents of an .avif(s)
avifROData raw = {
.data = (uint8_t*)avifimage.c_str(),
.size = avifimage.length()
};
avifImage* image = avifImageCreateEmpty();
avifDecoder* decoder = avifDecoderCreate();
avifResult decodeResult = avifDecoderRead(decoder, image, &raw);
// image is an independent copy of decoded data, decoder may be destroyed here
avifDecoderDestroy(decoder);
val result = val::null();
if (decodeResult == AVIF_RESULT_OK) {
// Convert to interleaved RGB(A)/BGR(A) using a libavif-allocated buffer.
avifRGBImage rgb;
avifRGBImageSetDefaults(&rgb, image); // Defaults to AVIF_RGB_FORMAT_RGBA which is what we want.
rgb.depth = 8; // Does not need to match image->depth. We always want 8-bit pixels.
avifRGBImageAllocatePixels(&rgb);
avifImageYUVToRGB(image, &rgb);
// We want to create a *copy* of the decoded data to be owned by the JavaScript side.
// For that, we perform `new Uint8Array(wasmMemBuffer, wasmPtr, wasmSize).slice()`:
result = ImageData.new_(Uint8ClampedArray.new_(typed_memory_view(rgb.rowBytes * rgb.height, rgb.pixels)), rgb.width, rgb.height);
// Now we can safely free the RGB pixels:
avifRGBImageFreePixels(&rgb);
}
// Image has been converted to RGB, we don't need the original anymore.
avifImageDestroy(image);
return result;
}
EMSCRIPTEN_BINDINGS(my_module) {
function("decode", &decode);
}

6
codecs/avif/dec/avif_dec.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
interface AVIFModule extends EmscriptenWasm.Module {
decode(data: BufferSource): ImageData | null;
}
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;

View File

@ -0,0 +1,72 @@
var avif_dec = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(avif_dec) {
avif_dec = avif_dec || {};
var d;d||(d=typeof avif_dec !== 'undefined' ? avif_dec : {});var aa,ba;d.ready=new Promise(function(a,b){aa=a;ba=b});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var u=!1,v=!1,ca=!1,da=!1;u="object"===typeof window;v="function"===typeof importScripts;ca="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;da=!u&&!ca&&!v;var w="",x,z,ea,fa;
if(ca)w=v?require("path").dirname(w)+"/":__dirname+"/",x=function(a,b){ea||(ea=require("fs"));fa||(fa=require("path"));a=fa.normalize(a);return ea.readFileSync(a,b?null:"utf8")},z=function(a){a=x(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||A("Assertion failed: undefined");return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",A),d.inspect=function(){return"[Emscripten Module object]"};
else if(da)"undefined"!=typeof read&&(x=function(a){return read(a)}),z=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||A("Assertion failed: undefined");return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(u||v)v?w=self.location.href:document.currentScript&&(w=document.currentScript.src),_scriptDir&&
(w=_scriptDir),0!==w.indexOf("blob:")?w=w.substr(0,w.lastIndexOf("/")+1):w="",x=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},v&&(z=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ha=d.print||console.log.bind(console),B=d.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;var ia=0,D;d.wasmBinary&&(D=d.wasmBinary);var noExitRuntime;
d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&A("no native wasm support detected");var E,ja=new WebAssembly.Table({initial:675,maximum:675,element:"anyfunc"}),ka=!1,la="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function ma(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&la)return la.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var h=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|h:(f&7)<<18|g<<12|h<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
function na(a,b,c){var e=F;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var h=a.charCodeAt(++f);g=65536+((g&1023)<<10)|h&1023}if(127>=g){if(b>=c)break;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var oa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function pa(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&G[c];)++c;c<<=1;if(32<c-a&&oa)return oa.decode(F.subarray(a,c));c=0;for(e="";;){var f=H[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function qa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)H[b>>1]=a.charCodeAt(f),b+=2;H[b>>1]=0;return b-e}function ra(a){return 2*a.length}
function sa(a,b){for(var c=0,e="";!(c>=b/4);){var f=I[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function ta(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var h=a.charCodeAt(++f);g=65536+((g&1023)<<10)|h&1023}I[b>>2]=g;b+=4;if(b+4>c)break}I[b>>2]=0;return b-e}
function ua(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var J,va,F,H,G,I,K,wa,xa;function ya(a){J=a;d.HEAP8=va=new Int8Array(a);d.HEAP16=H=new Int16Array(a);d.HEAP32=I=new Int32Array(a);d.HEAPU8=F=new Uint8Array(a);d.HEAPU16=G=new Uint16Array(a);d.HEAPU32=K=new Uint32Array(a);d.HEAPF32=wa=new Float32Array(a);d.HEAPF64=xa=new Float64Array(a)}var za=d.INITIAL_MEMORY||16777216;d.wasmMemory?E=d.wasmMemory:E=new WebAssembly.Memory({initial:za/65536,maximum:32768});
E&&(J=E.buffer);za=J.byteLength;ya(J);I[153976]=5858944;function Aa(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.ma;"number"===typeof c?void 0===b.ia?d.dynCall_v(c):d.dynCall_vi(c,b.ia):c(void 0===b.ia?null:b.ia)}}}var Ba=[],Ca=[],Da=[],Ea=[];function Fa(){var a=d.preRun.shift();Ba.unshift(a)}var L=0,Ga=null,N=null;d.preloadedImages={};d.preloadedAudios={};
function A(a){if(d.onAbort)d.onAbort(a);B(a);ka=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ha(a){var b=O;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ia(){return Ha("data:application/octet-stream;base64,")}var O="avif_dec.wasm";if(!Ia()){var Ja=O;O=d.locateFile?d.locateFile(Ja,w):w+Ja}
function Ka(){try{if(D)return new Uint8Array(D);if(z)return z(O);throw"both async and sync fetching of the wasm failed";}catch(a){A(a)}}function La(){return D||!u&&!v||"function"!==typeof fetch||Ha("file://")?new Promise(function(a){a(Ka())}):fetch(O,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+O+"'";return a.arrayBuffer()}).catch(function(){return Ka()})}Ca.push({ma:function(){Ma()}});function Na(){return 0<Na.ka}
function Oa(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Pa=void 0;function P(a){for(var b="";F[a];)b+=Pa[F[a++]];return b}var Q={},R={},Qa={};function Ra(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
function Sa(a,b){a=Ra(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Ta(a){var b=Error,c=Sa(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
var Ua=void 0;function T(a){throw new Ua(a);}var Va=void 0;function Wa(a,b){function c(l){l=b(l);if(l.length!==e.length)throw new Va("Mismatched type converter count");for(var k=0;k<e.length;++k)U(e[k],l[k])}var e=[];e.forEach(function(l){Qa[l]=a});var f=Array(a.length),g=[],h=0;a.forEach(function(l,k){R.hasOwnProperty(l)?f[k]=R[l]:(g.push(l),Q.hasOwnProperty(l)||(Q[l]=[]),Q[l].push(function(){f[k]=R[l];++h;h===g.length&&c(f)}))});0===g.length&&c(f)}
function U(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||T('type "'+e+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.na)return;T("Cannot register type '"+e+"' twice")}R[a]=b;delete Qa[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}var Xa=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function Ya(a){4<a&&0===--V[a].ja&&(V[a]=void 0,Xa.push(a))}function ab(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Xa.length?Xa.pop():V.length;V[b]={ja:1,value:a};return b}}function bb(a){return this.fromWireType(K[a>>2])}function cb(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function db(a,b){switch(b){case 2:return function(c){return this.fromWireType(wa[c>>2])};case 3:return function(c){return this.fromWireType(xa[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function eb(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Sa(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function fb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function gb(a,b){var c=d;if(void 0===c[a].ga){var e=c[a];c[a]=function(){c[a].ga.hasOwnProperty(arguments.length)||T("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].ga+")!");return c[a].ga[arguments.length].apply(this,arguments)};c[a].ga=[];c[a].ga[e.la]=e}}
function hb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].ga&&void 0!==d[a].ga[c])&&T("Cannot register public name '"+a+"' twice"),gb(a,a),d.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].ga[c]=b):(d[a]=b,void 0!==c&&(d[a].pa=c))}function ib(a,b){for(var c=[],e=0;e<a;e++)c.push(I[(b>>2)+e]);return c}
function jb(a,b){a=P(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&T("unknown function pointer with signature "+a+": "+b);return c}var kb=void 0;function lb(a){a=mb(a);var b=P(a);W(a);return b}
function nb(a,b){function c(g){f[g]||R[g]||(Qa[g]?Qa[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new kb(a+": "+e.map(lb).join([", "]));}function ob(a,b,c){switch(b){case 0:return c?function(e){return va[e]}:function(e){return F[e]};case 1:return c?function(e){return H[e>>1]}:function(e){return G[e>>1]};case 2:return c?function(e){return I[e>>2]}:function(e){return K[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var pb={};
function qb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function rb(a,b){var c=R[a];void 0===c&&T(b+" has unknown type "+lb(a));return c}for(var sb={},tb=[null,[],[]],ub=Array(256),vb=0;256>vb;++vb)ub[vb]=String.fromCharCode(vb);Pa=ub;Ua=d.BindingError=Ta("BindingError");Va=d.InternalError=Ta("InternalError");d.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};
d.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};kb=d.UnboundTypeError=Ta("UnboundTypeError");
var Db={u:function(a){return wb(a)},r:function(){},t:function(a){"uncaught_exception"in Na?Na.ka++:Na.ka=1;throw a;},D:function(a,b,c,e,f){var g=Oa(c);b=P(b);U(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,l){return l?e:f},argPackAdvance:8,readValueFromPointer:function(h){if(1===c)var l=va;else if(2===c)l=H;else if(4===c)l=I;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(l[h>>g])},ha:null})},C:function(a,b){b=P(b);U(a,{name:b,fromWireType:function(c){var e=
V[c].value;Ya(c);return e},toWireType:function(c,e){return ab(e)},argPackAdvance:8,readValueFromPointer:bb,ha:null})},p:function(a,b,c){c=Oa(c);b=P(b);U(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+cb(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:db(b,c),ha:null})},v:function(a,b,c,e,f,g){var h=ib(b,c);a=P(a);f=jb(e,f);hb(a,function(){nb("Cannot call "+a+" due to unbound types",
h)},b-1);Wa(h,function(l){var k=[l[0],null].concat(l.slice(1)),n=l=a,p=f,q=k.length;2>q&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==k[1]&&!1,C=!1,m=1;m<k.length;++m)if(null!==k[m]&&void 0===k[m].ha){C=!0;break}var Za="void"!==k[0].name,M="",S="";for(m=0;m<q-2;++m)M+=(0!==m?", ":"")+"arg"+m,S+=(0!==m?", ":"")+"arg"+m+"Wired";n="return function "+Ra(n)+"("+M+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+n+" called with ' + arguments.length + ' arguments, expected "+
(q-2)+" args!');\n}\n";C&&(n+="var destructors = [];\n");var $a=C?"destructors":"null";M="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[T,p,g,fb,k[0],k[1]];y&&(n+="var thisWired = classParam.toWireType("+$a+", this);\n");for(m=0;m<q-2;++m)n+="var arg"+m+"Wired = argType"+m+".toWireType("+$a+", arg"+m+"); // "+k[m+2].name+"\n",M.push("argType"+m),p.push(k[m+2]);y&&(S="thisWired"+(0<S.length?", ":"")+S);n+=(Za?"var rv = ":"")+"invoker(fn"+(0<S.length?", ":"")+S+");\n";
if(C)n+="runDestructors(destructors);\n";else for(m=y?1:2;m<k.length;++m)q=1===m?"thisWired":"arg"+(m-2)+"Wired",null!==k[m].ha&&(n+=q+"_dtor("+q+"); // "+k[m].name+"\n",M.push(q+"_dtor"),p.push(k[m].ha));Za&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");M.push(n+"}\n");k=eb(M).apply(null,p);m=b-1;if(!d.hasOwnProperty(l))throw new Va("Replacing nonexistant public symbol");void 0!==d[l].ga&&void 0!==m?d[l].ga[m]=k:(d[l]=k,d[l].la=m);return[]})},d:function(a,b,c,e,f){function g(n){return n}
b=P(b);-1===f&&(f=4294967295);var h=Oa(c);if(0===e){var l=32-8*c;g=function(n){return n<<l>>>l}}var k=-1!=b.indexOf("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(n,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+cb(p)+'" to '+this.name);if(p<e||p>f)throw new TypeError('Passing a number "'+cb(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return k?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:ob(b,
h,0!==e),ha:null})},c:function(a,b,c){function e(g){g>>=2;var h=K;return new f(J,h[g+1],h[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=P(c);U(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{na:!0})},q:function(a,b){b=P(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(e){var f=K[e>>2];if(c)for(var g=e+4,h=0;h<=f;++h){var l=e+4+h;if(h==f||0==F[l]){g=g?ma(F,g,l-g):"";if(void 0===k)var k=g;else k+=String.fromCharCode(0),
k+=g;g=l+1}}else{k=Array(f);for(h=0;h<f;++h)k[h]=String.fromCharCode(F[e+4+h]);k=k.join("")}W(e);return k},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||T("Cannot pass non-string to std::string");var h=(c&&g?function(){for(var n=0,p=0;p<f.length;++p){var q=f.charCodeAt(p);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++p)&1023);127>=q?++n:n=2047>=q?n+
2:65535>=q?n+3:n+4}return n}:function(){return f.length})(),l=wb(4+h+1);K[l>>2]=h;if(c&&g)na(f,l+4,h+1);else if(g)for(g=0;g<h;++g){var k=f.charCodeAt(g);255<k&&(W(l),T("String has UTF-16 code units that do not fit in 8 bits"));F[l+4+g]=k}else for(g=0;g<h;++g)F[l+4+g]=f[g];null!==e&&e.push(W,l);return l},argPackAdvance:8,readValueFromPointer:bb,ha:function(e){W(e)}})},j:function(a,b,c){c=P(c);if(2===b){var e=pa;var f=qa;var g=ra;var h=function(){return G};var l=1}else 4===b&&(e=sa,f=ta,g=ua,h=function(){return K},
l=2);U(a,{name:c,fromWireType:function(k){for(var n=K[k>>2],p=h(),q,y=k+4,C=0;C<=n;++C){var m=k+4+C*b;if(C==n||0==p[m>>l])y=e(y,m-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=m+b}W(k);return q},toWireType:function(k,n){"string"!==typeof n&&T("Cannot pass non-string to C++ string type "+c);var p=g(n),q=wb(4+p+b);K[q>>2]=p>>l;f(n,q+4,p+b);null!==k&&k.push(W,q);return q},argPackAdvance:8,readValueFromPointer:bb,ha:function(k){W(k)}})},E:function(a,b){b=P(b);U(a,{oa:!0,name:b,argPackAdvance:0,
fromWireType:function(){},toWireType:function(){}})},n:Ya,F:function(a){if(0===a)return ab(qb());var b=pb[a];a=void 0===b?P(a):b;return ab(qb()[a])},w:function(a){4<a&&(V[a].ja+=1)},l:function(a,b,c,e){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=sb[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var h="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)h+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+
g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",h+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(rb,d,ab);sb[b]=f}return f(a,c,e)},k:function(){A()},s:function(){B("missing function: aom_codec_av1_cx");A(-1)},e:function(a,b){X(a,b||1);throw"longjmp";},A:function(a,b,c){F.copyWithin(a,b,b+c)},f:function(a){a>>>=0;var b=F.length;
if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%65536&&(e+=65536-e%65536);a:{try{E.grow(Math.min(2147483648,e)-J.byteLength+65535>>>16);ya(E.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},B:function(){return 0},x:function(){},o:function(a,b,c,e){for(var f=0,g=0;g<c;g++){for(var h=I[b+8*g>>2],l=I[b+(8*g+4)>>2],k=0;k<l;k++){var n=F[h+k],p=tb[a];0===n||10===n?((1===a?ha:B)(ma(p,0)),p.length=0):p.push(n)}f+=l}I[e>>
2]=f;return 0},a:function(){return ia|0},h:xb,y:yb,z:zb,g:Ab,m:Bb,i:Cb,memory:E,b:function(a){ia=a|0},table:ja};
(function(){function a(f){d.asm=f.exports;L--;d.monitorRunDependencies&&d.monitorRunDependencies(L);0==L&&(null!==Ga&&(clearInterval(Ga),Ga=null),N&&(f=N,N=null,f()))}function b(f){a(f.instance)}function c(f){return La().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);A(g)})}var e={a:Db};L++;d.monitorRunDependencies&&d.monitorRunDependencies(L);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return B("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(D||"function"!==typeof WebAssembly.instantiateStreaming||Ia()||Ha("file://")||"function"!==typeof fetch)return c(b);fetch(O,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Ma=d.___wasm_call_ctors=function(){return(Ma=d.___wasm_call_ctors=d.asm.G).apply(null,arguments)},wb=d._malloc=function(){return(wb=d._malloc=d.asm.H).apply(null,arguments)},W=d._free=function(){return(W=d._free=d.asm.I).apply(null,arguments)},mb=d.___getTypeName=function(){return(mb=d.___getTypeName=d.asm.J).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.K).apply(null,arguments)};
var X=d._setThrew=function(){return(X=d._setThrew=d.asm.L).apply(null,arguments)},Y=d.stackSave=function(){return(Y=d.stackSave=d.asm.M).apply(null,arguments)},Z=d.stackRestore=function(){return(Z=d.stackRestore=d.asm.N).apply(null,arguments)},Eb=d.dynCall_v=function(){return(Eb=d.dynCall_v=d.asm.O).apply(null,arguments)},Fb=d.dynCall_vi=function(){return(Fb=d.dynCall_vi=d.asm.P).apply(null,arguments)},Gb=d.dynCall_vii=function(){return(Gb=d.dynCall_vii=d.asm.Q).apply(null,arguments)},Hb=d.dynCall_viiii=
function(){return(Hb=d.dynCall_viiii=d.asm.R).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.S).apply(null,arguments)};var Ib=d.dynCall_iii=function(){return(Ib=d.dynCall_iii=d.asm.T).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.U).apply(null,arguments)};var Jb=d.dynCall_iiiii=function(){return(Jb=d.dynCall_iiiii=d.asm.V).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.W).apply(null,arguments)};
d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.X).apply(null,arguments)};d.dynCall_viiiiiiii=function(){return(d.dynCall_viiiiiiii=d.asm.Y).apply(null,arguments)};d.dynCall_viiiiiiiiiii=function(){return(d.dynCall_viiiiiiiiiii=d.asm.Z).apply(null,arguments)};d.dynCall_viiiiiiiiiiii=function(){return(d.dynCall_viiiiiiiiiiii=d.asm._).apply(null,arguments)};d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.$).apply(null,arguments)};
d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.aa).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.ba).apply(null,arguments)};d.dynCall_iidiiii=function(){return(d.dynCall_iidiiii=d.asm.ca).apply(null,arguments)};d.dynCall_i=function(){return(d.dynCall_i=d.asm.da).apply(null,arguments)};d.dynCall_viiiiiiiiii=function(){return(d.dynCall_viiiiiiiiii=d.asm.ea).apply(null,arguments)};
d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.fa).apply(null,arguments)};function Bb(a,b,c){var e=Y();try{Gb(a,b,c)}catch(f){Z(e);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}function Cb(a,b,c,e,f){var g=Y();try{Hb(a,b,c,e,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function xb(a,b,c){var e=Y();try{return Ib(a,b,c)}catch(f){Z(e);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}function Ab(a,b){var c=Y();try{Fb(a,b)}catch(e){Z(c);if(e!==e+0&&"longjmp"!==e)throw e;X(1,0)}}
function zb(a){var b=Y();try{Eb(a)}catch(c){Z(b);if(c!==c+0&&"longjmp"!==c)throw c;X(1,0)}}function yb(a,b,c,e,f){var g=Y();try{return Jb(a,b,c,e,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}var Kb;N=function Lb(){Kb||Mb();Kb||(N=Lb)};
function Mb(){function a(){if(!Kb&&(Kb=!0,d.calledRun=!0,!ka)){Aa(Ca);Aa(Da);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Ea.unshift(b)}Aa(Ea)}}if(!(0<L)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Fa();Aa(Ba);0<L||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
d.run=Mb;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;Mb();
return avif_dec.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = avif_dec;
else if (typeof define === 'function' && define['amd'])
define([], function() { return avif_dec; });
else if (typeof exports === 'object')
exports["avif_dec"] = avif_dec;

Binary file not shown.

37
codecs/avif/enc/README.md Normal file
View File

@ -0,0 +1,37 @@
# AVIF encoder
- Source: <https://github.com/AOMediaCodec/libavif>
- Version: v0.5.4
## Example
Run example.js
## API
### `Uint8Array encode(std::string image_in, int image_width, int image_height, AvifOptions opts)`
Encodes the given image with given dimension to AVIF. Options looks like this:
```c++
struct AvifOptions {
// 0 = lossless
// 63 = worst quality
int minQuantizer;
int maxQuantizer;
// [0 - 6]
// Creates 2^n tiles in that dimension
int tileRowsLog2;
int tileColsLog2;
// 0 = slowest
// 10 = fastest
int speed;
// 0 = 4:2:0
// 1 = 4:2:2
// 2 = 4:4:4
int subsample;
};
```

View File

@ -0,0 +1,106 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include "avif/avif.h"
using namespace emscripten;
struct AvifOptions {
// [0 - 63]
// 0 = lossless
// 63 = worst quality
int minQuantizer;
int maxQuantizer;
int minQuantizerAlpha;
int maxQuantizerAlpha;
// [0 - 6]
// Creates 2^n tiles in that dimension
int tileRowsLog2;
int tileColsLog2;
// [0 - 10]
// 0 = slowest
// 10 = fastest
int speed;
// 0 = 4:0:0
// 1 = 4:2:0
// 2 = 4:2:2
// 3 = 4:4:4
int subsample;
};
thread_local const val Uint8Array = val::global("Uint8Array");
val encode(std::string buffer, int width, int height, AvifOptions options) {
avifRWData output = AVIF_DATA_EMPTY;
int depth = 8;
avifPixelFormat format;
switch (options.subsample) {
case 0:
format = AVIF_PIXEL_FORMAT_YUV400;
break;
case 1:
format = AVIF_PIXEL_FORMAT_YUV420;
break;
case 2:
format = AVIF_PIXEL_FORMAT_YUV422;
break;
case 3:
format = AVIF_PIXEL_FORMAT_YUV444;
break;
}
avifImage* image = avifImageCreate(width, height, depth, format);
if (
options.maxQuantizer == AVIF_QUANTIZER_LOSSLESS &&
options.minQuantizer == AVIF_QUANTIZER_LOSSLESS &&
options.minQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS &&
options.maxQuantizerAlpha == AVIF_QUANTIZER_LOSSLESS &&
format == AVIF_PIXEL_FORMAT_YUV444
) {
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_IDENTITY;
} else {
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT709;
}
uint8_t* rgba = (uint8_t*)buffer.c_str();
avifRGBImage srcRGB;
avifRGBImageSetDefaults(&srcRGB, image);
srcRGB.pixels = rgba;
srcRGB.rowBytes = width * 4;
avifImageRGBToYUV(image, &srcRGB);
avifEncoder* encoder = avifEncoderCreate();
encoder->maxThreads = 1;
encoder->minQuantizer = options.minQuantizer;
encoder->maxQuantizer = options.maxQuantizer;
encoder->minQuantizerAlpha = options.minQuantizerAlpha;
encoder->maxQuantizerAlpha = options.maxQuantizerAlpha;
encoder->tileRowsLog2 = options.tileRowsLog2;
encoder->tileColsLog2 = options.tileColsLog2;
encoder->speed = options.speed;
avifResult encodeResult = avifEncoderWrite(encoder, image, &output);
auto js_result = val::null();
if (encodeResult == AVIF_RESULT_OK) {
js_result = Uint8Array.new_(typed_memory_view(output.size, output.data));
}
avifImageDestroy(image);
avifEncoderDestroy(encoder);
avifRWDataFree(&output);
return js_result;
}
EMSCRIPTEN_BINDINGS(my_module) {
value_object<AvifOptions>("AvifOptions")
.field("minQuantizer", &AvifOptions::minQuantizer)
.field("maxQuantizer", &AvifOptions::maxQuantizer)
.field("minQuantizerAlpha", &AvifOptions::minQuantizerAlpha)
.field("maxQuantizerAlpha", &AvifOptions::maxQuantizerAlpha)
.field("tileRowsLog2", &AvifOptions::tileRowsLog2)
.field("tileColsLog2", &AvifOptions::tileColsLog2)
.field("speed", &AvifOptions::speed)
.field("subsample", &AvifOptions::subsample);
function("encode", &encode);
}

7
codecs/avif/enc/avif_enc.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import { EncodeOptions } from '../../../src/codecs/avif/encoder-meta';
interface AVIFModule extends EmscriptenWasm.Module {
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array | null;
}
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;

113
codecs/avif/enc/avif_enc.js Normal file
View File

@ -0,0 +1,113 @@
var avif_enc = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(avif_enc) {
avif_enc = avif_enc || {};
var f;f||(f=typeof avif_enc !== 'undefined' ? avif_enc : {});var aa,ba;f.ready=new Promise(function(a,b){aa=a;ba=b});var ca={},m;for(m in f)f.hasOwnProperty(m)&&(ca[m]=f[m]);var da=!1,r=!1,ea=!1,fa=!1;da="object"===typeof window;r="function"===typeof importScripts;ea="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;fa=!da&&!ea&&!r;var u="",ha,ia,ja,ka;
if(ea)u=r?require("path").dirname(u)+"/":__dirname+"/",ha=function(a,b){ja||(ja=require("fs"));ka||(ka=require("path"));a=ka.normalize(a);return ja.readFileSync(a,b?null:"utf8")},ia=function(a){a=ha(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",x),f.inspect=function(){return"[Emscripten Module object]"};else if(fa)"undefined"!=
typeof read&&(ha=function(a){return read(a)}),ia=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");assert("object"===typeof a);return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(da||r)r?u=self.location.href:document.currentScript&&(u=document.currentScript.src),_scriptDir&&(u=_scriptDir),0!==u.indexOf("blob:")?u=u.substr(0,
u.lastIndexOf("/")+1):u="",ha=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},r&&(ia=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var la=f.print||console.log.bind(console),z=f.printErr||console.warn.bind(console);for(m in ca)ca.hasOwnProperty(m)&&(f[m]=ca[m]);ca=null;var ma=0,na;f.wasmBinary&&(na=f.wasmBinary);var noExitRuntime;f.noExitRuntime&&(noExitRuntime=f.noExitRuntime);
"object"!==typeof WebAssembly&&x("no native wasm support detected");var A,oa=new WebAssembly.Table({initial:901,maximum:901,element:"anyfunc"}),pa=!1;function assert(a,b){a||x("Assertion failed: "+b)}var qa="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function B(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&qa)return qa.decode(a.subarray(b,c));for(d="";b<c;){var e=a[b++];if(e&128){var g=a[b++]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|g);else{var h=a[b++]&63;e=224==(e&240)?(e&15)<<12|g<<6|h:(e&7)<<18|g<<12|h<<6|a[b++]&63;65536>e?d+=String.fromCharCode(e):(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023))}}else d+=String.fromCharCode(e)}return d}
function sa(a,b,c,d){if(!(0<d))return 0;var e=c;d=c+d-1;for(var g=0;g<a.length;++g){var h=a.charCodeAt(g);if(55296<=h&&57343>=h){var k=a.charCodeAt(++g);h=65536+((h&1023)<<10)|k&1023}if(127>=h){if(c>=d)break;b[c++]=h}else{if(2047>=h){if(c+1>=d)break;b[c++]=192|h>>6}else{if(65535>=h){if(c+2>=d)break;b[c++]=224|h>>12}else{if(c+3>=d)break;b[c++]=240|h>>18;b[c++]=128|h>>12&63}b[c++]=128|h>>6&63}b[c++]=128|h&63}}b[c]=0;return c-e}
function ta(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&(d=65536+((d&1023)<<10)|a.charCodeAt(++c)&1023);127>=d?++b:b=2047>=d?b+2:65535>=d?b+3:b+4}return b}var ua="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function va(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&wa[c];)++c;c<<=1;if(32<c-a&&ua)return ua.decode(C.subarray(a,c));c=0;for(d="";;){var e=E[a+2*c>>1];if(0==e||c==b/2)return d;++c;d+=String.fromCharCode(e)}}
function xa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var e=0;e<c;++e)E[b>>1]=a.charCodeAt(e),b+=2;E[b>>1]=0;return b-d}function ya(a){return 2*a.length}function za(a,b){for(var c=0,d="";!(c>=b/4);){var e=F[a+4*c>>2];if(0==e)break;++c;65536<=e?(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023)):d+=String.fromCharCode(e)}return d}
function Aa(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var e=0;e<a.length;++e){var g=a.charCodeAt(e);if(55296<=g&&57343>=g){var h=a.charCodeAt(++e);g=65536+((g&1023)<<10)|h&1023}F[b>>2]=g;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d}function Ba(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var G,H,C,E,wa,F,I,Ca,Da;
function Ea(a){G=a;f.HEAP8=H=new Int8Array(a);f.HEAP16=E=new Int16Array(a);f.HEAP32=F=new Int32Array(a);f.HEAPU8=C=new Uint8Array(a);f.HEAPU16=wa=new Uint16Array(a);f.HEAPU32=I=new Uint32Array(a);f.HEAPF32=Ca=new Float32Array(a);f.HEAPF64=Da=new Float64Array(a)}var Fa=f.INITIAL_MEMORY||16777216;f.wasmMemory?A=f.wasmMemory:A=new WebAssembly.Memory({initial:Fa/65536,maximum:32768});A&&(G=A.buffer);Fa=G.byteLength;Ea(G);F[219592]=6121408;
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(f);else{var c=b.qb;"number"===typeof c?void 0===b.Ya?f.dynCall_v(c):f.dynCall_vi(c,b.Ya):c(void 0===b.Ya?null:b.Ya)}}}var Ha=[],Ia=[],Ja=[],Ka=[];function La(){var a=f.preRun.shift();Ha.unshift(a)}var Ma=Math.abs,Na=Math.ceil,Oa=Math.floor,Pa=Math.min,J=0,Qa=null,Ra=null;f.preloadedImages={};f.preloadedAudios={};
function x(a){if(f.onAbort)f.onAbort(a);z(a);pa=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Sa(a){var b=K;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ta(){return Sa("data:application/octet-stream;base64,")}var K="avif_enc.wasm";if(!Ta()){var Ua=K;K=f.locateFile?f.locateFile(Ua,u):u+Ua}
function Va(){try{if(na)return new Uint8Array(na);if(ia)return ia(K);throw"both async and sync fetching of the wasm failed";}catch(a){x(a)}}function Wa(){return na||!da&&!r||"function"!==typeof fetch||Sa("file://")?new Promise(function(a){a(Va())}):fetch(K,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+K+"'";return a.arrayBuffer()}).catch(function(){return Va()})}var Xa,Ya;Ia.push({qb:function(){Za()}});function $a(){return 0<$a.Va}
function ab(a,b){for(var c=0,d=a.length-1;0<=d;d--){var e=a[d];"."===e?a.splice(d,1):".."===e?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function bb(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=ab(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
function cb(a){var b=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=b[0];b=b[1];if(!a&&!b)return".";b&&(b=b.substr(0,b.length-1));return a+b}function db(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
function eb(){for(var a="",b=!1,c=arguments.length-1;-1<=c&&!b;c--){b=0<=c?arguments[c]:"/";if("string"!==typeof b)throw new TypeError("Arguments to path.resolve must be strings");if(!b)return"";a=b+"/"+a;b="/"===b.charAt(0)}a=ab(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var fb=[];function gb(a,b){fb[a]={input:[],output:[],Ua:b};hb(a,ib)}
var ib={open:function(a){var b=fb[a.node.rdev];if(!b)throw new L(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.Ua.flush(a.tty)},flush:function(a){a.tty.Ua.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Ua.jb)throw new L(60);for(var e=0,g=0;g<d;g++){try{var h=a.tty.Ua.jb(a.tty)}catch(k){throw new L(29);}if(void 0===h&&0===e)throw new L(6);if(null===h||void 0===h)break;e++;b[c+g]=h}e&&(a.node.timestamp=Date.now());return e},write:function(a,b,c,d){if(!a.tty||!a.tty.Ua.$a)throw new L(60);
try{for(var e=0;e<d;e++)a.tty.Ua.$a(a.tty,b[c+e])}catch(g){throw new L(29);}d&&(a.node.timestamp=Date.now());return e}},jb={jb:function(a){if(!a.input.length){var b=null;if(ea){var c=Buffer.Va?Buffer.Va(256):new Buffer(256),d=0;try{d=ja.readSync(process.stdin.fd,c,0,256,null)}catch(e){if(-1!=e.toString().indexOf("EOF"))d=0;else throw e;}0<d?b=c.slice(0,d).toString("utf-8"):b=null}else"undefined"!=typeof window&&"function"==typeof window.prompt?(b=window.prompt("Input: "),null!==b&&(b+="\n")):"function"==
typeof readline&&(b=readline(),null!==b&&(b+="\n"));if(!b)return null;c=Array(ta(b)+1);b=sa(b,c,0,c.length);c.length=b;a.input=c}return a.input.shift()},$a:function(a,b){null===b||10===b?(la(B(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(la(B(a.output,0)),a.output=[])}},kb={$a:function(a,b){null===b||10===b?(z(B(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(z(B(a.output,0)),a.output=[])}},M={Ma:null,
Qa:function(){return M.createNode(null,"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new L(63);M.Ma||(M.Ma={dir:{node:{Ra:M.Ja.Ra,Oa:M.Ja.Oa,lookup:M.Ja.lookup,Wa:M.Ja.Wa,rename:M.Ja.rename,unlink:M.Ja.unlink,rmdir:M.Ja.rmdir,readdir:M.Ja.readdir,symlink:M.Ja.symlink},stream:{Ta:M.Ka.Ta}},file:{node:{Ra:M.Ja.Ra,Oa:M.Ja.Oa},stream:{Ta:M.Ka.Ta,read:M.Ka.read,write:M.Ka.write,cb:M.Ka.cb,kb:M.Ka.kb,mb:M.Ka.mb}},link:{node:{Ra:M.Ja.Ra,Oa:M.Ja.Oa,readlink:M.Ja.readlink},
stream:{}},eb:{node:{Ra:M.Ja.Ra,Oa:M.Ja.Oa},stream:lb}});c=mb(a,b,c,d);16384===(c.mode&61440)?(c.Ja=M.Ma.dir.node,c.Ka=M.Ma.dir.stream,c.Ia={}):32768===(c.mode&61440)?(c.Ja=M.Ma.file.node,c.Ka=M.Ma.file.stream,c.La=0,c.Ia=null):40960===(c.mode&61440)?(c.Ja=M.Ma.link.node,c.Ka=M.Ma.link.stream):8192===(c.mode&61440)&&(c.Ja=M.Ma.eb.node,c.Ka=M.Ma.eb.stream);c.timestamp=Date.now();a&&(a.Ia[b]=c);return c},Hb:function(a){if(a.Ia&&a.Ia.subarray){for(var b=[],c=0;c<a.La;++c)b.push(a.Ia[c]);return b}return a.Ia},
Ib:function(a){return a.Ia?a.Ia.subarray?a.Ia.subarray(0,a.La):new Uint8Array(a.Ia):new Uint8Array(0)},fb:function(a,b){var c=a.Ia?a.Ia.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Ia,a.Ia=new Uint8Array(b),0<a.La&&a.Ia.set(c.subarray(0,a.La),0))},Ab:function(a,b){if(a.La!=b)if(0==b)a.Ia=null,a.La=0;else{if(!a.Ia||a.Ia.subarray){var c=a.Ia;a.Ia=new Uint8Array(b);c&&a.Ia.set(c.subarray(0,Math.min(b,a.La)))}else if(a.Ia||(a.Ia=[]),a.Ia.length>b)a.Ia.length=b;
else for(;a.Ia.length<b;)a.Ia.push(0);a.La=b}},Ja:{Ra:function(a){var b={};b.dev=8192===(a.mode&61440)?a.id:1;b.ino=a.id;b.mode=a.mode;b.nlink=1;b.uid=0;b.gid=0;b.rdev=a.rdev;16384===(a.mode&61440)?b.size=4096:32768===(a.mode&61440)?b.size=a.La:40960===(a.mode&61440)?b.size=a.link.length:b.size=0;b.atime=new Date(a.timestamp);b.mtime=new Date(a.timestamp);b.ctime=new Date(a.timestamp);b.ob=4096;b.blocks=Math.ceil(b.size/b.ob);return b},Oa:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&
(a.timestamp=b.timestamp);void 0!==b.size&&M.Ab(a,b.size)},lookup:function(){throw nb[44];},Wa:function(a,b,c,d){return M.createNode(a,b,c,d)},rename:function(a,b,c){if(16384===(a.mode&61440)){try{var d=ob(b,c)}catch(g){}if(d)for(var e in d.Ia)throw new L(55);}delete a.parent.Ia[a.name];a.name=c;b.Ia[c]=a;a.parent=b},unlink:function(a,b){delete a.Ia[b]},rmdir:function(a,b){var c=ob(a,b),d;for(d in c.Ia)throw new L(55);delete a.Ia[b]},readdir:function(a){var b=[".",".."],c;for(c in a.Ia)a.Ia.hasOwnProperty(c)&&
b.push(c);return b},symlink:function(a,b,c){a=M.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new L(28);return a.link}},Ka:{read:function(a,b,c,d,e){var g=a.node.Ia;if(e>=a.node.La)return 0;a=Math.min(a.node.La-e,d);if(8<a&&g.subarray)b.set(g.subarray(e,e+a),c);else for(d=0;d<a;d++)b[c+d]=g[e+d];return a},write:function(a,b,c,d,e,g){b.buffer===H.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Ia||a.Ia.subarray)){if(g)return a.Ia=
b.subarray(c,c+d),a.La=d;if(0===a.La&&0===e)return a.Ia=b.slice(c,c+d),a.La=d;if(e+d<=a.La)return a.Ia.set(b.subarray(c,c+d),e),d}M.fb(a,e+d);if(a.Ia.subarray&&b.subarray)a.Ia.set(b.subarray(c,c+d),e);else for(g=0;g<d;g++)a.Ia[e+g]=b[c+g];a.La=Math.max(a.La,e+d);return d},Ta:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.La);if(0>b)throw new L(28);return b},cb:function(a,b,c){M.fb(a.node,b+c);a.node.La=Math.max(a.node.La,b+c)},kb:function(a,b,c,d,e,g){assert(0===
b);if(32768!==(a.node.mode&61440))throw new L(43);a=a.node.Ia;if(g&2||a.buffer!==G){if(0<d||d+c<a.length)a.subarray?a=a.subarray(d,d+c):a=Array.prototype.slice.call(a,d,d+c);d=!0;g=16384*Math.ceil(c/16384);for(b=pb(g);c<g;)H[b+c++]=0;c=b;if(!c)throw new L(48);H.set(a,c)}else d=!1,c=a.byteOffset;return{Mb:c,Gb:d}},mb:function(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new L(43);if(e&2)return 0;M.Ka.write(a,b,0,d,c,!1);return 0}}},qb=null,rb={},sb=[],tb=1,ub=null,vb=!0,wb={},L=null,nb={};
function N(a,b){a=eb("/",a);b=b||{};if(!a)return{path:"",node:null};var c={ib:!0,ab:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.ab)throw new L(32);a=ab(a.split("/").filter(function(h){return!!h}),!1);var e=qb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;e=ob(e,a[d]);c=bb(c+"/"+a[d]);e.Xa&&(!g||g&&b.ib)&&(e=e.Xa.root);if(!g||b.hb)for(g=0;40960===(e.mode&61440);)if(e=xb(c),c=eb(cb(c),e),e=N(c,{ab:b.ab}).node,40<g++)throw new L(32);}return{path:c,node:e}}
function yb(a){for(var b;;){if(a===a.parent)return a=a.Qa.lb,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function zb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%ub.length}function ob(a,b){var c;if(c=(c=Ab(a,"x"))?c:a.Ja.lookup?0:2)throw new L(c,a);for(c=ub[zb(a.id,b)];c;c=c.xb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Ja.lookup(a,b)}
function mb(a,b,c,d){a=new Bb(a,b,c,d);b=zb(a.parent.id,a.name);a.xb=ub[b];return ub[b]=a}var Cb={r:0,rs:1052672,"r+":2,w:577,wx:705,xw:705,"w+":578,"wx+":706,"xw+":706,a:1089,ax:1217,xa:1217,"a+":1090,"ax+":1218,"xa+":1218};function Db(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function Ab(a,b){if(vb)return 0;if(-1===b.indexOf("r")||a.mode&292){if(-1!==b.indexOf("w")&&!(a.mode&146)||-1!==b.indexOf("x")&&!(a.mode&73))return 2}else return 2;return 0}
function Eb(a,b){try{return ob(a,b),20}catch(c){}return Ab(a,"wx")}function Fb(a){var b=4096;for(a=a||0;a<=b;a++)if(!sb[a])return a;throw new L(33);}function Gb(a,b){Hb||(Hb=function(){},Hb.prototype={});var c=new Hb,d;for(d in a)c[d]=a[d];a=c;b=Fb(b);a.fd=b;return sb[b]=a}var lb={open:function(a){a.Ka=rb[a.node.rdev].Ka;a.Ka.open&&a.Ka.open(a)},Ta:function(){throw new L(70);}};function hb(a,b){rb[a]={Ka:b}}
function Ib(a,b){var c="/"===b,d=!b;if(c&&qb)throw new L(10);if(!c&&!d){var e=N(b,{ib:!1});b=e.path;e=e.node;if(e.Xa)throw new L(10);if(16384!==(e.mode&61440))throw new L(54);}b={type:a,Lb:{},lb:b,wb:[]};a=a.Qa(b);a.Qa=b;b.root=a;c?qb=a:e&&(e.Xa=b,e.Qa&&e.Qa.wb.push(b))}function Jb(a,b,c){var d=N(a,{parent:!0}).node;a=db(a);if(!a||"."===a||".."===a)throw new L(28);var e=Eb(d,a);if(e)throw new L(e);if(!d.Ja.Wa)throw new L(63);return d.Ja.Wa(d,a,b,c)}function O(a){Jb(a,16895,0)}
function Kb(a,b,c){"undefined"===typeof c&&(c=b,b=438);Jb(a,b|8192,c)}function Lb(a,b){if(!eb(a))throw new L(44);var c=N(b,{parent:!0}).node;if(!c)throw new L(44);b=db(b);var d=Eb(c,b);if(d)throw new L(d);if(!c.Ja.symlink)throw new L(63);c.Ja.symlink(c,b,a)}function xb(a){a=N(a).node;if(!a)throw new L(44);if(!a.Ja.readlink)throw new L(28);return eb(yb(a.parent),a.Ja.readlink(a))}
function Mb(a,b,c,d){if(""===a)throw new L(44);if("string"===typeof b){var e=Cb[b];if("undefined"===typeof e)throw Error("Unknown file open mode: "+b);b=e}c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=bb(a);try{g=N(a,{hb:!(b&131072)}).node}catch(k){}}e=!1;if(b&64)if(g){if(b&128)throw new L(20);}else g=Jb(a,c,0),e=!0;if(!g)throw new L(44);8192===(g.mode&61440)&&(b&=-513);if(b&65536&&16384!==(g.mode&61440))throw new L(54);if(!e&&(c=g?40960===(g.mode&61440)?
32:16384===(g.mode&61440)&&("r"!==Db(b)||b&512)?31:Ab(g,Db(b)):44))throw new L(c);if(b&512){c=g;var h;"string"===typeof c?h=N(c,{hb:!0}).node:h=c;if(!h.Ja.Oa)throw new L(63);if(16384===(h.mode&61440))throw new L(31);if(32768!==(h.mode&61440))throw new L(28);if(c=Ab(h,"w"))throw new L(c);h.Ja.Oa(h,{size:0,timestamp:Date.now()})}b&=-131713;d=Gb({node:g,path:yb(g),flags:b,seekable:!0,position:0,Ka:g.Ka,Fb:[],error:!1},d);d.Ka.open&&d.Ka.open(d);!f.logReadFiles||b&1||(Nb||(Nb={}),a in Nb||(Nb[a]=1,z("FS.trackingDelegate error on read file: "+
a)));try{wb.onOpenFile&&(g=0,1!==(b&2097155)&&(g|=1),0!==(b&2097155)&&(g|=2),wb.onOpenFile(a,g))}catch(k){z("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+k.message)}return d}function Ob(a,b,c){if(null===a.fd)throw new L(8);if(!a.seekable||!a.Ka.Ta)throw new L(70);if(0!=c&&1!=c&&2!=c)throw new L(28);a.position=a.Ka.Ta(a,b,c);a.Fb=[]}
function Pb(){L||(L=function(a,b){this.node=b;this.Bb=function(c){this.Sa=c};this.Bb(a);this.message="FS error"},L.prototype=Error(),L.prototype.constructor=L,[44].forEach(function(a){nb[a]=new L(a);nb[a].stack="<generic error, no stack>"}))}var Qb;function Rb(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
function Sb(a,b,c){a=bb("/dev/"+a);var d=Rb(!!b,!!c);Tb||(Tb=64);var e=Tb++<<8|0;hb(e,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,h,k,l){for(var n=0,p=0;p<l;p++){try{var t=b()}catch(v){throw new L(29);}if(void 0===t&&0===n)throw new L(6);if(null===t||void 0===t)break;n++;h[k+p]=t}n&&(g.node.timestamp=Date.now());return n},write:function(g,h,k,l){for(var n=0;n<l;n++)try{c(h[k+n])}catch(p){throw new L(29);}l&&(g.node.timestamp=Date.now());return n}});
Kb(a,d,e)}var Tb,Q={},Hb,Nb,Ub=void 0;function Vb(){Ub+=4;return F[Ub-4>>2]}function Wb(a){a=sb[a];if(!a)throw new L(8);return a}var Xb={};function Yb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Zb(a){return this.fromWireType(I[a>>2])}var $b={},R={},ac={};function bc(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
function cc(a,b){a=bc(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function dc(a){var b=Error,c=cc(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
var ec=void 0;function fc(a,b,c){function d(k){k=c(k);if(k.length!==a.length)throw new ec("Mismatched type converter count");for(var l=0;l<a.length;++l)S(a[l],k[l])}a.forEach(function(k){ac[k]=b});var e=Array(b.length),g=[],h=0;b.forEach(function(k,l){R.hasOwnProperty(k)?e[l]=R[k]:(g.push(k),$b.hasOwnProperty(k)||($b[k]=[]),$b[k].push(function(){e[l]=R[k];++h;h===g.length&&d(e)}))});0===g.length&&d(e)}
function hc(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var ic=void 0;function T(a){for(var b="";C[a];)b+=ic[C[a++]];return b}var jc=void 0;function U(a){throw new jc(a);}
function S(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||U('type "'+d+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.ub)return;U("Cannot register type '"+d+"' twice")}R[a]=b;delete ac[a];$b.hasOwnProperty(a)&&(b=$b[a],delete $b[a],b.forEach(function(e){e()}))}var kc=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function lc(a){4<a&&0===--V[a].bb&&(V[a]=void 0,kc.push(a))}function mc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=kc.length?kc.pop():V.length;V[b]={bb:1,value:a};return b}}function nc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function oc(a,b){switch(b){case 2:return function(c){return this.fromWireType(Ca[c>>2])};case 3:return function(c){return this.fromWireType(Da[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function pc(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=cc(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function qc(a,b){var c=f;if(void 0===c[a].Na){var d=c[a];c[a]=function(){c[a].Na.hasOwnProperty(arguments.length)||U("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Na+")!");return c[a].Na[arguments.length].apply(this,arguments)};c[a].Na=[];c[a].Na[d.nb]=d}}
function rc(a,b,c){f.hasOwnProperty(a)?((void 0===c||void 0!==f[a].Na&&void 0!==f[a].Na[c])&&U("Cannot register public name '"+a+"' twice"),qc(a,a),f.hasOwnProperty(c)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),f[a].Na[c]=b):(f[a]=b,void 0!==c&&(f[a].Kb=c))}function sc(a,b){for(var c=[],d=0;d<a;d++)c.push(F[(b>>2)+d]);return c}
function tc(a,b){a=T(a);var c=f["dynCall_"+a];for(var d=[],e=1;e<a.length;++e)d.push("a"+e);e="return function dynCall_"+(a+"_"+b)+"("+d.join(", ")+") {\n";e+=" return dynCall(rawFunction"+(d.length?", ":"")+d.join(", ")+");\n";c=(new Function("dynCall","rawFunction",e+"};\n"))(c,b);"function"!==typeof c&&U("unknown function pointer with signature "+a+": "+b);return c}var uc=void 0;function vc(a){a=wc(a);var b=T(a);W(a);return b}
function xc(a,b){function c(g){e[g]||R[g]||(ac[g]?ac[g].forEach(c):(d.push(g),e[g]=!0))}var d=[],e={};b.forEach(c);throw new uc(a+": "+d.map(vc).join([", "]));}function yc(a,b,c){switch(b){case 0:return c?function(d){return H[d]}:function(d){return C[d]};case 1:return c?function(d){return E[d>>1]}:function(d){return wa[d>>1]};case 2:return c?function(d){return F[d>>2]}:function(d){return I[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var zc={};
function Ac(){return"object"===typeof globalThis?globalThis:Function("return this")()}function Bc(a,b){var c=R[a];void 0===c&&U(b+" has unknown type "+vc(a));return c}var Cc={};function Bb(a,b,c,d){a||(a=this);this.parent=a;this.Qa=a.Qa;this.Xa=null;this.id=tb++;this.name=b;this.mode=c;this.Ja={};this.Ka={};this.rdev=d}
Object.defineProperties(Bb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}}});Pb();ub=Array(4096);Ib(M,"/");O("/tmp");O("/home");O("/home/web_user");
(function(){O("/dev");hb(259,{read:function(){return 0},write:function(d,e,g,h){return h}});Kb("/dev/null",259);gb(1280,jb);gb(1536,kb);Kb("/dev/tty",1280);Kb("/dev/tty1",1536);if("object"===typeof crypto&&"function"===typeof crypto.getRandomValues){var a=new Uint8Array(1);var b=function(){crypto.getRandomValues(a);return a[0]}}else if(ea)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){x("random_device")});Sb("random",b);Sb("urandom",b);O("/dev/shm");
O("/dev/shm/tmp")})();O("/proc");O("/proc/self");O("/proc/self/fd");Ib({Qa:function(){var a=mb("/proc/self","fd",16895,73);a.Ja={lookup:function(b,c){var d=sb[+c];if(!d)throw new L(8);b={parent:null,Qa:{lb:"fake"},Ja:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");ec=f.InternalError=dc("InternalError");for(var Dc=Array(256),Ec=0;256>Ec;++Ec)Dc[Ec]=String.fromCharCode(Ec);ic=Dc;jc=f.BindingError=dc("BindingError");
f.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};f.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};uc=f.UnboundTypeError=dc("UnboundTypeError");
var Qc={w:function(a){return pb(a)},T:function(){},R:function(a){"uncaught_exception"in $a?$a.Va++:$a.Va=1;throw a;},p:function(a,b,c){Ub=c;try{var d=Wb(a);switch(b){case 0:var e=Vb();return 0>e?-28:Mb(d.path,d.flags,0,e).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=Vb(),d.flags|=e,0;case 12:return e=Vb(),E[e+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return F[Fc()>>2]=28,-1;default:return-28}}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Sa}},
K:function(a,b,c){Ub=c;try{var d=Wb(a);switch(b){case 21509:case 21505:return d.tty?0:-59;case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:return d.tty?0:-59;case 21519:if(!d.tty)return-59;var e=Vb();return F[e>>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=e=Vb();if(!d.Ka.vb)throw new L(59);return d.Ka.vb(d,b,a);case 21523:return d.tty?0:-59;case 21524:return d.tty?0:-59;default:x("bad ioctl syscall "+b)}}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Sa}},L:function(a,
b,c){Ub=c;try{var d=a?B(C,a,void 0):"",e=Vb();return Mb(d,b,e).fd}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Sa}},A:function(a){var b=Xb[a];delete Xb[a];var c=b.yb,d=b.zb,e=b.gb,g=e.map(function(h){return h.tb}).concat(e.map(function(h){return h.Db}));fc([a],g,function(h){var k={};e.forEach(function(l,n){var p=h[n],t=l.rb,v=l.sb,w=h[n+e.length],q=l.Cb,D=l.Eb;k[l.pb]={read:function(y){return p.fromWireType(t(v,y))},write:function(y,P){var ra=[];q(D,y,w.toWireType(ra,P));Yb(ra)}}});
return[{name:b.name,fromWireType:function(l){var n={},p;for(p in k)n[p]=k[p].read(l);d(l);return n},toWireType:function(l,n){for(var p in k)if(!(p in n))throw new TypeError('Missing field: "'+p+'"');var t=c();for(p in k)k[p].write(t,n[p]);null!==l&&l.push(d,t);return t},argPackAdvance:8,readValueFromPointer:Zb,Pa:d}]})},N:function(a,b,c,d,e){var g=hc(c);b=T(b);S(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,k){return k?d:e},argPackAdvance:8,readValueFromPointer:function(h){if(1===
c)var k=H;else if(2===c)k=E;else if(4===c)k=F;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[h>>g])},Pa:null})},M:function(a,b){b=T(b);S(a,{name:b,fromWireType:function(c){var d=V[c].value;lc(c);return d},toWireType:function(c,d){return mc(d)},argPackAdvance:8,readValueFromPointer:Zb,Pa:null})},s:function(a,b,c){c=hc(c);b=T(b);S(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,e){if("number"!==typeof e&&"boolean"!==typeof e)throw new TypeError('Cannot convert "'+
nc(e)+'" to '+this.name);return e},argPackAdvance:8,readValueFromPointer:oc(b,c),Pa:null})},y:function(a,b,c,d,e,g){var h=sc(b,c);a=T(a);e=tc(d,e);rc(a,function(){xc("Cannot call "+a+" due to unbound types",h)},b-1);fc([],h,function(k){var l=[k[0],null].concat(k.slice(1)),n=k=a,p=e,t=l.length;2>t&&U("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var v=null!==l[1]&&!1,w=!1,q=1;q<l.length;++q)if(null!==l[q]&&void 0===l[q].Pa){w=!0;break}var D="void"!==l[0].name,
y="",P="";for(q=0;q<t-2;++q)y+=(0!==q?", ":"")+"arg"+q,P+=(0!==q?", ":"")+"arg"+q+"Wired";n="return function "+bc(n)+"("+y+") {\nif (arguments.length !== "+(t-2)+") {\nthrowBindingError('function "+n+" called with ' + arguments.length + ' arguments, expected "+(t-2)+" args!');\n}\n";w&&(n+="var destructors = [];\n");var ra=w?"destructors":"null";y="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[U,p,g,Yb,l[0],l[1]];v&&(n+="var thisWired = classParam.toWireType("+ra+", this);\n");
for(q=0;q<t-2;++q)n+="var arg"+q+"Wired = argType"+q+".toWireType("+ra+", arg"+q+"); // "+l[q+2].name+"\n",y.push("argType"+q),p.push(l[q+2]);v&&(P="thisWired"+(0<P.length?", ":"")+P);n+=(D?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";if(w)n+="runDestructors(destructors);\n";else for(q=v?1:2;q<l.length;++q)t=1===q?"thisWired":"arg"+(q-2)+"Wired",null!==l[q].Pa&&(n+=t+"_dtor("+t+"); // "+l[q].name+"\n",y.push(t+"_dtor"),p.push(l[q].Pa));D&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");
y.push(n+"}\n");l=pc(y).apply(null,p);q=b-1;if(!f.hasOwnProperty(k))throw new ec("Replacing nonexistant public symbol");void 0!==f[k].Na&&void 0!==q?f[k].Na[q]=l:(f[k]=l,f[k].nb=q);return[]})},i:function(a,b,c,d,e){function g(n){return n}b=T(b);-1===e&&(e=4294967295);var h=hc(c);if(0===d){var k=32-8*c;g=function(n){return n<<k>>>k}}var l=-1!=b.indexOf("unsigned");S(a,{name:b,fromWireType:g,toWireType:function(n,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+
nc(p)+'" to '+this.name);if(p<d||p>e)throw new TypeError('Passing a number "'+nc(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+e+"]!");return l?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:yc(b,h,0!==d),Pa:null})},f:function(a,b,c){function d(g){g>>=2;var h=I;return new e(G,h[g+1],h[g])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);S(a,{name:c,fromWireType:d,argPackAdvance:8,
readValueFromPointer:d},{ub:!0})},u:function(a,b){b=T(b);var c="std::string"===b;S(a,{name:b,fromWireType:function(d){var e=I[d>>2];if(c)for(var g=d+4,h=0;h<=e;++h){var k=d+4+h;if(h==e||0==C[k]){g=g?B(C,g,k-g):"";if(void 0===l)var l=g;else l+=String.fromCharCode(0),l+=g;g=k+1}}else{l=Array(e);for(h=0;h<e;++h)l[h]=String.fromCharCode(C[d+4+h]);l=l.join("")}W(d);return l},toWireType:function(d,e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));var g="string"===typeof e;g||e instanceof Uint8Array||e instanceof
Uint8ClampedArray||e instanceof Int8Array||U("Cannot pass non-string to std::string");var h=(c&&g?function(){return ta(e)}:function(){return e.length})(),k=pb(4+h+1);I[k>>2]=h;if(c&&g)sa(e,C,k+4,h+1);else if(g)for(g=0;g<h;++g){var l=e.charCodeAt(g);255<l&&(W(k),U("String has UTF-16 code units that do not fit in 8 bits"));C[k+4+g]=l}else for(g=0;g<h;++g)C[k+4+g]=e[g];null!==d&&d.push(W,k);return k},argPackAdvance:8,readValueFromPointer:Zb,Pa:function(d){W(d)}})},n:function(a,b,c){c=T(c);if(2===b){var d=
va;var e=xa;var g=ya;var h=function(){return wa};var k=1}else 4===b&&(d=za,e=Aa,g=Ba,h=function(){return I},k=2);S(a,{name:c,fromWireType:function(l){for(var n=I[l>>2],p=h(),t,v=l+4,w=0;w<=n;++w){var q=l+4+w*b;if(w==n||0==p[q>>k])v=d(v,q-v),void 0===t?t=v:(t+=String.fromCharCode(0),t+=v),v=q+b}W(l);return t},toWireType:function(l,n){"string"!==typeof n&&U("Cannot pass non-string to C++ string type "+c);var p=g(n),t=pb(4+p+b);I[t>>2]=p>>k;e(n,t+4,p+b);null!==l&&l.push(W,t);return t},argPackAdvance:8,
readValueFromPointer:Zb,Pa:function(l){W(l)}})},G:function(a,b,c,d,e,g){Xb[a]={name:T(b),yb:tc(c,d),zb:tc(e,g),gb:[]}},z:function(a,b,c,d,e,g,h,k,l,n){Xb[a].gb.push({pb:T(b),tb:c,rb:tc(d,e),sb:g,Db:h,Cb:tc(k,l),Eb:n})},O:function(a,b){b=T(b);S(a,{Jb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:lc,S:function(a){if(0===a)return mc(Ac());var b=zc[a];a=void 0===b?T(a):b;return mc(Ac()[a])},x:function(a){4<a&&(V[a].bb+=1)},H:function(a,b,c,d){a||U("Cannot use deleted val. handle = "+
a);a=V[a].value;var e=Cc[b];if(!e){e="";for(var g=0;g<b;++g)e+=(0!==g?", ":"")+"arg"+g;var h="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)h+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";e=(new Function("requireRegisteredType","Module","__emval_register",h+("var obj = new constructor("+e+");\nreturn __emval_register(obj);\n}\n")))(Bc,
f,mc);Cc[b]=e}return e(a,c,d)},v:function(){x()},P:function(){z("missing function: aom_codec_av1_dx");x(-1)},d:function(a,b){X(a,b||1);throw"longjmp";},I:function(a,b,c){C.copyWithin(a,b,b+c)},j:function(a){a>>>=0;var b=C.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(16777216,a,d);0<d%65536&&(d+=65536-d%65536);a:{try{A.grow(Math.min(2147483648,d)-G.byteLength+65535>>>16);Ea(A.buffer);var e=1;break a}catch(g){}e=void 0}if(e)return!0}return!1},
r:function(a){try{var b=Wb(a);if(null===b.fd)throw new L(8);b.Za&&(b.Za=null);try{b.Ka.close&&b.Ka.close(b)}catch(c){throw c;}finally{sb[b.fd]=null}b.fd=null;return 0}catch(c){return"undefined"!==typeof Q&&c instanceof L||x(c),c.Sa}},J:function(a,b,c,d){try{a:{for(var e=Wb(a),g=a=0;g<c;g++){var h=F[b+(8*g+4)>>2],k=e,l=F[b+8*g>>2],n=h,p=void 0,t=H;if(0>n||0>p)throw new L(28);if(null===k.fd)throw new L(8);if(1===(k.flags&2097155))throw new L(8);if(16384===(k.node.mode&61440))throw new L(31);if(!k.Ka.read)throw new L(28);
var v="undefined"!==typeof p;if(!v)p=k.position;else if(!k.seekable)throw new L(70);var w=k.Ka.read(k,t,l,n,p);v||(k.position+=w);var q=w;if(0>q){var D=-1;break a}a+=q;if(q<h)break}D=a}F[d>>2]=D;return 0}catch(y){return"undefined"!==typeof Q&&y instanceof L||x(y),y.Sa}},E:function(a,b,c,d,e){try{var g=Wb(a);a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Ob(g,a,d);Ya=[g.position>>>0,(Xa=g.position,1<=+Ma(Xa)?0<Xa?(Pa(+Oa(Xa/4294967296),4294967295)|0)>>>0:~~+Na((Xa-+(~~Xa>>>
0))/4294967296)>>>0:0)];F[e>>2]=Ya[0];F[e+4>>2]=Ya[1];g.Za&&0===a&&0===d&&(g.Za=null);return 0}catch(h){return"undefined"!==typeof Q&&h instanceof L||x(h),h.Sa}},q:function(a,b,c,d){try{a:{for(var e=Wb(a),g=a=0;g<c;g++){var h=e,k=F[b+8*g>>2],l=F[b+(8*g+4)>>2],n=void 0,p=H;if(0>l||0>n)throw new L(28);if(null===h.fd)throw new L(8);if(0===(h.flags&2097155))throw new L(8);if(16384===(h.node.mode&61440))throw new L(31);if(!h.Ka.write)throw new L(28);h.seekable&&h.flags&1024&&Ob(h,0,2);var t="undefined"!==
typeof n;if(!t)n=h.position;else if(!h.seekable)throw new L(70);var v=h.Ka.write(h,p,k,l,n,void 0);t||(h.position+=v);try{if(h.path&&wb.onWriteToFile)wb.onWriteToFile(h.path)}catch(D){z("FS.trackingDelegate['onWriteToFile']('"+h.path+"') threw an exception: "+D.message)}var w=v;if(0>w){var q=-1;break a}a+=w}q=a}F[d>>2]=q;return 0}catch(D){return"undefined"!==typeof Q&&D instanceof L||x(D),D.Sa}},b:function(){return ma|0},k:Gc,e:Hc,o:Ic,F:Jc,C:Kc,B:Lc,D:Mc,m:Nc,l:Oc,c:Pc,memory:A,g:function(a){a=+a;
return 0<=a?+Oa(a+.5):+Na(a-.5)},h:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},a:function(a){ma=a|0},table:oa,Q:function(a){var b=Date.now()/1E3|0;a&&(F[a>>2]=b);return b}};
(function(){function a(e){f.asm=e.exports;J--;f.monitorRunDependencies&&f.monitorRunDependencies(J);0==J&&(null!==Qa&&(clearInterval(Qa),Qa=null),Ra&&(e=Ra,Ra=null,e()))}function b(e){a(e.instance)}function c(e){return Wa().then(function(g){return WebAssembly.instantiate(g,d)}).then(e,function(g){z("failed to asynchronously prepare wasm: "+g);x(g)})}var d={a:Qc};J++;f.monitorRunDependencies&&f.monitorRunDependencies(J);if(f.instantiateWasm)try{return f.instantiateWasm(d,a)}catch(e){return z("Module.instantiateWasm callback failed with error: "+
e),!1}(function(){if(na||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(K,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,d).then(b,function(g){z("wasm streaming compile failed: "+g);z("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Za=f.___wasm_call_ctors=function(){return(Za=f.___wasm_call_ctors=f.asm.U).apply(null,arguments)},pb=f._malloc=function(){return(pb=f._malloc=f.asm.V).apply(null,arguments)},W=f._free=function(){return(W=f._free=f.asm.W).apply(null,arguments)},wc=f.___getTypeName=function(){return(wc=f.___getTypeName=f.asm.X).apply(null,arguments)};f.___embind_register_native_and_builtin_types=function(){return(f.___embind_register_native_and_builtin_types=f.asm.Y).apply(null,arguments)};
var Fc=f.___errno_location=function(){return(Fc=f.___errno_location=f.asm.Z).apply(null,arguments)},X=f._setThrew=function(){return(X=f._setThrew=f.asm._).apply(null,arguments)},Y=f.stackSave=function(){return(Y=f.stackSave=f.asm.$).apply(null,arguments)},Z=f.stackRestore=function(){return(Z=f.stackRestore=f.asm.aa).apply(null,arguments)},Rc=f.dynCall_vi=function(){return(Rc=f.dynCall_vi=f.asm.ba).apply(null,arguments)},Sc=f.dynCall_vii=function(){return(Sc=f.dynCall_vii=f.asm.ca).apply(null,arguments)};
f.dynCall_viii=function(){return(f.dynCall_viii=f.asm.da).apply(null,arguments)};var Tc=f.dynCall_viiii=function(){return(Tc=f.dynCall_viiii=f.asm.ea).apply(null,arguments)},Uc=f.dynCall_ii=function(){return(Uc=f.dynCall_ii=f.asm.fa).apply(null,arguments)},Vc=f.dynCall_iii=function(){return(Vc=f.dynCall_iii=f.asm.ga).apply(null,arguments)};f.dynCall_iiii=function(){return(f.dynCall_iiii=f.asm.ha).apply(null,arguments)};f.dynCall_iiiii=function(){return(f.dynCall_iiiii=f.asm.ia).apply(null,arguments)};
var Wc=f.dynCall_iiiiiiiii=function(){return(Wc=f.dynCall_iiiiiiiii=f.asm.ja).apply(null,arguments)},Xc=f.dynCall_iiiiiiiiii=function(){return(Xc=f.dynCall_iiiiiiiiii=f.asm.ka).apply(null,arguments)},Yc=f.dynCall_iiiijj=function(){return(Yc=f.dynCall_iiiijj=f.asm.la).apply(null,arguments)},Zc=f.dynCall_ij=function(){return(Zc=f.dynCall_ij=f.asm.ma).apply(null,arguments)},$c=f.dynCall_jjij=function(){return($c=f.dynCall_jjij=f.asm.na).apply(null,arguments)};
f.dynCall_i=function(){return(f.dynCall_i=f.asm.oa).apply(null,arguments)};f.dynCall_iiiiii=function(){return(f.dynCall_iiiiii=f.asm.pa).apply(null,arguments)};f.dynCall_viiiii=function(){return(f.dynCall_viiiii=f.asm.qa).apply(null,arguments)};f.dynCall_viiiiii=function(){return(f.dynCall_viiiiii=f.asm.ra).apply(null,arguments)};f.dynCall_viiiiiiii=function(){return(f.dynCall_viiiiiiii=f.asm.sa).apply(null,arguments)};f.dynCall_viiiiiii=function(){return(f.dynCall_viiiiiii=f.asm.ta).apply(null,arguments)};
f.dynCall_viiiiiiiiiii=function(){return(f.dynCall_viiiiiiiiiii=f.asm.ua).apply(null,arguments)};f.dynCall_jiiiiiiiii=function(){return(f.dynCall_jiiiiiiiii=f.asm.va).apply(null,arguments)};f.dynCall_iiiiiiii=function(){return(f.dynCall_iiiiiiii=f.asm.wa).apply(null,arguments)};f.dynCall_iiiiiii=function(){return(f.dynCall_iiiiiii=f.asm.xa).apply(null,arguments)};f.dynCall_iiiiiiiiiiii=function(){return(f.dynCall_iiiiiiiiiiii=f.asm.ya).apply(null,arguments)};
f.dynCall_iidiiii=function(){return(f.dynCall_iidiiii=f.asm.za).apply(null,arguments)};f.dynCall_jiji=function(){return(f.dynCall_jiji=f.asm.Aa).apply(null,arguments)};f.dynCall_viiiiiiiiii=function(){return(f.dynCall_viiiiiiiiii=f.asm.Ba).apply(null,arguments)};f.dynCall_viiiiiiiiiiiii=function(){return(f.dynCall_viiiiiiiiiiiii=f.asm.Ca).apply(null,arguments)};f.dynCall_jiiiiiiii=function(){return(f.dynCall_jiiiiiiii=f.asm.Da).apply(null,arguments)};
f.dynCall_ff=function(){return(f.dynCall_ff=f.asm.Ea).apply(null,arguments)};f.dynCall_jiiiiii=function(){return(f.dynCall_jiiiiii=f.asm.Fa).apply(null,arguments)};f.dynCall_jiiiii=function(){return(f.dynCall_jiiiii=f.asm.Ga).apply(null,arguments)};f.dynCall_iiijii=function(){return(f.dynCall_iiijii=f.asm.Ha).apply(null,arguments)};function Hc(a,b,c){var d=Y();try{return Vc(a,b,c)}catch(e){Z(d);if(e!==e+0&&"longjmp"!==e)throw e;X(1,0)}}
function Nc(a,b){var c=Y();try{Rc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Pc(a,b,c,d,e){var g=Y();try{Tc(a,b,c,d,e)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function Oc(a,b,c){var d=Y();try{Sc(a,b,c)}catch(e){Z(d);if(e!==e+0&&"longjmp"!==e)throw e;X(1,0)}}function Gc(a,b){var c=Y();try{return Uc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}
function Jc(a,b,c,d,e,g,h,k,l,n){var p=Y();try{return Xc(a,b,c,d,e,g,h,k,l,n)}catch(t){Z(p);if(t!==t+0&&"longjmp"!==t)throw t;X(1,0)}}function Ic(a,b,c,d,e,g,h,k,l){var n=Y();try{return Wc(a,b,c,d,e,g,h,k,l)}catch(p){Z(n);if(p!==p+0&&"longjmp"!==p)throw p;X(1,0)}}function Mc(a,b,c,d,e,g){var h=Y();try{return $c(a,b,c,d,e,g)}catch(k){Z(h);if(k!==k+0&&"longjmp"!==k)throw k;X(1,0)}}
function Kc(a,b,c,d,e,g,h,k){var l=Y();try{return Yc(a,b,c,d,e,g,h,k)}catch(n){Z(l);if(n!==n+0&&"longjmp"!==n)throw n;X(1,0)}}function Lc(a,b,c){var d=Y();try{return Zc(a,b,c)}catch(e){Z(d);if(e!==e+0&&"longjmp"!==e)throw e;X(1,0)}}var ad;Ra=function bd(){ad||cd();ad||(Ra=bd)};
function cd(){function a(){if(!ad&&(ad=!0,f.calledRun=!0,!pa)){f.noFSInit||Qb||(Qb=!0,Pb(),f.stdin=f.stdin,f.stdout=f.stdout,f.stderr=f.stderr,f.stdin?Sb("stdin",f.stdin):Lb("/dev/tty","/dev/stdin"),f.stdout?Sb("stdout",null,f.stdout):Lb("/dev/tty","/dev/stdout"),f.stderr?Sb("stderr",null,f.stderr):Lb("/dev/tty1","/dev/stderr"),Mb("/dev/stdin","r"),Mb("/dev/stdout","w"),Mb("/dev/stderr","w"));Ga(Ia);vb=!1;Ga(Ja);aa(f);if(f.onRuntimeInitialized)f.onRuntimeInitialized();if(f.postRun)for("function"==
typeof f.postRun&&(f.postRun=[f.postRun]);f.postRun.length;){var b=f.postRun.shift();Ka.unshift(b)}Ga(Ka)}}if(!(0<J)){if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preRun]);f.preRun.length;)La();Ga(Ha);0<J||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1);a()},1)):a())}}f.run=cd;if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.pop()();noExitRuntime=!0;cd();
return avif_enc.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = avif_enc;
else if (typeof define === 'function' && define['amd'])
define([], function() { return avif_enc; });
else if (typeof exports === 'object')
exports["avif_enc"] = avif_enc;

Binary file not shown.

6
codecs/avif/package.json Normal file
View File

@ -0,0 +1,6 @@
{
"name": "avif",
"scripts": {
"build": "../build-cpp.sh"
}
}

3
codecs/build-cpp.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh -e
docker build -t squoosh-cpp - < ../cpp.Dockerfile
docker run --rm -v $PWD:/src squoosh-cpp

4
codecs/build-rust.sh Executable file
View File

@ -0,0 +1,4 @@
set -e
docker build -t squoosh-rust - < ../rust.Dockerfile
docker run --rm -v $PWD:/src squoosh-rust "$@"

9
codecs/cpp.Dockerfile Normal file
View File

@ -0,0 +1,9 @@
FROM emscripten/emsdk:1.40.0
RUN apt-get update && apt-get install -qqy autoconf libtool pkg-config
ENV CFLAGS "-Os -flto"
ENV CXXFLAGS "${CFLAGS} -std=c++17"
ENV LDFLAGS "${CFLAGS}"
# Build and cache standard libraries with these flags
RUN emcc ${CXXFLAGS} --bind -xc++ /dev/null -o /dev/null
WORKDIR /src
CMD ["sh", "-c", "emmake make -j`nproc`"]

View File

@ -1,5 +1 @@
**/*.rs.bk
target
Cargo.lock
bin/
pkg/README.md
/target

289
codecs/hqx/Cargo.lock generated Normal file
View File

@ -0,0 +1,289 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "bumpalo"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "console_error_panic_hook"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "futures"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "hqx"
version = "0.1.0"
source = "git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2#5f19cda24191ccc7c0c4920b6b246b4e242f377c"
dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "js-sys"
version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memory_units"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "squooshhqx"
version = "0.1.0"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"hqx 0.1.0 (git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
"wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"web-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro-support 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasm-bindgen-test"
version = "0.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wasm-bindgen-test-macro"
version = "0.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "web-sys"
version = "0.3.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "wee_alloc"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)",
"memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum bumpalo 3.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum console_error_panic_hook 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
"checksum futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
"checksum hqx 0.1.0 (git+https://github.com/CryZe/wasmboy-rs?tag=v0.1.2)" = "<none>"
"checksum js-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "52732a3d3ad72c58ad2dc70624f9c17b46ecd0943b9a4f1ee37c4c18c5d983e2"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.73 (registry+https://github.com/rust-lang/crates.io-index)" = "bd7d4bd64732af4bf3a67f367c27df8520ad7e230c5817b8ff485864d80242b9"
"checksum log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
"checksum memory_units 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
"checksum proc-macro2 1.0.19 (registry+https://github.com/rust-lang/crates.io-index)" = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
"checksum quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
"checksum syn 1.0.35 (registry+https://github.com/rust-lang/crates.io-index)" = "fb7f4c519df8c117855e19dd8cc851e89eb746fe7a73f0157e0d95fdec5369b0"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unicode-xid 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
"checksum wasm-bindgen 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "f3edbcc9536ab7eababcc6d2374a0b7bfe13a2b6d562c5e07f370456b1a8f33d"
"checksum wasm-bindgen-backend 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "89ed2fb8c84bfad20ea66b26a3743f3e7ba8735a69fe7d95118c33ec8fc1244d"
"checksum wasm-bindgen-futures 0.3.27 (registry+https://github.com/rust-lang/crates.io-index)" = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
"checksum wasm-bindgen-macro 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "eb071268b031a64d92fc6cf691715ca5a40950694d8f683c5bb43db7c730929e"
"checksum wasm-bindgen-macro-support 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "cf592c807080719d1ff2f245a687cbadb3ed28b2077ed7084b47aba8b691f2c6"
"checksum wasm-bindgen-shared 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "72b6c0220ded549d63860c78c38f3bcc558d1ca3f4efa74942c536ddbbb55e87"
"checksum wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1"
"checksum wasm-bindgen-test-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5"
"checksum web-sys 0.3.42 (registry+https://github.com/rust-lang/crates.io-index)" = "8be2398f326b7ba09815d0b403095f34dd708579220d099caae89be0b32137b2"
"checksum wee_alloc 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -1,12 +1,11 @@
FROM rust
# This is intentionally an old version of Rust. Newer versions
# generate _significantly_ bigger Wasm binaries.
FROM rust:1.37
RUN rustup target add wasm32-unknown-unknown
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN mkdir /opt/binaryen && \
curl -L https://github.com/WebAssembly/binaryen/releases/download/1.38.32/binaryen-1.38.32-x86-linux.tar.gz | tar -xzf - -C /opt/binaryen --strip 1
RUN mkdir /opt/wabt && \
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.11/wabt-1.0.11-linux.tar.gz | tar -xzf - -C /opt/wabt --strip 1
ENV PATH="/opt/binaryen:/opt/wabt:${PATH}"
ENV PATH="/opt/binaryen:${PATH}"
WORKDIR /src

201
codecs/hqx/LICENSE.codec.md Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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
http://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.

5
codecs/hqx/README.md Normal file
View File

@ -0,0 +1,5 @@
# HQX
- Source: <https://github.com/CryZe/wasmboy-rs>
- Version: v0.1.2
- License: Apache 2.0

View File

@ -6,11 +6,7 @@ echo "============================================="
echo "Compiling wasm"
echo "============================================="
(
wasm-pack build
wasm-strip pkg/squooshhqx_bg.wasm
echo "Optimising Wasm so it doesn't break Chrome (this takes like 10-15mins. get a cup of tea)"
echo "Once https://crbug.com/974804 is fixed, we can remove this step"
wasm-opt -Os --no-validation -o pkg/squooshhqx_bg.wasm pkg/squooshhqx_bg.wasm
wasm-pack build -- --verbose --locked
rm pkg/.gitignore
)
echo "============================================="

View File

@ -1,7 +1,7 @@
{
"name": "hqx",
"scripts": {
"build:image": "docker build -t squoosh-hqx .",
"build:image": "docker build -t squoosh-hqx - < Dockerfile",
"build": "docker run --rm -v $(pwd):/src squoosh-hqx ./build.sh"
}
}

View File

@ -11,5 +11,5 @@
],
"module": "squooshhqx.js",
"types": "squooshhqx.d.ts",
"sideEffects": "false"
"sideEffects": false
}

View File

@ -1,4 +1,5 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {Uint32Array} input_image
* @param {number} input_width

View File

@ -1,46 +1,2 @@
import * as wasm from './squooshhqx_bg.wasm';
let cachegetUint32Memory = null;
function getUint32Memory() {
if (cachegetUint32Memory === null || cachegetUint32Memory.buffer !== wasm.memory.buffer) {
cachegetUint32Memory = new Uint32Array(wasm.memory.buffer);
}
return cachegetUint32Memory;
}
let WASM_VECTOR_LEN = 0;
function passArray32ToWasm(arg) {
const ptr = wasm.__wbindgen_malloc(arg.length * 4);
getUint32Memory().set(arg, ptr / 4);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachegetInt32Memory = null;
function getInt32Memory() {
if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) {
cachegetInt32Memory = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory;
}
function getArrayU32FromWasm(ptr, len) {
return getUint32Memory().subarray(ptr / 4, ptr / 4 + len);
}
/**
* @param {Uint32Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} factor
* @returns {Uint32Array}
*/
export function resize(input_image, input_width, input_height, factor) {
const retptr = 8;
const ret = wasm.resize(retptr, passArray32ToWasm(input_image), WASM_VECTOR_LEN, input_width, input_height, factor);
const memi32 = getInt32Memory();
const v0 = getArrayU32FromWasm(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1]).slice();
wasm.__wbindgen_free(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1] * 4);
return v0;
}
import * as wasm from "./squooshhqx_bg.wasm";
export * from "./squooshhqx_bg.js";

View File

@ -1,5 +1,6 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function resize(a: number, b: number, c: number, d: number, e: number, f: number): void;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_free(a: number, b: number): void;
export function resize(a: number, b: number, c: number, d: number, e: number, f: number): void;

View File

@ -0,0 +1,48 @@
import * as wasm from './squooshhqx_bg.wasm';
let cachegetUint32Memory0 = null;
function getUint32Memory0() {
if (cachegetUint32Memory0 === null || cachegetUint32Memory0.buffer !== wasm.memory.buffer) {
cachegetUint32Memory0 = new Uint32Array(wasm.memory.buffer);
}
return cachegetUint32Memory0;
}
let WASM_VECTOR_LEN = 0;
function passArray32ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 4);
getUint32Memory0().set(arg, ptr / 4);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory0;
}
function getArrayU32FromWasm0(ptr, len) {
return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
}
/**
* @param {Uint32Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} factor
* @returns {Uint32Array}
*/
export function resize(input_image, input_width, input_height, factor) {
var ptr0 = passArray32ToWasm0(input_image, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.resize(8, ptr0, len0, input_width, input_height, factor);
var r0 = getInt32Memory0()[8 / 4 + 0];
var r1 = getInt32Memory0()[8 / 4 + 1];
var v1 = getArrayU32FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 4);
return v1;
}

Binary file not shown.

View File

@ -0,0 +1,641 @@
libimagequant is derived from code by Jef Poskanzer and Greg Roelofs
licensed under pngquant's original license (at the end of this file),
and contains extensive changes and additions by Kornel Lesiński
licensed under GPL v3 or later.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
libimagequant © 2009-2018 by Kornel Lesiński.
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
© 1989, 1991 by Jef Poskanzer.
© 1997, 2000, 2002 by Greg Roelofs.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, provided
that the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation. This software is provided "as is" without express or
implied warranty.

View File

@ -0,0 +1,40 @@
CODEC_URL := https://github.com/ImageOptim/libimagequant/archive/2.12.1.tar.gz
CODEC_DIR := node_modules/libimagequant
CODEC_OUT_RELATIVE := libimagequant.a
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
OUT_JS := imagequant.js
OUT_WASM := $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR) \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
$(CODEC_OUT): $(CODEC_DIR)/config.mk
$(MAKE) -C $(CODEC_DIR) $(CODEC_OUT_RELATIVE)
$(CODEC_DIR)/config.mk: $(CODEC_DIR)/configure
cd $(CODEC_DIR) && ./configure \
--disable-sse
$(CODEC_DIR)/configure: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

View File

@ -2,6 +2,7 @@
- Source: <https://github.com/ImageOptim/libimagequant>
- Version: v2.12.1
- License: GPL3
## Dependencies
@ -24,7 +25,3 @@ Quantizes the given images, using at most `numColors`, a value between 2 and 256
### `RawImage zx_quantize(std::string buffer, int image_width, int image_height, float dithering)`
???
### `void free_result()`
Frees the result created by `quantize()`.

View File

@ -1,43 +0,0 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
echo "============================================="
echo "Compiling libimagequant"
echo "============================================="
(
cd node_modules/libimagequant
emconfigure ./configure --disable-sse
emmake make static -j`nproc`
)
echo "============================================="
echo "Compiling wasm module"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="imagequant"' \
-I node_modules/libimagequant \
-o ./imagequant.js \
--std=c++11 \
-x c++ \
imagequant.cpp \
node_modules/libimagequant/libimagequant.a
)
echo "============================================="
echo "Compiling wasm module done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten-upstream\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@ -28,7 +28,6 @@
// const rawImage = Module.quantize(image.data, image.width, image.height, 256, 1.0);
const rawImage = Module.zx_quantize(image.data, image.width, image.height, 1.0);
console.log('done');
Module.free_result();
const imageData = new ImageData(new Uint8ClampedArray(rawImage.buffer), rawImage.width, rawImage.height);
const canvas = document.createElement('canvas');

View File

@ -1,95 +1,87 @@
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include <stdlib.h>
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <inttypes.h>
#include <limits.h>
#include <math.h>
#include <stdlib.h>
#include "libimagequant.h"
using namespace emscripten;
int version() {
return (((LIQ_VERSION/10000) % 100) << 16) |
(((LIQ_VERSION/100 ) % 100) << 8) |
(((LIQ_VERSION/1 ) % 100) << 0);
return (((LIQ_VERSION / 10000) % 100) << 16) | (((LIQ_VERSION / 100) % 100) << 8) |
(((LIQ_VERSION / 1) % 100) << 0);
}
class RawImage {
public:
val buffer;
int width;
int height;
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
RawImage(val b, int w, int h)
: buffer(b), width(w), height(h) {}
};
#define liq_ptr(T) std::unique_ptr<T, std::integral_constant<decltype(&T##_destroy), T##_destroy>>
using liq_attr_ptr = liq_ptr(liq_attr);
using liq_image_ptr = liq_ptr(liq_image);
using liq_result_ptr = liq_ptr(liq_result);
liq_attr *attr;
liq_image *image;
liq_result *res;
uint8_t* result;
RawImage quantize(std::string rawimage, int image_width, int image_height, int num_colors, float dithering) {
const uint8_t* image_buffer = (uint8_t*)rawimage.c_str();
int size = image_width * image_height;
attr = liq_attr_create();
image = liq_image_create_rgba(attr, image_buffer, image_width, image_height, 0);
liq_set_max_colors(attr, num_colors);
liq_result_ptr liq_image_quantize(liq_image* image, liq_attr* attr) {
liq_result* res = nullptr;
liq_image_quantize(image, attr, &res);
liq_set_dithering_level(res, dithering);
uint8_t* image8bit = (uint8_t*) malloc(size);
result = (uint8_t*) malloc(size * 4);
liq_write_remapped_image(res, image, image8bit, size);
const liq_palette *pal = liq_get_palette(res);
return liq_result_ptr(res);
}
val quantize(std::string rawimage,
int image_width,
int image_height,
int num_colors,
float dithering) {
auto image_buffer = (const liq_color*)rawimage.c_str();
int size = image_width * image_height;
liq_attr_ptr attr(liq_attr_create());
liq_image_ptr image(
liq_image_create_rgba(attr.get(), image_buffer, image_width, image_height, 0));
liq_set_max_colors(attr.get(), num_colors);
auto res = liq_image_quantize(image.get(), attr.get());
liq_set_dithering_level(res.get(), dithering);
std::vector<uint8_t> image8bit(size);
std::vector<liq_color> result(size);
liq_write_remapped_image(res.get(), image.get(), image8bit.data(), image8bit.size());
auto pal = liq_get_palette(res.get());
// Turn palletted image back into an RGBA image
for(int i = 0; i < size; i++) {
result[i * 4 + 0] = pal->entries[image8bit[i]].r;
result[i * 4 + 1] = pal->entries[image8bit[i]].g;
result[i * 4 + 2] = pal->entries[image8bit[i]].b;
result[i * 4 + 3] = pal->entries[image8bit[i]].a;
for (int i = 0; i < size; i++) {
result[i] = pal->entries[image8bit[i]];
}
free(image8bit);
liq_result_destroy(res);
liq_image_destroy(image);
liq_attr_destroy(attr);
return {
val(typed_memory_view(image_width*image_height*4, result)),
image_width,
image_height
};
return Uint8ClampedArray.new_(
typed_memory_view(result.size() * sizeof(liq_color), (const uint8_t*)result.data()));
}
const liq_color zx_colors[] = {
{.r = 0, .g = 0, .b = 0, .a = 255}, // regular black
{.r = 0, .g = 0, .b = 215, .a = 255}, // regular blue
{.r = 215, .g = 0, .b = 0, .a = 255}, // regular red
{.r = 215, .g = 0, .b = 215, .a = 255}, // regular magenta
{.r = 0, .g = 215, .b = 0, .a = 255}, // regular green
{.r = 0, .g = 215, .b = 215, .a = 255}, // regular cyan
{.r = 215, .g = 215, .b = 0, .a = 255}, // regular yellow
{.r = 215, .g = 215, .b = 215, .a = 255}, // regular white
{.r = 0, .g = 0, .b = 255, .a = 255}, // bright blue
{.r = 255, .g = 0, .b = 0, .a = 255}, // bright red
{.r = 255, .g = 0, .b = 255, .a = 255}, // bright magenta
{.r = 0, .g = 255, .b = 0, .a = 255}, // bright green
{.r = 0, .g = 255, .b = 255, .a = 255}, // bright cyan
{.r = 255, .g = 255, .b = 0, .a = 255}, // bright yellow
{.r = 255, .g = 255, .b = 255, .a = 255} // bright white
{.r = 0, .g = 0, .b = 0, .a = 255}, // regular black
{.r = 0, .g = 0, .b = 215, .a = 255}, // regular blue
{.r = 215, .g = 0, .b = 0, .a = 255}, // regular red
{.r = 215, .g = 0, .b = 215, .a = 255}, // regular magenta
{.r = 0, .g = 215, .b = 0, .a = 255}, // regular green
{.r = 0, .g = 215, .b = 215, .a = 255}, // regular cyan
{.r = 215, .g = 215, .b = 0, .a = 255}, // regular yellow
{.r = 215, .g = 215, .b = 215, .a = 255}, // regular white
{.r = 0, .g = 0, .b = 255, .a = 255}, // bright blue
{.r = 255, .g = 0, .b = 0, .a = 255}, // bright red
{.r = 255, .g = 0, .b = 255, .a = 255}, // bright magenta
{.r = 0, .g = 255, .b = 0, .a = 255}, // bright green
{.r = 0, .g = 255, .b = 255, .a = 255}, // bright cyan
{.r = 255, .g = 255, .b = 0, .a = 255}, // bright yellow
{.r = 255, .g = 255, .b = 255, .a = 255} // bright white
};
uint8_t block[8 * 8 * 4];
/**
* The ZX has one bit per pixel, but can assign two colours to an 8x8 block. The two colours must
* both be 'regular' or 'bright'. Black exists as both regular and bright.
* The ZX has one bit per pixel, but can assign two colours to an 8x8 block. The
* two colours must both be 'regular' or 'bright'. Black exists as both regular
* and bright.
*/
RawImage zx_quantize(std::string rawimage, int image_width, int image_height, float dithering) {
const uint8_t* image_buffer = (uint8_t*) rawimage.c_str();
val zx_quantize(std::string rawimage, int image_width, int image_height, float dithering) {
auto image_buffer = (const liq_color*)rawimage.c_str();
int size = image_width * image_height;
int bytes_per_pixel = 4;
result = (uint8_t*) malloc(size * bytes_per_pixel);
uint8_t* image8bit = (uint8_t*) malloc(8 * 8);
liq_color block[8 * 8];
uint8_t image8bit[8 * 8];
std::vector<liq_color> result(size);
// For each 8x8 grid
for (int block_start_y = 0; block_start_y < image_height; block_start_y += 8) {
@ -99,7 +91,8 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
int block_width = 8;
int block_height = 8;
// If the block hangs off the right/bottom of the image dimensions, make it smaller to fit.
// If the block hangs off the right/bottom of the image dimensions, make
// it smaller to fit.
if (block_start_y + block_height > image_height) {
block_height = image_height - block_start_y;
}
@ -111,26 +104,22 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
// For each pixel in that block:
for (int y = block_start_y; y < block_start_y + block_height; y++) {
for (int x = block_start_x; x < block_start_x + block_width; x++) {
int pixel_start = (y * image_width * bytes_per_pixel) + (x * bytes_per_pixel);
int pixel_start = (y * image_width) + x;
int smallest_distance = INT_MAX;
int winning_index = -1;
// Copy pixel data for quantizing later
block[block_index++] = image_buffer[pixel_start];
block[block_index++] = image_buffer[pixel_start + 1];
block[block_index++] = image_buffer[pixel_start + 2];
block[block_index++] = image_buffer[pixel_start + 3];
// Which zx color is this pixel closest to?
for (int color_index = 0; color_index < 15; color_index++) {
liq_color color = zx_colors[color_index];
liq_color pixel = image_buffer[pixel_start];
// Using Euclidean distance. LibQuant has better methods, but it requires conversion to
// LAB, so I don't think it's worth it.
// Using Euclidean distance. LibQuant has better methods, but it
// requires conversion to LAB, so I don't think it's worth it.
int distance =
pow(color.r - image_buffer[pixel_start + 0], 2) +
pow(color.g - image_buffer[pixel_start + 1], 2) +
pow(color.b - image_buffer[pixel_start + 2], 2);
pow(color.r - pixel.r, 2) + pow(color.g - pixel.g, 2) + pow(color.b - pixel.b, 2);
if (distance < smallest_distance) {
winning_index = color_index;
@ -151,7 +140,8 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
for (int color_index = 0; color_index < 15; color_index++) {
if (color_popularity[color_index] > highest_popularity) {
// Store this as the most popular pixel, and demote the current values:
// Store this as the most popular pixel, and demote the current
// values:
third_color_index = second_color_index;
third_highest_popularity = second_highest_popularity;
second_color_index = first_color_index;
@ -169,8 +159,8 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
}
}
// ZX images can't mix bright and regular colours, except black which appears in both.
// Resolve any conflict:
// ZX images can't mix bright and regular colours, except black which
// appears in both. Resolve any conflict:
while (1) {
// If either colour is black, there's no conflict to resolve.
if (first_color_index != 0 && second_color_index != 0) {
@ -183,63 +173,44 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
}
}
// If, during conflict resolving, we now have two of the same colour (because we initially
// selected the bright & regular version of the same colour), retry again with the third
// most popular colour.
// If, during conflict resolving, we now have two of the same colour
// (because we initially selected the bright & regular version of the
// same colour), retry again with the third most popular colour.
if (first_color_index == second_color_index) {
second_color_index = third_color_index;
} else break;
} else
break;
}
// Quantize
attr = liq_attr_create();
image = liq_image_create_rgba(attr, block, block_width, block_height, 0);
liq_set_max_colors(attr, 2);
liq_image_add_fixed_color(image, zx_colors[first_color_index]);
liq_image_add_fixed_color(image, zx_colors[second_color_index]);
liq_image_quantize(image, attr, &res);
liq_set_dithering_level(res, dithering);
liq_write_remapped_image(res, image, image8bit, size);
const liq_palette *pal = liq_get_palette(res);
liq_attr_ptr attr(liq_attr_create());
liq_image_ptr image(liq_image_create_rgba(attr.get(), block, block_width, block_height, 0));
liq_set_max_colors(attr.get(), 2);
liq_image_add_fixed_color(image.get(), zx_colors[first_color_index]);
liq_image_add_fixed_color(image.get(), zx_colors[second_color_index]);
auto res = liq_image_quantize(image.get(), attr.get());
liq_set_dithering_level(res.get(), dithering);
liq_write_remapped_image(res.get(), image.get(), image8bit, size);
auto pal = liq_get_palette(res.get());
// Turn palletted image back into an RGBA image, and write it into the full size result image.
for(int y = 0; y < block_height; y++) {
for(int x = 0; x < block_width; x++) {
// Turn palletted image back into an RGBA image, and write it into the
// full size result image.
for (int y = 0; y < block_height; y++) {
for (int x = 0; x < block_width; x++) {
int image8BitPos = y * block_width + x;
int resultStartPos = ((block_start_y + y) * bytes_per_pixel * image_width) + ((block_start_x + x) * bytes_per_pixel);
result[resultStartPos + 0] = pal->entries[image8bit[image8BitPos]].r;
result[resultStartPos + 1] = pal->entries[image8bit[image8BitPos]].g;
result[resultStartPos + 2] = pal->entries[image8bit[image8BitPos]].b;
result[resultStartPos + 3] = pal->entries[image8bit[image8BitPos]].a;
int resultStartPos = ((block_start_y + y) * image_width) + (block_start_x + x);
result[resultStartPos] = pal->entries[image8bit[image8BitPos]];
}
}
liq_result_destroy(res);
liq_image_destroy(image);
liq_attr_destroy(attr);
}
}
free(image8bit);
return {
val(typed_memory_view(image_width*image_height*4, result)),
image_width,
image_height
};
}
void free_result() {
free(result);
return Uint8ClampedArray.new_(
typed_memory_view(result.size() * sizeof(liq_color), (const uint8_t*)result.data()));
}
EMSCRIPTEN_BINDINGS(my_module) {
class_<RawImage>("RawImage")
.property("buffer", &RawImage::buffer)
.property("width", &RawImage::width)
.property("height", &RawImage::height);
function("quantize", &quantize);
function("zx_quantize", &zx_quantize);
function("version", &version);
function("free_result", &free_result);
}

View File

@ -1,15 +1,6 @@
interface RawImage {
buffer: Uint8Array;
width: number;
height: number;
}
interface QuantizerModule extends EmscriptenWasm.Module {
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): RawImage;
zx_quantize(data: BufferSource, width: number, height: number, dither: number): RawImage;
free_result(): void;
quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): Uint8ClampedArray;
zx_quantize(data: BufferSource, width: number, height: number, dither: number): Uint8ClampedArray;
}
export default function(opts: EmscriptenWasm.ModuleOpts): QuantizerModule;

View File

@ -6,69 +6,56 @@ var imagequant = (function() {
function(imagequant) {
imagequant = imagequant || {};
var e;e||(e=typeof imagequant !== 'undefined' ? imagequant : {});var r={},t;for(t in e)e.hasOwnProperty(t)&&(r[t]=e[t]);var aa=!1,z=!1,ba=!1,ca=!1;aa="object"===typeof window;z="function"===typeof importScripts;ba="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ca=!aa&&!ba&&!z;var A="",da,B,ea,ha;
if(ba)A=z?require("path").dirname(A)+"/":__dirname+"/",da=function(a,b){ea||(ea=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return ea.readFileSync(a,b?null:"utf8")},B=function(a){a=da(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||C("Assertion failed: undefined");return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",C),e.inspect=function(){return"[Emscripten Module object]"};
else if(ca)"undefined"!=typeof read&&(da=function(a){return read(a)}),B=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||C("Assertion failed: undefined");return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(aa||z)z?A=self.location.href:document.currentScript&&(A=document.currentScript.src),_scriptDir&&
(A=_scriptDir),0!==A.indexOf("blob:")?A=A.substr(0,A.lastIndexOf("/")+1):A="",da=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},z&&(B=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ia=e.print||console.log.bind(console),E=e.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(e[t]=r[t]);r=null;var F;e.wasmBinary&&(F=e.wasmBinary);var noExitRuntime;
e.noExitRuntime&&(noExitRuntime=e.noExitRuntime);"object"!==typeof WebAssembly&&E("no native wasm support detected");var G,ja=new WebAssembly.Table({initial:49,maximum:49,element:"anyfunc"}),ka=!1,la="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function ma(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&la)return la.decode(a.subarray(b,c));for(d="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))d+=String.fromCharCode((f&31)<<6|g);else{var n=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|n:(f&7)<<18|g<<12|n<<6|a[b++]&63;65536>f?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d}
function na(a,b,c){var d=H;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var n=a.charCodeAt(++f);g=65536+((g&1023)<<10)|n&1023}if(127>=g){if(b>=c)break;d[b++]=g}else{if(2047>=g){if(b+1>=c)break;d[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;d[b++]=224|g>>12}else{if(b+3>=c)break;d[b++]=240|g>>18;d[b++]=128|g>>12&63}d[b++]=128|g>>6&63}d[b++]=128|g&63}}d[b]=0}}var oa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function pa(a){var b;for(b=a>>1;I[b];)++b;b<<=1;if(32<b-a&&oa)return oa.decode(H.subarray(a,b));b=0;for(var c="";;){var d=I[a+2*b>>1];if(0==d)return c;++b;c+=String.fromCharCode(d)}}function qa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var d=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)I[b>>1]=a.charCodeAt(f),b+=2;I[b>>1]=0;return b-d}function ra(a){return 2*a.length}
function sa(a){for(var b=0,c="";;){var d=J[a+4*b>>2];if(0==d)return c;++b;65536<=d?(d-=65536,c+=String.fromCharCode(55296|d>>10,56320|d&1023)):c+=String.fromCharCode(d)}}function ta(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var d=b;c=d+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var n=a.charCodeAt(++f);g=65536+((g&1023)<<10)|n&1023}J[b>>2]=g;b+=4;if(b+4>c)break}J[b>>2]=0;return b-d}
function ua(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);55296<=d&&57343>=d&&++c;b+=4}return b}var K,va,H,I,wa,J,L,xa,ya;function za(a){K=a;e.HEAP8=va=new Int8Array(a);e.HEAP16=I=new Int16Array(a);e.HEAP32=J=new Int32Array(a);e.HEAPU8=H=new Uint8Array(a);e.HEAPU16=wa=new Uint16Array(a);e.HEAPU32=L=new Uint32Array(a);e.HEAPF32=xa=new Float32Array(a);e.HEAPF64=ya=new Float64Array(a)}var Aa=e.INITIAL_MEMORY||16777216;e.wasmMemory?G=e.wasmMemory:G=new WebAssembly.Memory({initial:Aa/65536});
G&&(K=G.buffer);Aa=K.byteLength;za(K);J[1660]=5249680;function Ba(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b();else{var c=b.ra;"number"===typeof c?void 0===b.ia?e.dynCall_v(c):e.dynCall_vi(c,b.ia):c(void 0===b.ia?null:b.ia)}}}var Ca=[],Da=[],Ea=[],Fa=[];function Ga(){var a=e.preRun.shift();Ca.unshift(a)}var M=0,Ha=null,N=null;e.preloadedImages={};e.preloadedAudios={};
function C(a){if(e.onAbort)e.onAbort(a);ia(a);E(a);ka=!0;throw new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");}function Ia(){var a=O;return String.prototype.startsWith?a.startsWith("data:application/octet-stream;base64,"):0===a.indexOf("data:application/octet-stream;base64,")}var O="imagequant.wasm";if(!Ia()){var Ja=O;O=e.locateFile?e.locateFile(Ja,A):A+Ja}
function Ka(){try{if(F)return new Uint8Array(F);if(B)return B(O);throw"both async and sync fetching of the wasm failed";}catch(a){C(a)}}function La(){return F||!aa&&!z||"function"!==typeof fetch?new Promise(function(a){a(Ka())}):fetch(O,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+O+"'";return a.arrayBuffer()}).catch(function(){return Ka()})}Da.push({ra:function(){Ma()}});
function Na(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Oa=void 0;function P(a){for(var b="";H[a];)b+=Oa[H[a++]];return b}var Q={},R={},Pa={};function Qa(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
function Ra(a,b){a=Qa(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Sa(a){var b=Error,c=Ra(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
var Ta=void 0;function S(a){throw new Ta(a);}var Ua=void 0;function Va(a){throw new Ua(a);}function Wa(a,b,c){function d(h){h=c(h);h.length!==a.length&&Va("Mismatched type converter count");for(var k=0;k<a.length;++k)T(a[k],h[k])}a.forEach(function(h){Pa[h]=b});var f=Array(b.length),g=[],n=0;b.forEach(function(h,k){R.hasOwnProperty(h)?f[k]=R[h]:(g.push(h),Q.hasOwnProperty(h)||(Q[h]=[]),Q[h].push(function(){f[k]=R[h];++n;n===g.length&&d(f)}))});0===g.length&&d(f)}
function T(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||S('type "'+d+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(c.ua)return;S("Cannot register type '"+d+"' twice")}R[a]=b;delete Pa[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}function Xa(a){return{count:a.count,da:a.da,ea:a.ea,T:a.T,V:a.V,W:a.W,X:a.X}}
function Ya(a){S(a.S.V.U.name+" instance already deleted")}var Za=!1;function $a(){}function ab(a){--a.count.value;0===a.count.value&&(a.W?a.X.ba(a.W):a.V.U.ba(a.T))}function bb(a){if("undefined"===typeof FinalizationGroup)return bb=function(b){return b},a;Za=new FinalizationGroup(function(b){for(var c=b.next();!c.done;c=b.next())c=c.value,c.T?ab(c):console.warn("object already deleted: "+c.T)});bb=function(b){Za.register(b,b.S,b.S);return b};$a=function(b){Za.unregister(b.S)};return bb(a)}
var cb=void 0,db=[];function eb(){for(;db.length;){var a=db.pop();a.S.da=!1;a["delete"]()}}function U(){}var fb={};function gb(a,b){var c=e;if(void 0===c[a].Z){var d=c[a];c[a]=function(){c[a].Z.hasOwnProperty(arguments.length)||S("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Z+")!");return c[a].Z[arguments.length].apply(this,arguments)};c[a].Z=[];c[a].Z[d.oa]=d}}
function hb(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].Z&&void 0!==e[a].Z[c])&&S("Cannot register public name '"+a+"' twice"),gb(a,a),e.hasOwnProperty(c)&&S("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].Z[c]=b):(e[a]=b,void 0!==c&&(e[a].Aa=c))}function ib(a,b,c,d,f,g,n,h){this.name=a;this.constructor=b;this.aa=c;this.ba=d;this.Y=f;this.sa=g;this.fa=n;this.qa=h}
function jb(a,b,c){for(;b!==c;)b.fa||S("Expected null or instance of "+c.name+", got an instance of "+b.name),a=b.fa(a),b=b.Y;return a}function kb(a,b){if(null===b)return this.ja&&S("null is not a valid "+this.name),0;b.S||S('Cannot pass "'+V(b)+'" as a '+this.name);b.S.T||S("Cannot pass deleted object as a pointer of type "+this.name);return jb(b.S.T,b.S.V.U,this.U)}
function lb(a,b){if(null===b){this.ja&&S("null is not a valid "+this.name);if(this.ha){var c=this.wa();null!==a&&a.push(this.ba,c);return c}return 0}b.S||S('Cannot pass "'+V(b)+'" as a '+this.name);b.S.T||S("Cannot pass deleted object as a pointer of type "+this.name);!this.ga&&b.S.V.ga&&S("Cannot convert argument of type "+(b.S.X?b.S.X.name:b.S.V.name)+" to parameter type "+this.name);c=jb(b.S.T,b.S.V.U,this.U);if(this.ha)switch(void 0===b.S.W&&S("Passing raw pointer to smart pointer is illegal"),
this.ya){case 0:b.S.X===this?c=b.S.W:S("Cannot convert argument of type "+(b.S.X?b.S.X.name:b.S.V.name)+" to parameter type "+this.name);break;case 1:c=b.S.W;break;case 2:if(b.S.X===this)c=b.S.W;else{var d=b.clone();c=this.xa(c,mb(function(){d["delete"]()}));null!==a&&a.push(this.ba,c)}break;default:S("Unsupporting sharing policy")}return c}
function nb(a,b){if(null===b)return this.ja&&S("null is not a valid "+this.name),0;b.S||S('Cannot pass "'+V(b)+'" as a '+this.name);b.S.T||S("Cannot pass deleted object as a pointer of type "+this.name);b.S.V.ga&&S("Cannot convert argument of type "+b.S.V.name+" to parameter type "+this.name);return jb(b.S.T,b.S.V.U,this.U)}function ob(a){return this.fromWireType(L[a>>2])}function qb(a,b,c){if(b===c)return a;if(void 0===c.Y)return null;a=qb(a,b,c.Y);return null===a?null:c.qa(a)}var rb={};
function sb(a,b){for(void 0===b&&S("ptr should not be undefined");a.Y;)b=a.fa(b),a=a.Y;return rb[b]}function tb(a,b){b.V&&b.T||Va("makeClassHandle requires ptr and ptrType");!!b.X!==!!b.W&&Va("Both smartPtrType and smartPtr must be specified");b.count={value:1};return bb(Object.create(a,{S:{value:b}}))}
function W(a,b,c,d){this.name=a;this.U=b;this.ja=c;this.ga=d;this.ha=!1;this.ba=this.xa=this.wa=this.na=this.ya=this.va=void 0;void 0!==b.Y?this.toWireType=lb:(this.toWireType=d?kb:nb,this.$=null)}function ub(a,b,c){e.hasOwnProperty(a)||Va("Replacing nonexistant public symbol");void 0!==e[a].Z&&void 0!==c?e[a].Z[c]=b:(e[a]=b,e[a].oa=c)}
function X(a,b){a=P(a);var c=e["dynCall_"+a];for(var d=[],f=1;f<a.length;++f)d.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+d.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(d.length?", ":"")+d.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&S("unknown function pointer with signature "+a+": "+b);return c}var vb=void 0;function wb(a){a=xb(a);var b=P(a);Y(a);return b}
function yb(a,b){function c(g){f[g]||R[g]||(Pa[g]?Pa[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new vb(a+": "+d.map(wb).join([", "]));}function zb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Ab(a,b,c){a instanceof Object||S(c+' with invalid "this": '+a);a instanceof b.U.constructor||S(c+' incompatible with "this" of type '+a.constructor.name);a.S.T||S("cannot call emscripten binding method "+c+" on deleted object");return jb(a.S.T,a.S.V.U,b.U)}
var Bb=[],Z=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Cb(a){4<a&&0===--Z[a].ka&&(Z[a]=void 0,Bb.push(a))}function mb(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Bb.length?Bb.pop():Z.length;Z[b]={ka:1,value:a};return b}}function V(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function Db(a,b){switch(b){case 2:return function(c){return this.fromWireType(xa[c>>2])};case 3:return function(c){return this.fromWireType(ya[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Eb(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Ra(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function Fb(a,b){for(var c=[],d=0;d<a;d++)c.push(J[(b>>2)+d]);return c}function Gb(a,b,c){switch(b){case 0:return c?function(d){return va[d]}:function(d){return H[d]};case 1:return c?function(d){return I[d>>1]}:function(d){return wa[d>>1]};case 2:return c?function(d){return J[d>>2]}:function(d){return L[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}for(var Hb=[null,[],[]],Ib=Array(256),Jb=0;256>Jb;++Jb)Ib[Jb]=String.fromCharCode(Jb);Oa=Ib;Ta=e.BindingError=Sa("BindingError");
Ua=e.InternalError=Sa("InternalError");U.prototype.isAliasOf=function(a){if(!(this instanceof U&&a instanceof U))return!1;var b=this.S.V.U,c=this.S.T,d=a.S.V.U;for(a=a.S.T;b.Y;)c=b.fa(c),b=b.Y;for(;d.Y;)a=d.fa(a),d=d.Y;return b===d&&c===a};U.prototype.clone=function(){this.S.T||Ya(this);if(this.S.ea)return this.S.count.value+=1,this;var a=bb(Object.create(Object.getPrototypeOf(this),{S:{value:Xa(this.S)}}));a.S.count.value+=1;a.S.da=!1;return a};
U.prototype["delete"]=function(){this.S.T||Ya(this);this.S.da&&!this.S.ea&&S("Object already scheduled for deletion");$a(this);ab(this.S);this.S.ea||(this.S.W=void 0,this.S.T=void 0)};U.prototype.isDeleted=function(){return!this.S.T};U.prototype.deleteLater=function(){this.S.T||Ya(this);this.S.da&&!this.S.ea&&S("Object already scheduled for deletion");db.push(this);1===db.length&&cb&&cb(eb);this.S.da=!0;return this};W.prototype.ta=function(a){this.na&&(a=this.na(a));return a};
W.prototype.ma=function(a){this.ba&&this.ba(a)};W.prototype.argPackAdvance=8;W.prototype.readValueFromPointer=ob;W.prototype.deleteObject=function(a){if(null!==a)a["delete"]()};
W.prototype.fromWireType=function(a){function b(){return this.ha?tb(this.U.aa,{V:this.va,T:c,X:this,W:a}):tb(this.U.aa,{V:this,T:a})}var c=this.ta(a);if(!c)return this.ma(a),null;var d=sb(this.U,c);if(void 0!==d){if(0===d.S.count.value)return d.S.T=c,d.S.W=a,d.clone();d=d.clone();this.ma(a);return d}d=this.U.sa(c);d=fb[d];if(!d)return b.call(this);d=this.ga?d.pa:d.pointerType;var f=qb(c,this.U,d.U);return null===f?b.call(this):this.ha?tb(d.U.aa,{V:d,T:f,X:this,W:a}):tb(d.U.aa,{V:d,T:f})};
e.getInheritedInstanceCount=function(){return Object.keys(rb).length};e.getLiveInheritedInstances=function(){var a=[],b;for(b in rb)rb.hasOwnProperty(b)&&a.push(rb[b]);return a};e.flushPendingDeletes=eb;e.setDelayFunction=function(a){cb=a;db.length&&cb&&cb(eb)};vb=e.UnboundTypeError=Sa("UnboundTypeError");e.count_emval_handles=function(){for(var a=0,b=5;b<Z.length;++b)void 0!==Z[b]&&++a;return a};e.get_first_emval=function(){for(var a=5;a<Z.length;++a)if(void 0!==Z[a])return Z[a];return null};
var Lb={u:function(a,b,c,d,f){var g=Na(c);b=P(b);T(a,{name:b,fromWireType:function(n){return!!n},toWireType:function(n,h){return h?d:f},argPackAdvance:8,readValueFromPointer:function(n){if(1===c)var h=va;else if(2===c)h=I;else if(4===c)h=J;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[n>>g])},$:null})},p:function(a,b,c,d,f,g,n,h,k,l,m,q,v){m=P(m);g=X(f,g);h&&(h=X(n,h));l&&(l=X(k,l));v=X(q,v);var u=Qa(m);hb(u,function(){yb("Cannot construct "+m+" due to unbound types",
[d])});Wa([a,b,c],d?[d]:[],function(p){p=p[0];if(d){var w=p.U;var x=w.aa}else x=U.prototype;p=Ra(u,function(){if(Object.getPrototypeOf(this)!==y)throw new Ta("Use 'new' to construct "+m);if(void 0===D.la)throw new Ta(m+" has no accessible constructor");var pb=D.la[arguments.length];if(void 0===pb)throw new Ta("Tried to invoke ctor of "+m+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(D.la).toString()+") parameters instead!");return pb.apply(this,arguments)});
var y=Object.create(x,{constructor:{value:p}});p.prototype=y;var D=new ib(m,p,y,v,w,g,h,l);w=new W(m,D,!0,!1);x=new W(m+"*",D,!1,!1);var fa=new W(m+" const*",D,!1,!0);fb[a]={pointerType:x,pa:fa};ub(u,p);return[w,x,fa]})},d:function(a,b,c,d,f,g,n,h,k,l){b=P(b);f=X(d,f);Wa([],[a],function(m){m=m[0];var q=m.name+"."+b,v={get:function(){yb("Cannot access "+q+" due to unbound types",[c,n])},enumerable:!0,configurable:!0};k?v.set=function(){yb("Cannot access "+q+" due to unbound types",[c,n])}:v.set=function(){S(q+
" is a read-only property")};Object.defineProperty(m.U.aa,b,v);Wa([],k?[c,n]:[c],function(u){var p=u[0],w={get:function(){var y=Ab(this,m,q+" getter");return p.fromWireType(f(g,y))},enumerable:!0};if(k){k=X(h,k);var x=u[1];w.set=function(y){var D=Ab(this,m,q+" setter"),fa=[];k(l,D,x.toWireType(fa,y));zb(fa)}}Object.defineProperty(m.U.aa,b,w);return[]});return[]})},t:function(a,b){b=P(b);T(a,{name:b,fromWireType:function(c){var d=Z[c].value;Cb(c);return d},toWireType:function(c,d){return mb(d)},argPackAdvance:8,
readValueFromPointer:ob,$:null})},h:function(a,b,c){c=Na(c);b=P(b);T(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+V(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Db(b,c),$:null})},c:function(a,b,c,d,f,g){var n=Fb(b,c);a=P(a);f=X(d,f);hb(a,function(){yb("Cannot call "+a+" due to unbound types",n)},b-1);Wa([],n,function(h){var k=[h[0],null].concat(h.slice(1)),l=h=a,m=
f,q=k.length;2>q&&S("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var v=null!==k[1]&&!1,u=!1,p=1;p<k.length;++p)if(null!==k[p]&&void 0===k[p].$){u=!0;break}var w="void"!==k[0].name,x="",y="";for(p=0;p<q-2;++p)x+=(0!==p?", ":"")+"arg"+p,y+=(0!==p?", ":"")+"arg"+p+"Wired";l="return function "+Qa(l)+"("+x+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+l+" called with ' + arguments.length + ' arguments, expected "+(q-2)+" args!');\n}\n";
u&&(l+="var destructors = [];\n");var D=u?"destructors":"null";x="throwBindingError invoker fn runDestructors retType classParam".split(" ");m=[S,m,g,zb,k[0],k[1]];v&&(l+="var thisWired = classParam.toWireType("+D+", this);\n");for(p=0;p<q-2;++p)l+="var arg"+p+"Wired = argType"+p+".toWireType("+D+", arg"+p+"); // "+k[p+2].name+"\n",x.push("argType"+p),m.push(k[p+2]);v&&(y="thisWired"+(0<y.length?", ":"")+y);l+=(w?"var rv = ":"")+"invoker(fn"+(0<y.length?", ":"")+y+");\n";if(u)l+="runDestructors(destructors);\n";
else for(p=v?1:2;p<k.length;++p)q=1===p?"thisWired":"arg"+(p-2)+"Wired",null!==k[p].$&&(l+=q+"_dtor("+q+"); // "+k[p].name+"\n",x.push(q+"_dtor"),m.push(k[p].$));w&&(l+="var ret = retType.fromWireType(rv);\nreturn ret;\n");x.push(l+"}\n");k=Eb(x).apply(null,m);ub(h,k,b-1);return[]})},b:function(a,b,c,d,f){function g(l){return l}b=P(b);-1===f&&(f=4294967295);var n=Na(c);if(0===d){var h=32-8*c;g=function(l){return l<<h>>>h}}var k=-1!=b.indexOf("unsigned");T(a,{name:b,fromWireType:g,toWireType:function(l,
m){if("number"!==typeof m&&"boolean"!==typeof m)throw new TypeError('Cannot convert "'+V(m)+'" to '+this.name);if(m<d||m>f)throw new TypeError('Passing a number "'+V(m)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return k?m>>>0:m|0},argPackAdvance:8,readValueFromPointer:Gb(b,n,0!==d),$:null})},a:function(a,b,c){function d(g){g>>=2;var n=L;return new f(K,n[g+1],n[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,
Float32Array,Float64Array][b];c=P(c);T(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{ua:!0})},i:function(a,b){b=P(b);var c="std::string"===b;T(a,{name:b,fromWireType:function(d){var f=L[d>>2];if(c){var g=H[d+4+f],n=0;0!=g&&(n=g,H[d+4+f]=0);var h=d+4;for(g=0;g<=f;++g){var k=d+4+g;if(0==H[k]){h=h?ma(H,h,void 0):"";if(void 0===l)var l=h;else l+=String.fromCharCode(0),l+=h;h=k+1}}0!=n&&(H[d+4+f]=n)}else{l=Array(f);for(g=0;g<f;++g)l[g]=String.fromCharCode(H[d+4+g]);l=l.join("")}Y(d);
return l},toWireType:function(d,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||S("Cannot pass non-string to std::string");var n=(c&&g?function(){for(var l=0,m=0;m<f.length;++m){var q=f.charCodeAt(m);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++m)&1023);127>=q?++l:l=2047>=q?l+2:65535>=q?l+3:l+4}return l}:function(){return f.length})(),h=Kb(4+n+1);L[h>>2]=n;if(c&&g)na(f,h+
4,n+1);else if(g)for(g=0;g<n;++g){var k=f.charCodeAt(g);255<k&&(Y(h),S("String has UTF-16 code units that do not fit in 8 bits"));H[h+4+g]=k}else for(g=0;g<n;++g)H[h+4+g]=f[g];null!==d&&d.push(Y,h);return h},argPackAdvance:8,readValueFromPointer:ob,$:function(d){Y(d)}})},e:function(a,b,c){c=P(c);if(2===b){var d=pa;var f=qa;var g=ra;var n=function(){return wa};var h=1}else 4===b&&(d=sa,f=ta,g=ua,n=function(){return L},h=2);T(a,{name:c,fromWireType:function(k){var l=L[k>>2],m=n(),q=m[k+4+l*b>>h],v=
0;0!=q&&(v=q,m[k+4+l*b>>h]=0);var u=k+4;for(q=0;q<=l;++q){var p=k+4+q*b;if(0==m[p>>h]){u=d(u);if(void 0===w)var w=u;else w+=String.fromCharCode(0),w+=u;u=p+b}}0!=v&&(m[k+4+l*b>>h]=v);Y(k);return w},toWireType:function(k,l){"string"!==typeof l&&S("Cannot pass non-string to C++ string type "+c);var m=g(l),q=Kb(4+m+b);L[q>>2]=m>>h;f(l,q+4,m+b);null!==k&&k.push(Y,q);return q},argPackAdvance:8,readValueFromPointer:ob,$:function(k){Y(k)}})},l:function(a,b){b=P(b);T(a,{za:!0,name:b,argPackAdvance:0,fromWireType:function(){},
toWireType:function(){}})},j:Cb,n:function(a){4<a&&(Z[a].ka+=1)},k:function(a,b){var c=R[a];void 0===c&&S("_emval_take_value has unknown type "+wb(a));a=c.readValueFromPointer(b);return mb(a)},g:function(){C()},r:function(a,b,c){H.copyWithin(a,b,b+c)},s:function(a){var b=H.length;if(2147418112<a)return!1;for(var c=1;4>=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(16777216,a,d);0<d%65536&&(d+=65536-d%65536);a:{try{G.grow(Math.min(2147418112,d)-K.byteLength+65535>>16);za(G.buffer);
var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},m:function(){return 0},o:function(){},f:function(a,b,c,d){for(var f=0,g=0;g<c;g++){for(var n=J[b+8*g>>2],h=J[b+(8*g+4)>>2],k=0;k<h;k++){var l=H[n+k],m=Hb[a];0===l||10===l?((1===a?ia:E)(ma(m,0)),m.length=0):m.push(l)}f+=h}J[d>>2]=f;return 0},memory:G,q:function(){},table:ja},Mb=function(){function a(f){e.asm=f.exports;M--;e.monitorRunDependencies&&e.monitorRunDependencies(M);0==M&&(null!==Ha&&(clearInterval(Ha),Ha=null),N&&(f=N,N=null,f()))}
function b(f){a(f.instance)}function c(f){return La().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){E("failed to asynchronously prepare wasm: "+g);C(g)})}var d={a:Lb};M++;e.monitorRunDependencies&&e.monitorRunDependencies(M);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return E("Module.instantiateWasm callback failed with error: "+f),!1}(function(){if(F||"function"!==typeof WebAssembly.instantiateStreaming||Ia()||"function"!==typeof fetch)return c(b);
fetch(O,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){E("wasm streaming compile failed: "+g);E("falling back to ArrayBuffer instantiation");c(b)})})})();return{}}();e.asm=Mb;
var Ma=e.___wasm_call_ctors=function(){return(Ma=e.___wasm_call_ctors=e.asm.v).apply(null,arguments)},Kb=e._malloc=function(){return(Kb=e._malloc=e.asm.w).apply(null,arguments)},Y=e._free=function(){return(Y=e._free=e.asm.x).apply(null,arguments)},xb=e.___getTypeName=function(){return(xb=e.___getTypeName=e.asm.y).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.z).apply(null,arguments)};
e.dynCall_ii=function(){return(e.dynCall_ii=e.asm.A).apply(null,arguments)};e.dynCall_vi=function(){return(e.dynCall_vi=e.asm.B).apply(null,arguments)};e.dynCall_iii=function(){return(e.dynCall_iii=e.asm.C).apply(null,arguments)};e.dynCall_viii=function(){return(e.dynCall_viii=e.asm.D).apply(null,arguments)};e.dynCall_viiiiif=function(){return(e.dynCall_viiiiif=e.asm.E).apply(null,arguments)};e.dynCall_viiiif=function(){return(e.dynCall_viiiif=e.asm.F).apply(null,arguments)};
e.dynCall_i=function(){return(e.dynCall_i=e.asm.G).apply(null,arguments)};e.dynCall_v=function(){return(e.dynCall_v=e.asm.H).apply(null,arguments)};e.dynCall_iiiiiif=function(){return(e.dynCall_iiiiiif=e.asm.I).apply(null,arguments)};e.dynCall_iiiiif=function(){return(e.dynCall_iiiiif=e.asm.J).apply(null,arguments)};e.dynCall_vif=function(){return(e.dynCall_vif=e.asm.K).apply(null,arguments)};e.dynCall_iiii=function(){return(e.dynCall_iiii=e.asm.L).apply(null,arguments)};
e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.M).apply(null,arguments)};e.dynCall_iidiiii=function(){return(e.dynCall_iidiiii=e.asm.N).apply(null,arguments)};e.dynCall_vii=function(){return(e.dynCall_vii=e.asm.O).apply(null,arguments)};e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.P).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.Q).apply(null,arguments)};e.dynCall_viiii=function(){return(e.dynCall_viiii=e.asm.R).apply(null,arguments)};
e.asm=Mb;var Nb;e.then=function(a){if(Nb)a(e);else{var b=e.onRuntimeInitialized;e.onRuntimeInitialized=function(){b&&b();a(e)}}return e};N=function Ob(){Nb||Pb();Nb||(N=Ob)};
function Pb(){function a(){if(!Nb&&(Nb=!0,e.calledRun=!0,!ka)){Ba(Da);Ba(Ea);if(e.onRuntimeInitialized)e.onRuntimeInitialized();if(e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;){var b=e.postRun.shift();Fa.unshift(b)}Ba(Fa)}}if(!(0<M)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)Ga();Ba(Ca);0<M||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}
e.run=Pb;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;Pb();
var d;d||(d=typeof imagequant !== 'undefined' ? imagequant : {});var aa;d.ready=new Promise(function(a){aa=a});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var u=!1,v=!1,ba=!1,ca=!1;u="object"===typeof window;v="function"===typeof importScripts;ba="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ca=!u&&!ba&&!v;var w="",x,z,da,ea;
if(ba)w=v?require("path").dirname(w)+"/":__dirname+"/",x=function(a,b){da||(da=require("fs"));ea||(ea=require("path"));a=ea.normalize(a);return da.readFileSync(a,b?null:"utf8")},z=function(a){a=x(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||A("Assertion failed: undefined");return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",A),d.inspect=function(){return"[Emscripten Module object]"};
else if(ca)"undefined"!=typeof read&&(x=function(a){return read(a)}),z=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||A("Assertion failed: undefined");return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(u||v)v?w=self.location.href:document.currentScript&&(w=document.currentScript.src),_scriptDir&&
(w=_scriptDir),0!==w.indexOf("blob:")?w=w.substr(0,w.lastIndexOf("/")+1):w="",x=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},v&&(z=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var fa=d.print||console.log.bind(console),B=d.printErr||console.warn.bind(console);for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;var D;d.wasmBinary&&(D=d.wasmBinary);var noExitRuntime;
d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&A("no native wasm support detected");var E,ha=new WebAssembly.Table({initial:46,maximum:46,element:"anyfunc"}),ia=!1,ja="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function ka(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&ja)return ja.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var l=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|l:(f&7)<<18|g<<12|l<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
function la(a,b,c){var e=F;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}if(127>=g){if(b>=c)break;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var ma="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function na(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&G[c];)++c;c<<=1;if(32<c-a&&ma)return ma.decode(F.subarray(a,c));c=0;for(e="";;){var f=H[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function oa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)H[b>>1]=a.charCodeAt(f),b+=2;H[b>>1]=0;return b-e}function pa(a){return 2*a.length}
function qa(a,b){for(var c=0,e="";!(c>=b/4);){var f=I[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function ra(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}I[b>>2]=g;b+=4;if(b+4>c)break}I[b>>2]=0;return b-e}
function sa(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var J,ta,F,H,G,I,L,ua,va;function wa(a){J=a;d.HEAP8=ta=new Int8Array(a);d.HEAP16=H=new Int16Array(a);d.HEAP32=I=new Int32Array(a);d.HEAPU8=F=new Uint8Array(a);d.HEAPU16=G=new Uint16Array(a);d.HEAPU32=L=new Uint32Array(a);d.HEAPF32=ua=new Float32Array(a);d.HEAPF64=va=new Float64Array(a)}var xa=d.INITIAL_MEMORY||16777216;d.wasmMemory?E=d.wasmMemory:E=new WebAssembly.Memory({initial:xa/65536,maximum:32768});
E&&(J=E.buffer);xa=J.byteLength;wa(J);I[1472]=5248928;function M(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.Y;"number"===typeof c?void 0===b.U?d.dynCall_v(c):d.dynCall_vi(c,b.U):c(void 0===b.U?null:b.U)}}}var ya=[],za=[],Aa=[],Ba=[];function Ca(){var a=d.preRun.shift();ya.unshift(a)}var N=0,Da=null,O=null;d.preloadedImages={};d.preloadedAudios={};
function A(a){if(d.onAbort)d.onAbort(a);fa(a);B(a);ia=!0;throw new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");}function Ea(a){var b=Q;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Fa(){return Ea("data:application/octet-stream;base64,")}var Q="imagequant.wasm";if(!Fa()){var Ga=Q;Q=d.locateFile?d.locateFile(Ga,w):w+Ga}
function Ha(){try{if(D)return new Uint8Array(D);if(z)return z(Q);throw"both async and sync fetching of the wasm failed";}catch(a){A(a)}}function Ia(){return D||!u&&!v||"function"!==typeof fetch||Ea("file://")?new Promise(function(a){a(Ha())}):fetch(Q,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+Q+"'";return a.arrayBuffer()}).catch(function(){return Ha()})}za.push({Y:function(){Ja()}});function R(){return 0<R.W}
function Ka(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var La=void 0;function S(a){for(var b="";F[a];)b+=La[F[a++]];return b}var T={},U={},V={};function Ma(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
function Na(a,b){a=Ma(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Oa(a){var b=Error,c=Na(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
var Pa=void 0;function W(a){throw new Pa(a);}var Qa=void 0;function Ra(a,b){function c(k){k=b(k);if(k.length!==e.length)throw new Qa("Mismatched type converter count");for(var h=0;h<e.length;++h)X(e[h],k[h])}var e=[];e.forEach(function(k){V[k]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(k,h){U.hasOwnProperty(k)?f[h]=U[k]:(g.push(k),T.hasOwnProperty(k)||(T[k]=[]),T[k].push(function(){f[h]=U[k];++l;l===g.length&&c(f)}))});0===g.length&&c(f)}
function X(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||W('type "'+e+'" must have a positive integer typeid pointer');if(U.hasOwnProperty(a)){if(c.Z)return;W("Cannot register type '"+e+"' twice")}U[a]=b;delete V[a];T.hasOwnProperty(a)&&(b=T[a],delete T[a],b.forEach(function(f){f()}))}var Sa=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function Ta(a){4<a&&0===--Y[a].V&&(Y[a]=void 0,Sa.push(a))}function Ua(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Sa.length?Sa.pop():Y.length;Y[b]={V:1,value:a};return b}}function Xa(a){return this.fromWireType(L[a>>2])}function Ya(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function Za(a,b){switch(b){case 2:return function(c){return this.fromWireType(ua[c>>2])};case 3:return function(c){return this.fromWireType(va[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function $a(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Na(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function ab(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function bb(a,b){var c=d;if(void 0===c[a].S){var e=c[a];c[a]=function(){c[a].S.hasOwnProperty(arguments.length)||W("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].S+")!");return c[a].S[arguments.length].apply(this,arguments)};c[a].S=[];c[a].S[e.X]=e}}
function cb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].S&&void 0!==d[a].S[c])&&W("Cannot register public name '"+a+"' twice"),bb(a,a),d.hasOwnProperty(c)&&W("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].S[c]=b):(d[a]=b,void 0!==c&&(d[a].aa=c))}function db(a,b){for(var c=[],e=0;e<a;e++)c.push(I[(b>>2)+e]);return c}
function eb(a,b){a=S(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&W("unknown function pointer with signature "+a+": "+b);return c}var fb=void 0;function gb(a){a=hb(a);var b=S(a);Z(a);return b}
function ib(a,b){function c(g){f[g]||U[g]||(V[g]?V[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new fb(a+": "+e.map(gb).join([", "]));}function jb(a,b,c){switch(b){case 0:return c?function(e){return ta[e]}:function(e){return F[e]};case 1:return c?function(e){return H[e>>1]}:function(e){return G[e>>1]};case 2:return c?function(e){return I[e>>2]}:function(e){return L[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var kb={};
function lb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function mb(a,b){var c=U[a];void 0===c&&W(b+" has unknown type "+gb(a));return c}for(var nb={},ob=[null,[],[]],pb=Array(256),qb=0;256>qb;++qb)pb[qb]=String.fromCharCode(qb);La=pb;Pa=d.BindingError=Oa("BindingError");Qa=d.InternalError=Oa("InternalError");d.count_emval_handles=function(){for(var a=0,b=5;b<Y.length;++b)void 0!==Y[b]&&++a;return a};
d.get_first_emval=function(){for(var a=5;a<Y.length;++a)if(void 0!==Y[a])return Y[a];return null};fb=d.UnboundTypeError=Oa("UnboundTypeError");
var sb={n:function(a){return rb(a)},w:function(){},m:function(a){"uncaught_exception"in R?R.W++:R.W=1;throw a;},u:function(a,b,c,e,f){var g=Ka(c);b=S(b);X(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,k){return k?e:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var k=ta;else if(2===c)k=H;else if(4===c)k=I;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[l>>g])},T:null})},t:function(a,b){b=S(b);X(a,{name:b,fromWireType:function(c){var e=
Y[c].value;Ta(c);return e},toWireType:function(c,e){return Ua(e)},argPackAdvance:8,readValueFromPointer:Xa,T:null})},h:function(a,b,c){c=Ka(c);b=S(b);X(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+Ya(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Za(b,c),T:null})},d:function(a,b,c,e,f,g){var l=db(b,c);a=S(a);f=eb(e,f);cb(a,function(){ib("Cannot call "+a+" due to unbound types",
l)},b-1);Ra(l,function(k){var h=[k[0],null].concat(k.slice(1)),n=k=a,p=f,q=h.length;2>q&&W("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==h[1]&&!1,C=!1,m=1;m<h.length;++m)if(null!==h[m]&&void 0===h[m].T){C=!0;break}var Va="void"!==h[0].name,K="",P="";for(m=0;m<q-2;++m)K+=(0!==m?", ":"")+"arg"+m,P+=(0!==m?", ":"")+"arg"+m+"Wired";n="return function "+Ma(n)+"("+K+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+n+" called with ' + arguments.length + ' arguments, expected "+
(q-2)+" args!');\n}\n";C&&(n+="var destructors = [];\n");var Wa=C?"destructors":"null";K="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[W,p,g,ab,h[0],h[1]];y&&(n+="var thisWired = classParam.toWireType("+Wa+", this);\n");for(m=0;m<q-2;++m)n+="var arg"+m+"Wired = argType"+m+".toWireType("+Wa+", arg"+m+"); // "+h[m+2].name+"\n",K.push("argType"+m),p.push(h[m+2]);y&&(P="thisWired"+(0<P.length?", ":"")+P);n+=(Va?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";
if(C)n+="runDestructors(destructors);\n";else for(m=y?1:2;m<h.length;++m)q=1===m?"thisWired":"arg"+(m-2)+"Wired",null!==h[m].T&&(n+=q+"_dtor("+q+"); // "+h[m].name+"\n",K.push(q+"_dtor"),p.push(h[m].T));Va&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");K.push(n+"}\n");h=$a(K).apply(null,p);m=b-1;if(!d.hasOwnProperty(k))throw new Qa("Replacing nonexistant public symbol");void 0!==d[k].S&&void 0!==m?d[k].S[m]=h:(d[k]=h,d[k].X=m);return[]})},b:function(a,b,c,e,f){function g(n){return n}b=
S(b);-1===f&&(f=4294967295);var l=Ka(c);if(0===e){var k=32-8*c;g=function(n){return n<<k>>>k}}var h=-1!=b.indexOf("unsigned");X(a,{name:b,fromWireType:g,toWireType:function(n,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+Ya(p)+'" to '+this.name);if(p<e||p>f)throw new TypeError('Passing a number "'+Ya(p)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return h?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:jb(b,
l,0!==e),T:null})},a:function(a,b,c){function e(g){g>>=2;var l=L;return new f(J,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=S(c);X(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{Z:!0})},i:function(a,b){b=S(b);var c="std::string"===b;X(a,{name:b,fromWireType:function(e){var f=L[e>>2];if(c)for(var g=e+4,l=0;l<=f;++l){var k=e+4+l;if(0==F[k]||l==f){g=g?ka(F,g,k-g):"";if(void 0===h)var h=g;else h+=String.fromCharCode(0),
h+=g;g=k+1}}else{h=Array(f);for(l=0;l<f;++l)h[l]=String.fromCharCode(F[e+4+l]);h=h.join("")}Z(e);return h},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||W("Cannot pass non-string to std::string");var l=(c&&g?function(){for(var n=0,p=0;p<f.length;++p){var q=f.charCodeAt(p);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++p)&1023);127>=q?++n:n=2047>=q?n+
2:65535>=q?n+3:n+4}return n}:function(){return f.length})(),k=rb(4+l+1);L[k>>2]=l;if(c&&g)la(f,k+4,l+1);else if(g)for(g=0;g<l;++g){var h=f.charCodeAt(g);255<h&&(Z(k),W("String has UTF-16 code units that do not fit in 8 bits"));F[k+4+g]=h}else for(g=0;g<l;++g)F[k+4+g]=f[g];null!==e&&e.push(Z,k);return k},argPackAdvance:8,readValueFromPointer:Xa,T:function(e){Z(e)}})},e:function(a,b,c){c=S(c);if(2===b){var e=na;var f=oa;var g=pa;var l=function(){return G};var k=1}else 4===b&&(e=qa,f=ra,g=sa,l=function(){return L},
k=2);X(a,{name:c,fromWireType:function(h){for(var n=L[h>>2],p=l(),q,y=h+4,C=0;C<=n;++C){var m=h+4+C*b;if(0==p[m>>k]||C==n)y=e(y,m-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=m+b}Z(h);return q},toWireType:function(h,n){"string"!==typeof n&&W("Cannot pass non-string to C++ string type "+c);var p=g(n),q=rb(4+p+b);L[q>>2]=p>>k;f(n,q+4,p+b);null!==h&&h.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Xa,T:function(h){Z(h)}})},j:function(a,b){b=S(b);X(a,{$:!0,name:b,argPackAdvance:0,fromWireType:function(){},
toWireType:function(){}})},r:Ta,v:function(a){if(0===a)return Ua(lb());var b=kb[a];a=void 0===b?S(a):b;return Ua(lb()[a])},k:function(a){4<a&&(Y[a].V+=1)},l:function(a,b,c,e){a||W("Cannot use deleted val. handle = "+a);a=Y[a].value;var f=nb[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var l="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)l+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+g+'], "parameter '+g+
'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",l+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(mb,d,Ua);nb[b]=f}return f(a,c,e)},f:function(){A()},q:function(a,b,c){F.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=F.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%
65536&&(e+=65536-e%65536);a:{try{E.grow(Math.min(2147483648,e)-J.byteLength+65535>>>16);wa(E.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},s:function(){return 0},o:function(){},g:function(a,b,c,e){for(var f=0,g=0;g<c;g++){for(var l=I[b+8*g>>2],k=I[b+(8*g+4)>>2],h=0;h<k;h++){var n=F[l+h],p=ob[a];0===n||10===n?((1===a?fa:B)(ka(p,0)),p.length=0):p.push(n)}f+=k}I[e>>2]=f;return 0},memory:E,p:function(){},table:ha};
(function(){function a(f){d.asm=f.exports;N--;d.monitorRunDependencies&&d.monitorRunDependencies(N);0==N&&(null!==Da&&(clearInterval(Da),Da=null),O&&(f=O,O=null,f()))}function b(f){a(f.instance)}function c(f){return Ia().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);A(g)})}var e={a:sb};N++;d.monitorRunDependencies&&d.monitorRunDependencies(N);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return B("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(D||"function"!==typeof WebAssembly.instantiateStreaming||Fa()||Ea("file://")||"function"!==typeof fetch)return c(b);fetch(Q,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Ja=d.___wasm_call_ctors=function(){return(Ja=d.___wasm_call_ctors=d.asm.x).apply(null,arguments)},rb=d._malloc=function(){return(rb=d._malloc=d.asm.y).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.z).apply(null,arguments)},hb=d.___getTypeName=function(){return(hb=d.___getTypeName=d.asm.A).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.B).apply(null,arguments)};
d.dynCall_iiiiiif=function(){return(d.dynCall_iiiiiif=d.asm.C).apply(null,arguments)};d.dynCall_viiiiif=function(){return(d.dynCall_viiiiif=d.asm.D).apply(null,arguments)};d.dynCall_iiiiif=function(){return(d.dynCall_iiiiif=d.asm.E).apply(null,arguments)};d.dynCall_viiiif=function(){return(d.dynCall_viiiif=d.asm.F).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.G).apply(null,arguments)};d.dynCall_i=function(){return(d.dynCall_i=d.asm.H).apply(null,arguments)};
d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.I).apply(null,arguments)};d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.J).apply(null,arguments)};d.dynCall_vif=function(){return(d.dynCall_vif=d.asm.K).apply(null,arguments)};d.dynCall_iidiiii=function(){return(d.dynCall_iidiiii=d.asm.L).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.M).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.N).apply(null,arguments)};
d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.O).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.P).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.Q).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.R).apply(null,arguments)};var tb;O=function ub(){tb||vb();tb||(O=ub)};
function vb(){function a(){if(!tb&&(tb=!0,d.calledRun=!0,!ia)){M(za);M(Aa);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Ba.unshift(b)}M(Ba)}}if(!(0<N)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Ca();M(ya);0<N||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
d.run=vb;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;vb();
return imagequant
return imagequant.ready
}
);
})();

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,6 @@
{
"name": "imagequant",
"scripts": {
"install": "napa",
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
},
"napa": {
"libimagequant": "ImageOptim/libimagequant#2.12.1"
},
"devDependencies": {
"napa": "3.0.0"
"build": "../build-cpp.sh"
}
}

View File

@ -0,0 +1,132 @@
libjpeg-turbo Licenses
======================
libjpeg-turbo is covered by three compatible BSD-style open source licenses:
- The IJG (Independent JPEG Group) License, which is listed in
[README.ijg](README.ijg)
This license applies to the libjpeg API library and associated programs
(any code inherited from libjpeg, and any modifications to that code.)
- The Modified (3-clause) BSD License, which is listed below
This license covers the TurboJPEG API library and associated programs, as
well as the build system.
- The [zlib License](https://opensource.org/licenses/Zlib)
This license is a subset of the other two, and it covers the libjpeg-turbo
SIMD extensions.
Complying with the libjpeg-turbo Licenses
=========================================
This section provides a roll-up of the libjpeg-turbo licensing terms, to the
best of our understanding.
1. If you are distributing a modified version of the libjpeg-turbo source,
then:
1. You cannot alter or remove any existing copyright or license notices
from the source.
**Origin**
- Clause 1 of the IJG License
- Clause 1 of the Modified BSD License
- Clauses 1 and 3 of the zlib License
2. You must add your own copyright notice to the header of each source
file you modified, so others can tell that you modified that file (if
there is not an existing copyright header in that file, then you can
simply add a notice stating that you modified the file.)
**Origin**
- Clause 1 of the IJG License
- Clause 2 of the zlib License
3. You must include the IJG README file, and you must not alter any of the
copyright or license text in that file.
**Origin**
- Clause 1 of the IJG License
2. If you are distributing only libjpeg-turbo binaries without the source, or
if you are distributing an application that statically links with
libjpeg-turbo, then:
1. Your product documentation must include a message stating:
This software is based in part on the work of the Independent JPEG
Group.
**Origin**
- Clause 2 of the IJG license
2. If your binary distribution includes or uses the TurboJPEG API, then
your product documentation must include the text of the Modified BSD
License (see below.)
**Origin**
- Clause 2 of the Modified BSD License
3. You cannot use the name of the IJG or The libjpeg-turbo Project or the
contributors thereof in advertising, publicity, etc.
**Origin**
- IJG License
- Clause 3 of the Modified BSD License
4. The IJG and The libjpeg-turbo Project do not warrant libjpeg-turbo to be
free of defects, nor do we accept any liability for undesirable
consequences resulting from your use of the software.
**Origin**
- IJG License
- Modified BSD License
- zlib License
The Modified (3-clause) BSD License
===================================
Copyright (C)2009-2020 D. R. Commander. All Rights Reserved.
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Neither the name of the libjpeg-turbo Project nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Why Three Licenses?
===================
The zlib License could have been used instead of the Modified (3-clause) BSD
License, and since the IJG License effectively subsumes the distribution
conditions of the zlib License, this would have effectively placed
libjpeg-turbo binary distributions under the IJG License. However, the IJG
License specifically refers to the Independent JPEG Group and does not extend
attribution and endorsement protections to other entities. Thus, it was
desirable to choose a license that granted us the same protections for new code
that were granted to the IJG for code derived from their software.

View File

@ -0,0 +1,52 @@
CODEC_URL := https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz
CODEC_DIR := node_modules/mozjpeg
CODEC_OUT_RELATIVE := .libs/libjpeg.a rdswitch.o
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
OUT_JS := mozjpeg_enc.js
OUT_WASM := $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR) \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
# This one is a bit special: there is no rule for .libs/libjpeg.a
# so we use libjpeg.la which implicitly builds that one instead.
$(CODEC_DIR)/.libs/libjpeg.a: $(CODEC_DIR)/Makefile
$(MAKE) -C $(CODEC_DIR) libjpeg.la
$(CODEC_DIR)/rdswitch.o: $(CODEC_DIR)/Makefile
$(MAKE) -C $(CODEC_DIR) rdswitch.o
$(CODEC_DIR)/Makefile: $(CODEC_DIR)/configure
cd $(CODEC_DIR) && ./configure \
--disable-shared \
--without-turbojpeg \
--without-simd \
--without-arith-enc \
--without-arith-dec
$(CODEC_DIR)/configure: $(CODEC_DIR)/configure.ac
cd $(CODEC_DIR) && autoreconf -iv
$(CODEC_DIR)/configure.ac: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

View File

@ -2,6 +2,7 @@
- Source: <https://github.com/mozilla/mozjpeg>
- Version: v3.3.1
- License: BSD
## Dependencies
@ -17,10 +18,6 @@ See `example.html`
Returns the version of MozJPEG as a number. va.b.c is encoded as 0x0a0b0c
### `void free_result()`
Frees the result created by `encode()`.
### `Uint8Array encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts)`
Encodes the given image with given dimension to JPEG. Options looks like this:

View File

@ -1,54 +0,0 @@
#!/bin/bash
set -e
export OPTIMIZE="-Os"
export LDFLAGS="${OPTIMIZE}"
export CFLAGS="${OPTIMIZE}"
export CPPFLAGS="${OPTIMIZE}"
apt-get update
apt-get install -qqy autoconf libtool libpng-dev pkg-config
echo "============================================="
echo "Compiling mozjpeg"
echo "============================================="
(
cd node_modules/mozjpeg
autoreconf -fiv
emconfigure ./configure --without-simd
emmake make libjpeg.la -j`nproc`
)
echo "============================================="
echo "Compiling mozjpeg done"
echo "============================================="
echo "============================================="
echo "Compiling wasm bindings"
echo "============================================="
(
emcc \
--bind \
${OPTIMIZE} \
--closure 1 \
-s WASM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="mozjpeg_enc"' \
-I node_modules/mozjpeg \
-o ./mozjpeg_enc.js \
-Wno-deprecated-register \
-Wno-writable-strings \
node_modules/mozjpeg/rdswitch.c \
-x c++ -std=c++11 \
mozjpeg_enc.cpp \
node_modules/mozjpeg/.libs/libjpeg.a
)
echo "============================================="
echo "Compiling wasm bindings done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull trzeci/emscripten-upstream\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@ -1,18 +1,22 @@
#include <emscripten/bind.h>
#include <emscripten/val.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdio.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "jpeglib.h"
extern "C" {
#include "cdjpeg.h"
}
using namespace emscripten;
// MozJPEG doesnt expose a numeric version, so I have to do some fun C macro hackery to turn it
// into a string. More details here: https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
// MozJPEG doesnt expose a numeric version, so I have to do some fun C macro
// hackery to turn it into a string. More details here:
// https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
#define xstr(s) str(s)
#define str(s) #s
@ -39,8 +43,8 @@ int version() {
char buffer[] = xstr(MOZJPEG_VERSION);
int version = 0;
int last_index = 0;
for(int i = 0; i < strlen(buffer); i++) {
if(buffer[i] == '.') {
for (int i = 0; i < strlen(buffer); i++) {
if (buffer[i] == '.') {
buffer[i] = '\0';
version = version << 8 | atoi(&buffer[last_index]);
buffer[i] = '.';
@ -51,16 +55,16 @@ int version() {
return version;
}
uint8_t* last_result;
struct jpeg_compress_struct cinfo;
thread_local const val Uint8Array = val::global("Uint8Array");
val encode(std::string image_in, int image_width, int image_height, MozJpegOptions opts) {
uint8_t* image_buffer = (uint8_t*) image_in.c_str();
uint8_t* image_buffer = (uint8_t*)image_in.c_str();
// The code below is basically the `write_JPEG_file` function from
// https://github.com/mozilla/mozjpeg/blob/master/example.c
// I just write to memory instead of a file.
/* Step 1: allocate and initialize JPEG compression object */
/* This struct contains the JPEG compression parameters and pointers to
* working space (which is allocated as needed by the JPEG library).
@ -68,6 +72,7 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
* compression/decompression processes, in existence at once. We refer
* to any one struct (and its associated working data) as a "JPEG object".
*/
jpeg_compress_struct cinfo;
/* This struct represents a JPEG error handler. It is declared separately
* because applications often want to supply a specialized error handler
* (see the second half of this file for an example). But here we just
@ -76,15 +81,7 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
* Note that this struct must live as long as the main JPEG parameter
* struct, to avoid dangling-pointer problems.
*/
struct jpeg_error_mgr jerr;
/* More stuff */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */
uint8_t* output;
unsigned long size;
/* Step 1: allocate and initialize JPEG compression object */
jpeg_error_mgr jerr;
/* We have to set up the error handler first, in case the initialization
* step fails. (Unlikely, but it could happen if you are out of memory.)
* This routine fills in the contents of struct jerr, and returns jerr's
@ -106,6 +103,8 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
// fprintf(stderr, "can't open %s\n", filename);
// exit(1);
// }
uint8_t* output = nullptr;
unsigned long size = 0;
jpeg_mem_dest(&cinfo, &output, &size);
/* Step 3: set parameters for compression */
@ -113,17 +112,17 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
/* First we supply a description of the input image.
* Four fields of the cinfo struct must be filled in:
*/
cinfo.image_width = image_width; /* image width and height, in pixels */
cinfo.image_width = image_width; /* image width and height, in pixels */
cinfo.image_height = image_height;
cinfo.input_components = 4; /* # of color components per pixel */
cinfo.in_color_space = JCS_EXT_RGBA; /* colorspace of input image */
cinfo.input_components = 4; /* # of color components per pixel */
cinfo.in_color_space = JCS_EXT_RGBA; /* colorspace of input image */
/* Now use the library's routine to set default compression parameters.
* (You must set at least cinfo.in_color_space before calling this,
* since the defaults depend on the source color space.)
*/
jpeg_set_defaults(&cinfo);
jpeg_set_colorspace(&cinfo, (J_COLOR_SPACE) opts.color_space);
jpeg_set_colorspace(&cinfo, (J_COLOR_SPACE)opts.color_space);
if (opts.quant_table != -1) {
jpeg_c_set_int_param(&cinfo, JINT_BASE_QUANT_TBL_IDX, opts.quant_table);
@ -143,17 +142,17 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
jpeg_c_set_bool_param(&cinfo, JBOOLEAN_TRELLIS_Q_OPT, opts.trellis_opt_table);
jpeg_c_set_int_param(&cinfo, JINT_TRELLIS_NUM_LOOPS, opts.trellis_loops);
// A little hacky to build a string for this, but it means we can use set_quality_ratings which
// does some useful heuristic stuff.
// A little hacky to build a string for this, but it means we can use
// set_quality_ratings which does some useful heuristic stuff.
std::string quality_str = std::to_string(opts.quality);
if (opts.separate_chroma_quality && opts.color_space == JCS_YCbCr) {
quality_str += "," + std::to_string(opts.chroma_quality);
}
char const *pqual = quality_str.c_str();
char const* pqual = quality_str.c_str();
set_quality_ratings(&cinfo, (char*) pqual, opts.baseline);
set_quality_ratings(&cinfo, (char*)pqual, opts.baseline);
if (!opts.auto_subsample && opts.color_space == JCS_YCbCr) {
cinfo.comp_info[0].h_samp_factor = opts.chroma_subsample;
@ -181,54 +180,54 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
* To keep things simple, we pass one scanline per call; you can pass
* more if you wish, though.
*/
row_stride = image_width * 4; /* JSAMPLEs per row in image_buffer */
int row_stride = image_width * 4; /* JSAMPLEs per row in image_buffer */
while (cinfo.next_scanline < cinfo.image_height) {
/* jpeg_write_scanlines expects an array of pointers to scanlines.
* Here the array is only one element long, but you could pass
* more than one scanline at a time if that's more convenient.
*/
row_pointer[0] = & image_buffer[cinfo.next_scanline * row_stride];
(void) jpeg_write_scanlines(&cinfo, row_pointer, 1);
JSAMPROW row_pointer =
&image_buffer[cinfo.next_scanline * row_stride]; /* pointer to JSAMPLE row[s] */
(void)jpeg_write_scanlines(&cinfo, &row_pointer, 1);
}
/* Step 6: Finish compression */
jpeg_finish_compress(&cinfo);
/* Step 7: release JPEG compression object */
last_result = output;
auto js_result = Uint8Array.new_(typed_memory_view(size, output));
/* And we're done! */
return val(typed_memory_view(size, output));
}
void free_result() {
/* This is an important step since it will release a good deal of memory. */
jpeg_destroy_compress(&cinfo);
free(output);
/* And we're done! */
return js_result;
}
EMSCRIPTEN_BINDINGS(my_module) {
value_object<MozJpegOptions>("MozJpegOptions")
.field("quality", &MozJpegOptions::quality)
.field("baseline", &MozJpegOptions::baseline)
.field("arithmetic", &MozJpegOptions::arithmetic)
.field("progressive", &MozJpegOptions::progressive)
.field("optimize_coding", &MozJpegOptions::optimize_coding)
.field("smoothing", &MozJpegOptions::smoothing)
.field("color_space", &MozJpegOptions::color_space)
.field("quant_table", &MozJpegOptions::quant_table)
.field("trellis_multipass", &MozJpegOptions::trellis_multipass)
.field("trellis_opt_zero", &MozJpegOptions::trellis_opt_zero)
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
.field("trellis_loops", &MozJpegOptions::trellis_loops)
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
.field("auto_subsample", &MozJpegOptions::auto_subsample)
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
.field("chroma_quality", &MozJpegOptions::chroma_quality)
;
.field("quality", &MozJpegOptions::quality)
.field("baseline", &MozJpegOptions::baseline)
.field("arithmetic", &MozJpegOptions::arithmetic)
.field("progressive", &MozJpegOptions::progressive)
.field("optimize_coding", &MozJpegOptions::optimize_coding)
.field("smoothing", &MozJpegOptions::smoothing)
.field("color_space", &MozJpegOptions::color_space)
.field("quant_table", &MozJpegOptions::quant_table)
.field("trellis_multipass", &MozJpegOptions::trellis_multipass)
.field("trellis_opt_zero", &MozJpegOptions::trellis_opt_zero)
.field("trellis_opt_table", &MozJpegOptions::trellis_opt_table)
.field("trellis_loops", &MozJpegOptions::trellis_loops)
.field("chroma_subsample", &MozJpegOptions::chroma_subsample)
.field("auto_subsample", &MozJpegOptions::auto_subsample)
.field("separate_chroma_quality", &MozJpegOptions::separate_chroma_quality)
.field("chroma_quality", &MozJpegOptions::chroma_quality);
function("version", &version);
function("encode", &encode);
function("free_result", &free_result);
}

View File

@ -2,7 +2,6 @@ import { EncodeOptions } from '../../src/codecs/mozjpeg/encoder-meta';
interface MozJPEGModule extends EmscriptenWasm.Module {
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
free_result(): void;
}
export default function(opts: EmscriptenWasm.ModuleOpts): MozJPEGModule;

View File

@ -6,58 +6,60 @@ var mozjpeg_enc = (function() {
function(mozjpeg_enc) {
mozjpeg_enc = mozjpeg_enc || {};
var c;c||(c=typeof mozjpeg_enc !== 'undefined' ? mozjpeg_enc : {});var r={},t;for(t in c)c.hasOwnProperty(t)&&(r[t]=c[t]);var aa="./this.program";function u(a,b){throw b;}var ba=!1,v=!1,ca=!1,da=!1;ba="object"===typeof window;v="function"===typeof importScripts;ca="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;da=!ba&&!ca&&!v;var w="",ea,x,fa,ha;
if(ca)w=v?require("path").dirname(w)+"/":__dirname+"/",ea=function(a,b){fa||(fa=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return fa.readFileSync(a,b?null:"utf8")},x=function(a){a=ea(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||A("Assertion failed: undefined");return a},1<process.argv.length&&(aa=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof ia))throw a;}),process.on("unhandledRejection",A),u=function(a){process.exit(a)},
c.inspect=function(){return"[Emscripten Module object]"};else if(da)"undefined"!=typeof read&&(ea=function(a){return read(a)}),x=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||A("Assertion failed: undefined");return a},"function"===typeof quit&&(u=function(a){quit(a)}),"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:
print);else if(ba||v)v?w=self.location.href:document.currentScript&&(w=document.currentScript.src),_scriptDir&&(w=_scriptDir),0!==w.indexOf("blob:")?w=w.substr(0,w.lastIndexOf("/")+1):w="",ea=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},v&&(x=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ja=c.print||console.log.bind(console),B=c.printErr||console.warn.bind(console);
for(t in r)r.hasOwnProperty(t)&&(c[t]=r[t]);r=null;c.thisProgram&&(aa=c.thisProgram);c.quit&&(u=c.quit);var C;c.wasmBinary&&(C=c.wasmBinary);var noExitRuntime;c.noExitRuntime&&(noExitRuntime=c.noExitRuntime);"object"!==typeof WebAssembly&&B("no native wasm support detected");var F,ka=new WebAssembly.Table({initial:134,maximum:134,element:"anyfunc"}),la=!1,ma="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function na(a,b,d){var e=b+d;for(d=b;a[d]&&!(d>=e);)++d;if(16<d-b&&a.subarray&&ma)return ma.decode(a.subarray(b,d));for(e="";b<d;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var m=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|m:(f&7)<<18|g<<12|m<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
function oa(a,b,d){var e=H;if(0<d){d=b+d-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var m=a.charCodeAt(++f);g=65536+((g&1023)<<10)|m&1023}if(127>=g){if(b>=d)break;e[b++]=g}else{if(2047>=g){if(b+1>=d)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=d)break;e[b++]=224|g>>12}else{if(b+3>=d)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var pa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function qa(a){var b;for(b=a>>1;I[b];)++b;b<<=1;if(32<b-a&&pa)return pa.decode(H.subarray(a,b));b=0;for(var d="";;){var e=I[a+2*b>>1];if(0==e)return d;++b;d+=String.fromCharCode(e)}}function ra(a,b,d){void 0===d&&(d=2147483647);if(2>d)return 0;d-=2;var e=b;d=d<2*a.length?d/2:a.length;for(var f=0;f<d;++f)I[b>>1]=a.charCodeAt(f),b+=2;I[b>>1]=0;return b-e}function sa(a){return 2*a.length}
function ta(a){for(var b=0,d="";;){var e=J[a+4*b>>2];if(0==e)return d;++b;65536<=e?(e-=65536,d+=String.fromCharCode(55296|e>>10,56320|e&1023)):d+=String.fromCharCode(e)}}function ua(a,b,d){void 0===d&&(d=2147483647);if(4>d)return 0;var e=b;d=e+d-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var m=a.charCodeAt(++f);g=65536+((g&1023)<<10)|m&1023}J[b>>2]=g;b+=4;if(b+4>d)break}J[b>>2]=0;return b-e}
function va(a){for(var b=0,d=0;d<a.length;++d){var e=a.charCodeAt(d);55296<=e&&57343>=e&&++d;b+=4}return b}var K,L,H,I,wa,J,M,xa,ya;function za(a){K=a;c.HEAP8=L=new Int8Array(a);c.HEAP16=I=new Int16Array(a);c.HEAP32=J=new Int32Array(a);c.HEAPU8=H=new Uint8Array(a);c.HEAPU16=wa=new Uint16Array(a);c.HEAPU32=M=new Uint32Array(a);c.HEAPF32=xa=new Float32Array(a);c.HEAPF64=ya=new Float64Array(a)}var Aa=c.INITIAL_MEMORY||16777216;c.wasmMemory?F=c.wasmMemory:F=new WebAssembly.Memory({initial:Aa/65536});
F&&(K=F.buffer);Aa=K.byteLength;za(K);J[39524]=5401136;function Ba(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b();else{var d=b.ba;"number"===typeof d?void 0===b.X?c.dynCall_v(d):c.dynCall_vi(d,b.X):d(void 0===b.X?null:b.X)}}}var Ca=[],Da=[],Ea=[],Fa=[];function Ga(){var a=c.preRun.shift();Ca.unshift(a)}var N=0,Ha=null,O=null;c.preloadedImages={};c.preloadedAudios={};
function A(a){if(c.onAbort)c.onAbort(a);ja(a);B(a);la=!0;throw new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");}function Ia(){var a=P;return String.prototype.startsWith?a.startsWith("data:application/octet-stream;base64,"):0===a.indexOf("data:application/octet-stream;base64,")}var P="mozjpeg_enc.wasm";if(!Ia()){var Ja=P;P=c.locateFile?c.locateFile(Ja,w):w+Ja}
function Ka(){try{if(C)return new Uint8Array(C);if(x)return x(P);throw"both async and sync fetching of the wasm failed";}catch(a){A(a)}}function La(){return C||!ba&&!v||"function"!==typeof fetch?new Promise(function(a){a(Ka())}):fetch(P,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+P+"'";return a.arrayBuffer()}).catch(function(){return Ka()})}Da.push({ba:function(){Ma()}});var Na={};function Oa(a){for(;a.length;){var b=a.pop();a.pop()(b)}}
function Pa(a){return this.fromWireType(M[a>>2])}var Q={},R={},Qa={};function Ra(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}function Sa(a,b){a=Ra(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}
function Ta(a){var b=Error,d=Sa(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});d.prototype=Object.create(b.prototype);d.prototype.constructor=d;d.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return d}var Ua=void 0;
function Va(a,b,d){function e(h){h=d(h);if(h.length!==a.length)throw new Ua("Mismatched type converter count");for(var k=0;k<a.length;++k)S(a[k],h[k])}a.forEach(function(h){Qa[h]=b});var f=Array(b.length),g=[],m=0;b.forEach(function(h,k){R.hasOwnProperty(h)?f[k]=R[h]:(g.push(h),Q.hasOwnProperty(h)||(Q[h]=[]),Q[h].push(function(){f[k]=R[h];++m;m===g.length&&e(f)}))});0===g.length&&e(f)}
function Wa(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Xa=void 0;function T(a){for(var b="";H[a];)b+=Xa[H[a++]];return b}var Ya=void 0;function U(a){throw new Ya(a);}
function S(a,b,d){d=d||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||U('type "'+e+'" must have a positive integer typeid pointer');if(R.hasOwnProperty(a)){if(d.ga)return;U("Cannot register type '"+e+"' twice")}R[a]=b;delete Qa[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}var Za=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function $a(a){4<a&&0===--V[a].Y&&(V[a]=void 0,Za.push(a))}function ab(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Za.length?Za.pop():V.length;V[b]={Y:1,value:a};return b}}function bb(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function cb(a,b){switch(b){case 2:return function(d){return this.fromWireType(xa[d>>2])};case 3:return function(d){return this.fromWireType(ya[d>>3])};default:throw new TypeError("Unknown float type: "+a);}}function db(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var d=Sa(b.name||"unknownFunctionName",function(){});d.prototype=b.prototype;d=new d;a=b.apply(d,a);return a instanceof Object?a:d}
function eb(a,b){var d=c;if(void 0===d[a].V){var e=d[a];d[a]=function(){d[a].V.hasOwnProperty(arguments.length)||U("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+d[a].V+")!");return d[a].V[arguments.length].apply(this,arguments)};d[a].V=[];d[a].V[e.$]=e}}
function fb(a,b,d){c.hasOwnProperty(a)?((void 0===d||void 0!==c[a].V&&void 0!==c[a].V[d])&&U("Cannot register public name '"+a+"' twice"),eb(a,a),c.hasOwnProperty(d)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+d+")!"),c[a].V[d]=b):(c[a]=b,void 0!==d&&(c[a].na=d))}function gb(a,b){for(var d=[],e=0;e<a;e++)d.push(J[(b>>2)+e]);return d}
function W(a,b){a=T(a);var d=c["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";d=(new Function("dynCall","rawFunction",f+"};\n"))(d,b);"function"!==typeof d&&U("unknown function pointer with signature "+a+": "+b);return d}var hb=void 0;function ib(a){a=jb(a);var b=T(a);Y(a);return b}
function kb(a,b){function d(g){f[g]||R[g]||(Qa[g]?Qa[g].forEach(d):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(d);throw new hb(a+": "+e.map(ib).join([", "]));}function lb(a,b,d){switch(b){case 0:return d?function(e){return L[e]}:function(e){return H[e]};case 1:return d?function(e){return I[e>>1]}:function(e){return wa[e>>1]};case 2:return d?function(e){return J[e>>2]}:function(e){return M[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var mb={};
function nb(){if(!ob){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:aa||"./this.program"},b;for(b in mb)a[b]=mb[b];var d=[];for(b in a)d.push(b+"="+a[b]);ob=d}return ob}var ob,pb=[null,[],[]];Ua=c.InternalError=Ta("InternalError");for(var qb=Array(256),rb=0;256>rb;++rb)qb[rb]=String.fromCharCode(rb);Xa=qb;Ya=c.BindingError=Ta("BindingError");
c.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};c.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};hb=c.UnboundTypeError=Ta("UnboundTypeError");
var tb={m:function(a){var b=Na[a];delete Na[a];var d=b.ha,e=b.ia,f=b.Z,g=f.map(function(m){return m.fa}).concat(f.map(function(m){return m.ka}));Va([a],g,function(m){var h={};f.forEach(function(k,l){var n=m[l],q=k.da,D=k.ea,y=m[l+f.length],p=k.ja,E=k.la;h[k.aa]={read:function(z){return n.fromWireType(q(D,z))},write:function(z,G){var X=[];p(E,z,y.toWireType(X,G));Oa(X)}}});return[{name:b.name,fromWireType:function(k){var l={},n;for(n in h)l[n]=h[n].read(k);e(k);return l},toWireType:function(k,l){for(var n in h)if(!(n in
l))throw new TypeError("Missing field");var q=d();for(n in h)h[n].write(q,l[n]);null!==k&&k.push(e,q);return q},argPackAdvance:8,readValueFromPointer:Pa,W:e}]})},s:function(a,b,d,e,f){var g=Wa(d);b=T(b);S(a,{name:b,fromWireType:function(m){return!!m},toWireType:function(m,h){return h?e:f},argPackAdvance:8,readValueFromPointer:function(m){if(1===d)var h=L;else if(2===d)h=I;else if(4===d)h=J;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[m>>g])},W:null})},r:function(a,
b){b=T(b);S(a,{name:b,fromWireType:function(d){var e=V[d].value;$a(d);return e},toWireType:function(d,e){return ab(e)},argPackAdvance:8,readValueFromPointer:Pa,W:null})},g:function(a,b,d){d=Wa(d);b=T(b);S(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+bb(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:cb(b,d),W:null})},c:function(a,b,d,e,f,g){var m=gb(b,d);a=T(a);f=W(e,
f);fb(a,function(){kb("Cannot call "+a+" due to unbound types",m)},b-1);Va([],m,function(h){var k=[h[0],null].concat(h.slice(1)),l=h=a,n=f,q=k.length;2>q&&U("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var D=null!==k[1]&&!1,y=!1,p=1;p<k.length;++p)if(null!==k[p]&&void 0===k[p].W){y=!0;break}var E="void"!==k[0].name,z="",G="";for(p=0;p<q-2;++p)z+=(0!==p?", ":"")+"arg"+p,G+=(0!==p?", ":"")+"arg"+p+"Wired";l="return function "+Ra(l)+"("+z+") {\nif (arguments.length !== "+
(q-2)+") {\nthrowBindingError('function "+l+" called with ' + arguments.length + ' arguments, expected "+(q-2)+" args!');\n}\n";y&&(l+="var destructors = [];\n");var X=y?"destructors":"null";z="throwBindingError invoker fn runDestructors retType classParam".split(" ");n=[U,n,g,Oa,k[0],k[1]];D&&(l+="var thisWired = classParam.toWireType("+X+", this);\n");for(p=0;p<q-2;++p)l+="var arg"+p+"Wired = argType"+p+".toWireType("+X+", arg"+p+"); // "+k[p+2].name+"\n",z.push("argType"+p),n.push(k[p+2]);D&&(G=
"thisWired"+(0<G.length?", ":"")+G);l+=(E?"var rv = ":"")+"invoker(fn"+(0<G.length?", ":"")+G+");\n";if(y)l+="runDestructors(destructors);\n";else for(p=D?1:2;p<k.length;++p)q=1===p?"thisWired":"arg"+(p-2)+"Wired",null!==k[p].W&&(l+=q+"_dtor("+q+"); // "+k[p].name+"\n",z.push(q+"_dtor"),n.push(k[p].W));E&&(l+="var ret = retType.fromWireType(rv);\nreturn ret;\n");z.push(l+"}\n");k=db(z).apply(null,n);p=b-1;if(!c.hasOwnProperty(h))throw new Ua("Replacing nonexistant public symbol");void 0!==c[h].V&&
void 0!==p?c[h].V[p]=k:(c[h]=k,c[h].$=p);return[]})},b:function(a,b,d,e,f){function g(l){return l}b=T(b);-1===f&&(f=4294967295);var m=Wa(d);if(0===e){var h=32-8*d;g=function(l){return l<<h>>>h}}var k=-1!=b.indexOf("unsigned");S(a,{name:b,fromWireType:g,toWireType:function(l,n){if("number"!==typeof n&&"boolean"!==typeof n)throw new TypeError('Cannot convert "'+bb(n)+'" to '+this.name);if(n<e||n>f)throw new TypeError('Passing a number "'+bb(n)+'" from JS side to C/C++ side to an argument of type "'+
b+'", which is outside the valid range ['+e+", "+f+"]!");return k?n>>>0:n|0},argPackAdvance:8,readValueFromPointer:lb(b,m,0!==e),W:null})},a:function(a,b,d){function e(g){g>>=2;var m=M;return new f(K,m[g+1],m[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];d=T(d);S(a,{name:d,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{ga:!0})},h:function(a,b){b=T(b);var d="std::string"===b;S(a,{name:b,fromWireType:function(e){var f=M[e>>2];if(d){var g=
H[e+4+f],m=0;0!=g&&(m=g,H[e+4+f]=0);var h=e+4;for(g=0;g<=f;++g){var k=e+4+g;if(0==H[k]){h=h?na(H,h,void 0):"";if(void 0===l)var l=h;else l+=String.fromCharCode(0),l+=h;h=k+1}}0!=m&&(H[e+4+f]=m)}else{l=Array(f);for(g=0;g<f;++g)l[g]=String.fromCharCode(H[e+4+g]);l=l.join("")}Y(e);return l},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||U("Cannot pass non-string to std::string");
var m=(d&&g?function(){for(var l=0,n=0;n<f.length;++n){var q=f.charCodeAt(n);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++n)&1023);127>=q?++l:l=2047>=q?l+2:65535>=q?l+3:l+4}return l}:function(){return f.length})(),h=sb(4+m+1);M[h>>2]=m;if(d&&g)oa(f,h+4,m+1);else if(g)for(g=0;g<m;++g){var k=f.charCodeAt(g);255<k&&(Y(h),U("String has UTF-16 code units that do not fit in 8 bits"));H[h+4+g]=k}else for(g=0;g<m;++g)H[h+4+g]=f[g];null!==e&&e.push(Y,h);return h},argPackAdvance:8,readValueFromPointer:Pa,
W:function(e){Y(e)}})},d:function(a,b,d){d=T(d);if(2===b){var e=qa;var f=ra;var g=sa;var m=function(){return wa};var h=1}else 4===b&&(e=ta,f=ua,g=va,m=function(){return M},h=2);S(a,{name:d,fromWireType:function(k){var l=M[k>>2],n=m(),q=n[k+4+l*b>>h],D=0;0!=q&&(D=q,n[k+4+l*b>>h]=0);var y=k+4;for(q=0;q<=l;++q){var p=k+4+q*b;if(0==n[p>>h]){y=e(y);if(void 0===E)var E=y;else E+=String.fromCharCode(0),E+=y;y=p+b}}0!=D&&(n[k+4+l*b>>h]=D);Y(k);return E},toWireType:function(k,l){"string"!==typeof l&&U("Cannot pass non-string to C++ string type "+
d);var n=g(l),q=sb(4+n+b);M[q>>2]=n>>h;f(l,q+4,n+b);null!==k&&k.push(Y,q);return q},argPackAdvance:8,readValueFromPointer:Pa,W:function(k){Y(k)}})},x:function(a,b,d,e,f,g){Na[a]={name:T(b),ha:W(d,e),ia:W(f,g),Z:[]}},f:function(a,b,d,e,f,g,m,h,k,l){Na[a].Z.push({aa:T(b),fa:d,da:W(e,f),ea:g,ka:m,ja:W(h,k),la:l})},t:function(a,b){b=T(b);S(a,{ma:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},k:$a,l:function(a){4<a&&(V[a].Y+=1)},y:function(a,b){var d=R[a];void 0===d&&U("_emval_take_value has unknown type "+
ib(a));a=d.readValueFromPointer(b);return ab(a)},u:function(){A()},p:function(a,b,d){H.copyWithin(a,b,b+d)},q:function(a){var b=H.length;if(2147418112<a)return!1;for(var d=1;4>=d;d*=2){var e=b*(1+.2/d);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%65536&&(e+=65536-e%65536);a:{try{F.grow(Math.min(2147418112,e)-K.byteLength+65535>>16);za(F.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},v:function(a,b){var d=0;nb().forEach(function(e,f){var g=b+d;f=J[a+4*f>>2]=g;for(g=0;g<
e.length;++g)L[f++>>0]=e.charCodeAt(g);L[f>>0]=0;d+=e.length+1});return 0},w:function(a,b){var d=nb();J[a>>2]=d.length;var e=0;d.forEach(function(f){e+=f.length+1});J[b>>2]=e;return 0},j:function(a){if(!noExitRuntime&&(la=!0,c.onExit))c.onExit(a);u(a,new ia(a))},i:function(){return 0},n:function(){},e:function(a,b,d,e){for(var f=0,g=0;g<d;g++){for(var m=J[b+8*g>>2],h=J[b+(8*g+4)>>2],k=0;k<h;k++){var l=H[m+k],n=pb[a];0===l||10===l?((1===a?ja:B)(na(n,0)),n.length=0):n.push(l)}f+=h}J[e>>2]=f;return 0},
memory:F,o:function(){},table:ka},ub=function(){function a(f){c.asm=f.exports;N--;c.monitorRunDependencies&&c.monitorRunDependencies(N);0==N&&(null!==Ha&&(clearInterval(Ha),Ha=null),O&&(f=O,O=null,f()))}function b(f){a(f.instance)}function d(f){return La().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);A(g)})}var e={a:tb};N++;c.monitorRunDependencies&&c.monitorRunDependencies(N);if(c.instantiateWasm)try{return c.instantiateWasm(e,
a)}catch(f){return B("Module.instantiateWasm callback failed with error: "+f),!1}(function(){if(C||"function"!==typeof WebAssembly.instantiateStreaming||Ia()||"function"!==typeof fetch)return d(b);fetch(P,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");d(b)})})})();return{}}();c.asm=ub;
var Ma=c.___wasm_call_ctors=function(){return(Ma=c.___wasm_call_ctors=c.asm.z).apply(null,arguments)},sb=c._malloc=function(){return(sb=c._malloc=c.asm.A).apply(null,arguments)},Y=c._free=function(){return(Y=c._free=c.asm.B).apply(null,arguments)},jb=c.___getTypeName=function(){return(jb=c.___getTypeName=c.asm.C).apply(null,arguments)};c.___embind_register_native_and_builtin_types=function(){return(c.___embind_register_native_and_builtin_types=c.asm.D).apply(null,arguments)};
c.dynCall_i=function(){return(c.dynCall_i=c.asm.E).apply(null,arguments)};c.dynCall_viiiii=function(){return(c.dynCall_viiiii=c.asm.F).apply(null,arguments)};c.dynCall_v=function(){return(c.dynCall_v=c.asm.G).apply(null,arguments)};c.dynCall_vi=function(){return(c.dynCall_vi=c.asm.H).apply(null,arguments)};c.dynCall_iii=function(){return(c.dynCall_iii=c.asm.I).apply(null,arguments)};c.dynCall_viii=function(){return(c.dynCall_viii=c.asm.J).apply(null,arguments)};
c.dynCall_ii=function(){return(c.dynCall_ii=c.asm.K).apply(null,arguments)};c.dynCall_iiiiii=function(){return(c.dynCall_iiiiii=c.asm.L).apply(null,arguments)};c.dynCall_viiiiiiii=function(){return(c.dynCall_viiiiiiii=c.asm.M).apply(null,arguments)};c.dynCall_vii=function(){return(c.dynCall_vii=c.asm.N).apply(null,arguments)};c.dynCall_viiii=function(){return(c.dynCall_viiii=c.asm.O).apply(null,arguments)};c.dynCall_viiiiiii=function(){return(c.dynCall_viiiiiii=c.asm.P).apply(null,arguments)};
c.dynCall_iiiiiii=function(){return(c.dynCall_iiiiiii=c.asm.Q).apply(null,arguments)};c.dynCall_iiiii=function(){return(c.dynCall_iiiii=c.asm.R).apply(null,arguments)};c.dynCall_iiii=function(){return(c.dynCall_iiii=c.asm.S).apply(null,arguments)};c.dynCall_jiji=function(){return(c.dynCall_jiji=c.asm.T).apply(null,arguments)};c.dynCall_viiiiii=function(){return(c.dynCall_viiiiii=c.asm.U).apply(null,arguments)};c.asm=ub;var Z;
c.then=function(a){if(Z)a(c);else{var b=c.onRuntimeInitialized;c.onRuntimeInitialized=function(){b&&b();a(c)}}return c};function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}O=function vb(){Z||wb();Z||(O=vb)};
function wb(){function a(){if(!Z&&(Z=!0,c.calledRun=!0,!la)){Ba(Da);Ba(Ea);if(c.onRuntimeInitialized)c.onRuntimeInitialized();if(c.postRun)for("function"==typeof c.postRun&&(c.postRun=[c.postRun]);c.postRun.length;){var b=c.postRun.shift();Fa.unshift(b)}Ba(Fa)}}if(!(0<N)){if(c.preRun)for("function"==typeof c.preRun&&(c.preRun=[c.preRun]);c.preRun.length;)Ga();Ba(Ca);0<N||(c.setStatus?(c.setStatus("Running..."),setTimeout(function(){setTimeout(function(){c.setStatus("")},1);a()},1)):a())}}c.run=wb;
if(c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();noExitRuntime=!0;wb();
var d;d||(d=typeof mozjpeg_enc !== 'undefined' ? mozjpeg_enc : {});var aa;d.ready=new Promise(function(a){aa=a});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var ba="./this.program";function u(a,b){throw b;}var v=!1,w=!1,ca=!1,da=!1;v="object"===typeof window;w="function"===typeof importScripts;ca="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;da=!v&&!ca&&!w;var x="",B,C,ea,fa;
if(ca)x=w?require("path").dirname(x)+"/":__dirname+"/",B=function(a,b){ea||(ea=require("fs"));fa||(fa=require("path"));a=fa.normalize(a);return ea.readFileSync(a,b?null:"utf8")},C=function(a){a=B(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||D("Assertion failed: undefined");return a},1<process.argv.length&&(ba=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof ha))throw a;}),process.on("unhandledRejection",D),u=function(a){process.exit(a)},
d.inspect=function(){return"[Emscripten Module object]"};else if(da)"undefined"!=typeof read&&(B=function(a){return read(a)}),C=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||D("Assertion failed: undefined");return a},"function"===typeof quit&&(u=function(a){quit(a)}),"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:
print);else if(v||w)w?x=self.location.href:document.currentScript&&(x=document.currentScript.src),_scriptDir&&(x=_scriptDir),0!==x.indexOf("blob:")?x=x.substr(0,x.lastIndexOf("/")+1):x="",B=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},w&&(C=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ia=d.print||console.log.bind(console),E=d.printErr||console.warn.bind(console);
for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;d.thisProgram&&(ba=d.thisProgram);d.quit&&(u=d.quit);var G;d.wasmBinary&&(G=d.wasmBinary);var noExitRuntime;d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&D("no native wasm support detected");var H,ja=new WebAssembly.Table({initial:122,maximum:122,element:"anyfunc"}),la=!1,ma="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function na(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&ma)return ma.decode(a.subarray(b,c));for(e="";b<c;){var f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var l=a[b++]&63;f=224==(f&240)?(f&15)<<12|g<<6|l:(f&7)<<18|g<<12|l<<6|a[b++]&63;65536>f?e+=String.fromCharCode(f):(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else e+=String.fromCharCode(f)}return e}
function oa(a,b,c){var e=I;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}if(127>=g){if(b>=c)break;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var pa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function qa(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&ra[c];)++c;c<<=1;if(32<c-a&&pa)return pa.decode(I.subarray(a,c));c=0;for(e="";;){var f=J[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function sa(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)J[b>>1]=a.charCodeAt(f),b+=2;J[b>>1]=0;return b-e}function ta(a){return 2*a.length}
function ua(a,b){for(var c=0,e="";!(c>=b/4);){var f=K[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function va(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var l=a.charCodeAt(++f);g=65536+((g&1023)<<10)|l&1023}K[b>>2]=g;b+=4;if(b+4>c)break}K[b>>2]=0;return b-e}
function wa(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var L,M,I,J,ra,K,N,xa,ya;function za(a){L=a;d.HEAP8=M=new Int8Array(a);d.HEAP16=J=new Int16Array(a);d.HEAP32=K=new Int32Array(a);d.HEAPU8=I=new Uint8Array(a);d.HEAPU16=ra=new Uint16Array(a);d.HEAPU32=N=new Uint32Array(a);d.HEAPF32=xa=new Float32Array(a);d.HEAPF64=ya=new Float64Array(a)}var Aa=d.INITIAL_MEMORY||16777216;d.wasmMemory?H=d.wasmMemory:H=new WebAssembly.Memory({initial:Aa/65536,maximum:32768});
H&&(L=H.buffer);Aa=L.byteLength;za(L);K[22876]=5334544;function Ba(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.ga;"number"===typeof c?void 0===b.$?d.dynCall_v(c):d.dynCall_vi(c,b.$):c(void 0===b.$?null:b.$)}}}var Ca=[],Da=[],Ea=[],Fa=[];function Ga(){var a=d.preRun.shift();Ca.unshift(a)}var O=0,Ha=null,P=null;d.preloadedImages={};d.preloadedAudios={};
function D(a){if(d.onAbort)d.onAbort(a);ia(a);E(a);la=!0;throw new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");}function Ia(a){var b=Q;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ja(){return Ia("data:application/octet-stream;base64,")}var Q="mozjpeg_enc.wasm";if(!Ja()){var Ka=Q;Q=d.locateFile?d.locateFile(Ka,x):x+Ka}
function La(){try{if(G)return new Uint8Array(G);if(C)return C(Q);throw"both async and sync fetching of the wasm failed";}catch(a){D(a)}}function Ma(){return G||!v&&!w||"function"!==typeof fetch||Ia("file://")?new Promise(function(a){a(La())}):fetch(Q,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+Q+"'";return a.arrayBuffer()}).catch(function(){return La()})}Da.push({ga:function(){Na()}});function Oa(){return 0<Oa.ba}var Pa={};
function Qa(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Ra(a){return this.fromWireType(N[a>>2])}var R={},S={},Sa={};function Ta(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}function Ua(a,b){a=Ta(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}
function Va(a){var b=Error,c=Ua(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}var Wa=void 0;
function Xa(a,b,c){function e(k){k=c(k);if(k.length!==a.length)throw new Wa("Mismatched type converter count");for(var h=0;h<a.length;++h)T(a[h],k[h])}a.forEach(function(k){Sa[k]=b});var f=Array(b.length),g=[],l=0;b.forEach(function(k,h){S.hasOwnProperty(k)?f[h]=S[k]:(g.push(k),R.hasOwnProperty(k)||(R[k]=[]),R[k].push(function(){f[h]=S[k];++l;l===g.length&&e(f)}))});0===g.length&&e(f)}
function Ya(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Za=void 0;function U(a){for(var b="";I[a];)b+=Za[I[a++]];return b}var $a=void 0;function V(a){throw new $a(a);}
function T(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||V('type "'+e+'" must have a positive integer typeid pointer');if(S.hasOwnProperty(a)){if(c.ka)return;V("Cannot register type '"+e+"' twice")}S[a]=b;delete Sa[a];R.hasOwnProperty(a)&&(b=R[a],delete R[a],b.forEach(function(f){f()}))}var ab=[],X=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function bb(a){4<a&&0===--X[a].aa&&(X[a]=void 0,ab.push(a))}function cb(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=ab.length?ab.pop():X.length;X[b]={aa:1,value:a};return b}}function db(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function eb(a,b){switch(b){case 2:return function(c){return this.fromWireType(xa[c>>2])};case 3:return function(c){return this.fromWireType(ya[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function fb(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Ua(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function gb(a,b){var c=d;if(void 0===c[a].Y){var e=c[a];c[a]=function(){c[a].Y.hasOwnProperty(arguments.length)||V("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Y+")!");return c[a].Y[arguments.length].apply(this,arguments)};c[a].Y=[];c[a].Y[e.ea]=e}}
function hb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].Y&&void 0!==d[a].Y[c])&&V("Cannot register public name '"+a+"' twice"),gb(a,a),d.hasOwnProperty(c)&&V("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].Y[c]=b):(d[a]=b,void 0!==c&&(d[a].ra=c))}function ib(a,b){for(var c=[],e=0;e<a;e++)c.push(K[(b>>2)+e]);return c}
function Y(a,b){a=U(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&V("unknown function pointer with signature "+a+": "+b);return c}var jb=void 0;function kb(a){a=lb(a);var b=U(a);Z(a);return b}
function mb(a,b){function c(g){f[g]||S[g]||(Sa[g]?Sa[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new jb(a+": "+e.map(kb).join([", "]));}function nb(a,b,c){switch(b){case 0:return c?function(e){return M[e]}:function(e){return I[e]};case 1:return c?function(e){return J[e>>1]}:function(e){return ra[e>>1]};case 2:return c?function(e){return K[e>>2]}:function(e){return N[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var ob={};
function pb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function qb(a,b){var c=S[a];void 0===c&&V(b+" has unknown type "+kb(a));return c}var rb={},sb={};function tb(){if(!ub){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"===typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:ba||"./this.program"},b;for(b in sb)a[b]=sb[b];var c=[];for(b in a)c.push(b+"="+a[b]);ub=c}return ub}
var ub,vb=[null,[],[]];Wa=d.InternalError=Va("InternalError");for(var wb=Array(256),xb=0;256>xb;++xb)wb[xb]=String.fromCharCode(xb);Za=wb;$a=d.BindingError=Va("BindingError");d.count_emval_handles=function(){for(var a=0,b=5;b<X.length;++b)void 0!==X[b]&&++a;return a};d.get_first_emval=function(){for(var a=5;a<X.length;++a)if(void 0!==X[a])return X[a];return null};jb=d.UnboundTypeError=Va("UnboundTypeError");
var zb={j:function(a){return yb(a)},C:function(){},A:function(a){"uncaught_exception"in Oa?Oa.ba++:Oa.ba=1;throw a;},l:function(a){var b=Pa[a];delete Pa[a];var c=b.la,e=b.ma,f=b.da,g=f.map(function(l){return l.ja}).concat(f.map(function(l){return l.oa}));Xa([a],g,function(l){var k={};f.forEach(function(h,m){var n=l[m],q=h.ha,y=h.ia,z=l[m+f.length],p=h.na,ka=h.pa;k[h.fa]={read:function(A){return n.fromWireType(q(y,A))},write:function(A,F){var W=[];p(ka,A,z.toWireType(W,F));Qa(W)}}});return[{name:b.name,
fromWireType:function(h){var m={},n;for(n in k)m[n]=k[n].read(h);e(h);return m},toWireType:function(h,m){for(var n in k)if(!(n in m))throw new TypeError('Missing field: "'+n+'"');var q=c();for(n in k)k[n].write(q,m[n]);null!==h&&h.push(e,q);return q},argPackAdvance:8,readValueFromPointer:Ra,Z:e}]})},x:function(a,b,c,e,f){var g=Ya(c);b=U(b);T(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,k){return k?e:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var k=M;else if(2===
c)k=J;else if(4===c)k=K;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[l>>g])},Z:null})},w:function(a,b){b=U(b);T(a,{name:b,fromWireType:function(c){var e=X[c].value;bb(c);return e},toWireType:function(c,e){return cb(e)},argPackAdvance:8,readValueFromPointer:Ra,Z:null})},h:function(a,b,c){c=Ya(c);b=U(b);T(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+db(f)+
'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:eb(b,c),Z:null})},e:function(a,b,c,e,f,g){var l=ib(b,c);a=U(a);f=Y(e,f);hb(a,function(){mb("Cannot call "+a+" due to unbound types",l)},b-1);Xa([],l,function(k){var h=[k[0],null].concat(k.slice(1)),m=k=a,n=f,q=h.length;2>q&&V("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==h[1]&&!1,z=!1,p=1;p<h.length;++p)if(null!==h[p]&&void 0===h[p].Z){z=!0;break}var ka="void"!==h[0].name,A="",F=
"";for(p=0;p<q-2;++p)A+=(0!==p?", ":"")+"arg"+p,F+=(0!==p?", ":"")+"arg"+p+"Wired";m="return function "+Ta(m)+"("+A+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+m+" called with ' + arguments.length + ' arguments, expected "+(q-2)+" args!');\n}\n";z&&(m+="var destructors = [];\n");var W=z?"destructors":"null";A="throwBindingError invoker fn runDestructors retType classParam".split(" ");n=[V,n,g,Qa,h[0],h[1]];y&&(m+="var thisWired = classParam.toWireType("+W+", this);\n");
for(p=0;p<q-2;++p)m+="var arg"+p+"Wired = argType"+p+".toWireType("+W+", arg"+p+"); // "+h[p+2].name+"\n",A.push("argType"+p),n.push(h[p+2]);y&&(F="thisWired"+(0<F.length?", ":"")+F);m+=(ka?"var rv = ":"")+"invoker(fn"+(0<F.length?", ":"")+F+");\n";if(z)m+="runDestructors(destructors);\n";else for(p=y?1:2;p<h.length;++p)q=1===p?"thisWired":"arg"+(p-2)+"Wired",null!==h[p].Z&&(m+=q+"_dtor("+q+"); // "+h[p].name+"\n",A.push(q+"_dtor"),n.push(h[p].Z));ka&&(m+="var ret = retType.fromWireType(rv);\nreturn ret;\n");
A.push(m+"}\n");h=fb(A).apply(null,n);p=b-1;if(!d.hasOwnProperty(k))throw new Wa("Replacing nonexistant public symbol");void 0!==d[k].Y&&void 0!==p?d[k].Y[p]=h:(d[k]=h,d[k].ea=p);return[]})},b:function(a,b,c,e,f){function g(m){return m}b=U(b);-1===f&&(f=4294967295);var l=Ya(c);if(0===e){var k=32-8*c;g=function(m){return m<<k>>>k}}var h=-1!=b.indexOf("unsigned");T(a,{name:b,fromWireType:g,toWireType:function(m,n){if("number"!==typeof n&&"boolean"!==typeof n)throw new TypeError('Cannot convert "'+db(n)+
'" to '+this.name);if(n<e||n>f)throw new TypeError('Passing a number "'+db(n)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return h?n>>>0:n|0},argPackAdvance:8,readValueFromPointer:nb(b,l,0!==e),Z:null})},a:function(a,b,c){function e(g){g>>=2;var l=N;return new f(L,l[g+1],l[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=U(c);T(a,{name:c,fromWireType:e,argPackAdvance:8,
readValueFromPointer:e},{ka:!0})},i:function(a,b){b=U(b);var c="std::string"===b;T(a,{name:b,fromWireType:function(e){var f=N[e>>2];if(c)for(var g=e+4,l=0;l<=f;++l){var k=e+4+l;if(0==I[k]||l==f){g=g?na(I,g,k-g):"";if(void 0===h)var h=g;else h+=String.fromCharCode(0),h+=g;g=k+1}}else{h=Array(f);for(l=0;l<f;++l)h[l]=String.fromCharCode(I[e+4+l]);h=h.join("")}Z(e);return h},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||
f instanceof Uint8ClampedArray||f instanceof Int8Array||V("Cannot pass non-string to std::string");var l=(c&&g?function(){for(var m=0,n=0;n<f.length;++n){var q=f.charCodeAt(n);55296<=q&&57343>=q&&(q=65536+((q&1023)<<10)|f.charCodeAt(++n)&1023);127>=q?++m:m=2047>=q?m+2:65535>=q?m+3:m+4}return m}:function(){return f.length})(),k=yb(4+l+1);N[k>>2]=l;if(c&&g)oa(f,k+4,l+1);else if(g)for(g=0;g<l;++g){var h=f.charCodeAt(g);255<h&&(Z(k),V("String has UTF-16 code units that do not fit in 8 bits"));I[k+4+g]=
h}else for(g=0;g<l;++g)I[k+4+g]=f[g];null!==e&&e.push(Z,k);return k},argPackAdvance:8,readValueFromPointer:Ra,Z:function(e){Z(e)}})},d:function(a,b,c){c=U(c);if(2===b){var e=qa;var f=sa;var g=ta;var l=function(){return ra};var k=1}else 4===b&&(e=ua,f=va,g=wa,l=function(){return N},k=2);T(a,{name:c,fromWireType:function(h){for(var m=N[h>>2],n=l(),q,y=h+4,z=0;z<=m;++z){var p=h+4+z*b;if(0==n[p>>k]||z==m)y=e(y,p-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=p+b}Z(h);return q},toWireType:function(h,
m){"string"!==typeof m&&V("Cannot pass non-string to C++ string type "+c);var n=g(m),q=yb(4+n+b);N[q>>2]=n>>k;f(m,q+4,n+b);null!==h&&h.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Ra,Z:function(h){Z(h)}})},m:function(a,b,c,e,f,g){Pa[a]={name:U(b),la:Y(c,e),ma:Y(f,g),da:[]}},f:function(a,b,c,e,f,g,l,k,h,m){Pa[a].da.push({fa:U(b),ja:c,ha:Y(e,f),ia:g,oa:l,na:Y(k,h),pa:m})},y:function(a,b){b=U(b);T(a,{qa:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},v:bb,
B:function(a){if(0===a)return cb(pb());var b=ob[a];a=void 0===b?U(a):b;return cb(pb()[a])},k:function(a){4<a&&(X[a].aa+=1)},n:function(a,b,c,e){a||V("Cannot use deleted val. handle = "+a);a=X[a].value;var f=rb[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var l="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)l+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+
g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",l+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(qb,d,cb);rb[b]=f}return f(a,c,e)},r:function(){D()},q:function(a,b,c){I.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=I.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%65536&&(e+=65536-e%65536);a:{try{H.grow(Math.min(2147483648,
e)-L.byteLength+65535>>>16);za(H.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},s:function(a,b){var c=0;tb().forEach(function(e,f){var g=b+c;f=K[a+4*f>>2]=g;for(g=0;g<e.length;++g)M[f++>>0]=e.charCodeAt(g);M[f>>0]=0;c+=e.length+1});return 0},t:function(a,b){var c=tb();K[a>>2]=c.length;var e=0;c.forEach(function(f){e+=f.length+1});K[b>>2]=e;return 0},z:function(a){if(!noExitRuntime&&(la=!0,d.onExit))d.onExit(a);u(a,new ha(a))},u:function(){return 0},o:function(){},g:function(a,
b,c,e){for(var f=0,g=0;g<c;g++){for(var l=K[b+8*g>>2],k=K[b+(8*g+4)>>2],h=0;h<k;h++){var m=I[l+h],n=vb[a];0===m||10===m?((1===a?ia:E)(na(n,0)),n.length=0):n.push(m)}f+=k}K[e>>2]=f;return 0},memory:H,p:function(){},table:ja};
(function(){function a(f){d.asm=f.exports;O--;d.monitorRunDependencies&&d.monitorRunDependencies(O);0==O&&(null!==Ha&&(clearInterval(Ha),Ha=null),P&&(f=P,P=null,f()))}function b(f){a(f.instance)}function c(f){return Ma().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){E("failed to asynchronously prepare wasm: "+g);D(g)})}var e={a:zb};O++;d.monitorRunDependencies&&d.monitorRunDependencies(O);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return E("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(G||"function"!==typeof WebAssembly.instantiateStreaming||Ja()||Ia("file://")||"function"!==typeof fetch)return c(b);fetch(Q,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){E("wasm streaming compile failed: "+g);E("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Na=d.___wasm_call_ctors=function(){return(Na=d.___wasm_call_ctors=d.asm.D).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.E).apply(null,arguments)},yb=d._malloc=function(){return(yb=d._malloc=d.asm.F).apply(null,arguments)},lb=d.___getTypeName=function(){return(lb=d.___getTypeName=d.asm.G).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.H).apply(null,arguments)};
d.dynCall_i=function(){return(d.dynCall_i=d.asm.I).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.J).apply(null,arguments)};d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.K).apply(null,arguments)};d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.L).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.M).apply(null,arguments)};d.dynCall_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.N).apply(null,arguments)};
d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.O).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.P).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.Q).apply(null,arguments)};d.dynCall_iiiii=function(){return(d.dynCall_iiiii=d.asm.R).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.S).apply(null,arguments)};d.dynCall_viiiiiiii=function(){return(d.dynCall_viiiiiiii=d.asm.T).apply(null,arguments)};
d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.U).apply(null,arguments)};d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.V).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.W).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.X).apply(null,arguments)};var Ab;function ha(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}P=function Bb(){Ab||Cb();Ab||(P=Bb)};
function Cb(){function a(){if(!Ab&&(Ab=!0,d.calledRun=!0,!la)){Ba(Da);Ba(Ea);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Fa.unshift(b)}Ba(Fa)}}if(!(0<O)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Ga();Ba(Ca);0<O||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
d.run=Cb;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;Cb();
return mozjpeg_enc
return mozjpeg_enc.ready
}
);
})();

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,6 @@
{
"name": "mozjpeg_enc",
"scripts": {
"install": "napa",
"build": "docker run --rm -v $(pwd):/src trzeci/emscripten-upstream ./build.sh"
},
"napa": {
"mozjpeg": "mozilla/mozjpeg#v3.3.1"
},
"devDependencies": {
"napa": "3.0.0"
"build": "../build-cpp.sh"
}
}

394
codecs/oxipng/Cargo.lock generated
View File

@ -2,501 +2,495 @@
# It is not intended for manual editing.
[[package]]
name = "adler32"
version = "1.0.4"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d"
[[package]]
name = "autocfg"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "bit-vec"
version = "0.6.1"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "build_const"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
[[package]]
name = "bumpalo"
version = "3.2.1"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
[[package]]
name = "bytemuck"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37fa13df2292ecb479ec23aa06f4507928bef07839be9ef15281411076629431"
[[package]]
name = "byteorder"
version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
[[package]]
name = "cc"
version = "1.0.50"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cloudflare-zlib"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5ed63a019d55bacd15cadcbcb96bf41b16281417fff393bdb55fa84255fe4b9"
dependencies = [
"cloudflare-zlib-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cloudflare-zlib-sys",
]
[[package]]
name = "cloudflare-zlib-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e195cb274a0d6ee87e718838a09baecd7cbc9f6075dac256a84cb5842739c06"
dependencies = [
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
"cc",
]
[[package]]
name = "crc"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
dependencies = [
"build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"build_const",
]
[[package]]
name = "crc32fast"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if",
]
[[package]]
name = "crossbeam-deque"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
dependencies = [
"crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-epoch",
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
name = "crossbeam-epoch"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
"cfg-if",
"crossbeam-utils",
"lazy_static",
"maybe-uninit",
"memoffset",
"scopeguard",
]
[[package]]
name = "crossbeam-queue"
version = "0.2.1"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if",
"crossbeam-utils",
"maybe-uninit",
]
[[package]]
name = "crossbeam-utils"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]]
name = "deflate"
version = "0.8.3"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174"
dependencies = [
"adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"adler32",
"byteorder",
]
[[package]]
name = "either"
version = "1.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
[[package]]
name = "hermit-abi"
version = "0.1.10"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9"
dependencies = [
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
"libc",
]
[[package]]
name = "image"
version = "0.23.2"
version = "0.23.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2397fc43bd5648b7117aabb3c5e62d0e62c194826ec77b0b4d0c41e62744635"
dependencies = [
"bytemuck 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"num-iter 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"png 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bytemuck",
"byteorder",
"num-iter",
"num-rational",
"num-traits",
"png",
]
[[package]]
name = "indexmap"
version = "1.3.2"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "inflate"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
"rayon",
]
[[package]]
name = "itertools"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"either",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.68"
version = "0.2.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
[[package]]
name = "libdeflater"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66dca08b13369865b2f6dca1dd05f833985cbe6c12a676b04d55f78b85e80246"
dependencies = [
"cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
"cc",
]
[[package]]
name = "log"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if",
]
[[package]]
name = "maybe-uninit"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
[[package]]
name = "memoffset"
version = "0.5.4"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c198b026e1bbf08a937e94c6c60f9ec4a2267f5b0d2eec9c1b21b061ce2be55f"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
]
[[package]]
name = "miniz_oxide"
version = "0.3.6"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435"
dependencies = [
"adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"adler32",
]
[[package]]
name = "num-integer"
version = "0.1.42"
version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.40"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.2.4"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a5b4d7360f362cfb50dde8143501e6940b22f644be75a4cc90b2d81968908138"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
dependencies = [
"autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
]
[[package]]
name = "num_cpus"
version = "1.12.0"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
dependencies = [
"hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
"hermit-abi",
"libc",
]
[[package]]
name = "oxipng"
version = "0.1.0"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5fd695858078338d73862ff3755f820eff0bf4f3304e4b52f22aba53463183a"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"oxipng 2.3.0 (git+https://github.com/shssoichiro/oxipng.git)",
"wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "oxipng"
version = "2.3.0"
source = "git+https://github.com/shssoichiro/oxipng.git#ec8ecf5a800dfb41359d9cf41eed8a730062b9a8"
dependencies = [
"bit-vec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"cloudflare-zlib 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"image 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libdeflater 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rgb 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)",
"zopfli 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bit-vec",
"byteorder",
"cloudflare-zlib",
"crc",
"image",
"indexmap",
"itertools",
"libdeflater",
"log",
"miniz_oxide",
"rgb",
"zopfli",
]
[[package]]
name = "png"
version = "0.16.1"
version = "0.16.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c150bf7479fafe3dd8740dbe48cc33b2a3efb7b0fe3483aced8bbc39f6d0238d"
dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"deflate 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
"inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags",
"crc32fast",
"deflate",
"miniz_oxide",
]
[[package]]
name = "proc-macro2"
version = "1.0.10"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
dependencies = [
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.3"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
]
[[package]]
name = "rayon"
version = "1.3.0"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080"
dependencies = [
"crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"autocfg",
"crossbeam-deque",
"either",
"rayon-core",
]
[[package]]
name = "rayon-core"
version = "1.7.0"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280"
dependencies = [
"crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-deque",
"crossbeam-queue",
"crossbeam-utils",
"lazy_static",
"num_cpus",
]
[[package]]
name = "rgb"
version = "0.8.17"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90ef54b45ae131327a88597e2463fee4098ad6c88ba7b6af4b3987db8aad4098"
dependencies = [
"bytemuck",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "squoosh-oxipng"
version = "0.1.0"
dependencies = [
"log",
"oxipng",
"wasm-bindgen",
]
[[package]]
name = "syn"
version = "1.0.17"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b"
dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "typed-arena"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
[[package]]
name = "unicode-xid"
version = "0.2.0"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "wasm-bindgen"
version = "0.2.60"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.60"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df"
dependencies = [
"bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"bumpalo",
"lazy_static",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.60"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8"
dependencies = [
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.60"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75"
dependencies = [
"proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.60"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae"
[[package]]
name = "zopfli"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4079b79464426ade2a1b0177fb0ce8396ba6b4084267407e333573c666073964"
dependencies = [
"adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"typed-arena 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"adler32",
"byteorder",
"crc",
"typed-arena",
]
[metadata]
"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
"checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
"checksum bit-vec 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a4523a10839ffae575fb08aa3423026c8cb4687eef43952afb956229d4f246f7"
"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
"checksum bumpalo 3.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "12ae9db68ad7fac5fe51304d20f016c911539251075a214f8e663babefa35187"
"checksum bytemuck 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37fa13df2292ecb479ec23aa06f4507928bef07839be9ef15281411076629431"
"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum cloudflare-zlib 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f5ed63a019d55bacd15cadcbcb96bf41b16281417fff393bdb55fa84255fe4b9"
"checksum cloudflare-zlib-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e195cb274a0d6ee87e718838a09baecd7cbc9f6075dac256a84cb5842739c06"
"checksum crc 1.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d663548de7f5cca343f1e0a48d14dcfb0e9eb4e079ec58883b7251539fa10aeb"
"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
"checksum crossbeam-deque 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
"checksum crossbeam-epoch 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
"checksum crossbeam-queue 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c695eeca1e7173472a32221542ae469b3e9aac3a4fc81f7696bcad82029493db"
"checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
"checksum deflate 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "050ef6de42a33903b30a7497b76b40d3d58691d4d3eec355348c122444a388f0"
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
"checksum hermit-abi 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
"checksum image 0.23.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9062b90712d25bc6bb165d110aa59c6b47c849246e341e7b86a98daff9d49f60"
"checksum indexmap 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "076f042c5b7b98f31d205f1249267e12a6518c1481e9dae9764af19b707d2292"
"checksum inflate 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
"checksum itertools 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
"checksum libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)" = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0"
"checksum libdeflater 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "66dca08b13369865b2f6dca1dd05f833985cbe6c12a676b04d55f78b85e80246"
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
"checksum memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8"
"checksum miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5"
"checksum num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba"
"checksum num-iter 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00"
"checksum num-rational 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
"checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
"checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6"
"checksum oxipng 2.3.0 (git+https://github.com/shssoichiro/oxipng.git)" = "<none>"
"checksum png 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "46060468187c21c00ffa2a920690b29997d7fd543f5a4d400461e4a7d4fccde8"
"checksum proc-macro2 1.0.10 (registry+https://github.com/rust-lang/crates.io-index)" = "df246d292ff63439fea9bc8c0a270bed0e390d5ebd4db4ba15aba81111b5abe3"
"checksum quote 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2bdc6c187c65bca4260c9011c9e3132efe4909da44726bad24cf7572ae338d7f"
"checksum rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db6ce3297f9c85e16621bb8cca38a06779ffc31bb8184e1be4bed2be4678a098"
"checksum rayon-core 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "08a89b46efaf957e52b18062fb2f4660f8b8a4dde1807ca002690868ef2c85a9"
"checksum rgb 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "a85b83fd629b0ce765f45316774fa6aaa95947fd74c8e4bbf3c6d1e349701d95"
"checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
"checksum syn 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03"
"checksum typed-arena 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9b2228007eba4120145f785df0f6c92ea538f5a3635a612ecf4e334c8c1446d"
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum wasm-bindgen 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "2cc57ce05287f8376e998cbddfb4c8cb43b84a7ec55cf4551d7c00eef317a47f"
"checksum wasm-bindgen-backend 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d967d37bf6c16cca2973ca3af071d0a2523392e4a594548155d89a678f4237cd"
"checksum wasm-bindgen-macro 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "8bd151b63e1ea881bb742cd20e1d6127cef28399558f3b5d415289bc41eee3a4"
"checksum wasm-bindgen-macro-support 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "d68a5b36eef1be7868f668632863292e37739656a80fc4b9acec7b0bd35a4931"
"checksum wasm-bindgen-shared 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)" = "daf76fe7d25ac79748a37538b7daeed1c7a6867c92d3245c12c6222e4a20d639"
"checksum zopfli 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4079b79464426ade2a1b0177fb0ce8396ba6b4084267407e333573c666073964"

View File

@ -1,5 +1,5 @@
[package]
name = "oxipng"
name = "squoosh-oxipng"
version = "0.1.0"
authors = ["Ingvar Stepanyan <me@rreverser.com>"]
edition = "2018"
@ -9,13 +9,10 @@ publish = false
crate-type = ["cdylib"]
[dependencies]
oxipng = { version = "2.3.0", default-features = false }
wasm-bindgen = "0.2.48"
oxipng = { version = "3.0.0", default-features = false }
wasm-bindgen = "0.2.64"
log = { version = "0.4", features = ["release_max_level_off"] }
[profile.release]
lto = true
opt-level = "s"
[patch.crates-io]
oxipng = { git = "https://github.com/shssoichiro/oxipng.git", branch = "master" }

View File

@ -3,10 +3,10 @@ RUN rustup target add wasm32-unknown-unknown
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN mkdir /opt/wabt && \
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.11/wabt-1.0.11-linux.tar.gz | tar -xzf - -C /opt/wabt --strip 1
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.17/wabt-1.0.17-ubuntu.tar.gz | tar -xzf - -C /opt/wabt --strip 1
RUN mkdir /opt/wasi-sdk && \
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-8/wasi-sdk-8.0-linux.tar.gz | tar -xzf - -C /opt/wasi-sdk --strip 1
curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-linux.tar.gz | tar -xzf - -C /opt/wasi-sdk --strip 1
ENV PATH="/opt/wabt:/opt/wasi-sdk/bin:${PATH}"
ENV PATH="/opt/wabt/bin:/opt/wasi-sdk/bin:${PATH}"
WORKDIR /src

View File

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2016 Joshua Holmer
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
codecs/oxipng/README.md Normal file
View File

@ -0,0 +1,5 @@
# OxiPNG
- Source: <https://github.com/shssoichiro/oxipng>
- Version: v3.0.0
- License: MIT

View File

@ -1,22 +0,0 @@
#!/bin/bash
set -e
echo "============================================="
echo "Compiling wasm"
echo "============================================="
(
wasm-pack build
wasm-strip pkg/oxipng_bg.wasm
rm pkg/.gitignore
)
echo "============================================="
echo "Compiling wasm done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull ubuntu\`"
echo "Run \`docker pull rust\`"
echo "Run \`docker build -t squoosh-oxipng .\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@ -1,7 +1,6 @@
{
"name": "oxipng",
"scripts": {
"build:image": "docker build -t squoosh-oxipng .",
"build": "docker run --rm -v $(pwd):/src squoosh-oxipng ./build.sh"
"build": "../build-rust.sh"
}
}

Binary file not shown.

View File

@ -1,15 +1,15 @@
{
"name": "oxipng",
"name": "squoosh-oxipng",
"collaborators": [
"Ingvar Stepanyan <me@rreverser.com>"
],
"version": "0.1.0",
"files": [
"oxipng_bg.wasm",
"oxipng.js",
"oxipng.d.ts"
"squoosh_oxipng_bg.wasm",
"squoosh_oxipng.js",
"squoosh_oxipng.d.ts"
],
"module": "oxipng.js",
"types": "oxipng.d.ts",
"module": "squoosh_oxipng.js",
"types": "squoosh_oxipng.d.ts",
"sideEffects": false
}

View File

@ -0,0 +1,2 @@
import * as wasm from "./squoosh_oxipng_bg.wasm";
export * from "./squoosh_oxipng_bg.js";

View File

@ -1,6 +1,6 @@
import * as wasm from './oxipng_bg.wasm';
import * as wasm from './squoosh_oxipng_bg.wasm';
const lTextDecoder = typeof TextDecoder === 'undefined' ? require('util').TextDecoder : TextDecoder;
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });

Binary file not shown.

View File

@ -1,10 +1,18 @@
mod malloc_shim;
use wasm_bindgen::prelude::*;
use oxipng::AlphaOptim;
#[wasm_bindgen(catch)]
pub fn optimise(data: &[u8], level: u8) -> Vec<u8> {
let mut options = oxipng::Options::from_preset(level);
options.alphas.insert(AlphaOptim::Black);
options.alphas.insert(AlphaOptim::White);
options.alphas.insert(AlphaOptim::Up);
options.alphas.insert(AlphaOptim::Down);
options.alphas.insert(AlphaOptim::Left);
options.alphas.insert(AlphaOptim::Right);
options.deflate = oxipng::Deflaters::Libdeflater;
oxipng::optimize_from_memory(data, &options).unwrap_throw()
}

View File

@ -1,6 +1,5 @@
**/*.rs.bk
target
Cargo.lock
bin/
pkg/README.md
lut.inc

284
codecs/resize/Cargo.lock generated Normal file
View File

@ -0,0 +1,284 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "bumpalo"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e8c087f005730276d1096a652e92a8bacee2e2472bcc9715a74d2bec38b5820"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "console_error_panic_hook"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8d976903543e0c48546a91908f21588a680a8c8f984df9a5d69feccb2b2a211"
dependencies = [
"cfg-if",
"wasm-bindgen",
]
[[package]]
name = "futures"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef"
[[package]]
name = "js-sys"
version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4b9172132a62451e56142bff9afc91c8e4a4500aa5b847da36815b63bfda916"
dependencies = [
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
[[package]]
name = "log"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
dependencies = [
"cfg-if",
]
[[package]]
name = "memory_units"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
[[package]]
name = "proc-macro2"
version = "0.4.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
dependencies = [
"unicode-xid 0.1.0",
]
[[package]]
name = "proc-macro2"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa"
dependencies = [
"unicode-xid 0.2.1",
]
[[package]]
name = "quote"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
dependencies = [
"proc-macro2 0.4.30",
]
[[package]]
name = "quote"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
dependencies = [
"proc-macro2 1.0.18",
]
[[package]]
name = "resize"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e653e390eafbfebb2b3c5fcfbc90d801bc410d0de1f44f266ffbf2151d28aa"
[[package]]
name = "scoped-tls"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "squoosh-resize"
version = "0.1.0"
dependencies = [
"cfg-if",
"console_error_panic_hook",
"resize",
"wasm-bindgen",
"wasm-bindgen-test",
"wee_alloc",
]
[[package]]
name = "syn"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "936cae2873c940d92e697597c5eee105fb570cd5689c695806f672883653349b"
dependencies = [
"proc-macro2 1.0.18",
"quote 1.0.7",
"unicode-xid 0.2.1",
]
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "wasm-bindgen"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a634620115e4a229108b71bde263bb4220c483b3f07f5ba514ee8d15064c4c2"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e53963b583d18a5aa3aaae4b4c1cb535218246131ba22a71f05b518098571df"
dependencies = [
"bumpalo",
"lazy_static",
"log",
"proc-macro2 1.0.18",
"quote 1.0.7",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-futures"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83420b37346c311b9ed822af41ec2e82839bfe99867ec6c54e2da43b7538771c"
dependencies = [
"cfg-if",
"futures",
"js-sys",
"wasm-bindgen",
"web-sys",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fcfd5ef6eec85623b4c6e844293d4516470d8f19cd72d0d12246017eb9060b8"
dependencies = [
"quote 1.0.7",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9adff9ee0e94b926ca81b57f57f86d5545cdcb1d259e21ec9bdd95b901754c75"
dependencies = [
"proc-macro2 1.0.18",
"quote 1.0.7",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7b90ea6c632dd06fd765d44542e234d5e63d9bb917ecd64d79778a13bd79ae"
[[package]]
name = "wasm-bindgen-test"
version = "0.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2d9693b63a742d481c7f80587e057920e568317b2806988c59cd71618bc26c1"
dependencies = [
"console_error_panic_hook",
"futures",
"js-sys",
"scoped-tls",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test-macro",
]
[[package]]
name = "wasm-bindgen-test-macro"
version = "0.2.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0789dac148a8840bbcf9efe13905463b733fa96543bfbf263790535c11af7ba5"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
]
[[package]]
name = "web-sys"
version = "0.3.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "863539788676619aac1a23e2df3655e96b32b0e05eb72ca34ba045ad573c625d"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "wee_alloc"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
dependencies = [
"cfg-if",
"libc",
"memory_units",
"winapi",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View File

@ -1,7 +1,8 @@
[package]
name = "resize"
name = "squoosh-resize"
version = "0.1.0"
authors = ["Surma <surma@surma.link>"]
publish = false
[lib]
#crate-type = ["cdylib", "rlib"]

View File

@ -1,9 +0,0 @@
FROM rust
RUN rustup target add wasm32-unknown-unknown
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN mkdir /opt/wabt && \
curl -L https://github.com/WebAssembly/wabt/releases/download/1.0.11/wabt-1.0.11-linux.tar.gz | tar -xzf - -C /opt/wabt --strip 1
ENV PATH="/opt/wabt:${PATH}"
WORKDIR /src

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 PistonDevelopers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
codecs/resize/README.md Normal file
View File

@ -0,0 +1,5 @@
# Resize
- Source: <https://github.com/PistonDevelopers/resize>
- Version: v0.3.0
- License: MIT

View File

@ -1,22 +0,0 @@
#!/bin/bash
set -e
echo "============================================="
echo "Compiling wasm"
echo "============================================="
(
wasm-pack build
wasm-strip pkg/resize_bg.wasm
rm pkg/.gitignore
)
echo "============================================="
echo "Compiling wasm done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull ubuntu\`"
echo "Run \`docker pull rust\`"
echo "Run \`docker build -t squoosh-resize .\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

View File

@ -1,7 +1,6 @@
{
"name": "resize",
"scripts": {
"build:image": "docker build -t squoosh-resize .",
"build": "docker run --rm -v $(pwd):/src squoosh-resize ./build.sh"
"build": "../build-rust.sh"
}
}

View File

@ -1,15 +1,15 @@
{
"name": "resize",
"name": "squoosh-resize",
"collaborators": [
"Surma <surma@surma.link>"
],
"version": "0.1.0",
"files": [
"resize_bg.wasm",
"resize.js",
"resize.d.ts"
"squoosh_resize_bg.wasm",
"squoosh_resize.js",
"squoosh_resize.d.ts"
],
"module": "resize.js",
"types": "resize.d.ts",
"sideEffects": "false"
"module": "squoosh_resize.js",
"types": "squoosh_resize.d.ts",
"sideEffects": false
}

View File

@ -1,13 +0,0 @@
/* tslint:disable */
/**
* @param {Uint8Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} output_width
* @param {number} output_height
* @param {number} typ_idx
* @param {boolean} premultiply
* @param {boolean} color_space_conversion
* @returns {Uint8Array}
*/
export function resize(input_image: Uint8Array, input_width: number, input_height: number, output_width: number, output_height: number, typ_idx: number, premultiply: boolean, color_space_conversion: boolean): Uint8Array;

View File

@ -1,50 +0,0 @@
import * as wasm from './resize_bg.wasm';
let cachegetUint8Memory = null;
function getUint8Memory() {
if (cachegetUint8Memory === null || cachegetUint8Memory.buffer !== wasm.memory.buffer) {
cachegetUint8Memory = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory;
}
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm(arg) {
const ptr = wasm.__wbindgen_malloc(arg.length * 1);
getUint8Memory().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachegetInt32Memory = null;
function getInt32Memory() {
if (cachegetInt32Memory === null || cachegetInt32Memory.buffer !== wasm.memory.buffer) {
cachegetInt32Memory = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory;
}
function getArrayU8FromWasm(ptr, len) {
return getUint8Memory().subarray(ptr / 1, ptr / 1 + len);
}
/**
* @param {Uint8Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} output_width
* @param {number} output_height
* @param {number} typ_idx
* @param {boolean} premultiply
* @param {boolean} color_space_conversion
* @returns {Uint8Array}
*/
export function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {
const retptr = 8;
const ret = wasm.resize(retptr, passArray8ToWasm(input_image), WASM_VECTOR_LEN, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion);
const memi32 = getInt32Memory();
const v0 = getArrayU8FromWasm(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1]).slice();
wasm.__wbindgen_free(memi32[retptr / 4 + 0], memi32[retptr / 4 + 1] * 1);
return v0;
}

Binary file not shown.

14
codecs/resize/pkg/squoosh_resize.d.ts vendored Normal file
View File

@ -0,0 +1,14 @@
/* tslint:disable */
/* eslint-disable */
/**
* @param {Uint8Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} output_width
* @param {number} output_height
* @param {number} typ_idx
* @param {boolean} premultiply
* @param {boolean} color_space_conversion
* @returns {Uint8Array}
*/
export function resize(input_image: Uint8Array, input_width: number, input_height: number, output_width: number, output_height: number, typ_idx: number, premultiply: boolean, color_space_conversion: boolean): Uint8Array;

View File

@ -0,0 +1,2 @@
import * as wasm from "./squoosh_resize_bg.wasm";
export * from "./squoosh_resize_bg.js";

View File

@ -1,5 +1,6 @@
/* tslint:disable */
/* eslint-disable */
export const memory: WebAssembly.Memory;
export function resize(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void;
export function __wbindgen_malloc(a: number): number;
export function __wbindgen_free(a: number, b: number): void;
export function resize(a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number): void;

View File

@ -0,0 +1,52 @@
import * as wasm from './squoosh_resize_bg.wasm';
let cachegetUint8Memory0 = null;
function getUint8Memory0() {
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
}
return cachegetUint8Memory0;
}
let WASM_VECTOR_LEN = 0;
function passArray8ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 1);
getUint8Memory0().set(arg, ptr / 1);
WASM_VECTOR_LEN = arg.length;
return ptr;
}
let cachegetInt32Memory0 = null;
function getInt32Memory0() {
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
}
return cachegetInt32Memory0;
}
function getArrayU8FromWasm0(ptr, len) {
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
}
/**
* @param {Uint8Array} input_image
* @param {number} input_width
* @param {number} input_height
* @param {number} output_width
* @param {number} output_height
* @param {number} typ_idx
* @param {boolean} premultiply
* @param {boolean} color_space_conversion
* @returns {Uint8Array}
*/
export function resize(input_image, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion) {
var ptr0 = passArray8ToWasm0(input_image, wasm.__wbindgen_malloc);
var len0 = WASM_VECTOR_LEN;
wasm.resize(8, ptr0, len0, input_width, input_height, output_width, output_height, typ_idx, premultiply, color_space_conversion);
var r0 = getInt32Memory0()[8 / 4 + 0];
var r1 = getInt32Memory0()[8 / 4 + 1];
var v1 = getArrayU8FromWasm0(r0, r1).slice();
wasm.__wbindgen_free(r0, r1 * 1);
return v1;
}

Binary file not shown.

View File

@ -48,7 +48,7 @@ fn alpha_multiplier_funcs(
if with_alpha_premultiplication {
(
|v, a| (v * (a as f32) / 255.0) as u8,
|v, a| (v as f32) * 255.0 / (a as f32).clamp(0.0, 255.0),
|v, a| ((v as f32) * 255.0 / (a as f32)).clamp(0.0, 255.0),
)
} else {
(|v, _a| v as u8, |v, _a| v as f32)

View File

@ -1,2 +1 @@
target
Cargo.lock

6
codecs/rotate/Cargo.lock generated Normal file
View File

@ -0,0 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "squoosh-rotate"
version = "0.1.0"

View File

@ -1,8 +1,9 @@
[package]
name = "rotate"
name = "squoosh-rotate"
version = "0.1.0"
authors = ["Surma <surma@google.com>"]
edition = "2018"
publish = false
[lib]
name = "rotate"

View File

@ -1,24 +1,8 @@
#!/bin/bash
#!/bin/sh
set -e
echo "============================================="
echo "Compiling wasm"
echo "============================================="
(
cargo build \
--target wasm32-unknown-unknown \
--release
cp target/wasm32-unknown-unknown/release/rotate.wasm .
wasm-strip rotate.wasm
)
echo "============================================="
echo "Compiling wasm done"
echo "============================================="
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "Did you update your docker image?"
echo "Run \`docker pull ubuntu\`"
echo "Run \`docker pull rust\`"
echo "Run \`docker build -t squoosh-rotate .\`"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
cargo build \
--target wasm32-unknown-unknown \
--release
wasm-opt -Os --strip target/wasm32-unknown-unknown/release/rotate.wasm -o rotate.wasm

View File

@ -1,8 +1,7 @@
{
"name": "rotate",
"scripts": {
"build:image": "docker build -t squoosh-rotate .",
"build": "docker run --rm -v $(pwd):/src squoosh-rotate ./build.sh",
"build": "../build-rust.sh ./build.sh",
"benchmark": "echo File size after gzip && npm run benchmark:filesize && echo Optimizing && npm run -s benchmark:optimizing",
"benchmark:baseline": "v8 --liftoff --no-wasm-tier-up --no-opt ./benchmark.js",
"benchmark:optimizing": "v8 --no-liftoff --no-wasm-tier-up ./benchmark.js",

Binary file not shown.

15
codecs/rust.Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM emscripten/emsdk:1.39.19 AS wasm-tools
WORKDIR /opt/wasm-tools
RUN wget -qO- https://github.com/rustwasm/wasm-pack/releases/download/v0.9.1/wasm-pack-v0.9.1-x86_64-unknown-linux-musl.tar.gz | tar -xzf - --strip 1
FROM rust:1.44-stretch AS rust
RUN rustup target add wasm32-unknown-unknown
COPY --from=wasm-tools /emsdk/upstream/bin/wasm-opt /emsdk/upstream/bin/clang /usr/local/bin/
COPY --from=wasm-tools /emsdk/upstream/lib/ /usr/local/lib/
COPY --from=wasm-tools /emsdk/upstream/emscripten/system/include/libc/ /wasm32/include/
COPY --from=wasm-tools /emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten/bits/ /wasm32/include/bits/
COPY --from=wasm-tools /opt/wasm-tools/wasm-pack /usr/local/cargo/bin/
ENV CPATH="/wasm32/include"
WORKDIR /src
CMD ["sh", "-c", "rm -rf pkg && wasm-pack build -- --verbose --locked && rm pkg/.gitignore"]

View File

@ -0,0 +1,29 @@
Copyright (c) 2010, Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name of Google nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

56
codecs/webp/Makefile Normal file
View File

@ -0,0 +1,56 @@
CODEC_URL := https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz
CODEC_DIR = node_modules/libwebp
CODEC_OUT_RELATIVE = src/.libs/libwebp.a
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
OUT_JS = enc/webp_enc.js dec/webp_dec.js
OUT_WASM = $(OUT_JS:.js=.wasm)
.PHONY: all clean
all: $(OUT_JS)
%.js: %.cpp $(CODEC_OUT)
$(CXX) \
-I $(CODEC_DIR) \
${CXXFLAGS} \
${LDFLAGS} \
--bind \
--closure 1 \
-s ALLOW_MEMORY_GROWTH=1 \
-s MODULARIZE=1 \
-s 'EXPORT_NAME="$(basename $(@F))"' \
-o $@ \
$+
$(CODEC_OUT): $(CODEC_DIR)/src/Makefile
$(MAKE) -C $(CODEC_DIR)/src
$(CODEC_DIR)/src/Makefile: $(CODEC_DIR)/configure
cd $(CODEC_DIR) && ./configure \
--disable-shared \
--disable-libwebpdemux \
--disable-wic \
--disable-gif \
--disable-tiff \
--disable-jpeg \
--disable-png \
--disable-sdl \
--disable-gl \
--disable-threading \
--disable-neon-rtcd \
--disable-neon \
--disable-sse2 \
--disable-sse4.1
$(CODEC_DIR)/configure: $(CODEC_DIR)/configure.ac
cd $(CODEC_DIR) && autoreconf -iv
$(CODEC_DIR)/configure.ac: $(CODEC_DIR)
$(CODEC_DIR):
mkdir -p $@
curl -sL $(CODEC_URL) | tar xz --strip 1 -C $@
clean:
$(RM) $(OUT_JS) $(OUT_WASM)
$(MAKE) -C $(CODEC_DIR) clean

5
codecs/webp/README.md Normal file
View File

@ -0,0 +1,5 @@
# WebP
- Source: https://github.com/webmproject/libwebp
- Version: v1.0.2
- License: BSD

View File

@ -16,7 +16,3 @@ Returns the version of libwebp as a number. va.b.c is encoded as 0x0a0b0c
### `RawImage decode(std::string buffer)`
Decodes the given webp buffer into raw RGBA. `RawImage` is a class with 3 fields: `buffer`, `width`, and `height`.
### `void free_result()`
Frees the result created by `decode()`.

View File

@ -10,10 +10,8 @@
Module.onRuntimeInitialized = async _ => {
console.log('Version:', Module.version().toString(16));
const image = await loadFile('../example.webp');
const result = Module.decode(image);
const imageData = new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height);
Module.free_result();
const image = await loadFile('../../example.webp');
const imageData = Module.decode(image);
const canvas = document.createElement('canvas');
canvas.width = result.width;
canvas.height = result.height;

View File

@ -0,0 +1,26 @@
#include <string>
#include "emscripten/bind.h"
#include "emscripten/val.h"
#include "src/webp/decode.h"
#include "src/webp/demux.h"
using namespace emscripten;
int version() {
return WebPGetDecoderVersion();
}
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
thread_local const val ImageData = val::global("ImageData");
val decode(std::string buffer) {
int width, height;
std::unique_ptr<uint8_t[]> rgba(
WebPDecodeRGBA((const uint8_t*)buffer.c_str(), buffer.size(), &width, &height));
return rgba ? ImageData.new_(Uint8ClampedArray.new_(typed_memory_view(width * height * 4, rgba.get())), width, height) : val::null();
}
EMSCRIPTEN_BINDINGS(my_module) {
function("decode", &decode);
function("version", &version);
}

5
codecs/webp/dec/webp_dec.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
interface WebPModule extends EmscriptenWasm.Module {
decode(data: BufferSource): ImageData | null;
}
export default function(opts: EmscriptenWasm.ModuleOpts): WebPModule;

View File

@ -0,0 +1,67 @@
var webp_dec = (function() {
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
return (
function(webp_dec) {
webp_dec = webp_dec || {};
var d;d||(d=typeof webp_dec !== 'undefined' ? webp_dec : {});var aa,ba;d.ready=new Promise(function(a,b){aa=a;ba=b});var t={},u;for(u in d)d.hasOwnProperty(u)&&(t[u]=d[u]);var v=!1,w=!1,ca=!1,da=!1;v="object"===typeof window;w="function"===typeof importScripts;ca="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;da=!v&&!ca&&!w;var x="",z,A,ea,fa;
if(ca)x=w?require("path").dirname(x)+"/":__dirname+"/",z=function(a,b){ea||(ea=require("fs"));fa||(fa=require("path"));a=fa.normalize(a);return ea.readFileSync(a,b?null:"utf8")},A=function(a){a=z(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||B("Assertion failed: undefined");return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",B),d.inspect=function(){return"[Emscripten Module object]"};
else if(da)"undefined"!=typeof read&&(z=function(a){return read(a)}),A=function(a){if("function"===typeof readbuffer)return new Uint8Array(readbuffer(a));a=read(a,"binary");"object"===typeof a||B("Assertion failed: undefined");return a},"undefined"!==typeof print&&("undefined"===typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!==typeof printErr?printErr:print);else if(v||w)w?x=self.location.href:document.currentScript&&(x=document.currentScript.src),_scriptDir&&
(x=_scriptDir),0!==x.indexOf("blob:")?x=x.substr(0,x.lastIndexOf("/")+1):x="",z=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},w&&(A=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});d.print||console.log.bind(console);var C=d.printErr||console.warn.bind(console);for(u in t)t.hasOwnProperty(u)&&(d[u]=t[u]);t=null;var D;d.wasmBinary&&(D=d.wasmBinary);var noExitRuntime;
d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&B("no native wasm support detected");var E,ha=new WebAssembly.Table({initial:130,maximum:130,element:"anyfunc"}),ia=!1,ja="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
function ka(a,b,c){var e=F;if(0<c){c=b+c-1;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var n=a.charCodeAt(++f);g=65536+((g&1023)<<10)|n&1023}if(127>=g){if(b>=c)break;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var la="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
function ma(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&G[c];)++c;c<<=1;if(32<c-a&&la)return la.decode(F.subarray(a,c));c=0;for(e="";;){var f=H[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function na(a,b,c){void 0===c&&(c=2147483647);if(2>c)return 0;c-=2;var e=b;c=c<2*a.length?c/2:a.length;for(var f=0;f<c;++f)H[b>>1]=a.charCodeAt(f),b+=2;H[b>>1]=0;return b-e}function oa(a){return 2*a.length}
function pa(a,b){for(var c=0,e="";!(c>=b/4);){var f=I[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,e+=String.fromCharCode(55296|f>>10,56320|f&1023)):e+=String.fromCharCode(f)}return e}function qa(a,b,c){void 0===c&&(c=2147483647);if(4>c)return 0;var e=b;c=e+c-4;for(var f=0;f<a.length;++f){var g=a.charCodeAt(f);if(55296<=g&&57343>=g){var n=a.charCodeAt(++f);g=65536+((g&1023)<<10)|n&1023}I[b>>2]=g;b+=4;if(b+4>c)break}I[b>>2]=0;return b-e}
function ra(a){for(var b=0,c=0;c<a.length;++c){var e=a.charCodeAt(c);55296<=e&&57343>=e&&++c;b+=4}return b}var J,sa,F,H,G,I,L,ta,ua;function va(a){J=a;d.HEAP8=sa=new Int8Array(a);d.HEAP16=H=new Int16Array(a);d.HEAP32=I=new Int32Array(a);d.HEAPU8=F=new Uint8Array(a);d.HEAPU16=G=new Uint16Array(a);d.HEAPU32=L=new Uint32Array(a);d.HEAPF32=ta=new Float32Array(a);d.HEAPF64=ua=new Float64Array(a)}var wa=d.INITIAL_MEMORY||16777216;d.wasmMemory?E=d.wasmMemory:E=new WebAssembly.Memory({initial:wa/65536,maximum:32768});
E&&(J=E.buffer);wa=J.byteLength;va(J);I[3260]=5256080;function M(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.P;"number"===typeof c?void 0===b.L?d.dynCall_v(c):d.dynCall_vi(c,b.L):c(void 0===b.L?null:b.L)}}}var xa=[],ya=[],za=[],Aa=[];function Ba(){var a=d.preRun.shift();xa.unshift(a)}var N=0,Ca=null,P=null;d.preloadedImages={};d.preloadedAudios={};
function B(a){if(d.onAbort)d.onAbort(a);C(a);ia=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Da(a){var b=Q;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ea(){return Da("data:application/octet-stream;base64,")}var Q="webp_dec.wasm";if(!Ea()){var Fa=Q;Q=d.locateFile?d.locateFile(Fa,x):x+Fa}
function Ga(){try{if(D)return new Uint8Array(D);if(A)return A(Q);throw"both async and sync fetching of the wasm failed";}catch(a){B(a)}}function Ha(){return D||!v&&!w||"function"!==typeof fetch||Da("file://")?new Promise(function(a){a(Ga())}):fetch(Q,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+Q+"'";return a.arrayBuffer()}).catch(function(){return Ga()})}ya.push({P:function(){Ia()}});function R(){return 0<R.N}
function Ja(a){switch(a){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+a);}}var Ka=void 0;function S(a){for(var b="";F[a];)b+=Ka[F[a++]];return b}var T={},U={},V={};function La(a){if(void 0===a)return"_unknown";a=a.replace(/[^a-zA-Z0-9_]/g,"$");var b=a.charCodeAt(0);return 48<=b&&57>=b?"_"+a:a}
function Ma(a,b){a=La(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Na(a){var b=Error,c=Ma(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c}
var Oa=void 0;function W(a){throw new Oa(a);}var Pa=void 0;function Qa(a,b){function c(k){k=b(k);if(k.length!==e.length)throw new Pa("Mismatched type converter count");for(var h=0;h<e.length;++h)X(e[h],k[h])}var e=[];e.forEach(function(k){V[k]=a});var f=Array(a.length),g=[],n=0;a.forEach(function(k,h){U.hasOwnProperty(k)?f[h]=U[k]:(g.push(k),T.hasOwnProperty(k)||(T[k]=[]),T[k].push(function(){f[h]=U[k];++n;n===g.length&&c(f)}))});0===g.length&&c(f)}
function X(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var e=b.name;a||W('type "'+e+'" must have a positive integer typeid pointer');if(U.hasOwnProperty(a)){if(c.R)return;W("Cannot register type '"+e+"' twice")}U[a]=b;delete V[a];T.hasOwnProperty(a)&&(b=T[a],delete T[a],b.forEach(function(f){f()}))}var Ra=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
function Sa(a){4<a&&0===--Y[a].M&&(Y[a]=void 0,Ra.push(a))}function Ta(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Ra.length?Ra.pop():Y.length;Y[b]={M:1,value:a};return b}}function Wa(a){return this.fromWireType(L[a>>2])}function Xa(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
function Ya(a,b){switch(b){case 2:return function(c){return this.fromWireType(ta[c>>2])};case 3:return function(c){return this.fromWireType(ua[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Za(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Ma(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
function $a(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function ab(a,b){var c=d;if(void 0===c[a].J){var e=c[a];c[a]=function(){c[a].J.hasOwnProperty(arguments.length)||W("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].J+")!");return c[a].J[arguments.length].apply(this,arguments)};c[a].J=[];c[a].J[e.O]=e}}
function bb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].J&&void 0!==d[a].J[c])&&W("Cannot register public name '"+a+"' twice"),ab(a,a),d.hasOwnProperty(c)&&W("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].J[c]=b):(d[a]=b,void 0!==c&&(d[a].T=c))}function cb(a,b){for(var c=[],e=0;e<a;e++)c.push(I[(b>>2)+e]);return c}
function db(a,b){a=S(a);var c=d["dynCall_"+a];for(var e=[],f=1;f<a.length;++f)e.push("a"+f);f="return function dynCall_"+(a+"_"+b)+"("+e.join(", ")+") {\n";f+=" return dynCall(rawFunction"+(e.length?", ":"")+e.join(", ")+");\n";c=(new Function("dynCall","rawFunction",f+"};\n"))(c,b);"function"!==typeof c&&W("unknown function pointer with signature "+a+": "+b);return c}var eb=void 0;function fb(a){a=gb(a);var b=S(a);Z(a);return b}
function hb(a,b){function c(g){f[g]||U[g]||(V[g]?V[g].forEach(c):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(c);throw new eb(a+": "+e.map(fb).join([", "]));}function ib(a,b,c){switch(b){case 0:return c?function(e){return sa[e]}:function(e){return F[e]};case 1:return c?function(e){return H[e>>1]}:function(e){return G[e>>1]};case 2:return c?function(e){return I[e>>2]}:function(e){return L[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var jb={};
function kb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function lb(a,b){var c=U[a];void 0===c&&W(b+" has unknown type "+fb(a));return c}for(var mb={},nb=Array(256),ob=0;256>ob;++ob)nb[ob]=String.fromCharCode(ob);Ka=nb;Oa=d.BindingError=Na("BindingError");Pa=d.InternalError=Na("InternalError");d.count_emval_handles=function(){for(var a=0,b=5;b<Y.length;++b)void 0!==Y[b]&&++a;return a};
d.get_first_emval=function(){for(var a=5;a<Y.length;++a)if(void 0!==Y[a])return Y[a];return null};eb=d.UnboundTypeError=Na("UnboundTypeError");
var qb={m:function(a){return pb(a)},i:function(){},l:function(a){"uncaught_exception"in R?R.N++:R.N=1;throw a;},j:function(a,b,c,e,f){var g=Ja(c);b=S(b);X(a,{name:b,fromWireType:function(n){return!!n},toWireType:function(n,k){return k?e:f},argPackAdvance:8,readValueFromPointer:function(n){if(1===c)var k=sa;else if(2===c)k=H;else if(4===c)k=I;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[n>>g])},K:null})},r:function(a,b){b=S(b);X(a,{name:b,fromWireType:function(c){var e=
Y[c].value;Sa(c);return e},toWireType:function(c,e){return Ta(e)},argPackAdvance:8,readValueFromPointer:Wa,K:null})},g:function(a,b,c){c=Ja(c);b=S(b);X(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+Xa(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Ya(b,c),K:null})},e:function(a,b,c,e,f,g){var n=cb(b,c);a=S(a);f=db(e,f);bb(a,function(){hb("Cannot call "+a+" due to unbound types",
n)},b-1);Qa(n,function(k){var h=[k[0],null].concat(k.slice(1)),p=k=a,q=f,m=h.length;2>m&&W("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var r=null!==h[1]&&!1,y=!1,l=1;l<h.length;++l)if(null!==h[l]&&void 0===h[l].K){y=!0;break}var Ua="void"!==h[0].name,K="",O="";for(l=0;l<m-2;++l)K+=(0!==l?", ":"")+"arg"+l,O+=(0!==l?", ":"")+"arg"+l+"Wired";p="return function "+La(p)+"("+K+") {\nif (arguments.length !== "+(m-2)+") {\nthrowBindingError('function "+p+" called with ' + arguments.length + ' arguments, expected "+
(m-2)+" args!');\n}\n";y&&(p+="var destructors = [];\n");var Va=y?"destructors":"null";K="throwBindingError invoker fn runDestructors retType classParam".split(" ");q=[W,q,g,$a,h[0],h[1]];r&&(p+="var thisWired = classParam.toWireType("+Va+", this);\n");for(l=0;l<m-2;++l)p+="var arg"+l+"Wired = argType"+l+".toWireType("+Va+", arg"+l+"); // "+h[l+2].name+"\n",K.push("argType"+l),q.push(h[l+2]);r&&(O="thisWired"+(0<O.length?", ":"")+O);p+=(Ua?"var rv = ":"")+"invoker(fn"+(0<O.length?", ":"")+O+");\n";
if(y)p+="runDestructors(destructors);\n";else for(l=r?1:2;l<h.length;++l)m=1===l?"thisWired":"arg"+(l-2)+"Wired",null!==h[l].K&&(p+=m+"_dtor("+m+"); // "+h[l].name+"\n",K.push(m+"_dtor"),q.push(h[l].K));Ua&&(p+="var ret = retType.fromWireType(rv);\nreturn ret;\n");K.push(p+"}\n");h=Za(K).apply(null,q);l=b-1;if(!d.hasOwnProperty(k))throw new Pa("Replacing nonexistant public symbol");void 0!==d[k].J&&void 0!==l?d[k].J[l]=h:(d[k]=h,d[k].O=l);return[]})},b:function(a,b,c,e,f){function g(p){return p}b=
S(b);-1===f&&(f=4294967295);var n=Ja(c);if(0===e){var k=32-8*c;g=function(p){return p<<k>>>k}}var h=-1!=b.indexOf("unsigned");X(a,{name:b,fromWireType:g,toWireType:function(p,q){if("number"!==typeof q&&"boolean"!==typeof q)throw new TypeError('Cannot convert "'+Xa(q)+'" to '+this.name);if(q<e||q>f)throw new TypeError('Passing a number "'+Xa(q)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+e+", "+f+"]!");return h?q>>>0:q|0},argPackAdvance:8,readValueFromPointer:ib(b,
n,0!==e),K:null})},a:function(a,b,c){function e(g){g>>=2;var n=L;return new f(J,n[g+1],n[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=S(c);X(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{R:!0})},h:function(a,b){b=S(b);var c="std::string"===b;X(a,{name:b,fromWireType:function(e){var f=L[e>>2];if(c)for(var g=e+4,n=0;n<=f;++n){var k=e+4+n;if(n==f||0==F[k]){if(g){var h=g;var p=F,q=h+(k-g);for(g=h;p[g]&&!(g>=q);)++g;
if(16<g-h&&p.subarray&&ja)h=ja.decode(p.subarray(h,g));else{for(q="";h<g;){var m=p[h++];if(m&128){var r=p[h++]&63;if(192==(m&224))q+=String.fromCharCode((m&31)<<6|r);else{var y=p[h++]&63;m=224==(m&240)?(m&15)<<12|r<<6|y:(m&7)<<18|r<<12|y<<6|p[h++]&63;65536>m?q+=String.fromCharCode(m):(m-=65536,q+=String.fromCharCode(55296|m>>10,56320|m&1023))}}else q+=String.fromCharCode(m)}h=q}}else h="";if(void 0===l)var l=h;else l+=String.fromCharCode(0),l+=h;g=k+1}}else{l=Array(f);for(n=0;n<f;++n)l[n]=String.fromCharCode(F[e+
4+n]);l=l.join("")}Z(e);return l},toWireType:function(e,f){f instanceof ArrayBuffer&&(f=new Uint8Array(f));var g="string"===typeof f;g||f instanceof Uint8Array||f instanceof Uint8ClampedArray||f instanceof Int8Array||W("Cannot pass non-string to std::string");var n=(c&&g?function(){for(var p=0,q=0;q<f.length;++q){var m=f.charCodeAt(q);55296<=m&&57343>=m&&(m=65536+((m&1023)<<10)|f.charCodeAt(++q)&1023);127>=m?++p:p=2047>=m?p+2:65535>=m?p+3:p+4}return p}:function(){return f.length})(),k=pb(4+n+1);L[k>>
2]=n;if(c&&g)ka(f,k+4,n+1);else if(g)for(g=0;g<n;++g){var h=f.charCodeAt(g);255<h&&(Z(k),W("String has UTF-16 code units that do not fit in 8 bits"));F[k+4+g]=h}else for(g=0;g<n;++g)F[k+4+g]=f[g];null!==e&&e.push(Z,k);return k},argPackAdvance:8,readValueFromPointer:Wa,K:function(e){Z(e)}})},d:function(a,b,c){c=S(c);if(2===b){var e=ma;var f=na;var g=oa;var n=function(){return G};var k=1}else 4===b&&(e=pa,f=qa,g=ra,n=function(){return L},k=2);X(a,{name:c,fromWireType:function(h){for(var p=L[h>>2],q=
n(),m,r=h+4,y=0;y<=p;++y){var l=h+4+y*b;if(y==p||0==q[l>>k])r=e(r,l-r),void 0===m?m=r:(m+=String.fromCharCode(0),m+=r),r=l+b}Z(h);return m},toWireType:function(h,p){"string"!==typeof p&&W("Cannot pass non-string to C++ string type "+c);var q=g(p),m=pb(4+q+b);L[m>>2]=q>>k;f(p,m+4,q+b);null!==h&&h.push(Z,m);return m},argPackAdvance:8,readValueFromPointer:Wa,K:function(h){Z(h)}})},k:function(a,b){b=S(b);X(a,{S:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},o:Sa,s:function(a){if(0===
a)return Ta(kb());var b=jb[a];a=void 0===b?S(a):b;return Ta(kb()[a])},n:function(a){4<a&&(Y[a].M+=1)},f:function(a,b,c,e){a||W("Cannot use deleted val. handle = "+a);a=Y[a].value;var f=mb[b];if(!f){f="";for(var g=0;g<b;++g)f+=(0!==g?", ":"")+"arg"+g;var n="return function emval_allocator_"+b+"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)n+="var argType"+g+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+
g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",n+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(lb,d,Ta);mb[b]=f}return f(a,c,e)},q:function(){B()},p:function(a,b,c){F.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=F.length;if(2147483648<a)return!1;for(var c=1;4>=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0<e%65536&&(e+=65536-e%65536);a:{try{E.grow(Math.min(2147483648,e)-J.byteLength+65535>>>
16);va(E.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},memory:E,table:ha};
(function(){function a(f){d.asm=f.exports;N--;d.monitorRunDependencies&&d.monitorRunDependencies(N);0==N&&(null!==Ca&&(clearInterval(Ca),Ca=null),P&&(f=P,P=null,f()))}function b(f){a(f.instance)}function c(f){return Ha().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){C("failed to asynchronously prepare wasm: "+g);B(g)})}var e={a:qb};N++;d.monitorRunDependencies&&d.monitorRunDependencies(N);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return C("Module.instantiateWasm callback failed with error: "+
f),!1}(function(){if(D||"function"!==typeof WebAssembly.instantiateStreaming||Ea()||Da("file://")||"function"!==typeof fetch)return c(b);fetch(Q,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){C("wasm streaming compile failed: "+g);C("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
var Ia=d.___wasm_call_ctors=function(){return(Ia=d.___wasm_call_ctors=d.asm.t).apply(null,arguments)},pb=d._malloc=function(){return(pb=d._malloc=d.asm.u).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.v).apply(null,arguments)},gb=d.___getTypeName=function(){return(gb=d.___getTypeName=d.asm.w).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.x).apply(null,arguments)};
d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.y).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.z).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.A).apply(null,arguments)};d.dynCall_i=function(){return(d.dynCall_i=d.asm.B).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.C).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.D).apply(null,arguments)};
d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.E).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.F).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.G).apply(null,arguments)};d.dynCall_viiiiiiiii=function(){return(d.dynCall_viiiiiiiii=d.asm.H).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.I).apply(null,arguments)};var rb;P=function sb(){rb||tb();rb||(P=sb)};
function tb(){function a(){if(!rb&&(rb=!0,d.calledRun=!0,!ia)){M(ya);M(za);aa(d);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Aa.unshift(b)}M(Aa)}}if(!(0<N)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Ba();M(xa);0<N||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
d.run=tb;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;tb();
return webp_dec.ready
}
);
})();
if (typeof exports === 'object' && typeof module === 'object')
module.exports = webp_dec;
else if (typeof define === 'function' && define['amd'])
define([], function() { return webp_dec; });
else if (typeof exports === 'object')
exports["webp_dec"] = webp_dec;

Some files were not shown because too many files have changed in this diff Show More