@cycjimmy/jsmpeg-player
Version:
MPEG1 Video Player Based On JSMpeg
6 lines • 124 kB
JavaScript
/*!
* @cycjimmy/jsmpeg-player v5.0.1
* 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=A||self).JSMpeg=t()}(this,(function(){"use strict";function A(){return(A=Object.assign||function(A){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(A[e]=i[e])}return A}).apply(this,arguments)}function t(A,t){A.prototype=Object.create(t.prototype),A.prototype.constructor=A,A.__proto__=t}function i(A){return A&&A.__esModule&&Object.prototype.hasOwnProperty.call(A,"default")?A.default:A}function e(A,t){return A(t={exports:{}},t.exports),t.exports}var s=i(e((function(A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=function(A){return"string"==typeof A&&A.constructor===String}}))),I=e((function(A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default=function(A){return"Promise"===Object.prototype.toString.call(A).slice(8,-1)}}));i(I);var g=i(e((function(A,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,e=(i=I)&&i.__esModule?i:{default:i};t.default=function(A){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return(0,e.default)(A)?A:new Promise((function(i){A(),setTimeout(i,t)}))}})));var o="nk-GvVcgZw",B="_2RIcqcDcdd",a="_9Rxgc3-sVf",C="H-DEgIh9Aq",Q="HE6yLI4_vV";!function(A,t){void 0===t&&(t={});var i=t.insertAt;if(A&&"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))}}("._2RIcqcDcdd,._9Rxgc3-sVf,.H-DEgIh9Aq,.nk-GvVcgZw{position:absolute;z-index:1;left:0;top:0;width:100%;height:100%}._9Rxgc3-sVf{display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-ms-flex-align:center;align-items:center}._2RIcqcDcdd,.nk-GvVcgZw{display:block}._2RIcqcDcdd.HE6yLI4_vV{display:none}._9Rxgc3-sVf,.H-DEgIh9Aq{opacity:.7;cursor:pointer;-webkit-tap-highlight-color:rgba(255,0,0,0)}.HE6yLI4_vV._9Rxgc3-sVf,.HE6yLI4_vV.H-DEgIh9Aq{display:none}._9Rxgc3-sVf{z-index:10}._9Rxgc3-sVf>svg{width:12vw;height:12vw;max-width:60px;max-height:60px;fill:#fff}.H-DEgIh9Aq{z-index:10;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-justify-content:flex-end;-ms-flex-pack:end;justify-content:flex-end;-webkit-align-items:flex-end;-ms-flex-align:end;align-items:flex-end}.H-DEgIh9Aq>svg{margin:0 15px 15px 0;width:9vw;height:9vw;max-width:40px;max-height:40px;fill:#fff}");var E=function(){function t(t,i,e,I){var g=void 0===e?{}:e,o=g.canvas,B=void 0===o?"":o,a=g.poster,C=void 0===a?"":a,Q=g.autoplay,E=void 0!==Q&&Q,r=g.autoSetWrapperSize,n=void 0!==r&&r,h=g.loop,d=void 0!==h&&h,c=g.control,l=void 0===c||c,u=g.decodeFirstFrame,D=void 0===u||u,w=g.picMode,p=void 0!==w&&w,f=g.progressive,m=void 0===f||f,y=g.chunkSize,R=void 0===y?1048576:y,k=g.hooks,G=void 0===k?{}:k;void 0===I&&(I={}),this.options=A({videoUrl:i,canvas:B,poster:C,picMode:p,autoplay:E,autoSetWrapperSize:n,loop:d,control:l,decodeFirstFrame:D,progressive:m,chunkSize:R,hooks:A({play:function(){},pause:function(){},stop:function(){},load:function(){}},G)},I),this.options.needPlayButton=this.options.control&&!this.options.picMode,this.player=null,this.els={wrapper:s(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=s(this.options.canvas)?document.querySelector(this.options.canvas):this.options.canvas:(this.els.canvas=document.createElement("canvas"),this.els.canvas.classList.add(o),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 M(this.options.videoUrl,i,{play:function(){t.options.needPlayButton&&t.els.playButton.classList.add(Q),t.els.poster&&t.els.poster.classList.add(Q),t.options.hooks.play()},pause:function(){t.options.needPlayButton&&t.els.playButton.classList.remove(Q),t.options.hooks.pause()},stop:function(){t.els.poster&&t.els.poster.classList.remove(Q),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(B),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(Q),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(C),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(a),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 g((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(Q),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}(),r=function(){return window.performance?window.performance.now()/1e3:Date.now()/1e3},n=function(A,t){if(A.fill)A.fill(t);else for(var i=0;i<A.length;i++)A[i]=t},h=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},d=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}(),c=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=r(),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=r()-this.loadStartTime,this.throttled||this.loadNextChunk()},A}(),l=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.socket=new WebSocket(this.url,this.options.protocols||null),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}(),u=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 g=Math.max(2*this.bytes.length,e-s);this.resize(g)}else this.evict(e);if(i)for(var o=0;o<t.length;o++)this.appendSingleBuffer(t[o]);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}();u.MODE={EVICT:1,EXPAND:2};var D=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 u(t),this.bits.write([this.leftoverBytes,A])}else this.bits=new u(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),t=(this.bits.read(1),this.bits.read(1)),i=(this.bits.read(1),this.bits.read(13)),e=(this.bits.read(2),this.bits.read(2)),s=(this.bits.read(4),this.pidsToStreamIds[i]);if(t&&s){var I=this.pesPacketInfo[s];I&&I.currentLength&&this.packetComplete(I)}if(1&e){if(2&e){var g=this.bits.read(8);this.bits.skip(g<<3)}if(t&&this.bits.nextBytesAreStartCode()){this.bits.skip(24),s=this.bits.read(8),this.pidsToStreamIds[i]=s;var o=this.bits.read(16);this.bits.skip(8);var B=this.bits.read(2);this.bits.skip(6);var a=this.bits.read(8),C=this.bits.index+(a<<3),Q=this.pesPacketInfo[s];if(Q){var E=0;if(2&B){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=o?o-a-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}();D.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 w=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.bits.index=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}(),p=function(A){function i(t){var i;(i=A.call(this,t)||this).onDecodeCallback=t.onVideoDecode;var e=t.videoBufferSize||524288,s=t.streaming?u.MODE.EVICT:u.MODE.EXPAND;return i.bits=new u(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(w.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=r();if(!this.hasSequenceHeader)return!1;if(-1===this.bits.findStartCode(i.START.PICTURE))return!1;this.decodePicture(),this.advanceDecodedTime(1/this.frameRate);var t=r()-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,g=this.forwardCb,o=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=g,this.currentCb32=o}}},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,0!=(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=0!=(2&this.macroblockType)?this.readHuffman(i.CODE_BLOCK_PATTERN):this.macroblockIntra?63:0,I=0,g=32;I<6;I++)0!=(s&g)&&this.decodeBlock(I),g>>=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,g,o,B,a,C,Q,E,r,n,h,d,c,l,u,D,w,p,f,m=this.currentY32,y=this.currentCb32,R=this.currentCr32;if(g=(I=this.codedWidth)-16,o=A>>1,B=t>>1,a=1==(1&A),C=1==(1&t),Q=((this.mbRow<<4)+B)*I+(this.mbCol<<4)+o,r=(E=this.mbRow*I+this.mbCol<<2)+(I<<2),a)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+=g>>2,Q+=g-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+=g>>2,Q+=g-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+=g>>2,Q+=g}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+=g>>2,Q+=g}if(g=(I=this.halfWidth)-8,o=A/2>>1,B=t/2>>1,a=1==(A/2&1),C=1==(t/2&1),Q=((this.mbRow<<3)+B)*I+(this.mbCol<<3)+o,r=(E=this.mbRow*I+this.mbCol<<1)+(I<<1),a)if(C)for(;E<r;){for(l=e[Q]+e[Q+I],w=s[Q]+s[Q+I],Q++,n=0;n<2;n++)D=l+(u=e[Q]+e[Q+I])+2>>2&255,f=w+(p=s[Q]+s[Q+I])+2>>2&255,D|=(l=e[++Q]+e[Q+I])+u+2<<6&65280,f|=(w=s[Q]+s[Q+I])+p+2<<6&65280,D|=l+(u=e[++Q]+e[Q+I])+2<<14&16711680,f|=w+(p=s[Q]+s[Q+I])+2<<14&16711680,l=e[++Q]+e[Q+I],w=s[Q]+s[Q+I],Q++,D|=l+u+2<<22&4278190080,f|=w+p+2<<22&4278190080,R[E]=D,y[E]=f,E++;E+=g>>2,Q+=g-1}else for(;E<r;){for(l=e[Q],w=s[Q],Q++,n=0;n<2;n++)D=l+(u=e[Q])+1>>1&255,f=w+(p=s[Q++])+1>>1&255,D|=(l=e[Q])+u+1<<7&65280,f|=(w=s[Q++])+p+1<<7&65280,D|=l+(u=e[Q])+1<<15&16711680,f|=w+(p=s[Q++])+1<<15&16711680,D|=(l=e[Q])+u+1<<23&4278190080,f|=(w=s[Q++])+p+1<<23&4278190080,R[E]=D,y[E]=f,E++;E+=g>>2,Q+=g-1}else if(C)for(;E<r;){for(n=0;n<2;n++)D=e[Q]+e[Q+I]+1>>1&255,f=s[Q]+s[Q+I]+1>>1&255,D|=e[++Q]+e[Q+I]+1<<7&65280,f|=s[Q]+s[Q+I]+1<<7&65280,D|=e[++Q]+e[Q+I]+1<<15&16711680,f|=s[Q]+s[Q+I]+1<<15&16711680,D|=e[++Q]+e[Q+I]+1<<23&4278190080,f|=s[Q]+s[Q+I]+1<<23&4278190080,Q++,R[E]=D,y[E]=f,E++;E+=g>>2,Q+=g}else for(;E<r;){for(n=0;n<2;n++)D=e[Q],f=s[Q],D|=e[++Q]<<8,f|=s[Q]<<8,D|=e[++Q]<<16,f|=s[Q]<<16,D|=e[++Q]<<24,f|=s[Q]<<24,Q++,R[E]=D,y[E]=f,E++;E+=g>>2,Q+=g}},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 g=this.bits.read(I);this.blockData[0]=0!=(g&1<<I-1)?s+g:s+(-1<<I|g+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 o,B,a,C=0;;){var Q=0,E=this.readHuffman(i.DCT_COEFF);if(1===E&&e>0&&0===this.bits.read(1))break;65535===E?(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=E>>8,C=255&E,this.bits.read(1)&&(C=-C)),e+=Q;var r=i.ZIG_ZAG[e];e++,C<<=1,this.macroblockIntra||(C+=C<0?-1:1),0==(1&(C=C*this.quantizerScale*t[r]>>4))&&(C-=C>0?1:-1),C>2047?C=2047:C<-2048&&(C=-2048),this.blockData[r]=C*i.PREMULTIPLIER_MATRIX[r]}A<4?(o=this.currentY,a=this.codedWidth-8,B=this.mbRow*this.codedWidth+this.mbCol<<4,0!=(1&A)&&(B+=8),0!=(2&A)&&(B+=this.codedWidth<<3)):(o=4===A?this.currentCb:this.currentCr,a=(this.codedWidth>>1)-8,B=(this.mbRow*this.codedWidth<<2)+(this.mbCol<<3)),this.macroblockIntra?1===e?(i.CopyValueToDestination(this.blockData[0]+128>>8,o,B,a),this.blockData[0]=0):(i.IDCT(this.blockData),i.CopyBlockToDestination(this.blockData,o,B,a),n(this.blockData,0)):1===e?(i.AddValueToDestination(this.blockData[0]+128>>8,o,B,a),this.blockData[0]=0):(i.IDCT(this.blockData),i.AddBlockToDestination(this.blockData,o,B,a),n(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,g,o,B,a,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],g=A[8+u]+A[56+u],o=A[24+u]+A[40+u],a=(r=(473*(s=A[8+u]-A[56+u])-196*e+128>>8)-(I=g+o))-(362*(g-o)+128>>8),n=(C=(B=A[0+u])-t)+(Q=(362*(A[16+u]-A[48+u])+128>>8)-i),h=(E=B+t)+i,d=C-Q,c=E-i,l=-a-(473*e+196*s+128>>8),A[0+u]=I+h,A[8+u]=r+n,A[16+u]=d-a,A[24+u]=c-l,A[32+u]=c+l,A[40+u]=a+d,A[48+u]=n-r,A[56+u]=h-I;for(var D=0;D<64;D+=8)t=A[4+D],i=A[2+D]+A[6+D],e=A[5+D]-A[3+D],g=A[1+D]+A[7+D],o=A[3+D]+A[5+D],a=(r=(473*(s=A[1+D]-A[7+D])-196*e+128>>8)-(I=g+o))-(362*(g-o)+128>>8),n=(C=(B=A[0+D])-t)+(Q=(362*(A[2+D]-A[6+D])+128>>8)-i),h=(E=B+t)+i,d=C-Q,c=E-i,l=-a-(473*e+196*s+128>>8),A[0+D]=I+h+128>>8,A[1+D]=r+n+128>>8,A[2+D]=d-a+128>>8,A[3+D]=c-l+128>>8,A[4+D]=c+l+128>>8,A[5+D]=a+d+128>>8,A[6+D]=n-r+128>>8,A[7+D]=h-I+128>>8},i}(w);p.prototype.frameRate=30,p.prototype.currentY=null,p.prototype.currentCr=null,p.prototype.currentCb=null,p.prototype.pictureType=0,p.prototype.forwardY=null,p.prototype.forwardCr=null,p.prototype.forwardCb=null,p.prototype.fullPelForward=!1,p.prototype.forwardFCode=0,p.prototype.forwardRSize=0,p.prototype.forwardF=0,p.prototype.quantizerScale=0,p.prototype.sliceBegin=!1,p.prototype.macroblockAddress=0,p.prototype.mbRow=0,p.prototype.mbCol=0,p.prototype.macroblockType=0,p.prototype.macroblockIntra=!1,p.prototype.macroblockMotFw=!1,p.prototype.motionFwH=0,p.prototype.motionFwV=0,p.prototype.motionFwHPrev=0,p.prototype.motionFwVPrev=0,p.prototype.dcPredictorY=0,p.prototype.dcPredictorCr=0,p.prototype.dcPredictorCb=0,p.prototype.blockData=null,p.PICTURE_RATE=[0,23.976,24,25,29.97,30,50,59.94,60,0,0,0,0,0,0,0],p.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]),p.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]),p.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]),p.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]),p.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]),p.MACROBLOCK_TYPE_INTRA=new Int8Array([3,6,0,-1,9,0,0,0,1,0,0,17]),p.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]),p.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]),p.MACROBLOCK_TYPE=[null,p.MACROBLOCK_TYPE_INTRA,p.MACROBLOCK_TYPE_PREDICTIVE,p.MACROBLOCK_TYPE_B],p.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]),p.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]),p.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]),p.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]),p.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]),p.PICTURE_TYPE={INTRA:1,PREDICTIVE:2,B:3},p.START={SEQUENCE:179,SLICE_FIRST:1,SLICE_LAST:175,PICTURE:0,EXTENSION:181,USER_DATA:178};var f=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?u.MODE.EVICT:u.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){w.prototype.write.call(this,A,t),!this.hasSequenceHeader&&this.functions._mpeg1_decoder_has_sequence_header(this.decoder)&&this.loadSequnceHeader()},e.loadSequnceHeader=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=r();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)),g=this.instance.heapU8.subarray(e,e+(this.codedSize>>2));this.destination.render(s,I,g,!1)}this.advanceDecodedTime(1/this.frameRate);var o=r()-A;return this.onDecodeCallback&&this.onDecodeCallback(this,o),!0},i}(w),m=function(A){function i(t){var e;(e=A.call(this,t)||this).onDecodeCallback=t.onAudioDecode;var s=t.audioBufferSize||131072,I=t.streaming?u.MODE.EVICT:u.MODE.EXPAND;e.bits=new u(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 g=0;g<2;g++)for(var o=0;o<32;o++)e.scaleFactor[g][o]=[0,0,0],e.sample[g][o]=[0,0,0];return e}t(i,A);var e=i.prototype;return e.decode=function(){var A=r(),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=r()-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),g=!this.bits.read(1);if(e!==i.FRAME_SYNC||s!==i.VERSION.MPEG_1||I!==i.LAYER.II)return 0;var o=this.bits.read(4)-1;if(o>13)return 0;var B=this.bits.read(2),a=i.SAMPLE_RATE[B];if(3===B)return 0;s===i.VERSION.MPEG_2&&(B+=4,o+=14);var C=this.bits.read(1),Q=(this.bits.read(1),this.bits.read(2)),E=0;Q===i.MODE.JOINT_STEREO?E=this.bits.read(2)+1<<2:(this.bits.skip(2),E=Q===i.MODE.MONO?0:32),this.bits.skip(4),g&&this.bits.skip(16);var r=144e3*i.BIT_RATE[o]/(a=i.SAMPLE_RATE[B])+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][o];d=63&(h=i.QUANT_LUT_STEP_2[l][B]),h>>=6}E>d&&(E=d);for(var u=0;u<E;u++)this.allocation[0][u]=this.readAllocation(u,h),this.allocation[1][u]=this.readAllocation(u,h);for(var D=E;D<d;D++)this.allocation[0][D]=this.allocation[1][D]=this.readAllocation(D,h);for(var w=Q===i.MODE.MONO?1:2,p=0;p<d;p++){for(var f=0;f<w;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<w;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,G=0;G<3;G++)for(var b=0;b<4;b++){for(var F=0;F<E;F++)this.readSamples(0,F,G),this.readSamples(1,F,G);for(var M=E;M<d;M++)this.readSamples(0,M,G),this.sample[1][M][0]=this.sample[0][M][0],this.sample[1][M][1]=this.sample[0][M][1],this.sample[1][M][2]=this.sample[0][M][2];for(var q=d;q<32;q++)this.sample[0][q][0]=0,this.sample[0][q][1]=0,this.sample[0][q][2]=0,this.sample[1][q][0]=0,this.sample[1][q][1]=0,this.sample[1][q][2]=0;for(var S=0;S<3;S++){this.VPos=this.VPos-64&1023;for(var N=0;N<2;N++){i.MatrixTransform(this.sample[N],S,this.V[N],this.VPos),n(this.U,0);for(var L=512-(this.VPos>>1),J=this.VPos%128>>1;J<1024;){for(var T=0;T<32;++T)this.U[T]+=this.D[L++]*this.V[N][J++];J+=96,L+=32}for(J=1120-J,L-=480;J<1024;){for(var U=0;U<32;++U)this.U[U]+=this.D[L++]*this.V[N][J++];J+=96,L+=32}for(var x=0===N?A:t,H=0;H<32;H++)x[k+H]=this.U[H]/2147418112}k+=32}}return this.sampleRate=a,r},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],g=this.sample[A][t],o=0;if(s){if(63===I)I=0;else{var B=I/3|0;I=i.SCALEFACTOR_BASE[I%3]+(1<<B>>1)>>B}var a=s.levels;s.group?(o=this.bits.read(s.bits),g[0]=o%a,o=o/a|0,g[1]=o%a,g[2]=o/a|0):(g[0]=this.bits.read(s.bits),g[1]=this.bits.read(s.bits),g[2]=this.bits.read(s.bits));var C=65536/(a+1)|0;o=((a=(a+1>>1)-1)-g[0])*C,g[0]=o*(I>>12)+(o*(4095&I)+2048>>12)>>12,o=(a-g[1])*C,g[1]=o*(I>>12)+(o*(4095&I)+2048>>12)>>12,o=(a-g[2])*C,g[2]=o*(I>>12)+(o*(4095&I)+2048>>12)>>12}else g[0]=g[1]=g[2]=0},i.MatrixTransform=function(A,t,i,e){var s,I,g,o,B,a,C,Q,E,r,n,h,d,c,l,u,D,w,p,f,m,y,R,k,G,b,F,M,q,S,N,L,J;s=A[0][t]+A[31][t],I=.500602998235*(A[0][t]-A[31][t]),g=A[1][t]+A[30][t],o=.505470959898*(A[1][t]-A[30][t]),B=A[2][t]+A[29][t],a=.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]),D=A[8][t]+A[23][t],w=.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]),G=A[12][t]+A[19][t],b=1.48416461631*(A[12][t]-A[19][t]),F=A[13][t]+A[18][t],M=2.05778100995*(A[13][t]-A[18][t]),q=A[14][t]+A[17][t],S=3.40760841847*(A[14][t]-A[17][t]),J=s+(N=A[15][t]+A[16][t]),N=.502419286188*(s-N),s=g+q,q=.52249861494*(g-q),g=B+F,F=.566944034816*(B-F),B=C+G,G=.64682178336*(C-G),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+D,D=5.10114861869*(l-D),l=J+d,d=.509795579104*(J-d),J=s+n,s=.601344886935*(s-n),n=g+E,E=.899976223136*(g-E),g=B+C,C=2.56291544774*(B-C),B=l+g,l=.541196100146*(l-g),g=J+n,n=1.30656296488*(J-n),J=B+g,B=.707106781187*(B-g),g=l+n,g+=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+D,N=.509795579104*(N-D),D=q+p,q=.601344886935*(q-p),p=F+m,m=.899976223136*(F-m),F=G+R,R=2.56291544774*(G-R),G=E+F,E=.541196100146*(E-F),F=D+p,p=1.30656296488*(D-p),D=G+F,F=.707106781187*(G-F),G=E+p,p=.707106781187*(E-p),E=N+R,N=.541196100146*(N-R),R=q+m,m=1.30656296488*(q-m),q=E+R,R=.707106781187*(E-R),E=N+m,D+=q+=E+=N=.707106781187*(N-m),q+=G+=p,G+=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=o+S,o=.52249861494*(o-S),S=a+M,M=.566944034816*(a-M),a=Q+b,Q=.64682178336*(Q-b),b=r+k,r=.788154623451*(r-k),k=h+y,y=1.06067768599*(h-y),h=c+f,f=1.72244709824*(c-f),c=u+w,u=5.10114861869*(u-w),w=m+c,c=.509795579104*(m-c),m=L+h,L=.601344886935*(L-h),h=S+k,k=.899976223136*(S-k),S=a+b,b=2.56291544774*(a-b),a=w+S,w=.541196100146*(w-S),S=m+h,h=1.30656296488*(m-h),m=a+S,S=.707106781187*(a-S),a=w+h,h=.707106781187*(w-h),w=c+b,b=.541196100146*(c-b),c=L+k,k=1.30656296488*(L-k),L=w+c,c=.707106781187*(w-c),w=b+k,L+=w+=k=.707106781187*(b-k),w+=c,b=c+k,c=I+u,I=.509795579104*(I-u),u=o+f,o=.601344886935*(o-f),f=M+y,y=.899976223136*(M-y),M=Q+r,r=2.56291544774*(Q-r),Q=c+M,c=.541196100146*(c-M),M=u+f,f=1.30656296488*(u-f),u=Q+M,M=.707106781187*(Q-M),Q=c+f,f=.707106781187*(c-f),c=I+r,I=.541196100146*(I-r),r=o+y,y=1.30656296488*(o-y),o=c+r,r=.707106781187*(c-r),c=I+y,m+=u+=o+=c+=I=.707106781187*(I-y),u+=L,L+=o+=Q+=f,o+=a+=h,a+=Q+=c+=r,Q+=w,w+=c+=M,c+=S,S+=M+=r+=I,M+=b,b+=r+=f,r+=h,h+=f+=I,f+=k,k+=I,i[e+48]=-J,i[e+49]=i[e+47]=-m,i[e+50]=i[e+46]=-D,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]=-q,i[e+55]=i[e+41]=-o,i[e+56]=i[e+40]=-g,i[e+57]=i[e+39]=-a,i[e+58]=i[e+38]=-G,i[e+59]=i[e+37]=-Q,i[e+60]=i[e+36]=-n,i[e+61]=i[e+35]=-w,i[e+62]=i[e+34]=-E,i[e+63]=i[e+33]=-c,i[e+32]=-B,i[e+0]=B,i[e+31]=-S,i[e+1]=S,i[e+30]=-F,i[e+2]=F,i[e+29]=-M,i[e+3]=M,i[e+28]=-C,i[e+4]=C,i[e+27]=-b,i[e+5]=b,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}(w);m.FRAME_SYNC=2047,m.VERSION={MPEG_2_5:0,MPEG_2:2,MPEG_1:3},m.LAYER={III:1,II:2,I:3},m.MODE={STEREO:0,JOINT_STEREO:1,DUAL_CHANNEL:2,MONO:3},m.SAMPLE_RATE=new Uint16Array([44100,48e3,32e3,0,22050,24e3,16e3,0]),m.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]),m.SCALEFACTOR_BASE=new Uint32Array([33554432,26632170,21137968]),m.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,1