Revert "feat: expo lift for google LTM"

This reverts commit 26bf3d418e.
This commit is contained in:
Hinnka committed 2026-07-17 21:34:56 +08:00
1 parent adaa5f42ce
commit d12904db82
8 files changed
+41 -101

No files matched your search

@@ -3647,7 +3647,6 @@ object GalleryManager {
capturePreviewThumbnail = capturePreviewThumbnail.takeIf {
viewfinderMatchEnabled
},
rawRenderingEngine = metadata.rawRenderingEngine,
profileToneMapMode = profileToneMapMode,
statsBounds = statsBounds,
rawBlackPointCorrection = metadata.rawBlackPointCorrection ?: 0f,
@@ -17,7 +17,6 @@ internal object DngHdrProfileGainTableGenerator {
private const val TAG = "DngHdrProfileGainTableGenerator"
const val CELL_STATS_FLOAT_STRIDE = 8
internal const val ADOBE_PROFILE_CAPTURE_BASELINE_OFFSET_EV = 0.7f
private const val MAP_INPUT_WEIGHT_COUNT = 5
private const val DEFAULT_TABLE_POINTS = 257
@@ -66,8 +65,8 @@ internal object DngHdrProfileGainTableGenerator {
)
internal val PHOTON_FUSION_PARAMETERS = HdrExposureFusionParameters(
autoExposureTarget = AUTO_EXPOSURE_TARGET,
wellExposedKey = WELL_EXPOSED_KEY,
autoExposureTarget = 0.35f,
wellExposedKey = 0.5f,
maxExposureGain = MAX_LTM_GAIN,
highlightFusionStart = HIGHLIGHT_FUSION_START,
highlightFusionEnd = HIGHLIGHT_FUSION_END,
@@ -755,7 +755,6 @@ class RawDemosaicProcessor {
cropRegion: Rect?,
rotation: Int,
request: RawExposurePreviewRequest?,
captureBaselineExposureOffsetEv: Float,
profileToneMapMode: RawProfileToneMapMode,
statsBounds: Rect?,
rawBlackPointCorrection: Float = 0f,
@@ -793,7 +792,6 @@ class RawDemosaicProcessor {
),
rawBlackBorderCrop = rawBlackBorderCrop,
exposurePreviewRequest = request,
captureBaselineExposureOffsetEv = captureBaselineExposureOffsetEv,
captureProfileToneMapMode = profileToneMapMode,
captureProfileStatsBounds = statsBounds,
onCaptureProfilePrepared = { preparedResult = it },
@@ -1019,7 +1017,6 @@ class RawDemosaicProcessor {
onMetadata: ((RawMetadata) -> Unit)? = null,
includeHdrReference: Boolean = false,
exposurePreviewRequest: RawExposurePreviewRequest? = null,
captureBaselineExposureOffsetEv: Float = 0f,
captureProfileToneMapMode: RawProfileToneMapMode? = null,
captureProfileStatsBounds: Rect? = null,
onCaptureProfilePrepared: ((RawDngCaptureProfileResult?) -> Unit)? = null,
@@ -1795,9 +1792,7 @@ class RawDemosaicProcessor {
)
}
val finalBaselineExposureEv = DngBaselineExposure.sanitize(
actualMetadata.baselineExposure +
(solvedExposureEv ?: 0f) +
captureBaselineExposureOffsetEv
actualMetadata.baselineExposure + (solvedExposureEv ?: 0f)
)
val captureProfileGainTableMap = when (captureProfileToneMapMode) {
RawProfileToneMapMode.Photon,
@@ -1823,7 +1818,6 @@ class RawDemosaicProcessor {
} else {
RawDngCaptureProfileResult(
exposureOffsetEv = solvedExposureEv,
captureBaselineExposureOffsetEv = captureBaselineExposureOffsetEv,
profileGainTableMap = captureProfileGainTableMap,
)
}
@@ -25,7 +25,6 @@ data class RawDngCaptureProfileInput(
data class RawDngCaptureProfileResult(
val exposureOffsetEv: Float?,
val captureBaselineExposureOffsetEv: Float,
val profileGainTableMap: DngProfileGainTableMap?,
)
@@ -33,7 +33,6 @@ internal object RawViewfinderExposureMatcher {
cropRegion: Rect?,
rotation: Int,
capturePreviewThumbnail: Bitmap?,
rawRenderingEngine: RawRenderingEngine,
profileToneMapMode: RawProfileToneMapMode,
statsBounds: Rect?,
rawBlackPointCorrection: Float = 0f,
@@ -53,18 +52,6 @@ internal object RawViewfinderExposureMatcher {
solve = { renderSample -> solve(it, renderSample) },
)
}
val captureBaselineExposureOffsetEv = firstCaptureDngBaselineExposureOffsetEv(
rawRenderingEngine = rawRenderingEngine,
profileToneMapMode = profileToneMapMode,
)
if (captureBaselineExposureOffsetEv != 0f) {
PLog.i(
TAG,
"Applying first-capture DNG BaselineExposure offset: " +
"engine=$rawRenderingEngine curve=$profileToneMapMode " +
"offsetEv=$captureBaselineExposureOffsetEv",
)
}
return renderer.prepareCaptureProfile(
context = context,
input = input,
@@ -72,7 +59,6 @@ internal object RawViewfinderExposureMatcher {
cropRegion = cropRegion,
rotation = rotation,
request = request,
captureBaselineExposureOffsetEv = captureBaselineExposureOffsetEv,
profileToneMapMode = profileToneMapMode,
statsBounds = statsBounds,
rawBlackPointCorrection = rawBlackPointCorrection,
@@ -83,19 +69,6 @@ internal object RawViewfinderExposureMatcher {
)
}
internal fun firstCaptureDngBaselineExposureOffsetEv(
rawRenderingEngine: RawRenderingEngine,
profileToneMapMode: RawProfileToneMapMode,
): Float {
val usesHdrProfileCurve = profileToneMapMode == RawProfileToneMapMode.GooglePixel ||
profileToneMapMode == RawProfileToneMapMode.Photon
return if (rawRenderingEngine == RawRenderingEngine.AdobeCurve && usesHdrProfileCurve) {
DngHdrProfileGainTableGenerator.ADOBE_PROFILE_CAPTURE_BASELINE_OFFSET_EV
} else {
0f
}
}
private fun buildReference(bitmap: Bitmap): RawViewfinderExposureMath.Reference? {
if (bitmap.isRecycled || bitmap.width <= 0 || bitmap.height <= 0) return null
return try {
@@ -421,14 +421,8 @@ object RawProcessor {
com.hinnka.mycamera.raw.MeteringSystem.RAW_EXPOSURE_MIN_EV,
com.hinnka.mycamera.raw.MeteringSystem.RAW_EXPOSURE_MAX_EV,
)
val captureBaselineExposureOffsetEv = captureProfile
?.captureBaselineExposureOffsetEv
?.takeIf { it.isFinite() }
?: 0f
val finalBaselineExposureEv = DngBaselineExposure.sanitize(
sourceBaselineExposureEv +
(exposureOffsetEv ?: 0f) +
captureBaselineExposureOffsetEv
sourceBaselineExposureEv + (exposureOffsetEv ?: 0f)
)
val profileRequired = options.profileToneMapMode == RawProfileToneMapMode.Photon ||
options.profileToneMapMode == RawProfileToneMapMode.GooglePixel
@@ -453,7 +447,6 @@ object RawProcessor {
"sourceBaselineGain=${DngBaselineExposure.exactGain(sourceBaselineExposureEv)} " +
"meteredExposureOffsetEv=${exposureOffsetEv ?: 0f} " +
"meteredExposureGain=${DngBaselineExposure.exactGain(exposureOffsetEv ?: 0f)} " +
"captureBaselineExposureOffsetEv=$captureBaselineExposureOffsetEv " +
"writtenBaselineEv=${finalProfile.baselineExposureEv} " +
"writtenBaselineGain=${DngBaselineExposure.exactGain(finalProfile.baselineExposureEv)} " +
"pgtm=${finalProfile.profileGainTableMap != null} " +
@@ -0,0 +1,37 @@
package com.hinnka.mycamera.lut
import org.junit.Assert.assertEquals
import org.junit.Test
class ChromaDenoiseDefaultsTest {
@Test
fun rawCaptureUsesAnExplicitDefaultWithoutScalingUserValues() {
assertEquals(0.25f, ChromaDenoiseDefaults.forRawCapture(0f), 0f)
assertEquals(0.25f, ChromaDenoiseDefaults.forRawCapture(0.1f), 0f)
assertEquals(0.5f, ChromaDenoiseDefaults.forRawCapture(0.5f), 0f)
}
@Test
fun activeNoiseBandwidthRespondsAcrossTheWholeSliderRange() {
assertEquals(0f, ChromaDenoiseDefaults.noiseBandwidth(0f), 0f)
assertEquals(5.25f, ChromaDenoiseDefaults.noiseBandwidth(0.25f), 1e-6f)
assertEquals(9.5f, ChromaDenoiseDefaults.noiseBandwidth(0.5f), 1e-6f)
assertEquals(18f, ChromaDenoiseDefaults.noiseBandwidth(1f), 0f)
}
@Test
fun outputStrengthSmoothlyReachesFullAtOneQuarter() {
assertEquals(0f, ChromaDenoiseDefaults.outputStrength(0f), 0f)
assertEquals(0.5f, ChromaDenoiseDefaults.outputStrength(0.125f), 1e-6f)
assertEquals(1f, ChromaDenoiseDefaults.outputStrength(0.25f), 0f)
assertEquals(1f, ChromaDenoiseDefaults.outputStrength(1f), 0f)
}
@Test
fun edgeGuidanceOnlyRelaxesAboveHalfStrength() {
assertEquals(0f, ChromaDenoiseDefaults.edgeGuidanceRelaxation(0f), 0f)
assertEquals(0f, ChromaDenoiseDefaults.edgeGuidanceRelaxation(0.5f), 0f)
assertEquals(0.5f, ChromaDenoiseDefaults.edgeGuidanceRelaxation(0.75f), 1e-6f)
assertEquals(1f, ChromaDenoiseDefaults.edgeGuidanceRelaxation(1f), 0f)
}
}
@@ -1,54 +0,0 @@
package com.hinnka.mycamera.raw
import org.junit.Assert.assertEquals
import org.junit.Test
class RawViewfinderExposureMatcherTest {
@Test
fun adobeGoogleCaptureAddsBaselineExposureOffset() {
assertEquals(
0.7f,
RawViewfinderExposureMatcher.firstCaptureDngBaselineExposureOffsetEv(
rawRenderingEngine = RawRenderingEngine.AdobeCurve,
profileToneMapMode = RawProfileToneMapMode.GooglePixel,
),
0f,
)
}
@Test
fun adobePhotonCaptureAddsBaselineExposureOffset() {
assertEquals(
0.7f,
RawViewfinderExposureMatcher.firstCaptureDngBaselineExposureOffsetEv(
rawRenderingEngine = RawRenderingEngine.AdobeCurve,
profileToneMapMode = RawProfileToneMapMode.Photon,
),
0f,
)
}
@Test
fun adobeDefaultCurveDoesNotAddBaselineExposureOffset() {
assertEquals(
0f,
RawViewfinderExposureMatcher.firstCaptureDngBaselineExposureOffsetEv(
rawRenderingEngine = RawRenderingEngine.AdobeCurve,
profileToneMapMode = RawProfileToneMapMode.Default,
),
0f,
)
}
@Test
fun nonAdobeHdrProfileDoesNotAddBaselineExposureOffset() {
assertEquals(
0f,
RawViewfinderExposureMatcher.firstCaptureDngBaselineExposureOffsetEv(
rawRenderingEngine = RawRenderingEngine.AgX,
profileToneMapMode = RawProfileToneMapMode.Photon,
),
0f,
)
}
}