[libcamera-devel] [PATCH 1/3] android: CameraDevice: Validate crop_rotate_scale_degrees in configuration
Hirokazu Honda
hiroh at chromium.org
Thu Mar 25 06:19:29 CET 2021
Libcamera doesn't handle |crop_rotate_scale_degrees| in
camera3_stream at all. This adds the validation of the requested
|crop_rotate_scale_degrees| in configuration, but still not
handle the specified values.
Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
---
src/android/camera_device.cpp | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 72a89258..1414bfef 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -256,6 +256,38 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,
unsortedConfigs = sortedConfigs;
}
+/*
+ * verifyCropRotateScaleDegrees returns where |crop_rotate_scale_degrees| in
+ * all camera3_stream in stream_list are valid.
+ */
+bool verifyCropRotateScaleDegrees(const camera3_stream_configuration_t &stream_list)
+{
+ if (stream_list.num_streams == 0)
+ return true;
+ const int crop_rotate_scale_degrees =
+ stream_list.streams[0]->crop_rotate_scale_degrees;
+ for (unsigned int i = 0; i < stream_list.num_streams; ++i) {
+ const camera3_stream_t &stream = *stream_list.streams[i];
+ if (CAMERA3_STREAM_ROTATION_0 > stream.crop_rotate_scale_degrees ||
+ CAMERA3_STREAM_ROTATION_270 < stream.crop_rotate_scale_degrees) {
+ LOG(HAL, Error) << "invalid crop_rotate_scale_degrees: "
+ << stream.crop_rotate_scale_degrees;
+ return false;
+ }
+ if (stream.crop_rotate_scale_degrees == CAMERA3_STREAM_ROTATION_180) {
+ LOG(HAL, Error) << "crop_rotate_scale_degrees should "
+ << "not be CAMERA3_STREAM_ROTATION_180";
+ return false;
+ }
+ if (crop_rotate_scale_degrees != stream.crop_rotate_scale_degrees) {
+ LOG(HAL, Error) << "crop_rotate_scale_degrees in all "
+ << "streams are not identical";
+ return false;
+ }
+ }
+ return true;
+}
+
} /* namespace */
/*
@@ -1566,6 +1598,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
running_ = false;
}
+ if (!verifyCropRotateScaleDegrees(*stream_list))
+ return -EINVAL;
+
/*
* Generate an empty configuration, and construct a StreamConfiguration
* for each camera3_stream to add to it.
--
2.31.0.291.g576ba9dcdaf-goog
More information about the libcamera-devel
mailing list