@photivra/engine 2.15.0 → 2.16.0
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 +47 -1
- package/CITATION.cff +1 -1
- package/README.md +6 -6
- package/SECURITY.md +1 -1
- package/THIRD_PARTY.md +14 -0
- package/dist/capture/native-environment-lean.js +1 -1
- package/dist/capture/native-environment-lean.js.map +1 -1
- package/dist/capture/native-raw-development.d.ts +15 -0
- package/dist/capture/native-raw-development.js +12 -6
- package/dist/capture/native-raw-development.js.map +1 -1
- package/dist/capture/raw-development-kernel.d.ts +10 -3
- package/dist/capture/raw-development-kernel.js +25 -6
- package/dist/capture/raw-development-kernel.js.map +1 -1
- package/dist/core/internal-radiance-evaluator.d.ts +5 -2
- package/dist/core/internal-radiance-evaluator.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/facade/defocus-image-space-provider.d.ts +109 -0
- package/dist/facade/defocus-image-space-provider.js +359 -0
- package/dist/facade/defocus-image-space-provider.js.map +1 -0
- package/dist/facade/diffraction-provider.d.ts +16 -0
- package/dist/facade/diffraction-provider.js +3 -3
- package/dist/facade/diffraction-provider.js.map +1 -1
- package/dist/facade/display-view.d.ts +21 -0
- package/dist/facade/display-view.js +66 -8
- package/dist/facade/display-view.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +111 -2
- package/dist/facade/simulate-capture.js +220 -44
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/simulate-display-view.js +7 -3
- package/dist/facade/simulate-display-view.js.map +1 -1
- package/dist/gpu/display-view-quality-gpu.d.ts +2 -0
- package/dist/gpu/display-view-quality-gpu.js +57 -13
- package/dist/gpu/display-view-quality-gpu.js.map +1 -1
- package/dist/gpu/display-view-speed-gpu.d.ts +2 -0
- package/dist/gpu/display-view-speed-gpu.js +45 -16
- package/dist/gpu/display-view-speed-gpu.js.map +1 -1
- package/dist/gpu/image-kernel-accelerator.js +3 -0
- package/dist/gpu/image-kernel-accelerator.js.map +1 -1
- package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +4 -0
- package/dist/gpu/wgsl-display-view-quality-kernel.js +53 -2
- package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -1
- package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +15 -0
- package/dist/gpu/wgsl-display-view-speed-kernel.js +42 -1
- package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/optics/defocus-disc-kernel.d.ts +3 -2
- package/dist/optics/defocus-disc-kernel.js +3 -2
- package/dist/optics/defocus-disc-kernel.js.map +1 -1
- package/dist/optics/sensor-environment-query.d.ts +31 -0
- package/dist/optics/sensor-environment-query.js +45 -13
- package/dist/optics/sensor-environment-query.js.map +1 -1
- package/dist/processing/development-detail.d.ts +132 -0
- package/dist/processing/development-detail.js +325 -0
- package/dist/processing/development-detail.js.map +1 -0
- package/docs/API_REFERENCE.md +6 -1
- package/docs/QUICK_START.md +190 -12
- package/docs/USAGE.md +14 -3
- package/docs/api/capture-native-raw-development.md +16 -0
- package/docs/api/core-version.md +1 -1
- package/docs/api/exports.json +27 -2
- package/docs/api/facade-simulate-capture.md +128 -3
- package/docs/api/optics-defocus-disc-kernel.md +3 -2
- package/package.json +1 -1
|
@@ -31,6 +31,14 @@ export interface NativeRawDevelopmentInput {
|
|
|
31
31
|
* always true for a 2×2 Bayer pattern. Interior pixels are unchanged.
|
|
32
32
|
*/
|
|
33
33
|
borderHandling?: RawReconstructionBorderHandling;
|
|
34
|
+
/**
|
|
35
|
+
* Development exposure push in stops (#556), from {@link NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS} −2 to +5; default 0.
|
|
36
|
+
* Each site's black-subtracted, white-normalized value is multiplied by 2^stops before demosaic, white balance, the
|
|
37
|
+
* highlight mode, colour and the tone curve, like a raw editor's exposure slider. A site whose pushed value reaches the
|
|
38
|
+
* white level is clipped there and counted as saturated (so `highlightMode: "reconstruct"` rolls it off); values below
|
|
39
|
+
* black stay signed. The RAW codes are not changed. 0 (or omitted) develops exactly as before, byte for byte.
|
|
40
|
+
*/
|
|
41
|
+
exposureCompensationStops?: number;
|
|
34
42
|
/** Counts the kept packed RAW plus the integer output. It does not count caller buffers, process heap or GPU memory. */
|
|
35
43
|
maximumRetainedPayloadBytes: number;
|
|
36
44
|
}
|
|
@@ -77,6 +85,11 @@ export interface NativeRawDevelopmentTask {
|
|
|
77
85
|
dispose(): void;
|
|
78
86
|
takeOutput(): NativeRawDevelopmentOutput;
|
|
79
87
|
}
|
|
88
|
+
/** Accepted range of `NativeRawDevelopmentInput.exposureCompensationStops` and `simulateCapture`'s `output.exposureCompensationStops` (#556). */
|
|
89
|
+
export declare const NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS: Readonly<{
|
|
90
|
+
readonly minimum: -2;
|
|
91
|
+
readonly maximum: 5;
|
|
92
|
+
}>;
|
|
80
93
|
/** Validates packed RAW storage and recomputes its plan. Shared with the native DNG writer. Not exported from the package. */
|
|
81
94
|
export declare function validatePackedNativeRaw(raw: NativeRawOutput): NativeRawOutput["plan"];
|
|
82
95
|
/** Takes the validated packed RAW's arrays (without copying where supported). Not exported from the package. */
|
|
@@ -105,6 +118,8 @@ export interface PreparedDevelopment {
|
|
|
105
118
|
nativeHeight: number;
|
|
106
119
|
reach: number;
|
|
107
120
|
} | undefined;
|
|
121
|
+
/** Development exposure gain 2^exposureCompensationStops; exactly 1 without a push. */
|
|
122
|
+
exposureGain: number;
|
|
108
123
|
}
|
|
109
124
|
/**
|
|
110
125
|
* Synchronous checks of metadata, kernel halo (the neighbourhood each pixel reads) and CFA, shared by the
|
|
@@ -21,6 +21,8 @@ import { stringifyCanonicalJson } from "../core/canonical-json.js";
|
|
|
21
21
|
import { freezeOwnedData } from "../core/owned-data.js";
|
|
22
22
|
import { createRawDevelopmentCounts, createRawPixelDeveloper, normalizedRawSite, rawSiteSaturated } from "./raw-development-kernel.js";
|
|
23
23
|
const TILE_WIDTH = 256;
|
|
24
|
+
/** Accepted range of `NativeRawDevelopmentInput.exposureCompensationStops` and `simulateCapture`'s `output.exposureCompensationStops` (#556). */
|
|
25
|
+
export const NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS = /* @__PURE__ */ Object.freeze({ minimum: -2, maximum: 5 });
|
|
24
26
|
/** Sites checked per integrity chunk before checking whether it is time to yield. */
|
|
25
27
|
const INTEGRITY_CHUNK_SITES = 1 << 18;
|
|
26
28
|
function canonical(value) {
|
|
@@ -71,7 +73,7 @@ export function takeNativeRawOwnership(given, plan) {
|
|
|
71
73
|
* task, the reference and the accelerator. No pixel loop. Not exported from the package.
|
|
72
74
|
*/
|
|
73
75
|
export function prepareNativeRawDevelopment(input) {
|
|
74
|
-
const r = requireAllowlistedRecord(input, ["raw", "phaseProfiles", "colorProfile", "whiteBalance", "rendering", "highlightMode", "borderHandling", "maximumRetainedPayloadBytes"], "Invalid native RAW development input.");
|
|
76
|
+
const r = requireAllowlistedRecord(input, ["raw", "phaseProfiles", "colorProfile", "whiteBalance", "rendering", "highlightMode", "borderHandling", "exposureCompensationStops", "maximumRetainedPayloadBytes"], "Invalid native RAW development input.");
|
|
75
77
|
const plan = validatePackedNativeRaw(input.raw), g = plan.exposure.resolvedGeometry, native = plan.exposure.geometry.nativeRaster;
|
|
76
78
|
const phases = freezeOwnedData(parseRawReconstructionPhaseProfiles(r.phaseProfiles, plan.frame.modeId, plan.frame.colorSamplingProfile));
|
|
77
79
|
const color = freezeOwnedData(parseExportSensorColorProfile(r.colorProfile)), profile = freezeOwnedData(parseSdrRenderingProfile(r.rendering));
|
|
@@ -82,6 +84,10 @@ export function prepareNativeRawDevelopment(input) {
|
|
|
82
84
|
const border = r.borderHandling === undefined ? "reject" : r.borderHandling;
|
|
83
85
|
if (border !== "reject" && border !== "mirror")
|
|
84
86
|
throw new InvalidConfigurationError("Unsupported RAW border handling.");
|
|
87
|
+
const stops = r.exposureCompensationStops === undefined ? 0 : r.exposureCompensationStops;
|
|
88
|
+
if (typeof stops !== "number" || !Number.isFinite(stops) || stops < NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS.minimum || stops > NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS.maximum)
|
|
89
|
+
throw new InvalidConfigurationError("RAW development exposureCompensationStops must be a finite number from -2 to +5.");
|
|
90
|
+
const exposureGain = stops === 0 ? 1 : 2 ** stops;
|
|
85
91
|
if (color.colorSamplingProfileId !== plan.frame.colorSamplingProfile.profileId || phases.some(p => canonical(p.profile.kernels.map(k => k.outputChannelId)) !== canonical(color.channelIds)) ||
|
|
86
92
|
(r.whiteBalance !== "not-required" && r.whiteBalance !== "apply-resolved-sensor-gains") || (intent !== null) !== (r.whiteBalance === "apply-resolved-sensor-gains") ||
|
|
87
93
|
raster.pixelWidth !== crop.width || raster.pixelHeight !== crop.height)
|
|
@@ -126,7 +132,7 @@ export function prepareNativeRawDevelopment(input) {
|
|
|
126
132
|
validateMirrorBorderCfaConsistency(layout, native.pixelWidth, native.pixelHeight, reach);
|
|
127
133
|
mirror = { nativeHeight: native.pixelHeight, reach };
|
|
128
134
|
}
|
|
129
|
-
return { plan, phases, color, profile, whiteBalance: r.whiteBalance, highlightMode, development, crop, raster, border, mirror };
|
|
135
|
+
return { plan, phases, color, profile, whiteBalance: r.whiteBalance, highlightMode, development, crop, raster, border, mirror, exposureGain };
|
|
130
136
|
}
|
|
131
137
|
/** Checks the numbers in rows [y0,y1). Values below black stay signed; each white-minus-black span is positive. Not exported from the package. */
|
|
132
138
|
export function checkNativeRawIntegrity(raw, nativeWidth, repeatWidth, repeatHeight, y0, y1) {
|
|
@@ -140,12 +146,12 @@ export function checkNativeRawIntegrity(raw, nativeWidth, repeatWidth, repeatHei
|
|
|
140
146
|
}
|
|
141
147
|
}
|
|
142
148
|
}
|
|
143
|
-
function source(raw, plan) {
|
|
149
|
+
function source(raw, plan, exposureGain) {
|
|
144
150
|
const layout = plan.frame.colorSamplingProfile.layout;
|
|
145
151
|
if (layout.kind !== "periodic-mosaic")
|
|
146
152
|
throw new InvalidConfigurationError("Development requires periodic CFA.");
|
|
147
153
|
return { nativeWidth: plan.exposure.geometry.nativeRaster.pixelWidth, repeatWidth: layout.repeatWidthSites, repeatHeight: layout.repeatHeightSites,
|
|
148
|
-
codes: raw.codes, blackLevels: raw.blackLevels, saturationFlags: raw.saturationFlags, whiteByPhase: raw.effectiveSaturationCodes };
|
|
154
|
+
codes: raw.codes, blackLevels: raw.blackLevels, saturationFlags: raw.saturationFlags, whiteByPhase: raw.effectiveSaturationCodes, ...(exposureGain === 1 ? {} : { exposureGain }) };
|
|
149
155
|
}
|
|
150
156
|
function emptyDiagnostics() {
|
|
151
157
|
return { renderingNegativeSampleCount: 0, renderingAboveReferenceSampleCount: 0, toneChangedSampleCount: 0, gamutClippedLowSampleCount: 0, gamutClippedHighSampleCount: 0, captureSaturation: "consumed-in-raw-development" };
|
|
@@ -162,7 +168,7 @@ function highlightOf(mode, counts) {
|
|
|
162
168
|
* 256-pixel rows with the reference `calculateSdrRendering`. It does not take ownership of the RAW.
|
|
163
169
|
*/
|
|
164
170
|
export function developNativeRawReference(input) {
|
|
165
|
-
const v = prepareNativeRawDevelopment(input), plan = v.plan, g = plan.exposure.resolvedGeometry, active = g.activeCapture.nativeRect, src = source(input.raw, plan);
|
|
171
|
+
const v = prepareNativeRawDevelopment(input), plan = v.plan, g = plan.exposure.resolvedGeometry, active = g.activeCapture.nativeRect, src = source(input.raw, plan, v.exposureGain);
|
|
166
172
|
checkNativeRawIntegrity(input.raw, src.nativeWidth, src.repeatWidth, src.repeatHeight, 0, plan.exposure.geometry.nativeRaster.pixelHeight);
|
|
167
173
|
const counts = createRawDevelopmentCounts(), diagnostics = emptyDiagnostics(), out = [];
|
|
168
174
|
for (let y = 0; y < v.raster.pixelHeight; y++)
|
|
@@ -228,7 +234,7 @@ export function createNativeRawDevelopmentTaskWithCadence(input, provider, caden
|
|
|
228
234
|
const nativeHeight = plan.exposure.geometry.nativeRaster.pixelHeight;
|
|
229
235
|
// Ownership is transferred only after every synchronous check has passed.
|
|
230
236
|
const raw = takeNativeRawOwnership(input.raw, plan);
|
|
231
|
-
const src = source(raw, plan), tilesPerRow = Math.ceil(raster.pixelWidth / TILE_WIDTH), totalTileCount = tilesPerRow * raster.pixelHeight;
|
|
237
|
+
const src = source(raw, plan, v.exposureGain), tilesPerRow = Math.ceil(raster.pixelWidth / TILE_WIDTH), totalTileCount = tilesPerRow * raster.pixelHeight;
|
|
232
238
|
const abort = new AbortController();
|
|
233
239
|
let state = "ready", output = null, codes = null, completed = 0;
|
|
234
240
|
function release() { raw.codes.fill(0); raw.blackLevels.fill(0); raw.digitalSaturationCodes.fill(0); raw.saturationFlags.fill(0); raw.effectiveSaturationCodes.fill(0); codes?.fill(0); codes = null; output = null; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-raw-development.js","sourceRoot":"","sources":["../../src/capture/native-raw-development.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EAAE,sBAAsB,EAAsE,MAAM,iBAAiB,CAAC;AAC7H,OAAO,EAAE,mCAAmC,EAA2C,MAAM,+BAA+B,CAAC;AAC7H,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,kCAAkC,EACpE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAiC,MAAM,0BAA0B,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAsD,MAAM,sCAAsC,CAAC;AACzI,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,mBAAmB,EAAqD,MAAM,4BAA4B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AC;QAAA,CAAC,CAAA,CAAC;QACtH,OAAO,KAAQ,IAAG,KAAK,KAAG,aAAa,EAAC,CAAC;YAAA,KAAK,GAAC,UAAU,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACpF,UAAU,KAA8B,IAAG,KAAK,KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,iCAAiC,CAAC,CAAC,CAAA,MAAM,KAAK,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,KAAK,CAAC,CAAA,CAAC;KAC5N,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW development: turns packed RAW codes into an SDR image. It reconstructs full colour from\n * the CFA (colour filter array) mosaic exactly, then applies the shared colour, white-balance and SDR\n * steps, in bounded pixel tiles.\n */\nimport { calculateNativeRawPlan, type NativeRawInput, type NativeRawOutput, type NativeRawTaskState } from \"./native-raw.js\";\nimport { parseRawReconstructionPhaseProfiles, type RawFrameReconstructionPhaseProfile } from \"./raw-frame-reconstruction.js\";\nimport { calculateRawReconstructionChannel, rawReconstructionKernelReach, validateMirrorBorderCfaConsistency,\n type RawReconstructionBorderHandling } from \"../sensor/raw-reconstruction.js\";\nimport { equalWithinUlps } from \"../core/portable-math.js\";\nimport { resolveColorSamplingSite } from \"../sensor/color-sampling.js\";\nimport { parseExportSensorColorProfile, type ExportSensorColorProfile } from \"./photographic-export.js\";\nimport { prepareSensorColorDevelopment, type RawHighlightMode, type SensorColorDevelopment } from \"../color/sensor-color-development.js\";\nimport { calculateSdrRendering, parseSdrRenderingProfile, prepareSdrPixelTone, type SdrRenderingProfile, type SdrRenderingResult } from \"../output/sdr-rendering.js\";\nimport { renderSdrRunInto, type NativeTaskProgress, type SdrPixelCounts } from \"../output/native-capture-sdr.js\";\nimport { transformOrientedRasterPointToNative } from \"../output/capture-geometry.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { requireAllowlistedRecord } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { createRawDevelopmentCounts, createRawPixelDeveloper, normalizedRawSite, rawSiteSaturated,\n type RawDevelopmentCounts, type RawDevelopmentSource } from \"./raw-development-kernel.js\";\n\nexport interface NativeRawDevelopmentInput {\n /**\n * Packed RAW. Ownership passes to the task. On creation its five typed arrays are detached with\n * `ArrayBuffer.prototype.transfer` (no copy; the caller's arrays become length 0), or copied when\n * the runtime has no `transfer`. The developed output hands back the same RAW, now owned by the output.\n */\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: \"not-required\" | \"apply-resolved-sensor-gains\";\n rendering: SdrRenderingProfile;\n /** Highlight handling. `clip` (default): clipped highlights become neutral. `reconstruct`: the documented blend toward neutral. */\n highlightMode?: RawHighlightMode;\n /**\n * Frame-edge handling. `reject` (default): every reconstruction neighbourhood must lie inside the\n * native RAW frame. `mirror`: a site outside the frame is read from its mirror image (reflect-101,\n * edge not repeated). This is allowed only when the mirrored site has the same CFA colour, which is\n * always true for a 2×2 Bayer pattern. Interior pixels are unchanged.\n */\n borderHandling?: RawReconstructionBorderHandling;\n /** Counts the kept packed RAW plus the integer output. It does not count caller buffers, process heap or GPU memory. */\n maximumRetainedPayloadBytes: number;\n}\n/** RAW saturation handled before white balance. Counts are pixels or samples of the developed output. */\nexport interface RawHighlightDiagnostics {\n mode: RawHighlightMode;\n /** Output pixels with at least one contributing site at or above its white level, or flagged as saturated. */\n saturatedPixelCount: number;\n /** `clip`: WB-scaled samples clipped at the smallest gain. Always 0 for `reconstruct`. */\n whiteBalanceClippedSampleCount: number;\n /** `reconstruct`: pixels blended toward neutral. Always 0 for `clip`. */\n reconstructedPixelCount: number;\n}\nexport interface NativeRawDevelopmentOutput {\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"];\n width: number;\n height: number;\n integerSamples: Uint8Array | Uint16Array;\n diagnostics: SdrRenderingResult[\"diagnostics\"];\n highlight: RawHighlightDiagnostics;\n borderHandling: RawReconstructionBorderHandling;\n outputEncoding: SdrRenderingResult[\"outputEncoding\"];\n rendering: SdrRenderingProfile;\n displayAdaptation: SdrRenderingResult[\"displayAdaptation\"];\n imageDataPairing: \"derived-from-exact-packed-native-raw\";\n producerOriginVerified: false;\n}\n/** Host callbacks, the same shape as the other native task providers but without a tile reader. */\nexport interface NativeRawDevelopmentProvider {\n /** Must yield to the host event loop, so cancellation and input events can run between tiles. */\n yieldControl(signal: AbortSignal): Promise<void>;\n /** Optional callback after each committed 256-pixel output tile. It cannot change the output. */\n onProgress?(progress: NativeTaskProgress): void;\n}\nexport interface NativeRawDevelopmentTask {\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n readonly totalTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawDevelopmentOutput;\n}\nconst TILE_WIDTH = 256;\n/** Sites checked per integrity chunk before checking whether it is time to yield. */\nconst INTEGRITY_CHUNK_SITES = 1 << 18;\nfunction canonical(value: unknown): string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"reject\",nonFiniteNumberMessage:\"Invalid RAW metadata.\",unsupportedValueMessage:\"Invalid RAW metadata.\"});\n}\n/** Validates packed RAW storage and recomputes its plan. Shared with the native DNG writer. Not exported from the package. */\nexport function validatePackedNativeRaw(raw: NativeRawOutput): NativeRawOutput[\"plan\"] {\n requireAllowlistedRecord(raw,[\"plan\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\"saturationFlags\",\"effectiveSaturationCodes\"],\"Invalid packed RAW output.\");\n const p=raw.plan;\n if(!p?.exposure||!p.frame)throw new InvalidConfigurationError(\"Packed RAW requires complete exposure and frame metadata.\");\n const {engineApiVersion,resolvedGeometry,equivalentFocalLength35Mm,...exposure}=p.exposure;\n void engineApiVersion;void resolvedGeometry;\n const {capture,containerBitDepth,...frame}=p.frame;void containerBitDepth;\n const input: NativeRawInput={exposure,...frame,maximumOutputBytes:p.outputBytes,...(p.tileWidth===undefined?{}:{tileWidth:p.tileWidth}),...(p.maximumPixels===undefined?{}:{maximumPixels:p.maximumPixels}),...(p.exposureWindow?{exposureWindow:p.exposureWindow}:{})};\n const plan=calculateNativeRawPlan(input);\n // The recomputed 35 mm-equivalent focal length (also inside frame.capture, the same exposure record) may\n // differ by a few ULPs, so records parse in every JavaScript engine. Every other field must match exactly.\n const eq=plan.exposure.equivalentFocalLength35Mm,archivedFrameEq=(capture as unknown as Record<string,unknown>|undefined)?.equivalentFocalLength35Mm;\n if(typeof equivalentFocalLength35Mm!==\"number\"||!equalWithinUlps(equivalentFocalLength35Mm,eq,8)||typeof archivedFrameEq!==\"number\"||!equalWithinUlps(archivedFrameEq,eq,8)||\n canonical({...p,exposure:{...p.exposure,equivalentFocalLength35Mm:eq},frame:{...p.frame,capture:{...p.frame.capture,equivalentFocalLength35Mm:eq}}})!==canonical(plan))\n throw new InvalidConfigurationError(\"Packed RAW metadata is stale or inconsistent.\");\n const layout=plan.frame.colorSamplingProfile.layout,phaseCount=layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites*layout.repeatHeightSites:0;\n const buffers=new Set<ArrayBufferLike>();\n for(const [a,type,length] of [[raw.codes,Uint16Array,plan.pixelCount],[raw.blackLevels,Uint16Array,plan.pixelCount],[raw.digitalSaturationCodes,Uint16Array,plan.pixelCount],\n [raw.saturationFlags,Uint8Array,plan.pixelCount],[raw.effectiveSaturationCodes,Uint16Array,phaseCount]] as const){\n if(!(a instanceof type)||!(a.buffer instanceof ArrayBuffer)||a.length!==length||a.buffer.byteLength!==a.byteLength||buffers.has(a.buffer))throw new InvalidConfigurationError(\"Packed RAW storage must be exact owned native arrays.\");\n buffers.add(a.buffer);\n }\n return plan;\n}\n/** Takes sole ownership: detaches without copying when the runtime supports ArrayBuffer transfer, otherwise copies. */\nfunction own<T extends Uint8Array<ArrayBuffer>|Uint16Array<ArrayBuffer>>(array: T, make: (buffer: ArrayBuffer)=>T): T {\n const buffer=array.buffer as ArrayBuffer&{transfer?:()=>ArrayBuffer};\n return typeof buffer.transfer===\"function\"?make(buffer.transfer()):make(buffer.slice(0));\n}\n/** Takes the validated packed RAW's arrays (without copying where supported). Not exported from the package. */\nexport function takeNativeRawOwnership(given: NativeRawOutput, plan: NativeRawOutput[\"plan\"]): NativeRawOutput {\n return {plan,codes:own(given.codes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),blackLevels:own(given.blackLevels as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),\n digitalSaturationCodes:own(given.digitalSaturationCodes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),saturationFlags:own(given.saturationFlags as Uint8Array<ArrayBuffer>,b=>new Uint8Array(b)),\n effectiveSaturationCodes:given.effectiveSaturationCodes.slice()};\n}\n/** Validated development metadata (internal; shared with the image-kernel accelerator). Not exported from the package. */\nexport interface PreparedDevelopment {\n plan: NativeRawOutput[\"plan\"]; phases: RawFrameReconstructionPhaseProfile[]; color: ExportSensorColorProfile; profile: SdrRenderingProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"]; highlightMode: RawHighlightMode; development: SensorColorDevelopment;\n crop: {x:number;y:number;width:number;height:number}; raster: {pixelWidth:number;pixelHeight:number};\n border: RawReconstructionBorderHandling; mirror: {nativeHeight:number;reach:number}|undefined;\n}\n/**\n * Synchronous checks of metadata, kernel halo (the neighbourhood each pixel reads) and CFA, shared by the\n * task, the reference and the accelerator. No pixel loop. Not exported from the package.\n */\nexport function prepareNativeRawDevelopment(input: NativeRawDevelopmentInput): PreparedDevelopment {\n const r=requireAllowlistedRecord(input,[\"raw\",\"phaseProfiles\",\"colorProfile\",\"whiteBalance\",\"rendering\",\"highlightMode\",\"borderHandling\",\"maximumRetainedPayloadBytes\"],\"Invalid native RAW development input.\");\n const plan=validatePackedNativeRaw(input.raw),g=plan.exposure.resolvedGeometry,native=plan.exposure.geometry.nativeRaster;\n const phases=freezeOwnedData(parseRawReconstructionPhaseProfiles(r.phaseProfiles,plan.frame.modeId,plan.frame.colorSamplingProfile));\n const color=freezeOwnedData(parseExportSensorColorProfile(r.colorProfile)),profile=freezeOwnedData(parseSdrRenderingProfile(r.rendering));\n const crop=g.output.cropRect,raster=g.output.raster,active=g.activeCapture.nativeRect,intent=plan.exposure.whiteBalanceIntent;\n const highlightMode=r.highlightMode===undefined?\"clip\":r.highlightMode;\n if(highlightMode!==\"clip\"&&highlightMode!==\"reconstruct\")throw new InvalidConfigurationError(\"Unsupported RAW highlight mode.\");\n const border=r.borderHandling===undefined?\"reject\":r.borderHandling;\n if(border!==\"reject\"&&border!==\"mirror\")throw new InvalidConfigurationError(\"Unsupported RAW border handling.\");\n if(color.colorSamplingProfileId!==plan.frame.colorSamplingProfile.profileId||phases.some(p=>canonical(p.profile.kernels.map(k=>k.outputChannelId))!==canonical(color.channelIds))||\n (r.whiteBalance!==\"not-required\"&&r.whiteBalance!==\"apply-resolved-sensor-gains\")||(intent!==null)!==(r.whiteBalance===\"apply-resolved-sensor-gains\")||\n raster.pixelWidth!==crop.width||raster.pixelHeight!==crop.height)throw new InvalidConfigurationError(\"Development requires bound sensor RGB, explicit one-time WB and 1:1 output crop.\");\n const bytes=plan.outputBytes+raster.pixelWidth*raster.pixelHeight*3*profile.bitDepth/8;\n if(typeof r.maximumRetainedPayloadBytes!==\"number\"||!Number.isSafeInteger(r.maximumRetainedPayloadBytes)||r.maximumRetainedPayloadBytes<bytes)throw new InvalidConfigurationError(\"Development exceeds retained output budget.\");\n const gains=intent?[intent.channelGains.red,intent.channelGains.green,intent.channelGains.blue]:null;\n const development=prepareSensorColorDevelopment(color.normalizedCameraChannelsToXyz,gains,highlightMode),layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n const nativeCorners=[{x:crop.x+.5,y:crop.y+.5},{x:crop.x+crop.width-.5,y:crop.y+crop.height-.5}].map(point=>{\n const p=transformOrientedRasterPointToNative({point,nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(p.x)+active.x,y:Math.floor(p.y)+active.y};\n });\n const minX=Math.min(...nativeCorners.map(p=>p.x)),maxX=Math.max(...nativeCorners.map(p=>p.x)),minY=Math.min(...nativeCorners.map(p=>p.y)),maxY=Math.max(...nativeCorners.map(p=>p.y));\n for(const phase of phases){\n const firstX=minX+(phase.phaseX-minX%layout.repeatWidthSites+layout.repeatWidthSites)%layout.repeatWidthSites;\n const firstY=minY+(phase.phaseY-minY%layout.repeatHeightSites+layout.repeatHeightSites)%layout.repeatHeightSites;\n if(firstX>maxX||firstY>maxY)continue;\n const lastX=maxX-(maxX-phase.phaseX+layout.repeatWidthSites)%layout.repeatWidthSites,lastY=maxY-(maxY-phase.phaseY+layout.repeatHeightSites)%layout.repeatHeightSites;\n for(const kernel of phase.profile.kernels)for(const c of kernel.contributions){\n if(firstX+c.offsetX<0||firstY+c.offsetY<0||lastX+c.offsetX>=native.pixelWidth||lastY+c.offsetY>=native.pixelHeight){\n if(border===\"reject\")throw new InvalidConfigurationError(\"Reconstruction halo leaves native RAW; no padding or renormalization.\");\n // Mirror: check the virtual site from the repeating pattern; validateMirrorBorderCfaConsistency proves mirrored reads agree with it.\n const vx=phase.phaseX+c.offsetX,vy=phase.phaseY+c.offsetY;\n if(layout.siteChannelIds[((vy%layout.repeatHeightSites)+layout.repeatHeightSites)%layout.repeatHeightSites*layout.repeatWidthSites+((vx%layout.repeatWidthSites)+layout.repeatWidthSites)%layout.repeatWidthSites]!==c.sourceChannelId)\n throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n continue;\n }\n const channel=resolveColorSamplingSite({profile:plan.frame.colorSamplingProfile,site:{x:firstX+c.offsetX,y:firstY+c.offsetY}}).mapping.channelId;\n if(channel!==c.sourceChannelId)throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n }\n }\n let mirror:PreparedDevelopment[\"mirror\"];\n if(border===\"mirror\"){\n const reach=rawReconstructionKernelReach(phases);\n validateMirrorBorderCfaConsistency(layout,native.pixelWidth,native.pixelHeight,reach);\n mirror={nativeHeight:native.pixelHeight,reach};\n }\n return {plan,phases,color,profile,whiteBalance:r.whiteBalance,highlightMode,development,crop,raster,border,mirror};\n}\n/** Checks the numbers in rows [y0,y1). Values below black stay signed; each white-minus-black span is positive. Not exported from the package. */\nexport function checkNativeRawIntegrity(raw: NativeRawOutput, nativeWidth: number, repeatWidth: number, repeatHeight: number, y0: number, y1: number): void {\n const codes=raw.codes,blacks=raw.blackLevels,digital=raw.digitalSaturationCodes,flags=raw.saturationFlags,white=raw.effectiveSaturationCodes;\n for(let y=y0;y<y1;y++){\n const row=(y%repeatHeight)*repeatWidth;\n for(let x=0,i=y*nativeWidth;x<nativeWidth;x++,i++){\n const d=digital[i]!,w=white[row+x%repeatWidth]!,b=blacks[i]!;\n if(b>=w||w>d||codes[i]!>d||flags[i]!>7)throw new InvalidConfigurationError(\"Invalid packed RAW code span, white level or saturation flags.\");\n }\n }\n}\nfunction source(raw: NativeRawOutput, plan: NativeRawOutput[\"plan\"]): RawDevelopmentSource {\n const layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n return {nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,repeatWidth:layout.repeatWidthSites,repeatHeight:layout.repeatHeightSites,\n codes:raw.codes,blackLevels:raw.blackLevels,saturationFlags:raw.saturationFlags,whiteByPhase:raw.effectiveSaturationCodes};\n}\nfunction emptyDiagnostics(): SdrRenderingResult[\"diagnostics\"] {\n return {renderingNegativeSampleCount:0,renderingAboveReferenceSampleCount:0,toneChangedSampleCount:0,gamutClippedLowSampleCount:0,gamutClippedHighSampleCount:0,captureSaturation:\"consumed-in-raw-development\"};\n}\nfunction highlightOf(mode: RawHighlightMode, counts: RawDevelopmentCounts): RawHighlightDiagnostics {\n return {mode,saturatedPixelCount:counts.saturatedPixelCount,whiteBalanceClippedSampleCount:counts.whiteBalanceClippedSampleCount,reconstructedPixelCount:counts.reconstructedPixelCount};\n}\n/**\n * Internal, slow reference development using one object per step (not exported from the package). It is\n * kept to prove that the fast typed kernel gives byte-identical output.\n *\n * For each pixel it maps orientation with `transformOrientedRasterPointToNative`, gathers each channel\n * with `calculateRawReconstructionChannel`, develops with the shared colour operator, and renders\n * 256-pixel rows with the reference `calculateSdrRendering`. It does not take ownership of the RAW.\n */\nexport function developNativeRawReference(input: NativeRawDevelopmentInput): {integerSamples:number[];diagnostics:SdrRenderingResult[\"diagnostics\"];highlight:RawHighlightDiagnostics} {\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,src=source(input.raw,plan);\n checkNativeRawIntegrity(input.raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,0,plan.exposure.geometry.nativeRaster.pixelHeight);\n const counts=createRawDevelopmentCounts(),diagnostics=emptyDiagnostics(),out:number[]=[];\n for(let y=0;y<v.raster.pixelHeight;y++)for(let x=0;x<v.raster.pixelWidth;x+=TILE_WIDTH){\n const width=Math.min(TILE_WIDTH,v.raster.pixelWidth-x),rgb:number[]=[];\n for(let j=0;j<width;j++){\n const q=transformOrientedRasterPointToNative({point:{x:v.crop.x+x+j+.5,y:v.crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});\n const point={x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};\n const phase=v.phases[(point.y%src.repeatHeight)*src.repeatWidth+point.x%src.repeatWidth]!;\n let saturated=false;\n const values=phase.profile.kernels.map(kernel=>calculateRawReconstructionChannel(kernel,point,(sx,sy)=>{\n if(rawSiteSaturated(src,sx,sy))saturated=true;return normalizedRawSite(src,sx,sy);\n },v.mirror===undefined?undefined:{width:src.nativeWidth,height:v.mirror.nativeHeight}).linearBlackSubtractedNormalizedValue);\n if(saturated)counts.saturatedPixelCount++;\n const developed=[0,0,0];v.development.developInto(values[0]!,values[1]!,values[2]!,developed,0,counts);rgb.push(...developed);\n }\n const rendered=calculateSdrRendering({sourceImageStateId:plan.frame.frameId+\":developed\",inputImageState:\"color-transformed-linear-rgb\",inputColorSpace:\"linear-srgb-d65\",whiteBalanceHandling:plan.exposure.whiteBalanceIntent?\"already-applied-upstream\":\"not-required\",pixelWidth:width,pixelHeight:1,referenceWhiteValue:1,samples:rgb,profile:v.profile}).value;\n out.push(...rendered.integerSamples);\n for(const key of [\"renderingNegativeSampleCount\",\"renderingAboveReferenceSampleCount\",\"toneChangedSampleCount\",\"gamutClippedLowSampleCount\",\"gamutClippedHighSampleCount\"] as const)diagnostics[key]+=rendered.diagnostics[key];\n }\n return {integerSamples:out,diagnostics,highlight:highlightOf(v.highlightMode,counts)};\n}\nfunction sdrOutputEncoding(maximum: number): SdrRenderingResult[\"outputEncoding\"] {\n return {imageState:\"output-referred-sdr\",colorSpace:\"srgb\",primariesXy:{red:[.64,.33],green:[.30,.60],blue:[.15,.06]},whitePointXy:[.3127,.3290],referenceWhiteLuminanceCdM2:80,codeMinimum:0,codeMaximum:maximum};\n}\n/**\n * Creates a native RAW development task.\n *\n * It checks that every CFA phase has a reconstruction kernel and that every kernel neighbourhood is\n * available, takes ownership of the packed RAW (without copying where supported), and renders 256-pixel\n * output tiles with the fast typed kernel. Development scales each site to its CFA phase's effective white\n * level, clips flagged or white-level sites before white balance, and applies the selected highlight mode\n * (see `prepareSensorColorDevelopment`).\n *\n * The RAW numbers are checked in bounded chunks at the start of `run()`, with host yields, so creating the\n * task costs only as much as reading the metadata. The task yields to the host at chunk and tile boundaries\n * once about 8 ms of work has passed since the last yield, and after the final tile. Yield timing never\n * changes the output.\n *\n * `provider` is `{ yieldControl, onProgress? }`, the same shape as the other native task providers. A bare\n * yield function is still accepted in 2.x but is deprecated.\n *\n * The tile width used at capture is kept when rebuilding the exact packed plan. That width changes neither\n * CFA or noise-seed coordinates nor the developed pixels, and says nothing about transport or what a device\n * can handle.\n */\nexport function createNativeRawDevelopmentTask(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>)): NativeRawDevelopmentTask {\n return createNativeRawDevelopmentTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes output. Not exported from the package. */\nexport function createNativeRawDevelopmentTaskWithCadence(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>),cadence: HostYieldCadence): NativeRawDevelopmentTask {\n const hooks=typeof provider===\"function\"?{yieldControl:provider}:provider;\n if(!hooks||typeof hooks.yieldControl!==\"function\"||(hooks.onProgress!==undefined&&typeof hooks.onProgress!==\"function\"))throw new InvalidConfigurationError(\"Development requires a host event-loop yield.\");\n const yieldControl=hooks.yieldControl.bind(hooks),onProgress=hooks.onProgress?.bind(hooks);\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,raster=v.raster,crop=v.crop;\n const nativeHeight=plan.exposure.geometry.nativeRaster.pixelHeight;\n // Ownership is transferred only after every synchronous check has passed.\n const raw=takeNativeRawOwnership(input.raw,plan);\n const src=source(raw,plan),tilesPerRow=Math.ceil(raster.pixelWidth/TILE_WIDTH),totalTileCount=tilesPerRow*raster.pixelHeight;\n const abort=new AbortController();let state:NativeRawTaskState=\"ready\",output:NativeRawDevelopmentOutput|null=null,codes:Uint8Array|Uint16Array|null=null,completed=0;\n function release(): void {raw.codes.fill(0);raw.blackLevels.fill(0);raw.digitalSaturationCodes.fill(0);raw.saturationFlags.fill(0);raw.effectiveSaturationCodes.fill(0);codes?.fill(0);codes=null;output=null;}\n function check(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW development aborted.\");}\n /** Native coordinates of oriented output pixel (x, y) and the step to (x+1, y), both integer. */\n function rowMapping(x: number, y: number, width: number): {nx:number;ny:number;dx:number;dy:number} {\n const at=(j:number):{x:number;y:number}=>{const q=transformOrientedRasterPointToNative({point:{x:crop.x+x+j+.5,y:crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};};\n const first=at(0),second=width>1?at(1):first,dx=second.x-first.x,dy=second.y-first.y,last=at(width-1);\n if(Math.abs(dx)+Math.abs(dy)!==(width>1?1:0)||last.x!==first.x+dx*(width-1)||last.y!==first.y+dy*(width-1))throw new InvalidConfigurationError(\"Development orientation mapping is not a unit native step.\");\n return {nx:first.x,ny:first.y,dx,dy};\n }\n return {get state():NativeRawTaskState{return state;},get completedTileCount():number{return completed;},totalTileCount,\n async run():Promise<void>{\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Development task is single-use.\");state=\"running\";\n try{\n const gate=createHostYieldGate(cadence);\n const rowsPerChunk=Math.max(1,Math.floor(INTEGRITY_CHUNK_SITES/src.nativeWidth));\n for(let y=0;y<nativeHeight;y+=rowsPerChunk){\n check();checkNativeRawIntegrity(raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,y,Math.min(nativeHeight,y+rowsPerChunk));\n if(gate.due()){await yieldControl(abort.signal);check();gate.restart();}\n }\n codes=v.profile.bitDepth===8?new Uint8Array(raster.pixelWidth*raster.pixelHeight*3):new Uint16Array(raster.pixelWidth*raster.pixelHeight*3);\n const diagnostics=emptyDiagnostics(),developer=createRawPixelDeveloper(src,v.phases,v.development,v.mirror),tone=prepareSdrPixelTone(v.profile);\n const scale=2**v.profile.renderingExposureEv,maximum=2**v.profile.bitDepth-1,rgb=new Float64Array(TILE_WIDTH*3),scratch=new Float64Array(3);\n if(!Number.isFinite(scale)||scale<=0)throw new InvalidConfigurationError(\"Rendering scale is unrepresentable.\");\n for(let y=0;y<raster.pixelHeight;y++)for(let x=0;x<raster.pixelWidth;x+=TILE_WIDTH){\n check();const width=Math.min(TILE_WIDTH,raster.pixelWidth-x),map=rowMapping(x,y,width);\n const counts:SdrPixelCounts={negative:0,above:0,changed:0,low:0,high:0,outOfGamut:false};\n developer.developRun(map.nx,map.ny,map.dx,map.dy,width,rgb);\n renderSdrRunInto(rgb,0,width,v.profile,tone,scale,maximum,codes,(y*raster.pixelWidth+x)*3,scratch,counts);\n // Same 256-pixel granularity as the reference rows, so exposure errors come before gamut rejection.\n if(counts.outOfGamut)throw new InvalidConfigurationError(\"Tone output exceeds the declared SDR gamut range.\");\n diagnostics.renderingNegativeSampleCount+=counts.negative;diagnostics.renderingAboveReferenceSampleCount+=counts.above;diagnostics.toneChangedSampleCount+=counts.changed;\n diagnostics.gamutClippedLowSampleCount+=counts.low;diagnostics.gamutClippedHighSampleCount+=counts.high;\n completed++;onProgress?.({completedTileCount:completed,totalTileCount});\n if(gate.due()||(y===raster.pixelHeight-1&&x+TILE_WIDTH>=raster.pixelWidth)){await yieldControl(abort.signal);check();gate.restart();}\n }\n output={raw,phaseProfiles:v.phases,colorProfile:v.color,whiteBalance:v.whiteBalance,width:raster.pixelWidth,height:raster.pixelHeight,integerSamples:codes,diagnostics,\n highlight:highlightOf(v.highlightMode,developer.counts),borderHandling:v.border,rendering:v.profile,displayAdaptation:{kind:\"external-platform\",applied:false,displayCapabilities:\"unknown\"},\n outputEncoding:sdrOutputEncoding(maximum),imageDataPairing:\"derived-from-exact-packed-native-raw\",producerOriginVerified:false};state=\"completed\";\n }catch(error){release();if(!abort.signal.aborted){state=\"failed\";abort.abort();}throw error;}\n },\n cancel():void{if(state===\"ready\"||state===\"running\"||state===\"completed\"){state=\"cancelled\";abort.abort();release();}},\n dispose():void{if(state!==\"transferred\"){state=\"disposed\";abort.abort();release();}},\n takeOutput():NativeRawDevelopmentOutput{if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Development output unavailable.\");const value=output;output=null;codes=null;state=\"transferred\";return value;}\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"native-raw-development.js","sourceRoot":"","sources":["../../src/capture/native-raw-development.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EAAE,sBAAsB,EAAsE,MAAM,iBAAiB,CAAC;AAC7H,OAAO,EAAE,mCAAmC,EAA2C,MAAM,+BAA+B,CAAC;AAC7H,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,kCAAkC,EACpE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAiC,MAAM,0BAA0B,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAsD,MAAM,sCAAsC,CAAC;AACzI,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,mBAAmB,EAAqD,MAAM,4BAA4B,CAAC;AACrK,OAAO,EAAE,gBAAgB,EAAgD,MAAM,iCAAiC,CAAC;AACjH,OAAO,EAAE,oCAAoC,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAyB,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EA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,CAAC;YAAA,OAAM,KAAK,EAAC,CAAC;gBAAA,OAAO,EAAE,CAAC;gBAAA,IAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC;oBAAA,KAAK,GAAC,QAAQ,CAAC;oBAAA,KAAK,CAAC,KAAK,EAAE,CAAC;gBAAA,CAAC;gBAAA,MAAM,KAAK,CAAC;YAAA,CAAC;QAC/F,CAAC;QACD,MAAM,KAAQ,IAAG,KAAK,KAAG,OAAO,IAAE,KAAK,KAAG,SAAS,IAAE,KAAK,KAAG,WAAW,EAAC,CAAC;YAAA,KAAK,GAAC,WAAW,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACtH,OAAO,KAAQ,IAAG,KAAK,KAAG,aAAa,EAAC,CAAC;YAAA,KAAK,GAAC,UAAU,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACpF,UAAU,KAA8B,IAAG,KAAK,KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,iCAAiC,CAAC,CAAC,CAAA,MAAM,KAAK,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,KAAK,CAAC,CAAA,CAAC;KAC5N,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW development: turns packed RAW codes into an SDR image. It reconstructs full colour from\n * the CFA (colour filter array) mosaic exactly, then applies the shared colour, white-balance and SDR\n * steps, in bounded pixel tiles.\n */\nimport { calculateNativeRawPlan, type NativeRawInput, type NativeRawOutput, type NativeRawTaskState } from \"./native-raw.js\";\nimport { parseRawReconstructionPhaseProfiles, type RawFrameReconstructionPhaseProfile } from \"./raw-frame-reconstruction.js\";\nimport { calculateRawReconstructionChannel, rawReconstructionKernelReach, validateMirrorBorderCfaConsistency,\n type RawReconstructionBorderHandling } from \"../sensor/raw-reconstruction.js\";\nimport { equalWithinUlps } from \"../core/portable-math.js\";\nimport { resolveColorSamplingSite } from \"../sensor/color-sampling.js\";\nimport { parseExportSensorColorProfile, type ExportSensorColorProfile } from \"./photographic-export.js\";\nimport { prepareSensorColorDevelopment, type RawHighlightMode, type SensorColorDevelopment } from \"../color/sensor-color-development.js\";\nimport { calculateSdrRendering, parseSdrRenderingProfile, prepareSdrPixelTone, type SdrRenderingProfile, type SdrRenderingResult } from \"../output/sdr-rendering.js\";\nimport { renderSdrRunInto, type NativeTaskProgress, type SdrPixelCounts } from \"../output/native-capture-sdr.js\";\nimport { transformOrientedRasterPointToNative } from \"../output/capture-geometry.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { requireAllowlistedRecord } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { createRawDevelopmentCounts, createRawPixelDeveloper, normalizedRawSite, rawSiteSaturated,\n type RawDevelopmentCounts, type RawDevelopmentSource } from \"./raw-development-kernel.js\";\n\nexport interface NativeRawDevelopmentInput {\n /**\n * Packed RAW. Ownership passes to the task. On creation its five typed arrays are detached with\n * `ArrayBuffer.prototype.transfer` (no copy; the caller's arrays become length 0), or copied when\n * the runtime has no `transfer`. The developed output hands back the same RAW, now owned by the output.\n */\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: \"not-required\" | \"apply-resolved-sensor-gains\";\n rendering: SdrRenderingProfile;\n /** Highlight handling. `clip` (default): clipped highlights become neutral. `reconstruct`: the documented blend toward neutral. */\n highlightMode?: RawHighlightMode;\n /**\n * Frame-edge handling. `reject` (default): every reconstruction neighbourhood must lie inside the\n * native RAW frame. `mirror`: a site outside the frame is read from its mirror image (reflect-101,\n * edge not repeated). This is allowed only when the mirrored site has the same CFA colour, which is\n * always true for a 2×2 Bayer pattern. Interior pixels are unchanged.\n */\n borderHandling?: RawReconstructionBorderHandling;\n /**\n * Development exposure push in stops (#556), from {@link NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS} −2 to +5; default 0.\n * Each site's black-subtracted, white-normalized value is multiplied by 2^stops before demosaic, white balance, the\n * highlight mode, colour and the tone curve, like a raw editor's exposure slider. A site whose pushed value reaches the\n * white level is clipped there and counted as saturated (so `highlightMode: \"reconstruct\"` rolls it off); values below\n * black stay signed. The RAW codes are not changed. 0 (or omitted) develops exactly as before, byte for byte.\n */\n exposureCompensationStops?: number;\n /** Counts the kept packed RAW plus the integer output. It does not count caller buffers, process heap or GPU memory. */\n maximumRetainedPayloadBytes: number;\n}\n/** RAW saturation handled before white balance. Counts are pixels or samples of the developed output. */\nexport interface RawHighlightDiagnostics {\n mode: RawHighlightMode;\n /** Output pixels with at least one contributing site at or above its white level, or flagged as saturated. */\n saturatedPixelCount: number;\n /** `clip`: WB-scaled samples clipped at the smallest gain. Always 0 for `reconstruct`. */\n whiteBalanceClippedSampleCount: number;\n /** `reconstruct`: pixels blended toward neutral. Always 0 for `clip`. */\n reconstructedPixelCount: number;\n}\nexport interface NativeRawDevelopmentOutput {\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"];\n width: number;\n height: number;\n integerSamples: Uint8Array | Uint16Array;\n diagnostics: SdrRenderingResult[\"diagnostics\"];\n highlight: RawHighlightDiagnostics;\n borderHandling: RawReconstructionBorderHandling;\n outputEncoding: SdrRenderingResult[\"outputEncoding\"];\n rendering: SdrRenderingProfile;\n displayAdaptation: SdrRenderingResult[\"displayAdaptation\"];\n imageDataPairing: \"derived-from-exact-packed-native-raw\";\n producerOriginVerified: false;\n}\n/** Host callbacks, the same shape as the other native task providers but without a tile reader. */\nexport interface NativeRawDevelopmentProvider {\n /** Must yield to the host event loop, so cancellation and input events can run between tiles. */\n yieldControl(signal: AbortSignal): Promise<void>;\n /** Optional callback after each committed 256-pixel output tile. It cannot change the output. */\n onProgress?(progress: NativeTaskProgress): void;\n}\nexport interface NativeRawDevelopmentTask {\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n readonly totalTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawDevelopmentOutput;\n}\nconst TILE_WIDTH = 256;\n/** Accepted range of `NativeRawDevelopmentInput.exposureCompensationStops` and `simulateCapture`'s `output.exposureCompensationStops` (#556). */\nexport const NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS = /* @__PURE__ */ Object.freeze({ minimum: -2, maximum: 5 } as const);\n/** Sites checked per integrity chunk before checking whether it is time to yield. */\nconst INTEGRITY_CHUNK_SITES = 1 << 18;\nfunction canonical(value: unknown): string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"reject\",nonFiniteNumberMessage:\"Invalid RAW metadata.\",unsupportedValueMessage:\"Invalid RAW metadata.\"});\n}\n/** Validates packed RAW storage and recomputes its plan. Shared with the native DNG writer. Not exported from the package. */\nexport function validatePackedNativeRaw(raw: NativeRawOutput): NativeRawOutput[\"plan\"] {\n requireAllowlistedRecord(raw,[\"plan\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\"saturationFlags\",\"effectiveSaturationCodes\"],\"Invalid packed RAW output.\");\n const p=raw.plan;\n if(!p?.exposure||!p.frame)throw new InvalidConfigurationError(\"Packed RAW requires complete exposure and frame metadata.\");\n const {engineApiVersion,resolvedGeometry,equivalentFocalLength35Mm,...exposure}=p.exposure;\n void engineApiVersion;void resolvedGeometry;\n const {capture,containerBitDepth,...frame}=p.frame;void containerBitDepth;\n const input: NativeRawInput={exposure,...frame,maximumOutputBytes:p.outputBytes,...(p.tileWidth===undefined?{}:{tileWidth:p.tileWidth}),...(p.maximumPixels===undefined?{}:{maximumPixels:p.maximumPixels}),...(p.exposureWindow?{exposureWindow:p.exposureWindow}:{})};\n const plan=calculateNativeRawPlan(input);\n // The recomputed 35 mm-equivalent focal length (also inside frame.capture, the same exposure record) may\n // differ by a few ULPs, so records parse in every JavaScript engine. Every other field must match exactly.\n const eq=plan.exposure.equivalentFocalLength35Mm,archivedFrameEq=(capture as unknown as Record<string,unknown>|undefined)?.equivalentFocalLength35Mm;\n if(typeof equivalentFocalLength35Mm!==\"number\"||!equalWithinUlps(equivalentFocalLength35Mm,eq,8)||typeof archivedFrameEq!==\"number\"||!equalWithinUlps(archivedFrameEq,eq,8)||\n canonical({...p,exposure:{...p.exposure,equivalentFocalLength35Mm:eq},frame:{...p.frame,capture:{...p.frame.capture,equivalentFocalLength35Mm:eq}}})!==canonical(plan))\n throw new InvalidConfigurationError(\"Packed RAW metadata is stale or inconsistent.\");\n const layout=plan.frame.colorSamplingProfile.layout,phaseCount=layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites*layout.repeatHeightSites:0;\n const buffers=new Set<ArrayBufferLike>();\n for(const [a,type,length] of [[raw.codes,Uint16Array,plan.pixelCount],[raw.blackLevels,Uint16Array,plan.pixelCount],[raw.digitalSaturationCodes,Uint16Array,plan.pixelCount],\n [raw.saturationFlags,Uint8Array,plan.pixelCount],[raw.effectiveSaturationCodes,Uint16Array,phaseCount]] as const){\n if(!(a instanceof type)||!(a.buffer instanceof ArrayBuffer)||a.length!==length||a.buffer.byteLength!==a.byteLength||buffers.has(a.buffer))throw new InvalidConfigurationError(\"Packed RAW storage must be exact owned native arrays.\");\n buffers.add(a.buffer);\n }\n return plan;\n}\n/** Takes sole ownership: detaches without copying when the runtime supports ArrayBuffer transfer, otherwise copies. */\nfunction own<T extends Uint8Array<ArrayBuffer>|Uint16Array<ArrayBuffer>>(array: T, make: (buffer: ArrayBuffer)=>T): T {\n const buffer=array.buffer as ArrayBuffer&{transfer?:()=>ArrayBuffer};\n return typeof buffer.transfer===\"function\"?make(buffer.transfer()):make(buffer.slice(0));\n}\n/** Takes the validated packed RAW's arrays (without copying where supported). Not exported from the package. */\nexport function takeNativeRawOwnership(given: NativeRawOutput, plan: NativeRawOutput[\"plan\"]): NativeRawOutput {\n return {plan,codes:own(given.codes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),blackLevels:own(given.blackLevels as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),\n digitalSaturationCodes:own(given.digitalSaturationCodes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),saturationFlags:own(given.saturationFlags as Uint8Array<ArrayBuffer>,b=>new Uint8Array(b)),\n effectiveSaturationCodes:given.effectiveSaturationCodes.slice()};\n}\n/** Validated development metadata (internal; shared with the image-kernel accelerator). Not exported from the package. */\nexport interface PreparedDevelopment {\n plan: NativeRawOutput[\"plan\"]; phases: RawFrameReconstructionPhaseProfile[]; color: ExportSensorColorProfile; profile: SdrRenderingProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"]; highlightMode: RawHighlightMode; development: SensorColorDevelopment;\n crop: {x:number;y:number;width:number;height:number}; raster: {pixelWidth:number;pixelHeight:number};\n border: RawReconstructionBorderHandling; mirror: {nativeHeight:number;reach:number}|undefined;\n /** Development exposure gain 2^exposureCompensationStops; exactly 1 without a push. */\n exposureGain: number;\n}\n/**\n * Synchronous checks of metadata, kernel halo (the neighbourhood each pixel reads) and CFA, shared by the\n * task, the reference and the accelerator. No pixel loop. Not exported from the package.\n */\nexport function prepareNativeRawDevelopment(input: NativeRawDevelopmentInput): PreparedDevelopment {\n const r=requireAllowlistedRecord(input,[\"raw\",\"phaseProfiles\",\"colorProfile\",\"whiteBalance\",\"rendering\",\"highlightMode\",\"borderHandling\",\"exposureCompensationStops\",\"maximumRetainedPayloadBytes\"],\"Invalid native RAW development input.\");\n const plan=validatePackedNativeRaw(input.raw),g=plan.exposure.resolvedGeometry,native=plan.exposure.geometry.nativeRaster;\n const phases=freezeOwnedData(parseRawReconstructionPhaseProfiles(r.phaseProfiles,plan.frame.modeId,plan.frame.colorSamplingProfile));\n const color=freezeOwnedData(parseExportSensorColorProfile(r.colorProfile)),profile=freezeOwnedData(parseSdrRenderingProfile(r.rendering));\n const crop=g.output.cropRect,raster=g.output.raster,active=g.activeCapture.nativeRect,intent=plan.exposure.whiteBalanceIntent;\n const highlightMode=r.highlightMode===undefined?\"clip\":r.highlightMode;\n if(highlightMode!==\"clip\"&&highlightMode!==\"reconstruct\")throw new InvalidConfigurationError(\"Unsupported RAW highlight mode.\");\n const border=r.borderHandling===undefined?\"reject\":r.borderHandling;\n if(border!==\"reject\"&&border!==\"mirror\")throw new InvalidConfigurationError(\"Unsupported RAW border handling.\");\n const stops=r.exposureCompensationStops===undefined?0:r.exposureCompensationStops;\n if(typeof stops!==\"number\"||!Number.isFinite(stops)||stops<NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS.minimum||stops>NATIVE_RAW_DEVELOPMENT_EXPOSURE_RANGE_STOPS.maximum)\n throw new InvalidConfigurationError(\"RAW development exposureCompensationStops must be a finite number from -2 to +5.\");\n const exposureGain=stops===0?1:2**stops;\n if(color.colorSamplingProfileId!==plan.frame.colorSamplingProfile.profileId||phases.some(p=>canonical(p.profile.kernels.map(k=>k.outputChannelId))!==canonical(color.channelIds))||\n (r.whiteBalance!==\"not-required\"&&r.whiteBalance!==\"apply-resolved-sensor-gains\")||(intent!==null)!==(r.whiteBalance===\"apply-resolved-sensor-gains\")||\n raster.pixelWidth!==crop.width||raster.pixelHeight!==crop.height)throw new InvalidConfigurationError(\"Development requires bound sensor RGB, explicit one-time WB and 1:1 output crop.\");\n const bytes=plan.outputBytes+raster.pixelWidth*raster.pixelHeight*3*profile.bitDepth/8;\n if(typeof r.maximumRetainedPayloadBytes!==\"number\"||!Number.isSafeInteger(r.maximumRetainedPayloadBytes)||r.maximumRetainedPayloadBytes<bytes)throw new InvalidConfigurationError(\"Development exceeds retained output budget.\");\n const gains=intent?[intent.channelGains.red,intent.channelGains.green,intent.channelGains.blue]:null;\n const development=prepareSensorColorDevelopment(color.normalizedCameraChannelsToXyz,gains,highlightMode),layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n const nativeCorners=[{x:crop.x+.5,y:crop.y+.5},{x:crop.x+crop.width-.5,y:crop.y+crop.height-.5}].map(point=>{\n const p=transformOrientedRasterPointToNative({point,nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(p.x)+active.x,y:Math.floor(p.y)+active.y};\n });\n const minX=Math.min(...nativeCorners.map(p=>p.x)),maxX=Math.max(...nativeCorners.map(p=>p.x)),minY=Math.min(...nativeCorners.map(p=>p.y)),maxY=Math.max(...nativeCorners.map(p=>p.y));\n for(const phase of phases){\n const firstX=minX+(phase.phaseX-minX%layout.repeatWidthSites+layout.repeatWidthSites)%layout.repeatWidthSites;\n const firstY=minY+(phase.phaseY-minY%layout.repeatHeightSites+layout.repeatHeightSites)%layout.repeatHeightSites;\n if(firstX>maxX||firstY>maxY)continue;\n const lastX=maxX-(maxX-phase.phaseX+layout.repeatWidthSites)%layout.repeatWidthSites,lastY=maxY-(maxY-phase.phaseY+layout.repeatHeightSites)%layout.repeatHeightSites;\n for(const kernel of phase.profile.kernels)for(const c of kernel.contributions){\n if(firstX+c.offsetX<0||firstY+c.offsetY<0||lastX+c.offsetX>=native.pixelWidth||lastY+c.offsetY>=native.pixelHeight){\n if(border===\"reject\")throw new InvalidConfigurationError(\"Reconstruction halo leaves native RAW; no padding or renormalization.\");\n // Mirror: check the virtual site from the repeating pattern; validateMirrorBorderCfaConsistency proves mirrored reads agree with it.\n const vx=phase.phaseX+c.offsetX,vy=phase.phaseY+c.offsetY;\n if(layout.siteChannelIds[((vy%layout.repeatHeightSites)+layout.repeatHeightSites)%layout.repeatHeightSites*layout.repeatWidthSites+((vx%layout.repeatWidthSites)+layout.repeatWidthSites)%layout.repeatWidthSites]!==c.sourceChannelId)\n throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n continue;\n }\n const channel=resolveColorSamplingSite({profile:plan.frame.colorSamplingProfile,site:{x:firstX+c.offsetX,y:firstY+c.offsetY}}).mapping.channelId;\n if(channel!==c.sourceChannelId)throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n }\n }\n let mirror:PreparedDevelopment[\"mirror\"];\n if(border===\"mirror\"){\n const reach=rawReconstructionKernelReach(phases);\n validateMirrorBorderCfaConsistency(layout,native.pixelWidth,native.pixelHeight,reach);\n mirror={nativeHeight:native.pixelHeight,reach};\n }\n return {plan,phases,color,profile,whiteBalance:r.whiteBalance,highlightMode,development,crop,raster,border,mirror,exposureGain};\n}\n/** Checks the numbers in rows [y0,y1). Values below black stay signed; each white-minus-black span is positive. Not exported from the package. */\nexport function checkNativeRawIntegrity(raw: NativeRawOutput, nativeWidth: number, repeatWidth: number, repeatHeight: number, y0: number, y1: number): void {\n const codes=raw.codes,blacks=raw.blackLevels,digital=raw.digitalSaturationCodes,flags=raw.saturationFlags,white=raw.effectiveSaturationCodes;\n for(let y=y0;y<y1;y++){\n const row=(y%repeatHeight)*repeatWidth;\n for(let x=0,i=y*nativeWidth;x<nativeWidth;x++,i++){\n const d=digital[i]!,w=white[row+x%repeatWidth]!,b=blacks[i]!;\n if(b>=w||w>d||codes[i]!>d||flags[i]!>7)throw new InvalidConfigurationError(\"Invalid packed RAW code span, white level or saturation flags.\");\n }\n }\n}\nfunction source(raw: NativeRawOutput, plan: NativeRawOutput[\"plan\"], exposureGain: number): RawDevelopmentSource {\n const layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n return {nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,repeatWidth:layout.repeatWidthSites,repeatHeight:layout.repeatHeightSites,\n codes:raw.codes,blackLevels:raw.blackLevels,saturationFlags:raw.saturationFlags,whiteByPhase:raw.effectiveSaturationCodes,...(exposureGain===1?{}:{exposureGain})};\n}\nfunction emptyDiagnostics(): SdrRenderingResult[\"diagnostics\"] {\n return {renderingNegativeSampleCount:0,renderingAboveReferenceSampleCount:0,toneChangedSampleCount:0,gamutClippedLowSampleCount:0,gamutClippedHighSampleCount:0,captureSaturation:\"consumed-in-raw-development\"};\n}\nfunction highlightOf(mode: RawHighlightMode, counts: RawDevelopmentCounts): RawHighlightDiagnostics {\n return {mode,saturatedPixelCount:counts.saturatedPixelCount,whiteBalanceClippedSampleCount:counts.whiteBalanceClippedSampleCount,reconstructedPixelCount:counts.reconstructedPixelCount};\n}\n/**\n * Internal, slow reference development using one object per step (not exported from the package). It is\n * kept to prove that the fast typed kernel gives byte-identical output.\n *\n * For each pixel it maps orientation with `transformOrientedRasterPointToNative`, gathers each channel\n * with `calculateRawReconstructionChannel`, develops with the shared colour operator, and renders\n * 256-pixel rows with the reference `calculateSdrRendering`. It does not take ownership of the RAW.\n */\nexport function developNativeRawReference(input: NativeRawDevelopmentInput): {integerSamples:number[];diagnostics:SdrRenderingResult[\"diagnostics\"];highlight:RawHighlightDiagnostics} {\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,src=source(input.raw,plan,v.exposureGain);\n checkNativeRawIntegrity(input.raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,0,plan.exposure.geometry.nativeRaster.pixelHeight);\n const counts=createRawDevelopmentCounts(),diagnostics=emptyDiagnostics(),out:number[]=[];\n for(let y=0;y<v.raster.pixelHeight;y++)for(let x=0;x<v.raster.pixelWidth;x+=TILE_WIDTH){\n const width=Math.min(TILE_WIDTH,v.raster.pixelWidth-x),rgb:number[]=[];\n for(let j=0;j<width;j++){\n const q=transformOrientedRasterPointToNative({point:{x:v.crop.x+x+j+.5,y:v.crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});\n const point={x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};\n const phase=v.phases[(point.y%src.repeatHeight)*src.repeatWidth+point.x%src.repeatWidth]!;\n let saturated=false;\n const values=phase.profile.kernels.map(kernel=>calculateRawReconstructionChannel(kernel,point,(sx,sy)=>{\n if(rawSiteSaturated(src,sx,sy))saturated=true;return normalizedRawSite(src,sx,sy);\n },v.mirror===undefined?undefined:{width:src.nativeWidth,height:v.mirror.nativeHeight}).linearBlackSubtractedNormalizedValue);\n if(saturated)counts.saturatedPixelCount++;\n const developed=[0,0,0];v.development.developInto(values[0]!,values[1]!,values[2]!,developed,0,counts);rgb.push(...developed);\n }\n const rendered=calculateSdrRendering({sourceImageStateId:plan.frame.frameId+\":developed\",inputImageState:\"color-transformed-linear-rgb\",inputColorSpace:\"linear-srgb-d65\",whiteBalanceHandling:plan.exposure.whiteBalanceIntent?\"already-applied-upstream\":\"not-required\",pixelWidth:width,pixelHeight:1,referenceWhiteValue:1,samples:rgb,profile:v.profile}).value;\n out.push(...rendered.integerSamples);\n for(const key of [\"renderingNegativeSampleCount\",\"renderingAboveReferenceSampleCount\",\"toneChangedSampleCount\",\"gamutClippedLowSampleCount\",\"gamutClippedHighSampleCount\"] as const)diagnostics[key]+=rendered.diagnostics[key];\n }\n return {integerSamples:out,diagnostics,highlight:highlightOf(v.highlightMode,counts)};\n}\nfunction sdrOutputEncoding(maximum: number): SdrRenderingResult[\"outputEncoding\"] {\n return {imageState:\"output-referred-sdr\",colorSpace:\"srgb\",primariesXy:{red:[.64,.33],green:[.30,.60],blue:[.15,.06]},whitePointXy:[.3127,.3290],referenceWhiteLuminanceCdM2:80,codeMinimum:0,codeMaximum:maximum};\n}\n/**\n * Creates a native RAW development task.\n *\n * It checks that every CFA phase has a reconstruction kernel and that every kernel neighbourhood is\n * available, takes ownership of the packed RAW (without copying where supported), and renders 256-pixel\n * output tiles with the fast typed kernel. Development scales each site to its CFA phase's effective white\n * level, clips flagged or white-level sites before white balance, and applies the selected highlight mode\n * (see `prepareSensorColorDevelopment`).\n *\n * The RAW numbers are checked in bounded chunks at the start of `run()`, with host yields, so creating the\n * task costs only as much as reading the metadata. The task yields to the host at chunk and tile boundaries\n * once about 8 ms of work has passed since the last yield, and after the final tile. Yield timing never\n * changes the output.\n *\n * `provider` is `{ yieldControl, onProgress? }`, the same shape as the other native task providers. A bare\n * yield function is still accepted in 2.x but is deprecated.\n *\n * The tile width used at capture is kept when rebuilding the exact packed plan. That width changes neither\n * CFA or noise-seed coordinates nor the developed pixels, and says nothing about transport or what a device\n * can handle.\n */\nexport function createNativeRawDevelopmentTask(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>)): NativeRawDevelopmentTask {\n return createNativeRawDevelopmentTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes output. Not exported from the package. */\nexport function createNativeRawDevelopmentTaskWithCadence(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>),cadence: HostYieldCadence): NativeRawDevelopmentTask {\n const hooks=typeof provider===\"function\"?{yieldControl:provider}:provider;\n if(!hooks||typeof hooks.yieldControl!==\"function\"||(hooks.onProgress!==undefined&&typeof hooks.onProgress!==\"function\"))throw new InvalidConfigurationError(\"Development requires a host event-loop yield.\");\n const yieldControl=hooks.yieldControl.bind(hooks),onProgress=hooks.onProgress?.bind(hooks);\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,raster=v.raster,crop=v.crop;\n const nativeHeight=plan.exposure.geometry.nativeRaster.pixelHeight;\n // Ownership is transferred only after every synchronous check has passed.\n const raw=takeNativeRawOwnership(input.raw,plan);\n const src=source(raw,plan,v.exposureGain),tilesPerRow=Math.ceil(raster.pixelWidth/TILE_WIDTH),totalTileCount=tilesPerRow*raster.pixelHeight;\n const abort=new AbortController();let state:NativeRawTaskState=\"ready\",output:NativeRawDevelopmentOutput|null=null,codes:Uint8Array|Uint16Array|null=null,completed=0;\n function release(): void {raw.codes.fill(0);raw.blackLevels.fill(0);raw.digitalSaturationCodes.fill(0);raw.saturationFlags.fill(0);raw.effectiveSaturationCodes.fill(0);codes?.fill(0);codes=null;output=null;}\n function check(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW development aborted.\");}\n /** Native coordinates of oriented output pixel (x, y) and the step to (x+1, y), both integer. */\n function rowMapping(x: number, y: number, width: number): {nx:number;ny:number;dx:number;dy:number} {\n const at=(j:number):{x:number;y:number}=>{const q=transformOrientedRasterPointToNative({point:{x:crop.x+x+j+.5,y:crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};};\n const first=at(0),second=width>1?at(1):first,dx=second.x-first.x,dy=second.y-first.y,last=at(width-1);\n if(Math.abs(dx)+Math.abs(dy)!==(width>1?1:0)||last.x!==first.x+dx*(width-1)||last.y!==first.y+dy*(width-1))throw new InvalidConfigurationError(\"Development orientation mapping is not a unit native step.\");\n return {nx:first.x,ny:first.y,dx,dy};\n }\n return {get state():NativeRawTaskState{return state;},get completedTileCount():number{return completed;},totalTileCount,\n async run():Promise<void>{\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Development task is single-use.\");state=\"running\";\n try{\n const gate=createHostYieldGate(cadence);\n const rowsPerChunk=Math.max(1,Math.floor(INTEGRITY_CHUNK_SITES/src.nativeWidth));\n for(let y=0;y<nativeHeight;y+=rowsPerChunk){\n check();checkNativeRawIntegrity(raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,y,Math.min(nativeHeight,y+rowsPerChunk));\n if(gate.due()){await yieldControl(abort.signal);check();gate.restart();}\n }\n codes=v.profile.bitDepth===8?new Uint8Array(raster.pixelWidth*raster.pixelHeight*3):new Uint16Array(raster.pixelWidth*raster.pixelHeight*3);\n const diagnostics=emptyDiagnostics(),developer=createRawPixelDeveloper(src,v.phases,v.development,v.mirror),tone=prepareSdrPixelTone(v.profile);\n const scale=2**v.profile.renderingExposureEv,maximum=2**v.profile.bitDepth-1,rgb=new Float64Array(TILE_WIDTH*3),scratch=new Float64Array(3);\n if(!Number.isFinite(scale)||scale<=0)throw new InvalidConfigurationError(\"Rendering scale is unrepresentable.\");\n for(let y=0;y<raster.pixelHeight;y++)for(let x=0;x<raster.pixelWidth;x+=TILE_WIDTH){\n check();const width=Math.min(TILE_WIDTH,raster.pixelWidth-x),map=rowMapping(x,y,width);\n const counts:SdrPixelCounts={negative:0,above:0,changed:0,low:0,high:0,outOfGamut:false};\n developer.developRun(map.nx,map.ny,map.dx,map.dy,width,rgb);\n renderSdrRunInto(rgb,0,width,v.profile,tone,scale,maximum,codes,(y*raster.pixelWidth+x)*3,scratch,counts);\n // Same 256-pixel granularity as the reference rows, so exposure errors come before gamut rejection.\n if(counts.outOfGamut)throw new InvalidConfigurationError(\"Tone output exceeds the declared SDR gamut range.\");\n diagnostics.renderingNegativeSampleCount+=counts.negative;diagnostics.renderingAboveReferenceSampleCount+=counts.above;diagnostics.toneChangedSampleCount+=counts.changed;\n diagnostics.gamutClippedLowSampleCount+=counts.low;diagnostics.gamutClippedHighSampleCount+=counts.high;\n completed++;onProgress?.({completedTileCount:completed,totalTileCount});\n if(gate.due()||(y===raster.pixelHeight-1&&x+TILE_WIDTH>=raster.pixelWidth)){await yieldControl(abort.signal);check();gate.restart();}\n }\n output={raw,phaseProfiles:v.phases,colorProfile:v.color,whiteBalance:v.whiteBalance,width:raster.pixelWidth,height:raster.pixelHeight,integerSamples:codes,diagnostics,\n highlight:highlightOf(v.highlightMode,developer.counts),borderHandling:v.border,rendering:v.profile,displayAdaptation:{kind:\"external-platform\",applied:false,displayCapabilities:\"unknown\"},\n outputEncoding:sdrOutputEncoding(maximum),imageDataPairing:\"derived-from-exact-packed-native-raw\",producerOriginVerified:false};state=\"completed\";\n }catch(error){release();if(!abort.signal.aborted){state=\"failed\";abort.abort();}throw error;}\n },\n cancel():void{if(state===\"ready\"||state===\"running\"||state===\"completed\"){state=\"cancelled\";abort.abort();release();}},\n dispose():void{if(state!==\"transferred\"){state=\"disposed\";abort.abort();release();}},\n takeOutput():NativeRawDevelopmentOutput{if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Development output unavailable.\");const value=output;output=null;codes=null;state=\"transferred\";return value;}\n };\n}\n"]}
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* For native site i with CFA (colour filter array) phase p: if any saturation flag is set, or code ≥ W_p,
|
|
6
6
|
* the normalized value is 1 (clipped at the sensor's effective white level; this uses up the flags).
|
|
7
|
-
* Otherwise it is the signed (code − black)/(W_p − black).
|
|
7
|
+
* Otherwise it is the signed (code − black)/(W_p − black). With a development exposure gain G ≠ 1 (#556) the value is
|
|
8
|
+
* multiplied by G, and a site whose pushed value reaches 1 is clipped at 1 and counted as saturated, like a site at
|
|
9
|
+
* its white level. Reconstruction sums value·weight in the declared
|
|
8
10
|
* contribution order (the same order as `calculateRawReconstructionChannel`). Then
|
|
9
11
|
* `SensorColorDevelopment.developInto` applies white balance (WB), highlight handling and colour.
|
|
10
12
|
*
|
|
@@ -24,15 +26,20 @@ export interface RawDevelopmentSource {
|
|
|
24
26
|
saturationFlags: ArrayLike<number>;
|
|
25
27
|
/** Effective white code per CFA phase, `phaseY*repeatWidth+phaseX`. */
|
|
26
28
|
whiteByPhase: ArrayLike<number>;
|
|
29
|
+
/**
|
|
30
|
+
* Development exposure gain 2^stops on the black-subtracted, white-normalized value (#556). Omitted or 1: no push, and
|
|
31
|
+
* every value is unchanged bit for bit.
|
|
32
|
+
*/
|
|
33
|
+
exposureGain?: number;
|
|
27
34
|
}
|
|
28
35
|
/** Development counters; `saturatedPixelCount` counts pixels with at least one clipped contributing site. */
|
|
29
36
|
export interface RawDevelopmentCounts extends SensorColorDevelopmentCounts {
|
|
30
37
|
saturatedPixelCount: number;
|
|
31
38
|
}
|
|
32
39
|
export declare function createRawDevelopmentCounts(): RawDevelopmentCounts;
|
|
33
|
-
/** Normalized value of one site, or 1 when it is saturated. Shared by the reference read callback. */
|
|
40
|
+
/** Normalized (and pushed) value of one site, or 1 when it is saturated. Shared by the reference read callback. */
|
|
34
41
|
export declare function normalizedRawSite(source: RawDevelopmentSource, x: number, y: number): number;
|
|
35
|
-
/** True when the site is clipped at the white level or flagged. */
|
|
42
|
+
/** True when the site is clipped at the white level or flagged, or its pushed value reaches 1. */
|
|
36
43
|
export declare function rawSiteSaturated(source: RawDevelopmentSource, x: number, y: number): boolean;
|
|
37
44
|
/** Develops native pixels; output is linear sRGB/D65. */
|
|
38
45
|
export interface RawPixelDeveloper {
|
|
@@ -3,16 +3,27 @@ import { reflectRawSiteIndex } from "../sensor/raw-reconstruction.js";
|
|
|
3
3
|
export function createRawDevelopmentCounts() {
|
|
4
4
|
return { saturatedPixelCount: 0, whiteBalanceClippedSampleCount: 0, reconstructedPixelCount: 0 };
|
|
5
5
|
}
|
|
6
|
-
/** Normalized value of one site, or 1 when it is saturated. Shared by the reference read callback. */
|
|
6
|
+
/** Normalized (and pushed) value of one site, or 1 when it is saturated. Shared by the reference read callback. */
|
|
7
7
|
export function normalizedRawSite(source, x, y) {
|
|
8
8
|
const i = y * source.nativeWidth + x, code = source.codes[i], black = source.blackLevels[i], white = source.whiteByPhase[(y % source.repeatHeight) * source.repeatWidth + x % source.repeatWidth];
|
|
9
|
-
|
|
9
|
+
if (source.saturationFlags[i] !== 0 || code >= white)
|
|
10
|
+
return 1;
|
|
11
|
+
const value = (code - black) / (white - black), gain = source.exposureGain;
|
|
12
|
+
if (gain === undefined || gain === 1)
|
|
13
|
+
return value;
|
|
14
|
+
const pushed = value * gain;
|
|
15
|
+
return pushed >= 1 ? 1 : pushed;
|
|
10
16
|
}
|
|
11
|
-
/** True when the site is clipped at the white level or flagged. */
|
|
17
|
+
/** True when the site is clipped at the white level or flagged, or its pushed value reaches 1. */
|
|
12
18
|
export function rawSiteSaturated(source, x, y) {
|
|
13
|
-
const i = y * source.nativeWidth + x;
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
const i = y * source.nativeWidth + x, code = source.codes[i], white = source.whiteByPhase[(y % source.repeatHeight) * source.repeatWidth + x % source.repeatWidth];
|
|
20
|
+
if (source.saturationFlags[i] !== 0 || code >= white)
|
|
21
|
+
return true;
|
|
22
|
+
const gain = source.exposureGain;
|
|
23
|
+
if (gain === undefined || gain === 1)
|
|
24
|
+
return false;
|
|
25
|
+
const black = source.blackLevels[i];
|
|
26
|
+
return (code - black) / (white - black) * gain >= 1;
|
|
16
27
|
}
|
|
17
28
|
/**
|
|
18
29
|
* `mirror` (optional) turns on mirrored reads (reflect-101) for pixels within `reach` sites of the frame
|
|
@@ -29,6 +40,7 @@ export function createRawPixelDeveloper(source, phases, development, mirror) {
|
|
|
29
40
|
}));
|
|
30
41
|
}
|
|
31
42
|
const codes = source.codes, blacks = source.blackLevels, flags = source.saturationFlags, counts = createRawDevelopmentCounts();
|
|
43
|
+
const gain = source.exposureGain ?? 1, pushed = gain !== 1;
|
|
32
44
|
const channel = new Float64Array(3);
|
|
33
45
|
const mirrorTable = mirror === undefined ? null : phases.map((phase) => phase.profile.kernels);
|
|
34
46
|
function developMirroredAt(x, y, out, offset) {
|
|
@@ -68,6 +80,13 @@ export function createRawPixelDeveloper(source, phases, development, mirror) {
|
|
|
68
80
|
else {
|
|
69
81
|
const black = blacks[i];
|
|
70
82
|
normalized = (code - black) / (top - black);
|
|
83
|
+
if (pushed) {
|
|
84
|
+
normalized *= gain;
|
|
85
|
+
if (normalized >= 1) {
|
|
86
|
+
normalized = 1;
|
|
87
|
+
saturated = true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
71
90
|
}
|
|
72
91
|
value += normalized * weight[j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AAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;gBAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAC3F,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Internal fast RAW development kernel on typed arrays, shared by packed native development and the\n * bounded paired export.\n *\n * For native site i with CFA (colour filter array) phase p: if any saturation flag is set, or code ≥ W_p,\n * the normalized value is 1 (clipped at the sensor's effective white level; this uses up the flags).\n * Otherwise it is the signed (code − black)/(W_p − black). Reconstruction sums value·weight in the declared\n * contribution order (the same order as `calculateRawReconstructionChannel`). Then\n * `SensorColorDevelopment.developInto` applies white balance (WB), highlight handling and colour.\n *\n * Kernels are flattened per absolute CFA phase into typed arrays of index offsets, weights and source-site\n * white levels, so no per-pixel objects are allocated. Not exported from the package.\n */\nimport type { RawFrameReconstructionPhaseProfile } from \"./raw-frame-reconstruction.js\";\nimport type { SensorColorDevelopment, SensorColorDevelopmentCounts } from \"../color/sensor-color-development.js\";\nimport { reflectRawSiteIndex } from \"../sensor/raw-reconstruction.js\";\n\n/** Read-only RAW site storage. Arrays are row-major over the full native frame. */\nexport interface RawDevelopmentSource {\n nativeWidth: number;\n repeatWidth: number;\n repeatHeight: number;\n codes: ArrayLike<number>;\n blackLevels: ArrayLike<number>;\n /** Non-zero means the site saturated: physically, before the ADC, or digitally. */\n saturationFlags: ArrayLike<number>;\n /** Effective white code per CFA phase, `phaseY*repeatWidth+phaseX`. */\n whiteByPhase: ArrayLike<number>;\n}\n/** Development counters; `saturatedPixelCount` counts pixels with at least one clipped contributing site. */\nexport interface RawDevelopmentCounts extends SensorColorDevelopmentCounts { saturatedPixelCount: number }\nexport function createRawDevelopmentCounts(): RawDevelopmentCounts {\n return { saturatedPixelCount: 0, whiteBalanceClippedSampleCount: 0, reconstructedPixelCount: 0 };\n}\n/** Normalized value of one site, or 1 when it is saturated. Shared by the reference read callback. */\nexport function normalizedRawSite(source: RawDevelopmentSource, x: number, y: number): number {\n const i = y*source.nativeWidth+x, code = source.codes[i]!, black = source.blackLevels[i]!,\n white = source.whiteByPhase[(y % source.repeatHeight)*source.repeatWidth + x % source.repeatWidth]!;\n return source.saturationFlags[i]! !== 0 || code >= white ? 1 : (code-black)/(white-black);\n}\n/** True when the site is clipped at the white level or flagged. */\nexport function rawSiteSaturated(source: RawDevelopmentSource, x: number, y: number): boolean {\n const i = y*source.nativeWidth+x;\n return source.saturationFlags[i]! !== 0 ||\n source.codes[i]! >= source.whiteByPhase[(y % source.repeatHeight)*source.repeatWidth + x % source.repeatWidth]!;\n}\n\ninterface FlatKernel { delta: Int32Array; weight: Float64Array; white: Float64Array }\n/** Develops native pixels; output is linear sRGB/D65. */\nexport interface RawPixelDeveloper {\n /** Develops the pixel centred on native site (x, y) into out[offset..offset+2]. Halo is validated by the caller. */\n developAt(x: number, y: number, out: Float64Array | number[], offset: number): void;\n /** Develops `count` pixels from native (x, y) stepping (dx, dy) into out[0..3·count). */\n developRun(x: number, y: number, dx: number, dy: number, count: number, out: Float64Array): void;\n readonly counts: RawDevelopmentCounts;\n}\n/**\n * `mirror` (optional) turns on mirrored reads (reflect-101) for pixels within `reach` sites of the frame\n * edge. Interior pixels, and every pixel when it is omitted, use the normal flattened-kernel path.\n */\nexport function createRawPixelDeveloper(source: RawDevelopmentSource, phases: readonly RawFrameReconstructionPhaseProfile[],\n development: SensorColorDevelopment, mirror?: { nativeHeight: number; reach: number }): RawPixelDeveloper {\n const rw = source.repeatWidth, rh = source.repeatHeight, w = source.nativeWidth;\n const table: FlatKernel[][] = [];\n for (const phase of phases) {\n table[phase.phaseY*rw+phase.phaseX] = phase.profile.kernels.map((kernel) => ({\n delta: Int32Array.from(kernel.contributions, (c) => c.offsetY*w+c.offsetX),\n weight: Float64Array.from(kernel.contributions, (c) => c.weight),\n white: Float64Array.from(kernel.contributions, (c) => source.whiteByPhase[\n (((phase.phaseY+c.offsetY) % rh + rh) % rh)*rw + ((phase.phaseX+c.offsetX) % rw + rw) % rw]!)\n }));\n }\n const codes = source.codes, blacks = source.blackLevels, flags = source.saturationFlags, counts = createRawDevelopmentCounts();\n const channel = new Float64Array(3);\n const mirrorTable = mirror === undefined ? null : phases.map((phase) => phase.profile.kernels);\n function developMirroredAt(x: number, y: number, out: Float64Array | number[], offset: number): void {\n const kernels = mirrorTable![(y % rh)*rw + x % rw]!, h = mirror!.nativeHeight;\n let saturated = false;\n for (let k = 0; k < 3; k++) {\n let value = 0;\n for (const c of kernels[k]!.contributions) {\n const sx = reflectRawSiteIndex(x+c.offsetX, w), sy = reflectRawSiteIndex(y+c.offsetY, h);\n if (rawSiteSaturated(source, sx, sy)) saturated = true;\n value += normalizedRawSite(source, sx, sy)*c.weight;\n }\n channel[k] = value;\n }\n if (saturated) counts.saturatedPixelCount++;\n development.developInto(channel[0]!, channel[1]!, channel[2]!, out, offset, counts);\n }\n function developAt(x: number, y: number, out: Float64Array | number[], offset: number): void {\n if (mirror !== undefined && (x < mirror.reach || y < mirror.reach || x+mirror.reach >= w || y+mirror.reach >= mirror.nativeHeight)) {\n developMirroredAt(x, y, out, offset); return;\n }\n const kernels = table[(y % rh)*rw + x % rw]!, center = y*w+x;\n let saturated = false;\n for (let k = 0; k < 3; k++) {\n const kernel = kernels[k]!, delta = kernel.delta, weight = kernel.weight, white = kernel.white;\n let value = 0;\n for (let j = 0; j < delta.length; j++) {\n const i = center+delta[j]!, code = codes[i]!, top = white[j]!;\n let normalized: number;\n if (flags[i]! !== 0 || code >= top) { normalized = 1; saturated = true; } else { const black = blacks[i]!; normalized = (code-black)/(top-black); }\n value += normalized*weight[j]!;\n }\n channel[k] = value;\n }\n if (saturated) counts.saturatedPixelCount++;\n development.developInto(channel[0]!, channel[1]!, channel[2]!, out, offset, counts);\n }\n return {\n counts, developAt,\n developRun(x: number, y: number, dx: number, dy: number, count: number, out: Float64Array): void {\n for (let j = 0, o = 0; j < count; j++, x += dx, y += dy, o += 3) developAt(x, y, out, o);\n }\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"raw-development-kernel.js","sourceRoot":"","sources":["../../src/capture/raw-development-kernel.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAmBtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAqBtE,MAAM,UAAU,0BAA0B;IACxC,OAAO,EAAE,mBAAmB,EAAE,CAAC,EAAE,8BAA8B,EAAE,CAAC,EAAE,uBAAuB,EAAE,CAAC,EAAE,CAAC;AACnG,CAAC;AACD,mHAAmH;AACnH,MAAM,UAAU,iBAAiB,CAAC,MAA4B,EAAE,CAAS,EAAE,CAAS;IAClF,MAAM,CAAC,GAAG,CAAC,GAAC,MAAM,CAAC,WAAW,GAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAE,EAAE,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAE,EACvF,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,GAAC,MAAM,CAAC,WAAW,GAAG,CAAC,GAAG,MAAM,CAAC,WAAW,CAAE,CAAC;IACtG,IAAI,MAAM,CAAC,eAAe,CAAC,CAAC,CAAE,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK;QAAE,OAAO,CAAC,CAAC;IAChE,MAAM,KAAK,GAAG,CAAC,IAAI,GAAC,KAAK,CAAC,GAAC,CAAC,KAAK,GAAC,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC;IACrE,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,MAAM,MAAM,GAAG,KAAK,GAAC,IAAI,CAAC;IAC1B,OAAO,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AAClC,CAAC;AACD,kGAAkG;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,CAAE,CAAC;oBAAC,UAAU,GAAG,CAAC,IAAI,GAAC,KAAK,CAAC,GAAC,CAAC,GAAG,GAAC,KAAK,CAAC,CAAC;oBAChE,IAAI,MAAM,EAAE,CAAC;wBAAC,UAAU,IAAI,IAAI,CAAC;wBAAC,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;4BAAC,UAAU,GAAG,CAAC,CAAC;4BAAC,SAAS,GAAG,IAAI,CAAC;wBAAC,CAAC;oBAAC,CAAC;gBAChG,CAAC;gBACD,KAAK,IAAI,UAAU,GAAC,MAAM,CAAC,CAAC,CAAE,CAAC;YACjC,CAAC;YACD,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QACrB,CAAC;QACD,IAAI,SAAS;YAAE,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC5C,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAE,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,OAAO,CAAC,CAAC,CAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO;QACL,MAAM,EAAE,SAAS;QACjB,UAAU,CAAC,CAAS,EAAE,CAAS,EAAE,EAAU,EAAE,EAAU,EAAE,KAAa,EAAE,GAAiB;YACvF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;gBAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAC3F,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Internal fast RAW development kernel on typed arrays, shared by packed native development and the\n * bounded paired export.\n *\n * For native site i with CFA (colour filter array) phase p: if any saturation flag is set, or code ≥ W_p,\n * the normalized value is 1 (clipped at the sensor's effective white level; this uses up the flags).\n * Otherwise it is the signed (code − black)/(W_p − black). With a development exposure gain G ≠ 1 (#556) the value is\n * multiplied by G, and a site whose pushed value reaches 1 is clipped at 1 and counted as saturated, like a site at\n * its white level. Reconstruction sums value·weight in the declared\n * contribution order (the same order as `calculateRawReconstructionChannel`). Then\n * `SensorColorDevelopment.developInto` applies white balance (WB), highlight handling and colour.\n *\n * Kernels are flattened per absolute CFA phase into typed arrays of index offsets, weights and source-site\n * white levels, so no per-pixel objects are allocated. Not exported from the package.\n */\nimport type { RawFrameReconstructionPhaseProfile } from \"./raw-frame-reconstruction.js\";\nimport type { SensorColorDevelopment, SensorColorDevelopmentCounts } from \"../color/sensor-color-development.js\";\nimport { reflectRawSiteIndex } from \"../sensor/raw-reconstruction.js\";\n\n/** Read-only RAW site storage. Arrays are row-major over the full native frame. */\nexport interface RawDevelopmentSource {\n nativeWidth: number;\n repeatWidth: number;\n repeatHeight: number;\n codes: ArrayLike<number>;\n blackLevels: ArrayLike<number>;\n /** Non-zero means the site saturated: physically, before the ADC, or digitally. */\n saturationFlags: ArrayLike<number>;\n /** Effective white code per CFA phase, `phaseY*repeatWidth+phaseX`. */\n whiteByPhase: ArrayLike<number>;\n /**\n * Development exposure gain 2^stops on the black-subtracted, white-normalized value (#556). Omitted or 1: no push, and\n * every value is unchanged bit for bit.\n */\n exposureGain?: number;\n}\n/** Development counters; `saturatedPixelCount` counts pixels with at least one clipped contributing site. */\nexport interface RawDevelopmentCounts extends SensorColorDevelopmentCounts { saturatedPixelCount: number }\nexport function createRawDevelopmentCounts(): RawDevelopmentCounts {\n return { saturatedPixelCount: 0, whiteBalanceClippedSampleCount: 0, reconstructedPixelCount: 0 };\n}\n/** Normalized (and pushed) value of one site, or 1 when it is saturated. Shared by the reference read callback. */\nexport function normalizedRawSite(source: RawDevelopmentSource, x: number, y: number): number {\n const i = y*source.nativeWidth+x, code = source.codes[i]!, black = source.blackLevels[i]!,\n white = source.whiteByPhase[(y % source.repeatHeight)*source.repeatWidth + x % source.repeatWidth]!;\n if (source.saturationFlags[i]! !== 0 || code >= white) return 1;\n const value = (code-black)/(white-black), gain = source.exposureGain;\n if (gain === undefined || gain === 1) return value;\n const pushed = value*gain;\n return pushed >= 1 ? 1 : pushed;\n}\n/** True when the site is clipped at the white level or flagged, or its pushed value reaches 1. */\nexport function rawSiteSaturated(source: RawDevelopmentSource, x: number, y: number): boolean {\n const i = y*source.nativeWidth+x, code = source.codes[i]!,\n white = source.whiteByPhase[(y % source.repeatHeight)*source.repeatWidth + x % source.repeatWidth]!;\n if (source.saturationFlags[i]! !== 0 || code >= white) return true;\n const gain = source.exposureGain;\n if (gain === undefined || gain === 1) return false;\n const black = source.blackLevels[i]!;\n return (code-black)/(white-black)*gain >= 1;\n}\n\ninterface FlatKernel { delta: Int32Array; weight: Float64Array; white: Float64Array }\n/** Develops native pixels; output is linear sRGB/D65. */\nexport interface RawPixelDeveloper {\n /** Develops the pixel centred on native site (x, y) into out[offset..offset+2]. Halo is validated by the caller. */\n developAt(x: number, y: number, out: Float64Array | number[], offset: number): void;\n /** Develops `count` pixels from native (x, y) stepping (dx, dy) into out[0..3·count). */\n developRun(x: number, y: number, dx: number, dy: number, count: number, out: Float64Array): void;\n readonly counts: RawDevelopmentCounts;\n}\n/**\n * `mirror` (optional) turns on mirrored reads (reflect-101) for pixels within `reach` sites of the frame\n * edge. Interior pixels, and every pixel when it is omitted, use the normal flattened-kernel path.\n */\nexport function createRawPixelDeveloper(source: RawDevelopmentSource, phases: readonly RawFrameReconstructionPhaseProfile[],\n development: SensorColorDevelopment, mirror?: { nativeHeight: number; reach: number }): RawPixelDeveloper {\n const rw = source.repeatWidth, rh = source.repeatHeight, w = source.nativeWidth;\n const table: FlatKernel[][] = [];\n for (const phase of phases) {\n table[phase.phaseY*rw+phase.phaseX] = phase.profile.kernels.map((kernel) => ({\n delta: Int32Array.from(kernel.contributions, (c) => c.offsetY*w+c.offsetX),\n weight: Float64Array.from(kernel.contributions, (c) => c.weight),\n white: Float64Array.from(kernel.contributions, (c) => source.whiteByPhase[\n (((phase.phaseY+c.offsetY) % rh + rh) % rh)*rw + ((phase.phaseX+c.offsetX) % rw + rw) % rw]!)\n }));\n }\n const codes = source.codes, blacks = source.blackLevels, flags = source.saturationFlags, counts = createRawDevelopmentCounts();\n const gain = source.exposureGain ?? 1, pushed = gain !== 1;\n const channel = new Float64Array(3);\n const mirrorTable = mirror === undefined ? null : phases.map((phase) => phase.profile.kernels);\n function developMirroredAt(x: number, y: number, out: Float64Array | number[], offset: number): void {\n const kernels = mirrorTable![(y % rh)*rw + x % rw]!, h = mirror!.nativeHeight;\n let saturated = false;\n for (let k = 0; k < 3; k++) {\n let value = 0;\n for (const c of kernels[k]!.contributions) {\n const sx = reflectRawSiteIndex(x+c.offsetX, w), sy = reflectRawSiteIndex(y+c.offsetY, h);\n if (rawSiteSaturated(source, sx, sy)) saturated = true;\n value += normalizedRawSite(source, sx, sy)*c.weight;\n }\n channel[k] = value;\n }\n if (saturated) counts.saturatedPixelCount++;\n development.developInto(channel[0]!, channel[1]!, channel[2]!, out, offset, counts);\n }\n function developAt(x: number, y: number, out: Float64Array | number[], offset: number): void {\n if (mirror !== undefined && (x < mirror.reach || y < mirror.reach || x+mirror.reach >= w || y+mirror.reach >= mirror.nativeHeight)) {\n developMirroredAt(x, y, out, offset); return;\n }\n const kernels = table[(y % rh)*rw + x % rw]!, center = y*w+x;\n let saturated = false;\n for (let k = 0; k < 3; k++) {\n const kernel = kernels[k]!, delta = kernel.delta, weight = kernel.weight, white = kernel.white;\n let value = 0;\n for (let j = 0; j < delta.length; j++) {\n const i = center+delta[j]!, code = codes[i]!, top = white[j]!;\n let normalized: number;\n if (flags[i]! !== 0 || code >= top) { normalized = 1; saturated = true; } else {\n const black = blacks[i]!; normalized = (code-black)/(top-black);\n if (pushed) { normalized *= gain; if (normalized >= 1) { normalized = 1; saturated = true; } }\n }\n value += normalized*weight[j]!;\n }\n channel[k] = value;\n }\n if (saturated) counts.saturatedPixelCount++;\n development.developInto(channel[0]!, channel[1]!, channel[2]!, out, offset, counts);\n }\n return {\n counts, developAt,\n developRun(x: number, y: number, dx: number, dy: number, count: number, out: Float64Array): void {\n for (let j = 0, o = 0; j < count; j++, x += dx, y += dy, o += 3) developAt(x, y, out, o);\n }\n };\n}\n"]}
|
|
@@ -7,12 +7,15 @@ export declare function isInternalSceneRadianceEvaluator(evaluator: unknown): bo
|
|
|
7
7
|
* function of a location key (a chart material, a convolved lattice site) and the wavelength.
|
|
8
8
|
*/
|
|
9
9
|
export interface InternalRadianceAccess {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* The key the evaluator reads for a query with this outgoing direction at this request time (`timeSecondsFromExposureStart`);
|
|
12
|
+
* undefined where it would throw. Most evaluators ignore the time; the image-space defocus with camera rotation (#548) does not.
|
|
13
|
+
*/
|
|
11
14
|
keyOfDirection(direction: Readonly<{
|
|
12
15
|
x: number;
|
|
13
16
|
y: number;
|
|
14
17
|
z: number;
|
|
15
|
-
}
|
|
18
|
+
}>, timeSeconds: number): number | undefined;
|
|
16
19
|
/** The radiance the evaluator returns for a query of that key at that wavelength. */
|
|
17
20
|
radianceOfKey(key: number, wavelengthNanometers: number): number;
|
|
18
21
|
/** True when keys are few (chart materials), so the native environment may keep a table of their radiances. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-radiance-evaluator.js","sourceRoot":"","sources":["../../src/core/internal-radiance-evaluator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAU,CAAC;AAElD,sDAAsD;AACtD,MAAM,UAAU,kCAAkC,CAAmB,SAAY;IAC/E,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,gCAAgC,CAAC,SAAkB;IACjE,OAAO,OAAO,SAAS,KAAK,UAAU,IAAI,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC/E,CAAC;
|
|
1
|
+
{"version":3,"file":"internal-radiance-evaluator.js","sourceRoot":"","sources":["../../src/core/internal-radiance-evaluator.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAU,CAAC;AAElD,sDAAsD;AACtD,MAAM,UAAU,kCAAkC,CAAmB,SAAY;IAC/E,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACnC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,gCAAgC,CAAC,SAAkB;IACjE,OAAO,OAAO,SAAS,KAAK,UAAU,IAAI,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC/E,CAAC;AAiBD,MAAM,eAAe,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEtE;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,SAAiB,EAAE,MAA8B;IAC9F,IAAI,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC;QAAE,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,sBAAsB,CAAC,SAAkB;IACvD,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtF,CAAC;AAED;;;;;GAKG;AACH,MAAM,qBAAqB,GAAG,IAAI,OAAO,EAAU,CAAC;AAEpD,+DAA+D;AAC/D,MAAM,UAAU,4BAA4B,CAAmB,MAAS;IACtE,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,0BAA0B,CAAC,MAAe;IACxD,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,qBAAqB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAC3E,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC;IACpF,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,GAAG,CAAE,CAAC;QAChE,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,KAAK,SAAS,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IACtH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Internal (not exported from the package): marks the scene-radiance evaluators that the engine itself builds for\n * `simulateCapture` chart scenes (2.6). Their results are object literals with the schema's exact keys, constant\n * schema/quantity/unit/status fields, the request's identifiers and deep-frozen engine-owned uncertainty, evidence\n * and limitations; the native environment then skips re-parsing those fixed parts (see\n * `parseSceneRadianceEvaluationResultWithValidatedRecords`). Evaluators from callers are never marked and keep the\n * full validation. The mark is on the function object, which only the engine holds.\n */\nconst INTERNAL_EVALUATORS = new WeakSet<object>();\n\n/** Marks an engine-built evaluator and returns it. */\nexport function markInternalSceneRadianceEvaluator<T extends object>(evaluator: T): T {\n INTERNAL_EVALUATORS.add(evaluator);\n return evaluator;\n}\n\n/** True only for an evaluator marked by the engine. */\nexport function isInternalSceneRadianceEvaluator(evaluator: unknown): boolean {\n return typeof evaluator === \"function\" && INTERNAL_EVALUATORS.has(evaluator);\n}\n\n/**\n * Internal (#394): the lookup behind an engine-built evaluator whose result for an environment-direction query is a pure\n * function of a location key (a chart material, a convolved lattice site) and the wavelength.\n */\nexport interface InternalRadianceAccess {\n /**\n * The key the evaluator reads for a query with this outgoing direction at this request time (`timeSecondsFromExposureStart`);\n * undefined where it would throw. Most evaluators ignore the time; the image-space defocus with camera rotation (#548) does not.\n */\n keyOfDirection(direction: Readonly<{ x: number; y: number; z: number }>, timeSeconds: number): number | undefined;\n /** The radiance the evaluator returns for a query of that key at that wavelength. */\n radianceOfKey(key: number, wavelengthNanometers: number): number;\n /** True when keys are few (chart materials), so the native environment may keep a table of their radiances. */\n tabulated: boolean;\n}\nconst RADIANCE_ACCESS = new WeakMap<object, InternalRadianceAccess>();\n\n/**\n * Registers the lookup of an engine-built evaluator (#394), so the native environment may take its radiances from the key\n * instead of calling it (its lean templates verify this against their own evaluations). Only for an evaluator already marked\n * internal; caller scenes never register.\n */\nexport function registerInternalRadianceAccess(evaluator: object, access: InternalRadianceAccess): void {\n if (INTERNAL_EVALUATORS.has(evaluator)) RADIANCE_ACCESS.set(evaluator, access);\n}\n\n/** The registered lookup of an engine-built evaluator, if any. */\nexport function internalRadianceAccess(evaluator: unknown): InternalRadianceAccess | undefined {\n return typeof evaluator === \"function\" ? RADIANCE_ACCESS.get(evaluator) : undefined;\n}\n\n/**\n * Internal (#394): marks the native tile readers that `simulateCapture` builds. Each call returns fresh site records built by\n * the engine (new top-level objects per site, shared nested records the engine never changes afterwards), never shown to\n * supplied code, so the native environment may plan them as engine-owned data without the private structured clone it makes\n * of a caller's tiles. Readers from callers are never marked. The mark is on the function object, which only the engine holds.\n */\nconst INTERNAL_TILE_READERS = new WeakSet<object>();\n\n/** Marks an engine-built native tile reader and returns it. */\nexport function markInternalNativeTileReader<T extends object>(reader: T): T {\n INTERNAL_TILE_READERS.add(reader);\n return reader;\n}\n\n/** True only for a tile reader marked by the engine. */\nexport function isInternalNativeTileReader(reader: unknown): boolean {\n return typeof reader === \"function\" && INTERNAL_TILE_READERS.has(reader);\n}\n\n/** True when the value and everything reachable from it are frozen (primitives count as frozen). */\nexport function isDeeplyFrozen(value: unknown): boolean {\n if (value === null || typeof value !== \"object\") return typeof value !== \"function\";\n if (!Object.isFrozen(value)) return false;\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)!;\n if (descriptor.get !== undefined || descriptor.set !== undefined || !isDeeplyFrozen(descriptor.value)) return false;\n }\n return true;\n}\n"]}
|
package/dist/core/version.d.ts
CHANGED
package/dist/core/version.js
CHANGED
package/dist/core/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAiB,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Version of the engine release. Since 1.0.1 it equals the npm package version.\n *\n * New captures and plans record this version as their creator. Archived records keep the\n * version they were made with. Proof-of-concept (POC), schema and model contracts have their\n * own versions. Release checks confirm it matches package.json and the packed package.\n * @see docs/RELEASE_1_0_1.md\n */\nexport const ENGINE_API_VERSION = \"2.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAiB,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Version of the engine release. Since 1.0.1 it equals the npm package version.\n *\n * New captures and plans record this version as their creator. Archived records keep the\n * version they were made with. Proof-of-concept (POC), schema and model contracts have their\n * own versions. Release checks confirm it matches package.json and the packed package.\n * @see docs/RELEASE_1_0_1.md\n */\nexport const ENGINE_API_VERSION = \"2.16.0\" as const;\n"]}
|