[libcamera-devel] [PATCH v2] android: camera_device: Add existing check for ScalerCrop control
Phi-bang Nguyen
pnguyen at baylibre.com
Fri Mar 26 20:52:12 CET 2021
The ScalerCrop control does not contain the existing check which can
cause the camera HAL crash at boot. Fix it.
Signed-off-by: Phi-Bang Nguyen <pnguyen at baylibre.com>
---
src/android/camera_device.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ae693664..678bfff8 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -1107,11 +1107,14 @@ const camera_metadata_t
*CameraDevice::getStaticMetadata()
* use the maximum and minimum crop rectangles to calculate the
* digital zoom factor.
*/
+ float maxZoom = {1};
const auto info = controlsInfo.find(&controls::ScalerCrop);
- Rectangle min = info->second.min().get<Rectangle>();
- Rectangle max = info->second.max().get<Rectangle>();
- float maxZoom = std::min(1.0f * max.width / min.width,
+ if (info != controlsInfo.end()) {
+ Rectangle min = info->second.min().get<Rectangle>();
+ Rectangle max = info->second.max().get<Rectangle>();
+ maxZoom = std::min(1.0f * max.width / min.width,
1.0f * max.height / min.height);
+ }
staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM,
&maxZoom, 1);
}
--
2.25.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20210326/0a20e3f9/attachment-0001.htm>
More information about the libcamera-devel
mailing list