define(["exports"],function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0,_exports.default=function(){function ExpGolomb(data){babelHelpers.classCallCheck(this,ExpGolomb),this.data=data,this.bytesAvailable=data.byteLength,this.word=0,this.bitsAvailable=0}return babelHelpers.createClass(ExpGolomb,[{key:"loadWord",value:function(){var data=this.data,bytesAvailable=this.bytesAvailable,position=data.byteLength-bytesAvailable,workingBytes=new Uint8Array(4),bytesAvailable=Math.min(4,bytesAvailable);if(0===bytesAvailable)throw new Error("no bytes available");workingBytes.set(data.subarray(position,position+bytesAvailable)),this.word=new DataView(workingBytes.buffer).getUint32(0),this.bitsAvailable=8*bytesAvailable,this.bytesAvailable-=bytesAvailable}},{key:"skipBits",value:function(count){var skipBytes;this.bitsAvailable>count||(count=(count-=this.bitsAvailable)-((skipBytes=count>>3)>>3),this.bytesAvailable-=skipBytes,this.loadWord()),this.word<<=count,this.bitsAvailable-=count}},{key:"readBits",value:function(size){var bits=Math.min(this.bitsAvailable,size),valu=this.word>>>32-bits;return this.bitsAvailable-=bits,0<this.bitsAvailable?this.word<<=bits:0<this.bytesAvailable&&this.loadWord(),0<(bits=size-bits)&&this.bitsAvailable?valu<<bits|this.readBits(bits):valu}},{key:"skipLZ",value:function(){for(var leadingZeroCount=0;leadingZeroCount<this.bitsAvailable;++leadingZeroCount)if(0!=(this.word&2147483648>>>leadingZeroCount))return this.word<<=leadingZeroCount,this.bitsAvailable-=leadingZeroCount,leadingZeroCount;return this.loadWord(),leadingZeroCount+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var clz=this.skipLZ();return this.readBits(clz+1)-1}},{key:"readEG",value:function(){var valu=this.readUEG();return 1&valu?1+valu>>>1:-1*(valu>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}},{key:"skipScalingList",value:function(count){for(var lastScale=8,nextScale=8,j=0;j<count;j++)lastScale=0===(nextScale=0!==nextScale?(lastScale+this.readEG()+256)%256:nextScale)?lastScale:nextScale}},{key:"readSPS",value:function(){var numRefFramesInPicOrderCntCycle,scalingListCount,i,frameCropLeftOffset=0,frameCropRightOffset=0,frameCropTopOffset=0,frameCropBottomOffset=0,readUByte=this.readUByte.bind(this),readBits=this.readBits.bind(this),readUEG=this.readUEG.bind(this),readBoolean=this.readBoolean.bind(this),skipBits=this.skipBits.bind(this),skipEG=this.skipEG.bind(this),skipUEG=this.skipUEG.bind(this),skipScalingList=this.skipScalingList.bind(this);if(readUByte(),profileIdc=readUByte(),readBits(5),skipBits(3),readUByte(),skipUEG(),100===profileIdc||110===profileIdc||122===profileIdc||244===profileIdc||44===profileIdc||83===profileIdc||86===profileIdc||118===profileIdc||128===profileIdc){var profileIdc=readUEG();if(3===profileIdc&&skipBits(1),skipUEG(),skipUEG(),skipBits(1),readBoolean())for(scalingListCount=3!==profileIdc?8:12,i=0;i<scalingListCount;i++)readBoolean()&&skipScalingList(i<6?16:64)}skipUEG();var profileIdc=readUEG();if(0===profileIdc)readUEG();else if(1===profileIdc)for(skipBits(1),skipEG(),skipEG(),numRefFramesInPicOrderCntCycle=readUEG(),i=0;i<numRefFramesInPicOrderCntCycle;i++)skipEG();skipUEG(),skipBits(1),profileIdc=readUEG(),skipUEG=readUEG(),0===(readBits=readBits(1))&&skipBits(1),skipBits(1),readBoolean()&&(frameCropLeftOffset=readUEG(),frameCropRightOffset=readUEG(),frameCropTopOffset=readUEG(),frameCropBottomOffset=readUEG());var pixelRatio=[1,1];if(readBoolean()&&readBoolean())switch(readUByte()){case 1:pixelRatio=[1,1];break;case 2:pixelRatio=[12,11];break;case 3:pixelRatio=[10,11];break;case 4:pixelRatio=[16,11];break;case 5:pixelRatio=[40,33];break;case 6:pixelRatio=[24,11];break;case 7:pixelRatio=[20,11];break;case 8:pixelRatio=[32,11];break;case 9:pixelRatio=[80,33];break;case 10:pixelRatio=[18,11];break;case 11:pixelRatio=[15,11];break;case 12:pixelRatio=[64,33];break;case 13:pixelRatio=[160,99];break;case 14:pixelRatio=[4,3];break;case 15:pixelRatio=[3,2];break;case 16:pixelRatio=[2,1];break;case 255:pixelRatio=[readUByte()<<8|readUByte(),readUByte()<<8|readUByte()]}return{width:Math.ceil(16*(profileIdc+1)-2*frameCropLeftOffset-2*frameCropRightOffset),height:(2-readBits)*(skipUEG+1)*16-(readBits?2:4)*(frameCropTopOffset+frameCropBottomOffset),pixelRatio:pixelRatio}}},{key:"readSliceType",value:function(){return this.readUByte(),this.readUEG(),this.readUEG()}}]),ExpGolomb}()});