mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-15 00:19:44 +03:00
android: camera_device: Calculate MAX_JPEG_SIZE
Calculate the JPEG maximum size using the maximum preview format size multiplied by a 1.5 factor. The same multiplication factor is used in the existing HAL implementations in ChromeOS. 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:
parent
7fab304719
commit
756fcbaaf2
1 changed files with 10 additions and 11 deletions
|
@ -347,12 +347,6 @@ CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camer
|
||||||
{
|
{
|
||||||
camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);
|
camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);
|
||||||
|
|
||||||
/*
|
|
||||||
* \todo Determine a more accurate value for this during
|
|
||||||
* streamConfiguration.
|
|
||||||
*/
|
|
||||||
maxJpegBufferSize_ = 13 << 20; /* 13631488 from USB HAL */
|
|
||||||
|
|
||||||
maker_ = "libcamera";
|
maker_ = "libcamera";
|
||||||
model_ = "cameraModel";
|
model_ = "cameraModel";
|
||||||
|
|
||||||
|
@ -550,6 +544,7 @@ int CameraDevice::initializeStreamConfigurations()
|
||||||
* build the stream configuration map reported through the camera static
|
* build the stream configuration map reported through the camera static
|
||||||
* metadata.
|
* metadata.
|
||||||
*/
|
*/
|
||||||
|
Size maxJpegSize;
|
||||||
for (const auto &format : camera3FormatsMap) {
|
for (const auto &format : camera3FormatsMap) {
|
||||||
int androidFormat = format.first;
|
int androidFormat = format.first;
|
||||||
const Camera3Format &camera3Format = format.second;
|
const Camera3Format &camera3Format = format.second;
|
||||||
|
@ -643,12 +638,20 @@ int CameraDevice::initializeStreamConfigurations()
|
||||||
* \todo Support JPEG streams produced by the Camera
|
* \todo Support JPEG streams produced by the Camera
|
||||||
* natively.
|
* natively.
|
||||||
*/
|
*/
|
||||||
if (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888)
|
if (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {
|
||||||
streamConfigurations_.push_back(
|
streamConfigurations_.push_back(
|
||||||
{ res, HAL_PIXEL_FORMAT_BLOB });
|
{ res, HAL_PIXEL_FORMAT_BLOB });
|
||||||
|
maxJpegSize = std::max(maxJpegSize, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \todo Calculate the maximum JPEG buffer size by asking the
|
||||||
|
* encoder giving the maximum frame size required.
|
||||||
|
*/
|
||||||
|
maxJpegBufferSize_ = maxJpegSize.width * maxJpegSize.height * 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
LOG(HAL, Debug) << "Collected stream configuration map: ";
|
LOG(HAL, Debug) << "Collected stream configuration map: ";
|
||||||
for (const auto &entry : streamConfigurations_)
|
for (const auto &entry : streamConfigurations_)
|
||||||
LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
|
LOG(HAL, Debug) << "{ " << entry.resolution.toString() << " - "
|
||||||
|
@ -923,10 +926,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
|
||||||
staticMetadata_->addEntry(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
|
staticMetadata_->addEntry(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
|
||||||
thumbnailEntries.data(), thumbnailEntries.size());
|
thumbnailEntries.data(), thumbnailEntries.size());
|
||||||
|
|
||||||
/*
|
|
||||||
* \todo Calculate the maximum JPEG buffer size by asking the encoder
|
|
||||||
* giving the maximum frame size required.
|
|
||||||
*/
|
|
||||||
staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1);
|
staticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1);
|
||||||
|
|
||||||
/* Sensor static metadata. */
|
/* Sensor static metadata. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue