summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-09-01 23:22:40 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-09-07 19:17:54 +0300
commit94cbaa381aa8b1b3f34ad8bf14989456ba79a9af (patch)
tree9a8a02a636d969481cf085dc39c0d8b9dd22fe07 /src/android
parente85978ef5f813866178e809529db0602d00acde8 (diff)
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 <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Diffstat (limited to 'src/android')
-rw-r--r--src/android/mm/generic_camera_buffer.cpp13
-rw-r--r--src/android/yuv/post_processor_yuv.cpp10
2 files changed, 7 insertions, 16 deletions
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;
diff --git a/src/android/yuv/post_processor_yuv.cpp b/src/android/yuv/post_processor_yuv.cpp
index 6952fc38..7b3b4960 100644
--- a/src/android/yuv/post_processor_yuv.cpp
+++ b/src/android/yuv/post_processor_yuv.cpp
@@ -134,11 +134,9 @@ void PostProcessorYuv::calculateLengths(const StreamConfiguration &inCfg,
sourceStride_[i] = inCfg.stride;
destinationStride_[i] = nv12Info.stride(destinationSize_.width, i, 1);
- const unsigned int vertSubSample =
- nv12Info.planes[i].verticalSubSampling;
- sourceLength_[i] = sourceStride_[i] *
- ((sourceSize_.height + vertSubSample - 1) / vertSubSample);
- destinationLength_[i] = destinationStride_[i] *
- ((destinationSize_.height + vertSubSample - 1) / vertSubSample);
+ sourceLength_[i] = nv12Info.planeSize(sourceSize_.height, i,
+ sourceStride_[i]);
+ destinationLength_[i] = nv12Info.planeSize(destinationSize_.height, i,
+ destinationStride_[i]);
}
}