summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-01-28 15:26:20 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-02-08 11:04:21 +0100
commit756fcbaaf2df0e563e066090f1d3e529f74ebe84 (patch)
tree48832a7418fb6b60051946e80ed1c2f84368026d /src
parent7fab304719d4f3414bdda579bff4e9cab46fc81d (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/android/camera_device.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index ad7e31cf..1e2a5b5f 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -347,12 +347,6 @@ CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camer
{
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";
model_ = "cameraModel";
@@ -550,6 +544,7 @@ int CameraDevice::initializeStreamConfigurations()
* build the stream configuration map reported through the camera static
* metadata.
*/
+ Size maxJpegSize;
for (const auto &format : camera3FormatsMap) {
int androidFormat = format.first;
const Camera3Format &camera3Format = format.second;
@@ -643,10 +638,18 @@ int CameraDevice::initializeStreamConfigurations()
* \todo Support JPEG streams produced by the Camera
* natively.
*/
- if (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888)
+ if (androidFormat == HAL_PIXEL_FORMAT_YCbCr_420_888) {
streamConfigurations_.push_back(
{ 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: ";
@@ -923,10 +926,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()
staticMetadata_->addEntry(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES,
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);
/* Sensor static metadata. */