diff --git a/codecs/imagequant/README.md b/codecs/imagequant/README.md index 2d9d7343..c2f86a94 100644 --- a/codecs/imagequant/README.md +++ b/codecs/imagequant/README.md @@ -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()`. diff --git a/codecs/imagequant/example.html b/codecs/imagequant/example.html index 36da340c..cae32c8e 100644 --- a/codecs/imagequant/example.html +++ b/codecs/imagequant/example.html @@ -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'); diff --git a/codecs/imagequant/imagequant.d.ts b/codecs/imagequant/imagequant.d.ts index 122d15b8..d25d7a35 100644 --- a/codecs/imagequant/imagequant.d.ts +++ b/codecs/imagequant/imagequant.d.ts @@ -1,9 +1,6 @@ interface QuantizerModule extends EmscriptenWasm.Module { quantize(data: BufferSource, width: number, height: number, numColors: number, dither: number): Uint8ClampedArray; zx_quantize(data: BufferSource, width: number, height: number, dither: number): Uint8ClampedArray; - free_result(ptr: number): void; } export default function(opts: EmscriptenWasm.ModuleOpts): QuantizerModule; - - diff --git a/codecs/mozjpeg_enc/README.md b/codecs/mozjpeg_enc/README.md index e7b99769..780a7d62 100644 --- a/codecs/mozjpeg_enc/README.md +++ b/codecs/mozjpeg_enc/README.md @@ -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: diff --git a/codecs/mozjpeg_enc/example.html b/codecs/mozjpeg_enc/example.html index 2cff900f..6900e1d0 100644 --- a/codecs/mozjpeg_enc/example.html +++ b/codecs/mozjpeg_enc/example.html @@ -20,29 +20,28 @@ module.onRuntimeInitialized = async _ => { console.log('Version:', module.version().toString(16)); const image = await loadImage('../example.png'); - const result = module.encode(image.data, image.width, image.height, { - quality: 75, - baseline: false, - arithmetic: false, - progressive: true, - optimize_coding: true, - smoothing: 0, - color_space: 3, - quant_table: 3, - trellis_multipass: false, - trellis_opt_zero: false, - trellis_opt_table: false, - trellis_loops: 1, - auto_subsample: true, - chroma_subsample: 2, - separate_chroma_quality: false, - chroma_quality: 75, - }); + let results = []; + for (let i = 0; i < 2; i++) { + results.push(module.encode(image.data, image.width, image.height, { + quality: 75, + baseline: false, + arithmetic: false, + progressive: true, + optimize_coding: true, + smoothing: 0, + color_space: 3, + quant_table: 3, + trellis_multipass: false, + trellis_opt_zero: false, + trellis_opt_table: false, + trellis_loops: 1, + auto_subsample: true, + chroma_subsample: 2, + separate_chroma_quality: false, + chroma_quality: 75, + })); + } - const blob = new Blob([result], {type: 'image/jpeg'}); - const blobURL = URL.createObjectURL(blob); - const img = document.createElement('img'); - img.src = blobURL; - document.body.appendChild(img); + console.log(results); }; diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.cpp b/codecs/mozjpeg_enc/mozjpeg_enc.cpp index ae368c15..b1528550 100644 --- a/codecs/mozjpeg_enc/mozjpeg_enc.cpp +++ b/codecs/mozjpeg_enc/mozjpeg_enc.cpp @@ -55,8 +55,7 @@ int version() { return version; } -uint8_t* last_result; -struct jpeg_compress_struct cinfo; +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 +64,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 +81,7 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio * Note that this struct must live as long as the main JPEG parameter * struct, to avoid dangling-pointer problems. */ - struct jpeg_error_mgr jerr; - /* More stuff */ - JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */ - int row_stride; /* physical row width in image buffer */ - uint8_t* output; - unsigned long size; - - /* Step 1: allocate and initialize JPEG compression object */ - + jpeg_error_mgr jerr; /* We have to set up the error handler first, in case the initialization * step fails. (Unlikely, but it could happen if you are out of memory.) * This routine fills in the contents of struct jerr, and returns jerr's @@ -109,6 +103,8 @@ val encode(std::string image_in, int image_width, int image_height, MozJpegOptio // fprintf(stderr, "can't open %s\n", filename); // exit(1); // } + uint8_t* output; + unsigned long size; jpeg_mem_dest(&cinfo, &output, &size); /* Step 3: set parameters for compression */ @@ -184,31 +180,32 @@ 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); + + /* And we're done! */ + return js_result; } EMSCRIPTEN_BINDINGS(my_module) { @@ -232,5 +229,4 @@ EMSCRIPTEN_BINDINGS(my_module) { function("version", &version); function("encode", &encode); - function("free_result", &free_result); } diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.d.ts b/codecs/mozjpeg_enc/mozjpeg_enc.d.ts index 0c3691f4..58e808f4 100644 --- a/codecs/mozjpeg_enc/mozjpeg_enc.d.ts +++ b/codecs/mozjpeg_enc/mozjpeg_enc.d.ts @@ -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; diff --git a/codecs/mozjpeg_enc/mozjpeg_enc.js b/codecs/mozjpeg_enc/mozjpeg_enc.js index e08ce046..29a97983 100644 --- a/codecs/mozjpeg_enc/mozjpeg_enc.js +++ b/codecs/mozjpeg_enc/mozjpeg_enc.js @@ -6,55 +6,56 @@ var mozjpeg_enc = (function() { function(mozjpeg_enc) { mozjpeg_enc = mozjpeg_enc || {}; -var c;c||(c=typeof mozjpeg_enc !== 'undefined' ? mozjpeg_enc : {});var r={},t;for(t in c)c.hasOwnProperty(t)&&(r[t]=c[t]);var aa="./this.program";function u(a,b){throw b;}var ba=!1,v=!1,ca=!1,da=!1;ba="object"===typeof window;v="function"===typeof importScripts;ca="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;da=!ba&&!ca&&!v;var w="",ea,x,fa,ha; +var d;d||(d=typeof mozjpeg_enc !== 'undefined' ? mozjpeg_enc : {});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[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=e);)++d;if(16f?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=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>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>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=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=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=e);)++c;if(16f?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=H;if(0=g){var m=a.charCodeAt(++f);g=65536+((g&1023)<<10)|m&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){var b;for(b=a>>1;I[b];)++b;b<<=1;if(32>1];if(0==e)return c;++b;c+=String.fromCharCode(e)}}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>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,c="";;){var e=J[a+4*b>>2];if(0==e)return c;++b;65536<=e?(e-=65536,c+=String.fromCharCode(55296|e>>10,56320|e&1023)):c+=String.fromCharCode(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=g){var m=a.charCodeAt(++f);g=65536+((g&1023)<<10)|m&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=e&&++c;b+=4}return b}var K,L,H,I,wa,J,M,xa,ya;function za(a){K=a;d.HEAP8=L=new Int8Array(a);d.HEAP16=I=new Int16Array(a);d.HEAP32=J=new Int32Array(a);d.HEAPU8=H=new Uint8Array(a);d.HEAPU16=wa=new Uint16Array(a);d.HEAPU32=M=new Uint32Array(a);d.HEAPF32=xa=new Float32Array(a);d.HEAPF64=ya=new Float64Array(a)}var Aa=d.INITIAL_MEMORY||16777216;d.wasmMemory?F=d.wasmMemory:F=new WebAssembly.Memory({initial:Aa/65536}); +F&&(K=F.buffer);Aa=K.byteLength;za(K);J[23012]=5335088;function Ba(a){for(;0>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>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>2)+e]);return d} -function W(a,b){a=T(a);var d=c["dynCall_"+a];for(var e=[],f=1;f>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>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>2])};case 3:return function(c){return this.fromWireType(ya[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function eb(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Ta(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c} +function fb(a,b){var c=d;if(void 0===c[a].W){var e=c[a];c[a]=function(){c[a].W.hasOwnProperty(arguments.length)||U("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].W+")!");return c[a].W[arguments.length].apply(this,arguments)};c[a].W=[];c[a].W[e.ba]=e}} +function gb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].W&&void 0!==d[a].W[c])&&U("Cannot register public name '"+a+"' twice"),fb(a,a),d.hasOwnProperty(c)&&U("Cannot register multiple overloads of a function with the same number of arguments ("+c+")!"),d[a].W[c]=b):(d[a]=b,void 0!==c&&(d[a].pa=c))}function hb(a,b){for(var c=[],e=0;e>2)+e]);return c} +function W(a,b){a=T(a);var c=d["dynCall_"+a];for(var e=[],f=1;f>1]}:function(e){return wa[e>>1]};case 2:return c?function(e){return J[e>>2]}:function(e){return M[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var nb={}; +function ob(){return"object"===typeof globalThis?globalThis:Function("return this")()}function pb(a,b){var c=R[a];void 0===c&&U(b+" has unknown type "+jb(a));return c}var qb={},rb={};function sb(){if(!tb){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 rb)a[b]=rb[b];var c=[];for(b in a)c.push(b+"="+a[b]);tb=c}return tb} +var tb,ub=[null,[],[]];Va=d.InternalError=Ua("InternalError");for(var vb=Array(256),wb=0;256>wb;++wb)vb[wb]=String.fromCharCode(wb);Ya=vb;Za=d.BindingError=Ua("BindingError");d.count_emval_handles=function(){for(var a=0,b=5;b>g])},X:null})},s:function(a,b){b=T(b);S(a,{name:b,fromWireType:function(c){var e=V[c].value;ab(c);return e},toWireType:function(c,e){return bb(e)},argPackAdvance:8,readValueFromPointer:Qa,X:null})},g:function(a,b,c){c=Xa(c);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,c), +X:null})},e:function(a,b,c,e,f,g){var m=hb(b,c);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>>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(nf)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= +p+"); // "+k[p+2].name+"\n",z.push("argType"+p),n.push(k[p+2]);D&&(G="thisWired"+(0>>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(nf)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,c){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];c=T(c);S(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{ia:!0})},h:function(a,b){b=T(b);var c="std::string"===b;S(a,{name:b,fromWireType:function(e){var f=M[e>>2];if(c){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=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>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=d;d*=2){var e=b*(1+.2/d);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0>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>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>2],h=J[b+(8*g+4)>>2],k=0;k>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=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=xb(4+m+1);M[h>>2]=m;if(c&&g)oa(f,h+4,m+1);else if(g)for(g=0;g>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 "+ +c);var n=g(l),q=xb(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)}})},n:function(a,b,c,e,f,g){Oa[a]={name:T(b),ja:W(c,e),ka:W(f,g),aa:[]}},f:function(a,b,c,e,f,g,m,h,k,l){Oa[a].aa.push({da:T(b),ha:c,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(){}})},z:ab,A:function(a){if(0===a)return bb(ob());var b=nb[a];a=void 0===b?T(a):b; +return bb(ob()[a])},l:function(a){4> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n"; +f=(new Function("requireRegisteredType","Module","__emval_register",m+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(pb,d,bb);qb[b]=f}return f(a,c,e)},q:function(a,b,c){H.copyWithin(a,b,b+c)},c:function(a){var b=H.length;if(2147418112=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0>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 c=0;sb().forEach(function(e,f){var g=b+c;f=J[a+4*f>>2]=g;for(g=0;g>0]=e.charCodeAt(g);L[f>>0]=0;c+=e.length+1});return 0},w:function(a,b){var c=sb();J[a>>2]=c.length;var e=0;c.forEach(function(f){e+=f.length+1});J[b>>2]=e;return 0},y:function(a){if(!noExitRuntime&&(la=!0,d.onExit))d.onExit(a);u(a,new ia(a))},x:function(){return 0},o:function(){},i:function(a,b,c,e){for(var f=0,g=0;g>2],h=J[b+(8*g+4)>>2],k=0;k>2]=f;return 0},memory:F,p:function(){},table:ka},zb=function(){function a(f){d.asm=f.exports;N--;d.monitorRunDependencies&&d.monitorRunDependencies(N);0==N&&(null!==Ha&&(clearInterval(Ha),Ha=null),O&&(f=O,O=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:yb};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(C||"function"!==typeof WebAssembly.instantiateStreaming||Ia()||"function"!==typeof fetch)return c(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");c(b)})})})();return{}}(); +d.asm=zb;var Ma=d.___wasm_call_ctors=function(){return(Ma=d.___wasm_call_ctors=d.asm.B).apply(null,arguments)},xb=d._malloc=function(){return(xb=d._malloc=d.asm.C).apply(null,arguments)},Y=d._free=function(){return(Y=d._free=d.asm.D).apply(null,arguments)},kb=d.___getTypeName=function(){return(kb=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_vi=function(){return(d.dynCall_vi=d.asm.G).apply(null,arguments)};d.dynCall_i=function(){return(d.dynCall_i=d.asm.H).apply(null,arguments)};d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.I).apply(null,arguments)};d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.J).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.K).apply(null,arguments)};d.dynCall_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.L).apply(null,arguments)}; +d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.M).apply(null,arguments)};d.dynCall_vii=function(){return(d.dynCall_vii=d.asm.N).apply(null,arguments)};d.dynCall_iiiiiii=function(){return(d.dynCall_iiiiiii=d.asm.O).apply(null,arguments)};d.dynCall_iiiii=function(){return(d.dynCall_iiiii=d.asm.P).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.Q).apply(null,arguments)};d.dynCall_viiiiiiii=function(){return(d.dynCall_viiiiiiii=d.asm.R).apply(null,arguments)}; +d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.S).apply(null,arguments)};d.dynCall_viiiiiii=function(){return(d.dynCall_viiiiiii=d.asm.T).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.U).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.V).apply(null,arguments)};d.asm=zb;var Z;d.then=function(a){if(Z)a(d);else{var b=d.onRuntimeInitialized;d.onRuntimeInitialized=function(){b&&b();a(d)}}return d}; +function ia(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}O=function Ab(){Z||Bb();Z||(O=Ab)}; +function Bb(){function a(){if(!Z&&(Z=!0,d.calledRun=!0,!la)){Ba(Da);Ba(Ea);if(d.onRuntimeInitialized)d.onRuntimeInitialized();if(d.postRun)for("function"==typeof d.postRun&&(d.postRun=[d.postRun]);d.postRun.length;){var b=d.postRun.shift();Fa.unshift(b)}Ba(Fa)}}if(!(0 { console.log('Version:', Module.version().toString(16)); const image = await loadFile('../../example.webp'); - const result = Module.decode(image); - const imageData = new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height); - Module.free_result(); + const imageData = Module.decode(image); const canvas = document.createElement('canvas'); canvas.width = result.width; canvas.height = result.height; diff --git a/codecs/webp/dec/webp_dec.cpp b/codecs/webp/dec/webp_dec.cpp index 969338d5..ea6eed74 100644 --- a/codecs/webp/dec/webp_dec.cpp +++ b/codecs/webp/dec/webp_dec.cpp @@ -10,33 +10,17 @@ int version() { return WebPGetDecoderVersion(); } -class RawImage { - public: - val buffer; - int width; - int height; +const val Uint8ClampedArray = val::global("Uint8ClampedArray"); +const val ImageData = val::global("ImageData"); - RawImage(val b, int w, int h) : buffer(b), width(w), height(h) {} -}; - -uint8_t* last_result; -RawImage decode(std::string buffer) { +val decode(std::string buffer) { int width, height; - last_result = WebPDecodeRGBA((const uint8_t*)buffer.c_str(), buffer.size(), &width, &height); - return RawImage(val(typed_memory_view(width * height * 4, last_result)), width, height); -} - -void free_result() { - free(last_result); + std::unique_ptr rgba( + WebPDecodeRGBA((const uint8_t*)buffer.c_str(), buffer.size(), &width, &height)); + return ImageData.new_(Uint8ClampedArray.new_(typed_memory_view(width * height * 4, rgba.get())), width, height); } EMSCRIPTEN_BINDINGS(my_module) { - class_("RawImage") - .property("buffer", &RawImage::buffer) - .property("width", &RawImage::width) - .property("height", &RawImage::height); - function("decode", &decode); function("version", &version); - function("free_result", &free_result); } diff --git a/codecs/webp/dec/webp_dec.d.ts b/codecs/webp/dec/webp_dec.d.ts index a53187bb..6afc15a8 100644 --- a/codecs/webp/dec/webp_dec.d.ts +++ b/codecs/webp/dec/webp_dec.d.ts @@ -1,13 +1,5 @@ -interface RawImage { - buffer: Uint8Array; - width: number; - height: number; -} - interface WebPModule extends EmscriptenWasm.Module { - decode(data: BufferSource): RawImage; - free_result(): void; + decode(data: BufferSource): ImageData; } export default function(opts: EmscriptenWasm.ModuleOpts): WebPModule; - diff --git a/codecs/webp/dec/webp_dec.js b/codecs/webp/dec/webp_dec.js index b13ef59b..70e7d9ba 100644 --- a/codecs/webp/dec/webp_dec.js +++ b/codecs/webp/dec/webp_dec.js @@ -6,64 +6,51 @@ var webp_dec = (function() { function(webp_dec) { webp_dec = webp_dec || {}; -var e;e||(e=typeof webp_dec !== 'undefined' ? webp_dec : {});var r={},w;for(w in e)e.hasOwnProperty(w)&&(r[w]=e[w]);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||D("Assertion failed: undefined");return a},1=g){var q=a.charCodeAt(++f);g=65536+((g&1023)<<10)|q&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 na="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0; -function oa(a){var b;for(b=a>>1;I[b];)++b;b<<=1;if(32>1];if(0==d)return c;++b;c+=String.fromCharCode(d)}}function pa(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>1]=a.charCodeAt(f),b+=2;I[b>>1]=0;return b-d}function qa(a){return 2*a.length} -function ra(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 sa(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=g){var q=a.charCodeAt(++f);g=65536+((g&1023)<<10)|q&1023}J[b>>2]=g;b+=4;if(b+4>c)break}J[b>>2]=0;return b-d} -function ta(a){for(var b=0,c=0;c=d&&++c;b+=4}return b}var K,ua,H,I,va,J,L,wa,xa;function ya(a){K=a;e.HEAP8=ua=new Int8Array(a);e.HEAP16=I=new Int16Array(a);e.HEAP32=J=new Int32Array(a);e.HEAPU8=H=new Uint8Array(a);e.HEAPU16=va=new Uint16Array(a);e.HEAPU32=L=new Uint32Array(a);e.HEAPF32=wa=new Float32Array(a);e.HEAPF64=xa=new Float64Array(a)}var za=e.INITIAL_MEMORY||16777216;e.wasmMemory?G=e.wasmMemory:G=new WebAssembly.Memory({initial:za/65536}); -G&&(K=G.buffer);za=K.byteLength;ya(K);J[3336]=5256384;function Aa(a){for(;0=b?"_"+a:a} -function Ra(a,b){a=Qa(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Sa(a){var b=Error,c=Ra(a,function(d){this.name=a;this.message=d;d=Error(d).stack;void 0!==d&&(this.stack=this.toString()+"\n"+d.replace(/^Error(:[^\n]*)?\n/,""))});c.prototype=Object.create(b.prototype);c.prototype.constructor=c;c.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message};return c} -var Ta=void 0;function S(a){throw new Ta(a);}var Ua=void 0;function Va(a){throw new Ua(a);}function Wa(a,b,c){function d(h){h=c(h);h.length!==a.length&&Va("Mismatched type converter count");for(var l=0;l>2])}function qb(a,b,c){if(b===c)return a;if(void 0===c.R)return null;a=qb(a,b,c.R);return null===a?null:c.ja(a)}var rb={}; -function sb(a,b){for(void 0===b&&S("ptr should not be undefined");a.R;)b=a.Z(b),a=a.R;return rb[b]}function tb(a,b){b.N&&b.L||Va("makeClassHandle requires ptr and ptrType");!!b.P!==!!b.O&&Va("Both smartPtrType and smartPtr must be specified");b.count={value:1};return bb(Object.create(a,{K:{value:b}}))}function W(a,b,c,d){this.name=a;this.M=b;this.da=c;this.$=d;this.aa=!1;this.V=this.qa=this.pa=this.ga=this.ra=this.oa=void 0;void 0!==b.R?this.toWireType=lb:(this.toWireType=d?kb:nb,this.T=null)} -function ub(a,b,c){e.hasOwnProperty(a)||Va("Replacing nonexistant public symbol");void 0!==e[a].S&&void 0!==c?e[a].S[c]=b:(e[a]=b,e[a].ha=c)} -function X(a,b){a=P(a);var c=e["dynCall_"+a];for(var d=[],f=1;f>2])};case 3:return function(c){return this.fromWireType(xa[c>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Eb(a){var b=Function;if(!(b instanceof Function))throw new TypeError("new_ called with constructor type "+typeof b+" which is not a function");var c=Ra(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c} -function Fb(a,b){for(var c=[],d=0;d>2)+d]);return c}function Gb(a,b,c){switch(b){case 0:return c?function(d){return ua[d]}:function(d){return H[d]};case 1:return c?function(d){return I[d>>1]}:function(d){return va[d>>1]};case 2:return c?function(d){return J[d>>2]}:function(d){return L[d>>2]};default:throw new TypeError("Unknown integer type: "+a);}}for(var Hb=Array(256),Ib=0;256>Ib;++Ib)Hb[Ib]=String.fromCharCode(Ib);Oa=Hb;Ta=e.BindingError=Sa("BindingError"); -Ua=e.InternalError=Sa("InternalError");U.prototype.isAliasOf=function(a){if(!(this instanceof U&&a instanceof U))return!1;var b=this.K.N.M,c=this.K.L,d=a.K.N.M;for(a=a.K.L;b.R;)c=b.Z(c),b=b.R;for(;d.R;)a=d.Z(a),d=d.R;return b===d&&c===a};U.prototype.clone=function(){this.K.L||Ya(this);if(this.K.Y)return this.K.count.value+=1,this;var a=bb(Object.create(Object.getPrototypeOf(this),{K:{value:Xa(this.K)}}));a.K.count.value+=1;a.K.W=!1;return a}; -U.prototype["delete"]=function(){this.K.L||Ya(this);this.K.W&&!this.K.Y&&S("Object already scheduled for deletion");$a(this);ab(this.K);this.K.Y||(this.K.O=void 0,this.K.L=void 0)};U.prototype.isDeleted=function(){return!this.K.L};U.prototype.deleteLater=function(){this.K.L||Ya(this);this.K.W&&!this.K.Y&&S("Object already scheduled for deletion");db.push(this);1===db.length&&cb&&cb(eb);this.K.W=!0;return this};W.prototype.ma=function(a){this.ga&&(a=this.ga(a));return a}; -W.prototype.fa=function(a){this.V&&this.V(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.aa?tb(this.M.U,{N:this.oa,L:c,P:this,O:a}):tb(this.M.U,{N:this,L:a})}var c=this.ma(a);if(!c)return this.fa(a),null;var d=sb(this.M,c);if(void 0!==d){if(0===d.K.count.value)return d.K.L=c,d.K.O=a,d.clone();d=d.clone();this.fa(a);return d}d=this.M.la(c);d=fb[d];if(!d)return b.call(this);d=this.$?d.ia:d.pointerType;var f=qb(c,this.M,d.M);return null===f?b.call(this):this.aa?tb(d.M.U,{N:d,L:f,P:this,O:a}):tb(d.M.U,{N:d,L:f})}; -e.getInheritedInstanceCount=function(){return Object.keys(rb).length};e.getLiveInheritedInstances=function(){var a=[],b;for(b in rb)rb.hasOwnProperty(b)&&a.push(rb[b]);return a};e.flushPendingDeletes=eb;e.setDelayFunction=function(a){cb=a;db.length&&cb&&cb(eb)};vb=e.UnboundTypeError=Sa("UnboundTypeError");e.count_emval_handles=function(){for(var a=0,b=5;b>g])},T:null})},o:function(a,b,c,d,f,g,q,h,l,m,k,p,t){k=P(k);g=X(f,g);h&&(h=X(q,h)); -m&&(m=X(l,m));t=X(p,t);var v=Qa(k);hb(v,function(){yb("Cannot construct "+k+" due to unbound types",[d])});Wa([a,b,c],d?[d]:[],function(n){n=n[0];if(d){var u=n.M;var x=u.U}else x=U.prototype;n=Ra(v,function(){if(Object.getPrototypeOf(this)!==y)throw new Ta("Use 'new' to construct "+k);if(void 0===C.X)throw new Ta(k+" has no accessible constructor");var ob=C.X[arguments.length];if(void 0===ob)throw new Ta("Tried to invoke ctor of "+k+" with invalid number of parameters ("+arguments.length+") - expected ("+ -Object.keys(C.X).toString()+") parameters instead!");return ob.apply(this,arguments)});var y=Object.create(x,{constructor:{value:n}});n.prototype=y;var C=new ib(k,n,y,t,u,g,h,m);u=new W(k,C,!0,!1);x=new W(k+"*",C,!1,!1);var fa=new W(k+" const*",C,!1,!0);fb[a]={pointerType:x,ia:fa};ub(v,n);return[u,x,fa]})},e:function(a,b,c,d,f,g,q,h,l,m){b=P(b);f=X(d,f);Wa([],[a],function(k){k=k[0];var p=k.name+"."+b,t={get:function(){yb("Cannot access "+p+" due to unbound types",[c,q])},enumerable:!0,configurable:!0}; -l?t.set=function(){yb("Cannot access "+p+" due to unbound types",[c,q])}:t.set=function(){S(p+" is a read-only property")};Object.defineProperty(k.M.U,b,t);Wa([],l?[c,q]:[c],function(v){var n=v[0],u={get:function(){var y=Ab(this,k,p+" getter");return n.fromWireType(f(g,y))},enumerable:!0};if(l){l=X(h,l);var x=v[1];u.set=function(y){var C=Ab(this,k,p+" setter"),fa=[];l(m,C,x.toWireType(fa,y));zb(fa)}}Object.defineProperty(k.M.U,b,u);return[]});return[]})},q:function(a,b){b=P(b);T(a,{name:b,fromWireType:function(c){var d= -Z[c].value;Cb(c);return d},toWireType:function(c,d){return mb(d)},argPackAdvance:8,readValueFromPointer:pb,T:null})},h:function(a,b,c){c=Na(c);b=P(b);T(a,{name:b,fromWireType:function(d){return d},toWireType:function(d,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+V(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Db(b,c),T:null})},d:function(a,b,c,d,f,g){var q=Fb(b,c);a=P(a);f=X(d,f);hb(a,function(){yb("Cannot call "+a+" due to unbound types", -q)},b-1);Wa([],q,function(h){var l=[h[0],null].concat(h.slice(1)),m=h=a,k=f,p=l.length;2>p&&S("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var t=null!==l[1]&&!1,v=!1,n=1;n>>h}}var l=-1!=b.indexOf("unsigned");T(a,{name:b, -fromWireType:g,toWireType:function(m,k){if("number"!==typeof k&&"boolean"!==typeof k)throw new TypeError('Cannot convert "'+V(k)+'" to '+this.name);if(kf)throw new TypeError('Passing a number "'+V(k)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return l?k>>>0:k|0},argPackAdvance:8,readValueFromPointer:Gb(b,q,0!==d),T:null})},a:function(a,b,c){function d(g){g>>=2;var q=L;return new f(K,q[g+1],q[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},{na:!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],q=0;0!=g&&(q=g,H[d+4+f]=0);var h=d+4;for(g=0;g<=f;++g){var l=d+4+g;if(0==H[l]){if(h){for(var m=H,k=h+NaN,p=h;m[p]&&!(p>=k);)++p;if(16t?k+=String.fromCharCode(t):(t-=65536,k+=String.fromCharCode(55296|t>>10,56320|t&1023))}}else k+=String.fromCharCode(t)}h=k}}else h="";if(void 0===u)var u=h;else u+=String.fromCharCode(0),u+=h;h=l+1}}0!=q&&(H[d+4+f]=q)}else{u=Array(f);for(g=0;g=p&&(p=65536+((p&1023)<<10)|f.charCodeAt(++k)&1023);127>=p?++m:m=2047>=p?m+2:65535>=p?m+3:m+4}return m}:function(){return f.length})(),h=Jb(4+q+1);L[h>>2]=q;if(c&&g)ma(f,h+4,q+1);else if(g)for(g=0;g>2],k=q(),p=k[l+4+m*b>>h],t=0;0!=p&&(t=p,k[l+4+m*b>>h]=0);var v=l+4;for(p=0;p<=m;++p){var n= -l+4+p*b;if(0==k[n>>h]){v=d(v);if(void 0===u)var u=v;else u+=String.fromCharCode(0),u+=v;v=n+b}}0!=t&&(k[l+4+m*b>>h]=t);Y(l);return u},toWireType:function(l,m){"string"!==typeof m&&S("Cannot pass non-string to C++ string type "+c);var k=g(m),p=Jb(4+k+b);L[p>>2]=k>>h;f(m,p+4,k+b);null!==l&&l.push(Y,p);return p},argPackAdvance:8,readValueFromPointer:pb,T:function(l){Y(l)}})},l:function(a,b){b=P(b);T(a,{sa:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},g:Cb,r:function(a){4< -a&&(Z[a].ea+=1)},j:function(a,b){var c=R[a];void 0===c&&S("_emval_take_value has unknown type "+wb(a));a=c.readValueFromPointer(b);return mb(a)},p:function(a,b,c){H.copyWithin(a,b,b+c)},c:function(a){var b=H.length;if(2147418112=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(16777216,a,d);0>16);ya(G.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},memory:G, -table:ja},Lb=function(){function a(f){e.asm=f.exports;M--;e.monitorRunDependencies&&e.monitorRunDependencies(M);0==M&&(null!==Ga&&(clearInterval(Ga),Ga=null),N&&(f=N,N=null,f()))}function b(f){a(f.instance)}function c(f){return Ka().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){E("failed to asynchronously prepare wasm: "+g);D(g)})}var d={a:Kb};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||Ha()||"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=Lb; -var La=e.___wasm_call_ctors=function(){return(La=e.___wasm_call_ctors=e.asm.s).apply(null,arguments)},Y=e._free=function(){return(Y=e._free=e.asm.t).apply(null,arguments)},Jb=e._malloc=function(){return(Jb=e._malloc=e.asm.u).apply(null,arguments)},xb=e.___getTypeName=function(){return(xb=e.___getTypeName=e.asm.v).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.w).apply(null,arguments)}; -e.dynCall_ii=function(){return(e.dynCall_ii=e.asm.x).apply(null,arguments)};e.dynCall_vi=function(){return(e.dynCall_vi=e.asm.y).apply(null,arguments)};e.dynCall_iii=function(){return(e.dynCall_iii=e.asm.z).apply(null,arguments)};e.dynCall_viii=function(){return(e.dynCall_viii=e.asm.A).apply(null,arguments)};e.dynCall_vii=function(){return(e.dynCall_vii=e.asm.B).apply(null,arguments)};e.dynCall_i=function(){return(e.dynCall_i=e.asm.C).apply(null,arguments)}; -e.dynCall_v=function(){return(e.dynCall_v=e.asm.D).apply(null,arguments)};e.dynCall_iiii=function(){return(e.dynCall_iiii=e.asm.E).apply(null,arguments)};e.dynCall_iiiiiii=function(){return(e.dynCall_iiiiiii=e.asm.F).apply(null,arguments)};e.dynCall_viiii=function(){return(e.dynCall_viiii=e.asm.G).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.H).apply(null,arguments)};e.dynCall_viiiiiiiii=function(){return(e.dynCall_viiiiiiiii=e.asm.I).apply(null,arguments)}; -e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.J).apply(null,arguments)};e.asm=Lb;var Mb;e.then=function(a){if(Mb)a(e);else{var b=e.onRuntimeInitialized;e.onRuntimeInitialized=function(){b&&b();a(e)}}return e};N=function Nb(){Mb||Ob();Mb||(N=Nb)}; -function Ob(){function a(){if(!Mb&&(Mb=!0,e.calledRun=!0,!ka)){Aa(Ca);Aa(Da);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();Ea.unshift(b)}Aa(Ea)}}if(!(0=g){var q=a.charCodeAt(++f);g=65536+((g&1023)<<10)|q&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 ka="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0; +function la(a){var b;for(b=a>>1;H[b];)++b;b<<=1;if(32>1];if(0==e)return d;++b;d+=String.fromCharCode(e)}}function ma(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>1]=a.charCodeAt(f),b+=2;H[b>>1]=0;return b-e}function na(a){return 2*a.length} +function oa(a){for(var b=0,d="";;){var e=I[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 pa(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=g){var q=a.charCodeAt(++f);g=65536+((g&1023)<<10)|q&1023}I[b>>2]=g;b+=4;if(b+4>d)break}I[b>>2]=0;return b-e} +function qa(a){for(var b=0,d=0;d=e&&++d;b+=4}return b}var J,ra,G,H,sa,I,K,ta,ua;function va(a){J=a;c.HEAP8=ra=new Int8Array(a);c.HEAP16=H=new Int16Array(a);c.HEAP32=I=new Int32Array(a);c.HEAPU8=G=new Uint8Array(a);c.HEAPU16=sa=new Uint16Array(a);c.HEAPU32=K=new Uint32Array(a);c.HEAPF32=ta=new Float32Array(a);c.HEAPF64=ua=new Float64Array(a)}var wa=c.INITIAL_MEMORY||16777216;c.wasmMemory?F=c.wasmMemory:F=new WebAssembly.Memory({initial:wa/65536}); +F&&(J=F.buffer);wa=J.byteLength;va(J);I[3260]=5256080;function M(a){for(;0=b?"_"+a:a} +function Ma(a,b){a=La(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Na(a){var b=Error,d=Ma(a,function(e){this.name=a;this.message=e;e=Error(e).stack;void 0!==e&&(this.stack=this.toString()+"\n"+e.replace(/^Error(:[^\n]*)?\n/,""))});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 Oa=void 0;function V(a){throw new Oa(a);}var Pa=void 0;function Qa(a,b){function d(h){h=b(h);if(h.length!==e.length)throw new Pa("Mismatched type converter count");for(var k=0;k>2])}function Wa(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a} +function Xa(a,b){switch(b){case 2:return function(d){return this.fromWireType(ta[d>>2])};case 3:return function(d){return this.fromWireType(ua[d>>3])};default:throw new TypeError("Unknown float type: "+a);}}function Ya(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=Ma(b.name||"unknownFunctionName",function(){});d.prototype=b.prototype;d=new d;a=b.apply(d,a);return a instanceof Object?a:d} +function Za(a){for(;a.length;){var b=a.pop();a.pop()(b)}}function $a(a,b){var d=c;if(void 0===d[a].H){var e=d[a];d[a]=function(){d[a].H.hasOwnProperty(arguments.length)||V("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+d[a].H+")!");return d[a].H[arguments.length].apply(this,arguments)};d[a].H=[];d[a].H[e.M]=e}} +function ab(a,b,d){c.hasOwnProperty(a)?((void 0===d||void 0!==c[a].H&&void 0!==c[a].H[d])&&V("Cannot register public name '"+a+"' twice"),$a(a,a),c.hasOwnProperty(d)&&V("Cannot register multiple overloads of a function with the same number of arguments ("+d+")!"),c[a].H[d]=b):(c[a]=b,void 0!==d&&(c[a].R=d))}function bb(a,b){for(var d=[],e=0;e>2)+e]);return d} +function cb(a,b){a=S(a);var d=c["dynCall_"+a];for(var e=[],f=1;f>1]}:function(e){return sa[e>>1]};case 2:return d?function(e){return I[e>>2]}:function(e){return K[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var ib={}; +function jb(){return"object"===typeof globalThis?globalThis:Function("return this")()}function kb(a,b){var d=U[a];void 0===d&&V(b+" has unknown type "+eb(a));return d}for(var lb={},mb=Array(256),nb=0;256>nb;++nb)mb[nb]=String.fromCharCode(nb);Ja=mb;Oa=c.BindingError=Na("BindingError");Pa=c.InternalError=Na("InternalError");c.count_emval_handles=function(){for(var a=0,b=5;b>g])},I:null})},o:function(a,b){b=S(b);W(a,{name:b,fromWireType:function(d){var e=X[d].value; +Ta(d);return e},toWireType:function(d,e){return Ua(e)},argPackAdvance:8,readValueFromPointer:Va,I:null})},h:function(a,b,d){d=Ia(d);b=S(b);W(a,{name:b,fromWireType:function(e){return e},toWireType:function(e,f){if("number"!==typeof f&&"boolean"!==typeof f)throw new TypeError('Cannot convert "'+Wa(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:Xa(b,d),I:null})},f:function(a,b,d,e,f,g){var q=bb(b,d);a=S(a);f=cb(e,f);ab(a,function(){gb("Cannot call "+a+" due to unbound types", +q)},b-1);Qa(q,function(h){var k=[h[0],null].concat(h.slice(1)),l=h=a,n=f,p=k.length;2>p&&V("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var r=null!==k[1]&&!1,v=!1,m=1;m>>h}}var k=-1!=b.indexOf("unsigned");W(a,{name:b,fromWireType:g,toWireType:function(l,n){if("number"!==typeof n&&"boolean"!==typeof n)throw new TypeError('Cannot convert "'+Wa(n)+'" to '+this.name);if(nf)throw new TypeError('Passing a number "'+Wa(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:hb(b, +q,0!==e),I:null})},a:function(a,b,d){function e(g){g>>=2;var q=K;return new f(J,q[g+1],q[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];d=S(d);W(a,{name:d,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{O:!0})},e:function(a,b){b=S(b);var d="std::string"===b;W(a,{name:b,fromWireType:function(e){var f=K[e>>2];if(d){var g=G[e+4+f],q=0;0!=g&&(q=g,G[e+4+f]=0);var h=e+4;for(g=0;g<=f;++g){var k=e+4+g;if(0==G[k]){if(h){for(var l=G,n=h+ +NaN,p=h;l[p]&&!(p>=n);)++p;if(16r?n+=String.fromCharCode(r):(r-=65536,n+=String.fromCharCode(55296|r>>10,56320|r&1023))}}else n+=String.fromCharCode(r)}h=n}}else h="";if(void 0===u)var u=h;else u+=String.fromCharCode(0),u+=h;h=k+1}}0!=q&&(G[e+4+f]=q)}else{u= +Array(f);for(g=0;g=p&&(p=65536+((p&1023)<<10)|f.charCodeAt(++n)&1023);127>=p?++l:l=2047>=p?l+2:65535>=p?l+3:l+4}return l}: +function(){return f.length})(),h=ob(4+q+1);K[h>>2]=q;if(d&&g)ja(f,h+4,q+1);else if(g)for(g=0;g>2],n=q(),p=n[k+4+l*b>>h],r=0;0!=p&&(r=p,n[k+4+l*b>>h]=0);var v=k+4;for(p=0;p<=l;++p){var m=k+4+p*b;if(0==n[m>>h]){v=e(v);if(void 0===u)var u=v;else u+=String.fromCharCode(0),u+=v;v=m+b}}0!=r&&(n[k+4+l*b>>h]=r);Y(k);return u},toWireType:function(k,l){"string"!==typeof l&&V("Cannot pass non-string to C++ string type "+d);var n=g(l),p=ob(4+n+b);K[p>>2]=n>>h;f(l,p+4,n+b);null!==k&&k.push(Y,p);return p},argPackAdvance:8,readValueFromPointer:Va,I:function(k){Y(k)}})}, +j:function(a,b){b=S(b);W(a,{P:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},p:Ta,q:function(a){if(0===a)return Ua(jb());var b=ib[a];a=void 0===b?S(a):b;return Ua(jb()[a])},m:function(a){4> 2) + "+ +g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType","Module","__emval_register",q+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(kb,c,Ua);lb[b]=f}return f(a,d,e)},n:function(a,b,d){G.copyWithin(a,b,b+d)},c:function(a){var b=G.length;if(2147418112=d;d*=2){var e=b*(1+.2/d);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0>16);va(F.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},memory:F,table:fa},qb=function(){function a(f){c.asm=f.exports;N--;c.monitorRunDependencies&&c.monitorRunDependencies(N);0==N&&(null!==Ca&&(clearInterval(Ca),Ca=null),O&&(f=O,O=null,f()))}function b(f){a(f.instance)}function d(f){return Ga().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){D("failed to asynchronously prepare wasm: "+ +g);C(g)})}var e={a:pb};N++;c.monitorRunDependencies&&c.monitorRunDependencies(N);if(c.instantiateWasm)try{return c.instantiateWasm(e,a)}catch(f){return D("Module.instantiateWasm callback failed with error: "+f),!1}(function(){if(E||"function"!==typeof WebAssembly.instantiateStreaming||Da()||"function"!==typeof fetch)return d(b);fetch(Q,{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"); +d(b)})})})();return{}}();c.asm=qb;var Ha=c.___wasm_call_ctors=function(){return(Ha=c.___wasm_call_ctors=c.asm.r).apply(null,arguments)},ob=c._malloc=function(){return(ob=c._malloc=c.asm.s).apply(null,arguments)},Y=c._free=function(){return(Y=c._free=c.asm.t).apply(null,arguments)},fb=c.___getTypeName=function(){return(fb=c.___getTypeName=c.asm.u).apply(null,arguments)}; +c.___embind_register_native_and_builtin_types=function(){return(c.___embind_register_native_and_builtin_types=c.asm.v).apply(null,arguments)};c.dynCall_vi=function(){return(c.dynCall_vi=c.asm.w).apply(null,arguments)};c.dynCall_iii=function(){return(c.dynCall_iii=c.asm.x).apply(null,arguments)};c.dynCall_vii=function(){return(c.dynCall_vii=c.asm.y).apply(null,arguments)};c.dynCall_ii=function(){return(c.dynCall_ii=c.asm.z).apply(null,arguments)}; +c.dynCall_i=function(){return(c.dynCall_i=c.asm.A).apply(null,arguments)};c.dynCall_iiii=function(){return(c.dynCall_iiii=c.asm.B).apply(null,arguments)};c.dynCall_iiiiiii=function(){return(c.dynCall_iiiiiii=c.asm.C).apply(null,arguments)};c.dynCall_viiii=function(){return(c.dynCall_viiii=c.asm.D).apply(null,arguments)};c.dynCall_viiiii=function(){return(c.dynCall_viiiii=c.asm.E).apply(null,arguments)};c.dynCall_viiiiiiiii=function(){return(c.dynCall_viiiiiiiii=c.asm.F).apply(null,arguments)}; +c.dynCall_viiiiii=function(){return(c.dynCall_viiiiii=c.asm.G).apply(null,arguments)};c.asm=qb;var Z;c.then=function(a){if(Z)a(c);else{var b=c.onRuntimeInitialized;c.onRuntimeInitialized=function(){b&&b();a(c)}}return c};O=function rb(){Z||sb();Z||(O=rb)}; +function sb(){function a(){if(!Z&&(Z=!0,c.calledRun=!0,!ha)){M(ya);M(za);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();Aa.unshift(b)}M(Aa)}}if(!(0=g){var n=a.charCodeAt(++f);g=65536+((g&1023)<<10)|n&1023}if(127>=g){if(b>=c)break;e[b++]=g}else{if(2047>=g){if(b+1>=c)break;e[b++]=192|g>>6}else{if(65535>=g){if(b+2>=c)break;e[b++]=224|g>>12}else{if(b+3>=c)break;e[b++]=240|g>>18;e[b++]=128|g>>12&63}e[b++]=128|g>>6&63}e[b++]=128|g&63}}e[b]=0}}var ka="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0; function la(a){var b;for(b=a>>1;J[b];)++b;b<<=1;if(32>1];if(0==e)return c;++b;c+=String.fromCharCode(e)}}function ma(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>1]=a.charCodeAt(f),b+=2;J[b>>1]=0;return b-e}function na(a){return 2*a.length} function oa(a){for(var b=0,c="";;){var e=K[a+4*b>>2];if(0==e)return c;++b;65536<=e?(e-=65536,c+=String.fromCharCode(55296|e>>10,56320|e&1023)):c+=String.fromCharCode(e)}}function pa(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=g){var n=a.charCodeAt(++f);g=65536+((g&1023)<<10)|n&1023}K[b>>2]=g;b+=4;if(b+4>c)break}K[b>>2]=0;return b-e} @@ -30,31 +30,32 @@ function ab(a,b,c){switch(b){case 0:return function(e){return this.fromWireType( 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(ta[c>>2])};case 3:return function(c){return this.fromWireType(ua[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=Pa(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){for(var c=[],e=0;e>2)+e]);return c} function Y(a,b){a=T(a);var c=d["dynCall_"+a];for(var e=[],f=1;f>1]}:function(e){return sa[e>>1]};case 2:return c?function(e){return K[e>>2]}:function(e){return M[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}Ra=d.InternalError=Qa("InternalError"); -for(var lb=Array(256),mb=0;256>mb;++mb)lb[mb]=String.fromCharCode(mb);Ua=lb;Va=d.BindingError=Qa("BindingError");d.count_emval_handles=function(){for(var a=0,b=5;b>g])},O:null})},r:function(a,b){b=T(b);S(a,{name:b,fromWireType:function(c){var e=V[c].value;Xa(c);return e},toWireType:function(c,e){return Ya(e)},argPackAdvance:8,readValueFromPointer:Ma,O:null})},o:function(a,b,c,e){function f(){}c=Ta(c);b=T(b);f.values={};S(a,{name:b,constructor:f,fromWireType:function(g){return this.constructor.values[g]},toWireType:function(g,n){return n.value},argPackAdvance:8,readValueFromPointer:ab(b,c,e),O:null});$a(b,f)},n:function(a,b,c){var e= -db(a,"enum");b=T(b);a=e.constructor;e=Object.create(e.constructor.prototype,{value:{value:c},constructor:{value:Pa(e.name+"_"+b,function(){})}});a.values[c]=e;a[b]=e},g:function(a,b,c){c=Ta(c);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 "'+eb(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:fb(b,c),O:null})},d:function(a,b,c,e,f,g){var n=hb(b,c);a=T(a);f=Y(e,f); -$a(a,function(){jb("Cannot call "+a+" due to unbound types",n)},b-1);Sa([],n,function(h){var k=[h[0],null].concat(h.slice(1)),l=h=a,m=f,p=k.length;2>p&&U("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var r=null!==k[1]&&!1,v=!1,q=1;q>1]}:function(e){return sa[e>>1]};case 2:return c?function(e){return K[e>>2]}:function(e){return M[e>>2]};default:throw new TypeError("Unknown integer type: "+a);}}var lb={}; +function mb(){return"object"===typeof globalThis?globalThis:Function("return this")()}var nb={};Ra=d.InternalError=Qa("InternalError");for(var ob=Array(256),pb=0;256>pb;++pb)ob[pb]=String.fromCharCode(pb);Ua=ob;Va=d.BindingError=Qa("BindingError");d.count_emval_handles=function(){for(var a=0,b=5;b>g])},O:null})},s:function(a,b){b=T(b);S(a,{name:b,fromWireType:function(c){var e=V[c].value;Xa(c);return e},toWireType:function(c,e){return Ya(e)},argPackAdvance:8,readValueFromPointer:Ma,O:null})},n:function(a,b,c,e){function f(){}c=Ta(c);b=T(b);f.values={};S(a,{name:b,constructor:f,fromWireType:function(g){return this.constructor.values[g]},toWireType:function(g,n){return n.value},argPackAdvance:8,readValueFromPointer:ab(b,c,e),O:null});$a(b,f)},m:function(a,b,c){var e= +db(a,"enum");b=T(b);a=e.constructor;e=Object.create(e.constructor.prototype,{value:{value:c},constructor:{value:Pa(e.name+"_"+b,function(){})}});a.values[c]=e;a[b]=e},f:function(a,b,c){c=Ta(c);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 "'+eb(f)+'" to '+this.name);return f},argPackAdvance:8,readValueFromPointer:fb(b,c),O:null})},h:function(a,b,c,e,f,g){var n=hb(b,c);a=T(a);f=Y(e,f); +$a(a,function(){jb("Cannot call "+a+" due to unbound types",n)},b-1);Sa([],n,function(h){var k=[h[0],null].concat(h.slice(1)),l=h=a,m=f,p=k.length;2>p&&U("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var r=null!==k[1]&&!1,w=!1,q=1;q>>h}}var k=-1!=b.indexOf("unsigned");S(a,{name:b,fromWireType:g,toWireType:function(l,m){if("number"!==typeof m&&"boolean"!==typeof m)throw new TypeError('Cannot convert "'+eb(m)+'" to '+this.name);if(mf)throw new TypeError('Passing a number "'+eb(m)+'" from JS side to C/C++ side to an argument of type "'+ -b+'", which is outside the valid range ['+e+", "+f+"]!");return k?m>>>0:m|0},argPackAdvance:8,readValueFromPointer:kb(b,n,0!==e),O:null})},a:function(a,b,c){function e(g){g>>=2;var n=M;return new f(L,n[g+1],n[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);S(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{aa:!0})},h:function(a,b){b=T(b);var c="std::string"===b;S(a,{name:b,fromWireType:function(e){var f=M[e>>2];if(c){var g= -I[e+4+f],n=0;0!=g&&(n=g,I[e+4+f]=0);var h=e+4;for(g=0;g<=f;++g){var k=e+4+g;if(0==I[k]){if(h){for(var l=I,m=h+NaN,p=h;l[p]&&!(p>=m);)++p;if(16r?m+=String.fromCharCode(r):(r-=65536,m+=String.fromCharCode(55296|r>>10,56320|r&1023))}}else m+=String.fromCharCode(r)}h= +b+'", which is outside the valid range ['+e+", "+f+"]!");return k?m>>>0:m|0},argPackAdvance:8,readValueFromPointer:kb(b,n,0!==e),O:null})},a:function(a,b,c){function e(g){g>>=2;var n=M;return new f(L,n[g+1],n[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=T(c);S(a,{name:c,fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{aa:!0})},g:function(a,b){b=T(b);var c="std::string"===b;S(a,{name:b,fromWireType:function(e){var f=M[e>>2];if(c){var g= +I[e+4+f],n=0;0!=g&&(n=g,I[e+4+f]=0);var h=e+4;for(g=0;g<=f;++g){var k=e+4+g;if(0==I[k]){if(h){for(var l=I,m=h+NaN,p=h;l[p]&&!(p>=m);)++p;if(16r?m+=String.fromCharCode(r):(r-=65536,m+=String.fromCharCode(55296|r>>10,56320|r&1023))}}else m+=String.fromCharCode(r)}h= m}}else h="";if(void 0===t)var t=h;else t+=String.fromCharCode(0),t+=h;h=k+1}}0!=n&&(I[e+4+f]=n)}else{t=Array(f);for(g=0;g=p&&(p=65536+((p&1023)<<10)|f.charCodeAt(++m)&1023);127>=p?++l:l=2047>=p?l+2:65535>=p?l+3:l+4}return l}:function(){return f.length})(),h=nb(4+n+1);M[h>>2]=n;if(c&&g)ja(f,h+4,n+1);else if(g)for(g=0;g>2],m=n(),p=m[k+4+l*b>>h],r=0;0!=p&&(r=p,m[k+4+l*b>>h]=0);var v=k+4;for(p=0;p<=l;++p){var q=k+4+p*b;if(0==m[q>>h]){v=e(v);if(void 0===t)var t=v;else t+=String.fromCharCode(0),t+=v;v=q+b}}0!=r&&(m[k+4+l*b>>h]=r);X(k);return t},toWireType:function(k,l){"string"!==typeof l&&U("Cannot pass non-string to C++ string type "+c);var m=g(l),p=nb(4+m+b);M[p>> -2]=m>>h;f(l,p+4,m+b);null!==k&&k.push(X,p);return p},argPackAdvance:8,readValueFromPointer:Ma,O:function(k){X(k)}})},m:function(a,b,c,e,f,g){Ka[a]={name:T(b),ba:Y(c,e),da:Y(f,g),U:[]}},e:function(a,b,c,e,f,g,n,h,k,l){Ka[a].U.push({W:T(b),$:c,Y:Y(e,f),Z:g,fa:n,ea:Y(h,k),ga:l})},t:function(a,b){b=T(b);S(a,{ha:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},u:Xa,k:function(a){4=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0>16);va(G.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},memory:G,table:fa},pb=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 Ha().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){E("failed to asynchronously prepare wasm: "+g);D(g)})}var e={a:ob};N++;d.monitorRunDependencies&&d.monitorRunDependencies(N);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return E("Module.instantiateWasm callback failed with error: "+f),!1}(function(){if(F||"function"!==typeof WebAssembly.instantiateStreaming||Ea()||"function"!== -typeof fetch)return c(b);fetch(P,{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");c(b)})})})();return{}}();d.asm=pb; -var Ia=d.___wasm_call_ctors=function(){return(Ia=d.___wasm_call_ctors=d.asm.v).apply(null,arguments)},nb=d._malloc=function(){return(nb=d._malloc=d.asm.w).apply(null,arguments)},X=d._free=function(){return(X=d._free=d.asm.x).apply(null,arguments)},cb=d.___getTypeName=function(){return(cb=d.___getTypeName=d.asm.y).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.z).apply(null,arguments)}; -d.dynCall_i=function(){return(d.dynCall_i=d.asm.A).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.B).apply(null,arguments)};d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.C).apply(null,arguments)};d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.D).apply(null,arguments)};d.dynCall_fii=function(){return(d.dynCall_fii=d.asm.E).apply(null,arguments)};d.dynCall_viif=function(){return(d.dynCall_viif=d.asm.F).apply(null,arguments)}; -d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.G).apply(null,arguments)};d.dynCall_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.H).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.I).apply(null,arguments)};d.dynCall_v=function(){return(d.dynCall_v=d.asm.J).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.K).apply(null,arguments)};d.dynCall_viiiiiiiii=function(){return(d.dynCall_viiiiiiiii=d.asm.L).apply(null,arguments)}; -d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.M).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.N).apply(null,arguments)};d.asm=pb;var Z;d.then=function(a){if(Z)a(d);else{var b=d.onRuntimeInitialized;d.onRuntimeInitialized=function(){b&&b();a(d)}}return d};O=function qb(){Z||rb();Z||(O=qb)}; -function rb(){function a(){if(!Z&&(Z=!0,d.calledRun=!0,!ha)){xa(za);xa(Aa);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)}xa(Ba)}}if(!(0=p&&(p=65536+((p&1023)<<10)|f.charCodeAt(++m)&1023);127>=p?++l:l=2047>=p?l+2:65535>=p?l+3:l+4}return l}:function(){return f.length})(),h=qb(4+n+1);M[h>>2]=n;if(c&&g)ja(f,h+4,n+1);else if(g)for(g=0;g>2],m=n(),p=m[k+4+l*b>>h],r=0;0!=p&&(r=p,m[k+4+l*b>>h]=0);var w=k+4;for(p=0;p<=l;++p){var q=k+4+p*b;if(0==m[q>>h]){w=e(w);if(void 0===t)var t=w;else t+=String.fromCharCode(0),t+=w;w=q+b}}0!=r&&(m[k+4+l*b>>h]=r);X(k);return t},toWireType:function(k,l){"string"!==typeof l&&U("Cannot pass non-string to C++ string type "+c);var m=g(l),p=qb(4+m+b);M[p>> +2]=m>>h;f(l,p+4,m+b);null!==k&&k.push(X,p);return p},argPackAdvance:8,readValueFromPointer:Ma,O:function(k){X(k)}})},l:function(a,b,c,e,f,g){Ka[a]={name:T(b),ba:Y(c,e),da:Y(f,g),U:[]}},d:function(a,b,c,e,f,g,n,h,k,l){Ka[a].U.push({W:T(b),$:c,Y:Y(e,f),Z:g,fa:n,ea:Y(h,k),ga:l})},u:function(a,b){b=T(b);S(a,{ha:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},p:Xa,r:function(a){if(0===a)return Ya(mb());var b=lb[a];a=void 0===b?T(a):b;return Ya(mb()[a])},v:function(a){4< +a&&(V[a].S+=1)},o:function(a,b,c,e){a||U("Cannot use deleted val. handle = "+a);a=V[a].value;var f=nb[b];if(!f){f="";for(var g=0;g> 2) + "+g+'], "parameter '+g+'");\nvar arg'+g+" = argType"+g+".readValueFromPointer(args);\nargs += argType"+g+"['argPackAdvance'];\n";f=(new Function("requireRegisteredType", +"Module","__emval_register",n+("var obj = new constructor("+f+");\nreturn __emval_register(obj);\n}\n")))(db,d,Ya);nb[b]=f}return f(a,c,e)},q:function(a,b,c){I.copyWithin(a,b,b+c)},c:function(a){var b=I.length;if(2147418112=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0>16);va(G.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},memory:G,table:fa}, +sb=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 Ha().then(function(g){return WebAssembly.instantiate(g,e)}).then(f,function(g){E("failed to asynchronously prepare wasm: "+g);D(g)})}var e={a:rb};N++;d.monitorRunDependencies&&d.monitorRunDependencies(N);if(d.instantiateWasm)try{return d.instantiateWasm(e,a)}catch(f){return E("Module.instantiateWasm callback failed with error: "+ +f),!1}(function(){if(F||"function"!==typeof WebAssembly.instantiateStreaming||Ea()||"function"!==typeof fetch)return c(b);fetch(P,{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");c(b)})})})();return{}}();d.asm=sb; +var Ia=d.___wasm_call_ctors=function(){return(Ia=d.___wasm_call_ctors=d.asm.w).apply(null,arguments)},qb=d._malloc=function(){return(qb=d._malloc=d.asm.x).apply(null,arguments)},X=d._free=function(){return(X=d._free=d.asm.y).apply(null,arguments)},cb=d.___getTypeName=function(){return(cb=d.___getTypeName=d.asm.z).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.A).apply(null,arguments)}; +d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.B).apply(null,arguments)};d.dynCall_i=function(){return(d.dynCall_i=d.asm.C).apply(null,arguments)};d.dynCall_iii=function(){return(d.dynCall_iii=d.asm.D).apply(null,arguments)};d.dynCall_viii=function(){return(d.dynCall_viii=d.asm.E).apply(null,arguments)};d.dynCall_fii=function(){return(d.dynCall_fii=d.asm.F).apply(null,arguments)};d.dynCall_viif=function(){return(d.dynCall_viif=d.asm.G).apply(null,arguments)}; +d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.H).apply(null,arguments)};d.dynCall_iiiiii=function(){return(d.dynCall_iiiiii=d.asm.I).apply(null,arguments)};d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.J).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.K).apply(null,arguments)};d.dynCall_viiiiiiiii=function(){return(d.dynCall_viiiiiiiii=d.asm.L).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.M).apply(null,arguments)}; +d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.N).apply(null,arguments)};d.asm=sb;var Z;d.then=function(a){if(Z)a(d);else{var b=d.onRuntimeInitialized;d.onRuntimeInitialized=function(){b&&b();a(d)}}return d};O=function tb(){Z||ub();Z||(O=tb)}; +function ub(){function a(){if(!Z&&(Z=!0,d.calledRun=!0,!ha)){xa(za);xa(Aa);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)}xa(Ba)}}if(!(0 { if (!emscriptenModule) emscriptenModule = initEmscriptenModule(webp_dec, wasmUrl); const module = await emscriptenModule; - const rawImage = module.decode(data); - const result = new ImageData( - new Uint8ClampedArray(rawImage.buffer), - rawImage.width, - rawImage.height, - ); - - module.free_result(); - return result; + return module.decode(data); } diff --git a/src/codecs/webp/encoder.ts b/src/codecs/webp/encoder.ts index d773c425..fc80ce92 100644 --- a/src/codecs/webp/encoder.ts +++ b/src/codecs/webp/encoder.ts @@ -9,10 +9,7 @@ export async function encode(data: ImageData, options: EncodeOptions): Promise