From 4961033ac9a84fa26cbbca22c81832d34138196f Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Tue, 1 Sep 2020 18:11:34 +0200 Subject: android: camera_device: Generate RAW resolutions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Hirokazu Honda Reviewed-by: Niklas Söderlund Acked-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi --- src/android/camera_device.cpp | 23 ++++++++++++++++++++--- src/android/camera_device.h | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'src/android') diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 0386287d..0608d026 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -314,6 +314,17 @@ std::vector CameraDevice::getYUVResolutions(CameraConfiguration *cameraCon return supportedResolutions; } +std::vector CameraDevice::getRawResolutions(const libcamera::PixelFormat &pixelFormat) +{ + std::unique_ptr cameraConfig = + camera_->generateConfiguration({ StillCaptureRaw }); + StreamConfiguration &cfg = cameraConfig->at(0); + const StreamFormats &formats = cfg.formats(); + std::vector 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 @@ -458,9 +469,15 @@ int CameraDevice::initializeStreamConfigurations() << camera3Format.name << " to " << mappedFormat.toString(); - std::vector resolutions = getYUVResolutions(cameraConfig.get(), - mappedFormat, - cameraResolutions); + std::vector resolutions; + const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat); + if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + resolutions = getRawResolutions(mappedFormat); + else + resolutions = getYUVResolutions(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 1ff43327..c0732fb8 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -97,6 +97,8 @@ private: getYUVResolutions(libcamera::CameraConfiguration *cameraConfig, const libcamera::PixelFormat &pixelFormat, const std::vector &resolutions); + std::vector + getRawResolutions(const libcamera::PixelFormat &pixelFormat); std::tuple calculateStaticMetadataSize(); libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer); -- cgit v1.2.1