mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-15 18:57:12 +01:00
2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
|
(()=>{var e={5745:function(e,t,r){var n="/",i=void 0!==i?i:{};"undefined"!=typeof self&&self,e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){(function(t){var r,n,o=new Promise((function(e){n=e}));t.onmessage=function(e){o.then((function(){switch(e.data.command){case"decode":r&&r.decode(e.data.pages);break;case"done":r&&(r.sendLastBuffer(),t.close());break;case"init":r=new s(e.data,i)}}))};var s=function(e,t){if(!t)throw new Error("Module with exports required to initialize a decoder instance");this.mainReady=o,this.config=Object.assign({bufferLength:4096,decoderSampleRate:48e3,outputBufferSampleRate:48e3,resampleQuality:3},e),this._opus_decoder_create=t._opus_decoder_create,this._opus_decoder_destroy=t._opus_decoder_destroy,this._speex_resampler_process_interleaved_float=t._speex_resampler_process_interleaved_float,this._speex_resampler_init=t._speex_resampler_init,this._speex_resampler_destroy=t._speex_resampler_destroy,this._opus_decode_float=t._opus_decode_float,this._free=t._free,this._malloc=t._malloc,this.HEAPU8=t.HEAPU8,this.HEAP16=t.HEAP16,this.HEAP32=t.HEAP32,this.HEAPF32=t.HEAPF32,this.outputBuffers=[]};s.prototype.decode=function(e){var t=new DataView(e.buffer),r=this.getPageBoundaries(t),n=r.length-1;r.map((function(r,i){var o=t.getUint8(r+5,!0),s=t.getUint32(r+18,!0);if(2&o&&(this.numberOfChannels=t.getUint8(r+37,!0),this.init()),s>1){for(var u=t.getUint8(r+26,!0),a=r+27+u,f=0;f<u;f++){var c=t.getUint8(r+27+f,!0);if(this.decoderBuffer.set(e.subarray(a,a+=c),this.decoderBufferIndex),this.decoderBufferIndex+=c,c<255){var l=this._opus_decode_float(this.decoder,this.decoderBufferPointer,this.decoderBufferIndex,this.decoderOutputPointer,this.decoderOutputMaxLength,0),h=Math.ceil(l*this.config.outputBufferSampleRate/this.config.decoderSampleRate);this.HEAP32[this.decoderOutputLengthPointer>>2]=l,this.HEAP32[this.resampleOutputLengthPointer>>2]=h,this._speex_resampler_process_interleaved_float(this.resampler,this.decoderOutputPointer,this.decoderOutputLengthPointer,this.resampleOutputBufferPointer,this.resampleOutputLengthPointer),this.sendToOutputBuffers(this.HEAPF32.subarray(this.resampleOutputBufferPointer>>2,(this.resampleOutputBufferPointer>>2)+h*this.numberOfChannels)),this.decoderBufferIndex=0}}(4&o||i==n)&&this.sendLastBuffer()}}),this)},s.prototype.getPageBoundaries=function(e){for(var t=[],r=0;r<e.byteLength-32;r++)1399285583==e.getUint32(r,!0)&&t.push(r);return t},s.prototype.init=function(){this.resetOutputBuffers(),this.initCodec(),this.initResampler()},s.prototype.initCodec=function(){this.decoder&&(this._opus_decoder_destroy(this.decoder),this._free(this.decoderBufferPointer),this._free(this.decoderOutputLengthPointer),this._free(this.decoderOutputPointer));var e=this._malloc(4);this.decoder=this._opus_decoder_create(this.config.decoderSampleRate,this.numberOfChannels,e),this._free(e),this.decoderBufferMaxLength=4e3,this.decoderBufferPointer=this._malloc(this.decoderBufferMaxLength),this.decoderBuffer=this.HEAPU8.subarray(this.decoderBufferPointer,this.decoderBufferPointer+this.decoderBufferMaxLength),this.decoderBufferIndex=0,this.decoderOutputLengthPointer=this._malloc(4),this.decoderOutputMaxLength=this.config.decoder
|
||
|
//# sourceMappingURL=745.9316c5c2b711c39a20a5.js.map
|