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>
This commit is contained in:
Jacopo Mondi 2020-09-01 17:42:13 +02:00
parent af264ec750
commit bfee6316fc
2 changed files with 34 additions and 13 deletions

View file

@ -289,6 +289,31 @@ int CameraDevice::initialize()
return ret; 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 * Initialize the format conversion map to translate from Android format
* identifier to libcamera pixel formats and fill in the list of supported * identifier to libcamera pixel formats and fill in the list of supported
@ -433,19 +458,10 @@ int CameraDevice::initializeStreamConfigurations()
<< camera3Format.name << " to " << camera3Format.name << " to "
<< mappedFormat.toString(); << mappedFormat.toString();
for (const Size &res : cameraResolutions) { std::vector<Size> resolutions = getYUVResolutions(cameraConfig.get(),
cfg.pixelFormat = mappedFormat; mappedFormat,
cfg.size = res; cameraResolutions);
for (const Size &res : resolutions) {
CameraConfiguration::Status status = cameraConfig->validate();
if (status != CameraConfiguration::Valid) {
LOG(HAL, Debug) << cfg.toString()
<< " not supported";
continue;
}
LOG(HAL, Debug) << cfg.toString() << " supported";
streamConfigurations_.push_back({ res, androidFormat }); streamConfigurations_.push_back({ res, androidFormat });
/* /*

View file

@ -93,6 +93,11 @@ private:
}; };
int initializeStreamConfigurations(); 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(); std::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();
libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer); libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);
void notifyShutter(uint32_t frameNumber, uint64_t timestamp); void notifyShutter(uint32_t frameNumber, uint64_t timestamp);