Camera: Fix coordinate mapping within partial result
Capture result coordinate mapping has the assumption that all relevant
tags are within the same capture result. With partial result, this
assumption is no longer true.
Address the issue by removing the remapped tags from partial result.
This approach shouldn't be causing performance degradation because we
are not touching 3A states, and 3A regions has dependency on crop
region, zoom ratio, and various modes used by the coordinate mappers.
Test: Camera CTS
Bug: 170575182
Change-Id: I022482ebf0f687d9b6138684aeda0f2bbf94046b
diff --git a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
index 889ce86..90f6216 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
@@ -182,7 +182,33 @@
return;
}
- insertResultLocked(states, &captureResult, frameNumber);
+ // Update partial result by removing keys remapped by DistortionCorrection, ZoomRatio,
+ // and RotationAndCrop mappers.
+ std::set<uint32_t> keysToRemove;
+
+ auto iter = states.distortionMappers.find(states.cameraId.c_str());
+ if (iter != states.distortionMappers.end()) {
+ const auto& remappedKeys = iter->second.getRemappedKeys();
+ keysToRemove.insert(remappedKeys.begin(), remappedKeys.end());
+ }
+
+ const auto& remappedKeys = states.zoomRatioMappers[states.cameraId.c_str()].getRemappedKeys();
+ keysToRemove.insert(remappedKeys.begin(), remappedKeys.end());
+
+ auto mapper = states.rotateAndCropMappers.find(states.cameraId.c_str());
+ if (mapper != states.rotateAndCropMappers.end()) {
+ const auto& remappedKeys = iter->second.getRemappedKeys();
+ keysToRemove.insert(remappedKeys.begin(), remappedKeys.end());
+ }
+
+ for (uint32_t key : keysToRemove) {
+ captureResult.mMetadata.erase(key);
+ }
+
+ // Send partial result
+ if (captureResult.mMetadata.entryCount() > 0) {
+ insertResultLocked(states, &captureResult, frameNumber);
+ }
}
void sendCaptureResult(