From 94cbaa381aa8b1b3f34ad8bf14989456ba79a9af Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 1 Sep 2021 23:22:40 +0300 Subject: libcamera: formats: Add planeSize() helpers to PixelFormatInfo Add two helpers functions to the PixelFormatInfo class to compute the byte size of a given plane, taking the frame size, the stride, the alignment constraints and the vertical subsampling into account. Use the new functions through the code base to replace manual implementations. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Hirokazu Honda --- src/android/mm/generic_camera_buffer.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/android/mm') diff --git a/src/android/mm/generic_camera_buffer.cpp b/src/android/mm/generic_camera_buffer.cpp index 27a30e2d..a4349f89 100644 --- a/src/android/mm/generic_camera_buffer.cpp +++ b/src/android/mm/generic_camera_buffer.cpp @@ -107,16 +107,9 @@ CameraBuffer::Private::Private([[maybe_unused]] CameraBuffer *cameraBuffer, unsigned int offset = 0; for (unsigned int i = 0; i < numPlanes; ++i) { - /* - * \todo Remove if this plane size computation function is - * added to PixelFormatInfo. - */ - const unsigned int vertSubSample = info.planes[i].verticalSubSampling; - const unsigned int stride = info.stride(size.width, i, 1u); - const unsigned int planeSize = - stride * ((size.height + vertSubSample - 1) / vertSubSample); - - planeInfo_[i].stride = stride; + const unsigned int planeSize = info.planeSize(size, i); + + planeInfo_[i].stride = info.stride(size.width, i, 1u); planeInfo_[i].offset = offset; planeInfo_[i].size = planeSize; -- cgit v1.2.1