QCamera2: HAL3: Avoid modifying metadata in place twice
ae_regions/af_regions/face within metadata are modified in-place to
convert from sensor space to active array space. In the case of
jump-start, the same metadata structure is used for 2 capture_result,
resulting in two in-place modifications.
Fix the issue by making a copy of those fields before calling
toActiveArray.
Test: Camera CTS
Bug: 64667574
Change-Id: I9c6c7b047ea62321c4d27cdb3bdbba5a97f5385a
diff --git a/msm8998/QCamera2/HAL3/QCamera3HWI.cpp b/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
index 824b035..451b107 100644
--- a/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
+++ b/msm8998/QCamera2/HAL3/QCamera3HWI.cpp
@@ -7267,12 +7267,11 @@
faceScores[i] = (uint8_t)faceDetectionInfo->faces[i].score;
// Adjust crop region from sensor output coordinate system to active
// array coordinate system.
- cam_rect_t& rect = faceDetectionInfo->faces[i].face_boundary;
+ cam_rect_t rect = faceDetectionInfo->faces[i].face_boundary;
mCropRegionMapper.toActiveArray(rect.left, rect.top,
rect.width, rect.height);
- convertToRegions(faceDetectionInfo->faces[i].face_boundary,
- faceRectangles+j, -1);
+ convertToRegions(rect, faceRectangles+j, -1);
LOGL("FD_DEBUG : Frame[%d] Face[%d] : top-left (%d, %d), "
"bottom-right (%d, %d)",
@@ -7299,19 +7298,20 @@
CAM_INTF_META_FACE_LANDMARK, metadata) {
for (size_t i = 0; i < numFaces; i++) {
+ cam_face_landmarks_info_t face_landmarks = landmarks->face_landmarks[i];
// Map the co-ordinate sensor output coordinate system to active
// array coordinate system.
mCropRegionMapper.toActiveArray(
- landmarks->face_landmarks[i].left_eye_center.x,
- landmarks->face_landmarks[i].left_eye_center.y);
+ face_landmarks.left_eye_center.x,
+ face_landmarks.left_eye_center.y);
mCropRegionMapper.toActiveArray(
- landmarks->face_landmarks[i].right_eye_center.x,
- landmarks->face_landmarks[i].right_eye_center.y);
+ face_landmarks.right_eye_center.x,
+ face_landmarks.right_eye_center.y);
mCropRegionMapper.toActiveArray(
- landmarks->face_landmarks[i].mouth_center.x,
- landmarks->face_landmarks[i].mouth_center.y);
+ face_landmarks.mouth_center.x,
+ face_landmarks.mouth_center.y);
- convertLandmarks(landmarks->face_landmarks[i], faceLandmarks+k);
+ convertLandmarks(face_landmarks, faceLandmarks+k);
LOGL("FD_DEBUG LANDMARK : Frame[%d] Face[%d] : "
"left-eye (%d, %d), right-eye (%d, %d), mouth (%d, %d)",
@@ -7742,16 +7742,17 @@
int32_t aeRegions[REGIONS_TUPLE_COUNT];
// Adjust crop region from sensor output coordinate system to active
// array coordinate system.
- mCropRegionMapper.toActiveArray(hAeRegions->rect.left, hAeRegions->rect.top,
- hAeRegions->rect.width, hAeRegions->rect.height);
+ cam_rect_t hAeRect = hAeRegions->rect;
+ mCropRegionMapper.toActiveArray(hAeRect.left, hAeRect.top,
+ hAeRect.width, hAeRect.height);
- convertToRegions(hAeRegions->rect, aeRegions, hAeRegions->weight);
+ convertToRegions(hAeRect, aeRegions, hAeRegions->weight);
camMetadata.update(ANDROID_CONTROL_AE_REGIONS, aeRegions,
REGIONS_TUPLE_COUNT);
LOGD("Metadata : ANDROID_CONTROL_AE_REGIONS: FWK: [%d,%d,%d,%d] HAL: [%d,%d,%d,%d]",
aeRegions[0], aeRegions[1], aeRegions[2], aeRegions[3],
- hAeRegions->rect.left, hAeRegions->rect.top, hAeRegions->rect.width,
- hAeRegions->rect.height);
+ hAeRect.left, hAeRect.top, hAeRect.width,
+ hAeRect.height);
}
if (!pendingRequest.focusStateSent) {
@@ -8318,19 +8319,20 @@
IF_META_AVAILABLE(cam_area_t, hAfRegions, CAM_INTF_META_AF_ROI, metadata) {
/*af regions*/
+ cam_rect_t hAfRect = hAfRegions->rect;
int32_t afRegions[REGIONS_TUPLE_COUNT];
// Adjust crop region from sensor output coordinate system to active
// array coordinate system.
- mCropRegionMapper.toActiveArray(hAfRegions->rect.left, hAfRegions->rect.top,
- hAfRegions->rect.width, hAfRegions->rect.height);
+ mCropRegionMapper.toActiveArray(hAfRect.left, hAfRect.top,
+ hAfRect.width, hAfRect.height);
- convertToRegions(hAfRegions->rect, afRegions, hAfRegions->weight);
+ convertToRegions(hAfRect, afRegions, hAfRegions->weight);
camMetadata.update(ANDROID_CONTROL_AF_REGIONS, afRegions,
REGIONS_TUPLE_COUNT);
LOGD("Metadata : ANDROID_CONTROL_AF_REGIONS: FWK: [%d,%d,%d,%d] HAL: [%d,%d,%d,%d]",
afRegions[0], afRegions[1], afRegions[2], afRegions[3],
- hAfRegions->rect.left, hAfRegions->rect.top, hAfRegions->rect.width,
- hAfRegions->rect.height);
+ hAfRect.left, hAfRect.top, hAfRect.width,
+ hAfRect.height);
}
// AF region confidence