Compare commits
120 Commits
Author | SHA1 | Date | |
---|---|---|---|
fc9bd5bf08 | |||
c214a7a942 | |||
06b0136373 | |||
a375a57317 | |||
1e2a54261d | |||
dd7264753c | |||
6dab5e3ce7 | |||
5c8f0739a0 | |||
80f00bc8cf | |||
396808b73d | |||
321996807e | |||
16f0cc3c10 | |||
73e2b60a50 | |||
646f5c983a | |||
5715fb7b1b | |||
cd33a2f759 | |||
ee561bb00e | |||
75275a5596 | |||
8cd811cafd | |||
4e090ea2f8 | |||
6b007a0235 | |||
c23d1091e7 | |||
69bd7331ff | |||
245527ae0f | |||
f0173012c0 | |||
37acb149a0 | |||
2c923e5239 | |||
fe52c9b307 | |||
3745a3fff1 | |||
d89e846896 | |||
db6dea846a | |||
8036579a3c | |||
0807fa4b9a | |||
3cda8285a1 | |||
0218d0aac5 | |||
cfba6e7bd5 | |||
c6015e2e8d | |||
94a2a7b32f | |||
03f33847a3 | |||
563b558204 | |||
3c92f2d531 | |||
f5ab9a9a59 | |||
7893660679 | |||
15dac42a7f | |||
53298a23ad | |||
7ffa45ba86 | |||
ee99cf6e0b | |||
2edb8cbd7e | |||
0ac3d17969 | |||
1baa823d77 | |||
368ad9505e | |||
08c267a98b | |||
0c3ef3fdf5 | |||
17dcc9c7d4 | |||
ac9a7767d2 | |||
c29006d593 | |||
e1ab43b76f | |||
409df481db | |||
02807aab32 | |||
34cb55978f | |||
d0f5d5a644 | |||
37f09245a6 | |||
c43f75f1f2 | |||
227d32be7b | |||
87955ab9a0 | |||
ecb0b15cdc | |||
ed451e4dfa | |||
1a26057452 | |||
98b930abde | |||
ddbeaa0870 | |||
b69dc4c7f4 | |||
ed6b8b89c6 | |||
2580f1e292 | |||
2ac684f98f | |||
b8d921ec16 | |||
9c0a375f01 | |||
d1cff7d84e | |||
9c2b582986 | |||
e342766cbf | |||
f1cd6a87da | |||
39e5741cb2 | |||
93cbe557cd | |||
97931bad22 | |||
1f35c40d3f | |||
c39383333f | |||
4fc18de5f9 | |||
aac30e6fd3 | |||
45785bcca3 | |||
f36cb5d3ef | |||
b7f7a5ac0a | |||
dd895f026b | |||
548c126521 | |||
ca00a22303 | |||
1ce6dd73d8 | |||
ff7dc2c4cf | |||
117b87132e | |||
42e7a7e165 | |||
796324ad71 | |||
cf1a718534 | |||
718427badb | |||
c5c520a71d | |||
17ffa57a8b | |||
005d5180b4 | |||
ce9b96994c | |||
a1fb445b06 | |||
8a516131ea | |||
9816be83ab | |||
63f607a3ea | |||
f95954a9f1 | |||
5b496ad85f | |||
bc1bf8542c | |||
e8f4e82cf8 | |||
9a838f1d55 | |||
b9b4a696c1 | |||
810856eb0a | |||
30bafab263 | |||
c659018550 | |||
7a4076156a | |||
57982e95c1 | |||
ec29c8b8cc |
@ -2,3 +2,6 @@ language: node_js
|
||||
cache: npm
|
||||
script: npm run build
|
||||
after_success: npm run sizereport
|
||||
os:
|
||||
- linux
|
||||
- windows
|
||||
|
76
codecs/avif/Makefile
Normal file
76
codecs/avif/Makefile
Normal file
@ -0,0 +1,76 @@
|
||||
CODEC_URL = https://github.com/AOMediaCodec/libavif/archive/v0.8.0.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
14
codecs/avif/dec/README.md
Normal 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`.
|
50
codecs/avif/dec/avif_dec.cpp
Normal file
50
codecs/avif/dec/avif_dec.cpp
Normal 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
6
codecs/avif/dec/avif_dec.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
interface AVIFModule extends EmscriptenWasm.Module {
|
||||
decode(data: BufferSource): ImageData | null;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): AVIFModule;
|
||||
|
111
codecs/avif/dec/avif_dec.js
Normal file
111
codecs/avif/dec/avif_dec.js
Normal file
@ -0,0 +1,111 @@
|
||||
|
||||
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 e;e||(e=typeof avif_dec !== 'undefined' ? avif_dec : {});var aa,ba;e.ready=new Promise(function(a,b){aa=a;ba=b});var ca={},l;for(l in e)e.hasOwnProperty(l)&&(ca[l]=e[l]);var ea=!1,q=!1,fa=!1,ha=!1;ea="object"===typeof window;q="function"===typeof importScripts;fa="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ha=!ea&&!fa&&!q;var u="",ia,ja,ka,la;
|
||||
if(fa)u=q?require("path").dirname(u)+"/":__dirname+"/",ia=function(a,b){ka||(ka=require("fs"));la||(la=require("path"));a=la.normalize(a);return ka.readFileSync(a,b?null:"utf8")},ja=function(a){a=ia(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",w),e.inspect=function(){return"[Emscripten Module object]"};else if(ha)"undefined"!=
|
||||
typeof read&&(ia=function(a){return read(a)}),ja=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(ea||q)q?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="",ia=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},q&&(ja=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.responseType="arraybuffer";b.send(null);return new Uint8Array(b.response)});var ma=e.print||console.log.bind(console),y=e.printErr||console.warn.bind(console);for(l in ca)ca.hasOwnProperty(l)&&(e[l]=ca[l]);ca=null;var na=0,oa;e.wasmBinary&&(oa=e.wasmBinary);var noExitRuntime;e.noExitRuntime&&(noExitRuntime=e.noExitRuntime);
|
||||
"object"!==typeof WebAssembly&&w("no native wasm support detected");var z,pa=new WebAssembly.Table({initial:2113,maximum:2113,element:"anyfunc"}),qa=!1;function assert(a,b){a||w("Assertion failed: "+b)}var ra="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
|
||||
function A(a,b,c){var d=b+c;for(c=b;a[c]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&ra)return ra.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 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?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d}
|
||||
function sa(a,b,c,d){if(!(0<d))return 0;var f=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-f}
|
||||
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(B.subarray(a,c));c=0;for(d="";;){var f=C[a+2*c>>1];if(0==f||c==b/2)return d;++c;d+=String.fromCharCode(f)}}
|
||||
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 f=0;f<c;++f)C[b>>1]=a.charCodeAt(f),b+=2;C[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 f=D[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023)):d+=String.fromCharCode(f)}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 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}D[b>>2]=g;b+=4;if(b+4>c)break}D[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 E,F,B,C,wa,D,I,Ca,Da;
|
||||
function Ea(a){E=a;e.HEAP8=F=new Int8Array(a);e.HEAP16=C=new Int16Array(a);e.HEAP32=D=new Int32Array(a);e.HEAPU8=B=new Uint8Array(a);e.HEAPU16=wa=new Uint16Array(a);e.HEAPU32=I=new Uint32Array(a);e.HEAPF32=Ca=new Float32Array(a);e.HEAPF64=Da=new Float64Array(a)}var Fa=e.INITIAL_MEMORY||16777216;e.wasmMemory?z=e.wasmMemory:z=new WebAssembly.Memory({initial:Fa/65536,maximum:32768});z&&(E=z.buffer);Fa=E.byteLength;Ea(E);D[224044]=6139216;
|
||||
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.ob;"number"===typeof c?void 0===b.Ya?e.dynCall_v(c):e.dynCall_vi(c,b.Ya):c(void 0===b.Ya?null:b.Ya)}}}var Ha=[],Ia=[],Ja=[],Ka=[];function La(){var a=e.preRun.shift();Ha.unshift(a)}var Ma=Math.abs,Na=Math.ceil,Oa=Math.floor,Pa=Math.min,J=0,Qa=null,Ra=null;e.preloadedImages={};e.preloadedAudios={};
|
||||
function w(a){if(e.onAbort)e.onAbort(a);y(a);qa=!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_dec.wasm";if(!Ta()){var Ua=K;K=e.locateFile?e.locateFile(Ua,u):u+Ua}
|
||||
function Va(){try{if(oa)return new Uint8Array(oa);if(ja)return ja(K);throw"both async and sync fetching of the wasm failed";}catch(a){w(a)}}function Wa(){return oa||!ea&&!q||"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 L,Xa;Ia.push({ob:function(){Ya()}});function Za(){return 0<Za.Va}
|
||||
function $a(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(a.splice(d,1),c++):c&&(a.splice(d,1),c--)}if(b)for(;c;c--)a.unshift("..");return a}function ab(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
|
||||
function bb(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 cb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
|
||||
function db(){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=$a(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var eb=[];function fb(a,b){eb[a]={input:[],output:[],Ua:b};gb(a,hb)}
|
||||
var hb={open:function(a){var b=eb[a.node.rdev];if(!b)throw new M(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.ib)throw new M(60);for(var f=0,g=0;g<d;g++){try{var h=a.tty.Ua.ib(a.tty)}catch(k){throw new M(29);}if(void 0===h&&0===f)throw new M(6);if(null===h||void 0===h)break;f++;b[c+g]=h}f&&(a.node.timestamp=Date.now());return f},write:function(a,b,c,d){if(!a.tty||!a.tty.Ua.$a)throw new M(60);
|
||||
try{for(var f=0;f<d;f++)a.tty.Ua.$a(a.tty,b[c+f])}catch(g){throw new M(29);}d&&(a.node.timestamp=Date.now());return f}},ib={ib:function(a){if(!a.input.length){var b=null;if(fa){var c=Buffer.Va?Buffer.Va(256):new Buffer(256),d=0;try{d=ka.readSync(process.stdin.fd,c,0,256,null)}catch(f){if(-1!=f.toString().indexOf("EOF"))d=0;else throw f;}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?(ma(A(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(ma(A(a.output,0)),a.output=[])}},jb={$a:function(a,b){null===b||10===b?(y(A(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(y(A(a.output,0)),a.output=[])}},N={Ma:null,
|
||||
Pa:function(){return N.createNode(null,"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new M(63);N.Ma||(N.Ma={dir:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa,lookup:N.Ja.lookup,Wa:N.Ja.Wa,rename:N.Ja.rename,unlink:N.Ja.unlink,rmdir:N.Ja.rmdir,readdir:N.Ja.readdir,symlink:N.Ja.symlink},stream:{Ta:N.Ka.Ta}},file:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa},stream:{Ta:N.Ka.Ta,read:N.Ka.read,write:N.Ka.write,cb:N.Ka.cb,jb:N.Ka.jb,lb:N.Ka.lb}},link:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa,readlink:N.Ja.readlink},
|
||||
stream:{}},eb:{node:{Ra:N.Ja.Ra,Oa:N.Ja.Oa},stream:kb}});c=lb(a,b,c,d);16384===(c.mode&61440)?(c.Ja=N.Ma.dir.node,c.Ka=N.Ma.dir.stream,c.Ia={}):32768===(c.mode&61440)?(c.Ja=N.Ma.file.node,c.Ka=N.Ma.file.stream,c.La=0,c.Ia=null):40960===(c.mode&61440)?(c.Ja=N.Ma.link.node,c.Ka=N.Ma.link.stream):8192===(c.mode&61440)&&(c.Ja=N.Ma.eb.node,c.Ka=N.Ma.eb.stream);c.timestamp=Date.now();a&&(a.Ia[b]=c);return c},xb: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},
|
||||
yb: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))},tb: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.nb=4096;b.blocks=Math.ceil(b.size/b.nb);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&&N.tb(a,b.size)},lookup:function(){throw mb[44];},Wa:function(a,b,c,d){return N.createNode(a,b,c,d)},rename:function(a,b,c){if(16384===(a.mode&61440)){try{var d=nb(b,c)}catch(g){}if(d)for(var f in d.Ia)throw new M(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=nb(a,b),d;for(d in c.Ia)throw new M(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=N.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new M(28);return a.link}},Ka:{read:function(a,b,c,d,f){var g=a.node.Ia;if(f>=a.node.La)return 0;a=Math.min(a.node.La-f,d);if(8<a&&g.subarray)b.set(g.subarray(f,f+a),c);else for(d=0;d<a;d++)b[c+d]=g[f+d];return a},write:function(a,b,c,d,f,g){b.buffer===F.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===f)return a.Ia=b.slice(c,c+d),a.La=d;if(f+d<=a.La)return a.Ia.set(b.subarray(c,c+d),f),d}N.fb(a,f+d);if(a.Ia.subarray&&b.subarray)a.Ia.set(b.subarray(c,c+d),f);else for(g=0;g<d;g++)a.Ia[f+g]=b[c+g];a.La=Math.max(a.La,f+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 M(28);return b},cb:function(a,b,c){N.fb(a.node,b+c);a.node.La=Math.max(a.node.La,b+c)},jb:function(a,b,c,d,f,g){assert(0===
|
||||
b);if(32768!==(a.node.mode&61440))throw new M(43);a=a.node.Ia;if(g&2||a.buffer!==E){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=ob(g);c<g;)F[b+c++]=0;c=b;if(!c)throw new M(48);F.set(a,c)}else d=!1,c=a.byteOffset;return{Cb:c,wb:d}},lb:function(a,b,c,d,f){if(32768!==(a.node.mode&61440))throw new M(43);if(f&2)return 0;N.Ka.write(a,b,0,d,c,!1);return 0}}},pb=null,qb={},rb=[],sb=1,tb=null,ub=!0,vb={},M=null,mb={};
|
||||
function O(a,b){a=db("/",a);b=b||{};if(!a)return{path:"",node:null};var c={hb:!0,ab:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.ab)throw new M(32);a=$a(a.split("/").filter(function(h){return!!h}),!1);var f=pb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;f=nb(f,a[d]);c=ab(c+"/"+a[d]);f.Xa&&(!g||g&&b.hb)&&(f=f.Xa.root);if(!g||b.gb)for(g=0;40960===(f.mode&61440);)if(f=wb(c),c=db(bb(c),f),f=O(c,{ab:b.ab}).node,40<g++)throw new M(32);}return{path:c,node:f}}
|
||||
function xb(a){for(var b;;){if(a===a.parent)return a=a.Pa.kb,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function yb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%tb.length}function nb(a,b){var c;if(c=(c=zb(a,"x"))?c:a.Ja.lookup?0:2)throw new M(c,a);for(c=tb[yb(a.id,b)];c;c=c.sb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Ja.lookup(a,b)}
|
||||
function lb(a,b,c,d){a=new Ab(a,b,c,d);b=yb(a.parent.id,a.name);a.sb=tb[b];return tb[b]=a}var Bb={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 Cb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function zb(a,b){if(ub)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 Db(a,b){try{return nb(a,b),20}catch(c){}return zb(a,"wx")}function Eb(a){var b=4096;for(a=a||0;a<=b;a++)if(!rb[a])return a;throw new M(33);}function Fb(a,b){Gb||(Gb=function(){},Gb.prototype={});var c=new Gb,d;for(d in a)c[d]=a[d];a=c;b=Eb(b);a.fd=b;return rb[b]=a}var kb={open:function(a){a.Ka=qb[a.node.rdev].Ka;a.Ka.open&&a.Ka.open(a)},Ta:function(){throw new M(70);}};function gb(a,b){qb[a]={Ka:b}}
|
||||
function Hb(a,b){var c="/"===b,d=!b;if(c&&pb)throw new M(10);if(!c&&!d){var f=O(b,{hb:!1});b=f.path;f=f.node;if(f.Xa)throw new M(10);if(16384!==(f.mode&61440))throw new M(54);}b={type:a,Bb:{},kb:b,rb:[]};a=a.Pa(b);a.Pa=b;b.root=a;c?pb=a:f&&(f.Xa=b,f.Pa&&f.Pa.rb.push(b))}function Ib(a,b,c){var d=O(a,{parent:!0}).node;a=cb(a);if(!a||"."===a||".."===a)throw new M(28);var f=Db(d,a);if(f)throw new M(f);if(!d.Ja.Wa)throw new M(63);return d.Ja.Wa(d,a,b,c)}function P(a){Ib(a,16895,0)}
|
||||
function Jb(a,b,c){"undefined"===typeof c&&(c=b,b=438);Ib(a,b|8192,c)}function Kb(a,b){if(!db(a))throw new M(44);var c=O(b,{parent:!0}).node;if(!c)throw new M(44);b=cb(b);var d=Db(c,b);if(d)throw new M(d);if(!c.Ja.symlink)throw new M(63);c.Ja.symlink(c,b,a)}function wb(a){a=O(a).node;if(!a)throw new M(44);if(!a.Ja.readlink)throw new M(28);return db(xb(a.parent),a.Ja.readlink(a))}
|
||||
function Lb(a,b,c,d){if(""===a)throw new M(44);if("string"===typeof b){var f=Bb[b];if("undefined"===typeof f)throw Error("Unknown file open mode: "+b);b=f}c=b&64?("undefined"===typeof c?438:c)&4095|32768:0;if("object"===typeof a)var g=a;else{a=ab(a);try{g=O(a,{gb:!(b&131072)}).node}catch(k){}}f=!1;if(b&64)if(g){if(b&128)throw new M(20);}else g=Ib(a,c,0),f=!0;if(!g)throw new M(44);8192===(g.mode&61440)&&(b&=-513);if(b&65536&&16384!==(g.mode&61440))throw new M(54);if(!f&&(c=g?40960===(g.mode&61440)?
|
||||
32:16384===(g.mode&61440)&&("r"!==Cb(b)||b&512)?31:zb(g,Cb(b)):44))throw new M(c);if(b&512){c=g;var h;"string"===typeof c?h=O(c,{gb:!0}).node:h=c;if(!h.Ja.Oa)throw new M(63);if(16384===(h.mode&61440))throw new M(31);if(32768!==(h.mode&61440))throw new M(28);if(c=zb(h,"w"))throw new M(c);h.Ja.Oa(h,{size:0,timestamp:Date.now()})}b&=-131713;d=Fb({node:g,path:xb(g),flags:b,seekable:!0,position:0,Ka:g.Ka,vb:[],error:!1},d);d.Ka.open&&d.Ka.open(d);!e.logReadFiles||b&1||(Mb||(Mb={}),a in Mb||(Mb[a]=1,y("FS.trackingDelegate error on read file: "+
|
||||
a)));try{vb.onOpenFile&&(g=0,1!==(b&2097155)&&(g|=1),0!==(b&2097155)&&(g|=2),vb.onOpenFile(a,g))}catch(k){y("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+k.message)}return d}function Nb(a,b,c){if(null===a.fd)throw new M(8);if(!a.seekable||!a.Ka.Ta)throw new M(70);if(0!=c&&1!=c&&2!=c)throw new M(28);a.position=a.Ka.Ta(a,b,c);a.vb=[]}
|
||||
function Ob(){M||(M=function(a,b){this.node=b;this.ub=function(c){this.Sa=c};this.ub(a);this.message="FS error"},M.prototype=Error(),M.prototype.constructor=M,[44].forEach(function(a){mb[a]=new M(a);mb[a].stack="<generic error, no stack>"}))}var Pb;function Qb(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
|
||||
function Rb(a,b,c){a=ab("/dev/"+a);var d=Qb(!!b,!!c);Sb||(Sb=64);var f=Sb++<<8|0;gb(f,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,h,k,m){for(var n=0,r=0;r<m;r++){try{var t=b()}catch(v){throw new M(29);}if(void 0===t&&0===n)throw new M(6);if(null===t||void 0===t)break;n++;h[k+r]=t}n&&(g.node.timestamp=Date.now());return n},write:function(g,h,k,m){for(var n=0;n<m;n++)try{c(h[k+n])}catch(r){throw new M(29);}m&&(g.node.timestamp=Date.now());return n}});
|
||||
Jb(a,d,f)}var Sb,Q={},Gb,Mb,Tb=void 0;function Ub(){Tb+=4;return D[Tb-4>>2]}function Vb(a){a=rb[a];if(!a)throw new M(8);return a}function Wb(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 Yb=void 0;function R(a){for(var b="";B[a];)b+=Yb[B[a++]];return b}var Zb={},S={},$b={};function ac(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 bc(a,b){a=ac(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function cc(a){var b=Error,c=bc(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 dc=void 0;function T(a){throw new dc(a);}var ec=void 0;function fc(a,b){function c(k){k=b(k);if(k.length!==d.length)throw new ec("Mismatched type converter count");for(var m=0;m<d.length;++m)U(d[m],k[m])}var d=[];d.forEach(function(k){$b[k]=a});var f=Array(a.length),g=[],h=0;a.forEach(function(k,m){S.hasOwnProperty(k)?f[m]=S[k]:(g.push(k),Zb.hasOwnProperty(k)||(Zb[k]=[]),Zb[k].push(function(){f[m]=S[k];++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 d=b.name;a||T('type "'+d+'" must have a positive integer typeid pointer');if(S.hasOwnProperty(a)){if(c.pb)return;T("Cannot register type '"+d+"' twice")}S[a]=b;delete $b[a];Zb.hasOwnProperty(a)&&(b=Zb[a],delete Zb[a],b.forEach(function(f){f()}))}var hc=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function ic(a){4<a&&0===--V[a].bb&&(V[a]=void 0,hc.push(a))}function jc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=hc.length?hc.pop():V.length;V[b]={bb:1,value:a};return b}}function kc(a){return this.fromWireType(I[a>>2])}function lc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function mc(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 nc(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=bc(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function oc(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function pc(a,b){var c=e;if(void 0===c[a].Na){var d=c[a];c[a]=function(){c[a].Na.hasOwnProperty(arguments.length)||T("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.mb]=d}}
|
||||
function qc(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].Na&&void 0!==e[a].Na[c])&&T("Cannot register public name '"+a+"' twice"),pc(a,a),e.hasOwnProperty(c)&&T("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].Na[c]=b):(e[a]=b,void 0!==c&&(e[a].Ab=c))}function rc(a,b){for(var c=[],d=0;d<a;d++)c.push(D[(b>>2)+d]);return c}
|
||||
function sc(a,b){a=R(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&&T("unknown function pointer with signature "+a+": "+b);return c}var tc=void 0;function uc(a){a=vc(a);var b=R(a);W(a);return b}
|
||||
function wc(a,b){function c(g){f[g]||S[g]||($b[g]?$b[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new tc(a+": "+d.map(uc).join([", "]));}function xc(a,b,c){switch(b){case 0:return c?function(d){return F[d]}:function(d){return B[d]};case 1:return c?function(d){return C[d>>1]}:function(d){return wa[d>>1]};case 2:return c?function(d){return D[d>>2]}:function(d){return I[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var yc={};
|
||||
function zc(){return"object"===typeof globalThis?globalThis:Function("return this")()}function Ac(a,b){var c=S[a];void 0===c&&T(b+" has unknown type "+uc(a));return c}var Bc={};function Ab(a,b,c,d){a||(a=this);this.parent=a;this.Pa=a.Pa;this.Xa=null;this.id=sb++;this.name=b;this.mode=c;this.Ja={};this.Ka={};this.rdev=d}
|
||||
Object.defineProperties(Ab.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}}});Ob();tb=Array(4096);Hb(N,"/");P("/tmp");P("/home");P("/home/web_user");
|
||||
(function(){P("/dev");gb(259,{read:function(){return 0},write:function(d,f,g,h){return h}});Jb("/dev/null",259);fb(1280,ib);fb(1536,jb);Jb("/dev/tty",1280);Jb("/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(fa)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){w("random_device")});Rb("random",b);Rb("urandom",b);P("/dev/shm");
|
||||
P("/dev/shm/tmp")})();P("/proc");P("/proc/self");P("/proc/self/fd");Hb({Pa:function(){var a=lb("/proc/self","fd",16895,73);a.Ja={lookup:function(b,c){var d=rb[+c];if(!d)throw new M(8);b={parent:null,Pa:{kb:"fake"},Ja:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");for(var Cc=Array(256),Dc=0;256>Dc;++Dc)Cc[Dc]=String.fromCharCode(Dc);Yb=Cc;dc=e.BindingError=cc("BindingError");ec=e.InternalError=cc("InternalError");
|
||||
e.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};e.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};tc=e.UnboundTypeError=cc("UnboundTypeError");
|
||||
var Rc={A:function(a){return ob(a)},x:function(){},z:function(a){"uncaught_exception"in Za?Za.Va++:Za.Va=1;throw a;},t:function(a,b,c){Tb=c;try{var d=Vb(a);switch(b){case 0:var f=Ub();return 0>f?-28:Lb(d.path,d.flags,0,f).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return f=Ub(),d.flags|=f,0;case 12:return f=Ub(),C[f+0>>1]=2,0;case 13:case 14:return 0;case 16:case 8:return-28;case 9:return D[Ec()>>2]=28,-1;default:return-28}}catch(g){return"undefined"!==typeof Q&&g instanceof M||w(g),-g.Sa}},
|
||||
M:function(a,b,c){Tb=c;try{var d=Vb(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 f=Ub();return D[f>>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=f=Ub();if(!d.Ka.qb)throw new M(59);return d.Ka.qb(d,b,a);case 21523:return d.tty?0:-59;case 21524:return d.tty?0:-59;default:w("bad ioctl syscall "+b)}}catch(g){return"undefined"!==typeof Q&&g instanceof M||w(g),-g.Sa}},N:function(a,
|
||||
b,c){Tb=c;try{var d=a?A(B,a,void 0):"",f=Ub();return Lb(d,b,f).fd}catch(g){return"undefined"!==typeof Q&&g instanceof M||w(g),-g.Sa}},P:function(a,b,c,d,f){var g=Wb(c);b=R(b);U(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,k){return k?d:f},argPackAdvance:8,readValueFromPointer:function(h){if(1===c)var k=F;else if(2===c)k=C;else if(4===c)k=D;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[h>>g])},Qa:null})},O:function(a,b){b=R(b);U(a,{name:b,
|
||||
fromWireType:function(c){var d=V[c].value;ic(c);return d},toWireType:function(c,d){return jc(d)},argPackAdvance:8,readValueFromPointer:kc,Qa:null})},v:function(a,b,c){c=Wb(c);b=R(b);U(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+lc(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:mc(b,c),Qa:null})},B:function(a,b,c,d,f,g){var h=rc(b,c);a=R(a);f=sc(d,f);qc(a,function(){wc("Cannot call "+
|
||||
a+" due to unbound types",h)},b-1);fc(h,function(k){var m=[k[0],null].concat(k.slice(1)),n=k=a,r=f,t=m.length;2>t&&T("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var v=null!==m[1]&&!1,x=!1,p=1;p<m.length;++p)if(null!==m[p]&&void 0===m[p].Qa){x=!0;break}var G="void"!==m[0].name,H="",da="";for(p=0;p<t-2;++p)H+=(0!==p?", ":"")+"arg"+p,da+=(0!==p?", ":"")+"arg"+p+"Wired";n="return function "+ac(n)+"("+H+") {\nif (arguments.length !== "+(t-2)+") {\nthrowBindingError('function "+
|
||||
n+" called with ' + arguments.length + ' arguments, expected "+(t-2)+" args!');\n}\n";x&&(n+="var destructors = [];\n");var Xb=x?"destructors":"null";H="throwBindingError invoker fn runDestructors retType classParam".split(" ");r=[T,r,g,oc,m[0],m[1]];v&&(n+="var thisWired = classParam.toWireType("+Xb+", this);\n");for(p=0;p<t-2;++p)n+="var arg"+p+"Wired = argType"+p+".toWireType("+Xb+", arg"+p+"); // "+m[p+2].name+"\n",H.push("argType"+p),r.push(m[p+2]);v&&(da="thisWired"+(0<da.length?", ":"")+da);
|
||||
n+=(G?"var rv = ":"")+"invoker(fn"+(0<da.length?", ":"")+da+");\n";if(x)n+="runDestructors(destructors);\n";else for(p=v?1:2;p<m.length;++p)t=1===p?"thisWired":"arg"+(p-2)+"Wired",null!==m[p].Qa&&(n+=t+"_dtor("+t+"); // "+m[p].name+"\n",H.push(t+"_dtor"),r.push(m[p].Qa));G&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");H.push(n+"}\n");m=nc(H).apply(null,r);p=b-1;if(!e.hasOwnProperty(k))throw new ec("Replacing nonexistant public symbol");void 0!==e[k].Na&&void 0!==p?e[k].Na[p]=m:(e[k]=
|
||||
m,e[k].mb=p);return[]})},i:function(a,b,c,d,f){function g(n){return n}b=R(b);-1===f&&(f=4294967295);var h=Wb(c);if(0===d){var k=32-8*c;g=function(n){return n<<k>>>k}}var m=-1!=b.indexOf("unsigned");U(a,{name:b,fromWireType:g,toWireType:function(n,r){if("number"!==typeof r&&"boolean"!==typeof r)throw new TypeError('Cannot convert "'+lc(r)+'" to '+this.name);if(r<d||r>f)throw new TypeError('Passing a number "'+lc(r)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+
|
||||
d+", "+f+"]!");return m?r>>>0:r|0},argPackAdvance:8,readValueFromPointer:xc(b,h,0!==d),Qa:null})},f:function(a,b,c){function d(g){g>>=2;var h=I;return new f(E,h[g+1],h[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=R(c);U(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{pb:!0})},w:function(a,b){b=R(b);var c="std::string"===b;U(a,{name:b,fromWireType:function(d){var f=I[d>>2];if(c)for(var g=d+4,h=0;h<=f;++h){var k=d+4+
|
||||
h;if(h==f||0==B[k]){g=g?A(B,g,k-g):"";if(void 0===m)var m=g;else m+=String.fromCharCode(0),m+=g;g=k+1}}else{m=Array(f);for(h=0;h<f;++h)m[h]=String.fromCharCode(B[d+4+h]);m=m.join("")}W(d);return m},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||T("Cannot pass non-string to std::string");var h=(c&&g?function(){return ta(f)}:function(){return f.length})(),k=ob(4+h+
|
||||
1);I[k>>2]=h;if(c&&g)sa(f,B,k+4,h+1);else if(g)for(g=0;g<h;++g){var m=f.charCodeAt(g);255<m&&(W(k),T("String has UTF-16 code units that do not fit in 8 bits"));B[k+4+g]=m}else for(g=0;g<h;++g)B[k+4+g]=f[g];null!==d&&d.push(W,k);return k},argPackAdvance:8,readValueFromPointer:kc,Qa:function(d){W(d)}})},n:function(a,b,c){c=R(c);if(2===b){var d=va;var f=xa;var g=ya;var h=function(){return wa};var k=1}else 4===b&&(d=za,f=Aa,g=Ba,h=function(){return I},k=2);U(a,{name:c,fromWireType:function(m){for(var n=
|
||||
I[m>>2],r=h(),t,v=m+4,x=0;x<=n;++x){var p=m+4+x*b;if(x==n||0==r[p>>k])v=d(v,p-v),void 0===t?t=v:(t+=String.fromCharCode(0),t+=v),v=p+b}W(m);return t},toWireType:function(m,n){"string"!==typeof n&&T("Cannot pass non-string to C++ string type "+c);var r=g(n),t=ob(4+r+b);I[t>>2]=r>>k;f(n,t+4,r+b);null!==m&&m.push(W,t);return t},argPackAdvance:8,readValueFromPointer:kc,Qa:function(m){W(m)}})},y:function(a,b){b=R(b);U(a,{zb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},
|
||||
s:ic,Q:function(a){if(0===a)return jc(zc());var b=yc[a];a=void 0===b?R(a):b;return jc(zc()[a])},F:function(a){4<a&&(V[a].bb+=1)},q:function(a,b,c,d){a||T("Cannot use deleted val. handle = "+a);a=V[a].value;var f=Bc[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")))(Ac,e,jc);Bc[b]=f}return f(a,c,d)},o:function(){w()},d:function(a,b){X(a,b||1);throw"longjmp";},K:function(a,b,c){B.copyWithin(a,b,b+c)},j:function(a){a>>>=0;var b=B.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{z.grow(Math.min(2147483648,d)-E.byteLength+65535>>>16);Ea(z.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},u:function(a){try{var b=Vb(a);if(null===b.fd)throw new M(8);b.Za&&(b.Za=null);try{b.Ka.close&&b.Ka.close(b)}catch(c){throw c;}finally{rb[b.fd]=null}b.fd=null;return 0}catch(c){return"undefined"!==typeof Q&&c instanceof M||w(c),c.Sa}},L:function(a,b,c,d){try{a:{for(var f=Vb(a),g=a=0;g<c;g++){var h=D[b+(8*g+4)>>2],k=f,m=D[b+8*g>>2],
|
||||
n=h,r=void 0,t=F;if(0>n||0>r)throw new M(28);if(null===k.fd)throw new M(8);if(1===(k.flags&2097155))throw new M(8);if(16384===(k.node.mode&61440))throw new M(31);if(!k.Ka.read)throw new M(28);var v="undefined"!==typeof r;if(!v)r=k.position;else if(!k.seekable)throw new M(70);var x=k.Ka.read(k,t,m,n,r);v||(k.position+=x);var p=x;if(0>p){var G=-1;break a}a+=p;if(p<h)break}G=a}D[d>>2]=G;return 0}catch(H){return"undefined"!==typeof Q&&H instanceof M||w(H),H.Sa}},G:function(a,b,c,d,f){try{var g=Vb(a);
|
||||
a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Nb(g,a,d);Xa=[g.position>>>0,(L=g.position,1<=+Ma(L)?0<L?(Pa(+Oa(L/4294967296),4294967295)|0)>>>0:~~+Na((L-+(~~L>>>0))/4294967296)>>>0:0)];D[f>>2]=Xa[0];D[f+4>>2]=Xa[1];g.Za&&0===a&&0===d&&(g.Za=null);return 0}catch(h){return"undefined"!==typeof Q&&h instanceof M||w(h),h.Sa}},r:function(a,b,c,d){try{a:{for(var f=Vb(a),g=a=0;g<c;g++){var h=f,k=D[b+8*g>>2],m=D[b+(8*g+4)>>2],n=void 0,r=F;if(0>m||0>n)throw new M(28);if(null===
|
||||
h.fd)throw new M(8);if(0===(h.flags&2097155))throw new M(8);if(16384===(h.node.mode&61440))throw new M(31);if(!h.Ka.write)throw new M(28);h.seekable&&h.flags&1024&&Nb(h,0,2);var t="undefined"!==typeof n;if(!t)n=h.position;else if(!h.seekable)throw new M(70);var v=h.Ka.write(h,r,k,m,n,void 0);t||(h.position+=v);try{if(h.path&&vb.onWriteToFile)vb.onWriteToFile(h.path)}catch(G){y("FS.trackingDelegate['onWriteToFile']('"+h.path+"') threw an exception: "+G.message)}var x=v;if(0>x){var p=-1;break a}a+=
|
||||
x}p=a}D[d>>2]=p;return 0}catch(G){return"undefined"!==typeof Q&&G instanceof M||w(G),G.Sa}},a:function(){return na|0},m:Fc,e:Gc,I:Hc,p:Ic,H:Jc,D:Kc,C:Lc,E:Mc,J:Nc,k:Oc,l:Pc,c:Qc,memory:z,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)},b:function(a){na=a|0},table:pa};
|
||||
(function(){function a(f){e.asm=f.exports;J--;e.monitorRunDependencies&&e.monitorRunDependencies(J);0==J&&(null!==Qa&&(clearInterval(Qa),Qa=null),Ra&&(f=Ra,Ra=null,f()))}function b(f){a(f.instance)}function c(f){return Wa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){y("failed to asynchronously prepare wasm: "+g);w(g)})}var d={a:Rc};J++;e.monitorRunDependencies&&e.monitorRunDependencies(J);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return y("Module.instantiateWasm callback failed with error: "+
|
||||
f),!1}(function(){if(oa||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(K,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){y("wasm streaming compile failed: "+g);y("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
|
||||
var Ya=e.___wasm_call_ctors=function(){return(Ya=e.___wasm_call_ctors=e.asm.R).apply(null,arguments)},ob=e._malloc=function(){return(ob=e._malloc=e.asm.S).apply(null,arguments)},W=e._free=function(){return(W=e._free=e.asm.T).apply(null,arguments)},vc=e.___getTypeName=function(){return(vc=e.___getTypeName=e.asm.U).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.V).apply(null,arguments)};
|
||||
var Ec=e.___errno_location=function(){return(Ec=e.___errno_location=e.asm.W).apply(null,arguments)},X=e._setThrew=function(){return(X=e._setThrew=e.asm.X).apply(null,arguments)},Y=e.stackSave=function(){return(Y=e.stackSave=e.asm.Y).apply(null,arguments)},Z=e.stackRestore=function(){return(Z=e.stackRestore=e.asm.Z).apply(null,arguments)},Sc=e.dynCall_v=function(){return(Sc=e.dynCall_v=e.asm._).apply(null,arguments)},Tc=e.dynCall_vi=function(){return(Tc=e.dynCall_vi=e.asm.$).apply(null,arguments)},
|
||||
Uc=e.dynCall_vii=function(){return(Uc=e.dynCall_vii=e.asm.aa).apply(null,arguments)};e.dynCall_viii=function(){return(e.dynCall_viii=e.asm.ba).apply(null,arguments)};var Vc=e.dynCall_viiii=function(){return(Vc=e.dynCall_viiii=e.asm.ca).apply(null,arguments)},Wc=e.dynCall_ii=function(){return(Wc=e.dynCall_ii=e.asm.da).apply(null,arguments)},Xc=e.dynCall_iii=function(){return(Xc=e.dynCall_iii=e.asm.ea).apply(null,arguments)};e.dynCall_iiii=function(){return(e.dynCall_iiii=e.asm.fa).apply(null,arguments)};
|
||||
var Yc=e.dynCall_iiiii=function(){return(Yc=e.dynCall_iiiii=e.asm.ga).apply(null,arguments)},Zc=e.dynCall_iiiiiiiii=function(){return(Zc=e.dynCall_iiiiiiiii=e.asm.ha).apply(null,arguments)},$c=e.dynCall_iiiiiiiiii=function(){return($c=e.dynCall_iiiiiiiiii=e.asm.ia).apply(null,arguments)},ad=e.dynCall_iiiijj=function(){return(ad=e.dynCall_iiiijj=e.asm.ja).apply(null,arguments)},bd=e.dynCall_ij=function(){return(bd=e.dynCall_ij=e.asm.ka).apply(null,arguments)},cd=e.dynCall_jjij=function(){return(cd=
|
||||
e.dynCall_jjij=e.asm.la).apply(null,arguments)};e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.ma).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.na).apply(null,arguments)};e.dynCall_viiiiiiii=function(){return(e.dynCall_viiiiiiii=e.asm.oa).apply(null,arguments)};e.dynCall_viiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiii=e.asm.pa).apply(null,arguments)};e.dynCall_viiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiii=e.asm.qa).apply(null,arguments)};
|
||||
e.dynCall_viiiiiii=function(){return(e.dynCall_viiiiiii=e.asm.ra).apply(null,arguments)};e.dynCall_viiiiiiiii=function(){return(e.dynCall_viiiiiiiii=e.asm.sa).apply(null,arguments)};e.dynCall_iiiiii=function(){return(e.dynCall_iiiiii=e.asm.ta).apply(null,arguments)};e.dynCall_jiiiiiiiii=function(){return(e.dynCall_jiiiiiiiii=e.asm.ua).apply(null,arguments)};e.dynCall_iiiiiii=function(){return(e.dynCall_iiiiiii=e.asm.va).apply(null,arguments)};
|
||||
e.dynCall_iiiiiiii=function(){return(e.dynCall_iiiiiiii=e.asm.wa).apply(null,arguments)};e.dynCall_iiiiiiiiiiii=function(){return(e.dynCall_iiiiiiiiiiii=e.asm.xa).apply(null,arguments)};e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.ya).apply(null,arguments)};e.dynCall_iidiiii=function(){return(e.dynCall_iidiiii=e.asm.za).apply(null,arguments)};e.dynCall_i=function(){return(e.dynCall_i=e.asm.Aa).apply(null,arguments)};
|
||||
e.dynCall_viiiiiiiiii=function(){return(e.dynCall_viiiiiiiiii=e.asm.Ba).apply(null,arguments)};e.dynCall_viiiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiiii=e.asm.Ca).apply(null,arguments)};e.dynCall_jiiiiiiii=function(){return(e.dynCall_jiiiiiiii=e.asm.Da).apply(null,arguments)};e.dynCall_ff=function(){return(e.dynCall_ff=e.asm.Ea).apply(null,arguments)};e.dynCall_jiiiiii=function(){return(e.dynCall_jiiiiii=e.asm.Fa).apply(null,arguments)};
|
||||
e.dynCall_jiiiii=function(){return(e.dynCall_jiiiii=e.asm.Ga).apply(null,arguments)};e.dynCall_iiijii=function(){return(e.dynCall_iiijii=e.asm.Ha).apply(null,arguments)};function Pc(a,b,c){var d=Y();try{Uc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}function Qc(a,b,c,d,f){var g=Y();try{Vc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function Gc(a,b,c){var d=Y();try{return Xc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}
|
||||
function Oc(a,b){var c=Y();try{Tc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Nc(a){var b=Y();try{Sc(a)}catch(c){Z(b);if(c!==c+0&&"longjmp"!==c)throw c;X(1,0)}}function Fc(a,b){var c=Y();try{return Wc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Hc(a,b,c,d,f){var g=Y();try{return Yc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}
|
||||
function Jc(a,b,c,d,f,g,h,k,m,n){var r=Y();try{return $c(a,b,c,d,f,g,h,k,m,n)}catch(t){Z(r);if(t!==t+0&&"longjmp"!==t)throw t;X(1,0)}}function Ic(a,b,c,d,f,g,h,k,m){var n=Y();try{return Zc(a,b,c,d,f,g,h,k,m)}catch(r){Z(n);if(r!==r+0&&"longjmp"!==r)throw r;X(1,0)}}function Mc(a,b,c,d,f,g){var h=Y();try{return cd(a,b,c,d,f,g)}catch(k){Z(h);if(k!==k+0&&"longjmp"!==k)throw k;X(1,0)}}
|
||||
function Kc(a,b,c,d,f,g,h,k){var m=Y();try{return ad(a,b,c,d,f,g,h,k)}catch(n){Z(m);if(n!==n+0&&"longjmp"!==n)throw n;X(1,0)}}function Lc(a,b,c){var d=Y();try{return bd(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}var dd;Ra=function ed(){dd||fd();dd||(Ra=ed)};
|
||||
function fd(){function a(){if(!dd&&(dd=!0,e.calledRun=!0,!qa)){e.noFSInit||Pb||(Pb=!0,Ob(),e.stdin=e.stdin,e.stdout=e.stdout,e.stderr=e.stderr,e.stdin?Rb("stdin",e.stdin):Kb("/dev/tty","/dev/stdin"),e.stdout?Rb("stdout",null,e.stdout):Kb("/dev/tty","/dev/stdout"),e.stderr?Rb("stderr",null,e.stderr):Kb("/dev/tty1","/dev/stderr"),Lb("/dev/stdin","r"),Lb("/dev/stdout","w"),Lb("/dev/stderr","w"));Ga(Ia);ub=!1;Ga(Ja);aa(e);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();Ka.unshift(b)}Ga(Ka)}}if(!(0<J)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)La();Ga(Ha);0<J||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}e.run=fd;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;fd();
|
||||
|
||||
|
||||
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;
|
||||
|
BIN
codecs/avif/dec/avif_dec.wasm
Normal file
BIN
codecs/avif/dec/avif_dec.wasm
Normal file
Binary file not shown.
37
codecs/avif/enc/README.md
Normal file
37
codecs/avif/enc/README.md
Normal 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;
|
||||
};
|
||||
```
|
84
codecs/avif/enc/avif_enc.cpp
Normal file
84
codecs/avif/enc/avif_enc.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
#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;
|
||||
// [0 - 6]
|
||||
// Creates 2^n tiles in that dimension
|
||||
int tileRowsLog2;
|
||||
int tileColsLog2;
|
||||
// [0 - 10]
|
||||
// 0 = slowest
|
||||
// 10 = fastest
|
||||
int speed;
|
||||
// 0 = 4:2:0
|
||||
// 1 = 4:2:2
|
||||
// 2 = 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_YUV420;
|
||||
break;
|
||||
case 1:
|
||||
format = AVIF_PIXEL_FORMAT_YUV422;
|
||||
break;
|
||||
case 2:
|
||||
format = AVIF_PIXEL_FORMAT_YUV444;
|
||||
break;
|
||||
}
|
||||
|
||||
avifImage* image = avifImageCreate(width, height, depth, format);
|
||||
|
||||
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->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("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
7
codecs/avif/enc/avif_enc.d.ts
vendored
Normal 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;
|
114
codecs/avif/enc/avif_enc.js
Normal file
114
codecs/avif/enc/avif_enc.js
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
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 e;e||(e=typeof avif_enc !== 'undefined' ? avif_enc : {});var aa,ba;e.ready=new Promise(function(a,b){aa=a;ba=b});var ca={},m;for(m in e)e.hasOwnProperty(m)&&(ca[m]=e[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),e.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=e.print||console.log.bind(console),z=e.printErr||console.warn.bind(console);for(m in ca)ca.hasOwnProperty(m)&&(e[m]=ca[m]);ca=null;var ma=0,na;e.wasmBinary&&(na=e.wasmBinary);var noExitRuntime;e.noExitRuntime&&(noExitRuntime=e.noExitRuntime);
|
||||
"object"!==typeof WebAssembly&&x("no native wasm support detected");var A,oa=new WebAssembly.Table({initial:2116,maximum:2116,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 f=a[b++];if(f&128){var g=a[b++]&63;if(192==(f&224))d+=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?d+=String.fromCharCode(f):(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023))}}else d+=String.fromCharCode(f)}return d}
|
||||
function sa(a,b,c,d){if(!(0<d))return 0;var f=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-f}
|
||||
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 f=D[a+2*c>>1];if(0==f||c==b/2)return d;++c;d+=String.fromCharCode(f)}}
|
||||
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 f=0;f<c;++f)D[b>>1]=a.charCodeAt(f),b+=2;D[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 f=F[a+4*c>>2];if(0==f)break;++c;65536<=f?(f-=65536,d+=String.fromCharCode(55296|f>>10,56320|f&1023)):d+=String.fromCharCode(f)}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 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}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,D,wa,F,I,Ca,Da;
|
||||
function Ea(a){G=a;e.HEAP8=H=new Int8Array(a);e.HEAP16=D=new Int16Array(a);e.HEAP32=F=new Int32Array(a);e.HEAPU8=C=new Uint8Array(a);e.HEAPU16=wa=new Uint16Array(a);e.HEAPU32=I=new Uint32Array(a);e.HEAPF32=Ca=new Float32Array(a);e.HEAPF64=Da=new Float64Array(a)}var Fa=e.INITIAL_MEMORY||16777216;e.wasmMemory?A=e.wasmMemory:A=new WebAssembly.Memory({initial:Fa/65536,maximum:32768});A&&(G=A.buffer);Fa=G.byteLength;Ea(G);F[224172]=6139728;
|
||||
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(e);else{var c=b.ub;"number"===typeof c?void 0===b.bb?e.dynCall_v(c):e.dynCall_vi(c,b.bb):c(void 0===b.bb?null:b.bb)}}}var Ha=[],Ia=[],Ja=[],Ka=[];function La(){var a=e.preRun.shift();Ha.unshift(a)}var Ma=Math.abs,Na=Math.ceil,Oa=Math.floor,Pa=Math.min,J=0,Qa=null,Ra=null;e.preloadedImages={};e.preloadedAudios={};
|
||||
function x(a){if(e.onAbort)e.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=e.locateFile?e.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({ub:function(){Za()}});function $a(){return 0<$a.Za}
|
||||
function ab(a,b){for(var c=0,d=a.length-1;0<=d;d--){var f=a[d];"."===f?a.splice(d,1):".."===f?(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:[],Ya: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.Ya.flush(a.tty)},flush:function(a){a.tty.Ya.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Ya.nb)throw new L(60);for(var f=0,g=0;g<d;g++){try{var h=a.tty.Ya.nb(a.tty)}catch(k){throw new L(29);}if(void 0===h&&0===f)throw new L(6);if(null===h||void 0===h)break;f++;b[c+g]=h}f&&(a.node.timestamp=Date.now());return f},write:function(a,b,c,d){if(!a.tty||!a.tty.Ya.eb)throw new L(60);
|
||||
try{for(var f=0;f<d;f++)a.tty.Ya.eb(a.tty,b[c+f])}catch(g){throw new L(29);}d&&(a.node.timestamp=Date.now());return f}},jb={nb:function(a){if(!a.input.length){var b=null;if(ea){var c=Buffer.Za?Buffer.Za(256):new Buffer(256),d=0;try{d=ja.readSync(process.stdin.fd,c,0,256,null)}catch(f){if(-1!=f.toString().indexOf("EOF"))d=0;else throw f;}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()},eb: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={eb: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={Qa:null,
|
||||
Ua: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.Qa||(M.Qa={dir:{node:{Va:M.Na.Va,Sa:M.Na.Sa,lookup:M.Na.lookup,$a:M.Na.$a,rename:M.Na.rename,unlink:M.Na.unlink,rmdir:M.Na.rmdir,readdir:M.Na.readdir,symlink:M.Na.symlink},stream:{Xa:M.Oa.Xa}},file:{node:{Va:M.Na.Va,Sa:M.Na.Sa},stream:{Xa:M.Oa.Xa,read:M.Oa.read,write:M.Oa.write,hb:M.Oa.hb,ob:M.Oa.ob,qb:M.Oa.qb}},link:{node:{Va:M.Na.Va,Sa:M.Na.Sa,readlink:M.Na.readlink},
|
||||
stream:{}},ib:{node:{Va:M.Na.Va,Sa:M.Na.Sa},stream:lb}});c=mb(a,b,c,d);16384===(c.mode&61440)?(c.Na=M.Qa.dir.node,c.Oa=M.Qa.dir.stream,c.Ma={}):32768===(c.mode&61440)?(c.Na=M.Qa.file.node,c.Oa=M.Qa.file.stream,c.Pa=0,c.Ma=null):40960===(c.mode&61440)?(c.Na=M.Qa.link.node,c.Oa=M.Qa.link.stream):8192===(c.mode&61440)&&(c.Na=M.Qa.ib.node,c.Oa=M.Qa.ib.stream);c.timestamp=Date.now();a&&(a.Ma[b]=c);return c},Lb:function(a){if(a.Ma&&a.Ma.subarray){for(var b=[],c=0;c<a.Pa;++c)b.push(a.Ma[c]);return b}return a.Ma},
|
||||
Mb:function(a){return a.Ma?a.Ma.subarray?a.Ma.subarray(0,a.Pa):new Uint8Array(a.Ma):new Uint8Array(0)},jb:function(a,b){var c=a.Ma?a.Ma.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.Ma,a.Ma=new Uint8Array(b),0<a.Pa&&a.Ma.set(c.subarray(0,a.Pa),0))},Eb:function(a,b){if(a.Pa!=b)if(0==b)a.Ma=null,a.Pa=0;else{if(!a.Ma||a.Ma.subarray){var c=a.Ma;a.Ma=new Uint8Array(b);c&&a.Ma.set(c.subarray(0,Math.min(b,a.Pa)))}else if(a.Ma||(a.Ma=[]),a.Ma.length>b)a.Ma.length=b;
|
||||
else for(;a.Ma.length<b;)a.Ma.push(0);a.Pa=b}},Na:{Va: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.Pa: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.sb=4096;b.blocks=Math.ceil(b.size/b.sb);return b},Sa:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&
|
||||
(a.timestamp=b.timestamp);void 0!==b.size&&M.Eb(a,b.size)},lookup:function(){throw nb[44];},$a: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 f in d.Ma)throw new L(55);}delete a.parent.Ma[a.name];a.name=c;b.Ma[c]=a;a.parent=b},unlink:function(a,b){delete a.Ma[b]},rmdir:function(a,b){var c=ob(a,b),d;for(d in c.Ma)throw new L(55);delete a.Ma[b]},readdir:function(a){var b=[".",".."],c;for(c in a.Ma)a.Ma.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}},Oa:{read:function(a,b,c,d,f){var g=a.node.Ma;if(f>=a.node.Pa)return 0;a=Math.min(a.node.Pa-f,d);if(8<a&&g.subarray)b.set(g.subarray(f,f+a),c);else for(d=0;d<a;d++)b[c+d]=g[f+d];return a},write:function(a,b,c,d,f,g){b.buffer===H.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.Ma||a.Ma.subarray)){if(g)return a.Ma=
|
||||
b.subarray(c,c+d),a.Pa=d;if(0===a.Pa&&0===f)return a.Ma=b.slice(c,c+d),a.Pa=d;if(f+d<=a.Pa)return a.Ma.set(b.subarray(c,c+d),f),d}M.jb(a,f+d);if(a.Ma.subarray&&b.subarray)a.Ma.set(b.subarray(c,c+d),f);else for(g=0;g<d;g++)a.Ma[f+g]=b[c+g];a.Pa=Math.max(a.Pa,f+d);return d},Xa:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.Pa);if(0>b)throw new L(28);return b},hb:function(a,b,c){M.jb(a.node,b+c);a.node.Pa=Math.max(a.node.Pa,b+c)},ob:function(a,b,c,d,f,g){assert(0===
|
||||
b);if(32768!==(a.node.mode&61440))throw new L(43);a=a.node.Ma;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{Qb:c,Kb:d}},qb:function(a,b,c,d,f){if(32768!==(a.node.mode&61440))throw new L(43);if(f&2)return 0;M.Oa.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={mb:!0,fb:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.fb)throw new L(32);a=ab(a.split("/").filter(function(h){return!!h}),!1);var f=qb;c="/";for(d=0;d<a.length;d++){var g=d===a.length-1;if(g&&b.parent)break;f=ob(f,a[d]);c=bb(c+"/"+a[d]);f.ab&&(!g||g&&b.mb)&&(f=f.ab.root);if(!g||b.lb)for(g=0;40960===(f.mode&61440);)if(f=xb(c),c=eb(cb(c),f),f=N(c,{fb:b.fb}).node,40<g++)throw new L(32);}return{path:c,node:f}}
|
||||
function yb(a){for(var b;;){if(a===a.parent)return a=a.Ua.pb,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.Na.lookup?0:2)throw new L(c,a);for(c=ub[zb(a.id,b)];c;c=c.Bb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.Na.lookup(a,b)}
|
||||
function mb(a,b,c,d){a=new Bb(a,b,c,d);b=zb(a.parent.id,a.name);a.Bb=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.Oa=rb[a.node.rdev].Oa;a.Oa.open&&a.Oa.open(a)},Xa:function(){throw new L(70);}};function hb(a,b){rb[a]={Oa:b}}
|
||||
function Ib(a,b){var c="/"===b,d=!b;if(c&&qb)throw new L(10);if(!c&&!d){var f=N(b,{mb:!1});b=f.path;f=f.node;if(f.ab)throw new L(10);if(16384!==(f.mode&61440))throw new L(54);}b={type:a,Pb:{},pb:b,Ab:[]};a=a.Ua(b);a.Ua=b;b.root=a;c?qb=a:f&&(f.ab=b,f.Ua&&f.Ua.Ab.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 f=Eb(d,a);if(f)throw new L(f);if(!d.Na.$a)throw new L(63);return d.Na.$a(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.Na.symlink)throw new L(63);c.Na.symlink(c,b,a)}function xb(a){a=N(a).node;if(!a)throw new L(44);if(!a.Na.readlink)throw new L(28);return eb(yb(a.parent),a.Na.readlink(a))}
|
||||
function Mb(a,b,c,d){if(""===a)throw new L(44);if("string"===typeof b){var f=Cb[b];if("undefined"===typeof f)throw Error("Unknown file open mode: "+b);b=f}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,{lb:!(b&131072)}).node}catch(k){}}f=!1;if(b&64)if(g){if(b&128)throw new L(20);}else g=Jb(a,c,0),f=!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(!f&&(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,{lb:!0}).node:h=c;if(!h.Na.Sa)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.Na.Sa(h,{size:0,timestamp:Date.now()})}b&=-131713;d=Gb({node:g,path:yb(g),flags:b,seekable:!0,position:0,Oa:g.Oa,Jb:[],error:!1},d);d.Oa.open&&d.Oa.open(d);!e.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.Oa.Xa)throw new L(70);if(0!=c&&1!=c&&2!=c)throw new L(28);a.position=a.Oa.Xa(a,b,c);a.Jb=[]}
|
||||
function Pb(){L||(L=function(a,b){this.node=b;this.Fb=function(c){this.Wa=c};this.Fb(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 f=Tb++<<8|0;hb(f,{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,f)}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 f=Array(b.length),g=[],h=0;b.forEach(function(k,l){R.hasOwnProperty(k)?f[l]=R[k]:(g.push(k),$b.hasOwnProperty(k)||($b[k]=[]),$b[k].push(function(){f[l]=R[k];++h;h===g.length&&d(f)}))});0===g.length&&d(f)}
|
||||
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.yb)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(f){f()}))}var kc=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function lc(a){4<a&&0===--V[a].gb&&(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]={gb: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=e;if(void 0===c[a].Ra){var d=c[a];c[a]=function(){c[a].Ra.hasOwnProperty(arguments.length)||U("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].Ra+")!");return c[a].Ra[arguments.length].apply(this,arguments)};c[a].Ra=[];c[a].Ra[d.rb]=d}}
|
||||
function rc(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].Ra&&void 0!==e[a].Ra[c])&&U("Cannot register public name '"+a+"' twice"),qc(a,a),e.hasOwnProperty(c)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].Ra[c]=b):(e[a]=b,void 0!==c&&(e[a].Ob=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=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&&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){f[g]||R[g]||(ac[g]?ac[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};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 D[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.Ua=a.Ua;this.ab=null;this.id=tb++;this.name=b;this.mode=c;this.Na={};this.Oa={};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,f,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({Ua:function(){var a=mb("/proc/self","fd",16895,73);a.Na={lookup:function(b,c){var d=sb[+c];if(!d)throw new L(8);b={parent:null,Ua:{pb:"fake"},Na:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");ec=e.InternalError=dc("InternalError");for(var Dc=Array(256),Ec=0;256>Ec;++Ec)Dc[Ec]=String.fromCharCode(Ec);ic=Dc;jc=e.BindingError=dc("BindingError");
|
||||
e.count_emval_handles=function(){for(var a=0,b=5;b<V.length;++b)void 0!==V[b]&&++a;return a};e.get_first_emval=function(){for(var a=5;a<V.length;++a)if(void 0!==V[a])return V[a];return null};uc=e.UnboundTypeError=dc("UnboundTypeError");
|
||||
var Sc={w:function(a){return pb(a)},U:function(){},S:function(a){"uncaught_exception"in $a?$a.Za++:$a.Za=1;throw a;},q:function(a,b,c){Ub=c;try{var d=Wb(a);switch(b){case 0:var f=Vb();return 0>f?-28:Mb(d.path,d.flags,0,f).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return f=Vb(),d.flags|=f,0;case 12:return f=Vb(),D[f+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.Wa}},
|
||||
M: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 f=Vb();return F[f>>2]=0;case 21520:return d.tty?-28:-59;case 21531:a=f=Vb();if(!d.Oa.zb)throw new L(59);return d.Oa.zb(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.Wa}},N:function(a,
|
||||
b,c){Ub=c;try{var d=a?B(C,a,void 0):"",f=Vb();return Mb(d,b,f).fd}catch(g){return"undefined"!==typeof Q&&g instanceof L||x(g),-g.Wa}},A:function(a){var b=Xb[a];delete Xb[a];var c=b.Cb,d=b.Db,f=b.kb,g=f.map(function(h){return h.xb}).concat(f.map(function(h){return h.Hb}));fc([a],g,function(h){var k={};f.forEach(function(l,n){var p=h[n],t=l.vb,v=l.wb,w=h[n+f.length],q=l.Gb,E=l.Ib;k[l.tb]={read:function(y){return p.fromWireType(t(v,y))},write:function(y,P){var ra=[];q(E,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,Ta:d}]})},P:function(a,b,c,d,f){var g=hc(c);b=T(b);S(a,{name:b,fromWireType:function(h){return!!h},toWireType:function(h,k){return k?d:f},argPackAdvance:8,readValueFromPointer:function(h){if(1===
|
||||
c)var k=H;else if(2===c)k=D;else if(4===c)k=F;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[h>>g])},Ta:null})},O: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,Ta:null})},t:function(a,b,c){c=hc(c);b=T(b);S(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+
|
||||
nc(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:oc(b,c),Ta:null})},y:function(a,b,c,d,f,g){var h=sc(b,c);a=T(a);f=tc(d,f);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=f,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].Ta){w=!0;break}var E="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+=(E?"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].Ta&&(n+=t+"_dtor("+t+"); // "+l[q].name+"\n",y.push(t+"_dtor"),p.push(l[q].Ta));E&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");
|
||||
y.push(n+"}\n");l=pc(y).apply(null,p);q=b-1;if(!e.hasOwnProperty(k))throw new ec("Replacing nonexistant public symbol");void 0!==e[k].Ra&&void 0!==q?e[k].Ra[q]=l:(e[k]=l,e[k].rb=q);return[]})},i:function(a,b,c,d,f){function g(n){return n}b=T(b);-1===f&&(f=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>f)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+", "+f+"]!");return l?p>>>0:p|0},argPackAdvance:8,readValueFromPointer:yc(b,h,0!==d),Ta:null})},f:function(a,b,c){function d(g){g>>=2;var h=I;return new f(G,h[g+1],h[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);S(a,{name:c,fromWireType:d,argPackAdvance:8,
|
||||
readValueFromPointer:d},{yb:!0})},u:function(a,b){b=T(b);var c="std::string"===b;S(a,{name:b,fromWireType:function(d){var f=I[d>>2];if(c)for(var g=d+4,h=0;h<=f;++h){var k=d+4+h;if(h==f||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(f);for(h=0;h<f;++h)l[h]=String.fromCharCode(C[d+4+h]);l=l.join("")}W(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||U("Cannot pass non-string to std::string");var h=(c&&g?function(){return ta(f)}:function(){return f.length})(),k=pb(4+h+1);I[k>>2]=h;if(c&&g)sa(f,C,k+4,h+1);else if(g)for(g=0;g<h;++g){var l=f.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]=f[g];null!==d&&d.push(W,k);return k},argPackAdvance:8,readValueFromPointer:Zb,Ta:function(d){W(d)}})},n:function(a,b,c){c=T(c);if(2===b){var d=
|
||||
va;var f=xa;var g=ya;var h=function(){return wa};var k=1}else 4===b&&(d=za,f=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;f(n,t+4,p+b);null!==l&&l.push(W,t);return t},argPackAdvance:8,
|
||||
readValueFromPointer:Zb,Ta:function(l){W(l)}})},H:function(a,b,c,d,f,g){Xb[a]={name:T(b),Cb:tc(c,d),Db:tc(f,g),kb:[]}},z:function(a,b,c,d,f,g,h,k,l,n){Xb[a].kb.push({tb:T(b),xb:c,vb:tc(d,f),wb:g,Hb:h,Gb:tc(k,l),Ib:n})},Q:function(a,b){b=T(b);S(a,{Nb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},s:lc,T: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].gb+=1)},J:function(a,b,c,d){a||U("Cannot use deleted val. handle = "+
|
||||
a);a=V[a].value;var f=Cc[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")))(Bc,
|
||||
e,mc);Cc[b]=f}return f(a,c,d)},v:function(){x()},d:function(a,b){X(a,b||1);throw"longjmp";},K: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 f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},r:function(a){try{var b=Wb(a);if(null===b.fd)throw new L(8);
|
||||
b.cb&&(b.cb=null);try{b.Oa.close&&b.Oa.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.Wa}},L:function(a,b,c,d){try{a:{for(var f=Wb(a),g=a=0;g<c;g++){var h=F[b+(8*g+4)>>2],k=f,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.Oa.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.Oa.read(k,t,l,n,p);v||(k.position+=w);var q=w;if(0>q){var E=-1;break a}a+=q;if(q<h)break}E=a}F[d>>2]=E;return 0}catch(y){return"undefined"!==typeof Q&&y instanceof L||x(y),y.Wa}},E:function(a,b,c,d,f){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[f>>2]=
|
||||
Ya[0];F[f+4>>2]=Ya[1];g.cb&&0===a&&0===d&&(g.cb=null);return 0}catch(h){return"undefined"!==typeof Q&&h instanceof L||x(h),h.Wa}},p:function(a,b,c,d){try{a:{for(var f=Wb(a),g=a=0;g<c;g++){var h=f,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.Oa.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.Oa.write(h,p,k,l,n,void 0);t||(h.position+=v);try{if(h.path&&wb.onWriteToFile)wb.onWriteToFile(h.path)}catch(E){z("FS.trackingDelegate['onWriteToFile']('"+h.path+"') threw an exception: "+E.message)}var w=v;if(0>w){var q=-1;break a}a+=w}q=a}F[d>>2]=q;return 0}catch(E){return"undefined"!==typeof Q&&E instanceof L||x(E),E.Wa}},a:function(){return ma|0},m:Gc,e:Hc,G:Ic,o:Jc,F:Kc,C:Lc,B:Mc,D:Nc,I:Oc,k:Pc,l:Qc,c:Rc,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)},b:function(a){ma=a|0},table:oa,R:function(a){var b=Date.now()/1E3|0;a&&(F[a>>2]=b);return b}};
|
||||
(function(){function a(f){e.asm=f.exports;J--;e.monitorRunDependencies&&e.monitorRunDependencies(J);0==J&&(null!==Qa&&(clearInterval(Qa),Qa=null),Ra&&(f=Ra,Ra=null,f()))}function b(f){a(f.instance)}function c(f){return Wa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){z("failed to asynchronously prepare wasm: "+g);x(g)})}var d={a:Sc};J++;e.monitorRunDependencies&&e.monitorRunDependencies(J);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return z("Module.instantiateWasm callback failed with error: "+
|
||||
f),!1}(function(){if(na||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(K,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){z("wasm streaming compile failed: "+g);z("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
|
||||
var Za=e.___wasm_call_ctors=function(){return(Za=e.___wasm_call_ctors=e.asm.V).apply(null,arguments)},pb=e._malloc=function(){return(pb=e._malloc=e.asm.W).apply(null,arguments)},W=e._free=function(){return(W=e._free=e.asm.X).apply(null,arguments)},wc=e.___getTypeName=function(){return(wc=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)};
|
||||
var Fc=e.___errno_location=function(){return(Fc=e.___errno_location=e.asm._).apply(null,arguments)},X=e._setThrew=function(){return(X=e._setThrew=e.asm.$).apply(null,arguments)},Y=e.stackSave=function(){return(Y=e.stackSave=e.asm.aa).apply(null,arguments)},Z=e.stackRestore=function(){return(Z=e.stackRestore=e.asm.ba).apply(null,arguments)},Tc=e.dynCall_v=function(){return(Tc=e.dynCall_v=e.asm.ca).apply(null,arguments)},Uc=e.dynCall_vi=function(){return(Uc=e.dynCall_vi=e.asm.da).apply(null,arguments)},
|
||||
Vc=e.dynCall_vii=function(){return(Vc=e.dynCall_vii=e.asm.ea).apply(null,arguments)};e.dynCall_viii=function(){return(e.dynCall_viii=e.asm.fa).apply(null,arguments)};var Wc=e.dynCall_viiii=function(){return(Wc=e.dynCall_viiii=e.asm.ga).apply(null,arguments)},Xc=e.dynCall_ii=function(){return(Xc=e.dynCall_ii=e.asm.ha).apply(null,arguments)},Yc=e.dynCall_iii=function(){return(Yc=e.dynCall_iii=e.asm.ia).apply(null,arguments)};e.dynCall_iiii=function(){return(e.dynCall_iiii=e.asm.ja).apply(null,arguments)};
|
||||
var Zc=e.dynCall_iiiii=function(){return(Zc=e.dynCall_iiiii=e.asm.ka).apply(null,arguments)},$c=e.dynCall_iiiiiiiii=function(){return($c=e.dynCall_iiiiiiiii=e.asm.la).apply(null,arguments)},ad=e.dynCall_iiiiiiiiii=function(){return(ad=e.dynCall_iiiiiiiiii=e.asm.ma).apply(null,arguments)},bd=e.dynCall_iiiijj=function(){return(bd=e.dynCall_iiiijj=e.asm.na).apply(null,arguments)},cd=e.dynCall_ij=function(){return(cd=e.dynCall_ij=e.asm.oa).apply(null,arguments)},dd=e.dynCall_jjij=function(){return(dd=
|
||||
e.dynCall_jjij=e.asm.pa).apply(null,arguments)};e.dynCall_i=function(){return(e.dynCall_i=e.asm.qa).apply(null,arguments)};e.dynCall_iiiiii=function(){return(e.dynCall_iiiiii=e.asm.ra).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.sa).apply(null,arguments)};e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.ta).apply(null,arguments)};e.dynCall_viiiiiiii=function(){return(e.dynCall_viiiiiiii=e.asm.ua).apply(null,arguments)};
|
||||
e.dynCall_viiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiii=e.asm.va).apply(null,arguments)};e.dynCall_viiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiii=e.asm.wa).apply(null,arguments)};e.dynCall_viiiiiii=function(){return(e.dynCall_viiiiiii=e.asm.xa).apply(null,arguments)};e.dynCall_viiiiiiiii=function(){return(e.dynCall_viiiiiiiii=e.asm.ya).apply(null,arguments)};e.dynCall_jiiiiiiiii=function(){return(e.dynCall_jiiiiiiiii=e.asm.za).apply(null,arguments)};
|
||||
e.dynCall_iiiiiii=function(){return(e.dynCall_iiiiiii=e.asm.Aa).apply(null,arguments)};e.dynCall_iiiiiiii=function(){return(e.dynCall_iiiiiiii=e.asm.Ba).apply(null,arguments)};e.dynCall_iiiiiiiiiiii=function(){return(e.dynCall_iiiiiiiiiiii=e.asm.Ca).apply(null,arguments)};e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.Da).apply(null,arguments)};e.dynCall_iidiiii=function(){return(e.dynCall_iidiiii=e.asm.Ea).apply(null,arguments)};
|
||||
e.dynCall_viiiiiiiiii=function(){return(e.dynCall_viiiiiiiiii=e.asm.Fa).apply(null,arguments)};e.dynCall_viiiiiiiiiiiii=function(){return(e.dynCall_viiiiiiiiiiiii=e.asm.Ga).apply(null,arguments)};e.dynCall_jiiiiiiii=function(){return(e.dynCall_jiiiiiiii=e.asm.Ha).apply(null,arguments)};e.dynCall_ff=function(){return(e.dynCall_ff=e.asm.Ia).apply(null,arguments)};e.dynCall_jiiiiii=function(){return(e.dynCall_jiiiiii=e.asm.Ja).apply(null,arguments)};
|
||||
e.dynCall_jiiiii=function(){return(e.dynCall_jiiiii=e.asm.Ka).apply(null,arguments)};e.dynCall_iiijii=function(){return(e.dynCall_iiijii=e.asm.La).apply(null,arguments)};function Qc(a,b,c){var d=Y();try{Vc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}function Rc(a,b,c,d,f){var g=Y();try{Wc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}function Hc(a,b,c){var d=Y();try{return Yc(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}
|
||||
function Pc(a,b){var c=Y();try{Uc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Oc(a){var b=Y();try{Tc(a)}catch(c){Z(b);if(c!==c+0&&"longjmp"!==c)throw c;X(1,0)}}function Gc(a,b){var c=Y();try{return Xc(a,b)}catch(d){Z(c);if(d!==d+0&&"longjmp"!==d)throw d;X(1,0)}}function Ic(a,b,c,d,f){var g=Y();try{return Zc(a,b,c,d,f)}catch(h){Z(g);if(h!==h+0&&"longjmp"!==h)throw h;X(1,0)}}
|
||||
function Kc(a,b,c,d,f,g,h,k,l,n){var p=Y();try{return ad(a,b,c,d,f,g,h,k,l,n)}catch(t){Z(p);if(t!==t+0&&"longjmp"!==t)throw t;X(1,0)}}function Jc(a,b,c,d,f,g,h,k,l){var n=Y();try{return $c(a,b,c,d,f,g,h,k,l)}catch(p){Z(n);if(p!==p+0&&"longjmp"!==p)throw p;X(1,0)}}function Nc(a,b,c,d,f,g){var h=Y();try{return dd(a,b,c,d,f,g)}catch(k){Z(h);if(k!==k+0&&"longjmp"!==k)throw k;X(1,0)}}
|
||||
function Lc(a,b,c,d,f,g,h,k){var l=Y();try{return bd(a,b,c,d,f,g,h,k)}catch(n){Z(l);if(n!==n+0&&"longjmp"!==n)throw n;X(1,0)}}function Mc(a,b,c){var d=Y();try{return cd(a,b,c)}catch(f){Z(d);if(f!==f+0&&"longjmp"!==f)throw f;X(1,0)}}var ed;Ra=function fd(){ed||gd();ed||(Ra=fd)};
|
||||
function gd(){function a(){if(!ed&&(ed=!0,e.calledRun=!0,!pa)){e.noFSInit||Qb||(Qb=!0,Pb(),e.stdin=e.stdin,e.stdout=e.stdout,e.stderr=e.stderr,e.stdin?Sb("stdin",e.stdin):Lb("/dev/tty","/dev/stdin"),e.stdout?Sb("stdout",null,e.stdout):Lb("/dev/tty","/dev/stdout"),e.stderr?Sb("stderr",null,e.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(e);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();Ka.unshift(b)}Ga(Ka)}}if(!(0<J)){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)La();Ga(Ha);0<J||(e.setStatus?(e.setStatus("Running..."),setTimeout(function(){setTimeout(function(){e.setStatus("")},1);a()},1)):a())}}e.run=gd;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;gd();
|
||||
|
||||
|
||||
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;
|
||||
|
BIN
codecs/avif/enc/avif_enc.wasm
Normal file
BIN
codecs/avif/enc/avif_enc.wasm
Normal file
Binary file not shown.
6
codecs/avif/package.json
Normal file
6
codecs/avif/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "avif",
|
||||
"scripts": {
|
||||
"build": "../build-cpp.sh"
|
||||
}
|
||||
}
|
3
codecs/build-cpp.sh
Executable file
3
codecs/build-cpp.sh
Executable 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
4
codecs/build-rust.sh
Executable 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
9
codecs/cpp.Dockerfile
Normal 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`"]
|
6
codecs/hqx/.gitignore
vendored
6
codecs/hqx/.gitignore
vendored
@ -1,5 +1 @@
|
||||
**/*.rs.bk
|
||||
target
|
||||
Cargo.lock
|
||||
bin/
|
||||
pkg/README.md
|
||||
/target
|
||||
|
289
codecs/hqx/Cargo.lock
generated
Normal file
289
codecs/hqx/Cargo.lock
generated
Normal 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"
|
@ -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
|
||||
|
@ -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 "============================================="
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,5 @@
|
||||
],
|
||||
"module": "squooshhqx.js",
|
||||
"types": "squooshhqx.d.ts",
|
||||
"sideEffects": "false"
|
||||
"sideEffects": false
|
||||
}
|
11
codecs/hqx/pkg/squooshhqx.d.ts
vendored
11
codecs/hqx/pkg/squooshhqx.d.ts
vendored
@ -1,9 +1,10 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* @param {Uint32Array} input_image
|
||||
* @param {number} input_width
|
||||
* @param {number} input_height
|
||||
* @param {number} factor
|
||||
* @returns {Uint32Array}
|
||||
* @param {Uint32Array} input_image
|
||||
* @param {number} input_width
|
||||
* @param {number} input_height
|
||||
* @param {number} factor
|
||||
* @returns {Uint32Array}
|
||||
*/
|
||||
export function resize(input_image: Uint32Array, input_width: number, input_height: number, factor: number): Uint32Array;
|
||||
|
@ -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";
|
3
codecs/hqx/pkg/squooshhqx_bg.d.ts
vendored
3
codecs/hqx/pkg/squooshhqx_bg.d.ts
vendored
@ -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;
|
||||
|
48
codecs/hqx/pkg/squooshhqx_bg.js
Normal file
48
codecs/hqx/pkg/squooshhqx_bg.js
Normal 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.
40
codecs/imagequant/Makefile
Normal file
40
codecs/imagequant/Makefile
Normal 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
|
@ -24,7 +24,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()`.
|
||||
|
@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export EM_CACHE="${PWD}/node_modules/.em_cache"
|
||||
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
||||
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 \
|
||||
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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@ -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');
|
||||
|
@ -14,48 +14,43 @@ int version() {
|
||||
(((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>>
|
||||
|
||||
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);
|
||||
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_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;
|
||||
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[] = {
|
||||
@ -76,19 +71,17 @@ const liq_color zx_colors[] = {
|
||||
{.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.
|
||||
*/
|
||||
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) {
|
||||
@ -111,25 +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.
|
||||
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);
|
||||
int distance =
|
||||
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;
|
||||
@ -193,53 +183,34 @@ RawImage zx_quantize(std::string rawimage, int image_width, int image_height, fl
|
||||
}
|
||||
|
||||
// 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++) {
|
||||
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);
|
||||
}
|
||||
|
13
codecs/imagequant/imagequant.d.ts
vendored
13
codecs/imagequant/imagequant.d.ts
vendored
@ -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;
|
||||
|
||||
|
||||
|
@ -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:55,maximum:55,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[1612]=5249488;function Ba(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b();else{var c=b.ta;"number"===typeof c?void 0===b.la?e.dynCall_v(c):e.dynCall_vi(c,b.la):c(void 0===b.la?null:b.la)}}}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({ta:function(){Ma()}});function Na(){return 0<Na.ga}
|
||||
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="";H[a];)b+=Pa[H[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(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 Ua=void 0;function S(a){throw new Ua(a);}var Va=void 0;function Wa(a){throw new Va(a);}function Xa(a,b,c){function d(h){h=c(h);h.length!==a.length&&Wa("Mismatched type converter count");for(var k=0;k<a.length;++k)T(a[k],h[k])}a.forEach(function(h){Qa[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.wa)return;S("Cannot register type '"+d+"' twice")}R[a]=b;delete Qa[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}function Ya(a){return{count:a.count,fa:a.fa,ha:a.ha,V:a.V,X:a.X,Y:a.Y,Z:a.Z}}
|
||||
function Za(a){S(a.U.X.W.name+" instance already deleted")}var $a=!1;function ab(){}function bb(a){--a.count.value;0===a.count.value&&(a.Y?a.Z.ea(a.Y):a.X.W.ea(a.V))}function cb(a){if("undefined"===typeof FinalizationGroup)return cb=function(b){return b},a;$a=new FinalizationGroup(function(b){for(var c=b.next();!c.done;c=b.next())c=c.value,c.V?bb(c):console.warn("object already deleted: "+c.V)});cb=function(b){$a.register(b,b.U,b.U);return b};ab=function(b){$a.unregister(b.U)};return cb(a)}
|
||||
var db=void 0,eb=[];function fb(){for(;eb.length;){var a=eb.pop();a.U.fa=!1;a["delete"]()}}function U(){}var gb={};function hb(a,b){var c=e;if(void 0===c[a].aa){var d=c[a];c[a]=function(){c[a].aa.hasOwnProperty(arguments.length)||S("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].aa+")!");return c[a].aa[arguments.length].apply(this,arguments)};c[a].aa=[];c[a].aa[d.qa]=d}}
|
||||
function ib(a,b,c){e.hasOwnProperty(a)?((void 0===c||void 0!==e[a].aa&&void 0!==e[a].aa[c])&&S("Cannot register public name '"+a+"' twice"),hb(a,a),e.hasOwnProperty(c)&&S("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),e[a].aa[c]=b):(e[a]=b,void 0!==c&&(e[a].Ca=c))}function jb(a,b,c,d,f,g,n,h){this.name=a;this.constructor=b;this.da=c;this.ea=d;this.$=f;this.ua=g;this.ia=n;this.sa=h}
|
||||
function kb(a,b,c){for(;b!==c;)b.ia||S("Expected null or instance of "+c.name+", got an instance of "+b.name),a=b.ia(a),b=b.$;return a}function lb(a,b){if(null===b)return this.ma&&S("null is not a valid "+this.name),0;b.U||S('Cannot pass "'+V(b)+'" as a '+this.name);b.U.V||S("Cannot pass deleted object as a pointer of type "+this.name);return kb(b.U.V,b.U.X.W,this.W)}
|
||||
function mb(a,b){if(null===b){this.ma&&S("null is not a valid "+this.name);if(this.ka){var c=this.ya();null!==a&&a.push(this.ea,c);return c}return 0}b.U||S('Cannot pass "'+V(b)+'" as a '+this.name);b.U.V||S("Cannot pass deleted object as a pointer of type "+this.name);!this.ja&&b.U.X.ja&&S("Cannot convert argument of type "+(b.U.Z?b.U.Z.name:b.U.X.name)+" to parameter type "+this.name);c=kb(b.U.V,b.U.X.W,this.W);if(this.ka)switch(void 0===b.U.Y&&S("Passing raw pointer to smart pointer is illegal"),
|
||||
this.Aa){case 0:b.U.Z===this?c=b.U.Y:S("Cannot convert argument of type "+(b.U.Z?b.U.Z.name:b.U.X.name)+" to parameter type "+this.name);break;case 1:c=b.U.Y;break;case 2:if(b.U.Z===this)c=b.U.Y;else{var d=b.clone();c=this.za(c,nb(function(){d["delete"]()}));null!==a&&a.push(this.ea,c)}break;default:S("Unsupporting sharing policy")}return c}
|
||||
function ob(a,b){if(null===b)return this.ma&&S("null is not a valid "+this.name),0;b.U||S('Cannot pass "'+V(b)+'" as a '+this.name);b.U.V||S("Cannot pass deleted object as a pointer of type "+this.name);b.U.X.ja&&S("Cannot convert argument of type "+b.U.X.name+" to parameter type "+this.name);return kb(b.U.V,b.U.X.W,this.W)}function pb(a){return this.fromWireType(L[a>>2])}function rb(a,b,c){if(b===c)return a;if(void 0===c.$)return null;a=rb(a,b,c.$);return null===a?null:c.sa(a)}var sb={};
|
||||
function tb(a,b){for(void 0===b&&S("ptr should not be undefined");a.$;)b=a.ia(b),a=a.$;return sb[b]}function ub(a,b){b.X&&b.V||Wa("makeClassHandle requires ptr and ptrType");!!b.Z!==!!b.Y&&Wa("Both smartPtrType and smartPtr must be specified");b.count={value:1};return cb(Object.create(a,{U:{value:b}}))}
|
||||
function W(a,b,c,d){this.name=a;this.W=b;this.ma=c;this.ja=d;this.ka=!1;this.ea=this.za=this.ya=this.pa=this.Aa=this.xa=void 0;void 0!==b.$?this.toWireType=mb:(this.toWireType=d?lb:ob,this.ba=null)}function vb(a,b,c){e.hasOwnProperty(a)||Wa("Replacing nonexistant public symbol");void 0!==e[a].aa&&void 0!==c?e[a].aa[c]=b:(e[a]=b,e[a].qa=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 wb=void 0;function xb(a){a=yb(a);var b=P(a);Y(a);return b}
|
||||
function zb(a,b){function c(g){f[g]||R[g]||(Qa[g]?Qa[g].forEach(c):(d.push(g),f[g]=!0))}var d=[],f={};b.forEach(c);throw new wb(a+": "+d.map(xb).join([", "]));}function Ab(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Bb(a,b,c){a instanceof Object||S(c+' with invalid "this": '+a);a instanceof b.W.constructor||S(c+' incompatible with "this" of type '+a.constructor.name);a.U.V||S("cannot call emscripten binding method "+c+" on deleted object");return kb(a.U.V,a.U.X.W,b.W)}
|
||||
var Cb=[],Z=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Db(a){4<a&&0===--Z[a].na&&(Z[a]=void 0,Cb.push(a))}function nb(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Cb.length?Cb.pop():Z.length;Z[b]={na: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 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=Sa(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){for(var c=[],d=0;d<a;d++)c.push(J[(b>>2)+d]);return c}function Hb(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 Ib=[null,[],[]],Jb=Array(256),Kb=0;256>Kb;++Kb)Jb[Kb]=String.fromCharCode(Kb);Pa=Jb;Ua=e.BindingError=Ta("BindingError");
|
||||
Va=e.InternalError=Ta("InternalError");U.prototype.isAliasOf=function(a){if(!(this instanceof U&&a instanceof U))return!1;var b=this.U.X.W,c=this.U.V,d=a.U.X.W;for(a=a.U.V;b.$;)c=b.ia(c),b=b.$;for(;d.$;)a=d.ia(a),d=d.$;return b===d&&c===a};U.prototype.clone=function(){this.U.V||Za(this);if(this.U.ha)return this.U.count.value+=1,this;var a=cb(Object.create(Object.getPrototypeOf(this),{U:{value:Ya(this.U)}}));a.U.count.value+=1;a.U.fa=!1;return a};
|
||||
U.prototype["delete"]=function(){this.U.V||Za(this);this.U.fa&&!this.U.ha&&S("Object already scheduled for deletion");ab(this);bb(this.U);this.U.ha||(this.U.Y=void 0,this.U.V=void 0)};U.prototype.isDeleted=function(){return!this.U.V};U.prototype.deleteLater=function(){this.U.V||Za(this);this.U.fa&&!this.U.ha&&S("Object already scheduled for deletion");eb.push(this);1===eb.length&&db&&db(fb);this.U.fa=!0;return this};W.prototype.va=function(a){this.pa&&(a=this.pa(a));return a};
|
||||
W.prototype.oa=function(a){this.ea&&this.ea(a)};W.prototype.argPackAdvance=8;W.prototype.readValueFromPointer=pb;W.prototype.deleteObject=function(a){if(null!==a)a["delete"]()};
|
||||
W.prototype.fromWireType=function(a){function b(){return this.ka?ub(this.W.da,{X:this.xa,V:c,Z:this,Y:a}):ub(this.W.da,{X:this,V:a})}var c=this.va(a);if(!c)return this.oa(a),null;var d=tb(this.W,c);if(void 0!==d){if(0===d.U.count.value)return d.U.V=c,d.U.Y=a,d.clone();d=d.clone();this.oa(a);return d}d=this.W.ua(c);d=gb[d];if(!d)return b.call(this);d=this.ja?d.ra:d.pointerType;var f=rb(c,this.W,d.W);return null===f?b.call(this):this.ka?ub(d.W.da,{X:d,V:f,Z:this,Y:a}):ub(d.W.da,{X:d,V:f})};
|
||||
e.getInheritedInstanceCount=function(){return Object.keys(sb).length};e.getLiveInheritedInstances=function(){var a=[],b;for(b in sb)sb.hasOwnProperty(b)&&a.push(sb[b]);return a};e.flushPendingDeletes=fb;e.setDelayFunction=function(a){db=a;eb.length&&db&&db(fb)};wb=e.UnboundTypeError=Ta("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 Mb={o:function(a){return Lb(a)},n:function(a){"uncaught_exception"in Na?Na.ga++:Na.ga=1;throw a;},u:function(a,b,c,d,f){var g=Oa(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])},ba: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=Ra(m);ib(u,function(){zb("Cannot construct "+m+" due to unbound types",[d])});Xa([a,b,c],d?[d]:[],function(p){p=p[0];if(d){var w=p.W;var x=w.da}else x=U.prototype;p=Sa(u,function(){if(Object.getPrototypeOf(this)!==y)throw new Ua("Use 'new' to construct "+m);if(void 0===D.ga)throw new Ua(m+" has no accessible constructor");var qb=D.ga[arguments.length];if(void 0===qb)throw new Ua("Tried to invoke ctor of "+m+" with invalid number of parameters ("+arguments.length+") - expected ("+
|
||||
Object.keys(D.ga).toString()+") parameters instead!");return qb.apply(this,arguments)});var y=Object.create(x,{constructor:{value:p}});p.prototype=y;var D=new jb(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);gb[a]={pointerType:x,ra:fa};vb(u,p);return[w,x,fa]})},e:function(a,b,c,d,f,g,n,h,k,l){b=P(b);f=X(d,f);Xa([],[a],function(m){m=m[0];var q=m.name+"."+b,v={get:function(){zb("Cannot access "+q+" due to unbound types",[c,n])},enumerable:!0,configurable:!0};
|
||||
k?v.set=function(){zb("Cannot access "+q+" due to unbound types",[c,n])}:v.set=function(){S(q+" is a read-only property")};Object.defineProperty(m.W.da,b,v);Xa([],k?[c,n]:[c],function(u){var p=u[0],w={get:function(){var y=Bb(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=Bb(this,m,q+" setter"),fa=[];k(l,D,x.toWireType(fa,y));Ab(fa)}}Object.defineProperty(m.W.da,b,w);return[]});return[]})},t:function(a,b){b=P(b);T(a,{name:b,fromWireType:function(c){var d=
|
||||
Z[c].value;Db(c);return d},toWireType:function(c,d){return nb(d)},argPackAdvance:8,readValueFromPointer:pb,ba:null})},h:function(a,b,c){c=Oa(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:Eb(b,c),ba:null})},d:function(a,b,c,d,f,g){var n=Gb(b,c);a=P(a);f=X(d,f);ib(a,function(){zb("Cannot call "+a+" due to unbound types",
|
||||
n)},b-1);Xa([],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].ba){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 "+Ra(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,Ab,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].ba&&(l+=q+"_dtor("+q+"); // "+k[p].name+"\n",x.push(q+"_dtor"),m.push(k[p].ba));w&&(l+="var ret = retType.fromWireType(rv);\nreturn ret;\n");x.push(l+"}\n");k=Fb(x).apply(null,m);vb(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=Oa(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:Hb(b,n,0!==d),ba: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},{wa:!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=Lb(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:pb,ba:function(d){Y(d)}})},f: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=Lb(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:pb,ba:function(k){Y(k)}})},v:function(a,b){b=P(b);T(a,{Ba:!0,
|
||||
name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},g:Db,w:function(a){4<a&&(Z[a].na+=1)},k:function(a,b){var c=R[a];void 0===c&&S("_emval_take_value has unknown type "+xb(a));a=c.readValueFromPointer(b);return nb(a)},m:function(){C()},s:function(a,b,c){H.copyWithin(a,b,b+c)},c: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},l:function(){return 0},q:function(){},j: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=Ib[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,r:function(){},table:ja},Nb=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:Mb};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=Nb;
|
||||
var Ma=e.___wasm_call_ctors=function(){return(Ma=e.___wasm_call_ctors=e.asm.x).apply(null,arguments)},Lb=e._malloc=function(){return(Lb=e._malloc=e.asm.y).apply(null,arguments)},Y=e._free=function(){return(Y=e._free=e.asm.z).apply(null,arguments)},yb=e.___getTypeName=function(){return(yb=e.___getTypeName=e.asm.A).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.B).apply(null,arguments)};
|
||||
e.dynCall_ii=function(){return(e.dynCall_ii=e.asm.C).apply(null,arguments)};e.dynCall_vi=function(){return(e.dynCall_vi=e.asm.D).apply(null,arguments)};e.dynCall_iii=function(){return(e.dynCall_iii=e.asm.E).apply(null,arguments)};e.dynCall_viii=function(){return(e.dynCall_viii=e.asm.F).apply(null,arguments)};e.dynCall_iiiiiif=function(){return(e.dynCall_iiiiiif=e.asm.G).apply(null,arguments)};e.dynCall_viiiiif=function(){return(e.dynCall_viiiiif=e.asm.H).apply(null,arguments)};
|
||||
e.dynCall_iiiiif=function(){return(e.dynCall_iiiiif=e.asm.I).apply(null,arguments)};e.dynCall_viiiif=function(){return(e.dynCall_viiiif=e.asm.J).apply(null,arguments)};e.dynCall_i=function(){return(e.dynCall_i=e.asm.K).apply(null,arguments)};e.dynCall_v=function(){return(e.dynCall_v=e.asm.L).apply(null,arguments)};e.dynCall_vif=function(){return(e.dynCall_vif=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_iiii=function(){return(e.dynCall_iiii=e.asm.P).apply(null,arguments)};e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.Q).apply(null,arguments)};e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.R).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.S).apply(null,arguments)};e.dynCall_viiii=function(){return(e.dynCall_viiii=e.asm.T).apply(null,arguments)};e.asm=Nb;var Ob;
|
||||
e.then=function(a){if(Ob)a(e);else{var b=e.onRuntimeInitialized;e.onRuntimeInitialized=function(){b&&b();a(e)}}return e};N=function Pb(){Ob||Qb();Ob||(N=Pb)};
|
||||
function Qb(){function a(){if(!Ob&&(Ob=!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=Qb;if(e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);0<e.preInit.length;)e.preInit.pop()();noExitRuntime=!0;Qb();
|
||||
|
||||
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.
1145
codecs/imagequant/package-lock.json
generated
1145
codecs/imagequant/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
}
|
||||
}
|
||||
|
1
codecs/jxl/.gitignore
vendored
Normal file
1
codecs/jxl/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
67
codecs/jxl/Makefile
Normal file
67
codecs/jxl/Makefile
Normal file
@ -0,0 +1,67 @@
|
||||
CODEC_URL = https://gitlab.com/wg1/jpeg-xl.git
|
||||
CODEC_VERSION = 4d70bd58fbcb758b61446aba447fedd9177a00c9
|
||||
CODEC_DIR = node_modules/jxl
|
||||
CODEC_BUILD_DIR := $(CODEC_DIR)/build
|
||||
CODEC_OUT := $(CODEC_BUILD_DIR)/lib/libjxl.a
|
||||
|
||||
OUT_JS = enc/jxl_enc.js dec/jxl_dec.js
|
||||
OUT_WASM = $(OUT_JS:.js=.wasm)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(OUT_JS)
|
||||
|
||||
%.js: %.cpp $(LIBAOM_OUT) $(CODEC_OUT)
|
||||
$(CXX) \
|
||||
-I $(CODEC_DIR) \
|
||||
-I $(CODEC_DIR)/lib \
|
||||
-I $(CODEC_DIR)/lib/include \
|
||||
-I $(CODEC_BUILD_DIR)/lib/include \
|
||||
-I $(CODEC_DIR)/third_party/highway \
|
||||
-I $(CODEC_DIR)/third_party/skcms \
|
||||
-I $(CODEC_DIR)/third_party/brunsli \
|
||||
-I $(CODEC_DIR)/third_party/brunsli/c/include \
|
||||
${CXXFLAGS} \
|
||||
${LDFLAGS} \
|
||||
--bind \
|
||||
--closure 1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MAXIMUM_MEMORY=4GB \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
||||
-o $@ \
|
||||
$+ \
|
||||
$(CODEC_BUILD_DIR)/artifacts/libbrunslienc-static.bc \
|
||||
$(CODEC_BUILD_DIR)/artifacts/libbrunslicommon-static.bc \
|
||||
$(CODEC_BUILD_DIR)/artifacts/libbrunslidec-static.bc \
|
||||
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlidec-static.a \
|
||||
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlienc-static.a \
|
||||
$(CODEC_BUILD_DIR)/third_party/brotli/libbrotlicommon-static.a \
|
||||
$(CODEC_BUILD_DIR)/third_party/libskcms.a \
|
||||
$(CODEC_BUILD_DIR)/third_party/highway/libhwy.a
|
||||
|
||||
$(CODEC_OUT): $(CODEC_DIR)/CMakeLists.txt
|
||||
mkdir -p $(CODEC_BUILD_DIR)
|
||||
cd $(CODEC_BUILD_DIR) && \
|
||||
emcmake cmake ../ && \
|
||||
$(MAKE) jxl-static
|
||||
|
||||
$(CODEC_DIR)/CMakeLists.txt: $(CODEC_DIR)
|
||||
|
||||
$(CODEC_DIR):
|
||||
# The JXL repository doesn’t have version tags or anything yet,
|
||||
# so we have to pin to a specific commit for now. This implies we
|
||||
# can’t use --recursive, as we will change commit after checkout (it
|
||||
# seems you can’t clone a specific commit directly), and it also means
|
||||
# we can’t use --depth 1 because we want to change commits.
|
||||
# The JXL code base also relies on submodules so we can’t just download
|
||||
# a .tar.gz from GitLab.
|
||||
mkdir -p $@
|
||||
git clone $(CODEC_URL) $@
|
||||
cd $@ && \
|
||||
git reset --hard $(CODEC_VERSION) && \
|
||||
git submodule update --init --recursive
|
||||
|
||||
clean:
|
||||
$(RM) $(OUT_JS) $(OUT_WASM)
|
||||
$(MAKE) -C $(CODEC_BUILD_DIR) clean
|
82
codecs/jxl/dec/jxl_dec.cpp
Normal file
82
codecs/jxl/dec/jxl_dec.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
|
||||
#include <jxl/decode.h>
|
||||
#include "lib/jxl/color_encoding_internal.h"
|
||||
|
||||
#include "skcms.h"
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
|
||||
thread_local const val ImageData = val::global("ImageData");
|
||||
|
||||
#define EXPECT_EQ(a, b) \
|
||||
if ((a) != (b)) { \
|
||||
JxlDecoderDestroy(dec); \
|
||||
return val::null(); \
|
||||
}
|
||||
|
||||
val decode(std::string data) {
|
||||
JxlDecoder* dec = JxlDecoderCreate(nullptr);
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS,
|
||||
JxlDecoderSubscribeEvents(
|
||||
dec, JXL_DEC_BASIC_INFO | JXL_DEC_COLOR_ENCODING | JXL_DEC_FULL_IMAGE));
|
||||
auto next_in = (const uint8_t*)data.c_str();
|
||||
auto avail_in = data.size();
|
||||
EXPECT_EQ(JXL_DEC_BASIC_INFO, JxlDecoderProcessInput(dec, &next_in, &avail_in));
|
||||
size_t buffer_size;
|
||||
const JxlPixelFormat format = {4, JXL_LITTLE_ENDIAN, JXL_TYPE_FLOAT};
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderImageOutBufferSize(dec, &format, &buffer_size));
|
||||
JxlBasicInfo info;
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS, JxlDecoderGetBasicInfo(dec, &info));
|
||||
|
||||
EXPECT_EQ(JXL_DEC_COLOR_ENCODING, JxlDecoderProcessInput(dec, &next_in, &avail_in));
|
||||
size_t icc_size;
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS,
|
||||
JxlDecoderGetICCProfileSize(dec, JXL_COLOR_PROFILE_TARGET_DATA, &icc_size));
|
||||
std::vector<uint8_t> icc_profile(icc_size);
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS,
|
||||
JxlDecoderGetColorAsICCProfile(dec, JXL_COLOR_PROFILE_TARGET_DATA, icc_profile.data(),
|
||||
icc_profile.size()));
|
||||
|
||||
std::unique_ptr<float[]> float_pixels(new float[(buffer_size + 3) / 4]);
|
||||
EXPECT_EQ(JXL_DEC_SUCCESS,
|
||||
JxlDecoderSetImageOutBuffer(
|
||||
dec, &format, reinterpret_cast<uint8_t*>(float_pixels.get()), buffer_size));
|
||||
EXPECT_EQ(JXL_DEC_FULL_IMAGE, JxlDecoderProcessInput(dec, &next_in, &avail_in));
|
||||
JxlDecoderDestroy(dec);
|
||||
#undef EXPECT_EQ
|
||||
|
||||
#define EXPECT_TRUE(a) \
|
||||
if (!(a)) { \
|
||||
return val::null(); \
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> pixels(new uint8_t[info.xsize * info.ysize * 4]);
|
||||
// Convert to sRGB.
|
||||
skcms_ICCProfile jxl_profile;
|
||||
// If the image is encoded in its original color space, the decoded data will be in the color
|
||||
// space defined by the decoded ICC profile. Otherwise, it is in Linear sRGB. TODO: the decoded
|
||||
// color profile should also be Linear sRGB if !uses_original_profile.
|
||||
if (info.uses_original_profile) {
|
||||
EXPECT_TRUE(skcms_Parse(icc_profile.data(), icc_profile.size(), &jxl_profile));
|
||||
} else {
|
||||
auto s = jxl::ColorEncoding::LinearSRGB(/*gray=*/false);
|
||||
EXPECT_TRUE(s.CreateICC());
|
||||
EXPECT_TRUE(skcms_Parse(s.ICC().data(), s.ICC().size(), &jxl_profile));
|
||||
}
|
||||
EXPECT_TRUE(skcms_Transform(
|
||||
float_pixels.get(), skcms_PixelFormat_RGBA_ffff,
|
||||
info.alpha_premultiplied ? skcms_AlphaFormat_PremulAsEncoded : skcms_AlphaFormat_Unpremul,
|
||||
&jxl_profile, pixels.get(), skcms_PixelFormat_RGBA_8888, skcms_AlphaFormat_Unpremul,
|
||||
skcms_sRGB_profile(), info.xsize * info.ysize));
|
||||
|
||||
return ImageData.new_(
|
||||
Uint8ClampedArray.new_(typed_memory_view(info.xsize * info.ysize * 4, pixels.get())),
|
||||
info.xsize, info.ysize);
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
function("decode", &decode);
|
||||
}
|
5
codecs/jxl/dec/jxl_dec.d.ts
vendored
Normal file
5
codecs/jxl/dec/jxl_dec.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
interface JXLModule extends EmscriptenWasm.Module {
|
||||
decode(data: BufferSource): ImageData;
|
||||
}
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): JXLModule;
|
69
codecs/jxl/dec/jxl_dec.js
Normal file
69
codecs/jxl/dec/jxl_dec.js
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
var jxl_dec = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
function(jxl_dec) {
|
||||
jxl_dec = jxl_dec || {};
|
||||
|
||||
|
||||
var d;d||(d=typeof jxl_dec !== 'undefined' ? jxl_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 ca="./this.program",u=!1,v=!1,da=!1,ea=!1;u="object"===typeof window;v="function"===typeof importScripts;da="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!u&&!da&&!v;var w="",x,z,fa,ha;
|
||||
if(da)w=v?require("path").dirname(w)+"/":__dirname+"/",x=function(a,b){fa||(fa=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return fa.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&&(ca=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(ea)"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 ia=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;d.thisProgram&&(ca=d.thisProgram);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,ja=new WebAssembly.Table({initial:280,maximum:280,element:"anyfunc"}),ka=!1,la="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
|
||||
function ma(a,b,c){b>>>=0;var e=b+c;for(c=b;a[c>>>0]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&la)return la.decode(a.subarray(b>>>0,c>>>0));for(e="";b<c;){var f=a[b++>>>0];if(f&128){var g=a[b++>>>0]&63;if(192==(f&224))e+=String.fromCharCode((f&31)<<6|g);else{var l=a[b++>>>0]&63;f=224==(f&240)?(f&15)<<12|g<<6|l:(f&7)<<18|g<<12|l<<6|a[b++>>>0]&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;b>>>=0;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++>>>0]=g}else{if(2047>=g){if(b+1>=c)break;e[b++>>>0]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++>>>0]=224|g>>12}else{if(b+3>=c)break;e[b++>>>0]=240|g>>18;e[b++>>>0]=128|g>>12&63}e[b++>>>0]=128|g>>6&63}e[b++>>>0]=128|g&63}}e[b>>>0]=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>>>0];)++c;c<<=1;if(32<c-a&&oa)return oa.decode(F.subarray(a>>>0,c>>>0));c=0;for(e="";;){var f=H[a+2*c>>1>>>0];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>>>0]=a.charCodeAt(f),b+=2;H[b>>1>>>0]=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>>>0];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){b>>>=0;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>>>0]=g;b+=4;if(b+4>c)break}I[b>>2>>>0]=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,L,F,H,G,I,M,va,wa;function xa(a){J=a;d.HEAP8=L=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=M=new Uint32Array(a);d.HEAPF32=va=new Float32Array(a);d.HEAPF64=wa=new Float64Array(a)}var ya=d.INITIAL_MEMORY||16777216;d.wasmMemory?E=d.wasmMemory:E=new WebAssembly.Memory({initial:ya/65536,maximum:65536});
|
||||
E&&(J=E.buffer);ya=J.byteLength;xa(J);I[755548]=8265232;function N(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(d);else{var c=b.da;"number"===typeof c?void 0===b.Z?d.dynCall_v(c):d.dynCall_vi(c,b.Z):c(void 0===b.Z?null:b.Z)}}}var za=[],Aa=[],Ba=[],Ca=[];function Da(){var a=d.preRun.shift();za.unshift(a)}var Ea=Math.ceil,Fa=Math.floor,O=0,Ga=null,Q=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=R;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ia(){return Ha("data:application/octet-stream;base64,")}var R="jxl_dec.wasm";if(!Ia()){var Ja=R;R=d.locateFile?d.locateFile(Ja,w):w+Ja}
|
||||
function Ka(){try{if(D)return new Uint8Array(D);if(z)return z(R);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(R,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+R+"'";return a.arrayBuffer()}).catch(function(){return Ka()})}Aa.push({da:function(){Ma()}});function S(){return 0<S.aa}
|
||||
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 T(a){for(var b="";F[a>>>0];)b+=Oa[F[a++>>>0]];return b}var U={},V={},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(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 Ta=void 0;function W(a){throw new Ta(a);}var Ua=void 0;function Va(a,b){function c(h){h=b(h);if(h.length!==e.length)throw new Ua("Mismatched type converter count");for(var k=0;k<e.length;++k)X(e[k],h[k])}var e=[];e.forEach(function(h){Pa[h]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(h,k){V.hasOwnProperty(h)?f[k]=V[h]:(g.push(h),U.hasOwnProperty(h)||(U[h]=[]),U[h].push(function(){f[k]=V[h];++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(V.hasOwnProperty(a)){if(c.ea)return;W("Cannot register type '"+e+"' twice")}V[a]=b;delete Pa[a];U.hasOwnProperty(a)&&(b=U[a],delete U[a],b.forEach(function(f){f()}))}var Wa=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function Xa(a){4<a&&0===--Y[a].$&&(Y[a]=void 0,Wa.push(a))}function Ya(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Wa.length?Wa.pop():Y.length;Y[b]={$:1,value:a};return b}}function Za(a){return this.fromWireType(M[a>>>2])}function $a(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(c){return this.fromWireType(va[c>>>2])};case 3:return function(c){return this.fromWireType(wa[c>>>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 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 eb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function fb(a,b){var c=d;if(void 0===c[a].X){var e=c[a];c[a]=function(){c[a].X.hasOwnProperty(arguments.length)||W("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].X+")!");return c[a].X[arguments.length].apply(this,arguments)};c[a].X=[];c[a].X[e.ba]=e}}
|
||||
function gb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].X&&void 0!==d[a].X[c])&&W("Cannot register public name '"+a+"' twice"),fb(a,a),d.hasOwnProperty(c)&&W("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].X[c]=b):(d[a]=b,void 0!==c&&(d[a].ga=c))}function hb(a,b){for(var c=[],e=0;e<a;e++)c.push(I[(b>>2)+e>>>0]);return c}
|
||||
function ib(a,b){a=T(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 jb=void 0;function kb(a){a=lb(a);var b=T(a);Z(a);return b}
|
||||
function mb(a,b){function c(g){f[g]||V[g]||(Pa[g]?Pa[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 L[e>>>0]}:function(e){return F[e>>>0]};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 M[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=V[a];void 0===c&&W(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",_:ca||"./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}
|
||||
for(var ub,vb=[null,[],[]],wb=Array(256),xb=0;256>xb;++xb)wb[xb]=String.fromCharCode(xb);Oa=wb;Ta=d.BindingError=Sa("BindingError");Ua=d.InternalError=Sa("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};jb=d.UnboundTypeError=Sa("UnboundTypeError");
|
||||
var zb={q:function(a){return yb(a)},l:function(){},p:function(a){"uncaught_exception"in S?S.aa++:S.aa=1;throw a;},z:function(a,b,c,e,f){var g=Na(c);b=T(b);X(a,{name:b,fromWireType:function(l){return!!l},toWireType:function(l,h){return h?e:f},argPackAdvance:8,readValueFromPointer:function(l){if(1===c)var h=L;else if(2===c)h=H;else if(4===c)h=I;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(h[l>>>g])},Y:null})},y:function(a,b){b=T(b);X(a,{name:b,fromWireType:function(c){var e=
|
||||
Y[c].value;Xa(c);return e},toWireType:function(c,e){return Ya(e)},argPackAdvance:8,readValueFromPointer:Za,Y:null})},j:function(a,b,c){c=Na(c);b=T(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 "'+$a(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:cb(b,c),Y:null})},n:function(a,b,c,e,f,g){var l=hb(b,c);a=T(a);f=ib(e,f);gb(a,function(){mb("Cannot call "+a+" due to unbound types",
|
||||
l)},b-1);Va(l,function(h){var k=[h[0],null].concat(h.slice(1)),m=h=a,p=f,q=k.length;2>q&&W("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var y=null!==k[1]&&!1,C=!1,n=1;n<k.length;++n)if(null!==k[n]&&void 0===k[n].Y){C=!0;break}var ab="void"!==k[0].name,K="",P="";for(n=0;n<q-2;++n)K+=(0!==n?", ":"")+"arg"+n,P+=(0!==n?", ":"")+"arg"+n+"Wired";m="return function "+Qa(m)+"("+K+") {\nif (arguments.length !== "+(q-2)+") {\nthrowBindingError('function "+m+" called with ' + arguments.length + ' arguments, expected "+
|
||||
(q-2)+" args!');\n}\n";C&&(m+="var destructors = [];\n");var bb=C?"destructors":"null";K="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[W,p,g,eb,k[0],k[1]];y&&(m+="var thisWired = classParam.toWireType("+bb+", this);\n");for(n=0;n<q-2;++n)m+="var arg"+n+"Wired = argType"+n+".toWireType("+bb+", arg"+n+"); // "+k[n+2].name+"\n",K.push("argType"+n),p.push(k[n+2]);y&&(P="thisWired"+(0<P.length?", ":"")+P);m+=(ab?"var rv = ":"")+"invoker(fn"+(0<P.length?", ":"")+P+");\n";
|
||||
if(C)m+="runDestructors(destructors);\n";else for(n=y?1:2;n<k.length;++n)q=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==k[n].Y&&(m+=q+"_dtor("+q+"); // "+k[n].name+"\n",K.push(q+"_dtor"),p.push(k[n].Y));ab&&(m+="var ret = retType.fromWireType(rv);\nreturn ret;\n");K.push(m+"}\n");k=db(K).apply(null,p);n=b-1;if(!d.hasOwnProperty(h))throw new Ua("Replacing nonexistant public symbol");void 0!==d[h].X&&void 0!==n?d[h].X[n]=k:(d[h]=k,d[h].ba=n);return[]})},b:function(a,b,c,e,f){function g(m){return m}
|
||||
b=T(b);-1===f&&(f=4294967295);var l=Na(c);if(0===e){var h=32-8*c;g=function(m){return m<<h>>>h}}var k=-1!=b.indexOf("unsigned");X(a,{name:b,fromWireType:g,toWireType:function(m,p){if("number"!==typeof p&&"boolean"!==typeof p)throw new TypeError('Cannot convert "'+$a(p)+'" to '+this.name);if(p<e||p>f)throw new TypeError('Passing a number "'+$a(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:nb(b,
|
||||
l,0!==e),Y:null})},a:function(a,b,c){function e(g){g>>=2;var l=M;return new f(J,l[g+1>>>0],l[g>>>0])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);X(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{ea:!0})},k:function(a,b){b=T(b);var c="std::string"===b;X(a,{name:b,fromWireType:function(e){var f=M[e>>>2];if(c)for(var g=e+4,l=0;l<=f;++l){var h=e+4+l;if(l==f||0==F[h>>>0]){var k=g;g=(k>>>=0)?ma(F,k,h-g):"";if(void 0===
|
||||
m)var m=g;else m+=String.fromCharCode(0),m+=g;g=h+1}}else{m=Array(f);for(l=0;l<f;++l)m[l]=String.fromCharCode(F[e+4+l>>>0]);m=m.join("")}Z(e);return m},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 m=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?++m:m=2047>=q?m+2:65535>=q?m+3:m+4}return m}:function(){return f.length})(),h=yb(4+l+1);h>>>=0;M[h>>>2]=l;if(c&&g)na(f,h+4,l+1);else if(g)for(g=0;g<l;++g){var k=f.charCodeAt(g);255<k&&(Z(h),W("String has UTF-16 code units that do not fit in 8 bits"));F[h+4+g>>>0]=k}else for(g=0;g<l;++g)F[h+4+g>>>0]=f[g];null!==e&&e.push(Z,h);return h},argPackAdvance:8,readValueFromPointer:Za,Y:function(e){Z(e)}})},d:function(a,b,c){c=T(c);if(2===b){var e=pa;var f=qa;var g=ra;var l=function(){return G};
|
||||
var h=1}else 4===b&&(e=sa,f=ta,g=ua,l=function(){return M},h=2);X(a,{name:c,fromWireType:function(k){for(var m=M[k>>>2],p=l(),q,y=k+4,C=0;C<=m;++C){var n=k+4+C*b;if(C==m||0==p[n>>>h])y=e(y,n-y),void 0===q?q=y:(q+=String.fromCharCode(0),q+=y),y=n+b}Z(k);return q},toWireType:function(k,m){"string"!==typeof m&&W("Cannot pass non-string to C++ string type "+c);var p=g(m),q=yb(4+p+b);q>>>=0;M[q>>>2]=p>>h;f(m,q+4,p+b);null!==k&&k.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Za,Y:function(k){Z(k)}})},
|
||||
m:function(a,b){b=T(b);X(a,{fa:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},w:Xa,A:function(a){if(0===a)return Ya(pb());var b=ob[a];a=void 0===b?T(a):b;return Ya(pb()[a])},o:function(a){4<a&&(Y[a].$+=1)},f:function(a,b,c,e){a||W("Cannot use deleted val. handle = "+a);a=Y[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,Ya);rb[b]=f}return f(a,c,e)},e:function(){A()},t:function(a,b,c){F.copyWithin(a>>>0,b>>>0,b+c>>>0)},c:function(a){a>>>=0;var b=F.length;if(4294967296<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(4294967296,e)-J.byteLength+65535>>>16);xa(E.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},u:function(a,b){var c=0;tb().forEach(function(e,f){var g=b+c;f=I[a+4*f>>2>>>0]=g;for(g=0;g<e.length;++g)L[f++>>0>>>0]=e.charCodeAt(g);L[f>>0>>>0]=0;c+=e.length+1});return 0},v:function(a,b){var c=tb();I[a>>2>>>0]=c.length;var e=0;c.forEach(function(f){e+=
|
||||
f.length+1});I[b>>2>>>0]=e;return 0},x:function(){return 0},r:function(){},h:function(a,b,c,e){for(var f=0,g=0;g<c;g++){for(var l=I[b+8*g>>2>>>0],h=I[b+(8*g+4)>>2>>>0],k=0;k<h;k++){var m=F[l+k>>>0],p=vb[a];0===m||10===m?((1===a?ia:B)(ma(p,0)),p.length=0):p.push(m)}f+=h}I[e>>2>>>0]=f;return 0},memory:E,g:function(a){a=+a;return 0<=a?+Fa(a+.5):+Ea(a-.5)},i:function(a){a=+a;return 0<=a?+Fa(a+.5):+Ea(a-.5)},s:function(){},table:ja};
|
||||
(function(){function a(f){d.asm=f.exports;O--;d.monitorRunDependencies&&d.monitorRunDependencies(O);0==O&&(null!==Ga&&(clearInterval(Ga),Ga=null),Q&&(f=Q,Q=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:zb};O++;d.monitorRunDependencies&&d.monitorRunDependencies(O);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(R,{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.B).apply(null,arguments)},yb=d._malloc=function(){return(yb=d._malloc=d.asm.C).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.D).apply(null,arguments)},lb=d.___getTypeName=function(){return(lb=d.___getTypeName=d.asm.E).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.F).apply(null,arguments)};
|
||||
d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.G).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.H).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.I).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.J).apply(null,arguments)};d.dynCall_iidiiii=function(){return(d.dynCall_iidiiii=d.asm.K).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.L).apply(null,arguments)};
|
||||
d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.M).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.N).apply(null,arguments)};d.dynCall_v=function(){return(d.dynCall_v=d.asm.O).apply(null,arguments)};d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.P).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.Q).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.R).apply(null,arguments)};
|
||||
d.dynCall_iiiii=function(){return(d.dynCall_iiiii=d.asm.S).apply(null,arguments)};d.dynCall_iiji=function(){return(d.dynCall_iiji=d.asm.T).apply(null,arguments)};d.dynCall_iifi=function(){return(d.dynCall_iifi=d.asm.U).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.V).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.W).apply(null,arguments)};var Ab;Q=function Bb(){Ab||Cb();Ab||(Q=Bb)};
|
||||
function Cb(){function a(){if(!Ab&&(Ab=!0,d.calledRun=!0,!ka)){N(Aa);N(Ba);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();Ca.unshift(b)}N(Ca)}}if(!(0<O)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Da();N(za);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 jxl_dec.ready
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = jxl_dec;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return jxl_dec; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["jxl_dec"] = jxl_dec;
|
||||
|
BIN
codecs/jxl/dec/jxl_dec.wasm
Normal file
BIN
codecs/jxl/dec/jxl_dec.wasm
Normal file
Binary file not shown.
60
codecs/jxl/enc/jxl_enc.cpp
Normal file
60
codecs/jxl/enc/jxl_enc.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
|
||||
#include "lib/jxl/enc_file.h"
|
||||
#include "lib/jxl/external_image.h"
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
thread_local const val Uint8Array = val::global("Uint8Array");
|
||||
|
||||
struct JXLOptions {
|
||||
// 1 = slowest
|
||||
// 7 = fastest
|
||||
int speed;
|
||||
float quality;
|
||||
};
|
||||
|
||||
val encode(std::string image, int width, int height, JXLOptions options) {
|
||||
jxl::CompressParams cparams;
|
||||
jxl::PassesEncoderState passes_enc_state;
|
||||
jxl::CodecInOut io;
|
||||
jxl::PaddedBytes bytes;
|
||||
jxl::ImageBundle* main = &io.Main();
|
||||
|
||||
cparams.speed_tier = static_cast<jxl::SpeedTier>(options.speed);
|
||||
cparams.butteraugli_distance = options.quality;
|
||||
|
||||
io.metadata.SetAlphaBits(8);
|
||||
|
||||
uint8_t* inBuffer = (uint8_t*)image.c_str();
|
||||
|
||||
auto result = jxl::ConvertImage(
|
||||
jxl::Span<const uint8_t>(reinterpret_cast<const uint8_t*>(image.data()), image.size()), width,
|
||||
height, jxl::ColorEncoding::SRGB(/*is_gray=*/false), /*has_alpha=*/true,
|
||||
/*alpha_is_premultiplied=*/false, /*bits_per_alpha=*/8, /*bits_per_sample=*/8,
|
||||
/*big_endian=*/false, /*flipped_y=*/false, /*pool=*/nullptr, main);
|
||||
|
||||
if (!result) {
|
||||
return val::null();
|
||||
}
|
||||
|
||||
auto js_result = val::null();
|
||||
if (EncodeFile(cparams, &io, &passes_enc_state, &bytes)) {
|
||||
js_result = Uint8Array.new_(typed_memory_view(bytes.size(), bytes.data()));
|
||||
}
|
||||
|
||||
// TODO: Any freeing that needs to be done?
|
||||
//
|
||||
return js_result;
|
||||
}
|
||||
|
||||
void free_result() {}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
value_object<JXLOptions>("JXLOptions")
|
||||
.field("speed", &JXLOptions::speed)
|
||||
.field("quality", &JXLOptions::quality);
|
||||
|
||||
function("encode", &encode);
|
||||
}
|
8
codecs/jxl/enc/jxl_enc.d.ts
vendored
Normal file
8
codecs/jxl/enc/jxl_enc.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { EncodeOptions } from '../../src/codecs/jxl/encoder-meta';
|
||||
|
||||
interface JXLModule extends EmscriptenWasm.Module {
|
||||
encode(data: BufferSource, width: number, height: number, options: EncodeOptions): Uint8Array;
|
||||
}
|
||||
|
||||
|
||||
export default function(opts: EmscriptenWasm.ModuleOpts): JXLModule;
|
117
codecs/jxl/enc/jxl_enc.js
Normal file
117
codecs/jxl/enc/jxl_enc.js
Normal file
@ -0,0 +1,117 @@
|
||||
|
||||
var jxl_enc = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
function(jxl_enc) {
|
||||
jxl_enc = jxl_enc || {};
|
||||
|
||||
|
||||
var f;f||(f=typeof jxl_enc !== 'undefined' ? jxl_enc : {});var aa,ba;f.ready=new Promise(function(a,b){aa=a;ba=b});var p={},t;for(t in f)f.hasOwnProperty(t)&&(p[t]=f[t]);var ca="./this.program",da=!1,w=!1,z=!1,ea=!1;da="object"===typeof window;w="function"===typeof importScripts;z="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!da&&!z&&!w;var A="",fa,ha,ia,ka;
|
||||
if(z)A=w?require("path").dirname(A)+"/":__dirname+"/",fa=function(a,b){ia||(ia=require("fs"));ka||(ka=require("path"));a=ka.normalize(a);return ia.readFileSync(a,b?null:"utf8")},ha=function(a){a=fa(a,!0);a.buffer||(a=new Uint8Array(a));assert(a.buffer);return a},1<process.argv.length&&(ca=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){throw a;}),process.on("unhandledRejection",B),f.inspect=function(){return"[Emscripten Module object]"};else if(ea)"undefined"!=
|
||||
typeof read&&(fa=function(a){return read(a)}),ha=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||w)w?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="",fa=function(a){var b=new XMLHttpRequest;b.open("GET",a,!1);b.send(null);return b.responseText},w&&(ha=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),C=f.printErr||console.warn.bind(console);for(t in p)p.hasOwnProperty(t)&&(f[t]=p[t]);p=null;f.thisProgram&&(ca=f.thisProgram);var ma;f.wasmBinary&&(ma=f.wasmBinary);var noExitRuntime;
|
||||
f.noExitRuntime&&(noExitRuntime=f.noExitRuntime);"object"!==typeof WebAssembly&&B("no native wasm support detected");var D,na=new WebAssembly.Table({initial:780,maximum:780,element:"anyfunc"}),oa=!1;function assert(a,b){a||B("Assertion failed: "+b)}var pa="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
|
||||
function qa(a,b,c){b>>>=0;var d=b+c;for(c=b;a[c>>>0]&&!(c>=d);)++c;if(16<c-b&&a.subarray&&pa)return pa.decode(a.subarray(b>>>0,c>>>0));for(d="";b<c;){var e=a[b++>>>0];if(e&128){var g=a[b++>>>0]&63;if(192==(e&224))d+=String.fromCharCode((e&31)<<6|g);else{var k=a[b++>>>0]&63;e=224==(e&240)?(e&15)<<12|g<<6|k:(e&7)<<18|g<<12|k<<6|a[b++>>>0]&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 ra(a,b){return(a>>>=0)?qa(E,a,b):""}
|
||||
function sa(a,b,c,d){c>>>=0;if(!(0<d))return 0;var e=c;d=c+d-1;for(var g=0;g<a.length;++g){var k=a.charCodeAt(g);if(55296<=k&&57343>=k){var m=a.charCodeAt(++g);k=65536+((k&1023)<<10)|m&1023}if(127>=k){if(c>=d)break;b[c++>>>0]=k}else{if(2047>=k){if(c+1>=d)break;b[c++>>>0]=192|k>>6}else{if(65535>=k){if(c+2>=d)break;b[c++>>>0]=224|k>>12}else{if(c+3>=d)break;b[c++>>>0]=240|k>>18;b[c++>>>0]=128|k>>12&63}b[c++>>>0]=128|k>>6&63}b[c++>>>0]=128|k&63}}b[c>>>0]=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>>>0];)++c;c<<=1;if(32<c-a&&ua)return ua.decode(E.subarray(a>>>0,c>>>0));c=0;for(d="";;){var e=G[a+2*c>>1>>>0];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)G[b>>1>>>0]=a.charCodeAt(e),b+=2;G[b>>1>>>0]=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=H[a+4*c>>2>>>0];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){b>>>=0;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 k=a.charCodeAt(++e);g=65536+((g&1023)<<10)|k&1023}H[b>>2>>>0]=g;b+=4;if(b+4>c)break}H[b>>2>>>0]=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 I,J,E,G,wa,H,K,Ca,Da;
|
||||
function Ea(a){I=a;f.HEAP8=J=new Int8Array(a);f.HEAP16=G=new Int16Array(a);f.HEAP32=H=new Int32Array(a);f.HEAPU8=E=new Uint8Array(a);f.HEAPU16=wa=new Uint16Array(a);f.HEAPU32=K=new Uint32Array(a);f.HEAPF32=Ca=new Float32Array(a);f.HEAPF64=Da=new Float64Array(a)}var Fa=f.INITIAL_MEMORY||16777216;f.wasmMemory?D=f.wasmMemory:D=new WebAssembly.Memory({initial:Fa/65536,maximum:65536});D&&(I=D.buffer);Fa=I.byteLength;Ea(I);H[771900]=8330640;
|
||||
function Ga(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b(f);else{var c=b.eb;"number"===typeof c?void 0===b.Ma?f.dynCall_v(c):f.dynCall_vi(c,b.Ma):c(void 0===b.Ma?null:b.Ma)}}}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,L=0,Qa=null,Ra=null;f.preloadedImages={};f.preloadedAudios={};
|
||||
function B(a){if(f.onAbort)f.onAbort(a);C(a);oa=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Sa(a){var b=M;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ta(){return Sa("data:application/octet-stream;base64,")}var M="jxl_enc.wasm";if(!Ta()){var Ua=M;M=f.locateFile?f.locateFile(Ua,A):A+Ua}
|
||||
function Va(){try{if(ma)return new Uint8Array(ma);if(ha)return ha(M);throw"both async and sync fetching of the wasm failed";}catch(a){B(a)}}function Wa(){return ma||!da&&!w||"function"!==typeof fetch||Sa("file://")?new Promise(function(a){a(Va())}):fetch(M,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+M+"'";return a.arrayBuffer()}).catch(function(){return Va()})}var N,Xa;Ia.push({eb:function(){Ya()}});function Za(){return 0<Za.Ia}
|
||||
function $a(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 ab(a){var b="/"===a.charAt(0),c="/"===a.substr(-1);(a=$a(a.split("/").filter(function(d){return!!d}),!b).join("/"))||b||(a=".");a&&c&&(a+="/");return(b?"/":"")+a}
|
||||
function bb(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 cb(a){if("/"===a)return"/";var b=a.lastIndexOf("/");return-1===b?a:a.substr(b+1)}
|
||||
function db(){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=$a(a.split("/").filter(function(d){return!!d}),!b).join("/");return(b?"/":"")+a||"."}var eb=[];function fb(a,b){eb[a]={input:[],output:[],Ba:b};gb(a,hb)}
|
||||
var hb={open:function(a){var b=eb[a.node.rdev];if(!b)throw new O(43);a.tty=b;a.seekable=!1},close:function(a){a.tty.Ba.flush(a.tty)},flush:function(a){a.tty.Ba.flush(a.tty)},read:function(a,b,c,d){if(!a.tty||!a.tty.Ba.Xa)throw new O(60);for(var e=0,g=0;g<d;g++){try{var k=a.tty.Ba.Xa(a.tty)}catch(m){throw new O(29);}if(void 0===k&&0===e)throw new O(6);if(null===k||void 0===k)break;e++;b[c+g]=k}e&&(a.node.timestamp=Date.now());return e},write:function(a,b,c,d){if(!a.tty||!a.tty.Ba.Oa)throw new O(60);
|
||||
try{for(var e=0;e<d;e++)a.tty.Ba.Oa(a.tty,b[c+e])}catch(g){throw new O(29);}d&&(a.node.timestamp=Date.now());return e}},jb={Xa:function(a){if(!a.input.length){var b=null;if(z){var c=Buffer.Ia?Buffer.Ia(256):new Buffer(256),d=0;try{d=ia.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;a.input=ib(b,!0)}return a.input.shift()},Oa:function(a,b){null===b||10===b?(la(qa(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(la(qa(a.output,0)),a.output=[])}},kb={Oa:function(a,b){null===b||10===b?(C(qa(a.output,0)),a.output=[]):0!=b&&a.output.push(b)},flush:function(a){a.output&&0<a.output.length&&(C(qa(a.output,0)),a.output=[])}},P={ta:null,ya:function(){return P.createNode(null,
|
||||
"/",16895,0)},createNode:function(a,b,c,d){if(24576===(c&61440)||4096===(c&61440))throw new O(63);P.ta||(P.ta={dir:{node:{za:P.pa.za,va:P.pa.va,lookup:P.pa.lookup,Fa:P.pa.Fa,rename:P.pa.rename,unlink:P.pa.unlink,rmdir:P.pa.rmdir,readdir:P.pa.readdir,symlink:P.pa.symlink},stream:{Aa:P.qa.Aa}},file:{node:{za:P.pa.za,va:P.pa.va},stream:{Aa:P.qa.Aa,read:P.qa.read,write:P.qa.write,Ra:P.qa.Ra,Ya:P.qa.Ya,Ha:P.qa.Ha}},link:{node:{za:P.pa.za,va:P.pa.va,readlink:P.pa.readlink},stream:{}},Sa:{node:{za:P.pa.za,
|
||||
va:P.pa.va},stream:lb}});c=mb(a,b,c,d);16384===(c.mode&61440)?(c.pa=P.ta.dir.node,c.qa=P.ta.dir.stream,c.oa={}):32768===(c.mode&61440)?(c.pa=P.ta.file.node,c.qa=P.ta.file.stream,c.ra=0,c.oa=null):40960===(c.mode&61440)?(c.pa=P.ta.link.node,c.qa=P.ta.link.stream):8192===(c.mode&61440)&&(c.pa=P.ta.Sa.node,c.qa=P.ta.Sa.stream);c.timestamp=Date.now();a&&(a.oa[b]=c);return c},xb:function(a){if(a.oa&&a.oa.subarray){for(var b=[],c=0;c<a.ra;++c)b.push(a.oa[c]);return b}return a.oa},yb:function(a){return a.oa?
|
||||
a.oa.subarray?a.oa.subarray(0,a.ra):new Uint8Array(a.oa):new Uint8Array(0)},Ta:function(a,b){b>>>=0;var c=a.oa?a.oa.length:0;c>=b||(b=Math.max(b,c*(1048576>c?2:1.125)>>>0),0!=c&&(b=Math.max(b,256)),c=a.oa,a.oa=new Uint8Array(b),0<a.ra&&a.oa.set(c.subarray(0,a.ra),0))},nb:function(a,b){b>>>=0;if(a.ra!=b)if(0==b)a.oa=null,a.ra=0;else{if(!a.oa||a.oa.subarray){var c=a.oa;a.oa=new Uint8Array(b);c&&a.oa.set(c.subarray(0,Math.min(b,a.ra)))}else if(a.oa||(a.oa=[]),a.oa.length>b)a.oa.length=b;else for(;a.oa.length<
|
||||
b;)a.oa.push(0);a.ra=b}},pa:{za: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.ra: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.bb=4096;b.blocks=Math.ceil(b.size/b.bb);return b},va:function(a,b){void 0!==b.mode&&(a.mode=b.mode);void 0!==b.timestamp&&(a.timestamp=
|
||||
b.timestamp);void 0!==b.size&&P.nb(a,b.size)},lookup:function(){throw nb[44];},Fa:function(a,b,c,d){return P.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.oa)throw new O(55);}delete a.parent.oa[a.name];a.name=c;b.oa[c]=a;a.parent=b},unlink:function(a,b){delete a.oa[b]},rmdir:function(a,b){var c=ob(a,b),d;for(d in c.oa)throw new O(55);delete a.oa[b]},readdir:function(a){var b=[".",".."],c;for(c in a.oa)a.oa.hasOwnProperty(c)&&
|
||||
b.push(c);return b},symlink:function(a,b,c){a=P.createNode(a,b,41471,0);a.link=c;return a},readlink:function(a){if(40960!==(a.mode&61440))throw new O(28);return a.link}},qa:{read:function(a,b,c,d,e){var g=a.node.oa;if(e>=a.node.ra)return 0;a=Math.min(a.node.ra-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===J.buffer&&(g=!1);if(!d)return 0;a=a.node;a.timestamp=Date.now();if(b.subarray&&(!a.oa||a.oa.subarray)){if(g)return a.oa=
|
||||
b.subarray(c,c+d),a.ra=d;if(0===a.ra&&0===e)return a.oa=b.slice(c,c+d),a.ra=d;if(e+d<=a.ra)return a.oa.set(b.subarray(c,c+d),e),d}P.Ta(a,e+d);if(a.oa.subarray&&b.subarray)a.oa.set(b.subarray(c,c+d),e);else for(g=0;g<d;g++)a.oa[e+g]=b[c+g];a.ra=Math.max(a.ra,e+d);return d},Aa:function(a,b,c){1===c?b+=a.position:2===c&&32768===(a.node.mode&61440)&&(b+=a.node.ra);if(0>b)throw new O(28);return b},Ra:function(a,b,c){P.Ta(a.node,b+c);a.node.ra=Math.max(a.node.ra,b+c)},Ya:function(a,b,c,d,e,g){assert(0===
|
||||
b);if(32768!==(a.node.mode&61440))throw new O(43);a=a.node.oa;if(g&2||a.buffer!==I){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;)J[b+c++>>>0]=0;c=b;if(!c)throw new O(48);c>>>=0;J.set(a,c>>>0)}else d=!1,c=a.byteOffset;return{Fb:c,$a:d}},Ha:function(a,b,c,d,e){if(32768!==(a.node.mode&61440))throw new O(43);if(e&2)return 0;P.qa.write(a,b,0,d,c,!1);return 0}}},qb=null,rb={},Q=[],sb=1,tb=null,ub=!0,vb={},O=null,
|
||||
nb={};function R(a,b){a=db("/",a);b=b||{};if(!a)return{path:"",node:null};var c={Wa:!0,Pa:0},d;for(d in c)void 0===b[d]&&(b[d]=c[d]);if(8<b.Pa)throw new O(32);a=$a(a.split("/").filter(function(k){return!!k}),!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=ab(c+"/"+a[d]);e.Ga&&(!g||g&&b.Wa)&&(e=e.Ga.root);if(!g||b.Va)for(g=0;40960===(e.mode&61440);)if(e=wb(c),c=db(bb(c),e),e=R(c,{Pa:b.Pa}).node,40<g++)throw new O(32);}return{path:c,node:e}}
|
||||
function xb(a){for(var b;;){if(a===a.parent)return a=a.ya.Za,b?"/"!==a[a.length-1]?a+"/"+b:a+b:a;b=b?a.name+"/"+b:a.name;a=a.parent}}function yb(a,b){for(var c=0,d=0;d<b.length;d++)c=(c<<5)-c+b.charCodeAt(d)|0;return(a+c>>>0)%tb.length}function ob(a,b){var c;if(c=(c=zb(a,"x"))?c:a.pa.lookup?0:2)throw new O(c,a);for(c=tb[yb(a.id,b)];c;c=c.kb){var d=c.name;if(c.parent.id===a.id&&d===b)return c}return a.pa.lookup(a,b)}
|
||||
function mb(a,b,c,d){a=new Ab(a,b,c,d);b=yb(a.parent.id,a.name);a.kb=tb[b];return tb[b]=a}var Bb={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 Cb(a){var b=["r","w","rw"][a&3];a&512&&(b+="w");return b}function zb(a,b){if(ub)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 Db(a,b){try{return ob(a,b),20}catch(c){}return zb(a,"wx")}function Eb(){var a=4096;for(var b=0;b<=a;b++)if(!Q[b])return b;throw new O(33);}function Fb(a){Gb||(Gb=function(){},Gb.prototype={});var b=new Gb,c;for(c in a)b[c]=a[c];a=b;b=Eb();a.fd=b;return Q[b]=a}var lb={open:function(a){a.qa=rb[a.node.rdev].qa;a.qa.open&&a.qa.open(a)},Aa:function(){throw new O(70);}};function gb(a,b){rb[a]={qa:b}}
|
||||
function Hb(a,b){var c="/"===b,d=!b;if(c&&qb)throw new O(10);if(!c&&!d){var e=R(b,{Wa:!1});b=e.path;e=e.node;if(e.Ga)throw new O(10);if(16384!==(e.mode&61440))throw new O(54);}b={type:a,Db:{},Za:b,jb:[]};a=a.ya(b);a.ya=b;b.root=a;c?qb=a:e&&(e.Ga=b,e.ya&&e.ya.jb.push(b))}function Ib(a,b,c){var d=R(a,{parent:!0}).node;a=cb(a);if(!a||"."===a||".."===a)throw new O(28);var e=Db(d,a);if(e)throw new O(e);if(!d.pa.Fa)throw new O(63);return d.pa.Fa(d,a,b,c)}function S(a){Ib(a,16895,0)}
|
||||
function Jb(a,b,c){"undefined"===typeof c&&(c=b,b=438);Ib(a,b|8192,c)}function Kb(a,b){if(!db(a))throw new O(44);var c=R(b,{parent:!0}).node;if(!c)throw new O(44);b=cb(b);var d=Db(c,b);if(d)throw new O(d);if(!c.pa.symlink)throw new O(63);c.pa.symlink(c,b,a)}function wb(a){a=R(a).node;if(!a)throw new O(44);if(!a.pa.readlink)throw new O(28);return db(xb(a.parent),a.pa.readlink(a))}
|
||||
function Lb(a,b){if(""===a)throw new O(44);if("string"===typeof b){var c=Bb[b];if("undefined"===typeof c)throw Error("Unknown file open mode: "+b);b=c}var d=b&64?("undefined"===typeof d?438:d)&4095|32768:0;if("object"===typeof a)var e=a;else{a=ab(a);try{e=R(a,{Va:!(b&131072)}).node}catch(k){}}c=!1;if(b&64)if(e){if(b&128)throw new O(20);}else e=Ib(a,d,0),c=!0;if(!e)throw new O(44);8192===(e.mode&61440)&&(b&=-513);if(b&65536&&16384!==(e.mode&61440))throw new O(54);if(!c&&(d=e?40960===(e.mode&61440)?
|
||||
32:16384===(e.mode&61440)&&("r"!==Cb(b)||b&512)?31:zb(e,Cb(b)):44))throw new O(d);if(b&512){d=e;var g;"string"===typeof d?g=R(d,{Va:!0}).node:g=d;if(!g.pa.va)throw new O(63);if(16384===(g.mode&61440))throw new O(31);if(32768!==(g.mode&61440))throw new O(28);if(d=zb(g,"w"))throw new O(d);g.pa.va(g,{size:0,timestamp:Date.now()})}b&=-131713;e=Fb({node:e,path:xb(e),flags:b,seekable:!0,position:0,qa:e.qa,wb:[],error:!1});e.qa.open&&e.qa.open(e);!f.logReadFiles||b&1||(Mb||(Mb={}),a in Mb||(Mb[a]=1,C("FS.trackingDelegate error on read file: "+
|
||||
a)));try{vb.onOpenFile&&(e=0,1!==(b&2097155)&&(e|=1),0!==(b&2097155)&&(e|=2),vb.onOpenFile(a,e))}catch(k){C("FS.trackingDelegate['onOpenFile']('"+a+"', flags) threw an exception: "+k.message)}}function Nb(a,b,c){if(null===a.fd)throw new O(8);if(!a.seekable||!a.qa.Aa)throw new O(70);if(0!=c&&1!=c&&2!=c)throw new O(28);a.position=a.qa.Aa(a,b,c);a.wb=[]}
|
||||
function Ob(){O||(O=function(a,b){this.node=b;this.ob=function(c){this.Ea=c};this.ob(a);this.message="FS error"},O.prototype=Error(),O.prototype.constructor=O,[44].forEach(function(a){nb[a]=new O(a);nb[a].stack="<generic error, no stack>"}))}var Pb;function Qb(a,b){var c=0;a&&(c|=365);b&&(c|=146);return c}
|
||||
function Rb(a,b,c){a=ab("/dev/"+a);var d=Qb(!!b,!!c);Sb||(Sb=64);var e=Sb++<<8|0;gb(e,{open:function(g){g.seekable=!1},close:function(){c&&c.buffer&&c.buffer.length&&c(10)},read:function(g,k,m,l){for(var q=0,r=0;r<l;r++){try{var u=b()}catch(x){throw new O(29);}if(void 0===u&&0===q)throw new O(6);if(null===u||void 0===u)break;q++;k[m+r]=u}q&&(g.node.timestamp=Date.now());return q},write:function(g,k,m,l){for(var q=0;q<l;q++)try{c(k[m+q])}catch(r){throw new O(29);}l&&(g.node.timestamp=Date.now());return q}});
|
||||
Jb(a,d,e)}var Sb,Tb={},Gb,Mb,Ub={};function Vb(a){a=Q[a];if(!a)throw new O(8);return a}var Wb={};function Xb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Yb(a){return this.fromWireType(K[a>>>2])}var T={},U={},Zb={};function $b(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 ac(a,b){a=$b(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function bc(a){var b=Error,c=ac(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 cc=void 0;function dc(a,b,c){function d(m){m=c(m);if(m.length!==a.length)throw new cc("Mismatched type converter count");for(var l=0;l<a.length;++l)V(a[l],m[l])}a.forEach(function(m){Zb[m]=b});var e=Array(b.length),g=[],k=0;b.forEach(function(m,l){U.hasOwnProperty(m)?e[l]=U[m]:(g.push(m),T.hasOwnProperty(m)||(T[m]=[]),T[m].push(function(){e[l]=U[m];++k;k===g.length&&d(e)}))});0===g.length&&d(e)}
|
||||
function ec(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 fc=void 0;function W(a){for(var b="";E[a>>>0];)b+=fc[E[a++>>>0]];return b}var hc=void 0;function X(a){throw new hc(a);}
|
||||
function V(a,b,c){c=c||{};if(!("argPackAdvance"in b))throw new TypeError("registerType registeredInstance requires argPackAdvance");var d=b.name;a||X('type "'+d+'" must have a positive integer typeid pointer');if(U.hasOwnProperty(a)){if(c.ib)return;X("Cannot register type '"+d+"' twice")}U[a]=b;delete Zb[a];T.hasOwnProperty(a)&&(b=T[a],delete T[a],b.forEach(function(e){e()}))}var ic=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function jc(a){4<a&&0===--Y[a].Qa&&(Y[a]=void 0,ic.push(a))}function kc(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=ic.length?ic.pop():Y.length;Y[b]={Qa:1,value:a};return b}}function lc(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function mc(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 nc(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=ac(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function oc(a,b){var c=f;if(void 0===c[a].ua){var d=c[a];c[a]=function(){c[a].ua.hasOwnProperty(arguments.length)||X("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].ua+")!");return c[a].ua[arguments.length].apply(this,arguments)};c[a].ua=[];c[a].ua[d.ab]=d}}
|
||||
function pc(a,b,c){f.hasOwnProperty(a)?((void 0===c||void 0!==f[a].ua&&void 0!==f[a].ua[c])&&X("Cannot register public name '"+a+"' twice"),oc(a,a),f.hasOwnProperty(c)&&X("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),f[a].ua[c]=b):(f[a]=b,void 0!==c&&(f[a].Cb=c))}function qc(a,b){for(var c=[],d=0;d<a;d++)c.push(H[(b>>2)+d>>>0]);return c}
|
||||
function rc(a,b){a=W(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&&X("unknown function pointer with signature "+a+": "+b);return c}var sc=void 0;function tc(a){a=uc(a);var b=W(a);Z(a);return b}
|
||||
function vc(a,b){function c(g){e[g]||U[g]||(Zb[g]?Zb[g].forEach(c):(d.push(g),e[g]=!0))}var d=[],e={};b.forEach(c);throw new sc(a+": "+d.map(tc).join([", "]));}function wc(a,b,c){switch(b){case 0:return c?function(d){return J[d>>>0]}:function(d){return E[d>>>0]};case 1:return c?function(d){return G[d>>>1]}:function(d){return wa[d>>>1]};case 2:return c?function(d){return H[d>>>2]}:function(d){return K[d>>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var xc={};
|
||||
function yc(){return"object"===typeof globalThis?globalThis:Function("return this")()}function zc(a,b){var c=U[a];void 0===c&&X(b+" has unknown type "+tc(a));return c}var Ac={},Bc={};function Cc(){if(!Dc){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",_:ca||"./this.program"},b;for(b in Bc)a[b]=Bc[b];var c=[];for(b in a)c.push(b+"="+a[b]);Dc=c}return Dc}var Dc;
|
||||
function Ec(a){return 0===a%4&&(0!==a%100||0===a%400)}function Fc(a,b){for(var c=0,d=0;d<=b;c+=a[d++]);return c}var Gc=[31,29,31,30,31,30,31,31,30,31,30,31],Hc=[31,28,31,30,31,30,31,31,30,31,30,31];function Ic(a,b){for(a=new Date(a.getTime());0<b;){var c=a.getMonth(),d=(Ec(a.getFullYear())?Gc:Hc)[c];if(b>d-a.getDate())b-=d-a.getDate()+1,a.setDate(1),11>c?a.setMonth(c+1):(a.setMonth(0),a.setFullYear(a.getFullYear()+1));else{a.setDate(a.getDate()+b);break}}return a}
|
||||
function Jc(a,b,c,d){function e(h,n,v){for(h="number"===typeof h?h.toString():h||"";h.length<n;)h=v[0]+h;return h}function g(h,n){return e(h,n,"0")}function k(h,n){function v(F){return 0>F?-1:0<F?1:0}var y;0===(y=v(h.getFullYear()-n.getFullYear()))&&0===(y=v(h.getMonth()-n.getMonth()))&&(y=v(h.getDate()-n.getDate()));return y}function m(h){switch(h.getDay()){case 0:return new Date(h.getFullYear()-1,11,29);case 1:return h;case 2:return new Date(h.getFullYear(),0,3);case 3:return new Date(h.getFullYear(),
|
||||
0,2);case 4:return new Date(h.getFullYear(),0,1);case 5:return new Date(h.getFullYear()-1,11,31);case 6:return new Date(h.getFullYear()-1,11,30)}}function l(h){h=Ic(new Date(h.sa+1900,0,1),h.La);var n=new Date(h.getFullYear()+1,0,4),v=m(new Date(h.getFullYear(),0,4));n=m(n);return 0>=k(v,h)?0>=k(n,h)?h.getFullYear()+1:h.getFullYear():h.getFullYear()-1}var q=H[d+40>>2>>>0];d={ub:H[d>>2>>>0],tb:H[d+4>>2>>>0],Ja:H[d+8>>2>>>0],Da:H[d+12>>2>>>0],Ca:H[d+16>>2>>>0],sa:H[d+20>>2>>>0],Ka:H[d+24>>2>>>0],La:H[d+
|
||||
28>>2>>>0],Gb:H[d+32>>2>>>0],sb:H[d+36>>2>>>0],vb:q?ra(q):""};c=ra(c);q={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var r in q)c=c.replace(new RegExp(r,"g"),q[r]);var u=
|
||||
"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),x="January February March April May June July August September October November December".split(" ");q={"%a":function(h){return u[h.Ka].substring(0,3)},"%A":function(h){return u[h.Ka]},"%b":function(h){return x[h.Ca].substring(0,3)},"%B":function(h){return x[h.Ca]},"%C":function(h){return g((h.sa+1900)/100|0,2)},"%d":function(h){return g(h.Da,2)},"%e":function(h){return e(h.Da,2," ")},"%g":function(h){return l(h).toString().substring(2)},
|
||||
"%G":function(h){return l(h)},"%H":function(h){return g(h.Ja,2)},"%I":function(h){h=h.Ja;0==h?h=12:12<h&&(h-=12);return g(h,2)},"%j":function(h){return g(h.Da+Fc(Ec(h.sa+1900)?Gc:Hc,h.Ca-1),3)},"%m":function(h){return g(h.Ca+1,2)},"%M":function(h){return g(h.tb,2)},"%n":function(){return"\n"},"%p":function(h){return 0<=h.Ja&&12>h.Ja?"AM":"PM"},"%S":function(h){return g(h.ub,2)},"%t":function(){return"\t"},"%u":function(h){return h.Ka||7},"%U":function(h){var n=new Date(h.sa+1900,0,1),v=0===n.getDay()?
|
||||
n:Ic(n,7-n.getDay());h=new Date(h.sa+1900,h.Ca,h.Da);return 0>k(v,h)?g(Math.ceil((31-v.getDate()+(Fc(Ec(h.getFullYear())?Gc:Hc,h.getMonth()-1)-31)+h.getDate())/7),2):0===k(v,n)?"01":"00"},"%V":function(h){var n=new Date(h.sa+1901,0,4),v=m(new Date(h.sa+1900,0,4));n=m(n);var y=Ic(new Date(h.sa+1900,0,1),h.La);return 0>k(y,v)?"53":0>=k(n,y)?"01":g(Math.ceil((v.getFullYear()<h.sa+1900?h.La+32-v.getDate():h.La+1-v.getDate())/7),2)},"%w":function(h){return h.Ka},"%W":function(h){var n=new Date(h.sa,0,
|
||||
1),v=1===n.getDay()?n:Ic(n,0===n.getDay()?1:7-n.getDay()+1);h=new Date(h.sa+1900,h.Ca,h.Da);return 0>k(v,h)?g(Math.ceil((31-v.getDate()+(Fc(Ec(h.getFullYear())?Gc:Hc,h.getMonth()-1)-31)+h.getDate())/7),2):0===k(v,n)?"01":"00"},"%y":function(h){return(h.sa+1900).toString().substring(2)},"%Y":function(h){return h.sa+1900},"%z":function(h){h=h.sb;var n=0<=h;h=Math.abs(h)/60;return(n?"+":"-")+String("0000"+(h/60*100+h%60)).slice(-4)},"%Z":function(h){return h.vb},"%%":function(){return"%"}};for(r in q)0<=
|
||||
c.indexOf(r)&&(c=c.replace(new RegExp(r,"g"),q[r](d)));r=ib(c,!1);if(r.length>b)return 0;J.set(r,a>>>0);return r.length-1}function Ab(a,b,c,d){a||(a=this);this.parent=a;this.ya=a.ya;this.Ga=null;this.id=sb++;this.name=b;this.mode=c;this.pa={};this.qa={};this.rdev=d}
|
||||
Object.defineProperties(Ab.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}}});Ob();tb=Array(4096);Hb(P,"/");S("/tmp");S("/home");S("/home/web_user");
|
||||
(function(){S("/dev");gb(259,{read:function(){return 0},write:function(d,e,g,k){return k}});Jb("/dev/null",259);fb(1280,jb);fb(1536,kb);Jb("/dev/tty",1280);Jb("/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(z)try{var c=require("crypto");b=function(){return c.randomBytes(1)[0]}}catch(d){}b||(b=function(){B("random_device")});Rb("random",b);Rb("urandom",b);S("/dev/shm");
|
||||
S("/dev/shm/tmp")})();S("/proc");S("/proc/self");S("/proc/self/fd");Hb({ya:function(){var a=mb("/proc/self","fd",16895,73);a.pa={lookup:function(b,c){var d=Q[+c];if(!d)throw new O(8);b={parent:null,ya:{Za:"fake"},pa:{readlink:function(){return d.path}}};return b.parent=b}};return a}},"/proc/self/fd");cc=f.InternalError=bc("InternalError");for(var Kc=Array(256),Lc=0;256>Lc;++Lc)Kc[Lc]=String.fromCharCode(Lc);fc=Kc;hc=f.BindingError=bc("BindingError");
|
||||
f.count_emval_handles=function(){for(var a=0,b=5;b<Y.length;++b)void 0!==Y[b]&&++a;return a};f.get_first_emval=function(){for(var a=5;a<Y.length;++a)if(void 0!==Y[a])return Y[a];return null};sc=f.UnboundTypeError=bc("UnboundTypeError");function ib(a,b){var c=Array(ta(a)+1);a=sa(a,c,0,c.length);b&&(c.length=a);return c}
|
||||
var Nc={t:function(a){return pb(a)},G:function(){},q:function(a){"uncaught_exception"in Za?Za.Ia++:Za.Ia=1;throw a;},x:function(){H[Mc()>>2>>>0]=63;return-1},w:function(a,b){try{a>>>=0;if(-1===(a|0)||0===b)var c=-28;else{var d=Ub[a];if(d&&b===d.Ab){var e=Q[d.fd];if(d.Eb&2){var g=d.flags,k=d.offset,m=E.slice(a,a+b);e&&e.qa.Ha&&e.qa.Ha(e,m,k>>>0,b,g)}Ub[a]=null;d.$a&&Z(d.Bb)}c=0}return c}catch(l){return"undefined"!==typeof Tb&&l instanceof O||B(l),-l.Ea}},n:function(a){var b=Wb[a];delete Wb[a];var c=
|
||||
b.lb,d=b.mb,e=b.Ua,g=e.map(function(k){return k.hb}).concat(e.map(function(k){return k.qb}));dc([a],g,function(k){var m={};e.forEach(function(l,q){var r=k[q],u=l.fb,x=l.gb,h=k[q+e.length],n=l.pb,v=l.rb;m[l.cb]={read:function(y){return r.fromWireType(u(x,y))},write:function(y,F){var ja=[];n(v,y,h.toWireType(ja,F));Xb(ja)}}});return[{name:b.name,fromWireType:function(l){var q={},r;for(r in m)q[r]=m[r].read(l);d(l);return q},toWireType:function(l,q){for(var r in m)if(!(r in q))throw new TypeError('Missing field: "'+
|
||||
r+'"');var u=c();for(r in m)m[r].write(u,q[r]);null!==l&&l.push(d,u);return u},argPackAdvance:8,readValueFromPointer:Yb,wa:d}]})},C:function(a,b,c,d,e){var g=ec(c);b=W(b);V(a,{name:b,fromWireType:function(k){return!!k},toWireType:function(k,m){return m?d:e},argPackAdvance:8,readValueFromPointer:function(k){if(1===c)var m=J;else if(2===c)m=G;else if(4===c)m=H;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(m[k>>>g])},wa:null})},B:function(a,b){b=W(b);V(a,{name:b,
|
||||
fromWireType:function(c){var d=Y[c].value;jc(c);return d},toWireType:function(c,d){return kc(d)},argPackAdvance:8,readValueFromPointer:Yb,wa:null})},j:function(a,b,c){c=ec(c);b=W(b);V(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,e){if("number"!==typeof e&&"boolean"!==typeof e)throw new TypeError('Cannot convert "'+lc(e)+'" to '+this.name);return e},argPackAdvance:8,readValueFromPointer:mc(b,c),wa:null})},m:function(a,b,c,d,e,g){var k=qc(b,c);a=W(a);e=rc(d,e);pc(a,function(){vc("Cannot call "+
|
||||
a+" due to unbound types",k)},b-1);dc([],k,function(m){var l=[m[0],null].concat(m.slice(1)),q=m=a,r=e,u=l.length;2>u&&X("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var x=null!==l[1]&&!1,h=!1,n=1;n<l.length;++n)if(null!==l[n]&&void 0===l[n].wa){h=!0;break}var v="void"!==l[0].name,y="",F="";for(n=0;n<u-2;++n)y+=(0!==n?", ":"")+"arg"+n,F+=(0!==n?", ":"")+"arg"+n+"Wired";q="return function "+$b(q)+"("+y+") {\nif (arguments.length !== "+(u-2)+") {\nthrowBindingError('function "+
|
||||
q+" called with ' + arguments.length + ' arguments, expected "+(u-2)+" args!');\n}\n";h&&(q+="var destructors = [];\n");var ja=h?"destructors":"null";y="throwBindingError invoker fn runDestructors retType classParam".split(" ");r=[X,r,g,Xb,l[0],l[1]];x&&(q+="var thisWired = classParam.toWireType("+ja+", this);\n");for(n=0;n<u-2;++n)q+="var arg"+n+"Wired = argType"+n+".toWireType("+ja+", arg"+n+"); // "+l[n+2].name+"\n",y.push("argType"+n),r.push(l[n+2]);x&&(F="thisWired"+(0<F.length?", ":"")+F);q+=
|
||||
(v?"var rv = ":"")+"invoker(fn"+(0<F.length?", ":"")+F+");\n";if(h)q+="runDestructors(destructors);\n";else for(n=x?1:2;n<l.length;++n)u=1===n?"thisWired":"arg"+(n-2)+"Wired",null!==l[n].wa&&(q+=u+"_dtor("+u+"); // "+l[n].name+"\n",y.push(u+"_dtor"),r.push(l[n].wa));v&&(q+="var ret = retType.fromWireType(rv);\nreturn ret;\n");y.push(q+"}\n");l=nc(y).apply(null,r);n=b-1;if(!f.hasOwnProperty(m))throw new cc("Replacing nonexistant public symbol");void 0!==f[m].ua&&void 0!==n?f[m].ua[n]=l:(f[m]=l,f[m].ab=
|
||||
n);return[]})},b:function(a,b,c,d,e){function g(q){return q}b=W(b);-1===e&&(e=4294967295);var k=ec(c);if(0===d){var m=32-8*c;g=function(q){return q<<m>>>m}}var l=-1!=b.indexOf("unsigned");V(a,{name:b,fromWireType:g,toWireType:function(q,r){if("number"!==typeof r&&"boolean"!==typeof r)throw new TypeError('Cannot convert "'+lc(r)+'" to '+this.name);if(r<d||r>e)throw new TypeError('Passing a number "'+lc(r)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+
|
||||
d+", "+e+"]!");return l?r>>>0:r|0},argPackAdvance:8,readValueFromPointer:wc(b,k,0!==d),wa:null})},a:function(a,b,c){function d(g){g>>=2;var k=K;return new e(I,k[g+1>>>0],k[g>>>0])}var e=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=W(c);V(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{ib:!0})},k:function(a,b){b=W(b);var c="std::string"===b;V(a,{name:b,fromWireType:function(d){var e=K[d>>>2];if(c)for(var g=d+4,k=0;k<=e;++k){var m=
|
||||
d+4+k;if(k==e||0==E[m>>>0]){g=ra(g,m-g);if(void 0===l)var l=g;else l+=String.fromCharCode(0),l+=g;g=m+1}}else{l=Array(e);for(k=0;k<e;++k)l[k]=String.fromCharCode(E[d+4+k>>>0]);l=l.join("")}Z(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||X("Cannot pass non-string to std::string");var k=(c&&g?function(){return ta(e)}:function(){return e.length})(),m=pb(4+
|
||||
k+1);m>>>=0;K[m>>>2]=k;if(c&&g)sa(e,E,m+4,k+1);else if(g)for(g=0;g<k;++g){var l=e.charCodeAt(g);255<l&&(Z(m),X("String has UTF-16 code units that do not fit in 8 bits"));E[m+4+g>>>0]=l}else for(g=0;g<k;++g)E[m+4+g>>>0]=e[g];null!==d&&d.push(Z,m);return m},argPackAdvance:8,readValueFromPointer:Yb,wa:function(d){Z(d)}})},f:function(a,b,c){c=W(c);if(2===b){var d=va;var e=xa;var g=ya;var k=function(){return wa};var m=1}else 4===b&&(d=za,e=Aa,g=Ba,k=function(){return K},m=2);V(a,{name:c,fromWireType:function(l){for(var q=
|
||||
K[l>>>2],r=k(),u,x=l+4,h=0;h<=q;++h){var n=l+4+h*b;if(h==q||0==r[n>>>m])x=d(x,n-x),void 0===u?u=x:(u+=String.fromCharCode(0),u+=x),x=n+b}Z(l);return u},toWireType:function(l,q){"string"!==typeof q&&X("Cannot pass non-string to C++ string type "+c);var r=g(q),u=pb(4+r+b);u>>>=0;K[u>>>2]=r>>m;e(q,u+4,r+b);null!==l&&l.push(Z,u);return u},argPackAdvance:8,readValueFromPointer:Yb,wa:function(l){Z(l)}})},o:function(a,b,c,d,e,g){Wb[a]={name:W(b),lb:rc(c,d),mb:rc(e,g),Ua:[]}},g:function(a,b,c,d,e,g,k,m,l,
|
||||
q){Wb[a].Ua.push({cb:W(b),hb:c,fb:rc(d,e),gb:g,qb:k,pb:rc(m,l),rb:q})},D:function(a,b){b=W(b);V(a,{zb:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},i:jc,F:function(a){if(0===a)return kc(yc());var b=xc[a];a=void 0===b?W(a):b;return kc(yc()[a])},E:function(a){4<a&&(Y[a].Qa+=1)},p:function(a,b,c,d){a||X("Cannot use deleted val. handle = "+a);a=Y[a].value;var e=Ac[b];if(!e){e="";for(var g=0;g<b;++g)e+=(0!==g?", ":"")+"arg"+g;var k="return function emval_allocator_"+b+
|
||||
"(constructor, argTypes, args) {\n";for(g=0;g<b;++g)k+="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",k+("var obj = new constructor("+e+");\nreturn __emval_register(obj);\n}\n")))(zc,f,kc);Ac[b]=e}return e(a,c,d)},l:function(){B()},u:function(a,b,c){E.copyWithin(a>>>0,b>>>
|
||||
0,b+c>>>0)},d:function(a){a>>>=0;var b=E.length;if(4294967296<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{D.grow(Math.min(4294967296,d)-I.byteLength+65535>>>16);Ea(D.buffer);var e=1;break a}catch(g){}e=void 0}if(e)return!0}return!1},y:function(a,b){var c=0;Cc().forEach(function(d,e){var g=b+c;e=H[a+4*e>>2>>>0]=g;for(g=0;g<d.length;++g)J[e++>>0>>>0]=d.charCodeAt(g);J[e>>0>>>0]=0;c+=d.length+1});return 0},
|
||||
z:function(a,b){var c=Cc();H[a>>2>>>0]=c.length;var d=0;c.forEach(function(e){d+=e.length+1});H[b>>2>>>0]=d;return 0},A:function(a){try{var b=Vb(a);if(null===b.fd)throw new O(8);b.Na&&(b.Na=null);try{b.qa.close&&b.qa.close(b)}catch(c){throw c;}finally{Q[b.fd]=null}b.fd=null;return 0}catch(c){return"undefined"!==typeof Tb&&c instanceof O||B(c),c.Ea}},r:function(a,b,c,d,e){try{var g=Vb(a);a=4294967296*c+(b>>>0);if(-9007199254740992>=a||9007199254740992<=a)return-61;Nb(g,a,d);Xa=[g.position>>>0,(N=g.position,
|
||||
1<=+Ma(N)?0<N?(Pa(+Oa(N/4294967296),4294967295)|0)>>>0:~~+Na((N-+(~~N>>>0))/4294967296)>>>0:0)];H[e>>2>>>0]=Xa[0];H[e+4>>2>>>0]=Xa[1];g.Na&&0===a&&0===d&&(g.Na=null);return 0}catch(k){return"undefined"!==typeof Tb&&k instanceof O||B(k),k.Ea}},h:function(a,b,c,d){try{a:{for(var e=Vb(a),g=a=0;g<c;g++){var k=e,m=H[b+8*g>>2>>>0],l=H[b+(8*g+4)>>2>>>0],q=void 0,r=J;m>>>=0;if(0>l||0>q)throw new O(28);if(null===k.fd)throw new O(8);if(0===(k.flags&2097155))throw new O(8);if(16384===(k.node.mode&61440))throw new O(31);
|
||||
if(!k.qa.write)throw new O(28);k.seekable&&k.flags&1024&&Nb(k,0,2);var u="undefined"!==typeof q;if(!u)q=k.position;else if(!k.seekable)throw new O(70);var x=k.qa.write(k,r,m,l,q,void 0);u||(k.position+=x);try{if(k.path&&vb.onWriteToFile)vb.onWriteToFile(k.path)}catch(v){C("FS.trackingDelegate['onWriteToFile']('"+k.path+"') threw an exception: "+v.message)}var h=x;if(0>h){var n=-1;break a}a+=h}n=a}H[d>>2>>>0]=n;return 0}catch(v){return"undefined"!==typeof Tb&&v instanceof O||B(v),v.Ea}},memory:D,e:function(a){a=
|
||||
+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},c:function(a){a=+a;return 0<=a?+Oa(a+.5):+Na(a-.5)},s:function(){},v:function(a,b,c,d){return Jc(a,b,c,d)},table:na};
|
||||
(function(){function a(e){f.asm=e.exports;L--;f.monitorRunDependencies&&f.monitorRunDependencies(L);0==L&&(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){C("failed to asynchronously prepare wasm: "+g);B(g)})}var d={a:Nc};L++;f.monitorRunDependencies&&f.monitorRunDependencies(L);if(f.instantiateWasm)try{return f.instantiateWasm(d,a)}catch(e){return C("Module.instantiateWasm callback failed with error: "+
|
||||
e),!1}(function(){if(ma||"function"!==typeof WebAssembly.instantiateStreaming||Ta()||Sa("file://")||"function"!==typeof fetch)return c(b);fetch(M,{credentials:"same-origin"}).then(function(e){return WebAssembly.instantiateStreaming(e,d).then(b,function(g){C("wasm streaming compile failed: "+g);C("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
|
||||
var Ya=f.___wasm_call_ctors=function(){return(Ya=f.___wasm_call_ctors=f.asm.H).apply(null,arguments)},pb=f._malloc=function(){return(pb=f._malloc=f.asm.I).apply(null,arguments)},Z=f._free=function(){return(Z=f._free=f.asm.J).apply(null,arguments)},Mc=f.___errno_location=function(){return(Mc=f.___errno_location=f.asm.K).apply(null,arguments)},uc=f.___getTypeName=function(){return(uc=f.___getTypeName=f.asm.L).apply(null,arguments)};
|
||||
f.___embind_register_native_and_builtin_types=function(){return(f.___embind_register_native_and_builtin_types=f.asm.M).apply(null,arguments)};f.dynCall_i=function(){return(f.dynCall_i=f.asm.N).apply(null,arguments)};f.dynCall_vi=function(){return(f.dynCall_vi=f.asm.O).apply(null,arguments)};f.dynCall_iii=function(){return(f.dynCall_iii=f.asm.P).apply(null,arguments)};f.dynCall_viii=function(){return(f.dynCall_viii=f.asm.Q).apply(null,arguments)};
|
||||
f.dynCall_fii=function(){return(f.dynCall_fii=f.asm.R).apply(null,arguments)};f.dynCall_viif=function(){return(f.dynCall_viif=f.asm.S).apply(null,arguments)};f.dynCall_iiiiii=function(){return(f.dynCall_iiiiii=f.asm.T).apply(null,arguments)};f.dynCall_viiiii=function(){return(f.dynCall_viiiii=f.asm.U).apply(null,arguments)};f.dynCall_ii=function(){return(f.dynCall_ii=f.asm.V).apply(null,arguments)};f.dynCall_iidiiii=function(){return(f.dynCall_iidiiii=f.asm.W).apply(null,arguments)};
|
||||
f.dynCall_vii=function(){return(f.dynCall_vii=f.asm.X).apply(null,arguments)};f.dynCall_iiiiiii=function(){return(f.dynCall_iiiiiii=f.asm.Y).apply(null,arguments)};f.dynCall_viiii=function(){return(f.dynCall_viiii=f.asm.Z).apply(null,arguments)};f.dynCall_iiii=function(){return(f.dynCall_iiii=f.asm._).apply(null,arguments)};f.dynCall_v=function(){return(f.dynCall_v=f.asm.$).apply(null,arguments)};f.dynCall_viiiiiii=function(){return(f.dynCall_viiiiiii=f.asm.aa).apply(null,arguments)};
|
||||
f.dynCall_viijii=function(){return(f.dynCall_viijii=f.asm.ba).apply(null,arguments)};f.dynCall_iiiii=function(){return(f.dynCall_iiiii=f.asm.ca).apply(null,arguments)};f.dynCall_fi=function(){return(f.dynCall_fi=f.asm.da).apply(null,arguments)};f.dynCall_viiiiii=function(){return(f.dynCall_viiiiii=f.asm.ea).apply(null,arguments)};f.dynCall_iiji=function(){return(f.dynCall_iiji=f.asm.fa).apply(null,arguments)};f.dynCall_iifi=function(){return(f.dynCall_iifi=f.asm.ga).apply(null,arguments)};
|
||||
f.dynCall_jiji=function(){return(f.dynCall_jiji=f.asm.ha).apply(null,arguments)};f.dynCall_iiiiiiiii=function(){return(f.dynCall_iiiiiiiii=f.asm.ia).apply(null,arguments)};f.dynCall_iiiiiiii=function(){return(f.dynCall_iiiiiiii=f.asm.ja).apply(null,arguments)};f.dynCall_iiiiiijj=function(){return(f.dynCall_iiiiiijj=f.asm.ka).apply(null,arguments)};f.dynCall_iiiiij=function(){return(f.dynCall_iiiiij=f.asm.la).apply(null,arguments)};
|
||||
f.dynCall_iiiiid=function(){return(f.dynCall_iiiiid=f.asm.ma).apply(null,arguments)};f.dynCall_iiiiijj=function(){return(f.dynCall_iiiiijj=f.asm.na).apply(null,arguments)};var Oc;Ra=function Pc(){Oc||Qc();Oc||(Ra=Pc)};
|
||||
function Qc(){function a(){if(!Oc&&(Oc=!0,f.calledRun=!0,!oa)){f.noFSInit||Pb||(Pb=!0,Ob(),f.stdin=f.stdin,f.stdout=f.stdout,f.stderr=f.stderr,f.stdin?Rb("stdin",f.stdin):Kb("/dev/tty","/dev/stdin"),f.stdout?Rb("stdout",null,f.stdout):Kb("/dev/tty","/dev/stdout"),f.stderr?Rb("stderr",null,f.stderr):Kb("/dev/tty1","/dev/stderr"),Lb("/dev/stdin","r"),Lb("/dev/stdout","w"),Lb("/dev/stderr","w"));Ga(Ia);ub=!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<L)){if(f.preRun)for("function"==typeof f.preRun&&(f.preRun=[f.preRun]);f.preRun.length;)La();Ga(Ha);0<L||(f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("")},1);a()},1)):a())}}f.run=Qc;if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.pop()();noExitRuntime=!0;Qc();
|
||||
|
||||
|
||||
return jxl_enc.ready
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = jxl_enc;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return jxl_enc; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["jxl_enc"] = jxl_enc;
|
||||
|
BIN
codecs/jxl/enc/jxl_enc.wasm
Normal file
BIN
codecs/jxl/enc/jxl_enc.wasm
Normal file
Binary file not shown.
6
codecs/jxl/package.json
Normal file
6
codecs/jxl/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "jxl",
|
||||
"scripts": {
|
||||
"build": "../build-cpp.sh"
|
||||
}
|
||||
}
|
52
codecs/mozjpeg/Makefile
Normal file
52
codecs/mozjpeg/Makefile
Normal 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 := enc/mozjpeg_enc.js dec/mozjpeg_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 $@ \
|
||||
$+
|
||||
|
||||
# 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
|
@ -17,10 +17,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:
|
18
codecs/mozjpeg/dec/example.html
Normal file
18
codecs/mozjpeg/dec/example.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="mozjpeg_dec.js"></script>
|
||||
<script>
|
||||
const module = mozjpeg_dec({
|
||||
async onRuntimeInitialized() {
|
||||
const image = await fetch("./original.jpg").then(r => r.arrayBuffer());
|
||||
const result = this.decode(image);
|
||||
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = result.width;
|
||||
canvas.height = result.height;
|
||||
// Draw image onto canvas
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.putImageData(result, 0, 0);
|
||||
document.body.append(canvas);
|
||||
}
|
||||
});
|
||||
</script>
|
59
codecs/mozjpeg/dec/mozjpeg_dec.cpp
Normal file
59
codecs/mozjpeg/dec/mozjpeg_dec.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include "config.h"
|
||||
#include "jpeglib.h"
|
||||
|
||||
extern "C" {
|
||||
#include "cdjpeg.h"
|
||||
}
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
thread_local const val Uint8ClampedArray = val::global("Uint8ClampedArray");
|
||||
thread_local const val ImageData = val::global("ImageData");
|
||||
|
||||
val decode(std::string image_in) {
|
||||
uint8_t* image_buffer = (uint8_t*)image_in.c_str();
|
||||
|
||||
jpeg_decompress_struct cinfo;
|
||||
jpeg_error_mgr jerr;
|
||||
// Initialize the JPEG decompression object with default error handling.
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
jpeg_create_decompress(&cinfo);
|
||||
|
||||
jpeg_mem_src(&cinfo, image_buffer, image_in.length());
|
||||
// Read file header, set default decompression parameters
|
||||
jpeg_read_header(&cinfo, TRUE);
|
||||
// Force RGBA decoding, even for grayscale images
|
||||
cinfo.out_color_space = JCS_EXT_RGBA;
|
||||
jpeg_start_decompress(&cinfo);
|
||||
|
||||
// Prepare output buffer
|
||||
size_t output_size = cinfo.output_width * cinfo.output_height * 4;
|
||||
std::vector<uint8_t> output_buffer(output_size);
|
||||
auto stride = cinfo.output_width * 4;
|
||||
|
||||
// Process data
|
||||
auto buffer_lines_available = cinfo.output_height;
|
||||
while (cinfo.output_scanline < cinfo.output_height) {
|
||||
uint8_t* ptr = &output_buffer[stride * cinfo.output_scanline];
|
||||
auto lines_read = jpeg_read_scanlines(&cinfo, &ptr, buffer_lines_available);
|
||||
buffer_lines_available -= lines_read;
|
||||
}
|
||||
jpeg_finish_decompress(&cinfo);
|
||||
|
||||
// Step 7: release JPEG compression object
|
||||
|
||||
auto data = Uint8ClampedArray.new_(typed_memory_view(output_buffer.size(), output_buffer.data()));
|
||||
auto js_result = ImageData.new_(data, cinfo.output_width, cinfo.output_height);
|
||||
|
||||
// This is an important step since it will release a good deal of memory.
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
|
||||
// And we're done!
|
||||
return js_result;
|
||||
}
|
||||
|
||||
EMSCRIPTEN_BINDINGS(my_module) {
|
||||
function("decode", &decode);
|
||||
}
|
69
codecs/mozjpeg/dec/mozjpeg_dec.js
Normal file
69
codecs/mozjpeg/dec/mozjpeg_dec.js
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
var mozjpeg_dec = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
function(mozjpeg_dec) {
|
||||
mozjpeg_dec = mozjpeg_dec || {};
|
||||
|
||||
|
||||
var d;d||(d=typeof mozjpeg_dec !== 'undefined' ? mozjpeg_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 ca="./this.program";function u(a,b){throw b;}var v=!1,w=!1,da=!1,ea=!1;v="object"===typeof window;w="function"===typeof importScripts;da="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!v&&!da&&!w;var x="",z,A,fa,ha;
|
||||
if(da)x=w?require("path").dirname(x)+"/":__dirname+"/",z=function(a,b){fa||(fa=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return fa.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&&(ca=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof ia))throw a;}),process.on("unhandledRejection",B),u=function(a){process.exit(a)},
|
||||
d.inspect=function(){return"[Emscripten Module object]"};else if(ea)"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},"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="",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)});var ja=d.print||console.log.bind(console),D=d.printErr||console.warn.bind(console);
|
||||
for(t in r)r.hasOwnProperty(t)&&(d[t]=r[t]);r=null;d.thisProgram&&(ca=d.thisProgram);d.quit&&(u=d.quit);var E;d.wasmBinary&&(E=d.wasmBinary);var noExitRuntime;d.noExitRuntime&&(noExitRuntime=d.noExitRuntime);"object"!==typeof WebAssembly&&B("no native wasm support detected");var F,ka=new WebAssembly.Table({initial:156,maximum:156,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=G;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)&&H[c];)++c;c<<=1;if(32<c-a&&pa)return pa.decode(G.subarray(a,c));c=0;for(e="";;){var f=I[a+2*c>>1];if(0==f||c==b/2)return e;++c;e+=String.fromCharCode(f)}}function ra(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)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,b){for(var c=0,e="";!(c>=b/4);){var f=J[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 ua(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}J[b>>2]=g;b+=4;if(b+4>c)break}J[b>>2]=0;return b-e}
|
||||
function va(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,G,I,H,J,N,wa,xa;function ya(a){L=a;d.HEAP8=M=new Int8Array(a);d.HEAP16=I=new Int16Array(a);d.HEAP32=J=new Int32Array(a);d.HEAPU8=G=new Uint8Array(a);d.HEAPU16=H=new Uint16Array(a);d.HEAPU32=N=new Uint32Array(a);d.HEAPF32=wa=new Float32Array(a);d.HEAPF64=xa=new Float64Array(a)}var za=d.INITIAL_MEMORY||16777216;d.wasmMemory?F=d.wasmMemory:F=new WebAssembly.Memory({initial:za/65536,maximum:32768});
|
||||
F&&(L=F.buffer);za=L.byteLength;ya(L);J[3104]=5255456;function O(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 Aa=[],Ba=[],Ca=[],Da=[];function Ea(){var a=d.preRun.shift();Aa.unshift(a)}var Q=0,Fa=null,R=null;d.preloadedImages={};d.preloadedAudios={};
|
||||
function B(a){if(d.onAbort)d.onAbort(a);D(a);la=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ga(a){var b=S;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ha(){return Ga("data:application/octet-stream;base64,")}var S="mozjpeg_dec.wasm";if(!Ha()){var Ia=S;S=d.locateFile?d.locateFile(Ia,x):x+Ia}
|
||||
function Ja(){try{if(E)return new Uint8Array(E);if(A)return A(S);throw"both async and sync fetching of the wasm failed";}catch(a){B(a)}}function Ka(){return E||!v&&!w||"function"!==typeof fetch||Ga("file://")?new Promise(function(a){a(Ja())}):fetch(S,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+S+"'";return a.arrayBuffer()}).catch(function(){return Ja()})}Ba.push({Y:function(){La()}});function Ma(){return 0<Ma.W}
|
||||
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 T(a){for(var b="";G[a];)b+=Oa[G[a++]];return b}var U={},V={},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(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 Ta=void 0;function W(a){throw new Ta(a);}var Ua=void 0;function Va(a,b){function c(k){k=b(k);if(k.length!==e.length)throw new Ua("Mismatched type converter count");for(var h=0;h<e.length;++h)X(e[h],k[h])}var e=[];e.forEach(function(k){Pa[k]=a});var f=Array(a.length),g=[],l=0;a.forEach(function(k,h){V.hasOwnProperty(k)?f[h]=V[k]:(g.push(k),U.hasOwnProperty(k)||(U[k]=[]),U[k].push(function(){f[h]=V[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(V.hasOwnProperty(a)){if(c.Z)return;W("Cannot register type '"+e+"' twice")}V[a]=b;delete Pa[a];U.hasOwnProperty(a)&&(b=U[a],delete U[a],b.forEach(function(f){f()}))}var Wa=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function Xa(a){4<a&&0===--Y[a].V&&(Y[a]=void 0,Wa.push(a))}function Ya(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Wa.length?Wa.pop():Y.length;Y[b]={V:1,value:a};return b}}function Za(a){return this.fromWireType(N[a>>2])}function $a(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(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 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 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 eb(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function fb(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 gb(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"),fb(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 hb(a,b){for(var c=[],e=0;e<a;e++)c.push(J[(b>>2)+e]);return c}
|
||||
function ib(a,b){a=T(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 jb=void 0;function kb(a){a=lb(a);var b=T(a);Z(a);return b}
|
||||
function mb(a,b){function c(g){f[g]||V[g]||(Pa[g]?Pa[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 G[e]};case 1:return c?function(e){return I[e>>1]}:function(e){return H[e>>1]};case 2:return c?function(e){return J[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=V[a];void 0===c&&W(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",_:ca||"./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}
|
||||
for(var ub,vb=[null,[],[]],wb=Array(256),xb=0;256>xb;++xb)wb[xb]=String.fromCharCode(xb);Oa=wb;Ta=d.BindingError=Sa("BindingError");Ua=d.InternalError=Sa("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};jb=d.UnboundTypeError=Sa("UnboundTypeError");
|
||||
var zb={o:function(a){return yb(a)},i:function(){},n:function(a){"uncaught_exception"in Ma?Ma.W++:Ma.W=1;throw a;},y:function(a,b,c,e,f){var g=Na(c);b=T(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=M;else if(2===c)k=I;else if(4===c)k=J;else throw new TypeError("Unknown boolean type size: "+b);return this.fromWireType(k[l>>g])},T:null})},x:function(a,b){b=T(b);X(a,{name:b,fromWireType:function(c){var e=
|
||||
Y[c].value;Xa(c);return e},toWireType:function(c,e){return Ya(e)},argPackAdvance:8,readValueFromPointer:Za,T:null})},g:function(a,b,c){c=Na(c);b=T(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 "'+$a(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:cb(b,c),T:null})},l:function(a,b,c,e,f,g){var l=hb(b,c);a=T(a);f=ib(e,f);gb(a,function(){mb("Cannot call "+a+" due to unbound types",
|
||||
l)},b-1);Va(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 ab="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 "+Qa(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 bb=C?"destructors":"null";K="throwBindingError invoker fn runDestructors retType classParam".split(" ");p=[W,p,g,eb,h[0],h[1]];y&&(n+="var thisWired = classParam.toWireType("+bb+", this);\n");for(m=0;m<q-2;++m)n+="var arg"+m+"Wired = argType"+m+".toWireType("+bb+", arg"+m+"); // "+h[m+2].name+"\n",K.push("argType"+m),p.push(h[m+2]);y&&(P="thisWired"+(0<P.length?", ":"")+P);n+=(ab?"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));ab&&(n+="var ret = retType.fromWireType(rv);\nreturn ret;\n");K.push(n+"}\n");h=db(K).apply(null,p);m=b-1;if(!d.hasOwnProperty(k))throw new Ua("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=
|
||||
T(b);-1===f&&(f=4294967295);var l=Na(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 "'+$a(p)+'" to '+this.name);if(p<e||p>f)throw new TypeError('Passing a number "'+$a(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:nb(b,
|
||||
l,0!==e),T: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=T(c);X(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{Z:!0})},h:function(a,b){b=T(b);var c="std::string"===b;X(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(l==f||0==G[k]){g=g?na(G,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(G[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=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),W("String has UTF-16 code units that do not fit in 8 bits"));G[k+4+g]=h}else for(g=0;g<l;++g)G[k+4+g]=f[g];null!==e&&e.push(Z,k);return k},argPackAdvance:8,readValueFromPointer:Za,T:function(e){Z(e)}})},d:function(a,b,c){c=T(c);if(2===b){var e=qa;var f=ra;var g=sa;var l=function(){return H};var k=1}else 4===b&&(e=ta,f=ua,g=va,l=function(){return N},
|
||||
k=2);X(a,{name:c,fromWireType:function(h){for(var n=N[h>>2],p=l(),q,y=h+4,C=0;C<=n;++C){var m=h+4+C*b;if(C==n||0==p[m>>k])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=yb(4+p+b);N[q>>2]=p>>k;f(n,q+4,p+b);null!==h&&h.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Za,T:function(h){Z(h)}})},j:function(a,b){b=T(b);X(a,{$:!0,name:b,argPackAdvance:0,fromWireType:function(){},
|
||||
toWireType:function(){}})},u:Xa,z:function(a){if(0===a)return Ya(pb());var b=ob[a];a=void 0===b?T(a):b;return Ya(pb()[a])},m:function(a){4<a&&(Y[a].V+=1)},e:function(a,b,c,e){a||W("Cannot use deleted val. handle = "+a);a=Y[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,Ya);rb[b]=f}return f(a,c,e)},s:function(){B()},r:function(a,b,c){G.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=G.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{F.grow(Math.min(2147483648,e)-L.byteLength+65535>>>16);ya(F.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},t:function(a,b){var c=0;tb().forEach(function(e,f){var g=b+c;f=J[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},v:function(a,b){var c=tb();J[a>>2]=c.length;var e=0;c.forEach(function(f){e+=f.length+1});J[b>>2]=e;return 0},k:function(a){if(!noExitRuntime&&(la=!0,d.onExit))d.onExit(a);u(a,new ia(a))},
|
||||
w:function(){return 0},p:function(){},f:function(a,b,c,e){for(var f=0,g=0;g<c;g++){for(var l=J[b+8*g>>2],k=J[b+(8*g+4)>>2],h=0;h<k;h++){var n=G[l+h],p=vb[a];0===n||10===n?((1===a?ja:D)(na(p,0)),p.length=0):p.push(n)}f+=k}J[e>>2]=f;return 0},memory:F,q:function(){},table:ka};
|
||||
(function(){function a(f){d.asm=f.exports;Q--;d.monitorRunDependencies&&d.monitorRunDependencies(Q);0==Q&&(null!==Fa&&(clearInterval(Fa),Fa=null),R&&(f=R,R=null,f()))}function b(f){a(f.instance)}function c(f){return Ka().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){D("failed to asynchronously prepare wasm: "+g);B(g)})}var e={a:zb};Q++;d.monitorRunDependencies&&d.monitorRunDependencies(Q);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return D("Module.instantiateWasm callback failed with error: "+
|
||||
f),!1}(function(){if(E||"function"!==typeof WebAssembly.instantiateStreaming||Ha()||Ga("file://")||"function"!==typeof fetch)return c(b);fetch(S,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,e).then(b,function(g){D("wasm streaming compile failed: "+g);D("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})();
|
||||
var La=d.___wasm_call_ctors=function(){return(La=d.___wasm_call_ctors=d.asm.A).apply(null,arguments)},yb=d._malloc=function(){return(yb=d._malloc=d.asm.B).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.C).apply(null,arguments)},lb=d.___getTypeName=function(){return(lb=d.___getTypeName=d.asm.D).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.E).apply(null,arguments)};
|
||||
d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.F).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.G).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.H).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.I).apply(null,arguments)};d.dynCall_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.J).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.K).apply(null,arguments)};
|
||||
d.dynCall_iiiii=function(){return(d.dynCall_iiiii=d.asm.L).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.M).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.N).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.O).apply(null,arguments)};d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.P).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.Q).apply(null,arguments)};
|
||||
d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.R).apply(null,arguments)};var Ab;function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}R=function Bb(){Ab||Cb();Ab||(R=Bb)};
|
||||
function Cb(){function a(){if(!Ab&&(Ab=!0,d.calledRun=!0,!la)){O(Ba);O(Ca);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();Da.unshift(b)}O(Da)}}if(!(0<Q)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Ea();O(Aa);0<Q||(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_dec.ready
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = mozjpeg_dec;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return mozjpeg_dec; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["mozjpeg_dec"] = mozjpeg_dec;
|
||||
|
BIN
codecs/mozjpeg/dec/mozjpeg_dec.wasm
Normal file
BIN
codecs/mozjpeg/dec/mozjpeg_dec.wasm
Normal file
Binary file not shown.
@ -1,10 +1,5 @@
|
||||
#include <emscripten/bind.h>
|
||||
#include <emscripten/val.h>
|
||||
#include <inttypes.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "jpeglib.h"
|
||||
|
||||
@ -14,12 +9,6 @@ extern "C" {
|
||||
|
||||
using namespace emscripten;
|
||||
|
||||
// MozJPEG doesn’t 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
|
||||
|
||||
struct MozJpegOptions {
|
||||
int quality;
|
||||
bool baseline;
|
||||
@ -39,24 +28,7 @@ struct MozJpegOptions {
|
||||
int chroma_quality;
|
||||
};
|
||||
|
||||
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] == '.') {
|
||||
buffer[i] = '\0';
|
||||
version = version << 8 | atoi(&buffer[last_index]);
|
||||
buffer[i] = '.';
|
||||
last_index = i + 1;
|
||||
}
|
||||
}
|
||||
version = version << 8 | atoi(&buffer[last_index]);
|
||||
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();
|
||||
@ -65,12 +37,15 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio
|
||||
// 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).
|
||||
* It is possible to have several such structures, representing multiple
|
||||
* 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
|
||||
@ -79,15 +54,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
|
||||
@ -109,6 +76,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 */
|
||||
@ -184,31 +153,33 @@ 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) {
|
||||
@ -230,7 +201,5 @@ EMSCRIPTEN_BINDINGS(my_module) {
|
||||
.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);
|
||||
}
|
@ -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;
|
72
codecs/mozjpeg/enc/mozjpeg_enc.js
Normal file
72
codecs/mozjpeg/enc/mozjpeg_enc.js
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
var mozjpeg_enc = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
function(mozjpeg_enc) {
|
||||
mozjpeg_enc = mozjpeg_enc || {};
|
||||
|
||||
|
||||
var d;d||(d=typeof mozjpeg_enc !== 'undefined' ? mozjpeg_enc : {});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 ca="./this.program";function u(a,b){throw b;}var v=!1,w=!1,da=!1,ea=!1;v="object"===typeof window;w="function"===typeof importScripts;da="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;ea=!v&&!da&&!w;var x="",B,C,fa,ha;
|
||||
if(da)x=w?require("path").dirname(x)+"/":__dirname+"/",B=function(a,b){fa||(fa=require("fs"));ha||(ha=require("path"));a=ha.normalize(a);return fa.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&&(ca=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof ia))throw a;}),process.on("unhandledRejection",D),u=function(a){process.exit(a)},
|
||||
d.inspect=function(){return"[Emscripten Module object]"};else if(ea)"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 ja=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&&(ca=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,la=new WebAssembly.Table({initial:120,maximum:120,element:"anyfunc"}),ma=!1,na="undefined"!==typeof TextDecoder?new TextDecoder("utf8"):void 0;
|
||||
function oa(a,b,c){var e=b+c;for(c=b;a[c]&&!(c>=e);)++c;if(16<c-b&&a.subarray&&na)return na.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 pa(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 qa="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0;
|
||||
function ra(a,b){var c=a>>1;for(var e=c+b/2;!(c>=e)&&sa[c];)++c;c<<=1;if(32<c-a&&qa)return qa.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 ta(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 ua(a){return 2*a.length}
|
||||
function va(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 wa(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 xa(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,sa,K,N,ya,za;function Aa(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=sa=new Uint16Array(a);d.HEAPU32=N=new Uint32Array(a);d.HEAPF32=ya=new Float32Array(a);d.HEAPF64=za=new Float64Array(a)}var Ba=d.INITIAL_MEMORY||16777216;d.wasmMemory?H=d.wasmMemory:H=new WebAssembly.Memory({initial:Ba/65536,maximum:32768});
|
||||
H&&(L=H.buffer);Ba=L.byteLength;Aa(L);K[22872]=5334528;function Ca(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 Da=[],Ea=[],Fa=[],Ga=[];function Ha(){var a=d.preRun.shift();Da.unshift(a)}var O=0,Ia=null,P=null;d.preloadedImages={};d.preloadedAudios={};
|
||||
function D(a){if(d.onAbort)d.onAbort(a);E(a);ma=!0;a=new WebAssembly.RuntimeError("abort("+a+"). Build with -s ASSERTIONS=1 for more info.");ba(a);throw a;}function Ja(a){var b=Q;return String.prototype.startsWith?b.startsWith(a):0===b.indexOf(a)}function Ka(){return Ja("data:application/octet-stream;base64,")}var Q="mozjpeg_enc.wasm";if(!Ka()){var La=Q;Q=d.locateFile?d.locateFile(La,x):x+La}
|
||||
function Ma(){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 Na(){return G||!v&&!w||"function"!==typeof fetch||Ja("file://")?new Promise(function(a){a(Ma())}):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 Ma()})}Ea.push({ga:function(){Oa()}});function Pa(){return 0<Pa.ba}var Qa={};
|
||||
function Ra(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Sa(a){return this.fromWireType(N[a>>2])}var R={},S={},Ta={};function Ua(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 Va(a,b){a=Ua(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}
|
||||
function Wa(a){var b=Error,c=Va(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 Xa=void 0;
|
||||
function Ya(a,b,c){function e(k){k=c(k);if(k.length!==a.length)throw new Xa("Mismatched type converter count");for(var h=0;h<a.length;++h)T(a[h],k[h])}a.forEach(function(k){Ta[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 Za(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 $a=void 0;function U(a){for(var b="";I[a];)b+=$a[I[a++]];return b}var ab=void 0;function V(a){throw new ab(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 Ta[a];R.hasOwnProperty(a)&&(b=R[a],delete R[a],b.forEach(function(f){f()}))}var bb=[],X=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function cb(a){4<a&&0===--X[a].aa&&(X[a]=void 0,bb.push(a))}function db(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():X.length;X[b]={aa:1,value:a};return b}}function eb(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}
|
||||
function fb(a,b){switch(b){case 2:return function(c){return this.fromWireType(ya[c>>2])};case 3:return function(c){return this.fromWireType(za[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function gb(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=Va(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}
|
||||
function hb(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 ib(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"),hb(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 jb(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 kb=void 0;function lb(a){a=mb(a);var b=U(a);Z(a);return b}
|
||||
function nb(a,b){function c(g){f[g]||S[g]||(Ta[g]?Ta[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 M[e]}:function(e){return I[e]};case 1:return c?function(e){return J[e>>1]}:function(e){return sa[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 pb={};
|
||||
function qb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function rb(a,b){var c=S[a];void 0===c&&V(b+" has unknown type "+lb(a));return c}var sb={},tb={};function ub(){if(!vb){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",_:ca||"./this.program"},b;for(b in tb)a[b]=tb[b];var c=[];for(b in a)c.push(b+"="+a[b]);vb=c}return vb}
|
||||
var vb,wb=[null,[],[]];Xa=d.InternalError=Wa("InternalError");for(var xb=Array(256),yb=0;256>yb;++yb)xb[yb]=String.fromCharCode(yb);$a=xb;ab=d.BindingError=Wa("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};kb=d.UnboundTypeError=Wa("UnboundTypeError");
|
||||
var Ab={i:function(a){return zb(a)},C:function(){},A:function(a){"uncaught_exception"in Pa?Pa.ba++:Pa.ba=1;throw a;},l:function(a){var b=Qa[a];delete Qa[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}));Ya([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));Ra(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:Sa,Z:e}]})},x:function(a,b,c,e,f){var g=Za(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;cb(c);return e},toWireType:function(c,e){return db(e)},argPackAdvance:8,readValueFromPointer:Sa,Z:null})},g:function(a,b,c){c=Za(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 "'+eb(f)+
|
||||
'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:fb(b,c),Z:null})},k:function(a,b,c,e,f,g){var l=jb(b,c);a=U(a);f=Y(e,f);ib(a,function(){nb("Cannot call "+a+" due to unbound types",l)},b-1);Ya([],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 "+Ua(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,Ra,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=gb(A).apply(null,n);p=b-1;if(!d.hasOwnProperty(k))throw new Xa("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=Za(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 "'+eb(n)+
|
||||
'" to '+this.name);if(n<e||n>f)throw new TypeError('Passing a number "'+eb(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:ob(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})},h: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(l==f||0==I[k]){g=g?oa(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=zb(4+l+1);N[k>>2]=l;if(c&&g)pa(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:Sa,Z:function(e){Z(e)}})},d:function(a,b,c){c=U(c);if(2===b){var e=ra;var f=ta;var g=ua;var l=function(){return sa};var k=1}else 4===b&&(e=va,f=wa,g=xa,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(z==m||0==n[p>>k])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=zb(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:Sa,Z:function(h){Z(h)}})},m:function(a,b,c,e,f,g){Qa[a]={name:U(b),la:Y(c,e),ma:Y(f,g),da:[]}},e:function(a,b,c,e,f,g,l,k,h,m){Qa[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:cb,
|
||||
B:function(a){if(0===a)return db(qb());var b=pb[a];a=void 0===b?U(a):b;return db(qb()[a])},j: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=sb[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")))(rb,d,db);sb[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);Aa(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;ub().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=ub();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&&(ma=!0,d.onExit))d.onExit(a);u(a,new ia(a))},u:function(){return 0},o:function(){},f: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=wb[a];0===m||10===m?((1===a?ja:E)(oa(n,0)),n.length=0):n.push(m)}f+=k}K[e>>2]=f;return 0},memory:H,p:function(){},table:la};
|
||||
(function(){function a(f){d.asm=f.exports;O--;d.monitorRunDependencies&&d.monitorRunDependencies(O);0==O&&(null!==Ia&&(clearInterval(Ia),Ia=null),P&&(f=P,P=null,f()))}function b(f){a(f.instance)}function c(f){return Na().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){E("failed to asynchronously prepare wasm: "+g);D(g)})}var e={a:Ab};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||Ka()||Ja("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 Oa=d.___wasm_call_ctors=function(){return(Oa=d.___wasm_call_ctors=d.asm.D).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.E).apply(null,arguments)},zb=d._malloc=function(){return(zb=d._malloc=d.asm.F).apply(null,arguments)},mb=d.___getTypeName=function(){return(mb=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_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.M).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.N).apply(null,arguments)};
|
||||
d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.O).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=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 Bb;function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}P=function Cb(){Bb||Db();Bb||(P=Cb)};
|
||||
function Db(){function a(){if(!Bb&&(Bb=!0,d.calledRun=!0,!ma)){Ca(Ea);Ca(Fa);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();Ga.unshift(b)}Ca(Ga)}}if(!(0<O)){if(d.preRun)for("function"==typeof d.preRun&&(d.preRun=[d.preRun]);d.preRun.length;)Ha();Ca(Da);0<O||(d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("")},1);a()},1)):a())}}
|
||||
d.run=Db;if(d.preInit)for("function"==typeof d.preInit&&(d.preInit=[d.preInit]);0<d.preInit.length;)d.preInit.pop()();noExitRuntime=!0;Db();
|
||||
|
||||
|
||||
return mozjpeg_enc.ready
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = mozjpeg_enc;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return mozjpeg_enc; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["mozjpeg_enc"] = mozjpeg_enc;
|
||||
|
Binary file not shown.
4
codecs/mozjpeg/package-lock.json
generated
Normal file
4
codecs/mozjpeg/package-lock.json
generated
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "mozjpeg_enc",
|
||||
"lockfileVersion": 1
|
||||
}
|
6
codecs/mozjpeg/package.json
Normal file
6
codecs/mozjpeg/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "mozjpeg_enc",
|
||||
"scripts": {
|
||||
"build": "../build-cpp.sh"
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
export EM_CACHE="${PWD}/node_modules/.em_cache"
|
||||
export OPTIMIZE="-Os -flto --llvm-lto 1"
|
||||
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 -iv
|
||||
emconfigure ./configure -C --without-simd
|
||||
emmake make libjpeg.la rdswitch.o -j`nproc`
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling mozjpeg done"
|
||||
echo "============================================="
|
||||
|
||||
echo "============================================="
|
||||
echo "Compiling wasm bindings"
|
||||
echo "============================================="
|
||||
(
|
||||
emcc \
|
||||
--bind \
|
||||
${OPTIMIZE} \
|
||||
--closure 1 \
|
||||
-s ALLOW_MEMORY_GROWTH=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s 'EXPORT_NAME="mozjpeg_enc"' \
|
||||
-I node_modules/mozjpeg \
|
||||
-o ./mozjpeg_enc.js \
|
||||
-std=c++11 \
|
||||
mozjpeg_enc.cpp \
|
||||
node_modules/mozjpeg/.libs/libjpeg.a \
|
||||
node_modules/mozjpeg/rdswitch.o
|
||||
)
|
||||
echo "============================================="
|
||||
echo "Compiling wasm bindings done"
|
||||
echo "============================================="
|
||||
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
||||
echo "Did you update your docker image?"
|
||||
echo "Run \`docker pull trzeci/emscripten-upstream\`"
|
||||
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@ -1,70 +0,0 @@
|
||||
|
||||
var mozjpeg_enc = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
||||
return (
|
||||
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:130,maximum:130,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[23104]=5335456;function Ba(a){for(;0<a.length;){var b=a.shift();if("function"==typeof b)b();else{var d=b.ea;"number"===typeof d?void 0===b.Y?c.dynCall_v(d):c.dynCall_vi(d,b.Y):d(void 0===b.Y?null:b.Y)}}}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({ea:function(){Ma()}});function Na(){return 0<Na.$}var Oa={};
|
||||
function Pa(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function Qa(a){return this.fromWireType(M[a>>2])}var Q={},R={},Ra={};function Sa(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 Ta(a,b){a=Sa(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}
|
||||
function Ua(a){var b=Error,d=Ta(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 Va=void 0;
|
||||
function Wa(a,b,d){function e(h){h=d(h);if(h.length!==a.length)throw new Va("Mismatched type converter count");for(var k=0;k<a.length;++k)S(a[k],h[k])}a.forEach(function(h){Ra[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 Xa(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 Ya=void 0;function T(a){for(var b="";H[a];)b+=Ya[H[a++]];return b}var Za=void 0;function U(a){throw new Za(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.ia)return;U("Cannot register type '"+e+"' twice")}R[a]=b;delete Ra[a];Q.hasOwnProperty(a)&&(b=Q[a],delete Q[a],b.forEach(function(f){f()}))}var $a=[],V=[{},{value:void 0},{value:null},{value:!0},{value:!1}];
|
||||
function ab(a){4<a&&0===--V[a].Z&&(V[a]=void 0,$a.push(a))}function bb(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=$a.length?$a.pop():V.length;V[b]={Z:1,value:a};return b}}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(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 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 d=Ta(b.name||"unknownFunctionName",function(){});d.prototype=b.prototype;d=new d;a=b.apply(d,a);return a instanceof Object?a:d}
|
||||
function fb(a,b){var d=c;if(void 0===d[a].W){var e=d[a];d[a]=function(){d[a].W.hasOwnProperty(arguments.length)||U("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+d[a].W+")!");return d[a].W[arguments.length].apply(this,arguments)};d[a].W=[];d[a].W[e.ba]=e}}
|
||||
function gb(a,b,d){c.hasOwnProperty(a)?((void 0===d||void 0!==c[a].W&&void 0!==c[a].W[d])&&U("Cannot register public name '"+a+"' twice"),fb(a,a),c.hasOwnProperty(d)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+d+")!"),c[a].W[d]=b):(c[a]=b,void 0!==d&&(c[a].pa=d))}function hb(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 ib=void 0;function jb(a){a=kb(a);var b=T(a);Y(a);return b}
|
||||
function lb(a,b){function d(g){f[g]||R[g]||(Ra[g]?Ra[g].forEach(d):(e.push(g),f[g]=!0))}var e=[],f={};b.forEach(d);throw new ib(a+": "+e.map(jb).join([", "]));}function mb(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 nb={};
|
||||
function ob(){if(!pb){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 nb)a[b]=nb[b];var d=[];for(b in a)d.push(b+"="+a[b]);pb=d}return pb}var pb,qb=[null,[],[]];Va=c.InternalError=Ua("InternalError");for(var rb=Array(256),sb=0;256>sb;++sb)rb[sb]=String.fromCharCode(sb);Ya=rb;Za=c.BindingError=Ua("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};ib=c.UnboundTypeError=Ua("UnboundTypeError");
|
||||
var ub={m:function(a){return tb(a)},l:function(a){"uncaught_exception"in Na?Na.$++:Na.$=1;throw a;},r:function(a){var b=Oa[a];delete Oa[a];var d=b.ja,e=b.ka,f=b.aa,g=f.map(function(m){return m.ha}).concat(f.map(function(m){return m.ma}));Wa([a],g,function(m){var h={};f.forEach(function(k,l){var n=m[l],q=k.fa,D=k.ga,y=m[l+f.length],p=k.la,E=k.na;h[k.da]={read:function(z){return n.fromWireType(q(D,z))},write:function(z,G){var X=[];p(E,z,y.toWireType(X,G));Pa(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:Qa,X:e}]})},t:function(a,b,d,e,f){var g=Xa(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])},X:null})},s:function(a,b){b=T(b);S(a,{name:b,fromWireType:function(d){var e=V[d].value;ab(d);return e},toWireType:function(d,e){return bb(e)},argPackAdvance:8,readValueFromPointer:Qa,X:null})},g:function(a,b,d){d=Xa(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 "'+cb(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:db(b,d),
|
||||
X:null})},d:function(a,b,d,e,f,g){var m=hb(b,d);a=T(a);f=W(e,f);gb(a,function(){lb("Cannot call "+a+" due to unbound types",m)},b-1);Wa([],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].X){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 "+Sa(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,Pa,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].X&&(l+=q+"_dtor("+q+"); // "+k[p].name+"\n",z.push(q+"_dtor"),n.push(k[p].X));E&&(l+="var ret = retType.fromWireType(rv);\nreturn ret;\n");z.push(l+"}\n");k=eb(z).apply(null,n);p=b-1;if(!c.hasOwnProperty(h))throw new Va("Replacing nonexistant public symbol");
|
||||
void 0!==c[h].W&&void 0!==p?c[h].W[p]=k:(c[h]=k,c[h].ba=p);return[]})},b:function(a,b,d,e,f){function g(l){return l}b=T(b);-1===f&&(f=4294967295);var m=Xa(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 "'+cb(n)+'" to '+this.name);if(n<e||n>f)throw new TypeError('Passing a number "'+cb(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:mb(b,m,0!==e),X: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},{ia:!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=tb(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:Qa,
|
||||
X:function(e){Y(e)}})},e: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=tb(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:Qa,X:function(k){Y(k)}})},y:function(a,b,d,e,f,g){Oa[a]={name:T(b),ja:W(d,e),ka:W(f,g),aa:[]}},f:function(a,b,d,e,f,g,m,h,k,l){Oa[a].aa.push({da:T(b),ha:d,fa:W(e,f),ga:g,ma:m,la:W(h,k),na:l})},u:function(a,b){b=T(b);S(a,{oa:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},k:ab,n:function(a){4<a&&(V[a].Z+=1)},z:function(a,b){var d=R[a];void 0===d&&
|
||||
U("_emval_take_value has unknown type "+jb(a));a=d.readValueFromPointer(b);return bb(a)},q:function(a,b,d){H.copyWithin(a,b,b+d)},c: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;ob().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=ob();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))},x:function(){return 0},o:function(){},i: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=qb[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,p:function(){},table:ka},vb=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:ub};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=vb;
|
||||
var Ma=c.___wasm_call_ctors=function(){return(Ma=c.___wasm_call_ctors=c.asm.A).apply(null,arguments)},tb=c._malloc=function(){return(tb=c._malloc=c.asm.B).apply(null,arguments)},Y=c._free=function(){return(Y=c._free=c.asm.C).apply(null,arguments)},kb=c.___getTypeName=function(){return(kb=c.___getTypeName=c.asm.D).apply(null,arguments)};c.___embind_register_native_and_builtin_types=function(){return(c.___embind_register_native_and_builtin_types=c.asm.E).apply(null,arguments)};
|
||||
c.dynCall_i=function(){return(c.dynCall_i=c.asm.F).apply(null,arguments)};c.dynCall_vi=function(){return(c.dynCall_vi=c.asm.G).apply(null,arguments)};c.dynCall_iii=function(){return(c.dynCall_iii=c.asm.H).apply(null,arguments)};c.dynCall_viii=function(){return(c.dynCall_viii=c.asm.I).apply(null,arguments)};c.dynCall_ii=function(){return(c.dynCall_ii=c.asm.J).apply(null,arguments)};c.dynCall_iiiiii=function(){return(c.dynCall_iiiiii=c.asm.K).apply(null,arguments)};
|
||||
c.dynCall_viiiii=function(){return(c.dynCall_viiiii=c.asm.L).apply(null,arguments)};c.dynCall_v=function(){return(c.dynCall_v=c.asm.M).apply(null,arguments)};c.dynCall_vii=function(){return(c.dynCall_vii=c.asm.N).apply(null,arguments)};c.dynCall_iiiiiii=function(){return(c.dynCall_iiiiiii=c.asm.O).apply(null,arguments)};c.dynCall_iiiii=function(){return(c.dynCall_iiiii=c.asm.P).apply(null,arguments)};c.dynCall_iiii=function(){return(c.dynCall_iiii=c.asm.Q).apply(null,arguments)};
|
||||
c.dynCall_viiiiiiii=function(){return(c.dynCall_viiiiiiii=c.asm.R).apply(null,arguments)};c.dynCall_viiii=function(){return(c.dynCall_viiii=c.asm.S).apply(null,arguments)};c.dynCall_viiiiiii=function(){return(c.dynCall_viiiiiii=c.asm.T).apply(null,arguments)};c.dynCall_jiji=function(){return(c.dynCall_jiji=c.asm.U).apply(null,arguments)};c.dynCall_viiiiii=function(){return(c.dynCall_viiiiii=c.asm.V).apply(null,arguments)};c.asm=vb;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 wb(){Z||xb();Z||(O=wb)};
|
||||
function xb(){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=xb;
|
||||
if(c.preInit)for("function"==typeof c.preInit&&(c.preInit=[c.preInit]);0<c.preInit.length;)c.preInit.pop()();noExitRuntime=!0;xb();
|
||||
|
||||
|
||||
return mozjpeg_enc
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = mozjpeg_enc;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return mozjpeg_enc; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["mozjpeg_enc"] = mozjpeg_enc;
|
||||
|
1147
codecs/mozjpeg_enc/package-lock.json
generated
1147
codecs/mozjpeg_enc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
394
codecs/oxipng/Cargo.lock
generated
394
codecs/oxipng/Cargo.lock
generated
@ -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"
|
||||
|
@ -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" }
|
||||
|
@ -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
|
||||
|
@ -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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@ -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.
@ -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
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} level
|
||||
* @returns {Uint8Array}
|
||||
* @param {Uint8Array} data
|
||||
* @param {number} level
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
export function optimise(data: Uint8Array, level: number): Uint8Array;
|
2
codecs/oxipng/pkg/squoosh_oxipng.js
Normal file
2
codecs/oxipng/pkg/squoosh_oxipng.js
Normal file
@ -0,0 +1,2 @@
|
||||
import * as wasm from "./squoosh_oxipng_bg.wasm";
|
||||
export * from "./squoosh_oxipng_bg.js";
|
@ -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 });
|
||||
|
BIN
codecs/oxipng/pkg/squoosh_oxipng_bg.wasm
Normal file
BIN
codecs/oxipng/pkg/squoosh_oxipng_bg.wasm
Normal file
Binary file not shown.
@ -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()
|
||||
}
|
||||
|
1
codecs/resize/.gitignore
vendored
1
codecs/resize/.gitignore
vendored
@ -1,6 +1,5 @@
|
||||
**/*.rs.bk
|
||||
target
|
||||
Cargo.lock
|
||||
bin/
|
||||
pkg/README.md
|
||||
lut.inc
|
||||
|
284
codecs/resize/Cargo.lock
generated
Normal file
284
codecs/resize/Cargo.lock
generated
Normal 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"
|
@ -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"]
|
||||
|
@ -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
|
@ -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 "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
13
codecs/resize/pkg/resize.d.ts
vendored
13
codecs/resize/pkg/resize.d.ts
vendored
@ -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;
|
@ -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
14
codecs/resize/pkg/squoosh_resize.d.ts
vendored
Normal 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;
|
2
codecs/resize/pkg/squoosh_resize.js
Normal file
2
codecs/resize/pkg/squoosh_resize.js
Normal file
@ -0,0 +1,2 @@
|
||||
import * as wasm from "./squoosh_resize_bg.wasm";
|
||||
export * from "./squoosh_resize_bg.js";
|
@ -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;
|
52
codecs/resize/pkg/squoosh_resize_bg.js
Normal file
52
codecs/resize/pkg/squoosh_resize_bg.js
Normal 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;
|
||||
}
|
||||
|
BIN
codecs/resize/pkg/squoosh_resize_bg.wasm
Normal file
BIN
codecs/resize/pkg/squoosh_resize_bg.wasm
Normal file
Binary file not shown.
@ -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)
|
||||
|
1
codecs/rotate/.gitignore
vendored
1
codecs/rotate/.gitignore
vendored
@ -1,2 +1 @@
|
||||
target
|
||||
Cargo.lock
|
||||
|
6
codecs/rotate/Cargo.lock
generated
Normal file
6
codecs/rotate/Cargo.lock
generated
Normal 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"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user