Set default autoframing values
Set default values for autoframing in CaptureRequest, CaptureResult and
CameraCharacteristics. This will also fix
CaptureRequestTest#testAutoframing which is complaining about
autoframingAvailable key being null.
Test: atest CaptureResultTest#testCameraCaptureResultAllKeys,
CaptureRequestTest#testAutoframing
Bug: 259572724
Change-Id: I596abc0bd1e7aa57c4ef1326fe6185695894951c
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp
index 851a6d0..dc37c59 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.cpp
+++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp
@@ -1353,6 +1353,19 @@
return res;
}
+status_t CameraProviderManager::ProviderInfo::DeviceInfo3::addAutoframingTags() {
+ status_t res = OK;
+ auto& c = mCameraCharacteristics;
+
+ auto availableAutoframingEntry = c.find(ANDROID_CONTROL_AUTOFRAMING_AVAILABLE);
+ if (availableAutoframingEntry.count == 0) {
+ uint8_t defaultAutoframingEntry = ANDROID_CONTROL_AUTOFRAMING_AVAILABLE_FALSE;
+ res = c.update(ANDROID_CONTROL_AUTOFRAMING_AVAILABLE,
+ &defaultAutoframingEntry, 1);
+ }
+ return res;
+}
+
status_t CameraProviderManager::ProviderInfo::DeviceInfo3::addPreCorrectionActiveArraySize() {
status_t res = OK;
auto& c = mCameraCharacteristics;
diff --git a/services/camera/libcameraservice/common/CameraProviderManager.h b/services/camera/libcameraservice/common/CameraProviderManager.h
index 86047e8..73a8b9c 100644
--- a/services/camera/libcameraservice/common/CameraProviderManager.h
+++ b/services/camera/libcameraservice/common/CameraProviderManager.h
@@ -669,6 +669,7 @@
status_t addDynamicDepthTags(bool maxResolution = false);
status_t deriveHeicTags(bool maxResolution = false);
status_t addRotateCropTags();
+ status_t addAutoframingTags();
status_t addPreCorrectionActiveArraySize();
status_t addReadoutTimestampTag(bool readoutTimestampSupported = true);
diff --git a/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp b/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp
index 6d35391..c034bbf 100644
--- a/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp
+++ b/services/camera/libcameraservice/common/aidl/AidlProviderInfo.cpp
@@ -521,6 +521,11 @@
ALOGE("%s: Unable to add default SCALER_ROTATE_AND_CROP tags: %s (%d)", __FUNCTION__,
strerror(-res), res);
}
+ res = addAutoframingTags();
+ if (OK != res) {
+ ALOGE("%s: Unable to add default AUTOFRAMING tags: %s (%d)", __FUNCTION__,
+ strerror(-res), res);
+ }
res = addPreCorrectionActiveArraySize();
if (OK != res) {
ALOGE("%s: Unable to add PRE_CORRECTION_ACTIVE_ARRAY_SIZE: %s (%d)", __FUNCTION__,
diff --git a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
index d60565f..cc55c6c 100644
--- a/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
+++ b/services/camera/libcameraservice/common/hidl/HidlProviderInfo.cpp
@@ -644,6 +644,11 @@
ALOGE("%s: Unable to add default SCALER_ROTATE_AND_CROP tags: %s (%d)", __FUNCTION__,
strerror(-res), res);
}
+ res = addAutoframingTags();
+ if (OK != res) {
+ ALOGE("%s: Unable to add default AUTOFRAMING tags: %s (%d)", __FUNCTION__,
+ strerror(-res), res);
+ }
res = addPreCorrectionActiveArraySize();
if (OK != res) {
ALOGE("%s: Unable to add PRE_CORRECTION_ACTIVE_ARRAY_SIZE: %s (%d)", __FUNCTION__,
diff --git a/services/camera/libcameraservice/device3/Camera3Device.cpp b/services/camera/libcameraservice/device3/Camera3Device.cpp
index d189de2..1d54b17 100644
--- a/services/camera/libcameraservice/device3/Camera3Device.cpp
+++ b/services/camera/libcameraservice/device3/Camera3Device.cpp
@@ -1461,6 +1461,13 @@
&kDefaultJpegQuality, 1);
}
+ // Fill in AUTOFRAMING if not available
+ if (!mRequestTemplateCache[templateId].exists(ANDROID_CONTROL_AUTOFRAMING)) {
+ static const uint8_t kDefaultAutoframingMode = ANDROID_CONTROL_AUTOFRAMING_OFF;
+ mRequestTemplateCache[templateId].update(ANDROID_CONTROL_AUTOFRAMING,
+ &kDefaultAutoframingMode, 1);
+ }
+
*request = mRequestTemplateCache[templateId];
mLastTemplateId = templateId;
}
diff --git a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
index 7506f79..04b05f2 100644
--- a/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
+++ b/services/camera/libcameraservice/device3/Camera3OutputUtils.cpp
@@ -354,6 +354,29 @@
}
}
+ // Fix up autoframing metadata
+ camera_metadata_entry autoframingEntry =
+ captureResult.mMetadata.find(ANDROID_CONTROL_AUTOFRAMING);
+ if (autoframingEntry.count == 0) {
+ const uint8_t defaultAutoframingEntry = ANDROID_CONTROL_AUTOFRAMING_OFF;
+ if (captureResult.mMetadata.update(ANDROID_CONTROL_AUTOFRAMING,
+ &defaultAutoframingEntry, 1) != OK) {
+ SET_ERR("Failed to set autoframing mode in metadata for frame %d", frameNumber);
+ return;
+ }
+ }
+
+ camera_metadata_entry autoframingStateEntry =
+ captureResult.mMetadata.find(ANDROID_CONTROL_AUTOFRAMING_STATE);
+ if (autoframingStateEntry.count == 0) {
+ const uint8_t defaultAutoframingStateEntry = ANDROID_CONTROL_AUTOFRAMING_STATE_INACTIVE;
+ if (captureResult.mMetadata.update(ANDROID_CONTROL_AUTOFRAMING_STATE,
+ &defaultAutoframingStateEntry, 1) != OK) {
+ SET_ERR("Failed to set autoframing state in metadata for frame %d", frameNumber);
+ return;
+ }
+ }
+
for (auto& physicalMetadata : captureResult.mPhysicalMetadatas) {
String8 cameraId8(physicalMetadata.mPhysicalCameraId);
auto mapper = states.distortionMappers.find(cameraId8.c_str());