[libcamera-devel] [PATCH 5/5] android: camera_device: List RAW resolutions
Jacopo Mondi
jacopo at jmondi.org
Wed Sep 2 12:47:30 CEST 2020
The resolutions supported for the RAW formats cannot be tested from
a list of known sizes like the processed ones. This is mainly due to the
fact RAW streams are produced by capturing frames at the CSI-2 receiver
output and their size corresponds to the sensor's native sizes.
In order to obtain the RAW frame size generate a temporary
CameraConfiguration for the Role::StillCaptureRAW role and inspect the
map of StreamFormats returned by the pipeline handler.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
src/android/camera_device.cpp | 21 +++++++++++++++++----
src/android/camera_device.h | 2 ++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 765c3292e4f3..181fca83988d 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -314,6 +314,17 @@ std::vector<Size> CameraDevice::listProcessedResolutions(CameraConfiguration *ca
return supportedResolutions;
}
+std::vector<Size> CameraDevice::listRawResolutions(const libcamera::PixelFormat &pixelFormat)
+{
+ std::unique_ptr<CameraConfiguration> cameraConfig =
+ camera_->generateConfiguration({ StillCaptureRaw });
+ StreamConfiguration &cfg = cameraConfig->at(0);
+ const StreamFormats &formats = cfg.formats();
+ std::vector<Size> supportedResolutions = formats.sizes(pixelFormat);
+
+ return supportedResolutions;
+}
+
/*
* Initialize the format conversion map to translate from Android format
* identifier to libcamera pixel formats and fill in the list of supported
@@ -466,13 +477,15 @@ int CameraDevice::initializeStreamConfigurations()
<< camera3Format.name << " to: "
<< mappedFormat.toString();
+ std::vector<Size> resolutions;
const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat);
if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)
- continue;
+ resolutions = listRawResolutions(mappedFormat);
+ else
+ resolutions = listProcessedResolutions(cameraConfig.get(),
+ mappedFormat,
+ cameraResolutions);
- std::vector<Size> resolutions = listProcessedResolutions(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 18fd5ff03cde..230e89b011e6 100644
--- a/src/android/camera_device.h
+++ b/src/android/camera_device.h
@@ -97,6 +97,8 @@ private:
listProcessedResolutions(libcamera::CameraConfiguration *cameraConfig,
const libcamera::PixelFormat &pixelFormat,
const std::vector<libcamera::Size> &resolutions);
+ std::vector<libcamera::Size>
+ listRawResolutions(const libcamera::PixelFormat &pixelFormat);
std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();
libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);
--
2.28.0
More information about the libcamera-devel
mailing list