@photivra/engine 2.2.1 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -1
- package/CITATION.cff +1 -1
- package/README.md +6 -6
- package/SECURITY.md +1 -1
- package/dist/capture/native-environment-raw.d.ts +18 -0
- package/dist/capture/native-environment-raw.js +17 -1
- package/dist/capture/native-environment-raw.js.map +1 -1
- package/dist/capture/native-raw-dng.d.ts +3 -0
- package/dist/capture/native-raw-dng.js +23 -3
- package/dist/capture/native-raw-dng.js.map +1 -1
- package/dist/capture/native-raw.d.ts +3 -0
- package/dist/capture/native-raw.js +8 -5
- package/dist/capture/native-raw.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/core/version.js.map +1 -1
- package/dist/equipment/generic-prime-lenses.d.ts +46 -0
- package/dist/equipment/generic-prime-lenses.js +59 -0
- package/dist/equipment/generic-prime-lenses.js.map +1 -0
- package/dist/facade/chart-scenes.d.ts +270 -1
- package/dist/facade/chart-scenes.js +443 -17
- package/dist/facade/chart-scenes.js.map +1 -1
- package/dist/facade/scene-radiance.d.ts +47 -0
- package/dist/facade/scene-radiance.js +65 -5
- package/dist/facade/scene-radiance.js.map +1 -1
- package/dist/facade/simulate-capture.d.ts +158 -4
- package/dist/facade/simulate-capture.js +324 -56
- package/dist/facade/simulate-capture.js.map +1 -1
- package/dist/facade/subject-framing.d.ts +55 -0
- package/dist/facade/subject-framing.js +66 -0
- package/dist/facade/subject-framing.js.map +1 -0
- package/dist/gpu/chart-radiance-gpu.d.ts +8 -0
- package/dist/gpu/chart-radiance-gpu.js +20 -1
- package/dist/gpu/chart-radiance-gpu.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/output/text-metadata.d.ts +32 -0
- package/dist/output/text-metadata.js +201 -0
- package/dist/output/text-metadata.js.map +1 -0
- package/docs/API_REFERENCE.md +56 -1
- package/docs/QUICK_START.md +325 -4
- package/docs/api/capture-native-raw-dng.md +2 -0
- package/docs/api/core-version.md +1 -1
- package/docs/api/equipment-generic-prime-lenses.md +85 -0
- package/docs/api/exports.json +172 -2
- package/docs/api/facade-chart-scenes.md +280 -4
- package/docs/api/facade-scene-radiance.md +42 -0
- package/docs/api/facade-simulate-capture.md +113 -2
- package/docs/api/facade-subject-framing.md +72 -0
- package/docs/api/output-text-metadata.md +20 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-raw-dng.js","sourceRoot":"","sources":["../../src/capture/native-raw-dng.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+DAA+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACzI,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,mCAAmC,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,6BAA6B,EAAiC,MAAM,0BAA0B,CAAC;AACxG,OAAO,EAAE,cAAc,EAAE,eAAe,IAAI,KAAK,EAAE,iBAAiB,IAAI,OAAO,EAAE,mBAAmB,IAAI,SAAS,EAC/G,eAAe,IAAI,QAAQ,EAAE,iBAAiB,IAAI,OAAO,EAAE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,EAAE,oBAAoB,EAAE,KAAc,EAAE,CAAC,CAAC;AACjJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n// This product includes DNG technology under license by Adobe.\n\n/**\n * Writes a packed native RAW (`NativeRawOutput`, from the native RAW or native environment RAW tasks) as a\n * lossless, uncompressed 16-bit DNG with a CFA (colour filter array) mosaic.\n *\n * The file describes only what the packed RAW, the caller's declared colour profile and noise model\n * contain. It never claims a linear float master as its source, or a developed image. The tag layout reuses\n * the TIFF/DNG writers of the paired photographic export (`packExportTiff`, DNG 1.4 tags, Adobe DNG\n * Specification 1.7.1.0):\n *\n * - CFA geometry: CFARepeatPatternDim 2×2, CFAPattern and BlackLevel phases relative to the ActiveArea\n * origin (DNG applies them to the stage-2, ActiveArea-cropped image); DefaultCropOrigin/Size are the\n * capture's oriented output crop mapped back to stored (native) coordinates; Orientation from the capture.\n * - Levels: BlackLevel per 2×2 phase (the packed per-site black levels must repeat with the CFA tile).\n * WhiteLevel is the smallest per-phase effective white code, so no channel is reported as unsaturated\n * above its own saturation point. DNG cannot represent a saturation flag on a site whose code is below\n * WhiteLevel; such sites are counted in `unrepresentedSaturationFlagCount`.\n * - Colour: ColorMatrix1 = (camera→XYZ)⁻¹ with CalibrationIlluminant1 D65 (21), ForwardMatrix1 =\n * Bradford(D65→D50)·M·diag(w), AnalogBalance 1, AsShotNeutral from the capture's white-balance intent\n * (the same operator native development uses), BaselineExposure as declared (default 0).\n * - Noise: NoiseProfile (51041) per CFA plane, var(x) = S·x + O for x = (code − black)/(WhiteLevel − black),\n * S = 1/(G·span), O = (σ_read²/G² + 1/12)/span², written only when the caller supplies each channel's\n * output-referred conversion gain G (electrons per code) and read noise σ_read (electrons). The model\n * covers only Poisson photo and dark shot noise, Gaussian read noise and uniform quantization. It is an\n * approximation: PRNU (photo-response non-uniformity), DSNU (dark-signal non-uniformity) and other\n * fixed-pattern noise are not included.\n * @see docs/NATIVE_RAW_AND_PRINT.md for the tag table, limits and the round trip through parseDngRawImage.\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireAllowlistedRecord } from \"../core/record-validation.js\";\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { resolveCaptureColorModel } from \"../color/capture-color.js\";\nimport { invertSensorColorMatrix, prepareSensorColorDevelopment, sensorColorReferenceWhite } from \"../color/sensor-color-development.js\";\nimport { ICC_D50_WHITE_XYZ } from \"../color/srgb-icc.js\";\nimport { chromaticAdaptationMatrix } from \"../color/chromatic-adaptation.js\";\nimport { transformOrientedRasterRectToNative } from \"../output/capture-geometry.js\";\nimport type { NativeRawOutput } from \"./native-raw.js\";\nimport { checkNativeRawIntegrity, validatePackedNativeRaw } from \"./native-raw-development.js\";\nimport { parseExportSensorColorProfile, type ExportSensorColorProfile } from \"./photographic-export.js\";\nimport { packExportTiff, exportTiffAscii as ascii, exportTiffNumbers as numbers, exportTiffRationals as rationals,\n exportTiffBytes as rawBytes, exportTiffDoubles as doubles } from \"./export-tiff.js\";\n\nexport const NATIVE_RAW_DNG_SCHEMA_VERSION = \"1.0.0\" as const;\n\n/** Output-referred noise parameters of one CFA channel (see the module notes). */\nexport interface NativeRawDngChannelNoise {\n /** Electrons per output RAW code (system conversion gain divided by any post-ADC digital gain). */\n conversionGainElectronsPerCode: number;\n /** Combined RMS read noise, electrons. */\n readNoiseRmsElectrons: number;\n}\nexport interface SerializeNativeRawDngInput {\n /** Packed native RAW. It is read, never taken over or modified. */\n raw: NativeRawOutput;\n /** Declared camera→XYZ (D65) colour profile for the RAW's CFA. Native development uses the same profile. */\n colorProfile: ExportSensorColorProfile;\n /** Optional NoiseProfile parameters by channel ID. If omitted, no NoiseProfile tag is written. */\n noise?: Readonly<Record<string, NativeRawDngChannelNoise>>;\n /** BaselineExposure in EV (exposure value stops). Default 0: the RAW white level maps to display white, as in native development. */\n baselineExposureEv?: number;\n /** Optional UTC time of the capture, exactly YYYY-MM-DDTHH:mm:ss.sssZ. If omitted, no date tags are written; the engine never makes up a clock time. */\n capturedAtUtc?: string;\n}\nexport interface NativeRawDng {\n schemaVersion: typeof NATIVE_RAW_DNG_SCHEMA_VERSION;\n mediaType: \"image/dng\";\n bytes: Uint8Array;\n sha256: string;\n /** RawDataUniqueID (32 hex digits): the first 128 bits of SHA-256 over a fixed header and the little-endian codes. */\n rawDataUniqueId: string;\n uniqueCameraModel: string;\n /** Stored geometry, levels and colour values exactly as written (rationals as numerator/denominator). */\n activeArea: { x: number; y: number; width: number; height: number };\n defaultCrop: { x: number; y: number; width: number; height: number };\n orientation: number;\n blackLevels: readonly number[];\n whiteLevel: number;\n cfaPattern: readonly number[];\n colorMatrix1: readonly number[];\n asShotNeutral: readonly number[];\n noiseProfile: readonly number[] | null;\n /** Sites flagged saturated whose code is below WhiteLevel; DNG has no field for them. */\n unrepresentedSaturationFlagCount: number;\n source: \"packed-native-raw\";\n linearMasterDeclared: false;\n}\n\nfunction fail(message: string): never { throw new InvalidConfigurationError(\"Native RAW DNG: \" + message); }\nasync function sha256(bytes: Uint8Array): Promise<string> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) fail(\"needs crypto.subtle (a secure browser context or Node 22+).\");\n return Array.from(new Uint8Array(await subtle.digest(\"SHA-256\", bytes as Uint8Array<ArrayBuffer>)), (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n/** Values exactly as stored by a RATIONAL/SRATIONAL tag (numerator / denominator), so reported metadata equals what a reader decodes. */\nfunction stored(tag: ReturnType<typeof rationals>): number[] {\n const view = new DataView(tag.data.buffer, tag.data.byteOffset, tag.data.byteLength);\n return Array.from({ length: tag.count }, (_, i) => (tag.type === 10 ? view.getInt32(i * 8, true) : view.getUint32(i * 8, true)) / view.getUint32(i * 8 + 4, true));\n}\nconst ORIENTATION = { landscape: 1, \"portrait-clockwise\": 6, \"landscape-inverted\": 3, \"portrait-counter-clockwise\": 8 } as const;\n\n/**\n * Writes packed native RAW codes as a lossless, uncompressed CFA DNG. The module notes list every tag and\n * where its value comes from. The input arrays are copied before the first await.\n */\nexport async function serializeNativeRawDng(input: SerializeNativeRawDngInput): Promise<NativeRawDng> {\n const r = requireAllowlistedRecord(input, [\"raw\", \"colorProfile\", \"noise\", \"baselineExposureEv\", \"capturedAtUtc\"], \"Invalid native RAW DNG input.\");\n const raw = r.raw as NativeRawOutput, plan = validatePackedNativeRaw(raw);\n const mosaic = plan.frame.colorSamplingProfile.layout;\n if (mosaic.kind === \"periodic-mosaic\") checkNativeRawIntegrity(raw, plan.exposure.geometry.nativeRaster.pixelWidth, mosaic.repeatWidthSites, mosaic.repeatHeightSites, 0, plan.exposure.geometry.nativeRaster.pixelHeight);\n const color = parseExportSensorColorProfile(r.colorProfile), frame = plan.frame, layout = frame.colorSamplingProfile.layout;\n if (layout.kind !== \"periodic-mosaic\" || layout.repeatWidthSites !== 2 || layout.repeatHeightSites !== 2 ||\n [...layout.siteChannelIds].sort().join() !== \"blue,green,green,red\" || color.channelIds.join() !== \"red,green,blue\")\n fail(\"supports 2×2 RGB Bayer CFAs with red, green, blue colour-profile channels only.\");\n if (color.colorSamplingProfileId !== frame.colorSamplingProfile.profileId) fail(\"colour profile is not bound to the RAW's CFA.\");\n const baseline = r.baselineExposureEv === undefined ? 0 : r.baselineExposureEv;\n if (typeof baseline !== \"number\" || !Number.isFinite(baseline) || Math.abs(baseline) > 16) fail(\"baselineExposureEv must be finite within ±16.\");\n const capturedAtUtc = r.capturedAtUtc as string | undefined;\n if (capturedAtUtc !== undefined && (typeof capturedAtUtc !== \"string\" || !/^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d\\.\\d{3}Z$/.test(capturedAtUtc) || Number.isNaN(Date.parse(capturedAtUtc))))\n fail(\"capturedAtUtc must be YYYY-MM-DDTHH:mm:ss.sssZ.\");\n\n const native = plan.exposure.geometry.nativeRaster, width = native.pixelWidth, height = native.pixelHeight, g = plan.exposure.resolvedGeometry;\n const active = g.activeCapture.nativeRect;\n const crop = transformOrientedRasterRectToNative({ rect: g.output.cropRect, nativeRaster: g.activeCapture.raster, orientation: plan.exposure.geometry.orientation });\n // Copy before any await: the caller keeps ownership of the packed arrays.\n const codes = raw.codes.slice(), blacks = raw.blackLevels.slice(), flags = raw.saturationFlags.slice(), whiteByPhase = Array.from(raw.effectiveSaturationCodes);\n\n // Levels per CFA phase, relative to the active area. The black-level tile must repeat exactly.\n const blackLevels: number[] = [], cfaPattern: number[] = [], whites: number[] = [], phaseChannel: string[] = [];\n for (let py = 0; py < 2; py++) for (let px = 0; px < 2; px++) {\n const ax = (active.x + px) % 2, ay = (active.y + py) % 2;\n const black = blacks[ay * width + ax]!;\n for (let y = ay; y < height; y += 2) for (let x = ax; x < width; x += 2) if (blacks[y * width + x] !== black) fail(\"per-site black levels do not repeat with the 2×2 CFA tile.\");\n const channel = layout.siteChannelIds[ay * 2 + ax]!;\n blackLevels.push(black); whites.push(whiteByPhase[ay * 2 + ax]!); phaseChannel.push(channel); cfaPattern.push([\"red\", \"green\", \"blue\"].indexOf(channel));\n }\n const whiteLevel = Math.min(...whites);\n if (blackLevels.some((b) => b >= whiteLevel)) fail(\"black level must be below the effective WhiteLevel.\");\n let unrepresented = 0;\n for (let i = 0; i < codes.length; i++) if (flags[i] !== 0 && codes[i]! < whiteLevel) unrepresented++;\n\n // NoiseProfile: one (S, O) pair per CFA plane colour, only when every phase of a channel shares its black level.\n let noiseProfile: number[] | null = null;\n if (r.noise !== undefined) {\n const noise = requireAllowlistedRecord(r.noise, [\"red\", \"green\", \"blue\"], \"Invalid native RAW DNG noise.\") as Record<string, NativeRawDngChannelNoise>;\n noiseProfile = [];\n for (const channel of [\"red\", \"green\", \"blue\"]) {\n const n = noise[channel];\n if (!n) fail(\"noise needs red, green and blue entries.\");\n requireAllowlistedRecord(n, [\"conversionGainElectronsPerCode\", \"readNoiseRmsElectrons\"], \"Invalid native RAW DNG channel noise.\");\n const gain = n.conversionGainElectronsPerCode, read = n.readNoiseRmsElectrons;\n if (typeof gain !== \"number\" || !Number.isFinite(gain) || gain <= 0 || typeof read !== \"number\" || !Number.isFinite(read) || read < 0) fail(\"noise gain must be positive and read noise non-negative.\");\n const phaseBlacks = blackLevels.filter((_, i) => phaseChannel[i] === channel);\n if (phaseBlacks.some((b) => b !== phaseBlacks[0])) { noiseProfile = null; break; }\n const span = whiteLevel - phaseBlacks[0]!;\n noiseProfile.push(1 / (gain * span), (read * read / (gain * gain) + 1 / 12) / (span * span));\n }\n }\n\n // Colour tags from the declared profile and the capture's white-balance intent.\n const m = color.normalizedCameraChannelsToXyz, colorMatrix = invertSensorColorMatrix(m), intent = plan.exposure.whiteBalanceIntent;\n const development = prepareSensorColorDevelopment(m, intent ? [intent.channelGains.red, intent.channelGains.green, intent.channelGains.blue] : null);\n const cameraWhite = sensorColorReferenceWhite(colorMatrix);\n const chad = chromaticAdaptationMatrix({ transform: \"bradford\", sourceWhiteXyz: resolveCaptureColorModel().referenceWhiteXyz,\n destinationWhiteXyz: { x: ICC_D50_WHITE_XYZ[0], y: 1, z: ICC_D50_WHITE_XYZ[2] } }).matrix;\n const forward = chad.map((row) => [0, 1, 2].map((j) => row.reduce((sum, x, k) => sum + x * m[k]![j]! * cameraWhite[j]!, 0)));\n\n const pixels = new Uint8Array(codes.length * 2), view = new DataView(pixels.buffer);\n codes.forEach((c, i) => view.setUint16(i * 2, c, true));\n const header = new TextEncoder().encode(JSON.stringify({ schema: \"photivra-native-raw-data-id-0.1\", width, height, cfa: layout.siteChannelIds, containerBitDepth: 16 }));\n const idInput = new Uint8Array(header.length + pixels.length); idInput.set(header); idInput.set(pixels, header.length);\n const rawDataUniqueId = (await sha256(idInput)).slice(0, 32);\n const colorHash = (await sha256(new TextEncoder().encode(JSON.stringify(color)))).slice(0, 16);\n const uniqueCameraModel = \"Photivra Virtual Camera \" + color.profileId + \" \" + color.profileVersion + \" \" + colorHash;\n const orientation = ORIENTATION[plan.exposure.geometry.orientation];\n const e = plan.exposure.exposure, software = \"Photivra \" + ENGINE_API_VERSION;\n const description = \"Simulated capture: packed native RAW from the Photivra engine (\" + frame.frameId + \"). Source \" + plan.exposure.source.kind +\n \"; no linear master image or developed rendering is stored.\";\n\n const exif = [rawBytes(36864, 7, new TextEncoder().encode(\"0232\")), rationals(33434, false, [e.shutterSeconds]), rationals(33437, false, [e.aperture]),\n ...(Number.isInteger(e.iso) && e.iso >= 1 && e.iso <= 65535 ? [numbers(34855, 3, [e.iso]), numbers(34864, 3, [2]), numbers(34866, 4, [e.iso])] : []),\n rationals(37386, false, [e.focalLengthMm]), numbers(40961, 3, [65535]), numbers(40962, 4, [crop.width]), numbers(40963, 4, [crop.height]),\n ...(capturedAtUtc === undefined ? [] : [ascii(36867, capturedAtUtc.slice(0, 19).replaceAll(\"-\", \":\").replace(\"T\", \" \")), ascii(36881, \"+00:00\"), ascii(37521, capturedAtUtc.slice(20, 23))])];\n const colorMatrixTag = rationals(50721, true, colorMatrix.flat()), neutralTag = rationals(50728, false, [...development.asShotNeutral]);\n const bytes = packExportTiff([ascii(270, description), ascii(271, \"Photivra\"), ascii(272, \"Photivra Virtual Camera\"), ascii(305, software), numbers(274, 3, [orientation]),\n numbers(254, 4, [0]), numbers(256, 4, [width]), numbers(257, 4, [height]), numbers(258, 3, [16]), numbers(259, 3, [1]), numbers(262, 3, [32803]),\n { ...numbers(273, 4, [0]), pointer: \"pixels\" as const }, numbers(277, 3, [1]), numbers(278, 4, [height]), numbers(279, 4, [pixels.length]),\n numbers(284, 3, [1]), numbers(339, 3, [1]), numbers(33421, 3, [2, 2]), numbers(33422, 1, cfaPattern),\n numbers(50706, 1, [1, 4, 0, 0]), numbers(50707, 1, [1, 1, 0, 0]), ascii(50708, uniqueCameraModel), numbers(50710, 1, [0, 1, 2]), numbers(50711, 3, [1]),\n numbers(50713, 3, [2, 2]), rationals(50714, false, blackLevels), numbers(50717, 4, [whiteLevel]), numbers(50719, 4, [crop.x, crop.y]), numbers(50720, 4, [crop.width, crop.height]),\n colorMatrixTag, rationals(50727, false, [1, 1, 1]), neutralTag,\n rationals(50730, true, [baseline]), numbers(50778, 3, [21]),\n rawBytes(50781, 1, Uint8Array.from(rawDataUniqueId.match(/../g)!.map((s) => parseInt(s, 16)))),\n numbers(50829, 4, [active.y, active.x, active.y + active.height, active.x + active.width]),\n rationals(50964, true, forward.flat()), ...(noiseProfile ? [doubles(51041, noiseProfile)] : [])], exif, pixels);\n return Object.freeze({ schemaVersion: NATIVE_RAW_DNG_SCHEMA_VERSION, mediaType: \"image/dng\" as const, bytes, sha256: await sha256(bytes), rawDataUniqueId, uniqueCameraModel,\n activeArea: { ...active }, defaultCrop: { ...crop }, orientation, blackLevels, whiteLevel, cfaPattern, colorMatrix1: stored(colorMatrixTag), asShotNeutral: stored(neutralTag),\n noiseProfile, unrepresentedSaturationFlagCount: unrepresented, source: \"packed-native-raw\" as const, linearMasterDeclared: false as const });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"native-raw-dng.js","sourceRoot":"","sources":["../../src/capture/native-raw-dng.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,+DAA+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACzI,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,mCAAmC,EAAE,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,EAAE,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AE,gCAAgC,EAAE,aAAa,EAAE,MAAM,EAAE,mBAA4B,EAAE,oBAAoB,EAAE,KAAc,EAAE,CAAC,CAAC;AACjJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n// This product includes DNG technology under license by Adobe.\n\n/**\n * Writes a packed native RAW (`NativeRawOutput`, from the native RAW or native environment RAW tasks) as a\n * lossless, uncompressed 16-bit DNG with a CFA (colour filter array) mosaic.\n *\n * The file describes only what the packed RAW, the caller's declared colour profile and noise model\n * contain. It never claims a linear float master as its source, or a developed image. The tag layout reuses\n * the TIFF/DNG writers of the paired photographic export (`packExportTiff`, DNG 1.4 tags, Adobe DNG\n * Specification 1.7.1.0):\n *\n * - CFA geometry: CFARepeatPatternDim 2×2, CFAPattern and BlackLevel phases relative to the ActiveArea\n * origin (DNG applies them to the stage-2, ActiveArea-cropped image); DefaultCropOrigin/Size are the\n * capture's oriented output crop mapped back to stored (native) coordinates; Orientation from the capture.\n * - Levels: BlackLevel per 2×2 phase (the packed per-site black levels must repeat with the CFA tile).\n * WhiteLevel is the smallest per-phase effective white code, so no channel is reported as unsaturated\n * above its own saturation point. DNG cannot represent a saturation flag on a site whose code is below\n * WhiteLevel; such sites are counted in `unrepresentedSaturationFlagCount`.\n * - Colour: ColorMatrix1 = (camera→XYZ)⁻¹ with CalibrationIlluminant1 D65 (21), ForwardMatrix1 =\n * Bradford(D65→D50)·M·diag(w), AnalogBalance 1, AsShotNeutral from the capture's white-balance intent\n * (the same operator native development uses), BaselineExposure as declared (default 0).\n * - Noise: NoiseProfile (51041) per CFA plane, var(x) = S·x + O for x = (code − black)/(WhiteLevel − black),\n * S = 1/(G·span), O = (σ_read²/G² + 1/12)/span², written only when the caller supplies each channel's\n * output-referred conversion gain G (electrons per code) and read noise σ_read (electrons). The model\n * covers only Poisson photo and dark shot noise, Gaussian read noise and uniform quantization. It is an\n * approximation: PRNU (photo-response non-uniformity), DSNU (dark-signal non-uniformity) and other\n * fixed-pattern noise are not included.\n * - Text (2.4, only with `textMetadata`): the caller's description is appended to ImageDescription after the\n * simulated-RAW statement and the copyright is written as Copyright (33432), each only when it is printable\n * ASCII (TIFF 6.0 §2: ASCII fields hold 7-bit codes). An XMP packet in tag 700 (BYTE; XMP Specification Part 3\n * §1.1.6, Table 13) always carries every given field in UTF-8: `dc:description` (the full ImageDescription text,\n * statement first, as XMP Part 3 §3.2.3 maps tag 270), `dc:rights`, `xmp:CreatorTool` and `exif:UserComment`.\n * The Software tag keeps naming the engine's writer. Without `textMetadata` the bytes are unchanged.\n * @see docs/NATIVE_RAW_AND_PRINT.md for the tag table, limits and the round trip through parseDngRawImage.\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireAllowlistedRecord } from \"../core/record-validation.js\";\nimport { ENGINE_API_VERSION } from \"../core/version.js\";\nimport { resolveCaptureColorModel } from \"../color/capture-color.js\";\nimport { invertSensorColorMatrix, prepareSensorColorDevelopment, sensorColorReferenceWhite } from \"../color/sensor-color-development.js\";\nimport { ICC_D50_WHITE_XYZ } from \"../color/srgb-icc.js\";\nimport { chromaticAdaptationMatrix } from \"../color/chromatic-adaptation.js\";\nimport { transformOrientedRasterRectToNative } from \"../output/capture-geometry.js\";\nimport type { NativeRawOutput } from \"./native-raw.js\";\nimport { checkNativeRawIntegrity, validatePackedNativeRaw } from \"./native-raw-development.js\";\nimport { parseExportSensorColorProfile, type ExportSensorColorProfile } from \"./photographic-export.js\";\nimport { parseOutputTextMetadata, xmpTextMetadataPacket, type OutputTextMetadata } from \"../output/text-metadata.js\";\nimport { packExportTiff, exportTiffAscii as ascii, exportTiffNumbers as numbers, exportTiffRationals as rationals,\n exportTiffBytes as rawBytes, exportTiffDoubles as doubles } from \"./export-tiff.js\";\n\nexport const NATIVE_RAW_DNG_SCHEMA_VERSION = \"1.0.0\" as const;\n\n/** Output-referred noise parameters of one CFA channel (see the module notes). */\nexport interface NativeRawDngChannelNoise {\n /** Electrons per output RAW code (system conversion gain divided by any post-ADC digital gain). */\n conversionGainElectronsPerCode: number;\n /** Combined RMS read noise, electrons. */\n readNoiseRmsElectrons: number;\n}\nexport interface SerializeNativeRawDngInput {\n /** Packed native RAW. It is read, never taken over or modified. */\n raw: NativeRawOutput;\n /** Declared camera→XYZ (D65) colour profile for the RAW's CFA. Native development uses the same profile. */\n colorProfile: ExportSensorColorProfile;\n /** Optional NoiseProfile parameters by channel ID. If omitted, no NoiseProfile tag is written. */\n noise?: Readonly<Record<string, NativeRawDngChannelNoise>>;\n /** BaselineExposure in EV (exposure value stops). Default 0: the RAW white level maps to display white, as in native development. */\n baselineExposureEv?: number;\n /** Optional UTC time of the capture, exactly YYYY-MM-DDTHH:mm:ss.sssZ. If omitted, no date tags are written; the engine never makes up a clock time. */\n capturedAtUtc?: string;\n /** Optional (2.4) caller text: description, software, copyright, comment (see the module notes). If omitted, no text is added. */\n textMetadata?: OutputTextMetadata;\n}\nexport interface NativeRawDng {\n schemaVersion: typeof NATIVE_RAW_DNG_SCHEMA_VERSION;\n mediaType: \"image/dng\";\n bytes: Uint8Array;\n sha256: string;\n /** RawDataUniqueID (32 hex digits): the first 128 bits of SHA-256 over a fixed header and the little-endian codes. */\n rawDataUniqueId: string;\n uniqueCameraModel: string;\n /** Stored geometry, levels and colour values exactly as written (rationals as numerator/denominator). */\n activeArea: { x: number; y: number; width: number; height: number };\n defaultCrop: { x: number; y: number; width: number; height: number };\n orientation: number;\n blackLevels: readonly number[];\n whiteLevel: number;\n cfaPattern: readonly number[];\n colorMatrix1: readonly number[];\n asShotNeutral: readonly number[];\n noiseProfile: readonly number[] | null;\n /** Sites flagged saturated whose code is below WhiteLevel; DNG has no field for them. */\n unrepresentedSaturationFlagCount: number;\n source: \"packed-native-raw\";\n linearMasterDeclared: false;\n}\n\nfunction fail(message: string): never { throw new InvalidConfigurationError(\"Native RAW DNG: \" + message); }\nasync function sha256(bytes: Uint8Array): Promise<string> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) fail(\"needs crypto.subtle (a secure browser context or Node 22+).\");\n return Array.from(new Uint8Array(await subtle.digest(\"SHA-256\", bytes as Uint8Array<ArrayBuffer>)), (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n}\n/** Values exactly as stored by a RATIONAL/SRATIONAL tag (numerator / denominator), so reported metadata equals what a reader decodes. */\nfunction stored(tag: ReturnType<typeof rationals>): number[] {\n const view = new DataView(tag.data.buffer, tag.data.byteOffset, tag.data.byteLength);\n return Array.from({ length: tag.count }, (_, i) => (tag.type === 10 ? view.getInt32(i * 8, true) : view.getUint32(i * 8, true)) / view.getUint32(i * 8 + 4, true));\n}\nconst ORIENTATION = { landscape: 1, \"portrait-clockwise\": 6, \"landscape-inverted\": 3, \"portrait-counter-clockwise\": 8 } as const;\n\n/**\n * Writes packed native RAW codes as a lossless, uncompressed CFA DNG. The module notes list every tag and\n * where its value comes from. The input arrays are copied before the first await.\n */\nexport async function serializeNativeRawDng(input: SerializeNativeRawDngInput): Promise<NativeRawDng> {\n const r = requireAllowlistedRecord(input, [\"raw\", \"colorProfile\", \"noise\", \"baselineExposureEv\", \"capturedAtUtc\", \"textMetadata\"], \"Invalid native RAW DNG input.\");\n const raw = r.raw as NativeRawOutput, plan = validatePackedNativeRaw(raw);\n const mosaic = plan.frame.colorSamplingProfile.layout;\n if (mosaic.kind === \"periodic-mosaic\") checkNativeRawIntegrity(raw, plan.exposure.geometry.nativeRaster.pixelWidth, mosaic.repeatWidthSites, mosaic.repeatHeightSites, 0, plan.exposure.geometry.nativeRaster.pixelHeight);\n const color = parseExportSensorColorProfile(r.colorProfile), frame = plan.frame, layout = frame.colorSamplingProfile.layout;\n if (layout.kind !== \"periodic-mosaic\" || layout.repeatWidthSites !== 2 || layout.repeatHeightSites !== 2 ||\n [...layout.siteChannelIds].sort().join() !== \"blue,green,green,red\" || color.channelIds.join() !== \"red,green,blue\")\n fail(\"supports 2×2 RGB Bayer CFAs with red, green, blue colour-profile channels only.\");\n if (color.colorSamplingProfileId !== frame.colorSamplingProfile.profileId) fail(\"colour profile is not bound to the RAW's CFA.\");\n const baseline = r.baselineExposureEv === undefined ? 0 : r.baselineExposureEv;\n if (typeof baseline !== \"number\" || !Number.isFinite(baseline) || Math.abs(baseline) > 16) fail(\"baselineExposureEv must be finite within ±16.\");\n const capturedAtUtc = r.capturedAtUtc as string | undefined;\n if (capturedAtUtc !== undefined && (typeof capturedAtUtc !== \"string\" || !/^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d\\.\\d{3}Z$/.test(capturedAtUtc) || Number.isNaN(Date.parse(capturedAtUtc))))\n fail(\"capturedAtUtc must be YYYY-MM-DDTHH:mm:ss.sssZ.\");\n let text: Readonly<OutputTextMetadata> | undefined;\n try { text = parseOutputTextMetadata(r.textMetadata, \"textMetadata\"); } catch (error) { fail((error as Error).message); }\n\n const native = plan.exposure.geometry.nativeRaster, width = native.pixelWidth, height = native.pixelHeight, g = plan.exposure.resolvedGeometry;\n const active = g.activeCapture.nativeRect;\n const crop = transformOrientedRasterRectToNative({ rect: g.output.cropRect, nativeRaster: g.activeCapture.raster, orientation: plan.exposure.geometry.orientation });\n // Copy before any await: the caller keeps ownership of the packed arrays.\n const codes = raw.codes.slice(), blacks = raw.blackLevels.slice(), flags = raw.saturationFlags.slice(), whiteByPhase = Array.from(raw.effectiveSaturationCodes);\n\n // Levels per CFA phase, relative to the active area. The black-level tile must repeat exactly.\n const blackLevels: number[] = [], cfaPattern: number[] = [], whites: number[] = [], phaseChannel: string[] = [];\n for (let py = 0; py < 2; py++) for (let px = 0; px < 2; px++) {\n const ax = (active.x + px) % 2, ay = (active.y + py) % 2;\n const black = blacks[ay * width + ax]!;\n for (let y = ay; y < height; y += 2) for (let x = ax; x < width; x += 2) if (blacks[y * width + x] !== black) fail(\"per-site black levels do not repeat with the 2×2 CFA tile.\");\n const channel = layout.siteChannelIds[ay * 2 + ax]!;\n blackLevels.push(black); whites.push(whiteByPhase[ay * 2 + ax]!); phaseChannel.push(channel); cfaPattern.push([\"red\", \"green\", \"blue\"].indexOf(channel));\n }\n const whiteLevel = Math.min(...whites);\n if (blackLevels.some((b) => b >= whiteLevel)) fail(\"black level must be below the effective WhiteLevel.\");\n let unrepresented = 0;\n for (let i = 0; i < codes.length; i++) if (flags[i] !== 0 && codes[i]! < whiteLevel) unrepresented++;\n\n // NoiseProfile: one (S, O) pair per CFA plane colour, only when every phase of a channel shares its black level.\n let noiseProfile: number[] | null = null;\n if (r.noise !== undefined) {\n const noise = requireAllowlistedRecord(r.noise, [\"red\", \"green\", \"blue\"], \"Invalid native RAW DNG noise.\") as Record<string, NativeRawDngChannelNoise>;\n noiseProfile = [];\n for (const channel of [\"red\", \"green\", \"blue\"]) {\n const n = noise[channel];\n if (!n) fail(\"noise needs red, green and blue entries.\");\n requireAllowlistedRecord(n, [\"conversionGainElectronsPerCode\", \"readNoiseRmsElectrons\"], \"Invalid native RAW DNG channel noise.\");\n const gain = n.conversionGainElectronsPerCode, read = n.readNoiseRmsElectrons;\n if (typeof gain !== \"number\" || !Number.isFinite(gain) || gain <= 0 || typeof read !== \"number\" || !Number.isFinite(read) || read < 0) fail(\"noise gain must be positive and read noise non-negative.\");\n const phaseBlacks = blackLevels.filter((_, i) => phaseChannel[i] === channel);\n if (phaseBlacks.some((b) => b !== phaseBlacks[0])) { noiseProfile = null; break; }\n const span = whiteLevel - phaseBlacks[0]!;\n noiseProfile.push(1 / (gain * span), (read * read / (gain * gain) + 1 / 12) / (span * span));\n }\n }\n\n // Colour tags from the declared profile and the capture's white-balance intent.\n const m = color.normalizedCameraChannelsToXyz, colorMatrix = invertSensorColorMatrix(m), intent = plan.exposure.whiteBalanceIntent;\n const development = prepareSensorColorDevelopment(m, intent ? [intent.channelGains.red, intent.channelGains.green, intent.channelGains.blue] : null);\n const cameraWhite = sensorColorReferenceWhite(colorMatrix);\n const chad = chromaticAdaptationMatrix({ transform: \"bradford\", sourceWhiteXyz: resolveCaptureColorModel().referenceWhiteXyz,\n destinationWhiteXyz: { x: ICC_D50_WHITE_XYZ[0], y: 1, z: ICC_D50_WHITE_XYZ[2] } }).matrix;\n const forward = chad.map((row) => [0, 1, 2].map((j) => row.reduce((sum, x, k) => sum + x * m[k]![j]! * cameraWhite[j]!, 0)));\n\n const pixels = new Uint8Array(codes.length * 2), view = new DataView(pixels.buffer);\n codes.forEach((c, i) => view.setUint16(i * 2, c, true));\n const header = new TextEncoder().encode(JSON.stringify({ schema: \"photivra-native-raw-data-id-0.1\", width, height, cfa: layout.siteChannelIds, containerBitDepth: 16 }));\n const idInput = new Uint8Array(header.length + pixels.length); idInput.set(header); idInput.set(pixels, header.length);\n const rawDataUniqueId = (await sha256(idInput)).slice(0, 32);\n const colorHash = (await sha256(new TextEncoder().encode(JSON.stringify(color)))).slice(0, 16);\n const uniqueCameraModel = \"Photivra Virtual Camera \" + color.profileId + \" \" + color.profileVersion + \" \" + colorHash;\n const orientation = ORIENTATION[plan.exposure.geometry.orientation];\n const e = plan.exposure.exposure, software = \"Photivra \" + ENGINE_API_VERSION;\n const statement = \"Simulated capture: packed native RAW from the Photivra engine (\" + frame.frameId + \"). Source \" + plan.exposure.source.kind +\n \"; no linear master image or developed rendering is stored.\";\n const printableAscii = (value: string | undefined): value is string => value !== undefined && /^[\\x20-\\x7e]*$/.test(value);\n const description = printableAscii(text?.description) ? statement + \" \" + text.description : statement;\n const textTags = text === undefined ? [] : [\n ...(printableAscii(text.copyright) ? [ascii(33432, text.copyright)] : []),\n rawBytes(700, 1, xmpTextMetadataPacket({ ...text, description: text.description === undefined ? statement : statement + \" \" + text.description }))];\n\n const exif = [rawBytes(36864, 7, new TextEncoder().encode(\"0232\")), rationals(33434, false, [e.shutterSeconds]), rationals(33437, false, [e.aperture]),\n ...(Number.isInteger(e.iso) && e.iso >= 1 && e.iso <= 65535 ? [numbers(34855, 3, [e.iso]), numbers(34864, 3, [2]), numbers(34866, 4, [e.iso])] : []),\n rationals(37386, false, [e.focalLengthMm]), numbers(40961, 3, [65535]), numbers(40962, 4, [crop.width]), numbers(40963, 4, [crop.height]),\n ...(capturedAtUtc === undefined ? [] : [ascii(36867, capturedAtUtc.slice(0, 19).replaceAll(\"-\", \":\").replace(\"T\", \" \")), ascii(36881, \"+00:00\"), ascii(37521, capturedAtUtc.slice(20, 23))])];\n const colorMatrixTag = rationals(50721, true, colorMatrix.flat()), neutralTag = rationals(50728, false, [...development.asShotNeutral]);\n const bytes = packExportTiff([ascii(270, description), ascii(271, \"Photivra\"), ascii(272, \"Photivra Virtual Camera\"), ascii(305, software), numbers(274, 3, [orientation]),\n numbers(254, 4, [0]), numbers(256, 4, [width]), numbers(257, 4, [height]), numbers(258, 3, [16]), numbers(259, 3, [1]), numbers(262, 3, [32803]),\n { ...numbers(273, 4, [0]), pointer: \"pixels\" as const }, numbers(277, 3, [1]), numbers(278, 4, [height]), numbers(279, 4, [pixels.length]),\n numbers(284, 3, [1]), numbers(339, 3, [1]), numbers(33421, 3, [2, 2]), numbers(33422, 1, cfaPattern),\n numbers(50706, 1, [1, 4, 0, 0]), numbers(50707, 1, [1, 1, 0, 0]), ascii(50708, uniqueCameraModel), numbers(50710, 1, [0, 1, 2]), numbers(50711, 3, [1]),\n numbers(50713, 3, [2, 2]), rationals(50714, false, blackLevels), numbers(50717, 4, [whiteLevel]), numbers(50719, 4, [crop.x, crop.y]), numbers(50720, 4, [crop.width, crop.height]),\n colorMatrixTag, rationals(50727, false, [1, 1, 1]), neutralTag,\n rationals(50730, true, [baseline]), numbers(50778, 3, [21]),\n rawBytes(50781, 1, Uint8Array.from(rawDataUniqueId.match(/../g)!.map((s) => parseInt(s, 16)))),\n numbers(50829, 4, [active.y, active.x, active.y + active.height, active.x + active.width]),\n rationals(50964, true, forward.flat()), ...(noiseProfile ? [doubles(51041, noiseProfile)] : []), ...textTags], exif, pixels);\n return Object.freeze({ schemaVersion: NATIVE_RAW_DNG_SCHEMA_VERSION, mediaType: \"image/dng\" as const, bytes, sha256: await sha256(bytes), rawDataUniqueId, uniqueCameraModel,\n activeArea: { ...active }, defaultCrop: { ...crop }, orientation, blackLevels, whiteLevel, cfaPattern, colorMatrix1: stored(colorMatrixTag), asShotNeutral: stored(neutralTag),\n noiseProfile, unrepresentedSaturationFlagCount: unrepresented, source: \"packed-native-raw\" as const, linearMasterDeclared: false as const });\n}\n"]}
|
|
@@ -149,4 +149,7 @@ rows?: {
|
|
|
149
149
|
readonly y: number;
|
|
150
150
|
readonly height: number;
|
|
151
151
|
readonly firstSite?: (site: SensorRawProducerSiteInput) => void;
|
|
152
|
+
/** Internal (2.3 region rendering): also restrict to native columns [x, x + width). The output arrays are then that rectangle, row-major. */
|
|
153
|
+
readonly x?: number;
|
|
154
|
+
readonly width?: number;
|
|
152
155
|
}): NativeRawTask;
|
|
@@ -109,7 +109,10 @@ rows) {
|
|
|
109
109
|
throw new InvalidConfigurationError("Native RAW requires reader and host event-loop yield.");
|
|
110
110
|
const read = provider.readTile.bind(provider), yieldControl = provider.yieldControl.bind(provider), abort = new AbortController();
|
|
111
111
|
const native = plan.exposure.geometry.nativeRaster, tileWidth = plan.tileWidth ?? NATIVE_RAW_LIMITS.tileWidth;
|
|
112
|
-
const rowStart = rows?.y ?? 0, rowEnd = rowStart + (rows?.height ?? native.pixelHeight),
|
|
112
|
+
const rowStart = rows?.y ?? 0, rowEnd = rowStart + (rows?.height ?? native.pixelHeight), colStart = rows?.x ?? 0, colEnd = colStart + (rows?.width ?? native.pixelWidth);
|
|
113
|
+
if (colStart < 0 || colEnd > native.pixelWidth || colEnd <= colStart)
|
|
114
|
+
throw new InvalidConfigurationError("Native RAW column band must lie inside the native raster.");
|
|
115
|
+
const bandWidth = colEnd - colStart, length = (rowEnd - rowStart) * bandWidth;
|
|
113
116
|
let state = "ready", count = 0, output = null, first;
|
|
114
117
|
function release() { if (output) {
|
|
115
118
|
output.codes.fill(0);
|
|
@@ -134,9 +137,9 @@ rows) {
|
|
|
134
137
|
const white = createPhaseWhiteLevelAccumulator(native.pixelWidth, layout.repeatWidthSites, layout.repeatHeightSites);
|
|
135
138
|
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) };
|
|
136
139
|
for (let y = rowStart; y < rowEnd; y++)
|
|
137
|
-
for (let x =
|
|
140
|
+
for (let x = colStart; x < colEnd; x += tileWidth) {
|
|
138
141
|
active();
|
|
139
|
-
const request = Object.freeze({ captureId: plan.exposure.captureId, frameId: plan.frame.frameId, x, y, width: Math.min(tileWidth,
|
|
142
|
+
const request = Object.freeze({ captureId: plan.exposure.captureId, frameId: plan.frame.frameId, x, y, width: Math.min(tileWidth, colEnd - x), height: 1 });
|
|
140
143
|
{
|
|
141
144
|
const supplied = await read(request, abort.signal);
|
|
142
145
|
active();
|
|
@@ -163,7 +166,7 @@ rows) {
|
|
|
163
166
|
const seed = plan.exposure.noise.seedUint32;
|
|
164
167
|
for (let j = 0; j < sites.length; j++) {
|
|
165
168
|
// index: absolute native index (seeds, CFA phase); at: position in this task's output arrays.
|
|
166
|
-
const index = y * native.pixelWidth + x + j, at =
|
|
169
|
+
const index = y * native.pixelWidth + x + j, at = (y - rowStart) * bandWidth + x + j - colStart, handle = lean?.[j];
|
|
167
170
|
if (handle) {
|
|
168
171
|
const o = leanSensor.compute(handle, index, seed, timing?.samples[j]);
|
|
169
172
|
output.codes[at] = o.rawCode;
|
|
@@ -185,7 +188,7 @@ rows) {
|
|
|
185
188
|
count++;
|
|
186
189
|
}
|
|
187
190
|
// Yield when the time budget is spent, and always after the final tile. Yield timing never changes output.
|
|
188
|
-
if (gate.due() || (y === rowEnd - 1 && x + tileWidth >=
|
|
191
|
+
if (gate.due() || (y === rowEnd - 1 && x + tileWidth >= colEnd)) {
|
|
189
192
|
await yieldControl(abort.signal);
|
|
190
193
|
active();
|
|
191
194
|
gate.restart();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-raw.js","sourceRoot":"","sources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gBAAA,KAAK,GAAC,SAAS,CAAC;gBAAA,KAAK,GAAC,WAAW,CAAC;YAC7G,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,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"]}
|
|
1
|
+
{"version":3,"file":"native-raw.js","sourceRoot":"","sources":["../../src/capture/native-raw.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;GAGG;AACH,OAA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C","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;\n /** Internal (2.3 region rendering): also restrict to native columns [x, x + width). The output arrays are then that rectangle, row-major. */\n readonly x?: number; readonly width?: number }): NativeRawTask {\n const plan=calculateNativeRawPlan(input);\n if(!provider||typeof provider.readTile!==\"function\"||typeof provider.yieldControl!==\"function\")throw new InvalidConfigurationError(\"Native RAW requires reader and host event-loop yield.\");\n const read=provider.readTile.bind(provider),yieldControl=provider.yieldControl.bind(provider),abort=new AbortController();\n const native=plan.exposure.geometry.nativeRaster,tileWidth=plan.tileWidth??NATIVE_RAW_LIMITS.tileWidth;\n const rowStart=rows?.y??0,rowEnd=rowStart+(rows?.height??native.pixelHeight),colStart=rows?.x??0,colEnd=colStart+(rows?.width??native.pixelWidth);\n if(colStart<0||colEnd>native.pixelWidth||colEnd<=colStart)throw new InvalidConfigurationError(\"Native RAW column band must lie inside the native raster.\");\n const bandWidth=colEnd-colStart,length=(rowEnd-rowStart)*bandWidth;\n let state:NativeRawTaskState=\"ready\",count=0,output:NativeRawOutput|null=null,first:SensorRawProducerSiteInput|undefined;\n function release(): void {if(output){output.codes.fill(0);output.blackLevels.fill(0);output.digitalSaturationCodes.fill(0);output.saturationFlags.fill(0);output.effectiveSaturationCodes.fill(0);}output=null;first=undefined;}\n function active(): void {if(abort.signal.aborted)throw new InvalidConfigurationError(\"Native RAW execution aborted.\");}\n return {plan,get state(): NativeRawTaskState {return state;},get completedTileCount(): number {return count;},\n async run(): Promise<void> {\n if(state!==\"ready\")throw new InvalidConfigurationError(\"Native RAW task is single-use.\");state=\"running\";\n try{\n const gate=sharedGate??createHostYieldGate(cadence);sharedGate?.restart();\n const layout=plan.frame.colorSamplingProfile.layout;if(layout.kind!==\"periodic-mosaic\")throw new InvalidConfigurationError(\"Native RAW requires periodic CFA.\");\n const white=createPhaseWhiteLevelAccumulator(native.pixelWidth,layout.repeatWidthSites,layout.repeatHeightSites);\n output={plan,codes:new Uint16Array(length),blackLevels:new Uint16Array(length),digitalSaturationCodes:new Uint16Array(length),saturationFlags:new Uint8Array(length),effectiveSaturationCodes:new Uint16Array(layout.repeatWidthSites*layout.repeatHeightSites)};\n for(let y=rowStart;y<rowEnd;y++)for(let x=colStart;x<colEnd;x+=tileWidth){\n active();const request=Object.freeze({captureId:plan.exposure.captureId,frameId:plan.frame.frameId,x,y,width:Math.min(tileWidth,colEnd-x),height:1});\n {\n const supplied=await read(request,abort.signal);active();\n const tile=requireAllowlistedRecord(supplied,[\"captureId\",\"frameId\",\"x\",\"y\",\"width\",\"height\",\"sites\"],\"Invalid native RAW tile.\");\n for(const key of Object.keys(request) as (keyof NativeRawTileRequest)[])if(tile[key]!==request[key])throw new InvalidConfigurationError(\"Native RAW tile identity mismatch.\");\n if(!Array.isArray(tile.sites)||tile.sites.length!==request.width||Array.from({length:request.width},(_,i)=>i in (tile.sites as unknown[])).includes(false))throw new InvalidConfigurationError(\"Native RAW tile needs exact dense coverage.\");\n const timing=plan.exposureWindow?windows(plan.exposure,plan.exposureWindow,Array.from({length:request.width},(_,i)=>({x:x+i+.5,y:y+.5}))):undefined;\n // Lean entries (built by the engine, provably valid against an earlier verified template) skip parsing and\n // identity checks. They are only claimed once the frame's first site is fixed.\n const lean=leanSensor&&first!==undefined?(tile.sites as unknown[]).map(site=>leanSensor.claim(site)):undefined;\n const sites=tile.sites.map((site,j)=>lean?.[j]?undefined:parseNativeRawProducerSite(site,y*native.pixelWidth+x+j,plan.frame,timing?.samples[j]));\n if(first===undefined){first=sites[0];if(first)rows?.firstSite?.(first);}for(const s of sites)if(s)validateNativeRawReadoutIdentity(s,first!);\n // Every site in this tile is validated before any output is written. A failure never returns partial output.\n const seed=plan.exposure.noise.seedUint32;\n for(let j=0;j<sites.length;j++){\n // index: absolute native index (seeds, CFA phase); at: position in this task's output arrays.\n const index=y*native.pixelWidth+x+j,at=(y-rowStart)*bandWidth+x+j-colStart,handle=lean?.[j];\n if(handle){\n const o=leanSensor!.compute(handle,index,seed,timing?.samples[j]);\n output.codes[at]=o.rawCode;output.blackLevels[at]=o.blackLevelCode;output.digitalSaturationCodes[at]=o.digitalSaturationCode;\n output.saturationFlags[at]=o.flags;white.record(index,o.whiteCode);continue;\n }\n const result=calculateNativeRawSite(sites[j]!,seed,index),r=result.readout.value;\n output.codes[at]=r.rawCode;output.blackLevels[at]=r.blackLevelCode;output.digitalSaturationCodes[at]=r.digitalSaturationCode;\n output.saturationFlags[at]=Number(r.physicalScalarSaturationApplied)|Number(r.preAdcSaturationApplied)<<1|Number(r.digitalSaturationApplied)<<2;\n const whiteCode=calculateSiteEffectiveSaturationCode(r,sites[j]!.readoutProfile,sites[j]!.regimeId);\n white.record(index,whiteCode);\n leanSensor?.observe(index,sites[j]!,result,whiteCode,seed);\n }\n count++;\n }\n // Yield when the time budget is spent, and always after the final tile. Yield timing never changes output.\n if(gate.due()||(y===rowEnd-1&&x+tileWidth>=colEnd)){await yieldControl(abort.signal);active();gate.restart();}\n }\n output.effectiveSaturationCodes.set(rows?white.partial():white.finish());first=undefined;state=\"completed\";\n }catch(error){release();if(!abort.signal.aborted){state=\"failed\";abort.abort();}throw error;}\n },\n cancel(): void {if(state===\"ready\"||state===\"running\"||state===\"completed\"){state=\"cancelled\";abort.abort();release();}},\n dispose(): void {if(state!==\"transferred\"){state=\"disposed\";abort.abort();release();}},\n takeOutput(): NativeRawOutput {if(state!==\"completed\"||!output)throw new InvalidConfigurationError(\"Native RAW output unavailable.\");const result=output;output=null;first=undefined;state=\"transferred\";return result;}\n };\n}\n"]}
|
package/dist/core/version.d.ts
CHANGED
package/dist/core/version.js
CHANGED
package/dist/core/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAgB,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Version of the engine release. Since 1.0.1 it equals the npm package version.\n *\n * New captures and plans record this version as their creator. Archived records keep the\n * version they were made with. Proof-of-concept (POC), schema and model contracts have their\n * own versions. Release checks confirm it matches package.json and the packed package.\n * @see docs/RELEASE_1_0_1.md\n */\nexport const ENGINE_API_VERSION = \"2.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAgB,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Version of the engine release. Since 1.0.1 it equals the npm package version.\n *\n * New captures and plans record this version as their creator. Archived records keep the\n * version they were made with. Proof-of-concept (POC), schema and model contracts have their\n * own versions. Release checks confirm it matches package.json and the packed package.\n * @see docs/RELEASE_1_0_1.md\n */\nexport const ENGINE_API_VERSION = \"2.4.1\" as const;\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Full-frame-equivalent focal lengths of the generic prime family, mm. */
|
|
2
|
+
export declare const GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM: readonly [10, 12, 14, 16, 20, 24, 28, 35, 40, 50, 85, 105, 135, 200, 300, 400, 500, 600, 800, 1200];
|
|
3
|
+
export type GenericPrimeEquivalentFocalLengthMm = typeof GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM[number];
|
|
4
|
+
/**
|
|
5
|
+
* The marked third-stop f-numbers (the conventional rounded values of N = 2^(k/6), k = 0, 1, …), from f/1 to f/32.
|
|
6
|
+
* A lens's `fNumbers` are those within its range; any f-number inside the range is accepted.
|
|
7
|
+
*/
|
|
8
|
+
export declare const GENERIC_PRIME_THIRD_STOP_F_NUMBERS: readonly [1, 1.1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.5, 2.8, 3.2, 3.5, 4, 4.5, 5, 5.6, 6.3, 7.1, 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 25, 29, 32];
|
|
9
|
+
/** Minimum focus rule: the object distance at this magnification, but at least `minimumDistanceM`. */
|
|
10
|
+
export declare const GENERIC_PRIME_MINIMUM_FOCUS: Readonly<{
|
|
11
|
+
magnification: 0.15;
|
|
12
|
+
minimumDistanceM: 0.1;
|
|
13
|
+
}>;
|
|
14
|
+
export interface GenericPrimeLens {
|
|
15
|
+
/** Public opaque id, for example "generic-prime-50mm-equivalent". */
|
|
16
|
+
lensId: string;
|
|
17
|
+
equivalentFocalLengthMm: GenericPrimeEquivalentFocalLengthMm;
|
|
18
|
+
/** Physical focal length for this sensor: equivalent ÷ crop factor. */
|
|
19
|
+
focalLengthMm: number;
|
|
20
|
+
/** Diagonal crop factor of the sensor (36 × 24 mm = 1). */
|
|
21
|
+
cropFactor35Mm: number;
|
|
22
|
+
/** Widest aperture (smallest f-number) and narrowest aperture. */
|
|
23
|
+
widestFNumber: number;
|
|
24
|
+
narrowestFNumber: number;
|
|
25
|
+
/** The marked third-stop f-numbers within the range. */
|
|
26
|
+
fNumbers: readonly number[];
|
|
27
|
+
/** max(0.10 m, f·(1 + 1/0.15)), metres from the lens (thin lens). */
|
|
28
|
+
minimumFocusDistanceM: number;
|
|
29
|
+
/** Magnification at the minimum focus distance, f/(d − f). */
|
|
30
|
+
maximumMagnification: number;
|
|
31
|
+
scientificStatus: "approximation";
|
|
32
|
+
limitations: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
/** Minimum focus distance of a generic prime of physical focal length `focalLengthMm`: max(0.10 m, f·(1 + 1/0.15)). */
|
|
35
|
+
export declare function calculateGenericPrimeMinimumFocusDistanceM(focalLengthMm: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Resolves a generic prime for a sensor: its actual focal length, f-number range, marked f-numbers and minimum focus.
|
|
38
|
+
* `activeImagingArea` is the sensor's active capture area in millimetres.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveGenericPrimeLens(input: {
|
|
41
|
+
equivalentFocalLengthMm: number;
|
|
42
|
+
activeImagingArea: {
|
|
43
|
+
widthMm: number;
|
|
44
|
+
heightMm: number;
|
|
45
|
+
};
|
|
46
|
+
}): GenericPrimeLens;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* Generic prime lens family (2.3): educational lenses named by their full-frame-equivalent focal length,
|
|
4
|
+
* written for this engine. They are not real products and carry no brand. Each lens is defined by three
|
|
5
|
+
* rules only:
|
|
6
|
+
* - actual focal length = equivalent focal length ÷ the sensor's diagonal crop factor
|
|
7
|
+
* (`calculateEquivalentFocalLength35Mm`, 36 × 24 mm reference);
|
|
8
|
+
* - an f-number range by focal-length class (widest aperture) and focal length (narrowest aperture);
|
|
9
|
+
* - a minimum focus distance max(0.10 m, f·(1 + 1/0.15)): the thin-lens object distance at 0.15×
|
|
10
|
+
* magnification (d = f(1 + 1/m)), but never closer than 10 cm. A generic thin-lens approximation, not a
|
|
11
|
+
* measured lens.
|
|
12
|
+
* @see docs/QUICK_START.md, "Generic prime lenses".
|
|
13
|
+
*/
|
|
14
|
+
import { InvalidConfigurationError } from "../core/configuration-error.js";
|
|
15
|
+
import { requireInputKeys, requireInputObject } from "../core/record-validation.js";
|
|
16
|
+
import { calculateEquivalentFocalLength35Mm } from "../camera/equivalent-focal-length.js";
|
|
17
|
+
/** Full-frame-equivalent focal lengths of the generic prime family, mm. */
|
|
18
|
+
export const GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM = Object.freeze([10, 12, 14, 16, 20, 24, 28, 35, 40, 50, 85, 105, 135, 200, 300, 400, 500, 600, 800, 1200]);
|
|
19
|
+
/**
|
|
20
|
+
* The marked third-stop f-numbers (the conventional rounded values of N = 2^(k/6), k = 0, 1, …), from f/1 to f/32.
|
|
21
|
+
* A lens's `fNumbers` are those within its range; any f-number inside the range is accepted.
|
|
22
|
+
*/
|
|
23
|
+
export const GENERIC_PRIME_THIRD_STOP_F_NUMBERS = Object.freeze([1, 1.1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.5, 2.8, 3.2, 3.5, 4, 4.5, 5, 5.6, 6.3, 7.1, 8, 9, 10, 11,
|
|
24
|
+
13, 14, 16, 18, 20, 22, 25, 29, 32]);
|
|
25
|
+
/** Minimum focus rule: the object distance at this magnification, but at least `minimumDistanceM`. */
|
|
26
|
+
export const GENERIC_PRIME_MINIMUM_FOCUS = Object.freeze({ magnification: 0.15, minimumDistanceM: 0.1 });
|
|
27
|
+
/** Widest f-number by equivalent focal length (inclusive upper bounds of each class). */
|
|
28
|
+
const WIDEST = [[16, 2.8], [28, 1.8], [85, 1.4], [135, 2], [300, 2.8], [600, 4], [800, 5.6], [1200, 8]];
|
|
29
|
+
/** Narrowest f-number by equivalent focal length. */
|
|
30
|
+
const NARROWEST = [[16, 16], [135, 22], [1200, 32]];
|
|
31
|
+
/** Minimum focus distance of a generic prime of physical focal length `focalLengthMm`: max(0.10 m, f·(1 + 1/0.15)). */
|
|
32
|
+
export function calculateGenericPrimeMinimumFocusDistanceM(focalLengthMm) {
|
|
33
|
+
if (typeof focalLengthMm !== "number" || !Number.isFinite(focalLengthMm) || focalLengthMm <= 0)
|
|
34
|
+
throw new InvalidConfigurationError("focalLengthMm must be a positive finite number.");
|
|
35
|
+
return Math.max(GENERIC_PRIME_MINIMUM_FOCUS.minimumDistanceM, focalLengthMm / 1000 * (1 + 1 / GENERIC_PRIME_MINIMUM_FOCUS.magnification));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolves a generic prime for a sensor: its actual focal length, f-number range, marked f-numbers and minimum focus.
|
|
39
|
+
* `activeImagingArea` is the sensor's active capture area in millimetres.
|
|
40
|
+
*/
|
|
41
|
+
export function resolveGenericPrimeLens(input) {
|
|
42
|
+
requireInputObject(input, "resolveGenericPrimeLens input");
|
|
43
|
+
requireInputKeys(input, "resolveGenericPrimeLens", ["equivalentFocalLengthMm", "activeImagingArea"]);
|
|
44
|
+
const equivalent = input.equivalentFocalLengthMm;
|
|
45
|
+
if (!GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM.includes(equivalent))
|
|
46
|
+
throw new InvalidConfigurationError("equivalentFocalLengthMm must be one of the generic primes: " + GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM.join(", ") + " mm.");
|
|
47
|
+
requireInputObject(input.activeImagingArea, "activeImagingArea");
|
|
48
|
+
const crop = calculateEquivalentFocalLength35Mm({ focalLengthMm: 1, activeImagingArea: { widthMm: input.activeImagingArea.widthMm, heightMm: input.activeImagingArea.heightMm } }).value.cropFactor35Mm;
|
|
49
|
+
const focalLengthMm = equivalent / crop;
|
|
50
|
+
const widest = WIDEST.find(([bound]) => equivalent <= bound)[1], narrowest = NARROWEST.find(([bound]) => equivalent <= bound)[1];
|
|
51
|
+
const minimumFocusDistanceM = calculateGenericPrimeMinimumFocusDistanceM(focalLengthMm), f = focalLengthMm / 1000;
|
|
52
|
+
return Object.freeze({ lensId: "generic-prime-" + equivalent + "mm-equivalent", equivalentFocalLengthMm: equivalent, focalLengthMm,
|
|
53
|
+
cropFactor35Mm: crop, widestFNumber: widest, narrowestFNumber: narrowest,
|
|
54
|
+
fNumbers: Object.freeze(GENERIC_PRIME_THIRD_STOP_F_NUMBERS.filter((n) => n >= widest && n <= narrowest)), minimumFocusDistanceM,
|
|
55
|
+
maximumMagnification: f / (minimumFocusDistanceM - f), scientificStatus: "approximation",
|
|
56
|
+
limitations: Object.freeze(["Generic educational prime defined by focal length, f-number range and a thin-lens minimum-focus rule; not a real product.",
|
|
57
|
+
"Minimum focus max(0.10 m, f·(1 + 1/0.15)) is a thin-lens approximation measured from the lens; real lenses differ (internal focusing, pupil positions, focus breathing)."]) });
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=generic-prime-lenses.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-prime-lenses.js","sourceRoot":"","sources":["../../src/equipment/generic-prime-lenses.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAE,kCAAkC,EAAE,MAAM,sCAAsC,CAAC;AAE1F,2EAA2E;AAC3E,MAAM,CAAC,MAAM,yCAAyC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAU,CAAC,CAAC;AAE5K;;;GAGG;AACH,MAAM,CAAC,MAAM,kCAAkC,G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,CAAE,CAAC,CAAC,CAAC,CAAC;IACnI,MAAM,qBAAqB,GAAG,0CAA0C,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,aAAa,GAAG,IAAI,CAAC;IAClH,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAAE,uBAAuB,EAAE,UAAiD,EAAE,aAAa;QACvK,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,SAAS;QACxE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,kCAAkC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,MAAM,IAAI,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,qBAAqB;QAC/H,oBAAoB,EAAE,CAAC,GAAG,CAAC,qBAAqB,GAAG,CAAC,CAAC,EAAE,gBAAgB,EAAE,eAAwB;QACjG,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,2HAA2H;YACrJ,0KAA0K,CAAC,CAAC,EAAE,CAAC,CAAC;AACtL,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Generic prime lens family (2.3): educational lenses named by their full-frame-equivalent focal length,\n * written for this engine. They are not real products and carry no brand. Each lens is defined by three\n * rules only:\n * - actual focal length = equivalent focal length ÷ the sensor's diagonal crop factor\n * (`calculateEquivalentFocalLength35Mm`, 36 × 24 mm reference);\n * - an f-number range by focal-length class (widest aperture) and focal length (narrowest aperture);\n * - a minimum focus distance max(0.10 m, f·(1 + 1/0.15)): the thin-lens object distance at 0.15×\n * magnification (d = f(1 + 1/m)), but never closer than 10 cm. A generic thin-lens approximation, not a\n * measured lens.\n * @see docs/QUICK_START.md, \"Generic prime lenses\".\n */\n\nimport { InvalidConfigurationError } from \"../core/configuration-error.js\";\nimport { requireInputKeys, requireInputObject } from \"../core/record-validation.js\";\nimport { calculateEquivalentFocalLength35Mm } from \"../camera/equivalent-focal-length.js\";\n\n/** Full-frame-equivalent focal lengths of the generic prime family, mm. */\nexport const GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM = Object.freeze([10, 12, 14, 16, 20, 24, 28, 35, 40, 50, 85, 105, 135, 200, 300, 400, 500, 600, 800, 1200] as const);\nexport type GenericPrimeEquivalentFocalLengthMm = typeof GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM[number];\n/**\n * The marked third-stop f-numbers (the conventional rounded values of N = 2^(k/6), k = 0, 1, …), from f/1 to f/32.\n * A lens's `fNumbers` are those within its range; any f-number inside the range is accepted.\n */\nexport const GENERIC_PRIME_THIRD_STOP_F_NUMBERS = Object.freeze([1, 1.1, 1.2, 1.4, 1.6, 1.8, 2, 2.2, 2.5, 2.8, 3.2, 3.5, 4, 4.5, 5, 5.6, 6.3, 7.1, 8, 9, 10, 11,\n 13, 14, 16, 18, 20, 22, 25, 29, 32] as const);\n/** Minimum focus rule: the object distance at this magnification, but at least `minimumDistanceM`. */\nexport const GENERIC_PRIME_MINIMUM_FOCUS = Object.freeze({ magnification: 0.15, minimumDistanceM: 0.1 });\n\n/** Widest f-number by equivalent focal length (inclusive upper bounds of each class). */\nconst WIDEST: readonly (readonly [number, number])[] = [[16, 2.8], [28, 1.8], [85, 1.4], [135, 2], [300, 2.8], [600, 4], [800, 5.6], [1200, 8]];\n/** Narrowest f-number by equivalent focal length. */\nconst NARROWEST: readonly (readonly [number, number])[] = [[16, 16], [135, 22], [1200, 32]];\n\nexport interface GenericPrimeLens {\n /** Public opaque id, for example \"generic-prime-50mm-equivalent\". */\n lensId: string;\n equivalentFocalLengthMm: GenericPrimeEquivalentFocalLengthMm;\n /** Physical focal length for this sensor: equivalent ÷ crop factor. */\n focalLengthMm: number;\n /** Diagonal crop factor of the sensor (36 × 24 mm = 1). */\n cropFactor35Mm: number;\n /** Widest aperture (smallest f-number) and narrowest aperture. */\n widestFNumber: number;\n narrowestFNumber: number;\n /** The marked third-stop f-numbers within the range. */\n fNumbers: readonly number[];\n /** max(0.10 m, f·(1 + 1/0.15)), metres from the lens (thin lens). */\n minimumFocusDistanceM: number;\n /** Magnification at the minimum focus distance, f/(d − f). */\n maximumMagnification: number;\n scientificStatus: \"approximation\";\n limitations: readonly string[];\n}\n\n/** Minimum focus distance of a generic prime of physical focal length `focalLengthMm`: max(0.10 m, f·(1 + 1/0.15)). */\nexport function calculateGenericPrimeMinimumFocusDistanceM(focalLengthMm: number): number {\n if (typeof focalLengthMm !== \"number\" || !Number.isFinite(focalLengthMm) || focalLengthMm <= 0) throw new InvalidConfigurationError(\"focalLengthMm must be a positive finite number.\");\n return Math.max(GENERIC_PRIME_MINIMUM_FOCUS.minimumDistanceM, focalLengthMm / 1000 * (1 + 1 / GENERIC_PRIME_MINIMUM_FOCUS.magnification));\n}\n\n/**\n * Resolves a generic prime for a sensor: its actual focal length, f-number range, marked f-numbers and minimum focus.\n * `activeImagingArea` is the sensor's active capture area in millimetres.\n */\nexport function resolveGenericPrimeLens(input: { equivalentFocalLengthMm: number; activeImagingArea: { widthMm: number; heightMm: number } }): GenericPrimeLens {\n requireInputObject(input, \"resolveGenericPrimeLens input\");\n requireInputKeys(input, \"resolveGenericPrimeLens\", [\"equivalentFocalLengthMm\", \"activeImagingArea\"]);\n const equivalent = input.equivalentFocalLengthMm;\n if (!(GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM as readonly number[]).includes(equivalent))\n throw new InvalidConfigurationError(\"equivalentFocalLengthMm must be one of the generic primes: \" + GENERIC_PRIME_EQUIVALENT_FOCAL_LENGTHS_MM.join(\", \") + \" mm.\");\n requireInputObject(input.activeImagingArea, \"activeImagingArea\");\n const crop = calculateEquivalentFocalLength35Mm({ focalLengthMm: 1, activeImagingArea: { widthMm: input.activeImagingArea.widthMm, heightMm: input.activeImagingArea.heightMm } }).value.cropFactor35Mm;\n const focalLengthMm = equivalent / crop;\n const widest = WIDEST.find(([bound]) => equivalent <= bound)![1], narrowest = NARROWEST.find(([bound]) => equivalent <= bound)![1];\n const minimumFocusDistanceM = calculateGenericPrimeMinimumFocusDistanceM(focalLengthMm), f = focalLengthMm / 1000;\n return Object.freeze({ lensId: \"generic-prime-\" + equivalent + \"mm-equivalent\", equivalentFocalLengthMm: equivalent as GenericPrimeEquivalentFocalLengthMm, focalLengthMm,\n cropFactor35Mm: crop, widestFNumber: widest, narrowestFNumber: narrowest,\n fNumbers: Object.freeze(GENERIC_PRIME_THIRD_STOP_F_NUMBERS.filter((n) => n >= widest && n <= narrowest)), minimumFocusDistanceM,\n maximumMagnification: f / (minimumFocusDistanceM - f), scientificStatus: \"approximation\" as const,\n limitations: Object.freeze([\"Generic educational prime defined by focal length, f-number range and a thin-lens minimum-focus rule; not a real product.\",\n \"Minimum focus max(0.10 m, f·(1 + 1/0.15)) is a thin-lens approximation measured from the lens; real lenses differ (internal focusing, pupil positions, focus breathing).\"]) });\n}\n"]}
|