summaryrefslogtreecommitdiff
path: root/src/android/mm/generic_camera_buffer.cpp
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2021-02-25 17:51:54 +0100
committerJacopo Mondi <jacopo@jmondi.org>2021-03-03 09:50:28 +0100
commit1223da76a2671e9bbe05e286fb0ce8b29b55b529 (patch)
treebfb210f8a3da0b06fc42848c761199cbc52e2500 /src/android/mm/generic_camera_buffer.cpp
parenteba862b0e30e73d1e1b05845a8c932bc0ff576ee (diff)
android: camera_buffer: Add method to get the JPEG blob size
To maintain compatibility with platforms that do not provide a memory backend implementation add a method to be return the size of the buffer used for JPEG encoding capped to a maximum size. Platforms that implement a memory backend will always calculate the correct buffer size. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/android/mm/generic_camera_buffer.cpp')
-rw-r--r--src/android/mm/generic_camera_buffer.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp
index 45a83c35..98e63dfa 100644
--- a/src/android/mm/generic_camera_buffer.cpp
+++ b/src/android/mm/generic_camera_buffer.cpp
@@ -27,6 +27,8 @@ public:
unsigned int numPlanes() const;
Span<uint8_t> plane(unsigned int plane);
+
+ size_t jpegBufferSize(size_t maxJpegBufferSize) const;
};
CameraBuffer::Private::Private(CameraBuffer *cameraBuffer,
@@ -77,6 +79,12 @@ Span<uint8_t> CameraBuffer::Private::plane(unsigned int plane)
return maps_[plane];
}
+size_t CameraBuffer::Private::jpegBufferSize(size_t maxJpegBufferSize) const
+{
+ return std::min<unsigned int>(maps_[0].size(),
+ maxJpegBufferSize);
+}
+
CameraBuffer::CameraBuffer(buffer_handle_t camera3Buffer, int flags)
: Extensible(new Private(this, camera3Buffer, flags))
{
@@ -109,3 +117,9 @@ Span<uint8_t> CameraBuffer::plane(unsigned int plane)
Private *const d = LIBCAMERA_D_PTR();
return d->plane(plane);
}
+
+size_t CameraBuffer::jpegBufferSize(size_t maxJpegBufferSize) const
+{
+ const Private *const d = LIBCAMERA_D_PTR();
+ return d->jpegBufferSize(maxJpegBufferSize);
+}