alpha2 0.4.6 → 0.5.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 +5 -4
- package/THIRD_PARTY_NOTICES.md +4 -0
- package/dist/abort.d.ts +12 -0
- package/dist/abort.js +48 -0
- package/dist/active-clock.d.ts +35 -0
- package/dist/active-clock.js +99 -0
- package/dist/assets.d.ts +51 -22
- package/dist/assets.js +8 -12
- package/dist/audio-layout.d.ts +52 -74
- package/dist/audio-layout.js +114 -148
- package/dist/audio-timeline.d.ts +89 -117
- package/dist/audio-timeline.js +102 -118
- package/dist/audio-worker.d.ts +12 -21
- package/dist/audio-worker.js +8 -13
- package/dist/audio-worklet-processor.js +45 -58
- package/dist/audio-worklet.d.ts +45 -76
- package/dist/audio-worklet.js +44 -79
- package/dist/audio.d.ts +15 -23
- package/dist/audio.js +9 -13
- package/dist/builder.d.ts +45 -63
- package/dist/builder.js +49 -45
- package/dist/capabilities.d.ts +99 -16
- package/dist/capabilities.js +2 -2
- package/dist/captions.d.ts +45 -22
- package/dist/captions.js +60 -15
- package/dist/chroma-siting.d.ts +24 -41
- package/dist/chroma-siting.js +38 -71
- package/dist/containers.d.ts +41 -30
- package/dist/containers.js +59 -27
- package/dist/decoder-fallback.d.ts +13 -0
- package/dist/decoder-fallback.js +38 -0
- package/dist/decoder-order.d.ts +24 -39
- package/dist/decoder-order.js +28 -42
- package/dist/edit.d.ts +77 -154
- package/dist/edit.js +98 -180
- package/dist/effects.d.ts +125 -176
- package/dist/effects.js +7 -9
- package/dist/export-destination.d.ts +25 -41
- package/dist/export-destination.js +20 -32
- package/dist/export-failure.d.ts +34 -59
- package/dist/export-failure.js +54 -48
- package/dist/export-metrics.d.ts +116 -0
- package/dist/export-metrics.js +74 -0
- package/dist/export-retry.d.ts +46 -29
- package/dist/export-retry.js +86 -51
- package/dist/exporter.d.ts +67 -116
- package/dist/exporter.js +133 -133
- package/dist/extensions.d.ts +69 -115
- package/dist/extensions.js +55 -82
- package/dist/frame-intake.d.ts +92 -0
- package/dist/frame-intake.js +114 -0
- package/dist/frame-supply.d.ts +96 -162
- package/dist/frame-supply.js +181 -171
- package/dist/frames.d.ts +23 -0
- package/dist/frames.js +34 -0
- package/dist/generated/project-schema.d.ts +712 -485
- package/dist/generated/project-schema.js +55 -2
- package/dist/generated/project-shape.js +276 -16
- package/dist/geometry.d.ts +28 -34
- package/dist/geometry.js +18 -23
- package/dist/gpu-recovery.d.ts +92 -0
- package/dist/gpu-recovery.js +135 -0
- package/dist/hdr-frames.d.ts +82 -67
- package/dist/hdr-frames.js +112 -49
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/json-text.d.ts +13 -23
- package/dist/json-text.js +10 -20
- package/dist/layout-values.d.ts +14 -22
- package/dist/layout-values.js +18 -21
- package/dist/layout.d.ts +48 -63
- package/dist/layout.js +37 -37
- package/dist/loudness.d.ts +27 -32
- package/dist/loudness.js +19 -23
- package/dist/media.d.ts +85 -237
- package/dist/media.js +133 -287
- package/dist/mediabunny.d.ts +178 -246
- package/dist/mediabunny.js +781 -583
- package/dist/paint.d.ts +23 -0
- package/dist/paint.js +37 -0
- package/dist/physical-frames.d.ts +5 -17
- package/dist/physical-frames.js +4 -11
- package/dist/player.d.ts +56 -47
- package/dist/player.js +155 -40
- package/dist/presented-frames.d.ts +2 -7
- package/dist/presented-frames.js +3 -8
- package/dist/project.d.ts +74 -118
- package/dist/project.js +384 -445
- package/dist/rate-control.d.ts +9 -23
- package/dist/rate-control.js +7 -18
- package/dist/renderer-choice.d.ts +41 -0
- package/dist/renderer-choice.js +82 -0
- package/dist/repacked-bytes.d.ts +0 -2
- package/dist/repacked-bytes.js +2 -5
- package/dist/robustness.d.ts +25 -37
- package/dist/robustness.js +71 -54
- package/dist/sha256.d.ts +5 -13
- package/dist/sha256.js +9 -24
- package/dist/text.d.ts +97 -71
- package/dist/text.js +33 -70
- package/dist/video-frames.d.ts +7 -25
- package/dist/video-frames.js +12 -29
- package/dist/waveform.d.ts +5 -11
- package/dist/waveform.js +4 -9
- package/dist/worker-error.d.ts +5 -20
- package/dist/worker-error.js +8 -25
- package/dist/worker.d.ts +82 -95
- package/dist/worker.js +235 -143
- package/package.json +26 -2
- package/wasm/alpha2_audio_worklet.wasm +0 -0
- package/wasm/alpha2_extensions.d.ts +26 -47
- package/wasm/alpha2_extensions.js +26 -47
- package/wasm/alpha2_extensions_bg.wasm +0 -0
- package/wasm/alpha2_wasm.d.ts +501 -587
- package/wasm/alpha2_wasm.js +661 -616
- package/wasm/alpha2_wasm_bg.wasm +0 -0
- package/wasm/alpha2_wasm_bg.wasm.d.ts +22 -12
- package/wasm/rust-crate-licenses.md +2 -2
- package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-070d94113471ef0a}/inline1.js +1 -0
- package/wasm/snippets/alpha2-wasm-070d94113471ef0a/inline2.js +82 -0
- package/wasm/snippets/alpha2-wasm-c62e60c964e88a52/inline2.js +0 -52
- /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-070d94113471ef0a}/inline0.js +0 -0
- /package/wasm/snippets/{alpha2-wasm-c62e60c964e88a52 → alpha2-wasm-070d94113471ef0a}/inline3.js +0 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ For an editor with documents, undo, and a ready preview and export bridge, see [
|
|
|
10
10
|
npm install alpha2
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
- The WebAssembly modules need Chrome 96, Firefox 89 or Safari
|
|
13
|
+
- The WebAssembly modules need Chrome 96, Firefox 89 or Safari 26, or later.
|
|
14
14
|
- Serve `.wasm` files as `application/wasm`; otherwise the loader falls back to a slower way of compiling them and warns.
|
|
15
15
|
- Audio preview needs a cross-origin isolated page (`Cross-Origin-Opener-Policy: same-origin`, `Cross-Origin-Embedder-Policy: require-corp`).
|
|
16
16
|
- [mediabunny](https://www.npmjs.com/package/mediabunny) is an optional dependency, for the decoders and the MP4, MOV, MKV and WebM writer in `alpha2/mediabunny`. It installs `@types/dom-webcodecs` 0.1.13, whose declarations clash with TypeScript 5.9's DOM library. A TypeScript application either compiles with `skipLibCheck` or adds `"overrides": { "@types/dom-webcodecs": "0.1.19" }` to its `package.json`; one that imports `alpha2/mediabunny` also needs `"ESNext.Disposable"` in its `lib`.
|
|
@@ -36,8 +36,8 @@ engine.renderAt(0n); // draws the frame at time 0 on the canvas
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
- `init()` loads `alpha2_wasm_bg.wasm` from beside the module. A bundler that moves it passes its URL, a `Response`, its bytes or a compiled `WebAssembly.Module` as `init({ module_or_path })`; the files are `alpha2/wasm/alpha2_wasm_bg.wasm` (the engine), `alpha2/wasm/alpha2_audio_worklet.wasm` (the audio worklet) and `alpha2/wasm/alpha2_extensions_bg.wasm` (SVG, animated images, Lottie, OpenEXR and image sequences, loaded only for such a source).
|
|
39
|
-
- `createForHtmlCanvas` draws on a page canvas; a worker passes an `OffscreenCanvas` to `createForCanvas`. Either renders with WebGPU, or with WebGL2 when the browser has no WebGPU.
|
|
40
|
-
- With neither (Chrome with acceleration off, a blocklisted GPU), `WebEffectRegistry.createCpu(canvas)` makes the engine's CPU renderer: the same calls, drawn in wasm on one thread, the preview put on the canvas's 2D context. It draws exactly what the native CPU renderer draws, refuses runtime WGSL effects with `EFFECT_ERROR`, and needs no canvas to export. `detectBrowserCapabilities()` reports which renderer the
|
|
39
|
+
- `createForHtmlCanvas` draws on a page canvas; a worker passes an `OffscreenCanvas` to `createForCanvas`. Either renders with WebGPU, or with WebGL2 when the browser has no WebGPU. The WebGPU device is opened before the canvas is bound, so a failure leaves the canvas free for another context. `{ softwareAdapter: "refuse" }` refuses software adapters (SwiftShader, llvmpipe, WARP, a WebGPU fallback adapter) and rejects `GPU_INIT_FAILED` when the browser offers nothing else.
|
|
40
|
+
- With neither (Chrome with acceleration off, a blocklisted GPU), `WebEffectRegistry.createCpu(canvas)` makes the engine's CPU renderer: the same calls, drawn in wasm on one thread, the preview put on the canvas's 2D context. It draws exactly what the native CPU renderer draws, refuses runtime WGSL effects with `EFFECT_ERROR`, and needs no canvas to export. `createRenderer(binding, canvas, mode)` in `alpha2/renderer-choice` makes the renderer a mode asks for (`"auto"` draws on a hardware GPU, else on the CPU renderer, as the native host's `auto` does) and says which it made. `detectBrowserCapabilities()` reports which renderer `"auto"` gets on the calling thread (`renderer`), probing WebGL2 on an `OffscreenCanvas`, as render hosts draw; a worker host's answer comes from `WorkerRenderBackend.detectCapabilities()`.
|
|
41
41
|
- A project is the engine's JSON document. `alpha2/project` has its TypeScript types, tick conversions and `validateProject`, which reports what the engine would refuse before the document is sent; `alpha2/builder` writes one with times in seconds. `loadProject` checks the document again and throws what it refuses.
|
|
42
42
|
- `renderAt(ticks)` returns JSON that names the sources it had no frame for (`missingSources`, `missingFrames`). The engine decides which frame of each source a time needs: `frameNeeds(ticks)` lists them with the exact source time, and the application decodes and uploads those (`uploadVideoFrame` for a `VideoFrame`, `uploadRgbaFrame` for pixels at a source time, `uploadRgbaImage` for a still). `FrameSupply` in `alpha2/frame-supply` does this for a decoder per clip, and keeps the uploads within a byte budget.
|
|
43
43
|
|
|
@@ -77,7 +77,7 @@ For preview, `alpha2/audio-timeline` moves the mixed blocks to the audio thread
|
|
|
77
77
|
|
|
78
78
|
## Preview in a worker
|
|
79
79
|
|
|
80
|
-
`alpha2/worker` runs the engine in a worker that owns the GPU device and an `OffscreenCanvas` (`installRenderWorker`, `createWasmRenderWorkerHost`), and `WorkerRenderBackend` drives it from the page. The host's `renderer` option is `"auto"` (WebGPU, else WebGL2, else the CPU renderer), `"gpu"` or `"cpu"`; `WorkerRenderBackend.rendererChoice` says which renderer the worker made and why it draws on the CPU, as the native host's `renderer` and `rendererReason` do. `Alpha2Player` in `alpha2/player` presents times through such a backend: it serializes presentations, asks for the frames a presentation lacks and shows them once they arrive, and
|
|
80
|
+
`alpha2/worker` runs the engine in a worker that owns the GPU device and an `OffscreenCanvas` (`installRenderWorker`, `createWasmRenderWorkerHost`), and `WorkerRenderBackend` drives it from the page. The host's `renderer` option is `"auto"` (WebGPU, else WebGL2, on a hardware adapter, else the CPU renderer), `"gpu"` (any adapter, software ones included) or `"cpu"`; `WorkerRenderBackend.rendererChoice` says which renderer the worker made and why it draws on the CPU, as the native host's `renderer` and `rendererReason` do. `Alpha2Player` in `alpha2/player` presents times through such a backend: it serializes presentations, asks for the frames a presentation lacks and shows them once they arrive, and recovers a lost GPU through `GpuRecoveryLadder` (`alpha2/gpu-recovery`): the GPU again after a first external loss, the CPU renderer once the loss was the work's own (`GPU_DEVICE_HUNG`), recurred at the same frame, or the page has lost the GPU twice (the browser withdraws GPU access after its next reset). A recovery that needs a new canvas takes one from the player's `replaceSurface` option; `@alpha2-sh/react` supplies it.
|
|
81
81
|
|
|
82
82
|
## Subpaths
|
|
83
83
|
|
|
@@ -99,6 +99,7 @@ For preview, `alpha2/audio-timeline` moves the mixed blocks to the audio thread
|
|
|
99
99
|
| `alpha2/mediabunny` | Decoders and an MP4, MOV, MKV and WebM sink on mediabunny (an optional dependency). |
|
|
100
100
|
| `alpha2/hdr-frames`, `alpha2/video-frames` | Uploading planar and HDR `VideoFrame`s; `VideoFrame`s from exported I420 planes. |
|
|
101
101
|
| `alpha2/player`, `alpha2/worker` | `Alpha2Player` and the render worker. |
|
|
102
|
+
| `alpha2/renderer-choice`, `alpha2/gpu-recovery` | Making the renderer a mode asks for; what a host does after a GPU loss. |
|
|
102
103
|
| `alpha2/exporter` | `Alpha2Exporter` and `exportToSink`. |
|
|
103
104
|
| `alpha2/export-destination` | Where an export's bytes go: a file, or memory. |
|
|
104
105
|
| `alpha2/export-failure`, `alpha2/export-retry` | How export failures are classified, and a retry policy over them. |
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -10,6 +10,10 @@ The `alpha2` npm package and the native archives each list the third-party Rust
|
|
|
10
10
|
|
|
11
11
|
The native archives load FFmpeg 8, built as shared libraries under the LGPL 2.1 or later with its GPL and nonfree components disabled. Each archive carries the license texts of FFmpeg and the libraries it is built with in `licenses/`, and says where to get the corresponding source in `compliance/SOURCE.md`.
|
|
12
12
|
|
|
13
|
+
## DirectX Shader Compiler
|
|
14
|
+
|
|
15
|
+
The Windows archive (and the wheel and Node install built from it) carries `bin/dxcompiler.dll` from Microsoft's DirectX Shader Compiler release v1.9.2609 (https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.9.2609), which `alpha2-host` loads to compile its DX12 shaders. It is under the University of Illinois/NCSA Open Source License (the LLVM release license), the MIT License, and the Microsoft Software License Terms for the DirectX Shader Compiler; the texts are in `licenses/DirectXShaderCompiler/`, and `compliance/DXC.toml` records the release and the checksums of what was shipped.
|
|
16
|
+
|
|
13
17
|
## OpenH264
|
|
14
18
|
|
|
15
19
|
alpha2 does not include OpenH264. On request (`python -m alpha2 install --openh264`, `npx @alpha2-sh/node install --openh264`) it downloads Cisco's prebuilt OpenH264 binary from Cisco to the user's machine, and `alpha2-host` loads it to encode H.264 in software; `ALPHA2_OPENH264=0` turns it off. Cisco's binary comes with the licence below (https://www.openh264.org/BINARY_LICENSE.txt, v1.0, its typographic quotes and copyright sign written in ASCII).
|
package/dist/abort.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signal's reason as an `Error`. An `Error` reason passes through; anything else becomes a
|
|
3
|
+
* `DOMException` named `AbortError`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function abortError(signal: AbortSignal): Error;
|
|
6
|
+
/** Throws {@link abortError} when `signal` has aborted. */
|
|
7
|
+
export declare function throwIfAborted(signal?: AbortSignal): void;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves with `work`, or rejects with `cancelled(signal)` as soon as `signal` aborts. A value that
|
|
10
|
+
* arrives after the abort is passed to `onLate` so its resources can be released.
|
|
11
|
+
*/
|
|
12
|
+
export declare function raceAbort<T>(work: Promise<T>, signal: AbortSignal | undefined, onLate?: (value: T) => void, cancelled?: (signal: AbortSignal) => Error): Promise<T>;
|
package/dist/abort.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signal's reason as an `Error`. An `Error` reason passes through; anything else becomes a
|
|
3
|
+
* `DOMException` named `AbortError`.
|
|
4
|
+
*/
|
|
5
|
+
export function abortError(signal) {
|
|
6
|
+
const reason = signal.reason;
|
|
7
|
+
if (reason instanceof Error)
|
|
8
|
+
return reason;
|
|
9
|
+
if (typeof reason === "string")
|
|
10
|
+
return new DOMException(reason, "AbortError");
|
|
11
|
+
return new DOMException("Aborted", "AbortError");
|
|
12
|
+
}
|
|
13
|
+
/** Throws {@link abortError} when `signal` has aborted. */
|
|
14
|
+
export function throwIfAborted(signal) {
|
|
15
|
+
if (signal?.aborted === true)
|
|
16
|
+
throw abortError(signal);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolves with `work`, or rejects with `cancelled(signal)` as soon as `signal` aborts. A value that
|
|
20
|
+
* arrives after the abort is passed to `onLate` so its resources can be released.
|
|
21
|
+
*/
|
|
22
|
+
export async function raceAbort(work, signal, onLate, cancelled = abortError) {
|
|
23
|
+
if (signal === undefined)
|
|
24
|
+
return work;
|
|
25
|
+
let lost = false;
|
|
26
|
+
void work.then((value) => {
|
|
27
|
+
if (lost)
|
|
28
|
+
onLate?.(value);
|
|
29
|
+
}, () => { });
|
|
30
|
+
let abort;
|
|
31
|
+
const aborted = new Promise((_, reject) => {
|
|
32
|
+
abort = () => {
|
|
33
|
+
lost = true;
|
|
34
|
+
reject(cancelled(signal));
|
|
35
|
+
};
|
|
36
|
+
if (signal.aborted)
|
|
37
|
+
abort();
|
|
38
|
+
else
|
|
39
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
return await Promise.race([work, aborted]);
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
if (abort !== undefined)
|
|
46
|
+
signal.removeEventListener("abort", abort);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeouts that count active time, not wall-clock time.
|
|
3
|
+
*
|
|
4
|
+
* A frozen or sleeping page would otherwise fire every pending timeout on resume and report a
|
|
5
|
+
* paused decoder or encoder as stalled. Each tick credits at most {@link MAX_CREDIT_MS}, so a long
|
|
6
|
+
* freeze counts as one tick while a throttled one-second timer still counts in full.
|
|
7
|
+
*/
|
|
8
|
+
/** Most active time one tick credits, in milliseconds. */
|
|
9
|
+
export declare const MAX_CREDIT_MS = 1100;
|
|
10
|
+
/** Stopwatch tick interval, in milliseconds. */
|
|
11
|
+
export declare const ACTIVE_TICK_MS = 250;
|
|
12
|
+
/** Clock source for a stopwatch; replaceable in tests. */
|
|
13
|
+
export interface ActiveClock {
|
|
14
|
+
now(): number;
|
|
15
|
+
every(ms: number, tick: () => void): () => void;
|
|
16
|
+
}
|
|
17
|
+
/** Active time since it started or was last reset. */
|
|
18
|
+
export declare class ActiveStopwatch {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(clock?: ActiveClock);
|
|
21
|
+
/** Active milliseconds so far. */
|
|
22
|
+
elapsed(): number;
|
|
23
|
+
reset(): void;
|
|
24
|
+
/** Calls `listener` after every tick until the returned function is called. */
|
|
25
|
+
onTick(listener: () => void): () => void;
|
|
26
|
+
/** Stops the ticks; `elapsed()` still answers. */
|
|
27
|
+
dispose(): void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolves once `ms` of active time has passed. Aborting `signal` stops the count and leaves the
|
|
31
|
+
* promise pending forever.
|
|
32
|
+
*/
|
|
33
|
+
export declare function activeTimeout(ms: number, signal?: AbortSignal, clock?: ActiveClock): Promise<void>;
|
|
34
|
+
/** Resolves with `work`, or rejects with `timeout()` if `ms` of active time passes first. */
|
|
35
|
+
export declare function withinActiveTime<T>(work: Promise<T>, ms: number, timeout: () => unknown, clock?: ActiveClock): Promise<T>;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeouts that count active time, not wall-clock time.
|
|
3
|
+
*
|
|
4
|
+
* A frozen or sleeping page would otherwise fire every pending timeout on resume and report a
|
|
5
|
+
* paused decoder or encoder as stalled. Each tick credits at most {@link MAX_CREDIT_MS}, so a long
|
|
6
|
+
* freeze counts as one tick while a throttled one-second timer still counts in full.
|
|
7
|
+
*/
|
|
8
|
+
/** Most active time one tick credits, in milliseconds. */
|
|
9
|
+
export const MAX_CREDIT_MS = 1_100;
|
|
10
|
+
/** Stopwatch tick interval, in milliseconds. */
|
|
11
|
+
export const ACTIVE_TICK_MS = 250;
|
|
12
|
+
const browserClock = {
|
|
13
|
+
now: () => performance.now(),
|
|
14
|
+
every: (ms, tick) => {
|
|
15
|
+
const timer = setInterval(tick, ms);
|
|
16
|
+
return () => clearInterval(timer);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
/** Active time since it started or was last reset. */
|
|
20
|
+
export class ActiveStopwatch {
|
|
21
|
+
#clock;
|
|
22
|
+
#elapsed = 0;
|
|
23
|
+
#last;
|
|
24
|
+
#stop;
|
|
25
|
+
#listeners = new Set();
|
|
26
|
+
constructor(clock = browserClock) {
|
|
27
|
+
this.#clock = clock;
|
|
28
|
+
this.#last = clock.now();
|
|
29
|
+
this.#stop = clock.every(ACTIVE_TICK_MS, () => this.#tick());
|
|
30
|
+
}
|
|
31
|
+
#credit() {
|
|
32
|
+
const now = this.#clock.now();
|
|
33
|
+
const credit = Math.min(Math.max(0, now - this.#last), MAX_CREDIT_MS);
|
|
34
|
+
this.#last = now;
|
|
35
|
+
return credit;
|
|
36
|
+
}
|
|
37
|
+
#tick() {
|
|
38
|
+
this.#elapsed += this.#credit();
|
|
39
|
+
for (const listener of [...this.#listeners])
|
|
40
|
+
listener();
|
|
41
|
+
}
|
|
42
|
+
/** Active milliseconds so far. */
|
|
43
|
+
elapsed() {
|
|
44
|
+
this.#elapsed += this.#credit();
|
|
45
|
+
return this.#elapsed;
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
this.#elapsed = 0;
|
|
49
|
+
this.#last = this.#clock.now();
|
|
50
|
+
}
|
|
51
|
+
/** Calls `listener` after every tick until the returned function is called. */
|
|
52
|
+
onTick(listener) {
|
|
53
|
+
this.#listeners.add(listener);
|
|
54
|
+
return () => this.#listeners.delete(listener);
|
|
55
|
+
}
|
|
56
|
+
/** Stops the ticks; `elapsed()` still answers. */
|
|
57
|
+
dispose() {
|
|
58
|
+
this.#stop?.();
|
|
59
|
+
this.#stop = undefined;
|
|
60
|
+
this.#listeners.clear();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolves once `ms` of active time has passed. Aborting `signal` stops the count and leaves the
|
|
65
|
+
* promise pending forever.
|
|
66
|
+
*/
|
|
67
|
+
export function activeTimeout(ms, signal, clock = browserClock) {
|
|
68
|
+
return new Promise((resolve) => {
|
|
69
|
+
if (signal?.aborted === true)
|
|
70
|
+
return;
|
|
71
|
+
const watch = new ActiveStopwatch(clock);
|
|
72
|
+
const stop = () => {
|
|
73
|
+
watch.dispose();
|
|
74
|
+
signal?.removeEventListener("abort", stop);
|
|
75
|
+
};
|
|
76
|
+
watch.onTick(() => {
|
|
77
|
+
if (watch.elapsed() < ms)
|
|
78
|
+
return;
|
|
79
|
+
stop();
|
|
80
|
+
resolve();
|
|
81
|
+
});
|
|
82
|
+
signal?.addEventListener("abort", stop, { once: true });
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/** Resolves with `work`, or rejects with `timeout()` if `ms` of active time passes first. */
|
|
86
|
+
export async function withinActiveTime(work, ms, timeout, clock = browserClock) {
|
|
87
|
+
const done = new AbortController();
|
|
88
|
+
try {
|
|
89
|
+
return await Promise.race([
|
|
90
|
+
work,
|
|
91
|
+
activeTimeout(ms, done.signal, clock).then(() => {
|
|
92
|
+
throw timeout();
|
|
93
|
+
}),
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
finally {
|
|
97
|
+
done.abort();
|
|
98
|
+
}
|
|
99
|
+
}
|
package/dist/assets.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type OriginalState = {
|
|
|
7
7
|
readonly fingerprint: MediaFingerprint;
|
|
8
8
|
} | {
|
|
9
9
|
readonly state: "offline";
|
|
10
|
+
/** The path the host looked the media up at, when it had one. */
|
|
11
|
+
readonly path?: string;
|
|
10
12
|
} | {
|
|
11
13
|
readonly state: "unsupported";
|
|
12
14
|
readonly reason: string;
|
|
@@ -23,9 +25,8 @@ export type ProxyState = {
|
|
|
23
25
|
/** A lighter copy of a source's media. */
|
|
24
26
|
export interface ProxyVariant {
|
|
25
27
|
readonly id: string;
|
|
26
|
-
/** The source revision it was made from. */
|
|
27
28
|
readonly source_revision: number;
|
|
28
|
-
/**
|
|
29
|
+
/** Fingerprint of the original it was made from. */
|
|
29
30
|
readonly made_from: MediaFingerprint;
|
|
30
31
|
/** Displayed size in pixels. */
|
|
31
32
|
readonly width: number;
|
|
@@ -36,20 +37,42 @@ export interface ProxyVariant {
|
|
|
36
37
|
};
|
|
37
38
|
readonly duration_ticks?: number;
|
|
38
39
|
readonly audio_sample_rate?: number;
|
|
39
|
-
/**
|
|
40
|
+
/** Color pipeline baked in when it was tone-mapped. */
|
|
40
41
|
readonly color_pipeline?: string;
|
|
41
42
|
readonly state: ProxyState;
|
|
42
43
|
}
|
|
43
44
|
/** One source's media, as a host sees it now. */
|
|
44
45
|
export interface AssetEntry {
|
|
45
46
|
readonly source_id: string;
|
|
46
|
-
/**
|
|
47
|
+
/** Host revision of the media; relinking bumps it. */
|
|
47
48
|
readonly revision: number;
|
|
48
49
|
readonly original: OriginalState;
|
|
49
50
|
/** In the host's order of preference. */
|
|
50
51
|
readonly proxies?: readonly ProxyVariant[];
|
|
52
|
+
/**
|
|
53
|
+
* Why the host drops the original's alpha, when it cannot decode it (for example HEVC auxiliary
|
|
54
|
+
* alpha, or VP9 alpha without `libvpx`).
|
|
55
|
+
*/
|
|
56
|
+
readonly alpha_dropped?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Every audio stream of the original in container order, which a clip's `audio.stream` counts
|
|
59
|
+
* over. Without it, clips' stream and channel choices are not checked.
|
|
60
|
+
*/
|
|
61
|
+
readonly audio_streams?: readonly AudioStreamFacts[];
|
|
51
62
|
}
|
|
52
|
-
/**
|
|
63
|
+
/** One audio stream of an original, as the host probed it. */
|
|
64
|
+
export interface AudioStreamFacts {
|
|
65
|
+
/** Channels the stream decodes to. */
|
|
66
|
+
readonly channels: number;
|
|
67
|
+
/** Whether a clip without `audio.stream` plays this stream. Default false. */
|
|
68
|
+
readonly default?: boolean;
|
|
69
|
+
readonly codec?: string;
|
|
70
|
+
/** The speaker of each channel as `FFmpeg` channel names, when declared. */
|
|
71
|
+
readonly layout?: readonly string[];
|
|
72
|
+
readonly language?: string;
|
|
73
|
+
readonly title?: string;
|
|
74
|
+
}
|
|
75
|
+
/** Media state of every source on one host. Runtime state, never part of a project. */
|
|
53
76
|
export interface AssetCatalog {
|
|
54
77
|
readonly assets: readonly AssetEntry[];
|
|
55
78
|
}
|
|
@@ -62,9 +85,8 @@ export type Selection = {
|
|
|
62
85
|
} | {
|
|
63
86
|
readonly media: "unavailable";
|
|
64
87
|
};
|
|
65
|
-
/** A part of a fingerprint. */
|
|
66
88
|
export type FingerprintField = "content" | "byte_length" | "video" | "audio" | "streams" | "duration" | "color";
|
|
67
|
-
/**
|
|
89
|
+
/** Result of comparing a recorded fingerprint with a found one. */
|
|
68
90
|
export type FingerprintMatch = {
|
|
69
91
|
readonly kind: "identical";
|
|
70
92
|
} | {
|
|
@@ -98,6 +120,8 @@ export type ConformIssue = {
|
|
|
98
120
|
readonly kind: "missing";
|
|
99
121
|
} | {
|
|
100
122
|
readonly kind: "offline";
|
|
123
|
+
/** The path the host looked the media up at, when it had one. */
|
|
124
|
+
readonly path?: string;
|
|
101
125
|
} | {
|
|
102
126
|
readonly kind: "unsupported";
|
|
103
127
|
readonly reason: string;
|
|
@@ -116,12 +140,20 @@ export type ConformIssue = {
|
|
|
116
140
|
} | {
|
|
117
141
|
readonly kind: "hdr_rejected";
|
|
118
142
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Neither the project nor the video declares its color: it is read as BT.709 limited-range SDR.
|
|
121
|
-
* Never blocking.
|
|
122
|
-
*/
|
|
143
|
+
/** No declared color, so the video is read as BT.709 limited-range SDR. Never blocking. */
|
|
123
144
|
| {
|
|
124
145
|
readonly kind: "undeclared_color";
|
|
146
|
+
}
|
|
147
|
+
/** The host cannot decode the original's alpha, so it draws opaque. Never blocking. */
|
|
148
|
+
| {
|
|
149
|
+
readonly kind: "alpha_dropped";
|
|
150
|
+
readonly reason: string;
|
|
151
|
+
}
|
|
152
|
+
/** A clip plays an audio stream or channel the original lacks. Always blocking. */
|
|
153
|
+
| {
|
|
154
|
+
readonly kind: "audio_selection";
|
|
155
|
+
readonly clip: string;
|
|
156
|
+
readonly reason: string;
|
|
125
157
|
});
|
|
126
158
|
/** One source's media for the purpose. */
|
|
127
159
|
export interface SourceConform {
|
|
@@ -134,12 +166,12 @@ export interface SourceConform {
|
|
|
134
166
|
/** Whether a project's sources can be read for a purpose, before a render starts. */
|
|
135
167
|
export interface ConformReport {
|
|
136
168
|
readonly purpose: MediaPurpose;
|
|
137
|
-
/**
|
|
169
|
+
/** True when no issue blocks the purpose. */
|
|
138
170
|
readonly ready: boolean;
|
|
139
171
|
/** Each host-supplied source a render reads, in project order. */
|
|
140
172
|
readonly sources: readonly SourceConform[];
|
|
141
173
|
}
|
|
142
|
-
/**
|
|
174
|
+
/** Lists every blocking issue with its source id. */
|
|
143
175
|
export declare function blockingIssues(report: ConformReport): readonly {
|
|
144
176
|
readonly sourceId: string;
|
|
145
177
|
readonly issue: ConformIssue;
|
|
@@ -151,21 +183,18 @@ export interface AssetBinding {
|
|
|
151
183
|
colorPipelineFingerprint(pipeline: string): string;
|
|
152
184
|
}
|
|
153
185
|
/**
|
|
154
|
-
*
|
|
155
|
-
* otherwise every part both
|
|
186
|
+
* Asks the engine whether `found` is the media `recorded` describes. Content hashes decide alone;
|
|
187
|
+
* otherwise every part both record must agree within demuxer tolerances.
|
|
156
188
|
*
|
|
157
|
-
* @throws When either fingerprint
|
|
158
|
-
* an input error, not other media.
|
|
189
|
+
* @throws When either fingerprint is malformed (for example an uppercase hash).
|
|
159
190
|
*/
|
|
160
191
|
export declare function compareFingerprints(binding: AssetBinding, recorded: MediaFingerprint, found: MediaFingerprint): FingerprintMatch;
|
|
161
192
|
/**
|
|
162
|
-
*
|
|
163
|
-
* engine.
|
|
193
|
+
* Asks the engine whether `project`'s media, as `catalog` describes it, is ready for `purpose`.
|
|
164
194
|
*
|
|
165
|
-
* @throws When the project or catalog does not load, or the catalog holds a fingerprint
|
|
166
|
-
* well formed.
|
|
195
|
+
* @throws When the project or catalog does not load, or the catalog holds a malformed fingerprint.
|
|
167
196
|
*/
|
|
168
197
|
export declare function conformProject(binding: AssetBinding, project: Project, catalog: AssetCatalog, purpose: MediaPurpose): ConformReport;
|
|
169
|
-
/**
|
|
198
|
+
/** Identity string a tone-mapped proxy records for `pipeline`. */
|
|
170
199
|
export declare function colorPipelineFingerprint(binding: AssetBinding, pipeline: ColorPipeline): string;
|
|
171
200
|
export * from "./sha256.js";
|
package/dist/assets.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
/** Every blocking issue, with its source. */
|
|
1
|
+
// Wire types for the engine's asset decisions (`alpha2-assets`); nothing is re-derived here.
|
|
2
|
+
/** Lists every blocking issue with its source id. */
|
|
4
3
|
export function blockingIssues(report) {
|
|
5
4
|
return report.sources.flatMap((source) => source.issues
|
|
6
5
|
.filter((issue) => issue.blocking)
|
|
7
6
|
.map((issue) => ({ sourceId: source.source_id, issue })));
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
* otherwise every part both
|
|
9
|
+
* Asks the engine whether `found` is the media `recorded` describes. Content hashes decide alone;
|
|
10
|
+
* otherwise every part both record must agree within demuxer tolerances.
|
|
12
11
|
*
|
|
13
|
-
* @throws When either fingerprint
|
|
14
|
-
* an input error, not other media.
|
|
12
|
+
* @throws When either fingerprint is malformed (for example an uppercase hash).
|
|
15
13
|
*/
|
|
16
14
|
export function compareFingerprints(binding, recorded, found) {
|
|
17
15
|
return JSON.parse(binding.compareFingerprints(JSON.stringify(recorded), JSON.stringify(found)));
|
|
18
16
|
}
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
21
|
-
* engine.
|
|
18
|
+
* Asks the engine whether `project`'s media, as `catalog` describes it, is ready for `purpose`.
|
|
22
19
|
*
|
|
23
|
-
* @throws When the project or catalog does not load, or the catalog holds a fingerprint
|
|
24
|
-
* well formed.
|
|
20
|
+
* @throws When the project or catalog does not load, or the catalog holds a malformed fingerprint.
|
|
25
21
|
*/
|
|
26
22
|
export function conformProject(binding, project, catalog, purpose) {
|
|
27
23
|
return JSON.parse(binding.conformProject(JSON.stringify(project), JSON.stringify(catalog), purpose));
|
|
28
24
|
}
|
|
29
|
-
/**
|
|
25
|
+
/** Identity string a tone-mapped proxy records for `pipeline`. */
|
|
30
26
|
export function colorPipelineFingerprint(binding, pipeline) {
|
|
31
27
|
return binding.colorPipelineFingerprint(JSON.stringify(pipeline));
|
|
32
28
|
}
|
package/dist/audio-layout.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Reads the speaker layout of a browser-decoded audio source the way the native host does.
|
|
3
3
|
*
|
|
4
|
-
* WebCodecs
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* Each rule is `FFmpeg`'s (`riffdec.c`, `mov_chan.c`, the FLAC and Matroska demuxers, the AAC,
|
|
9
|
-
* Opus, Vorbis, FLAC, AC-3 and DTS decoders), so the speakers reported here are the ones the native
|
|
10
|
-
* decoder reports for the same file. `null` means the source declares none, or the native decoder
|
|
11
|
-
* would leave its layout unspecified; the engine then assumes `FFmpeg`'s default for the channel
|
|
12
|
-
* count, as a native host does.
|
|
4
|
+
* WebCodecs and mediabunny expose only a channel count, so the layout is parsed from the bytes
|
|
5
|
+
* (WAVE channel mask, QuickTime `chan` or ISO `chnl` box, FLAC channel-mask comment, or codec
|
|
6
|
+
* headers). Every rule mirrors `FFmpeg`'s demuxers and decoders. `null` means no declared layout;
|
|
7
|
+
* the engine then uses `FFmpeg`'s default for the channel count.
|
|
13
8
|
*/
|
|
14
9
|
import type { AudioSpeaker } from "./media.js";
|
|
15
|
-
/**
|
|
10
|
+
/** Valid speaker names: the named `FFmpeg` channels plus `UNK`. */
|
|
16
11
|
export declare const AUDIO_SPEAKERS: ReadonlySet<string>;
|
|
12
|
+
/** Speakers of a native-order channel mask in bit order (`av_channel_layout_from_mask`). */
|
|
13
|
+
export declare function speakersOfMask(mask: bigint): AudioSpeaker[];
|
|
17
14
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* `speakers` with an LFE inserted in native order, plus its plane index, for decoders that add a
|
|
16
|
+
* silent LFE (a WebCodecs decoder does for E-AC-3 5.0). `null` when there is already an LFE or the
|
|
17
|
+
* list is not native-order named speakers.
|
|
20
18
|
*/
|
|
21
|
-
export declare function
|
|
19
|
+
export declare function speakersWithLfe(speakers: readonly AudioSpeaker[]): {
|
|
20
|
+
speakers: AudioSpeaker[];
|
|
21
|
+
lfePlane: number;
|
|
22
|
+
} | null;
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
-
* `
|
|
25
|
-
* `
|
|
24
|
+
* Speakers of a `WAVE_FORMAT_EXTENSIBLE` channel mask in a `fmt ` chunk payload, as `FFmpeg`'s RIFF
|
|
25
|
+
* demuxer reads it. `null` for other formats, short payloads, or a mask whose bit count is not
|
|
26
|
+
* `channels`.
|
|
26
27
|
*/
|
|
27
28
|
export declare function wavSpeakers(fmt: Uint8Array, channels: number): AudioSpeaker[] | null;
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* else, including a truncated payload.
|
|
30
|
+
* Speakers a QuickTime `chan` payload (after version and flags) declares, per `ff_mov_read_chan`:
|
|
31
|
+
* channel descriptions, a bitmap, or a known layout tag, each matching `channels`. `null`
|
|
32
|
+
* otherwise, including for truncated payloads.
|
|
33
33
|
*/
|
|
34
34
|
export declare function movChanSpeakers(chan: Uint8Array, channels: number): AudioSpeaker[] | null;
|
|
35
35
|
/**
|
|
@@ -38,87 +38,65 @@ export declare function movChanSpeakers(chan: Uint8Array, channels: number): Aud
|
|
|
38
38
|
*/
|
|
39
39
|
export type ByteReader = (offset: number, length: number) => Promise<Uint8Array>;
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* channels, a configuration `FFmpeg` does not know or of another count, a truncated payload, or
|
|
45
|
-
* one naming no speaker.
|
|
41
|
+
* Speakers an ISO `chnl` payload (after version and flags) declares, per `ff_mov_read_chnl`:
|
|
42
|
+
* explicit positions, or a channel configuration minus omitted channels. `null` for no channels,
|
|
43
|
+
* an unknown or mismatched configuration, a truncated payload, or no named speaker.
|
|
46
44
|
*/
|
|
47
45
|
export declare function chnlSpeakers(chnl: Uint8Array, channels: number): AudioSpeaker[] | null;
|
|
48
46
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* `ff_aac_output_configure` does. `null` when `FFmpeg` leaves the layout unspecified;
|
|
52
|
-
* `undefined` when it would not decode the config at all.
|
|
47
|
+
* Speakers of an `AudioSpecificConfig` as `ff_aac_output_configure` orders them. `null` when the
|
|
48
|
+
* layout stays unspecified; `undefined` when `FFmpeg` would not decode the config.
|
|
53
49
|
*/
|
|
54
50
|
export declare function aacSpeakers(config: Uint8Array): AudioSpeaker[] | null | undefined;
|
|
55
51
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* configuration or one `FFmpeg` would not decode.
|
|
52
|
+
* PCE output elements as type then position letters: `SF CF CB LL` is a front SCE, a front CPE,
|
|
53
|
+
* a back CPE and an LFE. `null` for a config with a channel configuration or one `FFmpeg` would not
|
|
54
|
+
* decode.
|
|
60
55
|
*/
|
|
61
56
|
export declare function aacProgramConfigElements(config: Uint8Array): string | null;
|
|
62
57
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* `undefined` when the packet does not start with a frame `FFmpeg` decodes.
|
|
58
|
+
* Speakers `FFmpeg`'s AC-3 or E-AC-3 decoder produces for a packet, including channels added by an
|
|
59
|
+
* E-AC-3 dependent frame. `undefined` when the packet does not start with a decodable frame.
|
|
66
60
|
*/
|
|
67
61
|
export declare function ac3Speakers(packet: Uint8Array): AudioSpeaker[] | undefined;
|
|
68
62
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* (channel extensions, an extension substream, a substream without a core) or is not a 16-bit
|
|
72
|
-
* core; those layouts are not read.
|
|
63
|
+
* Speakers of a core-only DTS packet. `null` for anything beyond a 16-bit core (channel extensions,
|
|
64
|
+
* extension substreams, coreless substreams), whose layouts are not read.
|
|
73
65
|
*/
|
|
74
66
|
export declare function dtsSpeakers(packet: Uint8Array): AudioSpeaker[] | null;
|
|
75
|
-
/**
|
|
67
|
+
/** AAC channel configuration for each ADTS channel count (configurations 1 to 7). */
|
|
76
68
|
export declare const ADTS_CONFIGURATIONS: Readonly<Record<number, number>>;
|
|
77
|
-
/**
|
|
78
|
-
* The AAC channel configuration of an `AudioSpecificConfig`. `null` for a truncated config or for
|
|
79
|
-
* configuration 0, which defers to a program config element.
|
|
80
|
-
*/
|
|
69
|
+
/** AAC channel configuration, or `null` when truncated or 0 (defers to a PCE). */
|
|
81
70
|
export declare function aacChannelConfiguration(config: Uint8Array): number | null;
|
|
82
|
-
/**
|
|
71
|
+
/** `OpusHead` channel mapping family; 0 without a head. */
|
|
83
72
|
export declare function opusMappingFamily(description: Uint8Array | null): number;
|
|
84
73
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* head, Vorbis's and FLAC's fixed orders, an AC-3 or E-AC-3 frame's channel mode, LFE and
|
|
89
|
-
* dependent channel map, a DTS core's channel arrangement, and mono or stereo for any codec.
|
|
90
|
-
* `null` when the codec says nothing the decoder would read, or the decoder would leave the layout
|
|
91
|
-
* unspecified.
|
|
74
|
+
* Speakers a codec's own headers declare, in `FFmpeg`'s decoder plane order. Covers AAC, Opus
|
|
75
|
+
* mapping families 0 and 1, Vorbis and FLAC fixed orders, AC-3/E-AC-3, DTS cores, and mono or
|
|
76
|
+
* stereo for any codec. `null` when the decoder would leave the layout unspecified.
|
|
92
77
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @param description The decoder configuration's description (`AudioSpecificConfig`,
|
|
96
|
-
* `OpusHead`), when the track has one.
|
|
97
|
-
* @param packet The track's first packet, which an AC-3, E-AC-3 or DTS decoder reads its layout
|
|
98
|
-
* from.
|
|
78
|
+
* Other decoders may deliver another order (Safari's AAC keeps bitstream order);
|
|
79
|
+
* `decoder-order.ts` measures and corrects for that.
|
|
99
80
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
81
|
+
* @param codec mediabunny's codec name (`aac`, `opus`, `vorbis`, `flac`, `ac3`, `eac3`, `dts`).
|
|
82
|
+
* @param description The decoder configuration description (`AudioSpecificConfig`, `OpusHead`).
|
|
83
|
+
* @param packet The first packet, from which AC-3, E-AC-3 and DTS layouts are read.
|
|
103
84
|
*/
|
|
104
85
|
export declare function codecSpeakers(codec: string | null, description: Uint8Array | null, channels: number, packet?: Uint8Array | null): AudioSpeaker[] | null;
|
|
105
86
|
/**
|
|
106
|
-
*
|
|
87
|
+
* Speakers the source's primary audio track declares, or `null`.
|
|
107
88
|
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* Matroska, a QuickTime `chan` or ISO `chnl` box, and FLAC's own order otherwise. PCM, and any
|
|
112
|
-
* other codec, is laid out by its container: a WAVE channel mask, a QuickTime `chan` box, an ISO
|
|
113
|
-
* `chnl` box.
|
|
89
|
+
* Codecs whose decoder sets a layout use {@link codecSpeakers} regardless of the container. FLAC
|
|
90
|
+
* takes a matching container layout (channel-mask comment, `chan` or `chnl`), else its own order.
|
|
91
|
+
* PCM and other codecs use the container's WAVE mask, `chan` or `chnl` box.
|
|
114
92
|
*
|
|
115
93
|
* @param read Reads the source file's bytes.
|
|
116
94
|
* @param size The source file's size in bytes.
|
|
117
|
-
* @param track
|
|
118
|
-
*
|
|
95
|
+
* @param track `id` selects the QuickTime `trak`; without a match, the first track with a layout
|
|
96
|
+
* box is used.
|
|
119
97
|
* @param description The track's decoder configuration description, if any.
|
|
120
|
-
* @param firstPacket Reads the
|
|
121
|
-
*
|
|
98
|
+
* @param firstPacket Reads the first packet, for AC-3, E-AC-3 and DTS; resolves `null` when there
|
|
99
|
+
* is none.
|
|
122
100
|
*
|
|
123
101
|
* Rejects only when `read` or `firstPacket` rejects; malformed bytes resolve to `null`.
|
|
124
102
|
*/
|