You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
10 KiB
1 line
10 KiB
1 month ago
|
(()=>{"use strict";var e,t={8103:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BufferReader=t.CompositeBufferReader=t.CompositeBuffer=t.Uint8ArrayBuffer=void 0;class n{constructor(e){this.buffer=e}get length(){return this.buffer.length}at(e){return this.buffer[e]}subarray(e,t){return new n(this.buffer.subarray(e,t))}}t.Uint8ArrayBuffer=n;class i{constructor(e){this.buffers=[],this.buffers=e}get length(){let e=0;for(const t of this.buffers)e+=t.length;return e}at(e){let t=0;for(const n of this.buffers){const i=e-t;if(i<n.length)return n.at(i);t+=n.length}throw new Error("Out of bounds")}subarray(e,t){const n=[];let r=0;for(const i of this.buffers){const o=Math.max(0,e-r),s=Math.min(i.length,t-r);s>0&&o<s&&n.push(i.subarray(o,s)),r+=i.length}return new i(n)}}t.CompositeBuffer=i,t.CompositeBufferReader=class{constructor(){this.buffers=[]}add(e){this.buffers.push(e)}get length(){let e=0;for(const t of this.buffers)e+=t.length;return e}read(e){if(0===e)return new i([]);const t=[];let r=0;for(;;){if(0===this.buffers.length)throw new Error("Trying to read more bytes than available");const n=this.buffers.shift(),i=e-r;if(n.length===i){t.push(n);break}if(n.length>i){t.push(n.subarray(0,i)),this.buffers.unshift(n.subarray(i,n.length));break}r+=n.length,t.push(n)}return new i(t.map((e=>new n(e))))}},t.BufferReader=class{constructor(e){this._index=0,this.buffer=e}get index(){return this._index}get hasNext(){return this._index<this.buffer.length}readHex(e,t){if(void 0!==t&&this._index+e>t)return 0;let n=0,i=0;const r=this._index;for(let t=this._index+e-1;t>=r;--t)n+=this.buffer.at(t)<<8*i,++i;return this._index+=e,n}readBuffer(e){const t=this.buffer.subarray(this.index,this.index+e);return this._index+=e,t}}},3704:(e,t,n)=>{t.In=void 0;var i=n(5254);Object.defineProperty(t,"In",{enumerable:!0,get:function(){return i.parseDisplaySets}});n(7304)},5254:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DisplaySet=t.parseDisplaySets=void 0;const i=n(8103),r=n(7304);t.parseDisplaySets=function(){const e=new s,t=new i.CompositeBufferReader;let n=13;return new TransformStream({transform(i,r){for(t.add(i);t.length>=n;)n=e.consume(t.read(n)),e.ready&&r.enqueue(e.next())},flush(t){e.ready&&t.enqueue(e.next())}})};class o{constructor(e,t,n,i,r,o){this.presentationCompositionSegment=e,this.windowDefinitionSegments=t,this.paletteDefinitionSegments=n,this.objectDefinitionSegments=i,this.endDefinitionSegment=r,this.previousDisplaySet=o}get firstOds(){return this.objectDefinitionSegments.find((e=>e.lastInSequenceFlag===r.LastInSequenceFlag.firstInSequence||e.lastInSequenceFlag===r.LastInSequenceFlag.firstAndLastInSequence))}paletteDefinitionSegment(e){const t=this.paletteDefinitionSegments.find((t=>t.paletteId===e));if(void 0===t){if(this.presentationCompositionSegment.compositionState!==r.CompositionState.normal)throw new Error("PCS references invalid PDS and composition state is not 'normal'");if(void 0===this.previousDisplaySet)throw new Error("PCS references invalid PDS and no previous display set to fallback to");return this.previousDisplaySet.paletteDefinitionSegment(e)}return t}imageData(e){const t=this.paletteDefinitionSegment(this.presentationCompositionSegment.paletteId);if(void 0===t)throw new Error("PCS references invalid PDS");const n=this.firstOds;if(void 0===n||void 0===n.width||void 0===n.height)throw new Error("Missing first ODS with defined width and height");const r=null!=e?e:new Uint8ClampedArray(n.width*n.height*4),o=t.paletteEntries.map((e=>this.ycrcbToRgba(e))),s=n.width;return function(e,t){let n=0,i=0,r=0;const o=e.length;for(;n<o;){const o=e.at(n);let s,a,d;if(o>0)a=o,s=1,d=1;else{const t=e.at(n+1);if(0===t)a=0,s=0,d=2,i=0,++r;else if(t<64)a=0,s=t,d=2;else if(t<128)a=0,s=(t-64<<8)+e.at(n+2),d=3;else if(t<192)a=e.at(n+2),s=t-128,d=3;else{const i=e.at(n+2);a=e.at(n+3),s=(t-192<<8)+i,d=4}}if(s>0){for(let e=i;e<i+s;++e)t(e,r,a);i+=s}n+=d}}(new i.CompositeBuffer(this.objectDefinitionSegments.map((e=>e.objectData))),((e,t,n)=>{const i=4*(t*s+e);if(n>=o.length)r[i]=0,r[i+1]=0,r[i+2]=0,r[i+3]=0;else{const e=
|