android: camera_buffer: Add stride/offset/size function

This adds getter functions of stride, offset and size to CameraBuffer
interface.

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Hirokazu Honda 2021-08-26 17:00:21 +09:00 committed by Laurent Pinchart
parent c5e2ed7806
commit 6453e75c7a
3 changed files with 65 additions and 0 deletions

View file

@ -34,10 +34,15 @@ public:
Span<uint8_t> plane(unsigned int plane);
unsigned int stride(unsigned int plane) const;
unsigned int offset(unsigned int plane) const;
unsigned int size(unsigned int plane) const;
size_t jpegBufferSize(size_t maxJpegBufferSize) const;
private:
struct PlaneInfo {
unsigned int stride;
unsigned int offset;
unsigned int size;
};
@ -114,6 +119,7 @@ CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer,
const unsigned int planeSize =
stride * ((size.height + vertSubSample - 1) / vertSubSample);
planeInfo_[i].stride = stride;
planeInfo_[i].offset = offset;
planeInfo_[i].size = planeSize;
@ -148,6 +154,30 @@ Span<uint8_t> CameraBuffer::Private::plane(unsigned int plane)
return planes_[plane];
}
unsigned int CameraBuffer::Private::stride(unsigned int plane) const
{
if (plane >= planeInfo_.size())
return 0;
return planeInfo_[plane].stride;
}
unsigned int CameraBuffer::Private::offset(unsigned int plane) const
{
if (plane >= planeInfo_.size())
return 0;
return planeInfo_[plane].offset;
}
unsigned int CameraBuffer::Private::size(unsigned int plane) const
{
if (plane >= planeInfo_.size())
return 0;
return planeInfo_[plane].size;
}
size_t CameraBuffer::Private::jpegBufferSize(size_t maxJpegBufferSize) const
{
ASSERT(bufferLength_ >= 0);