videoWorker.worker.js 58 KB

1
  1. !function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";function a(t){return(a="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"===typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}if(r.r(e),"undefined"==typeof n)var n={};n.MD5=function(t){function e(t){var e=(t>>>0).toString(16);return"00000000".substr(0,8-e.length)+e}function r(t,e,r){return t&e|~t&r}function n(t,e,r){return r&t|~r&e}function i(t,e,r){return t^e^r}function o(t,e,r){return e^(t|~r)}function s(t,e){return t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}function u(t){for(var e=[],r=0;r<t.length;r++)if(t.charCodeAt(r)<=127)e.push(t.charCodeAt(r));else for(var a=encodeURIComponent(t.charAt(r)).substr(1).split("%"),n=0;n<a.length;n++)e.push(parseInt(a[n],16));return e}function f(t){for(var e=new Array(t.length),r=0;r<t.length;r++)e[r]=t[r];return e}var l=null,c=null;function p(t,e){return 4294967295&t+e}return"string"==typeof t?l=u(t):t.constructor==Array?0===t.length?l=t:"string"==typeof t[0]?l=function(t){for(var e=[],r=0;r<t.length;r++)e=e.concat(u(t[r]));return e}(t):"number"==typeof t[0]?l=t:c=a(t[0]):"undefined"!=typeof ArrayBuffer?t instanceof ArrayBuffer?l=f(new Uint8Array(t)):t instanceof Uint8Array||t instanceof Int8Array?l=f(t):t instanceof Uint32Array||t instanceof Int32Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Float32Array||t instanceof Float64Array?l=f(new Uint8Array(t.buffer)):c=a(t):c=a(t),c&&alert("MD5 type mismatch, cannot process "+c),function(){function t(t,e,r,a){var n,i,o=y;y=v,v=g,g=p(g,(n=p(h,p(t,p(e,r))))<<(i=a)&4294967295|n>>>32-i),h=o}var a=l.length;l.push(128);var u=l.length%64;if(u>56){for(var f=0;f<64-u;f++)l.push(0);u=l.length%64}for(f=0;f<56-u;f++)l.push(0);l=l.concat(function(t){for(var e=[],r=0;r<8;r++)e.push(255&t),t>>>=8;return e}(8*a));var c=1732584193,m=4023233417,d=2562383102,_=271733878,h=0,g=0,v=0,y=0;for(f=0;f<l.length/64;f++){h=c;var b=64*f;t(r(g=m,v=d,y=_),3614090360,s(l,b),7),t(r(g,v,y),3905402710,s(l,b+4),12),t(r(g,v,y),606105819,s(l,b+8),17),t(r(g,v,y),3250441966,s(l,b+12),22),t(r(g,v,y),4118548399,s(l,b+16),7),t(r(g,v,y),1200080426,s(l,b+20),12),t(r(g,v,y),2821735955,s(l,b+24),17),t(r(g,v,y),4249261313,s(l,b+28),22),t(r(g,v,y),1770035416,s(l,b+32),7),t(r(g,v,y),2336552879,s(l,b+36),12),t(r(g,v,y),4294925233,s(l,b+40),17),t(r(g,v,y),2304563134,s(l,b+44),22),t(r(g,v,y),1804603682,s(l,b+48),7),t(r(g,v,y),4254626195,s(l,b+52),12),t(r(g,v,y),2792965006,s(l,b+56),17),t(r(g,v,y),1236535329,s(l,b+60),22),t(n(g,v,y),4129170786,s(l,b+4),5),t(n(g,v,y),3225465664,s(l,b+24),9),t(n(g,v,y),643717713,s(l,b+44),14),t(n(g,v,y),3921069994,s(l,b),20),t(n(g,v,y),3593408605,s(l,b+20),5),t(n(g,v,y),38016083,s(l,b+40),9),t(n(g,v,y),3634488961,s(l,b+60),14),t(n(g,v,y),3889429448,s(l,b+16),20),t(n(g,v,y),568446438,s(l,b+36),5),t(n(g,v,y),3275163606,s(l,b+56),9),t(n(g,v,y),4107603335,s(l,b+12),14),t(n(g,v,y),1163531501,s(l,b+32),20),t(n(g,v,y),2850285829,s(l,b+52),5),t(n(g,v,y),4243563512,s(l,b+8),9),t(n(g,v,y),1735328473,s(l,b+28),14),t(n(g,v,y),2368359562,s(l,b+48),20),t(i(g,v,y),4294588738,s(l,b+20),4),t(i(g,v,y),2272392833,s(l,b+32),11),t(i(g,v,y),1839030562,s(l,b+44),16),t(i(g,v,y),4259657740,s(l,b+56),23),t(i(g,v,y),2763975236,s(l,b+4),4),t(i(g,v,y),1272893353,s(l,b+16),11),t(i(g,v,y),4139469664,s(l,b+28),16),t(i(g,v,y),3200236656,s(l,b+40),23),t(i(g,v,y),681279174,s(l,b+52),4),t(i(g,v,y),3936430074,s(l,b),11),t(i(g,v,y),3572445317,s(l,b+12),16),t(i(g,v,y),76029189,s(l,b+24),23),t(i(g,v,y),3654602809,s(l,b+36),4),t(i(g,v,y),3873151461,s(l,b+48),11),t(i(g,v,y),530742520,s(l,b+60),16),t(i(g,v,y),3299628645,s(l,b+8),23),t(o(g,v,y),4096336452,s(l,b),6),t(o(g,v,y),1126891415,s(l,b+28),10),t(o(g,v,y),2878612391,s(l,b+56),15),t(o(g,v,y),4237533241,s(l,b+20),21),t(o(g,v,y),1700485571,s(l,b+48),6),t(o(g,v,y),2399980690,s(l,b+12),10),t(o(g,v,y),4293915773,s(l,b+40),15),t(o(g,v,y),2240044497,s(l,b+4),21),t(o(g,v,y),1873313359,s(l,b+32),6),t(o(g,v,y),4264355552,s(l,b+60),10),t(o(g,v,y),2734768916,s(l,b+24),15),t(o(g,v,y),1309151649,s(l,b+52),21),t(o(g,v,y),4149444226,s(l,b+16),6),t(o(g,v,y),3174756917,s(l,b+44),10),t(o(g,v,y),718787259,s(l,b+8),15),t(o(g,v,y),3951481745,s(l,b+36),21),c=p(c,h),m=p(m,g),d=p(d,v),_=p(_,y)}return function(t,r,a,n){for(var i="",o=0,s=0,u=3;u>=0;u--)o=255&(s=arguments[u]),o<<=8,o|=255&(s>>>=8),o<<=8,o|=255&(s>>>=8),o<<=8,i+=e(o|=s>>>=8);return i}(_,d,m,c).toUpperCase()}()};var i={log:function(){},error:function(){},count:function(){},info:function(){}};(function(){function t(){}t.createFromElementId=function(e){for(var r=document.getElementById(e),a="",n=r.firstChild;n;)3===n.nodeType&&(a+=n.textContent),n=n.nextSibling;var i=new t;return i.type=r.type,i.source=a,i},t.createFromSource=function(e,r){var a=new t;return a.type=e,a.source=r,a}})(),function(){function t(t){this.gl=t,this.program=this.gl.createProgram()}t.prototype={attach:function(t){this.gl.attachShader(this.program,t.shader)},link:function(){this.gl.linkProgram(this.program)},use:function(){this.gl.useProgram(this.program)},getAttributeLocation:function(t){return this.gl.getAttribLocation(this.program,t)},setMatrixUniform:function(t,e){var r=this.gl.getUniformLocation(this.program,t);this.gl.uniformMatrix4fv(r,!1,e)}}}(),function(){var t=null;function e(t,e,r){this.gl=t,this.size=e,this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),this.format=r||t.LUMINANCE,t.texImage2D(t.TEXTURE_2D,0,this.format,e.w,e.h,0,this.format,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)}e.prototype={fill:function(t,e){var r=this.gl;r.bindTexture(r.TEXTURE_2D,this.texture),e?r.texSubImage2D(r.TEXTURE_2D,0,0,0,this.size.w,this.size.h,this.format,r.UNSIGNED_BYTE,t):r.texImage2D(r.TEXTURE_2D,0,this.format,this.size.w,this.size.h,0,this.format,r.UNSIGNED_BYTE,t)},bind:function(e,r,a){var n=this.gl;t||(t=[n.TEXTURE0,n.TEXTURE1,n.TEXTURE2]),n.activeTexture(t[e]),n.bindTexture(n.TEXTURE_2D,this.texture),n.uniform1i(n.getUniformLocation(r.program,a),e)}}}();function o(){var t=0,e=0,r=null;function a(){t=360,e=240,r=null,this._length=0,this.head=null,this.tail=null,this.curIdx=0}return a.prototype={push:function(t,a,n,i,o,s){var u=new VideoBufferNode(t,a,n,i,o,s);return this._length>0?(this.tail.next=u,u.previous=this.tail,this.tail=u):(this.head=u,this.tail=u),this._length+=1,null!==r&&this._length>=e&&r(),u},pop:function(){var t=null;return this._length>1&&(t=this.head,this.head=this.head.next,null!==this.head?this.head.previous=null:this.tail=null,this._length-=1),t},setMaxLength:function(e){(t=e)>360?t=360:t<30&&(t=30)},setBUFFERING:function(t){(e=t)>240?e=240:e<6&&(e=6)},setBufferFullCallback:function(t){r=t},searchTimestamp:function(t){var e=this.head,r=this._length,a=1;if(0===r||t<=0||null===e)throw new Error("Failure: non-existent node in this list.");for(;null!==e&&(e.timeStamp.timestamp!==t.timestamp||e.timeStamp.timestamp_usec!==t.timestamp_usec);)e=e.next,a++;return r<a?e=null:this.curIdx=a,e},findIFrame:function(t){var e=this.head,r=this._length,a=1;if(0===r)throw new Error("Failure: non-existent node in this list.");for(;a<this.curIdx;)e=e.next,a++;if(!0===t)for(;"I"!==e.frameType;)e=e.next,a++;else for(;"I"!==e.frameType;)e=e.previous,a--;return r<a?e=null:this.curIdx=a,e}},new a}var s=function(){var t,e,r,a,n,o,s,u,f,l=null,c=new Uint8Array,p=!1;function m(){l=Module._OpenDecoder(0,0,0),m.prototype.setIsFirstFrame(!1)}return m.prototype={init:function(){i.log("H264 Decoder init")},setOutputSize:function(t){u!=2*t&&(u=2*t,f=Module._malloc(u),c=new Uint8Array(Module.HEAPU8.buffer,f,u))},decode:function(i,f){if(t=Date.now(),e=new Uint8Array(i),c.set(e),r=Module._FrameAlloc(),Module._DecodeFrame(l,c.byteOffset,i.byteLength,u,r),a=Date.now()-t,o=Module._getYLength(r),n=Module._getHeight(r),!m.prototype.isFirstFrame())return m.prototype.setIsFirstFrame(!0),{firstFrame:!0};if(o>0&&n>0){t=Date.now();var p=new Uint8Array(c);return s={data:p,option:{yaddr:Module._getY(r),uaddr:Module._getU(r),vaddr:Module._getV(r),ylen:o,height:n,beforeDecoding:t},width:o,height:n,codecType:"h264",decodingTime:a,frameType:f},Module._FrameFree(r),s}},setIsFirstFrame:function(t){p=t},isFirstFrame:function(){return p},free:function(){Module._free(f),f=null}},new m},u=new function(){var t=[],e={};function r(){for(var r in t)t[r]=[r.charCodeAt(0),r.charCodeAt(1),r.charCodeAt(2),r.charCodeAt(3)];e.FTYP=new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49]),e.STSD_PREFIX=new Uint8Array([0,0,0,0,0,0,0,1]),e.STTS=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSC=e.STCO=e.STTS,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.HDLR_VIDEO=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),e.HDLR_AUDIO=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),e.DREF=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}t={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var a=function(t){for(var e=8,r=Array.prototype.slice.call(arguments,1),a=0;a<r.length;a++)e+=r[a].byteLength;var n=new Uint8Array(e),i=0;for(n[i++]=e>>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e,n.set(t,i),i+=4,a=0;a<r.length;a++)n.set(r[a],i),i+=r[a].byteLength;return n},n=function(e){return a(t.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(65280&e.channelcount)>>8,255&e.channelcount,(65280&e.samplesize)>>8,255&e.samplesize,0,0,0,0,(65280&e.samplerate)>>8,255&e.samplerate,0,0]),function(e){var r=e.config,n=r.length,i=new Uint8Array([0,0,0,0,3,23+n,0,1,0,4,15+n,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([n]).concat(r).concat([6,1,2]));return a(t.esds,i)}(e))},o=function(r){return"audio"===r.type?a(t.stsd,e.STSD_PREFIX,n(r)):a(t.stsd,e.STSD_PREFIX,function(e){var r=e.sps||[],n=e.pps||[],i=[],o=[],s=0;for(s=0;s<r.length;s++)i.push((65280&r[s].byteLength)>>>8),i.push(255&r[s].byteLength),i=i.concat(Array.prototype.slice.call(r[s]));for(s=0;s<n.length;s++)o.push((65280&n[s].byteLength)>>>8),o.push(255&n[s].byteLength),o=o.concat(Array.prototype.slice.call(n[s]));return a(t.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(65280&e.width)>>8,255&e.width,(65280&e.height)>>8,255&e.height,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a(t.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255].concat([r.length]).concat(i).concat([n.length]).concat(o))))}(r))},s=function(r){var n=null;return n="audio"===r.type?a(t.smhd,e.SMHD):a(t.vmhd,e.VMHD),a(t.minf,n,a(t.dinf,a(t.dref,e.DREF)),function(r){return a(t.stbl,o(r),a(t.stts,e.STTS),a(t.stsc,e.STSC),a(t.stsz,e.STSZ),a(t.stco,e.STCO))}(r))},u=function(r){return a(t.mdia,function(e){var r=e.timescale,n=e.duration;return a(t.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,85,196,0,0]))}(r),function(r){var n=null;return n="audio"===r.type?e.HDLR_AUDIO:e.HDLR_VIDEO,a(t.hdlr,n)}(r),s(r))},f=function(e){return a(t.trak,function(e){var r=e.id,n=e.duration,i=e.width,o=e.height;return a(t.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,0,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>>8&255,255&i,0,0,o>>>8&255,255&o,0,0]))}(e),u(e))},l=function(e){return a(t.mvex,function(e){var r=e.id,n=new Uint8Array([0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return a(t.trex,n)}(e))},c=function(e){var r,n,o=(r=e.timescale,n=e.duration,i.log("mvhd: timescale: "+r+" duration: "+n),a(t.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,r>>>24&255,r>>>16&255,r>>>8&255,255&r,n>>>24&255,n>>>16&255,n>>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]))),s=f(e),u=l(e);return a(t.moov,o,s,u)},p=function(e,r){return"audio"===e.type?audioTrun(e,r):function(e,r){var n,i=null,o=null,s=0,u=r;if(null===(n=e.samples||[])[0].frameDuration)for(u+=24+4*n.length,i=trunHeader(n,u),s=0;s<n.length;s++)o=n[s],i=i.concat([(4278190080&o.size)>>>24,(16711680&o.size)>>>16,(65280&o.size)>>>8,255&o.size]);else for(i=function(t,e){return[0,0,3,5,(4278190080&t.length)>>>24,(16711680&t.length)>>>16,(65280&t.length)>>>8,255&t.length,(4278190080&e)>>>24,(16711680&e)>>>16,(65280&e)>>>8,255&e,0,0,0,0]}(n,u+=24+4*n.length+4*n.length),s=0;s<n.length;s++)o=n[s],i=i.concat([(4278190080&o.frameDuration)>>>24,(16711680&o.frameDuration)>>>16,(65280&o.frameDuration)>>>8,255&o.frameDuration,(4278190080&o.size)>>>24,(16711680&o.size)>>>16,(65280&o.size)>>>8,255&o.size]);return a(t.trun,new Uint8Array(i))}(e,r)},m=function(e,r){return a(t.moof,function(e){var r=new Uint8Array([0,0,0,0,e>>>24&255,e>>>16&255,e>>>8&255,255&e]);return a(t.mfhd,r)}(e),function(e){var r,n,i;return r=a(t.tfhd,new Uint8Array([0,2,0,0,0,0,0,1])),n=a(t.tfdt,new Uint8Array([0,0,0,0,e.baseMediaDecodeTime>>>24&255,e.baseMediaDecodeTime>>>16&255,e.baseMediaDecodeTime>>>8&255,255&e.baseMediaDecodeTime])),i=p(e,72),a(t.traf,r,n,i)}(r))};return r.prototype={initSegment:function(r){var n=a(t.ftyp,e.FTYP);i.log(r);var o=c(r),s=new Uint8Array(n.byteLength+o.byteLength);return s.set(n,0),s.set(o,n.byteLength),s},mediaSegment:function(e,r,n,i){var o=m(e,r),s=function(e){return a(t.mdat,e)}(n),u=null;return(u=new Uint8Array(o.byteLength+s.byteLength)).set(o),u.set(s,o.byteLength),u}},new r},f=function(){this.map={}};f.prototype={put:function(t,e){this.map[t]=e},get:function(t){return this.map[t]},containsKey:function(t){return t in this.map},containsValue:function(t){for(var e in this.map)if(this.map[e]===t)return!0;return!1},isEmpty:function(t){return 0===this.size()},clear:function(){for(var t in this.map)delete this.map[t]},remove:function(t){delete this.map[t]},keys:function(){var t=new Array;for(var e in this.map)t.push(e);return t},values:function(){var t=new Array;for(var e in this.map)t.push(this.map[e]);return t},size:function(){var t=0;for(var e in this.map)t++;return t}};var l=f;function c(){var t=7,e=7,r=2,a=3,n=4,i=5,o=8,s=16,u=32,f=255,c=0,p=null;function m(){c=0,p=new l}function d(r,n){var i=n,o=c+i>>a;return i=c+n&t,r[o]>>e-(i&e)&1}function _(t,e){var r=c>>a,n=8*(r+1)-c;if(n<8)for(var i=0;i<3;i++){var o=t[r+i];o=0==i?o>>n<<n:2==i?o&255>>8-n|1<<n:0,t.set([o],r+i)}else t.set([0],r),t.set([1],r+1)}function h(t,e){var r=0;if(1===e)r=d(t,0);else for(var a=0;a<e;a++)r=(r<<1)+d(t,a);return c+=e,r}function g(t,e){for(var a=0,n=0,i=e;c+i<8*t.length&&!d(t,i++);)a++;if(0===a)return c+=1,0;n=1<<a;for(var o=a-1;o>=0;o--,i++)n|=d(t,i)<<o;return c+=a*r+1,n-1}function v(t,e){var a=g(t,e);return 1&a?(a+1)/r:-a/r}function y(t){p.put("cpb_cnt_minus1",g(t,0)),p.put("bit_rate_scale",h(t,n)),p.put("cpb_size_scale",h(t,n));for(var e=p.get("cpb_cnt_minus1"),r=new Array(e),a=new Array(e),o=new Array(e),s=0;s<=e;s++)r[s]=g(t,0),a[s]=g(t,0),o[s]=h(t,1);p.put("bit_rate_value_minus1",r),p.put("cpb_size_value_minus1",a),p.put("cbr_flag",o),p.put("initial_cpb_removal_delay_length_minus1",h(t,i)),p.put("cpb_removal_delay_length_minus1",h(t,i)),p.put("dpb_output_delay_length_minus1",h(t,i)),p.put("time_offset_length",h(t,i))}return m.prototype={parse:function(t){c=0,p.clear(),p.put("forbidden_zero_bit",h(t,1)),p.put("nal_ref_idc",h(t,r)),p.put("nal_unit_type",h(t,i)),p.put("profile_idc",h(t,o)),p.put("profile_compatibility",h(t,o)),p.put("level_idc",h(t,o)),p.put("seq_parameter_set_id",g(t,0));var e=p.get("profile_idc");if((100===e||110===e||122===e||244===e||44===e||83===e||86===e||118===e||128===e||138===e||139===e||134===e)&&(p.put("chroma_format_idc",g(t,0)),p.get("chroma_format_idc")===a&&p.put("separate_colour_plane_flag",h(t,1)),p.put("bit_depth_luma_minus8",g(t,0)),p.put("bit_depth_chroma_minus8",g(t,0)),p.put("qpprime_y_zero_transform_bypass_flag",h(t,1)),p.put("seq_scaling_matrix_present_flag",h(t,1)),p.get("seq_scaling_matrix_present_flag"))){for(var n=p.get("chroma_format_idc")!==a?o:12,l=new Array(n),m=0;m<n;m++)if(l[m]=h(t,1),l[m])for(var d=m<6?s:64,b=8,D=8,T=0;T<d;T++)D&&(D=(b+v(t,0)+256)%256),b=0===D?b:D;p.put("seq_scaling_list_present_flag",l)}if(p.put("log2_max_frame_num_minus4",g(t,0)),p.put("pic_order_cnt_type",g(t,0)),0===p.get("pic_order_cnt_type"))p.put("log2_max_pic_order_cnt_lsb_minus4",g(t,0));else if(1===p.get("pic_order_cnt_type")){p.put("delta_pic_order_always_zero_flag",h(t,1)),p.put("offset_for_non_ref_pic",v(t,0)),p.put("offset_for_top_to_bottom_field",v(t,0)),p.put("num_ref_frames_in_pic_order_cnt_cycle",g(t,0));for(var S=0;S<p.get("num_ref_frames_in_pic_order_cnt_cycle");S++)p.put("num_ref_frames_in_pic_order_cnt_cycle",v(t,0))}return p.put("num_ref_frames",g(t,0)),p.put("gaps_in_frame_num_value_allowed_flag",h(t,1)),p.put("pic_width_in_mbs_minus1",g(t,0)),p.put("pic_height_in_map_units_minus1",g(t,0)),p.put("frame_mbs_only_flag",h(t,1)),0===p.get("frame_mbs_only_flag")&&p.put("mb_adaptive_frame_field_flag",h(t,1)),p.put("direct_8x8_interence_flag",h(t,1)),p.put("frame_cropping_flag",h(t,1)),1===p.get("frame_cropping_flag")&&(p.put("frame_cropping_rect_left_offset",g(t,0)),p.put("frame_cropping_rect_right_offset",g(t,0)),p.put("frame_cropping_rect_top_offset",g(t,0)),p.put("frame_cropping_rect_bottom_offset",g(t,0))),p.put("vui_parameters_present_flag",h(t,1)),p.get("vui_parameters_present_flag")&&function(t){p.put("aspect_ratio_info_present_flag",h(t,1)),p.get("aspect_ratio_info_present_flag")&&(p.put("aspect_ratio_idc",h(t,o)),p.get("aspect_ratio_idc")===f&&(_(t),p.put("sar_width",h(t,s)),_(t),p.put("sar_height",h(t,s)))),p.put("overscan_info_present_flag",h(t,1)),p.get("overscan_info_present_flag")&&p.put("overscan_appropriate_flag",h(t,1)),p.put("video_signal_type_present_flag",h(t,1)),p.get("video_signal_type_present_flag")&&(p.put("video_format",h(t,a)),p.put("video_full_range_flag",h(t,1)),p.put("colour_description_present_flag",h(t,1)),p.get("colour_description_present_flag")&&(p.put("colour_primaries",h(t,o)),p.put("transfer_characteristics",h(t,o)),p.put("matrix_coefficients",h(t,o)))),p.put("chroma_loc_info_present_flag",h(t,1)),p.get("chroma_loc_info_present_flag")&&(p.put("chroma_sample_loc_type_top_field",g(t,0)),p.put("chroma_sample_loc_type_bottom_field",g(t,0))),p.put("timing_info_present_flag",h(t,1)),p.get("timing_info_present_flag")&&(p.put("num_units_in_tick",h(t,u)),p.put("time_scale",h(t,u)),p.put("fixed_frame_rate_flag",h(t,1))),p.put("nal_hrd_parameters_present_flag",h(t,1)),p.get("nal_hrd_parameters_present_flag")&&y(t),p.put("vcl_hrd_parameters_present_flag",h(t,1)),p.get("vcl_hrd_parameters_present_flag")&&y(t),(p.get("nal_hrd_parameters_present_flag")||p.get("vcl_hrd_parameters_present_flag"))&&p.put("low_delay_hrd_flag",h(t,1)),p.put("pic_struct_present_flag",h(t,1)),p.put("bitstream_restriction_flag",h(t,1)),p.get("bitstream_restriction_flag")&&(p.put("motion_vectors_over_pic_boundaries_flag",h(t,1)),p.put("max_bytes_per_pic_denom",g(t,0)),p.put("max_bits_per_mb_denom",g(t,0)))}(t),!0},getSizeInfo:function(){var t=0,e=0;0===p.get("chroma_format_idc")?t=e=0:1===p.get("chroma_format_idc")?t=e=r:p.get("chroma_format_idc")===r?(t=r,e=1):p.get("chroma_format_idc")===a&&(0===p.get("separate_colour_plane_flag")?t=e=1:1===p.get("separate_colour_plane_flag")&&(t=e=0));var n=p.get("pic_width_in_mbs_minus1")+1,i=p.get("pic_height_in_map_units_minus1")+1,o=(r-p.get("frame_mbs_only_flag"))*i,u=0,f=0,l=0,c=0;1===p.get("frame_cropping_flag")&&(u=p.get("frame_cropping_rect_left_offset"),f=p.get("frame_cropping_rect_right_offset"),l=p.get("frame_cropping_rect_top_offset"),c=p.get("frame_cropping_rect_bottom_offset"));var m=n*s*(o*s);return{width:n*s-t*(u+f),height:o*s-e*(r-p.get("frame_mbs_only_flag"))*(l+c),decodeSize:m}},getSpsValue:function(t){return p.get(t)},getCodecInfo:function(){return p.get("profile_idc").toString(s)+(p.get("profile_compatibility")<15?"0"+p.get("profile_compatibility").toString(s):p.get("profile_compatibility").toString(s))+p.get("level_idc").toString(s)}},new m}var p=function(){var t=0,e=0,r=!1,a=(new Uint8Array(1048576),new Uint8Array(["0x00","0x00","0x00","0x01"]),new c),n=0,f=null,l=null,p=0,m=!1,d=0,_={frameData:null,timeStamp:null,initSegmentData:null,mediaSample:null,dropPercent:0,dropCount:0,codecInfo:"",playback:!1},h={timestamp:null,timezone:null},g={},v=null,y=null,b=!1,D=!1,T=0,S=0,w=0,C=0,I=!1,F=0,A=null,M=null,k="",x=null,L=0,R=0,U={width:0,height:0},B=null,E=!1;function P(t){t!==k&&("video"===t?k="video":(k="canvas",m=!0,d=0,_.frameData.firstFrame=!0))}function O(t,e,r){var a="";return t*e>921600&&!1===r?(a="video",E&&L>0&&L<=3&&(a="canvas")):a="canvas",a}function z(){this.decoder=new s,this.firstDiffTime=0,this.firstTime=0,this.lastMSW=0}return z.prototype={setReturnCallback:function(t){this.rtpReturnCallback=t},setBufferfullCallback:function(t){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(t)},getVideoBuffer:function(t){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(t)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},setTimeStamp:function(t){this.timeData=t},getTimeStamp:function(){return this.timeData},ntohl:function(t){return(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3]>>>0},appendBuffer:function(t,e,r){if(r+e.length>=t.length){var a=new Uint8Array(t.length+1048576);a.set(t,0),t=a}return t.set(e,r),t},getFramerate:function(){return L},setGovLength:function(t){x=t},getGovLength:function(){return x},setDecodingTime:function(t){this.decodingTime=t},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(t){this.checkDelay=t},init:function(t){b=!1,r=!1,k=t,this.decoder.setIsFirstFrame(!1),this.videoBufferList=new o,this.firstDiffTime=0,this.checkDelay=!0,this.timeData=null},setFramerate:function(t){0<t&&"undefined"!==typeof t&&(L=t,null!==this.videoBufferList&&(this.videoBufferList.setMaxLength(6*L),this.videoBufferList.setBUFFERING(4*L)))},parseRTPData:function(o,s,c,x,L){var E=null,z={},j=(s[19]<<24)+(s[18]<<16)+(s[17]<<8)+s[16]>>>0,N=Date.UTC("20"+(j>>>26),(j>>>22&15)-1,j>>>17&31,j>>>12&31,j>>>6&63,63&j)/1e3;if(L.timeStampmsw,N+=(new Date).getTimezoneOffset()/60*3600,k||253!==s[4]||(B=0!==s[5],k=O(L.width,L.height,B)),""!==k){if(0==this.firstTime)this.firstTime=N,this.lastMSW=0,M=(s[21]<<8)+s[20],h={timestamp:this.firstTime,timestamp_usec:0};else{var G,W=(s[21]<<8)+s[20];G=W>M?W-M:W+65535-M,this.lastMSW+=G,N>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=N,h={timestamp:N,timestamp_usec:this.lastMSW},M=W}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||(this.setFramerate(Math.round(1e3/((h.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(h.timestamp_usec-this.getTimeStamp().timestamp_usec)))),i.log("setFramerate"+Math.round(1e3/((h.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(h.timestamp_usec-this.getTimeStamp().timestamp_usec))))),this.setTimeStamp(h);for(var V=s[22],H=s.subarray(24+V,s.length-8),X=s.subarray(s.length-8,s.length),Y=(X[7],X[6],X[5],X[4],[]),q=0;q<=H.length;)if(0==H[q])if(0==H[q+1])if(1==H[q+2]){if(Y.push(q),5==(31&H[q+=3])||1==(31&H[q]))break}else 0==H[q+2]?q++:q+=3;else q+=2;else q+=1;var J="P";t=(s[21]<<8)+s[20];var Z=0;for(q=0;q<Y.length;q++)switch(E=H.subarray(Y[q]+3,Y[q+1]),31&H[Y[q]+3]){default:break;case 1:J="P",Z=Y[q]-1;break;case 5:J="I",Z=Y[q]-1;break;case 28:break;case 7:a.parse(E);var K=L;n=a.getSizeInfo().decodeSize,null!==f&&null!==l&&f.width===K.width&&f.height===K.height&&l===a.getCodecInfo()||(b=!1,f=K,l=a.getCodecInfo(),this.decoder.setIsFirstFrame(!1)),w=T=K.width,C=S=K.height,v=E,U.width==K.width&&U.height==K.height||(0!=U.width?(U.width=K.width,U.height=K.height,z.resolution=U,z.resolution.decodeMode=O(U.width,U.height,B),z.resolution.encodeMode="h264"):(U.width=K.width,U.height=K.height,z.decodeStart=U,z.decodeStart.decodeMode=k,z.decodeStart.encodeMode="h264"));break;case 8:y=E;break;case 6:case 9:}if(c&&!1===m&&(z.backupData={stream:new Uint8Array(H),frameType:J,width:w,height:C,codecType:"h264"},null!==h.timestamp&&"undefined"!==typeof h.timestamp?z.backupData.timestamp_usec=h.timestamp_usec:z.backupData.timestamp=(t/90).toFixed(0)),"canvas"===k){var Q=1e3*h.timestamp+h.timestamp_usec;if(0==this.firstDiffTime?(p=0,this.firstDiffTime=Date.now()-Q,i.log("firstDiff: "+R)):(Q-A<0&&(this.firstDiffTime=p+(Date.now()-Q).toFixed(0)),(p=Date.now()-Q-this.firstDiffTime)<0&&(this.firstDiffTime=0,p=0),p>8e3&&(z.error={errorCode:101},this.rtpReturnCallback(z))),A=Q,e!==n&&(this.decoder.free(),e=n,this.decoder.setOutputSize(e)),!0===m&&"P"===J)return;!0===m&&(m=!1),"I"===J&&d<2&&d++,_.frameData=null,!0===c&&!0===r||(_.frameData=this.decoder.decode(H)),_.timeStamp=null,h=null===h.timestamp?this.getTimeStamp():h,_.timeStamp=h}else{var $=null;if(b?_.initSegmentData=null:(b=!0,L={id:1,width:T,height:S,type:"video",profileIdc:a.getSpsValue("profile_idc"),profileCompatibility:0,levelIdc:a.getSpsValue("level_idc"),sps:[v],pps:[y],timescale:1e3,fps:this.getFramerate()},i.log(JSON.stringify(L)),_.initSegmentData=u.initSegment(L),_.codecInfo=a.getCodecInfo()),Z||i.log("11111111111111111111111111111111111111111"),"I"===J){var tt=Z;$=H.subarray(tt,H.length)}else $=H.subarray(Z,H.length);var et=$.length-4;$[0]=(4278190080&et)>>>24,$[1]=(16711680&et)>>>16,$[2]=(65280&et)>>>8,$[3]=255&et;var rt=this.getFramerate(),at={duration:Math.round(1/rt*1e3),size:$.length,frame_time_stamp:null,frameDuration:null};if(r)at.frame_time_stamp=t,_.frameData=new Uint8Array($),_.mediaSample=at;else{if(!1===c){if(at.frame_time_stamp=1e3*h.timestamp+h.timestamp_usec-R,!1===D)at.frame_time_stamp=0,R=1e3*h.timestamp+h.timestamp_usec,at.frameDuration=0,g=at,D=!0;else{var nt=g.frame_time_stamp,it=at.frame_time_stamp;at.frameDuration=Math.abs(it-nt),at.frameDuration>3e3&&(at.frameDuration=0),g=at}_.frameData=new Uint8Array($),_.mediaSample=at}h=null===h.timestamp?this.getTimeStamp():h,_.timeStamp=h}}var ot=w*C;if(!0===r&&(NaN.toFixed(0),ot>786432?(P("video"),z.decodeMode="video"):(P("canvas"),z.decodeMode="canvas")),_.playback=r,_.frameData.frameIndex=L.frameIndex,z.decodedData=_,!0===I)return"I"===J&&F++,2===F&&(F=0,I=!1),void i.info("H264Session::stop");this.rtpReturnCallback(z)}},findIFrame:function(){if(null!==this.videoBufferList){var t=this.videoBufferList.findIFrame();if(null===t||"undefined"===typeof t)return!1;var e={};return this.setTimeStamp(t.timeStamp),e.frameData=this.decoder.decode(t.buffer),e.timeStamp=t.timeStamp,e}},setInitSegment:function(){b=!1,f=null,l=null},setLessRate:function(t){E=t}},new z};var m=function(){var t,e,r,a,n,o,s,u,f,l=null,c=new Uint8Array,p=!1;function m(){l=Module._OpenDecoder(1,0,0),m.prototype.setIsFirstFrame(!1)}return m.prototype={init:function(){i.log("H265 Decoder init")},setOutputSize:function(t){u!=2*t&&(u=2*t,f=Module._malloc(u),c=new Uint8Array(Module.HEAPU8.buffer,f,u))},decode:function(i,f){if(t=Date.now(),e=new Uint8Array(i),c.set(e),r=Module._FrameAlloc(),Module._DecodeFrame(l,c.byteOffset,i.byteLength,u,r),a=Date.now()-t,o=Module._getYLength(r),n=Module._getHeight(r),!m.prototype.isFirstFrame())return m.prototype.setIsFirstFrame(!0),{firstFrame:!0};if(o>0&&n>0){t=Date.now();var p=new Uint8Array(c);return s={data:p,option:{yaddr:Module._getY(r),uaddr:Module._getU(r),vaddr:Module._getV(r),ylen:o,height:n,beforeDecoding:t},width:o,height:n,codecType:"h265",decodingTime:a,frameType:f},Module._FrameFree(r),s}},setIsFirstFrame:function(t){p=t},isFirstFrame:function(){return p},free:function(){Module._free(f),f=null}},new m};function d(){var t=null,e=null,r=0,a=0,n=0,i=0,o=0;function s(){0,t=new l}function u(){return 0==n&&(i=function(){if(a>=r)return 0;var t=e[a++];return 0==t?(o++,a<r&&2==o&&3==e[a]&&(a++,o=0)):o=0,t}(),n=8),i>>--n&1}function f(t,e){for(var r=0;e>0;)r<<=1,r|=u(),e--;return r}function c(t,e){for(var n=0;a<r&&0==u();)n++;return f(0,n)+((1<<n)-1)}return s.prototype={parse:function(e){e,0,t.clear(),t.put("forbidden_zero_bit",f(0,1)),t.put("nal_unit_type",f(0,6)),t.put("nuh_layer_id",f(0,6)),t.put("nuh_temporal_id_plus1",f(0,3)),t.put("sps_video_parameter_set_id",f(0,4)),0===t.get("nuh_layer_id")?t.put("sps_max_sub_layers_minus1",f(0,3)):t.put("sps_ext_or_max_sub_layers_minus1",f(0,3));var r=0!==t.get("nuh_layer_id")&&7===t.get("sps_ext_or_max_sub_layers_minus1");return r||(t.put("sps_max_sub_layers_minus1",f(0,1)),function(e,r){if(e){t.put("general_profile_space",f(0,2)),t.put("general_tier_flag",f(0,1)),t.put("general_profile_idc",f(0,5));for(var a=new Array(32),n=0;n<32;n++)a[n]=f(0,1);t.put("general_progressive_source_flag",f(0,1)),t.put("general_interlaced_source_flag",f(0,1)),t.put("general_non_packed_constraint_flag",f(0,1)),t.put("general_frame_only_constraint_flag",f(0,1));var i=t.get("general_profile_idc");4===i||a[4]||5===i||a[5]||6===i||a[6]||7===i||a[7]||8===i||a[8]||9===i||a[9]||10===i||a[10]?(t.put("general_max_12bit_constraint_flag",f(0,1)),t.put("general_max_10bit_constraint_flag",f(0,1)),t.put("general_max_8bit_constraint_flag",f(0,1)),t.put("general_max_422chroma_constraint_flag",f(0,1)),t.put("general_max_420chroma_constraint_flag",f(0,1)),t.put("general_max_monochrome_constraint_flag",f(0,1)),t.put("general_intra_constraint_flag",f(0,1)),t.put("general_one_picture_only_constraint_flag",f(0,1)),t.put("general_lower_bit_rate_constraint_flag",f(0,1)),5===i||a[5]||9===i||a[9]||10===i||a[10]?(t.put("general_max_14bit_constraint_flag",f(0,1)),t.put("general_reserved_zero_33bits",f(0,33))):t.put("general_reserved_zero_34bits",f(0,34))):t.put("general_reserved_zero_43bits",f(0,43)),i>=1&&i<=5||a[1]||a[2]||a[3]||a[4]||a[5]||a[9]?t.put("general_inbld_flag",f(0,1)):t.put("general_reserved_zero_bit",f(0,1))}t.put("general_level_idc",f(0,8));var o=new Array(r),s=new Array(r);for(_=0;_<r;_++)o[_]=f(0,1),s[_]=f(0,1);var u=new Array(8),l=new Array(r),c=new Array(r),p=new Array(r),m=[],d=new Array(r);if(r>0)for(var _=r;_<8;_++)u[_]=f(0,2);for(_=0;_<r;_++){if(o[_]){for(c[_]=f(0,2),p[_]=f(0,1),l[_]=f(0,5),n=0;n<32;n++)m[_][n]=f(0,1);t.put("sub_layer_progressive_source_flag",f(0,1)),t.put("sub_layer_interlaced_source_flag",f(0,1)),t.put("sub_layer_non_packed_constraint_flag",f(0,1)),t.put("sub_layer_frame_only_constraint_flag",f(0,1)),4===l[_]||m[_][4]||5===l[_]||m[_][5]||6===l[_]||m[_][6]||7===l[_]||m[_][7]||8===l[_]||m[_][8]||9===l[_]||m[_][9]||10===l[_]||m[_][10]?(t.put("sub_layer_max_12bit_constraint_flag",f(0,1)),t.put("sub_layer_max_10bit_constraint_flag",f(0,1)),t.put("sub_layer_max_8bit_constraint_flag",f(0,1)),t.put("sub_layer_max_422chroma_constraint_flag",f(0,1)),t.put("sub_layer_max_420chroma_constraint_flag",f(0,1)),t.put("sub_layer_max_monochrome_constraint_flag",f(0,1)),t.put("sub_layer_intra_constraint_flag",f(0,1)),t.put("sub_layer_one_picture_only_constraint_flag",f(0,1)),t.put("sub_layer_lower_bit_rate_constraint_flag",f(0,1)),5===l[_]||m[_][5]?(t.put("sub_layer_max_14bit_constraint_flag",f(0,1)),t.put("sub_layer_lower_bit_rate_constraint_flag",f(0,1)),d[_]=f(0,33)):d[_]=f(0,34)):t.put("sub_layer_reserved_zero_43bits",f(0,43)),l[_]>=1&&l[_]<=5||9==l[_]||m[1]||m[2]||m[3]||m[4]||m[5]||m[9]?t.put("sub_layer_inbld_flag",f(0,1)):t.put("sub_layer_reserved_zero_bit",f(0,1))}s[_]&&t.put("sub_layer_level_idc",f(0,8))}}(1,t.get("sps_max_sub_layers_minus1"))),f(0,84),t.put("sps_seq_parameter_set_id",c()),r?(t.put("update_rep_format_flag",f(0,1)),t.get("update_rep_format_flag")&&t.put("sps_rep_format_idx",f(0,8))):(t.put("chroma_format_idc",c()),3===t.get("chroma_format_idc")&&t.put("separate_colour_plane_flag",f(0,1)),t.put("pic_width_in_luma_samples",c()),t.put("pic_height_in_luma_samples",c()),t.put("conformance_window_flag",f(0,1)),t.get("conformance_window_flag")&&(t.put("conf_win_left_offset",c()),t.put("conf_win_right_offset",c()),t.put("conf_win_top_offset",c()),t.put("conf_win_bottom_offset",c()))),!0},parse2:function(s){var u=s.length;if(s,e=s,r=s.length,a=0,n=0,i=0,o=0,0,t.clear(),u<20)return!1;f(0,16),f(0,4);var l=f(0,3);if(t.put("sps_max_sub_layers_minus1",l),l>6)return!1;f(0,1),f(0,2),f(0,1);f(0,5);f(0,32),f(0,1),f(0,1),f(0,1),f(0,1),f(0,43),f(0,1),t.put("general_level_idc",f(0,8));for(var p=[],m=[],d=0;d<l;d++)p[d]=f(0,1),m[d]=f(0,1);if(l>0)for(d=l;d<8;d++)f(0,2);for(d=0;d<l;d++)p[d]&&(f(0,2),f(0,1),f(0,5),f(0,32),f(0,1),f(0,1),f(0,1),f(0,1),f(0,44)),m[d]&&f(0,8);var _=c();if(t.put("sps_seq_parameter_set_id",_),_>15)return!1;var h=c();return t.put("chroma_format_idc",h),!(_>3)&&(3==h&&f(0,1),t.put("pic_width_in_luma_samples",c()),t.put("pic_height_in_luma_samples",c()),f(0,1)&&(c(),c(),c(),c()),c()==c())},getSizeInfo:function(){var e=t.get("pic_width_in_luma_samples"),r=t.get("pic_height_in_luma_samples");if(t.get("conformance_window_flag")){var a=t.get("chroma_format_idc"),n=t.get("separate_colour_plane_flag");"undefined"===typeof n&&(n=0);var i=1!==a&&2!==a||0!==n?1:2,o=1===a&&0===n?2:1;e-=i*t.get("conf_win_right_offset")+i*t.get("conf_win_left_offset"),r-=o*t.get("conf_win_bottom_offset")+o*t.get("conf_win_top_offset")}return{width:e,height:r,decodeSize:e*r}},getSpsValue:function(e){return t.get(e)}},new s}var _=function(){var t,e=0,r=0,a=0,n=0,s=new d,u={frameData:null,timeStamp:null},f={timestamp:null,timezone:null},l=0,c=0,p=null,_=0,h={width:0,height:0},g=0,v=0;function y(){this.decoder=m(),this.firstTime=0,this.lastMSW=0}return y.prototype={setReturnCallback:function(t){this.rtpReturnCallback=t},setBufferfullCallback:function(t){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(t)},getVideoBuffer:function(t){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(t)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},ntohl:function(t){return(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3]>>>0},appendBuffer:function(t,e,r){if(r+e.length>=t.length){var a=new Uint8Array(t.length+1048576);a.set(t,0),t=a}return t.set(e,r),t},setGovLength:function(t){p=t},getGovLength:function(){return p},setDecodingTime:function(t){this.decodingTime=t},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(t){this.checkDelay=t},init:function(){this.decoder.setIsFirstFrame(!1),this.videoBufferList=new o,this.firstDiffTime=0,this.checkDelay=!0,this.timeData=null},parseRTPData:function(o,p,m,d,_){var y=null,b={},D=(p[19]<<24)+(p[18]<<16)+(p[17]<<8)+p[16]>>>0,T=Date.UTC("20"+(D>>>26),(D>>>22&15)-1,D>>>17&31,D>>>12&31,D>>>6&63,63&D)/1e3;if(T+=(new Date).getTimezoneOffset()/60*3600,0==this.firstTime)this.firstTime=T,this.lastMSW=0,r=(p[21]<<8)+p[20],f={timestamp:this.firstTime,timestamp_usec:0};else{var S,w=(p[21]<<8)+p[20];S=w>r?w-r:w+65535-r,this.lastMSW+=S,T>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=T,f={timestamp:T,timestamp_usec:this.lastMSW},r=w}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||(this.setFramerate(Math.round(1e3/((f.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(f.timestamp_usec-this.getTimeStamp().timestamp_usec)))),i.log("setFramerate"+Math.round(1e3/((f.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(f.timestamp_usec-this.getTimeStamp().timestamp_usec))))),this.setTimeStamp(f);var C=p[22];t=p.subarray(24+C,p.length-8),e=(p[21]<<8)+p[20];for(var I=[],F=0;F<=t.length;)if(0==t[F])if(0==t[F+1])if(1==t[F+2]){if(I.push(F),5==(31&t[F+=3])||1==(31&t[F]))break}else 0==t[F+2]?F++:F+=3;else F+=2;else F+=1;var A="P";for(F=0;F<I.length;F++)switch(y=t.subarray(I[F]+3,I[F+1]),t[I[F]+3]>>1&63){default:break;case 33:A="I",s.parse2(y);var M=_;n=s.getSizeInfo().decodeSize,l=M.width,c=M.height,h.width==M.width&&h.height==M.height||(0!=h.width?(h.width=M.width,h.height=M.height,b.resolution=h,b.resolution.decodeMode="canvas",b.resolution.encodeMode="h265"):(h.width=M.width,h.height=M.height,b.decodeStart=h,b.decodeStart.decodeMode="canvas",b.decodeStart.encodeMode="h265"))}var k=1e3*f.timestamp+f.timestamp_usec;0==this.firstDiffTime?(g=0,this.firstDiffTime=Date.now()-k,i.log("firstDiff: 0")):(k-v<0&&(this.firstDiffTime=g+(Date.now()-k).toFixed(0)),(g=Date.now()-k-this.firstDiffTime)<0&&(this.firstDiffTime=0,g=0),g>8e3&&(b.error={errorCode:101},this.rtpReturnCallback(b))),v=k,u.frameData=null,a!==n&&(this.decoder.free(),a=n,this.decoder.setOutputSize(a)),u.frameData=this.decoder.decode(t),u.frameData.frameType=A,u.frameData.frameIndex=_.frameIndex,u.timeStamp=null,f=null===f.timestamp?this.getTimeStamp():f,u.timeStamp=f,m&&(b.backupData={stream:t,frameType:A,width:l,height:c,codecType:"h265"},null!==f.timestamp&&"undefined"!==typeof f.timestamp?b.backupData.timestamp_usec=f.timestamp_usec:b.backupData.timestamp=(e/90).toFixed(0)),b.decodedData=u,this.rtpReturnCallback(b)},findIFrame:function(){if(null!==this.videoBufferList){var t=this.videoBufferList.findIFrame();if(null===t||"undefined"===typeof t)return!1;var e={};return this.setTimeStamp(t.timeStamp),e.frameData=this.decoder.decode(t.buffer),e.timeStamp=t.timeStamp,e}},getFramerate:function(){return _},setFramerate:function(t){0<t&&"undefined"!==typeof t&&(_=t,null!==this.videoBufferList&&(this.videoBufferList.setMaxLength(6*_),this.videoBufferList.setBUFFERING(4*_)))},getTimeStamp:function(){return this.timeData},setTimeStamp:function(t){this.timeData=t}},new y};var h=function(){var t,e,r=!1;function a(){i.log("MJPEG Decoder")}return a.prototype={setIsFirstFrame:function(t){r=t},isFirstFrame:function(){return r},setResolution:function(r,a){t=r,e=a},decode:function(r,n){return a.prototype.isFirstFrame()?{data:r,width:t,height:e,codecType:"mjpeg"}:(a.prototype.setIsFirstFrame(!0),{firstFrame:!0})}},new a},g=function(){var t=0,e=0,r={frameData:null,timeStamp:null},a={timestamp:null,timezone:null};var n=0,s=0,u=0,f=0,l=null,c=null,p=null,m=0,d=0,_=0,g={width:0,height:0};function v(){this.decoder=new h,this.firstTime=0,this.lastMSW=0}return v.prototype={init:function(){this.decoder.setIsFirstFrame(!1),this.videoBufferList=new o,this.timeData=null},parseRTPData:function(o,p,m,h,v){var y=new Uint8Array(1048576);t=v.width,e=v.height,l={};var b=p[22],D=p.subarray(24+b,p.length-8);c=D.length;var T=(p[19]<<24)+(p[18]<<16)+(p[17]<<8)+p[16]>>>0,S=Date.UTC("20"+(T>>>26),(T>>>22&15)-1,T>>>17&31,T>>>12&31,T>>>6&63,63&T)/1e3;if(S-=28800,0==this.firstTime)this.firstTime=S,this.lastMSW=0,f=(p[21]<<8)+p[20],a={timestamp:this.firstTime,timestamp_usec:0};else{var w,C=(p[21]<<8)+p[20];w=C>f?C-f:C+65535-f,this.lastMSW+=w,S>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=S,a={timestamp:S,timestamp_usec:this.lastMSW},f=C}0!==this.getFramerate()&&"undefined"!==typeof this.getFramerate()||"undefined"===typeof this.getTimeStamp()||this.setFramerate(Math.round(1e3/((a.timestamp-this.getTimeStamp().timestamp===0?0:1e3)+(a.timestamp_usec-this.getTimeStamp().timestamp_usec)))),this.setTimeStamp(a),u=(p[21]<<8)+p[20],s=c,(y=this.appendBuffer(y,D,n))[(n+=c)+s-2]=255,y[n+s-1]=217,g.width==t&&g.height==e||(0!=g.width?(g.width=t,g.height=e,l.resolution=g,l.resolution.decodeMode="canvas",l.resolution.encodeMode="mjpeg"):(g.width=t,g.height=e,l.decodeStart=g,l.decodeStart.decodeMode="canvas",l.decodeStart.encodeMode="mjpeg"));var I=1e3*a.timestamp+a.timestamp_usec;0==this.firstDiffTime?(d=0,this.firstDiffTime=Date.now()-I,i.log("firstDiff: "+this.firstTime)):(I-_<0&&(this.firstDiffTime=d+(Date.now()-I).toFixed(0)),(d=Date.now()-I-this.firstDiffTime)<0&&(this.firstDiffTime=0,d=0),d>8e3&&(l.error={errorCode:101},this.rtpReturnCallback(l))),_=I,r.frameData=null,this.decoder.setResolution(t,e),r.frameData=this.decoder.decode(y.subarray(0,n)),r.timeStamp=null,a=null===a.timestamp?this.getTimeStamp():a,r.timeStamp=a,!0===m&&(l.backupData={stream:y.subarray(0,n),width:t,height:e,codecType:"mjpeg"},null!==a.timestamp&&"undefined"!==typeof a.timestamp?l.backupData.timestamp_usec=a.timestamp_usec:l.backupData.timestamp=(u/90).toFixed(0)),n=0,r.playback=!1,l.decodedData=r,this.rtpReturnCallback(l)},getVideoBuffer:function(t){if(null!==this.videoBufferList)return this.videoBufferList.searchNodeAt(t)},clearBuffer:function(){null!==this.videoBufferList&&this.videoBufferList.clear()},findCurrent:function(){null!==this.videoBufferList&&this.videoBufferList.searchTimestamp(this.getTimeStamp())},findIFrame:function(){null!==this.videoBufferList&&this.videoBufferList.findIFrame()},SetRtpInterlevedID:function(t){this.interleavedID=t},setTimeStamp:function(t){this.timeData=t},getTimeStamp:function(){return this.timeData},getRTPPacket:function(t,e){},calculatePacketTime:function(t){},ntohl:function(t){return(t[0]<<24)+(t[1]<<16)+(t[2]<<8)+t[3]>>>0},appendBuffer:function(t,e,r){if(r+e.length>=t.length){var a=new Uint8Array(t.length+1048576);a.set(t,0),t=a}return t.set(e,r),t},setFramerate:function(t){0<t&&"undefined"!==typeof t&&(m=t,null!==this.videoBufferList&&(this.videoBufferList.setMaxLength(6*m),this.videoBufferList.setBUFFERING(4*m)))},getFramerate:function(){return m},setReturnCallback:function(t){this.rtpReturnCallback=t},setBufferfullCallback:function(t){null!==this.videoBufferList&&this.videoBufferList.setBufferFullCallback(t)},setGovLength:function(t){p=t},getGovLength:function(){return p},setDecodingTime:function(t){this.decodingTime=t},getDropPercent:function(){return 0},getDropCount:function(){return 0},initStartTime:function(){this.firstDiffTime=0,this.calcGov=0},setCheckDelay:function(t){this.checkDelay=t}},new v},v=function(){var t,e=null,r={1:"VideoSynopsis",2:"TrafficGate",3:"ElectronicPolice",4:"SinglePtzParking",5:"PtzParking",6:"Traffic",7:"Normal",8:"Prison",9:"ATM",10:"MetroIVS",11:"FaceDetection",12:"FaceRecognition",13:"NumberStat",14:"HeatMap",15:"VideoDiagnosis",16:"VideoEnhance",17:"SmokeFireDetect",18:"VehicleAnalyse",19:"PersonFeature",20:"SDFaceDetect",21:"HeatMapPlan",22:"ATMFD",23:"SCR",24:"NumberStatPlan",25:"CourseRecord",26:"Highway",27:"City",28:"LeTrack",29:"ObjectStruct",30:"Stereo",31:"StereoPc",32:"HumanDetect",33:"SDPedestrain",34:"FaceAnalysis",35:"FaceAttribute",36:"FacePicAnalyse",37:"SDEP",38:"XRayDetect",39:"ObjectDetect",40:"CrowdDistriMap",41:"StereoBehavior"};function a(){this.firstTime=0,this.lastMSW=0}function n(t){for(var e=[].slice.call(t),r="",a=0;a<e.length;a++)r+=String.fromCharCode(e[a]);return decodeURIComponent(escape(r))}function o(t){var e={result:!0,type:0};return e.params=JSON.parse(n(t)),e}function s(t){var e={result:!1},a=0,n=(t[a+1]<<8)+t[a];if(1!==n&&2!==n)return e;e.result=!0,e.type=5,e.params=null;var i=t[a+=2];if(0===i)return e;var o=t[a+=1];a+=1,e.params={},e.params.coordinate=128&o?8192:1024,e.params.isTrack=!!(127&o),e.params.object=[];for(var s=0;s<i;s++){var u={};u.objectId=(t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a],a+=4,u.operateType=t[a];var f=t[a+=1];a+=1,u.objectType=t[a];var l=t[a+=1];a+=1,a+=1,a+=1,u.classID=r[t[a]],a+=1,u.subType=t[a],a+=1,l>0&&(u.fatherId=[]);for(var c=0;c<l;c++)u.fatherId.push((t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a]),a+=4;f>0&&(u.track=[]);for(var p=0;p<f;p++){var m=(t[a+1]<<8)+t[a],d=(t[(a+=2)+1]<<8)+t[a],_=(t[(a+=2)+1]<<8)+t[a],h=(t[(a+=2)+1]<<8)+t[a];a+=2,u.track.push([m-_,d-h,m+_,d+h])}e.params.object.push(u)}return e}function u(t){for(var e={result:!1,type:20,params:[]},r=(t[0],t.length),a=0,i=t.slice(4),o=function(){var t={};t.objectId=(i[a+3]<<24)+(i[a+2]<<16)+(i[a+1]<<8)+(i[a+0]<<0),a+=4,t.result=!0,t.params={},t.custom=(i[a+1]<<8)+i[a],a+=2,t.objectStatus=i[a];var e=i[a+=1];a+=1,t.params.object=[];for(var r=null,o=0;o<e;o++){switch(i[a]){case 1:r=c(i.slice(a));break;case 2:r=l(i.slice(a));break;case 3:r=f(i.slice(a));break;case 4:r=p(i.slice(a))}t.params.object.push(r.info),a+=r.offset}1!=t.objectStatus&&3!=t.objectStatus||(t.params=null),0==e&&(t.params=null);var s=(i[a+1]<<8)+i[a];a+=2;var u=n(i.slice(a,a+s));return t.appendInfo=String.fromCharCode.apply(null,i.slice(a,a+s)),a+=s,t.appendInfo=u,t};a<r-4;)e.params.push(o());return e}function f(t){var e=0,r={type:t[0]};e+=1,r.pointCount=t[e],e+=1,r.lineWidth=t[e],e+=1,r.strokeStyle=t[e],e+=1,r.borderColor=[t[e+1],t[e+2],t[e+3],t[e]],r.borderColorType="RGBA",e+=4,r.fillColor=[t[e+1],t[e+2],t[e+3],t[e]],r.fillColorType="RGBA",e+=4,r.coordinate=[];for(var a=0;a<r.pointCount;a++){var n=(t[e+1]<<8)+t[e],i=(t[(e+=2)+1]<<8)+t[e];e+=2,r.coordinate.push([n,i])}return{info:r,offset:e}}function l(t){var e=0,r={type:t[0]};e+=1,r.pointCount=t[e],e+=1,r.lineWidth=t[e],e+=1,r.strokeStyle=t[e],e+=1,r.lineColor=[t[e+1],t[e+2],t[e+3],t[e]],r.lineColorType="RGBA",e+=4,r.coordinate=[];for(var a=0;a<r.pointCount;a++){var n=(t[e+1]<<8)+t[e],i=(t[(e+=2)+1]<<8)+t[e];e+=2,r.coordinate.push([n,i])}return{info:r,offset:e}}function c(t){var e=0,r={type:t[0]};e+=1,r.lineWidth=t[e],e+=1,r.strokeStyle=t[e],e+=1,e+=1,r.radius=(t[e+1]<<8)+t[e],e+=2;var a=(t[(e+=2)+1]<<8)+t[e],n=(t[(e+=2)+1]<<8)+t[e];return e+=2,r.coordinate=[a,n],r.borderColor=[t[e+1],t[e+2],t[e+3],t[e]],r.borderColorType="RGBA",e+=4,r.fillColor=[t[e+1],t[e+2],t[e+3],t[e]],r.fillColorType="RGBA",{info:r,offset:e+=4}}function p(t){var e=0,r={type:t[0]};e+=1,r.encodeType=t[e],e+=1;var a=(t[(e+=2)+1]<<8)+t[e],n=(t[(e+=2)+1]<<8)+t[e];return e+=2,r.coordinate=[a,n],r.fontColor=[t[e+1],t[e+2],t[e+3],t[e]],e+=4,r.colorType="RGBA",r.fontSize=t[e],e+=1,r.textAlign=t[e],e+=1,r.textLength=(t[e+1]<<8)+t[e],e+=2,r.content=String.fromCharCode.apply(null,t.slice(e,e+r.textLength)),{info:r,offset:e+=r.textLength}}function m(t,e){e.hasOwnProperty("attribute80")||(e.attribute80=[]);var r=1,a=t[r];r+=1;var n={color:{}};n.color.valid=t[r],r+=1,n.carModel=t[r],r+=1,n.color.red=t[r],r+=1,n.color.green=t[r],r+=1,n.color.blue=t[r],r+=1,n.color.alpha=t[r],r+=1,n.brand=(t[r+1]<<8)+t[r],r+=2,n.subBrand=(t[r+1]<<8)+t[r],r+=2,n.year=(t[r+1]<<8)+t[r],r+=2,n.reliability=t[r],r+=1;var i=(t[(r+=1)+1]<<8)+t[r],o=(t[(r+=2)+1]<<8)+t[r],s=(t[(r+=2)+1]<<8)+t[r],u=(t[(r+=2)+1]<<8)+t[r];return r+=2,n.windowPosition=[i-s,o-u,i+s,o+u],e.attribute80.push(n),a}function d(t,e){e.hasOwnProperty("attribute81")||(e.attribute81=[]);var r={},a=1,n=t[a],i=(t[(a+=1)+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a];return a+=2,r.mainPosition=[i-s,o-u,i+s,o+u],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a],a+=2,r.coPosition=[i-s,o-u,i+s,o+u],r.mainSafetyBelt=t[a]>>2&3,r.coSafetyBelt=3&t[a],a+=1,r.mainSunvisor=t[a]>>2&3,r.coSunvisor=3&t[a],a+=1,e.attribute81.push(r),n}function _(t,e){e.hasOwnProperty("attribute82")||(e.attribute82=[]);var r={},a=1,n=t[a];return a+=1,r.plateEncode=t[a],a+=1,r.plateInfoLen=t[a],a+=1,r.plateInfo=t.subarray(a,a+r.plateInfoLen),e.attribute82.push(r),n}function h(t,e){e.hasOwnProperty("attribute83")||(e.attribute83=[]);var r={},a=1,n=t[a];return a+=1,r.color={},r.color.valid=t[a],a+=1,r.color.red=t[a],a+=1,r.color.green=t[a],a+=1,r.color.blue=t[a],a+=1,r.color.alpha=t[a],a+=1,r.country=String.fromCharCode.apply(null,t.subarray(a,a+4)),a+=4,r.plateType=(t[a+1]<<8)+t[a],a+=2,a+=1,r.plateWidth=(t[a+1]<<8)+t[a],e.attribute83.push(r),n}function g(t,e){e.hasOwnProperty("attribute84")||(e.attribute84=[]);var r={},a=1,n=t[a];a+=1,r.fatherCount=t[a],a+=1,r.trackCount=t[a],a+=1,r.trackType=t[a],a+=1,a+=3,r.fatherCount>0&&(r.fatherID=[]);for(var i=0;i<r.fatherCount;i++)r.fatherID.push((t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a]),a+=4;r.trackCount>0&&(r.track=[]);for(var o=0;o<r.trackCount;o++){var s=(t[a+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a],f=(t[(a+=2)+1]<<8)+t[a],l=(t[(a+=2)+1]<<8)+t[a];a+=2,r.track.push([s-f,u-l,s+f,u+l])}return e.attribute84.push(r),n}function v(t,e){e.hasOwnProperty("attribute85")||(e.attribute85=[]);var r={},a=1,n=t[a];a+=1,r.colorSpace=t[a],a+=1,r.mainColorCount=t[a],a+=1,r.mainColorCount>0&&(r.mainColorInfo=[]);for(var i=0;i<r.mainColorCount;i++){var o={},s=(t[a+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a],f=(t[(a+=2)+1]<<8)+t[a],l=(t[(a+=2)+1]<<8)+t[a];a+=2,o.rect=[s-f,u-l,s+f,u+l],o.color=(t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a],a+=4,r.mainColorInfo.push(o)}return e.attribute85.push(r),n}function y(t,e){e.hasOwnProperty("attribute86")||(e.attribute86=[]);var r={},a=1,n=t[a];return a+=1,a+=1,r.speedType=t[a],a+=1,r.speed=t[a+1]<<8+t[a],a+=2,r.speedX=t[a+1]<<8+t[a],a+=2,r.speedY=(t[a+1]<<8)+t[a],e.attribute86.push(r),n}function b(t,e){e.hasOwnProperty("attribute87")||(e.attribute87=[]);var r={},a=1,n=t[a];a+=1;var i=(t[(a+=2)+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a];return r.track=[[i-s,o-u,i+s,o+u]],e.attribute87.push(r),n}function D(t,e){e.hasOwnProperty("attribute88")||(e.attribute88=[]);var r={},a=1;return a+=1,r.age=t[a],a+=1,r.sex=t[a],a+=1,r.face=t[a],a+=1,r.glass=t[a],a+=1,r.hat=t[a],a+=1,r.call=t[a],a+=1,r.backpack=t[a],a+=1,r.umbrella=t[a],a+=1,r.height=t[a],a+=1,r.mask=t[a]>>2&3,r.beard=3&t[a],e.attribute88.push(r),len}function T(t,e){e.hasOwnProperty("attribute89")||(e.attribute89=[]);var r={},a=1,n=t[a];a+=1,r.yawAngle=parseInt((t[a+1]<<8)+t[a]),a+=2,r.rollAngle=parseInt((t[a+1]<<8)+t[a]),a+=2,r.pitchAngle=parseInt((t[a+1]<<8)+t[a]);var i=(t[(a+=2)+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a];a+=2,r.lEyePos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.rEyePos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.nosePos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.lMouthPos=[i,o],i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.rMouthPos=[i,o];var s=t[a];a+=3,s>0&&(r.featurePos=[]);for(var u=0;u<s;u++)i=(t[a+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],a+=2,r.featurePos.push([i,o]);return e.attribute89.push(r),n}function S(t,e){e.hasOwnProperty("attribute8C")||(e.attribute8C=[]);var r={},a=1,n=t[a];a+=1,r.hangingCount=t[a],a+=1,r.tissueCount=t[a],a+=1,r.sunVisorCount=t[a],a+=1,r.annualInspectionCount=t[a],a+=1,a+=6,r.hangingCount>0&&(r.hangingCount=[]);for(var i=0;i<r.hangingCount;i++){var o=(t[a+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a],f=(t[(a+=2)+1]<<8)+t[a];a+=2,r.hangingPos.push([o-u,s-f,o+u,s+f])}for(r.tissueCount>0&&(r.tissueCount=[]),i=0;i<r.tissueCount;i++)o=(t[a+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a],f=(t[(a+=2)+1]<<8)+t[a],a+=2,r.tissueCount.push([o-u,s-f,o+u,s+f]);for(r.sunVisorCount>0&&(r.sunVisorCount=[]),i=0;i<r.tissueCount;i++)o=(t[a+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a],f=(t[(a+=2)+1]<<8)+t[a],a+=2,r.sunVisorCount.push([o-u,s-f,o+u,s+f]);for(r.annualInspectionCount>0&&(r.annualInspectionCount=[]),i=0;i<r.tissueCount;i++)o=(t[a+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a],f=(t[(a+=2)+1]<<8)+t[a],a+=2,r.annualInspectionCount.push([o-u,s-f,o+u,s+f]);return e.attribute8C.push(r),n}function w(t,e){e.hasOwnProperty("attribute8E")||(e.attribute8E=[]);var r={},a=1,n=t[a];a+=1,r.nameCodecFormat=t[a];var i=t[a+=1];return a+=1,r.name=String.fromCharCode.apply(null,t.subarray(a,i)),e.attribute8E.push(r),n}function C(t,e){for(var r={128:m,129:d,130:_,131:h,132:g,133:v,134:y,135:b,136:D,137:T,140:S,142:w},a=0,n=t[a];a<t.length;){var i=t.subarray(a,t.length);a+=r[n].call(null,i,e)}}function I(t,e){e.hasOwnProperty("vehicleObject")||(e.vehicleObject=[]);var r={},a=0;r.type=t[a],a+=1;var n=(t[(a+=1)+1]<<8)+t[a];a+=2,r.objectId=(t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a];var i=(t[(a+=4)+1]<<8)+t[a],o=(t[(a+=2)+1]<<8)+t[a],s=(t[(a+=2)+1]<<8)+t[a],u=(t[(a+=2)+1]<<8)+t[a];return a+=2,r.track=[[i-s,o-u,i+s,o+u]],r.valid=t[a],a+=1,r.operateType=t[a],a+=1,a+=2,C(t.subarray(a,n),r),e.vehicleObject.push(r),n}function F(t,e){e.hasOwnProperty("faceObject")||(e.faceObject=[]);var r={},a=0;r.type=t[a],a+=1;var n=(t[(a+=1)+1]<<8)+t[a];return n<12?0:(a+=2,r.objectId=(t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a],a+=4,r.version=t[a],a+=1,a+=3,r.faceData=t.subarray(a,n),e.faceObject.push(r),n)}function A(t,e){e.hasOwnProperty("commonObject")||(e.commonObject=[]);var r={},a=0;r.type=t[a],a+=1;var n=(t[(a+=1)+1]<<8)+t[a];return a+=2,r.objectId=(t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a],a+=4,r.operateType=t[a],a+=1,a+=3,C(t.subarray(a,n),r),e.commonObject.push(r),n}function M(t,e,r){var a=0,n=(t[a+3]<<24)+(t[a+2]<<16)+(t[a+1]<<8)+t[a],i=t[a+=4];if(a+=1,a+=3,0==i)return a;e.groupId=n,e.object={};for(var o=0;o<i;o++){var s=t[a],u=t.subarray(a,t.length),f=0;switch(s){case 2:case 5:f=I(u,e.object);break;case 15:f=F(u,e.object);break;default:f=A(u,e.object)}if(0==f)return 0;a+=f}return r(e),a}function k(t,e,r){var a={coordinate:8192};if(e.length<32)return!1;var n=4;a.classID=t;var i=e[n];if(0==i)return!0;a.groupCount=i,n+=1,n+=7,a.cameral=[];for(var o=0;o<20;o++)a.cameral.push(e[n+o]);n+=20;for(var s=0;s<a.groupCount;s++){var u=M(e.subarray(n,e.length),JSON.parse(JSON.stringify(a)),r);if(u<=0)break;n+=u}}return a.prototype={init:function(){i.log("init")},parseRTPData:function(a,n,i,f,l,c){var p=(n[19]<<24)+(n[18]<<16)+(n[17]<<8)+n[16]>>>0,m=Date.UTC("20"+(p>>26),(p>>22&15)-1,p>>17&31,p>>12&31,p>>6&63,63&p)/1e3;if(m-=28800,0==this.firstTime)this.firstTime=m,this.lastMSW=0,e=(n[21]<<8)+n[20],t={timestamp:this.firstTime,timestamp_usec:0};else{var d,_=(n[21]<<8)+n[20];d=_>=e?_-e:_+65535-e,this.lastMSW+=d,m>this.firstTime&&(this.lastMSW-=1e3),this.firstTime=m,t={timestamp:m,timestamp_usec:this.lastMSW},e=_}!function(e,a,n,i){var f=a[22],l=a.subarray(24+f,a.length-8);switch(e){case 0:n({ivsDraw:o(l),timeStamp:t,channel:i});break;case 5:n({ivsDraw:s(l),timeStamp:t,channel:i});break;case 6:break;case 14:var c=[];if(function(t,e){for(var a=t.length,n=0;n+4<a;){var i=t[n],o=(t[n+1],(t[n+3]<<8)+t[n+2]),s=t.subarray(n,o);if(n+=o,161!==i&&!k(r[i-64],s,e))break}}(l,function(t){c.push(t)}),c.length){var p={result:!1,type:14,params:c};n({ivsDraw:p,timeStamp:t,channel:i})}break;case 20:n({ivsDraw:u(l),timeStamp:t,channel:i})}}(n[5],n,this.rtpReturnCallback,c)},setBufferfullCallback:function(){},setReturnCallback:function(t){this.rtpReturnCallback=t}},new a};importScripts("./../module/ffmpegasm.js"),addEventListener("message",function(t){var e=t.data;switch(k=t.data.channelId,e.type){case"sdpInfo":b=e.data,0,function(t){y=[],w=!1;for(var e=0;e<t.sdpInfo.length;e++)D=null,T=t.decodeMode,"H264"===t.sdpInfo[e].codecName||"RAW"===t.sdpInfo[e].codecName&&t.mp4Codec&&"H264"===t.mp4Codec.VideoCodec?(null===I&&(I=p()),(D=I).init(t.decodeMode),D.setFramerate(t.sdpInfo[e].Framerate),D.setGovLength(t.govLength),D.setCheckDelay(t.checkDelay),D.setLessRate(t.lessRateCanvas)):"H265"===t.sdpInfo[e].codecName||"RAW"===t.sdpInfo[e].codecName&&t.mp4Codec&&"H265"===t.mp4Codec.VideoCodec?(null===F&&(F=_()),(D=F).init(),D.setFramerate(t.sdpInfo[e].Framerate),D.setGovLength(t.govLength),D.setCheckDelay(t.checkDelay)):"JPEG"===t.sdpInfo[e].codecName?(null===A&&(A=g()),(D=A).init(),D.setFramerate(t.sdpInfo[e].Framerate)):"stream-assist-frame"===t.sdpInfo[e].codecName&&(i.log(t.sdpInfo[e]),null===M&&(M=v()),(D=M).init()),"undefined"!==typeof t.sdpInfo[e].Framerate&&t.sdpInfo[e].Framerate,null!==D&&(D.setBufferfullCallback(L),D.setReturnCallback(R),C=t.sdpInfo[e].RtpInterlevedID,y[C]=D)}(b);break;case"MediaData":if(!0===w){!function(t){C=t.data.rtspInterleave[1],"undefined"!==typeof y[C]&&y[C].bufferingRtpData(t.data.rtspInterleave,t.data.header,t.data.payload)}(e);break}C=e.data.rtspInterleave[1],"undefined"!==typeof y[C]&&y[C].parseRTPData(e.data.rtspInterleave,e.data.payload,S,x,e.info,e.channel);break;case"initStartTime":y[C].initStartTime();break;case"end":U("end")}},!1),Module.onRuntimeInitialized=function(){Module._RegisterAll(),U("WorkerReady")};var y=[],b=null,D=null,T="",S=!1,w=!1,C=-1,I=null,F=null,A=null,M=null,k=null,x=1;function L(){y[C].findCurrent(),U("stepPlay","BufferFull")}function R(t){var e=null;if(null===t||"undefined"===typeof t)return e=null,void null;if("undefined"!==typeof t.error?(U("error",t.error),e=t.decodedData):(e=t.decodedData,null!==t.decodeMode&&"undefined"!==typeof t.decodeMode&&(T=t.decodeMode,U("setVideoTagMode",t.decodeMode))),null!=t.decodeStart&&(U("DecodeStart",t.decodeStart),T=t.decodeStart.decodeMode),null!==e&&"undefined"!==typeof e)if(void 0!==e.frameData&&null!==e.frameData&&"canvas"===T){!0===e.frameData.firstFrame&&U("firstFrame",e.frameData.firstFrame);var r={bufferIdx:e.frameData.bufferIdx,width:e.frameData.width,height:e.frameData.height,codecType:e.frameData.codecType,frameType:e.frameData.frameType,timeStamp:null,frameIndex:e.frameData.frameIndex};null!==e.timeStamp&&"undefined"!==typeof e.timeStamp&&(r.timeStamp=e.timeStamp),U("videoInfo",r),"undefined"!==typeof e.frameData.data&&null!==e.frameData.data&&U("canvasRender",e.frameData.data,e.frameData.option)}else if(null!==e.frameData&&"video"===T){null!==e.initSegmentData&&(U("codecInfo",e.codecInfo),U("initSegment",e.initSegmentData));r={codecType:e.frameData.codecType,frameIndex:e.frameData.frameIndex};"undefined"!==typeof e.frameData.width&&(r.width=e.frameData.width,r.height=e.frameData.height),U("videoInfo",r),U("videoTimeStamp",e.timeStamp),e.frameData.length>0&&(U("mediaSample",e.mediaSample),U("videoRender",e.frameData))}else U("drop",t.decodedData);null!=t.resolution&&U("MSEResolutionChanged",t.resolution),null!=t.ivsDraw&&U("ivsDraw",t)}function U(t,e,r){var a={type:t,data:e,channelId:k,option:r};"canvasRender"===t?postMessage(a,[e.buffer]):postMessage(a)}}]);