@cycjimmy/jsmpeg-player
Version:
MPEG1 Video Player Based On JSMpeg
6 lines • 125 kB
JavaScript
/*!
* @cycjimmy/jsmpeg-player v6.1.2
* Homepage: https://github.com/cycjimmy/jsmpeg-player#readme
* Released under the MIT License.
*/
!function(A,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(A="undefined"!=typeof globalThis?globalThis:A||self).JSMpeg=t()}(this,(function(){"use strict";function A(){return A=Object.assign?Object.assign.bind():function(A){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var e in i)({}).hasOwnProperty.call(i,e)&&(A[e]=i[e])}return A},A.apply(null,arguments)}function t(A,t){A.prototype=Object.create(t.prototype),A.prototype.constructor=A,i(A,t)}function i(A,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(A,t){return A.__proto__=t,A},i(A,t)}var e=A=>"string"==typeof A&&A.constructor===String,s=function(A){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return t=A,"Promise"===Object.prototype.toString.call(t).slice(8,-1)?A:new Promise((t=>{A(),setTimeout(t,i)}))};var I="WJ3NAvwFY9",o="tR2-0dd-e1",g="ZgIIHVSSYI",a="kAA8SjbHe2",B="OueN4AU4CJ";!function(A,t){void 0===t&&(t={});var i=t.insertAt;if("undefined"!=typeof document){var e=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css","top"===i&&e.firstChild?e.insertBefore(s,e.firstChild):e.appendChild(s),s.styleSheet?s.styleSheet.cssText=A:s.appendChild(document.createTextNode(A))}}(".WJ3NAvwFY9,.ZgIIHVSSYI,.kAA8SjbHe2,.tR2-0dd-e1{height:100%;left:0;position:absolute;top:0;width:100%;z-index:1}.ZgIIHVSSYI{-ms-flex-pack:center;-ms-flex-align:center;-webkit-align-items:center;align-items:center;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:center;justify-content:center}.WJ3NAvwFY9,.tR2-0dd-e1{display:block}.tR2-0dd-e1.OueN4AU4CJ{display:none}.ZgIIHVSSYI,.kAA8SjbHe2{-webkit-tap-highlight-color:rgba(255,0,0,0);cursor:pointer;opacity:.7}.OueN4AU4CJ.ZgIIHVSSYI,.OueN4AU4CJ.kAA8SjbHe2{display:none}.ZgIIHVSSYI{z-index:10}.ZgIIHVSSYI>svg{fill:#fff;height:12vw;max-height:60px;max-width:60px;width:12vw}.kAA8SjbHe2{-ms-flex-pack:end;-ms-flex-align:end;-webkit-align-items:flex-end;align-items:flex-end;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:flex-end;justify-content:flex-end;z-index:10}.kAA8SjbHe2>svg{fill:#fff;height:9vw;margin:0 15px 15px 0;max-height:40px;max-width:40px;width:9vw}");var C=function(){function t(t,i,s,I){var o=void 0===s?{}:s,g=o.canvas,a=void 0===g?"":g,B=o.poster,C=void 0===B?"":B,Q=o.autoplay,E=void 0!==Q&&Q,r=o.autoSetWrapperSize,n=void 0!==r&&r,h=o.loop,d=void 0!==h&&h,c=o.control,l=void 0===c||c,u=o.decodeFirstFrame,w=void 0===u||u,D=o.picMode,p=void 0!==D&&D,f=o.progressive,m=void 0===f||f,y=o.chunkSize,R=void 0===y?1048576:y,k=o.hooks,b=void 0===k?{}:k;void 0===I&&(I={}),this.options=A({videoUrl:i,canvas:a,poster:C,picMode:p,autoplay:E,autoSetWrapperSize:n,loop:d,control:l,decodeFirstFrame:w,progressive:m,chunkSize:R,hooks:A({play:function(){},pause:function(){},stop:function(){},load:function(){}},b)},I),this.options.needPlayButton=this.options.control&&!this.options.picMode,this.player=null,this.els={wrapper:e(t)?document.querySelector(t):t,canvas:null,playButton:document.createElement("div"),unmuteButton:null,poster:null},"static"===window.getComputedStyle(this.els.wrapper).getPropertyValue("position")&&(this.els.wrapper.style.position="relative"),this.els.wrapper.clientRect=this.els.wrapper.getBoundingClientRect(),this.initCanvas(),this.initPlayButton(),this.initPlayer()}var i=t.prototype;return i.initCanvas=function(){this.options.canvas?this.els.canvas=e(this.options.canvas)?document.querySelector(this.options.canvas):this.options.canvas:(this.els.canvas=document.createElement("canvas"),this.els.canvas.classList.add(I),this.els.wrapper.appendChild(this.els.canvas))},i.initPlayer=function(){var t=this;this.options=A(this.options,{canvas:this.els.canvas});var i=A({},this.options,{autoplay:!1});if(this.player=new G(this.options.videoUrl,i,{play:function(){t.options.needPlayButton&&t.els.playButton.classList.add(B),t.els.poster&&t.els.poster.classList.add(B),t.options.hooks.play()},pause:function(){t.options.needPlayButton&&t.els.playButton.classList.remove(B),t.options.hooks.pause()},stop:function(){t.els.poster&&t.els.poster.classList.remove(B),t.options.hooks.stop()},load:function(){t.options.autoplay&&t.play(),t._autoSetWrapperSize(),t.options.hooks.load()}}),this._copyPlayerFuncs(),this.els.wrapper.playerInstance=this.player,!this.options.poster||this.options.autoplay||this.player.options.streaming||(this.options.decodeFirstFrame=!1,this.els.poster=new Image,this.els.poster.src=this.options.poster,this.els.poster.classList.add(o),this.els.wrapper.appendChild(this.els.poster)),this.player.options.streaming||this.els.wrapper.addEventListener("click",this.onClick.bind(this)),(this.options.autoplay||this.player.options.streaming)&&this.els.playButton.classList.add(B),this.player.audioOut&&!this.player.audioOut.unlocked){var e=this.els.wrapper;(this.options.autoplay||this.player.options.streaming)&&(this.els.unmuteButton=document.createElement("div"),this.els.unmuteButton.innerHTML='\n<svg viewBox="0 0 64 64">\n <path d="M58.3,45.5l-4.8-4.3c1.4-2.9,2.2-6.2,2.2-9.6c0-11.1-8.2-20.3-18.9-21.9V3.3C50.9,4.9,62,16.9,62,31.6 C62,36.6,60.6,41.4,58.3,45.5L58.3,45.5z M30.4,5.6v15.2l-8.3-7.3L30.4,5.6L30.4,5.6z M36.7,19.9c4.6,1.9,7.9,6.4,7.9,11.7 c0,0.6-0.1,1.1-0.1,1.7l-7.8-6.9V19.9L36.7,19.9z M57.5,60.7l-7.1-6.3c-3.9,2.9-8.6,4.8-13.7,5.4v-6.4c3.2-0.5,6.2-1.7,8.8-3.4 l-8.1-7.2c-0.2,0.1-0.5,0.3-0.7,0.4v-1l-6.3-5.6v20.2L15.4,42.6H2V20.5h10.2l-9.7-8.6l4.2-4.7L61.7,56L57.5,60.7L57.5,60.7z"/>\n</svg>\n',this.els.unmuteButton.classList.add(a),this.els.wrapper.appendChild(this.els.unmuteButton),e=this.els.unmuteButton),this.unlockAudioBound=this.onUnlockAudio.bind(this,e),e.addEventListener("touchstart",this.unlockAudioBound,!1),e.addEventListener("click",this.unlockAudioBound,!0)}},i.initPlayButton=function(){this.options.needPlayButton&&(this.els.playButton.classList.add(g),this.els.playButton.innerHTML='\n<svg viewBox="0 0 64 64">\n <path d="M26,45.5L44,32L26,18.6v27V45.5L26,45.5z M32,2C15.4,2,2,15.5,2,32c0,16.6,13.4,30,30,30c16.6,0,30-13.4,30-30 C62,15.4,48.5,2,32,2L32,2z M32,56c-9.7,0-18.5-5.9-22.2-14.8C6.1,32.2,8.1,21.9,15,15c6.9-6.9,17.2-8.9,26.2-5.2 C50.1,13.5,56,22.3,56,32C56,45.3,45.2,56,32,56L32,56z"/>\n</svg>\n',this.els.wrapper.appendChild(this.els.playButton))},i._autoSetWrapperSize=function(){var A=this;if(!this.options.autoSetWrapperSize)return Promise.resolve();var t=this.player.video.destination;return t?Promise.resolve().then((function(){return s((function(){A.els.wrapper.style.width=t.width+"px",A.els.wrapper.style.height=t.height+"px"}))})):Promise.resolve()},i.onUnlockAudio=function(A,t){var i=this;this.els.unmuteButton&&(t.preventDefault(),t.stopPropagation()),this.player.audioOut.unlock((function(){i.els.unmuteButton&&i.els.unmuteButton.classList.add(B),A.removeEventListener("touchstart",i.unlockAudioBound),A.removeEventListener("click",i.unlockAudioBound)}))},i.onClick=function(){this.options.control&&(this.player.isPlaying?this.pause():this.play())},i._copyPlayerFuncs=function(){var A=this;this.play=function(){return A.player.play()},this.pause=function(){return A.player.pause()},this.stop=function(){return A.player.stop()},this.destroy=function(){A.player.destroy(),A.els.wrapper.innerHTML="",A.els.wrapper.playerInstance=null}},t}(),Q=function(){return window.performance?window.performance.now()/1e3:Date.now()/1e3},E=function(A,t){if(A.fill)A.fill(t);else for(var i=0;i<A.length;i++)A[i]=t},r=function(A){for(var t=window.atob(A),i=t.length,e=new Uint8Array(i),s=0;s<i;s++)e[s]=t.charCodeAt(s);return e.buffer},n=function(){function A(A,t){this.url=A,this.destination=null,this.request=null,this.streaming=!1,this.completed=!1,this.established=!1,this.progress=0,this.onEstablishedCallback=t.onSourceEstablished,this.onCompletedCallback=t.onSourceCompleted,t.hookOnEstablished&&(this.hookOnEstablished=t.hookOnEstablished)}var t=A.prototype;return t.connect=function(A){this.destination=A},t.start=function(){this.request=new XMLHttpRequest,this.request.onreadystatechange=function(){this.request.readyState===this.request.DONE&&200===this.request.status&&this.onLoad(this.request.response)}.bind(this),this.request.onprogress=this.onProgress.bind(this),this.request.open("GET",this.url),this.request.responseType="arraybuffer",this.request.send()},t.resume=function(){},t.destroy=function(){this.request.abort()},t.onProgress=function(A){this.progress=A.loaded/A.total},t.onLoad=function(A){this.established=!0,this.completed=!0,this.progress=1,this.hookOnEstablished&&this.hookOnEstablished(),this.onEstablishedCallback&&this.onEstablishedCallback(this),this.onCompletedCallback&&this.onCompletedCallback(this),this.destination&&this.destination.write(A)},A}(),h=function(){function A(A,t){this.url=A,this.destination=null,this.request=null,this.streaming=!1,this.completed=!1,this.established=!1,this.progress=0,this.fileSize=0,this.loadedSize=0,this.chunkSize=t.chunkSize||1048576,this.isLoading=!1,this.loadStartTime=0,this.throttled=!1!==t.throttled,this.aborted=!1,this.onEstablishedCallback=t.onSourceEstablished,this.onCompletedCallback=t.onSourceCompleted,t.hookOnEstablished&&(this.hookOnEstablished=t.hookOnEstablished)}var t=A.prototype;return t.connect=function(A){this.destination=A},t.start=function(){var A=this;this.request=new XMLHttpRequest,this.request.onreadystatechange=function(){A.request.readyState===A.request.DONE&&(A.fileSize=parseInt(A.request.getResponseHeader("Content-Length"),10),A.loadNextChunk())},this.request.onprogress=this.onProgress.bind(this),this.request.open("HEAD",this.url),this.request.send()},t.resume=function(A){!this.isLoading&&this.throttled&&(8*this.loadTime+2>A&&this.loadNextChunk())},t.destroy=function(){this.request.abort(),this.aborted=!0},t.loadNextChunk=function(){var A=this,t=this.loadedSize,i=Math.min(this.loadedSize+this.chunkSize-1,this.fileSize-1);if(t>=this.fileSize||this.aborted)return this.completed=!0,void(this.onCompletedCallback&&this.onCompletedCallback(this));this.isLoading=!0,this.loadStartTime=Q(),this.request=new XMLHttpRequest,this.request.onreadystatechange=function(){A.request.readyState===A.request.DONE&&A.request.status>=200&&A.request.status<300?A.onChunkLoad(A.request.response):A.request.readyState===A.request.DONE&&A.loadFails++<3&&A.loadNextChunk()},0===t&&(this.request.onprogress=this.onProgress.bind(this)),this.request.open("GET",this.url+"?"+t+"-"+i),this.request.setRequestHeader("Range","bytes="+t+"-"+i),this.request.responseType="arraybuffer",this.request.send()},t.onProgress=function(A){this.progress=A.loaded/A.total},t.onChunkLoad=function(A){var t=!this.established;this.established=!0,this.progress=1,this.loadedSize+=A.byteLength,this.loadFails=0,this.isLoading=!1,t&&this.hookOnEstablished&&this.hookOnEstablished(),t&&this.onEstablishedCallback&&this.onEstablishedCallback(this),this.destination&&this.destination.write(A),this.loadTime=Q()-this.loadStartTime,this.throttled||this.loadNextChunk()},A}(),d=function(){function A(A,t){this.url=A,this.options=t,this.socket=null,this.streaming=!0,this.callbacks={connect:[],data:[]},this.destination=null,this.reconnectInterval=void 0!==t.reconnectInterval?t.reconnectInterval:5,this.shouldAttemptReconnect=!!this.reconnectInterval,this.completed=!1,this.established=!1,this.progress=0,this.reconnectTimeoutId=0,this.onEstablishedCallback=t.onSourceEstablished,this.onCompletedCallback=t.onSourceCompleted,t.hookOnEstablished&&(this.hookOnEstablished=t.hookOnEstablished)}var t=A.prototype;return t.connect=function(A){this.destination=A},t.destroy=function(){clearTimeout(this.reconnectTimeoutId),this.shouldAttemptReconnect=!1,this.socket.close()},t.start=function(){this.shouldAttemptReconnect=!!this.reconnectInterval,this.progress=0,this.established=!1,this.options.protocols?this.socket=new WebSocket(this.url,this.options.protocols):this.socket=new WebSocket(this.url),this.socket.binaryType="arraybuffer",this.socket.onmessage=this.onMessage.bind(this),this.socket.onopen=this.onOpen.bind(this),this.socket.onerror=this.onClose.bind(this),this.socket.onclose=this.onClose.bind(this)},t.resume=function(){},t.onOpen=function(){this.progress=1},t.onClose=function(){var A=this;this.shouldAttemptReconnect&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=setTimeout((function(){A.start()}),1e3*this.reconnectInterval))},t.onMessage=function(A){var t=!this.established;this.established=!0,t&&this.hookOnEstablished&&this.hookOnEstablished(),t&&this.onEstablishedCallback&&this.onEstablishedCallback(this),this.destination&&this.destination.write(A.data)},A}(),c=function(){function A(t,i){"object"==typeof t?(this.bytes=t instanceof Uint8Array?t:new Uint8Array(t),this.byteLength=this.bytes.length):(this.bytes=new Uint8Array(t||1048576),this.byteLength=0),this.mode=i||A.MODE.EXPAND,this.index=0}var t=A.prototype;return t.resize=function(A){var t=new Uint8Array(A);0!==this.byteLength&&(this.byteLength=Math.min(this.byteLength,A),t.set(this.bytes,0,this.byteLength)),this.bytes=t,this.index=Math.min(this.index,this.byteLength<<3)},t.evict=function(A){var t=this.index>>3,i=this.bytes.length-this.byteLength;if(this.index===this.byteLength<<3||A>i+t)return this.byteLength=0,void(this.index=0);0!==t&&(this.bytes.copyWithin?this.bytes.copyWithin(0,t,this.byteLength):this.bytes.set(this.bytes.subarray(t,this.byteLength)),this.byteLength-=t,this.index-=t<<3)},t.write=function(t){var i="object"==typeof t[0],e=0,s=this.bytes.length-this.byteLength;if(i){e=0;for(var I=0;I<t.length;I++)e+=t[I].byteLength}else e=t.byteLength;if(e>s)if(this.mode===A.MODE.EXPAND){var o=Math.max(2*this.bytes.length,e-s);this.resize(o)}else this.evict(e);if(i)for(var g=0;g<t.length;g++)this.appendSingleBuffer(t[g]);else this.appendSingleBuffer(t);return e},t.appendSingleBuffer=function(A){A=A instanceof Uint8Array?A:new Uint8Array(A),this.bytes.set(A,this.byteLength),this.byteLength+=A.length},t.findNextStartCode=function(){for(var A=this.index+7>>3;A<this.byteLength;A++)if(0===this.bytes[A]&&0===this.bytes[A+1]&&1===this.bytes[A+2])return this.index=A+4<<3,this.bytes[A+3];return this.index=this.byteLength<<3,-1},t.findStartCode=function(A){var t=this.findNextStartCode();return t===A||-1===t?t:-1},t.nextBytesAreStartCode=function(){var A=this.index+7>>3;return A>=this.byteLength||0===this.bytes[A]&&0===this.bytes[A+1]&&1===this.bytes[A+2]},t.peek=function(A){for(var t=this.index,i=0;A;){var e=8-(7&t),s=e<A?e:A,I=e-s;i=i<<s|(this.bytes[t>>3]&255>>8-s<<I)>>I,t+=s,A-=s}return i},t.read=function(A){var t=this.peek(A);return this.index+=A,t},t.skip=function(A){return this.index+=A},t.rewind=function(A){this.index=Math.max(this.index-A,0)},t.has=function(A){return(this.byteLength<<3)-this.index>=A},A}();c.MODE={EVICT:1,EXPAND:2};var l=function(){function A(){this.bits=null,this.leftoverBytes=null,this.guessVideoFrameEnd=!0,this.pidsToStreamIds={},this.pesPacketInfo={},this.startTime=0,this.currentTime=0}var t=A.prototype;return t.connect=function(A,t){this.pesPacketInfo[A]={destination:t,currentLength:0,totalLength:0,pts:0,buffers:[]}},t.write=function(A){if(this.leftoverBytes){var t=A.byteLength+this.leftoverBytes.byteLength;this.bits=new c(t),this.bits.write([this.leftoverBytes,A])}else this.bits=new c(A);for(;this.bits.has(1504)&&this.parsePacket(););var i=this.bits.byteLength-(this.bits.index>>3);this.leftoverBytes=i>0?this.bits.bytes.subarray(this.bits.index>>3):null},t.parsePacket=function(){if(71!==this.bits.read(8)&&!this.resync())return!1;var A=187+(this.bits.index>>3);this.bits.read(1);var t=this.bits.read(1);this.bits.read(1);var i=this.bits.read(13);this.bits.read(2);var e=this.bits.read(2);this.bits.read(4);var s=this.pidsToStreamIds[i];if(t&&s){var I=this.pesPacketInfo[s];I&&I.currentLength&&this.packetComplete(I)}if(1&e){if(2&e){var o=this.bits.read(8);this.bits.skip(o<<3)}if(t&&this.bits.nextBytesAreStartCode()){this.bits.skip(24),s=this.bits.read(8),this.pidsToStreamIds[i]=s;var g=this.bits.read(16);this.bits.skip(8);var a=this.bits.read(2);this.bits.skip(6);var B=this.bits.read(8),C=this.bits.index+(B<<3),Q=this.pesPacketInfo[s];if(Q){var E=0;if(2&a){this.bits.skip(4);var r=this.bits.read(3);this.bits.skip(1);var n=this.bits.read(15);this.bits.skip(1);var h=this.bits.read(15);this.bits.skip(1),E=(1073741824*r+32768*n+h)/9e4,this.currentTime=E,-1===this.startTime&&(this.startTime=E)}var d=g?g-B-3:0;this.packetStart(Q,E,d)}this.bits.index=C}if(s){var c=this.pesPacketInfo[s];if(c){var l=this.bits.index>>3,u=!t&&2&e;(this.packetAddData(c,l,A)||this.guessVideoFrameEnd&&u)&&this.packetComplete(c)}}}return this.bits.index=A<<3,!0},t.resync=function(){if(!this.bits.has(9024))return!1;for(var A=this.bits.index>>3,t=0;t<187;t++)if(71===this.bits.bytes[A+t]){for(var i=!0,e=1;e<5;e++)if(71!==this.bits.bytes[A+t+188*e]){i=!1;break}if(i)return this.bits.index=A+t+1<<3,!0}return this.bits.skip(1496),!1},t.packetStart=function(A,t,i){A.totalLength=i,A.currentLength=0,A.pts=t},t.packetAddData=function(A,t,i){return A.buffers.push(this.bits.bytes.subarray(t,i)),A.currentLength+=i-t,0!==A.totalLength&&A.currentLength>=A.totalLength},t.packetComplete=function(A){A.destination.write(A.pts,A.buffers),A.totalLength=0,A.currentLength=0,A.buffers=[]},A}();l.STREAM={PACK_HEADER:186,SYSTEM_HEADER:187,PROGRAM_MAP:188,PRIVATE_1:189,PADDING:190,PRIVATE_2:191,AUDIO_1:192,VIDEO_1:224,DIRECTORY:255};var u=function(){function A(A){this.destination=null,this.canPlay=!1,this.collectTimestamps=!A.streaming,this.bytesWritten=0,this.timestamps=[],this.timestampIndex=0,this.startTime=0,this.decodedTime=0,Object.defineProperty(this,"currentTime",{get:this.getCurrentTime})}var t=A.prototype;return t.destroy=function(){},t.connect=function(A){this.destination=A},t.bufferGetIndex=function(){return this.bits.index},t.bufferSetIndex=function(A){this.bits.index=A},t.bufferWrite=function(A){return this.bits.write(A)},t.write=function(A,t){this.collectTimestamps&&(0===this.timestamps.length&&(this.startTime=A,this.decodedTime=A),this.timestamps.push({index:this.bytesWritten<<3,time:A})),this.bytesWritten+=this.bufferWrite(t),this.canPlay=!0},t.seek=function(A){if(this.collectTimestamps){this.timestampIndex=0;for(var t=0;t<this.timestamps.length&&!(this.timestamps[t].time>A);t++)this.timestampIndex=t;var i=this.timestamps[this.timestampIndex];i?(this.bufferSetIndex(i.index),this.decodedTime=i.time):(this.bufferSetIndex(0),this.decodedTime=this.startTime)}},t.decode=function(){this.advanceDecodedTime(0)},t.advanceDecodedTime=function(A){if(this.collectTimestamps){for(var t=-1,i=this.bufferGetIndex(),e=this.timestampIndex;e<this.timestamps.length&&!(this.timestamps[e].index>i);e++)t=e;if(-1!==t&&t!==this.timestampIndex)return this.timestampIndex=t,void(this.decodedTime=this.timestamps[this.timestampIndex].time)}this.decodedTime+=A},t.getCurrentTime=function(){return this.decodedTime},A}(),w=function(A){function i(t){var i;(i=A.call(this,t)||this).onDecodeCallback=t.onVideoDecode;var e=t.videoBufferSize||524288,s=t.streaming?c.MODE.EVICT:c.MODE.EXPAND;return i.bits=new c(e,s),i.customIntraQuantMatrix=new Uint8Array(64),i.customNonIntraQuantMatrix=new Uint8Array(64),i.blockData=new Int32Array(64),i.currentFrame=0,i.decodeFirstFrame=!1!==t.decodeFirstFrame,i}t(i,A);var e=i.prototype;return e.write=function(A,t){if(u.prototype.write.call(this,A,t),!this.hasSequenceHeader){if(-1===this.bits.findStartCode(i.START.SEQUENCE))return!1;this.decodeSequenceHeader(),this.decodeFirstFrame&&this.decode()}},e.decode=function(){var A=Q();if(!this.hasSequenceHeader)return!1;if(-1===this.bits.findStartCode(i.START.PICTURE))return!1;this.decodePicture(),this.advanceDecodedTime(1/this.frameRate);var t=Q()-A;return this.onDecodeCallback&&this.onDecodeCallback(this,t),!0},e.readHuffman=function(A){var t=0;do{t=A[t+this.bits.read(1)]}while(t>=0&&0!==A[t]);return A[t+2]},e.decodeSequenceHeader=function(){var A=this.bits.read(12),t=this.bits.read(12);if(this.bits.skip(4),this.frameRate=i.PICTURE_RATE[this.bits.read(4)],this.bits.skip(30),A===this.width&&t===this.height||(this.width=A,this.height=t,this.initBuffers(),this.destination&&this.destination.resize(A,t)),this.bits.read(1)){for(var e=0;e<64;e++)this.customIntraQuantMatrix[i.ZIG_ZAG[e]]=this.bits.read(8);this.intraQuantMatrix=this.customIntraQuantMatrix}if(this.bits.read(1)){for(var s=0;s<64;s++){var I=i.ZIG_ZAG[s];this.customNonIntraQuantMatrix[I]=this.bits.read(8)}this.nonIntraQuantMatrix=this.customNonIntraQuantMatrix}this.hasSequenceHeader=!0},e.initBuffers=function(){this.intraQuantMatrix=i.DEFAULT_INTRA_QUANT_MATRIX,this.nonIntraQuantMatrix=i.DEFAULT_NON_INTRA_QUANT_MATRIX,this.mbWidth=this.width+15>>4,this.mbHeight=this.height+15>>4,this.mbSize=this.mbWidth*this.mbHeight,this.codedWidth=this.mbWidth<<4,this.codedHeight=this.mbHeight<<4,this.codedSize=this.codedWidth*this.codedHeight,this.halfWidth=this.mbWidth<<3,this.halfHeight=this.mbHeight<<3,this.currentY=new Uint8ClampedArray(this.codedSize),this.currentY32=new Uint32Array(this.currentY.buffer),this.currentCr=new Uint8ClampedArray(this.codedSize>>2),this.currentCr32=new Uint32Array(this.currentCr.buffer),this.currentCb=new Uint8ClampedArray(this.codedSize>>2),this.currentCb32=new Uint32Array(this.currentCb.buffer),this.forwardY=new Uint8ClampedArray(this.codedSize),this.forwardY32=new Uint32Array(this.forwardY.buffer),this.forwardCr=new Uint8ClampedArray(this.codedSize>>2),this.forwardCr32=new Uint32Array(this.forwardCr.buffer),this.forwardCb=new Uint8ClampedArray(this.codedSize>>2),this.forwardCb32=new Uint32Array(this.forwardCb.buffer)},e.decodePicture=function(){if(this.currentFrame++,this.bits.skip(10),this.pictureType=this.bits.read(3),this.bits.skip(16),!(this.pictureType<=0||this.pictureType>=i.PICTURE_TYPE.B)){if(this.pictureType===i.PICTURE_TYPE.PREDICTIVE){if(this.fullPelForward=this.bits.read(1),this.forwardFCode=this.bits.read(3),0===this.forwardFCode)return;this.forwardRSize=this.forwardFCode-1,this.forwardF=1<<this.forwardRSize}var A=0;do{A=this.bits.findNextStartCode()}while(A===i.START.EXTENSION||A===i.START.USER_DATA);for(;A>=i.START.SLICE_FIRST&&A<=i.START.SLICE_LAST;)this.decodeSlice(255&A),A=this.bits.findNextStartCode();if(-1!==A&&this.bits.rewind(32),this.destination&&this.destination.render(this.currentY,this.currentCr,this.currentCb,!0),this.pictureType===i.PICTURE_TYPE.INTRA||this.pictureType===i.PICTURE_TYPE.PREDICTIVE){var t=this.forwardY,e=this.forwardY32,s=this.forwardCr,I=this.forwardCr32,o=this.forwardCb,g=this.forwardCb32;this.forwardY=this.currentY,this.forwardY32=this.currentY32,this.forwardCr=this.currentCr,this.forwardCr32=this.currentCr32,this.forwardCb=this.currentCb,this.forwardCb32=this.currentCb32,this.currentY=t,this.currentY32=e,this.currentCr=s,this.currentCr32=I,this.currentCb=o,this.currentCb32=g}}},e.decodeSlice=function(A){for(this.sliceBegin=!0,this.macroblockAddress=(A-1)*this.mbWidth-1,this.motionFwH=this.motionFwHPrev=0,this.motionFwV=this.motionFwVPrev=0,this.dcPredictorY=128,this.dcPredictorCr=128,this.dcPredictorCb=128,this.quantizerScale=this.bits.read(5);this.bits.read(1);)this.bits.skip(8);do{this.decodeMacroblock()}while(!this.bits.nextBytesAreStartCode())},e.decodeMacroblock=function(){for(var A=0,t=this.readHuffman(i.MACROBLOCK_ADDRESS_INCREMENT);34===t;)t=this.readHuffman(i.MACROBLOCK_ADDRESS_INCREMENT);for(;35===t;)A+=33,t=this.readHuffman(i.MACROBLOCK_ADDRESS_INCREMENT);if(A+=t,this.sliceBegin)this.sliceBegin=!1,this.macroblockAddress+=A;else{if(this.macroblockAddress+A>=this.mbSize)return;for(A>1&&(this.dcPredictorY=128,this.dcPredictorCr=128,this.dcPredictorCb=128,this.pictureType===i.PICTURE_TYPE.PREDICTIVE&&(this.motionFwH=this.motionFwHPrev=0,this.motionFwV=this.motionFwVPrev=0));A>1;)this.macroblockAddress++,this.mbRow=this.macroblockAddress/this.mbWidth|0,this.mbCol=this.macroblockAddress%this.mbWidth,this.copyMacroblock(this.motionFwH,this.motionFwV,this.forwardY,this.forwardCr,this.forwardCb),A--;this.macroblockAddress++}this.mbRow=this.macroblockAddress/this.mbWidth|0,this.mbCol=this.macroblockAddress%this.mbWidth;var e=i.MACROBLOCK_TYPE[this.pictureType];this.macroblockType=this.readHuffman(e),this.macroblockIntra=1&this.macroblockType,this.macroblockMotFw=8&this.macroblockType,16&this.macroblockType&&(this.quantizerScale=this.bits.read(5)),this.macroblockIntra?(this.motionFwH=this.motionFwHPrev=0,this.motionFwV=this.motionFwVPrev=0):(this.dcPredictorY=128,this.dcPredictorCr=128,this.dcPredictorCb=128,this.decodeMotionVectors(),this.copyMacroblock(this.motionFwH,this.motionFwV,this.forwardY,this.forwardCr,this.forwardCb));for(var s=2&this.macroblockType?this.readHuffman(i.CODE_BLOCK_PATTERN):this.macroblockIntra?63:0,I=0,o=32;I<6;I++)s&o&&this.decodeBlock(I),o>>=1},e.decodeMotionVectors=function(){var A,t,e=0;this.macroblockMotFw?(0!==(A=this.readHuffman(i.MOTION))&&1!==this.forwardF?(e=this.bits.read(this.forwardRSize),t=(Math.abs(A)-1<<this.forwardRSize)+e+1,A<0&&(t=-t)):t=A,this.motionFwHPrev+=t,this.motionFwHPrev>(this.forwardF<<4)-1?this.motionFwHPrev-=this.forwardF<<5:this.motionFwHPrev<-this.forwardF<<4&&(this.motionFwHPrev+=this.forwardF<<5),this.motionFwH=this.motionFwHPrev,this.fullPelForward&&(this.motionFwH<<=1),0!==(A=this.readHuffman(i.MOTION))&&1!==this.forwardF?(e=this.bits.read(this.forwardRSize),t=(Math.abs(A)-1<<this.forwardRSize)+e+1,A<0&&(t=-t)):t=A,this.motionFwVPrev+=t,this.motionFwVPrev>(this.forwardF<<4)-1?this.motionFwVPrev-=this.forwardF<<5:this.motionFwVPrev<-this.forwardF<<4&&(this.motionFwVPrev+=this.forwardF<<5),this.motionFwV=this.motionFwVPrev,this.fullPelForward&&(this.motionFwV<<=1)):this.pictureType===i.PICTURE_TYPE.PREDICTIVE&&(this.motionFwH=this.motionFwHPrev=0,this.motionFwV=this.motionFwVPrev=0)},e.copyMacroblock=function(A,t,i,e,s){var I,o,g,a,B,C,Q,E,r,n,h,d,c,l,u,w,D,p,f,m=this.currentY32,y=this.currentCb32,R=this.currentCr32;if(o=(I=this.codedWidth)-16,g=A>>1,a=t>>1,B=!(1&~A),C=!(1&~t),Q=((this.mbRow<<4)+a)*I+(this.mbCol<<4)+g,r=(E=this.mbRow*I+this.mbCol<<2)+(I<<2),B)if(C)for(;E<r;){for(h=i[Q]+i[Q+I],Q++,n=0;n<4;n++)c=h+(d=i[Q]+i[Q+I])+2>>2&255,c|=(h=i[++Q]+i[Q+I])+d+2<<6&65280,c|=h+(d=i[++Q]+i[Q+I])+2<<14&16711680,h=i[++Q]+i[Q+I],Q++,c|=h+d+2<<22&4278190080,m[E++]=c;E+=o>>2,Q+=o-1}else for(;E<r;){for(h=i[Q++],n=0;n<4;n++)c=h+(d=i[Q++])+1>>1&255,c|=(h=i[Q++])+d+1<<7&65280,c|=h+(d=i[Q++])+1<<15&16711680,c|=(h=i[Q++])+d+1<<23&4278190080,m[E++]=c;E+=o>>2,Q+=o-1}else if(C)for(;E<r;){for(n=0;n<4;n++)c=i[Q]+i[Q+I]+1>>1&255,c|=i[++Q]+i[Q+I]+1<<7&65280,c|=i[++Q]+i[Q+I]+1<<15&16711680,c|=i[++Q]+i[Q+I]+1<<23&4278190080,Q++,m[E++]=c;E+=o>>2,Q+=o}else for(;E<r;){for(n=0;n<4;n++)c=i[Q],c|=i[++Q]<<8,c|=i[++Q]<<16,c|=i[++Q]<<24,Q++,m[E++]=c;E+=o>>2,Q+=o}if(o=(I=this.halfWidth)-8,g=A/2>>1,a=t/2>>1,B=1==(A/2&1),C=1==(t/2&1),Q=((this.mbRow<<3)+a)*I+(this.mbCol<<3)+g,r=(E=this.mbRow*I+this.mbCol<<1)+(I<<1),B)if(C)for(;E<r;){for(l=e[Q]+e[Q+I],D=s[Q]+s[Q+I],Q++,n=0;n<2;n++)w=l+(u=e[Q]+e[Q+I])+2>>2&255,f=D+(p=s[Q]+s[Q+I])+2>>2&255,w|=(l=e[++Q]+e[Q+I])+u+2<<6&65280,f|=(D=s[Q]+s[Q+I])+p+2<<6&65280,w|=l+(u=e[++Q]+e[Q+I])+2<<14&16711680,f|=D+(p=s[Q]+s[Q+I])+2<<14&16711680,l=e[++Q]+e[Q+I],D=s[Q]+s[Q+I],Q++,w|=l+u+2<<22&4278190080,f|=D+p+2<<22&4278190080,R[E]=w,y[E]=f,E++;E+=o>>2,Q+=o-1}else for(;E<r;){for(l=e[Q],D=s[Q],Q++,n=0;n<2;n++)w=l+(u=e[Q])+1>>1&255,f=D+(p=s[Q++])+1>>1&255,w|=(l=e[Q])+u+1<<7&65280,f|=(D=s[Q++])+p+1<<7&65280,w|=l+(u=e[Q])+1<<15&16711680,f|=D+(p=s[Q++])+1<<15&16711680,w|=(l=e[Q])+u+1<<23&4278190080,f|=(D=s[Q++])+p+1<<23&4278190080,R[E]=w,y[E]=f,E++;E+=o>>2,Q+=o-1}else if(C)for(;E<r;){for(n=0;n<2;n++)w=e[Q]+e[Q+I]+1>>1&255,f=s[Q]+s[Q+I]+1>>1&255,w|=e[++Q]+e[Q+I]+1<<7&65280,f|=s[Q]+s[Q+I]+1<<7&65280,w|=e[++Q]+e[Q+I]+1<<15&16711680,f|=s[Q]+s[Q+I]+1<<15&16711680,w|=e[++Q]+e[Q+I]+1<<23&4278190080,f|=s[Q]+s[Q+I]+1<<23&4278190080,Q++,R[E]=w,y[E]=f,E++;E+=o>>2,Q+=o}else for(;E<r;){for(n=0;n<2;n++)w=e[Q],f=s[Q],w|=e[++Q]<<8,f|=s[Q]<<8,w|=e[++Q]<<16,f|=s[Q]<<16,w|=e[++Q]<<24,f|=s[Q]<<24,Q++,R[E]=w,y[E]=f,E++;E+=o>>2,Q+=o}},e.decodeBlock=function(A){var t,e=0;if(this.macroblockIntra){var s,I;if(A<4?(s=this.dcPredictorY,I=this.readHuffman(i.DCT_DC_SIZE_LUMINANCE)):(s=4===A?this.dcPredictorCr:this.dcPredictorCb,I=this.readHuffman(i.DCT_DC_SIZE_CHROMINANCE)),I>0){var o=this.bits.read(I);this.blockData[0]=o&1<<I-1?s+o:s+(-1<<I|o+1)}else this.blockData[0]=s;A<4?this.dcPredictorY=this.blockData[0]:4===A?this.dcPredictorCr=this.blockData[0]:this.dcPredictorCb=this.blockData[0],this.blockData[0]<<=8,t=this.intraQuantMatrix,e=1}else t=this.nonIntraQuantMatrix;for(var g,a,B,C=0;;){var Q=0,r=this.readHuffman(i.DCT_COEFF);if(1===r&&e>0&&0===this.bits.read(1))break;65535===r?(Q=this.bits.read(6),0===(C=this.bits.read(8))?C=this.bits.read(8):128===C?C=this.bits.read(8)-256:C>128&&(C-=256)):(Q=r>>8,C=255&r,this.bits.read(1)&&(C=-C)),e+=Q;var n=i.ZIG_ZAG[e];e++,C<<=1,this.macroblockIntra||(C+=C<0?-1:1),1&(C=C*this.quantizerScale*t[n]>>4)||(C-=C>0?1:-1),C>2047?C=2047:C<-2048&&(C=-2048),this.blockData[n]=C*i.PREMULTIPLIER_MATRIX[n]}A<4?(g=this.currentY,B=this.codedWidth-8,a=this.mbRow*this.codedWidth+this.mbCol<<4,1&A&&(a+=8),2&A&&(a+=this.codedWidth<<3)):(g=4===A?this.currentCb:this.currentCr,B=(this.codedWidth>>1)-8,a=(this.mbRow*this.codedWidth<<2)+(this.mbCol<<3)),this.macroblockIntra?1===e?(i.CopyValueToDestination(this.blockData[0]+128>>8,g,a,B),this.blockData[0]=0):(i.IDCT(this.blockData),i.CopyBlockToDestination(this.blockData,g,a,B),E(this.blockData,0)):1===e?(i.AddValueToDestination(this.blockData[0]+128>>8,g,a,B),this.blockData[0]=0):(i.IDCT(this.blockData),i.AddBlockToDestination(this.blockData,g,a,B),E(this.blockData,0)),e=0},i.CopyBlockToDestination=function(A,t,i,e){for(var s=0;s<64;s+=8,i+=e+8)t[i+0]=A[s+0],t[i+1]=A[s+1],t[i+2]=A[s+2],t[i+3]=A[s+3],t[i+4]=A[s+4],t[i+5]=A[s+5],t[i+6]=A[s+6],t[i+7]=A[s+7]},i.AddBlockToDestination=function(A,t,i,e){for(var s=0;s<64;s+=8,i+=e+8)t[i+0]+=A[s+0],t[i+1]+=A[s+1],t[i+2]+=A[s+2],t[i+3]+=A[s+3],t[i+4]+=A[s+4],t[i+5]+=A[s+5],t[i+6]+=A[s+6],t[i+7]+=A[s+7]},i.CopyValueToDestination=function(A,t,i,e){for(var s=0;s<64;s+=8,i+=e+8)t[i+0]=A,t[i+1]=A,t[i+2]=A,t[i+3]=A,t[i+4]=A,t[i+5]=A,t[i+6]=A,t[i+7]=A},i.AddValueToDestination=function(A,t,i,e){for(var s=0;s<64;s+=8,i+=e+8)t[i+0]+=A,t[i+1]+=A,t[i+2]+=A,t[i+3]+=A,t[i+4]+=A,t[i+5]+=A,t[i+6]+=A,t[i+7]+=A},i.IDCT=function(A){for(var t,i,e,s,I,o,g,a,B,C,Q,E,r,n,h,d,c,l,u=0;u<8;++u)t=A[32+u],i=A[16+u]+A[48+u],e=A[40+u]-A[24+u],o=A[8+u]+A[56+u],g=A[24+u]+A[40+u],B=(r=(473*(s=A[8+u]-A[56+u])-196*e+128>>8)-(I=o+g))-(362*(o-g)+128>>8),n=(C=(a=A[0+u])-t)+(Q=(362*(A[16+u]-A[48+u])+128>>8)-i),h=(E=a+t)+i,d=C-Q,c=E-i,l=-B-(473*e+196*s+128>>8),A[0+u]=I+h,A[8+u]=r+n,A[16+u]=d-B,A[24+u]=c-l,A[32+u]=c+l,A[40+u]=B+d,A[48+u]=n-r,A[56+u]=h-I;for(var w=0;w<64;w+=8)t=A[4+w],i=A[2+w]+A[6+w],e=A[5+w]-A[3+w],o=A[1+w]+A[7+w],g=A[3+w]+A[5+w],B=(r=(473*(s=A[1+w]-A[7+w])-196*e+128>>8)-(I=o+g))-(362*(o-g)+128>>8),n=(C=(a=A[0+w])-t)+(Q=(362*(A[2+w]-A[6+w])+128>>8)-i),h=(E=a+t)+i,d=C-Q,c=E-i,l=-B-(473*e+196*s+128>>8),A[0+w]=I+h+128>>8,A[1+w]=r+n+128>>8,A[2+w]=d-B+128>>8,A[3+w]=c-l+128>>8,A[4+w]=c+l+128>>8,A[5+w]=B+d+128>>8,A[6+w]=n-r+128>>8,A[7+w]=h-I+128>>8},i}(u);w.prototype.frameRate=30,w.prototype.currentY=null,w.prototype.currentCr=null,w.prototype.currentCb=null,w.prototype.pictureType=0,w.prototype.forwardY=null,w.prototype.forwardCr=null,w.prototype.forwardCb=null,w.prototype.fullPelForward=!1,w.prototype.forwardFCode=0,w.prototype.forwardRSize=0,w.prototype.forwardF=0,w.prototype.quantizerScale=0,w.prototype.sliceBegin=!1,w.prototype.macroblockAddress=0,w.prototype.mbRow=0,w.prototype.mbCol=0,w.prototype.macroblockType=0,w.prototype.macroblockIntra=!1,w.prototype.macroblockMotFw=!1,w.prototype.motionFwH=0,w.prototype.motionFwV=0,w.prototype.motionFwHPrev=0,w.prototype.motionFwVPrev=0,w.prototype.dcPredictorY=0,w.prototype.dcPredictorCr=0,w.prototype.dcPredictorCb=0,w.prototype.blockData=null,w.PICTURE_RATE=[0,23.976,24,25,29.97,30,50,59.94,60,0,0,0,0,0,0,0],w.ZIG_ZAG=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),w.DEFAULT_INTRA_QUANT_MATRIX=new Uint8Array([8,16,19,22,26,27,29,34,16,16,22,24,27,29,34,37,19,22,26,27,29,34,34,38,22,22,26,27,29,34,37,40,22,26,27,29,32,35,40,48,26,27,29,32,35,40,48,58,26,27,29,34,38,46,56,69,27,29,35,38,46,56,69,83]),w.DEFAULT_NON_INTRA_QUANT_MATRIX=new Uint8Array([16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16]),w.PREMULTIPLIER_MATRIX=new Uint8Array([32,44,42,38,32,25,17,9,44,62,58,52,44,35,24,12,42,58,55,49,42,33,23,12,38,52,49,44,38,30,20,10,32,44,42,38,32,25,17,9,25,35,33,30,25,20,14,7,17,24,23,20,17,14,9,5,9,12,12,10,9,7,5,2]),w.MACROBLOCK_ADDRESS_INCREMENT=new Int16Array([3,6,0,9,12,0,0,0,1,15,18,0,21,24,0,27,30,0,33,36,0,0,0,3,0,0,2,39,42,0,45,48,0,0,0,5,0,0,4,51,54,0,57,60,0,0,0,7,0,0,6,63,66,0,69,72,0,75,78,0,81,84,0,-1,87,0,-1,90,0,93,96,0,99,102,0,105,108,0,111,114,0,0,0,9,0,0,8,117,120,0,123,126,0,129,132,0,135,138,0,0,0,15,0,0,14,0,0,13,0,0,12,0,0,11,0,0,10,141,-1,0,-1,144,0,147,150,0,153,156,0,159,162,0,165,168,0,171,174,0,177,180,0,183,-1,0,-1,186,0,189,192,0,195,198,0,201,204,0,207,210,0,213,216,0,219,222,0,0,0,21,0,0,20,0,0,19,0,0,18,0,0,17,0,0,16,0,0,35,0,0,34,0,0,33,0,0,32,0,0,31,0,0,30,0,0,29,0,0,28,0,0,27,0,0,26,0,0,25,0,0,24,0,0,23,0,0,22]),w.MACROBLOCK_TYPE_INTRA=new Int8Array([3,6,0,-1,9,0,0,0,1,0,0,17]),w.MACROBLOCK_TYPE_PREDICTIVE=new Int8Array([3,6,0,9,12,0,0,0,10,15,18,0,0,0,2,21,24,0,0,0,8,27,30,0,33,36,0,-1,39,0,0,0,18,0,0,26,0,0,1,0,0,17]),w.MACROBLOCK_TYPE_B=new Int8Array([3,6,0,9,15,0,12,18,0,24,21,0,0,0,12,27,30,0,0,0,14,39,42,0,36,33,0,0,0,4,0,0,6,54,48,0,45,51,0,0,0,8,0,0,10,-1,57,0,0,0,1,60,63,0,0,0,30,0,0,17,0,0,22,0,0,26]),w.MACROBLOCK_TYPE=[null,w.MACROBLOCK_TYPE_INTRA,w.MACROBLOCK_TYPE_PREDICTIVE,w.MACROBLOCK_TYPE_B],w.CODE_BLOCK_PATTERN=new Int16Array([6,3,0,9,18,0,12,15,0,24,33,0,36,39,0,27,21,0,30,42,0,60,57,0,54,48,0,69,51,0,81,75,0,63,84,0,45,66,0,72,78,0,0,0,60,105,120,0,132,144,0,114,108,0,126,141,0,87,93,0,117,96,0,0,0,32,135,138,0,99,123,0,129,102,0,0,0,4,90,111,0,0,0,8,0,0,16,0,0,44,150,168,0,0,0,28,0,0,52,0,0,62,183,177,0,156,180,0,0,0,1,165,162,0,0,0,61,0,0,56,171,174,0,0,0,2,0,0,40,153,186,0,0,0,48,192,189,0,147,159,0,0,0,20,0,0,12,240,249,0,0,0,63,231,225,0,195,219,0,252,198,0,0,0,24,0,0,36,0,0,3,207,261,0,243,237,0,204,213,0,210,234,0,201,228,0,216,222,0,258,255,0,264,246,0,-1,282,0,285,291,0,0,0,33,0,0,9,318,330,0,306,348,0,0,0,5,0,0,10,279,267,0,0,0,6,0,0,18,0,0,17,0,0,34,339,357,0,309,312,0,270,276,0,327,321,0,351,354,0,303,297,0,294,288,0,300,273,0,342,345,0,315,324,0,336,333,0,363,375,0,0,0,41,0,0,14,0,0,21,372,366,0,360,369,0,0,0,11,0,0,19,0,0,7,0,0,35,0,0,13,0,0,50,0,0,49,0,0,58,0,0,37,0,0,25,0,0,45,0,0,57,0,0,26,0,0,29,0,0,38,0,0,53,0,0,23,0,0,43,0,0,46,0,0,42,0,0,22,0,0,54,0,0,51,0,0,15,0,0,30,0,0,39,0,0,47,0,0,55,0,0,27,0,0,59,0,0,31]),w.MOTION=new Int16Array([3,6,0,12,9,0,0,0,0,18,15,0,24,21,0,0,0,-1,0,0,1,27,30,0,36,33,0,0,0,2,0,0,-2,42,45,0,48,39,0,60,54,0,0,0,3,0,0,-3,51,57,0,-1,69,0,81,75,0,78,63,0,72,66,0,96,84,0,87,93,0,-1,99,0,108,105,0,0,0,-4,90,102,0,0,0,4,0,0,-7,0,0,5,111,123,0,0,0,-5,0,0,7,114,120,0,126,117,0,0,0,-6,0,0,6,153,162,0,150,147,0,135,138,0,156,141,0,129,159,0,132,144,0,0,0,10,0,0,9,0,0,8,0,0,-8,171,198,0,0,0,-9,180,192,0,168,183,0,165,186,0,174,189,0,0,0,-10,177,195,0,0,0,12,0,0,16,0,0,13,0,0,14,0,0,11,0,0,15,0,0,-16,0,0,-12,0,0,-14,0,0,-15,0,0,-11,0,0,-13]),w.DCT_DC_SIZE_LUMINANCE=new Int8Array([6,3,0,18,15,0,9,12,0,0,0,1,0,0,2,27,24,0,21,30,0,0,0,0,36,33,0,0,0,4,0,0,3,39,42,0,0,0,5,0,0,6,48,45,0,51,-1,0,0,0,7,0,0,8]),w.DCT_DC_SIZE_CHROMINANCE=new Int8Array([6,3,0,12,9,0,18,15,0,24,21,0,0,0,2,0,0,1,0,0,0,30,27,0,0,0,3,36,33,0,0,0,4,42,39,0,0,0,5,48,45,0,0,0,6,51,-1,0,0,0,7,0,0,8]),w.DCT_COEFF=new Int32Array([3,6,0,12,9,0,0,0,1,21,24,0,18,15,0,39,27,0,33,30,0,42,36,0,0,0,257,60,66,0,54,63,0,48,57,0,0,0,513,51,45,0,0,0,2,0,0,3,81,75,0,87,93,0,72,78,0,96,90,0,0,0,1025,69,84,0,0,0,769,0,0,258,0,0,1793,0,0,65535,0,0,1537,111,108,0,0,0,1281,105,102,0,117,114,0,99,126,0,120,123,0,156,150,0,162,159,0,144,147,0,129,135,0,138,132,0,0,0,2049,0,0,4,0,0,514,0,0,2305,153,141,0,165,171,0,180,168,0,177,174,0,183,186,0,0,0,2561,0,0,3329,0,0,6,0,0,259,0,0,5,0,0,770,0,0,2817,0,0,3073,228,225,0,201,210,0,219,213,0,234,222,0,216,231,0,207,192,0,204,189,0,198,195,0,243,261,0,273,240,0,246,237,0,249,258,0,279,276,0,252,255,0,270,282,0,264,267,0,0,0,515,0,0,260,0,0,7,0,0,1026,0,0,1282,0,0,4097,0,0,3841,0,0,3585,315,321,0,333,342,0,312,291,0,375,357,0,288,294,0,-1,369,0,285,303,0,318,363,0,297,306,0,339,309,0,336,348,0,330,300,0,372,345,0,351,366,0,327,354,0,360,324,0,381,408,0,417,420,0,390,378,0,435,438,0,384,387,0,0,0,2050,396,402,0,465,462,0,0,0,8,411,399,0,429,432,0,453,414,0,426,423,0,0,0,10,0,0,9,0,0,11,0,0,5377,0,0,1538,0,0,771,0,0,5121,0,0,1794,0,0,4353,0,0,4609,0,0,4865,444,456,0,0,0,1027,459,450,0,0,0,261,393,405,0,0,0,516,447,441,0,516,519,0,486,474,0,510,483,0,504,498,0,471,537,0,507,501,0,522,513,0,534,531,0,468,477,0,492,495,0,549,546,0,525,528,0,0,0,263,0,0,2562,0,0,2306,0,0,5633,0,0,5889,0,0,6401,0,0,6145,0,0,1283,0,0,772,0,0,13,0,0,12,0,0,14,0,0,15,0,0,517,0,0,6657,0,0,262,540,543,0,480,489,0,588,597,0,0,0,27,609,555,0,606,603,0,0,0,19,0,0,22,591,621,0,0,0,18,573,576,0,564,570,0,0,0,20,552,582,0,0,0,21,558,579,0,0,0,23,612,594,0,0,0,25,0,0,24,600,615,0,0,0,31,0,0,30,0,0,28,0,0,29,0,0,26,0,0,17,0,0,16,567,618,0,561,585,0,654,633,0,0,0,37,645,648,0,0,0,36,630,636,0,0,0,34,639,627,0,663,666,0,657,624,0,651,642,0,669,660,0,0,0,35,0,0,267,0,0,40,0,0,268,0,0,266,0,0,32,0,0,264,0,0,265,0,0,38,0,0,269,0,0,270,0,0,33,0,0,39,0,0,7937,0,0,6913,0,0,7681,0,0,4098,0,0,7425,0,0,7169,0,0,271,0,0,274,0,0,273,0,0,272,0,0,1539,0,0,2818,0,0,3586,0,0,3330,0,0,3074,0,0,3842]),w.PICTURE_TYPE={INTRA:1,PREDICTIVE:2,B:3},w.START={SEQUENCE:179,SLICE_FIRST:1,SLICE_LAST:175,PICTURE:0,EXTENSION:181,USER_DATA:178};var D=function(A){function i(t){var i;return(i=A.call(this,t)||this).onDecodeCallback=t.onVideoDecode,i.module=t.wasmModule,i.bufferSize=t.videoBufferSize||524288,i.bufferMode=t.streaming?c.MODE.EVICT:c.MODE.EXPAND,i.decodeFirstFrame=!1!==t.decodeFirstFrame,i.hasSequenceHeader=!1,i}t(i,A);var e=i.prototype;return e.initializeWasmDecoder=function(){this.module.instance&&(this.instance=this.module.instance,this.functions=this.module.instance.exports,this.decoder=this.functions._mpeg1_decoder_create(this.bufferSize,this.bufferMode))},e.destroy=function(){this.decoder&&this.functions._mpeg1_decoder_destroy(this.decoder)},e.bufferGetIndex=function(){if(this.decoder)return this.functions._mpeg1_decoder_get_index(this.decoder)},e.bufferSetIndex=function(A){this.decoder&&this.functions._mpeg1_decoder_set_index(this.decoder,A)},e.bufferWrite=function(A){this.decoder||this.initializeWasmDecoder();for(var t=0,i=0;i<A.length;i++)t+=A[i].length;for(var e=this.functions._mpeg1_decoder_get_write_ptr(this.decoder,t),s=0;s<A.length;s++)this.instance.heapU8.set(A[s],e),e+=A[s].length;return this.functions._mpeg1_decoder_did_write(this.decoder,t),t},e.write=function(A,t){u.prototype.write.call(this,A,t),!this.hasSequenceHeader&&this.functions._mpeg1_decoder_has_sequence_header(this.decoder)&&this.loadSequenceHeader()},e.loadSequenceHeader=function(){if(this.hasSequenceHeader=!0,this.frameRate=this.functions._mpeg1_decoder_get_frame_rate(this.decoder),this.codedSize=this.functions._mpeg1_decoder_get_coded_size(this.decoder),this.destination){var A=this.functions._mpeg1_decoder_get_width(this.decoder),t=this.functions._mpeg1_decoder_get_height(this.decoder);this.destination.resize(A,t)}this.decodeFirstFrame&&this.decode()},e.decode=function(){var A=Q();if(!this.decoder)return!1;if(!this.functions._mpeg1_decoder_decode(this.decoder))return!1;if(this.destination){var t=this.functions._mpeg1_decoder_get_y_ptr(this.decoder),i=this.functions._mpeg1_decoder_get_cr_ptr(this.decoder),e=this.functions._mpeg1_decoder_get_cb_ptr(this.decoder),s=this.instance.heapU8.subarray(t,t+this.codedSize),I=this.instance.heapU8.subarray(i,i+(this.codedSize>>2)),o=this.instance.heapU8.subarray(e,e+(this.codedSize>>2));this.destination.render(s,I,o,!1)}this.advanceDecodedTime(1/this.frameRate);var g=Q()-A;return this.onDecodeCallback&&this.onDecodeCallback(this,g),!0},i}(u),p=function(A){function i(t){var e;(e=A.call(this,t)||this).onDecodeCallback=t.onAudioDecode;var s=t.audioBufferSize||131072,I=t.streaming?c.MODE.EVICT:c.MODE.EXPAND;e.bits=new c(s,I),e.left=new Float32Array(1152),e.right=new Float32Array(1152),e.sampleRate=44100,e.D=new Float32Array(1024),e.D.set(i.SYNTHESIS_WINDOW,0),e.D.set(i.SYNTHESIS_WINDOW,512),e.V=[new Float32Array(1024),new Float32Array(1024)],e.U=new Int32Array(32),e.VPos=0,e.allocation=[new Array(32),new Array(32)],e.scaleFactorInfo=[new Uint8Array(32),new Uint8Array(32)],e.scaleFactor=[new Array(32),new Array(32)],e.sample=[new Array(32),new Array(32)];for(var o=0;o<2;o++)for(var g=0;g<32;g++)e.scaleFactor[o][g]=[0,0,0],e.sample[o][g]=[0,0,0];return e}t(i,A);var e=i.prototype;return e.decode=function(){var A=Q(),t=this.bits.index>>3;if(t>=this.bits.byteLength)return!1;var i=this.decodeFrame(this.left,this.right);if(this.bits.index=t+i<<3,!i)return!1;this.destination&&this.destination.play(this.sampleRate,this.left,this.right),this.advanceDecodedTime(this.left.length/this.sampleRate);var e=Q()-A;return this.onDecodeCallback&&this.onDecodeCallback(this,e),!0},e.getCurrentTime=function(){var A=this.destination?this.destination.enqueuedTime:0;return this.decodedTime-A},e.decodeFrame=function(A,t){var e=this.bits.read(11),s=this.bits.read(2),I=this.bits.read(2),o=!this.bits.read(1);if(e!==i.FRAME_SYNC||s!==i.VERSION.MPEG_1||I!==i.LAYER.II)return 0;var g=this.bits.read(4)-1;if(g>13)return 0;var a=this.bits.read(2),B=i.SAMPLE_RATE[a];if(3===a)return 0;s===i.VERSION.MPEG_2&&(a+=4,g+=14);var C=this.bits.read(1);this.bits.read(1);var Q=this.bits.read(2),r=0;Q===i.MODE.JOINT_STEREO?r=this.bits.read(2)+1<<2:(this.bits.skip(2),r=Q===i.MODE.MONO?0:32),this.bits.skip(4),o&&this.bits.skip(16);var n=144e3*i.BIT_RATE[g]/(B=i.SAMPLE_RATE[a])+C|0,h=0,d=0;if(s===i.VERSION.MPEG_2)h=2,d=30;else{var c=Q===i.MODE.MONO?0:1,l=i.QUANT_LUT_STEP_1[c][g];d=63&(h=i.QUANT_LUT_STEP_2[l][a]),h>>=6}r>d&&(r=d);for(var u=0;u<r;u++)this.allocation[0][u]=this.readAllocation(u,h),this.allocation[1][u]=this.readAllocation(u,h);for(var w=r;w<d;w++)this.allocation[0][w]=this.allocation[1][w]=this.readAllocation(w,h);for(var D=Q===i.MODE.MONO?1:2,p=0;p<d;p++){for(var f=0;f<D;f++)this.allocation[f][p]&&(this.scaleFactorInfo[f][p]=this.bits.read(2));Q===i.MODE.MONO&&(this.scaleFactorInfo[1][p]=this.scaleFactorInfo[0][p])}for(var m=0;m<d;m++){for(var y=0;y<D;y++)if(this.allocation[y][m]){var R=this.scaleFactor[y][m];switch(this.scaleFactorInfo[y][m]){case 0:R[0]=this.bits.read(6),R[1]=this.bits.read(6),R[2]=this.bits.read(6);break;case 1:R[0]=R[1]=this.bits.read(6),R[2]=this.bits.read(6);break;case 2:R[0]=R[1]=R[2]=this.bits.read(6);break;case 3:R[0]=this.bits.read(6),R[1]=R[2]=this.bits.read(6)}}Q===i.MODE.MONO&&(this.scaleFactor[1][m][0]=this.scaleFactor[0][m][0],this.scaleFactor[1][m][1]=this.scaleFactor[0][m][1],this.scaleFactor[1][m][2]=this.scaleFactor[0][m][2])}for(var k=0,b=0;b<3;b++)for(var G=0;G<4;G++){for(var F=0;F<r;F++)this.readSamples(0,F,b),this.readSamples(1,F,b);for(var S=r;S<d;S++)this.readSamples(0,S,b),this.sample[1][S][0]=this.sample[0][S][0],this.sample[1][S][1]=this.sample[0][S][1],this.sample[1][S][2]=this.sample[0][S][2];for(var M=d;M<32;M++)this.sample[0][M][0]=0,this.sample[0][M][1]=0,this.sample[0][M][2]=0,this.sample[1][M][0]=0,this.sample[1][M][1]=0,this.sample[1][M][2]=0;for(var q=0;q<3;q++){this.VPos=this.VPos-64&1023;for(var N=0;N<2;N++){i.MatrixTransform(this.sample[N],q,this.V[N],this.VPos),E(this.U,0);for(var L=512-(this.VPos>>1),U=this.VPos%128>>1;U<1024;){for(var J=0;J<32;++J)this.U[J]+=this.D[L++]*this.V[N][U++];U+=96,L+=32}for(U=1120-U,L-=480;U<1024;){for(var T=0;T<32;++T)this.U[T]+=this.D[L++]*this.V[N][U++];U+=96,L+=32}for(var v=0===N?A:t,x=0;x<32;x++)v[k+x]=this.U[x]/2147418112}k+=32}}return this.sampleRate=B,n},e.readAllocation=function(A,t){var e=i.QUANT_LUT_STEP_3[t][A],s=i.QUANT_LUT_STEP4[15&e][this.bits.read(e>>4)];return s?i.QUANT_TAB[s-1]:0},e.readSamples=function(A,t,e){var s=this.allocation[A][t],I=this.scaleFactor[A][t][e],o=this.sample[A][t],g=0;if(s){if(63===I)I=0;else{var a=I/3|0;I=i.SCALEFACTOR_BASE[I%3]+(1<<a>>1)>>a}var B=s.levels;s.group?(g=this.bits.read(s.bits),o[0]=g%B,g=g/B|0,o[1]=g%B,o[2]=g/B|0):(o[0]=this.bits.read(s.bits),o[1]=this.bits.read(s.bits),o[2]=this.bits.read(s.bits));var C=65536/(B+1)|0;g=((B=(B+1>>1)-1)-o[0])*C,o[0]=g*(I>>12)+(g*(4095&I)+2048>>12)>>12,g=(B-o[1])*C,o[1]=g*(I>>12)+(g*(4095&I)+2048>>12)>>12,g=(B-o[2])*C,o[2]=g*(I>>12)+(g*(4095&I)+2048>>12)>>12}else o[0]=o[1]=o[2]=0},i.MatrixTransform=function(A,t,i,e){var s,I,o,g,a,B,C,Q,E,r,n,h,d,c,l,u,w,D,p,f,m,y,R,k,b,G,F,S,M,q,N,L,U;s=A[0][t]+A[31][t],I=.500602998235*(A[0][t]-A[31][t]),o=A[1][t]+A[30][t],g=.505470959898*(A[1][t]-A[30][t]),a=A[2][t]+A[29][t],B=.515447309923*(A[2][t]-A[29][t]),C=A[3][t]+A[28][t],Q=.53104259109*(A[3][t]-A[28][t]),E=A[4][t]+A[27][t],r=.553103896034*(A[4][t]-A[27][t]),n=A[5][t]+A[26][t],h=.582934968206*(A[5][t]-A[26][t]),d=A[6][t]+A[25][t],c=.622504123036*(A[6][t]-A[25][t]),l=A[7][t]+A[24][t],u=.674808341455*(A[7][t]-A[24][t]),w=A[8][t]+A[23][t],D=.744536271002*(A[8][t]-A[23][t]),p=A[9][t]+A[22][t],f=.839349645416*(A[9][t]-A[22][t]),m=A[10][t]+A[21][t],y=.972568237862*(A[10][t]-A[21][t]),R=A[11][t]+A[20][t],k=1.16943993343*(A[11][t]-A[20][t]),b=A[12][t]+A[19][t],G=1.48416461631*(A[12][t]-A[19][t]),F=A[13][t]+A[18][t],S=2.05778100995*(A[13][t]-A[18][t]),M=A[14][t]+A[17][t],q=3.40760841847*(A[14][t]-A[17][t]),U=s+(N=A[15][t]+A[16][t]),N=.502419286188*(s-N),s=o+M,M=.52249861494*(o-M),o=a+F,F=.566944034816*(a-F),a=C+b,b=.64682178336*(C-b),C=E+R,R=.788154623451*(E-R),E=n+m,m=1.06067768599*(n-m),n=d+p,p=1.72244709824*(d-p),d=l+w,w=5.10114861869*(l-w),l=U+d,d=.509795579104*(U-d),U=s+n,s=.601344886935*(s-n),n=o+E,E=.899976223136*(o-E),o=a+C,C=2.56291544774*(a-C),a=l+o,l=.541196100146*(l-o),o=U+n,n=1.30656296488*(U-n),U=a+o,a=.707106781187*(a-o),o=l+n,o+=l=.707106781187*(l-n),n=d+C,d=.541196100146*(d-C),C=s+E,E=1.30656296488*(s-E),s=n+C,C=.707106781187*(n-C),n=d+E,s+=n+=d=.707106781187*(d-E),n+=C,C+=d,E=N+w,N=.509795579104*(N-w),w=M+p,M=.601344886935*(M-p),p=F+m,m=.899976223136*(F-m),F=b+R,R=2.56291544774*(b-R),b=E+F,E=.541196100146*(E-F),F=w+p,p=1.30656296488*(w-p),w=b+F,F=.707106781187*(b-F),b=E+p,p=.707106781187*(E-p),E=N+R,N=.541196100146*(N-R),R=M+m,m=1.30656296488*(M-m),M=E+R,R=.707106781187*(E-R),E=N+m,w+=M+=E+=N=.707106781187*(N-m),M+=b+=p,b+=E+=R,E+=F,F+=R+=N,R+=p,p+=N,m=I+(L=10.1900081235*(A[15][t]-A[16][t])),I=.502419286188*(I-L),L=g+q,g=.52249861494*(g-q),q=B+S,S=.566944034816*(B-S),B=Q+G,Q=.64682178336*(Q-G),G=r+k,r=.788154623451*(r-k),k=h+y,y=1.06067768599*(h-y),h=c+f,f=1.72244709824*(c-f),c=u+D,u=5.10114861869*(u-D),D=m+c,c=.509795579104*(m-c),m=L+h,L=.601344886935*(L-h),h=q+k,k=.899976223136*(q-k),q=B+G,G=2.56291544774*(B-G),B=D+q,D=.541196100146*(D-q),q=m+h,h=1.30656296488*(m-h),m=B+q,q=.707106781187*(B-q),B=D+h,h=.707106781187*(D-h),D=c+G,G=.541196100146*(c-G),c=L+k,k=1.30656296488*(L-k),L=D+c,c=.707106781187*(D-c),D=G+k,L+=D+=k=.707106781187*(G-k),D+=c,G=c+k,c=I+u,I=.509795579104*(I-u),u=g+f,g=.601344886935*(g-f),f=S+y,y=.899976223136*(S-y),S=Q+r,r=2.56291544774*(Q-r),Q=c+S,c=.541196100146*(c-S),S=u+f,f=1.30656296488*(u-f),u=Q+S,S=.707106781187*(Q-S),Q=c+f,f=.707106781187*(c-f),c=I+r,I=.541196100146*(I-r),r=g+y,y=1.30656296488*(g-y),g=c+r,r=.707106781187*(c-r),c=I+y,m+=u+=g+=c+=I=.707106781187*(I-y),u+=L,L+=g+=Q+=f,g+=B+=h,B+=Q+=c+=r,Q+=D,D+=c+=S,c+=q,q+=S+=r+=I,S+=G,G+=r+=f,r+=h,h+=f+=I,f+=k,k+=I,i[e+48]=-U,i[e+49]=i[e+47]=-m,i[e+50]=i[e+46]=-w,i[e+51]=i[e+45]=-u,i[e+52]=i[e+44]=-s,i[e+53]=i[e+43]=-L,i[e+54]=i[e+42]=-M,i[e+55]=i[e+41]=-g,i[e+56]=i[e+40]=-o,i[e+57]=i[e+39]=-B,i[e+58]=i[e+38]=-b,i[e+59]=i[e+37]=-Q,i[e+60]=i[e+36]=-n,i[e+61]=i[e+35]=-D,i[e+62]=i[e+34]=-E,i[e+63]=i[e+33]=-c,i[e+32]=-a,i[e+0]=a,i[e+31]=-q,i[e+1]=q,i[e+30]=-F,i[e+2]=F,i[e+29]=-S,i[e+3]=S,i[e+28]=-C,i[e+4]=C,i[e+27]=-G,i[e+5]=G,i[e+26]=-R,i[e+6]=R,i[e+25]=-r,i[e+7]=r,i[e+24]=-l,i[e+8]=l,i[e+23]=-h,i[e+9]=h,i[e+22]=-p,i[e+10]=p,i[e+21]=-f,i[e+11]=f,i[e+20]=-d,i[e+12]=d,i[e+19]=-k,i[e+13]=k,i[e+18]=-N,i[e+14]=N,i[e+17]=-I,i[e+15]=I,i[e+16]=0},i}(u);p.FRAME_SYNC=2047,p.VERSION={MPEG_2_5:0,MPEG_2:2,MPEG_1:3},p.LAYER={III:1,II:2,I:3},p.MODE={STEREO:0,JOINT_STEREO:1,DUAL_CHANNEL:2,MONO:3},p.SAMPLE_RATE=new Uint16Array([44100,48e3,32e3,0,22050,24e3,16e3,0]),p.BIT_RATE=new Uint16Array([32,48,56,64,80,96,112,128,160,192,224,256,320,384,8,16,24,32,40,48,56,64,80,96,112,128,144,160]),p.SCALEFACTOR_BASE=new Uint32Array([33554432,26632170,21137968]),p.SYNTHESIS_WINDOW=new Float32Array([0,-.5,-.5,-.5,-.5,-.5,-.5,-1,-1,-1,-1,-1.5,-1.5,-2,-2,-2.5,-2.5,-3,-3.5,-3.5,-4,-4.5,-5,-5.5,-6.5,-7,-8,-8.5,-9.5,-10.5,-12,-13,-14.5,-15.5,-17.5,-19,-20.5,-22.5,-24.5,-26.5,-29,-31.5,-34,-36.5,-39.5,-42.5,-45.5,-48.5,-52,-55.5,-58.5,-62.5,-66,-69.5,-73.5,-77,-80.5,-84.5,-88,-91.5,-95,-98,-101,-104,106.5,109,111,112.5,113.5,114,114,113.5,112,110.5,107.5,104,100,94.5,88.5,81.5,73,63.5,53,41.5,28.5,14.5,-1,-18,-36,-55.5,-76.5,-98.5,-122,-147,-173.5,-200.5,-229.5,-259.5,-290.5,-322.5,-355.5,-389.5,-424,-459.5,-495.5,-532,-568.5,-605,-641.5,-678,-714,-749,-783.5,-817,-849,-879.5,-908.5,-935,-959.5,-981,-1000.5,-1016,-1028.5,-1037.5,-1042.5,-1043.5,-1040,-1031.5,1018.5,1e3,976,946.5,911,869.5,82