@mediabunny/prores 1.50.0 → 1.50.1

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 CHANGED
@@ -28,6 +28,25 @@ Alternatively, directly include them using a script tag:
28
28
 
29
29
  This will expose the global objects `Mediabunny` and `MediabunnyProres`. Use `mediabunny-prores.d.ts` to provide types for these globals. You can download the built distribution files from the [releases page](https://github.com/Vanilagy/mediabunny/releases).
30
30
 
31
+ ## Setup
32
+
33
+ `@mediabunny/prores` can make use of shared-memory multithreading to achieve maximum performance. To enable this in browsers, your website must be cross-origin isolated by setting the following response headers:
34
+ ```
35
+ Cross-Origin-Opener-Policy: same-origin
36
+ Cross-Origin-Embedder-Policy: require-corp
37
+ ```
38
+
39
+ Alternatively, you can use:
40
+ ```
41
+ Cross-Origin-Opener-Policy: same-origin
42
+ Cross-Origin-Embedder-Policy: credentialless
43
+ ```
44
+ which is generally more permissive but is not supported in Safari (of course).
45
+
46
+ ---
47
+
48
+ If you cannot enable cross-origin isolation, `@mediabunny/prores` will fall back to a slower multithreading algorithm.
49
+
31
50
  ## Usage
32
51
 
33
52
  ```ts
@@ -47,18 +47,6 @@ var MediabunnyProres = (() => {
47
47
  }
48
48
  });
49
49
 
50
- // (disabled):node:worker_threads
51
- var require_node_worker_threads = __commonJS({
52
- "(disabled):node:worker_threads"() {
53
- }
54
- });
55
-
56
- // (disabled):node:os
57
- var require_node_os = __commonJS({
58
- "(disabled):node:os"() {
59
- }
60
- });
61
-
62
50
  // packages/prores/src/index.ts
63
51
  var index_exports = {};
64
52
  __export(index_exports, {
@@ -72,12 +60,12 @@ var MediabunnyProres = (() => {
72
60
  super(e), this.name = "OutOfMemoryError";
73
61
  }
74
62
  };
75
- var z = class extends Error {
63
+ var B = class extends Error {
76
64
  constructor(e = "Invalid data: the packet ended before the decoder expected it to.") {
77
65
  super(e), this.name = "UnexpectedEofError";
78
66
  }
79
67
  };
80
- var D = class extends Error {
68
+ var k = class extends Error {
81
69
  constructor(e = "The packet contains invalid data.") {
82
70
  super(e), this.name = "InvalidDataError";
83
71
  }
@@ -87,12 +75,12 @@ var MediabunnyProres = (() => {
87
75
  super(e), this.name = "NotSupportedError";
88
76
  }
89
77
  };
90
- var B = class extends Error {
78
+ var H = class extends Error {
91
79
  constructor(e = "The decoder is in an invalid internal state. This should never happen! Please report.") {
92
80
  super(e), this.name = "InvalidStateError";
93
81
  }
94
82
  };
95
- var H = class extends Error {
83
+ var N = class extends Error {
96
84
  constructor(e = "The decoder has been closed.") {
97
85
  super(e), this.name = "DecoderClosedError";
98
86
  }
@@ -107,16 +95,16 @@ var MediabunnyProres = (() => {
107
95
  case -1:
108
96
  return new g(e);
109
97
  case -2:
110
- return new z(e);
98
+ return new B(e);
111
99
  case -3:
112
- return new D(e);
100
+ return new k(e);
113
101
  case -4:
114
102
  return new A(e);
115
103
  case -5:
116
- return new B(e);
104
+ return new H(e);
117
105
  // Overflow is just another flavor of invalid data
118
106
  case -6:
119
- return new D(e ?? "Unexpected integer overflow.");
107
+ return new k(e ?? "Unexpected integer overflow.");
120
108
  default:
121
109
  throw new Error(`Unhandled error code: ${t}`);
122
110
  }
@@ -151,7 +139,7 @@ var MediabunnyProres = (() => {
151
139
  }
152
140
  return r;
153
141
  };
154
- var N = class {
142
+ var j = class {
155
143
  constructor() {
156
144
  __publicField(this, "currentPromise", Promise.resolve());
157
145
  __publicField(this, "pending", 0);
@@ -167,7 +155,8 @@ var MediabunnyProres = (() => {
167
155
  return this.currentPromise = r, this.pending++, await o, e;
168
156
  }
169
157
  };
170
- var k = typeof SharedArrayBuffer < "u";
158
+ var D = typeof SharedArrayBuffer < "u";
159
+ var T = (t) => t;
171
160
  Symbol.dispose ??= Symbol("dispose");
172
161
  Symbol.asyncDispose ??= Symbol("asyncDispose");
173
162
  var w = [
@@ -196,14 +185,14 @@ var MediabunnyProres = (() => {
196
185
  "I444AP10",
197
186
  "I444AP12"
198
187
  ];
199
- var j = {
188
+ var Q = {
200
189
  1: "bt709",
201
190
  5: "bt470bg",
202
191
  6: "smpte170m",
203
192
  9: "bt2020",
204
193
  12: "smpte432"
205
194
  };
206
- var Q = {
195
+ var V = {
207
196
  1: "bt709",
208
197
  6: "smpte170m",
209
198
  8: "linear",
@@ -211,7 +200,7 @@ var MediabunnyProres = (() => {
211
200
  16: "pq",
212
201
  18: "hlg"
213
202
  };
214
- var V = {
203
+ var G = {
215
204
  0: "rgb",
216
205
  1: "bt709",
217
206
  5: "bt470bg",
@@ -221,7 +210,7 @@ var MediabunnyProres = (() => {
221
210
  var y = new FinalizationRegistry(({ runtime: t, ptr: e }) => {
222
211
  t.exports.closeFrame(e);
223
212
  });
224
- var G = class {
213
+ var X = class {
225
214
  constructor() {
226
215
  /**
227
216
  * The raw data of the decoded frame, stored in the format described by `pixelFormat`. All frame data is stored in
@@ -320,15 +309,15 @@ var MediabunnyProres = (() => {
320
309
  }
321
310
  /** {@link Frame.colorPrimaries} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
322
311
  get colorPrimariesString() {
323
- return this.colorPrimaries === null ? void 0 : j[this.colorPrimaries];
312
+ return this.colorPrimaries === null ? void 0 : Q[this.colorPrimaries];
324
313
  }
325
314
  /** {@link Frame.colorTransfer} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
326
315
  get colorTransferString() {
327
- return this.colorTransfer === null ? void 0 : Q[this.colorTransfer];
316
+ return this.colorTransfer === null ? void 0 : V[this.colorTransfer];
328
317
  }
329
318
  /** {@link Frame.colorMatrix} as a string compatible with the WebCodecs API, or `undefined` if none exists. */
330
319
  get colorMatrixString() {
331
- return this.colorMatrix === null ? void 0 : V[this.colorMatrix];
320
+ return this.colorMatrix === null ? void 0 : G[this.colorMatrix];
332
321
  }
333
322
  /** Whether this frame is locked by an in-flight decoding operation. While locked, it cannot be used or cleared. */
334
323
  get isLocked() {
@@ -375,7 +364,7 @@ var MediabunnyProres = (() => {
375
364
  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;
376
365
  }
377
366
  };
378
- var X = (t, e, r, o) => {
367
+ var Y = (t, e, r, o) => {
379
368
  const i = t.getFrameDataPtr(r), s = t.getFrameDataSize(r), n = new Uint8Array(e.buffer, i, s), c = w[t.getFramePixelFormat(r)];
380
369
  d(c !== void 0);
381
370
  const a = w[t.getOriginalPixelFormat(o)];
@@ -1285,7 +1274,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1285
1274
  \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
1286
1275
  ((((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
1287
1276
  \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`;
1288
- var Y = async (t, e) => {
1277
+ var J = async (t, e) => {
1289
1278
  const { instance: r } = await WebAssembly.instantiate(t, {
1290
1279
  env: {
1291
1280
  memory: e,
@@ -1308,13 +1297,13 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1308
1297
  m[t] = _.charCodeAt(t);
1309
1298
  return m;
1310
1299
  };
1311
- var T = async () => {
1300
+ var L = async () => {
1312
1301
  if (typeof Worker < "u" && !("Bun" in globalThis)) {
1313
1302
  const e = new Blob([S], { type: "text/javascript" }), r = URL.createObjectURL(e), o = new Worker(r, { type: "module" });
1314
1303
  return new x(o, null);
1315
1304
  }
1316
- const { Worker: t } = await Promise.resolve().then(() => __toESM(require_node_worker_threads(), 1));
1317
- return new x(null, new t(S, { eval: true }));
1305
+ const t = await import("node:" + T("worker_threads"));
1306
+ return new x(null, new t.Worker(S, { eval: true }));
1318
1307
  };
1319
1308
  var x = class {
1320
1309
  constructor(e, r) {
@@ -1343,16 +1332,16 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1343
1332
  for (const e of t)
1344
1333
  e.terminate();
1345
1334
  });
1346
- var J = async () => {
1335
+ var K = async () => {
1347
1336
  if (typeof navigator < "u" && navigator.hardwareConcurrency)
1348
1337
  return navigator.hardwareConcurrency;
1349
- const t = await Promise.resolve().then(() => __toESM(require_node_os(), 1));
1338
+ const t = await import("node:" + T("os"));
1350
1339
  return t.availableParallelism?.() ?? t.cpus().length;
1351
1340
  };
1352
1341
  var p = null;
1353
- var K = new N();
1354
- var Z = async () => {
1355
- const t = await K.acquire();
1342
+ var Z = new j();
1343
+ var $ = async () => {
1344
+ const t = await Z.acquire();
1356
1345
  try {
1357
1346
  if (p) {
1358
1347
  const r = p.deref();
@@ -1366,11 +1355,11 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1366
1355
  }
1367
1356
  };
1368
1357
  var v = null;
1369
- var $ = () => {
1358
+ var ee = () => {
1370
1359
  let t = v?.deref();
1371
- return t || (t = new ee(), v = new WeakRef(t)), t;
1360
+ return t || (t = new re(), v = new WeakRef(t)), t;
1372
1361
  };
1373
- var L = class {
1362
+ var U = class {
1374
1363
  constructor() {
1375
1364
  __publicField(this, "workers", []);
1376
1365
  // The number of decoders currently using this runtime
@@ -1389,12 +1378,12 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1389
1378
  this.workers.length = 0, E.unregister(this);
1390
1379
  }
1391
1380
  };
1392
- var P = class _P extends L {
1381
+ var P = class _P extends U {
1393
1382
  constructor(e, r) {
1394
1383
  super(), this.memory = e, this.exports = r;
1395
1384
  }
1396
1385
  static async init() {
1397
- const e = new WebAssembly.Memory({ initial: 32, maximum: 65536, shared: true }), r = await Y(b(), e), o = r.allocateThreadLocalState(r.__tls_size.value, r.__tls_align.value);
1386
+ 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);
1398
1387
  if (o === 0)
1399
1388
  throw new Error("Failed to allocate thread-local state.");
1400
1389
  r.__wasm_init_tls(o);
@@ -1409,7 +1398,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1409
1398
  );
1410
1399
  if (r === 0 || o === 0)
1411
1400
  throw new Error("Failed to allocate worker stack or thread-local state.");
1412
- const i = await T();
1401
+ const i = await L();
1413
1402
  i.postMessage({
1414
1403
  type: l.SharedMemoryInit,
1415
1404
  wasmBinary: b(),
@@ -1423,7 +1412,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1423
1412
  super.destroy(), p = null;
1424
1413
  }
1425
1414
  };
1426
- var ee = class extends L {
1415
+ var re = class extends U {
1427
1416
  constructor() {
1428
1417
  super(...arguments);
1429
1418
  // How many packets each worker currently has in flight
@@ -1456,7 +1445,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1456
1445
  return;
1457
1446
  const o = await Promise.all(
1458
1447
  Array.from({ length: r }, async () => {
1459
- const s = await T(), n = await new Promise((c) => {
1448
+ const s = await L(), n = await new Promise((c) => {
1460
1449
  s.postMessage({
1461
1450
  type: l.MessagePassingInit,
1462
1451
  wasmBinary: b()
@@ -1499,7 +1488,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1499
1488
  "apco"
1500
1489
  // ProRes 422 Proxy
1501
1490
  ];
1502
- var U = class {
1491
+ var q = class {
1503
1492
  constructor(e) {
1504
1493
  /** @internal */
1505
1494
  __publicField(this, "_closed", false);
@@ -1551,7 +1540,7 @@ lkA\bt rA\xB0\xE0\0r;\0\0 Aj!\v \0 Aj jA! k\xBD\x80\x80\x80\0! A0j$\x
1551
1540
  throw new TypeError(
1552
1541
  `options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${w.join(", ")}.`
1553
1542
  );
1554
- if (e.useSharedMemory && !k)
1543
+ if (e.useSharedMemory && !D)
1555
1544
  return new A(
1556
1545
  `Shared memory is not available in this environment, so useSharedMemory: true cannot be used.
1557
1546
  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).
@@ -1564,17 +1553,17 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1564
1553
  r |= 1 << w.indexOf(s);
1565
1554
  } else
1566
1555
  r = 4294967295;
1567
- const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await J();
1556
+ const o = e.proresFourCc === "ap4h" || e.proresFourCc === "ap4x" ? 12 : 10, i = e.concurrency ?? await K();
1568
1557
  if (e.useSharedMemory || i === 0) {
1569
- const s = await Z();
1558
+ const s = await $();
1570
1559
  s.ref(), await s.ensureWorkers(i);
1571
1560
  const n = s.exports.createDecoder(i, o, r);
1572
- return n === 0 ? (s.unref(), new g()) : new re(s, n, i);
1561
+ return n === 0 ? (s.unref(), new g()) : new te(s, n, i);
1573
1562
  } else {
1574
- const s = $();
1563
+ const s = ee();
1575
1564
  s.ref();
1576
1565
  const n = await s.ensureWorkers(i);
1577
- return n ? (s.unref(), n) : new te(
1566
+ return n ? (s.unref(), n) : new oe(
1578
1567
  s,
1579
1568
  i,
1580
1569
  o,
@@ -1584,7 +1573,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1584
1573
  }
1585
1574
  /** Whether the environment supports proper shared-memory multithreading. */
1586
1575
  static canUseSharedMemory() {
1587
- return k;
1576
+ return D;
1588
1577
  }
1589
1578
  /**
1590
1579
  * Queues a ProRes packet for decoding with the given options. The decoded result will be stored in the passed
@@ -1595,14 +1584,14 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1595
1584
  async decode(e, r, o = {}) {
1596
1585
  if (!(e instanceof Uint8Array))
1597
1586
  throw new TypeError("packetData must be a Uint8Array.");
1598
- if (!(r instanceof G))
1587
+ if (!(r instanceof X))
1599
1588
  throw new TypeError("frame must be a Frame.");
1600
1589
  if (typeof o != "object" || !o)
1601
1590
  throw new TypeError("options must be an object.");
1602
1591
  if (o.transfer !== void 0 && typeof o.transfer != "boolean")
1603
1592
  throw new TypeError("options.transfer, when provided, must be a boolean.");
1604
1593
  if (this._closed)
1605
- return new H();
1594
+ return new N();
1606
1595
  if (r._locked)
1607
1596
  return new C();
1608
1597
  r._reset(), r._locked = true, this._decodeQueueSize++;
@@ -1641,7 +1630,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1641
1630
  t.exports.closeDecoder(e), t.unref();
1642
1631
  }
1643
1632
  );
1644
- var re = class extends U {
1633
+ var te = class extends q {
1645
1634
  constructor(e, r, o) {
1646
1635
  super(false);
1647
1636
  /** @internal */
@@ -1669,7 +1658,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1669
1658
  return new g();
1670
1659
  new Uint8Array(s.buffer).set(e, c);
1671
1660
  let a = i.decodePacket(this._decoderPtr, n);
1672
- 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(X(i, s, n, this._decoderPtr)), r);
1661
+ 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);
1673
1662
  }
1674
1663
  /** @internal */
1675
1664
  _createError(e) {
@@ -1687,7 +1676,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1687
1676
  var R = new FinalizationRegistry((t) => {
1688
1677
  t.unref();
1689
1678
  });
1690
- var te = class extends U {
1679
+ var oe = class extends q {
1691
1680
  constructor(e, r, o, i) {
1692
1681
  super(true);
1693
1682
  /** @internal */
@@ -1721,8 +1710,8 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1721
1710
  },
1722
1711
  f ? [s.buffer, f] : [s.buffer]
1723
1712
  );
1724
- const I = (q) => {
1725
- const u = q.data;
1713
+ const I = (z) => {
1714
+ const u = z.data;
1726
1715
  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)));
1727
1716
  };
1728
1717
  c.addEventListener("message", I);
@@ -1788,9 +1777,9 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1788
1777
  if (typeof VideoFrame !== "undefined") {
1789
1778
  _ProresDecoder._supportedVideoFrameFormats ??= _ProresDecoder._determineSupportedVideoFrameFormats();
1790
1779
  }
1791
- const decoder = await U.create({
1780
+ const decoder = await q.create({
1792
1781
  proresFourCc: this.config.codec,
1793
- useSharedMemory: U.canUseSharedMemory(),
1782
+ useSharedMemory: q.canUseSharedMemory(),
1794
1783
  allowedOutputFormats: _ProresDecoder._supportedVideoFrameFormats ?? void 0
1795
1784
  });
1796
1785
  if (decoder instanceof Error) {
@@ -1815,7 +1804,7 @@ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`
1815
1804
  if (this.framePool.length > 0) {
1816
1805
  frame = this.framePool.shift();
1817
1806
  } else {
1818
- frame = new G();
1807
+ frame = new X();
1819
1808
  }
1820
1809
  const result = await this.decoder.decode(packet.data, frame);
1821
1810
  this.framePool.push(frame);
@@ -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
- "use strict";var MediabunnyProres=(()=>{var cr=Object.create;var y=Object.defineProperty;var dr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var mr=Object.getPrototypeOf,hr=Object.prototype.hasOwnProperty;var fr=(A,r,e)=>r in A?y(A,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):A[r]=e;var S=(A,r)=>()=>(r||A((r={exports:{}}).exports,r),r.exports),pr=(A,r)=>{for(var e in r)y(A,e,{get:r[e],enumerable:!0})},L=(A,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of ur(r))!hr.call(A,n)&&n!==e&&y(A,n,{get:()=>r[n],enumerable:!(t=dr(r,n))||t.enumerable});return A};var x=(A,r,e)=>(e=A!=null?cr(mr(A)):{},L(r||!A||!A.__esModule?y(e,"default",{value:A,enumerable:!0}):e,A)),gr=A=>L(y({},"__esModule",{value:!0}),A);var j=(A,r,e)=>fr(A,typeof r!="symbol"?r+"":r,e);var X=S((Sr,Z)=>{Z.exports=Mediabunny});var Y=S(()=>{});var J=S(()=>{});var kr={};pr(kr,{registerProresDecoder:()=>Fr});var u=x(X());var f=class extends Error{constructor(r="The decoder ran out of memory."){super(r),this.name="OutOfMemoryError"}},R=class extends Error{constructor(r="Invalid data: the packet ended before the decoder expected it to."){super(r),this.name="UnexpectedEofError"}},E=class extends Error{constructor(r="The packet contains invalid data."){super(r),this.name="InvalidDataError"}},C=class extends Error{constructor(r="The packet uses a feature that is not supported."){super(r),this.name="NotSupportedError"}},_=class extends Error{constructor(r="The decoder is in an invalid internal state. This should never happen! Please report."){super(r),this.name="InvalidStateError"}},$=class extends Error{constructor(r="The decoder has been closed."){super(r),this.name="DecoderClosedError"}},F=class extends Error{constructor(r="The frame is locked by an in-flight decoding operation."){super(r),this.name="FrameLockedError"}},or=(A,r)=>{switch(A){case-1:return new f(r);case-2:return new R(r);case-3:return new E(r);case-4:return new C(r);case-5:return new _(r);case-6:return new E(r??"Unexpected integer overflow.");default:throw new Error(`Unhandled error code: ${A}`)}};function d(A){if(!A)throw new Error("Assertion failed.")}var jr=A=>{let r=0,e="";for(;r<A.length;){let t=A[r++];if(t>127)if(t>191&&t<224){if(r>=A.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");t=(t&31)<<6|A[r++]&63}else if(t>223&&t<240){if(r+1>=A.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");t=(t&15)<<12|(A[r++]&63)<<6|A[r++]&63}else if(t>239&&t<248){if(r+2>=A.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");t=(t&7)<<18|(A[r++]&63)<<12|(A[r++]&63)<<6|A[r++]&63}else throw new Error("UTF-8 decode: unknown multibyte start 0x"+t.toString(16)+" at index "+(r-1));if(t<=65535)e+=String.fromCharCode(t);else if(t<=1114111)t-=65536,e+=String.fromCharCode(t>>10|55296),e+=String.fromCharCode(t&1023|56320);else throw new Error("UTF-8 decode: code point 0x"+t.toString(16)+" exceeds UTF-16 reach")}return e},U=class{constructor(){j(this,"currentPromise",Promise.resolve());j(this,"pending",0)}async acquire(){let r,e=new Promise(n=>{let o=!1;r=()=>{o||(n(),this.pending--,o=!0)}}),t=this.currentPromise;return this.currentPromise=e,this.pending++,await t,r}},z=typeof SharedArrayBuffer<"u";Symbol.dispose??=Symbol("dispose");Symbol.asyncDispose??=Symbol("asyncDispose");var h=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12"],br={1:"bt709",5:"bt470bg",6:"smpte170m",9:"bt2020",12:"smpte432"},yr={1:"bt709",6:"smpte170m",8:"linear",13:"iec61966-2-1",16:"pq",18:"hlg"},Ir={0:"rgb",1:"bt709",5:"bt470bg",6:"smpte170m",9:"bt2020-ncl"},D=new FinalizationRegistry(({runtime:A,ptr:r})=>{A.exports.closeFrame(r)}),v=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:br[this.colorPrimaries]}get colorTransferString(){return this.colorTransfer===null?void 0:yr[this.colorTransfer]}get colorMatrixString(){return this.colorMatrix===null?void 0:Ir[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 F;this._ptr!==null&&(d(this._runtime),D.unregister(this),this._runtime.exports.closeFrame(this._ptr),this._runtime=null,this._ptr=null),this._buffer=null,this._reset()}[Symbol.dispose](){this.clear()}_ensureWasmFrame(r){if(this._runtime===r)return!0;this._runtime&&(D.unregister(this),this._runtime.exports.closeFrame(this._ptr),this._runtime=null,this._ptr=null);let e=r.exports.createFrame();return e===0?!1:(this._runtime=r,this._ptr=e,D.register(this,{runtime:r,ptr:e},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(r){this.frameData=r.frameData,this.codedWidth=r.codedWidth,this.codedHeight=r.codedHeight,this.visibleWidth=r.visibleWidth,this.visibleHeight=r.visibleHeight,this.pixelFormat=r.pixelFormat,this.originalPixelFormat=r.originalPixelFormat,this.pixelAspectRatio=r.pixelAspectRatio,this.colorPrimaries=r.colorPrimaries,this.colorTransfer=r.colorTransfer,this.colorMatrix=r.colorMatrix,this.colorRangeFull=r.colorRangeFull,this.scanType=r.scanType}},vr=(A,r,e,t)=>{let n=A.getFrameDataPtr(e),o=A.getFrameDataSize(e),i=new Uint8Array(r.buffer,n,o),s=h[A.getFramePixelFormat(e)];d(s!==void 0);let a=h[A.getOriginalPixelFormat(t)];d(a!==void 0);let B=["progressive","interlaced-top-field-first","interlaced-bottom-field-first"][A.getScanType(e)];return d(B!==void 0),{frameData:i,codedWidth:A.getCodedWidth(e),codedHeight:A.getCodedHeight(e),visibleWidth:A.getVisibleWidth(e),visibleHeight:A.getVisibleHeight(e),pixelFormat:s,originalPixelFormat:a,pixelAspectRatio:{num:A.getAspectRatioNum(e),den:A.getAspectRatioDen(e)},colorPrimaries:A.getColorPrimaries(e),colorTransfer:A.getColorTransfer(e),colorMatrix:A.getColorMatrix(e),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||{}),O=`\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\`
8
+ "use strict";var MediabunnyProres=(()=>{var Br=Object.create;var y=Object.defineProperty;var ar=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var cr=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty;var ur=(A,r,e)=>r in A?y(A,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):A[r]=e;var mr=(A,r)=>()=>(r||A((r={exports:{}}).exports,r),r.exports),hr=(A,r)=>{for(var e in r)y(A,e,{get:r[e],enumerable:!0})},K=(A,r,e,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of lr(r))!dr.call(A,n)&&n!==e&&y(A,n,{get:()=>r[n],enumerable:!(t=ar(r,n))||t.enumerable});return A};var fr=(A,r,e)=>(e=A!=null?Br(cr(A)):{},K(r||!A||!A.__esModule?y(e,"default",{value:A,enumerable:!0}):e,A)),pr=A=>K(y({},"__esModule",{value:!0}),A);var j=(A,r,e)=>ur(A,typeof r!="symbol"?r+"":r,e);var L=mr((qr,Q)=>{Q.exports=Mediabunny});var Fr={};hr(Fr,{registerProresDecoder:()=>Cr});var u=fr(L());var f=class extends Error{constructor(r="The decoder ran out of memory."){super(r),this.name="OutOfMemoryError"}},D=class extends Error{constructor(r="Invalid data: the packet ended before the decoder expected it to."){super(r),this.name="UnexpectedEofError"}},E=class extends Error{constructor(r="The packet contains invalid data."){super(r),this.name="InvalidDataError"}},C=class extends Error{constructor(r="The packet uses a feature that is not supported."){super(r),this.name="NotSupportedError"}},O=class extends Error{constructor(r="The decoder is in an invalid internal state. This should never happen! Please report."){super(r),this.name="InvalidStateError"}},R=class extends Error{constructor(r="The decoder has been closed."){super(r),this.name="DecoderClosedError"}},F=class extends Error{constructor(r="The frame is locked by an in-flight decoding operation."){super(r),this.name="FrameLockedError"}},er=(A,r)=>{switch(A){case-1:return new f(r);case-2:return new D(r);case-3:return new E(r);case-4:return new C(r);case-5:return new O(r);case-6:return new E(r??"Unexpected integer overflow.");default:throw new Error(`Unhandled error code: ${A}`)}};function d(A){if(!A)throw new Error("Assertion failed.")}var Ar=A=>{let r=0,e="";for(;r<A.length;){let t=A[r++];if(t>127)if(t>191&&t<224){if(r>=A.length)throw new Error("UTF-8 decode: incomplete 2-byte sequence");t=(t&31)<<6|A[r++]&63}else if(t>223&&t<240){if(r+1>=A.length)throw new Error("UTF-8 decode: incomplete 3-byte sequence");t=(t&15)<<12|(A[r++]&63)<<6|A[r++]&63}else if(t>239&&t<248){if(r+2>=A.length)throw new Error("UTF-8 decode: incomplete 4-byte sequence");t=(t&7)<<18|(A[r++]&63)<<12|(A[r++]&63)<<6|A[r++]&63}else throw new Error("UTF-8 decode: unknown multibyte start 0x"+t.toString(16)+" at index "+(r-1));if(t<=65535)e+=String.fromCharCode(t);else if(t<=1114111)t-=65536,e+=String.fromCharCode(t>>10|55296),e+=String.fromCharCode(t&1023|56320);else throw new Error("UTF-8 decode: code point 0x"+t.toString(16)+" exceeds UTF-16 reach")}return e},_=class{constructor(){j(this,"currentPromise",Promise.resolve());j(this,"pending",0)}async acquire(){let r,e=new Promise(n=>{let o=!1;r=()=>{o||(n(),this.pending--,o=!0)}}),t=this.currentPromise;return this.currentPromise=e,this.pending++,await t,r}},Z=typeof SharedArrayBuffer<"u",tr=A=>A;Symbol.dispose??=Symbol("dispose");Symbol.asyncDispose??=Symbol("asyncDispose");var h=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12"],gr={1:"bt709",5:"bt470bg",6:"smpte170m",9:"bt2020",12:"smpte432"},br={1:"bt709",6:"smpte170m",8:"linear",13:"iec61966-2-1",16:"pq",18:"hlg"},yr={0:"rgb",1:"bt709",5:"bt470bg",6:"smpte170m",9:"bt2020-ncl"},S=new FinalizationRegistry(({runtime:A,ptr:r})=>{A.exports.closeFrame(r)}),v=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:gr[this.colorPrimaries]}get colorTransferString(){return this.colorTransfer===null?void 0:br[this.colorTransfer]}get colorMatrixString(){return this.colorMatrix===null?void 0:yr[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 F;this._ptr!==null&&(d(this._runtime),S.unregister(this),this._runtime.exports.closeFrame(this._ptr),this._runtime=null,this._ptr=null),this._buffer=null,this._reset()}[Symbol.dispose](){this.clear()}_ensureWasmFrame(r){if(this._runtime===r)return!0;this._runtime&&(S.unregister(this),this._runtime.exports.closeFrame(this._ptr),this._runtime=null,this._ptr=null);let e=r.exports.createFrame();return e===0?!1:(this._runtime=r,this._ptr=e,S.register(this,{runtime:r,ptr:e},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(r){this.frameData=r.frameData,this.codedWidth=r.codedWidth,this.codedHeight=r.codedHeight,this.visibleWidth=r.visibleWidth,this.visibleHeight=r.visibleHeight,this.pixelFormat=r.pixelFormat,this.originalPixelFormat=r.originalPixelFormat,this.pixelAspectRatio=r.pixelAspectRatio,this.colorPrimaries=r.colorPrimaries,this.colorTransfer=r.colorTransfer,this.colorMatrix=r.colorMatrix,this.colorRangeFull=r.colorRangeFull,this.scanType=r.scanType}},Ir=(A,r,e,t)=>{let n=A.getFrameDataPtr(e),o=A.getFrameDataSize(e),i=new Uint8Array(r.buffer,n,o),s=h[A.getFramePixelFormat(e)];d(s!==void 0);let a=h[A.getOriginalPixelFormat(t)];d(a!==void 0);let B=["progressive","interlaced-top-field-first","interlaced-bottom-field-first"][A.getScanType(e)];return d(B!==void 0),{frameData:i,codedWidth:A.getCodedWidth(e),codedHeight:A.getCodedHeight(e),visibleWidth:A.getVisibleWidth(e),visibleHeight:A.getVisibleHeight(e),pixelFormat:s,originalPixelFormat:a,pixelAspectRatio:{num:A.getAspectRatioNum(e),den:A.getAspectRatioDen(e)},colorPrimaries:A.getColorPrimaries(e),colorTransfer:A.getColorTransfer(e),colorMatrix:A.getColorMatrix(e),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||{}),x=`\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,9 +883,9 @@ 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`,Tr=async(A,r)=>{let{instance:e}=await WebAssembly.instantiate(A,{env:{memory:r,externPrint:(t,n)=>{let o=new Uint8Array(r.buffer,t,n);console.log(jr(o))}}});return e.exports},rr=`"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
- `,I=null,M=()=>{if(I)return I;I=new Uint8Array(O.length);for(let A=0;A<O.length;A++)I[A]=O.charCodeAt(A);return I},ir=async()=>{if(typeof Worker<"u"&&!("Bun"in globalThis)){let r=new Blob([rr],{type:"text/javascript"}),e=URL.createObjectURL(r),t=new Worker(e,{type:"module"});return new k(t,null)}let{Worker:A}=await Promise.resolve().then(()=>x(Y(),1));return new k(null,new A(rr,{eval:!0}))},k=class{constructor(r,e){j(this,"wrappedListeners",new Map);this.webWorker=r,this.nodeWorker=e}postMessage(r,e){this.webWorker?this.webWorker.postMessage(r,{transfer:e??[]}):this.nodeWorker.postMessage(r,e??[])}addEventListener(r,e,t){if(this.webWorker)this.webWorker.addEventListener(r,e,t);else{let n=o=>e({data:o});this.wrappedListeners.set(e,n),t?.once?this.nodeWorker.once(r,n):this.nodeWorker.on(r,n)}}removeEventListener(r,e){this.webWorker?this.webWorker.removeEventListener(r,e):(this.nodeWorker.off(r,this.wrappedListeners.get(e)),this.wrappedListeners.delete(e))}terminate(){this.webWorker?this.webWorker.terminate():this.nodeWorker.terminate()}},er=new FinalizationRegistry(A=>{for(let r of A)r.terminate()}),Pr=async()=>{if(typeof navigator<"u"&&navigator.hardwareConcurrency)return navigator.hardwareConcurrency;let A=await Promise.resolve().then(()=>x(J(),1));return A.availableParallelism?.()??A.cpus().length},w=null,wr=new U,Er=async()=>{let A=await wr.acquire();try{if(w){let e=w.deref();if(e)return e}let r=await V.init();return w=new WeakRef(r),r}finally{A()}},N=null,Cr=()=>{let A=N?.deref();return A||(A=new W,N=new WeakRef(A)),A},q=class{constructor(){j(this,"workers",[]);j(this,"refCount",0);er.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 r of this.workers)r.terminate();this.workers.length=0,er.unregister(this)}},V=class A extends q{constructor(r,e){super(),this.memory=r,this.exports=e}static async init(){let r=new WebAssembly.Memory({initial:32,maximum:65536,shared:!0}),e=await Tr(M(),r),t=e.allocateThreadLocalState(e.__tls_size.value,e.__tls_align.value);if(t===0)throw new Error("Failed to allocate thread-local state.");e.__wasm_init_tls(t);let n=typeof window<"u"&&typeof document<"u"&&self===window;return e.setIsBrowserMainThread(Number(n)),new A(r,e)}async ensureWorkers(r){for(;this.workers.length<r;){let e=this.exports.allocateWorkerStack(),t=this.exports.allocateThreadLocalState(this.exports.__tls_size.value,this.exports.__tls_align.value);if(e===0||t===0)throw new Error("Failed to allocate worker stack or thread-local state.");let n=await ir();n.postMessage({type:c.SharedMemoryInit,wasmBinary:M(),memory:this.memory,stackPointer:e,tlsPointer:t}),this.workers.push(n)}}destroy(){super.destroy(),w=null}},W=class extends q{constructor(){super(...arguments);j(this,"workerLoad",[]);j(this,"nextRequestId",0);j(this,"nextDecoderId",0);j(this,"registeredDecoders",new Map)}registerDecoder(e,t,n){this.registeredDecoders.set(e,{bitDepth:t,allowedOutputFormats:n});for(let o of this.workers)o.postMessage({type:c.CreateDecoder,decoderId:e,bitDepth:t,allowedOutputFormats:n})}unregisterDecoder(e){this.registeredDecoders.delete(e);for(let t of this.workers)t.postMessage({type:c.CloseDecoder,decoderId:e})}async ensureWorkers(e){let t=e-this.workers.length;if(t<=0)return;let n=await Promise.all(Array.from({length:t},async()=>{let i=await ir(),s=await new Promise(a=>{i.postMessage({type:c.MessagePassingInit,wasmBinary:M()}),i.addEventListener("message",B=>a(B.data),{once:!0})});return s.type===c.InitOutOfMemoryError?(i.terminate(),new f(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(),N=null}},Ar=["ap4x","ap4h","apch","apcn","apcs","apco"],p=class{constructor(r){j(this,"_closed",!1);j(this,"_queue",Promise.resolve());j(this,"_concurrentDecode");j(this,"_decodeQueueSize",0);j(this,"_dequeuedResolve");j(this,"_dequeued",new Promise(r=>{this._dequeuedResolve=r}));this._concurrentDecode=r}get decodeQueueSize(){return this._decodeQueueSize}get dequeued(){return this._dequeued}_markDequeued(){this._decodeQueueSize--,this._dequeuedResolve(),this._dequeued=new Promise(r=>{this._dequeuedResolve=r})}static async create(r){if(typeof r!="object"||!r)throw new TypeError("options must be an object.");if(!Ar.includes(r.proresFourCc))throw new TypeError(`options.proresFourCc must be one of ${Ar.join(", ")}.`);if(typeof r.useSharedMemory!="boolean")throw new TypeError("options.useSharedMemory must be a boolean.");if(r.concurrency!==void 0&&(!Number.isInteger(r.concurrency)||r.concurrency<0))throw new TypeError("options.concurrency, when provided, must be a non-negative integer.");if(r.allowedOutputFormats&&!(Array.isArray(r.allowedOutputFormats)&&r.allowedOutputFormats.length>0&&r.allowedOutputFormats.every(o=>h.includes(o))))throw new TypeError(`options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${h.join(", ")}.`);if(r.useSharedMemory&&!z)return new C(`Shared memory is not available in this environment, so useSharedMemory: true cannot be used.
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`,vr=async(A,r)=>{let{instance:e}=await WebAssembly.instantiate(A,{env:{memory:r,externPrint:(t,n)=>{let o=new Uint8Array(r.buffer,t,n);console.log(Ar(o))}}});return e.exports},X=`"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
+ `,I=null,$=()=>{if(I)return I;I=new Uint8Array(x.length);for(let A=0;A<x.length;A++)I[A]=x.charCodeAt(A);return I},nr=async()=>{if(typeof Worker<"u"&&!("Bun"in globalThis)){let r=new Blob([X],{type:"text/javascript"}),e=URL.createObjectURL(r),t=new Worker(e,{type:"module"});return new k(t,null)}let A=await import("node:"+tr("worker_threads"));return new k(null,new A.Worker(X,{eval:!0}))},k=class{constructor(r,e){j(this,"wrappedListeners",new Map);this.webWorker=r,this.nodeWorker=e}postMessage(r,e){this.webWorker?this.webWorker.postMessage(r,{transfer:e??[]}):this.nodeWorker.postMessage(r,e??[])}addEventListener(r,e,t){if(this.webWorker)this.webWorker.addEventListener(r,e,t);else{let n=o=>e({data:o});this.wrappedListeners.set(e,n),t?.once?this.nodeWorker.once(r,n):this.nodeWorker.on(r,n)}}removeEventListener(r,e){this.webWorker?this.webWorker.removeEventListener(r,e):(this.nodeWorker.off(r,this.wrappedListeners.get(e)),this.wrappedListeners.delete(e))}terminate(){this.webWorker?this.webWorker.terminate():this.nodeWorker.terminate()}},Y=new FinalizationRegistry(A=>{for(let r of A)r.terminate()}),Tr=async()=>{if(typeof navigator<"u"&&navigator.hardwareConcurrency)return navigator.hardwareConcurrency;let A=await import("node:"+tr("os"));return A.availableParallelism?.()??A.cpus().length},P=null,wr=new _,Pr=async()=>{let A=await wr.acquire();try{if(P){let e=P.deref();if(e)return e}let r=await M.init();return P=new WeakRef(r),r}finally{A()}},U=null,Er=()=>{let A=U?.deref();return A||(A=new N,U=new WeakRef(A)),A},q=class{constructor(){j(this,"workers",[]);j(this,"refCount",0);Y.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 r of this.workers)r.terminate();this.workers.length=0,Y.unregister(this)}},M=class A extends q{constructor(r,e){super(),this.memory=r,this.exports=e}static async init(){let r=new WebAssembly.Memory({initial:32,maximum:65536,shared:!0}),e=await vr($(),r),t=e.allocateThreadLocalState(e.__tls_size.value,e.__tls_align.value);if(t===0)throw new Error("Failed to allocate thread-local state.");e.__wasm_init_tls(t);let n=typeof window<"u"&&typeof document<"u"&&self===window;return e.setIsBrowserMainThread(Number(n)),new A(r,e)}async ensureWorkers(r){for(;this.workers.length<r;){let e=this.exports.allocateWorkerStack(),t=this.exports.allocateThreadLocalState(this.exports.__tls_size.value,this.exports.__tls_align.value);if(e===0||t===0)throw new Error("Failed to allocate worker stack or thread-local state.");let n=await nr();n.postMessage({type:c.SharedMemoryInit,wasmBinary:$(),memory:this.memory,stackPointer:e,tlsPointer:t}),this.workers.push(n)}}destroy(){super.destroy(),P=null}},N=class extends q{constructor(){super(...arguments);j(this,"workerLoad",[]);j(this,"nextRequestId",0);j(this,"nextDecoderId",0);j(this,"registeredDecoders",new Map)}registerDecoder(e,t,n){this.registeredDecoders.set(e,{bitDepth:t,allowedOutputFormats:n});for(let o of this.workers)o.postMessage({type:c.CreateDecoder,decoderId:e,bitDepth:t,allowedOutputFormats:n})}unregisterDecoder(e){this.registeredDecoders.delete(e);for(let t of this.workers)t.postMessage({type:c.CloseDecoder,decoderId:e})}async ensureWorkers(e){let t=e-this.workers.length;if(t<=0)return;let n=await Promise.all(Array.from({length:t},async()=>{let i=await nr(),s=await new Promise(a=>{i.postMessage({type:c.MessagePassingInit,wasmBinary:$()}),i.addEventListener("message",B=>a(B.data),{once:!0})});return s.type===c.InitOutOfMemoryError?(i.terminate(),new f(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(),U=null}},J=["ap4x","ap4h","apch","apcn","apcs","apco"],p=class{constructor(r){j(this,"_closed",!1);j(this,"_queue",Promise.resolve());j(this,"_concurrentDecode");j(this,"_decodeQueueSize",0);j(this,"_dequeuedResolve");j(this,"_dequeued",new Promise(r=>{this._dequeuedResolve=r}));this._concurrentDecode=r}get decodeQueueSize(){return this._decodeQueueSize}get dequeued(){return this._dequeued}_markDequeued(){this._decodeQueueSize--,this._dequeuedResolve(),this._dequeued=new Promise(r=>{this._dequeuedResolve=r})}static async create(r){if(typeof r!="object"||!r)throw new TypeError("options must be an object.");if(!J.includes(r.proresFourCc))throw new TypeError(`options.proresFourCc must be one of ${J.join(", ")}.`);if(typeof r.useSharedMemory!="boolean")throw new TypeError("options.useSharedMemory must be a boolean.");if(r.concurrency!==void 0&&(!Number.isInteger(r.concurrency)||r.concurrency<0))throw new TypeError("options.concurrency, when provided, must be a non-negative integer.");if(r.allowedOutputFormats&&!(Array.isArray(r.allowedOutputFormats)&&r.allowedOutputFormats.length>0&&r.allowedOutputFormats.every(o=>h.includes(o))))throw new TypeError(`options.allowedOutputFormats, when provided, must be a non-empty array containing any of: ${h.join(", ")}.`);if(r.useSharedMemory&&!Z)return new C(`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 e;if(r.allowedOutputFormats){e=0;for(let o of r.allowedOutputFormats)e|=1<<h.indexOf(o)}else e=4294967295;let t=r.proresFourCc==="ap4h"||r.proresFourCc==="ap4x"?12:10,n=r.concurrency??await Pr();if(r.useSharedMemory||n===0){let o=await Er();o.ref(),await o.ensureWorkers(n);let i=o.exports.createDecoder(n,t,e);return i===0?(o.unref(),new f):new H(o,i,n)}else{let o=Cr();o.ref();let i=await o.ensureWorkers(n);return i?(o.unref(),i):new G(o,n,t,e)}}static canUseSharedMemory(){return z}async decode(r,e,t={}){if(!(r instanceof Uint8Array))throw new TypeError("packetData must be a Uint8Array.");if(!(e instanceof v))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 $;if(e._locked)return new F;e._reset(),e._locked=!0,this._decodeQueueSize++;let n=this._concurrentDecode?this._runDecode(r,e,t):null,o=this._queue.then(()=>n??this._runDecode(r,e,t)).finally(()=>{e._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 r=this._queue.then(()=>this._runClose());return this._queue=r.catch(()=>{}),r}get isClosed(){return this._closed}[Symbol.dispose](){this.close()}[Symbol.asyncDispose](){return this.close()}},tr=new FinalizationRegistry(({runtime:A,ptr:r})=>{A.exports.closeDecoder(r),A.unref()}),H=class extends p{constructor(e,t,n){super(!1);j(this,"_runtime");j(this,"_decoderPtr");j(this,"_taskStateOffset");j(this,"useSharedMemory",!0);j(this,"concurrency");this._runtime=e,this._decoderPtr=t,this._taskStateOffset=e.exports.getTaskStateAddress(t)/4,this.concurrency=n,tr.register(this,{runtime:e,ptr:t},this)}_runClose(){d(this._runtime),tr.unregister(this),this._runtime.exports.closeDecoder(this._decoderPtr),this._runtime.unref(),this._runtime=null}async _runDecode(e,t,n){d(this._runtime);let{exports:o,memory:i}=this._runtime;if(!t._ensureWasmFrame(this._runtime))return new f;let s=t._ptr;n.transfer&&(e=structuredClone(e,{transfer:[e.buffer]}));let a=o.allocatePacket(this._decoderPtr,e.byteLength);if(a===0)return new f;new Uint8Array(i.buffer).set(e,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(vr(o,i,s,this._decoderPtr)),t)}_createError(e){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=jr(new Uint8Array(n.buffer,i,s))}return or(e,o)}},nr=new FinalizationRegistry(A=>{A.unref()}),G=class extends p{constructor(e,t,n,o){super(!0);j(this,"_runtime");j(this,"_decoderId");j(this,"useSharedMemory",!1);j(this,"concurrency");this._runtime=e,this.concurrency=t,this._decoderId=e.nextDecoderId++,e.registerDecoder(this._decoderId,n,o),nr.register(this,e,this)}_runClose(){d(this._runtime),this._runtime.unregisterDecoder(this._decoderId),nr.unregister(this),this._runtime.unref(),this._runtime=null}_runDecode(e,t,n){d(this._runtime);let o=this._runtime,i=n.transfer?e:e.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++,g=t._buffer;return t._buffer=null,new Promise(l=>{a.postMessage({type:c.Decode,id:B,decoderId:this._decoderId,packet:i,frameBuffer:g},g?[i.buffer,g]:[i.buffer]);let P=lr=>{let m=lr.data;m.type!==c.Decoded&&m.type!==c.DecodeError||m.id===B&&(a.removeEventListener("message",P),o.workerLoad[s]--,m.type===c.DecodeError?l(or(m.code,m.message)):(t._buffer=m.contents.frameData.buffer,t._populate(m.contents),l(t)))};a.addEventListener("message",P)})}};function T(A){if(!A)throw new Error("Assertion failed.")}var Ur=1e6*(1+Number.EPSILON);var K=null,sr=()=>K!==null?K:K=!!(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 ar=Symbol.for("@mediabunny/prores loaded");globalThis[ar]&&u.Logging._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[ar]=!0;var b=class b extends u.CustomVideoDecoder{constructor(){super(...arguments);this.decoder=null;this.framePool=[]}static supports(e,t){return e==="prores"}static _determineSupportedVideoFrameFormats(){let e=[],t=new Uint8Array(32);for(let n of h)try{new VideoFrame(t,{format:n,codedWidth:2,codedHeight:2,timestamp:0,duration:0}).close(),e.push(n)}catch{}return e}async init(){typeof VideoFrame<"u"&&(b._supportedVideoFrameFormats??=b._determineSupportedVideoFrameFormats());let e=await p.create({proresFourCc:this.config.codec,useSharedMemory:p.canUseSharedMemory(),allowedOutputFormats:b._supportedVideoFrameFormats??void 0});if(e instanceof Error)throw e;this.decoder=e}async decode(e){if(T(this.decoder),this.decoder.useSharedMemory)await this.runDecode(e);else{for(;this.decoder.decodeQueueSize>=this.decoder.concurrency;)await this.decoder.dequeued;this.runDecode(e).catch(t=>this.onError(t))}}async runDecode(e){T(this.decoder);let t;this.framePool.length>0?t=this.framePool.shift():t=new v;let n=await this.decoder.decode(e.data,t);if(this.framePool.push(t),n instanceof Error)throw n;n.visibleHeight<n.codedHeight&&sr()&&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:e.microsecondTimestamp,duration:e.microsecondDuration,colorSpace:o});a=new u.VideoSample(B,{timestamp:e.timestamp,duration:e.duration})}else a=new u.VideoSample(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:e.timestamp,duration:e.duration,colorSpace:o});this.onSample(a)}trimCodedHeightToVisibleHeight(e){let t=e.pixelFormat.includes("P")?2:1,n=e.pixelFormat.includes("444")?1:2,o=e.pixelFormat.includes("420")?2:1,i=e.codedWidth/n,s=e.codedHeight/o,a=Math.ceil(e.visibleHeight/o),B=e.codedWidth*e.codedHeight,g=e.codedWidth*e.visibleHeight,l=i*s,P=i*a;e.frameData.set(e.frameData.subarray(t*B,t*(B+l)),t*g),e.frameData.set(e.frameData.subarray(t*(B+l),t*(B+2*l)),t*(g+P)),e.codedHeight=e.visibleHeight}async flush(){for(T(this.decoder);this.decoder.decodeQueueSize>0;)await this.decoder.dequeued}async close(){T(this.decoder),await this.decoder.close();for(let e of this.framePool)e.clear()}};b._supportedVideoFrameFormats=null;var Q=b,Br=!1,Fr=()=>{Br||(Br=!0,(0,u.registerDecoder)(Q))};return gr(kr);})();
889
+ Otherwise, pass useSharedMemory: false to use a slower, worker-based fallback.`);let e;if(r.allowedOutputFormats){e=0;for(let o of r.allowedOutputFormats)e|=1<<h.indexOf(o)}else e=4294967295;let t=r.proresFourCc==="ap4h"||r.proresFourCc==="ap4x"?12:10,n=r.concurrency??await Tr();if(r.useSharedMemory||n===0){let o=await Pr();o.ref(),await o.ensureWorkers(n);let i=o.exports.createDecoder(n,t,e);return i===0?(o.unref(),new f):new V(o,i,n)}else{let o=Er();o.ref();let i=await o.ensureWorkers(n);return i?(o.unref(),i):new W(o,n,t,e)}}static canUseSharedMemory(){return Z}async decode(r,e,t={}){if(!(r instanceof Uint8Array))throw new TypeError("packetData must be a Uint8Array.");if(!(e instanceof v))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 R;if(e._locked)return new F;e._reset(),e._locked=!0,this._decodeQueueSize++;let n=this._concurrentDecode?this._runDecode(r,e,t):null,o=this._queue.then(()=>n??this._runDecode(r,e,t)).finally(()=>{e._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 r=this._queue.then(()=>this._runClose());return this._queue=r.catch(()=>{}),r}get isClosed(){return this._closed}[Symbol.dispose](){this.close()}[Symbol.asyncDispose](){return this.close()}},z=new FinalizationRegistry(({runtime:A,ptr:r})=>{A.exports.closeDecoder(r),A.unref()}),V=class extends p{constructor(e,t,n){super(!1);j(this,"_runtime");j(this,"_decoderPtr");j(this,"_taskStateOffset");j(this,"useSharedMemory",!0);j(this,"concurrency");this._runtime=e,this._decoderPtr=t,this._taskStateOffset=e.exports.getTaskStateAddress(t)/4,this.concurrency=n,z.register(this,{runtime:e,ptr:t},this)}_runClose(){d(this._runtime),z.unregister(this),this._runtime.exports.closeDecoder(this._decoderPtr),this._runtime.unref(),this._runtime=null}async _runDecode(e,t,n){d(this._runtime);let{exports:o,memory:i}=this._runtime;if(!t._ensureWasmFrame(this._runtime))return new f;let s=t._ptr;n.transfer&&(e=structuredClone(e,{transfer:[e.buffer]}));let a=o.allocatePacket(this._decoderPtr,e.byteLength);if(a===0)return new f;new Uint8Array(i.buffer).set(e,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(Ir(o,i,s,this._decoderPtr)),t)}_createError(e){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=Ar(new Uint8Array(n.buffer,i,s))}return er(e,o)}},rr=new FinalizationRegistry(A=>{A.unref()}),W=class extends p{constructor(e,t,n,o){super(!0);j(this,"_runtime");j(this,"_decoderId");j(this,"useSharedMemory",!1);j(this,"concurrency");this._runtime=e,this.concurrency=t,this._decoderId=e.nextDecoderId++,e.registerDecoder(this._decoderId,n,o),rr.register(this,e,this)}_runClose(){d(this._runtime),this._runtime.unregisterDecoder(this._decoderId),rr.unregister(this),this._runtime.unref(),this._runtime=null}_runDecode(e,t,n){d(this._runtime);let o=this._runtime,i=n.transfer?e:e.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++,g=t._buffer;return t._buffer=null,new Promise(l=>{a.postMessage({type:c.Decode,id:B,decoderId:this._decoderId,packet:i,frameBuffer:g},g?[i.buffer,g]:[i.buffer]);let w=sr=>{let m=sr.data;m.type!==c.Decoded&&m.type!==c.DecodeError||m.id===B&&(a.removeEventListener("message",w),o.workerLoad[s]--,m.type===c.DecodeError?l(er(m.code,m.message)):(t._buffer=m.contents.frameData.buffer,t._populate(m.contents),l(t)))};a.addEventListener("message",w)})}};function T(A){if(!A)throw new Error("Assertion failed.")}var Dr=1e6*(1+Number.EPSILON);var H=null,or=()=>H!==null?H:H=!!(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 ir=Symbol.for("@mediabunny/prores loaded");globalThis[ir]&&u.Logging._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[ir]=!0;var b=class b extends u.CustomVideoDecoder{constructor(){super(...arguments);this.decoder=null;this.framePool=[]}static supports(e,t){return e==="prores"}static _determineSupportedVideoFrameFormats(){let e=[],t=new Uint8Array(32);for(let n of h)try{new VideoFrame(t,{format:n,codedWidth:2,codedHeight:2,timestamp:0,duration:0}).close(),e.push(n)}catch{}return e}async init(){typeof VideoFrame<"u"&&(b._supportedVideoFrameFormats??=b._determineSupportedVideoFrameFormats());let e=await p.create({proresFourCc:this.config.codec,useSharedMemory:p.canUseSharedMemory(),allowedOutputFormats:b._supportedVideoFrameFormats??void 0});if(e instanceof Error)throw e;this.decoder=e}async decode(e){if(T(this.decoder),this.decoder.useSharedMemory)await this.runDecode(e);else{for(;this.decoder.decodeQueueSize>=this.decoder.concurrency;)await this.decoder.dequeued;this.runDecode(e).catch(t=>this.onError(t))}}async runDecode(e){T(this.decoder);let t;this.framePool.length>0?t=this.framePool.shift():t=new v;let n=await this.decoder.decode(e.data,t);if(this.framePool.push(t),n instanceof Error)throw n;n.visibleHeight<n.codedHeight&&or()&&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:e.microsecondTimestamp,duration:e.microsecondDuration,colorSpace:o});a=new u.VideoSample(B,{timestamp:e.timestamp,duration:e.duration})}else a=new u.VideoSample(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:e.timestamp,duration:e.duration,colorSpace:o});this.onSample(a)}trimCodedHeightToVisibleHeight(e){let t=e.pixelFormat.includes("P")?2:1,n=e.pixelFormat.includes("444")?1:2,o=e.pixelFormat.includes("420")?2:1,i=e.codedWidth/n,s=e.codedHeight/o,a=Math.ceil(e.visibleHeight/o),B=e.codedWidth*e.codedHeight,g=e.codedWidth*e.visibleHeight,l=i*s,w=i*a;e.frameData.set(e.frameData.subarray(t*B,t*(B+l)),t*g),e.frameData.set(e.frameData.subarray(t*(B+l),t*(B+2*l)),t*(g+w)),e.codedHeight=e.visibleHeight}async flush(){for(T(this.decoder);this.decoder.decodeQueueSize>0;)await this.decoder.dequeued}async close(){T(this.decoder),await this.decoder.close();for(let e of this.framePool)e.clear()}};b._supportedVideoFrameFormats=null;var G=b,jr=!1,Cr=()=>{jr||(jr=!0,(0,u.registerDecoder)(G))};return pr(Fr);})();
891
891
  if (typeof module === "object" && typeof module.exports === "object") Object.assign(module.exports, MediabunnyProres)