@mediabunny/prores 1.50.0 → 1.50.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.
- package/README.md +19 -0
- package/dist/bundles/mediabunny-prores.js +54 -65
- package/dist/bundles/mediabunny-prores.min.js +5 -5
- package/dist/bundles/mediabunny-prores.min.mjs +5 -5
- package/dist/bundles/mediabunny-prores.mjs +54 -53
- package/dist/modules/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -6
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
6
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
7
7
|
*/
|
|
8
|
-
var
|
|
8
|
+
var or=Object.defineProperty;var jr=(A,e,r)=>e in A?or(A,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):A[e]=r;var j=(A,e,r)=>jr(A,typeof e!="symbol"?e+"":e,r);import{CustomVideoDecoder as hr,Logging as fr,registerDecoder as pr,VideoSample as er}from"mediabunny";var h=class extends Error{constructor(e="The decoder ran out of memory."){super(e),this.name="OutOfMemoryError"}},S=class extends Error{constructor(e="Invalid data: the packet ended before the decoder expected it to."){super(e),this.name="UnexpectedEofError"}},w=class extends Error{constructor(e="The packet contains invalid data."){super(e),this.name="InvalidDataError"}},P=class extends Error{constructor(e="The packet uses a feature that is not supported."){super(e),this.name="NotSupportedError"}},x=class extends Error{constructor(e="The decoder is in an invalid internal state. This should never happen! Please report."){super(e),this.name="InvalidStateError"}},D=class extends Error{constructor(e="The decoder has been closed."){super(e),this.name="DecoderClosedError"}},E=class extends Error{constructor(e="The frame is locked by an in-flight decoding operation."){super(e),this.name="FrameLockedError"}},X=(A,e)=>{switch(A){case-1:return new h(e);case-2:return new S(e);case-3:return new w(e);case-4:return new P(e);case-5:return new x(e);case-6:return new w(e??"Unexpected integer overflow.");default:throw new Error(`Unhandled error code: ${A}`)}};function d(A){if(!A)throw new Error("Assertion failed.")}var Y=A=>{let e=0,r="";for(;e<A.length;){let t=A[e++];if(t>127)if(t>191&&t<224){if(e>=A.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");t=(t&31)<<6|A[e++]&63}else if(t>223&&t<240){if(e+1>=A.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");t=(t&15)<<12|(A[e++]&63)<<6|A[e++]&63}else if(t>239&&t<248){if(e+2>=A.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");t=(t&7)<<18|(A[e++]&63)<<12|(A[e++]&63)<<6|A[e++]&63}else throw new Error("UTF-8 decode: unknown multibyte start 0x"+t.toString(16)+" at index "+(e-1));if(t<=65535)r+=String.fromCharCode(t);else if(t<=1114111)t-=65536,r+=String.fromCharCode(t>>10|55296),r+=String.fromCharCode(t&1023|56320);else throw new Error("UTF-8 decode: code point 0x"+t.toString(16)+" exceeds UTF-16 reach")}return r},O=class{constructor(){j(this,"currentPromise",Promise.resolve());j(this,"pending",0)}async acquire(){let e,r=new Promise(n=>{let o=!1;e=()=>{o||(n(),this.pending--,o=!0)}}),t=this.currentPromise;return this.currentPromise=r,this.pending++,await t,e}},H=typeof SharedArrayBuffer<"u",J=A=>A;Symbol.dispose??=Symbol("dispose");Symbol.asyncDispose??=Symbol("asyncDispose");var m=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12"],ir={1:"bt709",5:"bt470bg",6:"smpte170m",9:"bt2020",12:"smpte432"},sr={1:"bt709",6:"smpte170m",8:"linear",13:"iec61966-2-1",16:"pq",18:"hlg"},Br={0:"rgb",1:"bt709",5:"bt470bg",6:"smpte170m",9:"bt2020-ncl"},k=new FinalizationRegistry(({runtime:A,ptr:e})=>{A.exports.closeFrame(e)}),y=class{constructor(){j(this,"frameData",null);j(this,"codedWidth",null);j(this,"codedHeight",null);j(this,"visibleWidth",null);j(this,"visibleHeight",null);j(this,"pixelFormat",null);j(this,"originalPixelFormat",null);j(this,"pixelAspectRatio",null);j(this,"colorPrimaries",null);j(this,"colorTransfer",null);j(this,"colorMatrix",null);j(this,"colorRangeFull",null);j(this,"scanType",null);j(this,"_runtime",null);j(this,"_ptr",null);j(this,"_buffer",null);j(this,"_locked",!1)}get colorPrimariesString(){return this.colorPrimaries===null?void 0:ir[this.colorPrimaries]}get colorTransferString(){return this.colorTransfer===null?void 0:sr[this.colorTransfer]}get colorMatrixString(){return this.colorMatrix===null?void 0:Br[this.colorMatrix]}get isLocked(){return this._locked}get isFilled(){return this.frameData!==null&&this.codedWidth!==null&&this.codedHeight!==null&&this.visibleWidth!==null&&this.visibleHeight!==null&&this.pixelFormat!==null&&this.pixelAspectRatio!==null&&this.colorPrimaries!==null&&this.colorTransfer!==null&&this.colorMatrix!==null&&this.colorRangeFull!==null&&this.scanType!==null}toFilled(){return this.isFilled?this:null}clear(){if(this._locked)throw new E;this._ptr!==null&&(d(this._runtime),k.unregister(this),this._runtime.exports.closeFrame(this._ptr),this._runtime=null,this._ptr=null),this._buffer=null,this._reset()}[Symbol.dispose](){this.clear()}_ensureWasmFrame(e){if(this._runtime===e)return!0;this._runtime&&(k.unregister(this),this._runtime.exports.closeFrame(this._ptr),this._runtime=null,this._ptr=null);let r=e.exports.createFrame();return r===0?!1:(this._runtime=e,this._ptr=r,k.register(this,{runtime:e,ptr:r},this),!0)}_reset(){this.frameData=null,this.codedWidth=null,this.codedHeight=null,this.visibleWidth=null,this.visibleHeight=null,this.pixelFormat=null,this.pixelAspectRatio=null,this.colorPrimaries=null,this.colorTransfer=null,this.colorMatrix=null,this.colorRangeFull=null,this.scanType=null}_populate(e){this.frameData=e.frameData,this.codedWidth=e.codedWidth,this.codedHeight=e.codedHeight,this.visibleWidth=e.visibleWidth,this.visibleHeight=e.visibleHeight,this.pixelFormat=e.pixelFormat,this.originalPixelFormat=e.originalPixelFormat,this.pixelAspectRatio=e.pixelAspectRatio,this.colorPrimaries=e.colorPrimaries,this.colorTransfer=e.colorTransfer,this.colorMatrix=e.colorMatrix,this.colorRangeFull=e.colorRangeFull,this.scanType=e.scanType}},ar=(A,e,r,t)=>{let n=A.getFrameDataPtr(r),o=A.getFrameDataSize(r),i=new Uint8Array(e.buffer,n,o),s=m[A.getFramePixelFormat(r)];d(s!==void 0);let a=m[A.getOriginalPixelFormat(t)];d(a!==void 0);let B=["progressive","interlaced-top-field-first","interlaced-bottom-field-first"][A.getScanType(r)];return d(B!==void 0),{frameData:i,codedWidth:A.getCodedWidth(r),codedHeight:A.getCodedHeight(r),visibleWidth:A.getVisibleWidth(r),visibleHeight:A.getVisibleHeight(r),pixelFormat:s,originalPixelFormat:a,pixelAspectRatio:{num:A.getAspectRatioNum(r),den:A.getAspectRatioDen(r)},colorPrimaries:A.getColorPrimaries(r),colorTransfer:A.getColorTransfer(r),colorMatrix:A.getColorMatrix(r),colorRangeFull:!1,scanType:B}},c=(A=>(A[A.SharedMemoryInit=0]="SharedMemoryInit",A[A.MessagePassingInit=1]="MessagePassingInit",A[A.CreateDecoder=2]="CreateDecoder",A[A.CloseDecoder=3]="CloseDecoder",A[A.Decode=4]="Decode",A[A.Ready=5]="Ready",A[A.InitOutOfMemoryError=6]="InitOutOfMemoryError",A[A.Decoded=7]="Decoded",A[A.DecodeError=8]="DecodeError",A))(c||{}),q=`\0asm\0\0\0\x99\`\x7F\x7F\x7F\x7F\x7F\`\x7F\x7F\x7F\x7F\x7F\0\`\x7F\0\`\0\0\`\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`
|
|
9
9
|
\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\`\x7F\x7F\`\x7F\x7F\x7F\x7F{{{{{{{{{{{{{{{{\x7F\x7F\x7F\x7F\0\`\x7F\x7F\x7F\x7F{{{{{{{{{{{{{{{{\x7F\x7F\x7F\0\` \x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\x7F\0\`\x7F\x7F\0\`\x7F\x7F\x7F\x7F\`\x7F\x7F\x7F\x7F\0\`\x7F\x7F\x7F\`\x7F\x7F\x7F\0\`\0\x7Fenvmemory\x80\x80ML\x07\x07\b\b\b\b\b\b\b\b\b\b
|
|
10
10
|
\0\v\f\v\r\0\r\v\r\v\r\r\f\f\r\vp \x7FA\x80\x80\xC0\0\v\x7FA\0\v\x7F\0A\x90\b\v\x7F\0A\v\x07\xE1!__stack_pointer\0
|
|
11
11
|
__tls_base
|
|
@@ -883,8 +883,8 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
|
|
|
883
883
|
\v\x1B\f\r\x07 !(0)"#*1892+$%,3:;4-&'.5<=6/7>?\0\b
|
|
884
884
|
\v\x1B (!")081*#+29:3;\f\r\x07$,%&-4<5.'/6=>7?\0\0\0\0\0\0\0\0\0\0\0\0Packet is smaller than the picture data size indicated in the picture header.\0Packet is smaller than the frame size indicated in the frame header.\0Invalid DC code stream.\0Invalid AC code stream.\0Picture header size too small.\0Frame header size too small.\0Slice header size too small.\0Invalid packet header frame type.\0Invalid frame type.\0Invalid alpha info header field.\0Invalid aspect ratio information header field.\0Version > 1 is not supported.\0Slice widths larger than 128 are not supported.\0Only slice heights of 1 are supported.\0Slice data extends past the bounds of the picture data.\0Channel data planes too large to fit into slice data.\0((MMpp\0\0\0\0))))((((((L
|
|
885
885
|
((((L\0\0\0\0\0\0\0\0\0\x90\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\b\0\0\0
|
|
886
|
-
\0\0\0\f\0\0\0Frame dimensions (x) exceed the maximum supported size of 16384x16384.\0\0\0\0\0\0\0\0\x07\0\0\0\b\0\0\0Unexpected slice count: expected , found .\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`,
|
|
887
|
-
`,b=null,R=()=>{if(b)return b;b=new Uint8Array(q.length);for(let A=0;A<q.length;A++)b[A]=q.charCodeAt(A);return b},
|
|
886
|
+
\0\0\0\f\0\0\0Frame dimensions (x) exceed the maximum supported size of 16384x16384.\0\0\0\0\0\0\0\0\x07\0\0\0\b\0\0\0Unexpected slice count: expected , found .\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`,lr=async(A,e)=>{let{instance:r}=await WebAssembly.instantiate(A,{env:{memory:e,externPrint:(t,n)=>{let o=new Uint8Array(e.buffer,t,n);console.log(Y(o))}}});return r.exports},G=`"use strict";var h=(e=>(e[e.OutOfMemory=-1]="OutOfMemory",e[e.UnexpectedEof=-2]="UnexpectedEof",e[e.InvalidData=-3]="InvalidData",e[e.NotSupported=-4]="NotSupported",e[e.InvalidState=-5]="InvalidState",e[e.Overflow=-6]="Overflow",e))(h||{});function f(e){if(!e)throw new Error("Assertion failed.")}const O=e=>{let t=0,r="";for(;t<e.length;){let o=e[t++];if(o>127)if(o>191&&o<224){if(t>=e.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");o=(o&31)<<6|e[t++]&63}else if(o>223&&o<240){if(t+1>=e.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");o=(o&15)<<12|(e[t++]&63)<<6|e[t++]&63}else if(o>239&&o<248){if(t+2>=e.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");o=(o&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63}else throw new Error("UTF-8 decode: unknown multibyte start 0x"+o.toString(16)+" at index "+(t-1));if(o<=65535)r+=String.fromCharCode(o);else if(o<=1114111)o-=65536,r+=String.fromCharCode(o>>10|55296),r+=String.fromCharCode(o&1023|56320);else throw new Error("UTF-8 decode: code point 0x"+o.toString(16)+" exceeds UTF-16 reach")}return r};Symbol.dispose??=Symbol("dispose");Symbol.asyncDispose??=Symbol("asyncDispose");const S=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12"];new FinalizationRegistry(({runtime:e,ptr:t})=>{e.exports.closeFrame(t)});const _=(e,t,r,o)=>{const i=e.getFrameDataPtr(r),a=e.getFrameDataSize(r),I=new Uint8Array(t.buffer,i,a),u=S[e.getFramePixelFormat(r)];f(u!==void 0);const l=S[e.getOriginalPixelFormat(o)];f(l!==void 0);const c=["progressive","interlaced-top-field-first","interlaced-bottom-field-first"][e.getScanType(r)];return f(c!==void 0),{frameData:I,codedWidth:e.getCodedWidth(r),codedHeight:e.getCodedHeight(r),visibleWidth:e.getVisibleWidth(r),visibleHeight:e.getVisibleHeight(r),pixelFormat:u,originalPixelFormat:l,pixelAspectRatio:{num:e.getAspectRatioNum(r),den:e.getAspectRatioDen(r)},colorPrimaries:e.getColorPrimaries(r),colorTransfer:e.getColorTransfer(r),colorMatrix:e.getColorMatrix(r),colorRangeFull:!1,scanType:c}};var n=(e=>(e[e.SharedMemoryInit=0]="SharedMemoryInit",e[e.MessagePassingInit=1]="MessagePassingInit",e[e.CreateDecoder=2]="CreateDecoder",e[e.CloseDecoder=3]="CloseDecoder",e[e.Decode=4]="Decode",e[e.Ready=5]="Ready",e[e.InitOutOfMemoryError=6]="InitOutOfMemoryError",e[e.Decoded=7]="Decoded",e[e.DecodeError=8]="DecodeError",e))(n||{});const A=async(e,t)=>{const{instance:r}=await WebAssembly.instantiate(e,{env:{memory:t,externPrint:(o,i)=>{const a=new Uint8Array(t.buffer,o,i);console.log(O(a))}}});return r.exports};let d=null;const F=async e=>{switch(e.type){case n.SharedMemoryInit:{const t=await A(e.wasmBinary,e.memory);throw t.__stack_pointer.value=e.stackPointer,t.__wasm_init_tls(e.tlsPointer),t.setIsBrowserMainThread(0),t.startWorker(),new Error("Unexpected worker termination.")}case n.MessagePassingInit:{const t=new WebAssembly.Memory({initial:32,maximum:8192,shared:!0}),r=await A(e.wasmBinary,t),o=r.allocateThreadLocalState(r.__tls_size.value,r.__tls_align.value);if(o===0){s({type:n.InitOutOfMemoryError,message:"Failed to allocate thread-local state."});return}r.__wasm_init_tls(o),r.setIsBrowserMainThread(0);const i=r.createFrame();if(i===0){s({type:n.InitOutOfMemoryError,message:"Failed to create frame."});return}d={exports:r,memory:t,decoders:new Map,frame:i},s({type:n.Ready});return}case n.CreateDecoder:{f(d);const{exports:t}=d,{decoderId:r,bitDepth:o,allowedOutputFormats:i}=e,a=t.createDecoder(0,o,i);if(a===0)return;d.decoders.set(r,a);return}case n.CloseDecoder:{f(d);const{exports:t,decoders:r}=d,o=r.get(e.decoderId);o!==void 0&&(t.closeDecoder(o),r.delete(e.decoderId));return}case n.Decode:{f(d);const{exports:t,memory:r,decoders:o,frame:i}=d,{id:a,decoderId:I,packet:u,frameBuffer:l}=e,c=o.get(I);if(c===void 0){s({type:n.DecodeError,id:a,code:h.OutOfMemory});return}const g=t.allocatePacket(c,u.byteLength);if(g===0){s({type:n.DecodeError,id:a,code:h.OutOfMemory});return}new Uint8Array(r.buffer).set(u,g);const D=t.decodePacket(c,i);if(D<0){let v;const P=t.getErrorMessagePtr(c);if(P!==0){const b=t.getErrorMessageSize(c);v=O(new Uint8Array(r.buffer,P,b))}s({type:n.DecodeError,id:a,code:D,message:v});return}const m=_(t,r,i,c),y=l&&l.byteLength===m.frameData.byteLength?l:new ArrayBuffer(m.frameData.byteLength),p=new Uint8Array(y);p.set(m.frameData),m.frameData=p,s({type:n.Decoded,id:a,contents:m},[y]);return}}},s=(e,t)=>{w?w.postMessage(e,t??[]):self.postMessage(e,{transfer:t??[]})};let w=null;typeof self>"u"&&(w=require("node:worker_threads").parentPort);w?w.on("message",F):self.addEventListener("message",e=>void F(e.data));
|
|
887
|
+
`,b=null,R=()=>{if(b)return b;b=new Uint8Array(q.length);for(let A=0;A<q.length;A++)b[A]=q.charCodeAt(A);return b},z=async()=>{if(typeof Worker<"u"&&!("Bun"in globalThis)){let e=new Blob([G],{type:"text/javascript"}),r=URL.createObjectURL(e),t=new Worker(r,{type:"module"});return new C(t,null)}let A=await import("node:"+J("worker_threads"));return new C(null,new A.Worker(G,{eval:!0}))},C=class{constructor(e,r){j(this,"wrappedListeners",new Map);this.webWorker=e,this.nodeWorker=r}postMessage(e,r){this.webWorker?this.webWorker.postMessage(e,{transfer:r??[]}):this.nodeWorker.postMessage(e,r??[])}addEventListener(e,r,t){if(this.webWorker)this.webWorker.addEventListener(e,r,t);else{let n=o=>r({data:o});this.wrappedListeners.set(r,n),t?.once?this.nodeWorker.once(e,n):this.nodeWorker.on(e,n)}}removeEventListener(e,r){this.webWorker?this.webWorker.removeEventListener(e,r):(this.nodeWorker.off(e,this.wrappedListeners.get(r)),this.wrappedListeners.delete(r))}terminate(){this.webWorker?this.webWorker.terminate():this.nodeWorker.terminate()}},K=new FinalizationRegistry(A=>{for(let e of A)e.terminate()}),cr=async()=>{if(typeof navigator<"u"&&navigator.hardwareConcurrency)return navigator.hardwareConcurrency;let A=await import("node:"+J("os"));return A.availableParallelism?.()??A.cpus().length},T=null,dr=new O,ur=async()=>{let A=await dr.acquire();try{if(T){let r=T.deref();if(r)return r}let e=await $.init();return T=new WeakRef(e),e}finally{A()}},_=null,mr=()=>{let A=_?.deref();return A||(A=new U,_=new WeakRef(A)),A},F=class{constructor(){j(this,"workers",[]);j(this,"refCount",0);K.register(this,this.workers,this)}ref(){this.refCount++}unref(){this.refCount--,!(typeof window<"u"&&typeof document<"u")&&this.refCount===0&&this.destroy()}destroy(){for(let e of this.workers)e.terminate();this.workers.length=0,K.unregister(this)}},$=class A extends F{constructor(e,r){super(),this.memory=e,this.exports=r}static async init(){let e=new WebAssembly.Memory({initial:32,maximum:65536,shared:!0}),r=await lr(R(),e),t=r.allocateThreadLocalState(r.__tls_size.value,r.__tls_align.value);if(t===0)throw new Error("Failed to allocate thread-local state.");r.__wasm_init_tls(t);let n=typeof window<"u"&&typeof document<"u"&&self===window;return r.setIsBrowserMainThread(Number(n)),new A(e,r)}async ensureWorkers(e){for(;this.workers.length<e;){let r=this.exports.allocateWorkerStack(),t=this.exports.allocateThreadLocalState(this.exports.__tls_size.value,this.exports.__tls_align.value);if(r===0||t===0)throw new Error("Failed to allocate worker stack or thread-local state.");let n=await z();n.postMessage({type:c.SharedMemoryInit,wasmBinary:R(),memory:this.memory,stackPointer:r,tlsPointer:t}),this.workers.push(n)}}destroy(){super.destroy(),T=null}},U=class extends F{constructor(){super(...arguments);j(this,"workerLoad",[]);j(this,"nextRequestId",0);j(this,"nextDecoderId",0);j(this,"registeredDecoders",new Map)}registerDecoder(r,t,n){this.registeredDecoders.set(r,{bitDepth:t,allowedOutputFormats:n});for(let o of this.workers)o.postMessage({type:c.CreateDecoder,decoderId:r,bitDepth:t,allowedOutputFormats:n})}unregisterDecoder(r){this.registeredDecoders.delete(r);for(let t of this.workers)t.postMessage({type:c.CloseDecoder,decoderId:r})}async ensureWorkers(r){let t=r-this.workers.length;if(t<=0)return;let n=await Promise.all(Array.from({length:t},async()=>{let i=await z(),s=await new Promise(a=>{i.postMessage({type:c.MessagePassingInit,wasmBinary:R()}),i.addEventListener("message",B=>a(B.data),{once:!0})});return s.type===c.InitOutOfMemoryError?(i.terminate(),new h(s.message)):i})),o=n.find(i=>i instanceof Error);if(o){for(let i of n)i instanceof Error||i.terminate();return o}for(let i of n){this.workers.push(i),this.workerLoad.push(0);for(let[s,{bitDepth:a,allowedOutputFormats:B}]of this.registeredDecoders)i.postMessage({type:c.CreateDecoder,decoderId:s,bitDepth:a,allowedOutputFormats:B})}}destroy(){super.destroy(),_=null}},Q=["ap4x","ap4h","apch","apcn","apcs","apco"],f=class{constructor(e){j(this,"_closed",!1);j(this,"_queue",Promise.resolve());j(this,"_concurrentDecode");j(this,"_decodeQueueSize",0);j(this,"_dequeuedResolve");j(this,"_dequeued",new Promise(e=>{this._dequeuedResolve=e}));this._concurrentDecode=e}get decodeQueueSize(){return this._decodeQueueSize}get dequeued(){return this._dequeued}_markDequeued(){this._decodeQueueSize--,this._dequeuedResolve(),this._dequeued=new Promise(e=>{this._dequeuedResolve=e})}static async create(e){if(typeof e!="object"||!e)throw new TypeError("options must be an object.");if(!Q.includes(e.proresFourCc))throw new TypeError(`options.proresFourCc must be one of ${Q.join(", ")}.`);if(typeof e.useSharedMemory!="boolean")throw new TypeError("options.useSharedMemory must be a boolean.");if(e.concurrency!==void 0&&(!Number.isInteger(e.concurrency)||e.concurrency<0))throw new TypeError("options.concurrency, when provided, must be a non-negative integer.");if(e.allowedOutputFormats&&!(Array.isArray(e.allowedOutputFormats)&&e.allowedOutputFormats.length>0&&e.allowedOutputFormats.every(o=>m.includes(o))))throw new TypeError(`options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${m.join(", ")}.`);if(e.useSharedMemory&&!H)return new P(`Shared memory is not available in this environment, so useSharedMemory: true cannot be used.
|
|
888
888
|
Since it provides way better performance, you should enable it by serving the page cross-origin isolated by setting the Cross-Origin-Opener-Policy header to 'same-origin' and the Cross-Origin-Embedder-Policy header to 'credentialless' or 'require-corp' (only the latter is supported by Safari).
|
|
889
|
-
Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`);let r;if(e.allowedOutputFormats){r=0;for(let o of e.allowedOutputFormats)r|=1<<m.indexOf(o)}else r=4294967295;let t=e.proresFourCc==="ap4h"||e.proresFourCc==="ap4x"?12:10,n=e.concurrency??await
|
|
890
|
-
@mediabunny/prores was loaded twice. This will likely cause the decoder not to work correctly. Check if multiple dependencies are importing different versions of @mediabunny/prores, or if something is being bundled incorrectly.`);globalThis[
|
|
889
|
+
Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`);let r;if(e.allowedOutputFormats){r=0;for(let o of e.allowedOutputFormats)r|=1<<m.indexOf(o)}else r=4294967295;let t=e.proresFourCc==="ap4h"||e.proresFourCc==="ap4x"?12:10,n=e.concurrency??await cr();if(e.useSharedMemory||n===0){let o=await ur();o.ref(),await o.ensureWorkers(n);let i=o.exports.createDecoder(n,t,r);return i===0?(o.unref(),new h):new N(o,i,n)}else{let o=mr();o.ref();let i=await o.ensureWorkers(n);return i?(o.unref(),i):new M(o,n,t,r)}}static canUseSharedMemory(){return H}async decode(e,r,t={}){if(!(e instanceof Uint8Array))throw new TypeError("packetData must be a Uint8Array.");if(!(r instanceof y))throw new TypeError("frame must be a Frame.");if(typeof t!="object"||!t)throw new TypeError("options must be an object.");if(t.transfer!==void 0&&typeof t.transfer!="boolean")throw new TypeError("options.transfer, when provided, must be a boolean.");if(this._closed)return new D;if(r._locked)return new E;r._reset(),r._locked=!0,this._decodeQueueSize++;let n=this._concurrentDecode?this._runDecode(e,r,t):null,o=this._queue.then(()=>n??this._runDecode(e,r,t)).finally(()=>{r._locked=!1,this._decodeQueueSize--,this._dequeuedResolve(),this._dequeued=new Promise(i=>{this._dequeuedResolve=i})});return this._queue=o.catch(()=>{}),o}close(){if(this._closed)return this._queue;this._closed=!0;let e=this._queue.then(()=>this._runClose());return this._queue=e.catch(()=>{}),e}get isClosed(){return this._closed}[Symbol.dispose](){this.close()}[Symbol.asyncDispose](){return this.close()}},L=new FinalizationRegistry(({runtime:A,ptr:e})=>{A.exports.closeDecoder(e),A.unref()}),N=class extends f{constructor(r,t,n){super(!1);j(this,"_runtime");j(this,"_decoderPtr");j(this,"_taskStateOffset");j(this,"useSharedMemory",!0);j(this,"concurrency");this._runtime=r,this._decoderPtr=t,this._taskStateOffset=r.exports.getTaskStateAddress(t)/4,this.concurrency=n,L.register(this,{runtime:r,ptr:t},this)}_runClose(){d(this._runtime),L.unregister(this),this._runtime.exports.closeDecoder(this._decoderPtr),this._runtime.unref(),this._runtime=null}async _runDecode(r,t,n){d(this._runtime);let{exports:o,memory:i}=this._runtime;if(!t._ensureWasmFrame(this._runtime))return new h;let s=t._ptr;n.transfer&&(r=structuredClone(r,{transfer:[r.buffer]}));let a=o.allocatePacket(this._decoderPtr,r.byteLength);if(a===0)return new h;new Uint8Array(i.buffer).set(r,a);let B=o.decodePacket(this._decoderPtr,s);return B<0?this._createError(B):this.concurrency>0&&(await Atomics.waitAsync(new Int32Array(i.buffer),this._taskStateOffset,1).value,B=o.finalizePacketDecoding(this._decoderPtr),B<0)?this._createError(B):(t._populate(ar(o,i,s,this._decoderPtr)),t)}_createError(r){d(this._runtime);let{exports:t,memory:n}=this._runtime,o,i=t.getErrorMessagePtr(this._decoderPtr);if(i!==0){let s=t.getErrorMessageSize(this._decoderPtr);o=Y(new Uint8Array(n.buffer,i,s))}return X(r,o)}},Z=new FinalizationRegistry(A=>{A.unref()}),M=class extends f{constructor(r,t,n,o){super(!0);j(this,"_runtime");j(this,"_decoderId");j(this,"useSharedMemory",!1);j(this,"concurrency");this._runtime=r,this.concurrency=t,this._decoderId=r.nextDecoderId++,r.registerDecoder(this._decoderId,n,o),Z.register(this,r,this)}_runClose(){d(this._runtime),this._runtime.unregisterDecoder(this._decoderId),Z.unregister(this),this._runtime.unref(),this._runtime=null}_runDecode(r,t,n){d(this._runtime);let o=this._runtime,i=n.transfer?r:r.slice(),s=0;for(let l=1;l<o.workerLoad.length;l++)o.workerLoad[l]<o.workerLoad[s]&&(s=l);let a=o.workers[s];o.workerLoad[s]=o.workerLoad[s]+1;let B=o.nextRequestId++,p=t._buffer;return t._buffer=null,new Promise(l=>{a.postMessage({type:c.Decode,id:B,decoderId:this._decoderId,packet:i,frameBuffer:p},p?[i.buffer,p]:[i.buffer]);let v=nr=>{let u=nr.data;u.type!==c.Decoded&&u.type!==c.DecodeError||u.id===B&&(a.removeEventListener("message",v),o.workerLoad[s]--,u.type===c.DecodeError?l(X(u.code,u.message)):(t._buffer=u.contents.frameData.buffer,t._populate(u.contents),l(t)))};a.addEventListener("message",v)})}};function I(A){if(!A)throw new Error("Assertion failed.")}var Ir=1e6*(1+Number.EPSILON);var V=null,rr=()=>V!==null?V:V=!!(typeof navigator<"u"&&(navigator.vendor?.match(/apple/i)||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent)));var tr=Symbol.for("@mediabunny/prores loaded");globalThis[tr]&&fr._error(`[WARNING]
|
|
890
|
+
@mediabunny/prores was loaded twice. This will likely cause the decoder not to work correctly. Check if multiple dependencies are importing different versions of @mediabunny/prores, or if something is being bundled incorrectly.`);globalThis[tr]=!0;var g=class g extends hr{constructor(){super(...arguments);this.decoder=null;this.framePool=[]}static supports(r,t){return r==="prores"}static _determineSupportedVideoFrameFormats(){let r=[],t=new Uint8Array(32);for(let n of m)try{new VideoFrame(t,{format:n,codedWidth:2,codedHeight:2,timestamp:0,duration:0}).close(),r.push(n)}catch{}return r}async init(){typeof VideoFrame<"u"&&(g._supportedVideoFrameFormats??=g._determineSupportedVideoFrameFormats());let r=await f.create({proresFourCc:this.config.codec,useSharedMemory:f.canUseSharedMemory(),allowedOutputFormats:g._supportedVideoFrameFormats??void 0});if(r instanceof Error)throw r;this.decoder=r}async decode(r){if(I(this.decoder),this.decoder.useSharedMemory)await this.runDecode(r);else{for(;this.decoder.decodeQueueSize>=this.decoder.concurrency;)await this.decoder.dequeued;this.runDecode(r).catch(t=>this.onError(t))}}async runDecode(r){I(this.decoder);let t;this.framePool.length>0?t=this.framePool.shift():t=new y;let n=await this.decoder.decode(r.data,t);if(this.framePool.push(t),n instanceof Error)throw n;n.visibleHeight<n.codedHeight&&rr()&&this.trimCodedHeightToVisibleHeight(n);let o={primaries:n.colorPrimariesString,matrix:n.colorMatrixString,transfer:n.colorTransferString,fullRange:n.colorRangeFull},i=n.visibleWidth,s=n.visibleHeight;n.pixelAspectRatio.num>n.pixelAspectRatio.den?i=Math.round(n.visibleWidth*n.pixelAspectRatio.num/n.pixelAspectRatio.den):s=Math.round(n.visibleHeight*n.pixelAspectRatio.den/n.pixelAspectRatio.num);let a;if(typeof VideoFrame<"u"){let B=new VideoFrame(n.frameData,{format:n.pixelFormat,codedWidth:n.codedWidth,codedHeight:n.codedHeight,displayWidth:i,displayHeight:s,visibleRect:{x:0,y:0,width:n.visibleWidth,height:n.visibleHeight},timestamp:r.microsecondTimestamp,duration:r.microsecondDuration,colorSpace:o});a=new er(B,{timestamp:r.timestamp,duration:r.duration})}else a=new er(n.frameData,{format:n.pixelFormat,codedWidth:n.codedWidth,codedHeight:n.codedHeight,displayWidth:i,displayHeight:s,visibleRect:{left:0,top:0,width:n.visibleWidth,height:n.visibleHeight},timestamp:r.timestamp,duration:r.duration,colorSpace:o});this.onSample(a)}trimCodedHeightToVisibleHeight(r){let t=r.pixelFormat.includes("P")?2:1,n=r.pixelFormat.includes("444")?1:2,o=r.pixelFormat.includes("420")?2:1,i=r.codedWidth/n,s=r.codedHeight/o,a=Math.ceil(r.visibleHeight/o),B=r.codedWidth*r.codedHeight,p=r.codedWidth*r.visibleHeight,l=i*s,v=i*a;r.frameData.set(r.frameData.subarray(t*B,t*(B+l)),t*p),r.frameData.set(r.frameData.subarray(t*(B+l),t*(B+2*l)),t*(p+v)),r.codedHeight=r.visibleHeight}async flush(){for(I(this.decoder);this.decoder.decodeQueueSize>0;)await this.decoder.dequeued}async close(){I(this.decoder),await this.decoder.close();for(let r of this.framePool)r.clear()}};g._supportedVideoFrameFormats=null;var W=g,Ar=!1,qr=()=>{Ar||(Ar=!0,pr(W))};export{qr as registerProresDecoder};
|
|
@@ -18,12 +18,12 @@ var g = class extends Error {
|
|
|
18
18
|
super(e), this.name = "OutOfMemoryError";
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
var
|
|
21
|
+
var B = class extends Error {
|
|
22
22
|
constructor(e = "Invalid data: the packet ended before the decoder expected it to.") {
|
|
23
23
|
super(e), this.name = "UnexpectedEofError";
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
var
|
|
26
|
+
var k = class extends Error {
|
|
27
27
|
constructor(e = "The packet contains invalid data.") {
|
|
28
28
|
super(e), this.name = "InvalidDataError";
|
|
29
29
|
}
|
|
@@ -33,12 +33,12 @@ var A = class extends Error {
|
|
|
33
33
|
super(e), this.name = "NotSupportedError";
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
var
|
|
36
|
+
var H = class extends Error {
|
|
37
37
|
constructor(e = "The decoder is in an invalid internal state. This should never happen! Please report.") {
|
|
38
38
|
super(e), this.name = "InvalidStateError";
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
var
|
|
41
|
+
var N = class extends Error {
|
|
42
42
|
constructor(e = "The decoder has been closed.") {
|
|
43
43
|
super(e), this.name = "DecoderClosedError";
|
|
44
44
|
}
|
|
@@ -53,16 +53,16 @@ var O = (t, e) => {
|
|
|
53
53
|
case -1:
|
|
54
54
|
return new g(e);
|
|
55
55
|
case -2:
|
|
56
|
-
return new
|
|
56
|
+
return new B(e);
|
|
57
57
|
case -3:
|
|
58
|
-
return new
|
|
58
|
+
return new k(e);
|
|
59
59
|
case -4:
|
|
60
60
|
return new A(e);
|
|
61
61
|
case -5:
|
|
62
|
-
return new
|
|
62
|
+
return new H(e);
|
|
63
63
|
// Overflow is just another flavor of invalid data
|
|
64
64
|
case -6:
|
|
65
|
-
return new
|
|
65
|
+
return new k(e ?? "Unexpected integer overflow.");
|
|
66
66
|
default:
|
|
67
67
|
throw new Error(`Unhandled error code: ${t}`);
|
|
68
68
|
}
|
|
@@ -97,7 +97,7 @@ var W = (t) => {
|
|
|
97
97
|
}
|
|
98
98
|
return r;
|
|
99
99
|
};
|
|
100
|
-
var
|
|
100
|
+
var j = class {
|
|
101
101
|
constructor() {
|
|
102
102
|
__publicField(this, "currentPromise", Promise.resolve());
|
|
103
103
|
__publicField(this, "pending", 0);
|
|
@@ -113,7 +113,8 @@ var N = class {
|
|
|
113
113
|
return this.currentPromise = r, this.pending++, await o, e;
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
|
-
var
|
|
116
|
+
var D = typeof SharedArrayBuffer < "u";
|
|
117
|
+
var T = (t) => t;
|
|
117
118
|
Symbol.dispose ??= Symbol("dispose");
|
|
118
119
|
Symbol.asyncDispose ??= Symbol("asyncDispose");
|
|
119
120
|
var w = [
|
|
@@ -142,14 +143,14 @@ var w = [
|
|
|
142
143
|
"I444AP10",
|
|
143
144
|
"I444AP12"
|
|
144
145
|
];
|
|
145
|
-
var
|
|
146
|
+
var Q = {
|
|
146
147
|
1: "bt709",
|
|
147
148
|
5: "bt470bg",
|
|
148
149
|
6: "smpte170m",
|
|
149
150
|
9: "bt2020",
|
|
150
151
|
12: "smpte432"
|
|
151
152
|
};
|
|
152
|
-
var
|
|
153
|
+
var V = {
|
|
153
154
|
1: "bt709",
|
|
154
155
|
6: "smpte170m",
|
|
155
156
|
8: "linear",
|
|
@@ -157,7 +158,7 @@ var Q = {
|
|
|
157
158
|
16: "pq",
|
|
158
159
|
18: "hlg"
|
|
159
160
|
};
|
|
160
|
-
var
|
|
161
|
+
var G = {
|
|
161
162
|
0: "rgb",
|
|
162
163
|
1: "bt709",
|
|
163
164
|
5: "bt470bg",
|
|
@@ -167,7 +168,7 @@ var V = {
|
|
|
167
168
|
var y = new FinalizationRegistry(({ runtime: t, ptr: e }) => {
|
|
168
169
|
t.exports.closeFrame(e);
|
|
169
170
|
});
|
|
170
|
-
var
|
|
171
|
+
var X = class {
|
|
171
172
|
constructor() {
|
|
172
173
|
/**
|
|
173
174
|
* The raw data of the decoded frame, stored in the format described by `pixelFormat`. All frame data is stored in
|
|
@@ -266,15 +267,15 @@ var G = class {
|
|
|
266
267
|
}
|
|
267
268
|
/** {@link Frame.colorPrimaries} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
|
|
268
269
|
get colorPrimariesString() {
|
|
269
|
-
return this.colorPrimaries === null ? void 0 :
|
|
270
|
+
return this.colorPrimaries === null ? void 0 : Q[this.colorPrimaries];
|
|
270
271
|
}
|
|
271
272
|
/** {@link Frame.colorTransfer} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
|
|
272
273
|
get colorTransferString() {
|
|
273
|
-
return this.colorTransfer === null ? void 0 :
|
|
274
|
+
return this.colorTransfer === null ? void 0 : V[this.colorTransfer];
|
|
274
275
|
}
|
|
275
276
|
/** {@link Frame.colorMatrix} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
|
|
276
277
|
get colorMatrixString() {
|
|
277
|
-
return this.colorMatrix === null ? void 0 :
|
|
278
|
+
return this.colorMatrix === null ? void 0 : G[this.colorMatrix];
|
|
278
279
|
}
|
|
279
280
|
/** Whether this frame is locked by an in-flight decoding operation. While locked, it cannot be used or cleared. */
|
|
280
281
|
get isLocked() {
|
|
@@ -321,7 +322,7 @@ var G = class {
|
|
|
321
322
|
this.frameData = e.frameData, this.codedWidth = e.codedWidth, this.codedHeight = e.codedHeight, this.visibleWidth = e.visibleWidth, this.visibleHeight = e.visibleHeight, this.pixelFormat = e.pixelFormat, this.originalPixelFormat = e.originalPixelFormat, this.pixelAspectRatio = e.pixelAspectRatio, this.colorPrimaries = e.colorPrimaries, this.colorTransfer = e.colorTransfer, this.colorMatrix = e.colorMatrix, this.colorRangeFull = e.colorRangeFull, this.scanType = e.scanType;
|
|
322
323
|
}
|
|
323
324
|
};
|
|
324
|
-
var
|
|
325
|
+
var Y = (t, e, r, o) => {
|
|
325
326
|
const i = t.getFrameDataPtr(r), s = t.getFrameDataSize(r), n = new Uint8Array(e.buffer, i, s), c = w[t.getFramePixelFormat(r)];
|
|
326
327
|
d(c !== void 0);
|
|
327
328
|
const a = w[t.getOriginalPixelFormat(o)];
|
|
@@ -1231,7 +1232,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
|
|
|
1231
1232
|
\v\x1B (!")081*#+29:3;\f\r\x07$,%&-4<5.'/6=>7?\0\0\0\0\0\0\0\0\0\0\0\0Packet is smaller than the picture data size indicated in the picture header.\0Packet is smaller than the frame size indicated in the frame header.\0Invalid DC code stream.\0Invalid AC code stream.\0Picture header size too small.\0Frame header size too small.\0Slice header size too small.\0Invalid packet header frame type.\0Invalid frame type.\0Invalid alpha info header field.\0Invalid aspect ratio information header field.\0Version > 1 is not supported.\0Slice widths larger than 128 are not supported.\0Only slice heights of 1 are supported.\0Slice data extends past the bounds of the picture data.\0Channel data planes too large to fit into slice data.\0((MMpp\0\0\0\0))))((((((L
|
|
1232
1233
|
((((L\0\0\0\0\0\0\0\0\0\x90\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\b\0\0\0
|
|
1233
1234
|
\0\0\0\f\0\0\0Frame dimensions (x) exceed the maximum supported size of 16384x16384.\0\0\0\0\0\0\0\0\x07\0\0\0\b\0\0\0Unexpected slice count: expected , found .\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0 \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0`;
|
|
1234
|
-
var
|
|
1235
|
+
var J = async (t, e) => {
|
|
1235
1236
|
const { instance: r } = await WebAssembly.instantiate(t, {
|
|
1236
1237
|
env: {
|
|
1237
1238
|
memory: e,
|
|
@@ -1254,13 +1255,13 @@ var b = () => {
|
|
|
1254
1255
|
m[t] = _.charCodeAt(t);
|
|
1255
1256
|
return m;
|
|
1256
1257
|
};
|
|
1257
|
-
var
|
|
1258
|
+
var L = async () => {
|
|
1258
1259
|
if (typeof Worker < "u" && !("Bun" in globalThis)) {
|
|
1259
1260
|
const e = new Blob([S], { type: "text/javascript" }), r = URL.createObjectURL(e), o = new Worker(r, { type: "module" });
|
|
1260
1261
|
return new x(o, null);
|
|
1261
1262
|
}
|
|
1262
|
-
const
|
|
1263
|
-
return new x(null, new t(S, { eval: true }));
|
|
1263
|
+
const t = await import("node:" + T("worker_threads"));
|
|
1264
|
+
return new x(null, new t.Worker(S, { eval: true }));
|
|
1264
1265
|
};
|
|
1265
1266
|
var x = class {
|
|
1266
1267
|
constructor(e, r) {
|
|
@@ -1289,16 +1290,16 @@ var E = new FinalizationRegistry((t) => {
|
|
|
1289
1290
|
for (const e of t)
|
|
1290
1291
|
e.terminate();
|
|
1291
1292
|
});
|
|
1292
|
-
var
|
|
1293
|
+
var K = async () => {
|
|
1293
1294
|
if (typeof navigator < "u" && navigator.hardwareConcurrency)
|
|
1294
1295
|
return navigator.hardwareConcurrency;
|
|
1295
|
-
const t = await import("node:os");
|
|
1296
|
+
const t = await import("node:" + T("os"));
|
|
1296
1297
|
return t.availableParallelism?.() ?? t.cpus().length;
|
|
1297
1298
|
};
|
|
1298
1299
|
var p = null;
|
|
1299
|
-
var
|
|
1300
|
-
var
|
|
1301
|
-
const t = await
|
|
1300
|
+
var Z = new j();
|
|
1301
|
+
var $ = async () => {
|
|
1302
|
+
const t = await Z.acquire();
|
|
1302
1303
|
try {
|
|
1303
1304
|
if (p) {
|
|
1304
1305
|
const r = p.deref();
|
|
@@ -1312,11 +1313,11 @@ var Z = async () => {
|
|
|
1312
1313
|
}
|
|
1313
1314
|
};
|
|
1314
1315
|
var v = null;
|
|
1315
|
-
var
|
|
1316
|
+
var ee = () => {
|
|
1316
1317
|
let t = v?.deref();
|
|
1317
|
-
return t || (t = new
|
|
1318
|
+
return t || (t = new re(), v = new WeakRef(t)), t;
|
|
1318
1319
|
};
|
|
1319
|
-
var
|
|
1320
|
+
var U = class {
|
|
1320
1321
|
constructor() {
|
|
1321
1322
|
__publicField(this, "workers", []);
|
|
1322
1323
|
// The number of decoders currently using this runtime
|
|
@@ -1335,12 +1336,12 @@ var L = class {
|
|
|
1335
1336
|
this.workers.length = 0, E.unregister(this);
|
|
1336
1337
|
}
|
|
1337
1338
|
};
|
|
1338
|
-
var P = class _P extends
|
|
1339
|
+
var P = class _P extends U {
|
|
1339
1340
|
constructor(e, r) {
|
|
1340
1341
|
super(), this.memory = e, this.exports = r;
|
|
1341
1342
|
}
|
|
1342
1343
|
static async init() {
|
|
1343
|
-
const e = new WebAssembly.Memory({ initial: 32, maximum: 65536, shared: true }), r = await
|
|
1344
|
+
const e = new WebAssembly.Memory({ initial: 32, maximum: 65536, shared: true }), r = await J(b(), e), o = r.allocateThreadLocalState(r.__tls_size.value, r.__tls_align.value);
|
|
1344
1345
|
if (o === 0)
|
|
1345
1346
|
throw new Error("Failed to allocate thread-local state.");
|
|
1346
1347
|
r.__wasm_init_tls(o);
|
|
@@ -1355,7 +1356,7 @@ var P = class _P extends L {
|
|
|
1355
1356
|
);
|
|
1356
1357
|
if (r === 0 || o === 0)
|
|
1357
1358
|
throw new Error("Failed to allocate worker stack or thread-local state.");
|
|
1358
|
-
const i = await
|
|
1359
|
+
const i = await L();
|
|
1359
1360
|
i.postMessage({
|
|
1360
1361
|
type: l.SharedMemoryInit,
|
|
1361
1362
|
wasmBinary: b(),
|
|
@@ -1369,7 +1370,7 @@ var P = class _P extends L {
|
|
|
1369
1370
|
super.destroy(), p = null;
|
|
1370
1371
|
}
|
|
1371
1372
|
};
|
|
1372
|
-
var
|
|
1373
|
+
var re = class extends U {
|
|
1373
1374
|
constructor() {
|
|
1374
1375
|
super(...arguments);
|
|
1375
1376
|
// How many packets each worker currently has in flight
|
|
@@ -1402,7 +1403,7 @@ var ee = class extends L {
|
|
|
1402
1403
|
return;
|
|
1403
1404
|
const o = await Promise.all(
|
|
1404
1405
|
Array.from({ length: r }, async () => {
|
|
1405
|
-
const s = await
|
|
1406
|
+
const s = await L(), n = await new Promise((c) => {
|
|
1406
1407
|
s.postMessage({
|
|
1407
1408
|
type: l.MessagePassingInit,
|
|
1408
1409
|
wasmBinary: b()
|
|
@@ -1445,7 +1446,7 @@ var F = [
|
|
|
1445
1446
|
"apco"
|
|
1446
1447
|
// ProRes 422 Proxy
|
|
1447
1448
|
];
|
|
1448
|
-
var
|
|
1449
|
+
var q = class {
|
|
1449
1450
|
constructor(e) {
|
|
1450
1451
|
/** @internal */
|
|
1451
1452
|
__publicField(this, "_closed", false);
|
|
@@ -1497,7 +1498,7 @@ var U = class {
|
|
|
1497
1498
|
throw new TypeError(
|
|
1498
1499
|
`options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${w.join(", ")}.`
|
|
1499
1500
|
);
|
|
1500
|
-
if (e.useSharedMemory && !
|
|
1501
|
+
if (e.useSharedMemory && !D)
|
|
1501
1502
|
return new A(
|
|
1502
1503
|
`Shared memory is not available in this environment, so useSharedMemory: true cannot be used.
|
|
1503
1504
|
Since it provides way better performance, you should enable it by serving the page cross-origin isolated by setting the Cross-Origin-Opener-Policy header to 'same-origin' and the Cross-Origin-Embedder-Policy header to 'credentialless' or 'require-corp' (only the latter is supported by Safari).
|
|
@@ -1510,17 +1511,17 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
|
|
|
1510
1511
|
r |= 1 << w.indexOf(s);
|
|
1511
1512
|
} else
|
|
1512
1513
|
r = 4294967295;
|
|
1513
|
-
const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await
|
|
1514
|
+
const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await K();
|
|
1514
1515
|
if (e.useSharedMemory || i === 0) {
|
|
1515
|
-
const s = await
|
|
1516
|
+
const s = await $();
|
|
1516
1517
|
s.ref(), await s.ensureWorkers(i);
|
|
1517
1518
|
const n = s.exports.createDecoder(i, o, r);
|
|
1518
|
-
return n === 0 ? (s.unref(), new g()) : new
|
|
1519
|
+
return n === 0 ? (s.unref(), new g()) : new te(s, n, i);
|
|
1519
1520
|
} else {
|
|
1520
|
-
const s =
|
|
1521
|
+
const s = ee();
|
|
1521
1522
|
s.ref();
|
|
1522
1523
|
const n = await s.ensureWorkers(i);
|
|
1523
|
-
return n ? (s.unref(), n) : new
|
|
1524
|
+
return n ? (s.unref(), n) : new oe(
|
|
1524
1525
|
s,
|
|
1525
1526
|
i,
|
|
1526
1527
|
o,
|
|
@@ -1530,7 +1531,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
|
|
|
1530
1531
|
}
|
|
1531
1532
|
/** Whether the environment supports proper shared-memory multithreading. */
|
|
1532
1533
|
static canUseSharedMemory() {
|
|
1533
|
-
return
|
|
1534
|
+
return D;
|
|
1534
1535
|
}
|
|
1535
1536
|
/**
|
|
1536
1537
|
* Queues a ProRes packet for decoding with the given options. The decoded result will be stored in the passed
|
|
@@ -1541,14 +1542,14 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
|
|
|
1541
1542
|
async decode(e, r, o = {}) {
|
|
1542
1543
|
if (!(e instanceof Uint8Array))
|
|
1543
1544
|
throw new TypeError("packetData must be a Uint8Array.");
|
|
1544
|
-
if (!(r instanceof
|
|
1545
|
+
if (!(r instanceof X))
|
|
1545
1546
|
throw new TypeError("frame must be a Frame.");
|
|
1546
1547
|
if (typeof o != "object" || !o)
|
|
1547
1548
|
throw new TypeError("options must be an object.");
|
|
1548
1549
|
if (o.transfer !== void 0 && typeof o.transfer != "boolean")
|
|
1549
1550
|
throw new TypeError("options.transfer, when provided, must be a boolean.");
|
|
1550
1551
|
if (this._closed)
|
|
1551
|
-
return new
|
|
1552
|
+
return new N();
|
|
1552
1553
|
if (r._locked)
|
|
1553
1554
|
return new C();
|
|
1554
1555
|
r._reset(), r._locked = true, this._decodeQueueSize++;
|
|
@@ -1587,7 +1588,7 @@ var M = new FinalizationRegistry(
|
|
|
1587
1588
|
t.exports.closeDecoder(e), t.unref();
|
|
1588
1589
|
}
|
|
1589
1590
|
);
|
|
1590
|
-
var
|
|
1591
|
+
var te = class extends q {
|
|
1591
1592
|
constructor(e, r, o) {
|
|
1592
1593
|
super(false);
|
|
1593
1594
|
/** @internal */
|
|
@@ -1615,7 +1616,7 @@ var re = class extends U {
|
|
|
1615
1616
|
return new g();
|
|
1616
1617
|
new Uint8Array(s.buffer).set(e, c);
|
|
1617
1618
|
let a = i.decodePacket(this._decoderPtr, n);
|
|
1618
|
-
return a < 0 ? this._createError(a) : this.concurrency > 0 && (await Atomics.waitAsync(new Int32Array(s.buffer), this._taskStateOffset, 1).value, a = i.finalizePacketDecoding(this._decoderPtr), a < 0) ? this._createError(a) : (r._populate(
|
|
1619
|
+
return a < 0 ? this._createError(a) : this.concurrency > 0 && (await Atomics.waitAsync(new Int32Array(s.buffer), this._taskStateOffset, 1).value, a = i.finalizePacketDecoding(this._decoderPtr), a < 0) ? this._createError(a) : (r._populate(Y(i, s, n, this._decoderPtr)), r);
|
|
1619
1620
|
}
|
|
1620
1621
|
/** @internal */
|
|
1621
1622
|
_createError(e) {
|
|
@@ -1633,7 +1634,7 @@ var re = class extends U {
|
|
|
1633
1634
|
var R = new FinalizationRegistry((t) => {
|
|
1634
1635
|
t.unref();
|
|
1635
1636
|
});
|
|
1636
|
-
var
|
|
1637
|
+
var oe = class extends q {
|
|
1637
1638
|
constructor(e, r, o, i) {
|
|
1638
1639
|
super(true);
|
|
1639
1640
|
/** @internal */
|
|
@@ -1667,8 +1668,8 @@ var te = class extends U {
|
|
|
1667
1668
|
},
|
|
1668
1669
|
f ? [s.buffer, f] : [s.buffer]
|
|
1669
1670
|
);
|
|
1670
|
-
const I = (
|
|
1671
|
-
const u =
|
|
1671
|
+
const I = (z) => {
|
|
1672
|
+
const u = z.data;
|
|
1672
1673
|
u.type !== l.Decoded && u.type !== l.DecodeError || u.id === a && (c.removeEventListener("message", I), i.workerLoad[n]--, u.type === l.DecodeError ? h(O(u.code, u.message)) : (r._buffer = u.contents.frameData.buffer, r._populate(u.contents), h(r)));
|
|
1673
1674
|
};
|
|
1674
1675
|
c.addEventListener("message", I);
|
|
@@ -1734,9 +1735,9 @@ var _ProresDecoder = class _ProresDecoder extends CustomVideoDecoder {
|
|
|
1734
1735
|
if (typeof VideoFrame !== "undefined") {
|
|
1735
1736
|
_ProresDecoder._supportedVideoFrameFormats ??= _ProresDecoder._determineSupportedVideoFrameFormats();
|
|
1736
1737
|
}
|
|
1737
|
-
const decoder = await
|
|
1738
|
+
const decoder = await q.create({
|
|
1738
1739
|
proresFourCc: this.config.codec,
|
|
1739
|
-
useSharedMemory:
|
|
1740
|
+
useSharedMemory: q.canUseSharedMemory(),
|
|
1740
1741
|
allowedOutputFormats: _ProresDecoder._supportedVideoFrameFormats ?? void 0
|
|
1741
1742
|
});
|
|
1742
1743
|
if (decoder instanceof Error) {
|
|
@@ -1761,7 +1762,7 @@ var _ProresDecoder = class _ProresDecoder extends CustomVideoDecoder {
|
|
|
1761
1762
|
if (this.framePool.length > 0) {
|
|
1762
1763
|
frame = this.framePool.shift();
|
|
1763
1764
|
} else {
|
|
1764
|
-
frame = new
|
|
1765
|
+
frame = new X();
|
|
1765
1766
|
}
|
|
1766
1767
|
const result = await this.decoder.decode(packet.data, frame);
|
|
1767
1768
|
this.framePool.push(frame);
|