fix: hdr fusion metadata
This commit is contained in:
1 parent
2be40b6f0e
commit
5388781c9a
3 files changed
+23
-11
No files matched your search
@@ -2956,9 +2956,14 @@ object GalleryManager {
|
||||
closeRemainingImages()
|
||||
return@withContext false
|
||||
}
|
||||
val rawHdrMetadataCandidate = rawHdrStackSelection.first
|
||||
val rawMetadataImage = rawHdrMetadataCandidate.image
|
||||
val rawMetadataResult = rawHdrMetadataCandidate.captureResult
|
||||
val (shortCandidate, normalCandidates) = rawHdrStackSelection
|
||||
val normalReferenceCandidate = normalCandidates.first()
|
||||
|
||||
// The fused Bayer buffer is normalized to the short-exposure domain, so keep using
|
||||
// that frame for stack calibration. Public capture metadata, however, describes the
|
||||
// intended 0EV photo and must come from a normal-exposure reference frame.
|
||||
val rawMetadataImage = shortCandidate.image
|
||||
val rawMetadataResult = shortCandidate.captureResult
|
||||
|
||||
val rawMetadata = RawMetadata.create(
|
||||
rawMetadataImage.width,
|
||||
@@ -2998,8 +3003,7 @@ object GalleryManager {
|
||||
)
|
||||
}
|
||||
|
||||
rawHdrStackSelection.let { (shortCandidate, normalCandidates) ->
|
||||
val normalReferenceCandidate = normalCandidates.first()
|
||||
run {
|
||||
if (!useGpuAcceleration) {
|
||||
PLog.w(TAG, "RAW HDR denoise requires GLES stacker; ignoring disabled GPU acceleration setting")
|
||||
}
|
||||
@@ -3079,6 +3083,7 @@ object GalleryManager {
|
||||
isNormalizedSensorData = true,
|
||||
characteristics = characteristics,
|
||||
captureResult = shortCandidate.captureResult,
|
||||
captureMetadataResult = normalReferenceCandidate.captureResult,
|
||||
rotation = rotation,
|
||||
thumbnail = null,
|
||||
metadata = stackedMetadata,
|
||||
@@ -3348,6 +3353,7 @@ object GalleryManager {
|
||||
isNormalizedSensorData: Boolean,
|
||||
characteristics: CameraCharacteristics,
|
||||
captureResult: CaptureResult,
|
||||
captureMetadataResult: CaptureResult? = null,
|
||||
rotation: Int,
|
||||
thumbnail: Bitmap?,
|
||||
metadata: MediaMetadata,
|
||||
@@ -3370,6 +3376,7 @@ object GalleryManager {
|
||||
height = height,
|
||||
characteristics = characteristics,
|
||||
captureResult = captureResult,
|
||||
captureMetadataResult = captureMetadataResult,
|
||||
outputStream = outputStream,
|
||||
rotation = rotation,
|
||||
thumbnail = thumbnail,
|
||||
|
||||
@@ -277,6 +277,7 @@ object RawProcessor {
|
||||
height: Int,
|
||||
characteristics: CameraCharacteristics,
|
||||
captureResult: CaptureResult,
|
||||
captureMetadataResult: CaptureResult? = null,
|
||||
outputStream: java.io.OutputStream,
|
||||
rotation: Int = 0,
|
||||
thumbnail: Bitmap? = null,
|
||||
@@ -328,6 +329,7 @@ object RawProcessor {
|
||||
height = height,
|
||||
characteristics = characteristics,
|
||||
captureResult = captureResult,
|
||||
captureMetadataResult = captureMetadataResult ?: captureResult,
|
||||
orientation = orientation,
|
||||
cfaPattern = resolvedCfaPattern,
|
||||
blackLevel = blackLevel,
|
||||
|
||||
@@ -132,6 +132,7 @@ object SuperResolutionDngWriter {
|
||||
height: Int,
|
||||
characteristics: CameraCharacteristics,
|
||||
captureResult: CaptureResult,
|
||||
captureMetadataResult: CaptureResult = captureResult,
|
||||
orientation: Int,
|
||||
cfaPattern: Int,
|
||||
blackLevel: FloatArray,
|
||||
@@ -233,6 +234,7 @@ object SuperResolutionDngWriter {
|
||||
height = height,
|
||||
characteristics = characteristics,
|
||||
captureResult = captureResult,
|
||||
captureMetadataResult = captureMetadataResult,
|
||||
orientation = orientation,
|
||||
cfaPattern = cfaPattern,
|
||||
blackLevel = encodedBlackLevel,
|
||||
@@ -275,6 +277,7 @@ object SuperResolutionDngWriter {
|
||||
height: Int,
|
||||
characteristics: CameraCharacteristics,
|
||||
captureResult: CaptureResult,
|
||||
captureMetadataResult: CaptureResult,
|
||||
orientation: Int,
|
||||
cfaPattern: Int,
|
||||
blackLevel: FloatArray,
|
||||
@@ -306,18 +309,18 @@ object SuperResolutionDngWriter {
|
||||
val calibrationMatrix2 = characteristics.get(CameraCharacteristics.SENSOR_CALIBRATION_TRANSFORM2)
|
||||
val noiseProfile = buildNoiseProfile(captureResult)
|
||||
val dateTime = SimpleDateFormat("yyyy:MM:dd HH:mm:ss", Locale.US).format(
|
||||
captureResult.get(CaptureResult.SENSOR_TIMESTAMP)?.let { timestampNs ->
|
||||
captureMetadataResult.get(CaptureResult.SENSOR_TIMESTAMP)?.let { timestampNs ->
|
||||
Date(System.currentTimeMillis() - SystemClock.elapsedRealtime() + timestampNs / 1_000_000L)
|
||||
} ?: Date()
|
||||
)
|
||||
val exposureTimeSeconds = captureResult.get(CaptureResult.SENSOR_EXPOSURE_TIME)
|
||||
val exposureTimeSeconds = captureMetadataResult.get(CaptureResult.SENSOR_EXPOSURE_TIME)
|
||||
?.takeIf { it > 0L }
|
||||
?.let { it.toDouble() / 1_000_000_000.0 }
|
||||
val iso = captureResult.get(CaptureResult.SENSOR_SENSITIVITY)?.takeIf { it > 0 }
|
||||
val aperture = captureResult.get(CaptureResult.LENS_APERTURE)?.takeIf { it > 0f }
|
||||
val focalLength = captureResult.get(CaptureResult.LENS_FOCAL_LENGTH)?.takeIf { it > 0f }
|
||||
val iso = captureMetadataResult.get(CaptureResult.SENSOR_SENSITIVITY)?.takeIf { it > 0 }
|
||||
val aperture = captureMetadataResult.get(CaptureResult.LENS_APERTURE)?.takeIf { it > 0f }
|
||||
val focalLength = captureMetadataResult.get(CaptureResult.LENS_FOCAL_LENGTH)?.takeIf { it > 0f }
|
||||
val focalLength35mm = calculate35mmEquivalent(characteristics, focalLength)
|
||||
val exifWhiteBalance = captureResult.get(CaptureResult.CONTROL_AWB_MODE)?.let { awbMode ->
|
||||
val exifWhiteBalance = captureMetadataResult.get(CaptureResult.CONTROL_AWB_MODE)?.let { awbMode ->
|
||||
if (awbMode == CameraMetadata.CONTROL_AWB_MODE_AUTO) 0 else 1
|
||||
}
|
||||
val isCfa = imageLayout == ImageLayout.CFA
|
||||
|
||||
Reference in new issue
Block a user