@photivra/engine 2.2.1 → 2.4.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/CHANGELOG.md +38 -1
- package/CITATION.cff +1 -1
- package/README.md +6 -6
- package/SECURITY.md +1 -1
- package/dist/capture/native-environment-raw.d.ts +18 -0
- package/dist/capture/native-environment-raw.js +17 -1
- package/dist/capture/native-environment-raw.js.map +1 -1
- package/dist/capture/native-raw-dng.d.ts +3 -0
- package/dist/capture/native-raw-dng.js +23 -3
- package/dist/capture/native-raw-dng.js.map +1 -1
- package/dist/capture/native-raw.d.ts +3 -0
- package/dist/capture/native-raw.js +8 -5
- package/dist/capture/native-raw.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/generic-prime-lenses.d.ts +46 -0
- package/dist/equipment/generic-prime-lenses.js +59 -0
- package/dist/equipment/generic-prime-lenses.js.map +1 -0
- package/dist/facade/chart-scenes.d.ts +270 -1
- package/dist/facade/chart-scenes.js +443 -17
- package/dist/facade/chart-scenes.js.map +1 -1
- package/dist/facade/scene-radiance.d.ts +47 -0
- package/dist/facade/scene-radiance.js +65 -5
- package/dist/facade/scene-radiance.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +158 -4
- package/dist/facade/simulate-capture.js +324 -56
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/subject-framing.d.ts +55 -0
- package/dist/facade/subject-framing.js +66 -0
- package/dist/facade/subject-framing.js.map +1 -0
- package/dist/gpu/chart-radiance-gpu.d.ts +8 -0
- package/dist/gpu/chart-radiance-gpu.js +20 -1
- package/dist/gpu/chart-radiance-gpu.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/output/text-metadata.d.ts +32 -0
- package/dist/output/text-metadata.js +201 -0
- package/dist/output/text-metadata.js.map +1 -0
- package/docs/API_REFERENCE.md +56 -1
- package/docs/QUICK_START.md +325 -4
- package/docs/api/capture-native-raw-dng.md +2 -0
- package/docs/api/core-version.md +1 -1
- package/docs/api/equipment-generic-prime-lenses.md +85 -0
- package/docs/api/exports.json +172 -2
- package/docs/api/facade-chart-scenes.md +280 -4
- package/docs/api/facade-scene-radiance.md +42 -0
- package/docs/api/facade-simulate-capture.md +113 -2
- package/docs/api/facade-subject-framing.md +72 -0
- package/docs/api/output-text-metadata.md +20 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 2.
|
|
3
|
+
## 2.4.1 — unreleased (prepared October 18, 2026)
|
|
4
|
+
|
|
5
|
+
A republication of 2.4.0. 2.4.0 was tagged and released on GitHub on October 18, 2026 but never reached npm: the Publish npm workflow's verify job hit its 10-minute limit during the coverage gate on both attempts and was cancelled before the publish job ran. 2.4.1 carries the 2.4.0 contents unchanged (caller text metadata in JPEG, PNG and DNG outputs, `output.metadata`, `serializeNativeRawDng` `textMetadata` and `OutputTextMetadata`; see the 2.4.0 entry below) plus the publish-workflow fix. Apart from the engine version that captures record, every request, plan, RAW, image, encoded file and hash lock is byte-identical to 2.4.0, and without `output.metadata` to 2.3.0. Root exports stay at 1,714 symbols; none is added or removed.
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- **Publish workflow timeout.** The verify job of `.github/workflows/publish.yml` now has 25 minutes instead of 10 (#346). It took 9m20s for 2.2.1 and 9m33s for 2.3.0; the coverage gate alone takes 8–12 minutes. Repository tooling only: nothing in the published package changes.
|
|
10
|
+
|
|
11
|
+
## 2.4.0 — tagged; not published to npm (prepared October 18, 2026)
|
|
12
|
+
|
|
13
|
+
Tagged `v2.4.0` and released on GitHub, but never published to npm because the publish job timed out; use 2.4.1, which carries the same contents.
|
|
14
|
+
|
|
15
|
+
A minor release for labelling exported files: callers can write their own description, software name, copyright and comment into the JPEG, PNG and DNG files that `simulateCapture` produces (`output.metadata`, also on a PNG `simulateIdealReference`) and into DNGs written directly with `serializeNativeRawDng` (`textMetadata`). It is opt-in: without metadata every request, plan, RAW, image, encoded file and hash lock is byte-identical to 2.3.0 (the engine version recorded in captures aside). Root exports grow from 1,713 to 1,714 symbols (`OutputTextMetadata`); none is removed.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Text metadata in encoded files (`output.metadata`).** `simulateCapture` (and a PNG `simulateIdealReference`) takes an optional `output.metadata: { description?, software?, copyright?, comment? }` and writes the caller's text, unchanged, into the file: JPEG as an XMP `rdf:Description` in the existing APP1 packet (`dc:description`, `xmp:CreatorTool`, `dc:rights`, `exif:UserComment`) plus a COM segment for the comment; PNG as `tEXt` chunks (printable Latin-1) or uncompressed `iTXt` chunks (UTF-8) with the keywords Description, Software, Copyright and Comment before the first IDAT; DNG as an XMP packet in tag 700, with the description appended to ImageDescription after the simulated-RAW statement and a Copyright tag when the text is printable ASCII. The engine adds no text of its own beyond the DNG's existing simulated-RAW statement. Each field is 1–2048 UTF-8 bytes; NUL, lone surrogates, U+FFFE/U+FFFF and control characters other than line feed are rejected with an `InvalidConfigurationError` naming the field. Specifications: ITU-T T.81 §B.2.4.5, Adobe XMP Specification Parts 1–3, W3C PNG Third Edition §11.3.3, TIFF 6.0 (see the quick start's "Text metadata (2.4)").
|
|
20
|
+
- **`serializeNativeRawDng` `textMetadata`.** The same fields for direct DNG writing.
|
|
21
|
+
- **`OutputTextMetadata`** type. Root exports grow from 1,713 to 1,714 symbols; none is removed.
|
|
22
|
+
|
|
23
|
+
Defaults are unchanged: without `output.metadata` every request, RAW, image and encoded file is byte-identical to 2.3.0 (new hash locks on the facade's JPEG, PNG, Display P3 PNG, DNG and ideal-reference PNG bytes, recorded on 2.3.0, plus the existing integration locks; like the 2.0.0 lock, the DNG lock writes the Software tag's engine version back to the 2.3.0 name before hashing).
|
|
24
|
+
|
|
25
|
+
## 2.3.0 — published October 18, 2026
|
|
26
|
+
|
|
27
|
+
A minor release for building test charts and comparing captures: generic chart elements and a `composite` preset to lay them out, physical chart sizes (`chartSize`) with a framing-distance calculator and a generic prime lens family (`lens.prime`), an opt-in box pixel aperture, byte-identical region rendering for tiles and crops, and ideal reference images without camera effects (`simulateIdealReference`). Everything is opt-in: without the new inputs every request, plan, RAW, image, encoded file, scene digest and hash lock is byte-identical to 2.2.1 (the engine version recorded in captures aside). Root exports grow from 1,680 to 1,713 symbols; none is removed.
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Chart elements.** New generic, unbranded chart presets: `dead-leaves` (seeded, scale-invariant r⁻³ radius law after Cao, Guichard and Hornung, drawn front to back until covered), `bar-groups` (three-bar groups at a list of LW/PH frequencies, both orientations, optional engine-drawn seven-segment numerals), `hyperbolic-wedge`, `zone-plate`, `slanted-squares` (an edge field of rotated squares), `line-grid` and `fiducial`, plus `profile: "sine"` on `siemens-star` (the bar profile stays the default and its parameters and digests are unchanged). Continuous patterns are quantized to `CHART_CONTINUOUS_LEVELS` (1024) neutral levels. New analysis helpers `calculateBarGroupTargets` and `calculateSlantedSquareEdges`.
|
|
32
|
+
- **`composite` charts.** An ordered list of elements, each a preset in a placement rectangle (frame units) with an optional ellipse mask, over a background preset; later elements cover earlier ones and LW/PH frequencies keep the composite's picture height. Applications build their own layouts from engine parts; branded layouts stay in the application. Caller spectra inside elements enter the scene digest. The `webgpu-f32` chart-radiance stage rejects the new presets, composites and the sine star with `unsupported-on-backend` (documented in docs/WEBGPU.md); `cpu-reference` and `calculateChartRadianceBatch` cover them.
|
|
33
|
+
- **Fixed-size chart placement.** `simulateCapture` `chartSize: { widthM, heightM?, surroundReflectance? }` (and the same option on `createPlanarSceneRadianceProvider`) places the chart at its physical size on the plane at the subject distance instead of filling the frame, over a neutral surround (default 18 %). `result.scene.chart` and the assumption `scene.chartSize` report the frame coverage fractions, the thin-lens magnification v/d and the chart's image size; caller scene functions receive chart-local `chartU`, `chartV`. New `ChartSizeOption` and `CHART_SIZE_DEFAULT_SURROUND_REFLECTANCE`.
|
|
34
|
+
- **Pixel aperture.** `simulateCapture` `sensor.pixelAperture: "point" | "box" | { kind: "box", samplesPerAxis }` (default `"point"`, the unchanged centre sampling). `"box"` integrates each square photosite (fill factor 1) with an N × N midpoint rule (default 4; the environment's existing spatial quadrature), so whole-frame renders at large effective pitch no longer alias detail finer than a pixel at full contrast. The response |sin(πfp)/(N·sin(πfp/N))| follows the box pixel MTF |sinc(f·p)| within 2.6 % below Nyquist for N = 4; a test measures it on the RAW. It works with `lens.diffraction` on the object-space path (same RAW codes as the per-tap quadrature) and with `sensor.antiAliasing`. Measured cost: 5.2× at 48 × 48 and 7.8× at 128 × 128 for 4 × 4. New `SimulateCapturePixelAperture`, `SIMULATE_CAPTURE_BOX_APERTURE_DEFAULT_SAMPLES` and the cost option `sensor.pixelAperture.box`.
|
|
35
|
+
- **Region rendering.** `simulateCapture` `output.region: { x, y, width, height }` renders only that rectangle of the whole `output.width` × `output.height` frame, byte-identical to the same pixels of the whole render: noise seeds, CFA phase and rolling-shutter row timing use absolute native indices of the whole frame, the native rectangle carries the demosaic reach (bilinear 1, AHD 5) and mirror borders apply only at the frame's own edges, and diffraction keeps the whole render's convolution bands. Tests stitch tiles and compare byte for byte across demosaics, border modes, diffraction with anti-aliasing and the box aperture, rotation with a rolling shutter and a fixed-size composite chart. `result.region` reports the rectangle and its native sites; refused with `whiteBalance: "auto"`. New cost option `output.region`. Internally the native RAW task gains a column band next to its row band (no public API change).
|
|
36
|
+
- **Ideal reference images.** `simulateIdealReference(options)` renders the same request as `simulateCapture` without camera effects (no lens blur, diffraction, defocus, distortion, vignetting, anti-aliasing filter, mosaic or demosaic, noise, dark signal or motion), with the same scene, framing, chart size, output size, region and pixel sampling, for "compare with the chart" views. Exposure-matched: each channel is the noise-free signal the capture's sensor would record at its resolved exposure, normalized like the RAW development and developed with the capture's white balance, matrices, tone curve and encoding, so uniform patches render at the capture's mean level (tested within one 8-bit code). Labelled `kind: "ideal-reference"`, deterministic, no RAW simulated: 0.44 s for a 768 × 512 composite chart (1.61 s with the box aperture) against 49.3 s for the capture. New `IdealReferenceResult`.
|
|
37
|
+
- **Generic prime lenses.** A family of educational primes named by full-frame-equivalent focal length (10–1200 mm, `GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM`): focal length = equivalent ÷ diagonal crop factor, widest aperture by class (f/2.8 … f/8), narrowest f/16, f/22 or f/32, marked third-stop f-numbers (`GENERIC_PRIME_THIRD_STOP_F_NUMBERS`), and a thin-lens minimum focus max(0.10 m, f·(1 + 1/0.15)) (`GENERIC_PRIME_MINIMUM_FOCUS`, `calculateGenericPrimeMinimumFocusDistanceM`). Not real products, no brands. `resolveGenericPrimeLens` resolves one for a sensor; `simulateCapture` `lens.prime` uses one and rejects an f-number outside its range or a subject or focus distance below its minimum focus.
|
|
38
|
+
- **`calculateSubjectDistanceForFraming`.** The thin-lens distance d = f·(1 + 1/m) that fits a chart (`{ widthM, heightM? }`, as `chartSize`) to the frame (`fit`: contain, width, height or cover), with magnification, coverage, framed size, the prime family's minimum focus and `belowMinimumFocus`. Consistent with the facade's framing: `chartSize` at the returned distance covers the frame exactly. Full-frame A3: 0.127 m at 10 mm, 0.633 m at 50 mm, 2.53 m at 200 mm, 15.2 m at 1200 mm.
|
|
39
|
+
|
|
40
|
+
## 2.2.1 — published October 18, 2026
|
|
4
41
|
|
|
5
42
|
A patch release: `simulateCapture` `lens.diffraction` no longer fails for about a third of the combinations of real pixel pitches and f-numbers because of a floating-point rounding error in the kernel-to-site mapping, and the diffraction assumption states when its default window is capped at 32 sites. Captures that 2.2.0 completed are byte-identical (RAW codes, images, kernels and assumption values); only the explanation text of capped windows changes. No root export is added or removed (1,680 symbols).
|
|
6
43
|
|
package/CITATION.cff
CHANGED
|
@@ -9,7 +9,7 @@ abstract: "An open TypeScript engine for the science and mathematics of photogra
|
|
|
9
9
|
repository-code: "https://github.com/photivra/photivra"
|
|
10
10
|
url: "https://photivra.com"
|
|
11
11
|
license: "Apache-2.0"
|
|
12
|
-
version: "2.
|
|
12
|
+
version: "2.4.1"
|
|
13
13
|
keywords:
|
|
14
14
|
- photography
|
|
15
15
|
- camera optics
|
package/README.md
CHANGED
|
@@ -32,10 +32,10 @@ The source is licensed under Apache-2.0.
|
|
|
32
32
|
|
|
33
33
|
## Quick start
|
|
34
34
|
|
|
35
|
-
Install the published ESM package below. The [2.
|
|
35
|
+
Install the published ESM package below. The [2.4.1 release record](https://github.com/Photivra/photivra/blob/main/docs/RELEASE_2_4_1.md) and [changelog](https://github.com/Photivra/photivra/blob/main/CHANGELOG.md) describe the current release:
|
|
36
36
|
|
|
37
37
|
```sh
|
|
38
|
-
npm install @photivra/engine@2.
|
|
38
|
+
npm install @photivra/engine@2.4.1
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
Simulate a photograph of a test chart with a generic camera, then read the developed sRGB pixels:
|
|
@@ -75,7 +75,7 @@ console.log(horizontal.provenance);
|
|
|
75
75
|
|
|
76
76
|
Start with the [Developer Guide](https://github.com/Photivra/photivra/blob/main/docs/DEVELOPERS.md). Then use the [Usage Guide](https://github.com/Photivra/photivra/blob/main/docs/USAGE.md) and the [API reference](https://github.com/Photivra/photivra/blob/main/docs/API_REFERENCE.md), which is generated from the package exports.
|
|
77
77
|
|
|
78
|
-
Repository `main` may describe newer, unreleased work. For the stable contract, use the docs bundled in the published package, or the exact `v2.
|
|
78
|
+
Repository `main` may describe newer, unreleased work. For the stable contract, use the docs bundled in the published package, or the exact `v2.4.1` tag.
|
|
79
79
|
|
|
80
80
|
## Documentation
|
|
81
81
|
|
|
@@ -363,13 +363,13 @@ The application can then use those results, while the photography calculations t
|
|
|
363
363
|
|
|
364
364
|
## Status
|
|
365
365
|
|
|
366
|
-
- Repository package version: `2.
|
|
367
|
-
- Engine API contract: `2.
|
|
366
|
+
- Repository package version: `2.4.1` (release candidate prepared October 18, 2026; publication is separate)
|
|
367
|
+
- Engine API contract: `2.4.1`
|
|
368
368
|
- Versioned generic tier reference assets: [GENERIC_TIER_PRESETS.md](https://github.com/Photivra/photivra/blob/main/docs/GENERIC_TIER_PRESETS.md).
|
|
369
369
|
- Composed POC simulation API contract: `1.0.0`
|
|
370
370
|
- Stability: 1.0 root-package compatibility policy; bounded scientific models and independent POC contract
|
|
371
371
|
|
|
372
|
-
From 1.0.1, the package version and `ENGINE_API_VERSION` are equal. New captures/plans record 2.
|
|
372
|
+
From 1.0.1, the package version and `ENGINE_API_VERSION` are equal. New captures/plans record 2.4.1; existing archives keep their original creator identities. Schema, model and POC contract versions stay independent.
|
|
373
373
|
|
|
374
374
|
A breaking change to the root contracts now needs a new package major version. Additive and corrective changes follow [compatibility and migration](https://github.com/Photivra/photivra/blob/main/docs/RELEASE_1_3_0.md). A 1.0 package is not a claim of calibrated physical accuracy.
|
|
375
375
|
|
package/SECURITY.md
CHANGED
|
@@ -4,7 +4,7 @@ Please do not open a public issue that contains vulnerability details.
|
|
|
4
4
|
|
|
5
5
|
## Supported versions
|
|
6
6
|
|
|
7
|
-
The published 1.0.0 release started the 1.x root-package compatibility line, and 2.0.0 started the 2.x line. The current release is **2.
|
|
7
|
+
The published 1.0.0 release started the 1.x root-package compatibility line, and 2.0.0 started the 2.x line. The current release is **2.3.0**, published on October 18, 2026 (see [CHANGELOG.md](CHANGELOG.md)).
|
|
8
8
|
|
|
9
9
|
Security fixes target the current maintained development and release line. Do not assume that older 1.x releases, snapshots or pre-1.0 releases will receive fixes.
|
|
10
10
|
|
|
@@ -79,12 +79,30 @@ export declare function createNativeEnvironmentRawTask(input: NativeEnvironmentR
|
|
|
79
79
|
/** Internal: a partition's row band, and the facts it records while running for the merge step. */
|
|
80
80
|
interface NativeEnvironmentPartitionProbe {
|
|
81
81
|
readonly rows: NativeRawRowBand;
|
|
82
|
+
/** Internal (2.3 region rendering): native columns [x, x + width); absent means every column. */
|
|
83
|
+
readonly columns?: {
|
|
84
|
+
readonly x: number;
|
|
85
|
+
readonly width: number;
|
|
86
|
+
};
|
|
82
87
|
/** Canonical string of the band's shared source/optical/motion state (the first site's). */
|
|
83
88
|
shared?: string;
|
|
84
89
|
/** The band's first parsed RAW site (its readout identity). */
|
|
85
90
|
firstSite?: SensorRawProducerSiteInput;
|
|
86
91
|
}
|
|
87
92
|
export declare function createNativeEnvironmentRawTaskWithCadence(input: NativeEnvironmentRawInput, provider: NativeEnvironmentRawProvider, cadence: HostYieldCadence, partition?: NativeEnvironmentPartitionProbe): NativeEnvironmentRawTask;
|
|
93
|
+
/**
|
|
94
|
+
* Internal (not exported from the package; 2.3 `simulateCapture` `output.region`): the task for one rectangle of
|
|
95
|
+
* native sites [x, x + width) × [y, y + height) of the whole-frame input. Every site keeps its absolute native index,
|
|
96
|
+
* so its noise seeds, CFA phase, exposure window (rolling-shutter row timing) and value are those of the whole-frame
|
|
97
|
+
* task; the output arrays hold just the rectangle, row-major, and `effectiveSaturationCodes` holds 0 for a CFA
|
|
98
|
+
* phase the rectangle does not contain. Optical-stage retention is not supported.
|
|
99
|
+
*/
|
|
100
|
+
export declare function createNativeEnvironmentRawRegionTask(input: NativeEnvironmentRawInput, region: {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
}, provider: NativeEnvironmentRawProvider): NativeEnvironmentRawTask;
|
|
88
106
|
/** A band of whole native rows, [y, y + height), in absolute full-sensor coordinates. */
|
|
89
107
|
export interface NativeRawRowBand {
|
|
90
108
|
y: number;
|
|
@@ -310,7 +310,8 @@ export function createNativeEnvironmentRawTaskWithCadence(input, provider, caden
|
|
|
310
310
|
expectedIncidentPhotonCount: s.expectedIncidentPhotonCount, expectedGeneratedElectronCount: s.expectedGeneratedElectronCount })) }), signal);
|
|
311
311
|
return { ...request, sites: rawSites };
|
|
312
312
|
}, yieldControl
|
|
313
|
-
}, cadence, gate, sensorLean.hook, partition ? { y: partition.rows.y, height: partition.rows.height, firstSite: (site) => { partition.firstSite = site; }
|
|
313
|
+
}, cadence, gate, sensorLean.hook, partition ? { y: partition.rows.y, height: partition.rows.height, firstSite: (site) => { partition.firstSite = site; },
|
|
314
|
+
...(partition.columns ? { x: partition.columns.x, width: partition.columns.width } : {}) } : undefined);
|
|
314
315
|
// The frame reference is needed only while tiles are read; release it once the event settles.
|
|
315
316
|
const settle = () => { reference = undefined; };
|
|
316
317
|
return { plan: task.plan, get state() { return task.state; }, get completedTileCount() { return task.completedTileCount; }, get providerEvaluationCount() { return evaluations; },
|
|
@@ -328,6 +329,21 @@ export function createNativeEnvironmentRawTaskWithCadence(input, provider, caden
|
|
|
328
329
|
}
|
|
329
330
|
};
|
|
330
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* Internal (not exported from the package; 2.3 `simulateCapture` `output.region`): the task for one rectangle of
|
|
334
|
+
* native sites [x, x + width) × [y, y + height) of the whole-frame input. Every site keeps its absolute native index,
|
|
335
|
+
* so its noise seeds, CFA phase, exposure window (rolling-shutter row timing) and value are those of the whole-frame
|
|
336
|
+
* task; the output arrays hold just the rectangle, row-major, and `effectiveSaturationCodes` holds 0 for a CFA
|
|
337
|
+
* phase the rectangle does not contain. Optical-stage retention is not supported.
|
|
338
|
+
*/
|
|
339
|
+
export function createNativeEnvironmentRawRegionTask(input, region, provider) {
|
|
340
|
+
const plan = calculateNativeRawPlan(input?.raw), native = plan.exposure.geometry.nativeRaster;
|
|
341
|
+
const r = requireAllowlistedRecord(region, ["x", "y", "width", "height"], "Invalid native RAW region.");
|
|
342
|
+
if (![r.x, r.y, r.width, r.height].every(v => typeof v === "number" && Number.isSafeInteger(v)) || r.width < 1 || r.x < 0 || r.x + r.width > native.pixelWidth)
|
|
343
|
+
throw new InvalidConfigurationError("Native RAW region must lie inside the native raster.");
|
|
344
|
+
const rows = parseRowBand({ y: r.y, height: r.height }, native.pixelHeight);
|
|
345
|
+
return createNativeEnvironmentRawTaskWithCadence(input, provider, DEFAULT_HOST_YIELD_CADENCE, { rows, columns: { x: r.x, width: r.width } });
|
|
346
|
+
}
|
|
331
347
|
/**
|
|
332
348
|
* Splits a plan's native rows into at most `count` contiguous bands of nearly equal height (the first
|
|
333
349
|
* `height % count` bands are one row taller), in row order. Deterministic: it depends only on the raster height and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-environment-raw.js","sourceRoot":"","sources":["../../src/capture/native-environment-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,mCAAmC,EACN,MAAM,iBAAiB,CAAC;AACtH,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,sCAAsC,EAAE,sBAAsB,EAA+C,MAAM,+BAA+B,CAAC;AAC5J,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAyB,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAC3H,OAAO,EAAE,kCAAkC,EAAE,2CAA2C,EAAE,wBAAwB,EAChH,2CAA2C,EACwC,MAAM,uCAAuC,CAAC;AACnI,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,mCAAmC,EAAE,iCAAiC,EAAE,qBAAqB,EAC1E,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AA+DnF,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,sBAAsB,CAAC,K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O,IAAI,CAAC,kBAAkB,CAAC,CAAA,CAAC,EAAC,IAAI,uBAAuB,KAAU,OAAO,CAAC,CAAC,CAAA,CAAC;QACxL,GAAG,EAAC,GAAgB,EAAE,CAAA,IAAI,CAAC,GAAG,EAAE,EAAC,MAAM,EAAC,GAAO,EAAE,CAAA,IAAI,CAAC,MAAM,EAAE,EAAC,OAAO,EAAC,GAAO,EAAE,CAAA,IAAI,CAAC,OAAO,EAAE;QAC9F,UAAU,KAA8B,OAAO,EAAC,GAAG,EAAC,IAAI,CAAC,UAAU,EAAE,EAAC,YAAY,EAAC,uBAAuB,EAAC,CAAC,EAAC,cAAc,EAAC,oDAAoD,EAAC,yBAAyB,EAAC,KAAK,EAAC,uBAAuB,EAAC,KAAK,EAAC,CAAC,CAAA,CAAC;KAClP,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture from a scene-radiance provider: source radiance → optics → EQE (external quantum\n * efficiency) → packed RAW codes for the full native sensor, within fixed work limits.\n */\nimport { calculateNativeRawPlan, createNativeRawTaskWithCadence, nativeRawMaximumProviderEvaluations, type NativeRawInput, type NativeRawOutput,\n type NativeRawPlan, type NativeRawTask, type NativeRawTileRequest, type NativeRawTaskState } from \"./native-raw.js\";\nimport { createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport type { SensorRawProducerSiteInput } from \"./sensor-raw-producer.js\";\nimport { createEnvironmentRawFrameCanonicalMemo, planEnvironmentRawSite, type SimulateEnvironmentSensorRawFrameInput } from \"./environment-raw-producer.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { executeEnvironmentSensorPhotoSignal, prebuildApertureRadianceQuery } from \"../sensor/environment-photo-signal.js\";\nimport { composeNativeEnvironmentSensorSite, createNativeEnvironmentOpticalStageRecorder, createSensorStageRawTask,\n parseNativeEnvironmentOpticalStageRetention, type NativeEnvironmentOpticalStage, type NativeEnvironmentOpticalStageRetention,\n type NativeEnvironmentSensorStageInput, type NativeEnvironmentSensorStageProvider } from \"./native-environment-optical-stage.js\";\nimport { parseEvidenceList } from \"../core/evidence-provenance.js\";\nimport { rejectUnknownFields, requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { createNativeEnvironmentLeanExecutor, createNativeEnvironmentSensorLean, isLeanEnvironmentPlan,\n type LeanEnvironmentPlan } from \"./native-environment-lean.js\";\nimport { prepareCaptureExposureWindowSampler } from \"../sensor/exposure-window.js\";\nimport type { SensorEqeTemporalPhotoSignal } from \"../sensor/temporal-photo-signal.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport type { SensorApertureRay } from \"../optics/sensor-aperture-rays.js\";\n\ntype SitePlan = ReturnType<typeof planEnvironmentRawSite> | LeanEnvironmentPlan;\ntype PhotoSignal = SensorEqeTemporalPhotoSignal;\n\nexport interface NativeEnvironmentRawInput {\n raw: NativeRawInput;\n sceneBinding: SimulateEnvironmentSensorRawFrameInput[\"sceneBinding\"];\n /** Budget of provider calls for the whole capture, checked before work starts; at most 2 billion. Staying within it does not imply convergence. */\n maximumProviderEvaluations: number;\n /**\n * Optional: keep the optical stage (per-site expected photo signal, tied to every optical input) on the\n * output, for createNativeEnvironmentSensorStageTask. If omitted, behaviour and output shape are unchanged.\n */\n opticalStage?: NativeEnvironmentOpticalStageRetention;\n}\nexport interface NativeEnvironmentRawTile extends NativeRawTileRequest {\n sites: SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n}\n/** One radiance query of a batch: the frozen provider request and, for an ideal-pupil ray, its frozen aperture ray. */\nexport interface NativeEnvironmentRadianceQuery {\n request: Readonly<SceneRadianceEvaluationRequest>;\n apertureRay?: Readonly<SensorApertureRay>;\n}\nexport interface NativeEnvironmentRawProvider {\n /** Supplies physical site profiles, not photo counts or precomputed RAW codes. */\n readTile(request: Readonly<NativeRawTileRequest>,signal:AbortSignal):Promise<NativeEnvironmentRawTile>;\n evaluateRadiance: SimulateEnvironmentSensorRawFrameInput[\"evaluateRadiance\"];\n evaluateApertureRadiance?: SimulateEnvironmentSensorRawFrameInput[\"evaluateApertureRadiance\"];\n /**\n * Optional batched light sampling (2.0, additive). When present, the engine makes one call per tile instead of one\n * evaluateRadiance or evaluateApertureRadiance call per query. `queries` holds every query of the tile's sites, in\n * exactly the order the per-query callbacks would be made, each with the same frozen request (and aperture ray).\n * Return one result per query, in the same order; a promise is allowed (for example a GPU readback). Each result\n * is validated by the same parser and binding checks as a per-query result, so for the same results the output is\n * byte-identical. The per-query evaluators stay required as the reference contract, but are not called.\n */\n evaluateRadianceBatch?(queries:readonly NativeEnvironmentRadianceQuery[],signal:AbortSignal):\n readonly SceneRadianceEvaluationResult[]|Promise<readonly SceneRadianceEvaluationResult[]>;\n /** Optional, bounded diagnostic callback. Counts are expected values before any noise, clipping or ADC (analogue-to-digital conversion). */\n observePhotoTile?(tile:Readonly<NativeEnvironmentPhotoTile>,signal:AbortSignal):void|Promise<void>;\n yieldControl(signal:AbortSignal):Promise<void>;\n}\nexport interface NativeEnvironmentPhotoTile extends NativeRawTileRequest {\n sites:readonly {nativeIndex:number;expectedIncidentPhotonCount:number;expectedGeneratedElectronCount:number}[];\n}\nexport interface NativeEnvironmentRawOutput {\n raw: NativeRawOutput;\n sceneBinding: NativeEnvironmentRawInput[\"sceneBinding\"];\n providerEvaluationCount: number;\n upstreamOrigin: \"executed-environment-query-provider-optics-psf-eqe\";\n providerTransportVerified: false;\n productionPlanActivated: false;\n /** Present only when NativeEnvironmentRawInput.opticalStage was requested. The caller owns and disposes it. */\n opticalStage?: NativeEnvironmentOpticalStage;\n}\nexport interface NativeEnvironmentRawTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawOutput;\n}\nfunction canonical(value:unknown):string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"omit\",nonFiniteNumberMessage:\"Invalid native scene binding.\",unsupportedValueMessage:\"Invalid native scene binding.\"});\n}\n/** Site-environment fields that one native event shares across every site (same set as the optical-stage binding). */\nconst SHARED_STATE_KEYS = [\"sceneBindings\",\"optics\",\"motion\",\"psf\",\"pupil\",\"fieldThroughput\"] as const;\ntype SiteEnvironment = SimulateEnvironmentSensorRawFrameInput[\"sites\"][number][\"environment\"];\n/** The frame's first accepted shared state: its canonical string and its engine-owned (cloned) values. */\ninterface SharedStateReference {\n readonly canonical: string;\n readonly values: readonly unknown[];\n /** Arrays of the reference already checked to carry no holes or extra properties. */\n readonly cleanArrays: WeakSet<object>;\n}\n/**\n * Strict structural equality of structured-clone output against the reference: Object.is for primitives (0 and\n * -0 differ), identical prototypes limited to plain records and arrays, identical own keys in identical order,\n * and arrays with no holes or non-index properties. Anything else is unequal unless it is the same reference.\n * Equal values therefore serialize to the same canonical string and are interchangeable for every reader, so a\n * site may adopt the reference values. Recursion is bounded by the reference, which serialized without error.\n */\nfunction samePlainData(value: unknown, reference: unknown, cleanArrays: WeakSet<object>): boolean {\n if (Object.is(value, reference)) return true;\n if (typeof value !== \"object\" || typeof reference !== \"object\" || value === null || reference === null) return false;\n const prototype = Object.getPrototypeOf(value) as unknown;\n if (prototype !== Object.getPrototypeOf(reference)) return false;\n if (prototype === Array.prototype) {\n const a = value as unknown[], b = reference as unknown[], length = a.length;\n if (length !== b.length) return false;\n for (let index = 0; index < length; index++) if (!(index in a) || !(index in b) || !samePlainData(a[index], b[index], cleanArrays)) return false;\n // Holes are excluded above, so equal key counts exclude non-index properties as well.\n if (Object.keys(a).length !== length) return false;\n if (!cleanArrays.has(b)) { if (Object.keys(b).length !== length) return false; cleanArrays.add(b); }\n return true;\n }\n if (prototype !== Object.prototype && prototype !== null) return false;\n const a = value as Record<string, unknown>, b = reference as Record<string, unknown>, keys = Object.keys(a), referenceKeys = Object.keys(b);\n if (keys.length !== referenceKeys.length) return false;\n for (let index = 0; index < keys.length; index++) if (keys[index] !== referenceKeys[index]) return false;\n for (let index = 0; index < keys.length; index++) if (!samePlainData(a[keys[index]!], b[keys[index]!], cleanArrays)) return false;\n return true;\n}\n/**\n * Replaces a site's private copy of the shared state with the frame's reference values when every field is\n * strictly equal (a 2.0 performance change). All sites then share one engine-owned shared state, so its sampled\n * PSF is parsed and frozen once per frame and duplicate copies can be garbage-collected at once. `verified`\n * holds copies in the current tile already shown equal, so sites the supplier built from one object compare in\n * O(1). Returns false, changing nothing, when any field differs; the caller then serializes as before.\n */\nfunction adoptSharedState(environment: SiteEnvironment, reference: SharedStateReference, verified: unknown[]): boolean {\n const record = environment as unknown as Record<string, unknown>;\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const value = record[SHARED_STATE_KEYS[index]!];\n if (!(typeof value === \"object\" && value !== null && value === verified[index]) && !samePlainData(value, reference.values[index], reference.cleanArrays)) return false;\n }\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const key = SHARED_STATE_KEYS[index]!, value = record[key];\n if (value !== reference.values[index]) { verified[index] = value; record[key] = reference.values[index]; }\n }\n return true;\n}\n/**\n * Every radiance query the executors will make for these site plans, in their callback order: per site, per instant,\n * per group (spectral-major, spatial-minor), per tap, then per pupil ray. Pupil queries come from the executors' own\n * apertureRadianceQuery, which then hands the executor the same objects.\n */\nfunction tileQueries(plans:readonly SitePlan[]):NativeEnvironmentRadianceQuery[] {\n const queries:NativeEnvironmentRadianceQuery[]=[];\n const add=(tap:{request:SceneRadianceEvaluationRequest;apertureRays?:readonly SensorApertureRay[]}):void=>{\n if(tap.apertureRays===undefined){queries.push({request:tap.request});return;}\n // The executor later receives these same objects (apertureRadianceQuery), so they are built once.\n for(const ray of tap.apertureRays)queries.push(prebuildApertureRadianceQuery(tap.request,ray));\n };\n for(const p of plans){\n if(isLeanEnvironmentPlan(p)){for(const instant of p.instants)for(const tap of instant.taps)add(tap);}\n else for(const instant of p.instants)for(const group of instant.groups)for(const tap of group.taps)add(tap);\n }\n return queries;\n}\nfunction parseSceneBinding(value: unknown): NativeEnvironmentRawInput[\"sceneBinding\"] {\n const binding=requireAllowlistedRecord(value,[\"sceneStateId\",\"providerSceneId\",\"evidence\"],\"Invalid native scene binding.\");\n return freezeOwnedData({sceneStateId:requirePublicOpaqueId(binding.sceneStateId,\"Invalid scene-state ID.\"),providerSceneId:requirePublicOpaqueId(binding.providerSceneId,\"Invalid provider-scene ID.\"),evidence:parseEvidenceList(binding.evidence,\"nativeEnvironmentSceneBinding.evidence\")});\n}\n/**\n * Creates the native RAW task. Every tile is planned and checked against the limits before its radiance\n * callbacks run, and no partial output is ever returned.\n *\n * The task also yields to the host between sites inside a tile once about 8 ms of work has passed (one budget\n * shared with the tile loop). Cancellation is checked after each such yield, so cancel() takes effect within\n * about one site's work. Yield timing never changes tile requests, limit checks, callbacks or output.\n */\nexport function createNativeEnvironmentRawTask(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider):NativeEnvironmentRawTask {\n return createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, callbacks or output. Not exported from the package. */\n/** Validates a native environment input exactly as task creation does, before any callback. */\nfunction admitNativeEnvironmentInput(input:NativeEnvironmentRawInput):{plan:ReturnType<typeof calculateNativeRawPlan>;\n sceneBinding:NativeEnvironmentRawInput[\"sceneBinding\"];retention:NativeEnvironmentOpticalStageRetention|undefined;maximum:number} {\n const r=requireAllowlistedRecord(input,[\"raw\",\"sceneBinding\",\"maximumProviderEvaluations\",\"opticalStage\"],\"Invalid native environment input.\");\n const plan=calculateNativeRawPlan(input.raw),sceneBinding=parseSceneBinding(r.sceneBinding);\n const retention=r.opticalStage===undefined?undefined:parseNativeEnvironmentOpticalStageRetention(r.opticalStage);\n if(sceneBinding.sceneStateId!==plan.exposure.sceneStateId||plan.exposure.sceneTimeSeconds!==0||!plan.exposureWindow||\n typeof r.maximumProviderEvaluations!==\"number\"||!Number.isSafeInteger(r.maximumProviderEvaluations)||r.maximumProviderEvaluations<plan.pixelCount||r.maximumProviderEvaluations>nativeRawMaximumProviderEvaluations(plan))\n throw new InvalidConfigurationError(\"Native environment requires opening-reference scene binding, an explicit shutter event and bounded full-event query budget.\");\n return {plan,sceneBinding,retention,maximum:r.maximumProviderEvaluations};\n}\n/** Internal: a partition's row band, and the facts it records while running for the merge step. */\ninterface NativeEnvironmentPartitionProbe {\n readonly rows:NativeRawRowBand;\n /** Canonical string of the band's shared source/optical/motion state (the first site's). */\n shared?:string;\n /** The band's first parsed RAW site (its readout identity). */\n firstSite?:SensorRawProducerSiteInput;\n}\nexport function createNativeEnvironmentRawTaskWithCadence(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider,\n cadence:HostYieldCadence,partition?:NativeEnvironmentPartitionProbe):NativeEnvironmentRawTask {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(partition&&retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.evaluateRadiance!==\"function\"||typeof provider.yieldControl!==\"function\"||\n (provider.evaluateApertureRadiance!==undefined&&typeof provider.evaluateApertureRadiance!==\"function\")||\n (provider.observePhotoTile!==undefined&&typeof provider.observePhotoTile!==\"function\")||\n (provider.evaluateRadianceBatch!==undefined&&typeof provider.evaluateRadianceBatch!==\"function\"))throw new InvalidConfigurationError(\"Native environment requires physical source callbacks and host yields.\");\n const read=provider.readTile.bind(provider),evaluate=provider.evaluateRadiance.bind(provider),aperture=provider.evaluateApertureRadiance?.bind(provider),yieldControl=provider.yieldControl.bind(provider);\n const observe=provider.observePhotoTile?.bind(provider),batch=provider.evaluateRadianceBatch?.bind(provider);\n let evaluations=0,shared:string|undefined,reference:SharedStateReference|undefined;\n const recorder=retention?createNativeEnvironmentOpticalStageRecorder(plan,sceneBinding,retention):undefined;\n const memo=createEnvironmentRawFrameCanonicalMemo(plan.frame,plan.exposureWindow!),gate=createHostYieldGate(cadence);\n const layout=plan.frame.colorSamplingProfile.layout,relationship=plan.frame.bindingProfile.relationship;\n const leanFrame={frameId:plan.frame.frameId,nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,\n nativeHeight:plan.exposure.geometry.nativeRaster.pixelHeight,repeatWidth:layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites:0,\n repeatHeight:layout.kind===\"periodic-mosaic\"?layout.repeatHeightSites:0,\n identityBinding:relationship.sitesPerNativeSampleX===1&&relationship.sitesPerNativeSampleY===1&&relationship.anchor===\"shared-native-top-left\"};\n const lean=createNativeEnvironmentLeanExecutor(leanFrame);\n let nativeWindow:Parameters<typeof createNativeEnvironmentSensorLean>[2];\n try{nativeWindow=prepareCaptureExposureWindowSampler({...plan.exposureWindow!,nativeRaster:plan.exposure.geometry.nativeRaster});}catch{nativeWindow=undefined;}\n const sensorLean=createNativeEnvironmentSensorLean(leanFrame,plan.frame,nativeWindow);\n const task=createNativeRawTaskWithCadence(input.raw,{\n async readTile(request,signal){\n const supplied=await read(request,signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid physical source tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Physical source tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Physical source tile needs exact native coverage.\");\n // Private copy: planning takes each site environment as engine-owned plan data without copying it again.\n const sites=structuredClone(tile.sites) as SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n // Yield to the host between sites on the shared time budget. Cancellation is honoured right after it.\n const pause=async():Promise<void>=>{\n if(!gate.due())return;\n await yieldControl(signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n gate.restart();\n };\n let tileCount=0;\n const plans:SitePlan[]=[],verified:unknown[]=[];\n for(let j=0;j<sites.length;j++){\n if(j>0)await pause();\n const site=sites[j]!;\n requireAllowlistedRecord(site,[\"environment\",\"darkCurrentProfile\",\"operatingTemperatureC\",\"charge\",\"readout\"],\"Invalid physical site input.\");\n const e=site.environment,index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n if(e.temporalIntegrationId!==plan.frame.frameId+\":native:\"+index)throw new InvalidConfigurationError(\"Native environment IDs must bind the absolute native index.\");\n // A site strictly equal to the frame's first shared state adopts it and skips serialization; otherwise the\n // canonical comparison runs exactly as before and decides acceptance or the same error.\n let state:string;\n if(reference!==undefined&&adoptSharedState(e,reference,verified))state=reference.canonical;\n else{\n state=canonical({sceneBindings:e.sceneBindings,optics:e.optics,motion:e.motion,psf:e.psf,pupil:e.pupil,fieldThroughput:e.fieldThroughput});\n shared??=state;if(partition)partition.shared??=shared;if(state!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n reference??={canonical:state,values:SHARED_STATE_KEYS.map(key=>(e as unknown as Record<string,unknown>)[key]),cleanArrays:new WeakSet()};\n }\n // A site matching a verified template gets a lean plan (identical requests and limit checks; see\n // native-environment-lean.ts). A template candidate keeps full query records for its self-check.\n // Otherwise only the photo signal is needed, so the plan keeps just each query's frozen request and image-plane point.\n const leanPlan=lean.plan(e,index);\n let p:SitePlan;\n if(typeof leanPlan===\"object\")p=leanPlan;\n else{\n p=planEnvironmentRawSite(site,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,leanPlan===\"candidate\"?\"full\":\"photo-only\");\n if(leanPlan===\"candidate\")lean.admitCandidate(e,index,p);\n }\n if(p.owned.pupil&&!aperture)throw new InvalidConfigurationError(\"Pupil capture requires origin-aware source visibility.\");\n recorder?.admit(index,e,state);\n tileCount+=p.count;\n if(tileCount>100_000||evaluations+tileCount>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n plans.push(p);\n }\n // Only value.photo is consumed, so per-evaluation diagnostics are not retained.\n const rawSites:(ReturnType<typeof composeNativeEnvironmentSensorSite>|object)[]=[],photos:PhotoSignal[]=[];\n sensorLean.beginTile();\n let evaluateCounted=(q:Parameters<typeof evaluate>[0]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");evaluations++;return evaluate(q);};\n let apertureCounted=aperture?(q:Parameters<typeof aperture>[0],ray:Parameters<typeof aperture>[1]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native aperture evaluation aborted.\");evaluations++;return aperture(q,ray);}:undefined;\n let batched:{queries:readonly NativeEnvironmentRadianceQuery[];results:readonly SceneRadianceEvaluationResult[];next:number}|undefined;\n if(batch){\n // One call for the whole tile, with every planned query in per-query callback order (see tileQueries).\n const queries=tileQueries(plans);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n const results=await batch(Object.freeze(queries),signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n if(!Array.isArray(results)||results.length!==queries.length||Array.from({length:queries.length},(_,i)=>i in results).includes(false))\n throw new InvalidConfigurationError(\"Batched radiance must return one result per query, in query order.\");\n const current={queries,results:results as readonly SceneRadianceEvaluationResult[],next:0};\n batched=current;\n // The executors ask for each query in the same order; every step is checked against the planned query.\n const take=(q:Readonly<SceneRadianceEvaluationRequest>,ray:Readonly<SensorApertureRay>|undefined):SceneRadianceEvaluationResult=>{\n const k=current.next++,planned=current.queries[k];\n if(planned===undefined||planned.request.sampleId!==q.sampleId||(planned.apertureRay===undefined)!==(ray===undefined))\n throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n evaluations++;\n return current.results[k]!;\n };\n evaluateCounted=(q):ReturnType<typeof evaluate>=>take(q,undefined);\n apertureCounted=aperture?(q,ray):ReturnType<typeof evaluate>=>take(q,ray):undefined;\n }\n for(let j=0;j<sites.length;j++){\n await pause();\n const index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n let p=plans[j]!,photoSignal:PhotoSignal|undefined;\n if(isLeanEnvironmentPlan(p)){\n // The full plan (deterministic, no callbacks) is built only when the lean path needs it.\n const fullPlan=():ReturnType<typeof planEnvironmentRawSite>=>planEnvironmentRawSite(sites[j]!,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,\"photo-only\");\n photoSignal=lean.execute(p,evaluateCounted,apertureCounted,fullPlan);\n // An unverified template: plan this site in full now and execute it in full.\n if(photoSignal===undefined)p=fullPlan();\n }\n if(photoSignal===undefined){\n const full=p as ReturnType<typeof planEnvironmentRawSite>,candidate=lean.isCandidate(index);\n const result=executeEnvironmentSensorPhotoSignal(full,evaluateCounted,apertureCounted,candidate?\"full\":\"photo-only\");\n if(candidate)lean.verifyCandidate(index,full,result);\n photoSignal=result.value.photo.value.photoSignal;\n }\n recorder?.record(index,photoSignal);\n photos.push(photoSignal);\n // A site matching a verified sensor template becomes a lean entry: every check its composition and RAW\n // parse would run has been evaluated (see native-environment-lean.ts). Otherwise compose it in full.\n const claimed=sensorLean.claim(sites[j]!,photoSignal,index);\n if(claimed)rawSites.push(claimed);\n else{rawSites.push(composeNativeEnvironmentSensorSite(sites[j]!,photoSignal));sensorLean.remember(index,sites[j]!,photoSignal);}\n }\n if(batched&&batched.next!==batched.queries.length)throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n if(signal.aborted)throw new InvalidConfigurationError(\"Native photo observation aborted.\");\n if(observe)await observe(freezeOwnedData({...request,sites:photos.map((s,j)=>({nativeIndex:request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j,\n expectedIncidentPhotonCount:s.expectedIncidentPhotonCount,expectedGeneratedElectronCount:s.expectedGeneratedElectronCount}))}),signal);\n return {...request,sites:rawSites as ReturnType<typeof composeNativeEnvironmentSensorSite>[]};\n },yieldControl\n },cadence,gate,sensorLean.hook,partition?{y:partition.rows.y,height:partition.rows.height,firstSite:(site):void=>{partition.firstSite=site;}}:undefined);\n // The frame reference is needed only while tiles are read; release it once the event settles.\n const settle=():void=>{reference=undefined;};\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return evaluations;},\n run:():Promise<void>=>(recorder?task.run().catch((error:unknown)=>{if(task.state===\"failed\"||task.state===\"cancelled\"||task.state===\"disposed\")recorder.discard();throw error;}):task.run()).finally(settle),\n cancel:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.cancel();},dispose:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.dispose();},\n takeOutput():NativeEnvironmentRawOutput{\n // Finish retention first so a retention failure never strands the transferred RAW.\n const opticalStage=recorder&&task.state===\"completed\"?recorder.finish(evaluations):undefined;\n const raw=task.takeOutput();\n const base={raw,sceneBinding,providerEvaluationCount:evaluations,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\" as const,providerTransportVerified:false as const,productionPlanActivated:false as const};\n return opticalStage?{...base,opticalStage}:base;\n }\n };\n}\n/** A band of whole native rows, [y, y + height), in absolute full-sensor coordinates. */\nexport interface NativeRawRowBand { y: number; height: number }\n/**\n * Splits a plan's native rows into at most `count` contiguous bands of nearly equal height (the first\n * `height % count` bands are one row taller), in row order. Deterministic: it depends only on the raster height and\n * `count`. Use one band per worker with createNativeEnvironmentRawPartitionTask.\n */\nexport function calculateNativeRawRowBands(plan:Pick<NativeRawPlan,\"exposure\">,count:number):NativeRawRowBand[] {\n if(plan!==null&&typeof plan===\"object\")rejectUnknownFields(plan,[\"schemaVersion\",\"exposure\",\"frame\",\"exposureWindow\",\"pixelCount\",\"outputBytes\",\"tileCount\",\n \"tileWidth\",\"upstreamRadiometryVerified\",\"seedSchedule\"],\"Native RAW plan\");\n const height=plan?.exposure?.geometry?.nativeRaster?.pixelHeight;\n if(typeof height!==\"number\"||!Number.isSafeInteger(height)||height<1)throw new InvalidConfigurationError(\"Native RAW partitioning requires a native RAW plan.\");\n if(typeof count!==\"number\"||!Number.isSafeInteger(count)||count<1||count>1024)throw new InvalidConfigurationError(\"Native RAW partition count must be an integer from 1 to 1024.\");\n const bands=Math.min(count,height),base=Math.floor(height/bands),extra=height%bands,result:NativeRawRowBand[]=[];\n for(let i=0,y=0;i<bands;i++){const h=base+(i<extra?1:0);result.push({y,height:h});y+=h;}\n return result;\n}\n/**\n * One partition's result: plain data and typed arrays only, so it can be posted from a worker (transfer the four\n * arrays' buffers). Merge every partition of a capture with composeNativeEnvironmentRawPartitions.\n */\nexport interface NativeEnvironmentRawPartition {\n rows: NativeRawRowBand;\n /** Canonical JSON of the capture input (raw, sceneBinding, maximumProviderEvaluations); the merge requires it to match. */\n inputCanonical: string;\n /** Canonical JSON of the band's shared source/optical/motion state; every partition must match. */\n sharedStateCanonical: string;\n /** Readout identity of the band's first site; every partition must match (one readout identity per frame). */\n readoutIdentity: { readoutProfileId: string; regimeId: string; fixedPatternProfileId: string | null; fixedPatternSeedUint32: number | null };\n /** The band's rows only, row-major, as in NativeRawOutput. */\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n saturationFlags: Uint8Array;\n /** Effective white code per CFA phase; 0 for a phase the band does not contain. */\n effectiveSaturationCodes: Uint16Array;\n providerEvaluationCount: number;\n}\nexport interface NativeEnvironmentRawPartitionTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly rows: NativeRawRowBand;\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawPartition;\n}\nfunction inputCanonical(input:NativeEnvironmentRawInput):string {\n return canonical({raw:input.raw,sceneBinding:input.sceneBinding,maximumProviderEvaluations:input.maximumProviderEvaluations});\n}\nfunction parseRowBand(value:unknown,height:number):NativeRawRowBand {\n const band=requireAllowlistedRecord(value,[\"y\",\"height\"],\"Invalid native RAW row band.\");\n if(typeof band.y!==\"number\"||typeof band.height!==\"number\"||!Number.isSafeInteger(band.y)||!Number.isSafeInteger(band.height)||\n band.y<0||band.height<1||band.y+band.height>height)throw new InvalidConfigurationError(\"Native RAW row band must lie inside the native raster.\");\n return {y:band.y,height:band.height};\n}\n/**\n * Creates the task for one row band of a native environment capture (opt-in parallel execution, 2.0).\n *\n * Run one partition per worker (or one after another) with the same input, each worker using its own provider, then\n * merge them with composeNativeEnvironmentRawPartitions. The merged output is byte-identical to the single\n * createNativeEnvironmentRawTask output for the same input and a deterministic provider: noise seeds use absolute\n * native indices, and tiles, plans and per-site values are those of the whole-frame task.\n *\n * Each partition checks the same inputs and limits before its callbacks. maximumProviderEvaluations bounds each\n * partition's own work; the merge also rejects a total above it. Frame-wide checks that span sites (one shared\n * state, one readout identity, one white level per CFA phase) run inside each band and again across bands in the\n * merge. Callbacks are split across partitions, and when several partitions fail, which error is seen first depends\n * on the caller's scheduling. Optical-stage retention is not supported in a partition.\n *\n * The package bundles no worker code: the caller creates workers (Web Workers or Node worker threads), runs this\n * task inside each and posts the partition back.\n */\nexport function createNativeEnvironmentRawPartitionTask(input:NativeEnvironmentRawInput,rows:NativeRawRowBand,\n provider:NativeEnvironmentRawProvider):NativeEnvironmentRawPartitionTask {\n const plan=calculateNativeRawPlan(input?.raw),band=parseRowBand(rows,plan.exposure.geometry.nativeRaster.pixelHeight);\n const probe:NativeEnvironmentPartitionProbe={rows:band};\n const task=createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE,probe),text=inputCanonical(input);\n return {plan:task.plan,rows:band,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},\n get providerEvaluationCount():number{return task.providerEvaluationCount;},run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawPartition{\n if(task.state!==\"completed\"||probe.shared===undefined||probe.firstSite===undefined)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");\n const site=probe.firstSite,sharedStateCanonical=probe.shared,output=task.takeOutput(),raw=output.raw;\n return {rows:{...band},inputCanonical:text,sharedStateCanonical,readoutIdentity:{readoutProfileId:site.readoutProfile.profileId,regimeId:site.regimeId,\n fixedPatternProfileId:site.fixedPatternNoise?.profileId??null,fixedPatternSeedUint32:site.fixedPatternNoise?.sensorInstanceSeedUint32??null},\n codes:raw.codes,blackLevels:raw.blackLevels,digitalSaturationCodes:raw.digitalSaturationCodes,saturationFlags:raw.saturationFlags,\n effectiveSaturationCodes:raw.effectiveSaturationCodes,providerEvaluationCount:output.providerEvaluationCount};\n }\n };\n}\n/**\n * Assembles the partitions of one capture into the output createNativeEnvironmentRawTask would have returned for\n * the same input (byte-identical RAW arrays and white levels, the summed provider evaluation count).\n *\n * The partitions must be in row order and cover every native row exactly once, and each must come from\n * createNativeEnvironmentRawPartitionTask with this same input. It rejects, with InvalidConfigurationError, a\n * different input, a gap or overlap, wrong array types or lengths, a second shared state or readout identity, two\n * white levels for one CFA phase, a missing phase, or a total evaluation count above the input's budget. It cannot\n * verify how a partition was computed: posted partitions are the caller's own data.\n */\nexport function composeNativeEnvironmentRawPartitions(input:NativeEnvironmentRawInput,partitions:readonly NativeEnvironmentRawPartition[]):NativeEnvironmentRawOutput {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n const native=plan.exposure.geometry.nativeRaster,width=native.pixelWidth,layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const phases=layout.repeatWidthSites*layout.repeatHeightSites,text=inputCanonical(input);\n if(!Array.isArray(partitions)||partitions.length<1||partitions.length>native.pixelHeight||Array.from({length:partitions.length},(_,i)=>i in partitions).includes(false))\n throw new InvalidConfigurationError(\"Native RAW merge requires a dense list of partitions.\");\n const codes=new Uint16Array(plan.pixelCount),blackLevels=new Uint16Array(plan.pixelCount),digitalSaturationCodes=new Uint16Array(plan.pixelCount),saturationFlags=new Uint8Array(plan.pixelCount);\n const white=createPhaseWhiteLevelAccumulator(width,layout.repeatWidthSites,layout.repeatHeightSites);\n let y=0,total=0,shared:string|undefined,identity:string|undefined;\n for(const value of partitions){\n const p=requireAllowlistedRecord(value,[\"rows\",\"inputCanonical\",\"sharedStateCanonical\",\"readoutIdentity\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\n \"saturationFlags\",\"effectiveSaturationCodes\",\"providerEvaluationCount\"],\"Invalid native RAW partition.\");\n const band=parseRowBand(p.rows,native.pixelHeight),length=band.height*width;\n if(band.y!==y)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(p.inputCanonical!==text)throw new InvalidConfigurationError(\"Native RAW partition was computed from a different input.\");\n if(!(p.codes instanceof Uint16Array)||!(p.blackLevels instanceof Uint16Array)||!(p.digitalSaturationCodes instanceof Uint16Array)||\n !(p.saturationFlags instanceof Uint8Array)||!(p.effectiveSaturationCodes instanceof Uint16Array)||p.codes.length!==length||p.blackLevels.length!==length||\n p.digitalSaturationCodes.length!==length||p.saturationFlags.length!==length||p.effectiveSaturationCodes.length!==phases||\n typeof p.providerEvaluationCount!==\"number\"||!Number.isSafeInteger(p.providerEvaluationCount)||p.providerEvaluationCount<0||typeof p.sharedStateCanonical!==\"string\")\n throw new InvalidConfigurationError(\"Invalid native RAW partition arrays.\");\n const id=requireAllowlistedRecord(p.readoutIdentity,[\"readoutProfileId\",\"regimeId\",\"fixedPatternProfileId\",\"fixedPatternSeedUint32\"],\"Invalid native RAW partition identity.\");\n const idText=canonical(id);\n shared??=p.sharedStateCanonical;identity??=idText;\n if(p.sharedStateCanonical!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n if(idText!==identity)throw new InvalidConfigurationError(\"Frame requires one readout identity/regime, one fixed-pattern identity and a positive uint16 RAW code span.\");\n const offset=band.y*width;\n codes.set(p.codes,offset);blackLevels.set(p.blackLevels,offset);digitalSaturationCodes.set(p.digitalSaturationCodes,offset);saturationFlags.set(p.saturationFlags,offset);\n for(let phase=0;phase<phases;phase++)white.recordPhase(phase,p.effectiveSaturationCodes[phase]!);\n total+=p.providerEvaluationCount;y+=band.height;\n }\n if(y!==native.pixelHeight)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(total>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n const raw:NativeRawOutput={plan,codes,blackLevels,digitalSaturationCodes,saturationFlags,effectiveSaturationCodes:white.finish()};\n return {raw,sceneBinding,providerEvaluationCount:total,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};\n}\n/**\n * Re-runs only the sensor stage from a retained optical stage. No radiance callback is called.\n *\n * Use it when only post-optics settings change: noise seed, ISO and its readout regime and gain,\n * fixed-pattern noise, charge, dark-current and capacity profiles, white-balance intent, capture identity\n * or tile width. White balance and rendering are then applied by createNativeRawDevelopmentTask as usual.\n *\n * RAW codes are bit-identical to a full createNativeEnvironmentRawTask with the same final inputs, as long\n * as the radiance provider is a deterministic function of its request.\n *\n * Any optical difference is rejected with InvalidConfigurationError before output. That includes scene\n * binding, geometry or orientation, focal length, aperture, shutter or exposure window, focus,\n * frame/CFA/binding profiles, and any site environment field such as PSF, field throughput, pupil, motion,\n * spectral or temporal sampling and provider profiles.\n *\n * providerEvaluationCount is 0. The caller still owns the stage; it is not used up.\n */\nexport function createNativeEnvironmentSensorStageTask(input:NativeEnvironmentSensorStageInput,opticalStage:NativeEnvironmentOpticalStage,\n provider:NativeEnvironmentSensorStageProvider):NativeEnvironmentRawTask {\n const {task,sceneBinding}=createSensorStageRawTask(input,opticalStage,provider,parseSceneBinding);\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return 0;},\n run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawOutput{return {raw:task.takeOutput(),sceneBinding,providerEvaluationCount:0,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};}\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"native-environment-raw.js","sourceRoot":"","sources":["../../src/capture/native-environment-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAE,sBAAsB,EAAE,8BAA8B,EAAE,mCAAmC,EACN,MAAM,iBAAiB,CAAC;AACtH,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAAE,sCAAsC,EAAE,sBAAsB,EAA+C,MAAM,+BAA+B,CAAC;AAC5J,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAyB,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAE,mCAAmC,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAC3H,OAAO,EAAE,kCAAkC,EAAE,2CAA2C,EAAE,wBAAwB,EAChH,2CAA2C,EACwC,MAAM,uCAAuC,CAAC;AACnI,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACpH,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,mCAAmC,EAAE,iCAAiC,EAAE,qBAAqB,EAC1E,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;A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AC,CAAC;IAClG,OAAO,EAAC,IAAI,EAAC,IAAI,CAAC,IAAI,EAAC,IAAI,KAAK,KAAsB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAA,CAAC,EAAC,IAAI,kBAAkB,KAAU,OAAO,IAAI,CAAC,kBAAkB,CAAC,CAAA,CAAC,EAAC,IAAI,uBAAuB,KAAU,OAAO,CAAC,CAAC,CAAA,CAAC;QACxL,GAAG,EAAC,GAAgB,EAAE,CAAA,IAAI,CAAC,GAAG,EAAE,EAAC,MAAM,EAAC,GAAO,EAAE,CAAA,IAAI,CAAC,MAAM,EAAE,EAAC,OAAO,EAAC,GAAO,EAAE,CAAA,IAAI,CAAC,OAAO,EAAE;QAC9F,UAAU,KAA8B,OAAO,EAAC,GAAG,EAAC,IAAI,CAAC,UAAU,EAAE,EAAC,YAAY,EAAC,uBAAuB,EAAC,CAAC,EAAC,cAAc,EAAC,oDAAoD,EAAC,yBAAyB,EAAC,KAAK,EAAC,uBAAuB,EAAC,KAAK,EAAC,CAAC,CAAA,CAAC;KAClP,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture from a scene-radiance provider: source radiance → optics → EQE (external quantum\n * efficiency) → packed RAW codes for the full native sensor, within fixed work limits.\n */\nimport { calculateNativeRawPlan, createNativeRawTaskWithCadence, nativeRawMaximumProviderEvaluations, type NativeRawInput, type NativeRawOutput,\n type NativeRawPlan, type NativeRawTask, type NativeRawTileRequest, type NativeRawTaskState } from \"./native-raw.js\";\nimport { createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport type { SensorRawProducerSiteInput } from \"./sensor-raw-producer.js\";\nimport { createEnvironmentRawFrameCanonicalMemo, planEnvironmentRawSite, type SimulateEnvironmentSensorRawFrameInput } from \"./environment-raw-producer.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { executeEnvironmentSensorPhotoSignal, prebuildApertureRadianceQuery } from \"../sensor/environment-photo-signal.js\";\nimport { composeNativeEnvironmentSensorSite, createNativeEnvironmentOpticalStageRecorder, createSensorStageRawTask,\n parseNativeEnvironmentOpticalStageRetention, type NativeEnvironmentOpticalStage, type NativeEnvironmentOpticalStageRetention,\n type NativeEnvironmentSensorStageInput, type NativeEnvironmentSensorStageProvider } from \"./native-environment-optical-stage.js\";\nimport { parseEvidenceList } from \"../core/evidence-provenance.js\";\nimport { rejectUnknownFields, requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { createNativeEnvironmentLeanExecutor, createNativeEnvironmentSensorLean, isLeanEnvironmentPlan,\n type LeanEnvironmentPlan } from \"./native-environment-lean.js\";\nimport { prepareCaptureExposureWindowSampler } from \"../sensor/exposure-window.js\";\nimport type { SensorEqeTemporalPhotoSignal } from \"../sensor/temporal-photo-signal.js\";\nimport type { SceneRadianceEvaluationRequest, SceneRadianceEvaluationResult } from \"../schema/scene-radiance.js\";\nimport type { SensorApertureRay } from \"../optics/sensor-aperture-rays.js\";\n\ntype SitePlan = ReturnType<typeof planEnvironmentRawSite> | LeanEnvironmentPlan;\ntype PhotoSignal = SensorEqeTemporalPhotoSignal;\n\nexport interface NativeEnvironmentRawInput {\n raw: NativeRawInput;\n sceneBinding: SimulateEnvironmentSensorRawFrameInput[\"sceneBinding\"];\n /** Budget of provider calls for the whole capture, checked before work starts; at most 2 billion. Staying within it does not imply convergence. */\n maximumProviderEvaluations: number;\n /**\n * Optional: keep the optical stage (per-site expected photo signal, tied to every optical input) on the\n * output, for createNativeEnvironmentSensorStageTask. If omitted, behaviour and output shape are unchanged.\n */\n opticalStage?: NativeEnvironmentOpticalStageRetention;\n}\nexport interface NativeEnvironmentRawTile extends NativeRawTileRequest {\n sites: SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n}\n/** One radiance query of a batch: the frozen provider request and, for an ideal-pupil ray, its frozen aperture ray. */\nexport interface NativeEnvironmentRadianceQuery {\n request: Readonly<SceneRadianceEvaluationRequest>;\n apertureRay?: Readonly<SensorApertureRay>;\n}\nexport interface NativeEnvironmentRawProvider {\n /** Supplies physical site profiles, not photo counts or precomputed RAW codes. */\n readTile(request: Readonly<NativeRawTileRequest>,signal:AbortSignal):Promise<NativeEnvironmentRawTile>;\n evaluateRadiance: SimulateEnvironmentSensorRawFrameInput[\"evaluateRadiance\"];\n evaluateApertureRadiance?: SimulateEnvironmentSensorRawFrameInput[\"evaluateApertureRadiance\"];\n /**\n * Optional batched light sampling (2.0, additive). When present, the engine makes one call per tile instead of one\n * evaluateRadiance or evaluateApertureRadiance call per query. `queries` holds every query of the tile's sites, in\n * exactly the order the per-query callbacks would be made, each with the same frozen request (and aperture ray).\n * Return one result per query, in the same order; a promise is allowed (for example a GPU readback). Each result\n * is validated by the same parser and binding checks as a per-query result, so for the same results the output is\n * byte-identical. The per-query evaluators stay required as the reference contract, but are not called.\n */\n evaluateRadianceBatch?(queries:readonly NativeEnvironmentRadianceQuery[],signal:AbortSignal):\n readonly SceneRadianceEvaluationResult[]|Promise<readonly SceneRadianceEvaluationResult[]>;\n /** Optional, bounded diagnostic callback. Counts are expected values before any noise, clipping or ADC (analogue-to-digital conversion). */\n observePhotoTile?(tile:Readonly<NativeEnvironmentPhotoTile>,signal:AbortSignal):void|Promise<void>;\n yieldControl(signal:AbortSignal):Promise<void>;\n}\nexport interface NativeEnvironmentPhotoTile extends NativeRawTileRequest {\n sites:readonly {nativeIndex:number;expectedIncidentPhotonCount:number;expectedGeneratedElectronCount:number}[];\n}\nexport interface NativeEnvironmentRawOutput {\n raw: NativeRawOutput;\n sceneBinding: NativeEnvironmentRawInput[\"sceneBinding\"];\n providerEvaluationCount: number;\n upstreamOrigin: \"executed-environment-query-provider-optics-psf-eqe\";\n providerTransportVerified: false;\n productionPlanActivated: false;\n /** Present only when NativeEnvironmentRawInput.opticalStage was requested. The caller owns and disposes it. */\n opticalStage?: NativeEnvironmentOpticalStage;\n}\nexport interface NativeEnvironmentRawTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawOutput;\n}\nfunction canonical(value:unknown):string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"omit\",nonFiniteNumberMessage:\"Invalid native scene binding.\",unsupportedValueMessage:\"Invalid native scene binding.\"});\n}\n/** Site-environment fields that one native event shares across every site (same set as the optical-stage binding). */\nconst SHARED_STATE_KEYS = [\"sceneBindings\",\"optics\",\"motion\",\"psf\",\"pupil\",\"fieldThroughput\"] as const;\ntype SiteEnvironment = SimulateEnvironmentSensorRawFrameInput[\"sites\"][number][\"environment\"];\n/** The frame's first accepted shared state: its canonical string and its engine-owned (cloned) values. */\ninterface SharedStateReference {\n readonly canonical: string;\n readonly values: readonly unknown[];\n /** Arrays of the reference already checked to carry no holes or extra properties. */\n readonly cleanArrays: WeakSet<object>;\n}\n/**\n * Strict structural equality of structured-clone output against the reference: Object.is for primitives (0 and\n * -0 differ), identical prototypes limited to plain records and arrays, identical own keys in identical order,\n * and arrays with no holes or non-index properties. Anything else is unequal unless it is the same reference.\n * Equal values therefore serialize to the same canonical string and are interchangeable for every reader, so a\n * site may adopt the reference values. Recursion is bounded by the reference, which serialized without error.\n */\nfunction samePlainData(value: unknown, reference: unknown, cleanArrays: WeakSet<object>): boolean {\n if (Object.is(value, reference)) return true;\n if (typeof value !== \"object\" || typeof reference !== \"object\" || value === null || reference === null) return false;\n const prototype = Object.getPrototypeOf(value) as unknown;\n if (prototype !== Object.getPrototypeOf(reference)) return false;\n if (prototype === Array.prototype) {\n const a = value as unknown[], b = reference as unknown[], length = a.length;\n if (length !== b.length) return false;\n for (let index = 0; index < length; index++) if (!(index in a) || !(index in b) || !samePlainData(a[index], b[index], cleanArrays)) return false;\n // Holes are excluded above, so equal key counts exclude non-index properties as well.\n if (Object.keys(a).length !== length) return false;\n if (!cleanArrays.has(b)) { if (Object.keys(b).length !== length) return false; cleanArrays.add(b); }\n return true;\n }\n if (prototype !== Object.prototype && prototype !== null) return false;\n const a = value as Record<string, unknown>, b = reference as Record<string, unknown>, keys = Object.keys(a), referenceKeys = Object.keys(b);\n if (keys.length !== referenceKeys.length) return false;\n for (let index = 0; index < keys.length; index++) if (keys[index] !== referenceKeys[index]) return false;\n for (let index = 0; index < keys.length; index++) if (!samePlainData(a[keys[index]!], b[keys[index]!], cleanArrays)) return false;\n return true;\n}\n/**\n * Replaces a site's private copy of the shared state with the frame's reference values when every field is\n * strictly equal (a 2.0 performance change). All sites then share one engine-owned shared state, so its sampled\n * PSF is parsed and frozen once per frame and duplicate copies can be garbage-collected at once. `verified`\n * holds copies in the current tile already shown equal, so sites the supplier built from one object compare in\n * O(1). Returns false, changing nothing, when any field differs; the caller then serializes as before.\n */\nfunction adoptSharedState(environment: SiteEnvironment, reference: SharedStateReference, verified: unknown[]): boolean {\n const record = environment as unknown as Record<string, unknown>;\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const value = record[SHARED_STATE_KEYS[index]!];\n if (!(typeof value === \"object\" && value !== null && value === verified[index]) && !samePlainData(value, reference.values[index], reference.cleanArrays)) return false;\n }\n for (let index = 0; index < SHARED_STATE_KEYS.length; index++) {\n const key = SHARED_STATE_KEYS[index]!, value = record[key];\n if (value !== reference.values[index]) { verified[index] = value; record[key] = reference.values[index]; }\n }\n return true;\n}\n/**\n * Every radiance query the executors will make for these site plans, in their callback order: per site, per instant,\n * per group (spectral-major, spatial-minor), per tap, then per pupil ray. Pupil queries come from the executors' own\n * apertureRadianceQuery, which then hands the executor the same objects.\n */\nfunction tileQueries(plans:readonly SitePlan[]):NativeEnvironmentRadianceQuery[] {\n const queries:NativeEnvironmentRadianceQuery[]=[];\n const add=(tap:{request:SceneRadianceEvaluationRequest;apertureRays?:readonly SensorApertureRay[]}):void=>{\n if(tap.apertureRays===undefined){queries.push({request:tap.request});return;}\n // The executor later receives these same objects (apertureRadianceQuery), so they are built once.\n for(const ray of tap.apertureRays)queries.push(prebuildApertureRadianceQuery(tap.request,ray));\n };\n for(const p of plans){\n if(isLeanEnvironmentPlan(p)){for(const instant of p.instants)for(const tap of instant.taps)add(tap);}\n else for(const instant of p.instants)for(const group of instant.groups)for(const tap of group.taps)add(tap);\n }\n return queries;\n}\nfunction parseSceneBinding(value: unknown): NativeEnvironmentRawInput[\"sceneBinding\"] {\n const binding=requireAllowlistedRecord(value,[\"sceneStateId\",\"providerSceneId\",\"evidence\"],\"Invalid native scene binding.\");\n return freezeOwnedData({sceneStateId:requirePublicOpaqueId(binding.sceneStateId,\"Invalid scene-state ID.\"),providerSceneId:requirePublicOpaqueId(binding.providerSceneId,\"Invalid provider-scene ID.\"),evidence:parseEvidenceList(binding.evidence,\"nativeEnvironmentSceneBinding.evidence\")});\n}\n/**\n * Creates the native RAW task. Every tile is planned and checked against the limits before its radiance\n * callbacks run, and no partial output is ever returned.\n *\n * The task also yields to the host between sites inside a tile once about 8 ms of work has passed (one budget\n * shared with the tile loop). Cancellation is checked after each such yield, so cancel() takes effect within\n * about one site's work. Yield timing never changes tile requests, limit checks, callbacks or output.\n */\nexport function createNativeEnvironmentRawTask(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider):NativeEnvironmentRawTask {\n return createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, callbacks or output. Not exported from the package. */\n/** Validates a native environment input exactly as task creation does, before any callback. */\nfunction admitNativeEnvironmentInput(input:NativeEnvironmentRawInput):{plan:ReturnType<typeof calculateNativeRawPlan>;\n sceneBinding:NativeEnvironmentRawInput[\"sceneBinding\"];retention:NativeEnvironmentOpticalStageRetention|undefined;maximum:number} {\n const r=requireAllowlistedRecord(input,[\"raw\",\"sceneBinding\",\"maximumProviderEvaluations\",\"opticalStage\"],\"Invalid native environment input.\");\n const plan=calculateNativeRawPlan(input.raw),sceneBinding=parseSceneBinding(r.sceneBinding);\n const retention=r.opticalStage===undefined?undefined:parseNativeEnvironmentOpticalStageRetention(r.opticalStage);\n if(sceneBinding.sceneStateId!==plan.exposure.sceneStateId||plan.exposure.sceneTimeSeconds!==0||!plan.exposureWindow||\n typeof r.maximumProviderEvaluations!==\"number\"||!Number.isSafeInteger(r.maximumProviderEvaluations)||r.maximumProviderEvaluations<plan.pixelCount||r.maximumProviderEvaluations>nativeRawMaximumProviderEvaluations(plan))\n throw new InvalidConfigurationError(\"Native environment requires opening-reference scene binding, an explicit shutter event and bounded full-event query budget.\");\n return {plan,sceneBinding,retention,maximum:r.maximumProviderEvaluations};\n}\n/** Internal: a partition's row band, and the facts it records while running for the merge step. */\ninterface NativeEnvironmentPartitionProbe {\n readonly rows:NativeRawRowBand;\n /** Internal (2.3 region rendering): native columns [x, x + width); absent means every column. */\n readonly columns?:{readonly x:number;readonly width:number};\n /** Canonical string of the band's shared source/optical/motion state (the first site's). */\n shared?:string;\n /** The band's first parsed RAW site (its readout identity). */\n firstSite?:SensorRawProducerSiteInput;\n}\nexport function createNativeEnvironmentRawTaskWithCadence(input:NativeEnvironmentRawInput,provider:NativeEnvironmentRawProvider,\n cadence:HostYieldCadence,partition?:NativeEnvironmentPartitionProbe):NativeEnvironmentRawTask {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(partition&&retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.evaluateRadiance!==\"function\"||typeof provider.yieldControl!==\"function\"||\n (provider.evaluateApertureRadiance!==undefined&&typeof provider.evaluateApertureRadiance!==\"function\")||\n (provider.observePhotoTile!==undefined&&typeof provider.observePhotoTile!==\"function\")||\n (provider.evaluateRadianceBatch!==undefined&&typeof provider.evaluateRadianceBatch!==\"function\"))throw new InvalidConfigurationError(\"Native environment requires physical source callbacks and host yields.\");\n const read=provider.readTile.bind(provider),evaluate=provider.evaluateRadiance.bind(provider),aperture=provider.evaluateApertureRadiance?.bind(provider),yieldControl=provider.yieldControl.bind(provider);\n const observe=provider.observePhotoTile?.bind(provider),batch=provider.evaluateRadianceBatch?.bind(provider);\n let evaluations=0,shared:string|undefined,reference:SharedStateReference|undefined;\n const recorder=retention?createNativeEnvironmentOpticalStageRecorder(plan,sceneBinding,retention):undefined;\n const memo=createEnvironmentRawFrameCanonicalMemo(plan.frame,plan.exposureWindow!),gate=createHostYieldGate(cadence);\n const layout=plan.frame.colorSamplingProfile.layout,relationship=plan.frame.bindingProfile.relationship;\n const leanFrame={frameId:plan.frame.frameId,nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,\n nativeHeight:plan.exposure.geometry.nativeRaster.pixelHeight,repeatWidth:layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites:0,\n repeatHeight:layout.kind===\"periodic-mosaic\"?layout.repeatHeightSites:0,\n identityBinding:relationship.sitesPerNativeSampleX===1&&relationship.sitesPerNativeSampleY===1&&relationship.anchor===\"shared-native-top-left\"};\n const lean=createNativeEnvironmentLeanExecutor(leanFrame);\n let nativeWindow:Parameters<typeof createNativeEnvironmentSensorLean>[2];\n try{nativeWindow=prepareCaptureExposureWindowSampler({...plan.exposureWindow!,nativeRaster:plan.exposure.geometry.nativeRaster});}catch{nativeWindow=undefined;}\n const sensorLean=createNativeEnvironmentSensorLean(leanFrame,plan.frame,nativeWindow);\n const task=createNativeRawTaskWithCadence(input.raw,{\n async readTile(request,signal){\n const supplied=await read(request,signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid physical source tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Physical source tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Physical source tile needs exact native coverage.\");\n // Private copy: planning takes each site environment as engine-owned plan data without copying it again.\n const sites=structuredClone(tile.sites) as SimulateEnvironmentSensorRawFrameInput[\"sites\"];\n // Yield to the host between sites on the shared time budget. Cancellation is honoured right after it.\n const pause=async():Promise<void>=>{\n if(!gate.due())return;\n await yieldControl(signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native environment acquisition aborted.\");\n gate.restart();\n };\n let tileCount=0;\n const plans:SitePlan[]=[],verified:unknown[]=[];\n for(let j=0;j<sites.length;j++){\n if(j>0)await pause();\n const site=sites[j]!;\n requireAllowlistedRecord(site,[\"environment\",\"darkCurrentProfile\",\"operatingTemperatureC\",\"charge\",\"readout\"],\"Invalid physical site input.\");\n const e=site.environment,index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n if(e.temporalIntegrationId!==plan.frame.frameId+\":native:\"+index)throw new InvalidConfigurationError(\"Native environment IDs must bind the absolute native index.\");\n // A site strictly equal to the frame's first shared state adopts it and skips serialization; otherwise the\n // canonical comparison runs exactly as before and decides acceptance or the same error.\n let state:string;\n if(reference!==undefined&&adoptSharedState(e,reference,verified))state=reference.canonical;\n else{\n state=canonical({sceneBindings:e.sceneBindings,optics:e.optics,motion:e.motion,psf:e.psf,pupil:e.pupil,fieldThroughput:e.fieldThroughput});\n shared??=state;if(partition)partition.shared??=shared;if(state!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n reference??={canonical:state,values:SHARED_STATE_KEYS.map(key=>(e as unknown as Record<string,unknown>)[key]),cleanArrays:new WeakSet()};\n }\n // A site matching a verified template gets a lean plan (identical requests and limit checks; see\n // native-environment-lean.ts). A template candidate keeps full query records for its self-check.\n // Otherwise only the photo signal is needed, so the plan keeps just each query's frozen request and image-plane point.\n const leanPlan=lean.plan(e,index);\n let p:SitePlan;\n if(typeof leanPlan===\"object\")p=leanPlan;\n else{\n p=planEnvironmentRawSite(site,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,leanPlan===\"candidate\"?\"full\":\"photo-only\");\n if(leanPlan===\"candidate\")lean.admitCandidate(e,index,p);\n }\n if(p.owned.pupil&&!aperture)throw new InvalidConfigurationError(\"Pupil capture requires origin-aware source visibility.\");\n recorder?.admit(index,e,state);\n tileCount+=p.count;\n if(tileCount>100_000||evaluations+tileCount>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n plans.push(p);\n }\n // Only value.photo is consumed, so per-evaluation diagnostics are not retained.\n const rawSites:(ReturnType<typeof composeNativeEnvironmentSensorSite>|object)[]=[],photos:PhotoSignal[]=[];\n sensorLean.beginTile();\n let evaluateCounted=(q:Parameters<typeof evaluate>[0]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");evaluations++;return evaluate(q);};\n let apertureCounted=aperture?(q:Parameters<typeof aperture>[0],ray:Parameters<typeof aperture>[1]):ReturnType<typeof evaluate>=>{if(signal.aborted)throw new InvalidConfigurationError(\"Native aperture evaluation aborted.\");evaluations++;return aperture(q,ray);}:undefined;\n let batched:{queries:readonly NativeEnvironmentRadianceQuery[];results:readonly SceneRadianceEvaluationResult[];next:number}|undefined;\n if(batch){\n // One call for the whole tile, with every planned query in per-query callback order (see tileQueries).\n const queries=tileQueries(plans);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n const results=await batch(Object.freeze(queries),signal);\n if(signal.aborted)throw new InvalidConfigurationError(\"Native source evaluation aborted.\");\n if(!Array.isArray(results)||results.length!==queries.length||Array.from({length:queries.length},(_,i)=>i in results).includes(false))\n throw new InvalidConfigurationError(\"Batched radiance must return one result per query, in query order.\");\n const current={queries,results:results as readonly SceneRadianceEvaluationResult[],next:0};\n batched=current;\n // The executors ask for each query in the same order; every step is checked against the planned query.\n const take=(q:Readonly<SceneRadianceEvaluationRequest>,ray:Readonly<SensorApertureRay>|undefined):SceneRadianceEvaluationResult=>{\n const k=current.next++,planned=current.queries[k];\n if(planned===undefined||planned.request.sampleId!==q.sampleId||(planned.apertureRay===undefined)!==(ray===undefined))\n throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n evaluations++;\n return current.results[k]!;\n };\n evaluateCounted=(q):ReturnType<typeof evaluate>=>take(q,undefined);\n apertureCounted=aperture?(q,ray):ReturnType<typeof evaluate>=>take(q,ray):undefined;\n }\n for(let j=0;j<sites.length;j++){\n await pause();\n const index=request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j;\n let p=plans[j]!,photoSignal:PhotoSignal|undefined;\n if(isLeanEnvironmentPlan(p)){\n // The full plan (deterministic, no callbacks) is built only when the lean path needs it.\n const fullPlan=():ReturnType<typeof planEnvironmentRawSite>=>planEnvironmentRawSite(sites[j]!,index,plan.frame,sceneBinding,plan.exposureWindow!,\"engine-owned\",memo,\"photo-only\");\n photoSignal=lean.execute(p,evaluateCounted,apertureCounted,fullPlan);\n // An unverified template: plan this site in full now and execute it in full.\n if(photoSignal===undefined)p=fullPlan();\n }\n if(photoSignal===undefined){\n const full=p as ReturnType<typeof planEnvironmentRawSite>,candidate=lean.isCandidate(index);\n const result=executeEnvironmentSensorPhotoSignal(full,evaluateCounted,apertureCounted,candidate?\"full\":\"photo-only\");\n if(candidate)lean.verifyCandidate(index,full,result);\n photoSignal=result.value.photo.value.photoSignal;\n }\n recorder?.record(index,photoSignal);\n photos.push(photoSignal);\n // A site matching a verified sensor template becomes a lean entry: every check its composition and RAW\n // parse would run has been evaluated (see native-environment-lean.ts). Otherwise compose it in full.\n const claimed=sensorLean.claim(sites[j]!,photoSignal,index);\n if(claimed)rawSites.push(claimed);\n else{rawSites.push(composeNativeEnvironmentSensorSite(sites[j]!,photoSignal));sensorLean.remember(index,sites[j]!,photoSignal);}\n }\n if(batched&&batched.next!==batched.queries.length)throw new InvalidConfigurationError(\"Batched radiance results are out of step with the planned queries.\");\n if(signal.aborted)throw new InvalidConfigurationError(\"Native photo observation aborted.\");\n if(observe)await observe(freezeOwnedData({...request,sites:photos.map((s,j)=>({nativeIndex:request.y*plan.exposure.geometry.nativeRaster.pixelWidth+request.x+j,\n expectedIncidentPhotonCount:s.expectedIncidentPhotonCount,expectedGeneratedElectronCount:s.expectedGeneratedElectronCount}))}),signal);\n return {...request,sites:rawSites as ReturnType<typeof composeNativeEnvironmentSensorSite>[]};\n },yieldControl\n },cadence,gate,sensorLean.hook,partition?{y:partition.rows.y,height:partition.rows.height,firstSite:(site):void=>{partition.firstSite=site;},\n ...(partition.columns?{x:partition.columns.x,width:partition.columns.width}:{})}:undefined);\n // The frame reference is needed only while tiles are read; release it once the event settles.\n const settle=():void=>{reference=undefined;};\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return evaluations;},\n run:():Promise<void>=>(recorder?task.run().catch((error:unknown)=>{if(task.state===\"failed\"||task.state===\"cancelled\"||task.state===\"disposed\")recorder.discard();throw error;}):task.run()).finally(settle),\n cancel:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.cancel();},dispose:():void=>{if(task.state!==\"transferred\")recorder?.discard();task.dispose();},\n takeOutput():NativeEnvironmentRawOutput{\n // Finish retention first so a retention failure never strands the transferred RAW.\n const opticalStage=recorder&&task.state===\"completed\"?recorder.finish(evaluations):undefined;\n const raw=task.takeOutput();\n const base={raw,sceneBinding,providerEvaluationCount:evaluations,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\" as const,providerTransportVerified:false as const,productionPlanActivated:false as const};\n return opticalStage?{...base,opticalStage}:base;\n }\n };\n}\n/**\n * Internal (not exported from the package; 2.3 `simulateCapture` `output.region`): the task for one rectangle of\n * native sites [x, x + width) × [y, y + height) of the whole-frame input. Every site keeps its absolute native index,\n * so its noise seeds, CFA phase, exposure window (rolling-shutter row timing) and value are those of the whole-frame\n * task; the output arrays hold just the rectangle, row-major, and `effectiveSaturationCodes` holds 0 for a CFA\n * phase the rectangle does not contain. Optical-stage retention is not supported.\n */\nexport function createNativeEnvironmentRawRegionTask(input:NativeEnvironmentRawInput,region:{x:number;y:number;width:number;height:number},\n provider:NativeEnvironmentRawProvider):NativeEnvironmentRawTask {\n const plan=calculateNativeRawPlan(input?.raw),native=plan.exposure.geometry.nativeRaster;\n const r=requireAllowlistedRecord(region,[\"x\",\"y\",\"width\",\"height\"],\"Invalid native RAW region.\");\n if(![r.x,r.y,r.width,r.height].every(v=>typeof v===\"number\"&&Number.isSafeInteger(v))||(r.width as number)<1||(r.x as number)<0||(r.x as number)+(r.width as number)>native.pixelWidth)\n throw new InvalidConfigurationError(\"Native RAW region must lie inside the native raster.\");\n const rows=parseRowBand({y:r.y,height:r.height},native.pixelHeight);\n return createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE,{rows,columns:{x:r.x as number,width:r.width as number}});\n}\n/** A band of whole native rows, [y, y + height), in absolute full-sensor coordinates. */\nexport interface NativeRawRowBand { y: number; height: number }\n/**\n * Splits a plan's native rows into at most `count` contiguous bands of nearly equal height (the first\n * `height % count` bands are one row taller), in row order. Deterministic: it depends only on the raster height and\n * `count`. Use one band per worker with createNativeEnvironmentRawPartitionTask.\n */\nexport function calculateNativeRawRowBands(plan:Pick<NativeRawPlan,\"exposure\">,count:number):NativeRawRowBand[] {\n if(plan!==null&&typeof plan===\"object\")rejectUnknownFields(plan,[\"schemaVersion\",\"exposure\",\"frame\",\"exposureWindow\",\"pixelCount\",\"outputBytes\",\"tileCount\",\n \"tileWidth\",\"upstreamRadiometryVerified\",\"seedSchedule\"],\"Native RAW plan\");\n const height=plan?.exposure?.geometry?.nativeRaster?.pixelHeight;\n if(typeof height!==\"number\"||!Number.isSafeInteger(height)||height<1)throw new InvalidConfigurationError(\"Native RAW partitioning requires a native RAW plan.\");\n if(typeof count!==\"number\"||!Number.isSafeInteger(count)||count<1||count>1024)throw new InvalidConfigurationError(\"Native RAW partition count must be an integer from 1 to 1024.\");\n const bands=Math.min(count,height),base=Math.floor(height/bands),extra=height%bands,result:NativeRawRowBand[]=[];\n for(let i=0,y=0;i<bands;i++){const h=base+(i<extra?1:0);result.push({y,height:h});y+=h;}\n return result;\n}\n/**\n * One partition's result: plain data and typed arrays only, so it can be posted from a worker (transfer the four\n * arrays' buffers). Merge every partition of a capture with composeNativeEnvironmentRawPartitions.\n */\nexport interface NativeEnvironmentRawPartition {\n rows: NativeRawRowBand;\n /** Canonical JSON of the capture input (raw, sceneBinding, maximumProviderEvaluations); the merge requires it to match. */\n inputCanonical: string;\n /** Canonical JSON of the band's shared source/optical/motion state; every partition must match. */\n sharedStateCanonical: string;\n /** Readout identity of the band's first site; every partition must match (one readout identity per frame). */\n readoutIdentity: { readoutProfileId: string; regimeId: string; fixedPatternProfileId: string | null; fixedPatternSeedUint32: number | null };\n /** The band's rows only, row-major, as in NativeRawOutput. */\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n saturationFlags: Uint8Array;\n /** Effective white code per CFA phase; 0 for a phase the band does not contain. */\n effectiveSaturationCodes: Uint16Array;\n providerEvaluationCount: number;\n}\nexport interface NativeEnvironmentRawPartitionTask extends Omit<NativeRawTask,\"takeOutput\"> {\n readonly rows: NativeRawRowBand;\n readonly providerEvaluationCount: number;\n takeOutput(): NativeEnvironmentRawPartition;\n}\nfunction inputCanonical(input:NativeEnvironmentRawInput):string {\n return canonical({raw:input.raw,sceneBinding:input.sceneBinding,maximumProviderEvaluations:input.maximumProviderEvaluations});\n}\nfunction parseRowBand(value:unknown,height:number):NativeRawRowBand {\n const band=requireAllowlistedRecord(value,[\"y\",\"height\"],\"Invalid native RAW row band.\");\n if(typeof band.y!==\"number\"||typeof band.height!==\"number\"||!Number.isSafeInteger(band.y)||!Number.isSafeInteger(band.height)||\n band.y<0||band.height<1||band.y+band.height>height)throw new InvalidConfigurationError(\"Native RAW row band must lie inside the native raster.\");\n return {y:band.y,height:band.height};\n}\n/**\n * Creates the task for one row band of a native environment capture (opt-in parallel execution, 2.0).\n *\n * Run one partition per worker (or one after another) with the same input, each worker using its own provider, then\n * merge them with composeNativeEnvironmentRawPartitions. The merged output is byte-identical to the single\n * createNativeEnvironmentRawTask output for the same input and a deterministic provider: noise seeds use absolute\n * native indices, and tiles, plans and per-site values are those of the whole-frame task.\n *\n * Each partition checks the same inputs and limits before its callbacks. maximumProviderEvaluations bounds each\n * partition's own work; the merge also rejects a total above it. Frame-wide checks that span sites (one shared\n * state, one readout identity, one white level per CFA phase) run inside each band and again across bands in the\n * merge. Callbacks are split across partitions, and when several partitions fail, which error is seen first depends\n * on the caller's scheduling. Optical-stage retention is not supported in a partition.\n *\n * The package bundles no worker code: the caller creates workers (Web Workers or Node worker threads), runs this\n * task inside each and posts the partition back.\n */\nexport function createNativeEnvironmentRawPartitionTask(input:NativeEnvironmentRawInput,rows:NativeRawRowBand,\n provider:NativeEnvironmentRawProvider):NativeEnvironmentRawPartitionTask {\n const plan=calculateNativeRawPlan(input?.raw),band=parseRowBand(rows,plan.exposure.geometry.nativeRaster.pixelHeight);\n const probe:NativeEnvironmentPartitionProbe={rows:band};\n const task=createNativeEnvironmentRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE,probe),text=inputCanonical(input);\n return {plan:task.plan,rows:band,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},\n get providerEvaluationCount():number{return task.providerEvaluationCount;},run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawPartition{\n if(task.state!==\"completed\"||probe.shared===undefined||probe.firstSite===undefined)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");\n const site=probe.firstSite,sharedStateCanonical=probe.shared,output=task.takeOutput(),raw=output.raw;\n return {rows:{...band},inputCanonical:text,sharedStateCanonical,readoutIdentity:{readoutProfileId:site.readoutProfile.profileId,regimeId:site.regimeId,\n fixedPatternProfileId:site.fixedPatternNoise?.profileId??null,fixedPatternSeedUint32:site.fixedPatternNoise?.sensorInstanceSeedUint32??null},\n codes:raw.codes,blackLevels:raw.blackLevels,digitalSaturationCodes:raw.digitalSaturationCodes,saturationFlags:raw.saturationFlags,\n effectiveSaturationCodes:raw.effectiveSaturationCodes,providerEvaluationCount:output.providerEvaluationCount};\n }\n };\n}\n/**\n * Assembles the partitions of one capture into the output createNativeEnvironmentRawTask would have returned for\n * the same input (byte-identical RAW arrays and white levels, the summed provider evaluation count).\n *\n * The partitions must be in row order and cover every native row exactly once, and each must come from\n * createNativeEnvironmentRawPartitionTask with this same input. It rejects, with InvalidConfigurationError, a\n * different input, a gap or overlap, wrong array types or lengths, a second shared state or readout identity, two\n * white levels for one CFA phase, a missing phase, or a total evaluation count above the input's budget. It cannot\n * verify how a partition was computed: posted partitions are the caller's own data.\n */\nexport function composeNativeEnvironmentRawPartitions(input:NativeEnvironmentRawInput,partitions:readonly NativeEnvironmentRawPartition[]):NativeEnvironmentRawOutput {\n const {plan,sceneBinding,retention,maximum}=admitNativeEnvironmentInput(input);\n if(retention)throw new InvalidConfigurationError(\"A native environment partition cannot retain the optical stage.\");\n const native=plan.exposure.geometry.nativeRaster,width=native.pixelWidth,layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const phases=layout.repeatWidthSites*layout.repeatHeightSites,text=inputCanonical(input);\n if(!Array.isArray(partitions)||partitions.length<1||partitions.length>native.pixelHeight||Array.from({length:partitions.length},(_,i)=>i in partitions).includes(false))\n throw new InvalidConfigurationError(\"Native RAW merge requires a dense list of partitions.\");\n const codes=new Uint16Array(plan.pixelCount),blackLevels=new Uint16Array(plan.pixelCount),digitalSaturationCodes=new Uint16Array(plan.pixelCount),saturationFlags=new Uint8Array(plan.pixelCount);\n const white=createPhaseWhiteLevelAccumulator(width,layout.repeatWidthSites,layout.repeatHeightSites);\n let y=0,total=0,shared:string|undefined,identity:string|undefined;\n for(const value of partitions){\n const p=requireAllowlistedRecord(value,[\"rows\",\"inputCanonical\",\"sharedStateCanonical\",\"readoutIdentity\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\n \"saturationFlags\",\"effectiveSaturationCodes\",\"providerEvaluationCount\"],\"Invalid native RAW partition.\");\n const band=parseRowBand(p.rows,native.pixelHeight),length=band.height*width;\n if(band.y!==y)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(p.inputCanonical!==text)throw new InvalidConfigurationError(\"Native RAW partition was computed from a different input.\");\n if(!(p.codes instanceof Uint16Array)||!(p.blackLevels instanceof Uint16Array)||!(p.digitalSaturationCodes instanceof Uint16Array)||\n !(p.saturationFlags instanceof Uint8Array)||!(p.effectiveSaturationCodes instanceof Uint16Array)||p.codes.length!==length||p.blackLevels.length!==length||\n p.digitalSaturationCodes.length!==length||p.saturationFlags.length!==length||p.effectiveSaturationCodes.length!==phases||\n typeof p.providerEvaluationCount!==\"number\"||!Number.isSafeInteger(p.providerEvaluationCount)||p.providerEvaluationCount<0||typeof p.sharedStateCanonical!==\"string\")\n throw new InvalidConfigurationError(\"Invalid native RAW partition arrays.\");\n const id=requireAllowlistedRecord(p.readoutIdentity,[\"readoutProfileId\",\"regimeId\",\"fixedPatternProfileId\",\"fixedPatternSeedUint32\"],\"Invalid native RAW partition identity.\");\n const idText=canonical(id);\n shared??=p.sharedStateCanonical;identity??=idText;\n if(p.sharedStateCanonical!==shared)throw new InvalidConfigurationError(\"Native event requires one shared source/optical/motion state.\");\n if(idText!==identity)throw new InvalidConfigurationError(\"Frame requires one readout identity/regime, one fixed-pattern identity and a positive uint16 RAW code span.\");\n const offset=band.y*width;\n codes.set(p.codes,offset);blackLevels.set(p.blackLevels,offset);digitalSaturationCodes.set(p.digitalSaturationCodes,offset);saturationFlags.set(p.saturationFlags,offset);\n for(let phase=0;phase<phases;phase++)white.recordPhase(phase,p.effectiveSaturationCodes[phase]!);\n total+=p.providerEvaluationCount;y+=band.height;\n }\n if(y!==native.pixelHeight)throw new InvalidConfigurationError(\"Native RAW partitions must cover every row once, in row order.\");\n if(total>maximum)throw new InvalidConfigurationError(\"Native environment exceeds tile or full-event query budget.\");\n const raw:NativeRawOutput={plan,codes,blackLevels,digitalSaturationCodes,saturationFlags,effectiveSaturationCodes:white.finish()};\n return {raw,sceneBinding,providerEvaluationCount:total,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};\n}\n/**\n * Re-runs only the sensor stage from a retained optical stage. No radiance callback is called.\n *\n * Use it when only post-optics settings change: noise seed, ISO and its readout regime and gain,\n * fixed-pattern noise, charge, dark-current and capacity profiles, white-balance intent, capture identity\n * or tile width. White balance and rendering are then applied by createNativeRawDevelopmentTask as usual.\n *\n * RAW codes are bit-identical to a full createNativeEnvironmentRawTask with the same final inputs, as long\n * as the radiance provider is a deterministic function of its request.\n *\n * Any optical difference is rejected with InvalidConfigurationError before output. That includes scene\n * binding, geometry or orientation, focal length, aperture, shutter or exposure window, focus,\n * frame/CFA/binding profiles, and any site environment field such as PSF, field throughput, pupil, motion,\n * spectral or temporal sampling and provider profiles.\n *\n * providerEvaluationCount is 0. The caller still owns the stage; it is not used up.\n */\nexport function createNativeEnvironmentSensorStageTask(input:NativeEnvironmentSensorStageInput,opticalStage:NativeEnvironmentOpticalStage,\n provider:NativeEnvironmentSensorStageProvider):NativeEnvironmentRawTask {\n const {task,sceneBinding}=createSensorStageRawTask(input,opticalStage,provider,parseSceneBinding);\n return {plan:task.plan,get state():NativeRawTaskState{return task.state;},get completedTileCount():number{return task.completedTileCount;},get providerEvaluationCount():number{return 0;},\n run:():Promise<void>=>task.run(),cancel:():void=>task.cancel(),dispose:():void=>task.dispose(),\n takeOutput():NativeEnvironmentRawOutput{return {raw:task.takeOutput(),sceneBinding,providerEvaluationCount:0,upstreamOrigin:\"executed-environment-query-provider-optics-psf-eqe\",providerTransportVerified:false,productionPlanActivated:false};}\n };\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NativeRawOutput } from "./native-raw.js";
|
|
2
2
|
import { type ExportSensorColorProfile } from "./photographic-export.js";
|
|
3
|
+
import { type OutputTextMetadata } from "../output/text-metadata.js";
|
|
3
4
|
export declare const NATIVE_RAW_DNG_SCHEMA_VERSION: "1.0.0";
|
|
4
5
|
/** Output-referred noise parameters of one CFA channel (see the module notes). */
|
|
5
6
|
export interface NativeRawDngChannelNoise {
|
|
@@ -19,6 +20,8 @@ export interface SerializeNativeRawDngInput {
|
|
|
19
20
|
baselineExposureEv?: number;
|
|
20
21
|
/** Optional UTC time of the capture, exactly YYYY-MM-DDTHH:mm:ss.sssZ. If omitted, no date tags are written; the engine never makes up a clock time. */
|
|
21
22
|
capturedAtUtc?: string;
|
|
23
|
+
/** Optional (2.4) caller text: description, software, copyright, comment (see the module notes). If omitted, no text is added. */
|
|
24
|
+
textMetadata?: OutputTextMetadata;
|
|
22
25
|
}
|
|
23
26
|
export interface NativeRawDng {
|
|
24
27
|
schemaVersion: typeof NATIVE_RAW_DNG_SCHEMA_VERSION;
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
* covers only Poisson photo and dark shot noise, Gaussian read noise and uniform quantization. It is an
|
|
26
26
|
* approximation: PRNU (photo-response non-uniformity), DSNU (dark-signal non-uniformity) and other
|
|
27
27
|
* fixed-pattern noise are not included.
|
|
28
|
+
* - Text (2.4, only with `textMetadata`): the caller's description is appended to ImageDescription after the
|
|
29
|
+
* simulated-RAW statement and the copyright is written as Copyright (33432), each only when it is printable
|
|
30
|
+
* ASCII (TIFF 6.0 §2: ASCII fields hold 7-bit codes). An XMP packet in tag 700 (BYTE; XMP Specification Part 3
|
|
31
|
+
* §1.1.6, Table 13) always carries every given field in UTF-8: `dc:description` (the full ImageDescription text,
|
|
32
|
+
* statement first, as XMP Part 3 §3.2.3 maps tag 270), `dc:rights`, `xmp:CreatorTool` and `exif:UserComment`.
|
|
33
|
+
* The Software tag keeps naming the engine's writer. Without `textMetadata` the bytes are unchanged.
|
|
28
34
|
* @see docs/NATIVE_RAW_AND_PRINT.md for the tag table, limits and the round trip through parseDngRawImage.
|
|
29
35
|
*/
|
|
30
36
|
import { InvalidConfigurationError } from "../core/configuration-error.js";
|
|
@@ -37,6 +43,7 @@ import { chromaticAdaptationMatrix } from "../color/chromatic-adaptation.js";
|
|
|
37
43
|
import { transformOrientedRasterRectToNative } from "../output/capture-geometry.js";
|
|
38
44
|
import { checkNativeRawIntegrity, validatePackedNativeRaw } from "./native-raw-development.js";
|
|
39
45
|
import { parseExportSensorColorProfile } from "./photographic-export.js";
|
|
46
|
+
import { parseOutputTextMetadata, xmpTextMetadataPacket } from "../output/text-metadata.js";
|
|
40
47
|
import { packExportTiff, exportTiffAscii as ascii, exportTiffNumbers as numbers, exportTiffRationals as rationals, exportTiffBytes as rawBytes, exportTiffDoubles as doubles } from "./export-tiff.js";
|
|
41
48
|
export const NATIVE_RAW_DNG_SCHEMA_VERSION = "1.0.0";
|
|
42
49
|
function fail(message) { throw new InvalidConfigurationError("Native RAW DNG: " + message); }
|
|
@@ -57,7 +64,7 @@ const ORIENTATION = { landscape: 1, "portrait-clockwise": 6, "landscape-inverted
|
|
|
57
64
|
* where its value comes from. The input arrays are copied before the first await.
|
|
58
65
|
*/
|
|
59
66
|
export async function serializeNativeRawDng(input) {
|
|
60
|
-
const r = requireAllowlistedRecord(input, ["raw", "colorProfile", "noise", "baselineExposureEv", "capturedAtUtc"], "Invalid native RAW DNG input.");
|
|
67
|
+
const r = requireAllowlistedRecord(input, ["raw", "colorProfile", "noise", "baselineExposureEv", "capturedAtUtc", "textMetadata"], "Invalid native RAW DNG input.");
|
|
61
68
|
const raw = r.raw, plan = validatePackedNativeRaw(raw);
|
|
62
69
|
const mosaic = plan.frame.colorSamplingProfile.layout;
|
|
63
70
|
if (mosaic.kind === "periodic-mosaic")
|
|
@@ -74,6 +81,13 @@ export async function serializeNativeRawDng(input) {
|
|
|
74
81
|
const capturedAtUtc = r.capturedAtUtc;
|
|
75
82
|
if (capturedAtUtc !== undefined && (typeof capturedAtUtc !== "string" || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(capturedAtUtc) || Number.isNaN(Date.parse(capturedAtUtc))))
|
|
76
83
|
fail("capturedAtUtc must be YYYY-MM-DDTHH:mm:ss.sssZ.");
|
|
84
|
+
let text;
|
|
85
|
+
try {
|
|
86
|
+
text = parseOutputTextMetadata(r.textMetadata, "textMetadata");
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
fail(error.message);
|
|
90
|
+
}
|
|
77
91
|
const native = plan.exposure.geometry.nativeRaster, width = native.pixelWidth, height = native.pixelHeight, g = plan.exposure.resolvedGeometry;
|
|
78
92
|
const active = g.activeCapture.nativeRect;
|
|
79
93
|
const crop = transformOrientedRasterRectToNative({ rect: g.output.cropRect, nativeRaster: g.activeCapture.raster, orientation: plan.exposure.geometry.orientation });
|
|
@@ -142,8 +156,14 @@ export async function serializeNativeRawDng(input) {
|
|
|
142
156
|
const uniqueCameraModel = "Photivra Virtual Camera " + color.profileId + " " + color.profileVersion + " " + colorHash;
|
|
143
157
|
const orientation = ORIENTATION[plan.exposure.geometry.orientation];
|
|
144
158
|
const e = plan.exposure.exposure, software = "Photivra " + ENGINE_API_VERSION;
|
|
145
|
-
const
|
|
159
|
+
const statement = "Simulated capture: packed native RAW from the Photivra engine (" + frame.frameId + "). Source " + plan.exposure.source.kind +
|
|
146
160
|
"; no linear master image or developed rendering is stored.";
|
|
161
|
+
const printableAscii = (value) => value !== undefined && /^[\x20-\x7e]*$/.test(value);
|
|
162
|
+
const description = printableAscii(text?.description) ? statement + " " + text.description : statement;
|
|
163
|
+
const textTags = text === undefined ? [] : [
|
|
164
|
+
...(printableAscii(text.copyright) ? [ascii(33432, text.copyright)] : []),
|
|
165
|
+
rawBytes(700, 1, xmpTextMetadataPacket({ ...text, description: text.description === undefined ? statement : statement + " " + text.description }))
|
|
166
|
+
];
|
|
147
167
|
const exif = [rawBytes(36864, 7, new TextEncoder().encode("0232")), rationals(33434, false, [e.shutterSeconds]), rationals(33437, false, [e.aperture]),
|
|
148
168
|
...(Number.isInteger(e.iso) && e.iso >= 1 && e.iso <= 65535 ? [numbers(34855, 3, [e.iso]), numbers(34864, 3, [2]), numbers(34866, 4, [e.iso])] : []),
|
|
149
169
|
rationals(37386, false, [e.focalLengthMm]), numbers(40961, 3, [65535]), numbers(40962, 4, [crop.width]), numbers(40963, 4, [crop.height]),
|
|
@@ -159,7 +179,7 @@ export async function serializeNativeRawDng(input) {
|
|
|
159
179
|
rationals(50730, true, [baseline]), numbers(50778, 3, [21]),
|
|
160
180
|
rawBytes(50781, 1, Uint8Array.from(rawDataUniqueId.match(/../g).map((s) => parseInt(s, 16)))),
|
|
161
181
|
numbers(50829, 4, [active.y, active.x, active.y + active.height, active.x + active.width]),
|
|
162
|
-
rationals(50964, true, forward.flat()), ...(noiseProfile ? [doubles(51041, noiseProfile)] : [])], exif, pixels);
|
|
182
|
+
rationals(50964, true, forward.flat()), ...(noiseProfile ? [doubles(51041, noiseProfile)] : []), ...textTags], exif, pixels);
|
|
163
183
|
return Object.freeze({ schemaVersion: NATIVE_RAW_DNG_SCHEMA_VERSION, mediaType: "image/dng", bytes, sha256: await sha256(bytes), rawDataUniqueId, uniqueCameraModel,
|
|
164
184
|
activeArea: { ...active }, defaultCrop: { ...crop }, orientation, blackLevels, whiteLevel, cfaPattern, colorMatrix1: stored(colorMatrixTag), asShotNeutral: stored(neutralTag),
|
|
165
185
|
noiseProfile, unrepresentedSaturationFlagCount: unrepresented, source: "packed-native-raw", linearMasterDeclared: false });
|