feat: core imaging tuning refactor

This commit is contained in:
zhoubinjia committed 2026-09-15 16:56:19 +08:00
1 parent 4b4567d37a
commit 9c02146f90
47 files changed
+1209 -459

No files matched your search

@@ -0,0 +1,27 @@
/* AGC 9.6.19 V7 noise model 26: GC02M1 - LMIPRO.
* Extracted from libagc.so, SHA-256:
* b41bf1ab8c775e6afca35aab159935e83be01dff6bffd246d77d7920e5094262
* A/B/C/D at ELF VA 0x3b76e0/0x3b7700/0x3b7720/0x3b7740.
* Max analog ISO: 600 (ELF VA 0x3b6568).
* Standard GCam .c profile: planes R, Gr, Gb, B; input is the actual ISO.
* No AGC recipe ISO remapping or denoise-strength multipliers are included.
*/
double compute_noise_model_entry_S(int plane, int sens) {
static double noise_model_A[] = { 0.0000072370178460895120, 0.0000065231882496758227, 0.0000068691380416554428, 0.0000079136191584250803 };
static double noise_model_B[] = { -0.00011073147252834658, -0.000048916872447121773, -0.000075754391181991293, -0.00012886838607408598 };
double A = noise_model_A[plane];
double B = noise_model_B[plane];
double s = A * sens + B;
return s < 0.0 ? 0.0 : s;
}
double compute_noise_model_entry_O(int plane, int sens) {
static double noise_model_C[] = { 4.3911268460890447e-11, 6.5100383410561773e-11, 8.2524555196144753e-11, 4.9758523419218131e-11 };
static double noise_model_D[] = { 0.0000025261928220997869, 0.0000022153976695516784, 0.0000027291459915261260, 0.0000026378960491808950 };
double digital_gain = (sens / 600.0) < 1.0 ? 1.0 : (sens / 600.0);
double C = noise_model_C[plane];
double D = noise_model_D[plane];
double o = C * sens * sens + D * digital_gain * digital_gain;
return o < 0.0 ? 0.0 : o;
}
@@ -0,0 +1,40 @@
/* Generated test code to dump a table of data for external validation
* of the noise model parameters.
*/
#include <stdio.h>
#include <assert.h>
double compute_noise_model_entry_S(int plane, int sens);
double compute_noise_model_entry_O(int plane, int sens);
int main(void) {
for (int plane = 0; plane < 4; plane++) {
for (int sens = 50; sens <= 1600; sens += 100) {
double o = compute_noise_model_entry_O(plane, sens);
double s = compute_noise_model_entry_S(plane, sens);
printf("%d,%d,%lf,%lf\n", plane, sens, o, s);
}
}
return 0;
}
/* Generated functions to map a given sensitivity to the O and S noise
* model parameters in the DNG noise model. The planes are in
* R, Gr, Gb, B order.
*/
double compute_noise_model_entry_S(int plane, int sens) {
static double noise_model_A[] = { 3.729645920998918e-06,3.782009250290596e-06,3.8085745800818437e-06,3.7262479743019606e-06 };
static double noise_model_B[] = { 8.157411477824238e-06,9.084036440208794e-06,5.882073902516482e-06,9.997743561697092e-06 };
double A = noise_model_A[plane];
double B = noise_model_B[plane];
double s = A * sens + B;
return s < 0.0 ? 0.0 : s;
}
double compute_noise_model_entry_O(int plane, int sens) {
static double noise_model_C[] = { 1.3156833672393117e-10,1.332407774827434e-10,1.3146960863459476e-10,1.3063345467612423e-10 };
static double noise_model_D[] = { 1.2092197219330786e-06,1.1097618286944459e-06,1.1687899062887236e-06,1.1822263493014864e-06 };
double digital_gain = (sens / 800.0) < 1.0 ? 1.0 : (sens / 800.0);
double C = noise_model_C[plane];
double D = noise_model_D[plane];
double o = C * sens * sens + D * digital_gain * digital_gain;
return o < 0.0 ? 0.0 : o;
}
@@ -0,0 +1,40 @@
/* Generated test code to dump a table of data for external validation
* of the noise model parameters.
*/
#include <stdio.h>
#include <assert.h>
double compute_noise_model_entry_S(int plane, int sens);
double compute_noise_model_entry_O(int plane, int sens);
int main(void) {
for (int plane = 0; plane < 4; plane++) {
for (int sens = 50; sens <= 800; sens += 100) {
double o = compute_noise_model_entry_O(plane, sens);
double s = compute_noise_model_entry_S(plane, sens);
printf("%d,%d,%lf,%lf\n", plane, sens, o, s);
}
}
return 0;
}
/* Generated functions to map a given sensitivity to the O and S noise
* model parameters in the DNG noise model. The planes are in
* R, Gr, Gb, B order.
*/
double compute_noise_model_entry_S(int plane, int sens) {
static double noise_model_A[] = { 2.691353781189422e-06,2.6817014313123966e-06,2.682315890739256e-06,2.695296790679005e-06 };
static double noise_model_B[] = { 5.607265966668617e-06,1.0263138748900872e-05,1.0650013817119217e-05,7.6267061661234736e-06 };
double A = noise_model_A[plane];
double B = noise_model_B[plane];
double s = A * sens + B;
return s < 0.0 ? 0.0 : s;
}
double compute_noise_model_entry_O(int plane, int sens) {
static double noise_model_C[] = { 2.9917133034145296e-11,6.086258466440452e-11,6.308190715155536e-11,3.0739030068625654e-11 };
static double noise_model_D[] = { 3.275624181535426e-07,6.624913143068297e-07,6.662466882279819e-07,3.1510627507887423e-07 };
double digital_gain = (sens / 800.0) < 1.0 ? 1.0 : (sens / 800.0);
double C = noise_model_C[plane];
double D = noise_model_D[plane];
double o = C * sens * sens + D * digital_gain * digital_gain;
return o < 0.0 ? 0.0 : o;
}
@@ -5276,9 +5276,17 @@ class Camera2Controller(private val context: Context) {
return _state.value.currentCameraId
}
/**
* 获取传感器方向(供外部 YUV 处理使用)
*/
/** Physical sensor area for the selected output lens, in square millimeters. */
fun getCurrentSensorPhysicalAreaMm2(): Float? {
val characteristics = resolveActiveFocusCharacteristics()?.second
?: getActiveOpenCameraCharacteristics()
?: return null
val size = characteristics.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE)
?: return null
return (size.width * size.height).takeIf { it.isFinite() && it > 0f }
}
/** 获取传感器方向(供外部 YUV 处理使用) */
fun getSensorOrientation(): Int {
return cachedSensorOrientation
}
@@ -61,6 +61,7 @@ import com.hinnka.mycamera.model.CameraPreset
import com.hinnka.mycamera.model.LutSelectorMode
import com.hinnka.mycamera.mgc.PhotonLookContract
import com.hinnka.mycamera.processor.DenoiseStrength
import com.hinnka.mycamera.processor.PhotonSensorSizeTuning
import com.hinnka.mycamera.processor.MgcRawMaxMode
import org.json.JSONObject
@@ -187,6 +188,8 @@ data class UserPreferences(
val useMultipleExposure: Boolean = false, // 是否启用多重曝光
val multipleExposureCount: Int = 2, // 多重曝光张数
val useRawMax: Boolean = false, // HDR+:RAW 多帧融合
val rawMaxQualityTuningEnabled: Boolean =
PhotonSensorSizeTuning.DEFAULT_RAW_MAX_QUALITY_TUNING_ENABLED,
val hdrPlusMergeMode: MgcRawMaxMode = MgcRawMaxMode.DEFAULT,
val hdrPlusFrameCount: Int = MultiFrameConfig.DEFAULT_HDR_PLUS_FRAME_COUNT,
val hdrPlusBracketExposureEnabled: Boolean =
@@ -434,6 +437,7 @@ class UserPreferencesRepository(private val context: Context) {
// 多帧合成 Key
private val USE_JPG_MAX = booleanPreferencesKey("use_jpg_max")
private val RAW_MAX_QUALITY_TUNING_ENABLED = booleanPreferencesKey("raw_max_quality_tuning_enabled")
private val USE_RAW_MAX = booleanPreferencesKey("use_raw_max")
private val LEGACY_USE_MULTI_FRAME = booleanPreferencesKey("use_multi_frame")
private val LEGACY_USE_HDR_COMPOSITION = booleanPreferencesKey("use_hdr_composition")
@@ -739,6 +743,8 @@ class UserPreferencesRepository(private val context: Context) {
?: MultiFrameConfig.DEFAULT_SUPER_RESOLUTION_SCALE,
useMultipleExposure = preferences[USE_MULTIPLE_EXPOSURE] ?: false,
multipleExposureCount = preferences[MULTIPLE_EXPOSURE_COUNT] ?: 2,
rawMaxQualityTuningEnabled = preferences[RAW_MAX_QUALITY_TUNING_ENABLED]
?: PhotonSensorSizeTuning.DEFAULT_RAW_MAX_QUALITY_TUNING_ENABLED,
useRawMax = useRawMax,
hdrPlusMergeMode = hdrPlusMergeMode,
hdrPlusFrameCount = preferences[HDR_PLUS_FRAME_COUNT]
@@ -1740,6 +1746,12 @@ class UserPreferencesRepository(private val context: Context) {
}
}
suspend fun saveRawMaxQualityTuningEnabled(enabled: Boolean) {
context.dataStore.edit { preferences ->
preferences[RAW_MAX_QUALITY_TUNING_ENABLED] = enabled
}
}
suspend fun saveRawMaxNoiseReduction(value: Float) {
context.dataStore.edit { preferences ->
preferences[RAW_MAX_NOISE_REDUCTION_KEY] = DenoiseStrength.clamp(value)
@@ -38,8 +38,8 @@ import com.hinnka.mycamera.model.SafeImage
import com.hinnka.mycamera.processor.BokehStyle
import com.hinnka.mycamera.processor.GpuBayerSource
import com.hinnka.mycamera.processor.GpuLinearRgbSource
import com.hinnka.mycamera.processor.PhotonSensorSizeTuning
import com.hinnka.mycamera.processor.GpuLinearRgbStorage
import com.hinnka.mycamera.processor.PhotonCoreImagingTuning
import com.hinnka.mycamera.processor.MgcSpatialOutputMode
import com.hinnka.mycamera.processor.MgcMergeMethod
import com.hinnka.mycamera.processor.MultiFrameStacker
@@ -2243,9 +2243,8 @@ object GalleryManager {
captureExposureCompensationEv = captureExposureCompensationEv,
).let(physicalRawCrop::rebase).copy(
exposureCompensation = captureExposureCompensationEv,
coreImagingTuning = PhotonCoreImagingTuning.fromCustomProperties(
metadata.customProperties,
),
rawMaxQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(metadata.customProperties),
)
val rawBuffer = image.use {
RawProcessor.copyRawSensorImageToContiguousBuffer(
@@ -2374,7 +2373,8 @@ object GalleryManager {
rawWhiteLevelMode = updatedMetadata.rawWhiteLevelMode,
rawCustomWhiteLevel = updatedMetadata.rawCustomWhiteLevel,
sharpeningValue = rawSharpening,
processLocalCoreImagingTuning = sourceRawMetadata.coreImagingTuning,
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(updatedMetadata.customProperties),
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = updatedMetadata.rawDcpId,
@@ -2463,6 +2463,8 @@ object GalleryManager {
rawWhiteLevelMode = updatedMetadata.rawWhiteLevelMode,
rawCustomWhiteLevel = updatedMetadata.rawCustomWhiteLevel,
sharpeningValue = rawSharpening,
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(updatedMetadata.customProperties),
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = updatedMetadata.rawDcpId,
@@ -3255,6 +3257,8 @@ object GalleryManager {
colorSpace = RawDemosaicProcessor.getInstance().getRawColorSpace(),
).let(physicalRawCrop::rebase).copy(
exposureCompensation = captureExposureCompensationEv,
rawMaxQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(metadata.customProperties),
)
val noiseProfileSelection = ContentRepository.getInstance(context)
.rawNoiseProfileManager
@@ -3394,9 +3398,6 @@ object GalleryManager {
gpuLinearRgbStorage = GpuLinearRgbStorage.RGBA16F,
enableHdrFusion = rawMaxHdrFusionEnabled,
mergeMethod = rawMaxMergeMethod,
coreImagingTuning = PhotonCoreImagingTuning.fromCustomProperties(
metadata.customProperties,
),
)
}
@@ -3443,7 +3444,6 @@ object GalleryManager {
mgcDenoiseTuningSnr = finalStackResult.mgcDenoiseTuningSnr,
mgcSharpenAttenuationScale =
finalStackResult.mgcSharpenAttenuationScale,
coreImagingTuning = finalStackResult.coreImagingTuning,
)
val configuredRawMaxLumaStrength = RawDenoiseDefaults.normalize(
metadata.rawDenoiseValue ?: RawDenoiseDefaults.RAW_MAX_LUMA_STRENGTH
@@ -3706,10 +3706,10 @@ object GalleryManager {
rawWhiteLevelMode = updatedMetadata.rawWhiteLevelMode,
rawCustomWhiteLevel = updatedMetadata.rawCustomWhiteLevel,
sharpeningValue = rawSharpening,
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(updatedMetadata.customProperties),
processLocalMgcSharpenAttenuationScale =
finalStackResult.mgcSharpenAttenuationScale,
processLocalCoreImagingTuning =
finalStackResult.coreImagingTuning,
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = updatedMetadata.rawDcpId,
@@ -3796,6 +3796,8 @@ object GalleryManager {
rawWhiteLevelMode = updatedMetadata.rawWhiteLevelMode,
rawCustomWhiteLevel = updatedMetadata.rawCustomWhiteLevel,
sharpeningValue = rawSharpening,
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(updatedMetadata.customProperties),
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = updatedMetadata.rawDcpId,
@@ -4075,8 +4077,8 @@ object GalleryManager {
rawWhiteLevelMode = updatedMetadata.rawWhiteLevelMode,
rawCustomWhiteLevel = updatedMetadata.rawCustomWhiteLevel,
sharpeningValue = rawSharpening,
processLocalCoreImagingTuning =
PhotonCoreImagingTuning.fromCustomProperties(updatedMetadata.customProperties),
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(updatedMetadata.customProperties),
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = updatedMetadata.rawDcpId,
@@ -5507,10 +5509,8 @@ object GalleryManager {
rawWhiteLevelMode = updatedMetadata.rawWhiteLevelMode,
rawCustomWhiteLevel = updatedMetadata.rawCustomWhiteLevel,
sharpeningValue = RawSharpeningDefaults.DEFAULT_STRENGTH,
processLocalCoreImagingTuning =
PhotonCoreImagingTuning.fromCustomProperties(
updatedMetadata.customProperties,
),
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(updatedMetadata.customProperties),
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = updatedMetadata.rawDcpId,
@@ -5683,10 +5683,8 @@ object GalleryManager {
rawCustomWhiteLevel = updatedMetadata?.rawCustomWhiteLevel,
sharpeningValue = updatedMetadata?.sharpening
?: RawSharpeningDefaults.DEFAULT_STRENGTH,
processLocalCoreImagingTuning =
PhotonCoreImagingTuning.fromCustomProperties(
updatedMetadata?.customProperties.orEmpty(),
),
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(updatedMetadata?.customProperties.orEmpty()),
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = updatedMetadata?.rawDcpId,
@@ -23,9 +23,9 @@ import com.hinnka.mycamera.hdr.SourceKind
import com.hinnka.mycamera.lut.ColorCorrectionPipelineResolver
import com.hinnka.mycamera.lut.LutImageProcessor
import com.hinnka.mycamera.lut.LutManager
import com.hinnka.mycamera.processor.PhotonSensorSizeTuning
import com.hinnka.mycamera.processor.DepthBokehProcessor
import com.hinnka.mycamera.processor.BokehStyle
import com.hinnka.mycamera.processor.PhotonCoreImagingTuning
import com.hinnka.mycamera.raw.RawDemosaicProcessor
import com.hinnka.mycamera.raw.RawHdrRenderResult
import com.hinnka.mycamera.raw.RawMetadata
@@ -587,8 +587,8 @@ class PhotoProcessor(
rawWhiteLevelMode = metadata.rawWhiteLevelMode,
rawCustomWhiteLevel = metadata.rawCustomWhiteLevel,
sharpeningValue = rawSharpening,
processLocalCoreImagingTuning =
PhotonCoreImagingTuning.fromCustomProperties(metadata.customProperties),
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(metadata.customProperties),
denoiseValue = rawNoiseReduction,
chromaDenoiseValue = rawChromaNoiseReduction,
rawDcpId = metadata.rawDcpId,
@@ -669,8 +669,8 @@ class PhotoProcessor(
rawWhiteLevelMode = metadata.rawWhiteLevelMode,
rawCustomWhiteLevel = metadata.rawCustomWhiteLevel,
sharpeningValue = finalSharpening,
processLocalCoreImagingTuning =
PhotonCoreImagingTuning.fromCustomProperties(metadata.customProperties),
processLocalQualityTuningSensorAreaMm2 =
PhotonSensorSizeTuning.areaFromProperties(metadata.customProperties),
denoiseValue = finalNoiseReduction,
chromaDenoiseValue = finalChromaNoiseReduction,
rawDcpId = metadata.rawDcpId,
@@ -9,7 +9,7 @@ import kotlin.math.sqrt
/**
* Standard GCam sensor noise calibration.
*
* The four planes and coefficient arrays are canonical R, Gr, Gb, B. Evaluation follows the
* External `.c` and native gain tables use canonical R, Gr, Gb, B. Evaluation follows the
* generated GCam `.c` files exactly:
*
* S = A * sensitivity + B
@@ -72,6 +72,7 @@ data class CalibratedRawNoiseProfile(
}
}
/** Evaluate the selected calibration using capture ISO and the required camera gain limits. */
fun evaluate(
sensitivity: Int,
minimumSensitivityIso: Int = 0,
@@ -32,7 +32,6 @@ internal class GlesMgcRawFusion(
private val useCurrentGlContext: Boolean,
private val exportGpuLinearRgbSource: Boolean,
private val gpuLinearRgbStorage: GpuLinearRgbStorage,
private val coreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
) {
private val width = sourceBounds.width()
private val height = sourceBounds.height()
@@ -126,7 +125,6 @@ internal class GlesMgcRawFusion(
useCurrentGlContext = useCurrentGlContext,
exportGpuLinearRgbSource = exportGpuLinearRgbSource,
gpuLinearRgbStorage = gpuLinearRgbStorage,
coreImagingTuning = coreImagingTuning,
).processFrames(referenceFirstFrames)?.copy(
fastMomentsRawStats = fastMomentsRawStats,
)
@@ -220,7 +218,6 @@ internal class GlesMgcRawFusion(
useCurrentGlContext = useCurrentGlContext,
exportGpuLinearRgbSource = exportGpuLinearRgbSource,
gpuLinearRgbStorage = gpuLinearRgbStorage,
coreImagingTuning = coreImagingTuning,
computeFastMomentsRawStats = canReuseSpatialReferenceUpload,
).processFrames(scheduledFrames).let { result ->
fastMomentsRawStats?.let { stats ->
@@ -26,7 +26,6 @@ internal class GlesMgcRawSabreProcessor(
private val useCurrentGlContext: Boolean,
private val exportGpuLinearRgbSource: Boolean,
private val gpuLinearRgbStorage: GpuLinearRgbStorage,
private val coreImagingTuning: PhotonCoreImagingTuning,
) {
fun processFrames(frames: List<RawStackFrame>): RawStackResult? {
if (frames.isEmpty()) return null
@@ -77,7 +76,6 @@ internal class GlesMgcRawSabreProcessor(
exportGpuLinearRgbSource = exportGpuLinearRgbSource,
gpuLinearRgbStorage = gpuLinearRgbStorage,
processorPipeline = MgcRawProcessorPipeline.SABRE,
coreImagingTuning = coreImagingTuning,
).processFrames(admitted)
}
@@ -74,7 +74,6 @@ internal class GlesMgcRawSpatialStacker(
private val exportGpuLinearRgbSource: Boolean,
private val gpuLinearRgbStorage: GpuLinearRgbStorage = GpuLinearRgbStorage.RGBA16UI,
private val processorPipeline: MgcRawProcessorPipeline = MgcRawProcessorPipeline.SPATIAL,
private val coreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
private val computeFastMomentsRawStats: Boolean = false,
) {
private data class TextureLevel(
@@ -2016,7 +2015,6 @@ internal class GlesMgcRawSpatialStacker(
),
mgcDenoiseTuningSnr = finishRawDenoiseSnr,
mgcSharpenAttenuationScale = finishRawSharpenAttenuationScale,
coreImagingTuning = coreImagingTuning,
mgcSpatialReferenceOnlyDiagnostic = referenceOnly,
fastMomentsRawStats = fastMomentsRawStats,
)
@@ -2180,7 +2178,7 @@ internal class GlesMgcRawSpatialStacker(
val sabreKernelParameters = MgcSabreKernelTuning.build(
referenceSnr = kernelTuning.referenceSnr,
frameCount = frames.size,
mergeGradientThreshold = coreImagingTuning.fusion.mergeGradientThreshold,
mergeGradientThreshold = PhotonCoreImagingTuning.fusion.mergeGradientThreshold,
)
val sabreResolveParameters = MgcSabreResolveTuning.build(
referenceSnr = kernelTuning.referenceSnr,
@@ -2212,7 +2210,7 @@ internal class GlesMgcRawSpatialStacker(
"${sabreKernelParameters.anisotropyScale}," +
"${sabreKernelParameters.coherenceScale} " +
"forceReferenceColorRgb=${sabreKernelParameters.forceReferenceColorRgb} " +
"mergeGradientThreshold=${coreImagingTuning.fusion.mergeGradientThreshold ?: "adaptive"} " +
"mergeGradientThreshold=${PhotonCoreImagingTuning.fusion.mergeGradientThreshold ?: "adaptive"} " +
"guideColorSpace=sqrt noiseLut=qmc64x10 rejectionGuideFilter=bicubic-both-frames " +
"alignmentInputGain=${referenceCalibration.alignmentGain} " +
"alignmentDomain=signed-s16",
@@ -2372,13 +2370,15 @@ internal class GlesMgcRawSpatialStacker(
val mergedNoiseModel = MgcSabreMergedNoiseModel.merge(
noiseFrames,
kernelTuning.referenceSnr,
PhotonCoreImagingTuning.denoise.noiseSpectrumSeed,
)
PLog.i(
SABRE_TAG,
"MGC Sabre merged NoiseModel diagnosticAverageMergeFactor=$sabreAverageMergeFactor " +
"snrCorrection=${MgcSabreMergedNoiseModel.snrCorrection(kernelTuning.referenceSnr)} " +
"read=${mergedNoiseModel.read.contentToString()} " +
"shot=${mergedNoiseModel.shot.contentToString()}",
"shot=${mergedNoiseModel.shot.contentToString()} " +
"spectrumSeed=${mergedNoiseModel.correlation[0]}",
)
renderSabreDehomogenize(
@@ -2635,7 +2635,6 @@ internal class GlesMgcRawSpatialStacker(
mgcDenoiseCorrelation = mergedNoiseModel.correlation,
mgcDenoiseTuningSnr = finishRawDenoiseSnr,
mgcSharpenAttenuationScale = sabreResolveParameters.demosaicSharpness,
coreImagingTuning = coreImagingTuning,
)
returned = true
result
@@ -3752,7 +3751,7 @@ internal class GlesMgcRawSpatialStacker(
val referenceSignal = if (processorPipeline == MgcRawProcessorPipeline.SABRE) {
resolveFusionReferenceSignal(
measuredSignal = measuredReferenceSignal,
fallbackSignal = coreImagingTuning.fusion.missingReferenceSignal,
fallbackSignal = PhotonCoreImagingTuning.fusion.missingReferenceSignal,
)
} else {
measuredReferenceSignal ?: 0f
@@ -7,8 +7,9 @@ internal object MgcSabreMergedNoiseModel {
data class Output(val read: FloatArray, val shot: FloatArray, val correlation: FloatArray)
fun merge(frames: List<Frame>, referenceSnr: Float): Output {
fun merge(frames: List<Frame>, referenceSnr: Float, noiseSpectrumSeed: Float): Output {
require(frames.isNotEmpty())
require(noiseSpectrumSeed.isFinite() && noiseSpectrumSeed >= 0f)
val readSum = DoubleArray(3)
val shotSum = DoubleArray(3)
var weightSum = 0.0
@@ -34,9 +35,9 @@ internal object MgcSabreMergedNoiseModel {
val correction = 1f / samples
val read = FloatArray(3) { readSum[it].toFloat() * correction }
val shot = FloatArray(3) { (shotSum[it] / weightSum).toFloat() * correction }
// Physical RAW inputs have unit spectra and no quadratic term. Weighted composition
// preserves that spectrum; neither RBF weight statistics nor frame count scales it.
return Output(read, shot, FloatArray(128) { 1f })
// This model has no measured input spectrum. AGC's lib_luma_noise_key sets the
// constructor seed; neither RBF weight statistics nor frame count scales it.
return Output(read, shot, FloatArray(128) { noiseSpectrumSeed })
}
/** Average(1 / d) scales every coefficient by d; it preserves the correlation spectrum. */
@@ -142,8 +142,6 @@ data class RawStackResult(
val mgcDenoiseTuningSnr: Float? = null,
/** MGC-derived attenuation applied to Photon's final GLES sharpen strength. */
val mgcSharpenAttenuationScale: Float? = null,
/** Capture-scoped Photon controls for the core imaging chain. */
val coreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
/**
* True only for the debug reference-only isolation path. This state is process-local and is
* never persisted into RAW/DNG metadata.
@@ -307,7 +305,6 @@ object MultiFrameStacker {
exportGpuLinearRgbSource: Boolean = false,
gpuLinearRgbStorage: GpuLinearRgbStorage = GpuLinearRgbStorage.RGBA16UI,
enableHdrFusion: Boolean = true,
coreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
): RawStackResult? {
if (frames.isEmpty()) return null
val images = frames.map { it.image }
@@ -358,7 +355,6 @@ object MultiFrameStacker {
useCurrentGlContext = useCurrentGlContext,
exportGpuLinearRgbSource = exportGpuLinearRgbSource,
gpuLinearRgbStorage = gpuLinearRgbStorage,
coreImagingTuning = coreImagingTuning.normalized(),
).processFrames(frames)
}
@@ -1,154 +1,20 @@
package com.hinnka.mycamera.processor
/**
* Photon-owned controls for the core RAW imaging chain.
*
* The model is intentionally organized by processing domain. New captures use [DEFAULT]; decoding
* custom properties remains available so RAW files created by older versions can be reprocessed
* with their original parameters. Runtime processors consume these domain fields directly rather
* than importing a third-party patch vocabulary.
*/
data class PhotonCoreImagingTuning(
val fusion: PhotonFusionTuning = PhotonFusionTuning.DEFAULT,
val denoise: PhotonDenoiseTuning = PhotonDenoiseTuning.DEFAULT,
/** Controls Dehaze + DHA baked into HDRNet's ProfileGainTableMap output. */
val dehaze: PhotonDehazeTuning = PhotonDehazeTuning.DEFAULT,
) {
fun normalized(): PhotonCoreImagingTuning = copy(
fusion = fusion.normalized(),
denoise = denoise.normalized(),
dehaze = dehaze.normalized(),
)
fun toCustomProperties(): Map<String, String> {
val tuning = normalized()
return buildMap {
tuning.fusion.mergeGradientThreshold?.let {
put(FUSION_GRADIENT_THRESHOLD_PROPERTY, it.toString())
}
put(FUSION_FALLBACK_SIGNAL_PROPERTY, tuning.fusion.missingReferenceSignal.toString())
put(FUSION_CORRELATION_SCALE_PROPERTY, tuning.fusion.noiseCorrelationScale.toString())
put(DENOISE_LUMA_SCALE_PROPERTY, tuning.denoise.lumaStrengthScale.toPersistedString())
put(
DENOISE_REVERT_SCALE_PROPERTY,
tuning.denoise.detailReconstructionScale.toPersistedString(),
)
put(
DENOISE_OUTLIER_SCALE_PROPERTY,
tuning.denoise.outlierRejectionScale.toPersistedString(),
)
put(
DENOISE_CHROMA_SCALE_PROPERTY,
tuning.denoise.chromaStrengthScale.toPersistedString(),
)
put(
DENOISE_RESPONSE_OFFSET_PROPERTY,
tuning.denoise.frequencyResponse.responseOffset.toString(),
)
put(
DENOISE_RESPONSE_COSINE_OFFSET_PROPERTY,
tuning.denoise.frequencyResponse.cosineOffset.toString(),
)
tuning.denoise.sabreLumaNodes.toPersistedString()?.let {
put(DENOISE_SABRE_NODES_PROPERTY, it)
}
put(DEHAZE_ENABLED_PROPERTY, tuning.dehaze.enabled.toString())
put(DEHAZE_STRENGTH_PROPERTY, tuning.dehaze.strength.toString())
put(
DEHAZE_DYNAMIC_HIGHLIGHT_STRENGTH_PROPERTY,
tuning.dehaze.dynamicHighlightStrength.toString(),
)
}
}
fun toPersistedString(): String = toCustomProperties()
.entries
.sortedBy(Map.Entry<String, String>::key)
.joinToString("\n") { (key, value) -> "$key=$value" }
companion object {
const val FUSION_GRADIENT_THRESHOLD_PROPERTY = "photonFusionGradientThreshold"
const val FUSION_FALLBACK_SIGNAL_PROPERTY = "photonFusionMissingReferenceSignal"
const val FUSION_CORRELATION_SCALE_PROPERTY = "photonFusionNoiseCorrelationScale"
const val DENOISE_LUMA_SCALE_PROPERTY = "photonDenoiseLumaStrengthScale"
const val DENOISE_REVERT_SCALE_PROPERTY = "photonDenoiseDetailReconstructionScale"
const val DENOISE_OUTLIER_SCALE_PROPERTY = "photonDenoiseOutlierRejectionScale"
const val DENOISE_CHROMA_SCALE_PROPERTY = "photonDenoiseChromaStrengthScale"
const val DENOISE_RESPONSE_OFFSET_PROPERTY = "photonDenoiseResponseOffset"
const val DENOISE_RESPONSE_COSINE_OFFSET_PROPERTY = "photonDenoiseResponseCosineOffset"
const val DENOISE_SABRE_NODES_PROPERTY = "photonDenoiseSabreLumaNodes"
const val DEHAZE_ENABLED_PROPERTY = "photonDehazeEnabled"
const val DEHAZE_STRENGTH_PROPERTY = "photonDehazeStrength"
const val DEHAZE_DYNAMIC_HIGHLIGHT_STRENGTH_PROPERTY =
"photonDehazeDynamicHighlightStrength"
val DEFAULT = PhotonCoreImagingTuning()
fun fromPersistedString(value: String?): PhotonCoreImagingTuning {
if (value.isNullOrBlank()) return DEFAULT
val properties = value.lineSequence().mapNotNull { line ->
val separator = line.indexOf('=')
if (separator <= 0) null else line.substring(0, separator) to
line.substring(separator + 1)
}.toMap()
return fromCustomProperties(properties)
}
fun fromCustomProperties(properties: Map<String, String>): PhotonCoreImagingTuning {
val hasPhotonProperties = properties.keys.any { it.startsWith("photon") }
if (!hasPhotonProperties) return DEFAULT
return PhotonCoreImagingTuning(
fusion = PhotonFusionTuning(
mergeGradientThreshold = properties[FUSION_GRADIENT_THRESHOLD_PROPERTY]
?.toFloatOrNull(),
missingReferenceSignal = properties[FUSION_FALLBACK_SIGNAL_PROPERTY]
?.toFloatOrNull() ?: PhotonFusionTuning.DEFAULT_MISSING_REFERENCE_SIGNAL,
noiseCorrelationScale = properties[FUSION_CORRELATION_SCALE_PROPERTY]
?.toFloatOrNull() ?: 1f,
),
denoise = PhotonDenoiseTuning(
lumaStrengthScale = PhotonPyramidScales.fromPersistedString(
properties[DENOISE_LUMA_SCALE_PROPERTY],
),
detailReconstructionScale = PhotonPyramidScales.fromPersistedString(
properties[DENOISE_REVERT_SCALE_PROPERTY],
),
outlierRejectionScale = PhotonPyramidScales.fromPersistedString(
properties[DENOISE_OUTLIER_SCALE_PROPERTY],
),
chromaStrengthScale = PhotonPyramidScales.fromPersistedString(
properties[DENOISE_CHROMA_SCALE_PROPERTY],
),
frequencyResponse = PhotonDenoiseFrequencyResponse(
responseOffset = properties[DENOISE_RESPONSE_OFFSET_PROPERTY]
?.toFloatOrNull() ?: 1f,
cosineOffset = properties[DENOISE_RESPONSE_COSINE_OFFSET_PROPERTY]
?.toFloatOrNull() ?: -1f,
),
sabreLumaNodes = PhotonSabreLumaTuningNodes.fromPersistedString(
properties[DENOISE_SABRE_NODES_PROPERTY],
),
),
dehaze = PhotonDehazeTuning(
enabled = properties[DEHAZE_ENABLED_PROPERTY]
?.toBooleanStrictOrNull() ?: PhotonDehazeTuning.DEFAULT.enabled,
strength = properties[DEHAZE_STRENGTH_PROPERTY]
?.toFloatOrNull() ?: PhotonDehazeTuning.DEFAULT.strength,
dynamicHighlightStrength =
properties[DEHAZE_DYNAMIC_HIGHLIGHT_STRENGTH_PROPERTY]
?.toFloatOrNull()
?: PhotonDehazeTuning.DEFAULT.dynamicHighlightStrength,
),
).normalized()
}
}
/** Local defaults for Photon's RAW imaging chain, shared by capture and reprocessing. */
object PhotonCoreImagingTuning {
val fusion: PhotonFusionTuning = PhotonFusionTuning.DEFAULT
val denoise: PhotonDenoiseTuning = PhotonDenoiseTuning.DEFAULT
/** Dehaze + DHA baked into HDRNet's ProfileGainTableMap output. */
val dehaze: PhotonDehazeTuning = PhotonDehazeTuning.DEFAULT
}
/** Controls frame admission and propagated noise behavior in multi-frame fusion. */
data class PhotonFusionTuning(
/** Null keeps the SNR-adaptive merge threshold; a value directly overrides it. */
val mergeGradientThreshold: Float? = null,
/**
* AGC lib_sabre_denoise_control_key: -1 disables weak-texture broadening of the
* Sabre fusion kernel. Null restores the original SNR-adaptive threshold.
*/
val mergeGradientThreshold: Float? = -1f,
/** Normalized green signal used only when reference-frame measurement is unavailable. */
val missingReferenceSignal: Float = DEFAULT_MISSING_REFERENCE_SIGNAL,
/**
@@ -161,7 +27,7 @@ data class PhotonFusionTuning(
fun normalized(): PhotonFusionTuning = copy(
mergeGradientThreshold = mergeGradientThreshold
?.takeIf(Float::isFinite)
?.coerceIn(0f, 32f),
?.coerceIn(-32f, 32f),
missingReferenceSignal = missingReferenceSignal
.takeIf(Float::isFinite)
?.coerceIn(0f, 1f)
@@ -178,7 +44,7 @@ data class PhotonFusionTuning(
}
}
/** Fixed five-level pyramid multiplier with structural equality and stable serialization. */
/** Fixed five-level pyramid multiplier with structural equality. */
data class PhotonPyramidScales(
val level1: Float = 1f,
val level2: Float = 1f,
@@ -192,8 +58,6 @@ data class PhotonPyramidScales(
value.takeIf(Float::isFinite)?.coerceIn(0f, MAX_SCALE) ?: 1f
}
fun toPersistedString(): String = toFloatArray().joinToString(",")
private fun map(transform: (Float) -> Float): PhotonPyramidScales = PhotonPyramidScales(
transform(level1),
transform(level2),
@@ -213,18 +77,6 @@ data class PhotonPyramidScales(
level4 = value,
level5 = value,
).normalized()
fun fromPersistedString(value: String?): PhotonPyramidScales {
val values = value?.split(',')?.map(String::toFloatOrNull) ?: return IDENTITY
if (values.size != 5 || values.any { it == null }) return IDENTITY
return PhotonPyramidScales(
values[0]!!,
values[1]!!,
values[2]!!,
values[3]!!,
values[4]!!,
).normalized()
}
}
}
@@ -238,6 +90,11 @@ data class PhotonDenoiseTuning(
val frequencyResponse: PhotonDenoiseFrequencyResponse = PhotonDenoiseFrequencyResponse.DEFAULT,
/** Optional absolute Sabre luma strength nodes at SNR 5/20/40, before interpolation. */
val sabreLumaNodes: PhotonSabreLumaTuningNodes = PhotonSabreLumaTuningNodes.DEFAULT,
/** Independent absolute protobuf fields, also overridden before SNR interpolation. */
val sabreLumaRevertNodes: PhotonSabreLumaTuningNodes = PhotonSabreLumaTuningNodes.DEFAULT,
val sabreLumaOutlierNodes: PhotonSabreLumaTuningNodes = PhotonSabreLumaTuningNodes.DEFAULT,
/** Initial value of a default 128-bin spectrum; never a multiplier for measured spectra. */
val noiseSpectrumSeed: Float = DEFAULT_SPECTRUM_SEED,
) {
fun normalized(): PhotonDenoiseTuning = copy(
lumaStrengthScale = lumaStrengthScale.normalized(),
@@ -246,29 +103,36 @@ data class PhotonDenoiseTuning(
chromaStrengthScale = chromaStrengthScale.normalized(),
frequencyResponse = frequencyResponse.normalized(),
sabreLumaNodes = sabreLumaNodes.normalized(),
sabreLumaRevertNodes = sabreLumaRevertNodes.normalized(allowNegative = true),
sabreLumaOutlierNodes = sabreLumaOutlierNodes.normalized(allowNegative = true),
noiseSpectrumSeed = noiseSpectrumSeed.takeIf(Float::isFinite)
?.coerceIn(0f, 8f) ?: DEFAULT_SPECTRUM_SEED,
)
companion object {
const val DEFAULT_SPECTRUM_SEED = 1f
val DEFAULT = PhotonDenoiseTuning()
}
}
/** Constants in the denoise pyramid response `(responseOffset-cos²)+(cos+cosineOffset)²`. */
data class PhotonDenoiseFrequencyResponse(
val responseOffset: Float = 1f,
val responseOffset: Float = DEFAULT_RESPONSE_OFFSET,
val cosineOffset: Float = -1f,
) {
fun normalized(): PhotonDenoiseFrequencyResponse = copy(
responseOffset = responseOffset.takeIf(Float::isFinite)?.coerceIn(-32f, 32f) ?: 1f,
responseOffset = responseOffset.takeIf(Float::isFinite)?.coerceIn(-32f, 32f)
?: DEFAULT_RESPONSE_OFFSET,
cosineOffset = cosineOffset.takeIf(Float::isFinite)?.coerceIn(-32f, 32f) ?: -1f,
)
companion object {
const val DEFAULT_RESPONSE_OFFSET = 1f
val DEFAULT = PhotonDenoiseFrequencyResponse()
}
}
/** Optional absolute strength overrides for one five-level Sabre tuning node. */
/** Absolute field overrides. Null preserves the asset; signed revert/outlier values are literal. */
data class PhotonPyramidOverrides(
val level1: Float? = null,
val level2: Float? = null,
@@ -278,42 +142,24 @@ data class PhotonPyramidOverrides(
) {
fun toList(): List<Float?> = listOf(level1, level2, level3, level4, level5)
fun normalized(): PhotonPyramidOverrides {
fun normalized(allowNegative: Boolean = false): PhotonPyramidOverrides {
val values = toList().map { value ->
value?.takeIf(Float::isFinite)?.coerceIn(0f, 32f)
value?.takeIf(Float::isFinite)?.coerceIn(if (allowNegative) -32f else 0f, 32f)
}
return PhotonPyramidOverrides(values[0], values[1], values[2], values[3], values[4])
}
fun toPersistedString(): String = toList().joinToString(",") { it?.toString().orEmpty() }
companion object {
fun fromPersistedString(value: String): PhotonPyramidOverrides? {
val tokens = value.split(',')
if (tokens.size != 5) return null
val parsed = tokens.map { token ->
if (token.isEmpty()) null else token.toFloatOrNull() ?: return null
}
return PhotonPyramidOverrides(
parsed[0],
parsed[1],
parsed[2],
parsed[3],
parsed[4],
).normalized()
}
}
}
/** SNR nodes for one independent luma protobuf field (strength, revert, or outlier). */
data class PhotonSabreLumaTuningNodes(
val snr5: PhotonPyramidOverrides = PhotonPyramidOverrides(),
val snr20: PhotonPyramidOverrides = PhotonPyramidOverrides(),
val snr40: PhotonPyramidOverrides = PhotonPyramidOverrides(),
) {
fun normalized(): PhotonSabreLumaTuningNodes = copy(
snr5 = snr5.normalized(),
snr20 = snr20.normalized(),
snr40 = snr40.normalized(),
fun normalized(allowNegative: Boolean = false): PhotonSabreLumaTuningNodes = copy(
snr5 = snr5.normalized(allowNegative),
snr20 = snr20.normalized(allowNegative),
snr40 = snr40.normalized(allowNegative),
)
fun valuesForSnr(snr: Float): List<Float?>? = when (snr) {
@@ -323,28 +169,11 @@ data class PhotonSabreLumaTuningNodes(
else -> null
}
fun toPersistedString(): String? {
val tuning = normalized()
if (tuning == DEFAULT) return null
return listOf(tuning.snr5, tuning.snr20, tuning.snr40)
.joinToString(";") { it.toPersistedString() }
}
companion object {
const val SNR_5 = 5f
const val SNR_20 = 20f
const val SNR_40 = 40f
val DEFAULT = PhotonSabreLumaTuningNodes()
fun fromPersistedString(value: String?): PhotonSabreLumaTuningNodes {
val rows = value?.split(';') ?: return DEFAULT
if (rows.size != 3) return DEFAULT
return PhotonSabreLumaTuningNodes(
snr5 = PhotonPyramidOverrides.fromPersistedString(rows[0]) ?: return DEFAULT,
snr20 = PhotonPyramidOverrides.fromPersistedString(rows[1]) ?: return DEFAULT,
snr40 = PhotonPyramidOverrides.fromPersistedString(rows[2]) ?: return DEFAULT,
).normalized()
}
}
}
@@ -0,0 +1,128 @@
package com.hinnka.mycamera.processor
import kotlin.math.log2
/**
* Photon core-pipeline defaults resolved from the physical active sensor area.
*
* The calibration uses a log2-area regression because doubling collecting area is the useful
* photographic unit. Only dimensions with a meaningful size relationship are regressed; fields
* dominated by lens-specific tuning use robust constants. Values outside the calibrated mobile
* sensor range are clamped instead of extrapolated.
*/
object PhotonSensorSizeTuning {
const val MODEL_ID = "photon-sensor-area-v1"
const val MODEL_PROPERTY = "photonCoreTuningModel"
const val SENSOR_AREA_PROPERTY = "photonSensorPhysicalAreaMm2"
const val DEFAULT_RAW_MAX_QUALITY_TUNING_ENABLED = false
const val MIN_CALIBRATED_AREA_MM2 = 20.48f
const val MAX_CALIBRATED_AREA_MM2 = 128f
const val REFERENCE_AREA_MM2 = 32f
private val fusionNoiseCorrelationFit = LogAreaFit(
valueAtReferenceArea = 0.767513962f,
changePerAreaStop = -0.164396329f,
)
private val lumaStrengthFit = LogAreaFit(
valueAtReferenceArea = 0.252164225f,
changePerAreaStop = 0.059759506f,
)
private val denoiseResponseOffsetFit = LogAreaFit(
valueAtReferenceArea = 13.499369928f,
changePerAreaStop = -4.878369857f,
)
private val sabreSnr20Level1Fit = LogAreaFit(
valueAtReferenceArea = 0.608876213f,
changePerAreaStop = 0.033127858f,
)
/** Only the capture choice and sensor area are stored, never a core-parameter override. */
fun captureProperties(enabled: Boolean, sensorPhysicalAreaMm2: Float?): Map<String, String> {
val area = sensorPhysicalAreaMm2?.takeIf { it.isFinite() && it > 0f }
return if (enabled && area != null) mapOf(
MODEL_PROPERTY to MODEL_ID,
SENSOR_AREA_PROPERTY to area.toString(),
) else emptyMap()
}
fun areaFromProperties(properties: Map<String, String>): Float? =
if (properties[MODEL_PROPERTY] == MODEL_ID) {
properties[SENSOR_AREA_PROPERTY]?.toFloatOrNull()?.takeIf { it.isFinite() && it > 0f }
} else null
data class Parameters(
val fusion: PhotonFusionTuning = PhotonCoreImagingTuning.fusion,
val denoise: PhotonDenoiseTuning = PhotonCoreImagingTuning.denoise,
)
fun resolve(sensorPhysicalAreaMm2: Float?): Parameters =
sensorPhysicalAreaMm2?.let(::forSensorAreaMm2) ?: Parameters()
fun forPhysicalSizeMm(widthMm: Float, heightMm: Float): Parameters? {
if (!widthMm.isFinite() || !heightMm.isFinite() || widthMm <= 0f || heightMm <= 0f) {
return null
}
return forSensorAreaMm2(widthMm * heightMm)
}
fun forSensorAreaMm2(areaMm2: Float): Parameters? {
if (!areaMm2.isFinite() || areaMm2 <= 0f) return null
val calibratedArea = areaMm2.coerceIn(
MIN_CALIBRATED_AREA_MM2,
MAX_CALIBRATED_AREA_MM2,
)
val areaStops = log2((calibratedArea / REFERENCE_AREA_MM2).toDouble()).toFloat()
val lumaStrength = lumaStrengthFit.evaluate(areaStops)
return Parameters(
fusion = PhotonFusionTuning(
mergeGradientThreshold = PhotonCoreImagingTuning.fusion.mergeGradientThreshold,
missingReferenceSignal = PhotonFusionTuning.DEFAULT_MISSING_REFERENCE_SIGNAL,
noiseCorrelationScale = fusionNoiseCorrelationFit.evaluate(areaStops),
),
denoise = PhotonDenoiseTuning(
lumaStrengthScale = PhotonPyramidScales.uniform(lumaStrength),
detailReconstructionScale = PhotonPyramidScales.uniform(0.3125f),
outlierRejectionScale = PhotonPyramidScales.uniform(0.8125f),
chromaStrengthScale = PhotonPyramidScales.uniform(0.3125f),
frequencyResponse = PhotonDenoiseFrequencyResponse(
responseOffset = denoiseResponseOffsetFit.evaluate(areaStops),
cosineOffset = -1f,
),
sabreLumaNodes = PhotonSabreLumaTuningNodes(
snr5 = PhotonPyramidOverrides(
level1 = 0.8f,
level2 = 2.2f,
level3 = 0.5f,
level4 = 1.65f,
level5 = 0.7f,
),
snr20 = PhotonPyramidOverrides(
level1 = sabreSnr20Level1Fit.evaluate(areaStops),
level2 = 2.1f,
level3 = 0.4f,
level4 = 0.8f,
level5 = 0.2f,
),
snr40 = PhotonPyramidOverrides(
level1 = 0.85f,
level2 = 0.4f,
level3 = 0.3f,
level4 = 0.457f,
level5 = 0.1f,
),
),
),
)
}
private data class LogAreaFit(
val valueAtReferenceArea: Float,
val changePerAreaStop: Float,
) {
fun evaluate(areaStops: Float): Float =
valueAtReferenceArea + changePerAreaStop * areaStops
}
}
@@ -3,6 +3,7 @@ package com.hinnka.mycamera.raw
import android.opengl.GLES30
import android.opengl.GLES31
import android.util.Half
import com.hinnka.mycamera.processor.PhotonCoreImagingTuning
import com.hinnka.mycamera.utils.LargeDirectBuffer
import com.hinnka.mycamera.utils.PLog
import java.nio.ByteBuffer
@@ -32,7 +33,11 @@ internal object DemosaicNoiseSpectrum {
channels: IntArray,
inputCorrelation: FloatArray,
): FloatArray? {
if (inputCorrelation.size != SIZE) return null
if (inputCorrelation.size != SIZE ||
inputCorrelation.any { !it.isFinite() || it < 0f }
) return null
val inputMean = inputCorrelation.average()
if (inputMean == 0.0) return FloatArray(SIZE)
val demosaicPower = halfBinDirectionalPower(residuals, channels)
val demosaicPowerMean = demosaicPower.average()
if (!demosaicPowerMean.isFinite() || demosaicPowerMean <= 0.0) return null
@@ -42,8 +47,11 @@ internal object DemosaicNoiseSpectrum {
}
val compositionMean = composed.average()
if (!compositionMean.isFinite() || compositionMean <= 0.0) return null
// Synthetic calibration measures demosaic transfer using read/shot coefficients,
// without the input spectrum. Normalize only the composed shape: discarding the
// input amplitude here would erase a non-unit NoiseModel constructor seed.
return FloatArray(SIZE) { index ->
(composed[index] / compositionMean).toFloat()
(composed[index] / compositionMean * inputMean).toFloat()
}.takeIf { spectrum -> spectrum.all { it.isFinite() && it >= 0f } }
}
@@ -427,11 +435,12 @@ internal class DemosaicNoisePropagationCalibrator(
): DemosaicNoiseTransfer? {
val rgbNoise = MgcFullResolutionDenoise.resolveUserAdjustmentCameraRgbNoise(metadata)
?: return null
val spectrumSeed = PhotonCoreImagingTuning.denoise.noiseSpectrumSeed
val propagationMetadata = metadata.copy(
frameCount = 1,
mgcDenoiseReadNoise = rgbNoise.read,
mgcDenoiseShotNoise = rgbNoise.shot,
mgcDenoiseCorrelation = FloatArray(SPECTRUM_BINS) { 1f },
mgcDenoiseCorrelation = FloatArray(SPECTRUM_BINS) { spectrumSeed },
mgcSpatialStrengthMap = null,
)
return measure(propagationMetadata, calculationWb4)?.also { transfer ->
@@ -7,6 +7,7 @@ import android.opengl.GLES31
import com.hinnka.mycamera.processor.GlesComputeWorkGroup
import com.hinnka.mycamera.processor.GlesGpuCompletion
import com.hinnka.mycamera.processor.GlesGpuScheduler
import com.hinnka.mycamera.processor.PhotonCoreImagingTuning
import com.hinnka.mycamera.utils.PLog
import org.tensorflow.lite.DataType
import org.tensorflow.lite.Interpreter
@@ -1588,7 +1589,7 @@ internal class DngPhotonProfileGainTableAlgorithm {
GLES31.glGetUniformLocation(hdrNetInputProgram, "uWarpCount"),
activeWarpParameters.size / 8,
)
val dehazeTuning = input.metadata.coreImagingTuning.dehaze.normalized()
val dehazeTuning = PhotonCoreImagingTuning.dehaze.normalized()
val modelInputBuffer = ByteBuffer.allocateDirect(inputFloatCount * Float.SIZE_BYTES)
.order(ByteOrder.nativeOrder())
val modelOutputBuffer = ByteBuffer.allocateDirect(
@@ -1,6 +1,7 @@
package com.hinnka.mycamera.raw
import android.content.Context
import com.hinnka.mycamera.processor.PhotonSensorSizeTuning
import com.hinnka.mycamera.processor.DenoiseStrength
import com.hinnka.mycamera.processor.PhotonSabreLumaTuningNodes
import com.hinnka.mycamera.processor.RawNoiseModel
@@ -77,7 +78,7 @@ internal object MgcFullResolutionDenoise {
val chromaCorrelation: FloatArray,
)
private data class TuningPoint(
internal data class TuningPoint(
val snr: Float,
val tuning: Tuning,
)
@@ -184,14 +185,19 @@ internal object MgcFullResolutionDenoise {
val mergedCorrelation = if (useSpatialModel || useSabreModel) {
metadata.mgcDenoiseCorrelation
} else null
val coreTuning = metadata.coreImagingTuning.normalized()
val coreTuning = PhotonSensorSizeTuning.resolve(metadata.rawMaxQualityTuningSensorAreaMm2)
// Only a newly constructed single-frame model uses the seed. Fused models must
// supply their spectrum; measured/prepared spectra retain their own amplitude.
val defaultCorrelation = if (!useSpatialModel && !useSabreModel) {
FloatArray(128) { coreTuning.denoise.noiseSpectrumSeed }
} else null
val lumaCorrelation = applyFusionCorrelationScale(
correlation = preparedYuvNoiseModel?.lumaCorrelation ?: mergedCorrelation,
correlation = preparedYuvNoiseModel?.lumaCorrelation ?: mergedCorrelation ?: defaultCorrelation,
scale = coreTuning.fusion.noiseCorrelationScale,
enabled = useSabreModel,
)
val chromaCorrelation = applyFusionCorrelationScale(
correlation = preparedYuvNoiseModel?.chromaCorrelation ?: mergedCorrelation,
correlation = preparedYuvNoiseModel?.chromaCorrelation ?: mergedCorrelation ?: defaultCorrelation,
scale = coreTuning.fusion.noiseCorrelationScale,
enabled = useSabreModel,
)
@@ -266,6 +272,8 @@ internal object MgcFullResolutionDenoise {
tuning = point.tuning,
snr = point.snr,
nodes = coreTuning.denoise.sabreLumaNodes,
revertNodes = coreTuning.denoise.sabreLumaRevertNodes,
outlierNodes = coreTuning.denoise.sabreLumaOutlierNodes,
),
)
}
@@ -358,6 +366,7 @@ internal object MgcFullResolutionDenoise {
"rgbShot=${rgbShot.contentToString()} " +
"rgbRead=${rgbRead.contentToString()} " +
"rgbWb=${rgbWhiteBalance.contentToString()} " +
"qualityTuningSensorAreaMm2=${metadata.rawMaxQualityTuningSensorAreaMm2} " +
"tuningInterpolation=linear " +
"lumaScales=${coreTuning.denoise.lumaStrengthScale} " +
"detailReconstructionScales=${coreTuning.denoise.detailReconstructionScale} " +
@@ -500,15 +509,22 @@ internal object MgcFullResolutionDenoise {
tuning: Tuning,
snr: Float,
nodes: PhotonSabreLumaTuningNodes,
revertNodes: PhotonSabreLumaTuningNodes = PhotonSabreLumaTuningNodes.DEFAULT,
outlierNodes: PhotonSabreLumaTuningNodes = PhotonSabreLumaTuningNodes.DEFAULT,
): Tuning {
val row = nodes.normalized().valuesForSnr(snr) ?: return tuning.copyArrays()
require(row.size == tuning.strength.size)
fun overrideField(
original: FloatArray,
overrides: PhotonSabreLumaTuningNodes,
allowNegative: Boolean = false,
): FloatArray {
val row = overrides.normalized(allowNegative).valuesForSnr(snr) ?: return original.copyOf()
require(row.size == original.size)
return FloatArray(original.size) { index -> row[index] ?: original[index] }
}
return tuning.copy(
strength = FloatArray(tuning.strength.size) { index ->
row[index] ?: tuning.strength[index]
},
revertFactor = tuning.revertFactor.copyOf(),
outlierDistance = tuning.outlierDistance.copyOf(),
strength = overrideField(tuning.strength, nodes),
revertFactor = overrideField(tuning.revertFactor, revertNodes, allowNegative = true),
outlierDistance = overrideField(tuning.outlierDistance, outlierNodes, allowNegative = true),
)
}
@@ -550,13 +566,13 @@ internal object MgcFullResolutionDenoise {
}
/** Exact upper-bound clamp and linear SNR interpolation from libgcastartup.so+0x33ec5d4. */
private fun interpolateTuning(
internal fun interpolateTuning(
snr: Float,
points: List<TuningPoint>,
): Tuning {
val finiteSnr = snr.takeIf { it.isFinite() && it >= 0f }
?: points.first().snr
val upperIndex = points.indexOfFirst { it.snr >= finiteSnr }
val upperIndex = points.indexOfFirst { it.snr > finiteSnr }
if (upperIndex < 0) return points.last().tuning.copyArrays()
if (upperIndex == 0) return points.first().tuning.copyArrays()
val lower = points[upperIndex - 1]
@@ -565,11 +581,13 @@ internal object MgcFullResolutionDenoise {
(finiteSnr - lower.snr) /
(upper.snr - lower.snr)
).coerceIn(0f, 1f)
val lowerAmount = 1f - amount
fun interpolate(
first: FloatArray,
second: FloatArray,
): FloatArray = FloatArray(5) { index ->
first[index] + (second[index] - first[index]) * amount
// libgcastartup 0x54b3794..0x54b37ac: two FMULs, then FADD (not FMADD).
lowerAmount * first[index] + second[index] * amount
}
return Tuning(
strength = interpolate(
@@ -29,7 +29,6 @@ import com.hinnka.mycamera.processor.DenoiseStrength
import com.hinnka.mycamera.processor.GlesPixelBufferTransfer
import com.hinnka.mycamera.processor.GpuBayerSource
import com.hinnka.mycamera.processor.GpuLinearRgbSource
import com.hinnka.mycamera.processor.PhotonCoreImagingTuning
import com.hinnka.mycamera.processor.GpuLinearRgbStorage
import com.hinnka.mycamera.processor.GpuStackCompletionTimeline
import com.hinnka.mycamera.processor.RawNoiseModel
@@ -228,8 +227,7 @@ class RawDemosaicProcessor {
mgcSpatialStrengthMap = baseMetadata?.mgcSpatialStrengthMap,
mgcDenoiseTuningSnr = baseMetadata?.mgcDenoiseTuningSnr,
mgcSharpenAttenuationScale = baseMetadata?.mgcSharpenAttenuationScale,
coreImagingTuning = baseMetadata?.coreImagingTuning
?: PhotonCoreImagingTuning.DEFAULT,
rawMaxQualityTuningSensorAreaMm2 = baseMetadata?.rawMaxQualityTuningSensorAreaMm2,
rotation = dngRawData.rotation,
profileGainTableMap = baseMetadata?.profileGainTableMap
)
@@ -1816,7 +1814,7 @@ class RawDemosaicProcessor {
rawWhiteLevelMode: String? = null,
rawCustomWhiteLevel: Float? = null,
sharpeningValue: Float = 0f,
processLocalCoreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
processLocalQualityTuningSensorAreaMm2: Float? = null,
denoiseValue: Float? = null,
chromaDenoiseValue: Float? = null,
rawDcpId: String? = null,
@@ -1863,7 +1861,7 @@ class RawDemosaicProcessor {
rawWhiteLevelMode = rawWhiteLevelMode,
rawCustomWhiteLevel = rawCustomWhiteLevel,
sharpeningValue = sharpeningValue,
processLocalCoreImagingTuning = processLocalCoreImagingTuning,
processLocalQualityTuningSensorAreaMm2 = processLocalQualityTuningSensorAreaMm2,
denoiseValue = denoiseValue,
chromaDenoiseValue = chromaDenoiseValue,
rawDcpId = rawDcpId,
@@ -1913,6 +1911,7 @@ class RawDemosaicProcessor {
rawWhitePointCorrection: Float = 0f,
applyLensShadingCorrection: Boolean = true,
sharpeningValue: Float = 0f,
processLocalQualityTuningSensorAreaMm2: Float? = null,
denoiseValue: Float? = null,
chromaDenoiseValue: Float? = null,
rawDcpId: String? = null,
@@ -1954,6 +1953,7 @@ class RawDemosaicProcessor {
rawWhitePointCorrection = rawWhitePointCorrection,
applyLensShadingCorrection = applyLensShadingCorrection,
sharpeningValue = sharpeningValue,
processLocalQualityTuningSensorAreaMm2 = processLocalQualityTuningSensorAreaMm2,
denoiseValue = denoiseValue,
chromaDenoiseValue = chromaDenoiseValue,
rawDcpId = rawDcpId,
@@ -2055,8 +2055,8 @@ class RawDemosaicProcessor {
rawWhiteLevelMode: String? = null,
rawCustomWhiteLevel: Float? = null,
sharpeningValue: Float = 0f,
processLocalQualityTuningSensorAreaMm2: Float? = null,
processLocalMgcSharpenAttenuationScale: Float? = null,
processLocalCoreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
denoiseValue: Float? = null,
chromaDenoiseValue: Float? = null,
rawDcpId: String? = null,
@@ -2103,9 +2103,9 @@ class RawDemosaicProcessor {
rawWhiteLevelMode = rawWhiteLevelMode,
rawCustomWhiteLevel = rawCustomWhiteLevel,
sharpeningValue = sharpeningValue,
processLocalQualityTuningSensorAreaMm2 = processLocalQualityTuningSensorAreaMm2,
processLocalMgcSharpenAttenuationScale =
processLocalMgcSharpenAttenuationScale,
processLocalCoreImagingTuning = processLocalCoreImagingTuning,
denoiseValue = denoiseValue,
chromaDenoiseValue = chromaDenoiseValue,
rawDcpId = rawDcpId,
@@ -2165,6 +2165,7 @@ class RawDemosaicProcessor {
rawWhiteLevelMode: String? = null,
rawCustomWhiteLevel: Float? = null,
sharpeningValue: Float = 0f,
processLocalQualityTuningSensorAreaMm2: Float? = null,
denoiseValue: Float? = null,
chromaDenoiseValue: Float? = null,
rawDcpId: String? = null,
@@ -2261,6 +2262,7 @@ class RawDemosaicProcessor {
rawWhiteLevelMode = rawWhiteLevelMode,
rawCustomWhiteLevel = rawCustomWhiteLevel,
sharpeningValue = sharpeningValue,
processLocalQualityTuningSensorAreaMm2 = processLocalQualityTuningSensorAreaMm2,
denoiseValue = denoiseValue,
chromaDenoiseValue = chromaDenoiseValue,
rawDcpId = rawDcpId,
@@ -2318,8 +2320,8 @@ class RawDemosaicProcessor {
rawWhiteLevelMode: String? = null,
rawCustomWhiteLevel: Float? = null,
sharpeningValue: Float = 0f,
processLocalQualityTuningSensorAreaMm2: Float? = null,
processLocalMgcSharpenAttenuationScale: Float? = null,
processLocalCoreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
denoiseValue: Float? = null,
chromaDenoiseValue: Float? = null,
rawDcpId: String? = null,
@@ -2523,7 +2525,6 @@ class RawDemosaicProcessor {
mgcDenoiseTuningSnr = null,
mgcSharpenAttenuationScale =
processLocalMgcSharpenAttenuationScale,
coreImagingTuning = processLocalCoreImagingTuning.normalized(),
)
actualRotation = if (dngRawData.rotation != 0) dngRawData.rotation else rotation
embeddedDngRenderPlan = selectedEmbeddedDngProfile?.let { selectedProfile ->
@@ -2570,6 +2571,12 @@ class RawDemosaicProcessor {
.rawNoiseProfileManager
.resolveSelection(rawNoiseProfileId, actualMetadata),
)
actualMetadata = actualMetadata?.let {
it.copy(
rawMaxQualityTuningSensorAreaMm2 =
processLocalQualityTuningSensorAreaMm2 ?: it.rawMaxQualityTuningSensorAreaMm2,
)
}
val captureProfilePass = sceneExposureRequest != null ||
legacyAutoExposureRequest != null || captureProfilePreparationRequested
if (!captureProfilePass) {
@@ -4,8 +4,8 @@ import com.hinnka.mycamera.processor.DenoiseStrength
/**
* Capture-time multipliers on the HDR+ denoise tuning. Unity keeps the native model
* amplitude, including the AGC Pixel 5 default; its P5 gain-curve parameter 2.5 is not
* a global S/O or luma/chroma strength multiplier.
* amplitude of the selected noise model. Profile coefficients and Photon core tuning
* are applied independently of these capture-time user-strength multipliers.
*/
object RawDenoiseDefaults {
const val RAW_MAX_LUMA_STRENGTH = 1.0f
@@ -10,7 +10,6 @@ import android.util.Log
import android.util.Rational
import com.hinnka.mycamera.camera.readMetadataOrNull
import com.hinnka.mycamera.camera.readMetadataOrThrow
import com.hinnka.mycamera.processor.PhotonCoreImagingTuning
import com.hinnka.mycamera.processor.RawNoiseModel
import com.hinnka.mycamera.processor.RawNoiseProfileSelection
import com.hinnka.mycamera.utils.DeviceUtil
@@ -173,6 +172,8 @@ data class RawMetadata(
val maxAnalogSensitivity: Int = 0,
val shutterSpeed: Long = 0L,
val aperture: Float = FALLBACK_APERTURE_F_NUMBER,
/** Capture-scoped sensor area when RAWmax quality tuning is enabled; null uses defaults. */
val rawMaxQualityTuningSensorAreaMm2: Float? = null,
/** CameraCharacteristics sensor geometry used only for adaptive noise-model estimation. */
val sensorPhysicalWidthMm: Float = 0f,
val sensorPhysicalHeightMm: Float = 0f,
@@ -194,8 +195,6 @@ data class RawMetadata(
val mgcDenoiseTuningSnr: Float? = null,
/** MGC-derived attenuation applied to Photon's final GLES sharpen strength. */
val mgcSharpenAttenuationScale: Float? = null,
/** Capture-scoped Photon controls for fusion, denoise and dehaze. */
val coreImagingTuning: PhotonCoreImagingTuning = PhotonCoreImagingTuning.DEFAULT,
val rotation: Int? = null,
val profileGainTableMap: DngProfileGainTableMap? = null,
/** Whether the exact CaptureResult paired with this RAW reported at least one face. */
@@ -227,7 +226,7 @@ data class RawMetadata(
}
return if (model != null) {
copy(
channelNoiseProfile = model.canonicalChannelPairs(),
channelNoiseProfile = model.canonicalChannelPairs(cfaPattern),
noiseProfileLayout = RawNoiseProfileLayout.CANONICAL_BAYER,
)
} else {
@@ -1219,7 +1218,7 @@ data class RawMetadata(
if (mgcSpatialStrengthMap != other.mgcSpatialStrengthMap) return false
if (mgcDenoiseTuningSnr != other.mgcDenoiseTuningSnr) return false
if (mgcSharpenAttenuationScale != other.mgcSharpenAttenuationScale) return false
if (coreImagingTuning != other.coreImagingTuning) return false
if (rawMaxQualityTuningSensorAreaMm2 != other.rawMaxQualityTuningSensorAreaMm2) return false
if (rotation != other.rotation) return false
return true
@@ -1257,7 +1256,7 @@ data class RawMetadata(
result = 31 * result + (mgcSpatialStrengthMap?.hashCode() ?: 0)
result = 31 * result + (mgcDenoiseTuningSnr?.hashCode() ?: 0)
result = 31 * result + (mgcSharpenAttenuationScale?.hashCode() ?: 0)
result = 31 * result + coreImagingTuning.hashCode()
result = 31 * result + (rawMaxQualityTuningSensorAreaMm2?.hashCode() ?: 0)
result = 31 * result + (rotation ?: 0)
return result
}
@@ -142,6 +142,9 @@ class RawNoiseProfileManager(context: Context) {
private const val TAG = "RawNoiseProfileManager"
const val SYSTEM_PROFILE_ID = RawNoiseProfileSelection.SYSTEM_CAMERA2_ID
const val ADAPTIVE_PROFILE_ID = "adaptive_x9_ultra"
const val AGC26_PROFILE_ID = "builtin_noise_agc26_gc02m1_lmipro"
const val LGV50_PROFILE_ID = "builtin_noise_lgv50_imx363"
const val GALAXY_M51_PROFILE_ID = "builtin_noise_galaxym51_gc5035_54"
const val PIXEL5_PROFILE_ID = "builtin_noise_pixel5_agc"
const val PIXEL8_PRO_PROFILE_ID = "builtin_noise_pixel8_pro"
const val X9_ULTRA_PROFILE_ID = "builtin_noise_x9_ultra"
@@ -156,6 +159,27 @@ class RawNoiseProfileManager(context: Context) {
isBuiltIn = true,
nameResId = R.string.raw_noise_profile_pixel5,
),
RawNoiseProfileInfo(
id = AGC26_PROFILE_ID,
nameMap = emptyMap(),
filePath = "noise_profiles/GC02M1_LMIPRO.c",
isBuiltIn = true,
nameResId = R.string.raw_noise_profile_agc26,
),
RawNoiseProfileInfo(
id = LGV50_PROFILE_ID,
nameMap = emptyMap(),
filePath = "noise_profiles/LGV50_IMX363.c",
isBuiltIn = true,
nameResId = R.string.raw_noise_profile_lgv50,
),
RawNoiseProfileInfo(
id = GALAXY_M51_PROFILE_ID,
nameMap = emptyMap(),
filePath = "noise_profiles/GalaxyM51_SLSI_GC5035_54.c",
isBuiltIn = true,
nameResId = R.string.raw_noise_profile_galaxy_m51,
),
RawNoiseProfileInfo(
id = SYSTEM_PROFILE_ID,
nameMap = emptyMap(),
@@ -404,6 +404,7 @@ fun SettingsScreen(
val rawColorEngine by viewModel.rawRenderingEngine.collectAsState()
val rawToneMappingParameters by viewModel.rawToneMappingParameters.collectAsState()
val rawMaxSharpening by viewModel.rawMaxSharpening.collectAsState()
val rawMaxQualityTuningEnabled by viewModel.rawMaxQualityTuningEnabled.collectAsState()
val rawMaxNoiseReduction by viewModel.rawMaxNoiseReduction.collectAsState()
val rawMaxChromaNoiseReduction by viewModel.rawMaxChromaNoiseReduction.collectAsState()
val rawSpectralFilmStock by viewModel.rawSpectralFilmStock.collectAsState()
@@ -2075,6 +2076,17 @@ fun SettingsScreen(
SettingsSection(
title = stringResource(R.string.settings_professional_group_image_quality)
) {
SwitchSettingItem(
title = stringResource(R.string.settings_raw_max_quality_tuning),
description = stringResource(R.string.settings_raw_max_quality_tuning_description),
checked = rawMaxQualityTuningEnabled,
onCheckedChange = viewModel::setRawMaxQualityTuningEnabled,
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
)
val valueFormat = stringResource(R.string.settings_raw_max_output_scale_value)
SliderSettingItem(
title = stringResource(R.string.settings_raw_max_output_scale),
@@ -58,6 +58,7 @@ import com.hinnka.mycamera.processor.CaptureProcessingQueue
import com.hinnka.mycamera.processor.RawBurstFrameRole
import com.hinnka.mycamera.processor.MgcSpatialOutputMode
import com.hinnka.mycamera.processor.MgcMergeMethod
import com.hinnka.mycamera.processor.PhotonSensorSizeTuning
import com.hinnka.mycamera.processor.MgcRawMaxMode
import com.hinnka.mycamera.processor.RawmaxExposurePlanner
import com.hinnka.mycamera.processor.RawStackFrame
@@ -187,6 +188,14 @@ private data class RawSpectralFilmSettings(
private fun resolveEffectiveRawAutoExposure(): Boolean = false
private fun rawProcessingMetadataProperties(
userPrefs: UserPreferences?,
sensorPhysicalAreaMm2: Float?,
): Map<String, String> = PhotonSensorSizeTuning.captureProperties(
enabled = userPrefs?.let { it.useRawMax && it.rawMaxQualityTuningEnabled } == true,
sensorPhysicalAreaMm2 = sensorPhysicalAreaMm2,
)
private fun resolveCaptureSharpening(
isRawCapture: Boolean,
userPrefs: UserPreferences?,
@@ -1439,6 +1448,14 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
SharingStarted.Eagerly,
RawSharpeningDefaults.DEFAULT_STRENGTH,
)
val rawMaxQualityTuningEnabled: StateFlow<Boolean> = userPreferencesRepository.userPreferences
.map { it.rawMaxQualityTuningEnabled }
.stateIn(
viewModelScope,
SharingStarted.Eagerly,
PhotonSensorSizeTuning.DEFAULT_RAW_MAX_QUALITY_TUNING_ENABLED,
)
val rawMaxNoiseReduction: StateFlow<Float> = userPreferencesRepository.userPreferences
.map { it.rawMaxNoiseReduction }
.stateIn(
@@ -2519,6 +2536,10 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
viewModelScope.launch { userPreferencesRepository.saveRawMaxSharpening(value) }
}
fun setRawMaxQualityTuningEnabled(enabled: Boolean) {
viewModelScope.launch { userPreferencesRepository.saveRawMaxQualityTuningEnabled(enabled) }
}
fun setRawMaxNoiseReduction(value: Float) {
viewModelScope.launch { userPreferencesRepository.saveRawMaxNoiseReduction(value) }
}
@@ -2961,6 +2982,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
?: HncsFilmCurveMode.Standard,
rawExposureCompensation = userPrefs?.rawExposureCompensation ?: 0f,
rawAutoExposure = effectiveRawAutoExposure,
customProperties = rawProcessingMetadataProperties(
userPrefs, cameraController.getCurrentSensorPhysicalAreaMm2(),
),
rawHighlightsAdjustment = userPrefs?.rawHighlightsAdjustment ?: 0f,
rawShadowsAdjustment = userPrefs?.rawShadowsAdjustment ?: 0f,
rawBlackPointCorrection = userPrefs?.rawBlackPointCorrection ?: 0f,
@@ -5683,7 +5707,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
rawExposureCompensation = userPrefs?.rawExposureCompensation ?: 0f,
rawAutoExposure = effectiveRawAutoExposure,
customProperties = RawCaptureExposureCompensationMetadata.write(
emptyMap(),
rawProcessingMetadataProperties(
userPrefs, cameraController.getCurrentSensorPhysicalAreaMm2(),
),
captureExposureCompensationEv,
),
rawHighlightsAdjustment = userPrefs?.rawHighlightsAdjustment ?: 0f,
@@ -5843,6 +5869,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
?: HncsFilmCurveMode.Standard,
rawExposureCompensation = userPrefs?.rawExposureCompensation ?: 0f,
rawAutoExposure = effectiveRawAutoExposure,
customProperties = rawProcessingMetadataProperties(
userPrefs, cameraController.getCurrentSensorPhysicalAreaMm2(),
),
rawHighlightsAdjustment = userPrefs?.rawHighlightsAdjustment ?: 0f,
rawShadowsAdjustment = userPrefs?.rawShadowsAdjustment ?: 0f,
rawBlackPointCorrection = userPrefs?.rawBlackPointCorrection ?: 0f,
@@ -6111,7 +6140,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
rawExposureCompensation = userPrefs?.rawExposureCompensation ?: 0f,
rawAutoExposure = effectiveRawAutoExposure,
customProperties = RawCaptureExposureCompensationMetadata.write(
emptyMap(),
rawProcessingMetadataProperties(
userPrefs, cameraController.getCurrentSensorPhysicalAreaMm2(),
),
captureExposureCompensationEv,
),
rawHighlightsAdjustment = userPrefs?.rawHighlightsAdjustment ?: 0f,
@@ -6433,6 +6464,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
?: HncsFilmCurveMode.Standard,
rawExposureCompensation = userPrefs?.rawExposureCompensation ?: 0f,
rawAutoExposure = effectiveRawAutoExposure,
customProperties = rawProcessingMetadataProperties(
userPrefs, cameraController.getCurrentSensorPhysicalAreaMm2(),
),
rawHighlightsAdjustment = userPrefs?.rawHighlightsAdjustment ?: 0f,
rawShadowsAdjustment = userPrefs?.rawShadowsAdjustment ?: 0f,
rawBlackPointCorrection = userPrefs?.rawBlackPointCorrection ?: 0f,
@@ -1221,4 +1221,6 @@
<string name="settings_raw_camera_color_matching_description">開啟時會根據拍攝相機調整色彩,關閉時使用原版處理。</string>
<string name="settings_color_palette">調色盤</string>
<string name="settings_color_palette_description">在編輯頁顯示調色盤,可同時調整影調和飽和度。</string>
<string name="settings_raw_max_quality_tuning">HDR+ 畫質調校</string>
<string name="settings_raw_max_quality_tuning_description">依實體感光元件尺寸調整融合雜訊估計與降噪。關閉時使用預設成像參數。</string>
</resources>
+2
View File
@@ -311,4 +311,6 @@
<string name="settings_color_palette">Farbpalette</string>
<string name="settings_color_palette_description">Farbpalette im Editor anzeigen, um Tonwerte und Sättigung gleichzeitig anzupassen.</string>
<string name="recipe_palette_tone">Tonwerte</string>
<string name="settings_raw_max_quality_tuning">HDR+ Bildqualitätsoptimierung</string>
<string name="settings_raw_max_quality_tuning_description">Rauschschätzung bei der Fusion und Rauschminderung an die physische Sensorgröße anpassen. Wenn deaktiviert, werden die Standardparameter verwendet.</string>
</resources>
+2
View File
@@ -311,4 +311,6 @@
<string name="settings_color_palette">Palette de couleurs</string>
<string name="settings_color_palette_description">Afficher la palette sur la page de retouche pour ajuster ensemble le rendu tonal et la saturation.</string>
<string name="recipe_palette_tone">Rendu tonal</string>
<string name="settings_raw_max_quality_tuning">Réglage de la qualité HDR+</string>
<string name="settings_raw_max_quality_tuning_description">Adapte l’estimation du bruit de fusion et la réduction du bruit à la taille physique du capteur. Si désactivé, les paramètres par défaut sont utilisés.</string>
</resources>
+2
View File
@@ -311,4 +311,6 @@
<string name="settings_color_palette">Palet warna</string>
<string name="settings_color_palette_description">Tampilkan palet warna di editor untuk menyesuaikan tonalitas dan saturasi secara bersamaan.</string>
<string name="recipe_palette_tone">Tonalitas</string>
<string name="settings_raw_max_quality_tuning">Penyetelan kualitas gambar HDR+</string>
<string name="settings_raw_max_quality_tuning_description">Sesuaikan estimasi derau penggabungan dan pengurangan derau dengan ukuran fisik sensor. Saat nonaktif, gunakan parameter gambar bawaan.</string>
</resources>
+2
View File
@@ -1119,4 +1119,6 @@
<string name="settings_raw_lumix_photo_style_description">LUMIX S9のフォトスタイルを選択します。デフォルトはスタンダードです。</string>
<string name="settings_color_palette">カラーパレット</string>
<string name="settings_color_palette_description">編集画面にカラーパレットを表示し、階調と彩度を同時に調整できます。</string>
<string name="settings_raw_max_quality_tuning">HDR+ 画質調整</string>
<string name="settings_raw_max_quality_tuning_description">センサーの物理サイズに合わせて合成時のノイズ推定とノイズ低減を調整します。オフの場合は標準の画像処理パラメータを使用します。</string>
</resources>
+2
View File
@@ -312,4 +312,6 @@
<string name="settings_color_palette">색상 팔레트</string>
<string name="settings_color_palette_description">편집 화면에 색상 팔레트를 표시하여 명암과 채도를 함께 조정합니다.</string>
<string name="recipe_palette_tone">명암</string>
<string name="settings_raw_max_quality_tuning">HDR+ 화질 조정</string>
<string name="settings_raw_max_quality_tuning_description">센서의 물리적 크기에 맞춰 합성 노이즈 추정과 노이즈 감소를 조정합니다. 끄면 기본 이미지 처리 매개변수를 사용합니다.</string>
</resources>
@@ -312,4 +312,6 @@
<string name="settings_color_palette">Paleta de cores</string>
<string name="settings_color_palette_description">Mostrar a paleta no editor para ajustar o equilíbrio tonal e a saturação ao mesmo tempo.</string>
<string name="recipe_palette_tone">Equilíbrio tonal</string>
<string name="settings_raw_max_quality_tuning">Ajuste de qualidade HDR+</string>
<string name="settings_raw_max_quality_tuning_description">Ajusta a estimativa de ruído da fusão e a redução de ruído ao tamanho físico do sensor. Quando desativado, usa os parâmetros de imagem padrão.</string>
</resources>
+2
View File
@@ -929,4 +929,6 @@
<string name="settings_color_palette">จานสี</string>
<string name="settings_color_palette_description">แสดงจานสีในหน้าแก้ไขเพื่อปรับโทนแสงและความอิ่มสีพร้อมกัน</string>
<string name="recipe_palette_tone">โทนแสง</string>
<string name="settings_raw_max_quality_tuning">ปรับคุณภาพภาพ HDR+</string>
<string name="settings_raw_max_quality_tuning_description">ปรับการประเมินสัญญาณรบกวนในการรวมภาพและการลดสัญญาณรบกวนตามขนาดจริงของเซ็นเซอร์ เมื่อปิดจะใช้พารามิเตอร์ภาพเริ่มต้น</string>
</resources>
@@ -1242,4 +1242,6 @@
<string name="settings_raw_camera_color_matching_description">开启时根据拍摄相机调整色彩,关闭时使用原版处理。</string>
<string name="settings_color_palette">调色盘</string>
<string name="settings_color_palette_description">在编辑页显示调色盘,可同时调整影调和饱和度。</string>
<string name="settings_raw_max_quality_tuning">HDR+ 画质调优</string>
<string name="settings_raw_max_quality_tuning_description">按物理传感器尺寸调整融合噪声估计和降噪。关闭时使用默认成像参数。</string>
</resources>
@@ -1217,4 +1217,6 @@
<string name="settings_raw_camera_color_matching_description">開啟時會根據拍攝相機調整色彩,關閉時使用原版處理。</string>
<string name="settings_color_palette">調色盤</string>
<string name="settings_color_palette_description">在編輯頁顯示調色盤,可同時調整影調和飽和度。</string>
<string name="settings_raw_max_quality_tuning">HDR+ 畫質調校</string>
<string name="settings_raw_max_quality_tuning_description">按實體感光元件尺寸調整融合雜訊估計與降噪。關閉時使用預設成像參數。</string>
</resources>
@@ -1221,4 +1221,6 @@
<string name="settings_raw_camera_color_matching_description">開啟時會根據拍攝相機調整色彩,關閉時使用原版處理。</string>
<string name="settings_color_palette">調色盤</string>
<string name="settings_color_palette_description">在編輯頁顯示調色盤,可同時調整影調和飽和度。</string>
<string name="settings_raw_max_quality_tuning">HDR+ 畫質調校</string>
<string name="settings_raw_max_quality_tuning_description">依實體感光元件尺寸調整融合雜訊估計與降噪。關閉時使用預設成像參數。</string>
</resources>
+5
View File
@@ -335,6 +335,9 @@
<string name="raw_noise_profile_use_unified">Use unified model (%1$s)</string>
<string name="raw_noise_profile_system">System default (Camera2 API)</string>
<string name="raw_noise_profile_adaptive">Adaptive (estimated for current lens)</string>
<string name="raw_noise_profile_agc26" translatable="false">26 · GC02M1 - LMIPRO</string>
<string name="raw_noise_profile_lgv50" translatable="false">48 · LG V50 IMX363</string>
<string name="raw_noise_profile_galaxy_m51" translatable="false">70 · Galaxy M51 SLSI - GC5035 54</string>
<string name="raw_noise_profile_pixel5">Pixel 5</string>
<string name="raw_noise_profile_pixel8_pro">Pixel 8 Pro</string>
<string name="raw_noise_profile_x9_ultra">X9 Ultra</string>
@@ -1263,4 +1266,6 @@
<string name="settings_raw_camera_color_matching_description">Adjust colors according to the camera used for the photo when enabled; use the original processing when disabled.</string>
<string name="settings_color_palette">Color palette</string>
<string name="settings_color_palette_description">Show the color palette in the editor to adjust tonality and saturation together.</string>
<string name="settings_raw_max_quality_tuning">HDR+ image quality tuning</string>
<string name="settings_raw_max_quality_tuning_description">Adjust fusion noise estimates and denoising to the physical sensor size. When off, use default imaging parameters.</string>
</resources>
@@ -15,6 +15,28 @@ import kotlin.math.abs
* tuning gain again.
*/
class CalibratedRawNoiseProfileTest {
@Test
fun bundledAgc26CMatchesOriginalArm64SamplesAcrossAnalogGainBoundary() {
val profile = java.io.File("src/main/assets/noise_profiles/GC02M1_LMIPRO.c")
.inputStream().use { CalibratedRawNoiseProfile.parseGcamC("agc26", it) }
assertEquals(600, profile.maxAnalogSensitivity)
val rows = requireNotNull(javaClass.getResourceAsStream(
"/noise_profiles/agc96_model26_samples.csv",
)).bufferedReader().use { it.readLines().drop(1) }
assertEquals(56, rows.size)
for (line in rows) {
val row = line.split(',')
val iso = row[0].toInt()
val plane = row[1].toInt()
// A generated .c owns its ISO divisor; target-camera gain limits do not replace it.
for ((minimumIso, maximumAnalogIso) in listOf(0 to 0, 50 to 400, 100 to 1600)) {
val model = requireNotNull(profile.evaluate(iso, minimumIso, maximumAnalogIso))
assertEquals("S: $line", row[7].toFloat().toRawBits(), model.shotNoise[plane].toRawBits())
assertEquals("O: $line", row[8].toFloat().toRawBits(), model.readNoise[plane].toRawBits())
}
}
}
@Test
fun pixel5MatchesOriginalAgcArm64SamplesWithTargetCameraGainLimits() {
// Oracle: original AGC9.6.19 V7 ARM64 callback, not this implementation.
@@ -48,16 +48,16 @@ class MgcSabreKernelTuningTest {
}
@Test
fun mergeGradientThresholdReplacesOnlyCovarianceParameters1Z() {
fun defaultMergeGradientThresholdSurvivesNormalizationAndOnlyReplacesCovarianceParameters1Z() {
val stock = MgcSabreKernelTuning.build(referenceSnr = 11f, frameCount = 12)
val patched = MgcSabreKernelTuning.build(
referenceSnr = 11f,
frameCount = 12,
mergeGradientThreshold = 0.02f,
mergeGradientThreshold = PhotonCoreImagingTuning.fusion.normalized().mergeGradientThreshold,
)
assertEquals(0.02f, patched.gradientThreshold, 0f)
assertEquals(0.02f, patched.covarianceParameters1[2], 0f)
assertEquals(-1f, patched.gradientThreshold, 0f)
assertEquals(-1f, patched.covarianceParameters1[2], 0f)
assertEquals(stock.directionalScale, patched.directionalScale, 0f)
assertEquals(stock.isotropicScale, patched.isotropicScale, 0f)
assertEquals(stock.gradientTransition, patched.gradientTransition, 0f)
@@ -14,7 +14,7 @@ class MgcSabreMergedNoiseModelTest {
for ((snr, correction) in listOf(0f to 0.8f, 0.5f to 0.8f,
2.25f to 0.9f, 4f to 1f, 7f to 0.85f, 10f to 0.7f, 30f to 0.7f)) {
for (count in listOf(1, 2, 3, 8)) {
val output = MgcSabreMergedNoiseModel.merge(List(count) { frame }, snr)
val output = MgcSabreMergedNoiseModel.merge(List(count) { frame }, snr, 1f)
assertArrayEquals(FloatArray(3) { frame.read[it] * correction / count },
output.read, 1e-9f)
assertArrayEquals(FloatArray(3) { frame.shot[it] * correction / count },
@@ -37,11 +37,29 @@ class MgcSabreMergedNoiseModelTest {
floatArrayOf(0.008f, 0.024f, 0.032f),
floatArrayOf(0.06f, 0.08f, 0.16f),
),
), 4f)
), 4f, 1f)
assertArrayEquals(floatArrayOf(0.00225f, 0.0065f, 0.009f), output.read, 1e-9f)
assertArrayEquals(floatArrayOf(0.0175f, 0.025f, 0.05f), output.shot, 1e-8f)
assertEquals(0.2f / kotlin.math.sqrt(0.0115f),
MgcSpatialMergeTuning.outputNoiseModelSnr(0.2f, output.read[1], output.shot[1])!!,
1e-6f)
}
@Test
fun constructorSeedChangesOnlySpectrumAndSurvivesFrameComposition() {
val frame = MgcSabreMergedNoiseModel.Frame(
floatArrayOf(0.001f, 0.002f, 0.003f),
floatArrayOf(0.01f, 0.02f, 0.03f),
)
for (count in listOf(1, 3, 8)) {
val frames = List(count) { frame }
val classic = MgcSabreMergedNoiseModel.merge(frames, 20f, 1f)
val configured = MgcSabreMergedNoiseModel.merge(
frames, 20f, PhotonDenoiseTuning(noiseSpectrumSeed = 0.5f).noiseSpectrumSeed,
)
assertArrayEquals(classic.read, configured.read, 0f)
assertArrayEquals(classic.shot, configured.shot, 0f)
assertArrayEquals(FloatArray(128) { 0.5f }, configured.correlation, 0f)
}
}
}
@@ -1,92 +1,64 @@
package com.hinnka.mycamera.processor
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertEquals
import org.junit.Test
class PhotonCoreImagingTuningTest {
@Test
fun domainControlsKeepIndependentFixedLayouts() {
val tuning = PhotonCoreImagingTuning(
denoise = PhotonDenoiseTuning(
lumaStrengthScale = PhotonPyramidScales(1f, 2f, 3f, 4f, 5f),
detailReconstructionScale = PhotonPyramidScales(6f, 7f, 8f, 9f, 10f),
outlierRejectionScale = PhotonPyramidScales(2f, 3f, 4f, 5f, 6f),
chromaStrengthScale = PhotonPyramidScales(5f, 4f, 3f, 2f, 1f),
),
val tuning = PhotonDenoiseTuning(
lumaStrengthScale = PhotonPyramidScales(1f, 2f, 3f, 4f, 5f),
detailReconstructionScale = PhotonPyramidScales(6f, 7f, 8f, 9f, 10f),
outlierRejectionScale = PhotonPyramidScales(2f, 3f, 4f, 5f, 6f),
chromaStrengthScale = PhotonPyramidScales(5f, 4f, 3f, 2f, 1f),
)
assertArrayEquals(
floatArrayOf(1f, 2f, 3f, 4f, 5f),
tuning.denoise.lumaStrengthScale.toFloatArray(),
tuning.lumaStrengthScale.toFloatArray(),
0f,
)
assertArrayEquals(
floatArrayOf(6f, 7f, 8f, 9f, 10f),
tuning.denoise.detailReconstructionScale.toFloatArray(),
tuning.detailReconstructionScale.toFloatArray(),
0f,
)
}
@Test
fun persistedAndCapturePropertiesRoundTripPhotonModel() {
val tuning = PhotonCoreImagingTuning(
fusion = PhotonFusionTuning(
mergeGradientThreshold = 0.02f,
missingReferenceSignal = 0.12f,
noiseCorrelationScale = 0.75f,
),
denoise = PhotonDenoiseTuning(
lumaStrengthScale = PhotonPyramidScales(0.8f, 0.9f, 1f, 1.1f, 1.2f),
frequencyResponse = PhotonDenoiseFrequencyResponse(2f, -0.5f),
sabreLumaNodes = PhotonSabreLumaTuningNodes(
snr5 = PhotonPyramidOverrides(0.8f, null, 0.5f, null, 0.7f),
),
),
dehaze = PhotonDehazeTuning(
enabled = true,
strength = 0.5f,
dynamicHighlightStrength = 0.75f,
),
)
assertEquals(tuning, PhotonCoreImagingTuning.fromPersistedString(tuning.toPersistedString()))
assertEquals(tuning, PhotonCoreImagingTuning.fromCustomProperties(tuning.toCustomProperties()))
}
@Test
fun unrelatedPropertiesAreIgnored() {
assertEquals(
PhotonCoreImagingTuning.DEFAULT,
PhotonCoreImagingTuning.fromCustomProperties(
mapOf("unknownOldControl" to "4.0"),
),
)
}
@Test
fun normalizationKeepsControlsInsideOperationalRanges() {
val normalized = PhotonCoreImagingTuning(
fusion = PhotonFusionTuning(
mergeGradientThreshold = -2f,
missingReferenceSignal = 2f,
noiseCorrelationScale = Float.NaN,
),
denoise = PhotonDenoiseTuning(
lumaStrengthScale = PhotonPyramidScales(-1f, 100f, 1f, 1f, 1f),
),
val fusion = PhotonFusionTuning(
mergeGradientThreshold = -2f,
missingReferenceSignal = 2f,
noiseCorrelationScale = Float.NaN,
).normalized()
val denoise = PhotonDenoiseTuning(
lumaStrengthScale = PhotonPyramidScales(-1f, 100f, 1f, 1f, 1f),
sabreLumaNodes = PhotonSabreLumaTuningNodes(snr5 = PhotonPyramidOverrides(-1f)),
).normalized()
assertEquals(0f, requireNotNull(normalized.fusion.mergeGradientThreshold), 0f)
assertEquals(1f, normalized.fusion.missingReferenceSignal, 0f)
assertEquals(1f, normalized.fusion.noiseCorrelationScale, 0f)
assertEquals(-2f, requireNotNull(fusion.mergeGradientThreshold), 0f)
assertEquals(1f, fusion.missingReferenceSignal, 0f)
assertEquals(1f, fusion.noiseCorrelationScale, 0f)
assertArrayEquals(
floatArrayOf(0f, 16f, 1f, 1f, 1f),
normalized.denoise.lumaStrengthScale.toFloatArray(),
denoise.lumaStrengthScale.toFloatArray(),
0f,
)
assertNull(PhotonCoreImagingTuning.DEFAULT.fusion.mergeGradientThreshold)
assertEquals(-1f, requireNotNull(PhotonCoreImagingTuning.fusion.mergeGradientThreshold), 0f)
assertEquals(0f, requireNotNull(denoise.sabreLumaNodes.snr5.level1), 0f)
val defaults = PhotonCoreImagingTuning.denoise
assertEquals(PhotonPyramidScales.IDENTITY, defaults.lumaStrengthScale)
assertEquals(PhotonPyramidScales.IDENTITY, defaults.chromaStrengthScale)
assertEquals(PhotonPyramidScales.IDENTITY, defaults.detailReconstructionScale)
assertEquals(PhotonPyramidScales.IDENTITY, defaults.outlierRejectionScale)
assertEquals(PhotonSabreLumaTuningNodes.DEFAULT, defaults.sabreLumaNodes)
assertEquals(1f, defaults.frequencyResponse.responseOffset, 0f)
assertEquals(1f, defaults.noiseSpectrumSeed, 0f)
assertNull(denoise.sabreLumaRevertNodes.snr5.level1)
assertNull(denoise.sabreLumaOutlierNodes.snr20.level2)
}
@Test
@@ -102,22 +74,6 @@ class PhotonCoreImagingTuningTest {
assertEquals(true, normalized.isActive)
}
@Test
fun missingOperationalDehazeValuesUseHiddenDefault() {
val tuning = PhotonCoreImagingTuning.fromCustomProperties(
mapOf(
PhotonCoreImagingTuning.DEHAZE_ENABLED_PROPERTY to "true",
"photonDehazeExposureBiasStops" to "1.0",
"photonDehazeAtmosphericRegulation" to "2.0",
),
)
assertEquals(true, tuning.dehaze.enabled)
assertEquals(1f, tuning.dehaze.strength, 0f)
assertEquals(1f, tuning.dehaze.dynamicHighlightStrength, 0f)
assertEquals(true, tuning.dehaze.isActive)
}
@Test
fun missingReferenceSignalUsesPhotonFallbackDirectly() {
assertEquals(0.12f, resolveFusionReferenceSignal(0.12f, 0.3f), 0f)
@@ -0,0 +1,161 @@
package com.hinnka.mycamera.processor
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
import kotlin.math.log2
class PhotonSensorSizeTuningTest {
@Test
fun runtimeCoefficientsMatchLeastSquaresCalibration() {
val areas = floatArrayOf(128f, 20.48f, 24.5f, 62.9442f)
val atReference = requireNotNull(
PhotonSensorSizeTuning.forSensorAreaMm2(
PhotonSensorSizeTuning.REFERENCE_AREA_MM2,
),
)
val oneAreaStopLarger = requireNotNull(
PhotonSensorSizeTuning.forSensorAreaMm2(
PhotonSensorSizeTuning.REFERENCE_AREA_MM2 * 2f,
),
)
assertFit(
areas = areas,
samples = floatArrayOf(0.5f, 0.875f, 0.875f, 0.5f),
actualAtReference = atReference.fusion.noiseCorrelationScale,
actualOneStopLarger = oneAreaStopLarger.fusion.noiseCorrelationScale,
)
assertFit(
areas = areas,
samples = floatArrayOf(0.3125f, 0.171875f, 0.234375f, 0.40625f),
actualAtReference = atReference.denoise.lumaStrengthScale.level1,
actualOneStopLarger = oneAreaStopLarger.denoise.lumaStrengthScale.level1,
)
assertFit(
areas = areas,
samples = floatArrayOf(6.5f, 14.5f, 20f, 3.5f),
actualAtReference = atReference.denoise.frequencyResponse.responseOffset,
actualOneStopLarger = oneAreaStopLarger.denoise.frequencyResponse.responseOffset,
)
assertFit(
areas = areas,
samples = floatArrayOf(0.7f, 0.6f, 0.6f, 0.6f),
actualAtReference = atReference.denoise.sabreLumaNodes.snr20.level1
?: error("missing SNR20 L1"),
actualOneStopLarger = oneAreaStopLarger.denoise.sabreLumaNodes.snr20.level1
?: error("missing SNR20 L1"),
)
}
@Test
fun referenceAreaEvaluatesStoredModelCoefficients() {
val tuning = requireNotNull(
PhotonSensorSizeTuning.forSensorAreaMm2(
PhotonSensorSizeTuning.REFERENCE_AREA_MM2,
),
)
assertEquals(0.767513962f, tuning.fusion.noiseCorrelationScale, EPSILON)
assertEquals(0.252164225f, tuning.denoise.lumaStrengthScale.level1, EPSILON)
assertEquals(13.499369928f, tuning.denoise.frequencyResponse.responseOffset, EPSILON)
assertEquals(
0.608876213f,
tuning.denoise.sabreLumaNodes.snr20.level1 ?: error("missing SNR20 L1"),
EPSILON,
)
}
@Test
fun largerAreaMovesOnlyTheSupportedFittedDimensions() {
val small = requireNotNull(
PhotonSensorSizeTuning.forSensorAreaMm2(
PhotonSensorSizeTuning.MIN_CALIBRATED_AREA_MM2,
),
)
val large = requireNotNull(
PhotonSensorSizeTuning.forSensorAreaMm2(
PhotonSensorSizeTuning.MAX_CALIBRATED_AREA_MM2,
),
)
assertEquals(0.873362f, small.fusion.noiseCorrelationScale, 0.00001f)
assertEquals(0.438721f, large.fusion.noiseCorrelationScale, 0.00001f)
assertEquals(0.213688f, small.denoise.lumaStrengthScale.level1, 0.00001f)
assertEquals(0.371683f, large.denoise.lumaStrengthScale.level1, 0.00001f)
assertEquals(16.640339f, small.denoise.frequencyResponse.responseOffset, 0.00001f)
assertEquals(3.742630f, large.denoise.frequencyResponse.responseOffset, 0.00001f)
assertEquals(
small.denoise.chromaStrengthScale,
large.denoise.chromaStrengthScale,
)
}
@Test
fun fitClampsRatherThanExtrapolatingOutsideCalibrationRange() {
assertEquals(
PhotonSensorSizeTuning.forSensorAreaMm2(
PhotonSensorSizeTuning.MIN_CALIBRATED_AREA_MM2,
),
PhotonSensorSizeTuning.forSensorAreaMm2(1f),
)
assertEquals(
PhotonSensorSizeTuning.forSensorAreaMm2(
PhotonSensorSizeTuning.MAX_CALIBRATED_AREA_MM2,
),
PhotonSensorSizeTuning.forSensorAreaMm2(1_000f),
)
}
@Test
fun captureChoiceSurvivesMetadataWithoutPersistingCoreParameters() {
val area = 64f
val disabled = PhotonSensorSizeTuning.captureProperties(false, area)
assertEquals(emptyMap<String, String>(), disabled)
assertNull(PhotonSensorSizeTuning.areaFromProperties(disabled))
val enabled = PhotonSensorSizeTuning.captureProperties(true, area)
assertEquals(2, enabled.size)
assertEquals(area, requireNotNull(PhotonSensorSizeTuning.areaFromProperties(enabled)), 0f)
val tuned = PhotonSensorSizeTuning.resolve(PhotonSensorSizeTuning.areaFromProperties(enabled))
assertEquals(PhotonSensorSizeTuning.forSensorAreaMm2(area), tuned)
assertEquals(-1f, requireNotNull(tuned.fusion.mergeGradientThreshold), 0f)
assertEquals(-1f, requireNotNull(PhotonSensorSizeTuning.resolve(null).fusion.mergeGradientThreshold), 0f)
}
@Test
fun invalidPhysicalSizeFallsBackToNeutralDenoise() {
assertNull(PhotonSensorSizeTuning.forPhysicalSizeMm(Float.NaN, 4f))
assertNull(PhotonSensorSizeTuning.forSensorAreaMm2(0f))
assertEquals(PhotonSensorSizeTuning.Parameters(), PhotonSensorSizeTuning.resolve(null))
assertEquals(PhotonSensorSizeTuning.Parameters(), PhotonSensorSizeTuning.resolve(Float.NaN))
assertEquals(emptyMap<String, String>(), PhotonSensorSizeTuning.captureProperties(true, null))
assertEquals(emptyMap<String, String>(), PhotonSensorSizeTuning.captureProperties(true, Float.POSITIVE_INFINITY))
}
companion object {
private const val EPSILON = 0.000001f
private fun assertFit(
areas: FloatArray,
samples: FloatArray,
actualAtReference: Float,
actualOneStopLarger: Float,
) {
val x = areas.map {
log2((it / PhotonSensorSizeTuning.REFERENCE_AREA_MM2).toDouble()).toFloat()
}
val xMean = x.average().toFloat()
val yMean = samples.average().toFloat()
val slope = x.indices.sumOf { index ->
((x[index] - xMean) * (samples[index] - yMean)).toDouble()
}.toFloat() / x.sumOf { value ->
((value - xMean) * (value - xMean)).toDouble()
}.toFloat()
val valueAtReference = yMean - slope * xMean
assertEquals(valueAtReference, actualAtReference, EPSILON)
assertEquals(slope, actualOneStopLarger - actualAtReference, EPSILON)
}
}
}
@@ -1,6 +1,8 @@
package com.hinnka.mycamera.raw
import org.junit.Assert.assertEquals
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertNull
import org.junit.Test
import kotlin.math.PI
import kotlin.math.abs
@@ -9,6 +11,29 @@ import kotlin.math.max
import kotlin.math.sin
class DemosaicNoiseSpectrumTest {
@Test
fun propagationPreservesInputAmplitudeWithoutChangingNormalizedShape() {
val size = DemosaicNoiseSpectrum.SIZE
val residuals = arrayOf(FloatArray(size * size) { index ->
sin(index * 0.071).toFloat() + cos(index / size * 0.113).toFloat()
})
val input = FloatArray(size) { 0.5f + it.toFloat() / (size - 1) }
val unitMean = requireNotNull(DemosaicNoiseSpectrum.propagatedCorrelation(
residuals, intArrayOf(0), input,
))
assertEquals(1.0, unitMean.average(), 1e-6)
for (amplitude in listOf(0f, 0.5f, 2f)) {
val propagated = requireNotNull(DemosaicNoiseSpectrum.propagatedCorrelation(
residuals, intArrayOf(0), FloatArray(size) { input[it] * amplitude },
))
assertEquals(amplitude.toDouble(), propagated.average(), 1e-6)
assertArrayEquals(FloatArray(size) { unitMean[it] * amplitude }, propagated, 1e-6f)
}
assertNull(DemosaicNoiseSpectrum.propagatedCorrelation(
residuals, intArrayOf(0), FloatArray(size) { Float.NaN },
))
}
@Test
fun halfBinFftMatchesLegacyDirectTransform() {
val size = DemosaicNoiseSpectrum.SIZE
@@ -1,12 +1,139 @@
package com.hinnka.mycamera.raw
import com.hinnka.mycamera.processor.PhotonPyramidScales
import com.hinnka.mycamera.processor.PhotonPyramidOverrides
import com.hinnka.mycamera.processor.PhotonDenoiseTuning
import com.hinnka.mycamera.processor.PhotonSabreLumaTuningNodes
import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class MgcFullResolutionDenoiseTest {
// Historical fixture for native interpolation; deliberately independent of runtime defaults.
private val agcP0Fixture = run {
// Audited p0 A/B controls: A fills levels 1–4, B fills level 5.
val strengthScale = PhotonPyramidScales(2.5f, 2.5f, 2.5f, 2.5f, 1.25f)
val revertScale = PhotonPyramidScales.uniform(2f)
val outlierScale = PhotonPyramidScales.uniform(0.75f)
val strengthNodes = PhotonSabreLumaTuningNodes(
snr5 = PhotonPyramidOverrides(0.60f, 0.45f, 0.30f, 0.15f, 0.15f),
snr20 = PhotonPyramidOverrides(0.35f, 0.20f, 0.10f, 0.50f, 0f),
snr40 = PhotonPyramidOverrides(0.65f, 0.35f, 0.35f, 0.20f, 0.05f),
)
val revertNodes = PhotonSabreLumaTuningNodes(
// The protobuf's fifth layer has no revert field. AGC's L5A is outlier.
snr5 = PhotonPyramidOverrides(-1f, -1f, -1f, 0f, null),
snr20 = PhotonPyramidOverrides(-1f, -1f, 0f, -1f, null),
snr40 = PhotonPyramidOverrides(0f, 0f, 0f, 0f, null),
)
val outlierNodes = PhotonSabreLumaTuningNodes(
snr5 = PhotonPyramidOverrides(0.05f, 0f, 0f, 0.05f, 0f),
snr20 = PhotonPyramidOverrides(0.05f, -1f, 0f, 0f, -1f),
snr40 = PhotonPyramidOverrides(0f, 0.05f, 0f, 0f, 0f),
)
PhotonDenoiseTuning(
lumaStrengthScale = strengthScale,
detailReconstructionScale = revertScale,
outlierRejectionScale = outlierScale,
sabreLumaNodes = strengthNodes,
sabreLumaRevertNodes = revertNodes,
sabreLumaOutlierNodes = outlierNodes,
).normalized()
}
@Test
fun p0NodeLookupAndInterpolationMatchOriginalArm64Bits() {
val rows = requireNotNull(javaClass.getResourceAsStream(
"/noise_profiles/agc96_p0_luma_interpolation.csv",
)).bufferedReader().use { it.readLines().drop(1) }
assertEquals(180, rows.size)
val points = p0Points()
for (line in rows) {
val row = line.split(',')
val snr = Float.fromBits(row[0].toLong(16).toInt())
val actual = MgcFullResolutionDenoise.interpolateTuning(snr, points)
val values = when (row[1]) {
"strength" -> actual.strength
"revert" -> actual.revertFactor
"outlier" -> actual.outlierDistance
else -> error(line)
}
assertEquals(line, row[3].toLong(16).toInt(), values[row[2].toInt()].toRawBits())
}
}
@Test
fun p0OverridesAllSnrNodesAndPreservesSignedFieldsThroughScaling() {
val expectedStrength = listOf(
floatArrayOf(1.5f, 1.125f, 0.75f, 0.375f, 0.1875f),
floatArrayOf(0.875f, 0.5f, 0.25f, 1.25f, 0f),
floatArrayOf(1.625f, 0.875f, 0.875f, 0.5f, 0.0625f),
)
val expectedRevert = listOf(
floatArrayOf(-2f, -2f, -2f, 0f, 0f),
floatArrayOf(-2f, -2f, 0f, -2f, 0f),
floatArrayOf(0f, 0f, 0f, 0f, 0f),
)
val expectedOutlier = listOf(
floatArrayOf(0.0375f, 0f, 0f, 0.0375f, 0f),
floatArrayOf(0.0375f, -0.75f, 0f, 0f, -0.75f),
floatArrayOf(0f, 0.0375f, 0f, 0f, 0f),
)
p0Points().forEachIndexed { index, point ->
val actual = scaleP0(point.tuning)
assertArrayEquals(expectedStrength[index], actual.strength, 1e-7f)
assertArrayEquals(expectedRevert[index], actual.revertFactor, 0f)
assertArrayEquals(expectedOutlier[index], actual.outlierDistance, 1e-7f)
}
}
@Test
fun p0InterpolatesSignedFieldsBeforeMultipliersAndClampsOutsideSnrRange() {
val points = p0Points()
fun at(snr: Float) = scaleP0(MgcFullResolutionDenoise.interpolateTuning(snr, points))
val lowMid = at(12.5f)
assertArrayEquals(floatArrayOf(1.1875f, 0.8125f, 0.5f, 0.8125f, 0.09375f), lowMid.strength, 2e-7f)
assertArrayEquals(floatArrayOf(-2f, -2f, -1f, -1f, 0f), lowMid.revertFactor, 0f)
assertArrayEquals(floatArrayOf(0.0375f, -0.375f, 0f, 0.01875f, -0.375f), lowMid.outlierDistance, 1e-7f)
val highMid = at(30f)
assertArrayEquals(floatArrayOf(1.25f, 0.6875f, 0.5625f, 0.875f, 0.03125f), highMid.strength, 2e-7f)
assertArrayEquals(floatArrayOf(-1f, -1f, 0f, -1f, 0f), highMid.revertFactor, 0f)
assertArrayEquals(floatArrayOf(0.01875f, -0.35625f, 0f, 0f, -0.375f), highMid.outlierDistance, 1e-7f)
assertArrayEquals(at(5f).strength, at(0f).strength, 0f)
assertArrayEquals(at(40f).strength, at(60f).strength, 0f)
// Interpolating cannot modify the stored nodes for the next frame.
assertArrayEquals(floatArrayOf(-1f, -1f, -1f, 0f, 0f), points[0].tuning.revertFactor, 0f)
}
private fun p0Points(): List<MgcFullResolutionDenoise.TuningPoint> {
val defaults = agcP0Fixture
return listOf(5f, 20f, 40f).map { snr ->
MgcFullResolutionDenoise.TuningPoint(
snr,
MgcFullResolutionDenoise.applySabreLumaNodeOverrides(
tuning = MgcFullResolutionDenoise.Tuning(FloatArray(5) { 9f }, FloatArray(5), FloatArray(5) { 9f }),
snr = snr,
nodes = defaults.sabreLumaNodes,
revertNodes = defaults.sabreLumaRevertNodes,
outlierNodes = defaults.sabreLumaOutlierNodes,
),
)
}
}
private fun scaleP0(tuning: MgcFullResolutionDenoise.Tuning): MgcFullResolutionDenoise.Tuning {
val defaults = agcP0Fixture
return MgcFullResolutionDenoise.applyCoreDenoiseScales(
tuning = tuning,
globalStrengthScale = 1f,
strengthLevelScales = defaults.lumaStrengthScale.toFloatArray(),
revertLevelScales = defaults.detailReconstructionScale.toFloatArray(),
outlierLevelScales = defaults.outlierRejectionScale.toFloatArray(),
)
}
@Test
fun userAdjustmentNoiseModelMapsCamera2CfaPhasesToCanonicalRgb() {
val metadata = metadata(
@@ -0,0 +1,57 @@
iso,channel,digital_gain,shot,read,shot_bits,read_bits,shot_float,read_float
1,0,1.0,0.0,2.5262367333682478e-06,0000000000000000,3ec5310d54d8600d,0.0,2.526236812627758e-06
1,1,1.0,0.0,2.215462769935089e-06,0000000000000000,3ec295ab89c91020,0.0,2.2154627004056238e-06
1,2,1.0,0.0,2.729228516081322e-06,0000000000000000,3ec6e4f93e80431f,0.0,2.729228526732186e-06
1,3,1.0,0.0,2.6379458077043143e-06,0000000000000000,3ec620f20b64ce42,0.0,2.6379457267466933e-06
16,0,1.0,5.060813009085614e-06,2.537434106825775e-06,3ed53a01aff7a390,3ec54919270fd26d,5.060812782176072e-06,2.5374340566486353e-06
16,1,1.0,5.545413954769139e-05,2.232063367704782e-06,3f0d12edb9ed9135,3ec2b951d0388030,5.545414023799822e-05,2.2320634798234096e-06
16,2,1.0,3.415181748449579e-05,2.750272277656339e-06,3f01e7c7837899a8,3ec7122a2ca6905f,3.415181708987802e-05,2.7502721877681324e-06
16,3,1.0,0.0,2.650634231176215e-06,0000000000000000,3ec63c31943e90c2,0.0,2.650634314704803e-06
50,0,1.0,0.000251119419776129,2.635970993252013e-06,3f307515b2011451,3ec61cb460f7c0ed,0.0002511194325052202,2.6359709863754688e-06
50,1,1.0,0.0002772425400366694,2.378148628078083e-06,3f322b5ba47c064e,3ec3f30908d9f3f0,0.0002772425359580666,2.3781485651852563e-06
50,2,1.0,0.00026770251090078086,2.935457379516488e-06,3f318b4d87852e72,3ec89fd8c2c46b5f,0.00026770250406116247,2.935457359853899e-06
50,3,1.0,0.00026681257184716804,2.7622923577289404e-06,3f317c5f452ecab7,3ec72bfa4887a6c2,0.00026681256713345647,2.762292297120439e-06
100,0,1.0,0.0006129703120806046,2.9653055067086914e-06,3f4415f7b8ce9b1a,3ec8dff1f1386c6d,0.0006129703251644969,2.965305611724034e-06
100,1,1.0,0.0006034019525204604,2.866401503657296e-06,3f43c5b3d3826e34,3ec80b8ce43e1f30,0.0006034019752405584,2.8664014735113597e-06
100,2,1.0,0.000611159412983553,3.5543915434875735e-06,3f4406c6d880059a,3ecdd0ff6a763c5f,0.000611159426625818,3.5543914691515965e-06
100,3,1.0,0.0006624935297684221,3.1354812833730764e-06,3f45b56605a74371,3eca4d65109b68c2,0.0006624935194849968,3.135481392746442e-06
200,0,1.0,0.0013366720966895558,4.282643560535404e-06,3f55e668bc355e7e,3ed1f674191d8d36,0.0013366721104830503,4.282643658370944e-06
200,1,1.0,0.0012557207774880428,4.819413005974149e-06,3f5492dfeb05a228,3ed436ce28e76618,0.0012557207373902202,4.819412879442098e-06
200,2,1.0,0.0012980732171490972,6.0301281993719165e-06,3f55448380fd712e,3ed94acd049ec030,0.0012980732135474682,6.030128133716062e-06
200,3,1.0,0.00145385544561093,4.62823698594962e-06,3f57d1e965e37fce,3ed3698818753861,0.0014538554241880774,4.628237093129428e-06
400,0,1.0,0.002784075665907458,9.551995775842258e-06,3f66cea13de8c030,3ee408304d91749b,0.0027840756811201572,9.551995390211232e-06
400,1,1.0,0.0025603584274232075,1.2631459015241562e-05,3f64f975f6c73c22,3eea7d768204600c,0.0025603584945201874,1.26314589579124e-05
400,2,1.0,0.002671900825480186,1.5933074822909287e-05,3f65e361d53c26f9,3ef0b500908b520c,0.0026719009038060904,1.5933075701468624e-05
400,3,1.0,0.003036579277295946,1.0599259796255795e-05,3f68e02b16019dfc,3ee63a6f2c89a430,0.0030365793500095606,1.0599259439914022e-05
599,0,1.0,0.004224242217279271,1.828159985713574e-05,3f714d7062c70da5,3ef32b6df9e05542,0.004224242176860571,1.8281600205227733e-05
599,1,1.0,0.003858472889108696,2.5573480337644653e-05,3f6f9bcddbe1122b,3efad0d42fe72ee4,0.0038584729190915823,2.5573479433660395e-05
599,2,1.0,0.0040388592957696185,3.233903892045806e-05,3f708b0d096a65eb,3f00f478ea97d8f2,0.004038859158754349,3.233903771615587e-05
599,3,1.0,0.004611389489822537,2.049130401051978e-05,3f72e36470c43900,3ef57c97b0721cc8,0.004611389711499214,2.0491304894676432e-05
600,0,1.0,0.004231479235125361,1.833424946802035e-05,3f7155070edb6891,3ef3399007a04b4e,0.0042314790189266205,1.8334249034523964e-05
600,1,1.0,0.0038649960773583718,2.5651535697353917e-05,3f6fa97bf80ba72f,3efae5c81c501586,0.0038649961352348328,2.5651535906945355e-05
600,2,1.0,0.004045728433811274,3.243798586213824e-05,3f709240f4fccaad,3f0101c0b518b006,0.0040457285940647125,3.243798710172996e-05
600,3,1.0,0.004619303108980962,2.055096448009942e-05,3f72ebb0bc88be09,3ef58c9b8686ae18,0.004619303159415722,2.055096410913393e-05
601,0,1.0016666666666667,0.00423871625297145,1.8395414561384494e-05,3f715c9dbaefc37d,3ef349fb4353fa1d,0.004238716326653957,1.8395414372207597e-05
601,1,1.0016666666666667,0.0038715192656080476,2.5737112070610924e-05,3f6fb72a14363c33,3efafcc0dfcacbca,0.0038715193513780832,2.5737112082424574e-05
601,2,1.0016666666666667,0.00405259757185293,3.254620258719498e-05,3f709974e08f2f6f,3f011047017a020c,0.004052597563713789,3.254620241932571e-05
601,3,1.0016666666666667,0.004627216728139387,2.0619524781045534e-05,3f72f3fd084d4312,3ef59f02f418792f,0.00462721660733223,2.061952545773238e-05
800,0,1.3333333333333333,0.005678882804343263,3.259422127648062e-05,3f7742bd7ec27109,3f0116b8ea559845,0.005678882822394371,3.259422010160051e-05
800,1,1.3333333333333333,0.005169633727293536,4.560273012862918e-05,3f752cc0fca8091e,3f07e8b1e0472f93,0.005169633775949478,4.560273009701632e-05
800,2,1.3333333333333333,0.005419556042142363,5.7667530421579084e-05,3f7632d0ff5b81de,3f0e3c0141f3000a,0.005419556051492691,5.76675301999785e-05
800,3,1.3333333333333333,0.0062020269406659785,3.6535047964621195e-05,3f79674bee10ad14,3f0327a6b077b732,0.0062020267359912395,3.653504973044619e-05
1600,0,2.6666666666666665,0.011468497081214873,0.00013037688510592247,3f877ccb9f2f4976,3f2116b8ea559845,0.011468497104942799,0.00013037688040640205
1600,1,2.6666666666666665,0.010388184327034195,0.00018241092051451673,3f8546667f986f9d,3f27e8b1e0472f93,0.01038818433880806,0.00018241092038806528
1600,2,2.6666666666666665,0.010914866475466717,0.00023067012168631634,3f865a88946b2f50,3f2e3c0141f3000a,0.01091486681252718,0.000230670120799914
1600,3,2.6666666666666665,0.012532922267406042,0.00014614019185848478,3f89aadc5a18349f,3f2327a6b077b732,0.012532922439277172,0.00014614019892178476
3200,0,5.333333333333333,0.02304772563495809,0.0005215075404236899,3f9799d2af65b5ac,3f4116b8ea559845,0.02304772473871708,0.0005215075216256082
3200,1,5.333333333333333,0.02082528552651551,0.0007296436820580669,3f9553394110a2dc,3f47e8b1e0472f93,0.020825285464525223,0.0007296436815522611
3200,2,5.333333333333333,0.021905487342115424,0.0009226804867452653,3f966e645ef30609,3f4e3c0141f3000a,0.021905487403273582,0.000922680483199656
3200,3,5.333333333333333,0.02519471292088617,0.0005845607674339391,3f99cca4901bf865,3f4327a6b077b732,0.025194713845849037,0.000584560795687139
6400,0,10.666666666666666,0.04620618274244453,0.0020860301616947596,3fa7a8563780ebc7,3f6116b8ea559845,0.04620618373155594,0.002086030086502433
6400,1,10.666666666666666,0.041699487925478146,0.0029185747282322676,3fa559a2a1ccbc7c,3f67e8b1e0472f93,0.04169948771595955,0.0029185747262090445
6400,2,10.666666666666666,0.04388672907541284,0.0036907219469810614,3fa678524436f166,3f6e3c0141f3000a,0.04388672858476639,0.003690721932798624
6400,3,10.666666666666666,0.05051829422784643,0.0023382430697357565,3fa9dd88ab1dda48,3f6327a6b077b732,0.05051829293370247,0.002338243182748556
12800,0,21.333333333333332,0.09252309695741741,0.008344120646779038,3fb7af97fb8e86d5,3f8116b8ea559845,0.09252309799194336,0.008344120346009731
12800,1,21.333333333333332,0.0834478927234034,0.01167429891292907,3fb55cd7522ac94b,3f87e8b1e0472f93,0.0834478959441185,0.011674298904836178
12800,2,21.333333333333332,0.08784921254200767,0.014762887787924246,3fb67d4936d8e714,3f8e3c0141f3000a,0.0878492146730423,0.014762887731194496
12800,3,21.333333333333332,0.10116545684176693,0.009352972278943026,3fb9e5fab89ecb39,3f8327a6b077b732,0.10116545855998993,0.009352972730994225
1 iso channel digital_gain shot read shot_bits read_bits shot_float read_float
2 1 0 1.0 0.0 2.5262367333682478e-06 0000000000000000 3ec5310d54d8600d 0.0 2.526236812627758e-06
3 1 1 1.0 0.0 2.215462769935089e-06 0000000000000000 3ec295ab89c91020 0.0 2.2154627004056238e-06
4 1 2 1.0 0.0 2.729228516081322e-06 0000000000000000 3ec6e4f93e80431f 0.0 2.729228526732186e-06
5 1 3 1.0 0.0 2.6379458077043143e-06 0000000000000000 3ec620f20b64ce42 0.0 2.6379457267466933e-06
6 16 0 1.0 5.060813009085614e-06 2.537434106825775e-06 3ed53a01aff7a390 3ec54919270fd26d 5.060812782176072e-06 2.5374340566486353e-06
7 16 1 1.0 5.545413954769139e-05 2.232063367704782e-06 3f0d12edb9ed9135 3ec2b951d0388030 5.545414023799822e-05 2.2320634798234096e-06
8 16 2 1.0 3.415181748449579e-05 2.750272277656339e-06 3f01e7c7837899a8 3ec7122a2ca6905f 3.415181708987802e-05 2.7502721877681324e-06
9 16 3 1.0 0.0 2.650634231176215e-06 0000000000000000 3ec63c31943e90c2 0.0 2.650634314704803e-06
10 50 0 1.0 0.000251119419776129 2.635970993252013e-06 3f307515b2011451 3ec61cb460f7c0ed 0.0002511194325052202 2.6359709863754688e-06
11 50 1 1.0 0.0002772425400366694 2.378148628078083e-06 3f322b5ba47c064e 3ec3f30908d9f3f0 0.0002772425359580666 2.3781485651852563e-06
12 50 2 1.0 0.00026770251090078086 2.935457379516488e-06 3f318b4d87852e72 3ec89fd8c2c46b5f 0.00026770250406116247 2.935457359853899e-06
13 50 3 1.0 0.00026681257184716804 2.7622923577289404e-06 3f317c5f452ecab7 3ec72bfa4887a6c2 0.00026681256713345647 2.762292297120439e-06
14 100 0 1.0 0.0006129703120806046 2.9653055067086914e-06 3f4415f7b8ce9b1a 3ec8dff1f1386c6d 0.0006129703251644969 2.965305611724034e-06
15 100 1 1.0 0.0006034019525204604 2.866401503657296e-06 3f43c5b3d3826e34 3ec80b8ce43e1f30 0.0006034019752405584 2.8664014735113597e-06
16 100 2 1.0 0.000611159412983553 3.5543915434875735e-06 3f4406c6d880059a 3ecdd0ff6a763c5f 0.000611159426625818 3.5543914691515965e-06
17 100 3 1.0 0.0006624935297684221 3.1354812833730764e-06 3f45b56605a74371 3eca4d65109b68c2 0.0006624935194849968 3.135481392746442e-06
18 200 0 1.0 0.0013366720966895558 4.282643560535404e-06 3f55e668bc355e7e 3ed1f674191d8d36 0.0013366721104830503 4.282643658370944e-06
19 200 1 1.0 0.0012557207774880428 4.819413005974149e-06 3f5492dfeb05a228 3ed436ce28e76618 0.0012557207373902202 4.819412879442098e-06
20 200 2 1.0 0.0012980732171490972 6.0301281993719165e-06 3f55448380fd712e 3ed94acd049ec030 0.0012980732135474682 6.030128133716062e-06
21 200 3 1.0 0.00145385544561093 4.62823698594962e-06 3f57d1e965e37fce 3ed3698818753861 0.0014538554241880774 4.628237093129428e-06
22 400 0 1.0 0.002784075665907458 9.551995775842258e-06 3f66cea13de8c030 3ee408304d91749b 0.0027840756811201572 9.551995390211232e-06
23 400 1 1.0 0.0025603584274232075 1.2631459015241562e-05 3f64f975f6c73c22 3eea7d768204600c 0.0025603584945201874 1.26314589579124e-05
24 400 2 1.0 0.002671900825480186 1.5933074822909287e-05 3f65e361d53c26f9 3ef0b500908b520c 0.0026719009038060904 1.5933075701468624e-05
25 400 3 1.0 0.003036579277295946 1.0599259796255795e-05 3f68e02b16019dfc 3ee63a6f2c89a430 0.0030365793500095606 1.0599259439914022e-05
26 599 0 1.0 0.004224242217279271 1.828159985713574e-05 3f714d7062c70da5 3ef32b6df9e05542 0.004224242176860571 1.8281600205227733e-05
27 599 1 1.0 0.003858472889108696 2.5573480337644653e-05 3f6f9bcddbe1122b 3efad0d42fe72ee4 0.0038584729190915823 2.5573479433660395e-05
28 599 2 1.0 0.0040388592957696185 3.233903892045806e-05 3f708b0d096a65eb 3f00f478ea97d8f2 0.004038859158754349 3.233903771615587e-05
29 599 3 1.0 0.004611389489822537 2.049130401051978e-05 3f72e36470c43900 3ef57c97b0721cc8 0.004611389711499214 2.0491304894676432e-05
30 600 0 1.0 0.004231479235125361 1.833424946802035e-05 3f7155070edb6891 3ef3399007a04b4e 0.0042314790189266205 1.8334249034523964e-05
31 600 1 1.0 0.0038649960773583718 2.5651535697353917e-05 3f6fa97bf80ba72f 3efae5c81c501586 0.0038649961352348328 2.5651535906945355e-05
32 600 2 1.0 0.004045728433811274 3.243798586213824e-05 3f709240f4fccaad 3f0101c0b518b006 0.0040457285940647125 3.243798710172996e-05
33 600 3 1.0 0.004619303108980962 2.055096448009942e-05 3f72ebb0bc88be09 3ef58c9b8686ae18 0.004619303159415722 2.055096410913393e-05
34 601 0 1.0016666666666667 0.00423871625297145 1.8395414561384494e-05 3f715c9dbaefc37d 3ef349fb4353fa1d 0.004238716326653957 1.8395414372207597e-05
35 601 1 1.0016666666666667 0.0038715192656080476 2.5737112070610924e-05 3f6fb72a14363c33 3efafcc0dfcacbca 0.0038715193513780832 2.5737112082424574e-05
36 601 2 1.0016666666666667 0.00405259757185293 3.254620258719498e-05 3f709974e08f2f6f 3f011047017a020c 0.004052597563713789 3.254620241932571e-05
37 601 3 1.0016666666666667 0.004627216728139387 2.0619524781045534e-05 3f72f3fd084d4312 3ef59f02f418792f 0.00462721660733223 2.061952545773238e-05
38 800 0 1.3333333333333333 0.005678882804343263 3.259422127648062e-05 3f7742bd7ec27109 3f0116b8ea559845 0.005678882822394371 3.259422010160051e-05
39 800 1 1.3333333333333333 0.005169633727293536 4.560273012862918e-05 3f752cc0fca8091e 3f07e8b1e0472f93 0.005169633775949478 4.560273009701632e-05
40 800 2 1.3333333333333333 0.005419556042142363 5.7667530421579084e-05 3f7632d0ff5b81de 3f0e3c0141f3000a 0.005419556051492691 5.76675301999785e-05
41 800 3 1.3333333333333333 0.0062020269406659785 3.6535047964621195e-05 3f79674bee10ad14 3f0327a6b077b732 0.0062020267359912395 3.653504973044619e-05
42 1600 0 2.6666666666666665 0.011468497081214873 0.00013037688510592247 3f877ccb9f2f4976 3f2116b8ea559845 0.011468497104942799 0.00013037688040640205
43 1600 1 2.6666666666666665 0.010388184327034195 0.00018241092051451673 3f8546667f986f9d 3f27e8b1e0472f93 0.01038818433880806 0.00018241092038806528
44 1600 2 2.6666666666666665 0.010914866475466717 0.00023067012168631634 3f865a88946b2f50 3f2e3c0141f3000a 0.01091486681252718 0.000230670120799914
45 1600 3 2.6666666666666665 0.012532922267406042 0.00014614019185848478 3f89aadc5a18349f 3f2327a6b077b732 0.012532922439277172 0.00014614019892178476
46 3200 0 5.333333333333333 0.02304772563495809 0.0005215075404236899 3f9799d2af65b5ac 3f4116b8ea559845 0.02304772473871708 0.0005215075216256082
47 3200 1 5.333333333333333 0.02082528552651551 0.0007296436820580669 3f9553394110a2dc 3f47e8b1e0472f93 0.020825285464525223 0.0007296436815522611
48 3200 2 5.333333333333333 0.021905487342115424 0.0009226804867452653 3f966e645ef30609 3f4e3c0141f3000a 0.021905487403273582 0.000922680483199656
49 3200 3 5.333333333333333 0.02519471292088617 0.0005845607674339391 3f99cca4901bf865 3f4327a6b077b732 0.025194713845849037 0.000584560795687139
50 6400 0 10.666666666666666 0.04620618274244453 0.0020860301616947596 3fa7a8563780ebc7 3f6116b8ea559845 0.04620618373155594 0.002086030086502433
51 6400 1 10.666666666666666 0.041699487925478146 0.0029185747282322676 3fa559a2a1ccbc7c 3f67e8b1e0472f93 0.04169948771595955 0.0029185747262090445
52 6400 2 10.666666666666666 0.04388672907541284 0.0036907219469810614 3fa678524436f166 3f6e3c0141f3000a 0.04388672858476639 0.003690721932798624
53 6400 3 10.666666666666666 0.05051829422784643 0.0023382430697357565 3fa9dd88ab1dda48 3f6327a6b077b732 0.05051829293370247 0.002338243182748556
54 12800 0 21.333333333333332 0.09252309695741741 0.008344120646779038 3fb7af97fb8e86d5 3f8116b8ea559845 0.09252309799194336 0.008344120346009731
55 12800 1 21.333333333333332 0.0834478927234034 0.01167429891292907 3fb55cd7522ac94b 3f87e8b1e0472f93 0.0834478959441185 0.011674298904836178
56 12800 2 21.333333333333332 0.08784921254200767 0.014762887787924246 3fb67d4936d8e714 3f8e3c0141f3000a 0.0878492146730423 0.014762887731194496
57 12800 3 21.333333333333332 0.10116545684176693 0.009352972278943026 3fb9e5fab89ecb39 3f8327a6b077b732 0.10116545855998993 0.009352972730994225
@@ -0,0 +1,181 @@
snr_bits,field,level,value_bits
00000000,strength,0,3f19999a
00000000,strength,1,3ee66666
00000000,strength,2,3e99999a
00000000,strength,3,3e19999a
00000000,strength,4,3e19999a
00000000,revert,0,bf800000
00000000,revert,1,bf800000
00000000,revert,2,bf800000
00000000,revert,3,00000000
00000000,revert,4,00000000
00000000,outlier,0,3d4ccccd
00000000,outlier,1,00000000
00000000,outlier,2,00000000
00000000,outlier,3,3d4ccccd
00000000,outlier,4,00000000
40a00000,strength,0,3f19999a
40a00000,strength,1,3ee66666
40a00000,strength,2,3e99999a
40a00000,strength,3,3e19999a
40a00000,strength,4,3e19999a
40a00000,revert,0,bf800000
40a00000,revert,1,bf800000
40a00000,revert,2,bf800000
40a00000,revert,3,00000000
40a00000,revert,4,00000000
40a00000,outlier,0,3d4ccccd
40a00000,outlier,1,00000000
40a00000,outlier,2,00000000
40a00000,outlier,3,3d4ccccd
40a00000,outlier,4,00000000
41480000,strength,0,3ef33334
41480000,strength,1,3ea66666
41480000,strength,2,3e4ccccd
41480000,strength,3,3ea66666
41480000,strength,4,3d99999a
41480000,revert,0,bf800000
41480000,revert,1,bf800000
41480000,revert,2,bf000000
41480000,revert,3,bf000000
41480000,revert,4,00000000
41480000,outlier,0,3d4ccccd
41480000,outlier,1,bf000000
41480000,outlier,2,00000000
41480000,outlier,3,3ccccccd
41480000,outlier,4,bf000000
419fffff,strength,0,3eb33334
419fffff,strength,1,3e4ccccf
419fffff,strength,2,3dccccd0
419fffff,strength,3,3effffff
419fffff,strength,4,3299999a
419fffff,revert,0,bf800000
419fffff,revert,1,bf800000
419fffff,revert,2,b4000000
419fffff,revert,3,bf7ffffe
419fffff,revert,4,00000000
419fffff,outlier,0,3d4ccccd
419fffff,outlier,1,bf7ffffe
419fffff,outlier,2,00000000
419fffff,outlier,3,31cccccd
419fffff,outlier,4,bf7ffffe
41a00000,strength,0,3eb33333
41a00000,strength,1,3e4ccccd
41a00000,strength,2,3dcccccd
41a00000,strength,3,3f000000
41a00000,strength,4,00000000
41a00000,revert,0,bf800000
41a00000,revert,1,bf800000
41a00000,revert,2,00000000
41a00000,revert,3,bf800000
41a00000,revert,4,00000000
41a00000,outlier,0,3d4ccccd
41a00000,outlier,1,bf800000
41a00000,outlier,2,00000000
41a00000,outlier,3,00000000
41a00000,outlier,4,bf800000
41a00001,strength,0,3eb33334
41a00001,strength,1,3e4ccccd
41a00001,strength,2,3dcccccf
41a00001,strength,3,3effffff
41a00001,strength,4,31a3d70b
41a00001,revert,0,bf7ffffe
41a00001,revert,1,bf7ffffe
41a00001,revert,2,00000000
41a00001,revert,3,bf7ffffe
41a00001,revert,4,00000000
41a00001,outlier,0,3d4ccccb
41a00001,outlier,1,bf7ffffe
41a00001,outlier,2,00000000
41a00001,outlier,3,00000000
41a00001,outlier,4,bf7ffffe
41eb047d,strength,0,3efb3782
41eb047d,strength,1,3e8a688e
41eb047d,strength,2,3e5e6d95
41eb047d,strength,3,3eb7fbb2
41eb047d,strength,4,3cc00b7e
41eb047d,revert,0,bf07f8d2
41eb047d,revert,1,bf07f8d2
41eb047d,revert,2,00000000
41eb047d,revert,3,bf07f8d2
41eb047d,revert,4,00000000
41eb047d,outlier,0,3cd98e1d
41eb047d,outlier,1,bf01f876
41eb047d,outlier,2,00000000
41eb047d,outlier,3,00000000
41eb047d,outlier,4,bf07f8d2
41f00000,strength,0,3f000000
41f00000,strength,1,3e8ccccd
41f00000,strength,2,3e666666
41f00000,strength,3,3eb33333
41f00000,strength,4,3ccccccd
41f00000,revert,0,bf000000
41f00000,revert,1,bf000000
41f00000,revert,2,00000000
41f00000,revert,3,bf000000
41f00000,revert,4,00000000
41f00000,outlier,0,3ccccccd
41f00000,outlier,1,bef33333
41f00000,outlier,2,00000000
41f00000,outlier,3,00000000
41f00000,outlier,4,bf000000
421c30c3,strength,0,3f22be2b
421c30c3,strength,1,3eaf8af9
421c30c3,strength,2,3ead1ad2
421c30c3,strength,3,3e5b6db7
421c30c3,strength,4,3d430c31
421c30c3,revert,0,bd430c30
421c30c3,revert,1,bd430c30
421c30c3,revert,2,00000000
421c30c3,revert,3,bd430c30
421c30c3,revert,4,00000000
421c30c3,outlier,0,3b1c09c0
421c30c3,outlier,1,31800000
421c30c3,outlier,2,00000000
421c30c3,outlier,3,00000000
421c30c3,outlier,4,bd430c30
421fffff,strength,0,3f266665
421fffff,strength,1,3eb33332
421fffff,strength,2,3eb33332
421fffff,strength,3,3e4cccd1
421fffff,strength,4,3d4ccccb
421fffff,revert,0,b4400000
421fffff,revert,1,b4400000
421fffff,revert,2,00000000
421fffff,revert,3,b4400000
421fffff,revert,4,00000000
421fffff,outlier,0,3219999a
421fffff,outlier,1,3d4ccc9b
421fffff,outlier,2,00000000
421fffff,outlier,3,00000000
421fffff,outlier,4,b4400000
42200000,strength,0,3f266666
42200000,strength,1,3eb33333
42200000,strength,2,3eb33333
42200000,strength,3,3e4ccccd
42200000,strength,4,3d4ccccd
42200000,revert,0,00000000
42200000,revert,1,00000000
42200000,revert,2,00000000
42200000,revert,3,00000000
42200000,revert,4,00000000
42200000,outlier,0,00000000
42200000,outlier,1,3d4ccccd
42200000,outlier,2,00000000
42200000,outlier,3,00000000
42200000,outlier,4,00000000
42700000,strength,0,3f266666
42700000,strength,1,3eb33333
42700000,strength,2,3eb33333
42700000,strength,3,3e4ccccd
42700000,strength,4,3d4ccccd
42700000,revert,0,00000000
42700000,revert,1,00000000
42700000,revert,2,00000000
42700000,revert,3,00000000
42700000,revert,4,00000000
42700000,outlier,0,00000000
42700000,outlier,1,3d4ccccd
42700000,outlier,2,00000000
42700000,outlier,3,00000000
42700000,outlier,4,00000000
1 snr_bits field level value_bits
2 00000000 strength 0 3f19999a
3 00000000 strength 1 3ee66666
4 00000000 strength 2 3e99999a
5 00000000 strength 3 3e19999a
6 00000000 strength 4 3e19999a
7 00000000 revert 0 bf800000
8 00000000 revert 1 bf800000
9 00000000 revert 2 bf800000
10 00000000 revert 3 00000000
11 00000000 revert 4 00000000
12 00000000 outlier 0 3d4ccccd
13 00000000 outlier 1 00000000
14 00000000 outlier 2 00000000
15 00000000 outlier 3 3d4ccccd
16 00000000 outlier 4 00000000
17 40a00000 strength 0 3f19999a
18 40a00000 strength 1 3ee66666
19 40a00000 strength 2 3e99999a
20 40a00000 strength 3 3e19999a
21 40a00000 strength 4 3e19999a
22 40a00000 revert 0 bf800000
23 40a00000 revert 1 bf800000
24 40a00000 revert 2 bf800000
25 40a00000 revert 3 00000000
26 40a00000 revert 4 00000000
27 40a00000 outlier 0 3d4ccccd
28 40a00000 outlier 1 00000000
29 40a00000 outlier 2 00000000
30 40a00000 outlier 3 3d4ccccd
31 40a00000 outlier 4 00000000
32 41480000 strength 0 3ef33334
33 41480000 strength 1 3ea66666
34 41480000 strength 2 3e4ccccd
35 41480000 strength 3 3ea66666
36 41480000 strength 4 3d99999a
37 41480000 revert 0 bf800000
38 41480000 revert 1 bf800000
39 41480000 revert 2 bf000000
40 41480000 revert 3 bf000000
41 41480000 revert 4 00000000
42 41480000 outlier 0 3d4ccccd
43 41480000 outlier 1 bf000000
44 41480000 outlier 2 00000000
45 41480000 outlier 3 3ccccccd
46 41480000 outlier 4 bf000000
47 419fffff strength 0 3eb33334
48 419fffff strength 1 3e4ccccf
49 419fffff strength 2 3dccccd0
50 419fffff strength 3 3effffff
51 419fffff strength 4 3299999a
52 419fffff revert 0 bf800000
53 419fffff revert 1 bf800000
54 419fffff revert 2 b4000000
55 419fffff revert 3 bf7ffffe
56 419fffff revert 4 00000000
57 419fffff outlier 0 3d4ccccd
58 419fffff outlier 1 bf7ffffe
59 419fffff outlier 2 00000000
60 419fffff outlier 3 31cccccd
61 419fffff outlier 4 bf7ffffe
62 41a00000 strength 0 3eb33333
63 41a00000 strength 1 3e4ccccd
64 41a00000 strength 2 3dcccccd
65 41a00000 strength 3 3f000000
66 41a00000 strength 4 00000000
67 41a00000 revert 0 bf800000
68 41a00000 revert 1 bf800000
69 41a00000 revert 2 00000000
70 41a00000 revert 3 bf800000
71 41a00000 revert 4 00000000
72 41a00000 outlier 0 3d4ccccd
73 41a00000 outlier 1 bf800000
74 41a00000 outlier 2 00000000
75 41a00000 outlier 3 00000000
76 41a00000 outlier 4 bf800000
77 41a00001 strength 0 3eb33334
78 41a00001 strength 1 3e4ccccd
79 41a00001 strength 2 3dcccccf
80 41a00001 strength 3 3effffff
81 41a00001 strength 4 31a3d70b
82 41a00001 revert 0 bf7ffffe
83 41a00001 revert 1 bf7ffffe
84 41a00001 revert 2 00000000
85 41a00001 revert 3 bf7ffffe
86 41a00001 revert 4 00000000
87 41a00001 outlier 0 3d4ccccb
88 41a00001 outlier 1 bf7ffffe
89 41a00001 outlier 2 00000000
90 41a00001 outlier 3 00000000
91 41a00001 outlier 4 bf7ffffe
92 41eb047d strength 0 3efb3782
93 41eb047d strength 1 3e8a688e
94 41eb047d strength 2 3e5e6d95
95 41eb047d strength 3 3eb7fbb2
96 41eb047d strength 4 3cc00b7e
97 41eb047d revert 0 bf07f8d2
98 41eb047d revert 1 bf07f8d2
99 41eb047d revert 2 00000000
100 41eb047d revert 3 bf07f8d2
101 41eb047d revert 4 00000000
102 41eb047d outlier 0 3cd98e1d
103 41eb047d outlier 1 bf01f876
104 41eb047d outlier 2 00000000
105 41eb047d outlier 3 00000000
106 41eb047d outlier 4 bf07f8d2
107 41f00000 strength 0 3f000000
108 41f00000 strength 1 3e8ccccd
109 41f00000 strength 2 3e666666
110 41f00000 strength 3 3eb33333
111 41f00000 strength 4 3ccccccd
112 41f00000 revert 0 bf000000
113 41f00000 revert 1 bf000000
114 41f00000 revert 2 00000000
115 41f00000 revert 3 bf000000
116 41f00000 revert 4 00000000
117 41f00000 outlier 0 3ccccccd
118 41f00000 outlier 1 bef33333
119 41f00000 outlier 2 00000000
120 41f00000 outlier 3 00000000
121 41f00000 outlier 4 bf000000
122 421c30c3 strength 0 3f22be2b
123 421c30c3 strength 1 3eaf8af9
124 421c30c3 strength 2 3ead1ad2
125 421c30c3 strength 3 3e5b6db7
126 421c30c3 strength 4 3d430c31
127 421c30c3 revert 0 bd430c30
128 421c30c3 revert 1 bd430c30
129 421c30c3 revert 2 00000000
130 421c30c3 revert 3 bd430c30
131 421c30c3 revert 4 00000000
132 421c30c3 outlier 0 3b1c09c0
133 421c30c3 outlier 1 31800000
134 421c30c3 outlier 2 00000000
135 421c30c3 outlier 3 00000000
136 421c30c3 outlier 4 bd430c30
137 421fffff strength 0 3f266665
138 421fffff strength 1 3eb33332
139 421fffff strength 2 3eb33332
140 421fffff strength 3 3e4cccd1
141 421fffff strength 4 3d4ccccb
142 421fffff revert 0 b4400000
143 421fffff revert 1 b4400000
144 421fffff revert 2 00000000
145 421fffff revert 3 b4400000
146 421fffff revert 4 00000000
147 421fffff outlier 0 3219999a
148 421fffff outlier 1 3d4ccc9b
149 421fffff outlier 2 00000000
150 421fffff outlier 3 00000000
151 421fffff outlier 4 b4400000
152 42200000 strength 0 3f266666
153 42200000 strength 1 3eb33333
154 42200000 strength 2 3eb33333
155 42200000 strength 3 3e4ccccd
156 42200000 strength 4 3d4ccccd
157 42200000 revert 0 00000000
158 42200000 revert 1 00000000
159 42200000 revert 2 00000000
160 42200000 revert 3 00000000
161 42200000 revert 4 00000000
162 42200000 outlier 0 00000000
163 42200000 outlier 1 3d4ccccd
164 42200000 outlier 2 00000000
165 42200000 outlier 3 00000000
166 42200000 outlier 4 00000000
167 42700000 strength 0 3f266666
168 42700000 strength 1 3eb33333
169 42700000 strength 2 3eb33333
170 42700000 strength 3 3e4ccccd
171 42700000 strength 4 3d4ccccd
172 42700000 revert 0 00000000
173 42700000 revert 1 00000000
174 42700000 revert 2 00000000
175 42700000 revert 3 00000000
176 42700000 revert 4 00000000
177 42700000 outlier 0 00000000
178 42700000 outlier 1 3d4ccccd
179 42700000 outlier 2 00000000
180 42700000 outlier 3 00000000
181 42700000 outlier 4 00000000