@mediabunny/prores 1.66.2 → 1.66.3

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.
@@ -55,17 +55,17 @@ var MediabunnyProres = (() => {
55
55
  var import_mediabunny = __toESM(require_mediabunny());
56
56
 
57
57
  // node_modules/turbores/dist/turbores.js
58
- var p = class extends Error {
58
+ var y = class extends Error {
59
59
  constructor(e = "The decoder ran out of memory.") {
60
60
  super(e), this.name = "OutOfMemoryError";
61
61
  }
62
62
  };
63
- var H = class extends Error {
63
+ var j = class extends Error {
64
64
  constructor(e = "Invalid data: the packet ended before the decoder expected it to.") {
65
65
  super(e), this.name = "UnexpectedEofError";
66
66
  }
67
67
  };
68
- var x = class extends Error {
68
+ var E = class extends Error {
69
69
  constructor(e = "The packet contains invalid data.") {
70
70
  super(e), this.name = "InvalidDataError";
71
71
  }
@@ -75,12 +75,12 @@ var MediabunnyProres = (() => {
75
75
  super(e), this.name = "NotSupportedError";
76
76
  }
77
77
  };
78
- var N = class extends Error {
78
+ var Q = class extends Error {
79
79
  constructor(e = "The decoder is in an invalid internal state. This should never happen! Please report.") {
80
80
  super(e), this.name = "InvalidStateError";
81
81
  }
82
82
  };
83
- var j = class extends Error {
83
+ var G = class extends Error {
84
84
  constructor(e = "The decoder has been closed.") {
85
85
  super(e), this.name = "DecoderClosedError";
86
86
  }
@@ -90,30 +90,35 @@ var MediabunnyProres = (() => {
90
90
  super(e), this.name = "FrameLockedError";
91
91
  }
92
92
  };
93
- var W = (t, e) => {
93
+ var w = class extends Error {
94
+ constructor(e = "A worker failed to start.") {
95
+ super(e), this.name = "WorkerStartError";
96
+ }
97
+ };
98
+ var T = (t, e) => {
94
99
  switch (t) {
95
100
  case -1:
96
- return new p(e);
101
+ return new y(e);
97
102
  case -2:
98
- return new H(e);
103
+ return new j(e);
99
104
  case -3:
100
- return new x(e);
105
+ return new E(e);
101
106
  case -4:
102
107
  return new C(e);
103
108
  case -5:
104
- return new N(e);
109
+ return new Q(e);
105
110
  // Overflow is just another flavor of invalid data
106
111
  case -6:
107
- return new x(e ?? "Unexpected integer overflow.");
112
+ return new E(e ?? "Unexpected integer overflow.");
108
113
  default:
109
114
  throw new Error(`Unhandled error code: ${t}`);
110
115
  }
111
116
  };
112
- function h(t) {
117
+ function c(t) {
113
118
  if (!t)
114
119
  throw new Error("Assertion failed.");
115
120
  }
116
- var T = (t) => {
121
+ var U = (t) => {
117
122
  let e = 0, r = "";
118
123
  for (; e < t.length; ) {
119
124
  let o = t[e++];
@@ -139,7 +144,7 @@ var MediabunnyProres = (() => {
139
144
  }
140
145
  return r;
141
146
  };
142
- var y = class {
147
+ var _ = class {
143
148
  constructor() {
144
149
  __publicField(this, "currentPromise", Promise.resolve());
145
150
  __publicField(this, "pending", 0);
@@ -155,11 +160,11 @@ var MediabunnyProres = (() => {
155
160
  return this.currentPromise = r, this.pending++, await o, e;
156
161
  }
157
162
  };
158
- var I = typeof SharedArrayBuffer < "u";
163
+ var x = typeof SharedArrayBuffer < "u";
159
164
  var L = (t) => t;
160
165
  Symbol.dispose ??= Symbol("dispose");
161
166
  Symbol.asyncDispose ??= Symbol("asyncDispose");
162
- var g = [
167
+ var p = [
163
168
  // 4:2:0 Y, U, V
164
169
  "I420",
165
170
  "I420P10",
@@ -185,14 +190,14 @@ var MediabunnyProres = (() => {
185
190
  "I444AP10",
186
191
  "I444AP12"
187
192
  ];
188
- var Q = {
193
+ var V = {
189
194
  1: "bt709",
190
195
  5: "bt470bg",
191
196
  6: "smpte170m",
192
197
  9: "bt2020",
193
198
  12: "smpte432"
194
199
  };
195
- var V = {
200
+ var X = {
196
201
  1: "bt709",
197
202
  6: "smpte170m",
198
203
  8: "linear",
@@ -200,17 +205,17 @@ var MediabunnyProres = (() => {
200
205
  16: "pq",
201
206
  18: "hlg"
202
207
  };
203
- var G = {
208
+ var Y = {
204
209
  0: "rgb",
205
210
  1: "bt709",
206
211
  5: "bt470bg",
207
212
  6: "smpte170m",
208
213
  9: "bt2020-ncl"
209
214
  };
210
- var b = new FinalizationRegistry(({ runtime: t, ptr: e }) => {
215
+ var k = new FinalizationRegistry(({ runtime: t, ptr: e }) => {
211
216
  t.exports.closeFrame(e);
212
217
  });
213
- var X = class {
218
+ var J = class {
214
219
  constructor() {
215
220
  /**
216
221
  * The raw data of the decoded frame, stored in the format described by `pixelFormat`. All frame data is stored in
@@ -309,15 +314,15 @@ var MediabunnyProres = (() => {
309
314
  }
310
315
  /** {@link Frame.colorPrimaries} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
311
316
  get colorPrimariesString() {
312
- return this.colorPrimaries === null ? void 0 : Q[this.colorPrimaries];
317
+ return this.colorPrimaries === null ? void 0 : V[this.colorPrimaries];
313
318
  }
314
319
  /** {@link Frame.colorTransfer} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
315
320
  get colorTransferString() {
316
- return this.colorTransfer === null ? void 0 : V[this.colorTransfer];
321
+ return this.colorTransfer === null ? void 0 : X[this.colorTransfer];
317
322
  }
318
323
  /** {@link Frame.colorMatrix} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
319
324
  get colorMatrixString() {
320
- return this.colorMatrix === null ? void 0 : G[this.colorMatrix];
325
+ return this.colorMatrix === null ? void 0 : Y[this.colorMatrix];
321
326
  }
322
327
  /** Whether this frame is locked by an in-flight decoding operation. While locked, it cannot be used or cleared. */
323
328
  get isLocked() {
@@ -341,7 +346,7 @@ var MediabunnyProres = (() => {
341
346
  clear() {
342
347
  if (this._locked)
343
348
  throw new O();
344
- this._ptr !== null && (h(this._runtime), b.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null), this._buffer = null, this._reset();
349
+ this._ptr !== null && (c(this._runtime), k.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null), this._buffer = null, this._reset();
345
350
  }
346
351
  /** Calls `.clear()` internally. */
347
352
  [Symbol.dispose]() {
@@ -351,9 +356,9 @@ var MediabunnyProres = (() => {
351
356
  _ensureWasmFrame(e) {
352
357
  if (this._runtime === e)
353
358
  return true;
354
- this._runtime && (b.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null);
359
+ this._runtime && (k.unregister(this), this._runtime.exports.closeFrame(this._ptr), this._runtime = null, this._ptr = null);
355
360
  const r = e.exports.createFrame();
356
- return r === 0 ? false : (this._runtime = e, this._ptr = r, b.register(this, { runtime: e, ptr: r }, this), true);
361
+ return r === 0 ? false : (this._runtime = e, this._ptr = r, k.register(this, { runtime: e, ptr: r }, this), true);
357
362
  }
358
363
  /** @internal */
359
364
  _reset() {
@@ -364,24 +369,24 @@ var MediabunnyProres = (() => {
364
369
  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;
365
370
  }
366
371
  };
367
- var Y = (t, e, r, o) => {
368
- const i = t.getFrameDataPtr(r), s = t.getFrameDataSize(r), n = new Uint8Array(e.buffer, i, s), a = g[t.getFramePixelFormat(r)];
369
- h(a !== void 0);
370
- const c = g[t.getOriginalPixelFormat(o)];
371
- h(c !== void 0);
372
- const d = [
372
+ var K = (t, e, r, o) => {
373
+ const i = t.getFrameDataPtr(r), s = t.getFrameDataSize(r), n = new Uint8Array(e.buffer, i, s), a = p[t.getFramePixelFormat(r)];
374
+ c(a !== void 0);
375
+ const d = p[t.getOriginalPixelFormat(o)];
376
+ c(d !== void 0);
377
+ const u = [
373
378
  "progressive",
374
379
  "interlaced-top-field-first",
375
380
  "interlaced-bottom-field-first"
376
381
  ][t.getScanType(r)];
377
- return h(d !== void 0), {
382
+ return c(u !== void 0), {
378
383
  frameData: n,
379
384
  codedWidth: t.getCodedWidth(r),
380
385
  codedHeight: t.getCodedHeight(r),
381
386
  visibleWidth: t.getVisibleWidth(r),
382
387
  visibleHeight: t.getVisibleHeight(r),
383
388
  pixelFormat: a,
384
- originalPixelFormat: c,
389
+ originalPixelFormat: d,
385
390
  pixelAspectRatio: {
386
391
  num: t.getAspectRatioNum(r),
387
392
  den: t.getAspectRatioDen(r)
@@ -391,11 +396,11 @@ var MediabunnyProres = (() => {
391
396
  colorMatrix: t.getColorMatrix(r),
392
397
  colorRangeFull: false,
393
398
  // Always limited range, but expose it for clarity
394
- scanType: d
399
+ scanType: u
395
400
  };
396
401
  };
397
- var l = /* @__PURE__ */ ((t) => (t[t.SharedMemoryInit = 0] = "SharedMemoryInit", t[t.MessagePassingInit = 1] = "MessagePassingInit", t[t.CreateDecoder = 2] = "CreateDecoder", t[t.CloseDecoder = 3] = "CloseDecoder", t[t.Decode = 4] = "Decode", t[t.Ready = 5] = "Ready", t[t.InitOutOfMemoryError = 6] = "InitOutOfMemoryError", t[t.Decoded = 7] = "Decoded", t[t.DecodeError = 8] = "DecodeError", t))(l || {});
398
- var k = `\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\`
402
+ var l = /* @__PURE__ */ ((t) => (t[t.SharedMemoryInit = 0] = "SharedMemoryInit", t[t.MessagePassingInit = 1] = "MessagePassingInit", t[t.CreateDecoder = 2] = "CreateDecoder", t[t.CloseDecoder = 3] = "CloseDecoder", t[t.Decode = 4] = "Decode", t[t.Ready = 5] = "Ready", t[t.InitOutOfMemoryError = 6] = "InitOutOfMemoryError", t[t.InitError = 7] = "InitError", t[t.Decoded = 8] = "Decoded", t[t.DecodeError = 9] = "DecodeError", t))(l || {});
403
+ var S = `\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\`
399
404
  \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
400
405
  \0\v\f\v\r\0\r\v\v\v\r\r\f\f\v\vp \x7FA\x80\x80\xC0\0\v\x7FA\0\v\x7F\0A\x90\b\v\x7F\0A\v\x07\xE1!__stack_pointer\0
401
406
  __tls_base
@@ -1299,41 +1304,59 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1299
1304
  \0\xA0\0\xA0\x07\0\xA0\0\xA0\0\xA0\0\xA0\b\0\xA0\b\0\xA0\b\0\xA0\b\0\xA0
1300
1305
  \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
1301
1306
  \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`;
1302
- var J = async (t, e) => {
1307
+ var Z = async (t, e) => {
1303
1308
  const { instance: r } = await WebAssembly.instantiate(t, {
1304
1309
  env: {
1305
1310
  memory: e,
1306
1311
  externPrint: (o, i) => {
1307
1312
  const s = new Uint8Array(e.buffer, o, i);
1308
- console.log(T(s));
1313
+ console.log(U(s));
1309
1314
  }
1310
1315
  }
1311
1316
  });
1312
1317
  return r.exports;
1313
1318
  };
1314
- var D = `"use strict";var I=(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))(I||{});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),w=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:w,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 s=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){d({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){d({type:n.InitOutOfMemoryError,message:"Failed to create frame."});return}s={exports:r,memory:t,decoders:new Map,frame:i},d({type:n.Ready});return}case n.CreateDecoder:{f(s);const{exports:t}=s,{decoderId:r,bitDepth:o,allowedOutputFormats:i}=e,a=t.createDecoder(0,o,i);if(a===0)return;s.decoders.set(r,a);return}case n.CloseDecoder:{f(s);const{exports:t,decoders:r}=s,o=r.get(e.decoderId);o!==void 0&&(t.closeDecoder(o),r.delete(e.decoderId));return}case n.Decode:{f(s);const{exports:t,memory:r,decoders:o,frame:i}=s,{id:a,decoderId:w,packet:u,frameBuffer:l}=e,c=o.get(w);if(c===void 0){d({type:n.DecodeError,id:a,code:I.OutOfMemory});return}const g=t.allocatePacket(c,u.byteLength,0);if(g===0){d({type:n.DecodeError,id:a,code:I.OutOfMemory});return}new Uint8Array(r.buffer).set(u,g);const D=t.decodePacket(c,i,0);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))}d({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,d({type:n.Decoded,id:a,contents:m},[y]);return}}},d=(e,t)=>{h?h.postMessage(e,t??[]):self.postMessage(e,{transfer:t??[]})};let h=null;try{h=require("node:worker_threads").parentPort}catch{}h?h.on("message",F):self.addEventListener("message",e=>void F(e.data));
1319
+ var D = `"use strict";var w=(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))(w||{});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 v=["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),m=v[e.getFramePixelFormat(r)];f(m!==void 0);const l=v[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:m,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.InitError=7]="InitError",e[e.Decoded=8]="Decoded",e[e.DecodeError=9]="DecodeError",e))(n||{});const U=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);if(!t)return;throw t.__stack_pointer.value=e.stackPointer,t.__wasm_init_tls(e.tlsPointer),t.setIsBrowserMainThread(0),s({type:n.Ready}),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);if(!r)return;const 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:m,frameBuffer:l}=e,c=o.get(I);if(c===void 0){s({type:n.DecodeError,id:a,code:w.OutOfMemory});return}const g=t.allocatePacket(c,m.byteLength,0);if(g===0){s({type:n.DecodeError,id:a,code:w.OutOfMemory});return}new Uint8Array(r.buffer).set(m,g);const D=t.decodePacket(c,i,0);if(D<0){let S;const P=t.getErrorMessagePtr(c);if(P!==0){const b=t.getErrorMessageSize(c);S=O(new Uint8Array(r.buffer,P,b))}s({type:n.DecodeError,id:a,code:D,message:S});return}const h=_(t,r,i,c),y=l&&l.byteLength===h.frameData.byteLength?l:new ArrayBuffer(h.frameData.byteLength),p=new Uint8Array(y);p.set(h.frameData),h.frameData=p,s({type:n.Decoded,id:a,contents:h},[y]);return}}},A=async(e,t)=>{try{return await U(e,t)}catch(r){return s({type:n.InitError,message:String(r)}),null}},s=(e,t)=>{u?u.postMessage(e,t??[]):self.postMessage(e,{transfer:t??[]})};let u=null;try{u=require("node:worker_threads").parentPort}catch{"WorkerGlobalScope"in globalThis||(u=process.getBuiltinModule("node:worker_threads").parentPort)}u?u.on("message",F):self.addEventListener("message",e=>void F(e.data));
1315
1320
  `;
1316
- var w = null;
1317
- var P = () => {
1318
- if (w)
1319
- return w;
1320
- w = new Uint8Array(k.length);
1321
- for (let t = 0; t < k.length; t++)
1322
- w[t] = k.charCodeAt(t);
1323
- return w;
1321
+ var g = null;
1322
+ var I = () => {
1323
+ if (g)
1324
+ return g;
1325
+ g = new Uint8Array(S.length);
1326
+ for (let t = 0; t < S.length; t++)
1327
+ g[t] = S.charCodeAt(t);
1328
+ return g;
1324
1329
  };
1325
- var U = async () => {
1330
+ var q = async () => {
1331
+ const t = globalThis[Symbol.for("turbores:workerUrl")];
1332
+ if (t !== void 0 && typeof t != "string" && !(t instanceof URL))
1333
+ throw new TypeError("globalThis[Symbol.for('turbores:workerUrl')], when provided, must be a string or URL.");
1326
1334
  if (typeof Worker < "u" && !("Bun" in globalThis)) {
1327
- const e = new Blob([D], { type: "text/javascript" }), r = URL.createObjectURL(e), o = new Worker(r, { type: "module" });
1328
- return new E(o, null);
1335
+ let r = t;
1336
+ if (r === void 0) {
1337
+ const o = new Blob([D], { type: "text/javascript" });
1338
+ r = URL.createObjectURL(o);
1339
+ }
1340
+ try {
1341
+ return new F(new Worker(r, { type: "module" }), null);
1342
+ } catch (o) {
1343
+ return new w(`A worker failed to start: ${String(o)}`);
1344
+ }
1329
1345
  }
1330
- const t = await import(
1346
+ const e = await import(
1331
1347
  /* @vite-ignore */
1332
1348
  "node:" + L("worker_threads")
1333
1349
  );
1334
- return new E(null, new t.Worker(D, { eval: true }));
1350
+ try {
1351
+ return new F(
1352
+ null,
1353
+ t !== void 0 ? new e.Worker(t) : new e.Worker(D, { eval: true })
1354
+ );
1355
+ } catch (r) {
1356
+ return new w(`A worker failed to start: ${String(r)}`);
1357
+ }
1335
1358
  };
1336
- var E = class {
1359
+ var F = class {
1337
1360
  constructor(e, r) {
1338
1361
  __publicField(this, "wrappedListeners", /* @__PURE__ */ new Map());
1339
1362
  this.webWorker = e, this.nodeWorker = r;
@@ -1349,6 +1372,9 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1349
1372
  this.wrappedListeners.set(r, i), o?.once ? this.nodeWorker.once(e, i) : this.nodeWorker.on(e, i);
1350
1373
  }
1351
1374
  }
1375
+ onError(e) {
1376
+ this.webWorker ? this.webWorker.addEventListener("error", (r) => e(r.message)) : this.nodeWorker.on("error", (r) => e(r.message));
1377
+ }
1352
1378
  removeEventListener(e, r) {
1353
1379
  this.webWorker ? this.webWorker.removeEventListener(e, r) : (this.nodeWorker.off(e, this.wrappedListeners.get(r)), this.wrappedListeners.delete(r));
1354
1380
  }
@@ -1356,11 +1382,11 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1356
1382
  this.webWorker ? this.webWorker.terminate() : this.nodeWorker.terminate();
1357
1383
  }
1358
1384
  };
1359
- var F = new FinalizationRegistry((t) => {
1385
+ var M = new FinalizationRegistry((t) => {
1360
1386
  for (const e of t)
1361
1387
  e.terminate();
1362
1388
  });
1363
- var K = async () => {
1389
+ var $ = async () => {
1364
1390
  if (typeof navigator < "u" && navigator.hardwareConcurrency)
1365
1391
  return navigator.hardwareConcurrency;
1366
1392
  const t = await import(
@@ -1369,33 +1395,33 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1369
1395
  );
1370
1396
  return t.availableParallelism?.() ?? t.cpus().length;
1371
1397
  };
1372
- var _ = null;
1373
- var Z = new y();
1374
- var $ = async () => {
1375
- const t = await Z.acquire();
1398
+ var b = null;
1399
+ var ee = new _();
1400
+ var re = async () => {
1401
+ const t = await ee.acquire();
1376
1402
  try {
1377
- if (_) {
1378
- const r = _.deref();
1403
+ if (b) {
1404
+ const r = b.deref();
1379
1405
  if (r)
1380
1406
  return r;
1381
1407
  }
1382
1408
  const e = await v.init();
1383
- return _ = new WeakRef(e), e;
1409
+ return b = new WeakRef(e), e;
1384
1410
  } finally {
1385
1411
  t();
1386
1412
  }
1387
1413
  };
1388
- var S = null;
1389
- var ee = () => {
1390
- let t = S?.deref();
1391
- return t || (t = new re(), S = new WeakRef(t)), t;
1414
+ var P = null;
1415
+ var te = () => {
1416
+ let t = P?.deref();
1417
+ return t || (t = new oe(), P = new WeakRef(t)), t;
1392
1418
  };
1393
- var q = class {
1419
+ var z = class {
1394
1420
  constructor() {
1395
1421
  __publicField(this, "workers", []);
1396
1422
  // The number of decoders currently using this runtime
1397
1423
  __publicField(this, "refCount", 0);
1398
- F.register(this, this.workers, this);
1424
+ M.register(this, this.workers, this);
1399
1425
  }
1400
1426
  ref() {
1401
1427
  this.refCount++;
@@ -1406,15 +1432,15 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1406
1432
  destroy() {
1407
1433
  for (const e of this.workers)
1408
1434
  e.terminate();
1409
- this.workers.length = 0, F.unregister(this);
1435
+ this.workers.length = 0, M.unregister(this);
1410
1436
  }
1411
1437
  };
1412
- var v = class _v extends q {
1438
+ var v = class _v extends z {
1413
1439
  constructor(e, r) {
1414
1440
  super(), this.memory = e, this.exports = r;
1415
1441
  }
1416
1442
  static async init() {
1417
- const e = new WebAssembly.Memory({ initial: 32, maximum: 65536, shared: true }), r = await J(P(), e), o = r.allocateThreadLocalState(r.__tls_size.value, r.__tls_align.value);
1443
+ const e = new WebAssembly.Memory({ initial: 32, maximum: 65536, shared: true }), r = await Z(I(), e), o = r.allocateThreadLocalState(r.__tls_size.value, r.__tls_align.value);
1418
1444
  if (o === 0)
1419
1445
  throw new Error("Failed to allocate thread-local state.");
1420
1446
  r.__wasm_init_tls(o);
@@ -1422,28 +1448,39 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1422
1448
  return r.setIsBrowserMainThread(Number(i)), new _v(e, r);
1423
1449
  }
1424
1450
  async ensureWorkers(e) {
1425
- for (; this.workers.length < e; ) {
1426
- const r = this.exports.allocateWorkerStack(), o = this.exports.allocateThreadLocalState(
1451
+ const r = [];
1452
+ let o = null;
1453
+ for (; this.workers.length + r.length < e; ) {
1454
+ const i = this.exports.allocateWorkerStack(), s = this.exports.allocateThreadLocalState(
1427
1455
  this.exports.__tls_size.value,
1428
1456
  this.exports.__tls_align.value
1429
1457
  );
1430
- if (r === 0 || o === 0)
1458
+ if (i === 0 || s === 0)
1431
1459
  throw new Error("Failed to allocate worker stack or thread-local state.");
1432
- const i = await U();
1433
- i.postMessage({
1460
+ const n = await q();
1461
+ if (n instanceof w) {
1462
+ o = n;
1463
+ break;
1464
+ }
1465
+ n.postMessage({
1434
1466
  type: l.SharedMemoryInit,
1435
- wasmBinary: P(),
1467
+ wasmBinary: I(),
1436
1468
  memory: this.memory,
1437
- stackPointer: r,
1438
- tlsPointer: o
1439
- }), this.workers.push(i);
1469
+ stackPointer: i,
1470
+ tlsPointer: s
1471
+ }), r.push({ worker: n, reply: B(n) });
1440
1472
  }
1473
+ for (const { worker: i, reply: s } of r) {
1474
+ const n = await s;
1475
+ n instanceof w ? (i.terminate(), o = n) : (c(n.type === l.Ready), this.workers.push(i));
1476
+ }
1477
+ return o;
1441
1478
  }
1442
1479
  destroy() {
1443
- super.destroy(), _ = null;
1480
+ super.destroy(), b = null;
1444
1481
  }
1445
1482
  };
1446
- var re = class extends q {
1483
+ var oe = class extends z {
1447
1484
  constructor() {
1448
1485
  super(...arguments);
1449
1486
  // How many packets each worker currently has in flight
@@ -1476,15 +1513,19 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1476
1513
  return;
1477
1514
  const o = await Promise.all(
1478
1515
  Array.from({ length: r }, async () => {
1479
- const s = await U(), n = await new Promise((a) => {
1480
- s.postMessage({
1481
- type: l.MessagePassingInit,
1482
- wasmBinary: P()
1483
- }), s.addEventListener("message", (c) => a(c.data), { once: true });
1516
+ const s = await q();
1517
+ if (s instanceof w)
1518
+ return s;
1519
+ s.postMessage({
1520
+ type: l.MessagePassingInit,
1521
+ wasmBinary: I()
1484
1522
  });
1485
- return n.type === l.InitOutOfMemoryError ? (s.terminate(), new p(n.message)) : s;
1523
+ const n = await B(s);
1524
+ return n instanceof w ? (s.terminate(), n) : n.type === l.InitOutOfMemoryError ? (s.terminate(), new y(n.message)) : s;
1486
1525
  })
1487
- ), i = o.find((s) => s instanceof Error);
1526
+ ), i = o.find(
1527
+ (s) => s instanceof Error
1528
+ );
1488
1529
  if (i) {
1489
1530
  for (const s of o)
1490
1531
  s instanceof Error || s.terminate();
@@ -1492,20 +1533,28 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1492
1533
  }
1493
1534
  for (const s of o) {
1494
1535
  this.workers.push(s), this.workerLoad.push(0);
1495
- for (const [n, { bitDepth: a, allowedOutputFormats: c }] of this.registeredDecoders)
1536
+ for (const [n, { bitDepth: a, allowedOutputFormats: d }] of this.registeredDecoders)
1496
1537
  s.postMessage({
1497
1538
  type: l.CreateDecoder,
1498
1539
  decoderId: n,
1499
1540
  bitDepth: a,
1500
- allowedOutputFormats: c
1541
+ allowedOutputFormats: d
1501
1542
  });
1502
1543
  }
1503
1544
  }
1504
1545
  destroy() {
1505
- super.destroy(), S = null;
1546
+ super.destroy(), P = null;
1506
1547
  }
1507
1548
  };
1508
- var M = [
1549
+ var B = (t) => new Promise((e) => {
1550
+ t.addEventListener("message", (r) => {
1551
+ const o = r.data;
1552
+ o.type === l.InitError ? e(new w(`A worker failed to start: ${o.message}`)) : e(o);
1553
+ }, { once: true }), t.onError((r) => {
1554
+ e(new w(r ? `A worker failed to start: ${r}` : void 0));
1555
+ });
1556
+ });
1557
+ var R = [
1509
1558
  "ap4x",
1510
1559
  // ProRes 4444 XQ
1511
1560
  "ap4h",
@@ -1519,7 +1568,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1519
1568
  "apco"
1520
1569
  // ProRes 422 Proxy
1521
1570
  ];
1522
- var z = class {
1571
+ var H = class {
1523
1572
  constructor() {
1524
1573
  /** @internal */
1525
1574
  __publicField(this, "_closed", false);
@@ -1566,17 +1615,17 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1566
1615
  static async create(e) {
1567
1616
  if (typeof e != "object" || !e)
1568
1617
  throw new TypeError("options must be an object.");
1569
- if (!M.includes(e.proresFourCc))
1570
- throw new TypeError(`options.proresFourCc must be one of ${M.join(", ")}.`);
1618
+ if (!R.includes(e.proresFourCc))
1619
+ throw new TypeError(`options.proresFourCc must be one of ${R.join(", ")}.`);
1571
1620
  if (typeof e.useSharedMemory != "boolean")
1572
1621
  throw new TypeError("options.useSharedMemory must be a boolean.");
1573
1622
  if (e.concurrency !== void 0 && (!Number.isInteger(e.concurrency) || e.concurrency < 0))
1574
1623
  throw new TypeError("options.concurrency, when provided, must be a non-negative integer.");
1575
- if (e.allowedOutputFormats && !(Array.isArray(e.allowedOutputFormats) && e.allowedOutputFormats.length > 0 && e.allowedOutputFormats.every((s) => g.includes(s))))
1624
+ if (e.allowedOutputFormats && !(Array.isArray(e.allowedOutputFormats) && e.allowedOutputFormats.length > 0 && e.allowedOutputFormats.every((s) => p.includes(s))))
1576
1625
  throw new TypeError(
1577
- `options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${g.join(", ")}.`
1626
+ `options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${p.join(", ")}.`
1578
1627
  );
1579
- if (e.useSharedMemory && !I)
1628
+ if (e.useSharedMemory && !x)
1580
1629
  return new C(
1581
1630
  `Shared memory is not available in this environment, so useSharedMemory: true cannot be used.
1582
1631
  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).
@@ -1586,20 +1635,23 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1586
1635
  if (e.allowedOutputFormats) {
1587
1636
  r = 0;
1588
1637
  for (const s of e.allowedOutputFormats)
1589
- r |= 1 << g.indexOf(s);
1638
+ r |= 1 << p.indexOf(s);
1590
1639
  } else
1591
1640
  r = 4294967295;
1592
- const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await K();
1641
+ const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await $();
1593
1642
  if (e.useSharedMemory || i === 0) {
1594
- const s = await $();
1595
- s.ref(), await s.ensureWorkers(i);
1596
- const n = s.exports.createDecoder(i, o, r);
1597
- return n === 0 ? (s.unref(), new p()) : new te(s, n, i);
1643
+ const s = await re();
1644
+ s.ref();
1645
+ const n = await s.ensureWorkers(i);
1646
+ if (n)
1647
+ return s.unref(), n;
1648
+ const a = s.exports.createDecoder(i, o, r);
1649
+ return a === 0 ? (s.unref(), new y()) : new se(s, a, i);
1598
1650
  } else {
1599
- const s = ee();
1651
+ const s = te();
1600
1652
  s.ref();
1601
1653
  const n = await s.ensureWorkers(i);
1602
- return n ? (s.unref(), n) : new oe(
1654
+ return n ? (s.unref(), n) : new ie(
1603
1655
  s,
1604
1656
  i,
1605
1657
  o,
@@ -1609,7 +1661,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1609
1661
  }
1610
1662
  /** Whether the environment supports proper shared-memory multithreading. */
1611
1663
  static canUseSharedMemory() {
1612
- return I;
1664
+ return x;
1613
1665
  }
1614
1666
  /**
1615
1667
  * Queues a ProRes packet for decoding with the given options. The decoded result will be stored in the passed
@@ -1620,14 +1672,14 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1620
1672
  async decode(e, r, o = {}) {
1621
1673
  if (!(e instanceof Uint8Array))
1622
1674
  throw new TypeError("packetData must be a Uint8Array.");
1623
- if (!(r instanceof X))
1675
+ if (!(r instanceof J))
1624
1676
  throw new TypeError("frame must be a Frame.");
1625
1677
  if (typeof o != "object" || !o)
1626
1678
  throw new TypeError("options must be an object.");
1627
1679
  if (o.transfer !== void 0 && typeof o.transfer != "boolean")
1628
1680
  throw new TypeError("options.transfer, when provided, must be a boolean.");
1629
1681
  if (this._closed)
1630
- return new j();
1682
+ return new G();
1631
1683
  if (r._locked)
1632
1684
  return new O();
1633
1685
  r._reset(), r._locked = true, this._decodeQueueSize++;
@@ -1666,12 +1718,12 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1666
1718
  return this.close();
1667
1719
  }
1668
1720
  };
1669
- var R = new FinalizationRegistry(
1721
+ var A = new FinalizationRegistry(
1670
1722
  ({ runtime: t, ptr: e }) => {
1671
1723
  t.exports.closeDecoder(e), t.unref();
1672
1724
  }
1673
1725
  );
1674
- var te = class extends z {
1726
+ var se = class extends H {
1675
1727
  constructor(e, r, o) {
1676
1728
  super();
1677
1729
  /** @internal */
@@ -1681,68 +1733,68 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1681
1733
  /** @internal */
1682
1734
  __publicField(this, "_taskStateOffset");
1683
1735
  /** @internal */
1684
- __publicField(this, "_decodeMutex", new y());
1736
+ __publicField(this, "_decodeMutex", new _());
1685
1737
  /** @internal */
1686
1738
  __publicField(this, "_nextPacketSlot", 0);
1687
1739
  /** @internal */
1688
- __publicField(this, "_packetSlotMutexes", [new y(), new y()]);
1740
+ __publicField(this, "_packetSlotMutexes", [new _(), new _()]);
1689
1741
  /** @internal */
1690
1742
  __publicField(this, "_highWaterMark");
1691
1743
  __publicField(this, "useSharedMemory", true);
1692
1744
  __publicField(this, "concurrency");
1693
- this._highWaterMark = o === 0 ? 1 : 2, this._runtime = e, this._decoderPtr = r, this._taskStateOffset = e.exports.getTaskStateAddress(r) / 4, this.concurrency = o, R.register(this, { runtime: e, ptr: r }, this);
1745
+ this._highWaterMark = o === 0 ? 1 : 2, this._runtime = e, this._decoderPtr = r, this._taskStateOffset = e.exports.getTaskStateAddress(r) / 4, this.concurrency = o, A.register(this, { runtime: e, ptr: r }, this);
1694
1746
  }
1695
1747
  _runClose() {
1696
- h(this._runtime), R.unregister(this), this._runtime.exports.closeDecoder(this._decoderPtr), this._runtime.unref(), this._runtime = null;
1748
+ c(this._runtime), A.unregister(this), this._runtime.exports.closeDecoder(this._decoderPtr), this._runtime.unref(), this._runtime = null;
1697
1749
  }
1698
1750
  async _runDecode(e, r, o) {
1699
- h(this._runtime);
1751
+ c(this._runtime);
1700
1752
  const { exports: i, memory: s } = this._runtime;
1701
1753
  if (!r._ensureWasmFrame(this._runtime))
1702
- return new p();
1754
+ return new y();
1703
1755
  const n = r._ptr;
1704
1756
  o.transfer && (e = structuredClone(e, { transfer: [e.buffer] }));
1705
1757
  const a = this._nextPacketSlot;
1706
1758
  this._nextPacketSlot = this._nextPacketSlot + 1 & 1;
1707
- const c = await this._packetSlotMutexes[a].acquire();
1759
+ const d = await this._packetSlotMutexes[a].acquire();
1708
1760
  try {
1709
- const d = i.allocatePacket(this._decoderPtr, e.byteLength, a);
1710
- if (d === 0)
1711
- return new p();
1712
- new Uint8Array(s.buffer).set(e, d);
1713
- const u = await this._decodeMutex.acquire();
1761
+ const u = i.allocatePacket(this._decoderPtr, e.byteLength, a);
1762
+ if (u === 0)
1763
+ return new y();
1764
+ new Uint8Array(s.buffer).set(e, u);
1765
+ const h = await this._decodeMutex.acquire();
1714
1766
  try {
1715
1767
  let f = i.decodePacket(this._decoderPtr, n, a);
1716
1768
  if (f < 0)
1717
1769
  return this._createError(f);
1718
1770
  if (this.concurrency > 0 && (await Atomics.waitAsync(new Int32Array(s.buffer), this._taskStateOffset, 1).value, f = i.finalizePacketDecoding(this._decoderPtr), f < 0))
1719
1771
  return this._createError(f);
1720
- r._populate(Y(i, s, n, this._decoderPtr));
1772
+ r._populate(K(i, s, n, this._decoderPtr));
1721
1773
  } finally {
1722
- u();
1774
+ h();
1723
1775
  }
1724
1776
  } finally {
1725
- c();
1777
+ d();
1726
1778
  }
1727
1779
  return r;
1728
1780
  }
1729
1781
  /** @internal */
1730
1782
  _createError(e) {
1731
- h(this._runtime);
1783
+ c(this._runtime);
1732
1784
  const { exports: r, memory: o } = this._runtime;
1733
1785
  let i;
1734
1786
  const s = r.getErrorMessagePtr(this._decoderPtr);
1735
1787
  if (s !== 0) {
1736
1788
  const n = r.getErrorMessageSize(this._decoderPtr);
1737
- i = T(new Uint8Array(o.buffer, s, n));
1789
+ i = U(new Uint8Array(o.buffer, s, n));
1738
1790
  }
1739
- return W(e, i);
1791
+ return T(e, i);
1740
1792
  }
1741
1793
  };
1742
- var A = new FinalizationRegistry((t) => {
1794
+ var W = new FinalizationRegistry((t) => {
1743
1795
  t.unref();
1744
1796
  });
1745
- var oe = class extends z {
1797
+ var ie = class extends H {
1746
1798
  constructor(e, r, o, i) {
1747
1799
  super();
1748
1800
  /** @internal */
@@ -1753,34 +1805,34 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1753
1805
  __publicField(this, "_highWaterMark");
1754
1806
  __publicField(this, "useSharedMemory", false);
1755
1807
  __publicField(this, "concurrency");
1756
- this._highWaterMark = Math.max(r, 1), this._runtime = e, this.concurrency = r, this._decoderId = e.nextDecoderId++, e.registerDecoder(this._decoderId, o, i), A.register(this, e, this);
1808
+ this._highWaterMark = Math.max(r, 1), this._runtime = e, this.concurrency = r, this._decoderId = e.nextDecoderId++, e.registerDecoder(this._decoderId, o, i), W.register(this, e, this);
1757
1809
  }
1758
1810
  _runClose() {
1759
- h(this._runtime), this._runtime.unregisterDecoder(this._decoderId), A.unregister(this), this._runtime.unref(), this._runtime = null;
1811
+ c(this._runtime), this._runtime.unregisterDecoder(this._decoderId), W.unregister(this), this._runtime.unref(), this._runtime = null;
1760
1812
  }
1761
1813
  _runDecode(e, r, o) {
1762
- h(this._runtime);
1814
+ c(this._runtime);
1763
1815
  const i = this._runtime, s = o.transfer ? e : e.slice();
1764
1816
  let n = 0;
1765
- for (let u = 1; u < i.workerLoad.length; u++)
1766
- i.workerLoad[u] < i.workerLoad[n] && (n = u);
1817
+ for (let h = 1; h < i.workerLoad.length; h++)
1818
+ i.workerLoad[h] < i.workerLoad[n] && (n = h);
1767
1819
  const a = i.workers[n];
1768
1820
  i.workerLoad[n] = i.workerLoad[n] + 1;
1769
- const c = i.nextRequestId++, d = r._buffer;
1770
- return r._buffer = null, new Promise((u) => {
1821
+ const d = i.nextRequestId++, u = r._buffer;
1822
+ return r._buffer = null, new Promise((h) => {
1771
1823
  a.postMessage(
1772
1824
  {
1773
1825
  type: l.Decode,
1774
- id: c,
1826
+ id: d,
1775
1827
  decoderId: this._decoderId,
1776
1828
  packet: s,
1777
- frameBuffer: d
1829
+ frameBuffer: u
1778
1830
  },
1779
- d ? [s.buffer, d] : [s.buffer]
1831
+ u ? [s.buffer, u] : [s.buffer]
1780
1832
  );
1781
- const f = (B) => {
1782
- const m = B.data;
1783
- m.type !== l.Decoded && m.type !== l.DecodeError || m.id === c && (a.removeEventListener("message", f), i.workerLoad[n]--, m.type === l.DecodeError ? u(W(m.code, m.message)) : (r._buffer = m.contents.frameData.buffer, r._populate(m.contents), u(r)));
1833
+ const f = (N) => {
1834
+ const m = N.data;
1835
+ m.type !== l.Decoded && m.type !== l.DecodeError || m.id === d && (a.removeEventListener("message", f), i.workerLoad[n]--, m.type === l.DecodeError ? h(T(m.code, m.message)) : (r._buffer = m.contents.frameData.buffer, r._populate(m.contents), h(r)));
1784
1836
  };
1785
1837
  a.addEventListener("message", f);
1786
1838
  });
@@ -1828,7 +1880,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1828
1880
  static _determineSupportedVideoFrameFormats() {
1829
1881
  const result = [];
1830
1882
  const data = new Uint8Array(32);
1831
- for (const format of g) {
1883
+ for (const format of p) {
1832
1884
  try {
1833
1885
  const frame = new VideoFrame(data, {
1834
1886
  format,
@@ -1848,9 +1900,9 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1848
1900
  if (typeof VideoFrame !== "undefined") {
1849
1901
  _ProresDecoder._supportedVideoFrameFormats ??= _ProresDecoder._determineSupportedVideoFrameFormats();
1850
1902
  }
1851
- const decoder = await z.create({
1903
+ const decoder = await H.create({
1852
1904
  proresFourCc: this.config.codec,
1853
- useSharedMemory: z.canUseSharedMemory(),
1905
+ useSharedMemory: H.canUseSharedMemory(),
1854
1906
  allowedOutputFormats: _ProresDecoder._supportedVideoFrameFormats ?? void 0
1855
1907
  });
1856
1908
  if (decoder instanceof Error) {
@@ -1871,7 +1923,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1871
1923
  if (this.framePool.length > 0) {
1872
1924
  frame = this.framePool.shift();
1873
1925
  } else {
1874
- frame = new X();
1926
+ frame = new J();
1875
1927
  }
1876
1928
  const result = await this.decoder.decode(packet.data, frame);
1877
1929
  this.framePool.push(frame);