diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2020-09-01 17:42:13 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2020-09-18 11:31:55 +0200 |
commit | bfee6316fc57b36b506eda9ed34519a86b9d9216 (patch) | |
tree | 1e8e3125bfded8e96e7f92e15dbf40d397b2355d /src/android | |
parent | af264ec75092ecdc8d0a4791379e234e81ec42fc (diff) |
android: camera_device: Break out size calculation
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: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/camera_device.cpp | 42 | ||||
-rw-r--r-- | src/android/camera_device.h | 5 |
2 files changed, 34 insertions, 13 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d3a53c94..0386287d 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -289,6 +289,31 @@ int CameraDevice::initialize() return ret; } +std::vector<Size> CameraDevice::getYUVResolutions(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; + + CameraConfiguration::Status status = cameraConfig->validate(); + if (status != CameraConfiguration::Valid) { + LOG(HAL, Debug) << cfg.toString() << " not supported"; + continue; + } + + LOG(HAL, Debug) << cfg.toString() << " supported"; + + 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 @@ -433,19 +458,10 @@ int CameraDevice::initializeStreamConfigurations() << camera3Format.name << " to " << mappedFormat.toString(); - for (const Size &res : cameraResolutions) { - cfg.pixelFormat = mappedFormat; - cfg.size = res; - - CameraConfiguration::Status status = cameraConfig->validate(); - if (status != CameraConfiguration::Valid) { - LOG(HAL, Debug) << cfg.toString() - << " not supported"; - continue; - } - - LOG(HAL, Debug) << cfg.toString() << " supported"; - + std::vector<Size> 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 3934f194..1ff43327 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -93,6 +93,11 @@ private: }; int initializeStreamConfigurations(); + std::vector<libcamera::Size> + getYUVResolutions(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); |