@photivra/engine 2.0.0 → 2.2.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 (77) hide show
  1. package/CHANGELOG.md +39 -1
  2. package/CITATION.cff +1 -1
  3. package/README.md +6 -6
  4. package/SECURITY.md +1 -1
  5. package/dist/capture/export-jpeg.js +7 -1
  6. package/dist/capture/export-jpeg.js.map +1 -1
  7. package/dist/capture/native-environment-lean.js +5 -2
  8. package/dist/capture/native-environment-lean.js.map +1 -1
  9. package/dist/capture/native-environment-raw.js +2 -2
  10. package/dist/capture/native-environment-raw.js.map +1 -1
  11. package/dist/capture/native-raw-development.js +1 -1
  12. package/dist/capture/native-raw-development.js.map +1 -1
  13. package/dist/capture/native-raw.d.ts +16 -0
  14. package/dist/capture/native-raw.js +16 -3
  15. package/dist/capture/native-raw.js.map +1 -1
  16. package/dist/capture/packed-sensor-raw.d.ts +7 -0
  17. package/dist/capture/packed-sensor-raw.js +6 -2
  18. package/dist/capture/packed-sensor-raw.js.map +1 -1
  19. package/dist/core/pixel-limits.d.ts +14 -0
  20. package/dist/core/pixel-limits.js +40 -0
  21. package/dist/core/pixel-limits.js.map +1 -0
  22. package/dist/core/version.d.ts +1 -1
  23. package/dist/core/version.js +1 -1
  24. package/dist/core/version.js.map +1 -1
  25. package/dist/facade/chart-radiance-batch.d.ts +7 -0
  26. package/dist/facade/chart-radiance-batch.js +7 -3
  27. package/dist/facade/chart-radiance-batch.js.map +1 -1
  28. package/dist/facade/diffraction-provider.d.ts +30 -0
  29. package/dist/facade/diffraction-provider.js +127 -0
  30. package/dist/facade/diffraction-provider.js.map +1 -0
  31. package/dist/facade/host-yield.d.ts +1 -1
  32. package/dist/facade/host-yield.js +0 -4
  33. package/dist/facade/host-yield.js.map +1 -1
  34. package/dist/facade/simulate-capture.d.ts +88 -2
  35. package/dist/facade/simulate-capture.js +343 -41
  36. package/dist/facade/simulate-capture.js.map +1 -1
  37. package/dist/index.d.ts +5 -2
  38. package/dist/index.js +4 -2
  39. package/dist/index.js.map +1 -1
  40. package/dist/motion/temporal-exposure-sum.d.ts +7 -0
  41. package/dist/motion/temporal-exposure-sum.js +6 -2
  42. package/dist/motion/temporal-exposure-sum.js.map +1 -1
  43. package/dist/optics/diffraction-psf-profile.d.ts +118 -0
  44. package/dist/optics/diffraction-psf-profile.js +252 -0
  45. package/dist/optics/diffraction-psf-profile.js.map +1 -0
  46. package/dist/optics/irradiance-convolution.d.ts +7 -0
  47. package/dist/optics/irradiance-convolution.js +6 -2
  48. package/dist/optics/irradiance-convolution.js.map +1 -1
  49. package/dist/output/native-capture-sdr.d.ts +7 -0
  50. package/dist/output/native-capture-sdr.js +6 -3
  51. package/dist/output/native-capture-sdr.js.map +1 -1
  52. package/dist/output/png-encoder.d.ts +10 -1
  53. package/dist/output/png-encoder.js +10 -4
  54. package/dist/output/png-encoder.js.map +1 -1
  55. package/dist/output/print-jpeg.d.ts +18 -0
  56. package/dist/output/print-jpeg.js +15 -4
  57. package/dist/output/print-jpeg.js.map +1 -1
  58. package/dist/sensor/sampling-aperture.d.ts +15 -0
  59. package/dist/sensor/sampling-aperture.js +31 -10
  60. package/dist/sensor/sampling-aperture.js.map +1 -1
  61. package/docs/API_REFERENCE.md +27 -1
  62. package/docs/QUICK_START.md +285 -13
  63. package/docs/USAGE.md +3 -1
  64. package/docs/api/capture-native-raw.md +11 -2
  65. package/docs/api/capture-packed-sensor-raw.md +7 -1
  66. package/docs/api/core-pixel-limits.md +19 -0
  67. package/docs/api/core-version.md +1 -1
  68. package/docs/api/exports.json +62 -2
  69. package/docs/api/facade-chart-radiance-batch.md +8 -2
  70. package/docs/api/facade-simulate-capture.md +83 -3
  71. package/docs/api/motion-temporal-exposure-sum.md +7 -1
  72. package/docs/api/optics-diffraction-psf-profile.md +96 -0
  73. package/docs/api/optics-irradiance-convolution.md +7 -1
  74. package/docs/api/output-native-capture-sdr.md +7 -2
  75. package/docs/api/output-png-encoder.md +8 -1
  76. package/docs/api/output-print-jpeg.md +17 -0
  77. package/package.json +3 -2
