feat: expo lift for google LTM
This commit is contained in:
1 parent
676ab51710
commit
26bf3d418e
8 files changed
+101
-41
No files matched your search
@@ -3647,6 +3647,7 @@ object GalleryManager {
|
||||
capturePreviewThumbnail = capturePreviewThumbnail.takeIf {
|
||||
viewfinderMatchEnabled
|
||||
},
|
||||
rawRenderingEngine = metadata.rawRenderingEngine,
|
||||
profileToneMapMode = profileToneMapMode,
|
||||
statsBounds = statsBounds,
|
||||
rawBlackPointCorrection = metadata.rawBlackPointCorrection ?: 0f,
|
||||
|
||||
@@ -17,6 +17,7 @@ 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
|
||||
@@ -65,8 +66,8 @@ internal object DngHdrProfileGainTableGenerator {
|
||||
)
|
||||
|
||||
internal val PHOTON_FUSION_PARAMETERS = HdrExposureFusionParameters(
|
||||
autoExposureTarget = 0.35f,
|
||||
wellExposedKey = 0.5f,
|
||||
autoExposureTarget = AUTO_EXPOSURE_TARGET,
|
||||
wellExposedKey = WELL_EXPOSED_KEY,
|
||||
maxExposureGain = MAX_LTM_GAIN,
|
||||
highlightFusionStart = HIGHLIGHT_FUSION_START,
|
||||
highlightFusionEnd = HIGHLIGHT_FUSION_END,
|
||||
|
||||
@@ -755,6 +755,7 @@ class RawDemosaicProcessor {
|
||||
cropRegion: Rect?,
|
||||
rotation: Int,
|
||||
request: RawExposurePreviewRequest?,
|
||||
captureBaselineExposureOffsetEv: Float,
|
||||
profileToneMapMode: RawProfileToneMapMode,
|
||||
statsBounds: Rect?,
|
||||
rawBlackPointCorrection: Float = 0f,
|
||||
@@ -792,6 +793,7 @@ class RawDemosaicProcessor {
|
||||
),
|
||||
rawBlackBorderCrop = rawBlackBorderCrop,
|
||||
exposurePreviewRequest = request,
|
||||
captureBaselineExposureOffsetEv = captureBaselineExposureOffsetEv,
|
||||
captureProfileToneMapMode = profileToneMapMode,
|
||||
captureProfileStatsBounds = statsBounds,
|
||||
onCaptureProfilePrepared = { preparedResult = it },
|
||||
@@ -1017,6 +1019,7 @@ 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,
|
||||
@@ -1792,7 +1795,9 @@ class RawDemosaicProcessor {
|
||||
)
|
||||
}
|
||||
val finalBaselineExposureEv = DngBaselineExposure.sanitize(
|
||||
actualMetadata.baselineExposure + (solvedExposureEv ?: 0f)
|
||||
actualMetadata.baselineExposure +
|
||||
(solvedExposureEv ?: 0f) +
|
||||
captureBaselineExposureOffsetEv
|
||||
)
|
||||
val captureProfileGainTableMap = when (captureProfileToneMapMode) {
|
||||
RawProfileToneMapMode.Photon,
|
||||
@@ -1818,6 +1823,7 @@ class RawDemosaicProcessor {
|
||||
} else {
|
||||
RawDngCaptureProfileResult(
|
||||
exposureOffsetEv = solvedExposureEv,
|
||||
captureBaselineExposureOffsetEv = captureBaselineExposureOffsetEv,
|
||||
profileGainTableMap = captureProfileGainTableMap,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ data class RawDngCaptureProfileInput(
|
||||
|
||||
data class RawDngCaptureProfileResult(
|
||||
val exposureOffsetEv: Float?,
|
||||
val captureBaselineExposureOffsetEv: Float,
|
||||
val profileGainTableMap: DngProfileGainTableMap?,
|
||||
)
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ internal object RawViewfinderExposureMatcher {
|
||||
cropRegion: Rect?,
|
||||
rotation: Int,
|
||||
capturePreviewThumbnail: Bitmap?,
|
||||
rawRenderingEngine: RawRenderingEngine,
|
||||
profileToneMapMode: RawProfileToneMapMode,
|
||||
statsBounds: Rect?,
|
||||
rawBlackPointCorrection: Float = 0f,
|
||||
@@ -52,6 +53,18 @@ 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,
|
||||
@@ -59,6 +72,7 @@ internal object RawViewfinderExposureMatcher {
|
||||
cropRegion = cropRegion,
|
||||
rotation = rotation,
|
||||
request = request,
|
||||
captureBaselineExposureOffsetEv = captureBaselineExposureOffsetEv,
|
||||
profileToneMapMode = profileToneMapMode,
|
||||
statsBounds = statsBounds,
|
||||
rawBlackPointCorrection = rawBlackPointCorrection,
|
||||
@@ -69,6 +83,19 @@ 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,8 +421,14 @@ 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)
|
||||
sourceBaselineExposureEv +
|
||||
(exposureOffsetEv ?: 0f) +
|
||||
captureBaselineExposureOffsetEv
|
||||
)
|
||||
val profileRequired = options.profileToneMapMode == RawProfileToneMapMode.Photon ||
|
||||
options.profileToneMapMode == RawProfileToneMapMode.GooglePixel
|
||||
@@ -447,6 +453,7 @@ 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} " +
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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,
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user