Pushing changes
This commit is contained in:
1 parent
6075860b82
commit
ac667ec74f
1465 files changed
+345149
-3
No files matched your search
+14
@@ -0,0 +1,14 @@
|
||||
var ex = "uncaughtException";
|
||||
var pl = process.listeners(ex);
|
||||
|
||||
var opus = require("./opus-js/opus");
|
||||
var resampler = require("./opus-js/resampler");
|
||||
|
||||
process.removeAllListeners(ex);
|
||||
for (var i = 0; i < pl.length; i++) process.on(ex, pl[i]);
|
||||
|
||||
module.exports.Opus = opus.Opus;
|
||||
module.exports.OpusApplication = opus.OpusApplication;
|
||||
module.exports.OpusEncoder = opus.OpusEncoder;
|
||||
module.exports.OpusDecoder = opus.OpusDecoder;
|
||||
module.exports.Resampler = resampler.SpeexResampler;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
Copyright (c) 1994-2013 Xiph.Org Foundation and contributors
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.Org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION
|
||||
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
Copyright 2002-2008 Xiph.org Foundation
|
||||
Copyright 2002-2008 Jean-Marc Valin
|
||||
Copyright 2005-2007 Analog Devices Inc.
|
||||
Copyright 2005-2008 Commonwealth Scientific and Industrial Research
|
||||
Organisation (CSIRO)
|
||||
Copyright 1993, 2002, 2006 David Rowe
|
||||
Copyright 2003 EpicGames
|
||||
Copyright 1992-1994 Jutta Degener, Carsten Bormann
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
- Neither the name of the Xiph.org Foundation nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
Copyright (c) 2013-2014, Kazuki Oikawa
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function";var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&filename!=nodePath["resolve"](filename)){filename=path.join(__dirname,"..","src",filename);ret=nodeFS["readFileSync"](filename)}if(ret&&!binary)ret=ret.toString();return ret};Module["readBinary"]=function readBinary(filename){return Module["read"](filename,true)};Module["load"]=function load(f){globalEval(read(f))};Module["thisProgram"]=process["argv"][1]?process["argv"][1].replace(/\\/g, "/"):null;Module["arguments"]=process["argv"].slice(2);if(typeof module!=="undefined"){module["exports"]=Module}process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}))}else if(ENVIRONMENT_IS_SHELL){if(!Module["print"])Module["print"]=print;if(typeof printErr!="undefined")Module["printErr"]=printErr;if(typeof read!="undefined"){Module["read"]=read}else{Module["read"]=function read(){throw"no read() available (jsc?)"}}Module["readBinary"]=function readBinary(f){if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}var data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}this["Module"]=Module}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){Module["read"]=function read(url){var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof console!=="undefined"){if(!Module["print"])Module["print"]=function print(x){console.log(x)};if(!Module["printErr"])Module["printErr"]=function printErr(x){console.log(x)}}else{var TRY_USE_DUMP=false;if(!Module["print"])Module["print"]=TRY_USE_DUMP&&typeof dump!=="undefined"?(function(x){dump(x)}):(function(x){})}if(ENVIRONMENT_IS_WEB){window["Module"]=Module}else{Module["load"]=importScripts}}else{throw"Unknown runtime environment. Where are we?"}function globalEval(x){eval.call(null,x)}if(!Module["load"]&&Module["read"]){Module["load"]=function load(f){globalEval(Module["read"](f))}}if(!Module["print"]){Module["print"]=(function(){})}if(!Module["printErr"]){Module["printErr"]=Module["print"]}if(!Module["arguments"]){Module["arguments"]=[]}if(!Module["thisProgram"]){Module["thisProgram"]="./this.program"}Module.print=Module["print"];Module.printErr=Module["printErr"];Module["preRun"]=[];Module["postRun"]=[];for(var key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}var Runtime={setTempRet0:(function(value){tempRet0=value}),getTempRet0:(function(){return tempRet0}),stackSave:(function(){return STACKTOP}),stackRestore:(function(stackTop){STACKTOP=stackTop}),getNativeTypeSize:(function(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return Runtime.QUANTUM_SIZE}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}),getNativeFieldSize:(function(type){return Math.max(Runtime.getNativeTypeSize(type),Runtime.QUANTUM_SIZE)}),STACK_ALIGN:16,getAlignSize:(function(type,size,vararg){if(!vararg&&(type=="i64"||type=="double"))return 8;if(!type)return Math.min(size,8);return Math.min(size||(type?Runtime.getNativeFieldSize(type):0),Runtime.QUANTUM_SIZE)}),dynCall:(function(sig,ptr,args){if(args&&args.length){if(!args.splice)args=Array.prototype.slice.call(args);args.splice(0,0,ptr);return Module["dynCall_"+sig].apply(null,args)}else{return Module["dynCall_"+sig].call(null,ptr)}}),functionPointers:[],addFunction:(function(func){for(var i=0;i<Runtime.functionPointers.length;i++){if(!Runtime.functionPointers[i]){Runtime.functionPointers[i]=func;return 2*(1+i)}}throw"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS."}),removeFunction:(function(index){Runtime.functionPointers[(index-2)/2]=null}),getAsmConst:(function(code,numArgs){if(!Runtime.asmConstCache)Runtime.asmConstCache={};var func=Runtime.asmConstCache[code];if(func)return func;var args=[];for(var i=0;i<numArgs;i++){args.push(StLine truncated
|
||||
var asm=(function(global,env,buffer) {
|
||||
"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.STACKTOP|0;var j=env.STACK_MAX|0;var k=env.tempDoublePtr|0;var l=env.ABORT|0;var m=env.cttz_i8|0;var n=env.ctlz_i8|0;var o=0;var p=0;var q=0;var r=0;var s=+env.NaN,t=+env.Infinity;var u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0.0;var D=0;var E=0;var F=0;var G=0;var H=0;var I=0;var J=0;var K=0;var L=0;var M=0;var N=global.Math.floor;var O=global.Math.abs;var P=global.Math.sqrt;var Q=global.Math.pow;var R=global.Math.cos;var S=global.Math.sin;var T=global.Math.tan;var U=global.Math.acos;var V=global.Math.asin;var W=global.Math.atan;var X=global.Math.atan2;var Y=global.Math.exp;var Z=global.Math.log;var _=global.Math.ceil;var $=global.Math.imul;var aa=env.abort;var ba=env.assert;var ca=env.min;var da=env.invoke_iiiiiii;var ea=env.invoke_viiiiiii;var fa=env._fabs;var ga=env._sin;var ha=env._exp;var ia=env._llvm_pow_f64;var ja=env._log;var ka=env._atan2;var la=env.___setErrNo;var ma=env._llvm_stackrestore;var na=env._floor;var oa=env._log10;var pa=env._fabsf;var qa=env._sbrk;var ra=env._emscripten_memcpy_big;var sa=env._exp2;var ta=env._sysconf;var ua=env._cos;var va=env._lrintf;var wa=env._llvm_stacksave;var xa=env._floorf;var ya=env._sqrtf;var za=env.___errno_location;var Aa=env._abort;var Ba=env._time;var Ca=env._rint;var Da=env._sqrt;var Ea=0.0;
|
||||
// EMSCRIPTEN_START_FUNCS
|
||||
function Ha(a){a=a|0;var b=0;b=i;i=i+a|0;i=i+15&-16;return b|0}function Ia(){return i|0}function Ja(a){a=a|0;i=a}function Ka(a,b){a=a|0;b=b|0;if(!o){o=a;p=b}}function La(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0]}function Ma(b){b=b|0;a[k>>0]=a[b>>0];a[k+1>>0]=a[b+1>>0];a[k+2>>0]=a[b+2>>0];a[k+3>>0]=a[b+3>>0];a[k+4>>0]=a[b+4>>0];a[k+5>>0]=a[b+5>>0];a[k+6>>0]=a[b+6>>0];a[k+7>>0]=a[b+7>>0]}function Na(a){a=a|0;D=a}function Oa(){return D|0}function Pa(a,b){a=+a;b=b|0;var c=0,d=0,e=0;c=i;d=0;while(1){if((d|0)>=21)break;if(+g[320+(d<<2)>>2]>a)break;d=d+1|0}if((d|0)>(b|0)?+g[320+(b<<2)>>2]+ +g[408+(b<<2)>>2]>a:0){d=b;i=c;return d|0}if((d|0)>=(b|0)){i=c;return d|0}e=b+ -1|0;if(!(+g[320+(e<<2)>>2]- +g[408+(e<<2)>>2]<a)){e=d;i=c;return e|0}e=b;i=c;return e|0}function Qa(a){a=a|0;a=($(a,1664525)|0)+1013904223|0;return a|0}function Ra(a,d,e,f,h,j){a=a|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0,t=0;m=i;k=c[a+32>>2]|0;l=c[a+44>>2]<<j;n=a+8|0;a=0;do{o=$(a,l)|0;p=0;while(1){if((p|0)>=(f|0))break;s=b[k+(p<<1)>>1]|0;t=d+(o+(s<<j)<<2)|0;q=p+1|0;r=+P(+(+Sa(t,t,(b[k+(q<<1)>>1]|0)-s<<j)+1.0000000272452012e-27));g[e+(p+($(a,c[n>>2]|0)|0)<<2)>>2]=r;p=q}a=a+1|0}while((a|0)<(h|0));i=m;return}function Sa(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0.0,f=0,h=0.0;d=i;f=0;e=0.0;while(1){if((f|0)>=(c|0))break;h=e+ +g[a+(f<<2)>>2]*+g[b+(f<<2)>>2];f=f+1|0;e=h}i=d;return+e}function Ta(a,d,e,f,h,j,k){a=a|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=k|0;var l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0;n=i;l=c[a+32>>2]|0;m=$(c[a+44>>2]|0,k)|0;o=a+8|0;a=0;while(1){p=$(a,m)|0;r=0;a:while(1){if((r|0)>=(h|0))break;q=1.0/(+g[f+(r+($(a,c[o>>2]|0)|0)<<2)>>2]+1.0000000272452012e-27);t=$(b[l+(r<<1)>>1]|0,k)|0;r=r+1|0;s=$(b[l+(r<<1)>>1]|0,k)|0;while(1){if((t|0)>=(s|0))continue a;u=t+p|0;g[e+(u<<2)>>2]=+g[d+(u<<2)>>2]*q;t=t+1|0}}a=a+1|0;if((a|0)>=(j|0))break}i=n;return}function Ua(a,d,e,f,h,j,k,l,m){a=a|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;var n=0,o=0,p=0.0,q=0,r=0,s=0,t=0;o=i;n=c[a+32>>2]|0;a=$(c[a+44>>2]|0,k)|0;q=$(b[n+(j<<1)>>1]|0,k)|0;if((l|0)!=1){t=(a|0)/(l|0)|0;q=(q|0)<(t|0)?q:t}r=(m|0)==0;m=r?q:0;j=r?j:0;h=r?h:0;r=n+(h<<1)|0;s=b[r>>1]|0;l=d+(($(s<<16>>16,k)|0)<<2)|0;q=e;d=0;while(1){if((d|0)>=($(s<<16>>16,k)|0)){r=h;break}g[q>>2]=0.0;s=b[r>>1]|0;q=q+4|0;d=d+1|0}a:while(1){if((r|0)>=(j|0))break;s=$(b[n+(r<<1)>>1]|0,k)|0;d=r+1|0;h=$(b[n+(d<<1)>>1]|0,k)|0;p=+Y(+((+g[f+(r<<2)>>2]+ +g[20656+(r<<2)>>2])*.6931471805599453));t=l;while(1){l=t+4|0;r=q+4|0;g[q>>2]=+g[t>>2]*p;s=s+1|0;if((s|0)<(h|0)){q=r;t=l}else{q=r;r=d;continue a}}}_j(e+(m<<2)|0,0,a-m<<2|0)|0;i=o;return}function Va(a,e,f,h,j,k,l,m,n,o,p,q,r,s){a=a|0;e=e|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;o=o|0;p=p|0;q=q|0;r=r|0;s=s|0;var t=0,u=0,v=0,w=0,x=0,y=0,z=0.0,A=0.0,B=0,C=0,D=0,E=0,F=0,G=0.0,H=0.0,I=0,J=0,K=0,L=0,M=0.0,N=0;u=i;t=a+32|0;w=a+8|0;v=(j|0)==1;x=(h|0)==3;a=1<<h;a:while(1){if((l|0)>=(m|0))break;C=l+1|0;B=c[t>>2]|0;B=(b[B+(C<<1)>>1]|0)-(b[B+(l<<1)>>1]|0)|0;A=+Y(+(+((Wa((c[q+(l<<2)>>2]|0)+1|0,B)|0)>>>h|0)*-.125*.6931471805599453))*.5;D=B<<h;z=1.0/+P(+(+(D|0)));y=$(l,j)|0;E=0;while(1){I=c[w>>2]|0;F=($(E,I)|0)+l|0;M=+g[o+(F<<2)>>2];G=+g[p+(F<<2)>>2];if(v){L=I+l|0;H=+g[o+(L<<2)>>2];M=M>H?M:H;H=+g[p+(L<<2)>>2];if(!(G>H))G=H}G=+g[n+(F<<2)>>2]-(M<G?M:G);G=+Y(+(-(G<0.0?0.0:G)*.6931471805599453))*2.0;if(x)G=G*1.4142135381698608;G=(A<G?A:G)*z;F=$(E,k)|0;F=F+(b[(c[t>>2]|0)+(l<<1)>>1]<<h)|0;J=e+(F<<2)|0;I=f+(y+E)|0;H=-G;L=0;K=0;while(1){if((K|0)>=(a|0))break;b:do if(!(d[I>>0]&1<<K)){L=0;while(1){if((L|0)>=(B|0)){L=1;break b}N=Qa(r)|0;g[e+(F+((L<<h)+K)<<2)>>2]=(N&32768|0)==0?H:G;r=N;L=L+1|0}}while(0);K=K+1|0}if(L)Ed(J,D,1.0,s);E=E+1|0;if((E|0)>=(j|0)){l=C;continue a}}}i=u;return}function Wa(a,b){a=a|0;b=b|0;return(a>>>0)/(b>>>0)|0|0}function Xa(a,d,e,f,h,j,k,l,m,n){a=a|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;m=m|0;n=n|0;var o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0,E=0.0;o=i;q=c[a+32>>2]|0;r=$(c[a+44>>2]|0,n)|0;if(($((b[q+(l<<1)>>1]|0)-(b[q+(l+ -1<<1)>>1]|0)|0,n)|0)<9){D=0;i=o;return D|0}s=a+8|0;z=0;x=0;p=0;y=0;a=0;a:while(1){A=y;while(1){if((A|0)<(l|0))break;z=z+1|0;if((z|0)<(m|0))A=0;else break a}w=b[q+(A<<1)>>1]|0;B=($(w,n)|0)+($(z,r)|0)|0;y=A+1|0;w=$((b[q+(y<<1)>>1]|0)-w|0,n)|0;if((w|0)<9)continue;C=+(w|0);D=0;u=0;v=0;t=0;while(1){if((D|0)>=(w|0))break;E=+g[d+(B+D<<2)>>2];E=E*E*C;D=D+1|0;u=E<.25?u+1|0:u;v=E<.0625?v+1|0:v;t=E<.015625?t+1|0:t}if((A|0)>((c[s>>2]|0)+ -4|0))x=x+(Wa(v+u<<5,w)|0)|0;p=p+1|0;a=a+(((t<<1|0)>=(w|0)&1)+((v<<1|0)>=(w|0)&1)+((u<<1|0)>=(w|0)&1)<<8)|0}do if(k){if(!x)k=0;else k=Wa(x,$(4-(c[s>>2]|0)+l|0,m)|0)|0;k=(c[h>>2]|0)+k>>1;c[h>>2]=k;h=c[j>>2]|0;if((h|0)==2)k=k+4|0;else if(!h)k=k+ -4|0;if((k|0)>22){c[j>>2]=2;break}if((k|0)>18){c[j>>2]=1;break}else{c[j>>2]=0;break}}while(0);D=Wa(a,p)|0;D=D+(c[e>>2]|0)>>1;c[e>>2]=D;f=(D*3|0)+(3-f<<7|64)+2>>2;if((f|0)<80){D=3;i=o;return D|0}if((f|0)<256){D=2;i=o;return D|0}else{i=o;return((f|0)<384?1:0)|0}return 0}function Ya(a,b,c){a=a|0;b=b|0;c=c|0Line truncated
|
||||
|
||||
|
||||
|
||||
function Wd(a,c,d,e,f,g){a=a|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;l=i;g=d+2|0;m=d+4|0;k=d+6|0;h=d+8|0;n=d+10|0;j=f;while(1){if((j|0)>=(e|0))break;p=j+ -1|0;o=$(b[c+(p<<1)>>1]|0,b[d>>1]|0)|0;o=o+($(b[c+(j+ -2<<1)>>1]|0,b[g>>1]|0)|0)|0;o=o+($(b[c+(j+ -3<<1)>>1]|0,b[m>>1]|0)|0)|0;o=o+($(b[c+(j+ -4<<1)>>1]|0,b[k>>1]|0)|0)|0;o=o+($(b[c+(j+ -5<<1)>>1]|0,b[h>>1]|0)|0)|0;o=o+($(b[c+(j+ -6<<1)>>1]|0,b[n>>1]|0)|0)|0;q=6;while(1){if((q|0)>=(f|0))break;r=o+($(b[c+(p-q<<1)>>1]|0,b[d+(q<<1)>>1]|0)|0)|0;o=r+($(b[c+(p+~q<<1)>>1]|0,b[d+((q|1)<<1)>>1]|0)|0)|0;q=q+2|0}o=((b[c+(j<<1)>>1]<<12)-o>>11)+1>>1;if((o|0)>32767)o=32767;else o=(o|0)<-32768?-32768:o&65535;b[a+(j<<1)>>1]=o;j=j+1|0}_j(a|0,0,f<<1|0)|0;i=l;return}function Xd(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0;e=i;i=i+128|0;f=e;h=d&1;g=0;j=0;while(1){if((j|0)>=(d|0))break;k=b[a+(j<<1)>>1]|0;c[f+(h<<6)+(j<<2)>>2]=k<<12;g=g+k|0;j=j+1|0}if((g|0)>4095){k=0;i=e;return k|0}k=Yd(f,d)|0;i=e;return k|0}function Yd(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=i;f=b&1;l=1073741824;k=0;while(1){b=b+ -1|0;if((b|0)<=0)break;g=c[a+(f<<6)+(b<<2)>>2]|0;if((g|0)>16773022|(g|0)<-16773022){a=0;e=13;break}j=0-(g<<7)|0;h=((j|0)<0)<<31>>31;ik(j|0,h|0,j|0,h|0)|0;o=1073741824-D|0;m=32-(Zd((o|0)>0?o:0-o|0)|0)|0;g=_d(o,m+30|0)|0;k=ik(l|0,k|0,o|0,((o|0)<0)<<31>>31|0)|0;k=Yj(k|0,D|0,30)|0;k=k&-4;l=b&1;o=(m|0)==1;n=((g|0)<0)<<31>>31;m=m+ -1|0;p=0;while(1){if((p|0)>=(b|0))break;q=c[a+(f<<6)+(p<<2)>>2]|0;r=c[a+(f<<6)+(b-p+ -1<<2)>>2]|0;r=ik(r|0,((r|0)<0)<<31>>31|0,j|0,h|0)|0;r=Yj(r|0,D|0,30)|0;r=$j(r|0,D|0,1,0)|0;r=Yj(r|0,D|0,1)|0;r=q-r|0;r=ik(r|0,((r|0)<0)<<31>>31|0,g|0,n|0)|0;q=D;if(o){q=Yj(r|0,q|0,1)|0;q=$j(q|0,D|0,r&1|0,0)|0}else{q=Xj(r|0,q|0,m|0)|0;q=$j(q|0,D|0,1,0)|0;q=Yj(q|0,D|0,1)|0}c[a+(l<<6)+(p<<2)>>2]=q;p=p+1|0}f=l;l=k;k=((k|0)<0)<<31>>31}if((e|0)==13){i=d;return a|0}e=c[a+(f<<6)>>2]|0;if((e|0)>16773022|(e|0)<-16773022){r=0;i=d;return r|0}q=0-(e<<7)|0;r=((q|0)<0)<<31>>31;ik(q|0,r|0,q|0,r|0)|0;r=1073741824-D|0;r=ik(l|0,k|0,r|0,((r|0)<0)<<31>>31|0)|0;r=Yj(r|0,D|0,30)|0;r=r&-4;i=d;return r|0}function Zd(a){a=a|0;var b=0;b=i;if(!a)a=32;else a=Zj(a|0)|0;i=b;return a|0}function _d(a,b){a=a|0;b=b|0;var c=0,d=0,e=0,f=0,g=0,h=0;c=i;e=Zd((a|0)>0?a:0-a|0)|0;d=a<<e+ -1;h=d>>16;a=536870911/(h|0)|0;g=a<<16;f=g>>16;d=536870912-(($(h,f)|0)+(($(d&65535,f)|0)>>16))<<3;a=g+(($(d>>16,f)|0)+(($(d&65528,f)|0)>>16))+($(d,(a>>15)+1>>1)|0)|0;b=62-e-b|0;if((b|0)>=1){i=c;return((b|0)<32?a>>b:0)|0}b=0-b|0;d=-2147483648>>b;e=2147483647>>>b;if((d|0)>(e|0)){if((a|0)>(d|0)){h=d;h=h<<b;i=c;return h|0}h=(a|0)<(e|0)?e:a;h=h<<b;i=c;return h|0}else{if((a|0)>(e|0)){h=e;h=h<<b;i=c;return h|0}h=(a|0)<(d|0)?d:a;h=h<<b;i=c;return h|0}return 0}function $d(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0;e=i;i=i+32|0;f=e+8|0;g=e;j=a+12|0;if(!(c[j>>2]|0)){i=e;return}h=a+8|0;l=256-(c[h>>2]|0)<<10;k=l>>16;ae(f,g,k,l-(k<<16)|0);j=(c[h>>2]|0)+(c[j>>2]|0)|0;if((j|0)>256)j=256;else j=(j|0)<0?0:j;c[h>>2]=j;lf(b,f,g,a,b,d);i=e;return}function ae(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0;h=i;if((d|0)>=4){c[a+0>>2]=c[6270];c[a+4>>2]=c[6271];c[a+8>>2]=c[6272];e=b;c[e>>2]=35497197;c[e+4>>2]=57401098;i=h;return}if((e|0)<=0){g=25032+(d*12|0)|0;c[a+0>>2]=c[g+0>>2];c[a+4>>2]=c[g+4>>2];c[a+8>>2]=c[g+8>>2];g=25096+(d<<3)|0;a=c[g+4>>2]|0;e=b;c[e>>2]=c[g>>2];c[e+4>>2]=a;i=h;return}f=d+1|0;g=e<<16>>16;if((e|0)<32768){e=0;while(1){if((e|0)>=3){a=0;break}k=c[25032+(d*12|0)+(e<<2)>>2]|0;j=(c[25032+(f*12|0)+(e<<2)>>2]|0)-k|0;c[a+(e<<2)>>2]=k+(($(j>>16,g)|0)+(($(j&65535,g)|0)>>16));e=e+1|0}while(1){if((a|0)>=2)break;j=c[25096+(d<<3)+(a<<2)>>2]|0;k=(c[25096+(f<<3)+(a<<2)>>2]|0)-j|0;c[b+(a<<2)>>2]=j+(($(k>>16,g)|0)+(($(k&65535,g)|0)>>16));a=a+1|0}i=h;return}else{e=0;while(1){if((e|0)>=3){a=0;break}j=c[25032+(f*12|0)+(e<<2)>>2]|0;k=j-(c[25032+(d*12|0)+(e<<2)>>2]|0)|0;c[a+(e<<2)>>2]=j+(($(k>>16,g)|0)+(($(k&65535,g)|0)>>16));e=e+1|0}while(1){if((a|0)>=2)break;j=c[25096+(f<<3)+(a<<2)>>2]|0;k=j-(c[25096+(d<<3)+(a<<2)>>2]|0)|0;c[b+(a<<2)>>2]=j+(($(k>>16,g)|0)+(($(k&65535,g)|0)>>16));a=a+1|0}i=h;return}}function be(a,e,f){a=a|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0;g=i;i=i+208|0;l=g+136|0;j=g+100|0;k=g+64|0;h=g;m=(f|0)==16?21176:21192;n=0;while(1){if((n|0)>=(f|0))break;p=b[e+(n<<1)>>1]|0;o=p>>8;q=b[21992+(o<<1)>>1]|0;o=((q<<8)+($((b[21992+(o+1<<1)>>1]|0)-q|0,p-(o<<8)|0)|0)>>3)+1>>1;c[l+(d[m+n>>0]<<2)>>2]=o;n=n+1|0}m=f>>1;ce(j,l,m);ce(k,l+4|0,m);l=0;while(1){if((l|0)>=(m|0))break;q=l+1|0;p=(c[j+(q<<2)>>2]|0)+(c[j+(l<<2)>>2]|0)|0;o=(c[k+(q<<2)>>2]|0)-(c[k+(l<<2)>>2]|0)|0;c[h+(l<<2)>>2]=0-o-p;c[h+(f-l+ -1<<2)>>2]=o-p;l=q}k=0;j=0;while(1){if((j|0)<10){l=0;m=0}else break;while(1){if((m|0)>=(f|0))break;q=c[h+(m<<2)>>2]|0;q=(q|0)>0?q:0-q|0;p=(q|0)>(l|0);k=p?m:k;l=p?q:l;m=m+1|0}l=(l>>4)+1>>1;if((l|0)<=32767)break;q=(l|0)<163838?l:163838;nf(h,f,65470-(((q<<14)+ -536854528|0)/(($(q,k+1|0)|0)>>2|0)|0)|0);j=j+1|0}a:do if((j|0)==10){k=0;while(1){if((k|0)>=(f|0)){k=Line truncated
|
||||
|
||||
|
||||
|
||||
function Bg(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0.0;h=i;i=i+1040|0;n=h+72|0;m=h;o=f+(0-(c[b+4624>>2]|0)<<2)|0;p=b+4748|0;s=+(c[p>>2]|0)*.0078125;l=b+4728|0;q=+((c[l>>2]|0)+(c[b+4732>>2]|0)|0)*.5*30517578125.0e-15;j=d+856|0;g[j>>2]=q;r=+Cg((s+-20.0)*.25);k=d+860|0;g[k>>2]=r;if(!(c[b+4708>>2]|0)){C=1.0- +(c[b+4556>>2]|0)*.00390625;r=s-r*2.0*(q*.5+.5)*C*C}else r=s;f=b+4797|0;if((a[f>>0]|0)==2){q=r+ +g[b+12236>>2]*2.0;a[b+4798>>0]=0;g[d+864>>2]=0.0}else{q=r+(+(c[p>>2]|0)*-.4000000059604645*.0078125+6.0)*(1.0-q);t=c[b+4600>>2]<<1;p=b+4604|0;r=+(t|0);s=0.0;C=0.0;u=0;while(1){if((u|0)>=(((c[p>>2]<<16>>16)*5|0)/2|0|0))break;y=+Dg(r+ +sg(e,t));if((u|0)>0)s=s+ +O(+(y-C));C=y;e=e+(t<<2)|0;u=u+1|0}C=+Cg((s+-5.0)*.4000000059604645);e=d+864|0;g[e>>2]=C;p=b+4798|0;if(C>.75)a[p>>0]=0;else a[p>>0]=1;q=q+(+g[e>>2]+-.5)*2.0}C=+g[d+868>>2]*.0010000000474974513;C=.949999988079071/(C*C+1.0);y=+g[k>>2];r=(1.0-y*.75)*.009999999776482582;s=C+r;r=(C-r)/s;t=b+4704|0;e=c[t>>2]|0;if((e|0)>0)y=+(e|0)*152587890625.0e-16+y*.009999999776482582;else y=0.0;e=b+4604|0;p=b+4600|0;x=b+4628|0;w=b+4612|0;u=b+4660|0;v=0;while(1){z=c[e>>2]|0;if((v|0)>=(z|0))break;B=c[p>>2]|0;z=B*3|0;A=((c[x>>2]|0)-z|0)/2|0;eg(n,o,1,A);ak(n+(A<<2)|0,o+(A<<2)|0,B*12|0)|0;z=A+z|0;eg(n+(z<<2)|0,o+(z<<2)|0,2,A);o=o+(c[w>>2]<<2)|0;A=c[x>>2]|0;z=c[u>>2]|0;if((c[t>>2]|0)>0)ch(m,n,y,A,z);else fg(m,n,A,z+1|0);C=+g[m>>2];g[m>>2]=C+C*4999999873689376.0e-20;A=v<<4;B=d+(A<<2)+500|0;C=+P(+(+Ag(B,m,c[u>>2]|0)));z=d+(v<<2)|0;g[z>>2]=C;if((c[t>>2]|0)>0)g[z>>2]=C*+Eg(B,y,c[u>>2]|0);hg(B,c[u>>2]|0,s);A=d+(A<<2)+244|0;ak(A|0,B|0,c[u>>2]<<2|0)|0;hg(A,c[u>>2]|0,r);C=+bg(B,c[u>>2]|0);g[d+(v<<2)+788>>2]=1.0-(1.0-C/+bg(A,c[u>>2]|0))*.699999988079071;Fg(B,A,y,c[u>>2]|0);v=v+1|0}q=+sa(+(q*-.1599999964237213));m=0;while(1){if((m|0)>=(z|0))break;z=d+(m<<2)|0;g[z>>2]=+g[z>>2]*q+1.2483305931091309;z=c[e>>2]|0;m=m+1|0}q=+g[k>>2]*.10000000149011612+1.0499999523162842;m=0;while(1){if((m|0)>=(z|0))break;z=d+(m<<2)+788|0;g[z>>2]=+g[z>>2]*q;z=c[e>>2]|0;m=m+1|0}m=b+4556|0;q=((+(c[l>>2]|0)*30517578125.0e-15+-1.0)*.5+1.0)*4.0*+(c[m>>2]|0)*.00390625;a:do if((a[f>>0]|0)==2){l=0;while(1){if((l|0)>=(z|0))break;C=.20000000298023224/+(c[p>>2]|0)+3.0/+(c[d+(l<<2)+228>>2]|0);g[d+(l<<2)+756>>2]=C+-1.0;g[d+(l<<2)+772>>2]=1.0-C-C*q;z=c[e>>2]|0;l=l+1|0}q=-.25- +(c[m>>2]|0)*.26249998807907104*.00390625}else{C=1.2999999523162842/+(c[p>>2]|0);l=d+756|0;g[l>>2]=C+-1.0;m=d+772|0;g[m>>2]=1.0-C-C*q*.6000000238418579;n=1;while(1){z=c[e>>2]|0;if((n|0)>=(z|0)){q=-.25;break a}g[d+(n<<2)+756>>2]=+g[l>>2];g[d+(n<<2)+772>>2]=+g[m>>2];n=n+1|0}}while(0);s=1.0- +g[k>>2];y=+g[b+12236>>2];C=+g[j>>2];r=s*.10000000149011612*y+(1.0-C)*.10000000149011612;if((a[f>>0]|0)==2)s=((1.0-s*C)*.20000000298023224+.30000001192092896)*+P(+y);else s=0.0;j=b+7204|0;f=b+7208|0;b=b+7212|0;k=0;while(1){if((k|0)>=(z|0))break;C=+g[j>>2];C=C+(r-C)*.4000000059604645;g[j>>2]=C;g[d+(k<<2)+804>>2]=C;C=+g[f>>2];C=C+(s-C)*.4000000059604645;g[f>>2]=C;g[d+(k<<2)+836>>2]=C;C=+g[b>>2];C=C+(q-C)*.4000000059604645;g[b>>2]=C;g[d+(k<<2)+820>>2]=C;z=c[e>>2]|0;k=k+1|0}i=h;return}function Cg(a){a=+a;a=1.0/(+Y(+-a)+1.0);return+a}function Dg(a){a=+a;var b=0;b=i;a=+oa(+a)*3.32192809488736;i=b;return+a}function Eg(a,b,c){a=a|0;b=+b;c=c|0;var d=0,e=0.0;d=i;b=-b;e=+g[a+(c+ -1<<2)>>2];c=c+ -2|0;while(1){e=e*b;if((c|0)<=-1)break;e=e+ +g[a+(c<<2)>>2];c=c+ -1|0}i=d;return+(1.0/(1.0-e))}function Fg(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;var e=0,f=0.0,h=0,j=0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0.0,q=0.0,r=0,s=0;e=i;j=d;while(1){h=j+ -1|0;if((h|0)<=0)break;o=j+ -2|0;n=a+(o<<2)|0;g[n>>2]=+g[n>>2]- +g[a+(h<<2)>>2]*c;o=b+(o<<2)|0;g[o>>2]=+g[o>>2]- +g[b+(h<<2)>>2]*c;j=h}f=1.0-c*c;m=f/(+g[a>>2]*c+1.0);k=f/(+g[b>>2]*c+1.0);h=0;while(1){if((h|0)>=(d|0)){j=0;h=0;break}o=a+(h<<2)|0;g[o>>2]=+g[o>>2]*m;o=b+(h<<2)|0;g[o>>2]=+g[o>>2]*k;h=h+1|0}while(1){if((h|0)<10){l=-1.0;n=0}else{a=23;break}while(1){if((n|0)>=(d|0))break;q=+O(+(+g[a+(n<<2)>>2]));p=+O(+(+g[b+(n<<2)>>2]));p=q>p?q:p;o=p>l;j=o?n:j;l=o?p:l;n=n+1|0}if(!(l<=3.999000072479248))n=1;else{a=23;break}while(1){if((n|0)>=(d|0))break;o=n+ -1|0;r=a+(o<<2)|0;g[r>>2]=+g[r>>2]+ +g[a+(n<<2)>>2]*c;o=b+(o<<2)|0;g[o>>2]=+g[o>>2]+ +g[b+(n<<2)>>2]*c;n=n+1|0}m=1.0/m;k=1.0/k;n=0;while(1){if((n|0)>=(d|0))break;r=a+(n<<2)|0;g[r>>2]=+g[r>>2]*m;r=b+(n<<2)|0;g[r>>2]=+g[r>>2]*k;n=n+1|0}q=.9900000095367432-(+(h|0)*.10000000149011612+.800000011920929)*(l+-3.999000072479248)/(l*+(j+1|0));hg(a,d,q);hg(b,d,q);n=d;while(1){o=n+ -1|0;if((o|0)<=0)break;r=n+ -2|0;s=a+(r<<2)|0;g[s>>2]=+g[s>>2]- +g[a+(o<<2)>>2]*c;r=b+(r<<2)|0;g[r>>2]=+g[r>>2]- +g[b+(o<<2)>>2]*c;n=o}m=f/(+g[a>>2]*c+1.0);k=f/(+g[b>>2]*c+1.0);n=0;while(1){if((n|0)>=(d|0))break;s=a+(n<<2)|0;g[s>>2]=+g[s>>2]*m;s=b+(n<<2)|0;g[s>>2]=+g[s>>2]*k;n=n+1|0}h=h+1|0}if((a|0)==23){i=e;return}}function Gg(d,f,h,j,k,l,m,n,o,p,q,r){d=d|0;f=f|0;h=h|0;j=j|0;k=k|0;l=l|0;m=+m;n=+n;o=o|0;p=p|0;q=q|0;r=r|0;var s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0Line truncated
|
||||
|
||||
|
||||
|
||||
function vj(a,b,d,e,f,h,j){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0;k=i;if((h|0)>10|(h|0)<0){if(!j){p=0;i=k;return p|0}c[j>>2]=3;p=0;i=k;return p|0}l=wj(96)|0;c[l+52>>2]=0;c[l+56>>2]=0;p=l+16|0;c[l+0>>2]=0;c[l+4>>2]=0;c[l+8>>2]=0;c[l+12>>2]=0;c[p>>2]=-1;c[l+80>>2]=0;c[l+28>>2]=0;c[l+24>>2]=0;c[l+72>>2]=0;c[l+84>>2]=0;g[l+44>>2]=1.0;c[l+20>>2]=a;c[l+88>>2]=1;c[l+92>>2]=1;c[l+32>>2]=160;p=a<<2;m=l+60|0;c[m>>2]=wj(p)|0;n=l+68|0;c[n>>2]=wj(p)|0;o=l+64|0;c[o>>2]=wj(p)|0;p=0;while(1){if(p>>>0>=a>>>0)break;c[(c[m>>2]|0)+(p<<2)>>2]=0;c[(c[n>>2]|0)+(p<<2)>>2]=0;c[(c[o>>2]|0)+(p<<2)>>2]=0;p=p+1|0}xj(l,h);yj(l,b,d,e,f);b=zj(l)|0;if(!b)c[l+52>>2]=1;else{Aj(l);l=0}if(!j){p=l;i=k;return p|0}c[j>>2]=b;p=l;i=k;return p|0}function wj(a){a=a|0;var b=0;b=i;a=Sj(a)|0;i=b;return a|0}function xj(a,b){a=a|0;b=b|0;var d=0,e=0;d=i;if((!((b|0)>10|(b|0)<0)?(e=a+16|0,(c[e>>2]|0)!=(b|0)):0)?(c[e>>2]=b,(c[a+52>>2]|0)!=0):0)zj(a)|0;i=d;return}function yj(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0;g=i;k=a+4|0;if((((c[a>>2]|0)==(e|0)?(c[k>>2]|0)==(f|0):0)?(c[a+8>>2]|0)==(b|0):0)?(c[a+12>>2]|0)==(d|0):0){i=g;return}j=a+12|0;h=c[j>>2]|0;c[a>>2]=e;c[k>>2]=f;f=a+8|0;c[f>>2]=b;c[j>>2]=d;e=d;k=d;d=2;while(1){if(d>>>0>(c[(b>>>0<e>>>0?f:j)>>2]|0)>>>0)break;b=c[f>>2]|0;while(1){if((b>>>0)%(d>>>0)|0)break;if((e>>>0)%(d>>>0)|0)break;e=(b>>>0)/(d>>>0)|0;c[f>>2]=e;l=(k>>>0)/(d>>>0)|0;c[j>>2]=l;b=e;e=l;k=l}d=d+1|0}a:do if(h){e=a+20|0;d=a+64|0;b=0;while(1){if(b>>>0>=(c[e>>2]|0)>>>0)break a;f=(c[d>>2]|0)+(b<<2)|0;c[f>>2]=(($(c[f>>2]|0,c[j>>2]|0)|0)>>>0)/(h>>>0)|0;f=(c[d>>2]|0)+(b<<2)|0;k=c[j>>2]|0;if((c[f>>2]|0)>>>0>=k>>>0)c[f>>2]=k+ -1;b=b+1|0}}while(0);if(!(c[a+52>>2]|0)){i=g;return}zj(a)|0;i=g;return}function zj(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0;b=i;f=a+24|0;e=c[f>>2]|0;d=a+28|0;h=c[d>>2]|0;o=c[a+8>>2]|0;k=a+12|0;m=c[k>>2]|0;c[a+36>>2]=(o>>>0)/(m>>>0)|0;c[a+40>>2]=(o>>>0)%(m>>>0)|0;j=a+16|0;q=c[j>>2]|0;p=c[30620+(q*20|0)>>2]|0;l=a+48|0;c[l>>2]=p;n=c[30616+(q*20|0)>>2]|0;c[f>>2]=n;if(o>>>0>m>>>0){g[a+44>>2]=+g[30624+(q*20|0)>>2]*+(m>>>0)/+(o>>>0);n=((($(n,o)|0)>>>0)/(m>>>0)|0)+7&-8;c[f>>2]=n;if(m<<1>>>0<o>>>0){p=p>>>1;c[l>>2]=p}if(m<<2>>>0<o>>>0){p=p>>>1;c[l>>2]=p}if(m<<3>>>0<o>>>0){p=p>>>1;c[l>>2]=p}if(m<<4>>>0<o>>>0){p=p>>>1;c[l>>2]=p}if(!p){c[l>>2]=1;p=1}}else g[a+44>>2]=+g[30628+(q*20|0)>>2];r=$(n,m)|0;q=($(n,p)|0)+8|0;if(r>>>0<=q>>>0){m=(536870911/(m>>>0)|0)>>>0>=n>>>0;o=m&1;if(m){q=r;m=16}else m=15}else{o=0;m=15}if((m|0)==15?(536870903/(p>>>0)|0)>>>0>=n>>>0:0)m=16;do if((m|0)==16){m=a+80|0;if((c[m>>2]|0)>>>0<q>>>0){p=a+76|0;n=Ij(c[p>>2]|0,q<<2)|0;if(!n)break;c[p>>2]=n;c[m>>2]=q}m=a+44|0;n=a+76|0;do if(!o){o=-4;while(1){p=c[l>>2]|0;k=c[f>>2]|0;if((o|0)>=(($(p,k)|0)+4|0))break;s=+Jj(+g[m>>2],+(o|0)/+(p>>>0)- +(k>>>1>>>0),k,c[30632+((c[j>>2]|0)*20|0)>>2]|0);g[(c[n>>2]|0)+(o+4<<2)>>2]=s;o=o+1|0}k=a+84|0;if((c[j>>2]|0)>8){c[k>>2]=3;break}else{c[k>>2]=4;break}}else{l=0;while(1){if(l>>>0>=(c[k>>2]|0)>>>0)break;s=+(l>>>0);o=0;while(1){p=c[f>>2]|0;if(o>>>0>=p>>>0)break;t=+Jj(+g[m>>2],+(o-((p|0)/2|0)+1|0)-s/+((c[k>>2]|0)>>>0),p,c[30632+((c[j>>2]|0)*20|0)>>2]|0);r=($(l,p)|0)+o|0;g[(c[n>>2]|0)+(r<<2)>>2]=t;o=o+1|0}l=l+1|0}k=a+84|0;if((c[j>>2]|0)>8){c[k>>2]=1;break}else{c[k>>2]=2;break}}while(0);j=(c[f>>2]|0)+ -1+(c[a+32>>2]|0)|0;k=c[d>>2]|0;if(j>>>0>k>>>0){l=c[a+20>>2]|0;if((536870911/(l>>>0)|0)>>>0<j>>>0)break;k=a+72|0;l=Ij(c[k>>2]|0,($(l,j)|0)<<2)|0;if(!l)break;c[k>>2]=l;c[d>>2]=j}else j=k;if(!(c[a+56>>2]|0)){e=a+20|0;f=a+72|0;h=0;while(1){if(h>>>0>=($(c[e>>2]|0,j)|0)>>>0){d=0;break}g[(c[f>>2]|0)+(h<<2)>>2]=0.0;j=c[d>>2]|0;h=h+1|0}i=b;return d|0}j=c[f>>2]|0;if(j>>>0<=e>>>0){if(j>>>0>=e>>>0){r=0;i=b;return r|0}j=a+20|0;h=a+68|0;l=a+72|0;k=0;while(1){if(k>>>0>=(c[j>>2]|0)>>>0){d=0;break}m=(c[h>>2]|0)+(k<<2)|0;a=c[m>>2]|0;c[m>>2]=(e-(c[f>>2]|0)|0)>>>1;m=0;while(1){o=(c[h>>2]|0)+(k<<2)|0;n=c[o>>2]|0;if(m>>>0>=((c[f>>2]|0)+ -1+n+a|0)>>>0)break;r=($(k,c[d>>2]|0)|0)+m|0;q=c[l>>2]|0;g[q+(r<<2)>>2]=+g[q+(r+n<<2)>>2];m=m+1|0}c[o>>2]=n+a;k=k+1|0}i=b;return d|0}m=a+68|0;k=e+ -1|0;j=a+72|0;l=a+60|0;n=c[a+20>>2]|0;a:while(1){a=n+ -1|0;if(!n){d=0;break}p=c[(c[m>>2]|0)+(a<<2)>>2]|0;n=e+(p<<1)|0;q=$(a,h)|0;p=k+p|0;while(1){o=p+ -1|0;if(!p){o=0;break}r=c[j>>2]|0;p=($(a,c[d>>2]|0)|0)+o|0;g[r+(p+(c[(c[m>>2]|0)+(a<<2)>>2]|0)<<2)>>2]=+g[r+(q+o<<2)>>2];p=o}while(1){p=(c[m>>2]|0)+(a<<2)|0;if(o>>>0>=(c[p>>2]|0)>>>0)break;r=($(a,c[d>>2]|0)|0)+o|0;g[(c[j>>2]|0)+(r<<2)>>2]=0.0;o=o+1|0}c[p>>2]=0;o=c[f>>2]|0;if(o>>>0<=n>>>0){c[(c[m>>2]|0)+(a<<2)>>2]=(n-o|0)>>>1;o=0;while(1){n=c[(c[m>>2]|0)+(a<<2)>>2]|0;if(o>>>0>=((c[f>>2]|0)+ -1+n|0)>>>0){n=a;continue a}r=($(a,c[d>>2]|0)|0)+o|0;q=c[j>>2]|0;g[q+(r<<2)>>2]=+g[q+(r+n<<2)>>2];o=o+1|0}}q=n+ -1|0;p=n+ -2|0;o=0;while(1){if(o>>>0>=q>>>0)break;r=$(a,c[d>>2]|0)|0;u=c[j>>2]|0;g[u+(r+((c[f>>2]|0)+ -2-o)<<2)>>2]=+g[u+(r+(p-o)<<2)>>2];o=o+1|0}while(1){p=c[f>>2]|0;if(o>>>0>=(p+ -1|0)>>>0)break;u=($(a,c[d>>2]|0)|0)+(p+ -2-o)|0;g[(c[j>>2]|0)+(u<<2)>>2]Line truncated
|
||||
|
||||
|
||||
|
||||
|
||||
// EMSCRIPTEN_END_FUNCS
|
||||
var Fa=[ok,Kj,Lj,Mj,Nj,Fj,ok,ok];var Ga=[pk,Vi,Ui,pk];return{_speex_resampler_destroy:Aj,_opus_decode_float:Hi,_opus_encoder_destroy:lj,_opus_decoder_destroy:Ji,_bitshift64Lshr:Yj,_calloc:Sj,_opus_get_version_string:ub,_opus_decoder_create:wi,_bitshift64Ashr:Xj,_memset:_j,_i64Add:$j,_memcpy:ak,_realloc:Tj,_speex_resampler_init:uj,_opus_encode:ij,_speex_resampler_process_float:Cj,_opus_encoder_ctl:kj,_speex_resampler_process_int:Gj,_free:Rj,_opus_encode_float:jj,_memmove:bk,_speex_resampler_process_interleaved_float:Hj,_malloc:Qj,_opus_encoder_create:Ri,_llvm_ctlz_i32:Zj,_opus_decode:Ei,_opus_decoder_ctl:Ii,runPostSets:Wj,stackAlloc:Ha,stackSave:Ia,stackRestore:Ja,setThrew:Ka,setTempRet0:Na,getTempRet0:Oa,dynCall_iiiiiii:mk,dynCall_viiiiiii:nk}})
|
||||
|
||||
|
||||
// EMSCRIPTEN_END_ASM
|
||||
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var _speex_resampler_destroy=Module["_speex_resampler_destroy"]=asm["_speex_resampler_destroy"];var _opus_decode_float=Module["_opus_decode_float"]=asm["_opus_decode_float"];var _opus_encoder_destroy=Module["_opus_encoder_destroy"]=asm["_opus_encoder_destroy"];var _opus_decoder_destroy=Module["_opus_decoder_destroy"]=asm["_opus_decoder_destroy"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _calloc=Module["_calloc"]=asm["_calloc"];var _opus_get_version_string=Module["_opus_get_version_string"]=asm["_opus_get_version_string"];var _opus_decoder_create=Module["_opus_decoder_create"]=asm["_opus_decoder_create"];var _bitshift64Ashr=Module["_bitshift64Ashr"]=asm["_bitshift64Ashr"];var _memset=Module["_memset"]=asm["_memset"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _realloc=Module["_realloc"]=asm["_realloc"];var _speex_resampler_init=Module["_speex_resampler_init"]=asm["_speex_resampler_init"];var _opus_encode=Module["_opus_encode"]=asm["_opus_encode"];var _speex_resampler_process_float=Module["_speex_resampler_process_float"]=asm["_speex_resampler_process_float"];var _opus_encoder_ctl=Module["_opus_encoder_ctl"]=asm["_opus_encoder_ctl"];var _speex_resampler_process_int=Module["_speex_resampler_process_int"]=asm["_speex_resampler_process_int"];var _free=Module["_free"]=asm["_free"];var _opus_encode_float=Module["_opus_encode_float"]=asm["_opus_encode_float"];var _memmove=Module["_memmove"]=asm["_memmove"];var _speex_resampler_process_interleaved_float=Module["_speex_resampler_process_interleaved_float"]=asm["_speex_resampler_process_interleaved_float"];var _malloc=Module["_malloc"]=asm["_malloc"];var _opus_encoder_create=Module["_opus_encoder_create"]=asm["_opus_encoder_create"];var _llvm_ctlz_i32=Module["_llvm_ctlz_i32"]=asm["_llvm_ctlz_i32"];var _opus_decode=Module["_opus_decode"]=asm["_opus_decode"];var _opus_decoder_ctl=Module["_opus_decoder_ctl"]=asm["_opus_decoder_ctl"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var dynCall_iiiiiii=Module["dynCall_iiiiiii"]=asm["dynCall_iiiiiii"];var dynCall_viiiiiii=Module["dynCall_viiiiiii"]=asm["dynCall_viiiiiii"];Runtime.stackAlloc=asm["stackAlloc"];Runtime.stackSave=asm["stackSave"];Runtime.stackRestore=asm["stackRestore"];Runtime.setTempRet0=asm["setTempRet0"];Runtime.getTempRet0=asm["getTempRet0"];var i64Math=(function(){var goog={math:{}};goog.math.Long=(function(low,high){this.low_=low|0;this.high_=high|0});goog.math.Long.IntCache_={};goog.math.Long.fromInt=(function(value){if(-128<=value&&value<128){var cachedObj=goog.math.Long.IntCache_[value];if(cachedObj){return cachedObj}}var obj=new goog.math.Long(value|0,value<0?-1:0);if(-128<=value&&value<128){goog.math.Long.IntCache_[value]=obj}return obj});goog.math.Long.fromNumber=(function(value){if(isNaN(value)||!isFinite(value)){return goog.math.Long.ZERO}else if(value<=-goog.math.Long.TWO_PWR_63_DBL_){return goog.math.Long.MIN_VALUE}else if(value+1>=goog.math.Long.TWO_PWR_63_DBL_){return goog.math.Long.MAX_VALUE}else if(value<0){return goog.math.Long.fromNumber(-value).negate()}else{return new goog.math.Long(value%goog.math.Long.TWO_PWR_32_DBL_|0,value/goog.math.Long.TWO_PWR_32_DBL_|0)}});goog.math.Long.fromBits=(function(lowBits,highBits){return new goog.math.Long(lowBits,highBits)});goog.math.Long.fromString=(function(str,opt_radix){if(str.length==0){throw Error("number format error: empty string")}var radix=opt_radix||10;if(radix<2||36<radix){throw Error("radix out of range: "+radix)}if(str.charAt(0)=="-"){return goog.math.Long.fromString(str.substring(1),radix).negate()}else if(str.indexOf("-")>=0){throw Error('number format error: interior "-" character: '+str)}var radixToPower=goog.math.Long.fromNumber(Math.pow(radix,8));var result=goog.math.Long.ZERO;for(var i=0;i<str.length;i+=8){var size=Math.min(8,str.length-i);var value=parseInt(str.substring(i,i+size),radix);if(size<8){var power=goog.math.Long.fromNumber(Math.pow(radix,size));result=result.multiply(power).add(goog.math.Long.fromNumber(value))}else{result=result.multiply(radixToPower);result=result.add(goog.math.Long.fromNumber(value))}}return result});goog.math.Long.TWO_PWR_16_DBL_=1<<16;goog.math.Long.TWO_PWR_24_DBL_=1<<24;goog.math.Long.TWO_PWR_32_DBL_=goog.math.Long.TWO_PWR_16_DBL_*goog.math.Long.TWO_PWR_16_DBL_;goog.math.Long.TWO_PWR_31_DBL_=goog.math.Long.TWO_PWR_32_DBL_/2;goog.math.Long.TWO_PWR_48_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_16_DBL_;goog.math.Long.TWO_PWR_64_DBL_=goog.math.Long.TWO_PWR_32_DBL_*goog.math.Long.TWO_PWR_32_DBL_;goog.math.Long.TWO_PWR_63_DBL_=goog.math.Long.TWO_PWR_64_DBL_/2;goog.math.Long.ZERO=goog.math.Long.fromInt(0);goog.math.Long.ONE=goog.math.Long.fromInt(1);goog.math.Long.NEG_ONE=goog.math.Long.fromInt(-1);goog.math.Long.MAX_VALUE=goog.math.Long.fromBits(4294967295|0,2147483647|0);goog.math.Long.MIN_VALUE=goog.math.Long.fromBits(0,2147483648|0);goog.math.LonLine truncated
|
||||
|
||||
|
||||
|
||||
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
///<reference path="d.ts/asm.d.ts" />
|
||||
///<reference path="d.ts/libopus.d.ts" />
|
||||
|
||||
var native = require("./libopus_libspeexdsp");
|
||||
|
||||
var OPUS_SET_BITRATE_REQUEST = 4002;
|
||||
|
||||
var OpusApplication;
|
||||
(function (OpusApplication) {
|
||||
OpusApplication[OpusApplication["VoIP"] = 2048] = "VoIP";
|
||||
OpusApplication[OpusApplication["Audio"] = 2049] = "Audio";
|
||||
OpusApplication[OpusApplication["RestrictedLowDelay"] = 2051] = "RestrictedLowDelay";
|
||||
})(OpusApplication || (OpusApplication = {}));
|
||||
var OpusError;
|
||||
(function (OpusError) {
|
||||
OpusError[OpusError["OK"] = 0] = "OK";
|
||||
OpusError[OpusError["BadArgument"] = -1] = "BadArgument";
|
||||
OpusError[OpusError["BufferTooSmall"] = -2] = "BufferTooSmall";
|
||||
OpusError[OpusError["InternalError"] = -3] = "InternalError";
|
||||
OpusError[OpusError["InvalidPacket"] = -4] = "InvalidPacket";
|
||||
OpusError[OpusError["Unimplemented"] = -5] = "Unimplemented";
|
||||
OpusError[OpusError["InvalidState"] = -6] = "InvalidState";
|
||||
OpusError[OpusError["AllocFail"] = -7] = "AllocFail";
|
||||
})(OpusError || (OpusError = {}));
|
||||
var Opus = (function () {
|
||||
function Opus() {
|
||||
}
|
||||
Opus.getVersion = function () {
|
||||
var ptr = native._opus_get_version_string();
|
||||
return Pointer_stringify(ptr);
|
||||
};
|
||||
Opus.getMaxFrameSize = function (numberOfStreams) {
|
||||
if (numberOfStreams === void 0) { numberOfStreams = 1; }
|
||||
return (1275 * 3 + 7) * numberOfStreams;
|
||||
};
|
||||
Opus.getMinFrameDuration = function () {
|
||||
return 2.5;
|
||||
};
|
||||
Opus.getMaxFrameDuration = function () {
|
||||
return 60;
|
||||
};
|
||||
Opus.validFrameDuration = function (x) {
|
||||
return [2.5, 5, 10, 20, 40, 60].some(function (element) {
|
||||
return element == x;
|
||||
});
|
||||
};
|
||||
Opus.getMaxSamplesPerChannel = function (sampling_rate) {
|
||||
return sampling_rate / 1000 * Opus.getMaxFrameDuration();
|
||||
};
|
||||
return Opus;
|
||||
})();
|
||||
var OpusEncoder = (function () {
|
||||
function OpusEncoder(sampling_rate, channels, app, frame_duration) {
|
||||
if (frame_duration === void 0) { frame_duration = 20; }
|
||||
this.handle = 0;
|
||||
this.frame_size = 0;
|
||||
this.in_ptr = 0;
|
||||
this.in_off = 0;
|
||||
this.out_ptr = 0;
|
||||
if (!Opus.validFrameDuration(frame_duration))
|
||||
throw 'invalid frame duration';
|
||||
this.frame_size = sampling_rate * frame_duration / 1000;
|
||||
var err_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
|
||||
this.handle = native._opus_encoder_create(sampling_rate, channels, app, err_ptr);
|
||||
if (native.getValue(err_ptr, 'i32') != 0 /* OK */)
|
||||
throw 'opus_encoder_create failed: ' + native.getValue(err_ptr, 'i32');
|
||||
this.in_ptr = native._malloc(this.frame_size * channels * 4);
|
||||
this.in_len = this.frame_size * channels;
|
||||
this.in_i16 = native.HEAP16.subarray(this.in_ptr >> 1, (this.in_ptr >> 1) + this.in_len);
|
||||
this.in_f32 = native.HEAPF32.subarray(this.in_ptr >> 2, (this.in_ptr >> 2) + this.in_len);
|
||||
this.out_bytes = Opus.getMaxFrameSize();
|
||||
this.out_ptr = native._malloc(this.out_bytes);
|
||||
this.out_buf = native.HEAPU8.subarray(this.out_ptr, this.out_ptr + this.out_bytes);
|
||||
}
|
||||
OpusEncoder.prototype.set_bitrate = function (bitrate) {
|
||||
var bitrate_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
|
||||
native.setValue(bitrate_ptr, bitrate, 'i32');
|
||||
var ret = native._opus_encoder_ctl(this.handle, OPUS_SET_BITRATE_REQUEST, bitrate_ptr);
|
||||
if (ret < 0)
|
||||
throw 'opus_encoder_ctl failed: ' + ret;
|
||||
};
|
||||
OpusEncoder.prototype.encode = function (pcm) {
|
||||
var output = [];
|
||||
var pcm_off = 0;
|
||||
while (pcm.length - pcm_off >= this.in_len - this.in_off) {
|
||||
if (this.in_off > 0) {
|
||||
this.in_i16.set(pcm.subarray(pcm_off, pcm_off + this.in_len - this.in_off), this.in_off);
|
||||
pcm_off += this.in_len - this.in_off;
|
||||
this.in_off = 0;
|
||||
}
|
||||
else {
|
||||
this.in_i16.set(pcm.subarray(pcm_off, pcm_off + this.in_len));
|
||||
pcm_off += this.in_len;
|
||||
}
|
||||
var ret = native._opus_encode(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
|
||||
if (ret <= 0)
|
||||
throw 'opus_encode failed: ' + ret;
|
||||
var packet = new ArrayBuffer(ret);
|
||||
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
|
||||
output.push(packet);
|
||||
}
|
||||
if (pcm_off < pcm.length) {
|
||||
this.in_i16.set(pcm.subarray(pcm_off));
|
||||
this.in_off = pcm.length - pcm_off;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
OpusEncoder.prototype.encode_float = function (pcm) {
|
||||
var output = [];
|
||||
var pcm_off = 0;
|
||||
while (pcm.length - pcm_off >= this.in_len - this.in_off) {
|
||||
if (this.in_off > 0) {
|
||||
this.in_f32.set(pcm.subarray(pcm_off, pcm_off + this.in_len - this.in_off), this.in_off);
|
||||
pcm_off += this.in_len - this.in_off;
|
||||
this.in_off = 0;
|
||||
}
|
||||
else {
|
||||
this.in_f32.set(pcm.subarray(pcm_off, pcm_off + this.in_len));
|
||||
pcm_off += this.in_len;
|
||||
}
|
||||
var ret = native._opus_encode_float(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
|
||||
if (ret <= 0)
|
||||
throw 'opus_encode failed: ' + ret;
|
||||
var packet = new ArrayBuffer(ret);
|
||||
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
|
||||
output.push(packet);
|
||||
}
|
||||
if (pcm_off < pcm.length) {
|
||||
this.in_f32.set(pcm.subarray(pcm_off));
|
||||
this.in_off = pcm.length - pcm_off;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
OpusEncoder.prototype.encode_final = function () {
|
||||
if (this.in_off == 0)
|
||||
return new ArrayBuffer(0);
|
||||
for (var i = this.in_off; i < this.in_len; ++i)
|
||||
this.in_i16[i] = 0;
|
||||
var ret = native._opus_encode(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
|
||||
if (ret <= 0)
|
||||
throw 'opus_encode failed: ' + ret;
|
||||
var packet = new ArrayBuffer(ret);
|
||||
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
|
||||
return packet;
|
||||
};
|
||||
OpusEncoder.prototype.encode_float_final = function () {
|
||||
if (this.in_off == 0)
|
||||
return new ArrayBuffer(0);
|
||||
for (var i = this.in_off; i < this.in_len; ++i)
|
||||
this.in_f32[i] = 0;
|
||||
var ret = native._opus_encode_float(this.handle, this.in_ptr, this.frame_size, this.out_ptr, this.out_bytes);
|
||||
if (ret <= 0)
|
||||
throw 'opus_encode failed: ' + ret;
|
||||
var packet = new ArrayBuffer(ret);
|
||||
new Uint8Array(packet).set(this.out_buf.subarray(0, ret));
|
||||
return packet;
|
||||
};
|
||||
OpusEncoder.prototype.destroy = function () {
|
||||
if (!this.handle)
|
||||
return;
|
||||
native._opus_encoder_destroy(this.handle);
|
||||
native._free(this.in_ptr);
|
||||
this.handle = this.in_ptr = 0;
|
||||
};
|
||||
return OpusEncoder;
|
||||
})();
|
||||
var OpusDecoder = (function () {
|
||||
function OpusDecoder(sampling_rate, channels) {
|
||||
this.handle = 0;
|
||||
this.in_ptr = 0;
|
||||
this.out_ptr = 0;
|
||||
this.channels = channels;
|
||||
var err_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
|
||||
this.handle = native._opus_decoder_create(sampling_rate, channels, err_ptr);
|
||||
if (native.getValue(err_ptr, 'i32') != 0 /* OK */)
|
||||
throw 'opus_decoder_create failed: ' + native.getValue(err_ptr, 'i32');
|
||||
this.in_ptr = native._malloc(Opus.getMaxFrameSize(channels));
|
||||
this.in_buf = native.HEAPU8.subarray(this.in_ptr, this.in_ptr + Opus.getMaxFrameSize(channels));
|
||||
this.out_len = Opus.getMaxSamplesPerChannel(sampling_rate);
|
||||
var out_bytes = this.out_len * channels * 4;
|
||||
this.out_ptr = native._malloc(out_bytes);
|
||||
this.out_i16 = native.HEAP16.subarray(this.out_ptr >> 1, (this.out_ptr + out_bytes) >> 1);
|
||||
this.out_f32 = native.HEAPF32.subarray(this.out_ptr >> 2, (this.out_ptr + out_bytes) >> 2);
|
||||
}
|
||||
OpusDecoder.prototype.decode = function (packet) {
|
||||
this.in_buf.set(new Uint8Array(packet));
|
||||
var ret = native._opus_decode(this.handle, this.in_ptr, packet.byteLength, this.out_ptr, this.out_len, 0);
|
||||
if (ret < 0)
|
||||
throw 'opus_decode failed: ' + ret;
|
||||
var samples = new Int16Array(ret * this.channels);
|
||||
samples.set(this.out_i16.subarray(0, samples.length));
|
||||
return samples;
|
||||
};
|
||||
OpusDecoder.prototype.decode_float = function (packet) {
|
||||
this.in_buf.set(new Uint8Array(packet));
|
||||
var ret = native._opus_decode_float(this.handle, this.in_ptr, packet.byteLength, this.out_ptr, this.out_len, 0);
|
||||
if (ret < 0)
|
||||
throw 'opus_decode failed: ' + ret;
|
||||
var samples = new Float32Array(ret * this.channels);
|
||||
samples.set(this.out_f32.subarray(0, samples.length));
|
||||
return samples;
|
||||
};
|
||||
OpusDecoder.prototype.destroy = function () {
|
||||
if (!this.handle)
|
||||
return;
|
||||
native._opus_decoder_destroy(this.handle);
|
||||
native._free(this.in_ptr);
|
||||
native._free(this.out_ptr);
|
||||
this.handle = this.in_ptr = this.out_ptr = 0;
|
||||
};
|
||||
return OpusDecoder;
|
||||
})();
|
||||
|
||||
module.exports.Opus = Opus;
|
||||
module.exports.OpusApplication = OpusApplication;
|
||||
module.exports.OpusEncoder = OpusEncoder;
|
||||
module.exports.OpusDecoder = OpusDecoder;
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
///<reference path="d.ts/asm.d.ts" />
|
||||
///<reference path="d.ts/libspeexdsp.d.ts" />
|
||||
|
||||
var native = require("./libopus_libspeexdsp");
|
||||
|
||||
var SpeexResampler = (function () {
|
||||
function SpeexResampler(channels, in_rate, out_rate, bits_per_sample, is_float, quality) {
|
||||
if (quality === void 0) { quality = 5; }
|
||||
this.handle = 0;
|
||||
this.in_ptr = 0;
|
||||
this.out_ptr = 0;
|
||||
this.in_capacity = 0;
|
||||
this.in_len_ptr = 0;
|
||||
this.out_len_ptr = 0;
|
||||
this.channels = channels;
|
||||
this.in_rate = in_rate;
|
||||
this.out_rate = out_rate;
|
||||
this.bits_per_sample = bits_per_sample;
|
||||
var bytes = bits_per_sample / 8;
|
||||
if (bits_per_sample % 8 != 0 || bytes < 1 || bytes > 4)
|
||||
throw 'argument error: bits_per_sample = ' + bits_per_sample;
|
||||
if (is_float && bits_per_sample != 32)
|
||||
throw 'argument error: if is_float=true, bits_per_sample must be 32';
|
||||
var err_ptr = native.allocate(4, 'i32', native.ALLOC_STACK);
|
||||
this.handle = native._speex_resampler_init(channels, in_rate, out_rate, quality, err_ptr);
|
||||
if (native.getValue(err_ptr, 'i32') != 0)
|
||||
throw 'speex_resampler_init failed: ret=' + native.getValue(err_ptr, 'i32');
|
||||
if (!is_float) {
|
||||
if (bits_per_sample == 8)
|
||||
this.copy_to_buf = this._from_i8;
|
||||
else if (bits_per_sample == 16) {
|
||||
this.copy_to_buf = this._from_i16;
|
||||
}
|
||||
else if (bits_per_sample == 24)
|
||||
this.copy_to_buf = this._from_i24;
|
||||
else if (bits_per_sample == 32)
|
||||
this.copy_to_buf = this._from_i32;
|
||||
}
|
||||
else {
|
||||
this.copy_to_buf = this._from_f32;
|
||||
}
|
||||
this.in_len_ptr = native._malloc(4);
|
||||
this.out_len_ptr = native._malloc(4);
|
||||
}
|
||||
SpeexResampler.prototype.process = function (raw_input) {
|
||||
if (!this.handle)
|
||||
throw 'disposed object';
|
||||
var samples = (raw_input.byteLength / (this.bits_per_sample / 8) / this.channels);
|
||||
var outSamples = Math.ceil(samples * this.out_rate / this.in_rate);
|
||||
var requireSize = samples * 4;
|
||||
if (this.in_capacity < requireSize) {
|
||||
if (this.in_ptr)
|
||||
native._free(this.in_ptr);
|
||||
if (this.out_ptr)
|
||||
native._free(this.out_ptr);
|
||||
this.in_ptr = native._malloc(requireSize);
|
||||
this.out_ptr = native._malloc(outSamples * 4);
|
||||
this.in_capacity = requireSize;
|
||||
}
|
||||
var results = [];
|
||||
for (var ch = 0; ch < this.channels; ++ch) {
|
||||
this.copy_to_buf(raw_input, ch, samples);
|
||||
native.setValue(this.in_len_ptr, samples, 'i32');
|
||||
native.setValue(this.out_len_ptr, outSamples, 'i32');
|
||||
var ret = native._speex_resampler_process_float(this.handle, ch, this.in_ptr, this.in_len_ptr, this.out_ptr, this.out_len_ptr);
|
||||
if (ret != 0)
|
||||
throw 'speex_resampler_process_float failed: ' + ret;
|
||||
var ret_samples = native.getValue(this.out_len_ptr, 'i32');
|
||||
var ary = new Float32Array(ret_samples);
|
||||
ary.set(native.HEAPF32.subarray(this.out_ptr >> 2, (this.out_ptr >> 2) + ret_samples));
|
||||
results.push(ary);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
SpeexResampler.prototype.process_interleaved = function (raw_input) {
|
||||
if (!this.handle)
|
||||
throw 'disposed object';
|
||||
var samples = raw_input.byteLength / (this.bits_per_sample / 8);
|
||||
var outSamples = Math.ceil(samples * this.out_rate / this.in_rate);
|
||||
var requireSize = samples * 4;
|
||||
if (this.in_capacity < requireSize) {
|
||||
if (this.in_ptr)
|
||||
native._free(this.in_ptr);
|
||||
if (this.out_ptr)
|
||||
native._free(this.out_ptr);
|
||||
this.in_ptr = native._malloc(requireSize);
|
||||
this.out_ptr = native._malloc(outSamples * 4);
|
||||
this.in_capacity = requireSize;
|
||||
}
|
||||
this.copy_to_buf(raw_input, -1, samples);
|
||||
native.setValue(this.in_len_ptr, samples / this.channels, 'i32');
|
||||
native.setValue(this.out_len_ptr, outSamples / this.channels, 'i32');
|
||||
var ret = native._speex_resampler_process_interleaved_float(this.handle, this.in_ptr, this.in_len_ptr, this.out_ptr, this.out_len_ptr);
|
||||
if (ret != 0)
|
||||
throw 'speex_resampler_process_interleaved_float failed: ' + ret;
|
||||
var ret_samples = native.getValue(this.out_len_ptr, 'i32') * this.channels;
|
||||
var result = new Float32Array(ret_samples);
|
||||
result.set(native.HEAPF32.subarray(this.out_ptr >> 2, (this.out_ptr >> 2) + ret_samples));
|
||||
return result;
|
||||
};
|
||||
SpeexResampler.prototype.destroy = function () {
|
||||
if (!this.handle)
|
||||
return;
|
||||
native._speex_resampler_destroy(this.handle);
|
||||
this.handle = 0;
|
||||
native._free(this.in_len_ptr);
|
||||
native._free(this.out_len_ptr);
|
||||
if (this.in_ptr)
|
||||
native._free(this.in_ptr);
|
||||
if (this.out_ptr)
|
||||
native._free(this.out_ptr);
|
||||
this.in_len_ptr = this.out_len_ptr = this.in_ptr = this.out_ptr = 0;
|
||||
};
|
||||
SpeexResampler.prototype._from_i8 = function (raw_input, ch, samples) {
|
||||
var input = new Int8Array(raw_input);
|
||||
};
|
||||
SpeexResampler.prototype._from_i16 = function (raw_input, ch, samples) {
|
||||
var input = new Int16Array(raw_input);
|
||||
var off = this.in_ptr >> 2;
|
||||
if (ch >= 0) {
|
||||
var tc = this.channels;
|
||||
for (var i = 0; i < samples; ++i)
|
||||
native.HEAPF32[off + i] = input[i * tc + ch] / 32768.0;
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < samples; ++i)
|
||||
native.HEAPF32[off + i] = input[i] / 32768.0;
|
||||
}
|
||||
};
|
||||
SpeexResampler.prototype._from_i24 = function (raw_input, ch, samples) {
|
||||
var input = new Uint8Array(raw_input);
|
||||
};
|
||||
SpeexResampler.prototype._from_i32 = function (raw_input, ch, samples) {
|
||||
var input = new Int32Array(raw_input);
|
||||
};
|
||||
SpeexResampler.prototype._from_f32 = function (raw_input, ch, samples) {
|
||||
var input = new Float32Array(raw_input);
|
||||
var off = this.in_ptr >> 2;
|
||||
if (ch >= 0) {
|
||||
var tc = this.channels;
|
||||
for (var i = 0; i < samples; ++i)
|
||||
native.HEAPF32[off + i] = input[i * tc + ch];
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < samples; ++i)
|
||||
native.HEAPF32[off + i] = input[i];
|
||||
}
|
||||
};
|
||||
return SpeexResampler;
|
||||
})();
|
||||
|
||||
module.exports.SpeexResampler = SpeexResampler;
|
||||
Reference in new issue
Block a user