@photivra/engine 2.20.0 → 2.22.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 +295 -1
- package/CITATION.cff +1 -1
- package/README.md +7 -6
- package/SECURITY.md +1 -1
- package/THIRD_PARTY.md +18 -0
- package/dist/capture/c2pa-embed.d.ts +116 -0
- package/dist/capture/c2pa-embed.js +493 -0
- package/dist/capture/c2pa-embed.js.map +1 -0
- package/dist/capture/dng-import.d.ts +73 -8
- package/dist/capture/dng-import.js +315 -80
- package/dist/capture/dng-import.js.map +1 -1
- package/dist/capture/dng-lens-correction-opcodes.d.ts +2 -2
- package/dist/capture/dng-lens-correction-opcodes.js +2 -2
- package/dist/capture/dng-lens-correction-opcodes.js.map +1 -1
- package/dist/capture/dng-opcodes.d.ts +96 -0
- package/dist/capture/dng-opcodes.js +391 -0
- package/dist/capture/dng-opcodes.js.map +1 -0
- package/dist/capture/dng-profile-maps.d.ts +99 -0
- package/dist/capture/dng-profile-maps.js +381 -0
- package/dist/capture/dng-profile-maps.js.map +1 -0
- package/dist/capture/dng-stage-image.d.ts +23 -0
- package/dist/capture/dng-stage-image.js +65 -0
- package/dist/capture/dng-stage-image.js.map +1 -0
- package/dist/capture/exposure-build-up-stage.d.ts +16 -0
- package/dist/capture/exposure-build-up-stage.js +4 -0
- package/dist/capture/exposure-build-up-stage.js.map +1 -0
- package/dist/capture/jpeg-xl-tiles.d.ts +22 -0
- package/dist/capture/jpeg-xl-tiles.js +151 -0
- package/dist/capture/jpeg-xl-tiles.js.map +1 -0
- package/dist/capture/lossy-jpeg.d.ts +17 -0
- package/dist/capture/lossy-jpeg.js +369 -0
- package/dist/capture/lossy-jpeg.js.map +1 -0
- package/dist/capture/native-environment-lean.d.ts +2 -1
- package/dist/capture/native-environment-lean.js +41 -73
- package/dist/capture/native-environment-lean.js.map +1 -1
- package/dist/capture/native-environment-tabulated.js +4 -3
- package/dist/capture/native-environment-tabulated.js.map +1 -1
- package/dist/capture/native-raw-development.d.ts +2 -1
- package/dist/capture/native-raw-development.js.map +1 -1
- package/dist/capture/native-raw.d.ts +3 -2
- package/dist/capture/native-raw.js +5 -4
- package/dist/capture/native-raw.js.map +1 -1
- package/dist/capture/sensor-raw-producer.d.ts +4 -1
- package/dist/capture/sensor-raw-producer.js +12 -3
- package/dist/capture/sensor-raw-producer.js.map +1 -1
- package/dist/color/neighbor-highlight-reconstruction.d.ts +66 -0
- package/dist/color/neighbor-highlight-reconstruction.js +234 -0
- package/dist/color/neighbor-highlight-reconstruction.js.map +1 -0
- package/dist/color/sensor-color-development.d.ts +5 -0
- package/dist/color/sensor-color-development.js +7 -1
- package/dist/color/sensor-color-development.js.map +1 -1
- package/dist/color/spectral-spikiness.d.ts +11 -0
- package/dist/color/spectral-spikiness.js +23 -0
- package/dist/color/spectral-spikiness.js.map +1 -0
- package/dist/core/execution-error.d.ts +21 -0
- package/dist/core/execution-error.js +12 -0
- package/dist/core/execution-error.js.map +1 -0
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/generic-lens-catalogue.d.ts +3 -2
- package/dist/equipment/generic-lens-catalogue.js +18 -5
- package/dist/equipment/generic-lens-catalogue.js.map +1 -1
- package/dist/equipment/generic-tier-assets.d.ts +32 -0
- package/dist/equipment/generic-tier-assets.js +16 -11
- package/dist/equipment/generic-tier-assets.js.map +1 -1
- package/dist/equipment/sensor-profile-body.d.ts +78 -0
- package/dist/equipment/sensor-profile-body.js +77 -0
- package/dist/equipment/sensor-profile-body.js.map +1 -0
- package/dist/equipment/sensor-profiles.d.ts +8 -0
- package/dist/equipment/sensor-profiles.js +82 -0
- package/dist/equipment/sensor-profiles.js.map +1 -0
- package/dist/facade/catalogue-lens-signal.d.ts +28 -3
- package/dist/facade/catalogue-lens-signal.js +83 -78
- package/dist/facade/catalogue-lens-signal.js.map +1 -1
- package/dist/facade/chart-radiance-batch.js +2 -1
- package/dist/facade/chart-radiance-batch.js.map +1 -1
- package/dist/facade/defocus-image-space-provider.d.ts +7 -0
- package/dist/facade/defocus-image-space-provider.js +64 -76
- package/dist/facade/defocus-image-space-provider.js.map +1 -1
- package/dist/facade/diffraction-provider.d.ts +1 -1
- package/dist/facade/diffraction-provider.js +4 -4
- package/dist/facade/diffraction-provider.js.map +1 -1
- package/dist/facade/display-view-gpu-session.js +39 -5
- package/dist/facade/display-view-gpu-session.js.map +1 -1
- package/dist/facade/display-view-gpu.d.ts +19 -6
- package/dist/facade/display-view-gpu.js.map +1 -1
- package/dist/facade/display-view-lens-signal.js +25 -23
- package/dist/facade/display-view-lens-signal.js.map +1 -1
- package/dist/facade/display-view-normal.d.ts +15 -0
- package/dist/facade/display-view-normal.js +44 -0
- package/dist/facade/display-view-normal.js.map +1 -0
- package/dist/facade/display-view-rendering.d.ts +97 -0
- package/dist/facade/display-view-rendering.js +598 -0
- package/dist/facade/display-view-rendering.js.map +1 -0
- package/dist/facade/display-view.d.ts +37 -65
- package/dist/facade/display-view.js +152 -499
- package/dist/facade/display-view.js.map +1 -1
- package/dist/facade/expected-signal-setup.d.ts +3 -1
- package/dist/facade/expected-signal-setup.js +3 -3
- package/dist/facade/expected-signal-setup.js.map +1 -1
- package/dist/facade/expected-signal.d.ts +47 -14
- package/dist/facade/expected-signal.js +117 -112
- package/dist/facade/expected-signal.js.map +1 -1
- package/dist/facade/exposure-build-up.d.ts +70 -0
- package/dist/facade/exposure-build-up.js +164 -0
- package/dist/facade/exposure-build-up.js.map +1 -0
- package/dist/facade/fast-methods.d.ts +1 -1
- package/dist/facade/fast-methods.js +46 -9
- package/dist/facade/fast-methods.js.map +1 -1
- package/dist/facade/generic-lens-capture.d.ts +3 -3
- package/dist/facade/generic-lens-capture.js +3 -3
- package/dist/facade/generic-lens-capture.js.map +1 -1
- package/dist/facade/image-plane-enable.d.ts +7 -0
- package/dist/facade/image-plane-enable.js +17 -0
- package/dist/facade/image-plane-enable.js.map +1 -0
- package/dist/facade/image-plane-lattice-data.d.ts +6 -0
- package/dist/facade/image-plane-lattice-data.js +10 -0
- package/dist/facade/image-plane-lattice-data.js.map +1 -0
- package/dist/facade/image-plane-support.d.ts +33 -0
- package/dist/facade/image-plane-support.js +11 -0
- package/dist/facade/image-plane-support.js.map +1 -0
- package/dist/facade/image-plane.d.ts +36 -0
- package/dist/facade/image-plane.js +384 -0
- package/dist/facade/image-plane.js.map +1 -0
- package/dist/facade/mixed-illumination.d.ts +108 -0
- package/dist/facade/mixed-illumination.js +174 -0
- package/dist/facade/mixed-illumination.js.map +1 -0
- package/dist/facade/on-demand-kits.d.ts +14 -0
- package/dist/facade/on-demand-kits.js +36 -0
- package/dist/facade/on-demand-kits.js.map +1 -0
- package/dist/facade/opt-in-kit.d.ts +9 -0
- package/dist/facade/opt-in-kit.js +11 -0
- package/dist/facade/opt-in-kit.js.map +1 -0
- package/dist/facade/quality-kit.d.ts +21 -0
- package/dist/facade/quality-kit.js +23 -0
- package/dist/facade/quality-kit.js.map +1 -0
- package/dist/facade/quality-paths.d.ts +22 -0
- package/dist/facade/quality-paths.js +44 -0
- package/dist/facade/quality-paths.js.map +1 -0
- package/dist/facade/representative-light-sources.d.ts +72 -0
- package/dist/facade/representative-light-sources.js +124 -0
- package/dist/facade/representative-light-sources.js.map +1 -0
- package/dist/facade/scene-radiance.d.ts +145 -4
- package/dist/facade/scene-radiance.js +50 -13
- package/dist/facade/scene-radiance.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +68 -20
- package/dist/facade/simulate-capture.js +399 -146
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/simulate-display-view.d.ts +10 -12
- package/dist/facade/simulate-display-view.js +70 -53
- package/dist/facade/simulate-display-view.js.map +1 -1
- package/dist/gpu/chart-composite-gpu.d.ts +13 -1
- package/dist/gpu/chart-composite-gpu.js +48 -9
- package/dist/gpu/chart-composite-gpu.js.map +1 -1
- package/dist/gpu/chart-radiance-gpu.js +4 -30
- package/dist/gpu/chart-radiance-gpu.js.map +1 -1
- package/dist/gpu/display-view-composite-material-module.d.ts +10 -4
- package/dist/gpu/display-view-composite-material-module.js +39 -13
- package/dist/gpu/display-view-composite-material-module.js.map +1 -1
- package/dist/gpu/display-view-gpu-renderer.d.ts +43 -0
- package/dist/gpu/display-view-gpu-renderer.js +134 -0
- package/dist/gpu/display-view-gpu-renderer.js.map +1 -0
- package/dist/gpu/display-view-image-material-module.d.ts +87 -0
- package/dist/gpu/display-view-image-material-module.js +361 -0
- package/dist/gpu/display-view-image-material-module.js.map +1 -0
- package/dist/gpu/display-view-image-quality.d.ts +87 -0
- package/dist/gpu/display-view-image-quality.js +625 -0
- package/dist/gpu/display-view-image-quality.js.map +1 -0
- package/dist/gpu/display-view-quality-gpu.d.ts +80 -65
- package/dist/gpu/display-view-quality-gpu.js +187 -445
- package/dist/gpu/display-view-quality-gpu.js.map +1 -1
- package/dist/gpu/display-view-speed-gpu.d.ts +67 -19
- package/dist/gpu/display-view-speed-gpu.js +181 -105
- 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/image-kernel-execution.d.ts +2 -13
- package/dist/gpu/image-kernel-execution.js +2 -10
- package/dist/gpu/image-kernel-execution.js.map +1 -1
- package/dist/gpu/wgsl-display-view-coupled-stub.d.ts +8 -0
- package/dist/gpu/wgsl-display-view-coupled-stub.js +21 -0
- package/dist/gpu/wgsl-display-view-coupled-stub.js.map +1 -0
- package/dist/gpu/wgsl-display-view-coupled.d.ts +88 -0
- package/dist/gpu/wgsl-display-view-coupled.js +353 -0
- package/dist/gpu/wgsl-display-view-coupled.js.map +1 -0
- package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +33 -24
- package/dist/gpu/wgsl-display-view-quality-kernel.js +166 -146
- package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -1
- package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +19 -44
- package/dist/gpu/wgsl-display-view-speed-kernel.js +116 -18
- package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -1
- package/dist/gpu/wgsl-exact-sum.d.ts +20 -0
- package/dist/gpu/wgsl-exact-sum.js +42 -0
- package/dist/gpu/wgsl-exact-sum.js.map +1 -0
- package/dist/index.d.ts +22 -6
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/motion/subject-motion.d.ts +66 -0
- package/dist/motion/subject-motion.js +52 -0
- package/dist/motion/subject-motion.js.map +1 -0
- package/dist/optics/generic-lens-lateral-color.d.ts +83 -0
- package/dist/optics/generic-lens-lateral-color.js +77 -0
- package/dist/optics/generic-lens-lateral-color.js.map +1 -0
- package/dist/optics/generic-lens-psf.js +54 -46
- package/dist/optics/generic-lens-psf.js.map +1 -1
- package/dist/optics/lens-psf-profile.d.ts +7 -0
- package/dist/optics/lens-psf-profile.js +2 -1
- package/dist/optics/lens-psf-profile.js.map +1 -1
- package/dist/output/camera-channel-response.d.ts +50 -0
- package/dist/output/camera-channel-response.js +69 -0
- package/dist/output/camera-channel-response.js.map +1 -0
- package/dist/output/developed-lens-corrections.d.ts +19 -5
- package/dist/output/developed-lens-corrections.js +28 -9
- package/dist/output/developed-lens-corrections.js.map +1 -1
- package/dist/output/generic-lens-corrections.d.ts +41 -5
- package/dist/output/generic-lens-corrections.js +52 -8
- package/dist/output/generic-lens-corrections.js.map +1 -1
- package/dist/output/native-capture-sdr.js +5 -2
- package/dist/output/native-capture-sdr.js.map +1 -1
- package/dist/output/print-plan.d.ts +41 -5
- package/dist/output/print-plan.js +59 -14
- package/dist/output/print-plan.js.map +1 -1
- package/dist/output/sdr-rendering.d.ts +18 -1
- package/dist/output/sdr-rendering.js +39 -2
- package/dist/output/sdr-rendering.js.map +1 -1
- package/dist/sensor/binomial-sample.d.ts +3 -0
- package/dist/sensor/binomial-sample.js +86 -0
- package/dist/sensor/binomial-sample.js.map +1 -0
- package/dist/sensor/native-sensor-report.d.ts +10 -0
- package/dist/sensor/native-sensor-report.js +16 -0
- package/dist/sensor/native-sensor-report.js.map +1 -0
- package/dist/sensor/sensor-characteristics.d.ts +91 -13
- package/dist/sensor/sensor-characteristics.js +30 -15
- package/dist/sensor/sensor-characteristics.js.map +1 -1
- package/docs/AGENT_GUIDE.md +1 -0
- package/docs/API_REFERENCE.md +214 -4
- package/docs/QUICK_START.md +162 -8
- package/docs/USAGE.md +195 -22
- package/docs/api/capture-c2pa-embed.md +177 -0
- package/docs/api/capture-dng-import.md +86 -10
- package/docs/api/capture-dng-opcodes.md +93 -0
- package/docs/api/capture-dng-profile-maps.md +141 -0
- package/docs/api/capture-dng-stage-image.md +43 -0
- package/docs/api/capture-jpeg-xl-tiles.md +33 -0
- package/docs/api/capture-lossy-jpeg.md +41 -0
- package/docs/api/capture-native-raw-development.md +2 -1
- package/docs/api/core-execution-error.md +43 -0
- package/docs/api/core-version.md +1 -1
- package/docs/api/equipment-generic-lens-catalogue.md +10 -5
- package/docs/api/equipment-sensor-profile-body.md +64 -0
- package/docs/api/equipment-sensor-profiles.md +86 -0
- package/docs/api/exports.json +460 -5
- package/docs/api/facade-display-view-gpu.md +5 -2
- package/docs/api/facade-display-view.md +11 -15
- package/docs/api/facade-exposure-build-up.md +105 -0
- package/docs/api/facade-fast-methods.md +47 -10
- package/docs/api/facade-image-plane-enable.md +16 -0
- package/docs/api/facade-mixed-illumination.md +67 -0
- package/docs/api/facade-quality-paths.md +24 -0
- package/docs/api/facade-representative-light-sources.md +131 -0
- package/docs/api/facade-scene-radiance.md +54 -3
- package/docs/api/facade-simulate-capture.md +48 -11
- package/docs/api/facade-simulate-display-view.md +10 -12
- package/docs/api/gpu-image-kernel-execution.md +0 -36
- package/docs/api/motion-subject-motion.md +23 -0
- package/docs/api/optics-generic-lens-lateral-color.md +79 -0
- package/docs/api/output-camera-channel-response.md +55 -0
- package/docs/api/output-developed-lens-corrections.md +10 -1
- package/docs/api/output-generic-lens-corrections.md +40 -4
- package/docs/api/output-print-plan.md +35 -1
- package/docs/api/output-sdr-rendering.md +6 -1
- package/docs/api/sensor-sensor-characteristics.md +54 -2
- package/llms.txt +3 -0
- package/package.json +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-raw.js","sourceRoot":"","sources":["../../src/capture/native-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAE,gCAAgC,EAAiF,MAAM,wBAAwB,CAAC;AACzJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAE,oCAAoC,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAA6C,MAAM,yBAAyB,CAAC;AACrI,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qDAAqD,EAAE,2CAA2C,EAAE,MAAM,6CAA6C,CAAC;AACjK,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,0BAA0B,EAC1F,gCAAgC,EACW,MAAM,0BAA0B,CAAC;AAE9E,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAgB,CAAC;AAC1D,8HAA8H;AAC9H,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,aAAa,EAA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KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,gCAAgC,CAAC,CAAC,CAAA,MAAM,MAAM,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,SAAS,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,MAAM,CAAC,CAAA,CAAC;KACzN,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture with the existing per-site (scalar) RAW model: an up-front plan and limit check from\n * metadata only, then bounded tile-by-tile execution.\n */\nimport { normalizeCaptureExposureMetadata, type SimulatedCaptureInput, type SimulatedCapture, type CaptureExposureSource } from \"./simulated-capture.js\";\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { FULL_RESOLUTION_CEILING_PIXELS, resolveRaisedLimit, scaleBudgetCeiling } from \"../core/pixel-limits.js\";\nimport { calculateSiteEffectiveSaturationCode, createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence, type HostYieldGate } from \"./host-yield-cadence.js\";\nimport { parseCaptureModeProfile } from \"../sensor/capture-mode.js\";\nimport { parseSensorColorSamplingProfile } from \"../sensor/color-sampling.js\";\nimport { parseNativeEffectiveRasterColorSamplingBindingProfile, resolveCaptureModeColorSamplingContributors } from \"../sensor/capture-color-sampling-binding.js\";\nimport { calculateCaptureExposureWindows } from \"../sensor/exposure-window.js\";\nimport { SENSOR_RAW_PRODUCER_NOISE_MODEL, calculateNativeRawSite, parseNativeRawProducerSite,\n validateNativeRawReadoutIdentity, type NativeRawProducerFrameContext, type SensorRawProducerSiteInput,\n type SensorRawProducerExposureWindowInput } from \"./sensor-raw-producer.js\";\n\nexport const NATIVE_RAW_SCHEMA_VERSION = \"0.1.0\" as const;\n/** `maximumPixels` is the default pixel limit; a request may raise it with its own `maximumPixels`, up to `ceilingPixels`. */\nexport const NATIVE_RAW_LIMITS = /* @__PURE__ */ Object.freeze({ maximumPixels: 24_000_000, ceilingPixels: FULL_RESOLUTION_CEILING_PIXELS, maximumDimension: 16_384,\n tileWidth: 256, tileHeight: 1, outputBytesPerPixel: 7 });\n/** Default whole-event radiance query budget ceiling of the native environment tasks; it scales with a raised `maximumPixels`. */\nconst DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS = 2_000_000_000;\n/** A shooting event and where its source came from. Not a finished float master or committed RAW frame. */\nexport type NativeRawExposureInput = Omit<SimulatedCaptureInput, \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport type NativeRawExposure = Omit<SimulatedCapture, \"schemaVersion\" | \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport interface NativeRawInput {\n exposure: NativeRawExposureInput;\n frameId: string;\n modeId: string;\n captureModeProfile: NativeRawProducerFrameContext[\"captureModeProfile\"];\n colorSamplingProfile: NativeRawProducerFrameContext[\"colorSamplingProfile\"];\n bindingProfile: NativeRawProducerFrameContext[\"bindingProfile\"];\n exposureWindow?: SensorRawProducerExposureWindowInput;\n maximumOutputBytes: number;\n /** Optional tile width for execution, in native sites, 1–256. Default 256. It does not affect sampling. */\n tileWidth?: number;\n /**\n * Optional opt-in pixel limit for large sensors: an integer from 1 to `NATIVE_RAW_LIMITS.ceilingPixels`.\n * Default `NATIVE_RAW_LIMITS.maximumPixels` (24 000 000). `maximumOutputBytes` still applies. A raised limit\n * also raises the native environment tasks' whole-event query budget ceiling in proportion\n * (2 000 000 000 per 24 000 000 pixels). It does not affect sampling.\n */\n maximumPixels?: number;\n}\nexport interface NativeRawPlan {\n schemaVersion: typeof NATIVE_RAW_SCHEMA_VERSION;\n exposure: NativeRawExposure;\n frame: NativeRawProducerFrameContext;\n exposureWindow?: SensorRawProducerExposureWindowInput;\n pixelCount: number;\n outputBytes: number;\n tileCount: number;\n /** Present only when an execution tile width was given. Otherwise the plan keeps its earlier shape. */\n tileWidth?: number;\n /** Present only when a pixel limit was given. Otherwise the plan keeps its earlier shape. */\n maximumPixels?: number;\n upstreamRadiometryVerified: false;\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\";\n}\n/** Tile rectangle, in absolute full-sensor CFA coordinates, before orientation, active-area crop or output scaling. */\nexport interface NativeRawTileRequest { captureId: string; frameId: string; x: number; y: number; width: number; height: number }\nexport interface NativeRawTile extends NativeRawTileRequest { sites: readonly SensorRawProducerSiteInput[] }\nexport interface NativeRawProvider {\n readTile(request: Readonly<NativeRawTileRequest>, signal: AbortSignal): Promise<NativeRawTile>;\n yieldControl(signal: AbortSignal): Promise<void>;\n}\n/** Row-major arrays owned only by the output. They cannot be attached to the bounded SensorRawFrame type. */\nexport interface NativeRawOutput {\n plan: NativeRawPlan;\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n /** Saturation flags. Bit 0: physical charge clamp; bit 1: pre-ADC clamp; bit 2: digital saturation. */\n saturationFlags: Uint8Array;\n /**\n * Effective white (full-saturation) code for each absolute CFA repeat phase, indexed\n * `phaseY*repeatWidthSites+phaseX`: min(digital saturation, round(black + min(capacity, pre-ADC\n * saturation)/gain)). See `calculateEffectiveSaturationCode`. A few bytes, not one value per pixel.\n */\n effectiveSaturationCodes: Uint16Array;\n}\n/** Internal: lean per-site outputs of an engine-built site (see native-environment-lean.ts). */\nexport interface NativeRawLeanOutput { rawCode: number; blackLevelCode: number; digitalSaturationCode: number; flags: number; whiteCode: number }\n/**\n * Internal hook for tiles the engine builds itself (native environment RAW).\n *\n * claim() recognizes only entries the hook itself created, for sites whose parsing and identity checks are\n * provably redundant. compute() returns the outputs calculateNativeRawSite would produce, falling back to it\n * internally. observe() sees every fully computed site.\n */\nexport interface NativeRawLeanSensorHook {\n claim(site: unknown): object | undefined;\n compute(handle: object, index: number, seed: number, timing: ReturnType<typeof calculateCaptureExposureWindows>[\"value\"][\"samples\"][number] | undefined): NativeRawLeanOutput;\n observe(index: number, parsed: SensorRawProducerSiteInput, result: ReturnType<typeof calculateNativeRawSite>, whiteCode: number, seed: number): void;\n}\nexport type NativeRawTaskState = \"ready\" | \"running\" | \"completed\" | \"cancelled\" | \"failed\" | \"disposed\" | \"transferred\";\nexport interface NativeRawTask {\n readonly plan: NativeRawPlan;\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawOutput;\n}\nfunction windows(exposure: NativeRawExposure, schedule: SensorRawProducerExposureWindowInput,\n points: readonly {x:number;y:number}[]): ReturnType<typeof calculateCaptureExposureWindows>[\"value\"] {\n const r=requireAllowlistedRecord(schedule,[\"shutterMechanism\",\"nominalExposureDurationSeconds\",\"opening\",\"closing\"],\"Invalid RAW exposure schedule.\");\n requireAllowlistedRecord(r.nominalExposureDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW nominal exposure.\");\n for(const boundary of [r.opening,r.closing]){\n const b=requireAllowlistedRecord(boundary,[\"kind\",\"directionNative\",\"traversalDurationSeconds\"],\"Invalid RAW exposure boundary.\");\n if(b.directionNative!==undefined)requireAllowlistedRecord(b.directionNative,[\"value\",\"evidence\"],\"Invalid RAW scan direction.\");\n if(b.traversalDurationSeconds!==undefined)requireAllowlistedRecord(b.traversalDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW scan duration.\");\n }\n const result=calculateCaptureExposureWindows({...schedule,nativeRaster:exposure.geometry.nativeRaster,samplePointsNative:points});\n if(result.value.nominalExposureDurationSeconds.value!==exposure.exposure.shutterSeconds)throw new InvalidConfigurationError(\"RAW schedule differs from exposure duration.\");\n return result.value;\n}\n/** Plans the task and checks the image size, resources and profiles before any callback or output allocation. No placeholder plane is made. */\nexport function calculateNativeRawPlan(input: NativeRawInput): NativeRawPlan {\n const r=requireAllowlistedRecord(input,[\"exposure\",\"frameId\",\"modeId\",\"captureModeProfile\",\"colorSamplingProfile\",\"bindingProfile\",\"exposureWindow\",\"maximumOutputBytes\",\"tileWidth\",\"maximumPixels\"],\"Invalid native RAW input.\");\n if(r.tileWidth!==undefined&&(typeof r.tileWidth!==\"number\"||!Number.isSafeInteger(r.tileWidth)||r.tileWidth<1||r.tileWidth>NATIVE_RAW_LIMITS.tileWidth))\n throw new InvalidConfigurationError(\"Native RAW tile width must be an integer from 1 to 256.\");\n const tileWidth=(r.tileWidth as number|undefined)??NATIVE_RAW_LIMITS.tileWidth;\n const maximumPixels=resolveRaisedLimit(r.maximumPixels,NATIVE_RAW_LIMITS.maximumPixels,NATIVE_RAW_LIMITS.ceilingPixels,\n \"Native RAW maximumPixels must be an integer from 1 to \"+NATIVE_RAW_LIMITS.ceilingPixels+\".\");\n const exposure=normalizeCaptureExposureMetadata(r.exposure,ENGINE_API_VERSION,true),native=exposure.geometry.nativeRaster;\n const pixelCount=native.pixelWidth*native.pixelHeight,outputBytes=pixelCount*NATIVE_RAW_LIMITS.outputBytesPerPixel;\n if(pixelCount>maximumPixels||native.pixelWidth>NATIVE_RAW_LIMITS.maximumDimension||native.pixelHeight>NATIVE_RAW_LIMITS.maximumDimension||\n !Number.isSafeInteger(r.maximumOutputBytes)||typeof r.maximumOutputBytes!==\"number\"||r.maximumOutputBytes<outputBytes)throw new InvalidConfigurationError(\"Native RAW raster exceeds output admission budget.\");\n const frame={frameId:requirePublicOpaqueId(r.frameId,\"Invalid RAW frame ID.\"),capture:exposure,\n modeId:requirePublicOpaqueId(r.modeId,\"Invalid RAW mode ID.\"),containerBitDepth:16 as const,\n captureModeProfile:parseCaptureModeProfile(r.captureModeProfile),colorSamplingProfile:parseSensorColorSamplingProfile(r.colorSamplingProfile),\n bindingProfile:parseNativeEffectiveRasterColorSamplingBindingProfile(r.bindingProfile)};\n const mode=frame.captureModeProfile.modes.find(m=>m.modeId===frame.modeId);\n if(exposure.noise.model.id!==SENSOR_RAW_PRODUCER_NOISE_MODEL.id||exposure.noise.model.version!==SENSOR_RAW_PRODUCER_NOISE_MODEL.version||\n frame.colorSamplingProfile.layout.kind!==\"periodic-mosaic\"||mode?.acquisition.kind!==\"single-frame\"||mode.perFrameSampling.kind!==\"native-effective-raster\"||(mode.reconstructionStages?.length??0)!==0)\n throw new InvalidConfigurationError(\"Native RAW requires exact noise identity and single-frame native periodic CFA.\");\n // The binding is one affine mapping for the whole frame, so checking both corners covers it. Do this before any provider work.\n for(const p of [{x:0,y:0},{x:native.pixelWidth-1,y:native.pixelHeight-1}]){\n const c=resolveCaptureModeColorSamplingContributors({nativeRaster:native,captureModeProfile:frame.captureModeProfile,modeId:frame.modeId,colorSamplingProfile:frame.colorSamplingProfile,bindingProfile:frame.bindingProfile,modeSampleIndexFullFrame:p});\n if(c.totalContributorSites!==1||c.channelComposition.kind!==\"single-channel\")throw new InvalidConfigurationError(\"Native RAW must preserve one native CFA site per sample.\");\n }\n const schedule=r.exposureWindow===undefined?undefined:structuredClone(r.exposureWindow) as SensorRawProducerExposureWindowInput;\n // For the supported linear scans, the extreme values occur at the image corners. Check them before capture.\n if(schedule)windows(exposure,schedule,[{x:.5,y:.5},{x:native.pixelWidth-.5,y:.5},{x:.5,y:native.pixelHeight-.5},{x:native.pixelWidth-.5,y:native.pixelHeight-.5}]);\n return freezeOwnedData({schemaVersion:NATIVE_RAW_SCHEMA_VERSION,exposure,frame,pixelCount,outputBytes,\n tileCount:Math.ceil(native.pixelWidth/tileWidth)*native.pixelHeight,\n ...(r.tileWidth===undefined?{}:{tileWidth}),\n ...(r.maximumPixels===undefined?{}:{maximumPixels}),\n ...(schedule?{exposureWindow:schedule}:{}),upstreamRadiometryVerified:false as const,\n seedSchedule:\"murmur3-capture-seed-native-index-stream-v2\" as const});\n}\n/**\n * Internal: the largest whole-event radiance query budget a native environment task admits for this plan:\n * 2 000 000 000, scaled in proportion when the plan raised its pixel limit above 24 000 000. Not exported from the package.\n */\nexport function nativeRawMaximumProviderEvaluations(plan: Pick<NativeRawPlan,\"maximumPixels\">): number {\n return plan.maximumPixels===undefined?DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS:scaleBudgetCeiling(DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS,plan.maximumPixels);\n}\n/**\n * Runs validated per-site events (EQE photo signal, dark signal, charge completeness) through the shared\n * reference per-site physics.\n *\n * Tiles are read and committed one at a time. The task yields to the host at tile boundaries once about\n * 8 ms of work has passed since the last yield, and after the final tile. It checks for cancellation\n * before every tile, after every read and after every yield.\n */\nexport function createNativeRawTask(input: NativeRawInput,provider: NativeRawProvider): NativeRawTask {\n return createNativeRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, seeds or output. Not exported from the package. */\nexport function createNativeRawTaskWithCadence(input: NativeRawInput,provider: NativeRawProvider,cadence: HostYieldCadence,\n /** Internal: a yield timer shared with a provider that also yields inside readTile, so both use one time budget. */\n sharedGate?: HostYieldGate,\n /** Internal: faster (\"lean\") per-site sensor execution for engine-built tiles. It never changes output or errors. */\n leanSensor?: NativeRawLeanSensorHook,\n /**\n * Internal: run only native rows [y, y + height) (a partition). The output arrays then hold just those rows, and\n * effectiveSaturationCodes holds 0 for CFA phases the rows do not contain; the merge step completes them.\n * Seeds, tiles and per-site values are those of the whole-frame task.\n */\n rows?: { readonly y: number; readonly height: number; readonly firstSite?: (site: SensorRawProducerSiteInput) => void;\n /** Internal (2.3 region rendering): also restrict to native columns [x, x + width). The output arrays are then that rectangle, row-major. */\n readonly x?: number; readonly width?: number }): NativeRawTask {\n const plan=calculateNativeRawPlan(input);\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.yieldControl!==\"function\")throw new InvalidConfigurationError(\"Native RAW requires reader and host event-loop yield.\");\n const read=provider.readTile.bind(provider),yieldControl=provider.yieldControl.bind(provider),abort=new AbortController();\n const native=plan.exposure.geometry.nativeRaster,tileWidth=plan.tileWidth??NATIVE_RAW_LIMITS.tileWidth;\n const rowStart=rows?.y??0,rowEnd=rowStart+(rows?.height??native.pixelHeight),colStart=rows?.x??0,colEnd=colStart+(rows?.width??native.pixelWidth);\n if(colStart<0||colEnd>native.pixelWidth||colEnd<=colStart)throw new InvalidConfigurationError(\"Native RAW column band must lie inside the native raster.\");\n const bandWidth=colEnd-colStart,length=(rowEnd-rowStart)*bandWidth;\n let state:NativeRawTaskState=\"ready\",count=0,output:NativeRawOutput|null=null,first:SensorRawProducerSiteInput|undefined;\n function release(): void {if(output){output.codes.fill(0);output.blackLevels.fill(0);output.digitalSaturationCodes.fill(0);output.saturationFlags.fill(0);output.effectiveSaturationCodes.fill(0);}output=null;first=undefined;}\n function active(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW execution aborted.\");}\n return {plan,get state(): NativeRawTaskState {return state;},get completedTileCount(): number {return count;},\n async run(): Promise<void> {\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Native RAW task is single-use.\");state=\"running\";\n try{\n const gate=sharedGate??createHostYieldGate(cadence);sharedGate?.restart();\n const layout=plan.frame.colorSamplingProfile.layout;if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const white=createPhaseWhiteLevelAccumulator(native.pixelWidth,layout.repeatWidthSites,layout.repeatHeightSites);\n output={plan,codes:new Uint16Array(length),blackLevels:new Uint16Array(length),digitalSaturationCodes:new Uint16Array(length),saturationFlags:new Uint8Array(length),effectiveSaturationCodes:new Uint16Array(layout.repeatWidthSites*layout.repeatHeightSites)};\n for(let y=rowStart;y<rowEnd;y++)for(let x=colStart;x<colEnd;x+=tileWidth){\n active();const request=Object.freeze({captureId:plan.exposure.captureId,frameId:plan.frame.frameId,x,y,width:Math.min(tileWidth,colEnd-x),height:1});\n {\n const supplied=await read(request,abort.signal);active();\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid native RAW tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Native RAW tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Native RAW tile needs exact dense coverage.\");\n const timing=plan.exposureWindow?windows(plan.exposure,plan.exposureWindow,Array.from({length:request.width},(_,i)=>({x:x+i+.5,y:y+.5}))):undefined;\n // Lean entries (built by the engine, provably valid against an earlier verified template) skip parsing and\n // identity checks. They are only claimed once the frame's first site is fixed.\n const lean=leanSensor&&first!==undefined?(tile.sites as unknown[]).map(site=>leanSensor.claim(site)):undefined;\n const sites=tile.sites.map((site,j)=>lean?.[j]?undefined:parseNativeRawProducerSite(site,y*native.pixelWidth+x+j,plan.frame,timing?.samples[j]));\n if(first===undefined){first=sites[0];if(first)rows?.firstSite?.(first);}for(const s of sites)if(s)validateNativeRawReadoutIdentity(s,first!);\n // Every site in this tile is validated before any output is written. A failure never returns partial output.\n const seed=plan.exposure.noise.seedUint32;\n for(let j=0;j<sites.length;j++){\n // index: absolute native index (seeds, CFA phase); at: position in this task's output arrays.\n const index=y*native.pixelWidth+x+j,at=(y-rowStart)*bandWidth+x+j-colStart,handle=lean?.[j];\n if(handle){\n const o=leanSensor!.compute(handle,index,seed,timing?.samples[j]);\n output.codes[at]=o.rawCode;output.blackLevels[at]=o.blackLevelCode;output.digitalSaturationCodes[at]=o.digitalSaturationCode;\n output.saturationFlags[at]=o.flags;white.record(index,o.whiteCode);continue;\n }\n const result=calculateNativeRawSite(sites[j]!,seed,index),r=result.readout.value;\n output.codes[at]=r.rawCode;output.blackLevels[at]=r.blackLevelCode;output.digitalSaturationCodes[at]=r.digitalSaturationCode;\n output.saturationFlags[at]=Number(r.physicalScalarSaturationApplied)|Number(r.preAdcSaturationApplied)<<1|Number(r.digitalSaturationApplied)<<2;\n const whiteCode=calculateSiteEffectiveSaturationCode(r,sites[j]!.readoutProfile,sites[j]!.regimeId);\n white.record(index,whiteCode);\n leanSensor?.observe(index,sites[j]!,result,whiteCode,seed);\n }\n count++;\n }\n // Yield when the time budget is spent, and always after the final tile. Yield timing never changes output.\n if(gate.due()||(y===rowEnd-1&&x+tileWidth>=colEnd)){await yieldControl(abort.signal);active();gate.restart();}\n }\n output.effectiveSaturationCodes.set(rows?white.partial():white.finish());first=undefined;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(): NativeRawOutput {if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");const result=output;output=null;first=undefined;state=\"transferred\";return result;}\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"native-raw.js","sourceRoot":"","sources":["../../src/capture/native-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAE,wBAAwB,EAA6B,MAAM,8BAA8B,CAAC;AACnG,OAAO,EAAE,gCAAgC,EAAiF,MAAM,wBAAwB,CAAC;AACzJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,8BAA8B,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAE,oCAAoC,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,mB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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,KAAU,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;QACxH,OAAO,KAAU,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;QACtF,UAAU,KAAqB,IAAG,KAAK,KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,gCAAgC,CAAC,CAAC,CAAA,MAAM,MAAM,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,SAAS,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,MAAM,CAAC,CAAA,CAAC;KACzN,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture with the existing per-site (scalar) RAW model: an up-front plan and limit check from\n * metadata only, then bounded tile-by-tile execution.\n */\nimport { EXPOSURE_BUILD_UP_STAGES, type ExposureBuildUpStage } from \"./exposure-build-up-stage.js\";\nimport { normalizeCaptureExposureMetadata, type SimulatedCaptureInput, type SimulatedCapture, type CaptureExposureSource } from \"./simulated-capture.js\";\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { FULL_RESOLUTION_CEILING_PIXELS, resolveRaisedLimit, scaleBudgetCeiling } from \"../core/pixel-limits.js\";\nimport { calculateSiteEffectiveSaturationCode, createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence, type HostYieldGate } from \"./host-yield-cadence.js\";\nimport { parseCaptureModeProfile } from \"../sensor/capture-mode.js\";\nimport { parseSensorColorSamplingProfile } from \"../sensor/color-sampling.js\";\nimport { parseNativeEffectiveRasterColorSamplingBindingProfile, resolveCaptureModeColorSamplingContributors } from \"../sensor/capture-color-sampling-binding.js\";\nimport { calculateCaptureExposureWindows } from \"../sensor/exposure-window.js\";\nimport { SENSOR_RAW_PRODUCER_NOISE_MODEL, calculateNativeRawSite, parseNativeRawProducerSite,\n validateNativeRawReadoutIdentity, type NativeRawProducerFrameContext, type SensorRawProducerSiteInput,\n type SensorRawProducerExposureWindowInput } from \"./sensor-raw-producer.js\";\n\nexport const NATIVE_RAW_SCHEMA_VERSION = \"0.1.0\" as const;\n/** `maximumPixels` is the default pixel limit; a request may raise it with its own `maximumPixels`, up to `ceilingPixels`. */\nexport const NATIVE_RAW_LIMITS = /* @__PURE__ */ Object.freeze({ maximumPixels: 24_000_000, ceilingPixels: FULL_RESOLUTION_CEILING_PIXELS, maximumDimension: 16_384,\n tileWidth: 256, tileHeight: 1, outputBytesPerPixel: 7 });\n/** Default whole-event radiance query budget ceiling of the native environment tasks; it scales with a raised `maximumPixels`. */\nconst DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS = 2_000_000_000;\n/** A shooting event and where its source came from. Not a finished float master or committed RAW frame. */\nexport type NativeRawExposureInput = Omit<SimulatedCaptureInput, \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport type NativeRawExposure = Omit<SimulatedCapture, \"schemaVersion\" | \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport interface NativeRawInput {\n exposure: NativeRawExposureInput;\n frameId: string;\n modeId: string;\n captureModeProfile: NativeRawProducerFrameContext[\"captureModeProfile\"];\n colorSamplingProfile: NativeRawProducerFrameContext[\"colorSamplingProfile\"];\n bindingProfile: NativeRawProducerFrameContext[\"bindingProfile\"];\n exposureWindow?: SensorRawProducerExposureWindowInput;\n maximumOutputBytes: number;\n /** Optional tile width for execution, in native sites, 1–256. Default 256. It does not affect sampling. */\n tileWidth?: number;\n /**\n * Optional opt-in pixel limit for large sensors: an integer from 1 to `NATIVE_RAW_LIMITS.ceilingPixels`.\n * Default `NATIVE_RAW_LIMITS.maximumPixels` (24 000 000). `maximumOutputBytes` still applies. A raised limit\n * also raises the native environment tasks' whole-event query budget ceiling in proportion\n * (2 000 000 000 per 24 000 000 pixels). It does not affect sampling.\n */\n maximumPixels?: number;\n}\nexport interface NativeRawPlan {\n schemaVersion: typeof NATIVE_RAW_SCHEMA_VERSION;\n exposure: NativeRawExposure;\n frame: NativeRawProducerFrameContext;\n exposureWindow?: SensorRawProducerExposureWindowInput;\n pixelCount: number;\n outputBytes: number;\n tileCount: number;\n /** Present only when an execution tile width was given. Otherwise the plan keeps its earlier shape. */\n tileWidth?: number;\n /** Present only when a pixel limit was given. Otherwise the plan keeps its earlier shape. */\n maximumPixels?: number;\n upstreamRadiometryVerified: false;\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\";\n}\n/** Tile rectangle, in absolute full-sensor CFA coordinates, before orientation, active-area crop or output scaling. */\nexport interface NativeRawTileRequest { captureId: string; frameId: string; x: number; y: number; width: number; height: number }\nexport interface NativeRawTile extends NativeRawTileRequest { sites: readonly SensorRawProducerSiteInput[] }\nexport interface NativeRawProvider {\n readTile(request: Readonly<NativeRawTileRequest>, signal: AbortSignal): Promise<NativeRawTile>;\n yieldControl(signal: AbortSignal): Promise<void>;\n}\n/** Row-major arrays owned only by the output. They cannot be attached to the bounded SensorRawFrame type. */\nexport interface NativeRawOutput {\n plan: NativeRawPlan;\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n /** Saturation flags. Bit 0: physical charge clamp; bit 1: pre-ADC clamp; bit 2: digital saturation. */\n saturationFlags: Uint8Array;\n /**\n * Effective white (full-saturation) code for each absolute CFA repeat phase, indexed\n * `phaseY*repeatWidthSites+phaseX`: min(digital saturation, round(black + min(capacity, pre-ADC\n * saturation)/gain)). See `calculateEffectiveSaturationCode`. A few bytes, not one value per pixel.\n */\n effectiveSaturationCodes: Uint16Array;\n}\n/** Internal: lean per-site outputs of an engine-built site (see native-environment-lean.ts). */\nexport interface NativeRawLeanOutput { rawCode: number; blackLevelCode: number; digitalSaturationCode: number; flags: number; whiteCode: number }\n/**\n * Internal hook for tiles the engine builds itself (native environment RAW).\n *\n * claim() recognizes only entries the hook itself created, for sites whose parsing and identity checks are\n * provably redundant. compute() returns the outputs calculateNativeRawSite would produce, falling back to it\n * internally. observe() sees every fully computed site.\n */\nexport interface NativeRawLeanSensorHook {\n claim(site: unknown): object | undefined;\n compute(handle: object, index: number, seed: number, timing: ReturnType<typeof calculateCaptureExposureWindows>[\"value\"][\"samples\"][number] | undefined, b?: ExposureBuildUpStage): NativeRawLeanOutput;\n observe(index: number, parsed: SensorRawProducerSiteInput, result: ReturnType<typeof calculateNativeRawSite>, whiteCode: number, seed: number, b?: ExposureBuildUpStage): void;\n}\nexport type NativeRawTaskState = \"ready\" | \"running\" | \"completed\" | \"cancelled\" | \"failed\" | \"disposed\" | \"transferred\";\nexport interface NativeRawTask {\n readonly plan: NativeRawPlan;\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawOutput;\n}\nfunction windows(exposure: NativeRawExposure, schedule: SensorRawProducerExposureWindowInput,\n points: readonly {x:number;y:number}[]): ReturnType<typeof calculateCaptureExposureWindows>[\"value\"] {\n const r=requireAllowlistedRecord(schedule,[\"shutterMechanism\",\"nominalExposureDurationSeconds\",\"opening\",\"closing\"],\"Invalid RAW exposure schedule.\");\n requireAllowlistedRecord(r.nominalExposureDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW nominal exposure.\");\n for(const boundary of [r.opening,r.closing]){\n const b=requireAllowlistedRecord(boundary,[\"kind\",\"directionNative\",\"traversalDurationSeconds\"],\"Invalid RAW exposure boundary.\");\n if(b.directionNative!==undefined)requireAllowlistedRecord(b.directionNative,[\"value\",\"evidence\"],\"Invalid RAW scan direction.\");\n if(b.traversalDurationSeconds!==undefined)requireAllowlistedRecord(b.traversalDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW scan duration.\");\n }\n const result=calculateCaptureExposureWindows({...schedule,nativeRaster:exposure.geometry.nativeRaster,samplePointsNative:points});\n if(result.value.nominalExposureDurationSeconds.value!==exposure.exposure.shutterSeconds)throw new InvalidConfigurationError(\"RAW schedule differs from exposure duration.\");\n return result.value;\n}\n/** Plans the task and checks the image size, resources and profiles before any callback or output allocation. No placeholder plane is made. */\nexport function calculateNativeRawPlan(input: NativeRawInput): NativeRawPlan {\n const r=requireAllowlistedRecord(input,[\"exposure\",\"frameId\",\"modeId\",\"captureModeProfile\",\"colorSamplingProfile\",\"bindingProfile\",\"exposureWindow\",\"maximumOutputBytes\",\"tileWidth\",\"maximumPixels\"],\"Invalid native RAW input.\");\n if(r.tileWidth!==undefined&&(typeof r.tileWidth!==\"number\"||!Number.isSafeInteger(r.tileWidth)||r.tileWidth<1||r.tileWidth>NATIVE_RAW_LIMITS.tileWidth))\n throw new InvalidConfigurationError(\"Native RAW tile width must be an integer from 1 to 256.\");\n const tileWidth=(r.tileWidth as number|undefined)??NATIVE_RAW_LIMITS.tileWidth;\n const maximumPixels=resolveRaisedLimit(r.maximumPixels,NATIVE_RAW_LIMITS.maximumPixels,NATIVE_RAW_LIMITS.ceilingPixels,\n \"Native RAW maximumPixels must be an integer from 1 to \"+NATIVE_RAW_LIMITS.ceilingPixels+\".\");\n const exposure=normalizeCaptureExposureMetadata(r.exposure,ENGINE_API_VERSION,true),native=exposure.geometry.nativeRaster;\n const pixelCount=native.pixelWidth*native.pixelHeight,outputBytes=pixelCount*NATIVE_RAW_LIMITS.outputBytesPerPixel;\n if(pixelCount>maximumPixels||native.pixelWidth>NATIVE_RAW_LIMITS.maximumDimension||native.pixelHeight>NATIVE_RAW_LIMITS.maximumDimension||\n !Number.isSafeInteger(r.maximumOutputBytes)||typeof r.maximumOutputBytes!==\"number\"||r.maximumOutputBytes<outputBytes)throw new InvalidConfigurationError(\"Native RAW raster exceeds output admission budget.\");\n const frame={frameId:requirePublicOpaqueId(r.frameId,\"Invalid RAW frame ID.\"),capture:exposure,\n modeId:requirePublicOpaqueId(r.modeId,\"Invalid RAW mode ID.\"),containerBitDepth:16 as const,\n captureModeProfile:parseCaptureModeProfile(r.captureModeProfile),colorSamplingProfile:parseSensorColorSamplingProfile(r.colorSamplingProfile),\n bindingProfile:parseNativeEffectiveRasterColorSamplingBindingProfile(r.bindingProfile)};\n const mode=frame.captureModeProfile.modes.find(m=>m.modeId===frame.modeId);\n if(exposure.noise.model.id!==SENSOR_RAW_PRODUCER_NOISE_MODEL.id||exposure.noise.model.version!==SENSOR_RAW_PRODUCER_NOISE_MODEL.version||\n frame.colorSamplingProfile.layout.kind!==\"periodic-mosaic\"||mode?.acquisition.kind!==\"single-frame\"||mode.perFrameSampling.kind!==\"native-effective-raster\"||(mode.reconstructionStages?.length??0)!==0)\n throw new InvalidConfigurationError(\"Native RAW requires exact noise identity and single-frame native periodic CFA.\");\n // The binding is one affine mapping for the whole frame, so checking both corners covers it. Do this before any provider work.\n for(const p of [{x:0,y:0},{x:native.pixelWidth-1,y:native.pixelHeight-1}]){\n const c=resolveCaptureModeColorSamplingContributors({nativeRaster:native,captureModeProfile:frame.captureModeProfile,modeId:frame.modeId,colorSamplingProfile:frame.colorSamplingProfile,bindingProfile:frame.bindingProfile,modeSampleIndexFullFrame:p});\n if(c.totalContributorSites!==1||c.channelComposition.kind!==\"single-channel\")throw new InvalidConfigurationError(\"Native RAW must preserve one native CFA site per sample.\");\n }\n const schedule=r.exposureWindow===undefined?undefined:structuredClone(r.exposureWindow) as SensorRawProducerExposureWindowInput;\n // For the supported linear scans, the extreme values occur at the image corners. Check them before capture.\n if(schedule)windows(exposure,schedule,[{x:.5,y:.5},{x:native.pixelWidth-.5,y:.5},{x:.5,y:native.pixelHeight-.5},{x:native.pixelWidth-.5,y:native.pixelHeight-.5}]);\n return freezeOwnedData({schemaVersion:NATIVE_RAW_SCHEMA_VERSION,exposure,frame,pixelCount,outputBytes,\n tileCount:Math.ceil(native.pixelWidth/tileWidth)*native.pixelHeight,\n ...(r.tileWidth===undefined?{}:{tileWidth}),\n ...(r.maximumPixels===undefined?{}:{maximumPixels}),\n ...(schedule?{exposureWindow:schedule}:{}),upstreamRadiometryVerified:false as const,\n seedSchedule:\"murmur3-capture-seed-native-index-stream-v2\" as const});\n}\n/**\n * Internal: the largest whole-event radiance query budget a native environment task admits for this plan:\n * 2 000 000 000, scaled in proportion when the plan raised its pixel limit above 24 000 000. Not exported from the package.\n */\nexport function nativeRawMaximumProviderEvaluations(plan: Pick<NativeRawPlan,\"maximumPixels\">): number {\n return plan.maximumPixels===undefined?DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS:scaleBudgetCeiling(DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS,plan.maximumPixels);\n}\n/**\n * Runs validated per-site events (EQE photo signal, dark signal, charge completeness) through the shared\n * reference per-site physics.\n *\n * Tiles are read and committed one at a time. The task yields to the host at tile boundaries once about\n * 8 ms of work has passed since the last yield, and after the final tile. It checks for cancellation\n * before every tile, after every read and after every yield.\n */\nexport function createNativeRawTask(input: NativeRawInput,provider: NativeRawProvider): NativeRawTask {\n return createNativeRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, seeds or output. Not exported from the package. */\nexport function createNativeRawTaskWithCadence(input: NativeRawInput,provider: NativeRawProvider,cadence: HostYieldCadence,\n /** Internal: a yield timer shared with a provider that also yields inside readTile, so both use one time budget. */\n sharedGate?: HostYieldGate,\n /** Internal: faster (\"lean\") per-site sensor execution for engine-built tiles. It never changes output or errors. */\n leanSensor?: NativeRawLeanSensorHook,\n /**\n * Internal: run only native rows [y, y + height) (a partition). The output arrays then hold just those rows, and\n * effectiveSaturationCodes holds 0 for CFA phases the rows do not contain; the merge step completes them.\n * Seeds, tiles and per-site values are those of the whole-frame task.\n */\n rows?: { readonly y: number; readonly height: number; readonly firstSite?: (site: SensorRawProducerSiteInput) => void;\n /** Internal (2.3 region rendering): also restrict to native columns [x, x + width). The output arrays are then that rectangle, row-major. */\n readonly x?: number; readonly width?: number }): NativeRawTask {\n const plan=calculateNativeRawPlan(input);\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.yieldControl!==\"function\")throw new InvalidConfigurationError(\"Native RAW requires reader and host event-loop yield.\");\n const read=provider.readTile.bind(provider),yieldControl=provider.yieldControl.bind(provider),abort=new AbortController();\n const native=plan.exposure.geometry.nativeRaster,tileWidth=plan.tileWidth??NATIVE_RAW_LIMITS.tileWidth;\n const rowStart=rows?.y??0,rowEnd=rowStart+(rows?.height??native.pixelHeight),colStart=rows?.x??0,colEnd=colStart+(rows?.width??native.pixelWidth);\n if(colStart<0||colEnd>native.pixelWidth||colEnd<=colStart)throw new InvalidConfigurationError(\"Native RAW column band must lie inside the native raster.\");\n const bandWidth=colEnd-colStart,length=(rowEnd-rowStart)*bandWidth;\n let state:NativeRawTaskState=\"ready\",count=0,output:NativeRawOutput|null=null,first:SensorRawProducerSiteInput|undefined;\n function release(): void {if(output){output.codes.fill(0);output.blackLevels.fill(0);output.digitalSaturationCodes.fill(0);output.saturationFlags.fill(0);output.effectiveSaturationCodes.fill(0);}output=null;first=undefined;}\n function active(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW execution aborted.\");}\n return {plan,get state(): NativeRawTaskState {return state;},get completedTileCount(): number {return count;},\n async run(): Promise<void> {\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Native RAW task is single-use.\");state=\"running\";\n try{\n const gate=sharedGate??createHostYieldGate(cadence);sharedGate?.restart();\n const layout=plan.frame.colorSamplingProfile.layout;if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const white=createPhaseWhiteLevelAccumulator(native.pixelWidth,layout.repeatWidthSites,layout.repeatHeightSites);\n output={plan,codes:new Uint16Array(length),blackLevels:new Uint16Array(length),digitalSaturationCodes:new Uint16Array(length),saturationFlags:new Uint8Array(length),effectiveSaturationCodes:new Uint16Array(layout.repeatWidthSites*layout.repeatHeightSites)};\n for(let y=rowStart;y<rowEnd;y++)for(let x=colStart;x<colEnd;x+=tileWidth){\n active();const request=Object.freeze({captureId:plan.exposure.captureId,frameId:plan.frame.frameId,x,y,width:Math.min(tileWidth,colEnd-x),height:1});\n {\n const supplied=await read(request,abort.signal);active();\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid native RAW tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Native RAW tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Native RAW tile needs exact dense coverage.\");\n const timing=plan.exposureWindow?windows(plan.exposure,plan.exposureWindow,Array.from({length:request.width},(_,i)=>({x:x+i+.5,y:y+.5}))):undefined;\n // Lean entries (built by the engine, provably valid against an earlier verified template) skip parsing and\n // identity checks. They are only claimed once the frame's first site is fixed.\n const lean=leanSensor&&first!==undefined?(tile.sites as unknown[]).map(site=>leanSensor.claim(site)):undefined;\n const sites=tile.sites.map((site,j)=>lean?.[j]?undefined:parseNativeRawProducerSite(site,y*native.pixelWidth+x+j,plan.frame,timing?.samples[j]));\n if(first===undefined){first=sites[0];if(first)rows?.firstSite?.(first);}for(const s of sites)if(s)validateNativeRawReadoutIdentity(s,first!);\n // Every site in this tile is validated before any output is written. A failure never returns partial output.\n const seed=plan.exposure.noise.seedUint32,b=EXPOSURE_BUILD_UP_STAGES.get(input);\n for(let j=0;j<sites.length;j++){\n // index: absolute native index (seeds, CFA phase); at: position in this task's output arrays.\n const index=y*native.pixelWidth+x+j,at=(y-rowStart)*bandWidth+x+j-colStart,handle=lean?.[j];\n if(handle){\n const o=leanSensor!.compute(handle,index,seed,timing?.samples[j],b);\n output.codes[at]=o.rawCode;output.blackLevels[at]=o.blackLevelCode;output.digitalSaturationCodes[at]=o.digitalSaturationCode;\n output.saturationFlags[at]=o.flags;white.record(index,o.whiteCode);continue;\n }\n const result=calculateNativeRawSite(sites[j]!,seed,index,b),r=result.readout.value;\n output.codes[at]=r.rawCode;output.blackLevels[at]=r.blackLevelCode;output.digitalSaturationCodes[at]=r.digitalSaturationCode;\n output.saturationFlags[at]=Number(r.physicalScalarSaturationApplied)|Number(r.preAdcSaturationApplied)<<1|Number(r.digitalSaturationApplied)<<2;\n const whiteCode=calculateSiteEffectiveSaturationCode(r,sites[j]!.readoutProfile,sites[j]!.regimeId);\n white.record(index,whiteCode);\n leanSensor?.observe(index,sites[j]!,result,whiteCode,seed,b);\n }\n count++;\n }\n // Yield when the time budget is spent, and always after the final tile. Yield timing never changes output.\n if(gate.due()||(y===rowEnd-1&&x+tileWidth>=colEnd)){await yieldControl(abort.signal);active();gate.restart();}\n }\n output.effectiveSaturationCodes.set(rows?white.partial():white.finish());first=undefined;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(): NativeRawOutput {if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");const result=output;output=null;first=undefined;state=\"transferred\";return result;}\n };\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { type SensorRawFrameInput, type SensorRawFrame } from "./sensor-raw-fram
|
|
|
3
3
|
import { composeSensorAccumulatedCharge, type ComposeSensorPhotoAccumulatedChargeInput as ComposeSensorAccumulatedChargeInput } from "../sensor/accumulated-charge.js";
|
|
4
4
|
import { assessSensorPhysicalChargeCapacity, type SensorPhysicalChargeCapacityProfile } from "../sensor/physical-charge-capacity.js";
|
|
5
5
|
import { simulateSensorChargeRealization, simulateSensorRawCode, type SensorChargeSamplingProfile, type SensorReadoutConversionProfile } from "../sensor/raw-readout.js";
|
|
6
|
+
import type { ExposureBuildUpStage } from "./exposure-build-up-stage.js";
|
|
6
7
|
import { type SensorFixedPatternNoiseProfile } from "../sensor/fixed-pattern-noise.js";
|
|
7
8
|
import { type CalculateCaptureExposureWindowsInput, type CaptureExposureWindows } from "../sensor/exposure-window.js";
|
|
8
9
|
export declare const SENSOR_RAW_PRODUCER_SCHEMA_VERSION: "0.3.0";
|
|
@@ -60,7 +61,9 @@ export type NativeRawProducerFrameContext = Omit<SensorRawProducerInput["frame"]
|
|
|
60
61
|
export declare function parseNativeRawProducerSite(site: unknown, i: number, frame: NativeRawProducerFrameContext, window?: CaptureExposureWindows["samples"][number]): SensorRawProducerSiteInput;
|
|
61
62
|
export declare function validateNativeRawReadoutIdentity(s: SensorRawProducerSiteInput, first: SensorRawProducerSiteInput): void;
|
|
62
63
|
/** The shared per-site pipeline holds all the charge, capacity, random-noise and ADC equations. `i` is the absolute native row-major index. */
|
|
63
|
-
export declare function calculateNativeRawSite(s: SensorRawProducerSiteInput, seed: number, i: number
|
|
64
|
+
export declare function calculateNativeRawSite(s: SensorRawProducerSiteInput, seed: number, i: number,
|
|
65
|
+
/** Internal (#534): a build-up fraction's stage, which splits the realized counts down to the fraction and reads with its own stream. */
|
|
66
|
+
b?: ExposureBuildUpStage): SensorRawProducerResult["sites"][number];
|
|
64
67
|
/** Validates the complete per-site exposure inputs. Charge, noise or RAW codes are never accepted as a shortcut. */
|
|
65
68
|
export declare function parseSensorRawProducerInput(value: unknown): SensorRawProducerInput;
|
|
66
69
|
/** Runs accumulated charge → capacity → Poisson noise → read noise and ADC → native sample → immutable frame. */
|
|
@@ -231,16 +231,25 @@ export function validateNativeRawReadoutIdentity(s, first) {
|
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
233
|
/** The shared per-site pipeline holds all the charge, capacity, random-noise and ADC equations. `i` is the absolute native row-major index. */
|
|
234
|
-
export function calculateNativeRawSite(s, seed, i
|
|
234
|
+
export function calculateNativeRawSite(s, seed, i,
|
|
235
|
+
/** Internal (#534): a build-up fraction's stage, which splits the realized counts down to the fraction and reads with its own stream. */
|
|
236
|
+
b) {
|
|
235
237
|
const accumulatedCharge = composeSensorAccumulatedCharge(s.charge);
|
|
236
238
|
const capacity = assessSensorPhysicalChargeCapacity({ accumulatedCharge: accumulatedCharge.value, capacityProfile: s.capacityProfile,
|
|
237
239
|
operatingStateId: s.operatingStateId, operatingTemperatureC: s.charge.darkCharge.operatingTemperatureC });
|
|
238
240
|
const pattern = s.fixedPatternNoise === undefined ? {} : { fixedPatternNoise: s.fixedPatternNoise };
|
|
239
|
-
|
|
241
|
+
let realization = simulateSensorChargeRealization({ accumulatedCharge: accumulatedCharge.value, samplingProfile: s.samplingProfile,
|
|
240
242
|
seedUint32: deriveNativeSiteStreamSeedUint32(seed, i, NATIVE_SITE_CHARGE_STREAM_ID), ...pattern });
|
|
243
|
+
if (b) {
|
|
244
|
+
const v = realization.value;
|
|
245
|
+
if (v.additionalComponents.length)
|
|
246
|
+
throw new InvalidConfigurationError("An exposure build-up takes photo and dark charge only.");
|
|
247
|
+
b.split(i, v.photoSampledMeanElectronCount, v.darkSampledMeanElectronCount, v.photoRealizedElectronCount, v.darkRealizedElectronCount);
|
|
248
|
+
realization = { ...realization, value: { ...v, photoRealizedElectronCount: b.photo, darkRealizedElectronCount: b.dark, totalRealizedStoredElectronEquivalentCount: b.photo + b.dark + 0 } };
|
|
249
|
+
}
|
|
241
250
|
const readout = simulateSensorRawCode({ chargeRealization: realization.value, physicalCapacityAssessment: capacity.value,
|
|
242
251
|
readoutProfile: s.readoutProfile, regimeId: s.regimeId,
|
|
243
|
-
readNoiseSeedUint32: deriveNativeSiteStreamSeedUint32(seed, i, NATIVE_SITE_READ_NOISE_STREAM_ID), ...pattern });
|
|
252
|
+
readNoiseSeedUint32: deriveNativeSiteStreamSeedUint32(seed, i, b ? b.read : NATIVE_SITE_READ_NOISE_STREAM_ID), ...pattern });
|
|
244
253
|
return { accumulatedCharge, capacity, realization, readout };
|
|
245
254
|
}
|
|
246
255
|
/** The selected regime's declared INL, which the effective white level needs at saturation. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensor-raw-producer.js","sourceRoot":"","sources":["../../src/capture/sensor-raw-producer.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;GAQG;AAEH,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE/F,OAAO,EAAE,iCAAiC,EAAE,oCAAoC,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AACvJ,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAiD,MAAM,uBAAuB,CAAC;AAC5G,OAAO,EAAE,8BAA8B,EAAE,+CAA+C,EAAE,0CAA0C,EAC5C,MAAM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CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;QACzB,YAAY,EAAE,2CAA2C,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB;YAC9H,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,oBAAoB,EAAE,CAAC,CAAC,KAAK,CAAC,oBAAoB,EAAE,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc;YAClH,wBAAwB,EAAE,EAAE,CAAC,EAAE,CAAC,GAAC,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAC,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACpG,OAAO,mBAAmB,CAAC,EAAE,aAAa,EAAE,kCAAkC,EAAE,YAAY,EAAE,kCAAkC;QAC9H,cAAc,EAAE,wCAAwC,EAAE,0BAA0B,EAAE,KAAK;QAC3F,YAAY,EAAE,6CAA6C,EAAE,KAAK,EAAE,oBAAoB,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK;QACxH,GAAG,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,oBAAoB,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,EAChH,kCAAkC,EAAE,kCAAkC,EAAE;QACtE,0IAA0I;QAC1I,kKAAkK;QAClK,oIAAoI;QACpI,qJAAqJ;QACrJ,kLAAkL;QAClL,sHAAsH;KAAC,CAAC,CAAC;AAC7H,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Produces a sensor RAW frame from per-site exposure inputs, using the existing sensor steps:\n * accumulated charge → capacity → Poisson (shot) noise → read noise and ADC → native sample →\n * immutable frame.\n *\n * Inputs must be complete. Charge, noise or RAW codes cannot be passed in as a shortcut.\n * @see docs/SIMULATED_CAPTURE.md for equations, coordinate/unit conventions, blockers and support\n * limits.\n */\n\nimport { requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\n\nimport { parseSensorEqeTemporalPhotoSignal, PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS, PHOTO_SIGNAL_TRUE_FIELDS } from \"../sensor/temporal-photo-signal.js\";\nimport { RAW_REFERENCE_MAX_NATIVE_SITES } from \"./raw-frame-limits.js\";\n\nimport { approximationResult, type CalculationResult } from \"../core/calculation-result.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { parseEvidenceList } from \"../core/evidence-provenance.js\";\nimport { parseSimulatedCapture } from \"./simulated-capture.js\";\nimport { createSensorRawFrame, type SensorRawFrameInput, type SensorRawFrame } from \"./sensor-raw-frame.js\";\nimport { composeSensorAccumulatedCharge, parseSensorAccumulatedChargeCompletenessProfile, parseSensorAdditionalStoredChargeComponent,\n type ComposeSensorPhotoAccumulatedChargeInput as ComposeSensorAccumulatedChargeInput } from \"../sensor/accumulated-charge.js\";\nimport { assessSensorPhysicalChargeCapacity, parseSensorPhysicalChargeCapacityProfile,\n type SensorPhysicalChargeCapacityProfile } from \"../sensor/physical-charge-capacity.js\";\nimport { simulateSensorChargeRealization, simulateSensorRawCode, parseSensorChargeSamplingProfile,\n parseSensorReadoutConversionProfile, resolveSensorReadoutRegime, type SensorChargeSamplingProfile, type SensorReadoutConversionProfile } from \"../sensor/raw-readout.js\";\nimport { createSensorRawCaptureSample } from \"../sensor/raw-reconstruction.js\";\nimport { parseSensorFixedPatternNoiseProfile, type SensorFixedPatternNoiseProfile } from \"../sensor/fixed-pattern-noise.js\";\nimport { deriveNativeSiteStreamSeedUint32, NATIVE_SITE_CHARGE_STREAM_ID, NATIVE_SITE_READ_NOISE_STREAM_ID } from \"../sensor/stochastic-seed.js\";\nimport { parseSensorColorSamplingProfile } from \"../sensor/color-sampling.js\";\nimport { parseCaptureModeProfile } from \"../sensor/capture-mode.js\";\nimport { parseNativeEffectiveRasterColorSamplingBindingProfile, resolveCaptureModeColorSamplingContributors } from \"../sensor/capture-color-sampling-binding.js\";\nimport { calculateCaptureExposureWindows, type CalculateCaptureExposureWindowsInput, type CaptureExposureWindows } from \"../sensor/exposure-window.js\";\n\nexport const SENSOR_RAW_PRODUCER_SCHEMA_VERSION = \"0.3.0\" as const;\n/**\n * Version of the capture noise model. It fixes the hashed per-site seed schedule and the signed electronic\n * readout behaviour.\n *\n * 0.4.0: exact ADC rounding with ties up, normal-approximation Poisson draws for means of 1e9 and above,\n * optional post-ADC digital gain and INL (integral non-linearity), and optional per-sensor fixed-pattern noise.\n */\nexport const SENSOR_RAW_PRODUCER_NOISE_MODEL = /* @__PURE__ */ Object.freeze({ id: \"photivra-native-raw-noise\", version: \"0.4.0\" } as const);\n/** For each native site: one declared exposure event (EQE photo signal, dark signal, charge completeness) and its readout state. */\nexport interface SensorRawProducerSiteInput {\n charge: ComposeSensorAccumulatedChargeInput;\n samplingProfile: SensorChargeSamplingProfile;\n capacityProfile: SensorPhysicalChargeCapacityProfile;\n operatingStateId: string;\n readoutProfile: SensorReadoutConversionProfile;\n regimeId: string;\n /** Optional fixed-pattern noise (FPN) for this sensor; one profile for the whole frame. Omit it to disable FPN. */\n fixedPatternNoise?: SensorFixedPatternNoiseProfile;\n}\n/** Exposure schedule for the full sensor. The producer owns the sampling coordinates. */\nexport type SensorRawProducerExposureWindowInput = Omit<CalculateCaptureExposureWindowsInput,\n \"nativeRaster\" | \"activeCaptureRect\" | \"samplePointsNative\">;\n/** Input for one bounded frame. It is never a conversion from separate RGB pixels. */\nexport interface SensorRawProducerInput {\n frame: Omit<SensorRawFrameInput, \"samples\">;\n sites: readonly SensorRawProducerSiteInput[];\n /** If omitted, every event uses the existing global window 0..shutterSeconds. */\n exposureWindow?: SensorRawProducerExposureWindowInput;\n}\n/** Codes produced by the engine, with per-step diagnostics. The upstream radiance and response are as declared, not verified. */\nexport interface SensorRawProducerResult {\n schemaVersion: typeof SENSOR_RAW_PRODUCER_SCHEMA_VERSION;\n codeProducer: \"engine-charge-capacity-noise-adc\";\n upstreamOrigin: \"declared-eqe-and-dark-exposure-results\";\n upstreamRadiometryVerified: false;\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\";\n frame: SensorRawFrame;\n localExposureWindows?: CalculationResult<CaptureExposureWindows>;\n sites: readonly {\n accumulatedCharge: ReturnType<typeof composeSensorAccumulatedCharge>;\n capacity: ReturnType<typeof assessSensorPhysicalChargeCapacity>;\n realization: ReturnType<typeof simulateSensorChargeRealization>;\n readout: ReturnType<typeof simulateSensorRawCode>;\n }[];\n}\nfunction fields(value: unknown, allowed: readonly string[]): Record<string, unknown> {\n return requireAllowlistedRecord(value, allowed, \"Invalid sensor RAW producer fields.\");\n}\nfunction publicId(value: unknown): string {\n return requirePublicOpaqueId(value, \"Expected public producer identity.\");\n}\nconst KEY_RECURSE = 0, KEY_IDENTITY = 1, KEY_IDENTITY_LIST = 2;\n/** Bounded cache of how the identity check classifies each property name (it depends only on the name). */\nconst IDENTITY_KEY_KINDS = new Map<string, number>();\n/** Bounded cache of strings already known to be valid public IDs (validity depends only on the string). */\nconst VALID_PUBLIC_IDS = new Set<string>();\nconst IDENTITY_WALK_MEMO_LIMIT = 4096;\nfunction identityKeyKind(key: string): number {\n // Array indices and other names ending in a digit match neither suffix.\n const last = key.charCodeAt(key.length - 1);\n if (last >= 48 && last <= 57) return KEY_RECURSE;\n let kind = IDENTITY_KEY_KINDS.get(key);\n if (kind === undefined) {\n kind = /(?:Id|Version)$/.test(key) ? KEY_IDENTITY : /Ids$/.test(key) ? KEY_IDENTITY_LIST : KEY_RECURSE;\n if (IDENTITY_KEY_KINDS.size < IDENTITY_WALK_MEMO_LIMIT) IDENTITY_KEY_KINDS.set(key, kind);\n }\n return kind;\n}\nfunction memoizedPublicId(value: unknown): void {\n if (typeof value === \"string\" && VALID_PUBLIC_IDS.has(value)) return;\n publicId(value);\n if (VALID_PUBLIC_IDS.size < IDENTITY_WALK_MEMO_LIMIT) VALID_PUBLIC_IDS.add(value as string);\n}\n/**\n * At any depth, every property whose name ends in Id or Version must hold a public ID, and every property\n * ending in Ids a bounded dense list of them. Order, keys and errors are the same as the earlier\n * Object.entries walk. Key classification and already-valid IDs are cached, because each depends only on\n * its string.\n */\nfunction publicIdentities(value: unknown): void {\n if (value === null || typeof value !== \"object\") return;\n const record = value as Record<string, unknown>, keys = Object.keys(record);\n for (let index = 0; index < keys.length; index++) {\n const key = keys[index]!, kind = identityKeyKind(key), child = record[key];\n if (kind === KEY_IDENTITY) memoizedPublicId(child);\n else if (kind === KEY_IDENTITY_LIST) dense(child, 256).forEach(memoizedPublicId);\n else if (child !== null && typeof child === \"object\") publicIdentities(child);\n }\n}\nfunction dense(value: unknown, maximum: number): unknown[] {\n if (!Array.isArray(value) || value.length > maximum || Array.from({ length: value.length }, (_, i) => i in value).includes(false)) {\n throw new InvalidConfigurationError(\"Expected bounded dense producer array.\");\n }\n return value;\n}\nfunction optionalEvidence(value: unknown): ReturnType<typeof parseEvidenceList> {\n return dense(value, 256).length === 0 ? [] : parseEvidenceList(value, \"optionalExposureEvidence\");\n}\nfunction exposureEvidence(value: unknown, temporalPhoto?: Record<string, unknown>): ComposeSensorAccumulatedChargeInput[\"photoSignal\"][\"componentEvidence\"] {\n if (temporalPhoto !== undefined) return parseSensorEqeTemporalPhotoSignal({ ...temporalPhoto, componentEvidence: value }).componentEvidence;\n const r = fields(value, [\"stationarity\", \"exposureBinding\"]);\n const b = fields(r.exposureBinding, [\"binding\", \"colorSamplingProfile\", \"nominalExposureDuration\", \"openingBoundary\", \"closingBoundary\"]);\n return { stationarity: parseEvidenceList(r.stationarity, \"stationarity\"), exposureBinding: {\n binding: parseEvidenceList(b.binding, \"binding\"), colorSamplingProfile: parseEvidenceList(b.colorSamplingProfile, \"colorSamplingProfile\"),\n nominalExposureDuration: parseEvidenceList(b.nominalExposureDuration, \"nominalExposureDuration\"),\n openingBoundary: optionalEvidence(b.openingBoundary), closingBoundary: optionalEvidence(b.closingBoundary) } };\n}\nconst common = [\"colorSamplingProfileId\", \"channelId\", \"site\", \"bindingId\", \"stationarityProfileId\", \"timeReference\",\n \"startOffsetSecondsFromOpeningReference\", \"endOffsetSecondsFromOpeningReference\", \"localExposureDurationSeconds\", \"componentEvidence\"];\nconst photoTrue: string[] = [\"timeStationarityEstablished\", ...PHOTO_SIGNAL_TRUE_FIELDS];\nconst photoFalse: string[] = [\"timeVaryingSignalIntegrated\", ...PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS];\nfunction chargeInput(value: unknown): ComposeSensorAccumulatedChargeInput {\n const r = fields(value, [\"photoSignal\", \"darkCharge\", \"additionalChargeComponents\", \"completenessProfile\"]);\n const temporal = r.photoSignal !== null && typeof r.photoSignal === \"object\" &&\n (r.photoSignal as Record<string, unknown>).kind === \"eqe-temporal-photo-signal\";\n const p = temporal ? parseSensorEqeTemporalPhotoSignal(r.photoSignal) as unknown as Record<string, unknown> : fields(r.photoSignal, [...common, ...photoTrue, ...photoFalse, \"kind\", \"stationarityStatus\", \"integrationMethod\",\n \"accumulatedSignalCompleteness\", \"incidentPhotonRatePerSecond\", \"expectedGeneratedElectronRatePerSecond\", \"expectedIncidentPhotonCount\", \"expectedGeneratedElectronCount\"]);\n const darkFalse = [\"integerDarkElectronCountSampled\", \"darkShotNoiseApplied\", \"darkCurrentCompensationApplied\", \"photoSignalIncluded\",\n \"otherChargeIncluded\", \"physicalFullWellAssessmentAuthorized\", \"saturationAssessed\"];\n const d = fields(r.darkCharge, [...common, ...darkFalse, \"darkCurrentProfileId\", \"operatingTemperatureC\", \"temperatureModel\",\n \"temperatureInterpolationUsed\", \"temporalIntegrationId\", \"darkCurrentElectronsPerSecond\", \"expectedDarkElectronCount\", \"countMeaning\", \"expectationValueOnly\", \"spatialDarkCurrentNonuniformityModeled\"]);\n if ((!temporal && (p.kind !== \"eqe-expected-counts\" || p.integrationMethod !== \"constant-rate-times-local-exposure-duration\" ||\n p.accumulatedSignalCompleteness !== \"photo-signal-only\" || (p.stationarityStatus !== \"established\" && p.stationarityStatus !== \"approximation\") ||\n photoTrue.some((k) => p[k] !== true) || photoFalse.some((k) => p[k] !== false))) || darkFalse.some((k) => d[k] !== false) ||\n d.expectationValueOnly !== true || d.countMeaning !== \"expected-thermally-generated-electrons\" ||\n typeof d.spatialDarkCurrentNonuniformityModeled !== \"boolean\" || typeof d.temperatureInterpolationUsed !== \"boolean\" ||\n (d.temperatureModel !== \"fixed-reference-temperature\" && d.temperatureModel !== \"piecewise-linear-temperature-table\" &&\n d.temperatureModel !== \"log-linear-temperature-table\")) {\n throw new InvalidConfigurationError(\"Producer requires untreated EQE/dark exposure expectations, not sampled, clipped or A/W charge.\");\n }\n if (d.temperatureModel === \"fixed-reference-temperature\" && d.temperatureInterpolationUsed !== false) {\n throw new InvalidConfigurationError(\"Fixed-temperature dark result cannot claim temperature interpolation.\");\n }\n for (const record of [p, d]) {\n for (const k of [\"colorSamplingProfileId\", \"channelId\", \"bindingId\", temporal ? \"temporalIntegrationId\" : \"stationarityProfileId\"]) publicId(record[k]);\n fields(record.site, [\"x\", \"y\"]);\n if (record.timeReference !== \"first-opening-boundary-phase\") throw new InvalidConfigurationError(\"Unsupported producer time origin.\");\n }\n publicId(d.darkCurrentProfileId);\n for (const [record, keys] of [[p, [\"incidentPhotonRatePerSecond\", \"expectedGeneratedElectronRatePerSecond\", \"expectedIncidentPhotonCount\", \"expectedGeneratedElectronCount\"]],\n [d, [\"darkCurrentElectronsPerSecond\", \"expectedDarkElectronCount\"]]] as const) {\n for (const k of keys) if (!(temporal && record === p && k.endsWith(\"RatePerSecond\")) && (typeof record[k] !== \"number\" || !Number.isFinite(record[k]) || record[k] < 0)) throw new InvalidConfigurationError(\"Invalid expected rates/counts.\");\n }\n const duration = p.localExposureDurationSeconds;\n if (typeof duration !== \"number\" || !Number.isFinite(duration) || duration <= 0 ||\n (!temporal && (p.expectedIncidentPhotonCount !== (p.incidentPhotonRatePerSecond as number)*duration ||\n p.expectedGeneratedElectronCount !== (p.expectedGeneratedElectronRatePerSecond as number)*duration)) ||\n d.expectedDarkElectronCount !== (d.darkCurrentElectronsPerSecond as number)*duration ||\n (p.expectedGeneratedElectronCount as number) > (p.expectedIncidentPhotonCount as number)) {\n throw new InvalidConfigurationError(\"Exposure expectations must match their exact temporal integral or constant-rate products and EQE domain.\");\n }\n const e = fields(d.componentEvidence, [\"darkCurrent\", \"siteApproximation\", \"exposure\"]);\n const charge = { photoSignal: { ...p, componentEvidence: exposureEvidence(p.componentEvidence, temporal ? p : undefined) },\n darkCharge: { ...d, componentEvidence: { darkCurrent: parseEvidenceList(e.darkCurrent, \"darkCurrent\"),\n siteApproximation: optionalEvidence(e.siteApproximation), exposure: exposureEvidence(e.exposure, temporal ? p : undefined) } },\n completenessProfile: parseSensorAccumulatedChargeCompletenessProfile(r.completenessProfile),\n ...(r.additionalChargeComponents === undefined ? {} : { additionalChargeComponents:\n dense(r.additionalChargeComponents, 32).map(parseSensorAdditionalStoredChargeComponent) }) } as unknown as ComposeSensorAccumulatedChargeInput;\n // The existing charge composition checks that photo, dark, additional and completeness events agree exactly.\n composeSensorAccumulatedCharge(charge);\n return charge;\n}\nfunction localWindows(frame: SensorRawProducerInput[\"frame\"], value: unknown): CalculationResult<CaptureExposureWindows> {\n const r = fields(value, [\"shutterMechanism\", \"nominalExposureDurationSeconds\", \"opening\", \"closing\"]);\n fields(r.nominalExposureDurationSeconds, [\"value\", \"unit\", \"evidence\"]);\n for (const boundary of [r.opening, r.closing]) {\n const b = fields(boundary, [\"kind\", \"directionNative\", \"traversalDurationSeconds\"]);\n if (b.directionNative !== undefined) fields(b.directionNative, [\"value\", \"evidence\"]);\n if (b.traversalDurationSeconds !== undefined) fields(b.traversalDurationSeconds, [\"value\", \"unit\", \"evidence\"]);\n }\n const native = frame.capture.geometry.nativeRaster;\n const timing = calculateCaptureExposureWindows({\n ...r as unknown as SensorRawProducerExposureWindowInput,\n nativeRaster: native,\n samplePointsNative: Array.from({ length: native.pixelWidth*native.pixelHeight }, (_, i) => ({\n x: i%native.pixelWidth+0.5, y: Math.floor(i/native.pixelWidth)+0.5\n }))\n });\n if (timing.value.nominalExposureDurationSeconds.value !== frame.capture.exposure.shutterSeconds) {\n throw new InvalidConfigurationError(\"Exposure schedule nominal duration differs from committed capture.\");\n }\n return timing;\n}\nfunction sourceBoundary(schedule: CaptureExposureWindows[\"opening\"][\"schedule\"]): SensorRawProducerExposureWindowInput[\"opening\"] {\n return schedule.kind === \"simultaneous\" ? { kind: \"simultaneous\" } : {\n kind: \"uniform-linear-native-scan\", directionNative: schedule.directionNative,\n traversalDurationSeconds: schedule.traversalDurationSeconds\n };\n}\n/** Internal: per-site validation shared by the reference path and bounded packed execution. */\nexport type NativeRawProducerFrameContext = Omit<SensorRawProducerInput[\"frame\"], \"capture\"> & {\n capture: Pick<SensorRawProducerInput[\"frame\"][\"capture\"], \"geometry\" | \"exposure\" | \"noise\" | \"focus\" | \"sceneStateId\" | \"sceneTimeSeconds\">;\n};\nexport function parseNativeRawProducerSite(site: unknown, i: number, frame: NativeRawProducerFrameContext,\n window?: CaptureExposureWindows[\"samples\"][number]): SensorRawProducerSiteInput {\n const native = frame.capture.geometry.nativeRaster;\n const s = fields(site, [\"charge\", \"samplingProfile\", \"capacityProfile\", \"operatingStateId\", \"readoutProfile\", \"regimeId\", \"fixedPatternNoise\"]);\n const charge = chargeInput(s.charge), p = charge.photoSignal;\n const contributors = resolveCaptureModeColorSamplingContributors({ nativeRaster: native, captureModeProfile: frame.captureModeProfile,\n modeId: frame.modeId, colorSamplingProfile: frame.colorSamplingProfile, bindingProfile: frame.bindingProfile,\n modeSampleIndexFullFrame: { x: i%native.pixelWidth, y: Math.floor(i/native.pixelWidth) } });\n\n if (contributors.totalContributorSites !== 1 || contributors.channelComposition.kind !== \"single-channel\" ||\n p.colorSamplingProfileId !== frame.colorSamplingProfile.profileId || p.channelId !== contributors.channelComposition.channelId ||\n p.site.x !== contributors.colorSamplingSiteRect.x || p.site.y !== contributors.colorSamplingSiteRect.y ||\n p.bindingId !== frame.bindingProfile.bindingId || p.startOffsetSecondsFromOpeningReference !== (window?.startOffsetSecondsFromOpeningReference ?? 0) ||\n p.endOffsetSecondsFromOpeningReference !== (window?.endOffsetSecondsFromOpeningReference ?? frame.capture.exposure.shutterSeconds) ||\n p.localExposureDurationSeconds !== (window?.localExposureDurationSeconds ?? frame.capture.exposure.shutterSeconds)) {\n throw new InvalidConfigurationError(\"Charge site/channel/binding/local exposure differs from committed capture.\");\n }\n const readoutProfile = parseSensorReadoutConversionProfile(s.readoutProfile);\n const isoGain = readoutProfile.regimes.find((regime) => regime.regimeId === s.regimeId)?.exposureIndexGain;\n if (isoGain !== undefined && isoGain.exposureIndex !== frame.capture.exposure.iso) {\n throw new InvalidConfigurationError(\"Readout regime ISO gain differs from the committed capture ISO.\");\n }\n return { charge, samplingProfile: parseSensorChargeSamplingProfile(s.samplingProfile), capacityProfile: parseSensorPhysicalChargeCapacityProfile(s.capacityProfile),\n operatingStateId: publicId(s.operatingStateId), readoutProfile, regimeId: publicId(s.regimeId),\n ...(s.fixedPatternNoise === undefined ? {} : { fixedPatternNoise: parseSensorFixedPatternNoiseProfile(s.fixedPatternNoise) }) };\n}\nexport function validateNativeRawReadoutIdentity(s: SensorRawProducerSiteInput, first: SensorRawProducerSiteInput): void {\n publicIdentities(s);\n const readout = resolveSensorReadoutRegime({ profile: s.readoutProfile, regimeId: s.regimeId });\n if (s.readoutProfile.profileId !== first.readoutProfile.profileId || s.regimeId !== first.regimeId ||\n readout.regime.adc.bitDepth > 16 || readout.regime.adc.digitalSaturationCode <= readout.regime.adc.blackLevelCode ||\n s.readoutProfile.colorSamplingProfileId !== s.charge.photoSignal.colorSamplingProfileId ||\n s.readoutProfile.channelId !== s.charge.photoSignal.channelId || s.samplingProfile.completenessProfileId !== s.charge.completenessProfile.profileId ||\n s.fixedPatternNoise?.profileId !== first.fixedPatternNoise?.profileId ||\n s.fixedPatternNoise?.sensorInstanceSeedUint32 !== first.fixedPatternNoise?.sensorInstanceSeedUint32) {\n throw new InvalidConfigurationError(\"Frame requires one readout identity/regime, one fixed-pattern identity and a positive uint16 RAW code span.\");\n }\n}\n/** The shared per-site pipeline holds all the charge, capacity, random-noise and ADC equations. `i` is the absolute native row-major index. */\nexport function calculateNativeRawSite(s: SensorRawProducerSiteInput, seed: number, i: number): SensorRawProducerResult[\"sites\"][number] {\n const accumulatedCharge = composeSensorAccumulatedCharge(s.charge);\n const capacity = assessSensorPhysicalChargeCapacity({ accumulatedCharge: accumulatedCharge.value, capacityProfile: s.capacityProfile,\n operatingStateId: s.operatingStateId, operatingTemperatureC: s.charge.darkCharge.operatingTemperatureC });\n const pattern = s.fixedPatternNoise === undefined ? {} : { fixedPatternNoise: s.fixedPatternNoise };\n const realization = simulateSensorChargeRealization({ accumulatedCharge: accumulatedCharge.value, samplingProfile: s.samplingProfile,\n seedUint32: deriveNativeSiteStreamSeedUint32(seed, i, NATIVE_SITE_CHARGE_STREAM_ID), ...pattern });\n const readout = simulateSensorRawCode({ chargeRealization: realization.value, physicalCapacityAssessment: capacity.value,\n readoutProfile: s.readoutProfile, regimeId: s.regimeId,\n readNoiseSeedUint32: deriveNativeSiteStreamSeedUint32(seed, i, NATIVE_SITE_READ_NOISE_STREAM_ID), ...pattern });\n return { accumulatedCharge, capacity, realization, readout };\n}\n/** The selected regime's declared INL, which the effective white level needs at saturation. */\nfunction regimeInl(site: SensorRawProducerSiteInput): { adcIntegralNonLinearity?: NonNullable<SensorReadoutConversionProfile[\"regimes\"][number][\"adc\"][\"integralNonLinearity\"]> } {\n const inl = site.readoutProfile.regimes.find((r) => r.regimeId === site.regimeId)?.adc.integralNonLinearity;\n return inl === undefined ? {} : { adcIntegralNonLinearity: inl };\n}\n/** Validates the complete per-site exposure inputs. Charge, noise or RAW codes are never accepted as a shortcut. */\nexport function parseSensorRawProducerInput(value: unknown): SensorRawProducerInput {\n const r = fields(value, [\"frame\", \"sites\", \"exposureWindow\"]), f = fields(r.frame, [\"frameId\", \"capture\", \"modeId\", \"captureModeProfile\", \"colorSamplingProfile\", \"bindingProfile\", \"containerBitDepth\"]);\n const capture = parseSimulatedCapture(f.capture), native = capture.geometry.nativeRaster, count = native.pixelWidth*native.pixelHeight;\n const sites = dense(r.sites, RAW_REFERENCE_MAX_NATIVE_SITES);\n const frame = { frameId: publicId(f.frameId), capture, modeId: publicId(f.modeId), containerBitDepth: 16 as const,\n captureModeProfile: parseCaptureModeProfile(f.captureModeProfile), colorSamplingProfile: parseSensorColorSamplingProfile(f.colorSamplingProfile),\n bindingProfile: parseNativeEffectiveRasterColorSamplingBindingProfile(f.bindingProfile) };\n const mode = frame.captureModeProfile.modes.find((m) => m.modeId === frame.modeId);\n if (f.containerBitDepth !== 16 || count > RAW_REFERENCE_MAX_NATIVE_SITES || sites.length !== count ||\n capture.noise.model.id !== SENSOR_RAW_PRODUCER_NOISE_MODEL.id || capture.noise.model.version !== SENSOR_RAW_PRODUCER_NOISE_MODEL.version ||\n frame.colorSamplingProfile.layout.kind !== \"periodic-mosaic\" || !mode || mode.acquisition.kind !== \"single-frame\" ||\n mode.perFrameSampling.kind !== \"native-effective-raster\" || (mode.reconstructionStages?.length ?? 0) !== 0) {\n throw new InvalidConfigurationError(\"Producer requires exact noise identity and bounded single-frame native CFA coverage.\");\n }\n const timing = r.exposureWindow === undefined ? undefined : localWindows(frame, r.exposureWindow);\n const parsed = sites.map((site, i) => parseNativeRawProducerSite(site, i, frame, timing?.value.samples[i]));\n for (const site of parsed) validateNativeRawReadoutIdentity(site, parsed[0]!);\n publicIdentities(frame);\n return { frame, sites: parsed, ...(timing === undefined ? {} : { exposureWindow: {\n shutterMechanism: timing.value.shutterMechanism,\n nominalExposureDurationSeconds: timing.value.nominalExposureDurationSeconds,\n opening: sourceBoundary(timing.value.opening.schedule), closing: sourceBoundary(timing.value.closing.schedule)\n } }) };\n}\n/** Runs accumulated charge → capacity → Poisson noise → read noise and ADC → native sample → immutable frame. */\nexport function simulateSensorRawFrame(input: SensorRawProducerInput): CalculationResult<SensorRawProducerResult> {\n const v = parseSensorRawProducerInput(input), seed = v.frame.capture.noise.seedUint32;\n const sites = v.sites.map((s, i) => calculateNativeRawSite(s, seed, i));\n const native = v.frame.capture.geometry.nativeRaster;\n const samples = sites.map((s, i) => createSensorRawCaptureSample({ rawCode: s.readout.value,\n ...regimeInl(v.sites[i]!),\n contributors: resolveCaptureModeColorSamplingContributors({ nativeRaster: native, captureModeProfile: v.frame.captureModeProfile,\n modeId: v.frame.modeId, colorSamplingProfile: v.frame.colorSamplingProfile, bindingProfile: v.frame.bindingProfile,\n modeSampleIndexFullFrame: { x: i%native.pixelWidth, y: Math.floor(i/native.pixelWidth) } }) }));\n return approximationResult({ schemaVersion: SENSOR_RAW_PRODUCER_SCHEMA_VERSION, codeProducer: \"engine-charge-capacity-noise-adc\",\n upstreamOrigin: \"declared-eqe-and-dark-exposure-results\", upstreamRadiometryVerified: false,\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\", frame: createSensorRawFrame({ ...v.frame, samples }), sites,\n ...(v.exposureWindow === undefined ? {} : { localExposureWindows: localWindows(v.frame, v.exposureWindow) }) },\n \"native-sensor-raw-frame-producer\", SENSOR_RAW_PRODUCER_SCHEMA_VERSION, [\n \"Untreated EQE/dark exposure results and completeness evidence are upstream declarations; source radiometry is not independently verified\",\n \"Native row-major site seeds are MurmurHash3_x86_32 of (capture seed, absolute native index, stream 0 charge / 1 read noise); deterministic and non-cryptographic\",\n \"Existing scalar capacity/noise/readout approximations retain distinct physical/pre-ADC/digital saturation diagnostics; no blooming\",\n \"Optional fixed-pattern noise is deterministic per sensor instance (its own seed and absolute colour-sampling site), independent of the capture seed\",\n \"Stationarity applies separately to every exact local window; no time-varying radiance integration, multi-frame acquisition, RGB-to-RAW conversion or production-stage activation\",\n \"Stored capture float planes remain independent; same-RAW export must use the returned frame's reconstruction handoff\"]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sensor-raw-producer.js","sourceRoot":"","sources":["../../src/capture/sensor-raw-producer.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;GAQG;AAEH,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE/F,OAAO,EAAE,iCAAiC,EAAE,oCAAoC,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AACvJ,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAEvE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAiD,MAAM,uBAAuB,CAAC;AAC5G,OAAO,EAAE,8BAA8B,EAAE,+CAA+C,EAAE,0CAA0C,EAC5C,MAAM,iCAAiC,CAAC;AAChI,OAAO,EAAE,kCAAkC,EAAE,wCAAwC,EACzC,MAAM,uCAAuC,CAAC;AAC1F,OAAO,EAAE,+BAA+B,EAAE,qBAAqB,EAAE,gCAAgC,EAC/F,mCAAmC,EAAE,0BAA0B,EAAyE,MAAM,0BAA0B,CAAC;AAC3K,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAE/E,OAAO,EAAE,mCAAmC,EAAuC,MAAM,kCAAkC,CAAC;AAC5H,OAAO,EAAE,gCAAgC,EAAE,4BAA4B,EAAE,gCAAgC,EAAE,MAAM,8BAA8B,CAAC;AAChJ,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE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C,CAAC;AAC7H,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Produces a sensor RAW frame from per-site exposure inputs, using the existing sensor steps:\n * accumulated charge → capacity → Poisson (shot) noise → read noise and ADC → native sample →\n * immutable frame.\n *\n * Inputs must be complete. Charge, noise or RAW codes cannot be passed in as a shortcut.\n * @see docs/SIMULATED_CAPTURE.md for equations, coordinate/unit conventions, blockers and support\n * limits.\n */\n\nimport { requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\n\nimport { parseSensorEqeTemporalPhotoSignal, PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS, PHOTO_SIGNAL_TRUE_FIELDS } from \"../sensor/temporal-photo-signal.js\";\nimport { RAW_REFERENCE_MAX_NATIVE_SITES } from \"./raw-frame-limits.js\";\n\nimport { approximationResult, type CalculationResult } from \"../core/calculation-result.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { parseEvidenceList } from \"../core/evidence-provenance.js\";\nimport { parseSimulatedCapture } from \"./simulated-capture.js\";\nimport { createSensorRawFrame, type SensorRawFrameInput, type SensorRawFrame } from \"./sensor-raw-frame.js\";\nimport { composeSensorAccumulatedCharge, parseSensorAccumulatedChargeCompletenessProfile, parseSensorAdditionalStoredChargeComponent,\n type ComposeSensorPhotoAccumulatedChargeInput as ComposeSensorAccumulatedChargeInput } from \"../sensor/accumulated-charge.js\";\nimport { assessSensorPhysicalChargeCapacity, parseSensorPhysicalChargeCapacityProfile,\n type SensorPhysicalChargeCapacityProfile } from \"../sensor/physical-charge-capacity.js\";\nimport { simulateSensorChargeRealization, simulateSensorRawCode, parseSensorChargeSamplingProfile,\n parseSensorReadoutConversionProfile, resolveSensorReadoutRegime, type SensorChargeSamplingProfile, type SensorReadoutConversionProfile } from \"../sensor/raw-readout.js\";\nimport { createSensorRawCaptureSample } from \"../sensor/raw-reconstruction.js\";\nimport type { ExposureBuildUpStage } from \"./exposure-build-up-stage.js\";\nimport { parseSensorFixedPatternNoiseProfile, type SensorFixedPatternNoiseProfile } from \"../sensor/fixed-pattern-noise.js\";\nimport { deriveNativeSiteStreamSeedUint32, NATIVE_SITE_CHARGE_STREAM_ID, NATIVE_SITE_READ_NOISE_STREAM_ID } from \"../sensor/stochastic-seed.js\";\nimport { parseSensorColorSamplingProfile } from \"../sensor/color-sampling.js\";\nimport { parseCaptureModeProfile } from \"../sensor/capture-mode.js\";\nimport { parseNativeEffectiveRasterColorSamplingBindingProfile, resolveCaptureModeColorSamplingContributors } from \"../sensor/capture-color-sampling-binding.js\";\nimport { calculateCaptureExposureWindows, type CalculateCaptureExposureWindowsInput, type CaptureExposureWindows } from \"../sensor/exposure-window.js\";\n\nexport const SENSOR_RAW_PRODUCER_SCHEMA_VERSION = \"0.3.0\" as const;\n/**\n * Version of the capture noise model. It fixes the hashed per-site seed schedule and the signed electronic\n * readout behaviour.\n *\n * 0.4.0: exact ADC rounding with ties up, normal-approximation Poisson draws for means of 1e9 and above,\n * optional post-ADC digital gain and INL (integral non-linearity), and optional per-sensor fixed-pattern noise.\n */\nexport const SENSOR_RAW_PRODUCER_NOISE_MODEL = /* @__PURE__ */ Object.freeze({ id: \"photivra-native-raw-noise\", version: \"0.4.0\" } as const);\n/** For each native site: one declared exposure event (EQE photo signal, dark signal, charge completeness) and its readout state. */\nexport interface SensorRawProducerSiteInput {\n charge: ComposeSensorAccumulatedChargeInput;\n samplingProfile: SensorChargeSamplingProfile;\n capacityProfile: SensorPhysicalChargeCapacityProfile;\n operatingStateId: string;\n readoutProfile: SensorReadoutConversionProfile;\n regimeId: string;\n /** Optional fixed-pattern noise (FPN) for this sensor; one profile for the whole frame. Omit it to disable FPN. */\n fixedPatternNoise?: SensorFixedPatternNoiseProfile;\n}\n/** Exposure schedule for the full sensor. The producer owns the sampling coordinates. */\nexport type SensorRawProducerExposureWindowInput = Omit<CalculateCaptureExposureWindowsInput,\n \"nativeRaster\" | \"activeCaptureRect\" | \"samplePointsNative\">;\n/** Input for one bounded frame. It is never a conversion from separate RGB pixels. */\nexport interface SensorRawProducerInput {\n frame: Omit<SensorRawFrameInput, \"samples\">;\n sites: readonly SensorRawProducerSiteInput[];\n /** If omitted, every event uses the existing global window 0..shutterSeconds. */\n exposureWindow?: SensorRawProducerExposureWindowInput;\n}\n/** Codes produced by the engine, with per-step diagnostics. The upstream radiance and response are as declared, not verified. */\nexport interface SensorRawProducerResult {\n schemaVersion: typeof SENSOR_RAW_PRODUCER_SCHEMA_VERSION;\n codeProducer: \"engine-charge-capacity-noise-adc\";\n upstreamOrigin: \"declared-eqe-and-dark-exposure-results\";\n upstreamRadiometryVerified: false;\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\";\n frame: SensorRawFrame;\n localExposureWindows?: CalculationResult<CaptureExposureWindows>;\n sites: readonly {\n accumulatedCharge: ReturnType<typeof composeSensorAccumulatedCharge>;\n capacity: ReturnType<typeof assessSensorPhysicalChargeCapacity>;\n realization: ReturnType<typeof simulateSensorChargeRealization>;\n readout: ReturnType<typeof simulateSensorRawCode>;\n }[];\n}\nfunction fields(value: unknown, allowed: readonly string[]): Record<string, unknown> {\n return requireAllowlistedRecord(value, allowed, \"Invalid sensor RAW producer fields.\");\n}\nfunction publicId(value: unknown): string {\n return requirePublicOpaqueId(value, \"Expected public producer identity.\");\n}\nconst KEY_RECURSE = 0, KEY_IDENTITY = 1, KEY_IDENTITY_LIST = 2;\n/** Bounded cache of how the identity check classifies each property name (it depends only on the name). */\nconst IDENTITY_KEY_KINDS = new Map<string, number>();\n/** Bounded cache of strings already known to be valid public IDs (validity depends only on the string). */\nconst VALID_PUBLIC_IDS = new Set<string>();\nconst IDENTITY_WALK_MEMO_LIMIT = 4096;\nfunction identityKeyKind(key: string): number {\n // Array indices and other names ending in a digit match neither suffix.\n const last = key.charCodeAt(key.length - 1);\n if (last >= 48 && last <= 57) return KEY_RECURSE;\n let kind = IDENTITY_KEY_KINDS.get(key);\n if (kind === undefined) {\n kind = /(?:Id|Version)$/.test(key) ? KEY_IDENTITY : /Ids$/.test(key) ? KEY_IDENTITY_LIST : KEY_RECURSE;\n if (IDENTITY_KEY_KINDS.size < IDENTITY_WALK_MEMO_LIMIT) IDENTITY_KEY_KINDS.set(key, kind);\n }\n return kind;\n}\nfunction memoizedPublicId(value: unknown): void {\n if (typeof value === \"string\" && VALID_PUBLIC_IDS.has(value)) return;\n publicId(value);\n if (VALID_PUBLIC_IDS.size < IDENTITY_WALK_MEMO_LIMIT) VALID_PUBLIC_IDS.add(value as string);\n}\n/**\n * At any depth, every property whose name ends in Id or Version must hold a public ID, and every property\n * ending in Ids a bounded dense list of them. Order, keys and errors are the same as the earlier\n * Object.entries walk. Key classification and already-valid IDs are cached, because each depends only on\n * its string.\n */\nfunction publicIdentities(value: unknown): void {\n if (value === null || typeof value !== \"object\") return;\n const record = value as Record<string, unknown>, keys = Object.keys(record);\n for (let index = 0; index < keys.length; index++) {\n const key = keys[index]!, kind = identityKeyKind(key), child = record[key];\n if (kind === KEY_IDENTITY) memoizedPublicId(child);\n else if (kind === KEY_IDENTITY_LIST) dense(child, 256).forEach(memoizedPublicId);\n else if (child !== null && typeof child === \"object\") publicIdentities(child);\n }\n}\nfunction dense(value: unknown, maximum: number): unknown[] {\n if (!Array.isArray(value) || value.length > maximum || Array.from({ length: value.length }, (_, i) => i in value).includes(false)) {\n throw new InvalidConfigurationError(\"Expected bounded dense producer array.\");\n }\n return value;\n}\nfunction optionalEvidence(value: unknown): ReturnType<typeof parseEvidenceList> {\n return dense(value, 256).length === 0 ? [] : parseEvidenceList(value, \"optionalExposureEvidence\");\n}\nfunction exposureEvidence(value: unknown, temporalPhoto?: Record<string, unknown>): ComposeSensorAccumulatedChargeInput[\"photoSignal\"][\"componentEvidence\"] {\n if (temporalPhoto !== undefined) return parseSensorEqeTemporalPhotoSignal({ ...temporalPhoto, componentEvidence: value }).componentEvidence;\n const r = fields(value, [\"stationarity\", \"exposureBinding\"]);\n const b = fields(r.exposureBinding, [\"binding\", \"colorSamplingProfile\", \"nominalExposureDuration\", \"openingBoundary\", \"closingBoundary\"]);\n return { stationarity: parseEvidenceList(r.stationarity, \"stationarity\"), exposureBinding: {\n binding: parseEvidenceList(b.binding, \"binding\"), colorSamplingProfile: parseEvidenceList(b.colorSamplingProfile, \"colorSamplingProfile\"),\n nominalExposureDuration: parseEvidenceList(b.nominalExposureDuration, \"nominalExposureDuration\"),\n openingBoundary: optionalEvidence(b.openingBoundary), closingBoundary: optionalEvidence(b.closingBoundary) } };\n}\nconst common = [\"colorSamplingProfileId\", \"channelId\", \"site\", \"bindingId\", \"stationarityProfileId\", \"timeReference\",\n \"startOffsetSecondsFromOpeningReference\", \"endOffsetSecondsFromOpeningReference\", \"localExposureDurationSeconds\", \"componentEvidence\"];\nconst photoTrue: string[] = [\"timeStationarityEstablished\", ...PHOTO_SIGNAL_TRUE_FIELDS];\nconst photoFalse: string[] = [\"timeVaryingSignalIntegrated\", ...PHOTO_SIGNAL_DOWNSTREAM_FALSE_FIELDS];\nfunction chargeInput(value: unknown): ComposeSensorAccumulatedChargeInput {\n const r = fields(value, [\"photoSignal\", \"darkCharge\", \"additionalChargeComponents\", \"completenessProfile\"]);\n const temporal = r.photoSignal !== null && typeof r.photoSignal === \"object\" &&\n (r.photoSignal as Record<string, unknown>).kind === \"eqe-temporal-photo-signal\";\n const p = temporal ? parseSensorEqeTemporalPhotoSignal(r.photoSignal) as unknown as Record<string, unknown> : fields(r.photoSignal, [...common, ...photoTrue, ...photoFalse, \"kind\", \"stationarityStatus\", \"integrationMethod\",\n \"accumulatedSignalCompleteness\", \"incidentPhotonRatePerSecond\", \"expectedGeneratedElectronRatePerSecond\", \"expectedIncidentPhotonCount\", \"expectedGeneratedElectronCount\"]);\n const darkFalse = [\"integerDarkElectronCountSampled\", \"darkShotNoiseApplied\", \"darkCurrentCompensationApplied\", \"photoSignalIncluded\",\n \"otherChargeIncluded\", \"physicalFullWellAssessmentAuthorized\", \"saturationAssessed\"];\n const d = fields(r.darkCharge, [...common, ...darkFalse, \"darkCurrentProfileId\", \"operatingTemperatureC\", \"temperatureModel\",\n \"temperatureInterpolationUsed\", \"temporalIntegrationId\", \"darkCurrentElectronsPerSecond\", \"expectedDarkElectronCount\", \"countMeaning\", \"expectationValueOnly\", \"spatialDarkCurrentNonuniformityModeled\"]);\n if ((!temporal && (p.kind !== \"eqe-expected-counts\" || p.integrationMethod !== \"constant-rate-times-local-exposure-duration\" ||\n p.accumulatedSignalCompleteness !== \"photo-signal-only\" || (p.stationarityStatus !== \"established\" && p.stationarityStatus !== \"approximation\") ||\n photoTrue.some((k) => p[k] !== true) || photoFalse.some((k) => p[k] !== false))) || darkFalse.some((k) => d[k] !== false) ||\n d.expectationValueOnly !== true || d.countMeaning !== \"expected-thermally-generated-electrons\" ||\n typeof d.spatialDarkCurrentNonuniformityModeled !== \"boolean\" || typeof d.temperatureInterpolationUsed !== \"boolean\" ||\n (d.temperatureModel !== \"fixed-reference-temperature\" && d.temperatureModel !== \"piecewise-linear-temperature-table\" &&\n d.temperatureModel !== \"log-linear-temperature-table\")) {\n throw new InvalidConfigurationError(\"Producer requires untreated EQE/dark exposure expectations, not sampled, clipped or A/W charge.\");\n }\n if (d.temperatureModel === \"fixed-reference-temperature\" && d.temperatureInterpolationUsed !== false) {\n throw new InvalidConfigurationError(\"Fixed-temperature dark result cannot claim temperature interpolation.\");\n }\n for (const record of [p, d]) {\n for (const k of [\"colorSamplingProfileId\", \"channelId\", \"bindingId\", temporal ? \"temporalIntegrationId\" : \"stationarityProfileId\"]) publicId(record[k]);\n fields(record.site, [\"x\", \"y\"]);\n if (record.timeReference !== \"first-opening-boundary-phase\") throw new InvalidConfigurationError(\"Unsupported producer time origin.\");\n }\n publicId(d.darkCurrentProfileId);\n for (const [record, keys] of [[p, [\"incidentPhotonRatePerSecond\", \"expectedGeneratedElectronRatePerSecond\", \"expectedIncidentPhotonCount\", \"expectedGeneratedElectronCount\"]],\n [d, [\"darkCurrentElectronsPerSecond\", \"expectedDarkElectronCount\"]]] as const) {\n for (const k of keys) if (!(temporal && record === p && k.endsWith(\"RatePerSecond\")) && (typeof record[k] !== \"number\" || !Number.isFinite(record[k]) || record[k] < 0)) throw new InvalidConfigurationError(\"Invalid expected rates/counts.\");\n }\n const duration = p.localExposureDurationSeconds;\n if (typeof duration !== \"number\" || !Number.isFinite(duration) || duration <= 0 ||\n (!temporal && (p.expectedIncidentPhotonCount !== (p.incidentPhotonRatePerSecond as number)*duration ||\n p.expectedGeneratedElectronCount !== (p.expectedGeneratedElectronRatePerSecond as number)*duration)) ||\n d.expectedDarkElectronCount !== (d.darkCurrentElectronsPerSecond as number)*duration ||\n (p.expectedGeneratedElectronCount as number) > (p.expectedIncidentPhotonCount as number)) {\n throw new InvalidConfigurationError(\"Exposure expectations must match their exact temporal integral or constant-rate products and EQE domain.\");\n }\n const e = fields(d.componentEvidence, [\"darkCurrent\", \"siteApproximation\", \"exposure\"]);\n const charge = { photoSignal: { ...p, componentEvidence: exposureEvidence(p.componentEvidence, temporal ? p : undefined) },\n darkCharge: { ...d, componentEvidence: { darkCurrent: parseEvidenceList(e.darkCurrent, \"darkCurrent\"),\n siteApproximation: optionalEvidence(e.siteApproximation), exposure: exposureEvidence(e.exposure, temporal ? p : undefined) } },\n completenessProfile: parseSensorAccumulatedChargeCompletenessProfile(r.completenessProfile),\n ...(r.additionalChargeComponents === undefined ? {} : { additionalChargeComponents:\n dense(r.additionalChargeComponents, 32).map(parseSensorAdditionalStoredChargeComponent) }) } as unknown as ComposeSensorAccumulatedChargeInput;\n // The existing charge composition checks that photo, dark, additional and completeness events agree exactly.\n composeSensorAccumulatedCharge(charge);\n return charge;\n}\nfunction localWindows(frame: SensorRawProducerInput[\"frame\"], value: unknown): CalculationResult<CaptureExposureWindows> {\n const r = fields(value, [\"shutterMechanism\", \"nominalExposureDurationSeconds\", \"opening\", \"closing\"]);\n fields(r.nominalExposureDurationSeconds, [\"value\", \"unit\", \"evidence\"]);\n for (const boundary of [r.opening, r.closing]) {\n const b = fields(boundary, [\"kind\", \"directionNative\", \"traversalDurationSeconds\"]);\n if (b.directionNative !== undefined) fields(b.directionNative, [\"value\", \"evidence\"]);\n if (b.traversalDurationSeconds !== undefined) fields(b.traversalDurationSeconds, [\"value\", \"unit\", \"evidence\"]);\n }\n const native = frame.capture.geometry.nativeRaster;\n const timing = calculateCaptureExposureWindows({\n ...r as unknown as SensorRawProducerExposureWindowInput,\n nativeRaster: native,\n samplePointsNative: Array.from({ length: native.pixelWidth*native.pixelHeight }, (_, i) => ({\n x: i%native.pixelWidth+0.5, y: Math.floor(i/native.pixelWidth)+0.5\n }))\n });\n if (timing.value.nominalExposureDurationSeconds.value !== frame.capture.exposure.shutterSeconds) {\n throw new InvalidConfigurationError(\"Exposure schedule nominal duration differs from committed capture.\");\n }\n return timing;\n}\nfunction sourceBoundary(schedule: CaptureExposureWindows[\"opening\"][\"schedule\"]): SensorRawProducerExposureWindowInput[\"opening\"] {\n return schedule.kind === \"simultaneous\" ? { kind: \"simultaneous\" } : {\n kind: \"uniform-linear-native-scan\", directionNative: schedule.directionNative,\n traversalDurationSeconds: schedule.traversalDurationSeconds\n };\n}\n/** Internal: per-site validation shared by the reference path and bounded packed execution. */\nexport type NativeRawProducerFrameContext = Omit<SensorRawProducerInput[\"frame\"], \"capture\"> & {\n capture: Pick<SensorRawProducerInput[\"frame\"][\"capture\"], \"geometry\" | \"exposure\" | \"noise\" | \"focus\" | \"sceneStateId\" | \"sceneTimeSeconds\">;\n};\nexport function parseNativeRawProducerSite(site: unknown, i: number, frame: NativeRawProducerFrameContext,\n window?: CaptureExposureWindows[\"samples\"][number]): SensorRawProducerSiteInput {\n const native = frame.capture.geometry.nativeRaster;\n const s = fields(site, [\"charge\", \"samplingProfile\", \"capacityProfile\", \"operatingStateId\", \"readoutProfile\", \"regimeId\", \"fixedPatternNoise\"]);\n const charge = chargeInput(s.charge), p = charge.photoSignal;\n const contributors = resolveCaptureModeColorSamplingContributors({ nativeRaster: native, captureModeProfile: frame.captureModeProfile,\n modeId: frame.modeId, colorSamplingProfile: frame.colorSamplingProfile, bindingProfile: frame.bindingProfile,\n modeSampleIndexFullFrame: { x: i%native.pixelWidth, y: Math.floor(i/native.pixelWidth) } });\n\n if (contributors.totalContributorSites !== 1 || contributors.channelComposition.kind !== \"single-channel\" ||\n p.colorSamplingProfileId !== frame.colorSamplingProfile.profileId || p.channelId !== contributors.channelComposition.channelId ||\n p.site.x !== contributors.colorSamplingSiteRect.x || p.site.y !== contributors.colorSamplingSiteRect.y ||\n p.bindingId !== frame.bindingProfile.bindingId || p.startOffsetSecondsFromOpeningReference !== (window?.startOffsetSecondsFromOpeningReference ?? 0) ||\n p.endOffsetSecondsFromOpeningReference !== (window?.endOffsetSecondsFromOpeningReference ?? frame.capture.exposure.shutterSeconds) ||\n p.localExposureDurationSeconds !== (window?.localExposureDurationSeconds ?? frame.capture.exposure.shutterSeconds)) {\n throw new InvalidConfigurationError(\"Charge site/channel/binding/local exposure differs from committed capture.\");\n }\n const readoutProfile = parseSensorReadoutConversionProfile(s.readoutProfile);\n const isoGain = readoutProfile.regimes.find((regime) => regime.regimeId === s.regimeId)?.exposureIndexGain;\n if (isoGain !== undefined && isoGain.exposureIndex !== frame.capture.exposure.iso) {\n throw new InvalidConfigurationError(\"Readout regime ISO gain differs from the committed capture ISO.\");\n }\n return { charge, samplingProfile: parseSensorChargeSamplingProfile(s.samplingProfile), capacityProfile: parseSensorPhysicalChargeCapacityProfile(s.capacityProfile),\n operatingStateId: publicId(s.operatingStateId), readoutProfile, regimeId: publicId(s.regimeId),\n ...(s.fixedPatternNoise === undefined ? {} : { fixedPatternNoise: parseSensorFixedPatternNoiseProfile(s.fixedPatternNoise) }) };\n}\nexport function validateNativeRawReadoutIdentity(s: SensorRawProducerSiteInput, first: SensorRawProducerSiteInput): void {\n publicIdentities(s);\n const readout = resolveSensorReadoutRegime({ profile: s.readoutProfile, regimeId: s.regimeId });\n if (s.readoutProfile.profileId !== first.readoutProfile.profileId || s.regimeId !== first.regimeId ||\n readout.regime.adc.bitDepth > 16 || readout.regime.adc.digitalSaturationCode <= readout.regime.adc.blackLevelCode ||\n s.readoutProfile.colorSamplingProfileId !== s.charge.photoSignal.colorSamplingProfileId ||\n s.readoutProfile.channelId !== s.charge.photoSignal.channelId || s.samplingProfile.completenessProfileId !== s.charge.completenessProfile.profileId ||\n s.fixedPatternNoise?.profileId !== first.fixedPatternNoise?.profileId ||\n s.fixedPatternNoise?.sensorInstanceSeedUint32 !== first.fixedPatternNoise?.sensorInstanceSeedUint32) {\n throw new InvalidConfigurationError(\"Frame requires one readout identity/regime, one fixed-pattern identity and a positive uint16 RAW code span.\");\n }\n}\n/** The shared per-site pipeline holds all the charge, capacity, random-noise and ADC equations. `i` is the absolute native row-major index. */\nexport function calculateNativeRawSite(s: SensorRawProducerSiteInput, seed: number, i: number,\n /** Internal (#534): a build-up fraction's stage, which splits the realized counts down to the fraction and reads with its own stream. */\n b?: ExposureBuildUpStage): SensorRawProducerResult[\"sites\"][number] {\n const accumulatedCharge = composeSensorAccumulatedCharge(s.charge);\n const capacity = assessSensorPhysicalChargeCapacity({ accumulatedCharge: accumulatedCharge.value, capacityProfile: s.capacityProfile,\n operatingStateId: s.operatingStateId, operatingTemperatureC: s.charge.darkCharge.operatingTemperatureC });\n const pattern = s.fixedPatternNoise === undefined ? {} : { fixedPatternNoise: s.fixedPatternNoise };\n let realization = simulateSensorChargeRealization({ accumulatedCharge: accumulatedCharge.value, samplingProfile: s.samplingProfile,\n seedUint32: deriveNativeSiteStreamSeedUint32(seed, i, NATIVE_SITE_CHARGE_STREAM_ID), ...pattern });\n if (b) {\n const v = realization.value;\n if (v.additionalComponents.length) throw new InvalidConfigurationError(\"An exposure build-up takes photo and dark charge only.\");\n b.split(i, v.photoSampledMeanElectronCount, v.darkSampledMeanElectronCount, v.photoRealizedElectronCount, v.darkRealizedElectronCount);\n realization = { ...realization, value: { ...v, photoRealizedElectronCount: b.photo, darkRealizedElectronCount: b.dark, totalRealizedStoredElectronEquivalentCount: b.photo + b.dark + 0 } };\n }\n const readout = simulateSensorRawCode({ chargeRealization: realization.value, physicalCapacityAssessment: capacity.value,\n readoutProfile: s.readoutProfile, regimeId: s.regimeId,\n readNoiseSeedUint32: deriveNativeSiteStreamSeedUint32(seed, i, b ? b.read : NATIVE_SITE_READ_NOISE_STREAM_ID), ...pattern });\n return { accumulatedCharge, capacity, realization, readout };\n}\n/** The selected regime's declared INL, which the effective white level needs at saturation. */\nfunction regimeInl(site: SensorRawProducerSiteInput): { adcIntegralNonLinearity?: NonNullable<SensorReadoutConversionProfile[\"regimes\"][number][\"adc\"][\"integralNonLinearity\"]> } {\n const inl = site.readoutProfile.regimes.find((r) => r.regimeId === site.regimeId)?.adc.integralNonLinearity;\n return inl === undefined ? {} : { adcIntegralNonLinearity: inl };\n}\n/** Validates the complete per-site exposure inputs. Charge, noise or RAW codes are never accepted as a shortcut. */\nexport function parseSensorRawProducerInput(value: unknown): SensorRawProducerInput {\n const r = fields(value, [\"frame\", \"sites\", \"exposureWindow\"]), f = fields(r.frame, [\"frameId\", \"capture\", \"modeId\", \"captureModeProfile\", \"colorSamplingProfile\", \"bindingProfile\", \"containerBitDepth\"]);\n const capture = parseSimulatedCapture(f.capture), native = capture.geometry.nativeRaster, count = native.pixelWidth*native.pixelHeight;\n const sites = dense(r.sites, RAW_REFERENCE_MAX_NATIVE_SITES);\n const frame = { frameId: publicId(f.frameId), capture, modeId: publicId(f.modeId), containerBitDepth: 16 as const,\n captureModeProfile: parseCaptureModeProfile(f.captureModeProfile), colorSamplingProfile: parseSensorColorSamplingProfile(f.colorSamplingProfile),\n bindingProfile: parseNativeEffectiveRasterColorSamplingBindingProfile(f.bindingProfile) };\n const mode = frame.captureModeProfile.modes.find((m) => m.modeId === frame.modeId);\n if (f.containerBitDepth !== 16 || count > RAW_REFERENCE_MAX_NATIVE_SITES || sites.length !== count ||\n capture.noise.model.id !== SENSOR_RAW_PRODUCER_NOISE_MODEL.id || capture.noise.model.version !== SENSOR_RAW_PRODUCER_NOISE_MODEL.version ||\n frame.colorSamplingProfile.layout.kind !== \"periodic-mosaic\" || !mode || mode.acquisition.kind !== \"single-frame\" ||\n mode.perFrameSampling.kind !== \"native-effective-raster\" || (mode.reconstructionStages?.length ?? 0) !== 0) {\n throw new InvalidConfigurationError(\"Producer requires exact noise identity and bounded single-frame native CFA coverage.\");\n }\n const timing = r.exposureWindow === undefined ? undefined : localWindows(frame, r.exposureWindow);\n const parsed = sites.map((site, i) => parseNativeRawProducerSite(site, i, frame, timing?.value.samples[i]));\n for (const site of parsed) validateNativeRawReadoutIdentity(site, parsed[0]!);\n publicIdentities(frame);\n return { frame, sites: parsed, ...(timing === undefined ? {} : { exposureWindow: {\n shutterMechanism: timing.value.shutterMechanism,\n nominalExposureDurationSeconds: timing.value.nominalExposureDurationSeconds,\n opening: sourceBoundary(timing.value.opening.schedule), closing: sourceBoundary(timing.value.closing.schedule)\n } }) };\n}\n/** Runs accumulated charge → capacity → Poisson noise → read noise and ADC → native sample → immutable frame. */\nexport function simulateSensorRawFrame(input: SensorRawProducerInput): CalculationResult<SensorRawProducerResult> {\n const v = parseSensorRawProducerInput(input), seed = v.frame.capture.noise.seedUint32;\n const sites = v.sites.map((s, i) => calculateNativeRawSite(s, seed, i));\n const native = v.frame.capture.geometry.nativeRaster;\n const samples = sites.map((s, i) => createSensorRawCaptureSample({ rawCode: s.readout.value,\n ...regimeInl(v.sites[i]!),\n contributors: resolveCaptureModeColorSamplingContributors({ nativeRaster: native, captureModeProfile: v.frame.captureModeProfile,\n modeId: v.frame.modeId, colorSamplingProfile: v.frame.colorSamplingProfile, bindingProfile: v.frame.bindingProfile,\n modeSampleIndexFullFrame: { x: i%native.pixelWidth, y: Math.floor(i/native.pixelWidth) } }) }));\n return approximationResult({ schemaVersion: SENSOR_RAW_PRODUCER_SCHEMA_VERSION, codeProducer: \"engine-charge-capacity-noise-adc\",\n upstreamOrigin: \"declared-eqe-and-dark-exposure-results\", upstreamRadiometryVerified: false,\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\", frame: createSensorRawFrame({ ...v.frame, samples }), sites,\n ...(v.exposureWindow === undefined ? {} : { localExposureWindows: localWindows(v.frame, v.exposureWindow) }) },\n \"native-sensor-raw-frame-producer\", SENSOR_RAW_PRODUCER_SCHEMA_VERSION, [\n \"Untreated EQE/dark exposure results and completeness evidence are upstream declarations; source radiometry is not independently verified\",\n \"Native row-major site seeds are MurmurHash3_x86_32 of (capture seed, absolute native index, stream 0 charge / 1 read noise); deterministic and non-cryptographic\",\n \"Existing scalar capacity/noise/readout approximations retain distinct physical/pre-ADC/digital saturation diagnostics; no blooming\",\n \"Optional fixed-pattern noise is deterministic per sensor instance (its own seed and absolute colour-sampling site), independent of the capture seed\",\n \"Stationarity applies separately to every exact local window; no time-varying radiance integration, multi-frame acquisition, RGB-to-RAW conversion or production-stage activation\",\n \"Stored capture float planes remain independent; same-RAW export must use the returned frame's reconstruction handoff\"]);\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #602 (2.22.0): highlight reconstruction from neighboring pixels, `highlightMode: "reconstruct-neighbors"` (opt-in; an estimate,
|
|
3
|
+
* not a recovery of the clipped scene signal). The engine's own method, acting on the developed, white-balanced camera values
|
|
4
|
+
* u = g·c of the whole image at use (no tables):
|
|
5
|
+
*
|
|
6
|
+
* 1. A pixel is clipped when one of its normalized camera channels c_k reaches `NEIGHBOR_HIGHLIGHT_THRESHOLD` of white; clipped
|
|
7
|
+
* pixels form regions (8-connected).
|
|
8
|
+
* 2. Each unclipped pixel has the color ratios ρ = u/(u₀ + u₁ + u₂) (its chromaticity in white-balanced camera space). Pixels
|
|
9
|
+
* within `NEIGHBOR_HIGHLIGHT_MARGIN` pixels of a clipped one give no ratios: their demosaic reads clipped sites, which lowers
|
|
10
|
+
* the clipped channel (and noise selects them by the threshold); the regions below are the clipped pixels widened by it.
|
|
11
|
+
* 3. The clipped region takes its ratios from its unclipped boundary. **Fast:** the mean of ρ over the unclipped pixels within
|
|
12
|
+
* `NEIGHBOR_HIGHLIGHT_RING` pixels (Chebyshev distance) of the region. **Full:** the discrete harmonic (Laplace) interpolation
|
|
13
|
+
* of ρ inward: ρ at each clipped pixel is the mean of its 4-neighbors', with the unclipped neighbors' ratios as Dirichlet
|
|
14
|
+
* boundary values (pixels outside the image are left out), solved by successive over-relaxation from the fast values. A region
|
|
15
|
+
* with no unclipped neighbor keeps the neutral ratios.
|
|
16
|
+
* 4. A clipped pixel keeps its unclipped channels; its scale s = Σ_unclipped u_k / Σ_unclipped ρ_k, and each clipped channel
|
|
17
|
+
* becomes max(u_k, s·ρ_k) (never below what was recorded). Where every channel is clipped, s = max_k u_k/ρ_k.
|
|
18
|
+
* The result is not clipped at the white level: the tone curve and gamut handling then render it.
|
|
19
|
+
*
|
|
20
|
+
* Mathematics only, general and free: the discrete Laplace equation and its Dirichlet problem, and successive over-relaxation
|
|
21
|
+
* (e.g. G. Strang, MIT OpenCourseWare 18.086, "Mathematical Methods for Engineers II", finite differences for Laplace's equation
|
|
22
|
+
* and iterative solvers, free at https://ocw.mit.edu/courses/18-086-mathematical-methods-for-engineers-ii-spring-2006/).
|
|
23
|
+
*/
|
|
24
|
+
/** Normalized channel level at which a channel counts as clipped. */
|
|
25
|
+
export declare const NEIGHBOR_HIGHLIGHT_THRESHOLD = 0.98;
|
|
26
|
+
/** Pixels this close (Chebyshev distance) to a clipped pixel give no ratios and are filled with the region. */
|
|
27
|
+
export declare const NEIGHBOR_HIGHLIGHT_MARGIN = 2;
|
|
28
|
+
/** The fast method's ring width in pixels around a (widened) clipped region. */
|
|
29
|
+
export declare const NEIGHBOR_HIGHLIGHT_RING = 2;
|
|
30
|
+
/** The full method's relaxation factor, tolerance and iteration cap. */
|
|
31
|
+
export declare const NEIGHBOR_HIGHLIGHT_SOR: Readonly<{
|
|
32
|
+
omega: 1.8;
|
|
33
|
+
tolerance: 1e-9;
|
|
34
|
+
maximumIterations: 20000;
|
|
35
|
+
}>;
|
|
36
|
+
export interface NeighborHighlightReport {
|
|
37
|
+
method: "ring-average" | "harmonic-interpolation";
|
|
38
|
+
/** Clipped pixels rebuilt, and the clipped regions. */
|
|
39
|
+
reconstructedPixelCount: number;
|
|
40
|
+
regionCount: number;
|
|
41
|
+
/** Full method: the largest number of relaxation sweeps a region needed, and whether every region met the tolerance. */
|
|
42
|
+
iterations: number;
|
|
43
|
+
converged: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The region ratios of an image: per pixel the ratios ρ its rebuild uses (`ratios`, 3 per pixel; for an unclipped pixel its own),
|
|
47
|
+
* and which pixels are clipped. `clippedAt(i)` tells whether pixel i is clipped; `valueAt(i, out)` writes pixel i's u.
|
|
48
|
+
* Pixels are i = y·width + x.
|
|
49
|
+
*/
|
|
50
|
+
export declare function neighborHighlightRatios(width: number, height: number, clippedAt: (i: number) => boolean, valueAt: (i: number, out: Float64Array) => void, fast: boolean): {
|
|
51
|
+
clipped: Uint8Array;
|
|
52
|
+
ratios: Float64Array;
|
|
53
|
+
regionCount: number;
|
|
54
|
+
iterations: number;
|
|
55
|
+
converged: boolean;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The rebuild of one clipped pixel (step 4) into b, with its slopes ∂b/∂c (row-major 3 × 3, a.e.) when `slopes` is given.
|
|
59
|
+
* `c` are the normalized camera channels, `g` the white-balance gains, `rho` the pixel's ratios.
|
|
60
|
+
*/
|
|
61
|
+
export declare function rebuildClippedPixel(c0: number, c1: number, c2: number, g: ArrayLike<number>, rho: ArrayLike<number>, b: Float64Array | number[], slopes?: Float64Array): void;
|
|
62
|
+
/**
|
|
63
|
+
* Rebuilds the clipped pixels of a white-balanced image u (3 per pixel, in place; becomes b), with the normalized channels
|
|
64
|
+
* c = u/g deciding which channels are clipped.
|
|
65
|
+
*/
|
|
66
|
+
export declare function reconstructHighlightsFromNeighbors(u: Float64Array, width: number, height: number, gains: ArrayLike<number>, fast: boolean): NeighborHighlightReport;
|