diff --git a/cli/index.js b/cli/index.js index 3e871232..7fa64ac5 100644 --- a/cli/index.js +++ b/cli/index.js @@ -24,10 +24,16 @@ async function optimize(bitmapIn, encode, decode) { let bitmapOut; let binaryOut; - const { visdif } = await visdifModule(); + const { VisDiff } = await visdifModule(); + const comparator = new VisDiff( + bitmapIn.data, + bitmapIn.width, + bitmapIn.height + ); do { binaryOut = await encode(bitmapIn, quality); bitmapOut = await decode(binaryOut); + butteraugliDistance = comparator.distance(bitmapOut.data); console.log({ butteraugliDistance, quality, @@ -35,12 +41,6 @@ async function optimize(bitmapIn, encode, decode) { binaryOut, bitmapOut }); - butteraugliDistance = visdif( - bitmapIn.data, - bitmapOut.data, - bitmapIn.width, - bitmapIn.height - ); if (butteraugliDistance > butteraugliGoal) { quality += inc; } else { @@ -53,6 +53,8 @@ async function optimize(bitmapIn, encode, decode) { attempts < maxRounds ); + comparator.delete(); + return { bitmap: bitmapOut, binary: binaryOut, diff --git a/codecs/visdif/visdif.cpp b/codecs/visdif/visdif.cpp index 7f2608a3..a13e5e31 100644 --- a/codecs/visdif/visdif.cpp +++ b/codecs/visdif/visdif.cpp @@ -5,50 +5,57 @@ using namespace emscripten; using namespace butteraugli; -double visdif(std::string rgba1, std::string rgba2, int width, int height) { - const char* rgba1p = rgba1.c_str(); - const char* rgba2p = rgba2.c_str(); - // One Image8 for each color channel + alpha - std::vector img1; - img1.push_back(ImageF(width, height)); - img1.push_back(ImageF(width, height)); - img1.push_back(ImageF(width, height)); - img1.push_back(ImageF(width, height)); - std::vector img2; - img2.push_back(ImageF(width, height)); - img2.push_back(ImageF(width, height)); - img2.push_back(ImageF(width, height)); - img2.push_back(ImageF(width, height)); - // Convert from interleaved RGBA to separate channels +// Turns an interleaved RGBA buffer into 4 planes for each color channel +void planarize(std::vector& img, + const char* rgba, + int width, + int height, + float gamma = 2.2) { + assert(img.size() == 0); + img.push_back(ImageF(width, height)); + img.push_back(ImageF(width, height)); + img.push_back(ImageF(width, height)); + img.push_back(ImageF(width, height)); for (int y = 0; y < height; y++) { - float* const img1_row_r = img1[0].Row(y); - float* const img1_row_g = img1[1].Row(y); - float* const img1_row_b = img1[2].Row(y); - float* const img1_row_a = img1[3].Row(y); - float* const img2_row_r = img2[0].Row(y); - float* const img2_row_g = img2[1].Row(y); - float* const img2_row_b = img2[2].Row(y); - float* const img2_row_a = img2[3].Row(y); + float* const row_r = img[0].Row(y); + float* const row_g = img[1].Row(y); + float* const row_b = img[2].Row(y); + float* const row_a = img[3].Row(y); for (int x = 0; x < width; x++) { - img1_row_r[x] = 255.0 * pow(rgba1p[y * width * 4 + x * 4 + 0] / 255.0, 2.2); - img1_row_g[x] = 255.0 * pow(rgba1p[y * width * 4 + x * 4 + 1] / 255.0, 2.2); - img1_row_b[x] = 255.0 * pow(rgba1p[y * width * 4 + x * 4 + 2] / 255.0, 2.2); - img1_row_a[x] = 255.0 * pow(rgba1p[y * width * 4 + x * 4 + 3] / 255.0, 2.2); - img2_row_r[x] = 255.0 * pow(rgba2p[y * width * 4 + x * 4 + 0] / 255.0, 2.2); - img2_row_g[x] = 255.0 * pow(rgba2p[y * width * 4 + x * 4 + 1] / 255.0, 2.2); - img2_row_b[x] = 255.0 * pow(rgba2p[y * width * 4 + x * 4 + 2] / 255.0, 2.2); - img2_row_a[x] = 255.0 * pow(rgba2p[y * width * 4 + x * 4 + 3] / 255.0, 2.2); + row_r[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 0] / 255.0, gamma); + row_g[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 1] / 255.0, gamma); + row_b[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 2] / 255.0, gamma); + row_a[x] = 255.0 * pow(rgba[y * width * 4 + x * 4 + 3] / 255.0, gamma); } } - - ImageF diffmap; - double diffvalue; - if (!ButteraugliInterface(img1, img2, 1.0, diffmap, diffvalue)) { - return -1.0; - } - return diffvalue; } +class VisDiff { + private: + std::vector ref_img; + int width; + int height; + + public: + VisDiff(std::string ref_img, int width, int height) { + planarize(this->ref_img, ref_img.c_str(), width, height); + this->width = width; + this->height = height; + } + + double distance(std::string other_img) { + std::vector img; + planarize(img, other_img.c_str(), width, height); + + ImageF diffmap; + double diffvalue; + if (!ButteraugliInterface(ref_img, img, 1.0, diffmap, diffvalue)) { + return -1.0; + } + return diffvalue; + } +}; EMSCRIPTEN_BINDINGS(my_module) { - function("visdif", &visdif); + class_("VisDiff").constructor().function("distance", + &VisDiff::distance); } diff --git a/codecs/visdif/visdif.js b/codecs/visdif/visdif.js index 420802cd..20a2d881 100644 --- a/codecs/visdif/visdif.js +++ b/codecs/visdif/visdif.js @@ -7,49 +7,64 @@ function(visdif) { visdif = visdif || {}; -var d;d||(d=typeof visdif !== 'undefined' ? visdif : {});var aa,ba;d.ready=new Promise(function(a,b){aa=a;ba=b});var r={},t;for(t in d)d.hasOwnProperty(t)&&(r[t]=d[t]);var u=!1,v=!1,ca=!1,da=!1;u="object"===typeof window;v="function"===typeof importScripts;ca="object"===typeof process&&"object"===typeof process.versions&&"string"===typeof process.versions.node;da=!u&&!ca&&!v;var w="",x,z,ea,fa; -if(ca)w=v?require("path").dirname(w)+"/":__dirname+"/",x=function(a,b){ea||(ea=require("fs"));fa||(fa=require("path"));a=fa.normalize(a);return ea.readFileSync(a,b?null:"utf8")},z=function(a){a=x(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||A("Assertion failed: undefined");return a},1=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 la(a,b,c){var e=G;if(0=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)&&H[c];)++c;c<<=1;if(32>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>1]=a.charCodeAt(f),b+=2;I[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=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 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=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 sa(a){for(var b=0,c=0;c=e&&++c;b+=4}return b}var L,ta,G,I,H,K,M,ua,va;function wa(a){L=a;d.HEAP8=ta=new Int8Array(a);d.HEAP16=I=new Int16Array(a);d.HEAP32=K=new Int32Array(a);d.HEAPU8=G=new Uint8Array(a);d.HEAPU16=H=new Uint16Array(a);d.HEAPU32=M=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&&(L=E.buffer);xa=L.byteLength;wa(L);K[5740]=5266E3;function N(a){for(;0=b?"_"+a:a} -function Oa(a,b){a=Na(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function Pa(a){var b=Error,c=Oa(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 Sa=void 0;function W(a){throw new Sa(a);}var Ta=void 0;function Ua(a,b){function c(k){k=b(k);if(k.length!==e.length)throw new Ta("Mismatched type converter count");for(var h=0;h>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=Oa(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].F){var e=c[a];c[a]=function(){c[a].F.hasOwnProperty(arguments.length)||W("Function '"+b+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+c[a].F+")!");return c[a].F[arguments.length].apply(this,arguments)};c[a].F=[];c[a].F[e.J]=e}} -function cb(a,b,c){d.hasOwnProperty(a)?((void 0===c||void 0!==d[a].F&&void 0!==d[a].F[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].F[c]=b):(d[a]=b,void 0!==c&&(d[a].O=c))}function db(a,b){for(var c=[],e=0;e>2)+e]);return c} -function eb(a,b){a=T(a);var c=d["dynCall_"+a];for(var e=[],f=1;f>1]}:function(e){return H[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);}} -for(var kb=[null,[],[]],lb=Array(256),mb=0;256>mb;++mb)lb[mb]=String.fromCharCode(mb);La=lb;Sa=d.BindingError=Pa("BindingError");Ta=d.InternalError=Pa("InternalError");d.count_emval_handles=function(){for(var a=0,b=5;b>g])},G:null})},j:function(a,b){b=T(b);X(a,{name:b,fromWireType:function(c){var e=Y[c].value;4q&&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>>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(pf)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),G:null})},a:function(a,b,c){function e(g){g>>=2;var l=M;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},{L:!0})},g: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 k=e+4+l;if(l==f||0==G[k]){g=g?F(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=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=nb(4+l+1);M[k>>2]=l;if(c&&g)la(f,k+4,l+1);else if(g)for(g=0;g>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=nb(4+p+b);M[q>>2]=p>> -k;f(n,q+4,p+b);null!==h&&h.push(Z,q);return q},argPackAdvance:8,readValueFromPointer:Xa,G:function(h){Z(h)}})},l:function(a,b){b=T(b);X(a,{N:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},f:function(){A()},o:function(a,b,c){G.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=G.length;if(2147483648=c;c*=2){var e=b*(1+.2/c);e=Math.min(e,a+100663296);e=Math.max(16777216,a,e);0>>16);wa(E.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},h:function(a,b,c,e){for(var f=0,g=0;g>2],k=K[b+(8*g+4)>>2],h=0;h>2]=f;return 0},memory:E,n:function(){},table:ia}; -(function(){function a(f){d.asm=f.exports;O--;d.monitorRunDependencies&&d.monitorRunDependencies(O);0==O&&(null!==Da&&(clearInterval(Da),Da=null),Q&&(f=Q,Q=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:ob};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||Fa()||Ea("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 Ja=d.___wasm_call_ctors=function(){return(Ja=d.___wasm_call_ctors=d.asm.r).apply(null,arguments)},nb=d._malloc=function(){return(nb=d._malloc=d.asm.s).apply(null,arguments)},Z=d._free=function(){return(Z=d._free=d.asm.t).apply(null,arguments)},hb=d.___getTypeName=function(){return(hb=d.___getTypeName=d.asm.u).apply(null,arguments)};d.___embind_register_native_and_builtin_types=function(){return(d.___embind_register_native_and_builtin_types=d.asm.v).apply(null,arguments)}; -d.dynCall_diiiii=function(){return(d.dynCall_diiiii=d.asm.w).apply(null,arguments)};d.dynCall_diiii=function(){return(d.dynCall_diiii=d.asm.x).apply(null,arguments)};d.dynCall_vi=function(){return(d.dynCall_vi=d.asm.y).apply(null,arguments)};d.dynCall_ii=function(){return(d.dynCall_ii=d.asm.z).apply(null,arguments)};d.dynCall_iiii=function(){return(d.dynCall_iiii=d.asm.A).apply(null,arguments)};d.dynCall_viiiiii=function(){return(d.dynCall_viiiiii=d.asm.B).apply(null,arguments)}; -d.dynCall_viiiii=function(){return(d.dynCall_viiiii=d.asm.C).apply(null,arguments)};d.dynCall_viiii=function(){return(d.dynCall_viiii=d.asm.D).apply(null,arguments)};d.dynCall_jiji=function(){return(d.dynCall_jiji=d.asm.E).apply(null,arguments)};var pb;Q=function qb(){pb||rb();pb||(Q=qb)}; -function rb(){function a(){if(!pb&&(pb=!0,d.calledRun=!0,!ja)){N(za);N(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)}N(Ba)}}if(!(0=d);)++c;if(16f?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){var d=D;if(0=g){var k=a.charCodeAt(++f);g=65536+((g&1023)<<10)|k&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 ta="undefined"!==typeof TextDecoder?new TextDecoder("utf-16le"):void 0; +function ua(a,b){var c=a>>1;for(var d=c+b/2;!(c>=d)&&va[c];)++c;c<<=1;if(32>1];if(0==f||c==b/2)return d;++c;d+=String.fromCharCode(f)}}function wa(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;E[b>>1]=0;return b-d}function xa(a){return 2*a.length} +function ya(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 za(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 k=a.charCodeAt(++f);g=65536+((g&1023)<<10)|k&1023}F[b>>2]=g;b+=4;if(b+4>c)break}F[b>>2]=0;return b-d} +function Aa(a){for(var b=0,c=0;c=d&&++c;b+=4}return b}var G,Ba,D,E,va,F,I,Ca,Da;function Ea(a){G=a;e.HEAP8=Ba=new Int8Array(a);e.HEAP16=E=new Int16Array(a);e.HEAP32=F=new Int32Array(a);e.HEAPU8=D=new Uint8Array(a);e.HEAPU16=va=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?C=e.wasmMemory:C=new WebAssembly.Memory({initial:Fa/65536,maximum:32768});C&&(G=C.buffer);Fa=G.byteLength;Ea(G);F[5836]=5266384;function Ga(a){for(;0=b?"_"+a:a} +function Za(a,b){a=Ya(a);return(new Function("body","return function "+a+'() {\n "use strict"; return body.apply(this, arguments);\n};\n'))(b)}function $a(a){var b=Error,c=Za(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 O=void 0;function R(a){throw new O(a);}var ab=void 0;function bb(a){throw new ab(a);}function cb(a,b,c){function d(h){h=c(h);h.length!==a.length&&bb("Mismatched type converter count");for(var m=0;m>2])}function yb(a,b,c){if(b===c)return a;if(void 0===c.O)return null;a=yb(a,b,c.O);return null===a?null:c.ha(a)}var zb={}; +function Ab(a,b){for(void 0===b&&R("ptr should not be undefined");a.O;)b=a.X(b),a=a.O;return zb[b]}function Bb(a,b){b.L&&b.K||bb("makeClassHandle requires ptr and ptrType");!!b.N!==!!b.M&&bb("Both smartPtrType and smartPtr must be specified");b.count={value:1};return ib(Object.create(a,{I:{value:b}}))}function V(a,b,c,d){this.name=a;this.J=b;this.ba=c;this.Z=d;this.$=!1;this.T=this.pa=this.oa=this.fa=this.ra=this.ma=void 0;void 0!==b.O?this.toWireType=ub:(this.toWireType=d?rb:wb,this.R=null)} +function Cb(a,b){e.hasOwnProperty(a)||bb("Replacing nonexistant public symbol");e[a]=b;e[a].Y=void 0}function W(a,b){a=L(a);var c=e["dynCall_"+a];for(var d=[],f=1;f>2)+d]);return c}function Ib(a){for(;a.length;){var b=a.pop();a.pop()(b)}} +function Jb(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=Za(b.name||"unknownFunctionName",function(){});c.prototype=b.prototype;c=new c;a=b.apply(c,a);return a instanceof Object?a:c}var Kb=[],Y=[{},{value:void 0},{value:null},{value:!0},{value:!1}]; +function vb(a){switch(a){case void 0:return 1;case null:return 2;case !0:return 3;case !1:return 4;default:var b=Kb.length?Kb.pop():Y.length;Y[b]={qa:1,value:a};return b}}function U(a){if(null===a)return"null";var b=typeof a;return"object"===b||"array"===b||"function"===b?a.toString():""+a}function Lb(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 Mb(a,b,c){switch(b){case 0:return c?function(d){return Ba[d]}:function(d){return D[d]};case 1:return c?function(d){return E[d>>1]}:function(d){return va[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);}}for(var Nb=[null,[],[]],Ob=Array(256),Pb=0;256>Pb;++Pb)Ob[Pb]=String.fromCharCode(Pb);Wa=Ob;O=e.BindingError=$a("BindingError");ab=e.InternalError=$a("InternalError"); +T.prototype.isAliasOf=function(a){if(!(this instanceof T&&a instanceof T))return!1;var b=this.I.L.J,c=this.I.K,d=a.I.L.J;for(a=a.I.K;b.O;)c=b.X(c),b=b.O;for(;d.O;)a=d.X(a),d=d.O;return b===d&&c===a};T.prototype.clone=function(){this.I.K||eb(this);if(this.I.W)return this.I.count.value+=1,this;var a=ib(Object.create(Object.getPrototypeOf(this),{I:{value:db(this.I)}}));a.I.count.value+=1;a.I.U=!1;return a}; +T.prototype["delete"]=function(){this.I.K||eb(this);this.I.U&&!this.I.W&&R("Object already scheduled for deletion");gb(this);hb(this.I);this.I.W||(this.I.M=void 0,this.I.K=void 0)};T.prototype.isDeleted=function(){return!this.I.K};T.prototype.deleteLater=function(){this.I.K||eb(this);this.I.U&&!this.I.W&&R("Object already scheduled for deletion");kb.push(this);1===kb.length&&jb&&jb(lb);this.I.U=!0;return this};V.prototype.ka=function(a){this.fa&&(a=this.fa(a));return a}; +V.prototype.ea=function(a){this.T&&this.T(a)};V.prototype.argPackAdvance=8;V.prototype.readValueFromPointer=xb;V.prototype.deleteObject=function(a){if(null!==a)a["delete"]()}; +V.prototype.fromWireType=function(a){function b(){return this.$?Bb(this.J.V,{L:this.ma,K:c,N:this,M:a}):Bb(this.J.V,{L:this,K:a})}var c=this.ka(a);if(!c)return this.ea(a),null;var d=Ab(this.J,c);if(void 0!==d){if(0===d.I.count.value)return d.I.K=c,d.I.M=a,d.clone();d=d.clone();this.ea(a);return d}d=this.J.ja(c);d=mb[d];if(!d)return b.call(this);d=this.Z?d.ga:d.pointerType;var f=yb(c,this.J,d.J);return null===f?b.call(this):this.$?Bb(d.J.V,{L:d,K:f,N:this,M:a}):Bb(d.J.V,{L:d,K:f})}; +e.getInheritedInstanceCount=function(){return Object.keys(zb).length};e.getLiveInheritedInstances=function(){var a=[],b;for(b in zb)zb.hasOwnProperty(b)&&a.push(zb[b]);return a};e.flushPendingDeletes=lb;e.setDelayFunction=function(a){jb=a;kb.length&&jb&&jb(lb)};Db=e.UnboundTypeError=$a("UnboundTypeError");e.count_emval_handles=function(){for(var a=0,b=5;b>g])},R:null})},n:function(a,b,c,d,f,g,k,h,m,l,n,t,u){n=L(n);g=W(f,g);h&&(h=W(k,h));l&&(l=W(m,l));u=W(t,u);var y=Ya(n);ob(y,function(){Gb("Cannot construct "+n+" due to unbound types",[d])});cb([a,b,c],d?[d]:[],function(r){r=r[0];if(d){var w=r.J;var p=w.V}else p=T.prototype;r=Za(y,function(){if(Object.getPrototypeOf(this)!==H)throw new O("Use 'new' to construct "+n);if(void 0===x.S)throw new O(n+" has no accessible constructor");var P=x.S[arguments.length];if(void 0=== +P)throw new O("Tried to invoke ctor of "+n+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(x.S).toString()+") parameters instead!");return P.apply(this,arguments)});var H=Object.create(p,{constructor:{value:r}});r.prototype=H;var x=new pb(n,r,H,u,w,g,h,l);w=new V(n,x,!0,!1);p=new V(n+"*",x,!1,!1);var Z=new V(n+" const*",x,!1,!0);mb[a]={pointerType:p,ga:Z};Cb(y,r);return[w,p,Z]})},m:function(a,b,c,d,f,g){assert(0x&&R("argTypes array size mismatch! Must at least get return value and 'this' types!");var Z=null!==r[1]&&null!==p,P=!1;for(p=1;p>>h}}var m=-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 "'+U(n)+'" to '+this.name);if(nf)throw new TypeError('Passing a number "'+U(n)+'" from JS side to C/C++ side to an argument of type "'+b+'", which is outside the valid range ['+d+", "+f+"]!");return m?n>>>0:n|0},argPackAdvance:8,readValueFromPointer:Mb(b,k,0!==d),R:null})},a:function(a,b,c){function d(g){g>>=2;var k=I;return new f(G, +k[g+1],k[g])}var f=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][b];c=L(c);S(a,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{la:!0})},g:function(a,b){b=L(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,k=0;k<=f;++k){var h=d+4+k;if(k==f||0==D[h]){g=g?ra(D,g,h-g):"";if(void 0===m)var m=g;else m+=String.fromCharCode(0),m+=g;g=h+1}}else{m=Array(f);for(k=0;k=t&&(t=65536+((t&1023)<<10)|f.charCodeAt(++n)&1023);127>=t?++l:l=2047>=t?l+2:65535>=t?l+3:l+4}return l}:function(){return f.length})(),h=Qb(4+k+1);I[h>> +2]=k;if(c&&g)sa(f,h+4,k+1);else if(g)for(g=0;g>2], +n=k(),t,u=m+4,y=0;y<=l;++y){var r=m+4+y*b;if(y==l||0==n[r>>h])u=d(u,r-u),void 0===t?t=u:(t+=String.fromCharCode(0),t+=u),u=r+b}X(m);return t},toWireType:function(m,l){"string"!==typeof l&&R("Cannot pass non-string to C++ string type "+c);var n=g(l),t=Qb(4+n+b);I[t>>2]=n>>h;f(l,t+4,n+b);null!==m&&m.push(X,t);return t},argPackAdvance:8,readValueFromPointer:xb,R:function(m){X(m)}})},k:function(a,b){b=L(b);S(a,{sa:!0,name:b,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},e:function(){A()}, +q:function(a,b,c){D.copyWithin(a,b,b+c)},c:function(a){a>>>=0;var b=D.length;if(2147483648=c;c*=2){var d=b*(1+.2/c);d=Math.min(d,a+100663296);d=Math.max(16777216,a,d);0>>16);Ea(C.buffer);var f=1;break a}catch(g){}f=void 0}if(f)return!0}return!1},h:function(a,b,c,d){for(var f=0,g=0;g>2],h=F[b+(8*g+4)>>2],m=0;m>2]=f;return 0},memory:C,p:function(){},table:oa}; +(function(){function a(f){e.asm=f.exports;J--;e.monitorRunDependencies&&e.monitorRunDependencies(J);0==J&&(null!==Ma&&(clearInterval(Ma),Ma=null),Na&&(f=Na,Na=null,f()))}function b(f){a(f.instance)}function c(f){return Sa().then(function(g){return WebAssembly.instantiate(g,d)}).then(f,function(g){B("failed to asynchronously prepare wasm: "+g);A(g)})}var d={a:Rb};J++;e.monitorRunDependencies&&e.monitorRunDependencies(J);if(e.instantiateWasm)try{return e.instantiateWasm(d,a)}catch(f){return B("Module.instantiateWasm callback failed with error: "+ +f),!1}(function(){if(na||"function"!==typeof WebAssembly.instantiateStreaming||Pa()||Oa("file://")||"function"!==typeof fetch)return c(b);fetch(K,{credentials:"same-origin"}).then(function(f){return WebAssembly.instantiateStreaming(f,d).then(b,function(g){B("wasm streaming compile failed: "+g);B("falling back to ArrayBuffer instantiation");return c(b)})})})();return{}})(); +var Ta=e.___wasm_call_ctors=function(){return(Ta=e.___wasm_call_ctors=e.asm.t).apply(null,arguments)},Qb=e._malloc=function(){return(Qb=e._malloc=e.asm.u).apply(null,arguments)},X=e._free=function(){return(X=e._free=e.asm.v).apply(null,arguments)},Fb=e.___getTypeName=function(){return(Fb=e.___getTypeName=e.asm.w).apply(null,arguments)};e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.x).apply(null,arguments)}; +e.dynCall_ii=function(){return(e.dynCall_ii=e.asm.y).apply(null,arguments)};e.dynCall_vi=function(){return(e.dynCall_vi=e.asm.z).apply(null,arguments)};e.dynCall_dii=function(){return(e.dynCall_dii=e.asm.A).apply(null,arguments)};e.dynCall_iiiii=function(){return(e.dynCall_iiiii=e.asm.B).apply(null,arguments)};e.dynCall_iiii=function(){return(e.dynCall_iiii=e.asm.C).apply(null,arguments)};e.dynCall_diii=function(){return(e.dynCall_diii=e.asm.D).apply(null,arguments)}; +e.dynCall_viiiiii=function(){return(e.dynCall_viiiiii=e.asm.E).apply(null,arguments)};e.dynCall_viiiii=function(){return(e.dynCall_viiiii=e.asm.F).apply(null,arguments)};e.dynCall_viiii=function(){return(e.dynCall_viiii=e.asm.G).apply(null,arguments)};e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.H).apply(null,arguments)};var Sb;Na=function Tb(){Sb||Ub();Sb||(Na=Tb)}; +function Ub(){function a(){if(!Sb&&(Sb=!0,e.calledRun=!0,!pa)){Ga(Ia);Ga(Ja);ba(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