[libcamera-devel] [PATCH v3 04/11] android: camera_device: Break out size calculation
Jacopo Mondi
jacopo at jmondi.org
Tue Sep 8 15:41:35 CEST 2020
As the RAW stream sizes needs to be calculated differently from the
processed one, break out the procedure to calculate the processed
(RGB/YUV) resolutions from initializeStreamConfigurations() in order to
prepare for RAW sizes calculation.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 51 +++++++++++++++++++++++------------
src/android/camera_device.h | 5 ++++
2 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 17b5fd5f59eb..9d460906ab08 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -283,6 +283,36 @@ int CameraDevice::initialize()
return ret;
}
+std::vector<Size> CameraDevice::filterYUVResolutions(CameraConfiguration *cameraConfig,
+ const PixelFormat &pixelFormat,
+ const std::vector<Size> &resolutions)
+{
+ std::vector<Size> supportedResolutions;
+
+ StreamConfiguration &cfg = cameraConfig->at(0);
+ for (const Size &res : resolutions) {
+ cfg.pixelFormat = pixelFormat;
+ cfg.size = res;
+
+ std::stringstream ss;
+ ss << "Testing " << cfg.toString();
+
+ CameraConfiguration::Status status = cameraConfig->validate();
+ if (status != CameraConfiguration::Valid) {
+ ss << " not supported";
+ LOG(HAL, Debug) << ss.str();
+ continue;
+ }
+
+ ss << " supported";
+ LOG(HAL, Debug) << ss.str();
+
+ supportedResolutions.push_back(res);
+ }
+
+ return supportedResolutions;
+}
+
/*
* Initialize the format conversion map to translate from Android format
* identifier to libcamera pixel formats and fill in the list of supported
@@ -427,23 +457,10 @@ int CameraDevice::initializeStreamConfigurations()
<< camera3Format.name << " to "
<< mappedFormat.toString();
- for (const Size &res : cameraResolutions) {
- cfg.pixelFormat = mappedFormat;
- cfg.size = res;
-
- std::stringstream ss;
- ss << "Testing " << cfg.toString();
-
- CameraConfiguration::Status status = cameraConfig->validate();
- if (status != CameraConfiguration::Valid) {
- ss << " not supported";
- LOG(HAL, Debug) << ss.str();
- continue;
- }
-
- ss << " supported";
- LOG(HAL, Debug) << ss.str();
-
+ std::vector<Size> resolutions = filterYUVResolutions(cameraConfig.get(),
+ mappedFormat,
+ cameraResolutions);
+ for (const Size &res : resolutions) {
streamConfigurations_.push_back({ res, androidFormat });
/*
diff --git a/src/android/camera_device.h b/src/android/camera_device.h
index 3934f194f1b5..359a163ebab9 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -93,6 +93,11 @@ private:
};
int initializeStreamConfigurations();
+ std::vector<libcamera::Size>
+ filterYUVResolutions(libcamera::CameraConfiguration *cameraConfig,
+ const libcamera::PixelFormat &pixelFormat,
+ const std::vector<libcamera::Size> &resolutions);
+
std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();
libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);
void notifyShutter(uint32_t frameNumber, uint64_t timestamp);
--
2.28.0
More information about the libcamera-devel
mailing list