feat: new hdr fusion
This commit is contained in:
1 parent
249e54d937
commit
037ce6e95b
4 files changed
+898
-510
No files matched your search
@@ -32,6 +32,7 @@ import com.hinnka.mycamera.model.SafeImage
|
||||
import com.hinnka.mycamera.processor.MultiFrameStacker
|
||||
import com.hinnka.mycamera.processor.RawHdrStackFrame
|
||||
import com.hinnka.mycamera.processor.RawNoiseModel
|
||||
import com.hinnka.mycamera.processor.RawStackBufferLayout
|
||||
import com.hinnka.mycamera.processor.RawStackResult
|
||||
import com.hinnka.mycamera.processor.RawStackFrame
|
||||
import com.hinnka.mycamera.processor.YuvHdrStackFrame
|
||||
@@ -2758,7 +2759,11 @@ object GalleryManager {
|
||||
thumbnail = null,
|
||||
metadata = stackedMetadata,
|
||||
shouldAutoSave = shouldAutoSave,
|
||||
exportDngWithRawExport = exportDngWithRawExport
|
||||
exportDngWithRawExport = exportDngWithRawExport,
|
||||
imageLayout = finalStackResult.bufferLayout.toDngImageLayout(),
|
||||
compression = finalStackResult.bufferLayout.toDngCompression(),
|
||||
inputRowStepSamples = finalStackResult.inputRowStepSamples,
|
||||
inputColStepSamples = finalStackResult.inputColStepSamples,
|
||||
)
|
||||
} finally {
|
||||
finalStackResult.fusedBayerBuffer = null
|
||||
@@ -3111,13 +3116,17 @@ object GalleryManager {
|
||||
baselineExposureEv = rawHdrBaselineExposureEv,
|
||||
profileGainTableMap = rawHdrProfileGainTableMap,
|
||||
profileToneMapMode = rawHdrPgtmModeForMetadata(stackedMetadata),
|
||||
imageLayout = stackResult.bufferLayout.toDngImageLayout(),
|
||||
compression = stackResult.bufferLayout.toDngCompression(),
|
||||
inputRowStepSamples = stackResult.inputRowStepSamples,
|
||||
inputColStepSamples = stackResult.inputColStepSamples,
|
||||
)
|
||||
} finally {
|
||||
stackResult.fusedBayerBuffer = null
|
||||
rawHdrStackResult = null
|
||||
if (stackResult.fusedBayerUsesNativeAllocator) {
|
||||
LargeDirectBuffer.free(fusedBayerBuffer)
|
||||
PLog.d(TAG, "Released RAW HDR stacked Bayer buffer")
|
||||
PLog.d(TAG, "Released RAW HDR stacked linear RGB buffer")
|
||||
}
|
||||
}
|
||||
if (!dngWritten) {
|
||||
@@ -3359,6 +3368,18 @@ object GalleryManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun RawStackBufferLayout.toDngImageLayout(): SuperResolutionDngWriter.ImageLayout =
|
||||
when (this) {
|
||||
RawStackBufferLayout.CFA -> SuperResolutionDngWriter.ImageLayout.CFA
|
||||
RawStackBufferLayout.LINEAR_RGB -> SuperResolutionDngWriter.ImageLayout.LINEAR_RAW_RGB
|
||||
}
|
||||
|
||||
private fun RawStackBufferLayout.toDngCompression(): SuperResolutionDngWriter.Compression =
|
||||
when (this) {
|
||||
RawStackBufferLayout.CFA -> SuperResolutionDngWriter.Compression.UNCOMPRESSED
|
||||
RawStackBufferLayout.LINEAR_RGB -> SuperResolutionDngWriter.Compression.JPEG_LOSSLESS
|
||||
}
|
||||
|
||||
private suspend fun trySaveStackedRawDng(
|
||||
context: Context,
|
||||
photoId: String,
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -13,6 +13,11 @@ import com.hinnka.mycamera.raw.RawProfileToneMapMode
|
||||
import com.hinnka.mycamera.utils.BitmapUtils
|
||||
import com.hinnka.mycamera.utils.LargeDirectBuffer
|
||||
|
||||
enum class RawStackBufferLayout {
|
||||
CFA,
|
||||
LINEAR_RGB,
|
||||
}
|
||||
|
||||
data class RawStackResult(
|
||||
var fusedBayerBuffer: ByteBuffer?,
|
||||
val width: Int,
|
||||
@@ -23,6 +28,9 @@ data class RawStackResult(
|
||||
val profileGainTableMap: DngProfileGainTableMap? = null,
|
||||
val profileToneMapMode: RawProfileToneMapMode = RawProfileToneMapMode.Default,
|
||||
val diagnostics: RawStackDiagnostics? = null,
|
||||
val bufferLayout: RawStackBufferLayout = RawStackBufferLayout.CFA,
|
||||
val inputRowStepSamples: Int? = null,
|
||||
val inputColStepSamples: Int? = null,
|
||||
)
|
||||
|
||||
data class RawHdrStackFrame(
|
||||
|
||||
@@ -368,9 +368,16 @@ object SuperResolutionDngWriter {
|
||||
val encodedBlackLevels = if (isCfa) {
|
||||
blackLevelByCfaPosition(cfaPattern, blackLevel)
|
||||
} else {
|
||||
List(samplesPerPixel) { index ->
|
||||
blackLevel.getOrElse(index) { blackLevel.firstOrNull() ?: 0f }
|
||||
val red = blackLevel.getOrElse(0) { 0f }
|
||||
val green = if (blackLevel.size >= 3) {
|
||||
(blackLevel[1] + blackLevel[2]) * 0.5f
|
||||
} else {
|
||||
blackLevel.getOrElse(1) { red }
|
||||
}
|
||||
val blue = blackLevel.getOrElse(3) {
|
||||
blackLevel.getOrElse(2) { green }
|
||||
}
|
||||
listOf(red, green, blue)
|
||||
}
|
||||
|
||||
val exifEntries = buildList {
|
||||
|
||||
Reference in new issue
Block a user