@@ -1 +1 @@
1
- {"version":3,"file":"native-raw-development.js","sourceRoot":"","sources":["../../src/capture/native-raw-development.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EAAE,sBAAsB,EAAsE,MAAM,iBAAiB,CAAC;AAC7H,OAAO,EAAE,mCAAmC,EAA2C,MAAM,+BAA+B,CAAC;AAC7H,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,kCAAkC,EACpE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAiC,MAAM,0BAA0B,CAAC;AACxG,OAAO,EAAE,6BAA6B,EAAsD,MAAM,sCAAsC,CAAC;AACzI,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,mBAAmB,EAAqD,MAAM,4BAA4B,CAAC;AACrK,OAAO,EAAE,gBAAgB,EAAgD,MAAM,iCAAiC,CAAC;AACjH,OAAO,EAAE,oCAAoC,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAyB,MAAM,yBAAyB,CAAC;AACjH,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EACzC,MAAM,6BAA6B,CAAC;AAoE5F,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,qFAAqF;AACrF,MAAM,qBAAqB,GAAG,CAAC,IAAI,E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B,EAAC,KAAK,EAAC,CAAC;gBAAA,KAAK,GAAC,WAAW,CAAC;YACtJ,CAAC;YAAA,OAAM,KAAK,EAAC,CAAC;gBAAA,OAAO,EAAE,CAAC;gBAAA,IAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC;oBAAA,KAAK,GAAC,QAAQ,CAAC;oBAAA,KAAK,CAAC,KAAK,EAAE,CAAC;gBAAA,CAAC;gBAAA,MAAM,KAAK,CAAC;YAAA,CAAC;QAC/F,CAAC;QACD,MAAM,KAAQ,IAAG,KAAK,KAAG,OAAO,IAAE,KAAK,KAAG,SAAS,IAAE,KAAK,KAAG,WAAW,EAAC,CAAC;YAAA,KAAK,GAAC,WAAW,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACtH,OAAO,KAAQ,IAAG,KAAK,KAAG,aAAa,EAAC,CAAC;YAAA,KAAK,GAAC,UAAU,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACpF,UAAU,KAA8B,IAAG,KAAK,KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,iCAAiC,CAAC,CAAC,CAAA,MAAM,KAAK,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,KAAK,CAAC,CAAA,CAAC;KAC5N,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW development: turns packed RAW codes into an SDR image. It reconstructs full colour from\n * the CFA (colour filter array) mosaic exactly, then applies the shared colour, white-balance and SDR\n * steps, in bounded pixel tiles.\n */\nimport { calculateNativeRawPlan, type NativeRawInput, type NativeRawOutput, type NativeRawTaskState } from \"./native-raw.js\";\nimport { parseRawReconstructionPhaseProfiles, type RawFrameReconstructionPhaseProfile } from \"./raw-frame-reconstruction.js\";\nimport { calculateRawReconstructionChannel, rawReconstructionKernelReach, validateMirrorBorderCfaConsistency,\n type RawReconstructionBorderHandling } from \"../sensor/raw-reconstruction.js\";\nimport { equalWithinUlps } from \"../core/portable-math.js\";\nimport { resolveColorSamplingSite } from \"../sensor/color-sampling.js\";\nimport { parseExportSensorColorProfile, type ExportSensorColorProfile } from \"./photographic-export.js\";\nimport { prepareSensorColorDevelopment, type RawHighlightMode, type SensorColorDevelopment } from \"../color/sensor-color-development.js\";\nimport { calculateSdrRendering, parseSdrRenderingProfile, prepareSdrPixelTone, type SdrRenderingProfile, type SdrRenderingResult } from \"../output/sdr-rendering.js\";\nimport { renderSdrRunInto, type NativeTaskProgress, type SdrPixelCounts } from \"../output/native-capture-sdr.js\";\nimport { transformOrientedRasterPointToNative } from \"../output/capture-geometry.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { requireAllowlistedRecord } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { createRawDevelopmentCounts, createRawPixelDeveloper, normalizedRawSite, rawSiteSaturated,\n type RawDevelopmentCounts, type RawDevelopmentSource } from \"./raw-development-kernel.js\";\n\nexport interface NativeRawDevelopmentInput {\n /**\n * Packed RAW. Ownership passes to the task. On creation its five typed arrays are detached with\n * `ArrayBuffer.prototype.transfer` (no copy; the caller's arrays become length 0), or copied when\n * the runtime has no `transfer`. The developed output hands back the same RAW, now owned by the output.\n */\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: \"not-required\" | \"apply-resolved-sensor-gains\";\n rendering: SdrRenderingProfile;\n /** Highlight handling. `clip` (default): clipped highlights become neutral. `reconstruct`: the documented blend toward neutral. */\n highlightMode?: RawHighlightMode;\n /**\n * Frame-edge handling. `reject` (default): every reconstruction neighbourhood must lie inside the\n * native RAW frame. `mirror`: a site outside the frame is read from its mirror image (reflect-101,\n * edge not repeated). This is allowed only when the mirrored site has the same CFA colour, which is\n * always true for a 2×2 Bayer pattern. Interior pixels are unchanged.\n */\n borderHandling?: RawReconstructionBorderHandling;\n /** Counts the kept packed RAW plus the integer output. It does not count caller buffers, process heap or GPU memory. */\n maximumRetainedPayloadBytes: number;\n}\n/** RAW saturation handled before white balance. Counts are pixels or samples of the developed output. */\nexport interface RawHighlightDiagnostics {\n mode: RawHighlightMode;\n /** Output pixels with at least one contributing site at or above its white level, or flagged as saturated. */\n saturatedPixelCount: number;\n /** `clip`: WB-scaled samples clipped at the smallest gain. Always 0 for `reconstruct`. */\n whiteBalanceClippedSampleCount: number;\n /** `reconstruct`: pixels blended toward neutral. Always 0 for `clip`. */\n reconstructedPixelCount: number;\n}\nexport interface NativeRawDevelopmentOutput {\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"];\n width: number;\n height: number;\n integerSamples: Uint8Array | Uint16Array;\n diagnostics: SdrRenderingResult[\"diagnostics\"];\n highlight: RawHighlightDiagnostics;\n borderHandling: RawReconstructionBorderHandling;\n outputEncoding: SdrRenderingResult[\"outputEncoding\"];\n rendering: SdrRenderingProfile;\n displayAdaptation: SdrRenderingResult[\"displayAdaptation\"];\n imageDataPairing: \"derived-from-exact-packed-native-raw\";\n producerOriginVerified: false;\n}\n/** Host callbacks, the same shape as the other native task providers but without a tile reader. */\nexport interface NativeRawDevelopmentProvider {\n /** Must yield to the host event loop, so cancellation and input events can run between tiles. */\n yieldControl(signal: AbortSignal): Promise<void>;\n /** Optional callback after each committed 256-pixel output tile. It cannot change the output. */\n onProgress?(progress: NativeTaskProgress): void;\n}\nexport interface NativeRawDevelopmentTask {\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n readonly totalTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawDevelopmentOutput;\n}\nconst TILE_WIDTH = 256;\n/** Sites checked per integrity chunk before checking whether it is time to yield. */\nconst INTEGRITY_CHUNK_SITES = 1 << 18;\nfunction canonical(value: unknown): string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"reject\",nonFiniteNumberMessage:\"Invalid RAW metadata.\",unsupportedValueMessage:\"Invalid RAW metadata.\"});\n}\n/** Validates packed RAW storage and recomputes its plan. Shared with the native DNG writer. Not exported from the package. */\nexport function validatePackedNativeRaw(raw: NativeRawOutput): NativeRawOutput[\"plan\"] {\n requireAllowlistedRecord(raw,[\"plan\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\"saturationFlags\",\"effectiveSaturationCodes\"],\"Invalid packed RAW output.\");\n const p=raw.plan;\n if(!p?.exposure||!p.frame)throw new InvalidConfigurationError(\"Packed RAW requires complete exposure and frame metadata.\");\n const {engineApiVersion,resolvedGeometry,equivalentFocalLength35Mm,...exposure}=p.exposure;\n void engineApiVersion;void resolvedGeometry;\n const {capture,containerBitDepth,...frame}=p.frame;void containerBitDepth;\n const input: NativeRawInput={exposure,...frame,maximumOutputBytes:p.outputBytes,...(p.tileWidth===undefined?{}:{tileWidth:p.tileWidth}),...(p.exposureWindow?{exposureWindow:p.exposureWindow}:{})};\n const plan=calculateNativeRawPlan(input);\n // The recomputed 35 mm-equivalent focal length (also inside frame.capture, the same exposure record) may\n // differ by a few ULPs, so records parse in every JavaScript engine. Every other field must match exactly.\n const eq=plan.exposure.equivalentFocalLength35Mm,archivedFrameEq=(capture as unknown as Record<string,unknown>|undefined)?.equivalentFocalLength35Mm;\n if(typeof equivalentFocalLength35Mm!==\"number\"||!equalWithinUlps(equivalentFocalLength35Mm,eq,8)||typeof archivedFrameEq!==\"number\"||!equalWithinUlps(archivedFrameEq,eq,8)||\n canonical({...p,exposure:{...p.exposure,equivalentFocalLength35Mm:eq},frame:{...p.frame,capture:{...p.frame.capture,equivalentFocalLength35Mm:eq}}})!==canonical(plan))\n throw new InvalidConfigurationError(\"Packed RAW metadata is stale or inconsistent.\");\n const layout=plan.frame.colorSamplingProfile.layout,phaseCount=layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites*layout.repeatHeightSites:0;\n const buffers=new Set<ArrayBufferLike>();\n for(const [a,type,length] of [[raw.codes,Uint16Array,plan.pixelCount],[raw.blackLevels,Uint16Array,plan.pixelCount],[raw.digitalSaturationCodes,Uint16Array,plan.pixelCount],\n [raw.saturationFlags,Uint8Array,plan.pixelCount],[raw.effectiveSaturationCodes,Uint16Array,phaseCount]] as const){\n if(!(a instanceof type)||!(a.buffer instanceof ArrayBuffer)||a.length!==length||a.buffer.byteLength!==a.byteLength||buffers.has(a.buffer))throw new InvalidConfigurationError(\"Packed RAW storage must be exact owned native arrays.\");\n buffers.add(a.buffer);\n }\n return plan;\n}\n/** Takes sole ownership: detaches without copying when the runtime supports ArrayBuffer transfer, otherwise copies. */\nfunction own<T extends Uint8Array<ArrayBuffer>|Uint16Array<ArrayBuffer>>(array: T, make: (buffer: ArrayBuffer)=>T): T {\n const buffer=array.buffer as ArrayBuffer&{transfer?:()=>ArrayBuffer};\n return typeof buffer.transfer===\"function\"?make(buffer.transfer()):make(buffer.slice(0));\n}\n/** Takes the validated packed RAW's arrays (without copying where supported). Not exported from the package. */\nexport function takeNativeRawOwnership(given: NativeRawOutput, plan: NativeRawOutput[\"plan\"]): NativeRawOutput {\n return {plan,codes:own(given.codes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),blackLevels:own(given.blackLevels as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),\n digitalSaturationCodes:own(given.digitalSaturationCodes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),saturationFlags:own(given.saturationFlags as Uint8Array<ArrayBuffer>,b=>new Uint8Array(b)),\n effectiveSaturationCodes:given.effectiveSaturationCodes.slice()};\n}\n/** Validated development metadata (internal; shared with the image-kernel accelerator). Not exported from the package. */\nexport interface PreparedDevelopment {\n plan: NativeRawOutput[\"plan\"]; phases: RawFrameReconstructionPhaseProfile[]; color: ExportSensorColorProfile; profile: SdrRenderingProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"]; highlightMode: RawHighlightMode; development: SensorColorDevelopment;\n crop: {x:number;y:number;width:number;height:number}; raster: {pixelWidth:number;pixelHeight:number};\n border: RawReconstructionBorderHandling; mirror: {nativeHeight:number;reach:number}|undefined;\n}\n/**\n * Synchronous checks of metadata, kernel halo (the neighbourhood each pixel reads) and CFA, shared by the\n * task, the reference and the accelerator. No pixel loop. Not exported from the package.\n */\nexport function prepareNativeRawDevelopment(input: NativeRawDevelopmentInput): PreparedDevelopment {\n const r=requireAllowlistedRecord(input,[\"raw\",\"phaseProfiles\",\"colorProfile\",\"whiteBalance\",\"rendering\",\"highlightMode\",\"borderHandling\",\"maximumRetainedPayloadBytes\"],\"Invalid native RAW development input.\");\n const plan=validatePackedNativeRaw(input.raw),g=plan.exposure.resolvedGeometry,native=plan.exposure.geometry.nativeRaster;\n const phases=freezeOwnedData(parseRawReconstructionPhaseProfiles(r.phaseProfiles,plan.frame.modeId,plan.frame.colorSamplingProfile));\n const color=freezeOwnedData(parseExportSensorColorProfile(r.colorProfile)),profile=freezeOwnedData(parseSdrRenderingProfile(r.rendering));\n const crop=g.output.cropRect,raster=g.output.raster,active=g.activeCapture.nativeRect,intent=plan.exposure.whiteBalanceIntent;\n const highlightMode=r.highlightMode===undefined?\"clip\":r.highlightMode;\n if(highlightMode!==\"clip\"&&highlightMode!==\"reconstruct\")throw new InvalidConfigurationError(\"Unsupported RAW highlight mode.\");\n const border=r.borderHandling===undefined?\"reject\":r.borderHandling;\n if(border!==\"reject\"&&border!==\"mirror\")throw new InvalidConfigurationError(\"Unsupported RAW border handling.\");\n if(color.colorSamplingProfileId!==plan.frame.colorSamplingProfile.profileId||phases.some(p=>canonical(p.profile.kernels.map(k=>k.outputChannelId))!==canonical(color.channelIds))||\n (r.whiteBalance!==\"not-required\"&&r.whiteBalance!==\"apply-resolved-sensor-gains\")||(intent!==null)!==(r.whiteBalance===\"apply-resolved-sensor-gains\")||\n raster.pixelWidth!==crop.width||raster.pixelHeight!==crop.height)throw new InvalidConfigurationError(\"Development requires bound sensor RGB, explicit one-time WB and 1:1 output crop.\");\n const bytes=plan.outputBytes+raster.pixelWidth*raster.pixelHeight*3*profile.bitDepth/8;\n if(typeof r.maximumRetainedPayloadBytes!==\"number\"||!Number.isSafeInteger(r.maximumRetainedPayloadBytes)||r.maximumRetainedPayloadBytes<bytes)throw new InvalidConfigurationError(\"Development exceeds retained output budget.\");\n const gains=intent?[intent.channelGains.red,intent.channelGains.green,intent.channelGains.blue]:null;\n const development=prepareSensorColorDevelopment(color.normalizedCameraChannelsToXyz,gains,highlightMode),layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n const nativeCorners=[{x:crop.x+.5,y:crop.y+.5},{x:crop.x+crop.width-.5,y:crop.y+crop.height-.5}].map(point=>{\n const p=transformOrientedRasterPointToNative({point,nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(p.x)+active.x,y:Math.floor(p.y)+active.y};\n });\n const minX=Math.min(...nativeCorners.map(p=>p.x)),maxX=Math.max(...nativeCorners.map(p=>p.x)),minY=Math.min(...nativeCorners.map(p=>p.y)),maxY=Math.max(...nativeCorners.map(p=>p.y));\n for(const phase of phases){\n const firstX=minX+(phase.phaseX-minX%layout.repeatWidthSites+layout.repeatWidthSites)%layout.repeatWidthSites;\n const firstY=minY+(phase.phaseY-minY%layout.repeatHeightSites+layout.repeatHeightSites)%layout.repeatHeightSites;\n if(firstX>maxX||firstY>maxY)continue;\n const lastX=maxX-(maxX-phase.phaseX+layout.repeatWidthSites)%layout.repeatWidthSites,lastY=maxY-(maxY-phase.phaseY+layout.repeatHeightSites)%layout.repeatHeightSites;\n for(const kernel of phase.profile.kernels)for(const c of kernel.contributions){\n if(firstX+c.offsetX<0||firstY+c.offsetY<0||lastX+c.offsetX>=native.pixelWidth||lastY+c.offsetY>=native.pixelHeight){\n if(border===\"reject\")throw new InvalidConfigurationError(\"Reconstruction halo leaves native RAW; no padding or renormalization.\");\n // Mirror: check the virtual site from the repeating pattern; validateMirrorBorderCfaConsistency proves mirrored reads agree with it.\n const vx=phase.phaseX+c.offsetX,vy=phase.phaseY+c.offsetY;\n if(layout.siteChannelIds[((vy%layout.repeatHeightSites)+layout.repeatHeightSites)%layout.repeatHeightSites*layout.repeatWidthSites+((vx%layout.repeatWidthSites)+layout.repeatWidthSites)%layout.repeatWidthSites]!==c.sourceChannelId)\n throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n continue;\n }\n const channel=resolveColorSamplingSite({profile:plan.frame.colorSamplingProfile,site:{x:firstX+c.offsetX,y:firstY+c.offsetY}}).mapping.channelId;\n if(channel!==c.sourceChannelId)throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n }\n }\n let mirror:PreparedDevelopment[\"mirror\"];\n if(border===\"mirror\"){\n const reach=rawReconstructionKernelReach(phases);\n validateMirrorBorderCfaConsistency(layout,native.pixelWidth,native.pixelHeight,reach);\n mirror={nativeHeight:native.pixelHeight,reach};\n }\n return {plan,phases,color,profile,whiteBalance:r.whiteBalance,highlightMode,development,crop,raster,border,mirror};\n}\n/** Checks the numbers in rows [y0,y1). Values below black stay signed; each white-minus-black span is positive. Not exported from the package. */\nexport function checkNativeRawIntegrity(raw: NativeRawOutput, nativeWidth: number, repeatWidth: number, repeatHeight: number, y0: number, y1: number): void {\n const codes=raw.codes,blacks=raw.blackLevels,digital=raw.digitalSaturationCodes,flags=raw.saturationFlags,white=raw.effectiveSaturationCodes;\n for(let y=y0;y<y1;y++){\n const row=(y%repeatHeight)*repeatWidth;\n for(let x=0,i=y*nativeWidth;x<nativeWidth;x++,i++){\n const d=digital[i]!,w=white[row+x%repeatWidth]!,b=blacks[i]!;\n if(b>=w||w>d||codes[i]!>d||flags[i]!>7)throw new InvalidConfigurationError(\"Invalid packed RAW code span, white level or saturation flags.\");\n }\n }\n}\nfunction source(raw: NativeRawOutput, plan: NativeRawOutput[\"plan\"]): RawDevelopmentSource {\n const layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n return {nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,repeatWidth:layout.repeatWidthSites,repeatHeight:layout.repeatHeightSites,\n codes:raw.codes,blackLevels:raw.blackLevels,saturationFlags:raw.saturationFlags,whiteByPhase:raw.effectiveSaturationCodes};\n}\nfunction emptyDiagnostics(): SdrRenderingResult[\"diagnostics\"] {\n return {renderingNegativeSampleCount:0,renderingAboveReferenceSampleCount:0,toneChangedSampleCount:0,gamutClippedLowSampleCount:0,gamutClippedHighSampleCount:0,captureSaturation:\"consumed-in-raw-development\"};\n}\nfunction highlightOf(mode: RawHighlightMode, counts: RawDevelopmentCounts): RawHighlightDiagnostics {\n return {mode,saturatedPixelCount:counts.saturatedPixelCount,whiteBalanceClippedSampleCount:counts.whiteBalanceClippedSampleCount,reconstructedPixelCount:counts.reconstructedPixelCount};\n}\n/**\n * Internal, slow reference development using one object per step (not exported from the package). It is\n * kept to prove that the fast typed kernel gives byte-identical output.\n *\n * For each pixel it maps orientation with `transformOrientedRasterPointToNative`, gathers each channel\n * with `calculateRawReconstructionChannel`, develops with the shared colour operator, and renders\n * 256-pixel rows with the reference `calculateSdrRendering`. It does not take ownership of the RAW.\n */\nexport function developNativeRawReference(input: NativeRawDevelopmentInput): {integerSamples:number[];diagnostics:SdrRenderingResult[\"diagnostics\"];highlight:RawHighlightDiagnostics} {\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,src=source(input.raw,plan);\n checkNativeRawIntegrity(input.raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,0,plan.exposure.geometry.nativeRaster.pixelHeight);\n const counts=createRawDevelopmentCounts(),diagnostics=emptyDiagnostics(),out:number[]=[];\n for(let y=0;y<v.raster.pixelHeight;y++)for(let x=0;x<v.raster.pixelWidth;x+=TILE_WIDTH){\n const width=Math.min(TILE_WIDTH,v.raster.pixelWidth-x),rgb:number[]=[];\n for(let j=0;j<width;j++){\n const q=transformOrientedRasterPointToNative({point:{x:v.crop.x+x+j+.5,y:v.crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});\n const point={x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};\n const phase=v.phases[(point.y%src.repeatHeight)*src.repeatWidth+point.x%src.repeatWidth]!;\n let saturated=false;\n const values=phase.profile.kernels.map(kernel=>calculateRawReconstructionChannel(kernel,point,(sx,sy)=>{\n if(rawSiteSaturated(src,sx,sy))saturated=true;return normalizedRawSite(src,sx,sy);\n },v.mirror===undefined?undefined:{width:src.nativeWidth,height:v.mirror.nativeHeight}).linearBlackSubtractedNormalizedValue);\n if(saturated)counts.saturatedPixelCount++;\n const developed=[0,0,0];v.development.developInto(values[0]!,values[1]!,values[2]!,developed,0,counts);rgb.push(...developed);\n }\n const rendered=calculateSdrRendering({sourceImageStateId:plan.frame.frameId+\":developed\",inputImageState:\"color-transformed-linear-rgb\",inputColorSpace:\"linear-srgb-d65\",whiteBalanceHandling:plan.exposure.whiteBalanceIntent?\"already-applied-upstream\":\"not-required\",pixelWidth:width,pixelHeight:1,referenceWhiteValue:1,samples:rgb,profile:v.profile}).value;\n out.push(...rendered.integerSamples);\n for(const key of [\"renderingNegativeSampleCount\",\"renderingAboveReferenceSampleCount\",\"toneChangedSampleCount\",\"gamutClippedLowSampleCount\",\"gamutClippedHighSampleCount\"] as const)diagnostics[key]+=rendered.diagnostics[key];\n }\n return {integerSamples:out,diagnostics,highlight:highlightOf(v.highlightMode,counts)};\n}\nfunction sdrOutputEncoding(maximum: number): SdrRenderingResult[\"outputEncoding\"] {\n return {imageState:\"output-referred-sdr\",colorSpace:\"srgb\",primariesXy:{red:[.64,.33],green:[.30,.60],blue:[.15,.06]},whitePointXy:[.3127,.3290],referenceWhiteLuminanceCdM2:80,codeMinimum:0,codeMaximum:maximum};\n}\n/**\n * Creates a native RAW development task.\n *\n * It checks that every CFA phase has a reconstruction kernel and that every kernel neighbourhood is\n * available, takes ownership of the packed RAW (without copying where supported), and renders 256-pixel\n * output tiles with the fast typed kernel. Development scales each site to its CFA phase's effective white\n * level, clips flagged or white-level sites before white balance, and applies the selected highlight mode\n * (see `prepareSensorColorDevelopment`).\n *\n * The RAW numbers are checked in bounded chunks at the start of `run()`, with host yields, so creating the\n * task costs only as much as reading the metadata. The task yields to the host at chunk and tile boundaries\n * once about 8 ms of work has passed since the last yield, and after the final tile. Yield timing never\n * changes the output.\n *\n * `provider` is `{ yieldControl, onProgress? }`, the same shape as the other native task providers. A bare\n * yield function is still accepted in 2.x but is deprecated.\n *\n * The tile width used at capture is kept when rebuilding the exact packed plan. That width changes neither\n * CFA or noise-seed coordinates nor the developed pixels, and says nothing about transport or what a device\n * can handle.\n */\nexport function createNativeRawDevelopmentTask(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>)): NativeRawDevelopmentTask {\n return createNativeRawDevelopmentTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes output. Not exported from the package. */\nexport function createNativeRawDevelopmentTaskWithCadence(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>),cadence: HostYieldCadence): NativeRawDevelopmentTask {\n const hooks=typeof provider===\"function\"?{yieldControl:provider}:provider;\n if(!hooks||typeof hooks.yieldControl!==\"function\"||(hooks.onProgress!==undefined&&typeof hooks.onProgress!==\"function\"))throw new InvalidConfigurationError(\"Development requires a host event-loop yield.\");\n const yieldControl=hooks.yieldControl.bind(hooks),onProgress=hooks.onProgress?.bind(hooks);\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,raster=v.raster,crop=v.crop;\n const nativeHeight=plan.exposure.geometry.nativeRaster.pixelHeight;\n // Ownership is transferred only after every synchronous check has passed.\n const raw=takeNativeRawOwnership(input.raw,plan);\n const src=source(raw,plan),tilesPerRow=Math.ceil(raster.pixelWidth/TILE_WIDTH),totalTileCount=tilesPerRow*raster.pixelHeight;\n const abort=new AbortController();let state:NativeRawTaskState=\"ready\",output:NativeRawDevelopmentOutput|null=null,codes:Uint8Array|Uint16Array|null=null,completed=0;\n function release(): void {raw.codes.fill(0);raw.blackLevels.fill(0);raw.digitalSaturationCodes.fill(0);raw.saturationFlags.fill(0);raw.effectiveSaturationCodes.fill(0);codes?.fill(0);codes=null;output=null;}\n function check(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW development aborted.\");}\n /** Native coordinates of oriented output pixel (x, y) and the step to (x+1, y), both integer. */\n function rowMapping(x: number, y: number, width: number): {nx:number;ny:number;dx:number;dy:number} {\n const at=(j:number):{x:number;y:number}=>{const q=transformOrientedRasterPointToNative({point:{x:crop.x+x+j+.5,y:crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};};\n const first=at(0),second=width>1?at(1):first,dx=second.x-first.x,dy=second.y-first.y,last=at(width-1);\n if(Math.abs(dx)+Math.abs(dy)!==(width>1?1:0)||last.x!==first.x+dx*(width-1)||last.y!==first.y+dy*(width-1))throw new InvalidConfigurationError(\"Development orientation mapping is not a unit native step.\");\n return {nx:first.x,ny:first.y,dx,dy};\n }\n return {get state():NativeRawTaskState{return state;},get completedTileCount():number{return completed;},totalTileCount,\n async run():Promise<void>{\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Development task is single-use.\");state=\"running\";\n try{\n const gate=createHostYieldGate(cadence);\n const rowsPerChunk=Math.max(1,Math.floor(INTEGRITY_CHUNK_SITES/src.nativeWidth));\n for(let y=0;y<nativeHeight;y+=rowsPerChunk){\n check();checkNativeRawIntegrity(raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,y,Math.min(nativeHeight,y+rowsPerChunk));\n if(gate.due()){await yieldControl(abort.signal);check();gate.restart();}\n }\n codes=v.profile.bitDepth===8?new Uint8Array(raster.pixelWidth*raster.pixelHeight*3):new Uint16Array(raster.pixelWidth*raster.pixelHeight*3);\n const diagnostics=emptyDiagnostics(),developer=createRawPixelDeveloper(src,v.phases,v.development,v.mirror),tone=prepareSdrPixelTone(v.profile);\n const scale=2**v.profile.renderingExposureEv,maximum=2**v.profile.bitDepth-1,rgb=new Float64Array(TILE_WIDTH*3),scratch=new Float64Array(3);\n if(!Number.isFinite(scale)||scale<=0)throw new InvalidConfigurationError(\"Rendering scale is unrepresentable.\");\n for(let y=0;y<raster.pixelHeight;y++)for(let x=0;x<raster.pixelWidth;x+=TILE_WIDTH){\n check();const width=Math.min(TILE_WIDTH,raster.pixelWidth-x),map=rowMapping(x,y,width);\n const counts:SdrPixelCounts={negative:0,above:0,changed:0,low:0,high:0,outOfGamut:false};\n developer.developRun(map.nx,map.ny,map.dx,map.dy,width,rgb);\n renderSdrRunInto(rgb,0,width,v.profile,tone,scale,maximum,codes,(y*raster.pixelWidth+x)*3,scratch,counts);\n // Same 256-pixel granularity as the reference rows, so exposure errors come before gamut rejection.\n if(counts.outOfGamut)throw new InvalidConfigurationError(\"Tone output exceeds the declared SDR gamut range.\");\n diagnostics.renderingNegativeSampleCount+=counts.negative;diagnostics.renderingAboveReferenceSampleCount+=counts.above;diagnostics.toneChangedSampleCount+=counts.changed;\n diagnostics.gamutClippedLowSampleCount+=counts.low;diagnostics.gamutClippedHighSampleCount+=counts.high;\n completed++;onProgress?.({completedTileCount:completed,totalTileCount});\n if(gate.due()||(y===raster.pixelHeight-1&&x+TILE_WIDTH>=raster.pixelWidth)){await yieldControl(abort.signal);check();gate.restart();}\n }\n output={raw,phaseProfiles:v.phases,colorProfile:v.color,whiteBalance:v.whiteBalance,width:raster.pixelWidth,height:raster.pixelHeight,integerSamples:codes,diagnostics,\n highlight:highlightOf(v.highlightMode,developer.counts),borderHandling:v.border,rendering:v.profile,displayAdaptation:{kind:\"external-platform\",applied:false,displayCapabilities:\"unknown\"},\n outputEncoding:sdrOutputEncoding(maximum),imageDataPairing:\"derived-from-exact-packed-native-raw\",producerOriginVerified:false};state=\"completed\";\n }catch(error){release();if(!abort.signal.aborted){state=\"failed\";abort.abort();}throw error;}\n },\n cancel():void{if(state===\"ready\"||state===\"running\"||state===\"completed\"){state=\"cancelled\";abort.abort();release();}},\n dispose():void{if(state!==\"transferred\"){state=\"disposed\";abort.abort();release();}},\n takeOutput():NativeRawDevelopmentOutput{if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Development output unavailable.\");const value=output;output=null;codes=null;state=\"transferred\";return value;}\n };\n}\n"]}
1
+ {"version":3,"file":"native-raw-development.js","sourceRoot":"","sources":["../../src/capture/native-raw-development.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;GAIG;AACH,OAAO,EAAE,sBAAsB,EAAsE,MAAM,iBAAiB,CAAC;AAC7H,OAAO,EAAE,mCAAmC,EAA2C,MAAM,+BAA+B,CAAC;AAC7H,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,kCAAkC,EACpE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,6BAA6B,EAAiC,MAAM,0BAA0B,CAAC;AACxG,OAAO,EAAE,6BAA6B,E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AW,EAAC,CAAC;YAAA,KAAK,GAAC,WAAW,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACtH,OAAO,KAAQ,IAAG,KAAK,KAAG,aAAa,EAAC,CAAC;YAAA,KAAK,GAAC,UAAU,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACpF,UAAU,KAA8B,IAAG,KAAK,KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,iCAAiC,CAAC,CAAC,CAAA,MAAM,KAAK,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,KAAK,CAAC,CAAA,CAAC;KAC5N,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW development: turns packed RAW codes into an SDR image. It reconstructs full colour from\n * the CFA (colour filter array) mosaic exactly, then applies the shared colour, white-balance and SDR\n * steps, in bounded pixel tiles.\n */\nimport { calculateNativeRawPlan, type NativeRawInput, type NativeRawOutput, type NativeRawTaskState } from \"./native-raw.js\";\nimport { parseRawReconstructionPhaseProfiles, type RawFrameReconstructionPhaseProfile } from \"./raw-frame-reconstruction.js\";\nimport { calculateRawReconstructionChannel, rawReconstructionKernelReach, validateMirrorBorderCfaConsistency,\n type RawReconstructionBorderHandling } from \"../sensor/raw-reconstruction.js\";\nimport { equalWithinUlps } from \"../core/portable-math.js\";\nimport { resolveColorSamplingSite } from \"../sensor/color-sampling.js\";\nimport { parseExportSensorColorProfile, type ExportSensorColorProfile } from \"./photographic-export.js\";\nimport { prepareSensorColorDevelopment, type RawHighlightMode, type SensorColorDevelopment } from \"../color/sensor-color-development.js\";\nimport { calculateSdrRendering, parseSdrRenderingProfile, prepareSdrPixelTone, type SdrRenderingProfile, type SdrRenderingResult } from \"../output/sdr-rendering.js\";\nimport { renderSdrRunInto, type NativeTaskProgress, type SdrPixelCounts } from \"../output/native-capture-sdr.js\";\nimport { transformOrientedRasterPointToNative } from \"../output/capture-geometry.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence } from \"./host-yield-cadence.js\";\nimport { requireAllowlistedRecord } from \"../core/record-validation.js\";\nimport { stringifyCanonicalJson } from \"../core/canonical-json.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { createRawDevelopmentCounts, createRawPixelDeveloper, normalizedRawSite, rawSiteSaturated,\n type RawDevelopmentCounts, type RawDevelopmentSource } from \"./raw-development-kernel.js\";\n\nexport interface NativeRawDevelopmentInput {\n /**\n * Packed RAW. Ownership passes to the task. On creation its five typed arrays are detached with\n * `ArrayBuffer.prototype.transfer` (no copy; the caller's arrays become length 0), or copied when\n * the runtime has no `transfer`. The developed output hands back the same RAW, now owned by the output.\n */\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: \"not-required\" | \"apply-resolved-sensor-gains\";\n rendering: SdrRenderingProfile;\n /** Highlight handling. `clip` (default): clipped highlights become neutral. `reconstruct`: the documented blend toward neutral. */\n highlightMode?: RawHighlightMode;\n /**\n * Frame-edge handling. `reject` (default): every reconstruction neighbourhood must lie inside the\n * native RAW frame. `mirror`: a site outside the frame is read from its mirror image (reflect-101,\n * edge not repeated). This is allowed only when the mirrored site has the same CFA colour, which is\n * always true for a 2×2 Bayer pattern. Interior pixels are unchanged.\n */\n borderHandling?: RawReconstructionBorderHandling;\n /** Counts the kept packed RAW plus the integer output. It does not count caller buffers, process heap or GPU memory. */\n maximumRetainedPayloadBytes: number;\n}\n/** RAW saturation handled before white balance. Counts are pixels or samples of the developed output. */\nexport interface RawHighlightDiagnostics {\n mode: RawHighlightMode;\n /** Output pixels with at least one contributing site at or above its white level, or flagged as saturated. */\n saturatedPixelCount: number;\n /** `clip`: WB-scaled samples clipped at the smallest gain. Always 0 for `reconstruct`. */\n whiteBalanceClippedSampleCount: number;\n /** `reconstruct`: pixels blended toward neutral. Always 0 for `clip`. */\n reconstructedPixelCount: number;\n}\nexport interface NativeRawDevelopmentOutput {\n raw: NativeRawOutput;\n phaseProfiles: readonly RawFrameReconstructionPhaseProfile[];\n colorProfile: ExportSensorColorProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"];\n width: number;\n height: number;\n integerSamples: Uint8Array | Uint16Array;\n diagnostics: SdrRenderingResult[\"diagnostics\"];\n highlight: RawHighlightDiagnostics;\n borderHandling: RawReconstructionBorderHandling;\n outputEncoding: SdrRenderingResult[\"outputEncoding\"];\n rendering: SdrRenderingProfile;\n displayAdaptation: SdrRenderingResult[\"displayAdaptation\"];\n imageDataPairing: \"derived-from-exact-packed-native-raw\";\n producerOriginVerified: false;\n}\n/** Host callbacks, the same shape as the other native task providers but without a tile reader. */\nexport interface NativeRawDevelopmentProvider {\n /** Must yield to the host event loop, so cancellation and input events can run between tiles. */\n yieldControl(signal: AbortSignal): Promise<void>;\n /** Optional callback after each committed 256-pixel output tile. It cannot change the output. */\n onProgress?(progress: NativeTaskProgress): void;\n}\nexport interface NativeRawDevelopmentTask {\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n readonly totalTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawDevelopmentOutput;\n}\nconst TILE_WIDTH = 256;\n/** Sites checked per integrity chunk before checking whether it is time to yield. */\nconst INTEGRITY_CHUNK_SITES = 1 << 18;\nfunction canonical(value: unknown): string {\n return stringifyCanonicalJson(value,{undefinedObjectProperties:\"reject\",nonFiniteNumberMessage:\"Invalid RAW metadata.\",unsupportedValueMessage:\"Invalid RAW metadata.\"});\n}\n/** Validates packed RAW storage and recomputes its plan. Shared with the native DNG writer. Not exported from the package. */\nexport function validatePackedNativeRaw(raw: NativeRawOutput): NativeRawOutput[\"plan\"] {\n requireAllowlistedRecord(raw,[\"plan\",\"codes\",\"blackLevels\",\"digitalSaturationCodes\",\"saturationFlags\",\"effectiveSaturationCodes\"],\"Invalid packed RAW output.\");\n const p=raw.plan;\n if(!p?.exposure||!p.frame)throw new InvalidConfigurationError(\"Packed RAW requires complete exposure and frame metadata.\");\n const {engineApiVersion,resolvedGeometry,equivalentFocalLength35Mm,...exposure}=p.exposure;\n void engineApiVersion;void resolvedGeometry;\n const {capture,containerBitDepth,...frame}=p.frame;void containerBitDepth;\n const input: NativeRawInput={exposure,...frame,maximumOutputBytes:p.outputBytes,...(p.tileWidth===undefined?{}:{tileWidth:p.tileWidth}),...(p.maximumPixels===undefined?{}:{maximumPixels:p.maximumPixels}),...(p.exposureWindow?{exposureWindow:p.exposureWindow}:{})};\n const plan=calculateNativeRawPlan(input);\n // The recomputed 35 mm-equivalent focal length (also inside frame.capture, the same exposure record) may\n // differ by a few ULPs, so records parse in every JavaScript engine. Every other field must match exactly.\n const eq=plan.exposure.equivalentFocalLength35Mm,archivedFrameEq=(capture as unknown as Record<string,unknown>|undefined)?.equivalentFocalLength35Mm;\n if(typeof equivalentFocalLength35Mm!==\"number\"||!equalWithinUlps(equivalentFocalLength35Mm,eq,8)||typeof archivedFrameEq!==\"number\"||!equalWithinUlps(archivedFrameEq,eq,8)||\n canonical({...p,exposure:{...p.exposure,equivalentFocalLength35Mm:eq},frame:{...p.frame,capture:{...p.frame.capture,equivalentFocalLength35Mm:eq}}})!==canonical(plan))\n throw new InvalidConfigurationError(\"Packed RAW metadata is stale or inconsistent.\");\n const layout=plan.frame.colorSamplingProfile.layout,phaseCount=layout.kind===\"periodic-mosaic\"?layout.repeatWidthSites*layout.repeatHeightSites:0;\n const buffers=new Set<ArrayBufferLike>();\n for(const [a,type,length] of [[raw.codes,Uint16Array,plan.pixelCount],[raw.blackLevels,Uint16Array,plan.pixelCount],[raw.digitalSaturationCodes,Uint16Array,plan.pixelCount],\n [raw.saturationFlags,Uint8Array,plan.pixelCount],[raw.effectiveSaturationCodes,Uint16Array,phaseCount]] as const){\n if(!(a instanceof type)||!(a.buffer instanceof ArrayBuffer)||a.length!==length||a.buffer.byteLength!==a.byteLength||buffers.has(a.buffer))throw new InvalidConfigurationError(\"Packed RAW storage must be exact owned native arrays.\");\n buffers.add(a.buffer);\n }\n return plan;\n}\n/** Takes sole ownership: detaches without copying when the runtime supports ArrayBuffer transfer, otherwise copies. */\nfunction own<T extends Uint8Array<ArrayBuffer>|Uint16Array<ArrayBuffer>>(array: T, make: (buffer: ArrayBuffer)=>T): T {\n const buffer=array.buffer as ArrayBuffer&{transfer?:()=>ArrayBuffer};\n return typeof buffer.transfer===\"function\"?make(buffer.transfer()):make(buffer.slice(0));\n}\n/** Takes the validated packed RAW's arrays (without copying where supported). Not exported from the package. */\nexport function takeNativeRawOwnership(given: NativeRawOutput, plan: NativeRawOutput[\"plan\"]): NativeRawOutput {\n return {plan,codes:own(given.codes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),blackLevels:own(given.blackLevels as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),\n digitalSaturationCodes:own(given.digitalSaturationCodes as Uint16Array<ArrayBuffer>,b=>new Uint16Array(b)),saturationFlags:own(given.saturationFlags as Uint8Array<ArrayBuffer>,b=>new Uint8Array(b)),\n effectiveSaturationCodes:given.effectiveSaturationCodes.slice()};\n}\n/** Validated development metadata (internal; shared with the image-kernel accelerator). Not exported from the package. */\nexport interface PreparedDevelopment {\n plan: NativeRawOutput[\"plan\"]; phases: RawFrameReconstructionPhaseProfile[]; color: ExportSensorColorProfile; profile: SdrRenderingProfile;\n whiteBalance: NativeRawDevelopmentInput[\"whiteBalance\"]; highlightMode: RawHighlightMode; development: SensorColorDevelopment;\n crop: {x:number;y:number;width:number;height:number}; raster: {pixelWidth:number;pixelHeight:number};\n border: RawReconstructionBorderHandling; mirror: {nativeHeight:number;reach:number}|undefined;\n}\n/**\n * Synchronous checks of metadata, kernel halo (the neighbourhood each pixel reads) and CFA, shared by the\n * task, the reference and the accelerator. No pixel loop. Not exported from the package.\n */\nexport function prepareNativeRawDevelopment(input: NativeRawDevelopmentInput): PreparedDevelopment {\n const r=requireAllowlistedRecord(input,[\"raw\",\"phaseProfiles\",\"colorProfile\",\"whiteBalance\",\"rendering\",\"highlightMode\",\"borderHandling\",\"maximumRetainedPayloadBytes\"],\"Invalid native RAW development input.\");\n const plan=validatePackedNativeRaw(input.raw),g=plan.exposure.resolvedGeometry,native=plan.exposure.geometry.nativeRaster;\n const phases=freezeOwnedData(parseRawReconstructionPhaseProfiles(r.phaseProfiles,plan.frame.modeId,plan.frame.colorSamplingProfile));\n const color=freezeOwnedData(parseExportSensorColorProfile(r.colorProfile)),profile=freezeOwnedData(parseSdrRenderingProfile(r.rendering));\n const crop=g.output.cropRect,raster=g.output.raster,active=g.activeCapture.nativeRect,intent=plan.exposure.whiteBalanceIntent;\n const highlightMode=r.highlightMode===undefined?\"clip\":r.highlightMode;\n if(highlightMode!==\"clip\"&&highlightMode!==\"reconstruct\")throw new InvalidConfigurationError(\"Unsupported RAW highlight mode.\");\n const border=r.borderHandling===undefined?\"reject\":r.borderHandling;\n if(border!==\"reject\"&&border!==\"mirror\")throw new InvalidConfigurationError(\"Unsupported RAW border handling.\");\n if(color.colorSamplingProfileId!==plan.frame.colorSamplingProfile.profileId||phases.some(p=>canonical(p.profile.kernels.map(k=>k.outputChannelId))!==canonical(color.channelIds))||\n (r.whiteBalance!==\"not-required\"&&r.whiteBalance!==\"apply-resolved-sensor-gains\")||(intent!==null)!==(r.whiteBalance===\"apply-resolved-sensor-gains\")||\n raster.pixelWidth!==crop.width||raster.pixelHeight!==crop.height)throw new InvalidConfigurationError(\"Development requires bound sensor RGB, explicit one-time WB and 1:1 output crop.\");\n const bytes=plan.outputBytes+raster.pixelWidth*raster.pixelHeight*3*profile.bitDepth/8;\n if(typeof r.maximumRetainedPayloadBytes!==\"number\"||!Number.isSafeInteger(r.maximumRetainedPayloadBytes)||r.maximumRetainedPayloadBytes<bytes)throw new InvalidConfigurationError(\"Development exceeds retained output budget.\");\n const gains=intent?[intent.channelGains.red,intent.channelGains.green,intent.channelGains.blue]:null;\n const development=prepareSensorColorDevelopment(color.normalizedCameraChannelsToXyz,gains,highlightMode),layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n const nativeCorners=[{x:crop.x+.5,y:crop.y+.5},{x:crop.x+crop.width-.5,y:crop.y+crop.height-.5}].map(point=>{\n const p=transformOrientedRasterPointToNative({point,nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(p.x)+active.x,y:Math.floor(p.y)+active.y};\n });\n const minX=Math.min(...nativeCorners.map(p=>p.x)),maxX=Math.max(...nativeCorners.map(p=>p.x)),minY=Math.min(...nativeCorners.map(p=>p.y)),maxY=Math.max(...nativeCorners.map(p=>p.y));\n for(const phase of phases){\n const firstX=minX+(phase.phaseX-minX%layout.repeatWidthSites+layout.repeatWidthSites)%layout.repeatWidthSites;\n const firstY=minY+(phase.phaseY-minY%layout.repeatHeightSites+layout.repeatHeightSites)%layout.repeatHeightSites;\n if(firstX>maxX||firstY>maxY)continue;\n const lastX=maxX-(maxX-phase.phaseX+layout.repeatWidthSites)%layout.repeatWidthSites,lastY=maxY-(maxY-phase.phaseY+layout.repeatHeightSites)%layout.repeatHeightSites;\n for(const kernel of phase.profile.kernels)for(const c of kernel.contributions){\n if(firstX+c.offsetX<0||firstY+c.offsetY<0||lastX+c.offsetX>=native.pixelWidth||lastY+c.offsetY>=native.pixelHeight){\n if(border===\"reject\")throw new InvalidConfigurationError(\"Reconstruction halo leaves native RAW; no padding or renormalization.\");\n // Mirror: check the virtual site from the repeating pattern; validateMirrorBorderCfaConsistency proves mirrored reads agree with it.\n const vx=phase.phaseX+c.offsetX,vy=phase.phaseY+c.offsetY;\n if(layout.siteChannelIds[((vy%layout.repeatHeightSites)+layout.repeatHeightSites)%layout.repeatHeightSites*layout.repeatWidthSites+((vx%layout.repeatWidthSites)+layout.repeatWidthSites)%layout.repeatWidthSites]!==c.sourceChannelId)\n throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n continue;\n }\n const channel=resolveColorSamplingSite({profile:plan.frame.colorSamplingProfile,site:{x:firstX+c.offsetX,y:firstY+c.offsetY}}).mapping.channelId;\n if(channel!==c.sourceChannelId)throw new InvalidConfigurationError(\"Reconstruction source channel disagrees with absolute CFA phase.\");\n }\n }\n let mirror:PreparedDevelopment[\"mirror\"];\n if(border===\"mirror\"){\n const reach=rawReconstructionKernelReach(phases);\n validateMirrorBorderCfaConsistency(layout,native.pixelWidth,native.pixelHeight,reach);\n mirror={nativeHeight:native.pixelHeight,reach};\n }\n return {plan,phases,color,profile,whiteBalance:r.whiteBalance,highlightMode,development,crop,raster,border,mirror};\n}\n/** Checks the numbers in rows [y0,y1). Values below black stay signed; each white-minus-black span is positive. Not exported from the package. */\nexport function checkNativeRawIntegrity(raw: NativeRawOutput, nativeWidth: number, repeatWidth: number, repeatHeight: number, y0: number, y1: number): void {\n const codes=raw.codes,blacks=raw.blackLevels,digital=raw.digitalSaturationCodes,flags=raw.saturationFlags,white=raw.effectiveSaturationCodes;\n for(let y=y0;y<y1;y++){\n const row=(y%repeatHeight)*repeatWidth;\n for(let x=0,i=y*nativeWidth;x<nativeWidth;x++,i++){\n const d=digital[i]!,w=white[row+x%repeatWidth]!,b=blacks[i]!;\n if(b>=w||w>d||codes[i]!>d||flags[i]!>7)throw new InvalidConfigurationError(\"Invalid packed RAW code span, white level or saturation flags.\");\n }\n }\n}\nfunction source(raw: NativeRawOutput, plan: NativeRawOutput[\"plan\"]): RawDevelopmentSource {\n const layout=plan.frame.colorSamplingProfile.layout;\n if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Development requires periodic CFA.\");\n return {nativeWidth:plan.exposure.geometry.nativeRaster.pixelWidth,repeatWidth:layout.repeatWidthSites,repeatHeight:layout.repeatHeightSites,\n codes:raw.codes,blackLevels:raw.blackLevels,saturationFlags:raw.saturationFlags,whiteByPhase:raw.effectiveSaturationCodes};\n}\nfunction emptyDiagnostics(): SdrRenderingResult[\"diagnostics\"] {\n return {renderingNegativeSampleCount:0,renderingAboveReferenceSampleCount:0,toneChangedSampleCount:0,gamutClippedLowSampleCount:0,gamutClippedHighSampleCount:0,captureSaturation:\"consumed-in-raw-development\"};\n}\nfunction highlightOf(mode: RawHighlightMode, counts: RawDevelopmentCounts): RawHighlightDiagnostics {\n return {mode,saturatedPixelCount:counts.saturatedPixelCount,whiteBalanceClippedSampleCount:counts.whiteBalanceClippedSampleCount,reconstructedPixelCount:counts.reconstructedPixelCount};\n}\n/**\n * Internal, slow reference development using one object per step (not exported from the package). It is\n * kept to prove that the fast typed kernel gives byte-identical output.\n *\n * For each pixel it maps orientation with `transformOrientedRasterPointToNative`, gathers each channel\n * with `calculateRawReconstructionChannel`, develops with the shared colour operator, and renders\n * 256-pixel rows with the reference `calculateSdrRendering`. It does not take ownership of the RAW.\n */\nexport function developNativeRawReference(input: NativeRawDevelopmentInput): {integerSamples:number[];diagnostics:SdrRenderingResult[\"diagnostics\"];highlight:RawHighlightDiagnostics} {\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,src=source(input.raw,plan);\n checkNativeRawIntegrity(input.raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,0,plan.exposure.geometry.nativeRaster.pixelHeight);\n const counts=createRawDevelopmentCounts(),diagnostics=emptyDiagnostics(),out:number[]=[];\n for(let y=0;y<v.raster.pixelHeight;y++)for(let x=0;x<v.raster.pixelWidth;x+=TILE_WIDTH){\n const width=Math.min(TILE_WIDTH,v.raster.pixelWidth-x),rgb:number[]=[];\n for(let j=0;j<width;j++){\n const q=transformOrientedRasterPointToNative({point:{x:v.crop.x+x+j+.5,y:v.crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});\n const point={x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};\n const phase=v.phases[(point.y%src.repeatHeight)*src.repeatWidth+point.x%src.repeatWidth]!;\n let saturated=false;\n const values=phase.profile.kernels.map(kernel=>calculateRawReconstructionChannel(kernel,point,(sx,sy)=>{\n if(rawSiteSaturated(src,sx,sy))saturated=true;return normalizedRawSite(src,sx,sy);\n },v.mirror===undefined?undefined:{width:src.nativeWidth,height:v.mirror.nativeHeight}).linearBlackSubtractedNormalizedValue);\n if(saturated)counts.saturatedPixelCount++;\n const developed=[0,0,0];v.development.developInto(values[0]!,values[1]!,values[2]!,developed,0,counts);rgb.push(...developed);\n }\n const rendered=calculateSdrRendering({sourceImageStateId:plan.frame.frameId+\":developed\",inputImageState:\"color-transformed-linear-rgb\",inputColorSpace:\"linear-srgb-d65\",whiteBalanceHandling:plan.exposure.whiteBalanceIntent?\"already-applied-upstream\":\"not-required\",pixelWidth:width,pixelHeight:1,referenceWhiteValue:1,samples:rgb,profile:v.profile}).value;\n out.push(...rendered.integerSamples);\n for(const key of [\"renderingNegativeSampleCount\",\"renderingAboveReferenceSampleCount\",\"toneChangedSampleCount\",\"gamutClippedLowSampleCount\",\"gamutClippedHighSampleCount\"] as const)diagnostics[key]+=rendered.diagnostics[key];\n }\n return {integerSamples:out,diagnostics,highlight:highlightOf(v.highlightMode,counts)};\n}\nfunction sdrOutputEncoding(maximum: number): SdrRenderingResult[\"outputEncoding\"] {\n return {imageState:\"output-referred-sdr\",colorSpace:\"srgb\",primariesXy:{red:[.64,.33],green:[.30,.60],blue:[.15,.06]},whitePointXy:[.3127,.3290],referenceWhiteLuminanceCdM2:80,codeMinimum:0,codeMaximum:maximum};\n}\n/**\n * Creates a native RAW development task.\n *\n * It checks that every CFA phase has a reconstruction kernel and that every kernel neighbourhood is\n * available, takes ownership of the packed RAW (without copying where supported), and renders 256-pixel\n * output tiles with the fast typed kernel. Development scales each site to its CFA phase's effective white\n * level, clips flagged or white-level sites before white balance, and applies the selected highlight mode\n * (see `prepareSensorColorDevelopment`).\n *\n * The RAW numbers are checked in bounded chunks at the start of `run()`, with host yields, so creating the\n * task costs only as much as reading the metadata. The task yields to the host at chunk and tile boundaries\n * once about 8 ms of work has passed since the last yield, and after the final tile. Yield timing never\n * changes the output.\n *\n * `provider` is `{ yieldControl, onProgress? }`, the same shape as the other native task providers. A bare\n * yield function is still accepted in 2.x but is deprecated.\n *\n * The tile width used at capture is kept when rebuilding the exact packed plan. That width changes neither\n * CFA or noise-seed coordinates nor the developed pixels, and says nothing about transport or what a device\n * can handle.\n */\nexport function createNativeRawDevelopmentTask(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>)): NativeRawDevelopmentTask {\n return createNativeRawDevelopmentTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes output. Not exported from the package. */\nexport function createNativeRawDevelopmentTaskWithCadence(input: NativeRawDevelopmentInput,\n provider: NativeRawDevelopmentProvider | ((signal:AbortSignal)=>Promise<void>),cadence: HostYieldCadence): NativeRawDevelopmentTask {\n const hooks=typeof provider===\"function\"?{yieldControl:provider}:provider;\n if(!hooks||typeof hooks.yieldControl!==\"function\"||(hooks.onProgress!==undefined&&typeof hooks.onProgress!==\"function\"))throw new InvalidConfigurationError(\"Development requires a host event-loop yield.\");\n const yieldControl=hooks.yieldControl.bind(hooks),onProgress=hooks.onProgress?.bind(hooks);\n const v=prepareNativeRawDevelopment(input),plan=v.plan,g=plan.exposure.resolvedGeometry,active=g.activeCapture.nativeRect,raster=v.raster,crop=v.crop;\n const nativeHeight=plan.exposure.geometry.nativeRaster.pixelHeight;\n // Ownership is transferred only after every synchronous check has passed.\n const raw=takeNativeRawOwnership(input.raw,plan);\n const src=source(raw,plan),tilesPerRow=Math.ceil(raster.pixelWidth/TILE_WIDTH),totalTileCount=tilesPerRow*raster.pixelHeight;\n const abort=new AbortController();let state:NativeRawTaskState=\"ready\",output:NativeRawDevelopmentOutput|null=null,codes:Uint8Array|Uint16Array|null=null,completed=0;\n function release(): void {raw.codes.fill(0);raw.blackLevels.fill(0);raw.digitalSaturationCodes.fill(0);raw.saturationFlags.fill(0);raw.effectiveSaturationCodes.fill(0);codes?.fill(0);codes=null;output=null;}\n function check(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW development aborted.\");}\n /** Native coordinates of oriented output pixel (x, y) and the step to (x+1, y), both integer. */\n function rowMapping(x: number, y: number, width: number): {nx:number;ny:number;dx:number;dy:number} {\n const at=(j:number):{x:number;y:number}=>{const q=transformOrientedRasterPointToNative({point:{x:crop.x+x+j+.5,y:crop.y+y+.5},nativeRaster:g.activeCapture.raster,orientation:plan.exposure.geometry.orientation});return {x:Math.floor(q.x)+active.x,y:Math.floor(q.y)+active.y};};\n const first=at(0),second=width>1?at(1):first,dx=second.x-first.x,dy=second.y-first.y,last=at(width-1);\n if(Math.abs(dx)+Math.abs(dy)!==(width>1?1:0)||last.x!==first.x+dx*(width-1)||last.y!==first.y+dy*(width-1))throw new InvalidConfigurationError(\"Development orientation mapping is not a unit native step.\");\n return {nx:first.x,ny:first.y,dx,dy};\n }\n return {get state():NativeRawTaskState{return state;},get completedTileCount():number{return completed;},totalTileCount,\n async run():Promise<void>{\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Development task is single-use.\");state=\"running\";\n try{\n const gate=createHostYieldGate(cadence);\n const rowsPerChunk=Math.max(1,Math.floor(INTEGRITY_CHUNK_SITES/src.nativeWidth));\n for(let y=0;y<nativeHeight;y+=rowsPerChunk){\n check();checkNativeRawIntegrity(raw,src.nativeWidth,src.repeatWidth,src.repeatHeight,y,Math.min(nativeHeight,y+rowsPerChunk));\n if(gate.due()){await yieldControl(abort.signal);check();gate.restart();}\n }\n codes=v.profile.bitDepth===8?new Uint8Array(raster.pixelWidth*raster.pixelHeight*3):new Uint16Array(raster.pixelWidth*raster.pixelHeight*3);\n const diagnostics=emptyDiagnostics(),developer=createRawPixelDeveloper(src,v.phases,v.development,v.mirror),tone=prepareSdrPixelTone(v.profile);\n const scale=2**v.profile.renderingExposureEv,maximum=2**v.profile.bitDepth-1,rgb=new Float64Array(TILE_WIDTH*3),scratch=new Float64Array(3);\n if(!Number.isFinite(scale)||scale<=0)throw new InvalidConfigurationError(\"Rendering scale is unrepresentable.\");\n for(let y=0;y<raster.pixelHeight;y++)for(let x=0;x<raster.pixelWidth;x+=TILE_WIDTH){\n check();const width=Math.min(TILE_WIDTH,raster.pixelWidth-x),map=rowMapping(x,y,width);\n const counts:SdrPixelCounts={negative:0,above:0,changed:0,low:0,high:0,outOfGamut:false};\n developer.developRun(map.nx,map.ny,map.dx,map.dy,width,rgb);\n renderSdrRunInto(rgb,0,width,v.profile,tone,scale,maximum,codes,(y*raster.pixelWidth+x)*3,scratch,counts);\n // Same 256-pixel granularity as the reference rows, so exposure errors come before gamut rejection.\n if(counts.outOfGamut)throw new InvalidConfigurationError(\"Tone output exceeds the declared SDR gamut range.\");\n diagnostics.renderingNegativeSampleCount+=counts.negative;diagnostics.renderingAboveReferenceSampleCount+=counts.above;diagnostics.toneChangedSampleCount+=counts.changed;\n diagnostics.gamutClippedLowSampleCount+=counts.low;diagnostics.gamutClippedHighSampleCount+=counts.high;\n completed++;onProgress?.({completedTileCount:completed,totalTileCount});\n if(gate.due()||(y===raster.pixelHeight-1&&x+TILE_WIDTH>=raster.pixelWidth)){await yieldControl(abort.signal);check();gate.restart();}\n }\n output={raw,phaseProfiles:v.phases,colorProfile:v.color,whiteBalance:v.whiteBalance,width:raster.pixelWidth,height:raster.pixelHeight,integerSamples:codes,diagnostics,\n highlight:highlightOf(v.highlightMode,developer.counts),borderHandling:v.border,rendering:v.profile,displayAdaptation:{kind:\"external-platform\",applied:false,displayCapabilities:\"unknown\"},\n outputEncoding:sdrOutputEncoding(maximum),imageDataPairing:\"derived-from-exact-packed-native-raw\",producerOriginVerified:false};state=\"completed\";\n }catch(error){release();if(!abort.signal.aborted){state=\"failed\";abort.abort();}throw error;}\n },\n cancel():void{if(state===\"ready\"||state===\"running\"||state===\"completed\"){state=\"cancelled\";abort.abort();release();}},\n dispose():void{if(state!==\"transferred\"){state=\"disposed\";abort.abort();release();}},\n takeOutput():NativeRawDevelopmentOutput{if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Development output unavailable.\");const value=output;output=null;codes=null;state=\"transferred\";return value;}\n };\n}\n"]}
@@ -7,8 +7,10 @@ import { type HostYieldCadence, type HostYieldGate } from "./host-yield-cadence.
7
7
  import { calculateCaptureExposureWindows } from "../sensor/exposure-window.js";
8
8
  import { calculateNativeRawSite, type NativeRawProducerFrameContext, type SensorRawProducerSiteInput, type SensorRawProducerExposureWindowInput } from "./sensor-raw-producer.js";
9
9
  export declare const NATIVE_RAW_SCHEMA_VERSION: "0.1.0";
10
+ /** `maximumPixels` is the default pixel limit; a request may raise it with its own `maximumPixels`, up to `ceilingPixels`. */
10
11
  export declare const NATIVE_RAW_LIMITS: Readonly<{
11
12
  maximumPixels: 24000000;
13
+ ceilingPixels: 134217728;
12
14
  maximumDimension: 16384;
13
15
  tileWidth: 256;
14
16
  tileHeight: 1;
@@ -32,6 +34,13 @@ export interface NativeRawInput {
32
34
  maximumOutputBytes: number;
33
35
  /** Optional tile width for execution, in native sites, 1–256. Default 256. It does not affect sampling. */
34
36
  tileWidth?: number;
37
+ /**
38
+ * Optional opt-in pixel limit for large sensors: an integer from 1 to `NATIVE_RAW_LIMITS.ceilingPixels`.
39
+ * Default `NATIVE_RAW_LIMITS.maximumPixels` (24 000 000). `maximumOutputBytes` still applies. A raised limit
40
+ * also raises the native environment tasks' whole-event query budget ceiling in proportion
41
+ * (2 000 000 000 per 24 000 000 pixels). It does not affect sampling.
42
+ */
43
+ maximumPixels?: number;
35
44
  }
36
45
  export interface NativeRawPlan {
37
46
  schemaVersion: typeof NATIVE_RAW_SCHEMA_VERSION;
@@ -43,6 +52,8 @@ export interface NativeRawPlan {
43
52
  tileCount: number;
44
53
  /** Present only when an execution tile width was given. Otherwise the plan keeps its earlier shape. */
45
54
  tileWidth?: number;
55
+ /** Present only when a pixel limit was given. Otherwise the plan keeps its earlier shape. */
56
+ maximumPixels?: number;
46
57
  upstreamRadiometryVerified: false;
47
58
  seedSchedule: "murmur3-capture-seed-native-index-stream-v2";
48
59
  }
@@ -109,6 +120,11 @@ export interface NativeRawTask {
109
120
  }
110
121
  /** Plans the task and checks the image size, resources and profiles before any callback or output allocation. No placeholder plane is made. */
111
122
  export declare function calculateNativeRawPlan(input: NativeRawInput): NativeRawPlan;
123
+ /**
124
+ * Internal: the largest whole-event radiance query budget a native environment task admits for this plan:
125
+ * 2 000 000 000, scaled in proportion when the plan raised its pixel limit above 24 000 000. Not exported from the package.
126
+ */
127
+ export declare function nativeRawMaximumProviderEvaluations(plan: Pick<NativeRawPlan, "maximumPixels">): number;
112
128
  /**
113
129
  * Runs validated per-site events (EQE photo signal, dark signal, charge completeness) through the shared
114
130
  * reference per-site physics.
@@ -8,6 +8,7 @@ import { ENGINE_API_VERSION } from "../core/version.js";
8
8
  import { InvalidConfigurationError } from "../core/configuration-error.js";
9
9
  import { requireAllowlistedRecord, requirePublicOpaqueId } from "../core/record-validation.js";
10
10
  import { freezeOwnedData } from "../core/owned-data.js";
11
+ import { FULL_RESOLUTION_CEILING_PIXELS, resolveRaisedLimit, scaleBudgetCeiling } from "../core/pixel-limits.js";
11
12
  import { calculateSiteEffectiveSaturationCode, createPhaseWhiteLevelAccumulator } from "./raw-white-level.js";
12
13
  import { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate } from "./host-yield-cadence.js";
13
14
  import { parseCaptureModeProfile } from "../sensor/capture-mode.js";
@@ -16,8 +17,11 @@ import { parseNativeEffectiveRasterColorSamplingBindingProfile, resolveCaptureMo
16
17
  import { calculateCaptureExposureWindows } from "../sensor/exposure-window.js";
17
18
  import { SENSOR_RAW_PRODUCER_NOISE_MODEL, calculateNativeRawSite, parseNativeRawProducerSite, validateNativeRawReadoutIdentity } from "./sensor-raw-producer.js";
18
19
  export const NATIVE_RAW_SCHEMA_VERSION = "0.1.0";
19
- export const NATIVE_RAW_LIMITS = Object.freeze({ maximumPixels: 24_000_000, maximumDimension: 16_384,
20
+ /** `maximumPixels` is the default pixel limit; a request may raise it with its own `maximumPixels`, up to `ceilingPixels`. */
21
+ export const NATIVE_RAW_LIMITS = Object.freeze({ maximumPixels: 24_000_000, ceilingPixels: FULL_RESOLUTION_CEILING_PIXELS, maximumDimension: 16_384,
20
22
  tileWidth: 256, tileHeight: 1, outputBytesPerPixel: 7 });
23
+ /** Default whole-event radiance query budget ceiling of the native environment tasks; it scales with a raised `maximumPixels`. */
24
+ const DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS = 2_000_000_000;
21
25
  function windows(exposure, schedule, points) {
22
26
  const r = requireAllowlistedRecord(schedule, ["shutterMechanism", "nominalExposureDurationSeconds", "opening", "closing"], "Invalid RAW exposure schedule.");
23
27
  requireAllowlistedRecord(r.nominalExposureDurationSeconds, ["value", "unit", "evidence"], "Invalid RAW nominal exposure.");
@@ -35,13 +39,14 @@ function windows(exposure, schedule, points) {
35
39
  }
36
40
  /** Plans the task and checks the image size, resources and profiles before any callback or output allocation. No placeholder plane is made. */
37
41
  export function calculateNativeRawPlan(input) {
38
- const r = requireAllowlistedRecord(input, ["exposure", "frameId", "modeId", "captureModeProfile", "colorSamplingProfile", "bindingProfile", "exposureWindow", "maximumOutputBytes", "tileWidth"], "Invalid native RAW input.");
42
+ const r = requireAllowlistedRecord(input, ["exposure", "frameId", "modeId", "captureModeProfile", "colorSamplingProfile", "bindingProfile", "exposureWindow", "maximumOutputBytes", "tileWidth", "maximumPixels"], "Invalid native RAW input.");
39
43
  if (r.tileWidth !== undefined && (typeof r.tileWidth !== "number" || !Number.isSafeInteger(r.tileWidth) || r.tileWidth < 1 || r.tileWidth > NATIVE_RAW_LIMITS.tileWidth))
40
44
  throw new InvalidConfigurationError("Native RAW tile width must be an integer from 1 to 256.");
41
45
  const tileWidth = r.tileWidth ?? NATIVE_RAW_LIMITS.tileWidth;
46
+ const maximumPixels = resolveRaisedLimit(r.maximumPixels, NATIVE_RAW_LIMITS.maximumPixels, NATIVE_RAW_LIMITS.ceilingPixels, "Native RAW maximumPixels must be an integer from 1 to " + NATIVE_RAW_LIMITS.ceilingPixels + ".");
42
47
  const exposure = normalizeCaptureExposureMetadata(r.exposure, ENGINE_API_VERSION, true), native = exposure.geometry.nativeRaster;
43
48
  const pixelCount = native.pixelWidth * native.pixelHeight, outputBytes = pixelCount * NATIVE_RAW_LIMITS.outputBytesPerPixel;
44
- if (pixelCount > NATIVE_RAW_LIMITS.maximumPixels || native.pixelWidth > NATIVE_RAW_LIMITS.maximumDimension || native.pixelHeight > NATIVE_RAW_LIMITS.maximumDimension ||
49
+ if (pixelCount > maximumPixels || native.pixelWidth > NATIVE_RAW_LIMITS.maximumDimension || native.pixelHeight > NATIVE_RAW_LIMITS.maximumDimension ||
45
50
  !Number.isSafeInteger(r.maximumOutputBytes) || typeof r.maximumOutputBytes !== "number" || r.maximumOutputBytes < outputBytes)
46
51
  throw new InvalidConfigurationError("Native RAW raster exceeds output admission budget.");
47
52
  const frame = { frameId: requirePublicOpaqueId(r.frameId, "Invalid RAW frame ID."), capture: exposure,
@@ -65,9 +70,17 @@ export function calculateNativeRawPlan(input) {
65
70
  return freezeOwnedData({ schemaVersion: NATIVE_RAW_SCHEMA_VERSION, exposure, frame, pixelCount, outputBytes,
66
71
  tileCount: Math.ceil(native.pixelWidth / tileWidth) * native.pixelHeight,
67
72
  ...(r.tileWidth === undefined ? {} : { tileWidth }),
73
+ ...(r.maximumPixels === undefined ? {} : { maximumPixels }),
68
74
  ...(schedule ? { exposureWindow: schedule } : {}), upstreamRadiometryVerified: false,
69
75
  seedSchedule: "murmur3-capture-seed-native-index-stream-v2" });
70
76
  }
77
+ /**
78
+ * Internal: the largest whole-event radiance query budget a native environment task admits for this plan:
79
+ * 2 000 000 000, scaled in proportion when the plan raised its pixel limit above 24 000 000. Not exported from the package.
80
+ */
81
+ export function nativeRawMaximumProviderEvaluations(plan) {
82
+ return plan.maximumPixels === undefined ? DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS : scaleBudgetCeiling(DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS, plan.maximumPixels);
83
+ }
71
84
  /**
72
85
  * Runs validated per-site events (EQE photo signal, dark signal, charge completeness) through the shared
73
86
  * reference per-site physics.
@@ -1 +1 @@
1
- {"version":3,"file":"native-raw.js","sourceRoot":"","sources":["../../src/capture/native-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAE,gCAAgC,EAAiF,MAAM,wBAAwB,CAAC;AACzJ,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oCAAoC,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAA6C,MAAM,yBAAyB,CAAC;AACrI,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,qDAAqD,EAAE,2CAA2C,EAAE,MAAM,6CAA6C,CAAC;AACjK,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,0BAA0B,EAC1F,gCAAgC,EACW,MAAM,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,CAAC,KAAK,EAAE,CAAC;gBAAA,CAAC;gBAAA,MAAM,KAAK,CAAC;YAAA,CAAC;QAC/F,CAAC;QACD,MAAM,KAAU,IAAG,KAAK,KAAG,OAAO,IAAE,KAAK,KAAG,SAAS,IAAE,KAAK,KAAG,WAAW,EAAC,CAAC;YAAA,KAAK,GAAC,WAAW,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACxH,OAAO,KAAU,IAAG,KAAK,KAAG,aAAa,EAAC,CAAC;YAAA,KAAK,GAAC,UAAU,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACtF,UAAU,KAAqB,IAAG,KAAK,KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,gCAAgC,CAAC,CAAC,CAAA,MAAM,MAAM,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,SAAS,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,MAAM,CAAC,CAAA,CAAC;KACzN,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture with the existing per-site (scalar) RAW model: an up-front plan and limit check from\n * metadata only, then bounded tile-by-tile execution.\n */\nimport { normalizeCaptureExposureMetadata, type SimulatedCaptureInput, type SimulatedCapture, type CaptureExposureSource } from \"./simulated-capture.js\";\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { calculateSiteEffectiveSaturationCode, createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence, type HostYieldGate } from \"./host-yield-cadence.js\";\nimport { parseCaptureModeProfile } from \"../sensor/capture-mode.js\";\nimport { parseSensorColorSamplingProfile } from \"../sensor/color-sampling.js\";\nimport { parseNativeEffectiveRasterColorSamplingBindingProfile, resolveCaptureModeColorSamplingContributors } from \"../sensor/capture-color-sampling-binding.js\";\nimport { calculateCaptureExposureWindows } from \"../sensor/exposure-window.js\";\nimport { SENSOR_RAW_PRODUCER_NOISE_MODEL, calculateNativeRawSite, parseNativeRawProducerSite,\n validateNativeRawReadoutIdentity, type NativeRawProducerFrameContext, type SensorRawProducerSiteInput,\n type SensorRawProducerExposureWindowInput } from \"./sensor-raw-producer.js\";\n\nexport const NATIVE_RAW_SCHEMA_VERSION = \"0.1.0\" as const;\nexport const NATIVE_RAW_LIMITS = Object.freeze({ maximumPixels: 24_000_000, maximumDimension: 16_384,\n tileWidth: 256, tileHeight: 1, outputBytesPerPixel: 7 });\n/** A shooting event and where its source came from. Not a finished float master or committed RAW frame. */\nexport type NativeRawExposureInput = Omit<SimulatedCaptureInput, \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport type NativeRawExposure = Omit<SimulatedCapture, \"schemaVersion\" | \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport interface NativeRawInput {\n exposure: NativeRawExposureInput;\n frameId: string;\n modeId: string;\n captureModeProfile: NativeRawProducerFrameContext[\"captureModeProfile\"];\n colorSamplingProfile: NativeRawProducerFrameContext[\"colorSamplingProfile\"];\n bindingProfile: NativeRawProducerFrameContext[\"bindingProfile\"];\n exposureWindow?: SensorRawProducerExposureWindowInput;\n maximumOutputBytes: number;\n /** Optional tile width for execution, in native sites, 1–256. Default 256. It does not affect sampling. */\n tileWidth?: number;\n}\nexport interface NativeRawPlan {\n schemaVersion: typeof NATIVE_RAW_SCHEMA_VERSION;\n exposure: NativeRawExposure;\n frame: NativeRawProducerFrameContext;\n exposureWindow?: SensorRawProducerExposureWindowInput;\n pixelCount: number;\n outputBytes: number;\n tileCount: number;\n /** Present only when an execution tile width was given. Otherwise the plan keeps its earlier shape. */\n tileWidth?: number;\n upstreamRadiometryVerified: false;\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\";\n}\n/** Tile rectangle, in absolute full-sensor CFA coordinates, before orientation, active-area crop or output scaling. */\nexport interface NativeRawTileRequest { captureId: string; frameId: string; x: number; y: number; width: number; height: number }\nexport interface NativeRawTile extends NativeRawTileRequest { sites: readonly SensorRawProducerSiteInput[] }\nexport interface NativeRawProvider {\n readTile(request: Readonly<NativeRawTileRequest>, signal: AbortSignal): Promise<NativeRawTile>;\n yieldControl(signal: AbortSignal): Promise<void>;\n}\n/** Row-major arrays owned only by the output. They cannot be attached to the bounded SensorRawFrame type. */\nexport interface NativeRawOutput {\n plan: NativeRawPlan;\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n /** Saturation flags. Bit 0: physical charge clamp; bit 1: pre-ADC clamp; bit 2: digital saturation. */\n saturationFlags: Uint8Array;\n /**\n * Effective white (full-saturation) code for each absolute CFA repeat phase, indexed\n * `phaseY*repeatWidthSites+phaseX`: min(digital saturation, round(black + min(capacity, pre-ADC\n * saturation)/gain)). See `calculateEffectiveSaturationCode`. A few bytes, not one value per pixel.\n */\n effectiveSaturationCodes: Uint16Array;\n}\n/** Internal: lean per-site outputs of an engine-built site (see native-environment-lean.ts). */\nexport interface NativeRawLeanOutput { rawCode: number; blackLevelCode: number; digitalSaturationCode: number; flags: number; whiteCode: number }\n/**\n * Internal hook for tiles the engine builds itself (native environment RAW).\n *\n * claim() recognizes only entries the hook itself created, for sites whose parsing and identity checks are\n * provably redundant. compute() returns the outputs calculateNativeRawSite would produce, falling back to it\n * internally. observe() sees every fully computed site.\n */\nexport interface NativeRawLeanSensorHook {\n claim(site: unknown): object | undefined;\n compute(handle: object, index: number, seed: number, timing: ReturnType<typeof calculateCaptureExposureWindows>[\"value\"][\"samples\"][number] | undefined): NativeRawLeanOutput;\n observe(index: number, parsed: SensorRawProducerSiteInput, result: ReturnType<typeof calculateNativeRawSite>, whiteCode: number, seed: number): void;\n}\nexport type NativeRawTaskState = \"ready\" | \"running\" | \"completed\" | \"cancelled\" | \"failed\" | \"disposed\" | \"transferred\";\nexport interface NativeRawTask {\n readonly plan: NativeRawPlan;\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawOutput;\n}\nfunction windows(exposure: NativeRawExposure, schedule: SensorRawProducerExposureWindowInput,\n points: readonly {x:number;y:number}[]): ReturnType<typeof calculateCaptureExposureWindows>[\"value\"] {\n const r=requireAllowlistedRecord(schedule,[\"shutterMechanism\",\"nominalExposureDurationSeconds\",\"opening\",\"closing\"],\"Invalid RAW exposure schedule.\");\n requireAllowlistedRecord(r.nominalExposureDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW nominal exposure.\");\n for(const boundary of [r.opening,r.closing]){\n const b=requireAllowlistedRecord(boundary,[\"kind\",\"directionNative\",\"traversalDurationSeconds\"],\"Invalid RAW exposure boundary.\");\n if(b.directionNative!==undefined)requireAllowlistedRecord(b.directionNative,[\"value\",\"evidence\"],\"Invalid RAW scan direction.\");\n if(b.traversalDurationSeconds!==undefined)requireAllowlistedRecord(b.traversalDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW scan duration.\");\n }\n const result=calculateCaptureExposureWindows({...schedule,nativeRaster:exposure.geometry.nativeRaster,samplePointsNative:points});\n if(result.value.nominalExposureDurationSeconds.value!==exposure.exposure.shutterSeconds)throw new InvalidConfigurationError(\"RAW schedule differs from exposure duration.\");\n return result.value;\n}\n/** Plans the task and checks the image size, resources and profiles before any callback or output allocation. No placeholder plane is made. */\nexport function calculateNativeRawPlan(input: NativeRawInput): NativeRawPlan {\n const r=requireAllowlistedRecord(input,[\"exposure\",\"frameId\",\"modeId\",\"captureModeProfile\",\"colorSamplingProfile\",\"bindingProfile\",\"exposureWindow\",\"maximumOutputBytes\",\"tileWidth\"],\"Invalid native RAW input.\");\n if(r.tileWidth!==undefined&&(typeof r.tileWidth!==\"number\"||!Number.isSafeInteger(r.tileWidth)||r.tileWidth<1||r.tileWidth>NATIVE_RAW_LIMITS.tileWidth))\n throw new InvalidConfigurationError(\"Native RAW tile width must be an integer from 1 to 256.\");\n const tileWidth=(r.tileWidth as number|undefined)??NATIVE_RAW_LIMITS.tileWidth;\n const exposure=normalizeCaptureExposureMetadata(r.exposure,ENGINE_API_VERSION,true),native=exposure.geometry.nativeRaster;\n const pixelCount=native.pixelWidth*native.pixelHeight,outputBytes=pixelCount*NATIVE_RAW_LIMITS.outputBytesPerPixel;\n if(pixelCount>NATIVE_RAW_LIMITS.maximumPixels||native.pixelWidth>NATIVE_RAW_LIMITS.maximumDimension||native.pixelHeight>NATIVE_RAW_LIMITS.maximumDimension||\n !Number.isSafeInteger(r.maximumOutputBytes)||typeof r.maximumOutputBytes!==\"number\"||r.maximumOutputBytes<outputBytes)throw new InvalidConfigurationError(\"Native RAW raster exceeds output admission budget.\");\n const frame={frameId:requirePublicOpaqueId(r.frameId,\"Invalid RAW frame ID.\"),capture:exposure,\n modeId:requirePublicOpaqueId(r.modeId,\"Invalid RAW mode ID.\"),containerBitDepth:16 as const,\n captureModeProfile:parseCaptureModeProfile(r.captureModeProfile),colorSamplingProfile:parseSensorColorSamplingProfile(r.colorSamplingProfile),\n bindingProfile:parseNativeEffectiveRasterColorSamplingBindingProfile(r.bindingProfile)};\n const mode=frame.captureModeProfile.modes.find(m=>m.modeId===frame.modeId);\n if(exposure.noise.model.id!==SENSOR_RAW_PRODUCER_NOISE_MODEL.id||exposure.noise.model.version!==SENSOR_RAW_PRODUCER_NOISE_MODEL.version||\n frame.colorSamplingProfile.layout.kind!==\"periodic-mosaic\"||mode?.acquisition.kind!==\"single-frame\"||mode.perFrameSampling.kind!==\"native-effective-raster\"||(mode.reconstructionStages?.length??0)!==0)\n throw new InvalidConfigurationError(\"Native RAW requires exact noise identity and single-frame native periodic CFA.\");\n // The binding is one affine mapping for the whole frame, so checking both corners covers it. Do this before any provider work.\n for(const p of [{x:0,y:0},{x:native.pixelWidth-1,y:native.pixelHeight-1}]){\n const c=resolveCaptureModeColorSamplingContributors({nativeRaster:native,captureModeProfile:frame.captureModeProfile,modeId:frame.modeId,colorSamplingProfile:frame.colorSamplingProfile,bindingProfile:frame.bindingProfile,modeSampleIndexFullFrame:p});\n if(c.totalContributorSites!==1||c.channelComposition.kind!==\"single-channel\")throw new InvalidConfigurationError(\"Native RAW must preserve one native CFA site per sample.\");\n }\n const schedule=r.exposureWindow===undefined?undefined:structuredClone(r.exposureWindow) as SensorRawProducerExposureWindowInput;\n // For the supported linear scans, the extreme values occur at the image corners. Check them before capture.\n if(schedule)windows(exposure,schedule,[{x:.5,y:.5},{x:native.pixelWidth-.5,y:.5},{x:.5,y:native.pixelHeight-.5},{x:native.pixelWidth-.5,y:native.pixelHeight-.5}]);\n return freezeOwnedData({schemaVersion:NATIVE_RAW_SCHEMA_VERSION,exposure,frame,pixelCount,outputBytes,\n tileCount:Math.ceil(native.pixelWidth/tileWidth)*native.pixelHeight,\n ...(r.tileWidth===undefined?{}:{tileWidth}),\n ...(schedule?{exposureWindow:schedule}:{}),upstreamRadiometryVerified:false as const,\n seedSchedule:\"murmur3-capture-seed-native-index-stream-v2\" as const});\n}\n/**\n * Runs validated per-site events (EQE photo signal, dark signal, charge completeness) through the shared\n * reference per-site physics.\n *\n * Tiles are read and committed one at a time. The task yields to the host at tile boundaries once about\n * 8 ms of work has passed since the last yield, and after the final tile. It checks for cancellation\n * before every tile, after every read and after every yield.\n */\nexport function createNativeRawTask(input: NativeRawInput,provider: NativeRawProvider): NativeRawTask {\n return createNativeRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, seeds or output. Not exported from the package. */\nexport function createNativeRawTaskWithCadence(input: NativeRawInput,provider: NativeRawProvider,cadence: HostYieldCadence,\n /** Internal: a yield timer shared with a provider that also yields inside readTile, so both use one time budget. */\n sharedGate?: HostYieldGate,\n /** Internal: faster (\"lean\") per-site sensor execution for engine-built tiles. It never changes output or errors. */\n leanSensor?: NativeRawLeanSensorHook,\n /**\n * Internal: run only native rows [y, y + height) (a partition). The output arrays then hold just those rows, and\n * effectiveSaturationCodes holds 0 for CFA phases the rows do not contain; the merge step completes them.\n * Seeds, tiles and per-site values are those of the whole-frame task.\n */\n rows?: { readonly y: number; readonly height: number; readonly firstSite?: (site: SensorRawProducerSiteInput) => void }): NativeRawTask {\n const plan=calculateNativeRawPlan(input);\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.yieldControl!==\"function\")throw new InvalidConfigurationError(\"Native RAW requires reader and host event-loop yield.\");\n const read=provider.readTile.bind(provider),yieldControl=provider.yieldControl.bind(provider),abort=new AbortController();\n const native=plan.exposure.geometry.nativeRaster,tileWidth=plan.tileWidth??NATIVE_RAW_LIMITS.tileWidth;\n const rowStart=rows?.y??0,rowEnd=rowStart+(rows?.height??native.pixelHeight),offset=rowStart*native.pixelWidth,length=(rowEnd-rowStart)*native.pixelWidth;\n let state:NativeRawTaskState=\"ready\",count=0,output:NativeRawOutput|null=null,first:SensorRawProducerSiteInput|undefined;\n function release(): void {if(output){output.codes.fill(0);output.blackLevels.fill(0);output.digitalSaturationCodes.fill(0);output.saturationFlags.fill(0);output.effectiveSaturationCodes.fill(0);}output=null;first=undefined;}\n function active(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW execution aborted.\");}\n return {plan,get state(): NativeRawTaskState {return state;},get completedTileCount(): number {return count;},\n async run(): Promise<void> {\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Native RAW task is single-use.\");state=\"running\";\n try{\n const gate=sharedGate??createHostYieldGate(cadence);sharedGate?.restart();\n const layout=plan.frame.colorSamplingProfile.layout;if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const white=createPhaseWhiteLevelAccumulator(native.pixelWidth,layout.repeatWidthSites,layout.repeatHeightSites);\n output={plan,codes:new Uint16Array(length),blackLevels:new Uint16Array(length),digitalSaturationCodes:new Uint16Array(length),saturationFlags:new Uint8Array(length),effectiveSaturationCodes:new Uint16Array(layout.repeatWidthSites*layout.repeatHeightSites)};\n for(let y=rowStart;y<rowEnd;y++)for(let x=0;x<native.pixelWidth;x+=tileWidth){\n active();const request=Object.freeze({captureId:plan.exposure.captureId,frameId:plan.frame.frameId,x,y,width:Math.min(tileWidth,native.pixelWidth-x),height:1});\n {\n const supplied=await read(request,abort.signal);active();\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid native RAW tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Native RAW tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Native RAW tile needs exact dense coverage.\");\n const timing=plan.exposureWindow?windows(plan.exposure,plan.exposureWindow,Array.from({length:request.width},(_,i)=>({x:x+i+.5,y:y+.5}))):undefined;\n // Lean entries (built by the engine, provably valid against an earlier verified template) skip parsing and\n // identity checks. They are only claimed once the frame's first site is fixed.\n const lean=leanSensor&&first!==undefined?(tile.sites as unknown[]).map(site=>leanSensor.claim(site)):undefined;\n const sites=tile.sites.map((site,j)=>lean?.[j]?undefined:parseNativeRawProducerSite(site,y*native.pixelWidth+x+j,plan.frame,timing?.samples[j]));\n if(first===undefined){first=sites[0];if(first)rows?.firstSite?.(first);}for(const s of sites)if(s)validateNativeRawReadoutIdentity(s,first!);\n // Every site in this tile is validated before any output is written. A failure never returns partial output.\n const seed=plan.exposure.noise.seedUint32;\n for(let j=0;j<sites.length;j++){\n // index: absolute native index (seeds, CFA phase); at: position in this task's output arrays.\n const index=y*native.pixelWidth+x+j,at=index-offset,handle=lean?.[j];\n if(handle){\n const o=leanSensor!.compute(handle,index,seed,timing?.samples[j]);\n output.codes[at]=o.rawCode;output.blackLevels[at]=o.blackLevelCode;output.digitalSaturationCodes[at]=o.digitalSaturationCode;\n output.saturationFlags[at]=o.flags;white.record(index,o.whiteCode);continue;\n }\n const result=calculateNativeRawSite(sites[j]!,seed,index),r=result.readout.value;\n output.codes[at]=r.rawCode;output.blackLevels[at]=r.blackLevelCode;output.digitalSaturationCodes[at]=r.digitalSaturationCode;\n output.saturationFlags[at]=Number(r.physicalScalarSaturationApplied)|Number(r.preAdcSaturationApplied)<<1|Number(r.digitalSaturationApplied)<<2;\n const whiteCode=calculateSiteEffectiveSaturationCode(r,sites[j]!.readoutProfile,sites[j]!.regimeId);\n white.record(index,whiteCode);\n leanSensor?.observe(index,sites[j]!,result,whiteCode,seed);\n }\n count++;\n }\n // Yield when the time budget is spent, and always after the final tile. Yield timing never changes output.\n if(gate.due()||(y===rowEnd-1&&x+tileWidth>=native.pixelWidth)){await yieldControl(abort.signal);active();gate.restart();}\n }\n output.effectiveSaturationCodes.set(rows?white.partial():white.finish());first=undefined;state=\"completed\";\n }catch(error){release();if(!abort.signal.aborted){state=\"failed\";abort.abort();}throw error;}\n },\n cancel(): void {if(state===\"ready\"||state===\"running\"||state===\"completed\"){state=\"cancelled\";abort.abort();release();}},\n dispose(): void {if(state!==\"transferred\"){state=\"disposed\";abort.abort();release();}},\n takeOutput(): NativeRawOutput {if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");const result=output;output=null;first=undefined;state=\"transferred\";return result;}\n };\n}\n"]}
1
+ {"version":3,"file":"native-raw.js","sourceRoot":"","sources":["../../src/capture/native-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAAO,EAAE,gCAAgC,EAAiF,MAAM,wBAAwB,CAAC;AACzJ,OAAO,EAAE,kBAAk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,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAC,CAAC;oBAAA,KAAK,GAAC,QAAQ,CAAC;oBAAA,KAAK,CAAC,KAAK,EAAE,CAAC;gBAAA,CAAC;gBAAA,MAAM,KAAK,CAAC;YAAA,CAAC;QAC/F,CAAC;QACD,MAAM,KAAU,IAAG,KAAK,KAAG,OAAO,IAAE,KAAK,KAAG,SAAS,IAAE,KAAK,KAAG,WAAW,EAAC,CAAC;YAAA,KAAK,GAAC,WAAW,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACxH,OAAO,KAAU,IAAG,KAAK,KAAG,aAAa,EAAC,CAAC;YAAA,KAAK,GAAC,UAAU,CAAC;YAAA,KAAK,CAAC,KAAK,EAAE,CAAC;YAAA,OAAO,EAAE,CAAC;QAAA,CAAC,CAAA,CAAC;QACtF,UAAU,KAAqB,IAAG,KAAK,KAAG,WAAW,IAAE,CAAC,MAAM;YAAC,MAAM,IAAI,yBAAyB,CAAC,gCAAgC,CAAC,CAAC,CAAA,MAAM,MAAM,GAAC,MAAM,CAAC,CAAA,MAAM,GAAC,IAAI,CAAC,CAAA,KAAK,GAAC,SAAS,CAAC,CAAA,KAAK,GAAC,aAAa,CAAC,CAAA,OAAO,MAAM,CAAC,CAAA,CAAC;KACzN,CAAC;AACJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Native RAW capture with the existing per-site (scalar) RAW model: an up-front plan and limit check from\n * metadata only, then bounded tile-by-tile execution.\n */\nimport { normalizeCaptureExposureMetadata, type SimulatedCaptureInput, type SimulatedCapture, type CaptureExposureSource } from \"./simulated-capture.js\";\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireAllowlistedRecord, requirePublicOpaqueId } from \"../core/record-validation.js\";\nimport { freezeOwnedData } from \"../core/owned-data.js\";\nimport { FULL_RESOLUTION_CEILING_PIXELS, resolveRaisedLimit, scaleBudgetCeiling } from \"../core/pixel-limits.js\";\nimport { calculateSiteEffectiveSaturationCode, createPhaseWhiteLevelAccumulator } from \"./raw-white-level.js\";\nimport { DEFAULT_HOST_YIELD_CADENCE, createHostYieldGate, type HostYieldCadence, type HostYieldGate } from \"./host-yield-cadence.js\";\nimport { parseCaptureModeProfile } from \"../sensor/capture-mode.js\";\nimport { parseSensorColorSamplingProfile } from \"../sensor/color-sampling.js\";\nimport { parseNativeEffectiveRasterColorSamplingBindingProfile, resolveCaptureModeColorSamplingContributors } from \"../sensor/capture-color-sampling-binding.js\";\nimport { calculateCaptureExposureWindows } from \"../sensor/exposure-window.js\";\nimport { SENSOR_RAW_PRODUCER_NOISE_MODEL, calculateNativeRawSite, parseNativeRawProducerSite,\n validateNativeRawReadoutIdentity, type NativeRawProducerFrameContext, type SensorRawProducerSiteInput,\n type SensorRawProducerExposureWindowInput } from \"./sensor-raw-producer.js\";\n\nexport const NATIVE_RAW_SCHEMA_VERSION = \"0.1.0\" as const;\n/** `maximumPixels` is the default pixel limit; a request may raise it with its own `maximumPixels`, up to `ceilingPixels`. */\nexport const NATIVE_RAW_LIMITS = Object.freeze({ maximumPixels: 24_000_000, ceilingPixels: FULL_RESOLUTION_CEILING_PIXELS, maximumDimension: 16_384,\n tileWidth: 256, tileHeight: 1, outputBytesPerPixel: 7 });\n/** Default whole-event radiance query budget ceiling of the native environment tasks; it scales with a raised `maximumPixels`. */\nconst DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS = 2_000_000_000;\n/** A shooting event and where its source came from. Not a finished float master or committed RAW frame. */\nexport type NativeRawExposureInput = Omit<SimulatedCaptureInput, \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport type NativeRawExposure = Omit<SimulatedCapture, \"schemaVersion\" | \"planes\" | \"source\"> & {source:CaptureExposureSource};\nexport interface NativeRawInput {\n exposure: NativeRawExposureInput;\n frameId: string;\n modeId: string;\n captureModeProfile: NativeRawProducerFrameContext[\"captureModeProfile\"];\n colorSamplingProfile: NativeRawProducerFrameContext[\"colorSamplingProfile\"];\n bindingProfile: NativeRawProducerFrameContext[\"bindingProfile\"];\n exposureWindow?: SensorRawProducerExposureWindowInput;\n maximumOutputBytes: number;\n /** Optional tile width for execution, in native sites, 1–256. Default 256. It does not affect sampling. */\n tileWidth?: number;\n /**\n * Optional opt-in pixel limit for large sensors: an integer from 1 to `NATIVE_RAW_LIMITS.ceilingPixels`.\n * Default `NATIVE_RAW_LIMITS.maximumPixels` (24 000 000). `maximumOutputBytes` still applies. A raised limit\n * also raises the native environment tasks' whole-event query budget ceiling in proportion\n * (2 000 000 000 per 24 000 000 pixels). It does not affect sampling.\n */\n maximumPixels?: number;\n}\nexport interface NativeRawPlan {\n schemaVersion: typeof NATIVE_RAW_SCHEMA_VERSION;\n exposure: NativeRawExposure;\n frame: NativeRawProducerFrameContext;\n exposureWindow?: SensorRawProducerExposureWindowInput;\n pixelCount: number;\n outputBytes: number;\n tileCount: number;\n /** Present only when an execution tile width was given. Otherwise the plan keeps its earlier shape. */\n tileWidth?: number;\n /** Present only when a pixel limit was given. Otherwise the plan keeps its earlier shape. */\n maximumPixels?: number;\n upstreamRadiometryVerified: false;\n seedSchedule: \"murmur3-capture-seed-native-index-stream-v2\";\n}\n/** Tile rectangle, in absolute full-sensor CFA coordinates, before orientation, active-area crop or output scaling. */\nexport interface NativeRawTileRequest { captureId: string; frameId: string; x: number; y: number; width: number; height: number }\nexport interface NativeRawTile extends NativeRawTileRequest { sites: readonly SensorRawProducerSiteInput[] }\nexport interface NativeRawProvider {\n readTile(request: Readonly<NativeRawTileRequest>, signal: AbortSignal): Promise<NativeRawTile>;\n yieldControl(signal: AbortSignal): Promise<void>;\n}\n/** Row-major arrays owned only by the output. They cannot be attached to the bounded SensorRawFrame type. */\nexport interface NativeRawOutput {\n plan: NativeRawPlan;\n codes: Uint16Array;\n blackLevels: Uint16Array;\n digitalSaturationCodes: Uint16Array;\n /** Saturation flags. Bit 0: physical charge clamp; bit 1: pre-ADC clamp; bit 2: digital saturation. */\n saturationFlags: Uint8Array;\n /**\n * Effective white (full-saturation) code for each absolute CFA repeat phase, indexed\n * `phaseY*repeatWidthSites+phaseX`: min(digital saturation, round(black + min(capacity, pre-ADC\n * saturation)/gain)). See `calculateEffectiveSaturationCode`. A few bytes, not one value per pixel.\n */\n effectiveSaturationCodes: Uint16Array;\n}\n/** Internal: lean per-site outputs of an engine-built site (see native-environment-lean.ts). */\nexport interface NativeRawLeanOutput { rawCode: number; blackLevelCode: number; digitalSaturationCode: number; flags: number; whiteCode: number }\n/**\n * Internal hook for tiles the engine builds itself (native environment RAW).\n *\n * claim() recognizes only entries the hook itself created, for sites whose parsing and identity checks are\n * provably redundant. compute() returns the outputs calculateNativeRawSite would produce, falling back to it\n * internally. observe() sees every fully computed site.\n */\nexport interface NativeRawLeanSensorHook {\n claim(site: unknown): object | undefined;\n compute(handle: object, index: number, seed: number, timing: ReturnType<typeof calculateCaptureExposureWindows>[\"value\"][\"samples\"][number] | undefined): NativeRawLeanOutput;\n observe(index: number, parsed: SensorRawProducerSiteInput, result: ReturnType<typeof calculateNativeRawSite>, whiteCode: number, seed: number): void;\n}\nexport type NativeRawTaskState = \"ready\" | \"running\" | \"completed\" | \"cancelled\" | \"failed\" | \"disposed\" | \"transferred\";\nexport interface NativeRawTask {\n readonly plan: NativeRawPlan;\n readonly state: NativeRawTaskState;\n readonly completedTileCount: number;\n run(): Promise<void>;\n cancel(): void;\n dispose(): void;\n takeOutput(): NativeRawOutput;\n}\nfunction windows(exposure: NativeRawExposure, schedule: SensorRawProducerExposureWindowInput,\n points: readonly {x:number;y:number}[]): ReturnType<typeof calculateCaptureExposureWindows>[\"value\"] {\n const r=requireAllowlistedRecord(schedule,[\"shutterMechanism\",\"nominalExposureDurationSeconds\",\"opening\",\"closing\"],\"Invalid RAW exposure schedule.\");\n requireAllowlistedRecord(r.nominalExposureDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW nominal exposure.\");\n for(const boundary of [r.opening,r.closing]){\n const b=requireAllowlistedRecord(boundary,[\"kind\",\"directionNative\",\"traversalDurationSeconds\"],\"Invalid RAW exposure boundary.\");\n if(b.directionNative!==undefined)requireAllowlistedRecord(b.directionNative,[\"value\",\"evidence\"],\"Invalid RAW scan direction.\");\n if(b.traversalDurationSeconds!==undefined)requireAllowlistedRecord(b.traversalDurationSeconds,[\"value\",\"unit\",\"evidence\"],\"Invalid RAW scan duration.\");\n }\n const result=calculateCaptureExposureWindows({...schedule,nativeRaster:exposure.geometry.nativeRaster,samplePointsNative:points});\n if(result.value.nominalExposureDurationSeconds.value!==exposure.exposure.shutterSeconds)throw new InvalidConfigurationError(\"RAW schedule differs from exposure duration.\");\n return result.value;\n}\n/** Plans the task and checks the image size, resources and profiles before any callback or output allocation. No placeholder plane is made. */\nexport function calculateNativeRawPlan(input: NativeRawInput): NativeRawPlan {\n const r=requireAllowlistedRecord(input,[\"exposure\",\"frameId\",\"modeId\",\"captureModeProfile\",\"colorSamplingProfile\",\"bindingProfile\",\"exposureWindow\",\"maximumOutputBytes\",\"tileWidth\",\"maximumPixels\"],\"Invalid native RAW input.\");\n if(r.tileWidth!==undefined&&(typeof r.tileWidth!==\"number\"||!Number.isSafeInteger(r.tileWidth)||r.tileWidth<1||r.tileWidth>NATIVE_RAW_LIMITS.tileWidth))\n throw new InvalidConfigurationError(\"Native RAW tile width must be an integer from 1 to 256.\");\n const tileWidth=(r.tileWidth as number|undefined)??NATIVE_RAW_LIMITS.tileWidth;\n const maximumPixels=resolveRaisedLimit(r.maximumPixels,NATIVE_RAW_LIMITS.maximumPixels,NATIVE_RAW_LIMITS.ceilingPixels,\n \"Native RAW maximumPixels must be an integer from 1 to \"+NATIVE_RAW_LIMITS.ceilingPixels+\".\");\n const exposure=normalizeCaptureExposureMetadata(r.exposure,ENGINE_API_VERSION,true),native=exposure.geometry.nativeRaster;\n const pixelCount=native.pixelWidth*native.pixelHeight,outputBytes=pixelCount*NATIVE_RAW_LIMITS.outputBytesPerPixel;\n if(pixelCount>maximumPixels||native.pixelWidth>NATIVE_RAW_LIMITS.maximumDimension||native.pixelHeight>NATIVE_RAW_LIMITS.maximumDimension||\n !Number.isSafeInteger(r.maximumOutputBytes)||typeof r.maximumOutputBytes!==\"number\"||r.maximumOutputBytes<outputBytes)throw new InvalidConfigurationError(\"Native RAW raster exceeds output admission budget.\");\n const frame={frameId:requirePublicOpaqueId(r.frameId,\"Invalid RAW frame ID.\"),capture:exposure,\n modeId:requirePublicOpaqueId(r.modeId,\"Invalid RAW mode ID.\"),containerBitDepth:16 as const,\n captureModeProfile:parseCaptureModeProfile(r.captureModeProfile),colorSamplingProfile:parseSensorColorSamplingProfile(r.colorSamplingProfile),\n bindingProfile:parseNativeEffectiveRasterColorSamplingBindingProfile(r.bindingProfile)};\n const mode=frame.captureModeProfile.modes.find(m=>m.modeId===frame.modeId);\n if(exposure.noise.model.id!==SENSOR_RAW_PRODUCER_NOISE_MODEL.id||exposure.noise.model.version!==SENSOR_RAW_PRODUCER_NOISE_MODEL.version||\n frame.colorSamplingProfile.layout.kind!==\"periodic-mosaic\"||mode?.acquisition.kind!==\"single-frame\"||mode.perFrameSampling.kind!==\"native-effective-raster\"||(mode.reconstructionStages?.length??0)!==0)\n throw new InvalidConfigurationError(\"Native RAW requires exact noise identity and single-frame native periodic CFA.\");\n // The binding is one affine mapping for the whole frame, so checking both corners covers it. Do this before any provider work.\n for(const p of [{x:0,y:0},{x:native.pixelWidth-1,y:native.pixelHeight-1}]){\n const c=resolveCaptureModeColorSamplingContributors({nativeRaster:native,captureModeProfile:frame.captureModeProfile,modeId:frame.modeId,colorSamplingProfile:frame.colorSamplingProfile,bindingProfile:frame.bindingProfile,modeSampleIndexFullFrame:p});\n if(c.totalContributorSites!==1||c.channelComposition.kind!==\"single-channel\")throw new InvalidConfigurationError(\"Native RAW must preserve one native CFA site per sample.\");\n }\n const schedule=r.exposureWindow===undefined?undefined:structuredClone(r.exposureWindow) as SensorRawProducerExposureWindowInput;\n // For the supported linear scans, the extreme values occur at the image corners. Check them before capture.\n if(schedule)windows(exposure,schedule,[{x:.5,y:.5},{x:native.pixelWidth-.5,y:.5},{x:.5,y:native.pixelHeight-.5},{x:native.pixelWidth-.5,y:native.pixelHeight-.5}]);\n return freezeOwnedData({schemaVersion:NATIVE_RAW_SCHEMA_VERSION,exposure,frame,pixelCount,outputBytes,\n tileCount:Math.ceil(native.pixelWidth/tileWidth)*native.pixelHeight,\n ...(r.tileWidth===undefined?{}:{tileWidth}),\n ...(r.maximumPixels===undefined?{}:{maximumPixels}),\n ...(schedule?{exposureWindow:schedule}:{}),upstreamRadiometryVerified:false as const,\n seedSchedule:\"murmur3-capture-seed-native-index-stream-v2\" as const});\n}\n/**\n * Internal: the largest whole-event radiance query budget a native environment task admits for this plan:\n * 2 000 000 000, scaled in proportion when the plan raised its pixel limit above 24 000 000. Not exported from the package.\n */\nexport function nativeRawMaximumProviderEvaluations(plan: Pick<NativeRawPlan,\"maximumPixels\">): number {\n return plan.maximumPixels===undefined?DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS:scaleBudgetCeiling(DEFAULT_MAXIMUM_PROVIDER_EVALUATIONS,plan.maximumPixels);\n}\n/**\n * Runs validated per-site events (EQE photo signal, dark signal, charge completeness) through the shared\n * reference per-site physics.\n *\n * Tiles are read and committed one at a time. The task yields to the host at tile boundaries once about\n * 8 ms of work has passed since the last yield, and after the final tile. It checks for cancellation\n * before every tile, after every read and after every yield.\n */\nexport function createNativeRawTask(input: NativeRawInput,provider: NativeRawProvider): NativeRawTask {\n return createNativeRawTaskWithCadence(input,provider,DEFAULT_HOST_YIELD_CADENCE);\n}\n/** Internal: the same task with an explicit host-yield timing. Timing never changes tiles, seeds or output. Not exported from the package. */\nexport function createNativeRawTaskWithCadence(input: NativeRawInput,provider: NativeRawProvider,cadence: HostYieldCadence,\n /** Internal: a yield timer shared with a provider that also yields inside readTile, so both use one time budget. */\n sharedGate?: HostYieldGate,\n /** Internal: faster (\"lean\") per-site sensor execution for engine-built tiles. It never changes output or errors. */\n leanSensor?: NativeRawLeanSensorHook,\n /**\n * Internal: run only native rows [y, y + height) (a partition). The output arrays then hold just those rows, and\n * effectiveSaturationCodes holds 0 for CFA phases the rows do not contain; the merge step completes them.\n * Seeds, tiles and per-site values are those of the whole-frame task.\n */\n rows?: { readonly y: number; readonly height: number; readonly firstSite?: (site: SensorRawProducerSiteInput) => void }): NativeRawTask {\n const plan=calculateNativeRawPlan(input);\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.yieldControl!==\"function\")throw new InvalidConfigurationError(\"Native RAW requires reader and host event-loop yield.\");\n const read=provider.readTile.bind(provider),yieldControl=provider.yieldControl.bind(provider),abort=new AbortController();\n const native=plan.exposure.geometry.nativeRaster,tileWidth=plan.tileWidth??NATIVE_RAW_LIMITS.tileWidth;\n const rowStart=rows?.y??0,rowEnd=rowStart+(rows?.height??native.pixelHeight),offset=rowStart*native.pixelWidth,length=(rowEnd-rowStart)*native.pixelWidth;\n let state:NativeRawTaskState=\"ready\",count=0,output:NativeRawOutput|null=null,first:SensorRawProducerSiteInput|undefined;\n function release(): void {if(output){output.codes.fill(0);output.blackLevels.fill(0);output.digitalSaturationCodes.fill(0);output.saturationFlags.fill(0);output.effectiveSaturationCodes.fill(0);}output=null;first=undefined;}\n function active(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW execution aborted.\");}\n return {plan,get state(): NativeRawTaskState {return state;},get completedTileCount(): number {return count;},\n async run(): Promise<void> {\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Native RAW task is single-use.\");state=\"running\";\n try{\n const gate=sharedGate??createHostYieldGate(cadence);sharedGate?.restart();\n const layout=plan.frame.colorSamplingProfile.layout;if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const white=createPhaseWhiteLevelAccumulator(native.pixelWidth,layout.repeatWidthSites,layout.repeatHeightSites);\n output={plan,codes:new Uint16Array(length),blackLevels:new Uint16Array(length),digitalSaturationCodes:new Uint16Array(length),saturationFlags:new Uint8Array(length),effectiveSaturationCodes:new Uint16Array(layout.repeatWidthSites*layout.repeatHeightSites)};\n for(let y=rowStart;y<rowEnd;y++)for(let x=0;x<native.pixelWidth;x+=tileWidth){\n active();const request=Object.freeze({captureId:plan.exposure.captureId,frameId:plan.frame.frameId,x,y,width:Math.min(tileWidth,native.pixelWidth-x),height:1});\n {\n const supplied=await read(request,abort.signal);active();\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid native RAW tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Native RAW tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Native RAW tile needs exact dense coverage.\");\n const timing=plan.exposureWindow?windows(plan.exposure,plan.exposureWindow,Array.from({length:request.width},(_,i)=>({x:x+i+.5,y:y+.5}))):undefined;\n // Lean entries (built by the engine, provably valid against an earlier verified template) skip parsing and\n // identity checks. They are only claimed once the frame's first site is fixed.\n const lean=leanSensor&&first!==undefined?(tile.sites as unknown[]).map(site=>leanSensor.claim(site)):undefined;\n const sites=tile.sites.map((site,j)=>lean?.[j]?undefined:parseNativeRawProducerSite(site,y*native.pixelWidth+x+j,plan.frame,timing?.samples[j]));\n if(first===undefined){first=sites[0];if(first)rows?.firstSite?.(first);}for(const s of sites)if(s)validateNativeRawReadoutIdentity(s,first!);\n // Every site in this tile is validated before any output is written. A failure never returns partial output.\n const seed=plan.exposure.noise.seedUint32;\n for(let j=0;j<sites.length;j++){\n // index: absolute native index (seeds, CFA phase); at: position in this task's output arrays.\n const index=y*native.pixelWidth+x+j,at=index-offset,handle=lean?.[j];\n if(handle){\n const o=leanSensor!.compute(handle,index,seed,timing?.samples[j]);\n output.codes[at]=o.rawCode;output.blackLevels[at]=o.blackLevelCode;output.digitalSaturationCodes[at]=o.digitalSaturationCode;\n output.saturationFlags[at]=o.flags;white.record(index,o.whiteCode);continue;\n }\n const result=calculateNativeRawSite(sites[j]!,seed,index),r=result.readout.value;\n output.codes[at]=r.rawCode;output.blackLevels[at]=r.blackLevelCode;output.digitalSaturationCodes[at]=r.digitalSaturationCode;\n output.saturationFlags[at]=Number(r.physicalScalarSaturationApplied)|Number(r.preAdcSaturationApplied)<<1|Number(r.digitalSaturationApplied)<<2;\n const whiteCode=calculateSiteEffectiveSaturationCode(r,sites[j]!.readoutProfile,sites[j]!.regimeId);\n white.record(index,whiteCode);\n leanSensor?.observe(index,sites[j]!,result,whiteCode,seed);\n }\n count++;\n }\n // Yield when the time budget is spent, and always after the final tile. Yield timing never changes output.\n if(gate.due()||(y===rowEnd-1&&x+tileWidth>=native.pixelWidth)){await yieldControl(abort.signal);active();gate.restart();}\n }\n output.effectiveSaturationCodes.set(rows?white.partial():white.finish());first=undefined;state=\"completed\";\n }catch(error){release();if(!abort.signal.aborted){state=\"failed\";abort.abort();}throw error;}\n },\n cancel(): void {if(state===\"ready\"||state===\"running\"||state===\"completed\"){state=\"cancelled\";abort.abort();release();}},\n dispose(): void {if(state!==\"transferred\"){state=\"disposed\";abort.abort();release();}},\n takeOutput(): NativeRawOutput {if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");const result=output;output=null;first=undefined;state=\"transferred\";return result;}\n };\n}\n"]}
@@ -3,8 +3,10 @@ import { type SensorFixedPatternNoiseProfile } from "../sensor/fixed-pattern-noi
3
3
  import type { SensorAdditionalChargeSamplingModel } from "../sensor/raw-readout.js";
4
4
  import { SENSOR_RAW_PRODUCER_NOISE_MODEL } from "./sensor-raw-producer.js";
5
5
  export declare const PACKED_SENSOR_RAW_SCHEMA_VERSION: "0.1.0";
6
+ /** `maximumRegionSites` is the default region limit; a request may raise it with its own `maximumRegionSites`, up to `ceilingRegionSites`. */
6
7
  export declare const PACKED_SENSOR_RAW_LIMITS: Readonly<{
7
8
  maximumRegionSites: 24000000;
9
+ ceilingRegionSites: 134217728;
8
10
  maximumNativeSites: 4294967295;
9
11
  maximumDimension: 65535;
10
12
  maximumAdcBitDepth: 16;
@@ -59,6 +61,11 @@ export interface PackedSensorRawInput {
59
61
  fixedPatternNoise?: PackedSensorFixedPatternNoise;
60
62
  /** Optional (2.0), at most 8. */
61
63
  additionalChargeComponents?: readonly PackedSensorAdditionalChargeComponent[];
64
+ /**
65
+ * Optional opt-in region limit for large sensors: an integer from 1 to `PACKED_SENSOR_RAW_LIMITS.ceilingRegionSites`.
66
+ * Default `PACKED_SENSOR_RAW_LIMITS.maximumRegionSites` (24 000 000). It does not change the result.
67
+ */
68
+ maximumRegionSites?: number;
62
69
  }
63
70
  /** Validated plan. Arrays are borrowed, not copied. */
64
71
  export interface PackedSensorRawPlan {
@@ -20,13 +20,16 @@
20
20
  */
21
21
  import { InvalidConfigurationError } from "../core/configuration-error.js";
22
22
  import { requireAllowlistedRecord } from "../core/record-validation.js";
23
+ import { FULL_RESOLUTION_CEILING_PIXELS, resolveRaisedLimit } from "../core/pixel-limits.js";
23
24
  import { adcTransfer, resolveSensorReadoutRegime, samplePoisson } from "../sensor/raw-readout.js";
24
25
  import { createDeterministicUniformStream, deriveNativeSiteStreamSeedUint32, sampleDeterministicStandardNormal, NATIVE_SITE_CHARGE_STREAM_ID, NATIVE_SITE_READ_NOISE_STREAM_ID } from "../sensor/stochastic-seed.js";
25
26
  import { evaluateFixedPatternColumnOffset, evaluateFixedPatternRowOffset, evaluateFixedPatternSiteFactors, parseSensorFixedPatternNoiseProfile } from "../sensor/fixed-pattern-noise.js";
26
27
  import { SENSOR_RAW_PRODUCER_NOISE_MODEL } from "./sensor-raw-producer.js";
27
28
  export const PACKED_SENSOR_RAW_SCHEMA_VERSION = "0.1.0";
29
+ /** `maximumRegionSites` is the default region limit; a request may raise it with its own `maximumRegionSites`, up to `ceilingRegionSites`. */
28
30
  export const PACKED_SENSOR_RAW_LIMITS = Object.freeze({
29
31
  maximumRegionSites: 24_000_000,
32
+ ceilingRegionSites: FULL_RESOLUTION_CEILING_PIXELS,
30
33
  maximumNativeSites: 0xffffffff,
31
34
  maximumDimension: 65_535,
32
35
  maximumAdcBitDepth: 16,
@@ -57,7 +60,7 @@ function maximumOf(values, count) {
57
60
  /** Validates the request (every array value once) and returns its plan. */
58
61
  export function calculatePackedSensorRawPlan(input) {
59
62
  const r = requireAllowlistedRecord(input, ["schemaVersion", "nativeWidth", "nativeHeight", "region", "captureSeedUint32", "photoElectrons",
60
- "darkElectrons", "physicalChargeCapacityElectrons", "readoutProfile", "regimeId", "fixedPatternNoise", "additionalChargeComponents"], "Invalid packed sensor RAW input.");
63
+ "darkElectrons", "physicalChargeCapacityElectrons", "readoutProfile", "regimeId", "fixedPatternNoise", "additionalChargeComponents", "maximumRegionSites"], "Invalid packed sensor RAW input.");
61
64
  const L = PACKED_SENSOR_RAW_LIMITS;
62
65
  if (r.schemaVersion !== PACKED_SENSOR_RAW_SCHEMA_VERSION)
63
66
  throw new InvalidConfigurationError("Unsupported packed sensor RAW schema.");
@@ -67,7 +70,8 @@ export function calculatePackedSensorRawPlan(input) {
67
70
  const g = requireAllowlistedRecord(r.region, ["x", "y", "width", "height"], "Invalid packed sensor RAW region.");
68
71
  const x = integer(g.x, 0, nativeWidth - 1), y = integer(g.y, 0, nativeHeight - 1);
69
72
  const width = integer(g.width, 1, nativeWidth - x), height = integer(g.height, 1, nativeHeight - y);
70
- if (width * height > L.maximumRegionSites)
73
+ const maximumRegionSites = resolveRaisedLimit(r.maximumRegionSites, L.maximumRegionSites, L.ceilingRegionSites, "Packed sensor RAW maximumRegionSites must be an integer from 1 to " + L.ceilingRegionSites + ".");
74
+ if (width * height > maximumRegionSites)
71
75
  throw new InvalidConfigurationError("Packed sensor RAW region exceeds the site limit.");
72
76
  const captureSeedUint32 = integer(r.captureSeedUint32, 0, 0xffffffff);
73
77
  const capacity = r.physicalChargeCapacityElectrons;