@hyperframes/engine 0.4.6 → 0.4.8
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/dist/config.d.ts +6 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/services/browserManager.d.ts.map +1 -1
- package/dist/services/browserManager.js +6 -3
- package/dist/services/browserManager.js.map +1 -1
- package/dist/services/chunkEncoder.d.ts +14 -7
- package/dist/services/chunkEncoder.d.ts.map +1 -1
- package/dist/services/chunkEncoder.js +25 -9
- package/dist/services/chunkEncoder.js.map +1 -1
- package/dist/services/chunkEncoder.types.d.ts +4 -0
- package/dist/services/chunkEncoder.types.d.ts.map +1 -1
- package/dist/services/hdrCapture.d.ts +62 -0
- package/dist/services/hdrCapture.d.ts.map +1 -0
- package/dist/services/hdrCapture.js +259 -0
- package/dist/services/hdrCapture.js.map +1 -0
- package/dist/services/screenshotService.d.ts +115 -0
- package/dist/services/screenshotService.d.ts.map +1 -1
- package/dist/services/screenshotService.js +252 -19
- package/dist/services/screenshotService.js.map +1 -1
- package/dist/services/streamingEncoder.d.ts +18 -3
- package/dist/services/streamingEncoder.d.ts.map +1 -1
- package/dist/services/streamingEncoder.js +104 -50
- package/dist/services/streamingEncoder.js.map +1 -1
- package/dist/services/videoFrameExtractor.d.ts.map +1 -1
- package/dist/services/videoFrameExtractor.js +109 -18
- package/dist/services/videoFrameExtractor.js.map +1 -1
- package/dist/services/videoFrameInjector.d.ts +59 -0
- package/dist/services/videoFrameInjector.d.ts.map +1 -1
- package/dist/services/videoFrameInjector.js +290 -0
- package/dist/services/videoFrameInjector.js.map +1 -1
- package/dist/types.d.ts +32 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/alphaBlit.d.ts +105 -0
- package/dist/utils/alphaBlit.d.ts.map +1 -0
- package/dist/utils/alphaBlit.js +550 -0
- package/dist/utils/alphaBlit.js.map +1 -0
- package/dist/utils/ffprobe.d.ts +10 -0
- package/dist/utils/ffprobe.d.ts.map +1 -1
- package/dist/utils/ffprobe.js +7 -0
- package/dist/utils/ffprobe.js.map +1 -1
- package/dist/utils/hdr.d.ts +82 -0
- package/dist/utils/hdr.d.ts.map +1 -0
- package/dist/utils/hdr.js +87 -0
- package/dist/utils/hdr.js.map +1 -0
- package/dist/utils/layerCompositor.d.ts +36 -0
- package/dist/utils/layerCompositor.d.ts.map +1 -0
- package/dist/utils/layerCompositor.js +49 -0
- package/dist/utils/layerCompositor.js.map +1 -0
- package/dist/utils/shaderTransitions.d.ts +166 -0
- package/dist/utils/shaderTransitions.d.ts.map +1 -0
- package/dist/utils/shaderTransitions.js +894 -0
- package/dist/utils/shaderTransitions.js.map +1 -0
- package/package.json +3 -2
- package/src/config.ts +16 -0
- package/src/index.ts +61 -0
- package/src/services/browserManager.ts +6 -3
- package/src/services/chunkEncoder.test.ts +88 -0
- package/src/services/chunkEncoder.ts +35 -9
- package/src/services/chunkEncoder.types.ts +3 -0
- package/src/services/hdrCapture.test.ts +159 -0
- package/src/services/hdrCapture.ts +354 -0
- package/src/services/screenshotService.ts +271 -17
- package/src/services/streamingEncoder.test.ts +228 -0
- package/src/services/streamingEncoder.ts +153 -63
- package/src/services/videoFrameExtractor.ts +135 -31
- package/src/services/videoFrameInjector.ts +342 -0
- package/src/types.ts +34 -0
- package/src/utils/alphaBlit.test.ts +993 -0
- package/src/utils/alphaBlit.ts +643 -0
- package/src/utils/ffprobe.ts +22 -0
- package/src/utils/hdr.test.ts +191 -0
- package/src/utils/hdr.ts +137 -0
- package/src/utils/layerCompositor.test.ts +141 -0
- package/src/utils/layerCompositor.ts +58 -0
- package/src/utils/shaderTransitions.test.ts +674 -0
- package/src/utils/shaderTransitions.ts +1130 -0
- package/src/utils/uint16-alignment-audit.test.ts +125 -0
- package/tsconfig.json +2 -1
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|
|
5
|
+
* parameter generation for the HDR rendering pipeline.
|
|
6
|
+
*/
|
|
7
|
+
import type { VideoColorSpace } from "./ffprobe.js";
|
|
8
|
+
export type HdrTransfer = "hlg" | "pq";
|
|
9
|
+
/**
|
|
10
|
+
* Check if a video's color space indicates HDR content.
|
|
11
|
+
* Re-exported from videoFrameExtractor for backward compatibility.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isHdrColorSpace(cs: VideoColorSpace | null): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Determine the HDR transfer function from a video's color space metadata.
|
|
16
|
+
*
|
|
17
|
+
* IMPORTANT: Callers must gate on `isHdrColorSpace(cs)` first. This function
|
|
18
|
+
* assumes the input has already been classified as HDR and defaults ambiguous
|
|
19
|
+
* inputs to "hlg" — calling it with an SDR color space silently returns "hlg",
|
|
20
|
+
* which is wrong for SDR.
|
|
21
|
+
*
|
|
22
|
+
* Returns "pq" for SMPTE 2084, "hlg" for ARIB STD-B67, defaults to "hlg".
|
|
23
|
+
*/
|
|
24
|
+
export declare function detectTransfer(cs: VideoColorSpace | null): HdrTransfer;
|
|
25
|
+
/**
|
|
26
|
+
* HDR static metadata for the encoded stream.
|
|
27
|
+
*
|
|
28
|
+
* `masterDisplay` is the SMPTE ST 2086 mastering-display color volume string
|
|
29
|
+
* accepted by x265 (`G(Gx,Gy)B(Bx,By)R(Rx,Ry)WP(WPx,WPy)L(Lmax,Lmin)`).
|
|
30
|
+
* Chromaticity values are scaled by 50000 (0.00002 cd/m² per unit) and
|
|
31
|
+
* luminance values by 10000 (0.0001 cd/m² per unit).
|
|
32
|
+
*
|
|
33
|
+
* `maxCll` is the CTA-861.3 Content Light Level pair `MaxCLL,MaxFALL` in
|
|
34
|
+
* cd/m². Without these SEI messages, downstream players (Apple QuickTime,
|
|
35
|
+
* YouTube, HDR TVs) treat the stream as SDR BT.2020 and tone-map incorrectly
|
|
36
|
+
* — see packages/producer/scripts/hdr-smoke.ts for the regression assertion.
|
|
37
|
+
*/
|
|
38
|
+
export interface HdrMasteringMetadata {
|
|
39
|
+
masterDisplay: string;
|
|
40
|
+
maxCll: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Default HDR10 mastering metadata: P3-D65 primaries inside a BT.2020
|
|
44
|
+
* container, mastered for 0.0001–1000 cd/m² with MaxCLL=1000, MaxFALL=400.
|
|
45
|
+
*
|
|
46
|
+
* These are conservative defaults that match how most HDR10 grading suites
|
|
47
|
+
* (Premiere, DaVinci Resolve) tag content when per-frame measured values
|
|
48
|
+
* aren't available. A future PR can plumb measured MaxCLL through `--hdr-opt`.
|
|
49
|
+
*/
|
|
50
|
+
export declare const DEFAULT_HDR10_MASTERING: HdrMasteringMetadata;
|
|
51
|
+
export interface HdrEncoderColorParams {
|
|
52
|
+
colorPrimaries: string;
|
|
53
|
+
colorTrc: string;
|
|
54
|
+
colorspace: string;
|
|
55
|
+
pixelFormat: string;
|
|
56
|
+
/**
|
|
57
|
+
* Full x265-params string including color tagging and HDR static metadata.
|
|
58
|
+
* Pass directly to `-x265-params` (concatenate with other options via `:`).
|
|
59
|
+
*/
|
|
60
|
+
x265ColorParams: string;
|
|
61
|
+
/** The mastering metadata that was baked into `x265ColorParams`. */
|
|
62
|
+
mastering: HdrMasteringMetadata;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Get FFmpeg encoder color parameters for a given HDR transfer function.
|
|
66
|
+
*
|
|
67
|
+
* The returned `x265ColorParams` includes both color tagging
|
|
68
|
+
* (`colorprim`/`transfer`/`colormatrix`) and HDR static metadata
|
|
69
|
+
* (`master-display`/`max-cll`). Without the static metadata the encoded
|
|
70
|
+
* stream is rejected as SDR by most HDR-aware players and CDNs.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getHdrEncoderColorParams(transfer: HdrTransfer, mastering?: HdrMasteringMetadata): HdrEncoderColorParams;
|
|
73
|
+
export interface CompositionHdrInfo {
|
|
74
|
+
hasHdr: boolean;
|
|
75
|
+
dominantTransfer: HdrTransfer | null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Analyze a set of video color spaces to determine if the composition
|
|
79
|
+
* contains HDR content and what the dominant transfer function is.
|
|
80
|
+
*/
|
|
81
|
+
export declare function analyzeCompositionHdr(colorSpaces: Array<VideoColorSpace | null>): CompositionHdrInfo;
|
|
82
|
+
//# sourceMappingURL=hdr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hdr.d.ts","sourceRoot":"","sources":["../../src/utils/hdr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,IAAI,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI,GAAG,OAAO,CAQnE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,eAAe,GAAG,IAAI,GAAG,WAAW,CAGtE;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,EAAE,oBAGrC,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,SAAS,EAAE,oBAAoB,CAAC;CACjC;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,WAAW,EACrB,SAAS,GAAE,oBAA8C,GACxD,qBAAqB,CAYvB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,WAAW,GAAG,IAAI,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,KAAK,CAAC,eAAe,GAAG,IAAI,CAAC,GACzC,kBAAkB,CAepB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HDR Color Space Utilities
|
|
3
|
+
*
|
|
4
|
+
* Centralized HDR detection, transfer type handling, and FFmpeg color
|
|
5
|
+
* parameter generation for the HDR rendering pipeline.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Check if a video's color space indicates HDR content.
|
|
9
|
+
* Re-exported from videoFrameExtractor for backward compatibility.
|
|
10
|
+
*/
|
|
11
|
+
export function isHdrColorSpace(cs) {
|
|
12
|
+
if (!cs)
|
|
13
|
+
return false;
|
|
14
|
+
return (cs.colorPrimaries.includes("bt2020") ||
|
|
15
|
+
cs.colorSpace.includes("bt2020") ||
|
|
16
|
+
cs.colorTransfer === "smpte2084" ||
|
|
17
|
+
cs.colorTransfer === "arib-std-b67");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Determine the HDR transfer function from a video's color space metadata.
|
|
21
|
+
*
|
|
22
|
+
* IMPORTANT: Callers must gate on `isHdrColorSpace(cs)` first. This function
|
|
23
|
+
* assumes the input has already been classified as HDR and defaults ambiguous
|
|
24
|
+
* inputs to "hlg" — calling it with an SDR color space silently returns "hlg",
|
|
25
|
+
* which is wrong for SDR.
|
|
26
|
+
*
|
|
27
|
+
* Returns "pq" for SMPTE 2084, "hlg" for ARIB STD-B67, defaults to "hlg".
|
|
28
|
+
*/
|
|
29
|
+
export function detectTransfer(cs) {
|
|
30
|
+
if (cs?.colorTransfer === "smpte2084")
|
|
31
|
+
return "pq";
|
|
32
|
+
return "hlg";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Default HDR10 mastering metadata: P3-D65 primaries inside a BT.2020
|
|
36
|
+
* container, mastered for 0.0001–1000 cd/m² with MaxCLL=1000, MaxFALL=400.
|
|
37
|
+
*
|
|
38
|
+
* These are conservative defaults that match how most HDR10 grading suites
|
|
39
|
+
* (Premiere, DaVinci Resolve) tag content when per-frame measured values
|
|
40
|
+
* aren't available. A future PR can plumb measured MaxCLL through `--hdr-opt`.
|
|
41
|
+
*/
|
|
42
|
+
export const DEFAULT_HDR10_MASTERING = {
|
|
43
|
+
masterDisplay: "G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)",
|
|
44
|
+
maxCll: "1000,400",
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Get FFmpeg encoder color parameters for a given HDR transfer function.
|
|
48
|
+
*
|
|
49
|
+
* The returned `x265ColorParams` includes both color tagging
|
|
50
|
+
* (`colorprim`/`transfer`/`colormatrix`) and HDR static metadata
|
|
51
|
+
* (`master-display`/`max-cll`). Without the static metadata the encoded
|
|
52
|
+
* stream is rejected as SDR by most HDR-aware players and CDNs.
|
|
53
|
+
*/
|
|
54
|
+
export function getHdrEncoderColorParams(transfer, mastering = DEFAULT_HDR10_MASTERING) {
|
|
55
|
+
const colorTrc = transfer === "pq" ? "smpte2084" : "arib-std-b67";
|
|
56
|
+
const tagging = `colorprim=bt2020:transfer=${colorTrc}:colormatrix=bt2020nc`;
|
|
57
|
+
const metadata = `master-display=${mastering.masterDisplay}:max-cll=${mastering.maxCll}`;
|
|
58
|
+
return {
|
|
59
|
+
colorPrimaries: "bt2020",
|
|
60
|
+
colorTrc,
|
|
61
|
+
colorspace: "bt2020nc",
|
|
62
|
+
pixelFormat: "yuv420p10le",
|
|
63
|
+
x265ColorParams: `${tagging}:${metadata}`,
|
|
64
|
+
mastering,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Analyze a set of video color spaces to determine if the composition
|
|
69
|
+
* contains HDR content and what the dominant transfer function is.
|
|
70
|
+
*/
|
|
71
|
+
export function analyzeCompositionHdr(colorSpaces) {
|
|
72
|
+
let hasPq = false;
|
|
73
|
+
let hasHdr = false;
|
|
74
|
+
for (const cs of colorSpaces) {
|
|
75
|
+
if (!isHdrColorSpace(cs))
|
|
76
|
+
continue;
|
|
77
|
+
hasHdr = true;
|
|
78
|
+
if (cs?.colorTransfer === "smpte2084")
|
|
79
|
+
hasPq = true;
|
|
80
|
+
}
|
|
81
|
+
if (!hasHdr)
|
|
82
|
+
return { hasHdr: false, dominantTransfer: null };
|
|
83
|
+
// PQ takes priority — it's the more common HDR10 format
|
|
84
|
+
const dominantTransfer = hasPq ? "pq" : "hlg";
|
|
85
|
+
return { hasHdr: true, dominantTransfer };
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=hdr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hdr.js","sourceRoot":"","sources":["../../src/utils/hdr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,EAA0B;IACxD,IAAI,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC;IACtB,OAAO,CACL,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACpC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAChC,EAAE,CAAC,aAAa,KAAK,WAAW;QAChC,EAAE,CAAC,aAAa,KAAK,cAAc,CACpC,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,EAA0B;IACvD,IAAI,EAAE,EAAE,aAAa,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC;AAoBD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,aAAa,EAAE,sEAAsE;IACrF,MAAM,EAAE,UAAU;CACnB,CAAC;AAgBF;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,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5
|
+
* per-frame compositing loop. Adjacent DOM elements merge into a single
|
|
6
|
+
* layer to minimize Chrome screenshots.
|
|
7
|
+
*/
|
|
8
|
+
import type { ElementStackingInfo } from "../services/videoFrameInjector.js";
|
|
9
|
+
export type { ElementStackingInfo };
|
|
10
|
+
export type CompositeLayer = {
|
|
11
|
+
type: "dom";
|
|
12
|
+
elementIds: string[];
|
|
13
|
+
} | {
|
|
14
|
+
type: "hdr";
|
|
15
|
+
element: ElementStackingInfo;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Group z-sorted elements into composite layers. Adjacent DOM elements merge
|
|
19
|
+
* into a single layer; each HDR video/image is its own layer.
|
|
20
|
+
*
|
|
21
|
+
* Elements are sorted by \`zIndex\` ascending (back to front). Ties fall
|
|
22
|
+
* through to V8's stable sort, which preserves \`querySelectorAll\` DOM order —
|
|
23
|
+
* this is the same order Chrome uses for equal-z elements in a stacking
|
|
24
|
+
* context, so the blit order matches what the user sees in-browser.
|
|
25
|
+
*
|
|
26
|
+
* The DOM merge doesn't lose information: DOM layers are rendered via a
|
|
27
|
+
* full-page screenshot with non-layer elements hidden, so within-layer
|
|
28
|
+
* z-order is handled by Chrome itself.
|
|
29
|
+
*
|
|
30
|
+
* Invisible elements ARE included (video elements are hidden by the frame
|
|
31
|
+
* injector, but their injected \`<img>\` replacements are visible — they must
|
|
32
|
+
* stay in the correct z-ordered layer so sibling layers' DOM screenshots
|
|
33
|
+
* hide them).
|
|
34
|
+
*/
|
|
35
|
+
export declare function groupIntoLayers(elements: ElementStackingInfo[]): CompositeLayer[];
|
|
36
|
+
//# sourceMappingURL=layerCompositor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerCompositor.d.ts","sourceRoot":"","sources":["../../src/utils/layerCompositor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,YAAY,EAAE,mBAAmB,EAAE,CAAC;AAEpC,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,mBAAmB,EAAE,GAAG,cAAc,EAAE,CAuBjF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer Compositor — z-order analysis for multi-layer HDR compositing.
|
|
3
|
+
*
|
|
4
|
+
* Groups timed elements into z-ordered layers (DOM or HDR) for the
|
|
5
|
+
* per-frame compositing loop. Adjacent DOM elements merge into a single
|
|
6
|
+
* layer to minimize Chrome screenshots.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Group z-sorted elements into composite layers. Adjacent DOM elements merge
|
|
10
|
+
* into a single layer; each HDR video/image is its own layer.
|
|
11
|
+
*
|
|
12
|
+
* Elements are sorted by \`zIndex\` ascending (back to front). Ties fall
|
|
13
|
+
* through to V8's stable sort, which preserves \`querySelectorAll\` DOM order —
|
|
14
|
+
* this is the same order Chrome uses for equal-z elements in a stacking
|
|
15
|
+
* context, so the blit order matches what the user sees in-browser.
|
|
16
|
+
*
|
|
17
|
+
* The DOM merge doesn't lose information: DOM layers are rendered via a
|
|
18
|
+
* full-page screenshot with non-layer elements hidden, so within-layer
|
|
19
|
+
* z-order is handled by Chrome itself.
|
|
20
|
+
*
|
|
21
|
+
* Invisible elements ARE included (video elements are hidden by the frame
|
|
22
|
+
* injector, but their injected \`<img>\` replacements are visible — they must
|
|
23
|
+
* stay in the correct z-ordered layer so sibling layers' DOM screenshots
|
|
24
|
+
* hide them).
|
|
25
|
+
*/
|
|
26
|
+
export function groupIntoLayers(elements) {
|
|
27
|
+
// Include ALL elements regardless of visibility. Video elements are hidden by
|
|
28
|
+
// the frame injector (HEVC can't decode in headless Chrome) but their injected
|
|
29
|
+
// <img> replacements ARE visible. We need them in the correct z-ordered layer
|
|
30
|
+
// so they get hidden from other layers' DOM screenshots.
|
|
31
|
+
const sorted = [...elements].sort((a, b) => a.zIndex - b.zIndex);
|
|
32
|
+
const layers = [];
|
|
33
|
+
for (const el of sorted) {
|
|
34
|
+
if (el.isHdr) {
|
|
35
|
+
layers.push({ type: "hdr", element: el });
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const last = layers[layers.length - 1];
|
|
39
|
+
if (last && last.type === "dom") {
|
|
40
|
+
last.elementIds.push(el.id);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
layers.push({ type: "dom", elementIds: [el.id] });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return layers;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=layerCompositor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerCompositor.js","sourceRoot":"","sources":["../../src/utils/layerCompositor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAAC,QAA+B;IAC7D,8EAA8E;IAC9E,+EAA+E;IAC/E,8EAA8E;IAC9E,yDAAyD;IACzD,MAAM,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAEjE,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;QACxB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACvC,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;gBAChC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shader Transition Math Utilities
|
|
3
|
+
*
|
|
4
|
+
* Sampling helpers and math primitives for rgb48le shader transitions.
|
|
5
|
+
* Functions are ported from GLSL to operate on 16-bit little-endian pixel
|
|
6
|
+
* buffers (6 bytes per pixel: R, G, B each stored as UInt16LE).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Convert an rgb48le buffer from HDR signal space to linear light, in-place.
|
|
10
|
+
* Uses precomputed 65536-entry LUT for O(1) per-sample conversion.
|
|
11
|
+
* @param transfer "pq" or "hlg"
|
|
12
|
+
*/
|
|
13
|
+
export declare function hdrToLinear(buf: Buffer, transfer: "pq" | "hlg"): void;
|
|
14
|
+
/**
|
|
15
|
+
* Convert an rgb48le buffer from linear light back to HDR signal space, in-place.
|
|
16
|
+
* Uses precomputed 65536-entry LUT for O(1) per-sample conversion.
|
|
17
|
+
* @param transfer "pq" or "hlg"
|
|
18
|
+
*/
|
|
19
|
+
export declare function linearToHdr(buf: Buffer, transfer: "pq" | "hlg"): void;
|
|
20
|
+
/**
|
|
21
|
+
* Convert an rgb48le buffer between HDR transfer functions, in-place.
|
|
22
|
+
* Uses a composite 65536-entry LUT (source EOTF → linear → target OETF)
|
|
23
|
+
* for O(1) per-sample conversion. No-op if from === to.
|
|
24
|
+
*/
|
|
25
|
+
export declare function convertTransfer(buf: Buffer, from: "pq" | "hlg", to: "pq" | "hlg"): void;
|
|
26
|
+
/**
|
|
27
|
+
* Sample an rgb48le buffer at floating-point UV coordinates (0–1 range, clamped).
|
|
28
|
+
* Uses bilinear interpolation between the 4 nearest pixels, equivalent to
|
|
29
|
+
* GLSL `texture2D` with clamp-to-edge wrapping.
|
|
30
|
+
*
|
|
31
|
+
* @param buf rgb48le buffer — w * h * 6 bytes
|
|
32
|
+
* @param u Horizontal coordinate in [0, 1]
|
|
33
|
+
* @param v Vertical coordinate in [0, 1]
|
|
34
|
+
* @param w Image width in pixels
|
|
35
|
+
* @param h Image height in pixels
|
|
36
|
+
* @returns [r, g, b] as 16-bit values (0–65535)
|
|
37
|
+
*/
|
|
38
|
+
export declare function sampleRgb48le(buf: Buffer, u: number, v: number, w: number, h: number): [number, number, number];
|
|
39
|
+
/**
|
|
40
|
+
* Linear interpolate two 16-bit values. Equivalent to GLSL `mix(a, b, t)`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function mix16(a: number, b: number, t: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Clamp a value to the 16-bit unsigned range [0, 65535].
|
|
45
|
+
*/
|
|
46
|
+
export declare function clamp16(v: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Hermite interpolation from GLSL `smoothstep(edge0, edge1, x)`.
|
|
49
|
+
* Returns 0 for x ≤ edge0, 1 for x ≥ edge1, and a smooth S-curve between.
|
|
50
|
+
*/
|
|
51
|
+
export declare function smoothstep(edge0: number, edge1: number, x: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Deterministic pseudo-random value in [0, 1).
|
|
54
|
+
* Port of the GLSL idiom: `fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453)`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function hash(x: number, y: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* Value noise with C2-continuous quintic interpolation.
|
|
59
|
+
* Samples `hash()` at the 4 surrounding integer grid corners and blends
|
|
60
|
+
* using the quintic fade f = f³(f(6f − 15) + 10).
|
|
61
|
+
*
|
|
62
|
+
* Returns a value in [0, 1].
|
|
63
|
+
*/
|
|
64
|
+
export declare function vnoise(px: number, py: number): number;
|
|
65
|
+
/**
|
|
66
|
+
* Fractal Brownian motion — 5-octave accumulation of value noise.
|
|
67
|
+
*
|
|
68
|
+
* Each octave: accumulate `amplitude * vnoise(p)`, rotate p by 36.87°,
|
|
69
|
+
* scale by 2.02, halve the amplitude. Matching the GLSL convention of
|
|
70
|
+
* `mat2(0.8, 0.6, -0.6, 0.8)` for the rotation.
|
|
71
|
+
*/
|
|
72
|
+
export declare function fbm(px: number, py: number): number;
|
|
73
|
+
/** A transition function that blends two rgb48le buffers into an output buffer. */
|
|
74
|
+
export type TransitionFn = (from: Buffer, to: Buffer, output: Buffer, width: number, height: number, progress: number) => void;
|
|
75
|
+
/** Registry of all available transitions by name. */
|
|
76
|
+
export declare const TRANSITIONS: Record<string, TransitionFn>;
|
|
77
|
+
/**
|
|
78
|
+
* Simple linear blend between two frames. Equivalent to GLSL `mix(from, to, progress)`.
|
|
79
|
+
*/
|
|
80
|
+
export declare const crossfade: TransitionFn;
|
|
81
|
+
/**
|
|
82
|
+
* Flash-through-white transition: the outgoing scene brightens to white while
|
|
83
|
+
* the incoming scene emerges from white, creating a bright flash at the midpoint.
|
|
84
|
+
*
|
|
85
|
+
* Port of the GLSL flash-through-white shader.
|
|
86
|
+
*/
|
|
87
|
+
export declare const flashThroughWhite: TransitionFn;
|
|
88
|
+
/**
|
|
89
|
+
* RGB channel offset transition. Each channel is sampled at a different UV
|
|
90
|
+
* offset, spreading apart as progress increases (outgoing) and converging
|
|
91
|
+
* as progress approaches 1 (incoming). Port of the GLSL chromatic-split shader.
|
|
92
|
+
*/
|
|
93
|
+
export declare const chromaticSplit: TransitionFn;
|
|
94
|
+
/**
|
|
95
|
+
* Circular iris reveal. A sharp edge expands from the center while golden
|
|
96
|
+
* glow rings ripple outward at the boundary. Port of the GLSL sdf-iris shader.
|
|
97
|
+
*/
|
|
98
|
+
export declare const sdfIris: TransitionFn;
|
|
99
|
+
/**
|
|
100
|
+
* Block displacement + scanlines + RGB channel split. Intensity peaks at the
|
|
101
|
+
* midpoint (p=0.5) and decays at both ends. Port of the GLSL glitch shader.
|
|
102
|
+
*/
|
|
103
|
+
export declare const glitch: TransitionFn;
|
|
104
|
+
/**
|
|
105
|
+
* Warm lens-flare from the upper-right corner. The incoming scene burns through
|
|
106
|
+
* an overexposed flash, tonemapped with ACES and crossfaded with the outgoing
|
|
107
|
+
* scene. Port of the GLSL light-leak shader.
|
|
108
|
+
*/
|
|
109
|
+
export declare const lightLeak: TransitionFn;
|
|
110
|
+
/**
|
|
111
|
+
* FBM displacement warp. Both frames are warped in opposite directions by a
|
|
112
|
+
* fractal noise field, then blended by a noise-threshold mask that sweeps
|
|
113
|
+
* across the screen as progress advances. Port of the GLSL cross-warp-morph shader.
|
|
114
|
+
*/
|
|
115
|
+
export declare const crossWarpMorph: TransitionFn;
|
|
116
|
+
/**
|
|
117
|
+
* Horizontal motion blur. The outgoing frame is sampled with offsets shifted
|
|
118
|
+
* right (by progress*1.5) and the incoming frame is sampled with offsets shifted
|
|
119
|
+
* left (by (1-progress)*1.5). Each direction uses 10 samples averaged together.
|
|
120
|
+
* Port of the GLSL whip-pan shader.
|
|
121
|
+
*/
|
|
122
|
+
export declare const whipPan: TransitionFn;
|
|
123
|
+
/**
|
|
124
|
+
* Radial zoom blur with chromatic aberration. Both frames are blurred along a
|
|
125
|
+
* radial direction from center using 12 samples. R/G/B channels use slightly
|
|
126
|
+
* different zoom factors (1.06, 1.0, 0.94) for chromatic aberration. The
|
|
127
|
+
* outgoing frame zooms inward while the incoming zooms outward.
|
|
128
|
+
* Port of the GLSL cinematic-zoom shader.
|
|
129
|
+
*/
|
|
130
|
+
export declare const cinematicZoom: TransitionFn;
|
|
131
|
+
/**
|
|
132
|
+
* Radial warp toward center simulating a gravitational lens effect. The
|
|
133
|
+
* outgoing frame is warped with chromatic separation, masked by a horizon
|
|
134
|
+
* that depends on distance from center. Mixed to the incoming frame using
|
|
135
|
+
* smoothstep(0.3, 0.9, progress). Port of the GLSL gravitational-lens shader.
|
|
136
|
+
*/
|
|
137
|
+
export declare const gravitationalLens: TransitionFn;
|
|
138
|
+
/**
|
|
139
|
+
* Concentric wave distortion. Exponential wave functions create rings radiating
|
|
140
|
+
* outward from center. Both frames are distorted — the outgoing with progress-
|
|
141
|
+
* scaled amplitude, the incoming with (1-progress)-scaled amplitude. A warm
|
|
142
|
+
* accent tint highlights wave peaks. Port of the GLSL ripple-waves shader.
|
|
143
|
+
*/
|
|
144
|
+
export declare const rippleWaves: TransitionFn;
|
|
145
|
+
/**
|
|
146
|
+
* Rotational UV warp. The outgoing frame is rotated clockwise and the incoming
|
|
147
|
+
* counter-clockwise. Rotation angle depends on distance from center and FBM
|
|
148
|
+
* warp noise. Port of the GLSL swirl-vortex shader.
|
|
149
|
+
*/
|
|
150
|
+
export declare const swirlVortex: TransitionFn;
|
|
151
|
+
/**
|
|
152
|
+
* Heat shimmer effect. Horizontal displacement based on a sin wave modulated by
|
|
153
|
+
* FBM noise, fading toward the top of the screen. Both frames are displaced
|
|
154
|
+
* independently, and a warm haze overlay fades as progress advances.
|
|
155
|
+
* Port of the GLSL thermal-distortion shader.
|
|
156
|
+
*/
|
|
157
|
+
export declare const thermalDistortion: TransitionFn;
|
|
158
|
+
/**
|
|
159
|
+
* FBM-driven UV warp with edge glow. Computes two layers of FBM (q and r) to
|
|
160
|
+
* derive a warp direction. Both frames are displaced in opposite directions.
|
|
161
|
+
* An edge-detection glow appears at the transition boundary.
|
|
162
|
+
* Port of the GLSL domain-warp shader. Note: mix(B, A, e) ordering — e=1 shows A (from).
|
|
163
|
+
*/
|
|
164
|
+
export declare const domainWarp: TransitionFn;
|
|
165
|
+
export declare const ridgedBurn: TransitionFn;
|
|
166
|
+
//# sourceMappingURL=shaderTransitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shaderTransitions.d.ts","sourceRoot":"","sources":["../../src/utils/shaderTransitions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsFH;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAOrE;AA0CD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,EAAE,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAQvF;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CA8C1B;AAID;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzC;AAID;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAG1E;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;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