@dolbylaboratories/alps 2.0.0 → 3.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var Ot=Object.create;var q=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var Lt=Object.getOwnPropertyNames;var Ct=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty;var rt=i=>{throw TypeError(i)};var It=(i,t,s)=>t in i?q(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var Pt=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var St=(i,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let _ of Lt(t))!Tt.call(i,_)&&_!==s&&q(i,_,{get:()=>t[_],enumerable:!(e=Dt(t,_))||e.enumerable});return i};var kt=(i,t,s)=>(s=i!=null?Ot(Ct(i)):{},St(t||!i||!i.__esModule?q(s,"default",{value:i,enumerable:!0}):s,i));var a=(i,t,s)=>It(i,typeof t!="symbol"?t+"":t,s),Q=(i,t,s)=>t.has(i)||rt("Cannot "+s);var E=(i,t,s)=>(Q(i,t,"read from private field"),s?s.call(i):t.get(i)),H=(i,t,s)=>t.has(i)?rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),ot=(i,t,s,e)=>(Q(i,t,"write to private field"),e?e.call(i,s):t.set(i,s),s),U=(i,t,s)=>(Q(i,t,"access private method"),s);var xt=Pt(D=>{var m={};m.parseBuffer=function(i){return new w(i).parse()};m.addBoxProcessor=function(i,t){typeof i!="string"||typeof t!="function"||(n.prototype._boxProcessors[i]=t)};m.createFile=function(){return new w};m.createBox=function(i,t,s){var e=n.create(i);return t&&t.append(e,s),e};m.createFullBox=function(i,t,s){var e=m.createBox(i,t,s);return e.version=0,e.flags=0,e};m.Utils={};m.Utils.dataViewToString=function(i,t){var s=t||"utf-8";if(typeof TextDecoder<"u")return new TextDecoder(s).decode(i);var e=[],_=0;if(s==="utf-8")for(;_<i.byteLength;){var r=i.getUint8(_++);r<128||(r<224?(r=(r&31)<<6,r|=i.getUint8(_++)&63):r<240?(r=(r&15)<<12,r|=(i.getUint8(_++)&63)<<6,r|=i.getUint8(_++)&63):(r=(r&7)<<18,r|=(i.getUint8(_++)&63)<<12,r|=(i.getUint8(_++)&63)<<6,r|=i.getUint8(_++)&63)),e.push(String.fromCharCode(r))}else for(;_<i.byteLength;)e.push(String.fromCharCode(i.getUint8(_++)));return e.join("")};m.Utils.utf8ToByteArray=function(i){var t,s;if(typeof TextEncoder<"u")t=new TextEncoder().encode(i);else for(t=[],s=0;s<i.length;++s){var e=i.charCodeAt(s);e<128?t.push(e):e<2048?(t.push(192|e>>6),t.push(128|63&e)):e<65536?(t.push(224|e>>12),t.push(128|63&e>>6),t.push(128|63&e)):(t.push(240|e>>18),t.push(128|63&e>>12),t.push(128|63&e>>6),t.push(128|63&e))}return t};m.Utils.appendBox=function(i,t,s){if(t._offset=i._cursor.offset,t._root=i._root?i._root:i,t._raw=i._raw,t._parent=i,s!==-1){if(s==null){i.boxes.push(t);return}var e=-1,_;if(typeof s=="number")e=s;else{if(typeof s=="string")_=s;else if(typeof s=="object"&&s.type)_=s.type;else{i.boxes.push(t);return}for(var r=0;r<i.boxes.length;r++)if(_===i.boxes[r].type){e=r+1;break}}i.boxes.splice(e,0,t)}};typeof D<"u"&&(D.parseBuffer=m.parseBuffer,D.addBoxProcessor=m.addBoxProcessor,D.createFile=m.createFile,D.createBox=m.createBox,D.createFullBox=m.createFullBox,D.Utils=m.Utils);m.Cursor=function(i){this.offset=typeof i>"u"?0:i};var w=function(i){this._cursor=new m.Cursor,this.boxes=[],i&&(this._raw=new DataView(i))};w.prototype.fetch=function(i){var t=this.fetchAll(i,!0);return t.length?t[0]:null};w.prototype.fetchAll=function(i,t){var s=[];return w._sweep.call(this,i,s,t),s};w.prototype.parse=function(){for(this._cursor.offset=0,this.boxes=[];this._cursor.offset<this._raw.byteLength;){var i=n.parse(this);if(typeof i.type>"u")break;this.boxes.push(i)}return this};w._sweep=function(i,t,s){this.type&&this.type==i&&t.push(this);for(var e in this.boxes){if(t.length&&s)return;w._sweep.call(this.boxes[e],i,t,s)}};w.prototype.write=function(){var i=0,t;for(t=0;t<this.boxes.length;t++)i+=this.boxes[t].getLength(!1);var s=new Uint8Array(i);for(this._rawo=new DataView(s.buffer),this.bytes=s,this._cursor.offset=0,t=0;t<this.boxes.length;t++)this.boxes[t].write();return s.buffer};w.prototype.append=function(i,t){m.Utils.appendBox(this,i,t)};var n=function(){this._cursor=new m.Cursor};n.parse=function(i){var t=new n;return t._offset=i._cursor.offset,t._root=i._root?i._root:i,t._raw=i._raw,t._parent=i,t._parseBox(),i._cursor.offset=t._raw.byteOffset+t._raw.byteLength,t};n.create=function(i){var t=new n;return t.type=i,t.boxes=[],t};n.prototype._boxContainers=["dinf","edts","mdia","meco","mfra","minf","moof","moov","mvex","stbl","strk","traf","trak","tref","udta","vttc","sinf","schi","encv","enca","meta","grpl","prsl"];n.prototype._boxProcessors={};n.prototype._procField=function(i,t,s){this._parsing?this[i]=this._readField(t,s):this._writeField(t,s,this[i])};n.prototype._procFieldArray=function(i,t,s,e){var _;if(this._parsing)for(this[i]=[],_=0;_<t;_++)this[i][_]=this._readField(s,e);else for(_=0;_<this[i].length;_++)this._writeField(s,e,this[i][_])};n.prototype._procFullBox=function(){this._procField("version","uint",8),this._procField("flags","uint",24)};n.prototype._procEntries=function(i,t,s){var e;if(this._parsing)for(this[i]=[],e=0;e<t;e++)this[i].push({}),s.call(this,this[i][e]);else for(e=0;e<t;e++)s.call(this,this[i][e])};n.prototype._procSubEntries=function(i,t,s,e){var _;if(this._parsing)for(i[t]=[],_=0;_<s;_++)i[t].push({}),e.call(this,i[t][_]);else for(_=0;_<s;_++)e.call(this,i[t][_])};n.prototype._procEntryField=function(i,t,s,e){this._parsing?i[t]=this._readField(s,e):this._writeField(s,e,i[t])};n.prototype._procSubBoxes=function(i,t){var s;if(this._parsing)for(this[i]=[],s=0;s<t;s++)this[i].push(n.parse(this));else for(s=0;s<t;s++)this._rawo?this[i][s].write():this.size+=this[i][s].getLength()};n.prototype._readField=function(i,t){switch(i){case"uint":return this._readUint(t);case"int":return this._readInt(t);case"template":return this._readTemplate(t);case"string":return t===-1?this._readTerminatedString():this._readString(t);case"data":return this._readData(t);case"utf8":return this._readUTF8String();case"utf8string":return this._readUTF8TerminatedString();default:return-1}};n.prototype._readInt=function(i){var t=null,s=this._cursor.offset-this._raw.byteOffset;switch(i){case 8:t=this._raw.getInt8(s);break;case 16:t=this._raw.getInt16(s);break;case 32:t=this._raw.getInt32(s);break;case 64:var e=this._raw.getInt32(s),_=this._raw.getInt32(s+4);t=e*Math.pow(2,32)+_;break}return this._cursor.offset+=i>>3,t};n.prototype._readUint=function(i){var t=null,s=this._cursor.offset-this._raw.byteOffset,e,_;switch(i){case 8:t=this._raw.getUint8(s);break;case 16:t=this._raw.getUint16(s);break;case 24:e=this._raw.getUint16(s),_=this._raw.getUint8(s+2),t=(e<<8)+_;break;case 32:t=this._raw.getUint32(s);break;case 64:e=this._raw.getUint32(s),_=this._raw.getUint32(s+4),t=e*Math.pow(2,32)+_;break}return this._cursor.offset+=i>>3,t};n.prototype._readString=function(i){for(var t="",s=0;s<i;s++){var e=this._readUint(8);t+=String.fromCharCode(e)}return t};n.prototype._readTemplate=function(i){var t=this._readUint(i/2),s=this._readUint(i/2);return t+s/Math.pow(2,i/2)};n.prototype._readTerminatedString=function(){for(var i="";this._cursor.offset-this._offset<this._raw.byteLength;){var t=this._readUint(8);if(t===0)break;i+=String.fromCharCode(t)}return i};n.prototype._readData=function(i){var t=i>0?i:this._raw.byteLength-(this._cursor.offset-this._offset);if(t>0){var s=new Uint8Array(this._raw.buffer,this._cursor.offset,t);return this._cursor.offset+=t,s}else return null};n.prototype._readUTF8String=function(){var i=this._raw.byteLength-(this._cursor.offset-this._offset),t=null;return i>0&&(t=new DataView(this._raw.buffer,this._cursor.offset,i),this._cursor.offset+=i),t&&m.Utils.dataViewToString(t)};n.prototype._readUTF8TerminatedString=function(){var i=this._raw.byteLength-(this._cursor.offset-this._offset),t=null;if(i>0){t=new DataView(this._raw.buffer,this._cursor.offset,i);var s;for(s=0;s<i&&t.getUint8(s)!==0;s++);t=new DataView(this._raw.buffer,this._cursor.offset,s),this._cursor.offset+=Math.min(s+1,i)}return t&&m.Utils.dataViewToString(t)};n.prototype._parseBox=function(){if(this._parsing=!0,this._cursor.offset=this._offset,this._offset+8>this._raw.buffer.byteLength){this._root._incomplete=!0;return}switch(this._procField("size","uint",32),this._procField("type","string",4),this.size===1&&this._procField("largesize","uint",64),this.type==="uuid"&&this._procFieldArray("usertype",16,"uint",8),this.size){case 0:this._raw=new DataView(this._raw.buffer,this._offset);break;case 1:this._offset+this.size>this._raw.buffer.byteLength?(this._incomplete=!0,this._root._incomplete=!0):this._raw=new DataView(this._raw.buffer,this._offset,this.largesize);break;default:this._offset+this.size>this._raw.buffer.byteLength?(this._incomplete=!0,this._root._incomplete=!0):this._raw=new DataView(this._raw.buffer,this._offset,this.size)}this._incomplete||(this._boxProcessors[this.type]&&this._boxProcessors[this.type].call(this),this._boxContainers.indexOf(this.type)!==-1?this._parseContainerBox():this._data=this._readData())};n.prototype._parseFullBox=function(){this.version=this._readUint(8),this.flags=this._readUint(24)};n.prototype._parseContainerBox=function(){for(this.boxes=[];this._cursor.offset-this._raw.byteOffset<this._raw.byteLength;)this.boxes.push(n.parse(this))};n.prototype.append=function(i,t){m.Utils.appendBox(this,i,t)};n.prototype.getLength=function(){if(this._parsing=!1,this._rawo=null,this.size=0,this._procField("size","uint",32),this._procField("type","string",4),this.size===1&&this._procField("largesize","uint",64),this.type==="uuid"&&this._procFieldArray("usertype",16,"uint",8),this._boxProcessors[this.type]&&this._boxProcessors[this.type].call(this),this._boxContainers.indexOf(this.type)!==-1)for(var i=0;i<this.boxes.length;i++)this.size+=this.boxes[i].getLength();return this._data&&this._writeData(this._data),this.size};n.prototype.write=function(){switch(this._parsing=!1,this._cursor.offset=this._parent._cursor.offset,this.size){case 0:this._rawo=new DataView(this._parent._rawo.buffer,this._cursor.offset,this.parent._rawo.byteLength-this._cursor.offset);break;case 1:this._rawo=new DataView(this._parent._rawo.buffer,this._cursor.offset,this.largesize);break;default:this._rawo=new DataView(this._parent._rawo.buffer,this._cursor.offset,this.size)}if(this._procField("size","uint",32),this._procField("type","string",4),this.size===1&&this._procField("largesize","uint",64),this.type==="uuid"&&this._procFieldArray("usertype",16,"uint",8),this._boxProcessors[this.type]&&this._boxProcessors[this.type].call(this),this._boxContainers.indexOf(this.type)!==-1)for(var i=0;i<this.boxes.length;i++)this.boxes[i].write();return this._data&&this._writeData(this._data),this._parent._cursor.offset+=this.size,this.size};n.prototype._writeInt=function(i,t){if(this._rawo){var s=this._cursor.offset-this._rawo.byteOffset;switch(i){case 8:this._rawo.setInt8(s,t);break;case 16:this._rawo.setInt16(s,t);break;case 32:this._rawo.setInt32(s,t);break;case 64:var e=Math.floor(t/Math.pow(2,32)),_=t-e*Math.pow(2,32);this._rawo.setUint32(s,e),this._rawo.setUint32(s+4,_);break}this._cursor.offset+=i>>3}else this.size+=i>>3};n.prototype._writeUint=function(i,t){if(this._rawo){var s=this._cursor.offset-this._rawo.byteOffset,e,_;switch(i){case 8:this._rawo.setUint8(s,t);break;case 16:this._rawo.setUint16(s,t);break;case 24:e=(t&16776960)>>8,_=t&255,this._rawo.setUint16(s,e),this._rawo.setUint8(s+2,_);break;case 32:this._rawo.setUint32(s,t);break;case 64:e=Math.floor(t/Math.pow(2,32)),_=t-e*Math.pow(2,32),this._rawo.setUint32(s,e),this._rawo.setUint32(s+4,_);break}this._cursor.offset+=i>>3}else this.size+=i>>3};n.prototype._writeString=function(i,t){for(var s=0;s<i;s++)this._writeUint(8,t.charCodeAt(s))};n.prototype._writeTerminatedString=function(i){if(i.length!==0){for(var t=0;t<i.length;t++)this._writeUint(8,i.charCodeAt(t));this._writeUint(8,0)}};n.prototype._writeTemplate=function(i,t){var s=Math.floor(t),e=(t-s)*Math.pow(2,i/2);this._writeUint(i/2,s),this._writeUint(i/2,e)};n.prototype._writeData=function(i){var t;if(i)if(this._rawo){if(i instanceof Array){for(var s=this._cursor.offset-this._rawo.byteOffset,t=0;t<i.length;t++)this._rawo.setInt8(s+t,i[t]);this._cursor.offset+=i.length}i instanceof Uint8Array&&(this._root.bytes.set(i,this._cursor.offset),this._cursor.offset+=i.length)}else this.size+=i.length};n.prototype._writeUTF8String=function(i){var t=m.Utils.utf8ToByteArray(i);if(this._rawo)for(var s=new DataView(this._rawo.buffer,this._cursor.offset,t.length),e=0;e<t.length;e++)s.setUint8(e,t[e]);else this.size+=t.length};n.prototype._writeField=function(i,t,s){switch(i){case"uint":this._writeUint(t,s);break;case"int":this._writeInt(t,s);break;case"template":this._writeTemplate(t,s);break;case"string":t==-1?this._writeTerminatedString(s):this._writeString(t,s);break;case"data":this._writeData(s);break;case"utf8":this._writeUTF8String(s);break;default:break}};n.prototype._boxProcessors.ardi=function(){this._procFullBox(),this._procField("audio_rendering_indication","uint",8)};n.prototype._boxProcessors.avc1=n.prototype._boxProcessors.avc2=n.prototype._boxProcessors.avc3=n.prototype._boxProcessors.avc4=n.prototype._boxProcessors.hvc1=n.prototype._boxProcessors.hev1=n.prototype._boxProcessors.encv=function(){this._procFieldArray("reserved1",6,"uint",8),this._procField("data_reference_index","uint",16),this._procField("pre_defined1","uint",16),this._procField("reserved2","uint",16),this._procFieldArray("pre_defined2",3,"uint",32),this._procField("width","uint",16),this._procField("height","uint",16),this._procField("horizresolution","template",32),this._procField("vertresolution","template",32),this._procField("reserved3","uint",32),this._procField("frame_count","uint",16),this._procFieldArray("compressorname",32,"uint",8),this._procField("depth","uint",16),this._procField("pre_defined3","int",16),this._procField("config","data",-1)};n.prototype._boxProcessors.ctts=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"sample_count","uint",32),this._procEntryField(i,"sample_offset",this.version===1?"int":"uint",32)})};n.prototype._boxProcessors.dref=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procSubBoxes("entries",this.entry_count)};n.prototype._boxProcessors.elng=function(){this._procFullBox(),this._procField("extended_language","utf8string")};n.prototype._boxProcessors.elst=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"segment_duration","uint",this.version===1?64:32),this._procEntryField(i,"media_time","int",this.version===1?64:32),this._procEntryField(i,"media_rate_integer","int",16),this._procEntryField(i,"media_rate_fraction","int",16)})};n.prototype._boxProcessors.emsg=function(){this._procFullBox(),this.version==1?(this._procField("timescale","uint",32),this._procField("presentation_time","uint",64),this._procField("event_duration","uint",32),this._procField("id","uint",32),this._procField("scheme_id_uri","string",-1),this._procField("value","string",-1)):(this._procField("scheme_id_uri","string",-1),this._procField("value","string",-1),this._procField("timescale","uint",32),this._procField("presentation_time_delta","uint",32),this._procField("event_duration","uint",32),this._procField("id","uint",32)),this._procField("message_data","data",-1)};n.prototype._boxProcessors.free=n.prototype._boxProcessors.skip=function(){this._procField("data","data",-1)};n.prototype._boxProcessors.frma=function(){this._procField("data_format","uint",32)};n.prototype._boxProcessors.ftyp=n.prototype._boxProcessors.styp=function(){this._procField("major_brand","string",4),this._procField("minor_version","uint",32);var i=-1;this._parsing&&(i=(this._raw.byteLength-(this._cursor.offset-this._raw.byteOffset))/4),this._procFieldArray("compatible_brands",i,"string",4)};n.prototype._boxProcessors.hdlr=function(){this._procFullBox(),this._procField("pre_defined","uint",32),this._procField("handler_type","string",4),this._procFieldArray("reserved",3,"uint",32),this._procField("name","string",-1)};n.prototype._boxProcessors.imda=function(){this._procField("imda_identifier","uint",32),this._procField("data","data",-1)};n.prototype._boxProcessors.kind=function(){this._procFullBox(),this._procField("schemeURI","utf8string"),this._procField("value","utf8string")};n.prototype._boxProcessors.labl=function(){this._procFullBox(),this.is_group_label=(this.flags&1)!=0,this._procField("label_id","uint",16),this._procField("language","utf8string"),this._procField("label","utf8string")};n.prototype._boxProcessors.mdat=function(){this._procField("data","data",-1)};n.prototype._boxProcessors.mdhd=function(){this._procFullBox(),this._procField("creation_time","uint",this.version==1?64:32),this._procField("modification_time","uint",this.version==1?64:32),this._procField("timescale","uint",32),this._procField("duration","uint",this.version==1?64:32),!this._parsing&&typeof this.language=="string"&&(this.language=this.language.charCodeAt(0)-96<<10|this.language.charCodeAt(1)-96<<5|this.language.charCodeAt(2)-96),this._procField("language","uint",16),this._parsing&&(this.language=String.fromCharCode((this.language>>10&31)+96,(this.language>>5&31)+96,(this.language&31)+96)),this._procField("pre_defined","uint",16)};n.prototype._boxProcessors.mehd=function(){this._procFullBox(),this._procField("fragment_duration","uint",this.version==1?64:32)};n.prototype._boxProcessors.meta=function(){this._procFullBox()};n.prototype._boxProcessors.mfhd=function(){this._procFullBox(),this._procField("sequence_number","uint",32)};n.prototype._boxProcessors.mfro=function(){this._procFullBox(),this._procField("mfra_size","uint",32)};n.prototype._boxProcessors.mp4a=n.prototype._boxProcessors.enca=function(){this._procFieldArray("reserved1",6,"uint",8),this._procField("data_reference_index","uint",16),this._procFieldArray("reserved2",2,"uint",32),this._procField("channelcount","uint",16),this._procField("samplesize","uint",16),this._procField("pre_defined","uint",16),this._procField("reserved3","uint",16),this._procField("samplerate","template",32),this._procField("esds","data",-1)};n.prototype._boxProcessors.mvhd=function(){this._procFullBox(),this._procField("creation_time","uint",this.version==1?64:32),this._procField("modification_time","uint",this.version==1?64:32),this._procField("timescale","uint",32),this._procField("duration","uint",this.version==1?64:32),this._procField("rate","template",32),this._procField("volume","template",16),this._procField("reserved1","uint",16),this._procFieldArray("reserved2",2,"uint",32),this._procFieldArray("matrix",9,"template",32),this._procFieldArray("pre_defined",6,"uint",32),this._procField("next_track_ID","uint",32)};n.prototype._boxProcessors.payl=function(){this._procField("cue_text","utf8")};n.prototype._boxProcessors.prft=function(){this._procFullBox(),this._procField("reference_track_ID","uint",32),this._procField("ntp_timestamp_sec","uint",32),this._procField("ntp_timestamp_frac","uint",32),this._procField("media_time","uint",this.version==1?64:32)};n.prototype._boxProcessors.prsl=function(){this._procFullBox(),this._procField("group_id","uint",32),this._procField("num_entities_in_group","uint",32),this._procEntries("entities",this.num_entities_in_group,function(i){this._procEntryField(i,"entity_id","uint",32)}),this.flags&4096&&this._procField("preselection_tag","utf8string"),this.flags&8192&&this._procField("selection_priority","uint",8),this.flags&16384&&this._procField("interleaving_tag","utf8string")};n.prototype._boxProcessors.pssh=function(){this._procFullBox(),this._procFieldArray("SystemID",16,"uint",8),this._procField("DataSize","uint",32),this._procFieldArray("Data",this.DataSize,"uint",8)};n.prototype._boxProcessors.schm=function(){this._procFullBox(),this._procField("scheme_type","uint",32),this._procField("scheme_version","uint",32),this.flags&1&&this._procField("scheme_uri","string",-1)};n.prototype._boxProcessors.sdtp=function(){this._procFullBox();var i=-1;this._parsing&&(i=this._raw.byteLength-(this._cursor.offset-this._raw.byteOffset)),this._procFieldArray("sample_dependency_table",i,"uint",8)};n.prototype._boxProcessors.sidx=function(){this._procFullBox(),this._procField("reference_ID","uint",32),this._procField("timescale","uint",32),this._procField("earliest_presentation_time","uint",this.version==1?64:32),this._procField("first_offset","uint",this.version==1?64:32),this._procField("reserved","uint",16),this._procField("reference_count","uint",16),this._procEntries("references",this.reference_count,function(i){this._parsing||(i.reference=(i.reference_type&1)<<31,i.reference|=i.referenced_size&2147483647,i.sap=(i.starts_with_SAP&1)<<31,i.sap|=(i.SAP_type&3)<<28,i.sap|=i.SAP_delta_time&268435455),this._procEntryField(i,"reference","uint",32),this._procEntryField(i,"subsegment_duration","uint",32),this._procEntryField(i,"sap","uint",32),this._parsing&&(i.reference_type=i.reference>>31&1,i.referenced_size=i.reference&2147483647,i.starts_with_SAP=i.sap>>31&1,i.SAP_type=i.sap>>28&7,i.SAP_delta_time=i.sap&268435455)})};n.prototype._boxProcessors.smhd=function(){this._procFullBox(),this._procField("balance","uint",16),this._procField("reserved","uint",16)};n.prototype._boxProcessors.ssix=function(){this._procFullBox(),this._procField("subsegment_count","uint",32),this._procEntries("subsegments",this.subsegment_count,function(i){this._procEntryField(i,"ranges_count","uint",32),this._procSubEntries(i,"ranges",i.ranges_count,function(t){this._procEntryField(t,"level","uint",8),this._procEntryField(t,"range_size","uint",24)})})};n.prototype._boxProcessors.stsd=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procSubBoxes("entries",this.entry_count)};n.prototype._boxProcessors.sttg=function(){this._procField("settings","utf8")};n.prototype._boxProcessors.stts=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"sample_count","uint",32),this._procEntryField(i,"sample_delta","uint",32)})};n.prototype._boxProcessors.subs=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"sample_delta","uint",32),this._procEntryField(i,"subsample_count","uint",16),this._procSubEntries(i,"subsamples",i.subsample_count,function(t){this._procEntryField(t,"subsample_size","uint",this.version===1?32:16),this._procEntryField(t,"subsample_priority","uint",8),this._procEntryField(t,"discardable","uint",8),this._procEntryField(t,"codec_specific_parameters","uint",32)})})};n.prototype._boxProcessors.tenc=function(){this._procFullBox(),this._procField("default_IsEncrypted","uint",24),this._procField("default_IV_size","uint",8),this._procFieldArray("default_KID",16,"uint",8)};n.prototype._boxProcessors.tfdt=function(){this._procFullBox(),this._procField("baseMediaDecodeTime","uint",this.version==1?64:32)};n.prototype._boxProcessors.tfhd=function(){this._procFullBox(),this._procField("track_ID","uint",32),this.flags&1&&this._procField("base_data_offset","uint",64),this.flags&2&&this._procField("sample_description_offset","uint",32),this.flags&8&&this._procField("default_sample_duration","uint",32),this.flags&16&&this._procField("default_sample_size","uint",32),this.flags&32&&this._procField("default_sample_flags","uint",32)};n.prototype._boxProcessors.tfra=function(){this._procFullBox(),this._procField("track_ID","uint",32),this._parsing||(this.reserved=0,this.reserved|=(this.length_size_of_traf_num&48)<<4,this.reserved|=(this.length_size_of_trun_num&12)<<2,this.reserved|=this.length_size_of_sample_num&3),this._procField("reserved","uint",32),this._parsing&&(this.length_size_of_traf_num=(this.reserved&48)>>4,this.length_size_of_trun_num=(this.reserved&12)>>2,this.length_size_of_sample_num=this.reserved&3),this._procField("number_of_entry","uint",32),this._procEntries("entries",this.number_of_entry,function(i){this._procEntryField(i,"time","uint",this.version===1?64:32),this._procEntryField(i,"moof_offset","uint",this.version===1?64:32),this._procEntryField(i,"traf_number","uint",(this.length_size_of_traf_num+1)*8),this._procEntryField(i,"trun_number","uint",(this.length_size_of_trun_num+1)*8),this._procEntryField(i,"sample_number","uint",(this.length_size_of_sample_num+1)*8)})};n.prototype._boxProcessors.tkhd=function(){this._procFullBox(),this._procField("creation_time","uint",this.version==1?64:32),this._procField("modification_time","uint",this.version==1?64:32),this._procField("track_ID","uint",32),this._procField("reserved1","uint",32),this._procField("duration","uint",this.version==1?64:32),this._procFieldArray("reserved2",2,"uint",32),this._procField("layer","uint",16),this._procField("alternate_group","uint",16),this._procField("volume","template",16),this._procField("reserved3","uint",16),this._procFieldArray("matrix",9,"template",32),this._procField("width","template",32),this._procField("height","template",32)};n.prototype._boxProcessors.trex=function(){this._procFullBox(),this._procField("track_ID","uint",32),this._procField("default_sample_description_index","uint",32),this._procField("default_sample_duration","uint",32),this._procField("default_sample_size","uint",32),this._procField("default_sample_flags","uint",32)};n.prototype._boxProcessors.trun=function(){this._procFullBox(),this._procField("sample_count","uint",32),this.flags&1&&this._procField("data_offset","int",32),this.flags&4&&this._procField("first_sample_flags","uint",32),this._procEntries("samples",this.sample_count,function(i){this.flags&256&&this._procEntryField(i,"sample_duration","uint",32),this.flags&512&&this._procEntryField(i,"sample_size","uint",32),this.flags&1024&&this._procEntryField(i,"sample_flags","uint",32),this.flags&2048&&this._procEntryField(i,"sample_composition_time_offset",this.version===1?"int":"uint",32)})};n.prototype._boxProcessors["url "]=n.prototype._boxProcessors["urn "]=function(){this._procFullBox(),this.type==="urn "&&this._procField("name","string",-1),this._procField("location","string",-1)};n.prototype._boxProcessors.vlab=function(){this._procField("source_label","utf8")};n.prototype._boxProcessors.vmhd=function(){this._procFullBox(),this._procField("graphicsmode","uint",16),this._procFieldArray("opcolor",3,"uint",16)};n.prototype._boxProcessors.vttC=function(){this._procField("config","utf8")};n.prototype._boxProcessors.vtte=function(){}});var R="moov",nt="trak",at="tkhd",j="meta",ht="grpl",lt="prsl",ft="udta",ct="diap",ut="elng",pt="ardi",dt="labl",bt="kind",z="moof",gt="traf",At="tfhd",mt="trun";var it="b_presentation_id",st="presentation_id",et="presentation_level",G="payload_base_minus1",T="byte_alignment",Y="ac4_toc_end";var Mt=(i,t,s,e)=>{let _=t>>3,r=t+s-1>>3,h=t&7,f=t+s-1&7,c=255>>h,p=255<<7-f&255,l=0;for(let d=r;d>=_;d--){let u=i.getUint8(d),o=255;d===_&&(o&=c),d===r&&(o&=p);let g=u&~o;l=((u&o)<<e)+l;let B=g|l&255&o;l>>=8,i.setUint8(d,B)}return i},V=(i,t,s,e)=>{let _=t>>>3,r=t&7,h=(1<<s)-1<<16-s>>r,f=i.getUint8(_)<<8|i.getUint8(_+1);f&=~h,f|=e<<16-s-r,i.setUint8(_,f>>>8),i.setUint8(_+1,f&255)};var vt=i=>{let t=[],e=i.fetch(z),_=!0;for(let r of i.fetchAll(gt)){let h=r.boxes.find(l=>l.type===At),f=h.base_data_offset||0,c=h.flags&131072;if(f)throw Error("base_data_offset is relative to the file identified by the referenced data reference entry unsupported");if(!c)throw Error(_?"base_data_offset is relative to the first byte of the MovieFragmentBox containing this box unsupported":"base_data_offset is relative to the end of the data defined by the preceding track fragment is unsupported");let p=e._offset;for(let l of r.boxes.filter(d=>d.type===mt)){let d=p+f+l.data_offset;for(let u of l.samples)t.push({offset:d,size:u.sample_size}),d+=u.sample_size}_=!1}return t};var J=class{constructor(t){this.iterator=t,this.cache=0,this.bitsLeft=0}get(t,s){s>25;let f=s;for(;this.bitsLeft<f;){let p=this.iterator.next(),l=24-this.bitsLeft;this.cache|=p.value<<l,this.bitsLeft+=8,f>25&&(this.cache<<=8,this.bitsLeft-=8,f-=8)}let c=this.cache>>>32-f;return this.cache<<=f,this.bitsLeft-=f,c}get_align(t){return this.get("align",t)}};var X=class{constructor(t,s){this.elements=t,this.callback=s}before_call(t,s,e,_){this.elements.includes(e)&&this.callback(e,null,null,_,"before_call")}after_call(t,s,e,_){this.elements.includes(e)&&this.callback(e,s,null,_,"after_call")}write_uint(t,s,e,_){this.elements.includes(t)&&this.callback(t,e,s,_)}write_align(t,s){this.elements.includes(T)&&this.callback(T,s,t,null,"write_align")}after_position(t,s){this.elements.includes(t)&&this.callback(t,null,null,s,"after_position")}};var b=class extends Error{},K=class{constructor(t,s){a(this,"v",null);a(this,"content_classifier",null);a(this,"i",null);a(this,"frame_rate_factor",null);a(this,"bk_substream_index",null);a(this,"a_substream_indices",null);a(this,"last_referenced_substream",null);a(this,"referenced_substreams",null);a(this,"protection_bits_primary_bits",null);a(this,"protection_bits_secondary_bits",null);a(this,"toc_i",null);a(this,"OAMD_OBJECT_TYPE_BED",null);a(this,"OAMD_OBJECT_TYPE_ISF",null);a(this,"OAMD_OBJECT_TYPE_DYNAMIC",null);a(this,"OAMD_OBJECT_TYPE_RESERVED",null);a(this,"toc_j",null);a(this,"vb",null);a(this,"presentation_to_groups",null);a(this,"group_frame_rate_factor",null);a(this,"b_hsf_ext",null);a(this,"b_single_substream",null);a(this,"n_bed_objects",null);a(this,"a_num_bed_objects",null);a(this,"b_bed_objects_prev",null);a(this,"num_lfe",null);a(this,"n",null);a(this,"n_skip_bytes",null);a(this,"b_more_skip_bytes",null);a(this,"n_bits_read_0",null);a(this,"n_bits_read_1",null);a(this,"n_bits_read",null);a(this,"n_skip_bits",null);a(this,"reserved",null);a(this,"padding",null);a(this,"CHANNEL_MODE_MONO",null);a(this,"CHANNEL_MODE_STEREO",null);a(this,"CHANNEL_MODE_30",null);a(this,"CHANNEL_MODE_50",null);a(this,"CHANNEL_MODE_51",null);a(this,"CHANNEL_MODE_70_34",null);a(this,"CHANNEL_MODE_71_34",null);a(this,"CHANNEL_MODE_70_52",null);a(this,"CHANNEL_MODE_71_52",null);a(this,"CHANNEL_MODE_70_322",null);a(this,"CHANNEL_MODE_71_322",null);a(this,"CHANNEL_MODE_704",null);a(this,"CHANNEL_MODE_714",null);a(this,"CHANNEL_MODE_904",null);a(this,"CHANNEL_MODE_914",null);a(this,"CHANNEL_MODE_222",null);a(this,"presentation_config",null);a(this,"presentation_version",null);a(this,"b_add_emdf_substreams",null);a(this,"presentation_level",null);a(this,"b_presentation_id",null);a(this,"presentation_id",null);a(this,"b_pre_virtualized",null);a(this,"n_add_emdf_substreams",null);a(this,"pi_i",null);a(this,"b_single_substream_group",null);a(this,"b_presentation_filter",null);a(this,"b_enable_presentation",null);a(this,"n_substream_groups",null);a(this,"b_multi_pid",null);a(this,"n_substream_groups_minus2",null);a(this,"sg",null);a(this,"bitstream_version",null);a(this,"fs_index",null);a(this,"frame_rate_index",null);a(this,"BAM_g_position",0);a(this,"BAM_g_table0",[0,2,4,6]);a(this,"BAM_g_table1",[252,253,508,509]);a(this,"BAM_g_table2",[122,123,124,125]);a(this,"BAM_g_table3",[252,253,508,509]);a(this,"BAM_g_table4",[4,6,8,10,12,14]);a(this,"BAM_g_table5",[122,123,124,125]);a(this,"BAM_g_table6",[0,0]);a(this,"BAM_g_table7",[0,1,2,3,5,0,0,0]);a(this,"BAM_g_table8",[2,3,6,8,10,8,10,12]);a(this,"BAM_g_table9",[2,1,1,2,2,2,2,2,2,1]);a(this,"BAM_g_table10",[4,8,10,14,15,30,-1,-1]);a(this,"BAM_g_table11",[2,3,4,5,6,7]);a(this,"BAM_g_table12",[2,1,1,2,2,2,2,2,2,1]);a(this,"BAM_g_table13",[1920,1920,2048,1536,1536,960,960,1024,768,768,512,384,384,2048]);a(this,"BAM_g_table14",[2,3,4]);a(this,"BAM_g_table15",{0:2,1:4});a(this,"BAM_g_table16",[0,1,7,8,9]);a(this,"BAM_g_table17",{0:1,1:2});a(this,"BAM_g_table18",[5,6,7,8,9]);a(this,"BAM_g_table19",[10,11,12]);this.BAM_source=t,this.BAM_sink=s}F_channel_mode_contains_LFE(t){return t==this.CHANNEL_MODE_51||t==this.CHANNEL_MODE_71_34||t==this.CHANNEL_MODE_71_52||t==this.CHANNEL_MODE_71_322?1:0}F_bitrate_indicator(){var t,s;t=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_g_table0.slice(0).indexOf(t)>=0?t=t>>1:(this.v=this.BAM_source.get("",2),this.BAM_g_position+=2,this.v=(t<<2)+this.v,s=Math.floor(this.v/8),t=this.v-s*4)}F_content_type(){var t,s,e,_,r,h;if(this.content_classifier=this.BAM_source.get("",3),this.BAM_g_position+=3,r=this.BAM_source.get("",1),this.BAM_g_position+=1,r)if(t=this.BAM_source.get("",1),this.BAM_g_position+=1,t)h=this.BAM_source.get("",1),this.BAM_g_position+=1,e=this.BAM_source.get("",16),this.BAM_g_position+=16;else for(s=this.BAM_source.get("",6),this.BAM_g_position+=6,this.i=0;this.i<s;this.i++)_=this.BAM_source.get("",8),this.BAM_g_position+=8}F_ac4_substream_info_chan(t,s,e){var _,r,h,f,c,p,l,d,u,o=null,o,g,A;{if(this.F_define_channel_modes(),this.F_define_oamd(),c=this.F_channel_mode(),c==null)throw b("F_channel_mode","expected to return a value, returned None");if(c==511){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");c+=this.v}for(this.BAM_g_table1.slice(0).indexOf(c)>=0&&(l=this.BAM_source.get("",1),this.BAM_g_position+=1,u=this.BAM_source.get("",1),this.BAM_g_position+=1,p=this.BAM_source.get("",2),this.BAM_g_position+=2),this.fs_index==1&&(r=this.BAM_source.get("",1),this.BAM_g_position+=1,r&&(g=this.BAM_source.get("",1),this.BAM_g_position+=1)),h=this.BAM_source.get("",1),this.BAM_g_position+=1,h&&this.F_bitrate_indicator(),this.BAM_g_table2.slice(0).indexOf(c)>=0&&(A=this.BAM_source.get("",1),this.BAM_g_position+=1),this.frame_rate_factor=this.group_frame_rate_factor[t],this.i=0;this.i<this.frame_rate_factor;this.i++)d=this.BAM_source.get("",1),this.BAM_g_position+=1;if(e==1){if(_=this.BAM_source.get("",2),this.BAM_g_position+=2,_==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");_+=this.v}}else _=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;for(this.a_substream_indices.push(_),this.i=0;this.i<this.frame_rate_factor;this.i++){if(e==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,_+this.i),this.referenced_substreams.push(_+this.i)),this.BAM_g_table3.slice(0).indexOf(c)>=0,f=this.F_get_ch_mode(c),f==null)throw b("F_get_ch_mode","expected to return a value, returned None");this.BAM_g_table4.slice(0).indexOf(f)>=0?(o==null?o=new Array(_+this.i+1).fill(0):o.length<=_+this.i&&o.push.apply(o,new Array(_+this.i-o.length+1).fill(0)),o[_+this.i]=1):(o==null?o=new Array(_+this.i+1).fill(0):o.length<=_+this.i&&o.push.apply(o,new Array(_+this.i-o.length+1).fill(0)),o[_+this.i]=0)}}}F_channel_mode(){var t,s;return t=this.BAM_source.get("",1),this.BAM_g_position+=1,t==1&&(this.v=this.BAM_source.get("",1),this.BAM_g_position+=1,t=(t<<1)+this.v,s=2,t==3&&(this.v=this.BAM_source.get("",2),this.BAM_g_position+=2,t=(t<<2)+this.v,t==15&&(this.v=this.BAM_source.get("",3),this.BAM_g_position+=3,t=(t<<3)+this.v,(t==120||t==121)&&(s=t,t=2),t==126&&(this.v=this.BAM_source.get("",1),this.BAM_g_position+=1,t=(t<<1)+this.v),t==127&&(this.v=this.BAM_source.get("",2),this.BAM_g_position+=2,t=(t<<2)+this.v)))),t}F_ac4_substream_info(t,s,e){var _,r,h,f,c,p,l=null,l,d,u,o,g;{if(this.F_define_channel_modes(),p=this.F_channel_mode(),p==null)throw b("F_channel_mode","expected to return a value, returned None");if(p==511){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");p+=this.v}for(this.fs_index==1&&(h=this.BAM_source.get("",1),this.BAM_g_position+=1,h&&(d=this.BAM_source.get("",1),this.BAM_g_position+=1)),f=this.BAM_source.get("",1),this.BAM_g_position+=1,f&&this.F_bitrate_indicator(),this.BAM_g_table5.slice(0).indexOf(p)>=0&&(u=this.BAM_source.get("",1),this.BAM_g_position+=1),g=this.BAM_source.get("",1),this.BAM_g_position+=1,g?(this.F_content_type(),this.content_classifier==0||this.content_classifier==1?(o=0,c=0):this.content_classifier==2||this.content_classifier==3?(o=1,c=0):this.content_classifier==4?(o=0,c=1):this.content_classifier==5?(o=1,c=0):(this.content_classifier==6||this.content_classifier==7)&&(o=0,c=0)):(o=0,c=0),this.i=0;this.i<this.frame_rate_factor;this.i++)r=this.BAM_source.get("",1),this.BAM_g_position+=1;if(_=this.BAM_source.get("",2),this.BAM_g_position+=2,_==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");_+=this.v}for(this.a_substream_indices.push(_),this.i=0;this.i<this.frame_rate_factor;this.i++)if(this.last_referenced_substream=Math.max(this.last_referenced_substream,_+this.i),this.referenced_substreams.push(_+this.i),l==null?l=new Array(_+1+1).fill(0):l.length<=_+1&&l.push.apply(l,new Array(_+1-l.length+1).fill(0)),l[_+1]=this.F_channel_mode_contains_LFE(p),l[_+1]==null)throw b("F_channel_mode_contains_LFE","expected to return a value, returned None")}}F_emdf_protection(){var t,s,e,_;{if(e=this.BAM_source.get("",2),this.BAM_g_position+=2,s=this.BAM_source.get("",2),this.BAM_g_position+=2,e==0)throw"protection_length_primary == 0 is reserved";e==1?this.protection_bits_primary_bits=8:e==2?this.protection_bits_primary_bits=32:e==3&&(this.protection_bits_primary_bits=128),_=this.BAM_source.get("",this.protection_bits_primary_bits),this.BAM_g_position+=this.protection_bits_primary_bits,s==0?this.protection_bits_secondary_bits=0:s==1?this.protection_bits_secondary_bits=8:s==2?this.protection_bits_secondary_bits=32:s==3&&(this.protection_bits_secondary_bits=128),t=this.BAM_source.get("",this.protection_bits_secondary_bits),this.BAM_g_position+=this.protection_bits_secondary_bits}}F_emdf_info(){var t,s,e;{if(e=this.BAM_source.get("",2),this.BAM_g_position+=2,e==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");e+=this.v}if(t=this.BAM_source.get("",3),this.BAM_g_position+=3,t==7){if(this.v=this.F_variable_bits(3),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");t+=this.v}s=this.BAM_source.get("",1),this.BAM_g_position+=1,s&&this.F_emdf_payloads_substream_info(this.toc_i),this.F_emdf_protection()}}F_emdf_payloads_substream_info(t){var s;{if(s=this.BAM_source.get("",2),this.BAM_g_position+=2,s==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");s+=this.v}this.last_referenced_substream=Math.max(this.last_referenced_substream,s),this.referenced_substreams.push(s),this.a_substream_indices.push(s)}}F_ac4_hsf_ext_substream_info(t){var s;{if(t==1){if(s=this.BAM_source.get("",2),this.BAM_g_position+=2,s==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");s+=this.v}}else s=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;t==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,s),this.referenced_substreams.push(s))}}F_oamd_common_data(){var t,s,e,_,r,h,f,c,p,l,d;if(d=this.BAM_source.get("",1),this.BAM_g_position+=1,d==0&&(f=this.BAM_source.get("",5),this.BAM_g_position+=5),h=this.BAM_source.get("",1),this.BAM_g_position+=1,l=this.BAM_source.get("",1),this.BAM_g_position+=1,l){if(c=this.BAM_source.get("",1),this.BAM_g_position+=1,p=c+1,p==2){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");p+=this.v}if(t=p*8,_=this.BAM_g_position,s=this.BAM_g_position,r=s-_,t=t-r,t<0)throw"Wrong add_data_bytes_minus1 size indication";e=this.BAM_source.get("",t),this.BAM_g_position+=t}}F_define_oamd(){var t;this.OAMD_OBJECT_TYPE_BED=0,this.OAMD_OBJECT_TYPE_ISF=1,this.OAMD_OBJECT_TYPE_DYNAMIC=2,this.OAMD_OBJECT_TYPE_RESERVED=3,t=9}F_ac4_substream_info_ajoc(t,s,e){var _,r,h,f,c,p,l,d,u=null,u,o,g,A=null,A,B,F,v;{if(u=this.BAM_g_table6.slice(0),this.F_define_channel_modes(),o=this.BAM_source.get("",1),this.BAM_g_position+=1,F=this.BAM_source.get("",1),this.BAM_g_position+=1,F?(p=5,o?B=this.CHANNEL_MODE_51:B=this.CHANNEL_MODE_50):(g=this.BAM_source.get("",4),this.BAM_g_position+=4,p=g+1,this.F_bed_dyn_obj_assignment(p,0,o)),h=this.BAM_source.get("",1),this.BAM_g_position+=1,h&&this.F_oamd_common_data(),_=this.BAM_source.get("",4),this.BAM_g_position+=4,l=_+1,l==16){if(this.v=this.F_variable_bits(3),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");l=l+this.v}for(this.F_bed_dyn_obj_assignment(l,1,o),this.fs_index==1&&(f=this.BAM_source.get("",1),this.BAM_g_position+=1,f&&(v=this.BAM_source.get("",1),this.BAM_g_position+=1)),c=this.BAM_source.get("",1),this.BAM_g_position+=1,c&&this.F_bitrate_indicator(),this.frame_rate_factor=this.group_frame_rate_factor[t],this.i=0;this.i<this.frame_rate_factor;this.i++)d=this.BAM_source.get("",1),this.BAM_g_position+=1;if(e==1){if(r=this.BAM_source.get("",2),this.BAM_g_position+=2,r==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");r+=this.v}}else r=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;for(this.a_substream_indices.push(r),this.i=0;this.i<this.frame_rate_factor;this.i++)e==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,r+this.i),this.referenced_substreams.push(r+this.i)),A==null?A=new Array(r+this.i+1).fill(0):A.length<=r+this.i&&A.push.apply(A,new Array(r+this.i-A.length+1).fill(0)),A[r+this.i]=o}}F_ac4_sgi_specifier(t,s,e){var _;if(this.bitstream_version==1)this.F_ac4_substream_group_info(this.toc_j),this.toc_j+=1;else{if(_=this.BAM_source.get("",3),this.BAM_g_position+=3,_==7){if(this.vb=this.F_variable_bits(2),this.vb==null)throw b("F_variable_bits","expected to return a value, returned None");_+=this.vb}this.presentation_to_groups==null?this.presentation_to_groups=new Array(this.toc_i+1).fill(null):this.presentation_to_groups.length<=this.toc_i&&this.presentation_to_groups.push.apply(this.presentation_to_groups,new Array(this.toc_i-this.presentation_to_groups.length+1).fill(null)),this.presentation_to_groups[this.toc_i].push(_),this.group_frame_rate_factor==null?this.group_frame_rate_factor=new Array(_+1).fill(0):this.group_frame_rate_factor.length<=_&&this.group_frame_rate_factor.push.apply(this.group_frame_rate_factor,new Array(_-this.group_frame_rate_factor.length+1).fill(0)),this.group_frame_rate_factor[_]=this.frame_rate_factor}}F_ac4_substream_group_info(t){var s,e,_,r,h,f,c,p,l,d,u,o;{if(h=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_hsf_ext=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream)r=1;else if(p=this.BAM_source.get("",2),this.BAM_g_position+=2,r=p+2,r==5){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");r+=this.v}if(f=this.BAM_source.get("",1),this.BAM_g_position+=1,this.n_bed_objects=-1,this.a_num_bed_objects=[],f)for(c=0,_=0;_<r;_++)this.bitstream_version==1?(l=this.BAM_source.get("",1),this.BAM_g_position+=1):l=1,this.F_ac4_substream_info_chan(t,_,h),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(h);else for(d=this.BAM_source.get("",1),this.BAM_g_position+=1,d&&this.F_oamd_substream_info(h),s=0,this.b_bed_objects_prev=0,_=0;_<r;_++)c=this.BAM_source.get("",1),this.BAM_g_position+=1,c?(this.F_ac4_substream_info_ajoc(t,_,h),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(h)):(this.F_ac4_substream_info_obj(t,_,s,h),s+=1,this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(h));u=this.BAM_source.get("",1),this.BAM_g_position+=1,u?(this.F_content_type(),this.content_classifier==0||this.content_classifier==1?(o=0,e=0):this.content_classifier==2||this.content_classifier==3?(o=1,e=0):this.content_classifier==4?(o=0,e=1):this.content_classifier==5?(o=1,e=0):(this.content_classifier==6||this.content_classifier==7)&&(o=0,e=0)):(o=0,e=0)}}F_oamd_substream_info(t){var s,e;{if(this.F_define_oamd(),e=this.BAM_source.get("",1),this.BAM_g_position+=1,t==1){if(s=this.BAM_source.get("",2),this.BAM_g_position+=2,s==3){if(this.vb=this.F_variable_bits(2),this.vb==null)throw b("F_variable_bits","expected to return a value, returned None");s+=this.vb}}else s=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;t==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,s),this.referenced_substreams.push(s))}}F_ac4_substream_info_obj(t,s,e,_){var r,h,f,c,p,l,d,u,o,g,A,B,F,v,O,L,y,S,W,k,Z,N=null,N,M,wt,C;{if(u=0,this.F_define_oamd(),this.F_define_channel_modes(),B=this.BAM_source.get("",3),this.BAM_g_position+=3,o=this.BAM_g_table7.slice(0)[B],y=this.BAM_source.get("",1),this.BAM_g_position+=1,y)C=this.BAM_source.get("",1),this.BAM_g_position+=1,r=this.OAMD_OBJECT_TYPE_DYNAMIC,this.b_bed_objects_prev=0;else if(L=this.BAM_source.get("",1),this.BAM_g_position+=1,L){if(this.b_bed_objects_prev&&this.num_lfe==2?C=1:C=0,this.b_bed_objects_prev=1,this.num_lfe=0,r=this.OAMD_OBJECT_TYPE_BED,c=this.BAM_source.get("",1),this.BAM_g_position+=1,c){if(Z=this.BAM_source.get("",1),this.BAM_g_position+=1,Z){for(p=this.BAM_source.get("",3),this.BAM_g_position+=3,this.i=0;this.i<this.BAM_g_table8.slice(0)[p];this.i++)u+=1;p>=2&&(C=1)}else{if(h=this.BAM_source.get("",1),this.BAM_g_position+=1,h)for(k=this.BAM_source.get("",17),this.BAM_g_position+=17,this.i=0;this.i<17;this.i++)k&1<<this.i&&((this.i==3||this.i==16)&&(this.num_lfe+=1),u+=1);else for(M=this.BAM_source.get("",10),this.BAM_g_position+=10,this.i=0;this.i<10;this.i++)if(M&1<<this.i)for(l=0;l<this.BAM_g_table9.slice(0)[this.i];l++)(this.i==2||this.i==9)&&(this.num_lfe+=1),u+=1;this.num_lfe>0&&(C=1)}this.n_bed_objects=u,this.a_num_bed_objects.push(this.n_bed_objects)}}else if(C=0,this.b_bed_objects_prev=0,W=this.BAM_source.get("",1),this.BAM_g_position+=1,W)r=this.OAMD_OBJECT_TYPE_ISF,A=this.BAM_source.get("",1),this.BAM_g_position+=1,A&&(F=this.BAM_source.get("",3),this.BAM_g_position+=3);else if(f=this.BAM_source.get("",4),this.BAM_g_position+=4,g=this.BAM_source.get("",8*f),this.BAM_g_position+=8*f,r=this.OAMD_OBJECT_TYPE_RESERVED,o==0)throw"No non-LFE objects (of OAMD_OBJECT_TYPE_RESERVED) in substream!";for(this.fs_index==1&&(O=this.BAM_source.get("",1),this.BAM_g_position+=1,O&&(wt=this.BAM_source.get("",1),this.BAM_g_position+=1)),S=this.BAM_source.get("",1),this.BAM_g_position+=1,S&&this.F_bitrate_indicator(),this.frame_rate_factor=this.group_frame_rate_factor[t],this.i=0;this.i<this.frame_rate_factor;this.i++)d=this.BAM_source.get("",1),this.BAM_g_position+=1;if(_==1){if(v=this.BAM_source.get("",2),this.BAM_g_position+=2,v==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");v+=this.v}}else v=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;for(this.a_substream_indices.push(v),this.i=0;this.i<this.frame_rate_factor;this.i++)_==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,v+this.i),this.referenced_substreams.push(v+this.i)),N==null?N=new Array(v+this.i+1).fill(0):N.length<=v+this.i&&N.push.apply(N,new Array(v+this.i-N.length+1).fill(0)),N[v+this.i]=C}}F_bed_dyn_obj_assignment(t,s,e){var _,r,h,f,c,p,l,d,u,o,g,A,B,F,v,O,L,y;if(this.F_define_oamd(),o=0,O=this.BAM_source.get("",1),this.BAM_g_position+=1,O==0)if(g=this.BAM_source.get("",1),this.BAM_g_position+=1,g)r=this.BAM_source.get("",3),this.BAM_g_position+=3,f=this.OAMD_OBJECT_TYPE_ISF,_=this.BAM_g_table10.slice(0)[r];else if(f=this.OAMD_OBJECT_TYPE_BED,F=this.BAM_source.get("",1),this.BAM_g_position+=1,F)d=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_g_table11.slice(0).indexOf(d)>=0&&(o=1);else if(L=this.BAM_source.get("",1),this.BAM_g_position+=1,L)if(p=this.BAM_source.get("",1),this.BAM_g_position+=1,p)for(u=this.BAM_source.get("",17),this.BAM_g_position+=17,this.i=0;this.i<17;this.i++)u>>this.i&1&&(this.i==3||this.i==16)&&(o=1);else for(v=this.BAM_source.get("",10),this.BAM_g_position+=10,this.i=0;this.i<10;this.i++)v>>this.i&1&&((this.i==2||this.i==9)&&(o=1),h=this.BAM_g_table12.slice(0)[this.i]);else for(t>1?(B=Math.ceil(Math.log(t)/Math.log(2)),c=this.BAM_source.get("",B),this.BAM_g_position+=B,A=c+1):A=1,y=0;y<A;y++)l=this.BAM_source.get("",4),this.BAM_g_position+=4,(A==3||A==16)&&(o=1)}F_ac4_presentation_substream_info(t){var s,e=null,e,_,r;{if(_=this.BAM_source.get("",1),this.BAM_g_position+=1,r=this.BAM_source.get("",1),this.BAM_g_position+=1,s=this.BAM_source.get("",2),this.BAM_g_position+=2,s==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");s+=this.v}e==null?e=new Array(s+1).fill(0):e.length<=s&&e.push.apply(e,new Array(s-e.length+1).fill(0)),e[s]=0,this.last_referenced_substream=Math.max(this.last_referenced_substream,s),this.referenced_substreams.push(s)}}F_presentation_version(){var t,s;{for(t=0,s=this.BAM_source.get("",1),this.BAM_g_position+=1;s;)t=t+1,s=this.BAM_source.get("",1),this.BAM_g_position+=1;return t}}F_get_ch_mode(t){{if(t==this.CHANNEL_MODE_MONO)this.n=0;else if(t==this.CHANNEL_MODE_STEREO)this.n=1;else if(t==this.CHANNEL_MODE_30)this.n=2;else if(t==this.CHANNEL_MODE_50)this.n=3;else if(t==this.CHANNEL_MODE_51)this.n=4;else if(t==this.CHANNEL_MODE_70_34)this.n=5;else if(t==this.CHANNEL_MODE_71_34)this.n=6;else if(t==this.CHANNEL_MODE_70_52)this.n=7;else if(t==this.CHANNEL_MODE_71_52)this.n=8;else if(t==this.CHANNEL_MODE_70_322)this.n=9;else if(t==this.CHANNEL_MODE_71_322)this.n=10;else if(t==this.CHANNEL_MODE_704)this.n=11;else if(t==this.CHANNEL_MODE_714)this.n=12;else if(t==this.CHANNEL_MODE_904)this.n=13;else if(t==this.CHANNEL_MODE_914)this.n=14;else throw"Unknown channel mode!";return this.n}}F_presentation_config_ext_info(){{if(this.n_skip_bytes=this.BAM_source.get("",5),this.BAM_g_position+=5,this.b_more_skip_bytes=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_more_skip_bytes){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");this.n_skip_bytes+=this.v<<5}if(this.bitstream_version>=1&&this.presentation_config==8)this.n_bits_read_0=this.BAM_g_position,this.n_bits_read_1=this.BAM_g_position,this.padding=this.BAM_source.get("",this.n_skip_bytes*8-(this.n_bits_read_1-this.n_bits_read_0)),this.BAM_g_position+=this.n_skip_bytes*8-(this.n_bits_read_1-this.n_bits_read_0);else for(this.i=0;this.i<this.n_skip_bytes;this.i++)this.reserved=this.BAM_source.get("",8),this.BAM_g_position+=8}}F_define_channel_modes(){var t=null,t,s=null,s,e=null,e,_=null,_,r=null,r;this.CHANNEL_MODE_MONO=0,this.CHANNEL_MODE_STEREO=2,this.CHANNEL_MODE_30=12,this.CHANNEL_MODE_50=13,this.CHANNEL_MODE_51=14,this.CHANNEL_MODE_70_34=120,this.CHANNEL_MODE_71_34=121,this.CHANNEL_MODE_70_52=122,this.CHANNEL_MODE_71_52=123,this.CHANNEL_MODE_70_322=124,this.CHANNEL_MODE_71_322=125,this.CHANNEL_MODE_704=252,this.CHANNEL_MODE_714=253,this.CHANNEL_MODE_904=508,this.CHANNEL_MODE_914=509,this.CHANNEL_MODE_222=510,r=[this.CHANNEL_MODE_50,this.CHANNEL_MODE_51],t=[this.CHANNEL_MODE_70_34,this.CHANNEL_MODE_71_34],_=[this.CHANNEL_MODE_70_52,this.CHANNEL_MODE_71_52],s=[this.CHANNEL_MODE_70_322,this.CHANNEL_MODE_71_322],e=t+_+s}F_channel_mode_to_ch_mode(t){{if(t==this.CHANNEL_MODE_MONO)return 0;if(t==this.CHANNEL_MODE_STEREO)return 1;if(t==this.CHANNEL_MODE_30)return 2;if(t==this.CHANNEL_MODE_50)return 3;if(t==this.CHANNEL_MODE_51)return 4;if(t==this.CHANNEL_MODE_70_34)return 5;if(t==this.CHANNEL_MODE_71_34)return 6;if(t==this.CHANNEL_MODE_70_52)return 7;if(t==this.CHANNEL_MODE_71_52)return 8;if(t==this.CHANNEL_MODE_70_322)return 9;if(t==this.CHANNEL_MODE_71_322)return 10;if(t==this.CHANNEL_MODE_704)return 11;if(t==this.CHANNEL_MODE_714)return 12;if(t==this.CHANNEL_MODE_904)return 13;if(t==this.CHANNEL_MODE_914)return 14;if(t==this.CHANNEL_MODE_222)return 15;throw"Cannot convert extended channel mode to ch_mode!"}}F_variable_bits(t){var s,e,_;{for(e=0,_=1;_;)s=this.BAM_source.get("",t),this.BAM_g_position+=t,e+=s,_=this.BAM_source.get("",1),this.BAM_g_position+=1,_&&(e<<=t,e+=1<<t);return e}}F_raw_ac4_frame_toc_only(){var t,s,e;s=this.BAM_g_position,this.F_ac4_toc(),t=this.BAM_g_position,this.BAM_sink.after_position("ac4_toc_end",t),e=this.BAM_g_table13.slice(0)[this.frame_rate_index]}F_ac4_presentation_info(){{if(this.b_single_substream=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream!=1&&(this.presentation_config=this.BAM_source.get("",3),this.BAM_g_position+=3,this.presentation_config==7)){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");this.presentation_config+=this.v}if(this.presentation_version=this.F_presentation_version(),this.presentation_version==null)throw b("F_presentation_version","expected to return a value, returned None");if(this.b_single_substream!=1&&this.presentation_config==6)this.b_add_emdf_substreams=1;else{if(this.presentation_level=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_sink.write_uint("presentation_level",3,this.presentation_level,this.BAM_g_position),this.b_presentation_id=this.BAM_source.get("",1),this.BAM_g_position+=1,this.BAM_sink.write_uint("b_presentation_id",1,this.b_presentation_id,this.BAM_g_position),this.b_presentation_id){if(this.BAM_sink.before_call("variable_bits",[2],"presentation_id",this.BAM_g_position),this.presentation_id=this.F_variable_bits(2),this.presentation_id==null)throw b("F_variable_bits","expected to return a value, returned None");this.BAM_sink.after_call("variable_bits",this.presentation_id,"presentation_id",this.BAM_g_position)}this.F_frame_rate_multiply_info(),this.F_emdf_info(),this.b_single_substream==1?this.F_ac4_substream_info(0,0,0):(this.b_hsf_ext=this.BAM_source.get("",1),this.BAM_g_position+=1,this.presentation_config==0?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,1,1)):this.presentation_config==1?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,0,1)):this.presentation_config==2?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(1,0,1)):this.presentation_config==3?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,1,1),this.F_ac4_substream_info(1,0,2)):this.presentation_config==4?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,0,1),this.F_ac4_substream_info(1,0,2)):this.presentation_config==5?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1)):this.F_presentation_config_ext_info()),this.b_pre_virtualized=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_add_emdf_substreams=this.BAM_source.get("",1),this.BAM_g_position+=1}if(this.b_add_emdf_substreams){if(this.n_add_emdf_substreams=this.BAM_source.get("",2),this.BAM_g_position+=2,this.n_add_emdf_substreams==0){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");this.n_add_emdf_substreams=this.v+4}for(this.pi_i=0;this.pi_i<this.n_add_emdf_substreams;this.pi_i++)this.F_emdf_info()}}}F_substream_index_table(){var t,s=null,s,e=null,e,_=null,_,r,h,f;{if(r=this.BAM_source.get("",2),this.BAM_g_position+=2,r==0){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");r=this.v+4}if(r-1<this.last_referenced_substream)throw"Number of substreams (n_substreams) indicated by substream_index_table is less than last referenced substream in TOC (last_referenced_substream).";if(r-1>this.last_referenced_substream&&(e==null?e=new Array(r-1+1).fill(0):e.length<=r-1&&e.push.apply(e,new Array(r-1-e.length+1).fill(0)),e[r-1]=0,s==null?s=new Array(r-1+1).fill(null):s.length<=r-1&&s.push.apply(s,new Array(r-1-s.length+1).fill(null)),s[r-1]="unknown"),r==1?(t=this.BAM_source.get("",1),this.BAM_g_position+=1):t=1,t){for(h=0;h<r;h++)if(f=this.BAM_source.get("",1),this.BAM_g_position+=1,_==null?_=new Array(h+1).fill(0):_.length<=h&&_.push.apply(_,new Array(h-_.length+1).fill(0)),_[h]=this.BAM_source.get("",10),this.BAM_g_position+=10,f){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");_==null?_=new Array(h+1).fill(0):_.length<=h&&_.push.apply(_,new Array(h-_.length+1).fill(0)),_[h]+=this.v<<10}}}}F_ac4_presentation_v2_info(t){{if(this.presentation_to_groups==null?this.presentation_to_groups=new Array(this.toc_i+1).fill(null):this.presentation_to_groups.length<=this.toc_i&&this.presentation_to_groups.push.apply(this.presentation_to_groups,new Array(this.toc_i-this.presentation_to_groups.length+1).fill(null)),this.presentation_to_groups[this.toc_i]=[],this.b_single_substream_group=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream_group!=1&&(this.presentation_config=this.BAM_source.get("",3),this.BAM_g_position+=3,this.presentation_config==7)){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");this.presentation_config+=this.v}if(this.bitstream_version!=1&&(this.presentation_version=this.F_presentation_version(),this.presentation_version==null))throw b("F_presentation_version","expected to return a value, returned None");if(this.b_single_substream_group!=1&&this.presentation_config==6)this.b_add_emdf_substreams=1;else{if(this.bitstream_version!=1&&(this.presentation_level=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_sink.write_uint("presentation_level",3,this.presentation_level,this.BAM_g_position)),this.b_presentation_id=this.BAM_source.get("",1),this.BAM_g_position+=1,this.BAM_sink.write_uint("b_presentation_id",1,this.b_presentation_id,this.BAM_g_position),this.b_presentation_id){if(this.BAM_sink.before_call("variable_bits",[2],"presentation_id",this.BAM_g_position),this.presentation_id=this.F_variable_bits(2),this.presentation_id==null)throw b("F_variable_bits","expected to return a value, returned None");this.BAM_sink.after_call("variable_bits",this.presentation_id,"presentation_id",this.BAM_g_position)}if(this.F_frame_rate_multiply_info(),this.F_frame_rate_fractions_info(),this.F_emdf_info(),this.b_presentation_filter=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_presentation_filter&&(this.b_enable_presentation=this.BAM_source.get("",1),this.BAM_g_position+=1),this.b_single_substream_group==1)this.F_ac4_sgi_specifier(0,0,0),this.n_substream_groups=1;else if(this.b_multi_pid=this.BAM_source.get("",1),this.BAM_g_position+=1,this.presentation_config==0)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,1,1),this.n_substream_groups=2;else if(this.presentation_config==1)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,0,1),this.n_substream_groups=1;else if(this.presentation_config==2)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(1,0,1),this.n_substream_groups=2;else if(this.presentation_config==3)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,1,1),this.F_ac4_sgi_specifier(1,0,2),this.n_substream_groups=3;else if(this.presentation_config==4)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,0,1),this.F_ac4_sgi_specifier(1,0,2),this.n_substream_groups=2;else if(this.presentation_config==5){if(this.n_substream_groups_minus2=this.BAM_source.get("",2),this.BAM_g_position+=2,this.n_substream_groups=this.n_substream_groups_minus2+2,this.n_substream_groups==5){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");this.n_substream_groups+=this.v}for(this.sg=0;this.sg<this.n_substream_groups;this.sg++)this.F_ac4_sgi_specifier(0,0,0)}else this.n_substream_groups=0,this.F_presentation_config_ext_info();this.b_pre_virtualized=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_add_emdf_substreams=this.BAM_source.get("",1),this.BAM_g_position+=1,this.F_ac4_presentation_substream_info(this.presentation_version)}if(this.b_add_emdf_substreams){if(this.n_add_emdf_substreams=this.BAM_source.get("",2),this.BAM_g_position+=2,this.n_add_emdf_substreams==0){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");this.n_add_emdf_substreams=this.v+4}for(this.pi_i=0;this.pi_i<this.n_add_emdf_substreams;this.pi_i++)this.F_emdf_info()}}}F_frame_size(){var t;t=this.BAM_source.get("",16),this.BAM_g_position+=16,t==65535&&(t=this.BAM_source.get("",24),this.BAM_g_position+=24)}F_ac4_toc(){var t,s,e,_,r,h,f,c,p,l,d,u,o,g,A;{if(this.bitstream_version=this.BAM_source.get("",2),this.BAM_g_position+=2,this.bitstream_version==3){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");this.bitstream_version+=this.v}if(u=this.BAM_source.get("",10),this.BAM_g_position+=10,t=this.BAM_source.get("",1),this.BAM_g_position+=1,t&&(_=this.BAM_source.get("",3),this.BAM_g_position+=3,_>0&&(this.reserved=this.BAM_source.get("",2),this.BAM_g_position+=2)),this.fs_index=this.BAM_source.get("",1),this.BAM_g_position+=1,this.frame_rate_index=this.BAM_source.get("",4),this.BAM_g_position+=4,this.frame_rate_index>13)throw"frame_rate_index must be in range 0..13";if(this.fs_index==0&&this.frame_rate_index!=13)throw"44.1kHz sampling rate && frame rates other than 13 are illegal. See table 84 in the ETSI spec.";if(d=this.BAM_source.get("",1),this.BAM_g_position+=1,l=this.BAM_source.get("",1),this.BAM_g_position+=1,l)e=1;else if(g=this.BAM_source.get("",1),this.BAM_g_position+=1,g){if(this.v=this.F_variable_bits(2),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");e=this.v+2}else e=0;if(c=0,r=this.BAM_source.get("",1),this.BAM_g_position+=1,r&&(s=this.BAM_source.get("",5),this.BAM_g_position+=5,this.BAM_sink.write_uint("payload_base_minus1",5,s,this.BAM_g_position),c=s+1,c==32)){if(this.v=this.F_variable_bits(3),this.v==null)throw b("F_variable_bits","expected to return a value, returned None");c+=this.v}if(this.a_substream_indices=[],this.last_referenced_substream=-1,this.referenced_substreams=[],this.bk_substream_index=100,this.bitstream_version<=1)for(this.toc_j=0,this.toc_i=0;this.toc_i<e;this.toc_i++)this.F_ac4_presentation_info();else{for(o=this.BAM_source.get("",1),this.BAM_g_position+=1,o&&(A=this.BAM_source.get("",16),this.BAM_g_position+=16,p=this.BAM_source.get("",1),this.BAM_g_position+=1,p&&(h=this.BAM_source.get("",16*8),this.BAM_g_position+=16*8)),f=0,this.toc_i=0;this.toc_i<e;this.toc_i++)for(this.F_ac4_presentation_v2_info(this.toc_i),this.i=0;this.i<this.presentation_to_groups[this.toc_i].length;this.i++)f=Math.max(f,1+this.presentation_to_groups[this.toc_i][this.i]);for(this.toc_j=0;this.toc_j<f;this.toc_j++)this.F_ac4_substream_group_info(this.toc_j)}this.F_substream_index_table(),this.BAM_l_align=(8-(this.BAM_g_position%8+8)%8%8+8)%8,this.BAM_l_align_val=this.BAM_source.get_align(this.BAM_l_align),this.BAM_sink.write_align((8-(this.BAM_g_position%8+8)%8%8+8)%8,this.BAM_l_align_val),this.BAM_g_position+=this.BAM_l_align}}F_get_num_channels(t){{if(t==this.CHANNEL_MODE_MONO)this.n=1;else if(t==this.CHANNEL_MODE_STEREO)this.n=2;else if(t==this.CHANNEL_MODE_30)this.n=3;else if(t==this.CHANNEL_MODE_50)this.n=5;else if(t==this.CHANNEL_MODE_51)this.n=6;else if(t==this.CHANNEL_MODE_70_34)this.n=7;else if(t==this.CHANNEL_MODE_71_34)this.n=8;else if(t==this.CHANNEL_MODE_70_52)this.n=7;else if(t==this.CHANNEL_MODE_71_52)this.n=8;else if(t==this.CHANNEL_MODE_70_322)this.n=7;else if(t==this.CHANNEL_MODE_71_322)this.n=8;else if(t==this.CHANNEL_MODE_704)this.n=11;else if(t==this.CHANNEL_MODE_714)this.n=12;else if(t==this.CHANNEL_MODE_904)this.n=13;else if(t==this.CHANNEL_MODE_914)this.n=14;else throw"Unknown channel mode!";return this.n}}F_frame_rate_multiply_info(){var t,s;this.BAM_g_table14.slice(0).indexOf(this.frame_rate_index)>=0?(s=this.BAM_source.get("",1),this.BAM_g_position+=1,s?(t=this.BAM_source.get("",1),this.BAM_g_position+=1,this.frame_rate_factor=this.BAM_g_table15[t]):this.frame_rate_factor=1):this.BAM_g_table16.slice(0).indexOf(this.frame_rate_index)>=0?(s=this.BAM_source.get("",1),this.BAM_g_position+=1,this.frame_rate_factor=this.BAM_g_table17[s]):this.frame_rate_factor=1}F_frame_rate_fractions_info(){var t,s,e;s=1,this.BAM_g_table18.slice(0).indexOf(this.frame_rate_index)>=0&&this.frame_rate_factor==1&&(e=this.BAM_source.get("",1),this.BAM_g_position+=1,e==1&&(s=2)),this.BAM_g_table19.slice(0).indexOf(this.frame_rate_index)>=0&&(e=this.BAM_source.get("",1),this.BAM_g_position+=1,e==1&&(t=this.BAM_source.get("",1),this.BAM_g_position+=1,t==1?s=4:s=2))}};var Bt=(i,t)=>{let s=[],e=0,_={next(){return e<i.byteLength?{value:i.getUint8(e),done:++e>=i.byteLength}:{value:void 0,done:!0}}},r=(p,l,d,u,o)=>{let g=u-d;s.push({handler:o,name:p,pos:g,value:l,width:d})},h=new J(_),f=new X(t,r),c=new K(h,f);try{c.F_raw_ac4_frame_toc_only()}catch(p){s=null}return s};var Ut=3,Rt=7,jt=3,zt=2,Gt=256,Yt=[et,it,st,G,T,Y],Ft=i=>{var c,p,l,d;let t=i.fetch(R),s=i.fetch(j),e=[],_=s&&s.boxes.find(u=>u.type===ht),r=_&&_.boxes.filter(u=>u.type===lt),h=t&&t.boxes.filter(u=>u.type===nt),f=(c=h==null?void 0:h.map(u=>u.boxes.find(g=>g.type===at).track_ID))!=null?c:[];if(Array.isArray(r)){for(let u of r)if(u.entities.every(o=>f.includes(o.entity_id))){let o=parseInt(u.preselection_tag,10),g=isNaN(o)?null:o,A=(p=u.selection_priority)!=null?p:null,B=u.boxes.find(M=>M.type===ft),F=B==null?void 0:B.boxes.find(M=>M.type===ct),v=Number.isInteger(F==null?void 0:F.dialog_gain)?F.dialog_gain/Gt:null,O=u.boxes.find(M=>M.type===ut),L=(l=O==null?void 0:O.extended_language)!=null?l:null,y=u.boxes.find(M=>M.type===pt),S=(d=y==null?void 0:y.audio_rendering_indication)!=null?d:null,k=u.boxes.filter(M=>M.type===dt).map(M=>({isGroupLabel:M.is_group_label,label:M.label,labelId:M.label_id,language:M.language})),N=u.boxes.filter(M=>M.type===bt).map(M=>({schemeURI:M.schemeURI,value:M.value}));e.push({audioRenderingIndication:S,dialogGain:v,extendedLanguage:L,id:g,kinds:N,labels:k,selectionPriority:A})}}return e},Et=(i,t)=>{let s=vt(i);for(let e of s){let _=new DataView(i._raw.buffer,e.offset,e.size),r=Bt(_,Yt);if(r===null)return null;let h=r.find(o=>o.name===G);if(!h)return null;let f=0,c=r.find(o=>o.name===T);c&&(f=c.width);let p=r.find(o=>o.name===Y),l=[],d=[];if(r.forEach(o=>{switch(o.name){case et:{l.push({pos:o.pos,value:o.value,width:o.width});break}case st:{let g=l[l.length-1];if(l.length,o.handler==="before_call"&&(g.presentationIdPos=o.pos),o.handler==="after_call"){g.presentationId=o.value;let A=o.pos-g.presentationIdPos;g.presentationIdWidth=A,f+=A}break}case it:{d.push(o);break}case G:case T:case Y:break;default:}}),l.length<zt||l.some(o=>o.presentationId===void 0)||l.every(o=>o.presentationId!==t))return null;l.forEach(o=>{let g=o.presentationId;o.width,t!==g&&V(_,o.pos,o.width,Rt)});let u=f>>>jt;V(_,h.pos,h.width,h.value+u),d.forEach(o=>{V(_,o.pos,o.width,0)}),l.slice().reverse().forEach(o=>{let g=p.pos-o.presentationIdPos;Mt(_,o.presentationIdPos,g,o.presentationIdWidth)})}return t};var _t=kt(xt(),1);var yt={INIT:"init",MEDIA:"media"};_t.default.addBoxProcessor("diap",function(){this._procFullBox(),this._procField("dialog_gain","int",16)});var x,I,P,$,Nt=class{constructor(){H(this,P);H(this,x,{});H(this,I)}getStreams(){return E(this,x)}clearStream(t=null){delete E(this,x)[t]}setPresentationsChangedEventHandler(t){ot(this,I,t)}getPresentations(t=null){return U(this,P,$).call(this,t),E(this,x)[t].presentations}getActivePresentationId(t=null){var e;return(e=E(this,x)[t])==null?void 0:e.activePresentationId}setActivePresentationId(t,s=null){U(this,P,$).call(this,s),E(this,x)[s].activePresentationId=t}processIsoBmffSegment(t,s=null,e=void 0){let _=null,r=null,h=null,f=_t.default.parseBuffer(t),c=f.fetch(R),p=f.fetch(j),l=f.fetch(z);U(this,P,$).call(this,s);let d=E(this,x)[s];return c&&p&&(r=Ft(f),d.presentations=r,E(this,I)&&E(this,I).call(this,{streamId:s}),h=yt.INIT),l&&(_=Et(f,e!=null?e:d.activePresentationId),h=yt.MEDIA),{forcedPresentationId:_,presentations:r,segmentType:h}}};x=new WeakMap,I=new WeakMap,P=new WeakSet,$=function(t){E(this,x)[t]===void 0&&(E(this,x)[t]={activePresentationId:-1,presentations:[]})};export{Nt as Alps};
1
+ var Ht=Object.create;var _t=Object.defineProperty;var Ut=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var jt=Object.getPrototypeOf,Yt=Object.prototype.hasOwnProperty;var ut=i=>{throw TypeError(i)};var zt=(i,t,s)=>t in i?_t(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var Gt=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var Vt=(i,t,s,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let _ of Rt(t))!Yt.call(i,_)&&_!==s&&_t(i,_,{get:()=>t[_],enumerable:!(e=Ut(t,_))||e.enumerable});return i};var Xt=(i,t,s)=>(s=i!=null?Ht(jt(i)):{},Vt(t||!i||!i.__esModule?_t(s,"default",{value:i,enumerable:!0}):s,i));var n=(i,t,s)=>zt(i,typeof t!="symbol"?t+"":t,s),rt=(i,t,s)=>t.has(i)||ut("Cannot "+s);var y=(i,t,s)=>(rt(i,t,"read from private field"),s?s.call(i):t.get(i)),Y=(i,t,s)=>t.has(i)?ut("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),pt=(i,t,s,e)=>(rt(i,t,"write to private field"),e?e.call(i,s):t.set(i,s),s),z=(i,t,s)=>(rt(i,t,"access private method"),s);var It=Gt(C=>{var v={};v.parseBuffer=function(i){return new O(i).parse()};v.addBoxProcessor=function(i,t){typeof i!="string"||typeof t!="function"||(o.prototype._boxProcessors[i]=t)};v.createFile=function(){return new O};v.createBox=function(i,t,s){var e=o.create(i);return t&&t.append(e,s),e};v.createFullBox=function(i,t,s){var e=v.createBox(i,t,s);return e.version=0,e.flags=0,e};v.Utils={};v.Utils.dataViewToString=function(i,t){var s=t||"utf-8";if(typeof TextDecoder<"u")return new TextDecoder(s).decode(i);var e=[],_=0;if(s==="utf-8")for(;_<i.byteLength;){var r=i.getUint8(_++);r<128||(r<224?(r=(r&31)<<6,r|=i.getUint8(_++)&63):r<240?(r=(r&15)<<12,r|=(i.getUint8(_++)&63)<<6,r|=i.getUint8(_++)&63):(r=(r&7)<<18,r|=(i.getUint8(_++)&63)<<12,r|=(i.getUint8(_++)&63)<<6,r|=i.getUint8(_++)&63)),e.push(String.fromCharCode(r))}else for(;_<i.byteLength;)e.push(String.fromCharCode(i.getUint8(_++)));return e.join("")};v.Utils.utf8ToByteArray=function(i){var t,s;if(typeof TextEncoder<"u")t=new TextEncoder().encode(i);else for(t=[],s=0;s<i.length;++s){var e=i.charCodeAt(s);e<128?t.push(e):e<2048?(t.push(192|e>>6),t.push(128|63&e)):e<65536?(t.push(224|e>>12),t.push(128|63&e>>6),t.push(128|63&e)):(t.push(240|e>>18),t.push(128|63&e>>12),t.push(128|63&e>>6),t.push(128|63&e))}return t};v.Utils.appendBox=function(i,t,s){if(t._offset=i._cursor.offset,t._root=i._root?i._root:i,t._raw=i._raw,t._parent=i,s!==-1){if(s==null){i.boxes.push(t);return}var e=-1,_;if(typeof s=="number")e=s;else{if(typeof s=="string")_=s;else if(typeof s=="object"&&s.type)_=s.type;else{i.boxes.push(t);return}for(var r=0;r<i.boxes.length;r++)if(_===i.boxes[r].type){e=r+1;break}}i.boxes.splice(e,0,t)}};typeof C<"u"&&(C.parseBuffer=v.parseBuffer,C.addBoxProcessor=v.addBoxProcessor,C.createFile=v.createFile,C.createBox=v.createBox,C.createFullBox=v.createFullBox,C.Utils=v.Utils);v.Cursor=function(i){this.offset=typeof i>"u"?0:i};var O=function(i){this._cursor=new v.Cursor,this.boxes=[],i&&(this._raw=new DataView(i))};O.prototype.fetch=function(i){var t=this.fetchAll(i,!0);return t.length?t[0]:null};O.prototype.fetchAll=function(i,t){var s=[];return O._sweep.call(this,i,s,t),s};O.prototype.parse=function(){for(this._cursor.offset=0,this.boxes=[];this._cursor.offset<this._raw.byteLength;){var i=o.parse(this);if(typeof i.type>"u")break;this.boxes.push(i)}return this};O._sweep=function(i,t,s){this.type&&this.type==i&&t.push(this);for(var e in this.boxes){if(t.length&&s)return;O._sweep.call(this.boxes[e],i,t,s)}};O.prototype.write=function(){var i=0,t;for(t=0;t<this.boxes.length;t++)i+=this.boxes[t].getLength(!1);var s=new Uint8Array(i);for(this._rawo=new DataView(s.buffer),this.bytes=s,this._cursor.offset=0,t=0;t<this.boxes.length;t++)this.boxes[t].write();return s.buffer};O.prototype.append=function(i,t){v.Utils.appendBox(this,i,t)};var o=function(){this._cursor=new v.Cursor};o.parse=function(i){var t=new o;return t._offset=i._cursor.offset,t._root=i._root?i._root:i,t._raw=i._raw,t._parent=i,t._parseBox(),i._cursor.offset=t._raw.byteOffset+t._raw.byteLength,t};o.create=function(i){var t=new o;return t.type=i,t.boxes=[],t};o.prototype._boxContainers=["dinf","edts","mdia","meco","mfra","minf","moof","moov","mvex","stbl","strk","traf","trak","tref","udta","vttc","sinf","schi","encv","enca","meta","grpl","prsl"];o.prototype._boxProcessors={};o.prototype._procField=function(i,t,s){this._parsing?this[i]=this._readField(t,s):this._writeField(t,s,this[i])};o.prototype._procFieldArray=function(i,t,s,e){var _;if(this._parsing)for(this[i]=[],_=0;_<t;_++)this[i][_]=this._readField(s,e);else for(_=0;_<this[i].length;_++)this._writeField(s,e,this[i][_])};o.prototype._procFullBox=function(){this._procField("version","uint",8),this._procField("flags","uint",24)};o.prototype._procEntries=function(i,t,s){var e;if(this._parsing)for(this[i]=[],e=0;e<t;e++)this[i].push({}),s.call(this,this[i][e]);else for(e=0;e<t;e++)s.call(this,this[i][e])};o.prototype._procSubEntries=function(i,t,s,e){var _;if(this._parsing)for(i[t]=[],_=0;_<s;_++)i[t].push({}),e.call(this,i[t][_]);else for(_=0;_<s;_++)e.call(this,i[t][_])};o.prototype._procEntryField=function(i,t,s,e){this._parsing?i[t]=this._readField(s,e):this._writeField(s,e,i[t])};o.prototype._procSubBoxes=function(i,t){var s;if(this._parsing)for(this[i]=[],s=0;s<t;s++)this[i].push(o.parse(this));else for(s=0;s<t;s++)this._rawo?this[i][s].write():this.size+=this[i][s].getLength()};o.prototype._readField=function(i,t){switch(i){case"uint":return this._readUint(t);case"int":return this._readInt(t);case"template":return this._readTemplate(t);case"string":return t===-1?this._readTerminatedString():this._readString(t);case"data":return this._readData(t);case"utf8":return this._readUTF8String();case"utf8string":return this._readUTF8TerminatedString();default:return-1}};o.prototype._readInt=function(i){var t=null,s=this._cursor.offset-this._raw.byteOffset;switch(i){case 8:t=this._raw.getInt8(s);break;case 16:t=this._raw.getInt16(s);break;case 32:t=this._raw.getInt32(s);break;case 64:var e=this._raw.getInt32(s),_=this._raw.getInt32(s+4);t=e*Math.pow(2,32)+_;break}return this._cursor.offset+=i>>3,t};o.prototype._readUint=function(i){var t=null,s=this._cursor.offset-this._raw.byteOffset,e,_;switch(i){case 8:t=this._raw.getUint8(s);break;case 16:t=this._raw.getUint16(s);break;case 24:e=this._raw.getUint16(s),_=this._raw.getUint8(s+2),t=(e<<8)+_;break;case 32:t=this._raw.getUint32(s);break;case 64:e=this._raw.getUint32(s),_=this._raw.getUint32(s+4),t=e*Math.pow(2,32)+_;break}return this._cursor.offset+=i>>3,t};o.prototype._readString=function(i){for(var t="",s=0;s<i;s++){var e=this._readUint(8);t+=String.fromCharCode(e)}return t};o.prototype._readTemplate=function(i){var t=this._readUint(i/2),s=this._readUint(i/2);return t+s/Math.pow(2,i/2)};o.prototype._readTerminatedString=function(){for(var i="";this._cursor.offset-this._offset<this._raw.byteLength;){var t=this._readUint(8);if(t===0)break;i+=String.fromCharCode(t)}return i};o.prototype._readData=function(i){var t=i>0?i:this._raw.byteLength-(this._cursor.offset-this._offset);if(t>0){var s=new Uint8Array(this._raw.buffer,this._cursor.offset,t);return this._cursor.offset+=t,s}else return null};o.prototype._readUTF8String=function(){var i=this._raw.byteLength-(this._cursor.offset-this._offset),t=null;return i>0&&(t=new DataView(this._raw.buffer,this._cursor.offset,i),this._cursor.offset+=i),t&&v.Utils.dataViewToString(t)};o.prototype._readUTF8TerminatedString=function(){var i=this._raw.byteLength-(this._cursor.offset-this._offset),t=null;if(i>0){t=new DataView(this._raw.buffer,this._cursor.offset,i);var s;for(s=0;s<i&&t.getUint8(s)!==0;s++);t=new DataView(this._raw.buffer,this._cursor.offset,s),this._cursor.offset+=Math.min(s+1,i)}return t&&v.Utils.dataViewToString(t)};o.prototype._parseBox=function(){if(this._parsing=!0,this._cursor.offset=this._offset,this._offset+8>this._raw.buffer.byteLength){this._root._incomplete=!0;return}switch(this._procField("size","uint",32),this._procField("type","string",4),this.size===1&&this._procField("largesize","uint",64),this.type==="uuid"&&this._procFieldArray("usertype",16,"uint",8),this.size){case 0:this._raw=new DataView(this._raw.buffer,this._offset);break;case 1:this._offset+this.size>this._raw.buffer.byteLength?(this._incomplete=!0,this._root._incomplete=!0):this._raw=new DataView(this._raw.buffer,this._offset,this.largesize);break;default:this._offset+this.size>this._raw.buffer.byteLength?(this._incomplete=!0,this._root._incomplete=!0):this._raw=new DataView(this._raw.buffer,this._offset,this.size)}this._incomplete||(this._boxProcessors[this.type]&&this._boxProcessors[this.type].call(this),this._boxContainers.indexOf(this.type)!==-1?this._parseContainerBox():this._data=this._readData())};o.prototype._parseFullBox=function(){this.version=this._readUint(8),this.flags=this._readUint(24)};o.prototype._parseContainerBox=function(){for(this.boxes=[];this._cursor.offset-this._raw.byteOffset<this._raw.byteLength;)this.boxes.push(o.parse(this))};o.prototype.append=function(i,t){v.Utils.appendBox(this,i,t)};o.prototype.getLength=function(){if(this._parsing=!1,this._rawo=null,this.size=0,this._procField("size","uint",32),this._procField("type","string",4),this.size===1&&this._procField("largesize","uint",64),this.type==="uuid"&&this._procFieldArray("usertype",16,"uint",8),this._boxProcessors[this.type]&&this._boxProcessors[this.type].call(this),this._boxContainers.indexOf(this.type)!==-1)for(var i=0;i<this.boxes.length;i++)this.size+=this.boxes[i].getLength();return this._data&&this._writeData(this._data),this.size};o.prototype.write=function(){switch(this._parsing=!1,this._cursor.offset=this._parent._cursor.offset,this.size){case 0:this._rawo=new DataView(this._parent._rawo.buffer,this._cursor.offset,this.parent._rawo.byteLength-this._cursor.offset);break;case 1:this._rawo=new DataView(this._parent._rawo.buffer,this._cursor.offset,this.largesize);break;default:this._rawo=new DataView(this._parent._rawo.buffer,this._cursor.offset,this.size)}if(this._procField("size","uint",32),this._procField("type","string",4),this.size===1&&this._procField("largesize","uint",64),this.type==="uuid"&&this._procFieldArray("usertype",16,"uint",8),this._boxProcessors[this.type]&&this._boxProcessors[this.type].call(this),this._boxContainers.indexOf(this.type)!==-1)for(var i=0;i<this.boxes.length;i++)this.boxes[i].write();return this._data&&this._writeData(this._data),this._parent._cursor.offset+=this.size,this.size};o.prototype._writeInt=function(i,t){if(this._rawo){var s=this._cursor.offset-this._rawo.byteOffset;switch(i){case 8:this._rawo.setInt8(s,t);break;case 16:this._rawo.setInt16(s,t);break;case 32:this._rawo.setInt32(s,t);break;case 64:var e=Math.floor(t/Math.pow(2,32)),_=t-e*Math.pow(2,32);this._rawo.setUint32(s,e),this._rawo.setUint32(s+4,_);break}this._cursor.offset+=i>>3}else this.size+=i>>3};o.prototype._writeUint=function(i,t){if(this._rawo){var s=this._cursor.offset-this._rawo.byteOffset,e,_;switch(i){case 8:this._rawo.setUint8(s,t);break;case 16:this._rawo.setUint16(s,t);break;case 24:e=(t&16776960)>>8,_=t&255,this._rawo.setUint16(s,e),this._rawo.setUint8(s+2,_);break;case 32:this._rawo.setUint32(s,t);break;case 64:e=Math.floor(t/Math.pow(2,32)),_=t-e*Math.pow(2,32),this._rawo.setUint32(s,e),this._rawo.setUint32(s+4,_);break}this._cursor.offset+=i>>3}else this.size+=i>>3};o.prototype._writeString=function(i,t){for(var s=0;s<i;s++)this._writeUint(8,t.charCodeAt(s))};o.prototype._writeTerminatedString=function(i){if(i.length!==0){for(var t=0;t<i.length;t++)this._writeUint(8,i.charCodeAt(t));this._writeUint(8,0)}};o.prototype._writeTemplate=function(i,t){var s=Math.floor(t),e=(t-s)*Math.pow(2,i/2);this._writeUint(i/2,s),this._writeUint(i/2,e)};o.prototype._writeData=function(i){var t;if(i)if(this._rawo){if(i instanceof Array){for(var s=this._cursor.offset-this._rawo.byteOffset,t=0;t<i.length;t++)this._rawo.setInt8(s+t,i[t]);this._cursor.offset+=i.length}i instanceof Uint8Array&&(this._root.bytes.set(i,this._cursor.offset),this._cursor.offset+=i.length)}else this.size+=i.length};o.prototype._writeUTF8String=function(i){var t=v.Utils.utf8ToByteArray(i);if(this._rawo)for(var s=new DataView(this._rawo.buffer,this._cursor.offset,t.length),e=0;e<t.length;e++)s.setUint8(e,t[e]);else this.size+=t.length};o.prototype._writeField=function(i,t,s){switch(i){case"uint":this._writeUint(t,s);break;case"int":this._writeInt(t,s);break;case"template":this._writeTemplate(t,s);break;case"string":t==-1?this._writeTerminatedString(s):this._writeString(t,s);break;case"data":this._writeData(s);break;case"utf8":this._writeUTF8String(s);break;default:break}};o.prototype._boxProcessors.ardi=function(){this._procFullBox(),this._procField("audio_rendering_indication","uint",8)};o.prototype._boxProcessors.avc1=o.prototype._boxProcessors.avc2=o.prototype._boxProcessors.avc3=o.prototype._boxProcessors.avc4=o.prototype._boxProcessors.hvc1=o.prototype._boxProcessors.hev1=o.prototype._boxProcessors.encv=function(){this._procFieldArray("reserved1",6,"uint",8),this._procField("data_reference_index","uint",16),this._procField("pre_defined1","uint",16),this._procField("reserved2","uint",16),this._procFieldArray("pre_defined2",3,"uint",32),this._procField("width","uint",16),this._procField("height","uint",16),this._procField("horizresolution","template",32),this._procField("vertresolution","template",32),this._procField("reserved3","uint",32),this._procField("frame_count","uint",16),this._procFieldArray("compressorname",32,"uint",8),this._procField("depth","uint",16),this._procField("pre_defined3","int",16),this._procField("config","data",-1)};o.prototype._boxProcessors.ctts=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"sample_count","uint",32),this._procEntryField(i,"sample_offset",this.version===1?"int":"uint",32)})};o.prototype._boxProcessors.dref=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procSubBoxes("entries",this.entry_count)};o.prototype._boxProcessors.elng=function(){this._procFullBox(),this._procField("extended_language","utf8string")};o.prototype._boxProcessors.elst=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"segment_duration","uint",this.version===1?64:32),this._procEntryField(i,"media_time","int",this.version===1?64:32),this._procEntryField(i,"media_rate_integer","int",16),this._procEntryField(i,"media_rate_fraction","int",16)})};o.prototype._boxProcessors.emsg=function(){this._procFullBox(),this.version==1?(this._procField("timescale","uint",32),this._procField("presentation_time","uint",64),this._procField("event_duration","uint",32),this._procField("id","uint",32),this._procField("scheme_id_uri","string",-1),this._procField("value","string",-1)):(this._procField("scheme_id_uri","string",-1),this._procField("value","string",-1),this._procField("timescale","uint",32),this._procField("presentation_time_delta","uint",32),this._procField("event_duration","uint",32),this._procField("id","uint",32)),this._procField("message_data","data",-1)};o.prototype._boxProcessors.free=o.prototype._boxProcessors.skip=function(){this._procField("data","data",-1)};o.prototype._boxProcessors.frma=function(){this._procField("data_format","uint",32)};o.prototype._boxProcessors.ftyp=o.prototype._boxProcessors.styp=function(){this._procField("major_brand","string",4),this._procField("minor_version","uint",32);var i=-1;this._parsing&&(i=(this._raw.byteLength-(this._cursor.offset-this._raw.byteOffset))/4),this._procFieldArray("compatible_brands",i,"string",4)};o.prototype._boxProcessors.hdlr=function(){this._procFullBox(),this._procField("pre_defined","uint",32),this._procField("handler_type","string",4),this._procFieldArray("reserved",3,"uint",32),this._procField("name","string",-1)};o.prototype._boxProcessors.imda=function(){this._procField("imda_identifier","uint",32),this._procField("data","data",-1)};o.prototype._boxProcessors.kind=function(){this._procFullBox(),this._procField("schemeURI","utf8string"),this._procField("value","utf8string")};o.prototype._boxProcessors.labl=function(){this._procFullBox(),this.is_group_label=(this.flags&1)!=0,this._procField("label_id","uint",16),this._procField("language","utf8string"),this._procField("label","utf8string")};o.prototype._boxProcessors.mdat=function(){this._procField("data","data",-1)};o.prototype._boxProcessors.mdhd=function(){this._procFullBox(),this._procField("creation_time","uint",this.version==1?64:32),this._procField("modification_time","uint",this.version==1?64:32),this._procField("timescale","uint",32),this._procField("duration","uint",this.version==1?64:32),!this._parsing&&typeof this.language=="string"&&(this.language=this.language.charCodeAt(0)-96<<10|this.language.charCodeAt(1)-96<<5|this.language.charCodeAt(2)-96),this._procField("language","uint",16),this._parsing&&(this.language=String.fromCharCode((this.language>>10&31)+96,(this.language>>5&31)+96,(this.language&31)+96)),this._procField("pre_defined","uint",16)};o.prototype._boxProcessors.mehd=function(){this._procFullBox(),this._procField("fragment_duration","uint",this.version==1?64:32)};o.prototype._boxProcessors.meta=function(){this._procFullBox()};o.prototype._boxProcessors.mfhd=function(){this._procFullBox(),this._procField("sequence_number","uint",32)};o.prototype._boxProcessors.mfro=function(){this._procFullBox(),this._procField("mfra_size","uint",32)};o.prototype._boxProcessors.mp4a=o.prototype._boxProcessors.enca=function(){this._procFieldArray("reserved1",6,"uint",8),this._procField("data_reference_index","uint",16),this._procFieldArray("reserved2",2,"uint",32),this._procField("channelcount","uint",16),this._procField("samplesize","uint",16),this._procField("pre_defined","uint",16),this._procField("reserved3","uint",16),this._procField("samplerate","template",32),this._procField("esds","data",-1)};o.prototype._boxProcessors.mvhd=function(){this._procFullBox(),this._procField("creation_time","uint",this.version==1?64:32),this._procField("modification_time","uint",this.version==1?64:32),this._procField("timescale","uint",32),this._procField("duration","uint",this.version==1?64:32),this._procField("rate","template",32),this._procField("volume","template",16),this._procField("reserved1","uint",16),this._procFieldArray("reserved2",2,"uint",32),this._procFieldArray("matrix",9,"template",32),this._procFieldArray("pre_defined",6,"uint",32),this._procField("next_track_ID","uint",32)};o.prototype._boxProcessors.payl=function(){this._procField("cue_text","utf8")};o.prototype._boxProcessors.prft=function(){this._procFullBox(),this._procField("reference_track_ID","uint",32),this._procField("ntp_timestamp_sec","uint",32),this._procField("ntp_timestamp_frac","uint",32),this._procField("media_time","uint",this.version==1?64:32)};o.prototype._boxProcessors.prsl=function(){this._procFullBox(),this._procField("group_id","uint",32),this._procField("num_entities_in_group","uint",32),this._procEntries("entities",this.num_entities_in_group,function(i){this._procEntryField(i,"entity_id","uint",32)}),this.flags&4096&&this._procField("preselection_tag","utf8string"),this.flags&8192&&this._procField("selection_priority","uint",8),this.flags&16384&&this._procField("interleaving_tag","utf8string")};o.prototype._boxProcessors.pssh=function(){this._procFullBox(),this._procFieldArray("SystemID",16,"uint",8),this._procField("DataSize","uint",32),this._procFieldArray("Data",this.DataSize,"uint",8)};o.prototype._boxProcessors.schm=function(){this._procFullBox(),this._procField("scheme_type","uint",32),this._procField("scheme_version","uint",32),this.flags&1&&this._procField("scheme_uri","string",-1)};o.prototype._boxProcessors.sdtp=function(){this._procFullBox();var i=-1;this._parsing&&(i=this._raw.byteLength-(this._cursor.offset-this._raw.byteOffset)),this._procFieldArray("sample_dependency_table",i,"uint",8)};o.prototype._boxProcessors.sidx=function(){this._procFullBox(),this._procField("reference_ID","uint",32),this._procField("timescale","uint",32),this._procField("earliest_presentation_time","uint",this.version==1?64:32),this._procField("first_offset","uint",this.version==1?64:32),this._procField("reserved","uint",16),this._procField("reference_count","uint",16),this._procEntries("references",this.reference_count,function(i){this._parsing||(i.reference=(i.reference_type&1)<<31,i.reference|=i.referenced_size&2147483647,i.sap=(i.starts_with_SAP&1)<<31,i.sap|=(i.SAP_type&3)<<28,i.sap|=i.SAP_delta_time&268435455),this._procEntryField(i,"reference","uint",32),this._procEntryField(i,"subsegment_duration","uint",32),this._procEntryField(i,"sap","uint",32),this._parsing&&(i.reference_type=i.reference>>31&1,i.referenced_size=i.reference&2147483647,i.starts_with_SAP=i.sap>>31&1,i.SAP_type=i.sap>>28&7,i.SAP_delta_time=i.sap&268435455)})};o.prototype._boxProcessors.smhd=function(){this._procFullBox(),this._procField("balance","uint",16),this._procField("reserved","uint",16)};o.prototype._boxProcessors.ssix=function(){this._procFullBox(),this._procField("subsegment_count","uint",32),this._procEntries("subsegments",this.subsegment_count,function(i){this._procEntryField(i,"ranges_count","uint",32),this._procSubEntries(i,"ranges",i.ranges_count,function(t){this._procEntryField(t,"level","uint",8),this._procEntryField(t,"range_size","uint",24)})})};o.prototype._boxProcessors.stsd=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procSubBoxes("entries",this.entry_count)};o.prototype._boxProcessors.sttg=function(){this._procField("settings","utf8")};o.prototype._boxProcessors.stts=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"sample_count","uint",32),this._procEntryField(i,"sample_delta","uint",32)})};o.prototype._boxProcessors.subs=function(){this._procFullBox(),this._procField("entry_count","uint",32),this._procEntries("entries",this.entry_count,function(i){this._procEntryField(i,"sample_delta","uint",32),this._procEntryField(i,"subsample_count","uint",16),this._procSubEntries(i,"subsamples",i.subsample_count,function(t){this._procEntryField(t,"subsample_size","uint",this.version===1?32:16),this._procEntryField(t,"subsample_priority","uint",8),this._procEntryField(t,"discardable","uint",8),this._procEntryField(t,"codec_specific_parameters","uint",32)})})};o.prototype._boxProcessors.tenc=function(){this._procFullBox(),this._procField("default_IsEncrypted","uint",24),this._procField("default_IV_size","uint",8),this._procFieldArray("default_KID",16,"uint",8)};o.prototype._boxProcessors.tfdt=function(){this._procFullBox(),this._procField("baseMediaDecodeTime","uint",this.version==1?64:32)};o.prototype._boxProcessors.tfhd=function(){this._procFullBox(),this._procField("track_ID","uint",32),this.flags&1&&this._procField("base_data_offset","uint",64),this.flags&2&&this._procField("sample_description_offset","uint",32),this.flags&8&&this._procField("default_sample_duration","uint",32),this.flags&16&&this._procField("default_sample_size","uint",32),this.flags&32&&this._procField("default_sample_flags","uint",32)};o.prototype._boxProcessors.tfra=function(){this._procFullBox(),this._procField("track_ID","uint",32),this._parsing||(this.reserved=0,this.reserved|=(this.length_size_of_traf_num&48)<<4,this.reserved|=(this.length_size_of_trun_num&12)<<2,this.reserved|=this.length_size_of_sample_num&3),this._procField("reserved","uint",32),this._parsing&&(this.length_size_of_traf_num=(this.reserved&48)>>4,this.length_size_of_trun_num=(this.reserved&12)>>2,this.length_size_of_sample_num=this.reserved&3),this._procField("number_of_entry","uint",32),this._procEntries("entries",this.number_of_entry,function(i){this._procEntryField(i,"time","uint",this.version===1?64:32),this._procEntryField(i,"moof_offset","uint",this.version===1?64:32),this._procEntryField(i,"traf_number","uint",(this.length_size_of_traf_num+1)*8),this._procEntryField(i,"trun_number","uint",(this.length_size_of_trun_num+1)*8),this._procEntryField(i,"sample_number","uint",(this.length_size_of_sample_num+1)*8)})};o.prototype._boxProcessors.tkhd=function(){this._procFullBox(),this._procField("creation_time","uint",this.version==1?64:32),this._procField("modification_time","uint",this.version==1?64:32),this._procField("track_ID","uint",32),this._procField("reserved1","uint",32),this._procField("duration","uint",this.version==1?64:32),this._procFieldArray("reserved2",2,"uint",32),this._procField("layer","uint",16),this._procField("alternate_group","uint",16),this._procField("volume","template",16),this._procField("reserved3","uint",16),this._procFieldArray("matrix",9,"template",32),this._procField("width","template",32),this._procField("height","template",32)};o.prototype._boxProcessors.trex=function(){this._procFullBox(),this._procField("track_ID","uint",32),this._procField("default_sample_description_index","uint",32),this._procField("default_sample_duration","uint",32),this._procField("default_sample_size","uint",32),this._procField("default_sample_flags","uint",32)};o.prototype._boxProcessors.trun=function(){this._procFullBox(),this._procField("sample_count","uint",32),this.flags&1&&this._procField("data_offset","int",32),this.flags&4&&this._procField("first_sample_flags","uint",32),this._procEntries("samples",this.sample_count,function(i){this.flags&256&&this._procEntryField(i,"sample_duration","uint",32),this.flags&512&&this._procEntryField(i,"sample_size","uint",32),this.flags&1024&&this._procEntryField(i,"sample_flags","uint",32),this.flags&2048&&this._procEntryField(i,"sample_composition_time_offset",this.version===1?"int":"uint",32)})};o.prototype._boxProcessors["url "]=o.prototype._boxProcessors["urn "]=function(){this._procFullBox(),this.type==="urn "&&this._procField("name","string",-1),this._procField("location","string",-1)};o.prototype._boxProcessors.vlab=function(){this._procField("source_label","utf8")};o.prototype._boxProcessors.vmhd=function(){this._procFullBox(),this._procField("graphicsmode","uint",16),this._procFieldArray("opcolor",3,"uint",16)};o.prototype._boxProcessors.vttC=function(){this._procField("config","utf8")};o.prototype._boxProcessors.vtte=function(){}});var G="moov",dt="trak",bt="tkhd",V="meta",gt="grpl",At="prsl",mt="udta",Mt="diap",vt="elng",Bt="ardi",Ft="labl",Et="kind",X="moof",xt="traf",yt="tfhd",Nt="trun";var nt="b_presentation_id",at="presentation_id",ht="presentation_level",J="payload_base_minus1",S="byte_alignment",K="ac4_toc_end",$="payload_base";var W=i=>{let t=(i&240)>>>4|(i&15)<<4;return t=(t&204)>>>2|(t&51)<<2,t=(t&170)>>>1|(t&85)<<1,t},wt=(i,t,s,e)=>{if(s===0)return i;let _=t>>3,r=t+s-1>>3,u=255>>(t&7),a=255<<7-(t+s-1&7)&255,b=e<24,p=b?0:2**e,l=0;for(let f=r;f>=_;f--){let h=255;f===_&&(h&=u),f===r&&(h&=a);let d=i.getUint8(f);b?(l=((d&h)<<e)+l,i.setUint8(f,d&~h|l&255&h),l>>>=8):(l=(d&h)*p+l,i.setUint8(f,d&~h|l%256&h),l=Math.trunc(l/256))}return i},Ot=(i,t,s,e)=>{if(s===0)return i;let _=t>>3,r=t+s-1>>3,u=255>>(t&7),a=255<<7-(t+s-1&7)&255,b=e<24,p=b?0:2**e,l=0;for(let f=_;f<=r;f++){let h=255;f===_&&(h&=u),f===r&&(h&=a);let d=i.getUint8(f);b?(l=(W(d&h)<<e)+l,i.setUint8(f,d&~h|W(l&255)&h),l>>>=8):(l=W(d&h)*p+l,i.setUint8(f,d&~h|W(l%256)&h),l=Math.trunc(l/256))}return i},L=(i,t,s,e)=>{let _=t>>>3,r=t&7,u=(1<<s)-1<<16-s>>r,a=i.getUint8(_)<<8|i.getUint8(_+1);a&=~u,a|=e<<16-s-r,i.setUint8(_,a>>>8),i.setUint8(_+1,a&255)};var Dt=i=>{let t=[],e=i.fetch(X),_=!0;for(let r of i.fetchAll(xt)){let u=r.boxes.find(l=>l.type===yt),a=u.base_data_offset||0,b=u.flags&131072;if(a)throw Error("base_data_offset is relative to the file identified by the referenced data reference entry unsupported");if(!b)throw Error(_?"base_data_offset is relative to the first byte of the MovieFragmentBox containing this box unsupported":"base_data_offset is relative to the end of the data defined by the preceding track fragment is unsupported");let p=e._offset;for(let l of r.boxes.filter(f=>f.type===Nt)){let f=p+a+l.data_offset;for(let h of l.samples)t.push({offset:f,size:h.sample_size}),f+=h.sample_size}_=!1}return t};var Z=class{constructor(t){this.iterator=t,this.cache=0,this.bitsLeft=0}get(t,s){s>25;let a=s;for(;this.bitsLeft<a;){let p=this.iterator.next(),l=24-this.bitsLeft;this.cache|=p.value<<l,this.bitsLeft+=8,a>25&&(this.cache<<=8,this.bitsLeft-=8,a-=8)}let b=this.cache>>>32-a;return this.cache<<=a,this.bitsLeft-=a,b}get_align(t){return this.get("align",t)}};var q=class{constructor(t,s){this.elements=t,this.callback=s}before_call(t,s,e,_){this.elements.includes(e)&&this.callback(e,null,null,_,"before_call")}after_call(t,s,e,_){this.elements.includes(e)&&this.callback(e,s,null,_,"after_call")}write_uint(t,s,e,_){this.elements.includes(t)&&this.callback(t,e,s,_)}write_align(t,s){this.elements.includes(S)&&this.callback(S,s,t,null,"write_align")}after_position(t,s){this.elements.includes(t)&&this.callback(t,null,null,s,"after_position")}after_add(t,s){this.elements.includes(t)&&this.callback(t,s,null,null,"after_add")}};var m=class extends Error{},Q=class{constructor(t,s){n(this,"v",null);n(this,"content_classifier",null);n(this,"i",null);n(this,"frame_rate_factor",null);n(this,"bk_substream_index",null);n(this,"a_substream_indices",null);n(this,"last_referenced_substream",null);n(this,"referenced_substreams",null);n(this,"protection_bits_primary_bits",null);n(this,"protection_bits_secondary_bits",null);n(this,"toc_i",null);n(this,"OAMD_OBJECT_TYPE_BED",null);n(this,"OAMD_OBJECT_TYPE_ISF",null);n(this,"OAMD_OBJECT_TYPE_DYNAMIC",null);n(this,"OAMD_OBJECT_TYPE_RESERVED",null);n(this,"toc_j",null);n(this,"vb",null);n(this,"presentation_to_groups",null);n(this,"group_frame_rate_factor",null);n(this,"b_hsf_ext",null);n(this,"b_single_substream",null);n(this,"n_bed_objects",null);n(this,"a_num_bed_objects",null);n(this,"b_bed_objects_prev",null);n(this,"num_lfe",null);n(this,"n",null);n(this,"n_skip_bytes",null);n(this,"b_more_skip_bytes",null);n(this,"n_bits_read_0",null);n(this,"n_bits_read_1",null);n(this,"n_bits_read",null);n(this,"n_skip_bits",null);n(this,"reserved",null);n(this,"padding",null);n(this,"CHANNEL_MODE_MONO",null);n(this,"CHANNEL_MODE_STEREO",null);n(this,"CHANNEL_MODE_30",null);n(this,"CHANNEL_MODE_50",null);n(this,"CHANNEL_MODE_51",null);n(this,"CHANNEL_MODE_70_34",null);n(this,"CHANNEL_MODE_71_34",null);n(this,"CHANNEL_MODE_70_52",null);n(this,"CHANNEL_MODE_71_52",null);n(this,"CHANNEL_MODE_70_322",null);n(this,"CHANNEL_MODE_71_322",null);n(this,"CHANNEL_MODE_704",null);n(this,"CHANNEL_MODE_714",null);n(this,"CHANNEL_MODE_904",null);n(this,"CHANNEL_MODE_914",null);n(this,"CHANNEL_MODE_222",null);n(this,"presentation_config",null);n(this,"presentation_version",null);n(this,"b_add_emdf_substreams",null);n(this,"presentation_level",null);n(this,"b_presentation_id",null);n(this,"presentation_id",null);n(this,"b_pre_virtualized",null);n(this,"n_add_emdf_substreams",null);n(this,"pi_i",null);n(this,"b_single_substream_group",null);n(this,"b_presentation_filter",null);n(this,"b_enable_presentation",null);n(this,"n_substream_groups",null);n(this,"b_multi_pid",null);n(this,"n_substream_groups_minus2",null);n(this,"sg",null);n(this,"bitstream_version",null);n(this,"fs_index",null);n(this,"frame_rate_index",null);n(this,"BAM_g_position",0);n(this,"BAM_g_table0",[0,2,4,6]);n(this,"BAM_g_table1",[252,253,508,509]);n(this,"BAM_g_table2",[122,123,124,125]);n(this,"BAM_g_table3",[252,253,508,509]);n(this,"BAM_g_table4",[4,6,8,10,12,14]);n(this,"BAM_g_table5",[122,123,124,125]);n(this,"BAM_g_table6",[0,0]);n(this,"BAM_g_table7",[0,1,2,3,5,0,0,0]);n(this,"BAM_g_table8",[2,3,6,8,10,8,10,12]);n(this,"BAM_g_table9",[2,1,1,2,2,2,2,2,2,1]);n(this,"BAM_g_table10",[4,8,10,14,15,30,-1,-1]);n(this,"BAM_g_table11",[2,3,4,5,6,7]);n(this,"BAM_g_table12",[2,1,1,2,2,2,2,2,2,1]);n(this,"BAM_g_table13",[1920,1920,2048,1536,1536,960,960,1024,768,768,512,384,384,2048]);n(this,"BAM_g_table14",[2,3,4]);n(this,"BAM_g_table15",{0:2,1:4});n(this,"BAM_g_table16",[0,1,7,8,9]);n(this,"BAM_g_table17",{0:1,1:2});n(this,"BAM_g_table18",[5,6,7,8,9]);n(this,"BAM_g_table19",[10,11,12]);this.BAM_source=t,this.BAM_sink=s}F_channel_mode_contains_LFE(t){return t==this.CHANNEL_MODE_51||t==this.CHANNEL_MODE_71_34||t==this.CHANNEL_MODE_71_52||t==this.CHANNEL_MODE_71_322?1:0}F_bitrate_indicator(){var t,s;s=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_g_table0.slice(0).indexOf(s)>=0?s=s>>1:(this.v=this.BAM_source.get("",2),this.BAM_g_position+=2,this.v=(s<<2)+this.v,t=Math.floor(this.v/8),s=this.v-t*4)}F_content_type(){var t,s,e,_,r,u;if(this.content_classifier=this.BAM_source.get("",3),this.BAM_g_position+=3,e=this.BAM_source.get("",1),this.BAM_g_position+=1,e)if(s=this.BAM_source.get("",1),this.BAM_g_position+=1,s)t=this.BAM_source.get("",1),this.BAM_g_position+=1,_=this.BAM_source.get("",16),this.BAM_g_position+=16;else for(r=this.BAM_source.get("",6),this.BAM_g_position+=6,this.i=0;this.i<r;this.i++)u=this.BAM_source.get("",8),this.BAM_g_position+=8}F_ac4_substream_info_chan(t,s,e){var _,r,u,a,b,p,l,f,h,d,g,A=null,A;{if(this.F_define_channel_modes(),this.F_define_oamd(),a=this.F_channel_mode(),a==null)throw m("F_channel_mode","expected to return a value, returned None");if(a==511){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");a+=this.v}for(this.BAM_g_table1.slice(0).indexOf(a)>=0&&(h=this.BAM_source.get("",1),this.BAM_g_position+=1,l=this.BAM_source.get("",1),this.BAM_g_position+=1,r=this.BAM_source.get("",2),this.BAM_g_position+=2),this.fs_index==1&&(p=this.BAM_source.get("",1),this.BAM_g_position+=1,p&&(d=this.BAM_source.get("",1),this.BAM_g_position+=1)),b=this.BAM_source.get("",1),this.BAM_g_position+=1,b&&this.F_bitrate_indicator(),this.BAM_g_table2.slice(0).indexOf(a)>=0&&(f=this.BAM_source.get("",1),this.BAM_g_position+=1),this.frame_rate_factor=this.group_frame_rate_factor[t],this.i=0;this.i<this.frame_rate_factor;this.i++)u=this.BAM_source.get("",1),this.BAM_g_position+=1;if(e==1){if(g=this.BAM_source.get("",2),this.BAM_g_position+=2,g==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");g+=this.v}}else g=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;for(this.a_substream_indices.push(g),this.i=0;this.i<this.frame_rate_factor;this.i++){if(e==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,g+this.i),this.referenced_substreams.push(g+this.i)),this.BAM_g_table3.slice(0).indexOf(a)>=0,_=this.F_get_ch_mode(a),_==null)throw m("F_get_ch_mode","expected to return a value, returned None");this.BAM_g_table4.slice(0).indexOf(_)>=0?(A==null?A=new Array(g+this.i+1).fill(0):A.length<=g+this.i&&A.push.apply(A,new Array(g+this.i-A.length+1).fill(0)),A[g+this.i]=1):(A==null?A=new Array(g+this.i+1).fill(0):A.length<=g+this.i&&A.push.apply(A,new Array(g+this.i-A.length+1).fill(0)),A[g+this.i]=0)}}}F_channel_mode(){var t,s;return t=this.BAM_source.get("",1),this.BAM_g_position+=1,t==1&&(this.v=this.BAM_source.get("",1),this.BAM_g_position+=1,t=(t<<1)+this.v,s=2,t==3&&(this.v=this.BAM_source.get("",2),this.BAM_g_position+=2,t=(t<<2)+this.v,t==15&&(this.v=this.BAM_source.get("",3),this.BAM_g_position+=3,t=(t<<3)+this.v,(t==120||t==121)&&(s=t,t=2),t==126&&(this.v=this.BAM_source.get("",1),this.BAM_g_position+=1,t=(t<<1)+this.v),t==127&&(this.v=this.BAM_source.get("",2),this.BAM_g_position+=2,t=(t<<2)+this.v)))),t}F_ac4_substream_info(t,s,e){var _,r,u,a,b,p,l,f,h,d,g=null,g;{if(this.F_define_channel_modes(),a=this.F_channel_mode(),a==null)throw m("F_channel_mode","expected to return a value, returned None");if(a==511){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");a+=this.v}for(this.fs_index==1&&(p=this.BAM_source.get("",1),this.BAM_g_position+=1,p&&(_=this.BAM_source.get("",1),this.BAM_g_position+=1)),b=this.BAM_source.get("",1),this.BAM_g_position+=1,b&&this.F_bitrate_indicator(),this.BAM_g_table5.slice(0).indexOf(a)>=0&&(h=this.BAM_source.get("",1),this.BAM_g_position+=1),f=this.BAM_source.get("",1),this.BAM_g_position+=1,f?(this.F_content_type(),this.content_classifier==0||this.content_classifier==1?(r=0,l=0):this.content_classifier==2||this.content_classifier==3?(r=1,l=0):this.content_classifier==4?(r=0,l=1):this.content_classifier==5?(r=1,l=0):(this.content_classifier==6||this.content_classifier==7)&&(r=0,l=0)):(r=0,l=0),this.i=0;this.i<this.frame_rate_factor;this.i++)u=this.BAM_source.get("",1),this.BAM_g_position+=1;if(d=this.BAM_source.get("",2),this.BAM_g_position+=2,d==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");d+=this.v}for(this.a_substream_indices.push(d),this.i=0;this.i<this.frame_rate_factor;this.i++)if(this.last_referenced_substream=Math.max(this.last_referenced_substream,d+this.i),this.referenced_substreams.push(d+this.i),g==null?g=new Array(d+1+1).fill(0):g.length<=d+1&&g.push.apply(g,new Array(d+1-g.length+1).fill(0)),g[d+1]=this.F_channel_mode_contains_LFE(a),g[d+1]==null)throw m("F_channel_mode_contains_LFE","expected to return a value, returned None")}}F_emdf_protection(){var t,s,e,_;{if(_=this.BAM_source.get("",2),this.BAM_g_position+=2,s=this.BAM_source.get("",2),this.BAM_g_position+=2,_==0)throw"protection_length_primary == 0 is reserved";_==1?this.protection_bits_primary_bits=8:_==2?this.protection_bits_primary_bits=32:_==3&&(this.protection_bits_primary_bits=128),t=this.BAM_source.get("",this.protection_bits_primary_bits),this.BAM_g_position+=this.protection_bits_primary_bits,s==0?this.protection_bits_secondary_bits=0:s==1?this.protection_bits_secondary_bits=8:s==2?this.protection_bits_secondary_bits=32:s==3&&(this.protection_bits_secondary_bits=128),e=this.BAM_source.get("",this.protection_bits_secondary_bits),this.BAM_g_position+=this.protection_bits_secondary_bits}}F_emdf_info(){var t,s,e;{if(e=this.BAM_source.get("",2),this.BAM_g_position+=2,e==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");e+=this.v}if(t=this.BAM_source.get("",3),this.BAM_g_position+=3,t==7){if(this.v=this.F_variable_bits(3),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");t+=this.v}s=this.BAM_source.get("",1),this.BAM_g_position+=1,s&&this.F_emdf_payloads_substream_info(this.toc_i),this.F_emdf_protection()}}F_emdf_payloads_substream_info(t){var s;{if(s=this.BAM_source.get("",2),this.BAM_g_position+=2,s==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");s+=this.v}this.last_referenced_substream=Math.max(this.last_referenced_substream,s),this.referenced_substreams.push(s),this.a_substream_indices.push(s)}}F_ac4_hsf_ext_substream_info(t){var s;{if(t==1){if(s=this.BAM_source.get("",2),this.BAM_g_position+=2,s==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");s+=this.v}}else s=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;t==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,s),this.referenced_substreams.push(s))}}F_oamd_common_data(){var t,s,e,_,r,u,a,b,p,l,f;if(l=this.BAM_source.get("",1),this.BAM_g_position+=1,l==0&&(u=this.BAM_source.get("",5),this.BAM_g_position+=5),b=this.BAM_source.get("",1),this.BAM_g_position+=1,e=this.BAM_source.get("",1),this.BAM_g_position+=1,e){if(t=this.BAM_source.get("",1),this.BAM_g_position+=1,s=t+1,s==2){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");s+=this.v}if(p=s*8,f=this.BAM_g_position,r=this.BAM_g_position,_=r-f,p=p-_,p<0)throw"Wrong add_data_bytes_minus1 size indication";a=this.BAM_source.get("",p),this.BAM_g_position+=p}}F_define_oamd(){var t;this.OAMD_OBJECT_TYPE_BED=0,this.OAMD_OBJECT_TYPE_ISF=1,this.OAMD_OBJECT_TYPE_DYNAMIC=2,this.OAMD_OBJECT_TYPE_RESERVED=3,t=9}F_ac4_substream_info_ajoc(t,s,e){var _,r,u,a,b,p,l,f,h,d,g,A=null,A,c,M,B=null,B;{if(A=this.BAM_g_table6.slice(0),this.F_define_channel_modes(),M=this.BAM_source.get("",1),this.BAM_g_position+=1,f=this.BAM_source.get("",1),this.BAM_g_position+=1,f?(h=5,M?a=this.CHANNEL_MODE_51:a=this.CHANNEL_MODE_50):(d=this.BAM_source.get("",4),this.BAM_g_position+=4,h=d+1,this.F_bed_dyn_obj_assignment(h,0,M)),_=this.BAM_source.get("",1),this.BAM_g_position+=1,_&&this.F_oamd_common_data(),l=this.BAM_source.get("",4),this.BAM_g_position+=4,g=l+1,g==16){if(this.v=this.F_variable_bits(3),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");g=g+this.v}for(this.F_bed_dyn_obj_assignment(g,1,M),this.fs_index==1&&(u=this.BAM_source.get("",1),this.BAM_g_position+=1,u&&(p=this.BAM_source.get("",1),this.BAM_g_position+=1)),b=this.BAM_source.get("",1),this.BAM_g_position+=1,b&&this.F_bitrate_indicator(),this.frame_rate_factor=this.group_frame_rate_factor[t],this.i=0;this.i<this.frame_rate_factor;this.i++)r=this.BAM_source.get("",1),this.BAM_g_position+=1;if(e==1){if(c=this.BAM_source.get("",2),this.BAM_g_position+=2,c==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");c+=this.v}}else c=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;for(this.a_substream_indices.push(c),this.i=0;this.i<this.frame_rate_factor;this.i++)e==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,c+this.i),this.referenced_substreams.push(c+this.i)),B==null?B=new Array(c+this.i+1).fill(0):B.length<=c+this.i&&B.push.apply(B,new Array(c+this.i-B.length+1).fill(0)),B[c+this.i]=M}}F_ac4_sgi_specifier(t,s,e){var _;if(this.bitstream_version==1)this.F_ac4_substream_group_info(this.toc_j),this.toc_j+=1;else{if(_=this.BAM_source.get("",3),this.BAM_g_position+=3,_==7){if(this.vb=this.F_variable_bits(2),this.vb==null)throw m("F_variable_bits","expected to return a value, returned None");_+=this.vb}this.presentation_to_groups==null?this.presentation_to_groups=new Array(this.toc_i+1).fill(null):this.presentation_to_groups.length<=this.toc_i&&this.presentation_to_groups.push.apply(this.presentation_to_groups,new Array(this.toc_i-this.presentation_to_groups.length+1).fill(null)),this.presentation_to_groups[this.toc_i].push(_),this.group_frame_rate_factor==null?this.group_frame_rate_factor=new Array(_+1).fill(0):this.group_frame_rate_factor.length<=_&&this.group_frame_rate_factor.push.apply(this.group_frame_rate_factor,new Array(_-this.group_frame_rate_factor.length+1).fill(0)),this.group_frame_rate_factor[_]=this.frame_rate_factor}}F_ac4_substream_group_info(t){var s,e,_,r,u,a,b,p,l,f,h,d;{if(h=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_hsf_ext=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream)f=1;else if(a=this.BAM_source.get("",2),this.BAM_g_position+=2,f=a+2,f==5){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");f+=this.v}if(s=this.BAM_source.get("",1),this.BAM_g_position+=1,this.n_bed_objects=-1,this.a_num_bed_objects=[],s)for(_=0,r=0;r<f;r++)this.bitstream_version==1?(e=this.BAM_source.get("",1),this.BAM_g_position+=1):e=1,this.F_ac4_substream_info_chan(t,r,h),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(h);else for(l=this.BAM_source.get("",1),this.BAM_g_position+=1,l&&this.F_oamd_substream_info(h),b=0,this.b_bed_objects_prev=0,r=0;r<f;r++)_=this.BAM_source.get("",1),this.BAM_g_position+=1,_?(this.F_ac4_substream_info_ajoc(t,r,h),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(h)):(this.F_ac4_substream_info_obj(t,r,b,h),b+=1,this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(h));d=this.BAM_source.get("",1),this.BAM_g_position+=1,d?(this.F_content_type(),this.content_classifier==0||this.content_classifier==1?(p=0,u=0):this.content_classifier==2||this.content_classifier==3?(p=1,u=0):this.content_classifier==4?(p=0,u=1):this.content_classifier==5?(p=1,u=0):(this.content_classifier==6||this.content_classifier==7)&&(p=0,u=0)):(p=0,u=0)}}F_oamd_substream_info(t){var s,e;{if(this.F_define_oamd(),s=this.BAM_source.get("",1),this.BAM_g_position+=1,t==1){if(e=this.BAM_source.get("",2),this.BAM_g_position+=2,e==3){if(this.vb=this.F_variable_bits(2),this.vb==null)throw m("F_variable_bits","expected to return a value, returned None");e+=this.vb}}else e=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;t==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,e),this.referenced_substreams.push(e))}}F_ac4_substream_info_obj(t,s,e,_){var r,u,a,b,p,l,f,h,d,g,A,c,M,B,E,T,w,U,R,st,et,j,F,x,D=null,D;{if(A=0,this.F_define_oamd(),this.F_define_channel_modes(),b=this.BAM_source.get("",3),this.BAM_g_position+=3,et=this.BAM_g_table7.slice(0)[b],B=this.BAM_source.get("",1),this.BAM_g_position+=1,B)r=this.BAM_source.get("",1),this.BAM_g_position+=1,f=this.OAMD_OBJECT_TYPE_DYNAMIC,this.b_bed_objects_prev=0;else if(U=this.BAM_source.get("",1),this.BAM_g_position+=1,U){if(this.b_bed_objects_prev&&this.num_lfe==2?r=1:r=0,this.b_bed_objects_prev=1,this.num_lfe=0,f=this.OAMD_OBJECT_TYPE_BED,h=this.BAM_source.get("",1),this.BAM_g_position+=1,h){if(M=this.BAM_source.get("",1),this.BAM_g_position+=1,M){for(R=this.BAM_source.get("",3),this.BAM_g_position+=3,this.i=0;this.i<this.BAM_g_table8.slice(0)[R];this.i++)A+=1;R>=2&&(r=1)}else{if(F=this.BAM_source.get("",1),this.BAM_g_position+=1,F)for(T=this.BAM_source.get("",17),this.BAM_g_position+=17,this.i=0;this.i<17;this.i++)T&1<<this.i&&((this.i==3||this.i==16)&&(this.num_lfe+=1),A+=1);else for(E=this.BAM_source.get("",10),this.BAM_g_position+=10,this.i=0;this.i<10;this.i++)if(E&1<<this.i)for(d=0;d<this.BAM_g_table9.slice(0)[this.i];d++)(this.i==2||this.i==9)&&(this.num_lfe+=1),A+=1;this.num_lfe>0&&(r=1)}this.n_bed_objects=A,this.a_num_bed_objects.push(this.n_bed_objects)}}else if(r=0,this.b_bed_objects_prev=0,j=this.BAM_source.get("",1),this.BAM_g_position+=1,j)f=this.OAMD_OBJECT_TYPE_ISF,p=this.BAM_source.get("",1),this.BAM_g_position+=1,p&&(g=this.BAM_source.get("",3),this.BAM_g_position+=3);else if(c=this.BAM_source.get("",4),this.BAM_g_position+=4,a=this.BAM_source.get("",8*c),this.BAM_g_position+=8*c,f=this.OAMD_OBJECT_TYPE_RESERVED,et==0)throw"No non-LFE objects (of OAMD_OBJECT_TYPE_RESERVED) in substream!";for(this.fs_index==1&&(l=this.BAM_source.get("",1),this.BAM_g_position+=1,l&&(st=this.BAM_source.get("",1),this.BAM_g_position+=1)),w=this.BAM_source.get("",1),this.BAM_g_position+=1,w&&this.F_bitrate_indicator(),this.frame_rate_factor=this.group_frame_rate_factor[t],this.i=0;this.i<this.frame_rate_factor;this.i++)u=this.BAM_source.get("",1),this.BAM_g_position+=1;if(_==1){if(x=this.BAM_source.get("",2),this.BAM_g_position+=2,x==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");x+=this.v}}else x=this.bk_substream_index,this.bk_substream_index=this.bk_substream_index+1;for(this.a_substream_indices.push(x),this.i=0;this.i<this.frame_rate_factor;this.i++)_==1&&(this.last_referenced_substream=Math.max(this.last_referenced_substream,x+this.i),this.referenced_substreams.push(x+this.i)),D==null?D=new Array(x+this.i+1).fill(0):D.length<=x+this.i&&D.push.apply(D,new Array(x+this.i-D.length+1).fill(0)),D[x+this.i]=r}}F_bed_dyn_obj_assignment(t,s,e){var _,r,u,a,b,p,l,f,h,d,g,A,c,M,B,E,T,w;if(this.F_define_oamd(),a=0,d=this.BAM_source.get("",1),this.BAM_g_position+=1,d==0)if(l=this.BAM_source.get("",1),this.BAM_g_position+=1,l)A=this.BAM_source.get("",3),this.BAM_g_position+=3,p=this.OAMD_OBJECT_TYPE_ISF,f=this.BAM_g_table10.slice(0)[A];else if(p=this.OAMD_OBJECT_TYPE_BED,_=this.BAM_source.get("",1),this.BAM_g_position+=1,_)c=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_g_table11.slice(0).indexOf(c)>=0&&(a=1);else if(r=this.BAM_source.get("",1),this.BAM_g_position+=1,r)if(T=this.BAM_source.get("",1),this.BAM_g_position+=1,T)for(b=this.BAM_source.get("",17),this.BAM_g_position+=17,this.i=0;this.i<17;this.i++)b>>this.i&1&&(this.i==3||this.i==16)&&(a=1);else for(u=this.BAM_source.get("",10),this.BAM_g_position+=10,this.i=0;this.i<10;this.i++)u>>this.i&1&&((this.i==2||this.i==9)&&(a=1),M=this.BAM_g_table12.slice(0)[this.i]);else for(t>1?(h=Math.ceil(Math.log(t)/Math.log(2)),B=this.BAM_source.get("",h),this.BAM_g_position+=h,E=B+1):E=1,w=0;w<E;w++)g=this.BAM_source.get("",4),this.BAM_g_position+=4,(E==3||E==16)&&(a=1)}F_ac4_presentation_substream_info(t){var s,e,_,r=null,r;{if(s=this.BAM_source.get("",1),this.BAM_g_position+=1,e=this.BAM_source.get("",1),this.BAM_g_position+=1,_=this.BAM_source.get("",2),this.BAM_g_position+=2,_==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");_+=this.v}r==null?r=new Array(_+1).fill(0):r.length<=_&&r.push.apply(r,new Array(_-r.length+1).fill(0)),r[_]=0,this.last_referenced_substream=Math.max(this.last_referenced_substream,_),this.referenced_substreams.push(_)}}F_presentation_version(){var t,s;{for(s=0,t=this.BAM_source.get("",1),this.BAM_g_position+=1;t;)s=s+1,t=this.BAM_source.get("",1),this.BAM_g_position+=1;return s}}F_get_ch_mode(t){{if(t==this.CHANNEL_MODE_MONO)this.n=0;else if(t==this.CHANNEL_MODE_STEREO)this.n=1;else if(t==this.CHANNEL_MODE_30)this.n=2;else if(t==this.CHANNEL_MODE_50)this.n=3;else if(t==this.CHANNEL_MODE_51)this.n=4;else if(t==this.CHANNEL_MODE_70_34)this.n=5;else if(t==this.CHANNEL_MODE_71_34)this.n=6;else if(t==this.CHANNEL_MODE_70_52)this.n=7;else if(t==this.CHANNEL_MODE_71_52)this.n=8;else if(t==this.CHANNEL_MODE_70_322)this.n=9;else if(t==this.CHANNEL_MODE_71_322)this.n=10;else if(t==this.CHANNEL_MODE_704)this.n=11;else if(t==this.CHANNEL_MODE_714)this.n=12;else if(t==this.CHANNEL_MODE_904)this.n=13;else if(t==this.CHANNEL_MODE_914)this.n=14;else throw"Unknown channel mode!";return this.n}}F_presentation_config_ext_info(){{if(this.n_skip_bytes=this.BAM_source.get("",5),this.BAM_g_position+=5,this.b_more_skip_bytes=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_more_skip_bytes){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");this.n_skip_bytes+=this.v<<5}if(this.bitstream_version>=1&&this.presentation_config==8)this.n_bits_read_0=this.BAM_g_position,this.n_bits_read_1=this.BAM_g_position,this.padding=this.BAM_source.get("",this.n_skip_bytes*8-(this.n_bits_read_1-this.n_bits_read_0)),this.BAM_g_position+=this.n_skip_bytes*8-(this.n_bits_read_1-this.n_bits_read_0);else for(this.i=0;this.i<this.n_skip_bytes;this.i++)this.reserved=this.BAM_source.get("",8),this.BAM_g_position+=8}}F_define_channel_modes(){var t=null,t,s=null,s,e=null,e,_=null,_,r=null,r;this.CHANNEL_MODE_MONO=0,this.CHANNEL_MODE_STEREO=2,this.CHANNEL_MODE_30=12,this.CHANNEL_MODE_50=13,this.CHANNEL_MODE_51=14,this.CHANNEL_MODE_70_34=120,this.CHANNEL_MODE_71_34=121,this.CHANNEL_MODE_70_52=122,this.CHANNEL_MODE_71_52=123,this.CHANNEL_MODE_70_322=124,this.CHANNEL_MODE_71_322=125,this.CHANNEL_MODE_704=252,this.CHANNEL_MODE_714=253,this.CHANNEL_MODE_904=508,this.CHANNEL_MODE_914=509,this.CHANNEL_MODE_222=510,s=[this.CHANNEL_MODE_50,this.CHANNEL_MODE_51],e=[this.CHANNEL_MODE_70_34,this.CHANNEL_MODE_71_34],t=[this.CHANNEL_MODE_70_52,this.CHANNEL_MODE_71_52],r=[this.CHANNEL_MODE_70_322,this.CHANNEL_MODE_71_322],_=e+t+r}F_channel_mode_to_ch_mode(t){{if(t==this.CHANNEL_MODE_MONO)return 0;if(t==this.CHANNEL_MODE_STEREO)return 1;if(t==this.CHANNEL_MODE_30)return 2;if(t==this.CHANNEL_MODE_50)return 3;if(t==this.CHANNEL_MODE_51)return 4;if(t==this.CHANNEL_MODE_70_34)return 5;if(t==this.CHANNEL_MODE_71_34)return 6;if(t==this.CHANNEL_MODE_70_52)return 7;if(t==this.CHANNEL_MODE_71_52)return 8;if(t==this.CHANNEL_MODE_70_322)return 9;if(t==this.CHANNEL_MODE_71_322)return 10;if(t==this.CHANNEL_MODE_704)return 11;if(t==this.CHANNEL_MODE_714)return 12;if(t==this.CHANNEL_MODE_904)return 13;if(t==this.CHANNEL_MODE_914)return 14;if(t==this.CHANNEL_MODE_222)return 15;throw"Cannot convert extended channel mode to ch_mode!"}}F_variable_bits(t){var s,e,_;{for(s=0,_=1;_;)e=this.BAM_source.get("",t),this.BAM_g_position+=t,s+=e,_=this.BAM_source.get("",1),this.BAM_g_position+=1,_&&(s<<=t,s+=1<<t);return s}}F_raw_ac4_frame_toc_only(){var t,s,e;s=this.BAM_g_position,this.F_ac4_toc(),e=this.BAM_g_position,this.BAM_sink.after_position("ac4_toc_end",e),t=this.BAM_g_table13.slice(0)[this.frame_rate_index]}F_ac4_presentation_info(){{if(this.b_single_substream=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream!=1&&(this.presentation_config=this.BAM_source.get("",3),this.BAM_g_position+=3,this.presentation_config==7)){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");this.presentation_config+=this.v}if(this.presentation_version=this.F_presentation_version(),this.presentation_version==null)throw m("F_presentation_version","expected to return a value, returned None");if(this.b_single_substream!=1&&this.presentation_config==6)this.b_add_emdf_substreams=1;else{if(this.presentation_level=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_sink.write_uint("presentation_level",3,this.presentation_level,this.BAM_g_position),this.b_presentation_id=this.BAM_source.get("",1),this.BAM_g_position+=1,this.BAM_sink.write_uint("b_presentation_id",1,this.b_presentation_id,this.BAM_g_position),this.b_presentation_id){if(this.BAM_sink.before_call("variable_bits",[2],"presentation_id",this.BAM_g_position),this.presentation_id=this.F_variable_bits(2),this.presentation_id==null)throw m("F_variable_bits","expected to return a value, returned None");this.BAM_sink.after_call("variable_bits",this.presentation_id,"presentation_id",this.BAM_g_position)}this.F_frame_rate_multiply_info(),this.F_emdf_info(),this.b_single_substream==1?this.F_ac4_substream_info(0,0,0):(this.b_hsf_ext=this.BAM_source.get("",1),this.BAM_g_position+=1,this.presentation_config==0?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,1,1)):this.presentation_config==1?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,0,1)):this.presentation_config==2?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(1,0,1)):this.presentation_config==3?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,1,1),this.F_ac4_substream_info(1,0,2)):this.presentation_config==4?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1),this.F_ac4_substream_info(0,0,1),this.F_ac4_substream_info(1,0,2)):this.presentation_config==5?(this.F_ac4_substream_info(0,0,0),this.b_hsf_ext&&this.F_ac4_hsf_ext_substream_info(1)):this.F_presentation_config_ext_info()),this.b_pre_virtualized=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_add_emdf_substreams=this.BAM_source.get("",1),this.BAM_g_position+=1}if(this.b_add_emdf_substreams){if(this.n_add_emdf_substreams=this.BAM_source.get("",2),this.BAM_g_position+=2,this.n_add_emdf_substreams==0){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");this.n_add_emdf_substreams=this.v+4}for(this.pi_i=0;this.pi_i<this.n_add_emdf_substreams;this.pi_i++)this.F_emdf_info()}}}F_substream_index_table(){var t=null,t,s,e,_=null,_,r=null,r,u,a;{if(e=this.BAM_source.get("",2),this.BAM_g_position+=2,e==0){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");e=this.v+4}if(e-1<this.last_referenced_substream)throw"Number of substreams (n_substreams) indicated by substream_index_table is less than last referenced substream in TOC (last_referenced_substream).";if(e-1>this.last_referenced_substream&&(_==null?_=new Array(e-1+1).fill(0):_.length<=e-1&&_.push.apply(_,new Array(e-1-_.length+1).fill(0)),_[e-1]=0,t==null?t=new Array(e-1+1).fill(null):t.length<=e-1&&t.push.apply(t,new Array(e-1-t.length+1).fill(null)),t[e-1]="unknown"),e==1?(s=this.BAM_source.get("",1),this.BAM_g_position+=1):s=1,s){for(a=0;a<e;a++)if(u=this.BAM_source.get("",1),this.BAM_g_position+=1,r==null?r=new Array(a+1).fill(0):r.length<=a&&r.push.apply(r,new Array(a-r.length+1).fill(0)),r[a]=this.BAM_source.get("",10),this.BAM_g_position+=10,u){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");r==null?r=new Array(a+1).fill(0):r.length<=a&&r.push.apply(r,new Array(a-r.length+1).fill(0)),r[a]+=this.v<<10}}}}F_ac4_presentation_v2_info(t){{if(this.presentation_to_groups==null?this.presentation_to_groups=new Array(this.toc_i+1).fill(null):this.presentation_to_groups.length<=this.toc_i&&this.presentation_to_groups.push.apply(this.presentation_to_groups,new Array(this.toc_i-this.presentation_to_groups.length+1).fill(null)),this.presentation_to_groups[this.toc_i]=[],this.b_single_substream_group=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_single_substream_group!=1&&(this.presentation_config=this.BAM_source.get("",3),this.BAM_g_position+=3,this.presentation_config==7)){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");this.presentation_config+=this.v}if(this.bitstream_version!=1&&(this.presentation_version=this.F_presentation_version(),this.presentation_version==null))throw m("F_presentation_version","expected to return a value, returned None");if(this.b_single_substream_group!=1&&this.presentation_config==6)this.b_add_emdf_substreams=1;else{if(this.bitstream_version!=1&&(this.presentation_level=this.BAM_source.get("",3),this.BAM_g_position+=3,this.BAM_sink.write_uint("presentation_level",3,this.presentation_level,this.BAM_g_position)),this.b_presentation_id=this.BAM_source.get("",1),this.BAM_g_position+=1,this.BAM_sink.write_uint("b_presentation_id",1,this.b_presentation_id,this.BAM_g_position),this.b_presentation_id){if(this.BAM_sink.before_call("variable_bits",[2],"presentation_id",this.BAM_g_position),this.presentation_id=this.F_variable_bits(2),this.presentation_id==null)throw m("F_variable_bits","expected to return a value, returned None");this.BAM_sink.after_call("variable_bits",this.presentation_id,"presentation_id",this.BAM_g_position)}if(this.F_frame_rate_multiply_info(),this.F_frame_rate_fractions_info(),this.F_emdf_info(),this.b_presentation_filter=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_presentation_filter&&(this.b_enable_presentation=this.BAM_source.get("",1),this.BAM_g_position+=1),this.b_single_substream_group==1)this.F_ac4_sgi_specifier(0,0,0),this.n_substream_groups=1;else if(this.b_multi_pid=this.BAM_source.get("",1),this.BAM_g_position+=1,this.presentation_config==0)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,1,1),this.n_substream_groups=2;else if(this.presentation_config==1)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,0,1),this.n_substream_groups=1;else if(this.presentation_config==2)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(1,0,1),this.n_substream_groups=2;else if(this.presentation_config==3)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,1,1),this.F_ac4_sgi_specifier(1,0,2),this.n_substream_groups=3;else if(this.presentation_config==4)this.F_ac4_sgi_specifier(0,0,0),this.F_ac4_sgi_specifier(0,0,1),this.F_ac4_sgi_specifier(1,0,2),this.n_substream_groups=2;else if(this.presentation_config==5){if(this.n_substream_groups_minus2=this.BAM_source.get("",2),this.BAM_g_position+=2,this.n_substream_groups=this.n_substream_groups_minus2+2,this.n_substream_groups==5){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");this.n_substream_groups+=this.v}for(this.sg=0;this.sg<this.n_substream_groups;this.sg++)this.F_ac4_sgi_specifier(0,0,0)}else this.n_substream_groups=0,this.F_presentation_config_ext_info();this.b_pre_virtualized=this.BAM_source.get("",1),this.BAM_g_position+=1,this.b_add_emdf_substreams=this.BAM_source.get("",1),this.BAM_g_position+=1,this.F_ac4_presentation_substream_info(this.presentation_version)}if(this.b_add_emdf_substreams){if(this.n_add_emdf_substreams=this.BAM_source.get("",2),this.BAM_g_position+=2,this.n_add_emdf_substreams==0){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");this.n_add_emdf_substreams=this.v+4}for(this.pi_i=0;this.pi_i<this.n_add_emdf_substreams;this.pi_i++)this.F_emdf_info()}}}F_frame_size(){var t;t=this.BAM_source.get("",16),this.BAM_g_position+=16,t==65535&&(t=this.BAM_source.get("",24),this.BAM_g_position+=24)}F_ac4_toc(){var t,s,e,_,r,u,a,b,p,l,f,h,d,g,A;{if(this.bitstream_version=this.BAM_source.get("",2),this.BAM_g_position+=2,this.bitstream_version==3){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");this.bitstream_version+=this.v}if(b=this.BAM_source.get("",10),this.BAM_g_position+=10,e=this.BAM_source.get("",1),this.BAM_g_position+=1,e&&(p=this.BAM_source.get("",3),this.BAM_g_position+=3,p>0&&(this.reserved=this.BAM_source.get("",2),this.BAM_g_position+=2)),this.fs_index=this.BAM_source.get("",1),this.BAM_g_position+=1,this.frame_rate_index=this.BAM_source.get("",4),this.BAM_g_position+=4,this.frame_rate_index>13)throw"frame_rate_index must be in range 0..13";if(this.fs_index==0&&this.frame_rate_index!=13)throw"44.1kHz sampling rate && frame rates other than 13 are illegal. See table 84 in the ETSI spec.";if(l=this.BAM_source.get("",1),this.BAM_g_position+=1,A=this.BAM_source.get("",1),this.BAM_g_position+=1,A)d=1;else if(f=this.BAM_source.get("",1),this.BAM_g_position+=1,f){if(this.v=this.F_variable_bits(2),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");d=this.v+2}else d=0;if(t=0,r=this.BAM_source.get("",1),this.BAM_g_position+=1,r&&(a=this.BAM_source.get("",5),this.BAM_g_position+=5,this.BAM_sink.write_uint("payload_base_minus1",5,a,this.BAM_g_position),t=a+1,t==32)){if(this.v=this.F_variable_bits(3),this.v==null)throw m("F_variable_bits","expected to return a value, returned None");t+=this.v,this.BAM_sink.after_add("payload_base",t)}if(this.a_substream_indices=[],this.last_referenced_substream=-1,this.referenced_substreams=[],this.bk_substream_index=100,this.bitstream_version<=1)for(this.toc_j=0,this.toc_i=0;this.toc_i<d;this.toc_i++)this.F_ac4_presentation_info();else{for(g=this.BAM_source.get("",1),this.BAM_g_position+=1,g&&(u=this.BAM_source.get("",16),this.BAM_g_position+=16,_=this.BAM_source.get("",1),this.BAM_g_position+=1,_&&(s=this.BAM_source.get("",16*8),this.BAM_g_position+=16*8)),h=0,this.toc_i=0;this.toc_i<d;this.toc_i++)for(this.F_ac4_presentation_v2_info(this.toc_i),this.i=0;this.i<this.presentation_to_groups[this.toc_i].length;this.i++)h=Math.max(h,1+this.presentation_to_groups[this.toc_i][this.i]);for(this.toc_j=0;this.toc_j<h;this.toc_j++)this.F_ac4_substream_group_info(this.toc_j)}this.F_substream_index_table(),this.BAM_l_align=(8-(this.BAM_g_position%8+8)%8%8+8)%8,this.BAM_l_align_val=this.BAM_source.get_align(this.BAM_l_align),this.BAM_sink.write_align((8-(this.BAM_g_position%8+8)%8%8+8)%8,this.BAM_l_align_val),this.BAM_g_position+=this.BAM_l_align}}F_get_num_channels(t){{if(t==this.CHANNEL_MODE_MONO)this.n=1;else if(t==this.CHANNEL_MODE_STEREO)this.n=2;else if(t==this.CHANNEL_MODE_30)this.n=3;else if(t==this.CHANNEL_MODE_50)this.n=5;else if(t==this.CHANNEL_MODE_51)this.n=6;else if(t==this.CHANNEL_MODE_70_34)this.n=7;else if(t==this.CHANNEL_MODE_71_34)this.n=8;else if(t==this.CHANNEL_MODE_70_52)this.n=7;else if(t==this.CHANNEL_MODE_71_52)this.n=8;else if(t==this.CHANNEL_MODE_70_322)this.n=7;else if(t==this.CHANNEL_MODE_71_322)this.n=8;else if(t==this.CHANNEL_MODE_704)this.n=11;else if(t==this.CHANNEL_MODE_714)this.n=12;else if(t==this.CHANNEL_MODE_904)this.n=13;else if(t==this.CHANNEL_MODE_914)this.n=14;else throw"Unknown channel mode!";return this.n}}F_frame_rate_multiply_info(){var t,s;this.BAM_g_table14.slice(0).indexOf(this.frame_rate_index)>=0?(t=this.BAM_source.get("",1),this.BAM_g_position+=1,t?(s=this.BAM_source.get("",1),this.BAM_g_position+=1,this.frame_rate_factor=this.BAM_g_table15[s]):this.frame_rate_factor=1):this.BAM_g_table16.slice(0).indexOf(this.frame_rate_index)>=0?(t=this.BAM_source.get("",1),this.BAM_g_position+=1,this.frame_rate_factor=this.BAM_g_table17[t]):this.frame_rate_factor=1}F_frame_rate_fractions_info(){var t,s,e;s=1,this.BAM_g_table18.slice(0).indexOf(this.frame_rate_index)>=0&&this.frame_rate_factor==1&&(t=this.BAM_source.get("",1),this.BAM_g_position+=1,t==1&&(s=2)),this.BAM_g_table19.slice(0).indexOf(this.frame_rate_index)>=0&&(t=this.BAM_source.get("",1),this.BAM_g_position+=1,t==1&&(e=this.BAM_source.get("",1),this.BAM_g_position+=1,e==1?s=4:s=2))}};var Lt=(i,t)=>{let s=[],e=0,_={next(){return e<i.byteLength?{value:i.getUint8(e),done:++e>=i.byteLength}:{value:void 0,done:!0}}},r=(p,l,f,h,d)=>{let g=h-f;s.push({handler:d,name:p,pos:g,value:l,width:f})},u=new Z(_),a=new q(t,r),b=new Q(u,a);try{b.F_raw_ac4_frame_toc_only()}catch(p){s=null}return s};var Kt=3,$t=7,lt=3,Wt=2,Zt=2,qt=39,I=31,ft=5,P=3,Ct=32,tt=1,Qt=[ht,nt,at,J,S,K,$],Tt=i=>{var b,p,l,f;let t=i.fetch(G),s=i.fetch(V),e=[],_=s&&s.boxes.find(h=>h.type===gt),r=_&&_.boxes.filter(h=>h.type===At),u=t&&t.boxes.filter(h=>h.type===dt),a=(b=u==null?void 0:u.map(h=>h.boxes.find(g=>g.type===bt).track_ID))!=null?b:[];if(Array.isArray(r)){for(let h of r)if(h.entities.every(d=>a.includes(d.entity_id))){let d=parseInt(h.preselection_tag,10),g=isNaN(d)?null:d,A=(p=h.selection_priority)!=null?p:null,c=h.boxes.find(F=>F.type===mt),M=c==null?void 0:c.boxes.find(F=>F.type===Mt),B=Number.isInteger(M==null?void 0:M.dialog_gain)?M.dialog_gain/Zt:null,E=h.boxes.find(F=>F.type===vt),T=(l=E==null?void 0:E.extended_language)!=null?l:null,w=h.boxes.find(F=>F.type===Bt),U=(f=w==null?void 0:w.audio_rendering_indication)!=null?f:null,st=h.boxes.filter(F=>F.type===Ft).map(F=>({isGroupLabel:F.is_group_label,label:F.label,labelId:F.label_id,language:F.language})),j=h.boxes.filter(F=>F.type===Et).map(F=>({schemeURI:F.schemeURI,value:F.value}));e.push({audioRenderingIndication:U,dialogGain:B,extendedLanguage:T,id:g,kinds:j,labels:st,selectionPriority:A})}}return e},St=(i,t)=>{var e;let s=Dt(i);for(let _ of s){let r=new DataView(i._raw.buffer,_.offset,_.size),u=Lt(r,Qt);if(u===null)return null;let a=u.find(c=>c.name===J);if(!a)return null;let b=(e=u.find(c=>c.name===$))==null?void 0:e.value;b||(b=a.value+1);let p=0,l=u.find(c=>c.name===S);l&&(p=l.width);let f=u.find(c=>c.name===K),h=[],d=[];if(u.forEach(c=>{switch(c.name){case ht:{h.push({pos:c.pos,value:c.value,width:c.width});break}case at:{let M=h[h.length-1];if(h.length,c.handler==="before_call"&&(M.presentationIdPos=c.pos),c.handler==="after_call"){M.presentationId=c.value;let B=c.pos-M.presentationIdPos;M.presentationIdWidth=B,p+=B}break}case nt:{d.push(c);break}case J:case $:case S:case K:break;default:}}),h.length<Wt||h.some(c=>c.presentationId===void 0)||h.every(c=>c.presentationId!==t))return null;let g=p>>>lt,A=b+g;if(A>qt)return null;if(A>I&&b<=I){let M=p-(P+tt)>>>lt;if(b+M<=I)return null}if(h.forEach(c=>{let M=c.presentationId;c.width,t!==M&&L(r,c.pos,c.width,$t)}),d.forEach(c=>{L(r,c.pos,c.width,0)}),h.slice().reverse().forEach(c=>{let M=f.pos-c.presentationIdPos;wt(r,c.presentationIdPos,M,c.presentationIdWidth)}),A<=I)L(r,a.pos,a.width,a.value+g);else if(b>I)L(r,a.pos+ft,P,A-Ct);else{let M=p-(P+tt)>>>lt,B=b+M,E=f.pos-a.pos;Ot(r,a.pos,E,P+tt),L(r,a.pos,a.width,I),L(r,a.pos+ft,P,B-Ct),L(r,a.pos+ft+P,tt,0)}}return t};var ct=Xt(It(),1);var Pt={INIT:"init",MEDIA:"media"};ct.default.addBoxProcessor("diap",function(){this._procFullBox(),this._procField("dialog_gain","int",8)});var N,k,H,it,kt=class{constructor(){Y(this,H);Y(this,N,{});Y(this,k)}getStreams(){return y(this,N)}clearStream(t=null){delete y(this,N)[t]}setPresentationsChangedEventHandler(t){pt(this,k,t)}getPresentations(t=null){return z(this,H,it).call(this,t),y(this,N)[t].presentations}getActivePresentationId(t=null){var e;return(e=y(this,N)[t])==null?void 0:e.activePresentationId}setActivePresentationId(t,s=null){z(this,H,it).call(this,s),y(this,N)[s].activePresentationId=t}processIsoBmffSegment(t,s=null,e=void 0){let _=null,r=null,u=null,a=ct.default.parseBuffer(t),b=a.fetch(G),p=a.fetch(V),l=a.fetch(X);z(this,H,it).call(this,s);let f=y(this,N)[s];return b&&p&&(r=Tt(a),f.presentations=r,y(this,k)&&y(this,k).call(this,{streamId:s}),u=Pt.INIT),l&&(_=St(a,e!=null?e:f.activePresentationId),u=Pt.MEDIA),{forcedPresentationId:_,presentations:r,segmentType:u}}};N=new WeakMap,k=new WeakMap,H=new WeakSet,it=function(t){y(this,N)[t]===void 0&&(y(this,N)[t]={activePresentationId:-1,presentations:[]})};export{kt as Alps};
2
2
  /*! Bundled license information:
3
3
 
4
4
  codem-isoboxer/dist/iso_boxer.js:
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dolbylaboratories/alps",
3
3
  "main": "dist/alps.bundle.min.js",
4
4
  "types": "dist/alps.d.ts",
5
- "version": "2.0.0",
5
+ "version": "3.0.0-alpha.2",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -26,7 +26,7 @@
26
26
  "url": "https://github.com/DolbyLaboratories/alps-web.git"
27
27
  },
28
28
  "scripts": {
29
- "build": "esbuild src/alps.js --bundle --format=esm --drop:console --drop:debugger --sourcemap --target=chrome58,firefox57,safari11,edge16 --outfile=dist/alps.bundle.js",
29
+ "build": "esbuild src/alps.js --bundle --format=esm --drop:debugger --sourcemap --target=chrome58,firefox57,safari11,edge16 --outfile=dist/alps.bundle.js",
30
30
  "build:production": "esbuild src/alps.js --bundle --format=esm --minify --drop:console --drop:debugger --target=chrome58,firefox57,safari11,edge16 --outfile=dist/alps.bundle.min.js && npm run types",
31
31
  "types": "tsc src/alps.js -d --emitDeclarationOnly --allowJs --skipLibCheck --outDir .temp && mv .temp/alps.d.ts .temp/types.d.ts dist && rm -r .temp",
32
32
  "test": "jest",