feat: detail-adaptive Sabre rejection

This commit is contained in:
Hinnka committed 2026-09-19 09:05:46 +08:00
1 parent a41d03dbf9
commit f64681a651
5 files changed
+279 -45

No files matched your search

@@ -408,7 +408,26 @@ internal object GlesMgcRawSabreShaders {
motionPrior) {
robustnessBoost = uExtraMotionRobustnessBoost;
}
pixelVariance *= 2.0;
// Keep the symmetric V25 bicubic guides: an identical texture must not reject
// itself. Tighten only the measured-structure allowance, not the noise floor or
// the color-difference thresholds shared with Spatial/YUV. All values here have
// already been converted from guide alpha and scaled for the bicubic filter.
float detailNoise = greenOnly
? max(referenceNoise.y, currentNoise.y)
: max(
dot(referenceNoise, vec3(1.0 / 3.0)),
dot(currentNoise, vec3(1.0 / 3.0))
);
float detailConfidence = smoothstep(
${MgcSabreRejectionTuning.SABRE_DETAIL_VARIANCE_RATIO_START} * detailNoise,
${MgcSabreRejectionTuning.SABRE_DETAIL_VARIANCE_RATIO_END} * detailNoise,
pixelVariance
);
pixelVariance *= mix(
2.0,
${MgcSabreRejectionTuning.SABRE_DETAIL_VARIANCE_SCALE},
detailConfidence
);
vec3 combinedNoise = referenceNoise + currentNoise;
vec3 difference = current.rgb - reference.rgb;
vec3 differenceSquared = max(
@@ -2222,6 +2222,9 @@ internal class GlesMgcRawSpatialStacker(
"forceReferenceColorRgb=${sabreKernelParameters.forceReferenceColorRgb} " +
"mergeGradientThreshold=${PhotonCoreImagingTuning.fusion.mergeGradientThreshold ?: "adaptive"} " +
"guideColorSpace=sqrt noiseLut=qmc64x10 rejectionGuideFilter=bicubic-both-frames " +
"detailVarianceScale=${MgcSabreRejectionTuning.SABRE_DETAIL_VARIANCE_SCALE} " +
"detailVarianceNoiseRatio=${MgcSabreRejectionTuning.SABRE_DETAIL_VARIANCE_RATIO_START}.." +
"${MgcSabreRejectionTuning.SABRE_DETAIL_VARIANCE_RATIO_END} " +
"alignmentInputGain=${referenceCalibration.alignmentGain} " +
"alignmentDomain=signed-s16",
)
@@ -1,6 +1,6 @@
package com.hinnka.mycamera.processor
/** MGC 9.7.047 V25 Sabre/Spatial rejection defaults and runtime resolution scaling. */
/** MGC V25 rejection defaults, resolution scaling, and Photon Classic-Sabre detail tuning. */
internal object MgcSabreRejectionTuning {
data class FlowVariationThresholds(
val unblockerReduction: Float,
@@ -12,6 +12,17 @@ internal object MgcSabreRejectionTuning {
const val EXTRA_MOTION_ROBUSTNESS_BOOST = 6f
const val MOTION_ROBUSTNESS_VARIANCE_THRESHOLD = 25f
/**
* Photon Classic-Sabre tuning, not shared with Spatial/YUV rejection. Keep V25's measured
* variance allowance near the noise floor, then tighten it only when BOTH guides contain
* structure well above BOTH noise estimates. The bicubic comparison and noise floor remain
* unchanged; this reduces admission of residual misalignment without restoring asymmetric
* guide filtering. Ratios refer to variance, not amplitude SNR.
*/
const val SABRE_DETAIL_VARIANCE_RATIO_START = 8f
const val SABRE_DETAIL_VARIANCE_RATIO_END = 32f
const val SABRE_DETAIL_VARIANCE_SCALE = 1.25f
private const val REFERENCE_GUIDE_WIDTH = 2016f
private const val BASE_FLOW_VARIATION_THRESHOLD = 1e-4f
/**