221 lines
109 KiB
JavaScript
221 lines
109 KiB
JavaScript
/* Copyright 2021-2023 Ethan Halsall. This file is part of wasm-audio-decoders. https://github.com/eshaz/wasm-audio-decoders */
|
||
var t,s;t=this,s=function(t,s){const i=(t,s=4294967295,i=79764919)=>{const e=new Int32Array(256);let r,n,h,o=s;for(r=0;r<256;r++){for(h=r<<24,n=8;n>0;--n)h=2147483648&h?h<<1^i:h<<1;e[r]=h}for(r=0;r<t.length;r++)o=o<<8^e[255&(o>>24^t[r])];return o},e=(t,s=i)=>{const e=t=>new Uint8Array(t.length/2).map(((s,i)=>parseInt(t.substring(2*i,2*(i+1)),16))),r=t=>e(t)[0],n=new Map;[,8364,,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,,381,,,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,,382,376].forEach(((t,s)=>n.set(t,s)));const h=new Uint8Array(t.length);let o,a,l,c=!1,u=0,d=42,U=t.length>13&&"dynEncode"===t.substring(0,9),f=0;U&&(f=11,a=r(t.substring(9,f)),a<=1&&(f+=2,d=r(t.substring(11,f))),1===a&&(f+=8,l=(t=>new DataView(e(t).buffer).getInt32(0,!0))(t.substring(13,f))));const M=256-d;for(let i=f;i<t.length;i++)if(o=t.charCodeAt(i),61!==o||c){if(92===o&&i<t.length-5&&U){const s=t.charCodeAt(i+1);117!==s&&85!==s||(o=parseInt(t.substring(i+2,i+6),16),i+=5)}if(o>255){const t=n.get(o);t&&(o=t+127)}c&&(c=!1,o-=64),h[u++]=o<d&&o>0?o+M:o-d}else c=!0;const p=h.subarray(0,u);if(U&&1===a){const t=s(p);if(t!==l){const s="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",s+"\n","Expected: "+l+"; Got: "+t+"\n","Visit https://github.com/eshaz/simple-yenc for more information"),Error(s)}}return p};function r(){const t=Uint8Array,s=Float32Array;r.t||Object.defineProperties(r,{t:{value:new WeakMap},o:{value(t,s){r.t.set(t,Promise.resolve(s))}},l:{value(t,s){let i=r.t.get(t);return i||(s?i=WebAssembly.compile(e(s)):(s=t.u,i=r.U(s).then((t=>WebAssembly.compile(t)))),r.t.set(t,i)),i}},M:{value(t,i){let e=new s(i),r=0,n=0;for(;r<t.length;)e.set(t[r],n),n+=t[r++].length;return e}},p:{value:(t,s,i,e,r)=>({m:t,channelData:s,samplesDecoded:i,sampleRate:e,bitDepth:r})},T:{value(t,s,i,e,n,h){let o,a,l=[];for(o=0;o<i;o++){const t=[];for(a=0;a<s.length;)t.push(s[a++][o]||[]);l.push(r.M(t,e))}return r.p(t,l,e,n,h)}},U:{value(s){return s=e(s),new Promise((i=>{const e=String.raw`dynEncode0114db91da9bu*ttt$#U¤¤U¤¤3yzzss|yusvuyÚ&4<054<,5T44^T44<(6U~J(44< ~A544U~6J0444545 444J0444J,4U4U
Ò7U454U4Z4U4U^/6545T4T44BU~64CU~O4U54U~5 U5T4B4Z!4U~5U5U5T4U~6U4ZTU5U5T44~4O4U2ZTU5T44Z!4B6T44U~64B6U~O44U~4O4U~54U~5 44~C4~54U~5 44~5454U4B6Ub!444~UO4U~5 U54U4ZTU#44U$464<4~B6^4<444~U~B4U~54U544~544~U5 µUä#UJUè#5TT4U0ZTTUX5U5T4T4Uà#~4OU4U $~C4~54U~5 T44$6U\!TTT4UaT4<6T4<64<Z!44~4N4<U~5 4UZ!4U±_TU#44UU6UÔ~B$544$6U\!4U6U¤#~B44Uä#~B$~64<6_TU#444U~B~6~54<Y!44<_!T4Y!4<64~444~AN44<U~6J4U5 44J4U[!U#44UO4U~54U~5 U54 7U6844J44J 4UJ4UJ04VK(44<J44<J$4U´~54U~5 4U¤~5!TTT4U$5"U5TTTTTTT4U$"4VK,U54<(6U~64<$6_!4< 64~6A54A544U~6#J(U54A4U[!44J(44#~A4U6UUU
[!4464~64_!4<64~54<6T4<4]TU5 T4Y!44~44~AN4U~54U~54U5 44J(44J UÄA!U5U#UôJU"UÔJU#UÔ"JU#U´"JT4U´ZTU5T4UôZTU5T4UDZTU5T4U$[T44~UO4U~5 UÔUô4U~U´$.U5T4UP[T4U~4~UO4U~5 U#<U#<4U~U2$.UÄUN 44 ~UO4U~5 44!~UO4U~5 4U~4~UO4U~5 44J44J(U5 44U¤~J@44Uä~J<44UD~J844U~J44U$54U$5U54U$54U1^4U1^!4U~54U~5U54U~6U4U^/65T4T4U$54U~4BU~4O4U54U~5 UU'464U'_/54UU~5T4T4U~4BU~UO4U54U~5 U54Uä~4U¤~4U~U'$!44~5U5T44\T44U<~$6U\!4U#aT4U~4U~4O4U~5 U5U5U5TTT4U$"4YTU5 4U4~C5U5 U5U5444$4~64~\TU5 4U~4U~5T4Y!44O4U~54U~54U5 4CYTU5 4Uä~4U¤~4U~4$6TU54U\!44Bæ4Bä~[!4U~4UD~4U~4U~4$6TU54U\!44B4B~[!44U<~4U4~$5 4U"U#$544"Y!454U^!44<J44<(J454U~84UN!#%'+/37?GOWgw·×÷Uä;U9$%& !"#`;r.l(r,e).then((t=>WebAssembly.instantiate(t,{}))).then((({exports:e})=>{const r=new Map(Object.entries(e)),n=r.get("puff"),h=r.get("memory").buffer,o=new t(h),a=new DataView(h);let l=r.get("__heap_base");const c=s.length,u=l;l+=4,a.setInt32(u,c,!0);const d=l;l+=c,o.set(s,d);const U=l;l+=4,a.setInt32(U,o.byteLength-l,!0),n(l,U,d,u),i(o.slice(l,l+a.getInt32(U,!0)))}))}))}}}),Object.defineProperty(this,"u",{enumerable:!0,get:()=>this.v}),this.O=(t,s,i)=>{let e=[],r=0;for(;r<s;)e.push(t.slice(r*i,r++*i+i));return e},this.A=(t,s,i=!0)=>{const e=this.v.I(s.BYTES_PER_ELEMENT*t);return i&&this.J.add(e),{S:e,Y:t,_:new s(this.v.L,e,t)}},this.free=()=>{this.J.forEach((t=>{this.v.free(t)})),this.J.clear()},this.F=t=>{const s=[],i=new Uint8Array(this.v.L);for(let e=i[t];0!==e;e=i[++t])s.push(e);return String.fromCharCode.apply(null,s)},this.V=(t,s,i,e,r,n)=>{t.push({message:s,frameLength:i,frameNumber:e,inputBytes:r,outputSamples:n})},this.instantiate=(t,s)=>(s&&r.o(t,s),this.v=new t(r).instantiate(),this.J=new Set,this.v.ready.then((()=>this)))}class n extends((()=>globalThis.Worker||s)()){constructor(t,s,i,e){r.t||new r;let n=r.t.get(i);if(!n){let t,s="text/javascript",h=`'use strict';(${""+((t,s,i)=>{let e,r,n=new Promise((t=>{r=t}));self.onmessage=({data:{id:h,command:o,data:a}})=>{let l,c=n,u={id:h};"init"===o?(Object.defineProperties(t,{C:{value:s},P:{value:i},module:{value:a.module},B:{value:!0}}),e=new t(a.options),r()):"free"===o?e.free():"ready"===o?c=c.then((()=>e.ready)):"reset"===o?c=c.then((()=>e.reset())):(Object.assign(u,e[o](Array.isArray(a)?a.map((t=>new Uint8Array(t))):new Uint8Array(a))),l=u.channelData?u.channelData.map((t=>t.buffer)):[]),c.then((()=>self.postMessage(u,l)))}})})(${i}, ${r}, ${e})`;try{t=void 0!==process.versions.node}catch{}n=t?`data:${s};base64,${Buffer.from(h).toString("base64")}`:URL.createObjectURL(new Blob([h],{type:s})),r.t.set(i,n)}super(n,{name:s}),this.$=Number.MIN_SAFE_INTEGER,this.K=new Map,this.onmessage=({data:t})=>{const{id:s,...i}=t;this.K.get(s)(i),this.K.delete(s)},new e(r).l().then((s=>{this.q("init",{module:s,options:t})}))}async q(t,s){return new Promise((i=>{this.postMessage({command:t,id:this.$,data:s}),this.K.set(this.$++,i)}))}get ready(){return this.q("ready")}async free(){await this.q("free").finally((()=>{this.terminate()}))}async reset(){await this.q("reset")}}const h=(t,s)=>{Object.defineProperty(t,"name",{value:s})};function o(t){function s(){}for(var i=new Uint8Array(123),e=25;e>=0;--e)i[48+e]=52+e,i[65+e]=e,i[97+e]=26+e;var r,n;i[43]=62,i[47]=63,o.u||Object.defineProperty(o,"u",{get:()=>String.raw`dynEncode01a36c6f98c83ø%yã¯#6ïIØh¼ÿ-^º*:8ÖJÒ#Á(¶3ùsÕÿ§£/.*[v²¯\õzºÜá»(oBM×å ÊvmË1±Iü(&Øb?0=MáPðxA%TÔÎ=} c×0ÓPùN:Ê£ÌÓ±æQñÒ¥M_ªqA1kð¹¥ÊÇ@6u§k¿Ä9Ó²FÒà(A£c£ |