@photivra/engine 2.21.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.
Files changed (169) hide show
  1. package/CHANGELOG.md +118 -1
  2. package/CITATION.cff +1 -1
  3. package/README.md +6 -6
  4. package/SECURITY.md +1 -1
  5. package/THIRD_PARTY.md +11 -0
  6. package/dist/capture/c2pa-embed.d.ts +116 -0
  7. package/dist/capture/c2pa-embed.js +493 -0
  8. package/dist/capture/c2pa-embed.js.map +1 -0
  9. package/dist/capture/dng-import.d.ts +73 -8
  10. package/dist/capture/dng-import.js +315 -80
  11. package/dist/capture/dng-import.js.map +1 -1
  12. package/dist/capture/dng-opcodes.d.ts +96 -0
  13. package/dist/capture/dng-opcodes.js +391 -0
  14. package/dist/capture/dng-opcodes.js.map +1 -0
  15. package/dist/capture/dng-profile-maps.d.ts +99 -0
  16. package/dist/capture/dng-profile-maps.js +381 -0
  17. package/dist/capture/dng-profile-maps.js.map +1 -0
  18. package/dist/capture/dng-stage-image.d.ts +23 -0
  19. package/dist/capture/dng-stage-image.js +65 -0
  20. package/dist/capture/dng-stage-image.js.map +1 -0
  21. package/dist/capture/jpeg-xl-tiles.d.ts +22 -0
  22. package/dist/capture/jpeg-xl-tiles.js +151 -0
  23. package/dist/capture/jpeg-xl-tiles.js.map +1 -0
  24. package/dist/capture/lossy-jpeg.d.ts +17 -0
  25. package/dist/capture/lossy-jpeg.js +369 -0
  26. package/dist/capture/lossy-jpeg.js.map +1 -0
  27. package/dist/capture/native-raw-development.d.ts +2 -1
  28. package/dist/capture/native-raw-development.js.map +1 -1
  29. package/dist/color/neighbor-highlight-reconstruction.d.ts +66 -0
  30. package/dist/color/neighbor-highlight-reconstruction.js +234 -0
  31. package/dist/color/neighbor-highlight-reconstruction.js.map +1 -0
  32. package/dist/color/sensor-color-development.d.ts +5 -0
  33. package/dist/color/sensor-color-development.js +7 -1
  34. package/dist/color/sensor-color-development.js.map +1 -1
  35. package/dist/color/spectral-spikiness.d.ts +11 -0
  36. package/dist/color/spectral-spikiness.js +23 -0
  37. package/dist/color/spectral-spikiness.js.map +1 -0
  38. package/dist/core/execution-error.d.ts +21 -0
  39. package/dist/core/execution-error.js +12 -0
  40. package/dist/core/execution-error.js.map +1 -0
  41. package/dist/core/version.d.ts +1 -1
  42. package/dist/core/version.js +1 -1
  43. package/dist/core/version.js.map +1 -1
  44. package/dist/facade/catalogue-lens-signal.d.ts +26 -1
  45. package/dist/facade/catalogue-lens-signal.js +25 -7
  46. package/dist/facade/catalogue-lens-signal.js.map +1 -1
  47. package/dist/facade/diffraction-provider.d.ts +1 -1
  48. package/dist/facade/diffraction-provider.js +4 -4
  49. package/dist/facade/diffraction-provider.js.map +1 -1
  50. package/dist/facade/display-view-gpu-session.js +38 -6
  51. package/dist/facade/display-view-gpu-session.js.map +1 -1
  52. package/dist/facade/display-view-gpu.d.ts +13 -5
  53. package/dist/facade/display-view-gpu.js.map +1 -1
  54. package/dist/facade/display-view-normal.d.ts +15 -0
  55. package/dist/facade/display-view-normal.js +44 -0
  56. package/dist/facade/display-view-normal.js.map +1 -0
  57. package/dist/facade/display-view-rendering.d.ts +97 -0
  58. package/dist/facade/display-view-rendering.js +598 -0
  59. package/dist/facade/display-view-rendering.js.map +1 -0
  60. package/dist/facade/display-view.d.ts +37 -65
  61. package/dist/facade/display-view.js +147 -476
  62. package/dist/facade/display-view.js.map +1 -1
  63. package/dist/facade/expected-signal-setup.js +2 -2
  64. package/dist/facade/expected-signal-setup.js.map +1 -1
  65. package/dist/facade/fast-methods.d.ts +1 -1
  66. package/dist/facade/fast-methods.js +37 -8
  67. package/dist/facade/fast-methods.js.map +1 -1
  68. package/dist/facade/generic-lens-capture.d.ts +1 -1
  69. package/dist/facade/generic-lens-capture.js +1 -1
  70. package/dist/facade/generic-lens-capture.js.map +1 -1
  71. package/dist/facade/image-plane.js +41 -10
  72. package/dist/facade/image-plane.js.map +1 -1
  73. package/dist/facade/on-demand-kits.d.ts +14 -0
  74. package/dist/facade/on-demand-kits.js +36 -0
  75. package/dist/facade/on-demand-kits.js.map +1 -0
  76. package/dist/facade/opt-in-kit.d.ts +9 -0
  77. package/dist/facade/opt-in-kit.js +11 -0
  78. package/dist/facade/opt-in-kit.js.map +1 -0
  79. package/dist/facade/quality-kit.d.ts +21 -0
  80. package/dist/facade/quality-kit.js +23 -0
  81. package/dist/facade/quality-kit.js.map +1 -0
  82. package/dist/facade/quality-paths.d.ts +22 -0
  83. package/dist/facade/quality-paths.js +44 -0
  84. package/dist/facade/quality-paths.js.map +1 -0
  85. package/dist/facade/scene-radiance.d.ts +18 -2
  86. package/dist/facade/scene-radiance.js +6 -4
  87. package/dist/facade/scene-radiance.js.map +1 -1
  88. package/dist/facade/simulate-capture.d.ts +32 -13
  89. package/dist/facade/simulate-capture.js +162 -69
  90. package/dist/facade/simulate-capture.js.map +1 -1
  91. package/dist/facade/simulate-display-view.d.ts +10 -12
  92. package/dist/facade/simulate-display-view.js +57 -48
  93. package/dist/facade/simulate-display-view.js.map +1 -1
  94. package/dist/gpu/display-view-gpu-renderer.d.ts +43 -0
  95. package/dist/gpu/display-view-gpu-renderer.js +134 -0
  96. package/dist/gpu/display-view-gpu-renderer.js.map +1 -0
  97. package/dist/gpu/display-view-image-material-module.d.ts +3 -2
  98. package/dist/gpu/display-view-image-material-module.js +25 -3
  99. package/dist/gpu/display-view-image-material-module.js.map +1 -1
  100. package/dist/gpu/display-view-image-quality.d.ts +43 -1
  101. package/dist/gpu/display-view-image-quality.js +256 -11
  102. package/dist/gpu/display-view-image-quality.js.map +1 -1
  103. package/dist/gpu/display-view-quality-gpu.d.ts +13 -64
  104. package/dist/gpu/display-view-quality-gpu.js +60 -249
  105. package/dist/gpu/display-view-quality-gpu.js.map +1 -1
  106. package/dist/gpu/display-view-speed-gpu.d.ts +16 -16
  107. package/dist/gpu/display-view-speed-gpu.js +50 -12
  108. package/dist/gpu/display-view-speed-gpu.js.map +1 -1
  109. package/dist/gpu/image-kernel-accelerator.js +3 -0
  110. package/dist/gpu/image-kernel-accelerator.js.map +1 -1
  111. package/dist/gpu/image-kernel-execution.d.ts +2 -13
  112. package/dist/gpu/image-kernel-execution.js +2 -10
  113. package/dist/gpu/image-kernel-execution.js.map +1 -1
  114. package/dist/gpu/wgsl-display-view-coupled-stub.d.ts +8 -0
  115. package/dist/gpu/wgsl-display-view-coupled-stub.js +21 -0
  116. package/dist/gpu/wgsl-display-view-coupled-stub.js.map +1 -0
  117. package/dist/gpu/wgsl-display-view-coupled.d.ts +88 -0
  118. package/dist/gpu/wgsl-display-view-coupled.js +353 -0
  119. package/dist/gpu/wgsl-display-view-coupled.js.map +1 -0
  120. package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +4 -9
  121. package/dist/gpu/wgsl-display-view-quality-kernel.js +109 -111
  122. package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -1
  123. package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +1 -41
  124. package/dist/gpu/wgsl-display-view-speed-kernel.js +71 -8
  125. package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -1
  126. package/dist/index.d.ts +11 -3
  127. package/dist/index.js +9 -1
  128. package/dist/index.js.map +1 -1
  129. package/dist/output/camera-channel-response.d.ts +50 -0
  130. package/dist/output/camera-channel-response.js +69 -0
  131. package/dist/output/camera-channel-response.js.map +1 -0
  132. package/dist/output/native-capture-sdr.js +5 -2
  133. package/dist/output/native-capture-sdr.js.map +1 -1
  134. package/dist/output/sdr-rendering.d.ts +18 -1
  135. package/dist/output/sdr-rendering.js +39 -2
  136. package/dist/output/sdr-rendering.js.map +1 -1
  137. package/dist/sensor/native-sensor-report.d.ts +10 -0
  138. package/dist/sensor/native-sensor-report.js +16 -0
  139. package/dist/sensor/native-sensor-report.js.map +1 -0
  140. package/dist/sensor/sensor-characteristics.d.ts +81 -13
  141. package/dist/sensor/sensor-characteristics.js +10 -6
  142. package/dist/sensor/sensor-characteristics.js.map +1 -1
  143. package/docs/API_REFERENCE.md +117 -4
  144. package/docs/QUICK_START.md +37 -8
  145. package/docs/USAGE.md +104 -22
  146. package/docs/api/capture-c2pa-embed.md +177 -0
  147. package/docs/api/capture-dng-import.md +86 -10
  148. package/docs/api/capture-dng-opcodes.md +93 -0
  149. package/docs/api/capture-dng-profile-maps.md +141 -0
  150. package/docs/api/capture-dng-stage-image.md +43 -0
  151. package/docs/api/capture-jpeg-xl-tiles.md +33 -0
  152. package/docs/api/capture-lossy-jpeg.md +41 -0
  153. package/docs/api/capture-native-raw-development.md +2 -1
  154. package/docs/api/core-execution-error.md +43 -0
  155. package/docs/api/core-version.md +1 -1
  156. package/docs/api/exports.json +255 -5
  157. package/docs/api/facade-display-view-gpu.md +5 -2
  158. package/docs/api/facade-display-view.md +11 -15
  159. package/docs/api/facade-fast-methods.md +38 -9
  160. package/docs/api/facade-quality-paths.md +24 -0
  161. package/docs/api/facade-scene-radiance.md +1 -1
  162. package/docs/api/facade-simulate-capture.md +24 -7
  163. package/docs/api/facade-simulate-display-view.md +10 -12
  164. package/docs/api/gpu-image-kernel-execution.md +0 -36
  165. package/docs/api/output-camera-channel-response.md +55 -0
  166. package/docs/api/output-sdr-rendering.md +6 -1
  167. package/docs/api/sensor-sensor-characteristics.md +54 -2
  168. package/llms.txt +1 -0
  169. package/package.json +6 -5
