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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type TrackDecodeFacts } from "./hdr-frames.js";
|
|
2
|
+
/** Whether `error` is a WebCodecs decoder failure (not an abort, stall or end of stream). */
|
|
3
|
+
export declare function isDecoderFailure(error: unknown): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Runs `decodeOnce`; on a decoder failure, if `reopenSoftware` is given, reopens in software and
|
|
6
|
+
* runs it once more.
|
|
7
|
+
*/
|
|
8
|
+
export declare function withSoftwareFallback<T>(decodeOnce: () => Promise<T>, reopenSoftware: ((cause: DOMException) => Promise<void>) | undefined): Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Turns a decoder failure into {@link DecodeUnavailableError} when no frame of the track was ever
|
|
11
|
+
* decoded. Other errors are returned unchanged.
|
|
12
|
+
*/
|
|
13
|
+
export declare function decodeFailureOf(error: unknown, name: string, facts: TrackDecodeFacts, decodedAny: boolean): unknown;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Shared decoder failure policy: retry once in software, and report a track that never produced a
|
|
2
|
+
// frame as undecodable rather than as a retryable failure.
|
|
3
|
+
import { DecodeUnavailableError, decodeRefusalMessage, } from "./hdr-frames.js";
|
|
4
|
+
/** Whether `error` is a WebCodecs decoder failure (not an abort, stall or end of stream). */
|
|
5
|
+
export function isDecoderFailure(error) {
|
|
6
|
+
return (error instanceof DOMException &&
|
|
7
|
+
["EncodingError", "NotSupportedError", "OperationError"].includes(error.name));
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Runs `decodeOnce`; on a decoder failure, if `reopenSoftware` is given, reopens in software and
|
|
11
|
+
* runs it once more.
|
|
12
|
+
*/
|
|
13
|
+
export async function withSoftwareFallback(decodeOnce, reopenSoftware) {
|
|
14
|
+
try {
|
|
15
|
+
return await decodeOnce();
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (reopenSoftware === undefined || !isDecoderFailure(error))
|
|
19
|
+
throw error;
|
|
20
|
+
await reopenSoftware(error);
|
|
21
|
+
return decodeOnce();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Turns a decoder failure into {@link DecodeUnavailableError} when no frame of the track was ever
|
|
26
|
+
* decoded. Other errors are returned unchanged.
|
|
27
|
+
*/
|
|
28
|
+
export function decodeFailureOf(error, name, facts, decodedAny) {
|
|
29
|
+
if (decodedAny || !isDecoderFailure(error))
|
|
30
|
+
return error;
|
|
31
|
+
const refused = {
|
|
32
|
+
...facts,
|
|
33
|
+
browserError: `${error.name}: ${error.message}`,
|
|
34
|
+
};
|
|
35
|
+
return new DecodeUnavailableError(decodeRefusalMessage(name, refused), refused, {
|
|
36
|
+
cause: error,
|
|
37
|
+
});
|
|
38
|
+
}
|
package/dist/decoder-order.d.ts
CHANGED
|
@@ -1,66 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A short 48 kHz file whose plane `k`,
|
|
3
|
-
*
|
|
4
|
-
* (`scripts/generate-decoder-order-fixtures.mjs` writes them).
|
|
2
|
+
* A short 48 kHz file whose plane `k`, in `FFmpeg`'s order, holds only tone `tones[k]`. Written by
|
|
3
|
+
* `scripts/generate-decoder-order-fixtures.mjs`.
|
|
5
4
|
*/
|
|
6
5
|
export interface DecoderOrderFixture {
|
|
7
|
-
/**
|
|
6
|
+
/** Speakers in `FFmpeg`'s order. */
|
|
8
7
|
readonly speakers: readonly string[];
|
|
9
|
-
/**
|
|
8
|
+
/** Tone per plane in hertz, in `FFmpeg`'s order (93.75 Hz for the LFE). */
|
|
10
9
|
readonly tones: readonly number[];
|
|
11
|
-
/**
|
|
12
|
-
* The sample of the decoded planes the tones are read from, 1024 samples on: past the codec's
|
|
13
|
-
* priming and the encoder's first frame.
|
|
14
|
-
*/
|
|
10
|
+
/** First sample analyzed, past the codec priming and the encoder's first frame. */
|
|
15
11
|
readonly start: number;
|
|
16
|
-
/**
|
|
12
|
+
/** Base64 file contents. */
|
|
17
13
|
readonly file: string;
|
|
18
14
|
}
|
|
19
15
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* a codec whose decoders deliver one order (`FFmpeg` keeps FLAC's, PCM's and an unspecified
|
|
23
|
-
* layout's), or that no browser path decodes:
|
|
16
|
+
* Fixture key for the stream property that decides decoder plane order, or `null` when order
|
|
17
|
+
* cannot vary (one or two channels, or codecs with a single order such as FLAC and PCM):
|
|
24
18
|
*
|
|
25
|
-
* - AAC:
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* -
|
|
29
|
-
* -
|
|
30
|
-
* - AC-3 and E-AC-3: the speakers the first packet's frame header declares
|
|
31
|
-
* (`ac3:FL FR FC LFE SL SR`).
|
|
19
|
+
* - AAC: channel configuration (`aac:6`), ADTS configuration without a description
|
|
20
|
+
* (`aac:adts:6`), or program config elements (`aac:pce:SF CF CB LL`);
|
|
21
|
+
* - Opus mapping family 1: channel count (`opus:1:6`);
|
|
22
|
+
* - Vorbis: channel count (`vorbis:6`);
|
|
23
|
+
* - AC-3 and E-AC-3: speakers in the first frame header (`ac3:FL FR FC LFE SL SR`).
|
|
32
24
|
*
|
|
33
|
-
*
|
|
25
|
+
* Keys without a fixture are assumed to decode in `FFmpeg`'s order.
|
|
34
26
|
*/
|
|
35
27
|
export declare function decoderOrderKey(codec: string | null, description: Uint8Array | null, channels: number, packet?: Uint8Array | null): string | null;
|
|
36
|
-
/**
|
|
28
|
+
/** Fixture for a {@link decoderOrderKey} key, or `null`. */
|
|
37
29
|
export declare function decoderOrderFixture(key: string): Promise<DecoderOrderFixture | null>;
|
|
38
30
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* to read.
|
|
31
|
+
* Maps each decoded plane to its index in `FFmpeg`'s order by its dominant tone. Returns `null`
|
|
32
|
+
* unless every plane is identified exactly once.
|
|
42
33
|
*
|
|
43
|
-
* @param planes
|
|
44
|
-
* @param tones
|
|
45
|
-
* @param start
|
|
34
|
+
* @param planes Decoded fixture planes, in the decoder's order.
|
|
35
|
+
* @param tones Tone per plane in `FFmpeg`'s order.
|
|
36
|
+
* @param start First sample analyzed.
|
|
46
37
|
*/
|
|
47
38
|
export declare function planeOrderOfTones(planes: readonly Float32Array[], tones: readonly number[], sampleRate: number, start: number): number[] | null;
|
|
48
|
-
/**
|
|
39
|
+
/** Decoded fixture planes in the decoder's order. */
|
|
49
40
|
export interface DecodedFixture {
|
|
50
41
|
readonly planes: readonly Float32Array[];
|
|
51
42
|
readonly sampleRate: number;
|
|
52
43
|
}
|
|
53
|
-
/** Decodes a fixture file's primary audio track whole. */
|
|
54
44
|
export type FixtureDecode = (file: Uint8Array) => Promise<DecodedFixture>;
|
|
55
|
-
/**
|
|
56
|
-
* The plane order `decode` delivers `fixture` in ({@link planeOrderOfTones}), or `null` when it
|
|
57
|
-
* cannot be measured: the decode fails, or its planes do not each hold one tone.
|
|
58
|
-
*/
|
|
45
|
+
/** Plane order of `fixture` as `decode` delivers it, or `null` when it cannot be measured. */
|
|
59
46
|
export declare function measurePlaneOrder(fixture: DecoderOrderFixture, decode: FixtureDecode): Promise<number[] | null>;
|
|
60
47
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* kept; resolves `null` when there is nothing to measure (no key, or no fixture for it) or the
|
|
64
|
-
* measurement fails, and the decoder's order is then taken as `FFmpeg`'s. Never rejects.
|
|
48
|
+
* Decoder plane order for streams with this key, measured once and cached. Resolves `null` (use
|
|
49
|
+
* `FFmpeg`'s order) when there is no key or fixture, or measurement fails. Never rejects.
|
|
65
50
|
*/
|
|
66
51
|
export declare function decoderPlaneOrder(key: string | null): Promise<readonly number[] | null>;
|
package/dist/decoder-order.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Measures the channel order a browser's audio decoder delivers.
|
|
3
3
|
*
|
|
4
|
-
* WebCodecs leaves
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* the order is measured: a short built-in file whose planes each hold a tone of their own is
|
|
10
|
-
* decoded through the same decoder a source is, once per kind of stream in each page or worker,
|
|
11
|
-
* and each plane's tone says which of `FFmpeg`'s planes it is. A source's blocks are then laid out
|
|
12
|
-
* in `FFmpeg`'s order whatever the decoder delivers.
|
|
4
|
+
* WebCodecs leaves `AudioData` plane order to the decoder. `codecSpeakers` assumes `FFmpeg`'s
|
|
5
|
+
* order, which Chromium and Firefox keep, but Safari's AAC decoder delivers bitstream order (C L R
|
|
6
|
+
* for configuration 3), and Vorbis or AC-3 native order would differ the same way. A built-in file
|
|
7
|
+
* with a distinct tone per plane is decoded once per stream kind, and the tones map each decoded
|
|
8
|
+
* plane back to `FFmpeg`'s order.
|
|
13
9
|
*/
|
|
14
10
|
import { ALL_FORMATS, AudioSampleSink, BufferSource, Input } from "mediabunny";
|
|
15
11
|
import { ADTS_CONFIGURATIONS, aacChannelConfiguration, aacProgramConfigElements, ac3Speakers, opusMappingFamily, } from "./audio-layout.js";
|
|
16
|
-
/**
|
|
12
|
+
/** Fixtures per codec, loaded on first use. */
|
|
17
13
|
const FIXTURES = {
|
|
18
14
|
aac: () => import("./generated/aac-order-fixtures.js"),
|
|
19
15
|
opus: () => import("./generated/opus-order-fixtures.js"),
|
|
@@ -21,25 +17,21 @@ const FIXTURES = {
|
|
|
21
17
|
ac3: () => import("./generated/ac3-order-fixtures.js"),
|
|
22
18
|
eac3: () => import("./generated/eac3-order-fixtures.js"),
|
|
23
19
|
};
|
|
24
|
-
/**
|
|
20
|
+
/** Samples analyzed per plane. Each fixture tone sits on a bin of this length at 48 kHz. */
|
|
25
21
|
const ANALYSIS_FRAMES = 1_024;
|
|
26
|
-
/**
|
|
22
|
+
/** Power ratio the loudest tone needs over the next to identify a plane. */
|
|
27
23
|
const TONE_DOMINANCE = 10;
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* a codec whose decoders deliver one order (`FFmpeg` keeps FLAC's, PCM's and an unspecified
|
|
32
|
-
* layout's), or that no browser path decodes:
|
|
25
|
+
* Fixture key for the stream property that decides decoder plane order, or `null` when order
|
|
26
|
+
* cannot vary (one or two channels, or codecs with a single order such as FLAC and PCM):
|
|
33
27
|
*
|
|
34
|
-
* - AAC:
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* -
|
|
38
|
-
* -
|
|
39
|
-
* - AC-3 and E-AC-3: the speakers the first packet's frame header declares
|
|
40
|
-
* (`ac3:FL FR FC LFE SL SR`).
|
|
28
|
+
* - AAC: channel configuration (`aac:6`), ADTS configuration without a description
|
|
29
|
+
* (`aac:adts:6`), or program config elements (`aac:pce:SF CF CB LL`);
|
|
30
|
+
* - Opus mapping family 1: channel count (`opus:1:6`);
|
|
31
|
+
* - Vorbis: channel count (`vorbis:6`);
|
|
32
|
+
* - AC-3 and E-AC-3: speakers in the first frame header (`ac3:FL FR FC LFE SL SR`).
|
|
41
33
|
*
|
|
42
|
-
*
|
|
34
|
+
* Keys without a fixture are assumed to decode in `FFmpeg`'s order.
|
|
43
35
|
*/
|
|
44
36
|
export function decoderOrderKey(codec, description, channels, packet = null) {
|
|
45
37
|
if (channels <= 2)
|
|
@@ -69,7 +61,7 @@ export function decoderOrderKey(codec, description, channels, packet = null) {
|
|
|
69
61
|
return null;
|
|
70
62
|
}
|
|
71
63
|
}
|
|
72
|
-
/**
|
|
64
|
+
/** Fixture for a {@link decoderOrderKey} key, or `null`. */
|
|
73
65
|
export async function decoderOrderFixture(key) {
|
|
74
66
|
const load = FIXTURES[key.slice(0, key.indexOf(":"))];
|
|
75
67
|
if (load === undefined)
|
|
@@ -88,13 +80,12 @@ function tonePower(samples, frequency, sampleRate) {
|
|
|
88
80
|
return (previous * previous + before * before - coefficient * previous * before);
|
|
89
81
|
}
|
|
90
82
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* to read.
|
|
83
|
+
* Maps each decoded plane to its index in `FFmpeg`'s order by its dominant tone. Returns `null`
|
|
84
|
+
* unless every plane is identified exactly once.
|
|
94
85
|
*
|
|
95
|
-
* @param planes
|
|
96
|
-
* @param tones
|
|
97
|
-
* @param start
|
|
86
|
+
* @param planes Decoded fixture planes, in the decoder's order.
|
|
87
|
+
* @param tones Tone per plane in `FFmpeg`'s order.
|
|
88
|
+
* @param start First sample analyzed.
|
|
98
89
|
*/
|
|
99
90
|
export function planeOrderOfTones(planes, tones, sampleRate, start) {
|
|
100
91
|
if (planes.length !== tones.length)
|
|
@@ -113,10 +104,7 @@ export function planeOrderOfTones(planes, tones, sampleRate, start) {
|
|
|
113
104
|
}
|
|
114
105
|
return new Set(order).size === order.length ? order : null;
|
|
115
106
|
}
|
|
116
|
-
/**
|
|
117
|
-
* The plane order `decode` delivers `fixture` in ({@link planeOrderOfTones}), or `null` when it
|
|
118
|
-
* cannot be measured: the decode fails, or its planes do not each hold one tone.
|
|
119
|
-
*/
|
|
107
|
+
/** Plane order of `fixture` as `decode` delivers it, or `null` when it cannot be measured. */
|
|
120
108
|
export async function measurePlaneOrder(fixture, decode) {
|
|
121
109
|
let decoded;
|
|
122
110
|
try {
|
|
@@ -134,7 +122,7 @@ function base64Bytes(text) {
|
|
|
134
122
|
bytes[index] = binary.charCodeAt(index);
|
|
135
123
|
return bytes;
|
|
136
124
|
}
|
|
137
|
-
/** Decodes
|
|
125
|
+
/** Decodes through the same mediabunny path a source of this codec uses. */
|
|
138
126
|
async function decodeWithMediabunny(file) {
|
|
139
127
|
const input = new Input({
|
|
140
128
|
source: new BufferSource(file),
|
|
@@ -179,13 +167,11 @@ async function decodeWithMediabunny(file) {
|
|
|
179
167
|
input.dispose();
|
|
180
168
|
}
|
|
181
169
|
}
|
|
182
|
-
/**
|
|
170
|
+
/** Cached orders by fixture key; failed measurements cache `null`. */
|
|
183
171
|
const measured = new Map();
|
|
184
172
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* kept; resolves `null` when there is nothing to measure (no key, or no fixture for it) or the
|
|
188
|
-
* measurement fails, and the decoder's order is then taken as `FFmpeg`'s. Never rejects.
|
|
173
|
+
* Decoder plane order for streams with this key, measured once and cached. Resolves `null` (use
|
|
174
|
+
* `FFmpeg`'s order) when there is no key or fixture, or measurement fails. Never rejects.
|
|
189
175
|
*/
|
|
190
176
|
export function decoderPlaneOrder(key) {
|
|
191
177
|
if (key === null)
|