@@ -26,8 +26,7 @@ export interface PreparedDisplayViewRenderOptions {
26
26
  */
27
27
  export interface PreparedDisplayView {
28
28
  /**
29
- * Renders a view of the prepared request. Renders may run concurrently; they share no state except read-only setup and the
30
- * realm's AHD correction states, which never change a byte (docs/DISPLAY_VIEW.md, "AHD at low signal"). With `gpu: "auto"`
29
+ * Renders a view of the prepared request. Renders may run concurrently; they share no state except read-only setup. With `gpu: "auto"`
31
30
  * or `"require"` (#481) GPU renders of one prepared view run one at a time on its device, and `diagnostics.fast.execution`
32
31
  * says whether the GPU or the CPU reference rendered the view, and why.
33
32
  */
@@ -39,22 +38,21 @@ export interface PreparedDisplayView {
39
38
  */
40
39
  dispose(): void;
41
40
  /**
42
- * 2.10 (#447): the key of this request's AHD low-signal correction states, or null when the request has no AHD
43
- * (`output.demosaic` other than "ahd"). Every input of the key is fixed when the request is prepared; two prepared views
44
- * with the same key read the same states.
41
+ * 2.10 (#447), deprecated in 2.22.0: was the key of this request's AHD low-signal correction states. The view has no such
42
+ * states since 2.22.0 (docs/DISPLAY_VIEW.md, "AHD at low signal"), so this returns null for every request.
43
+ * @deprecated Since 2.22.0: always null. Removed in 3.0.0.
45
44
  */
46
45
  correctionKey(): string | null;
47
46
  /**
48
- * 2.10 (#447): the grid keys of every correction state a render of `view` reads (ascending, whether or not this realm holds
49
- * them), found by a render of the view's region that records the states instead of computing them. No image is returned;
50
- * it costs about one render whose states are all held. Fails with an InvalidConfigurationError when the request has no AHD.
47
+ * 2.10 (#447), deprecated in 2.22.0: was the grid keys of the correction states a render of `view` read. Since 2.22.0 it checks
48
+ * `view` as `render` does and returns `{ key: "", gridKeys }` with no grid keys, for every request; it renders nothing.
49
+ * @deprecated Since 2.22.0: returns no grid keys. Removed in 3.0.0.
51
50
  */
52
51
  collectCorrectionStates(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateKeys>;
53
52
  /**
54
- * 2.10 (#447): computes the correction states of `gridKeys` (from `collectCorrectionStates`, or a share of them) as a render
55
- * would, stores them in this realm's cache and returns their values, for {@link bindDisplayViewCorrectionStates} in
56
- * another realm. States this realm holds are read, not computed. Yields and honours `signal` like `render`. Fails with an
57
- * InvalidConfigurationError when the request has no AHD or a grid key is out of range.
53
+ * 2.10 (#447), deprecated in 2.22.0: computed correction states. Since 2.22.0 it checks that `gridKeys` is an Int32Array of
54
+ * grid keys (integers in [0, 97³)) and returns `{ key: "", gridKeys, values }` with no states, for every request; it computes nothing.
55
+ * @deprecated Since 2.22.0: returns no states. Removed in 3.0.0.
58
56
  */
59
57
  computeCorrectionStates(gridKeys: Int32Array, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateSet>;
60
58
  }
@@ -1,10 +1,4 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- /**
3
- * The public entry point of the display view (`simulateDisplayView`) and its renderer. `simulate-capture.ts` resolves the
4
- * request (`runCapture`) and calls the renderer it is given, so a bundle that imports only `simulateCapture` or
5
- * `simulateIdealReference` does not contain the display view (`display-view.ts`) or the portable evaluations it uses.
6
- * The design and its error analysis are in docs/DISPLAY_VIEW.md.
7
- */
8
2
  import { ENGINE_API_VERSION } from "../core/version.js";
9
3
  import { resolvePortableColorTemperatureWhiteBalance } from "../color/white-balance.js";
10
4
  import { resolveCaptureColorModel } from "../color/capture-color.js";
@@ -13,9 +7,10 @@ import { buildExpectedSignalInput } from "./expected-signal-setup.js";
13
7
  import { resolveSensorReadoutRegime } from "../sensor/raw-readout.js";
14
8
  import { resolvePortableChartScene } from "./chart-scenes.js";
15
9
  import { resolvePortableCaptureIlluminant, calculateIlluminantIrradianceScale } from "./scene-radiance.js";
16
- import { ahdCandidateKernels, computeDisplayViewCorrectionStates, createDisplayViewExpectedSignal, displayViewCorrectionKey, renderDisplayView, EXACT_AREA_MEAN_MAX_PIXELS } from "./display-view.js";
10
+ import { ahdCandidateKernels, checkDeprecatedGridKeys, createDisplayViewExpectedSignal, renderDisplayView, EXACT_AREA_MEAN_MAX_PIXELS } from "./display-view.js";
17
11
  import { runCapture, apertureNodeOffsets, bilinearPhaseProfiles, clockMs, fail, sceneIlluminantWhiteBalance, CAMERA_TO_XYZ, CHANNELS, DARK_CURRENT_ELECTRONS_PER_SECOND, FACADE_EVIDENCE, SIMULATE_CAPTURE_FACADE_VERSION, DISPLAY_VIEW_WITHOUT_VIEW, allowKeys, parseDisplayViewOption } from "./simulate-capture.js";
18
12
  import { createHostYield } from "./host-yield.js";
13
+ import { qualityKit } from "./on-demand-kits.js";
19
14
  import { createDefocusDiscSiteKernel } from "../optics/defocus-disc-kernel.js";
20
15
  import { cpuDisplayViewExecution, parsePrepareDisplayViewOptions } from "./display-view-gpu.js";
21
16
  export { serializeDisplayViewCorrectionStates, bindDisplayViewCorrectionStates } from "./display-view.js";
@@ -54,7 +49,7 @@ export async function prepareDisplayView(options, prepareOptions) {
54
49
  const prepared = await runCapture(options, "display-view", DISPLAY_VIEW_WITHOUT_VIEW, (context) => {
55
50
  frameWidth = context.width;
56
51
  frameHeight = context.height;
57
- return Promise.resolve(prepareView(context));
52
+ return prepareView(context);
58
53
  });
59
54
  // The GPU code is loaded only when a GPU mode asks for it, so bundles on the default stay without it.
60
55
  const session = gpuOptions.gpu === "off" ? null :
@@ -70,8 +65,6 @@ export async function prepareDisplayView(options, prepareOptions) {
70
65
  checkAbort();
71
66
  return { started, viewStarted, checkAbort, yieldControl: createHostYield().yieldControl, signal };
72
67
  };
73
- const correctionOf = (caller) => prepared.correction ??
74
- fail(caller + ": the prepared request has no AHD low-signal correction (it applies with output.demosaic \"ahd\").");
75
68
  const handle = Object.freeze({
76
69
  async render(view, renderOptions) {
77
70
  const run = runOf(renderOptions);
@@ -79,15 +72,27 @@ export async function prepareDisplayView(options, prepareOptions) {
79
72
  return await prepared.render(parsed, run, undefined, session);
80
73
  },
81
74
  dispose() { session?.dispose(); },
82
- correctionKey() { return prepared.correction ? displayViewCorrectionKey(prepared.correction) : null; },
83
- async collectCorrectionStates(view, renderOptions) {
84
- const run = runOf(renderOptions), correction = correctionOf("collectCorrectionStates");
85
- const parsed = parseDisplayViewOption(view, frameWidth, frameHeight);
86
- return { key: displayViewCorrectionKey(correction), gridKeys: await prepared.collect(parsed, run) };
75
+ // Deprecated since 2.22.0 (no correction states); kept until 3.0.0.
76
+ correctionKey() { return null; },
77
+ collectCorrectionStates(view, renderOptions) {
78
+ try {
79
+ runOf(renderOptions);
80
+ parseDisplayViewOption(view, frameWidth, frameHeight);
81
+ return Promise.resolve({ key: "", gridKeys: new Int32Array(0) });
82
+ }
83
+ catch (error) {
84
+ return Promise.reject(error);
85
+ }
87
86
  },
88
- async computeCorrectionStates(gridKeys, renderOptions) {
89
- const run = runOf(renderOptions), correction = correctionOf("computeCorrectionStates");
90
- return await computeDisplayViewCorrectionStates({ ...correction, yieldControl: run.yieldControl, checkAbort: run.checkAbort }, gridKeys);
87
+ computeCorrectionStates(gridKeys, renderOptions) {
88
+ try {
89
+ runOf(renderOptions);
90
+ checkDeprecatedGridKeys(gridKeys, "computeCorrectionStates");
91
+ return Promise.resolve({ key: "", gridKeys: new Int32Array(0), values: new Float64Array(0) });
92
+ }
93
+ catch (error) {
94
+ return Promise.reject(error);
95
+ }
91
96
  }
92
97
  });
93
98
  PREPARED_INTERNALS.set(handle, async (view, renderOptions) => {
@@ -120,15 +125,14 @@ export async function simulateDisplayViewWithInternals(options, view) {
120
125
  return { result, internals: internals.value, signal: internals.signal, setup: internals.setup, signalInput: internals.signalInput };
121
126
  }
122
127
  /**
123
- * AHD low-signal correction (display view): draws per flat-neighbourhood state, and the pixel noise (linear light) above which it
124
- * applies. 2.20.0: 2048 draws are its fast method (`output.demosaic.ahd`, the view's default); exact takes 4× the draws (half
125
- * the states' common offset) at the same threshold (owner decision 2026-11-09).
128
+ * 2.22.0: the measured shift of the AHD view's expected colour that the removed low-signal correction used to cancel, in 8-bit
129
+ * codes (mean over a centred 32 × 32 block, f/8; see docs/DISPLAY_VIEW.md, "AHD at low signal"), reported in `view.demosaic`.
126
130
  */
127
- const DISPLAY_VIEW_AHD_CORRECTION_DRAWS = [8192, 2048], DISPLAY_VIEW_AHD_CORRECTION_THRESHOLD = 0.01;
131
+ const AHD_LOW_SIGNAL_BIAS_CODES = { phone1p4umIso6400Red: -4, fullFrame6umIso6400MaxAbs: 0.3, appRequest6umIso400MaxAbs: 0.01 };
128
132
  /** Renders the display view of a resolved request (the last step of `runCapture` for "display-view"). */
129
133
  async function renderDisplayViewResult(context, viewInternals) {
130
134
  const viewStarted = clockMs();
131
- return await prepareView(context).render(context.parsedView, { started: context.started, viewStarted, checkAbort: context.checkAbort, yieldControl: context.yieldControl }, viewInternals);
135
+ return await (await prepareView(context)).render(context.parsedView, { started: context.started, viewStarted, checkAbort: context.checkAbort, yieldControl: context.yieldControl }, viewInternals);
132
136
  }
133
137
  /**
134
138
  * Internal (#387): the part of a display view that depends only on the request, done once (the portable illuminant, chart and
@@ -136,7 +140,7 @@ async function renderDisplayViewResult(context, viewInternals) {
136
140
  * matrix). The returned function renders one view from it; it keeps no state between renders (each has its own expected-
137
141
  * signal caches, lookup count and assumptions), so its results are those of separate calls.
138
142
  */
139
- function prepareView(context) {
143
+ async function prepareView(context) {
140
144
  const { ahd, antiAliasing, aspect, axisChannelResponse, boxSamples, buildProvider, callerScene, chart, materialLayers, chartReport, chartSize, diffraction, diffractionPsf, fNumber, focalLengthMm, focusDistanceM, height, highlightMode, exposureGain, illuminanceLux, illuminant, illuminantOption, imagingArea, intentOf, metresPerFrameUnit, noiseSeed, outputOptions, pitch, preset, provider, regimeByChannel, resolvedIso, isoReport, standardExposureDeviationStops, standardExposureIlluminanceLux, greyCardDeviationStops, metering, sceneOption, scenePreset, shutterSeconds, subjectDistanceM, toneCurve, whiteBalanceOption, whiteBalanceState, width, margin, mode, nativeHeight, nativeWidth, sourceSha256 } = context;
141
145
  const kelvinInput = context.kelvinWhiteBalanceInput;
142
146
  // The engine's illuminant formulas (Planckian, CIE A, daylight locus) evaluated with the portable power and e^x − 1, so
@@ -191,40 +195,38 @@ function prepareView(context) {
191
195
  demosaicTable[phase.phaseY * 2 + phase.phaseX] = CHANNELS.map((c) => phase.profile.kernels.find((k) => k.outputChannelId === c).contributions
192
196
  .map((t) => ({ dx: t.offsetX, dy: t.offsetY, weight: t.weight })));
193
197
  const viewIntent = intentOf(viewWhiteBalanceState), viewGains = viewIntent ? [viewIntent.channelGains.red, viewIntent.channelGains.green, viewIntent.channelGains.blue] : null;
194
- const colour = prepareSensorColorDevelopment(CAMERA_TO_XYZ, viewGains, highlightMode);
198
+ const colour = prepareSensorColorDevelopment(CAMERA_TO_XYZ, viewGains, highlightMode === "reconstruct-neighbors" ? "clip" : highlightMode);
195
199
  const toSrgb = resolveCaptureColorModel().xyzToCameraRgb, m = colour.cameraToXyz;
196
200
  const matrix = [0, 1, 2].map((r) => [0, 1, 2].map((c) => toSrgb[r][0] * m[0][c] + toSrgb[r][1] * m[1][c] + toSrgb[r][2] * m[2][c]));
197
201
  // Reach of a footprint's pixels into the scene, in sites: the demosaic (1), the largest query offset and the kernel radius.
198
202
  const reachSites = (ahd ? 3 : 1) + Math.ceil(Math.max(0, ...offsets.map((o) => Math.max(Math.abs(o.x), Math.abs(o.y))))) + (kernels ? kernels.radius : 0) + (largeDefocus ? largeDefocus.radius : 0);
199
- // The inputs of the AHD correction states (fixed here, so the correction key is too; #447).
200
203
  const gains = colour.appliedGains, clipLevel = Math.min(...colour.appliedGains), viewToneCurve = toneCurve;
201
- const ahdFast = +context.viewFast.ahd, correctionDraws = DISPLAY_VIEW_AHD_CORRECTION_DRAWS[ahdFast], correctionThreshold = DISPLAY_VIEW_AHD_CORRECTION_THRESHOLD;
202
- const ahdCorrection = ahd ? { labMatrix: CAMERA_TO_XYZ.map((row) => row.map((value, c) => value * (viewGains ? viewGains[c] : 1))), drawsPerState: correctionDraws,
203
- thresholdVariance: correctionThreshold * correctionThreshold } : undefined;
204
+ // #593, #601: the coupled rendering steps (luminance curves, reconstruct, desaturation), with the fast rules when the request is fast.
205
+ const coupledRendering = toneCurve === "extended-reinhard-luminance" || toneCurve === "naka-rushton-luminance" || highlightMode === "reconstruct" || highlightMode === "reconstruct-neighbors" || context.gamutHandling === "desaturate-to-luminance";
206
+ const rendering = coupledRendering ? { toneCurve, ...(outputOptions.toneCurveParameters === undefined ? {} : { toneCurveParameters: outputOptions.toneCurveParameters }),
207
+ highlightMode, gamutHandling: context.gamutHandling, fast: context.viewFast.rendering } : undefined;
208
+ // The coupled steps' module is loaded only for a view that asks for them (the Quality kit, #594; the default path never imports it).
209
+ const coupled = rendering ? (await qualityKit.load()).createDisplayViewCoupledRendering(rendering, colour.appliedGains, Math.min(...colour.appliedGains), matrix) : undefined;
210
+ // #457: AHD's homogeneity metric (the profile's camera → XYZ matrix times the white-balance gains) for its choice on the noise-free mosaic.
211
+ const ahdChoice = ahd ? { labMatrix: CAMERA_TO_XYZ.map((row) => row.map((value, c) => value * (viewGains ? viewGains[c] : 1))) } : undefined;
204
212
  // 2.20.0: a quarter of the samples per axis where the pilot finds no detail is the view's fast sampling; exact samples every pixel fully.
205
213
  const uniformSamplesOf = (k) => context.viewFast.uniformSampling ? Math.max(1, Math.round(k / 4)) : k;
206
214
  const ahdCandidates = ahd ? [0, 1, 2, 3].map((p) => ahdCandidateKernels(p % 2, Math.floor(p / 2))) : undefined;
207
215
  // #491: a fixed-size chart's placement for the GPU material lookup (the provider's chart-local units cu = u·m/h and the surround beyond the chart).
208
216
  const placement = chartSize ? { chartUnitsPerFrameUnit: metresPerFrameUnit / (chartSize.widthM / 2), aspect: chartSize.heightM / chartSize.widthM } : null;
209
- /** The renderer's setup of one view (with `ahdCollect`, a collect pass), and its expected signal. */
210
- const setupOf = (v, { checkAbort, yieldControl }, ahdCollect) => {
217
+ /** The renderer's setup of one view, and its expected signal. */
218
+ const setupOf = (v, { checkAbort, yieldControl }) => {
211
219
  const viewRegion = v.region ?? { x: 0, y: 0, width: v.width, height: v.height };
212
220
  // The native columns the region's windows span, beyond one window's width: a filled band need not be wider (a speed hint).
213
221
  // #563: through the lens (projection, distortion, vignetting, rotation) when the request has them.
214
222
  const signal = (context.lens ?? createDisplayViewExpectedSignal)(signalInput, Math.ceil((viewRegion.width + 2) * nativeWidth / v.width));
215
223
  return { signal, setup: { frameWidth: width, frameHeight: height, margin, nativeWidth, nativeHeight, viewWidth: v.width, viewHeight: v.height,
216
224
  region: viewRegion, samplesPerAxis: v.samplesPerAxis, uniformSamplesPerAxis: uniformSamplesOf(v.samplesPerAxis), reachSites, bitDepth: v.bitDepth, seed: noiseSeed, signal, readout, demosaic: demosaicTable,
217
- ...(ahdCandidates && ahdCorrection ? { candidates: ahdCandidates, ahdCorrection } : {}), ...(ahdCollect ? { ahdCollect } : {}),
218
- gains, clipLevel, matrix, toneCurve: viewToneCurve, yieldControl, checkAbort, gpu: { signalInput, chart: viewChart ?? null, layers: materialLayers ?? null, placement, ...(defocusKernel && !largeDefocus ? { defocusRadius: defocusKernel.radius } : {}) } } };
219
- };
220
- const correction = ahdCorrection ? { seed: noiseSeed, readout, gains, clipLevel, matrix, toneCurve: viewToneCurve, ahdCorrection } : undefined;
221
- const collect = async (v, run) => {
222
- const keys = new Set();
223
- await renderDisplayView(setupOf(v, run, keys).setup);
224
- return Int32Array.from(keys).sort();
225
+ ...(ahdCandidates && ahdChoice ? { candidates: ahdCandidates, ahdChoice } : {}),
226
+ gains, clipLevel, matrix, toneCurve: viewToneCurve, ...(rendering ? { rendering, coupled: coupled } : {}), yieldControl, checkAbort, gpu: { signalInput, chart: viewChart ?? null, layers: materialLayers ?? null, placement, ...(defocusKernel && !largeDefocus ? { defocusRadius: defocusKernel.radius } : {}) } } };
225
227
  };
226
228
  // #492: out of focus the view reads the defocus disc (its kernel in signalInput.kernels); the GPU Quality site pass gathers it (step 2c).
227
- const gpuRequest = { ahd, lens: !!context.lens, ...(viewMixed ? { mixedIllumination: true } : {}), defocus: defocusKernel !== null, ...(largeDefocus ? { largeDefocus: true } : {}), diffraction: diffraction !== undefined, antiAliasing: antiAliasing !== undefined, boxSamples, toneCurve: viewToneCurve,
229
+ const gpuRequest = { ahd, lens: !!context.lens, ...(viewMixed ? { mixedIllumination: true } : {}), defocus: defocusKernel !== null, ...(largeDefocus ? { largeDefocus: true } : {}), diffraction: diffraction !== undefined, antiAliasing: antiAliasing !== undefined, boxSamples, toneCurve: viewToneCurve, ...(highlightMode === "reconstruct" || highlightMode === "reconstruct-neighbors" || context.gamutHandling === "desaturate-to-luminance" ? { coupled: true } : {}),
228
230
  scene: chart ? "chart" : materialLayers ? "material-layers" : callerScene.kind };
229
231
  const render = async (v, run, viewInternals, gpu) => {
230
232
  const { started, viewStarted } = run;
@@ -264,12 +266,11 @@ function prepareView(context) {
264
266
  assume("view.noise", "model", { method: "variance-of-the-area-mean", distribution: "normal" }, "Noise of the mean of the real pixels: the covariance of the weighted sum of independent site noises (shot, dark, read and ADC), with the demosaic correlation (B_c = Σ β², in closed form from the rectangle) and the " +
265
267
  "expected slopes of the clips and the tone curve (Stein's lemma); the variance the linearization misses and the real pixels' output rounding are added per pixel. One correlated normal draw per display pixel, seeded " +
266
268
  "by sensor.noiseSeed: the same statistics as the resized capture, not the same realization.");
267
- assume("view.demosaic", "model", ahd ? { capture: "ahd", view: "ahd-candidates-with-low-signal-correction", correctedPixels: rendered.ahdCorrectedPixelCount,
268
- correctionDrawsPerState: correctionDraws, correctionThresholdLinearStd: correctionThreshold } : { capture: "bilinear", view: "bilinear" }, ahd ? "AHD is non-linear only in its choice between two linear candidates (green along the rows or the columns, red and blue from colour differences). The view propagates both candidates' exact linear statistics " +
269
- "and averages them. Where a sampled pixel's noise exceeds " + correctionThreshold + " (linear light), the choice reacts to the noise and shifts the colour, so the pixel adds the mean " +
270
- "difference between the engine's AHD steps and the two candidates on " + correctionDraws + " drawn noisy flat neighbourhoods (Poisson electrons plus read and ADC noise) with its channel means, " +
271
- "computed once per state of a logarithmic grid (8 steps per octave of the channel means) and interpolated trilinearly, a control variate with no per-pixel sampling noise; " +
272
- "the flat-neighbourhood state is an approximation at edges (docs/DISPLAY_VIEW.md, validation)." :
269
+ assume("view.demosaic", "model", ahd ? { capture: "ahd", view: "ahd-candidates-with-noise-free-choice", lowSignalNoiseChoice: "not-modelled", scientificStatus: "approximation",
270
+ measuredBias8BitCodes: AHD_LOW_SIGNAL_BIAS_CODES } : { capture: "bilinear", view: "bilinear" }, ahd ? "AHD is non-linear only in its choice between two linear candidates (green along the rows or the columns, red and blue from colour differences). The view propagates both candidates' exact linear statistics " +
271
+ "and averages them, or takes the candidate AHD chooses on the noise-free mosaic where the scene decides the choice. An approximation: at a few electrons per site the capture's choice also reacts to the noise " +
272
+ "and shifts its colour, which the view does not model (2.22.0). Measured on a centred 32 × 32 block at f/8: a 1.4 µm sensor at ISO 6400 has its red about 4 8-bit codes above the capture's on average " +
273
+ "(up to about 7 codes in a pixel), a 6 µm sensor at ISO 6400 at most 0.3 code, and the app's 6 µm ISO 400 request at most 0.01 code (docs/DISPLAY_VIEW.md, \"AHD at low signal\")." :
273
274
  "The bilinear demosaic's linear kernels, exactly.");
274
275
  if (defocusKernel) {
275
276
  assume("view.defocus", "model", { kernel: shaped ? (diffraction ? "diffraction-convolved-with-shaped-kernel" : "shaped-kernel") : diffraction ? "diffraction-convolved-with-disc" : "disc", defocusKernelRadiusSites: defocusKernel.radius,
@@ -288,6 +289,14 @@ function prepareView(context) {
288
289
  assume("view.execution", "model", { backend: execution.backend, arithmetic: execution.arithmetic, errorBound: execution.errorBound, adapter: execution.adapter }, "Estimated on the GPU: this view was rendered by the WebGPU float32 display-view renderer, a labelled approximation of the float64 CPU reference within the a-priori " +
289
290
  "error bound reported in diagnostics.fast.execution.errorBound; it is not bit-identical to the reference. The device passed the engine's run-time conformance check first.");
290
291
  }
292
+ if (rendering)
293
+ assume("view.rendering", "model", { toneCurve, highlightMode, gamutHandling: rendering.gamutHandling, method: "coupled-moments",
294
+ luminanceTone: rendering.toneCurve === "extended-reinhard-luminance" || rendering.toneCurve === "naka-rushton-luminance" ? (rendering.fast ? "gauss-hermite-8-in-luminance-else-gauss-legendre-4x16" : "gauss-legendre-4x16-in-luminance") : null,
295
+ chainPointsPerAxis: coupled.chainPoints, fast: rendering.fast, scientificStatus: rendering.fast ? "approximation" : "exact-in-the-limit" }, "The rendering steps that couple a pixel's components act on its normal camera-channel distribution: a luminance tone curve by conditioning each developed component on the luminance " +
296
+ "(closed-form clipped-normal moments for each luminance, integrated over it" + (rendering.fast ? " with an 8-point Gauss–Hermite rule where the luminance stays positive" : " with a composite 4 × 16-point Gauss–Legendre rule") + "); " +
297
+ "highlightMode \"reconstruct\" and the desaturation, where a pixel reaches them, by integrating the whole development chain over its camera channels with a " +
298
+ coupled.chainPoints + "-point-per-axis Gauss–Hermite rule (docs/DISPLAY_VIEW.md, \"Coupled rendering\"). " +
299
+ (rendering.fast ? "The fast rules (the request resolves to fast) are a bounded approximation of the full ones." : "The full rules converge to the exact moments of the view's normal model."));
291
300
  assume("view.source", "model", { rendering: "srgb", format: v.format, ignoredCaptureOutput: ["format", "colorEncoding", "bitDepth", "gamutMapping", "jpegQuantizationStep", "dng", "metadata", "maximumPixels"].filter((k) => outputOptions[k] !== undefined) }, "The view shows the capture's sRGB rendering (its tone curve, white balance and highlight mode); the capture's file-format options do not apply to it.");
292
301
  return Object.freeze({ kind: "display-view", label: "Display view: the full-resolution capture resized to " + v.width + " × " + v.height + " (estimated); not a capture.",
293
302
  facadeVersion: SIMULATE_CAPTURE_FACADE_VERSION, engineApiVersion: ENGINE_API_VERSION,
@@ -299,7 +308,7 @@ function prepareView(context) {
299
308
  illuminant: { id: illuminant.id, description: illuminant.description, illuminanceLux }, distanceM: subjectDistanceM,
300
309
  framedWidthM: 2 * metresPerFrameUnit, framedHeightM: 2 * metresPerFrameUnit * aspect, ...(chartReport ? { chart: chartReport } : {}), sourceSha256 },
301
310
  diagnostics: { sampleCount: rendered.sampleCount, siteEvaluations: rendered.siteCount, sceneLookups: signal.lookups, detailPixelCount: rendered.detailPixelCount,
302
- uniformPixelCount: rendered.uniformPixelCount, ahdCorrectedPixelCount: rendered.ahdCorrectedPixelCount, timingsMs: { view: viewMs, total: Date.now() - started },
311
+ uniformPixelCount: rendered.uniformPixelCount, ahdCorrectedPixelCount: 0, timingsMs: { view: viewMs, total: Date.now() - started },
303
312
  fast: Object.freeze({ ...context.fastReport, assurance: execution.backend === "webgpu-f32" ? "approximation-with-a-priori-bound" : context.fastReport.assurance, execution }),
304
313
  highlight: Object.freeze({ saturatedPixelCount: rendered.saturatedPixelCount, statistic: "expected-value" }) },
305
314
  provenance: { scientificStatus: "approximation", cameraPresetId: preset.presetId, cameraPresetVersion: preset.presetVersion, evidence: [...FACADE_EVIDENCE, ...preset.evidence],
@@ -308,6 +317,6 @@ function prepareView(context) {
308
317
  limitations: ["Estimated display view of the full-resolution capture: its expected value is a stratified Monte Carlo estimate and its noise is drawn from the variance of the area mean, so it has the resized capture's statistics, not its exact pixels; not a capture and not a measurement."] },
309
318
  assumptions: Object.freeze(assumptions.map((a) => Object.freeze(a))) });
310
319
  };
311
- return { render, collect, correction, gpuRequest };
320
+ return { render, gpuRequest };
312
321
  }
313
322
  //# sourceMappingURL=simulate-display-view.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"simulate-display-view.js","sourceRoot":"","sources":["../../src/facade/simulate-display-view.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,2CAA2C,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAmB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,mBAAmB,EAAE,kCAAkC,EAAE,+BAA+B,EAAE,wBAAwB,EAAE,iBAAiB,EAE5I,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,OAAO,EAAE,IAAI,EAAE,2BAA2B,EAAE,aAAa,EAAE,QAAQ,EAAE,iCAAiC,EAAE,eAAe,EACtL,+BAA+B,EAAE,yBAAyB,EAAE,SAAS,EAAE,sBAAsB,EACC,MAAM,uBA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L,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,EAAE,SAAS,EAAE,gBAAyB,EAAE,CAAC,EAAE;YACzH,UAAU,EAAE,EAAE,gBAAgB,EAAE,eAAwB,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE,mBAAmB,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;gBACtL,iBAAiB,EAAE,CAAC,uCAAuC,EAAE,4BAA4B,EAAE,sCAAsC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oCAAoC,EAAE,kCAAkC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACnO,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,+BAA+B,EAAE,wBAAwB,CAAC;gBAC3H,WAAW,EAAE,CAAC,kRAAkR,CAAC,EAAE;YACrS,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AACrD,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The public entry point of the display view (`simulateDisplayView`) and its renderer. `simulate-capture.ts` resolves the\n * request (`runCapture`) and calls the renderer it is given, so a bundle that imports only `simulateCapture` or\n * `simulateIdealReference` does not contain the display view (`display-view.ts`) or the portable evaluations it uses.\n * The design and its error analysis are in docs/DISPLAY_VIEW.md.\n */\n\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { resolvePortableColorTemperatureWhiteBalance } from \"../color/white-balance.js\";\nimport { resolveCaptureColorModel } from \"../color/capture-color.js\";\nimport { prepareSensorColorDevelopment } from \"../color/sensor-color-development.js\";\nimport { buildExpectedSignalInput } from \"./expected-signal-setup.js\";\nimport type { DisplayViewExpectedSignalInput } from \"./expected-signal.js\";\nimport { resolveSensorReadoutRegime } from \"../sensor/raw-readout.js\";\nimport { resolvePortableChartScene, type ChartScene } from \"./chart-scenes.js\";\nimport { resolvePortableCaptureIlluminant, calculateIlluminantIrradianceScale } from \"./scene-radiance.js\";\nimport { ahdCandidateKernels, computeDisplayViewCorrectionStates, createDisplayViewExpectedSignal, displayViewCorrectionKey, renderDisplayView, type DisplayViewChannelReadout,\n type DisplayViewCorrectionSetup, type DisplayViewCorrectionStateKeys, type DisplayViewCorrectionStateSet, type DisplayViewExpectedSignal, type DisplayViewRenderResult, type DisplayViewSetup,\n EXACT_AREA_MEAN_MAX_PIXELS } from \"./display-view.js\";\nimport { runCapture, apertureNodeOffsets, bilinearPhaseProfiles, clockMs, fail, sceneIlluminantWhiteBalance, CAMERA_TO_XYZ, CHANNELS, DARK_CURRENT_ELECTRONS_PER_SECOND, FACADE_EVIDENCE,\n SIMULATE_CAPTURE_FACADE_VERSION, DISPLAY_VIEW_WITHOUT_VIEW, allowKeys, parseDisplayViewOption, type DisplayViewResult, type DisplayViewRunContext, type ParsedDisplayView,\n type SimulateCaptureAssumption, type SimulateCaptureOptions, type SimulateDisplayViewOptions } from \"./simulate-capture.js\";\nimport { createHostYield } from \"./host-yield.js\";\nimport { createDefocusDiscSiteKernel } from \"../optics/defocus-disc-kernel.js\";\nimport { cpuDisplayViewExecution, parsePrepareDisplayViewOptions, type DisplayViewExecution, type DisplayViewGpuRequest, type PrepareDisplayViewOptions } from \"./display-view-gpu.js\";\nimport type { DisplayViewGpuSession } from \"./display-view-gpu-session.js\";\n\nexport { serializeDisplayViewCorrectionStates, bindDisplayViewCorrectionStates, type DisplayViewCorrectionStateKeys, type DisplayViewCorrectionStateSet } from \"./display-view.js\";\n\n/**\n * The display view of a capture request: the image the real full-resolution capture (`simulateCapture(options)`) would\n * give after it is resized to `view.width` × `view.height` by area averaging in linear light, estimated at a cost that\n * follows the display pixels, not the capture's. Optics (lens diffraction, the anti-aliasing filter, the pixel aperture)\n * act at the real pixel pitch; the colour mosaic, demosaic and development are those of the real pixels; the noise is\n * that of the average of the real pixels, demosaic correlation included; exposure, white balance and tone are the\n * capture's. The result is labelled `kind: \"display-view\"`; it is not a capture.\n * @see docs/DISPLAY_VIEW.md and docs/QUICK_START.md, \"Display view\".\n */\nexport async function simulateDisplayView(options: SimulateCaptureOptions, view: SimulateDisplayViewOptions): Promise<DisplayViewResult> {\n return await runCapture(options, \"display-view\", view, (context) => renderDisplayViewResult(context)) as DisplayViewResult;\n}\n/** Options of one {@link PreparedDisplayView} render. */\nexport interface PreparedDisplayViewRenderOptions {\n /** Aborting cancels this render only; the promise rejects with a domain error. The request's own `signal` applies to preparing only. */\n signal?: AbortSignal;\n}\n/**\n * 2.7: a display-view request resolved once (`prepareDisplayView`). `render(view)` gives the same result as\n * `simulateDisplayView(options, view)` for the prepared options, byte for byte (samples, view, exposure, scene, diagnostics\n * and assumptions; only `diagnostics.timingsMs` differ, and they cover the render only), without repeating the request's\n * setup: use it to render one view in many regions, for example on each worker of a progressive display.\n */\nexport interface PreparedDisplayView {\n /**\n * Renders a view of the prepared request. Renders may run concurrently; they share no state except read-only setup and the\n * realm's AHD correction states, which never change a byte (docs/DISPLAY_VIEW.md, \"AHD at low signal\"). With `gpu: \"auto\"`\n * or `\"require\"` (#481) GPU renders of one prepared view run one at a time on its device, and `diagnostics.fast.execution`\n * says whether the GPU or the CPU reference rendered the view, and why.\n */\n render(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewResult>;\n /**\n * 2.11 (#481): releases the WebGPU device the view acquired (none with `gpu: \"off\"`, or when `gpuDevice` gave an accelerator,\n * whose device its owner keeps). Later renders run the CPU reference labelled `fallbackReason: \"disposed\"` (`\"auto\"`) or fail\n * with that reason (`\"require\"`). Idempotent.\n */\n dispose(): void;\n /**\n * 2.10 (#447): the key of this request's AHD low-signal correction states, or null when the request has no AHD\n * (`output.demosaic` other than \"ahd\"). Every input of the key is fixed when the request is prepared; two prepared views\n * with the same key read the same states.\n */\n correctionKey(): string | null;\n /**\n * 2.10 (#447): the grid keys of every correction state a render of `view` reads (ascending, whether or not this realm holds\n * them), found by a render of the view's region that records the states instead of computing them. No image is returned;\n * it costs about one render whose states are all held. Fails with an InvalidConfigurationError when the request has no AHD.\n */\n collectCorrectionStates(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateKeys>;\n /**\n * 2.10 (#447): computes the correction states of `gridKeys` (from `collectCorrectionStates`, or a share of them) as a render\n * would, stores them in this realm's cache and returns their values, for {@link bindDisplayViewCorrectionStates} in\n * another realm. States this realm holds are read, not computed. Yields and honours `signal` like `render`. Fails with an\n * InvalidConfigurationError when the request has no AHD or a grid key is out of range.\n */\n computeCorrectionStates(gridKeys: Int32Array, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateSet>;\n}\n/**\n * 2.7 (#387): resolves a {@link simulateDisplayView} request once, without a view, and returns a handle whose `render(view)`\n * renders its views. The setup it does once (request validation, the camera, lens, scene, chart and illuminant, the channel\n * responses through the environment chain, the diffraction kernels, readout moments, demosaic tables and colour matrix) costs\n * about 0.3–1.3 s per call on a 24 MP request; a region costs only its own pixels. Errors in the request are raised here;\n * errors in the view by `render`.\n *\n * 2.11 (#481): `prepareOptions.gpu` chooses the renderer: `\"off\"` is the CPU reference, today's bytes; `\"auto\"` renders\n * on WebGPU when a conforming device is available and the request is supported, else on the CPU, labelled; `\"require\"` fails\n * instead of falling back (`ImageKernelExecutionError`, acquisition failures here, later ones from `render`). 2.20.0: the default is\n * `\"auto\"` when the request resolves to fast (the view's default) and `\"off\"` with `fast: false`. `gpuDevice` is a\n * WebGPU entry point or an `ImageKernelAccelerator` whose device the view shares; without it the engine acquires one device\n * for the prepared view (the request's `signal` aborts the acquisition) and `dispose()` releases it. The realm's\n * `setWebGpuEnabled(false)` vetoes both GPU modes (`webgpu-disabled`). See docs/DISPLAY_VIEW.md, \"Rendering on the GPU\".\n * @see docs/QUICK_START.md, \"Display view\".\n */\nexport async function prepareDisplayView(options: SimulateCaptureOptions, prepareOptions?: PrepareDisplayViewOptions): Promise<PreparedDisplayView> {\n // 2.20.0: the GPU follows the request's fast (the display view's default is fast): \"auto\" when fast, \"off\" when exact.\n const gpuOptions = parsePrepareDisplayViewOptions(prepareOptions, (options as { fast?: unknown } | null | undefined)?.fast !== false);\n let frameWidth = 0, frameHeight = 0;\n const prepared = await runCapture(options, \"display-view\", DISPLAY_VIEW_WITHOUT_VIEW, (context) => {\n frameWidth = context.width; frameHeight = context.height;\n return Promise.resolve(prepareView(context));\n }) as PreparedViewParts;\n // The GPU code is loaded only when a GPU mode asks for it, so bundles on the default stay without it.\n const session: DisplayViewGpuSession | null = gpuOptions.gpu === \"off\" ? null :\n await (await import(\"./display-view-gpu-session.js\")).openDisplayViewGpuSession(gpuOptions, prepared.gpuRequest, (options as { signal?: AbortSignal }).signal);\n /** One call's start times, cancellation (its own signal) and yielding. */\n const runOf = (renderOptions: PreparedDisplayViewRenderOptions | undefined): ViewRun => {\n const started = Date.now(), viewStarted = clockMs();\n const signal = renderOptions === undefined ? undefined : allowKeys(renderOptions, \"render options\", [\"signal\"]).signal as AbortSignal | undefined;\n if (signal !== undefined && (typeof signal !== \"object\" || signal === null || typeof signal.aborted !== \"boolean\")) fail(\"signal must be an AbortSignal.\");\n const checkAbort = (): void => { if (signal?.aborted) fail(\"simulateCapture aborted.\"); };\n checkAbort();\n return { started, viewStarted, checkAbort, yieldControl: createHostYield().yieldControl, signal };\n };\n const correctionOf = (caller: string): DisplayViewCorrectionSetup => prepared.correction ??\n fail(caller + \": the prepared request has no AHD low-signal correction (it applies with output.demosaic \\\"ahd\\\").\");\n const handle: PreparedDisplayView = Object.freeze({\n async render(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewResult> {\n const run = runOf(renderOptions);\n const parsed = parseDisplayViewOption(view, frameWidth, frameHeight);\n return await prepared.render(parsed, run, undefined, session);\n },\n dispose(): void { session?.dispose(); },\n correctionKey(): string | null { return prepared.correction ? displayViewCorrectionKey(prepared.correction) : null; },\n async collectCorrectionStates(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateKeys> {\n const run = runOf(renderOptions), correction = correctionOf(\"collectCorrectionStates\");\n const parsed = parseDisplayViewOption(view, frameWidth, frameHeight);\n return { key: displayViewCorrectionKey(correction)!, gridKeys: await prepared.collect(parsed, run) };\n },\n async computeCorrectionStates(gridKeys: Int32Array, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateSet> {\n const run = runOf(renderOptions), correction = correctionOf(\"computeCorrectionStates\");\n return await computeDisplayViewCorrectionStates({ ...correction, yieldControl: run.yieldControl, checkAbort: run.checkAbort }, gridKeys);\n }\n });\n PREPARED_INTERNALS.set(handle, async (view, renderOptions) => {\n const internals: ViewInternals = {};\n const result = await prepared.render(parseDisplayViewOption(view, frameWidth, frameHeight), runOf(renderOptions), internals, session);\n return { result, internals: internals.value! };\n });\n return handle;\n}\n/** The internal render of each prepared view (the same render as `render`, keeping its renderer's result). */\nconst PREPARED_INTERNALS = new WeakMap<PreparedDisplayView, (view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions) =>\n Promise<{ result: DisplayViewResult; internals: DisplayViewRenderResult }>>();\n/**\n * Internal (not exported from the package): renders a view of a prepared view as `render` does (the same GPU session and labels)\n * and also returns the renderer's noise-free expected linear values and noise standard deviations, whichever renderer ran (#480's\n * GPU producer, `scripts/lib/display-view-gpu-page.mjs`).\n */\nexport async function renderPreparedDisplayViewWithInternals(prepared: PreparedDisplayView, view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions):\n Promise<{ result: DisplayViewResult; internals: DisplayViewRenderResult }> {\n const render = PREPARED_INTERNALS.get(prepared);\n if (!render) fail(\"renderPreparedDisplayViewWithInternals needs a view returned by prepareDisplayView.\");\n return await render(view, renderOptions);\n}\n/**\n * Internal (not exported from the package): the display view plus its noise-free expected linear values and noise standard\n * deviations, for the validation scripts and tests.\n */\nexport async function simulateDisplayViewWithInternals(options: SimulateCaptureOptions, view: SimulateDisplayViewOptions):\n Promise<{ result: DisplayViewResult; internals: DisplayViewRenderResult; signal: DisplayViewExpectedSignal; setup: DisplayViewSetup; signalInput: DisplayViewExpectedSignalInput }> {\n const internals: ViewInternals = {};\n const result = await runCapture(options, \"display-view\", view, (context) => renderDisplayViewResult(context, internals)) as DisplayViewResult;\n return { result, internals: internals.value!, signal: internals.signal!, setup: internals.setup!, signalInput: internals.signalInput! };\n}\n\n/**\n * AHD low-signal correction (display view): draws per flat-neighbourhood state, and the pixel noise (linear light) above which it\n * applies. 2.20.0: 2048 draws are its fast method (`output.demosaic.ahd`, the view's default); exact takes 4× the draws (half\n * the states' common offset) at the same threshold (owner decision 2026-11-09).\n */\nconst DISPLAY_VIEW_AHD_CORRECTION_DRAWS = [8192, 2048], DISPLAY_VIEW_AHD_CORRECTION_THRESHOLD = 0.01;\n\ntype ViewInternals = { value?: DisplayViewRenderResult; signal?: DisplayViewExpectedSignal;\n /** #478: the render's setup and the expected signal's input, for the GPU display view's tests. */\n setup?: DisplayViewSetup; signalInput?: DisplayViewExpectedSignalInput };\n/** What one render of a prepared view needs from its call: its start times, cancellation and yielding. */\ninterface ViewRun { started: number; viewStarted: number; checkAbort: () => void; yieldControl: () => Promise<void>; signal?: AbortSignal | undefined }\ntype RenderPreparedView = (view: ParsedDisplayView, run: ViewRun, viewInternals?: ViewInternals, gpu?: DisplayViewGpuSession | null) => Promise<DisplayViewResult>;\n/**\n * A prepared request: its render, its collect pass (#447: the grid keys of the correction states a view's region reads) and\n * the inputs of its correction states (undefined without AHD).\n */\ninterface PreparedViewParts {\n render: RenderPreparedView;\n collect(view: ParsedDisplayView, run: ViewRun): Promise<Int32Array>;\n correction: DisplayViewCorrectionSetup | undefined;\n /** #481: what a GPU renderer is asked to support. */\n gpuRequest: DisplayViewGpuRequest;\n}\n\n/** Renders the display view of a resolved request (the last step of `runCapture` for \"display-view\"). */\nasync function renderDisplayViewResult(context: DisplayViewRunContext, viewInternals?: ViewInternals): Promise<DisplayViewResult> {\n const viewStarted = clockMs();\n return await prepareView(context).render(context.parsedView!, { started: context.started, viewStarted, checkAbort: context.checkAbort, yieldControl: context.yieldControl }, viewInternals);\n}\n\n/**\n * Internal (#387): the part of a display view that depends only on the request, done once (the portable illuminant, chart and\n * white balance, the channel responses, query offsets, diffraction kernels, readout moments, demosaic tables and colour\n * matrix). The returned function renders one view from it; it keeps no state between renders (each has its own expected-\n * signal caches, lookup count and assumptions), so its results are those of separate calls.\n */\nfunction prepareView(context: DisplayViewRunContext): PreparedViewParts {\n const { ahd, antiAliasing, aspect, axisChannelResponse, boxSamples, buildProvider, callerScene, chart, materialLayers, chartReport, chartSize, diffraction, diffractionPsf, fNumber, focalLengthMm, focusDistanceM, height, highlightMode, exposureGain, illuminanceLux, illuminant, illuminantOption, imagingArea, intentOf, metresPerFrameUnit, noiseSeed, outputOptions, pitch, preset, provider, regimeByChannel, resolvedIso, isoReport, standardExposureDeviationStops, standardExposureIlluminanceLux, greyCardDeviationStops, metering, sceneOption, scenePreset, shutterSeconds, subjectDistanceM, toneCurve, whiteBalanceOption, whiteBalanceState, width, margin, mode, nativeHeight, nativeWidth, sourceSha256 } = context;\n const kelvinInput = context.kelvinWhiteBalanceInput;\n // The engine's illuminant formulas (Planckian, CIE A, daylight locus) evaluated with the portable power and e^x − 1, so\n // the view's radiances, irradiance scale and scene-illuminant white balance have the same bits in every JavaScript\n // engine; they differ from the capture's own by at most a few ulps (docs/DISPLAY_VIEW.md, \"Same bytes in every engine\").\n // #550: mixed lighting resolved with the same portable formulas; its strongest source at the frame center stands in for the illuminant.\n const viewMixed = context.mixedIllumination?.(resolvePortableCaptureIlluminant), viewStrongest = viewMixed?.sources[viewMixed.center.strongestSource];\n const viewIlluminant = viewStrongest ? viewStrongest.illuminant : resolvePortableCaptureIlluminant(illuminantOption);\n const viewIrradianceScale = viewStrongest ? viewStrongest.irradianceScale : calculateIlluminantIrradianceScale(viewIlluminant.shape, illuminanceLux);\n const stillViewProvider = buildProvider(viewIlluminant, viewIrradianceScale, viewMixed);\n // #551: a moving subject is read at each temporal midpoint as radiance (no material tables).\n const viewProvider = context.movingScene ? context.movingScene(stillViewProvider, viewIrradianceScale, (nm) => viewIlluminant.shape.evaluate(nm), viewMixed) : stillViewProvider;\n const viewWhiteBalanceState = whiteBalanceOption === \"scene-illuminant\" ? sceneIlluminantWhiteBalance(viewIlluminant) : kelvinInput ? resolvePortableColorTemperatureWhiteBalance(kelvinInput) : whiteBalanceState;\n // The chart's materials likewise (a step wedge's geometric levels use the portable power); same geometry and order.\n const viewChart = chart ? resolvePortableChartScene({ scene: sceneOption as ChartScene, aspect: chartSize ? chartSize.heightM / chartSize.widthM : aspect }) : undefined;\n if (chart && viewChart!.materials.length !== chart.materials.length) fail(\"simulateDisplayView: the chart's materials could not be resolved portably.\");\n const { electronsPerRadiance, wavelengths, relativePerElectron } = axisChannelResponse(\"simulateDisplayView\");\n const perNode = CHANNELS.map((c) => Float64Array.from(wavelengths, (nm) => electronsPerRadiance[c].get(nm) ?? 0)) as [Float64Array, Float64Array, Float64Array];\n // The tabulated expected signal's input (#394: shared with the capture's tabulated RAW path).\n const sceneMaterials = viewChart ? viewChart.materials : callerScene?.kind === \"material-function\" ? callerScene.materials : undefined;\n // Defocus (#492): the geometric disc on the site lattice, combined with the diffraction kernels in the tables (expected-signal-setup.ts).\n // #553: with bokeh options (blades, spherical aberration) the capture built the shaped kernel; it replaces the disc.\n const defocusDisc = context.defocus, defocusKernel = defocusDisc && defocusDisc.diameterSites > 0 ? defocusDisc.siteKernel ?? createDefocusDiscSiteKernel(defocusDisc.diameterSites) : null;\n const shaped = defocusDisc?.siteKernel !== undefined;\n // The combined radius is at most 32 + 512 sites (the diffraction and disc caps), as in the capture. #564: above 64 sites the kernel is\n // convolved by runs after the in-focus signal (expected-signal.ts), the same sums regrouped.\n const diffractionRadius = diffraction ? diffraction.kernelRadiusSamples : 0, combinedRadius = defocusKernel ? diffractionRadius + defocusKernel.radius : diffractionRadius;\n const { offsets, signalInput } = buildExpectedSignalInput({ nativeWidth, nativeHeight, width, wavelengths, perNode, apertureNodes: apertureNodeOffsets(boxSamples), boxSamples,\n antiAliasing, pitch, defocus: defocusKernel, ...(context.lensPsf ? { lensKernels: context.lensPsf.axisKernels(wavelengths) } : {}), diffraction: diffraction ? { radius: diffraction.kernelRadiusSamples, psf: diffractionPsf!.configuration.psf, profileWavelengths: diffraction.profile.axes.wavelengthNm } : undefined,\n materials: sceneMaterials && provider.chartMaterialAt && !context.movingScene ? { materialAt: provider.chartMaterialAt,\n list: [...sceneMaterials.map((m, index) => (m.kind === \"neutral\" ? { neutral: m.reflectance } : { radiance: (nm: number): number => viewProvider.materialRadiance!(index, nm) })),\n ...(chartSize ? [{ neutral: chartSize.surroundReflectance }] : [])],\n whiteRadiance: (nm: number): number => viewIrradianceScale * viewIlluminant.shape.evaluate(nm) / Math.PI } : undefined,\n radianceAt: viewProvider.radianceAt, imageSignalScene: viewProvider.imageSignalScene,\n imagingArea, focalLengthMm, focusDistanceM, subjectDistanceM, metresPerFrameUnit, caller: \"simulateDisplayView\" });\n const kernels = signalInput.kernels, largeDefocus = signalInput.largeKernel;\n // Readout moments per channel: normalized value k·e with variance k²·(e + σ_read²) plus the ADC quantization (1/12 code², times d² before a digital gain d).\n // #556: a development exposure push G multiplies the normalized value before the per-site clip at white: k → G·k and the constant variance → G²·(…).\n // Without a push G = 1, and x·1 = x exactly in IEEE 754 arithmetic, so the moments are bit-identical to those without the push.\n const readout = CHANNELS.map((channel): DisplayViewChannelReadout => {\n const { readoutProfile, regimeId } = regimeByChannel[channel];\n const resolved = resolveSensorReadoutRegime({ profile: readoutProfile as Parameters<typeof resolveSensorReadoutRegime>[0][\"profile\"], regimeId });\n const k = relativePerElectron[channel], digitalGain = resolved.regime.adc.digitalGain ?? 1, gain = resolved.regime.systemConversionGainElectronsPerCode.value;\n const codeSpan = digitalGain / (gain * k), read = resolved.combinedReadNoiseRmsElectrons;\n const quantizationCodes = digitalGain * digitalGain / 12 + (digitalGain === 1 ? 0 : 1 / 12);\n return { perElectron: exposureGain * k, darkElectrons: DARK_CURRENT_ELECTRONS_PER_SECOND * shutterSeconds,\n constantVariance: exposureGain * exposureGain * (k * k * read * read + quantizationCodes / (codeSpan * codeSpan)) };\n }) as [DisplayViewChannelReadout, DisplayViewChannelReadout, DisplayViewChannelReadout];\n const phases = bilinearPhaseProfiles(), demosaicTable: { dx: number; dy: number; weight: number }[][][] = [];\n for (const phase of phases) demosaicTable[phase.phaseY * 2 + phase.phaseX] = CHANNELS.map((c) => phase.profile.kernels.find((k) => k.outputChannelId === c)!.contributions\n .map((t) => ({ dx: t.offsetX, dy: t.offsetY, weight: t.weight })));\n const viewIntent = intentOf(viewWhiteBalanceState), viewGains = viewIntent ? [viewIntent.channelGains.red, viewIntent.channelGains.green, viewIntent.channelGains.blue] : null;\n const colour = prepareSensorColorDevelopment(CAMERA_TO_XYZ as unknown as Parameters<typeof prepareSensorColorDevelopment>[0], viewGains, highlightMode);\n const toSrgb = resolveCaptureColorModel().xyzToCameraRgb, m = colour.cameraToXyz;\n const matrix = [0, 1, 2].map((r) => [0, 1, 2].map((c) => toSrgb[r]![0]! * m[0]![c]! + toSrgb[r]![1]! * m[1]![c]! + toSrgb[r]![2]! * m[2]![c]!));\n // Reach of a footprint's pixels into the scene, in sites: the demosaic (1), the largest query offset and the kernel radius.\n const reachSites = (ahd ? 3 : 1) + Math.ceil(Math.max(0, ...offsets.map((o) => Math.max(Math.abs(o.x), Math.abs(o.y))))) + (kernels ? kernels.radius : 0) + (largeDefocus ? largeDefocus.radius : 0);\n // The inputs of the AHD correction states (fixed here, so the correction key is too; #447).\n const gains = colour.appliedGains as [number, number, number], clipLevel = Math.min(...colour.appliedGains), viewToneCurve = toneCurve as \"identity\" | \"positive-reinhard-per-channel\";\n const ahdFast = +context.viewFast.ahd, correctionDraws = DISPLAY_VIEW_AHD_CORRECTION_DRAWS[ahdFast]!, correctionThreshold = DISPLAY_VIEW_AHD_CORRECTION_THRESHOLD;\n const ahdCorrection = ahd ? { labMatrix: CAMERA_TO_XYZ.map((row) => row.map((value, c) => value * (viewGains ? viewGains[c]! : 1))), drawsPerState: correctionDraws,\n thresholdVariance: correctionThreshold * correctionThreshold } : undefined;\n // 2.20.0: a quarter of the samples per axis where the pilot finds no detail is the view's fast sampling; exact samples every pixel fully.\n const uniformSamplesOf = (k: number): number => context.viewFast.uniformSampling ? Math.max(1, Math.round(k / 4)) : k;\n const ahdCandidates = ahd ? [0, 1, 2, 3].map((p) => ahdCandidateKernels(p % 2, Math.floor(p / 2))) : undefined;\n // #491: a fixed-size chart's placement for the GPU material lookup (the provider's chart-local units cu = u·m/h and the surround beyond the chart).\n const placement = chartSize ? { chartUnitsPerFrameUnit: metresPerFrameUnit / (chartSize.widthM / 2), aspect: chartSize.heightM / chartSize.widthM } : null;\n /** The renderer's setup of one view (with `ahdCollect`, a collect pass), and its expected signal. */\n const setupOf = (v: ParsedDisplayView, { checkAbort, yieldControl }: ViewRun, ahdCollect?: Set<number>): { setup: DisplayViewSetup; signal: DisplayViewExpectedSignal } => {\n const viewRegion = v.region ?? { x: 0, y: 0, width: v.width, height: v.height };\n // The native columns the region's windows span, beyond one window's width: a filled band need not be wider (a speed hint).\n // #563: through the lens (projection, distortion, vignetting, rotation) when the request has them.\n const signal = (context.lens ?? createDisplayViewExpectedSignal)(signalInput, Math.ceil((viewRegion.width + 2) * nativeWidth / v.width));\n return { signal, setup: { frameWidth: width, frameHeight: height, margin, nativeWidth, nativeHeight, viewWidth: v.width, viewHeight: v.height,\n region: viewRegion, samplesPerAxis: v.samplesPerAxis, uniformSamplesPerAxis: uniformSamplesOf(v.samplesPerAxis), reachSites, bitDepth: v.bitDepth, seed: noiseSeed, signal, readout, demosaic: demosaicTable,\n ...(ahdCandidates && ahdCorrection ? { candidates: ahdCandidates, ahdCorrection } : {}), ...(ahdCollect ? { ahdCollect } : {}),\n gains, clipLevel, matrix, toneCurve: viewToneCurve, yieldControl, checkAbort, gpu: { signalInput, chart: viewChart ?? null, layers: materialLayers ?? null, placement, ...(defocusKernel && !largeDefocus ? { defocusRadius: defocusKernel.radius } : {}) } } };\n };\n const correction: DisplayViewCorrectionSetup | undefined = ahdCorrection ? { seed: noiseSeed, readout, gains, clipLevel, matrix, toneCurve: viewToneCurve, ahdCorrection } : undefined;\n const collect = async (v: ParsedDisplayView, run: ViewRun): Promise<Int32Array> => {\n const keys = new Set<number>();\n await renderDisplayView(setupOf(v, run, keys).setup);\n return Int32Array.from(keys).sort();\n };\n // #492: out of focus the view reads the defocus disc (its kernel in signalInput.kernels); the GPU Quality site pass gathers it (step 2c).\n const gpuRequest: DisplayViewGpuRequest = { ahd, lens: !!context.lens, ...(viewMixed ? { mixedIllumination: true } : {}), defocus: defocusKernel !== null, ...(largeDefocus ? { largeDefocus: true } : {}), diffraction: diffraction !== undefined, antiAliasing: antiAliasing !== undefined, boxSamples, toneCurve: viewToneCurve,\n scene: chart ? \"chart\" : materialLayers ? \"material-layers\" : callerScene!.kind };\n const render: RenderPreparedView = async (v, run, viewInternals, gpu) => {\n const { started, viewStarted } = run;\n const assumptions: SimulateCaptureAssumption[] = [...context.assumptions];\n const assume = (id: string, kind: SimulateCaptureAssumption[\"kind\"], value: unknown, explanation: string): void => { assumptions.push({ id, kind, value, explanation }); };\n const { setup, signal } = setupOf(v, run), viewRegion = setup.region;\n // #481: the GPU session renders on the device when it can, else through the CPU reference, and labels which ran.\n const cpu = (): Promise<DisplayViewRenderResult> => renderDisplayView(setup);\n const { rendered, execution }: { rendered: DisplayViewRenderResult; execution: DisplayViewExecution } = gpu ? await gpu.render(setup, run.signal, cpu)\n : { rendered: await cpu(), execution: cpuDisplayViewExecution(\"off\", null, null, null) };\n if (viewInternals) { viewInternals.value = rendered; viewInternals.signal = signal; viewInternals.setup = setup; viewInternals.signalInput = signalInput; }\n const viewMs = clockMs() - viewStarted, scaleX = width / v.width, scaleY = height / v.height;\n assume(\"view.definition\", \"model\", { resampling: \"area-average-linear-light\", width: v.width, height: v.height, frameWidth: width, frameHeight: height, scaleX, scaleY },\n \"The image the full-resolution capture of this request would give after resizing to \" + v.width + \" × \" + v.height + \": each display pixel is the area-weighted mean, in linear light (sRGB samples decoded with the sRGB EOTF), \" +\n \"of the real output pixels its rectangle covers (\" + scaleX + \" × \" + scaleY + \" real pixels), then sRGB-encoded and rounded. The real capture's own samples are rounded to the view's bit depth before averaging.\");\n const uniformSamplesPerAxis = uniformSamplesOf(v.samplesPerAxis);\n const siteSentence = \"the expected electrons of the real sites its demosaic reads are exact at the real pitch (the scene sampled at those sites through the pixel aperture, \" +\n \"anti-aliasing filter and diffraction kernels, with the capture's own query arithmetic, so the colour mosaic and its aliasing are the real sensor's), and the per-site clip at white, the highlight clip, the tone curve \" +\n \"and the clip to [0, 1] act on the pixel's own noise distribution, approximated as normal.\";\n // 2.8 (#393): where a footprint holds at most 25 real pixels (and at most K²), every real pixel of it is evaluated once with its exact weight.\n if (rendered.estimation === \"exact-area-mean\") {\n assume(\"view.estimation\", \"model\", { method: \"exact-area-mean-over-real-pixels\", samplesPerAxis: v.samplesPerAxis, realPixelsPerDisplayPixel: scaleX * scaleY,\n evaluatedRealPixels: rendered.sampleCount },\n \"Each display pixel's expected value is the exact area mean of the real pixels its rectangle covers: every real pixel it touches is evaluated once and weighted by its overlap with the rectangle \" +\n \"(w_j / A, summing to 1), so there is no sampling error. This applies because each rectangle holds \" + scaleX * scaleY + \" real pixels (\" + scaleX + \" × \" + scaleY + \"), at most \" + EXACT_AREA_MEAN_MAX_PIXELS + \" and at most K² = \" + v.samplesPerAxis * v.samplesPerAxis + \"; coarser views use a stratified estimate, which costs less there. \" +\n \"For each real pixel \" + siteSentence);\n } else {\n assume(\"view.estimation\", \"model\", { method: \"stratified-monte-carlo-over-real-pixels\", samplesPerAxis: v.samplesPerAxis, uniformSamplesPerAxis,\n detailPixels: rendered.detailPixelCount, uniformPixels: rendered.uniformPixelCount },\n \"Each display pixel's expected value is the mean over K × K strata of its rectangle, one seeded uniformly jittered real pixel in each, so it is unbiased; the error is zero where the rectangle is uniform \" +\n \"and falls as K^-3/2 at an edge. K = \" + v.samplesPerAxis + \" where a fixed pilot grid over the rectangle (widened by the demosaic, filter and kernel reach) or a neighbouring pixel's grid finds more than one scene value, \" +\n \"K = \" + uniformSamplesPerAxis + \" elsewhere. For each sampled pixel \" + siteSentence);\n }\n assume(\"view.noise\", \"model\", { method: \"variance-of-the-area-mean\", distribution: \"normal\" },\n \"Noise of the mean of the real pixels: the covariance of the weighted sum of independent site noises (shot, dark, read and ADC), with the demosaic correlation (B_c = Σ β², in closed form from the rectangle) and the \" +\n \"expected slopes of the clips and the tone curve (Stein's lemma); the variance the linearization misses and the real pixels' output rounding are added per pixel. One correlated normal draw per display pixel, seeded \" +\n \"by sensor.noiseSeed: the same statistics as the resized capture, not the same realization.\");\n assume(\"view.demosaic\", \"model\", ahd ? { capture: \"ahd\", view: \"ahd-candidates-with-low-signal-correction\", correctedPixels: rendered.ahdCorrectedPixelCount,\n correctionDrawsPerState: correctionDraws, correctionThresholdLinearStd: correctionThreshold } : { capture: \"bilinear\", view: \"bilinear\" },\n ahd ? \"AHD is non-linear only in its choice between two linear candidates (green along the rows or the columns, red and blue from colour differences). The view propagates both candidates' exact linear statistics \" +\n \"and averages them. Where a sampled pixel's noise exceeds \" + correctionThreshold + \" (linear light), the choice reacts to the noise and shifts the colour, so the pixel adds the mean \" +\n \"difference between the engine's AHD steps and the two candidates on \" + correctionDraws + \" drawn noisy flat neighbourhoods (Poisson electrons plus read and ADC noise) with its channel means, \" +\n \"computed once per state of a logarithmic grid (8 steps per octave of the channel means) and interpolated trilinearly, a control variate with no per-pixel sampling noise; \" +\n \"the flat-neighbourhood state is an approximation at edges (docs/DISPLAY_VIEW.md, validation).\" :\n \"The bilinear demosaic's linear kernels, exactly.\");\n if (defocusKernel) {\n assume(\"view.defocus\", \"model\", { kernel: shaped ? (diffraction ? \"diffraction-convolved-with-shaped-kernel\" : \"shaped-kernel\") : diffraction ? \"diffraction-convolved-with-disc\" : \"disc\", defocusKernelRadiusSites: defocusKernel.radius,\n diffractionKernelRadiusSites: diffraction ? diffractionRadius : null, kernelRadiusSites: combinedRadius, scientificStatus: \"approximation\", ...(largeDefocus ? { convolution: \"runs\" } : {}) },\n // #564: the lens.defocus assumption explains the run convolution above 64 sites (convolution: \"runs\").\n \"The expected electrons of each real site read the scene on the site lattice through the defocus \" + (shaped ? \"kernel shaped by the lens (#553; see the lens.defocus assumption; \" : \"disc (\") +\n defocusKernel.diameterSites + \" sites across, a \" + defocusKernel.width + \" × \" +\n defocusKernel.width + \" window), as the capture's convolution does; the estimators then run unchanged on the blurred signal. \" + (diffraction ?\n \"With lens.diffraction each spectral node's kernel is its diffraction kernel convolved with the disc (\" + (2 * combinedRadius + 1) + \" × \" + (2 * combinedRadius + 1) + \" taps): \" +\n \"an approximation, because the PSF of a defocused wave is not the in-focus Airy pattern convolved with a geometric disc.\" :\n \"The disc is the same at every spectral node (geometric optics).\"));\n }\n if (viewMixed) assume(\"view.illumination\", \"model\", { method: \"radiance-at-every-query-point\" },\n \"Mixed lighting (#550): the radiance at every query point, as in the capture (no material tables; exact). Not on the GPU.\");\n if (execution.backend === \"webgpu-f32\") {\n assume(\"view.execution\", \"model\", { backend: execution.backend, arithmetic: execution.arithmetic, errorBound: execution.errorBound, adapter: execution.adapter },\n \"Estimated on the GPU: this view was rendered by the WebGPU float32 display-view renderer, a labelled approximation of the float64 CPU reference within the a-priori \" +\n \"error bound reported in diagnostics.fast.execution.errorBound; it is not bit-identical to the reference. The device passed the engine's run-time conformance check first.\");\n }\n assume(\"view.source\", \"model\", { rendering: \"srgb\", format: v.format, ignoredCaptureOutput: [\"format\", \"colorEncoding\", \"bitDepth\", \"gamutMapping\", \"jpegQuantizationStep\", \"dng\", \"metadata\", \"maximumPixels\"].filter((k) => outputOptions[k] !== undefined) },\n \"The view shows the capture's sRGB rendering (its tone curve, white balance and highlight mode); the capture's file-format options do not apply to it.\");\n return Object.freeze({ kind: \"display-view\" as const, label: \"Display view: the full-resolution capture resized to \" + v.width + \" × \" + v.height + \" (estimated); not a capture.\",\n facadeVersion: SIMULATE_CAPTURE_FACADE_VERSION, engineApiVersion: ENGINE_API_VERSION,\n image: { width: viewRegion.width, height: viewRegion.height, format: v.format, samples: rendered.samples },\n view: { width: v.width, height: v.height, frameWidth: width, frameHeight: height, scaleX, scaleY, samplesPerAxis: v.samplesPerAxis, ...(v.region ? { region: { ...v.region } } : {}) },\n exposure: { mode, settings: { fNumber, shutterSeconds, iso: resolvedIso }, ev100: Math.log2(fNumber ** 2 / shutterSeconds), ...isoReport, standardExposureDeviationStops, standardExposureIlluminanceLux, greyCardDeviationStops, metering },\n sensor: context.sensor,\n scene: { sceneId: chart ? \"chart:\" + chart.preset : callerScene!.sceneId, preset: scenePreset, parameters: (chart ?? callerScene as { parameters?: Readonly<Record<string, unknown>> }).parameters ?? {},\n illuminant: { id: illuminant.id, description: illuminant.description, illuminanceLux }, distanceM: subjectDistanceM,\n framedWidthM: 2 * metresPerFrameUnit, framedHeightM: 2 * metresPerFrameUnit * aspect, ...(chartReport ? { chart: chartReport } : {}), sourceSha256 },\n diagnostics: { sampleCount: rendered.sampleCount, siteEvaluations: rendered.siteCount, sceneLookups: signal.lookups, detailPixelCount: rendered.detailPixelCount,\n uniformPixelCount: rendered.uniformPixelCount, ahdCorrectedPixelCount: rendered.ahdCorrectedPixelCount, timingsMs: { view: viewMs, total: Date.now() - started },\n fast: Object.freeze({ ...context.fastReport, assurance: execution.backend === \"webgpu-f32\" ? \"approximation-with-a-priori-bound\" as const : context.fastReport.assurance, execution }),\n highlight: Object.freeze({ saturatedPixelCount: rendered.saturatedPixelCount, statistic: \"expected-value\" as const }) },\n provenance: { scientificStatus: \"approximation\" as const, cameraPresetId: preset.presetId, cameraPresetVersion: preset.presetVersion, evidence: [...FACADE_EVIDENCE, ...preset.evidence],\n composedContracts: [\"calculateEnvironmentSensorPhotoSignal\", \"resolveSensorReadoutRegime\", \"calculateSiteEffectiveSaturationCode\", ...(diffraction ? [\"createDiffractionLimitedPsfProfile\", \"resolveLensPsfConvolutionKernels\"] : []),\n ...(antiAliasing ? [\"resolveAntiAliasingSpatialKernel\"] : []), \"prepareSensorColorDevelopment\", \"display view estimator\"],\n limitations: [\"Estimated display view of the full-resolution capture: its expected value is a stratified Monte Carlo estimate and its noise is drawn from the variance of the area mean, so it has the resized capture's statistics, not its exact pixels; not a capture and not a measurement.\"] },\n assumptions: Object.freeze(assumptions.map((a) => Object.freeze(a))) });\n };\n return { render, collect, correction, gpuRequest };\n}\n"]}
1
+ {"version":3,"file":"simulate-display-view.js","sourceRoot":"","sources":["../../src/facade/simulate-display-view.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAYtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,2CAA2C,EAAE,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAC;AACrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAmB,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,gCAAgC,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAC3G,OAAO,EAAE,mBAA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CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,OAAO,KAAK,YAAY,CAAC,CAAC,CAAC,mCAA4C,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,CAAC;gBACtL,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,EAAE,SAAS,EAAE,gBAAyB,EAAE,CAAC,EAAE;YACzH,UAAU,EAAE,EAAE,gBAAgB,EAAE,eAAwB,EAAE,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE,mBAAmB,EAAE,MAAM,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC;gBACtL,iBAAiB,EAAE,CAAC,uCAAuC,EAAE,4BAA4B,EAAE,sCAAsC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,oCAAoC,EAAE,kCAAkC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACnO,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,+BAA+B,EAAE,wBAAwB,CAAC;gBAC3H,WAAW,EAAE,CAAC,kRAAkR,CAAC,EAAE;YACrS,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5E,CAAC,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAChC,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * The public entry point of the display view (`simulateDisplayView`) and its renderer. `simulate-capture.ts` resolves the\n * request (`runCapture`) and calls the renderer it is given, so a bundle that imports only `simulateCapture` or\n * `simulateIdealReference` does not contain the display view (`display-view.ts`) or the portable evaluations it uses.\n * The design and its error analysis are in docs/DISPLAY_VIEW.md.\n */\n\n// Types only: the coupled rendering steps (#593, #601) are loaded on demand, when a view asks for them.\nimport type { DisplayViewCoupledRendering, DisplayViewRenderingChoice } from \"./display-view-rendering.js\";\nimport type { SdrToneCurveParameters } from \"../output/sdr-rendering.js\";\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { resolvePortableColorTemperatureWhiteBalance } from \"../color/white-balance.js\";\nimport { resolveCaptureColorModel } from \"../color/capture-color.js\";\nimport { prepareSensorColorDevelopment } from \"../color/sensor-color-development.js\";\nimport { buildExpectedSignalInput } from \"./expected-signal-setup.js\";\nimport type { DisplayViewExpectedSignalInput } from \"./expected-signal.js\";\nimport { resolveSensorReadoutRegime } from \"../sensor/raw-readout.js\";\nimport { resolvePortableChartScene, type ChartScene } from \"./chart-scenes.js\";\nimport { resolvePortableCaptureIlluminant, calculateIlluminantIrradianceScale } from \"./scene-radiance.js\";\nimport { ahdCandidateKernels, checkDeprecatedGridKeys, createDisplayViewExpectedSignal, renderDisplayView, type DisplayViewChannelReadout,\n type DisplayViewCorrectionStateKeys, type DisplayViewCorrectionStateSet, type DisplayViewExpectedSignal, type DisplayViewRenderResult, type DisplayViewSetup,\n EXACT_AREA_MEAN_MAX_PIXELS } from \"./display-view.js\";\nimport { runCapture, apertureNodeOffsets, bilinearPhaseProfiles, clockMs, fail, sceneIlluminantWhiteBalance, CAMERA_TO_XYZ, CHANNELS, DARK_CURRENT_ELECTRONS_PER_SECOND, FACADE_EVIDENCE,\n SIMULATE_CAPTURE_FACADE_VERSION, DISPLAY_VIEW_WITHOUT_VIEW, allowKeys, parseDisplayViewOption, type DisplayViewResult, type DisplayViewRunContext, type ParsedDisplayView,\n type SimulateCaptureAssumption, type SimulateCaptureOptions, type SimulateDisplayViewOptions } from \"./simulate-capture.js\";\nimport { createHostYield } from \"./host-yield.js\";\nimport { qualityKit } from \"./on-demand-kits.js\";\nimport { createDefocusDiscSiteKernel } from \"../optics/defocus-disc-kernel.js\";\nimport { cpuDisplayViewExecution, parsePrepareDisplayViewOptions, type DisplayViewExecution, type DisplayViewGpuRequest, type PrepareDisplayViewOptions } from \"./display-view-gpu.js\";\nimport type { DisplayViewGpuSession } from \"./display-view-gpu-session.js\";\n\nexport { serializeDisplayViewCorrectionStates, bindDisplayViewCorrectionStates, type DisplayViewCorrectionStateKeys, type DisplayViewCorrectionStateSet } from \"./display-view.js\";\n\n/**\n * The display view of a capture request: the image the real full-resolution capture (`simulateCapture(options)`) would\n * give after it is resized to `view.width` × `view.height` by area averaging in linear light, estimated at a cost that\n * follows the display pixels, not the capture's. Optics (lens diffraction, the anti-aliasing filter, the pixel aperture)\n * act at the real pixel pitch; the colour mosaic, demosaic and development are those of the real pixels; the noise is\n * that of the average of the real pixels, demosaic correlation included; exposure, white balance and tone are the\n * capture's. The result is labelled `kind: \"display-view\"`; it is not a capture.\n * @see docs/DISPLAY_VIEW.md and docs/QUICK_START.md, \"Display view\".\n */\nexport async function simulateDisplayView(options: SimulateCaptureOptions, view: SimulateDisplayViewOptions): Promise<DisplayViewResult> {\n return await runCapture(options, \"display-view\", view, (context) => renderDisplayViewResult(context)) as DisplayViewResult;\n}\n/** Options of one {@link PreparedDisplayView} render. */\nexport interface PreparedDisplayViewRenderOptions {\n /** Aborting cancels this render only; the promise rejects with a domain error. The request's own `signal` applies to preparing only. */\n signal?: AbortSignal;\n}\n/**\n * 2.7: a display-view request resolved once (`prepareDisplayView`). `render(view)` gives the same result as\n * `simulateDisplayView(options, view)` for the prepared options, byte for byte (samples, view, exposure, scene, diagnostics\n * and assumptions; only `diagnostics.timingsMs` differ, and they cover the render only), without repeating the request's\n * setup: use it to render one view in many regions, for example on each worker of a progressive display.\n */\nexport interface PreparedDisplayView {\n /**\n * Renders a view of the prepared request. Renders may run concurrently; they share no state except read-only setup. With `gpu: \"auto\"`\n * or `\"require\"` (#481) GPU renders of one prepared view run one at a time on its device, and `diagnostics.fast.execution`\n * says whether the GPU or the CPU reference rendered the view, and why.\n */\n render(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewResult>;\n /**\n * 2.11 (#481): releases the WebGPU device the view acquired (none with `gpu: \"off\"`, or when `gpuDevice` gave an accelerator,\n * whose device its owner keeps). Later renders run the CPU reference labelled `fallbackReason: \"disposed\"` (`\"auto\"`) or fail\n * with that reason (`\"require\"`). Idempotent.\n */\n dispose(): void;\n /**\n * 2.10 (#447), deprecated in 2.22.0: was the key of this request's AHD low-signal correction states. The view has no such\n * states since 2.22.0 (docs/DISPLAY_VIEW.md, \"AHD at low signal\"), so this returns null for every request.\n * @deprecated Since 2.22.0: always null. Removed in 3.0.0.\n */\n correctionKey(): string | null;\n /**\n * 2.10 (#447), deprecated in 2.22.0: was the grid keys of the correction states a render of `view` read. Since 2.22.0 it checks\n * `view` as `render` does and returns `{ key: \"\", gridKeys }` with no grid keys, for every request; it renders nothing.\n * @deprecated Since 2.22.0: returns no grid keys. Removed in 3.0.0.\n */\n collectCorrectionStates(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateKeys>;\n /**\n * 2.10 (#447), deprecated in 2.22.0: computed correction states. Since 2.22.0 it checks that `gridKeys` is an Int32Array of\n * grid keys (integers in [0, 97³)) and returns `{ key: \"\", gridKeys, values }` with no states, for every request; it computes nothing.\n * @deprecated Since 2.22.0: returns no states. Removed in 3.0.0.\n */\n computeCorrectionStates(gridKeys: Int32Array, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateSet>;\n}\n/**\n * 2.7 (#387): resolves a {@link simulateDisplayView} request once, without a view, and returns a handle whose `render(view)`\n * renders its views. The setup it does once (request validation, the camera, lens, scene, chart and illuminant, the channel\n * responses through the environment chain, the diffraction kernels, readout moments, demosaic tables and colour matrix) costs\n * about 0.3–1.3 s per call on a 24 MP request; a region costs only its own pixels. Errors in the request are raised here;\n * errors in the view by `render`.\n *\n * 2.11 (#481): `prepareOptions.gpu` chooses the renderer: `\"off\"` is the CPU reference, today's bytes; `\"auto\"` renders\n * on WebGPU when a conforming device is available and the request is supported, else on the CPU, labelled; `\"require\"` fails\n * instead of falling back (`ImageKernelExecutionError`, acquisition failures here, later ones from `render`). 2.20.0: the default is\n * `\"auto\"` when the request resolves to fast (the view's default) and `\"off\"` with `fast: false`. `gpuDevice` is a\n * WebGPU entry point or an `ImageKernelAccelerator` whose device the view shares; without it the engine acquires one device\n * for the prepared view (the request's `signal` aborts the acquisition) and `dispose()` releases it. The realm's\n * `setWebGpuEnabled(false)` vetoes both GPU modes (`webgpu-disabled`). See docs/DISPLAY_VIEW.md, \"Rendering on the GPU\".\n * @see docs/QUICK_START.md, \"Display view\".\n */\nexport async function prepareDisplayView(options: SimulateCaptureOptions, prepareOptions?: PrepareDisplayViewOptions): Promise<PreparedDisplayView> {\n // 2.20.0: the GPU follows the request's fast (the display view's default is fast): \"auto\" when fast, \"off\" when exact.\n const gpuOptions = parsePrepareDisplayViewOptions(prepareOptions, (options as { fast?: unknown } | null | undefined)?.fast !== false);\n let frameWidth = 0, frameHeight = 0;\n const prepared = await runCapture(options, \"display-view\", DISPLAY_VIEW_WITHOUT_VIEW, (context) => {\n frameWidth = context.width; frameHeight = context.height;\n return prepareView(context);\n }) as PreparedViewParts;\n // The GPU code is loaded only when a GPU mode asks for it, so bundles on the default stay without it.\n const session: DisplayViewGpuSession | null = gpuOptions.gpu === \"off\" ? null :\n await (await import(\"./display-view-gpu-session.js\")).openDisplayViewGpuSession(gpuOptions, prepared.gpuRequest, (options as { signal?: AbortSignal }).signal);\n /** One call's start times, cancellation (its own signal) and yielding. */\n const runOf = (renderOptions: PreparedDisplayViewRenderOptions | undefined): ViewRun => {\n const started = Date.now(), viewStarted = clockMs();\n const signal = renderOptions === undefined ? undefined : allowKeys(renderOptions, \"render options\", [\"signal\"]).signal as AbortSignal | undefined;\n if (signal !== undefined && (typeof signal !== \"object\" || signal === null || typeof signal.aborted !== \"boolean\")) fail(\"signal must be an AbortSignal.\");\n const checkAbort = (): void => { if (signal?.aborted) fail(\"simulateCapture aborted.\"); };\n checkAbort();\n return { started, viewStarted, checkAbort, yieldControl: createHostYield().yieldControl, signal };\n };\n const handle: PreparedDisplayView = Object.freeze({\n async render(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewResult> {\n const run = runOf(renderOptions);\n const parsed = parseDisplayViewOption(view, frameWidth, frameHeight);\n return await prepared.render(parsed, run, undefined, session);\n },\n dispose(): void { session?.dispose(); },\n // Deprecated since 2.22.0 (no correction states); kept until 3.0.0.\n correctionKey(): string | null { return null; },\n collectCorrectionStates(view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateKeys> {\n try {\n runOf(renderOptions);\n parseDisplayViewOption(view, frameWidth, frameHeight);\n return Promise.resolve({ key: \"\", gridKeys: new Int32Array(0) });\n } catch (error) { return Promise.reject(error as Error); }\n },\n computeCorrectionStates(gridKeys: Int32Array, renderOptions?: PreparedDisplayViewRenderOptions): Promise<DisplayViewCorrectionStateSet> {\n try {\n runOf(renderOptions);\n checkDeprecatedGridKeys(gridKeys, \"computeCorrectionStates\");\n return Promise.resolve({ key: \"\", gridKeys: new Int32Array(0), values: new Float64Array(0) });\n } catch (error) { return Promise.reject(error as Error); }\n }\n });\n PREPARED_INTERNALS.set(handle, async (view, renderOptions) => {\n const internals: ViewInternals = {};\n const result = await prepared.render(parseDisplayViewOption(view, frameWidth, frameHeight), runOf(renderOptions), internals, session);\n return { result, internals: internals.value! };\n });\n return handle;\n}\n/** The internal render of each prepared view (the same render as `render`, keeping its renderer's result). */\nconst PREPARED_INTERNALS = new WeakMap<PreparedDisplayView, (view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions) =>\n Promise<{ result: DisplayViewResult; internals: DisplayViewRenderResult }>>();\n/**\n * Internal (not exported from the package): renders a view of a prepared view as `render` does (the same GPU session and labels)\n * and also returns the renderer's noise-free expected linear values and noise standard deviations, whichever renderer ran (#480's\n * GPU producer, `scripts/lib/display-view-gpu-page.mjs`).\n */\nexport async function renderPreparedDisplayViewWithInternals(prepared: PreparedDisplayView, view: SimulateDisplayViewOptions, renderOptions?: PreparedDisplayViewRenderOptions):\n Promise<{ result: DisplayViewResult; internals: DisplayViewRenderResult }> {\n const render = PREPARED_INTERNALS.get(prepared);\n if (!render) fail(\"renderPreparedDisplayViewWithInternals needs a view returned by prepareDisplayView.\");\n return await render(view, renderOptions);\n}\n/**\n * Internal (not exported from the package): the display view plus its noise-free expected linear values and noise standard\n * deviations, for the validation scripts and tests.\n */\nexport async function simulateDisplayViewWithInternals(options: SimulateCaptureOptions, view: SimulateDisplayViewOptions):\n Promise<{ result: DisplayViewResult; internals: DisplayViewRenderResult; signal: DisplayViewExpectedSignal; setup: DisplayViewSetup; signalInput: DisplayViewExpectedSignalInput }> {\n const internals: ViewInternals = {};\n const result = await runCapture(options, \"display-view\", view, (context) => renderDisplayViewResult(context, internals)) as DisplayViewResult;\n return { result, internals: internals.value!, signal: internals.signal!, setup: internals.setup!, signalInput: internals.signalInput! };\n}\n\n/**\n * 2.22.0: the measured shift of the AHD view's expected colour that the removed low-signal correction used to cancel, in 8-bit\n * codes (mean over a centred 32 × 32 block, f/8; see docs/DISPLAY_VIEW.md, \"AHD at low signal\"), reported in `view.demosaic`.\n */\nconst AHD_LOW_SIGNAL_BIAS_CODES = { phone1p4umIso6400Red: -4, fullFrame6umIso6400MaxAbs: 0.3, appRequest6umIso400MaxAbs: 0.01 } as const;\n\ntype ViewInternals = { value?: DisplayViewRenderResult; signal?: DisplayViewExpectedSignal;\n /** #478: the render's setup and the expected signal's input, for the GPU display view's tests. */\n setup?: DisplayViewSetup; signalInput?: DisplayViewExpectedSignalInput };\n/** What one render of a prepared view needs from its call: its start times, cancellation and yielding. */\ninterface ViewRun { started: number; viewStarted: number; checkAbort: () => void; yieldControl: () => Promise<void>; signal?: AbortSignal | undefined }\ntype RenderPreparedView = (view: ParsedDisplayView, run: ViewRun, viewInternals?: ViewInternals, gpu?: DisplayViewGpuSession | null) => Promise<DisplayViewResult>;\n/** A prepared request: its render. */\ninterface PreparedViewParts {\n render: RenderPreparedView;\n /** #481: what a GPU renderer is asked to support. */\n gpuRequest: DisplayViewGpuRequest;\n}\n\n/** Renders the display view of a resolved request (the last step of `runCapture` for \"display-view\"). */\nasync function renderDisplayViewResult(context: DisplayViewRunContext, viewInternals?: ViewInternals): Promise<DisplayViewResult> {\n const viewStarted = clockMs();\n return await (await prepareView(context)).render(context.parsedView!, { started: context.started, viewStarted, checkAbort: context.checkAbort, yieldControl: context.yieldControl }, viewInternals);\n}\n\n/**\n * Internal (#387): the part of a display view that depends only on the request, done once (the portable illuminant, chart and\n * white balance, the channel responses, query offsets, diffraction kernels, readout moments, demosaic tables and colour\n * matrix). The returned function renders one view from it; it keeps no state between renders (each has its own expected-\n * signal caches, lookup count and assumptions), so its results are those of separate calls.\n */\nasync function prepareView(context: DisplayViewRunContext): Promise<PreparedViewParts> {\n const { ahd, antiAliasing, aspect, axisChannelResponse, boxSamples, buildProvider, callerScene, chart, materialLayers, chartReport, chartSize, diffraction, diffractionPsf, fNumber, focalLengthMm, focusDistanceM, height, highlightMode, exposureGain, illuminanceLux, illuminant, illuminantOption, imagingArea, intentOf, metresPerFrameUnit, noiseSeed, outputOptions, pitch, preset, provider, regimeByChannel, resolvedIso, isoReport, standardExposureDeviationStops, standardExposureIlluminanceLux, greyCardDeviationStops, metering, sceneOption, scenePreset, shutterSeconds, subjectDistanceM, toneCurve, whiteBalanceOption, whiteBalanceState, width, margin, mode, nativeHeight, nativeWidth, sourceSha256 } = context;\n const kelvinInput = context.kelvinWhiteBalanceInput;\n // The engine's illuminant formulas (Planckian, CIE A, daylight locus) evaluated with the portable power and e^x − 1, so\n // the view's radiances, irradiance scale and scene-illuminant white balance have the same bits in every JavaScript\n // engine; they differ from the capture's own by at most a few ulps (docs/DISPLAY_VIEW.md, \"Same bytes in every engine\").\n // #550: mixed lighting resolved with the same portable formulas; its strongest source at the frame center stands in for the illuminant.\n const viewMixed = context.mixedIllumination?.(resolvePortableCaptureIlluminant), viewStrongest = viewMixed?.sources[viewMixed.center.strongestSource];\n const viewIlluminant = viewStrongest ? viewStrongest.illuminant : resolvePortableCaptureIlluminant(illuminantOption);\n const viewIrradianceScale = viewStrongest ? viewStrongest.irradianceScale : calculateIlluminantIrradianceScale(viewIlluminant.shape, illuminanceLux);\n const stillViewProvider = buildProvider(viewIlluminant, viewIrradianceScale, viewMixed);\n // #551: a moving subject is read at each temporal midpoint as radiance (no material tables).\n const viewProvider = context.movingScene ? context.movingScene(stillViewProvider, viewIrradianceScale, (nm) => viewIlluminant.shape.evaluate(nm), viewMixed) : stillViewProvider;\n const viewWhiteBalanceState = whiteBalanceOption === \"scene-illuminant\" ? sceneIlluminantWhiteBalance(viewIlluminant) : kelvinInput ? resolvePortableColorTemperatureWhiteBalance(kelvinInput) : whiteBalanceState;\n // The chart's materials likewise (a step wedge's geometric levels use the portable power); same geometry and order.\n const viewChart = chart ? resolvePortableChartScene({ scene: sceneOption as ChartScene, aspect: chartSize ? chartSize.heightM / chartSize.widthM : aspect }) : undefined;\n if (chart && viewChart!.materials.length !== chart.materials.length) fail(\"simulateDisplayView: the chart's materials could not be resolved portably.\");\n const { electronsPerRadiance, wavelengths, relativePerElectron } = axisChannelResponse(\"simulateDisplayView\");\n const perNode = CHANNELS.map((c) => Float64Array.from(wavelengths, (nm) => electronsPerRadiance[c].get(nm) ?? 0)) as [Float64Array, Float64Array, Float64Array];\n // The tabulated expected signal's input (#394: shared with the capture's tabulated RAW path).\n const sceneMaterials = viewChart ? viewChart.materials : callerScene?.kind === \"material-function\" ? callerScene.materials : undefined;\n // Defocus (#492): the geometric disc on the site lattice, combined with the diffraction kernels in the tables (expected-signal-setup.ts).\n // #553: with bokeh options (blades, spherical aberration) the capture built the shaped kernel; it replaces the disc.\n const defocusDisc = context.defocus, defocusKernel = defocusDisc && defocusDisc.diameterSites > 0 ? defocusDisc.siteKernel ?? createDefocusDiscSiteKernel(defocusDisc.diameterSites) : null;\n const shaped = defocusDisc?.siteKernel !== undefined;\n // The combined radius is at most 32 + 512 sites (the diffraction and disc caps), as in the capture. #564: above 64 sites the kernel is\n // convolved by runs after the in-focus signal (expected-signal.ts), the same sums regrouped.\n const diffractionRadius = diffraction ? diffraction.kernelRadiusSamples : 0, combinedRadius = defocusKernel ? diffractionRadius + defocusKernel.radius : diffractionRadius;\n const { offsets, signalInput } = buildExpectedSignalInput({ nativeWidth, nativeHeight, width, wavelengths, perNode, apertureNodes: apertureNodeOffsets(boxSamples), boxSamples,\n antiAliasing, pitch, defocus: defocusKernel, ...(context.lensPsf ? { lensKernels: context.lensPsf.axisKernels(wavelengths) } : {}), diffraction: diffraction ? { radius: diffraction.kernelRadiusSamples, psf: diffractionPsf!.configuration.psf, profileWavelengths: diffraction.profile.axes.wavelengthNm } : undefined,\n materials: sceneMaterials && provider.chartMaterialAt && !context.movingScene ? { materialAt: provider.chartMaterialAt,\n list: [...sceneMaterials.map((m, index) => (m.kind === \"neutral\" ? { neutral: m.reflectance } : { radiance: (nm: number): number => viewProvider.materialRadiance!(index, nm) })),\n ...(chartSize ? [{ neutral: chartSize.surroundReflectance }] : [])],\n whiteRadiance: (nm: number): number => viewIrradianceScale * viewIlluminant.shape.evaluate(nm) / Math.PI } : undefined,\n radianceAt: viewProvider.radianceAt, imageSignalScene: viewProvider.imageSignalScene,\n imagingArea, focalLengthMm, focusDistanceM, subjectDistanceM, metresPerFrameUnit, caller: \"simulateDisplayView\" });\n const kernels = signalInput.kernels, largeDefocus = signalInput.largeKernel;\n // Readout moments per channel: normalized value k·e with variance k²·(e + σ_read²) plus the ADC quantization (1/12 code², times d² before a digital gain d).\n // #556: a development exposure push G multiplies the normalized value before the per-site clip at white: k → G·k and the constant variance → G²·(…).\n // Without a push G = 1, and x·1 = x exactly in IEEE 754 arithmetic, so the moments are bit-identical to those without the push.\n const readout = CHANNELS.map((channel): DisplayViewChannelReadout => {\n const { readoutProfile, regimeId } = regimeByChannel[channel];\n const resolved = resolveSensorReadoutRegime({ profile: readoutProfile as Parameters<typeof resolveSensorReadoutRegime>[0][\"profile\"], regimeId });\n const k = relativePerElectron[channel], digitalGain = resolved.regime.adc.digitalGain ?? 1, gain = resolved.regime.systemConversionGainElectronsPerCode.value;\n const codeSpan = digitalGain / (gain * k), read = resolved.combinedReadNoiseRmsElectrons;\n const quantizationCodes = digitalGain * digitalGain / 12 + (digitalGain === 1 ? 0 : 1 / 12);\n return { perElectron: exposureGain * k, darkElectrons: DARK_CURRENT_ELECTRONS_PER_SECOND * shutterSeconds,\n constantVariance: exposureGain * exposureGain * (k * k * read * read + quantizationCodes / (codeSpan * codeSpan)) };\n }) as [DisplayViewChannelReadout, DisplayViewChannelReadout, DisplayViewChannelReadout];\n const phases = bilinearPhaseProfiles(), demosaicTable: { dx: number; dy: number; weight: number }[][][] = [];\n for (const phase of phases) demosaicTable[phase.phaseY * 2 + phase.phaseX] = CHANNELS.map((c) => phase.profile.kernels.find((k) => k.outputChannelId === c)!.contributions\n .map((t) => ({ dx: t.offsetX, dy: t.offsetY, weight: t.weight })));\n const viewIntent = intentOf(viewWhiteBalanceState), viewGains = viewIntent ? [viewIntent.channelGains.red, viewIntent.channelGains.green, viewIntent.channelGains.blue] : null;\n const colour = prepareSensorColorDevelopment(CAMERA_TO_XYZ as unknown as Parameters<typeof prepareSensorColorDevelopment>[0], viewGains, highlightMode === \"reconstruct-neighbors\" ? \"clip\" : highlightMode);\n const toSrgb = resolveCaptureColorModel().xyzToCameraRgb, m = colour.cameraToXyz;\n const matrix = [0, 1, 2].map((r) => [0, 1, 2].map((c) => toSrgb[r]![0]! * m[0]![c]! + toSrgb[r]![1]! * m[1]![c]! + toSrgb[r]![2]! * m[2]![c]!));\n // Reach of a footprint's pixels into the scene, in sites: the demosaic (1), the largest query offset and the kernel radius.\n const reachSites = (ahd ? 3 : 1) + Math.ceil(Math.max(0, ...offsets.map((o) => Math.max(Math.abs(o.x), Math.abs(o.y))))) + (kernels ? kernels.radius : 0) + (largeDefocus ? largeDefocus.radius : 0);\n const gains = colour.appliedGains as [number, number, number], clipLevel = Math.min(...colour.appliedGains), viewToneCurve = toneCurve;\n // #593, #601: the coupled rendering steps (luminance curves, reconstruct, desaturation), with the fast rules when the request is fast.\n const coupledRendering = toneCurve === \"extended-reinhard-luminance\" || toneCurve === \"naka-rushton-luminance\" || highlightMode === \"reconstruct\" || highlightMode === \"reconstruct-neighbors\" || context.gamutHandling === \"desaturate-to-luminance\";\n const rendering: DisplayViewRenderingChoice | undefined = coupledRendering ? { toneCurve, ...(outputOptions.toneCurveParameters === undefined ? {} : { toneCurveParameters: outputOptions.toneCurveParameters as SdrToneCurveParameters }),\n highlightMode, gamutHandling: context.gamutHandling, fast: context.viewFast.rendering } : undefined;\n // The coupled steps' module is loaded only for a view that asks for them (the Quality kit, #594; the default path never imports it).\n const coupled: DisplayViewCoupledRendering | undefined = rendering ? (await qualityKit.load()).createDisplayViewCoupledRendering(rendering, colour.appliedGains, Math.min(...colour.appliedGains), matrix)! : undefined;\n // #457: AHD's homogeneity metric (the profile's camera → XYZ matrix times the white-balance gains) for its choice on the noise-free mosaic.\n const ahdChoice = ahd ? { labMatrix: CAMERA_TO_XYZ.map((row) => row.map((value, c) => value * (viewGains ? viewGains[c]! : 1))) } : undefined;\n // 2.20.0: a quarter of the samples per axis where the pilot finds no detail is the view's fast sampling; exact samples every pixel fully.\n const uniformSamplesOf = (k: number): number => context.viewFast.uniformSampling ? Math.max(1, Math.round(k / 4)) : k;\n const ahdCandidates = ahd ? [0, 1, 2, 3].map((p) => ahdCandidateKernels(p % 2, Math.floor(p / 2))) : undefined;\n // #491: a fixed-size chart's placement for the GPU material lookup (the provider's chart-local units cu = u·m/h and the surround beyond the chart).\n const placement = chartSize ? { chartUnitsPerFrameUnit: metresPerFrameUnit / (chartSize.widthM / 2), aspect: chartSize.heightM / chartSize.widthM } : null;\n /** The renderer's setup of one view, and its expected signal. */\n const setupOf = (v: ParsedDisplayView, { checkAbort, yieldControl }: ViewRun): { setup: DisplayViewSetup; signal: DisplayViewExpectedSignal } => {\n const viewRegion = v.region ?? { x: 0, y: 0, width: v.width, height: v.height };\n // The native columns the region's windows span, beyond one window's width: a filled band need not be wider (a speed hint).\n // #563: through the lens (projection, distortion, vignetting, rotation) when the request has them.\n const signal = (context.lens ?? createDisplayViewExpectedSignal)(signalInput, Math.ceil((viewRegion.width + 2) * nativeWidth / v.width));\n return { signal, setup: { frameWidth: width, frameHeight: height, margin, nativeWidth, nativeHeight, viewWidth: v.width, viewHeight: v.height,\n region: viewRegion, samplesPerAxis: v.samplesPerAxis, uniformSamplesPerAxis: uniformSamplesOf(v.samplesPerAxis), reachSites, bitDepth: v.bitDepth, seed: noiseSeed, signal, readout, demosaic: demosaicTable,\n ...(ahdCandidates && ahdChoice ? { candidates: ahdCandidates, ahdChoice } : {}),\n gains, clipLevel, matrix, toneCurve: viewToneCurve, ...(rendering ? { rendering, coupled: coupled! } : {}), yieldControl, checkAbort, gpu: { signalInput, chart: viewChart ?? null, layers: materialLayers ?? null, placement, ...(defocusKernel && !largeDefocus ? { defocusRadius: defocusKernel.radius } : {}) } } };\n };\n // #492: out of focus the view reads the defocus disc (its kernel in signalInput.kernels); the GPU Quality site pass gathers it (step 2c).\n const gpuRequest: DisplayViewGpuRequest = { ahd, lens: !!context.lens, ...(viewMixed ? { mixedIllumination: true } : {}), defocus: defocusKernel !== null, ...(largeDefocus ? { largeDefocus: true } : {}), diffraction: diffraction !== undefined, antiAliasing: antiAliasing !== undefined, boxSamples, toneCurve: viewToneCurve, ...(highlightMode === \"reconstruct\" || highlightMode === \"reconstruct-neighbors\" || context.gamutHandling === \"desaturate-to-luminance\" ? { coupled: true } : {}),\n scene: chart ? \"chart\" : materialLayers ? \"material-layers\" : callerScene!.kind };\n const render: RenderPreparedView = async (v, run, viewInternals, gpu) => {\n const { started, viewStarted } = run;\n const assumptions: SimulateCaptureAssumption[] = [...context.assumptions];\n const assume = (id: string, kind: SimulateCaptureAssumption[\"kind\"], value: unknown, explanation: string): void => { assumptions.push({ id, kind, value, explanation }); };\n const { setup, signal } = setupOf(v, run), viewRegion = setup.region;\n // #481: the GPU session renders on the device when it can, else through the CPU reference, and labels which ran.\n const cpu = (): Promise<DisplayViewRenderResult> => renderDisplayView(setup);\n const { rendered, execution }: { rendered: DisplayViewRenderResult; execution: DisplayViewExecution } = gpu ? await gpu.render(setup, run.signal, cpu)\n : { rendered: await cpu(), execution: cpuDisplayViewExecution(\"off\", null, null, null) };\n if (viewInternals) { viewInternals.value = rendered; viewInternals.signal = signal; viewInternals.setup = setup; viewInternals.signalInput = signalInput; }\n const viewMs = clockMs() - viewStarted, scaleX = width / v.width, scaleY = height / v.height;\n assume(\"view.definition\", \"model\", { resampling: \"area-average-linear-light\", width: v.width, height: v.height, frameWidth: width, frameHeight: height, scaleX, scaleY },\n \"The image the full-resolution capture of this request would give after resizing to \" + v.width + \" × \" + v.height + \": each display pixel is the area-weighted mean, in linear light (sRGB samples decoded with the sRGB EOTF), \" +\n \"of the real output pixels its rectangle covers (\" + scaleX + \" × \" + scaleY + \" real pixels), then sRGB-encoded and rounded. The real capture's own samples are rounded to the view's bit depth before averaging.\");\n const uniformSamplesPerAxis = uniformSamplesOf(v.samplesPerAxis);\n const siteSentence = \"the expected electrons of the real sites its demosaic reads are exact at the real pitch (the scene sampled at those sites through the pixel aperture, \" +\n \"anti-aliasing filter and diffraction kernels, with the capture's own query arithmetic, so the colour mosaic and its aliasing are the real sensor's), and the per-site clip at white, the highlight clip, the tone curve \" +\n \"and the clip to [0, 1] act on the pixel's own noise distribution, approximated as normal.\";\n // 2.8 (#393): where a footprint holds at most 25 real pixels (and at most K²), every real pixel of it is evaluated once with its exact weight.\n if (rendered.estimation === \"exact-area-mean\") {\n assume(\"view.estimation\", \"model\", { method: \"exact-area-mean-over-real-pixels\", samplesPerAxis: v.samplesPerAxis, realPixelsPerDisplayPixel: scaleX * scaleY,\n evaluatedRealPixels: rendered.sampleCount },\n \"Each display pixel's expected value is the exact area mean of the real pixels its rectangle covers: every real pixel it touches is evaluated once and weighted by its overlap with the rectangle \" +\n \"(w_j / A, summing to 1), so there is no sampling error. This applies because each rectangle holds \" + scaleX * scaleY + \" real pixels (\" + scaleX + \" × \" + scaleY + \"), at most \" + EXACT_AREA_MEAN_MAX_PIXELS + \" and at most K² = \" + v.samplesPerAxis * v.samplesPerAxis + \"; coarser views use a stratified estimate, which costs less there. \" +\n \"For each real pixel \" + siteSentence);\n } else {\n assume(\"view.estimation\", \"model\", { method: \"stratified-monte-carlo-over-real-pixels\", samplesPerAxis: v.samplesPerAxis, uniformSamplesPerAxis,\n detailPixels: rendered.detailPixelCount, uniformPixels: rendered.uniformPixelCount },\n \"Each display pixel's expected value is the mean over K × K strata of its rectangle, one seeded uniformly jittered real pixel in each, so it is unbiased; the error is zero where the rectangle is uniform \" +\n \"and falls as K^-3/2 at an edge. K = \" + v.samplesPerAxis + \" where a fixed pilot grid over the rectangle (widened by the demosaic, filter and kernel reach) or a neighbouring pixel's grid finds more than one scene value, \" +\n \"K = \" + uniformSamplesPerAxis + \" elsewhere. For each sampled pixel \" + siteSentence);\n }\n assume(\"view.noise\", \"model\", { method: \"variance-of-the-area-mean\", distribution: \"normal\" },\n \"Noise of the mean of the real pixels: the covariance of the weighted sum of independent site noises (shot, dark, read and ADC), with the demosaic correlation (B_c = Σ β², in closed form from the rectangle) and the \" +\n \"expected slopes of the clips and the tone curve (Stein's lemma); the variance the linearization misses and the real pixels' output rounding are added per pixel. One correlated normal draw per display pixel, seeded \" +\n \"by sensor.noiseSeed: the same statistics as the resized capture, not the same realization.\");\n assume(\"view.demosaic\", \"model\", ahd ? { capture: \"ahd\", view: \"ahd-candidates-with-noise-free-choice\", lowSignalNoiseChoice: \"not-modelled\", scientificStatus: \"approximation\",\n measuredBias8BitCodes: AHD_LOW_SIGNAL_BIAS_CODES } : { capture: \"bilinear\", view: \"bilinear\" },\n ahd ? \"AHD is non-linear only in its choice between two linear candidates (green along the rows or the columns, red and blue from colour differences). The view propagates both candidates' exact linear statistics \" +\n \"and averages them, or takes the candidate AHD chooses on the noise-free mosaic where the scene decides the choice. An approximation: at a few electrons per site the capture's choice also reacts to the noise \" +\n \"and shifts its colour, which the view does not model (2.22.0). Measured on a centred 32 × 32 block at f/8: a 1.4 µm sensor at ISO 6400 has its red about 4 8-bit codes above the capture's on average \" +\n \"(up to about 7 codes in a pixel), a 6 µm sensor at ISO 6400 at most 0.3 code, and the app's 6 µm ISO 400 request at most 0.01 code (docs/DISPLAY_VIEW.md, \\\"AHD at low signal\\\").\" :\n \"The bilinear demosaic's linear kernels, exactly.\");\n if (defocusKernel) {\n assume(\"view.defocus\", \"model\", { kernel: shaped ? (diffraction ? \"diffraction-convolved-with-shaped-kernel\" : \"shaped-kernel\") : diffraction ? \"diffraction-convolved-with-disc\" : \"disc\", defocusKernelRadiusSites: defocusKernel.radius,\n diffractionKernelRadiusSites: diffraction ? diffractionRadius : null, kernelRadiusSites: combinedRadius, scientificStatus: \"approximation\", ...(largeDefocus ? { convolution: \"runs\" } : {}) },\n // #564: the lens.defocus assumption explains the run convolution above 64 sites (convolution: \"runs\").\n \"The expected electrons of each real site read the scene on the site lattice through the defocus \" + (shaped ? \"kernel shaped by the lens (#553; see the lens.defocus assumption; \" : \"disc (\") +\n defocusKernel.diameterSites + \" sites across, a \" + defocusKernel.width + \" × \" +\n defocusKernel.width + \" window), as the capture's convolution does; the estimators then run unchanged on the blurred signal. \" + (diffraction ?\n \"With lens.diffraction each spectral node's kernel is its diffraction kernel convolved with the disc (\" + (2 * combinedRadius + 1) + \" × \" + (2 * combinedRadius + 1) + \" taps): \" +\n \"an approximation, because the PSF of a defocused wave is not the in-focus Airy pattern convolved with a geometric disc.\" :\n \"The disc is the same at every spectral node (geometric optics).\"));\n }\n if (viewMixed) assume(\"view.illumination\", \"model\", { method: \"radiance-at-every-query-point\" },\n \"Mixed lighting (#550): the radiance at every query point, as in the capture (no material tables; exact). Not on the GPU.\");\n if (execution.backend === \"webgpu-f32\") {\n assume(\"view.execution\", \"model\", { backend: execution.backend, arithmetic: execution.arithmetic, errorBound: execution.errorBound, adapter: execution.adapter },\n \"Estimated on the GPU: this view was rendered by the WebGPU float32 display-view renderer, a labelled approximation of the float64 CPU reference within the a-priori \" +\n \"error bound reported in diagnostics.fast.execution.errorBound; it is not bit-identical to the reference. The device passed the engine's run-time conformance check first.\");\n }\n if (rendering) assume(\"view.rendering\", \"model\", { toneCurve, highlightMode, gamutHandling: rendering.gamutHandling, method: \"coupled-moments\",\n luminanceTone: rendering.toneCurve === \"extended-reinhard-luminance\" || rendering.toneCurve === \"naka-rushton-luminance\" ? (rendering.fast ? \"gauss-hermite-8-in-luminance-else-gauss-legendre-4x16\" : \"gauss-legendre-4x16-in-luminance\") : null,\n chainPointsPerAxis: coupled!.chainPoints, fast: rendering.fast, scientificStatus: rendering.fast ? \"approximation\" : \"exact-in-the-limit\" },\n \"The rendering steps that couple a pixel's components act on its normal camera-channel distribution: a luminance tone curve by conditioning each developed component on the luminance \" +\n \"(closed-form clipped-normal moments for each luminance, integrated over it\" + (rendering.fast ? \" with an 8-point Gauss–Hermite rule where the luminance stays positive\" : \" with a composite 4 × 16-point Gauss–Legendre rule\") + \"); \" +\n \"highlightMode \\\"reconstruct\\\" and the desaturation, where a pixel reaches them, by integrating the whole development chain over its camera channels with a \" +\n coupled!.chainPoints + \"-point-per-axis Gauss–Hermite rule (docs/DISPLAY_VIEW.md, \\\"Coupled rendering\\\"). \" +\n (rendering.fast ? \"The fast rules (the request resolves to fast) are a bounded approximation of the full ones.\" : \"The full rules converge to the exact moments of the view's normal model.\"));\n assume(\"view.source\", \"model\", { rendering: \"srgb\", format: v.format, ignoredCaptureOutput: [\"format\", \"colorEncoding\", \"bitDepth\", \"gamutMapping\", \"jpegQuantizationStep\", \"dng\", \"metadata\", \"maximumPixels\"].filter((k) => outputOptions[k] !== undefined) },\n \"The view shows the capture's sRGB rendering (its tone curve, white balance and highlight mode); the capture's file-format options do not apply to it.\");\n return Object.freeze({ kind: \"display-view\" as const, label: \"Display view: the full-resolution capture resized to \" + v.width + \" × \" + v.height + \" (estimated); not a capture.\",\n facadeVersion: SIMULATE_CAPTURE_FACADE_VERSION, engineApiVersion: ENGINE_API_VERSION,\n image: { width: viewRegion.width, height: viewRegion.height, format: v.format, samples: rendered.samples },\n view: { width: v.width, height: v.height, frameWidth: width, frameHeight: height, scaleX, scaleY, samplesPerAxis: v.samplesPerAxis, ...(v.region ? { region: { ...v.region } } : {}) },\n exposure: { mode, settings: { fNumber, shutterSeconds, iso: resolvedIso }, ev100: Math.log2(fNumber ** 2 / shutterSeconds), ...isoReport, standardExposureDeviationStops, standardExposureIlluminanceLux, greyCardDeviationStops, metering },\n sensor: context.sensor,\n scene: { sceneId: chart ? \"chart:\" + chart.preset : callerScene!.sceneId, preset: scenePreset, parameters: (chart ?? callerScene as { parameters?: Readonly<Record<string, unknown>> }).parameters ?? {},\n illuminant: { id: illuminant.id, description: illuminant.description, illuminanceLux }, distanceM: subjectDistanceM,\n framedWidthM: 2 * metresPerFrameUnit, framedHeightM: 2 * metresPerFrameUnit * aspect, ...(chartReport ? { chart: chartReport } : {}), sourceSha256 },\n diagnostics: { sampleCount: rendered.sampleCount, siteEvaluations: rendered.siteCount, sceneLookups: signal.lookups, detailPixelCount: rendered.detailPixelCount,\n uniformPixelCount: rendered.uniformPixelCount, ahdCorrectedPixelCount: 0, timingsMs: { view: viewMs, total: Date.now() - started },\n fast: Object.freeze({ ...context.fastReport, assurance: execution.backend === \"webgpu-f32\" ? \"approximation-with-a-priori-bound\" as const : context.fastReport.assurance, execution }),\n highlight: Object.freeze({ saturatedPixelCount: rendered.saturatedPixelCount, statistic: \"expected-value\" as const }) },\n provenance: { scientificStatus: \"approximation\" as const, cameraPresetId: preset.presetId, cameraPresetVersion: preset.presetVersion, evidence: [...FACADE_EVIDENCE, ...preset.evidence],\n composedContracts: [\"calculateEnvironmentSensorPhotoSignal\", \"resolveSensorReadoutRegime\", \"calculateSiteEffectiveSaturationCode\", ...(diffraction ? [\"createDiffractionLimitedPsfProfile\", \"resolveLensPsfConvolutionKernels\"] : []),\n ...(antiAliasing ? [\"resolveAntiAliasingSpatialKernel\"] : []), \"prepareSensorColorDevelopment\", \"display view estimator\"],\n limitations: [\"Estimated display view of the full-resolution capture: its expected value is a stratified Monte Carlo estimate and its noise is drawn from the variance of the area mean, so it has the resized capture's statistics, not its exact pixels; not a capture and not a measurement.\"] },\n assumptions: Object.freeze(assumptions.map((a) => Object.freeze(a))) });\n };\n return { render, gpuRequest };\n}\n"]}