[libcamera-devel] [RFC PATCH v1 12/12] libcamera: v4l2_videodevice: Use utils::enumerate()
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Thu Sep 2 06:23:03 CEST 2021
Replace a manual counter with the utils::enumerate() utility function.
Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
src/libcamera/v4l2_videodevice.cpp | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index b80b9038a914..8a7d847c060e 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1338,13 +1338,12 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
planes.resize(formatInfo_->numPlanes());
const FileDescriptor &fd = planes[0].fd;
size_t offset = 0;
- for (size_t i = 0; i < planes.size(); ++i) {
- planes[i].fd = fd;
- planes[i].offset = offset;
-
+ for (auto [i, plane] : utils::enumerate(planes)) {
+ plane.fd = fd;
+ plane.offset = offset;
/* \todo Take the V4L2 stride into account */
- planes[i].length = formatInfo_->planeSize(format_.size, i);
- offset += planes[i].length;
+ plane.length = formatInfo_->planeSize(format_.size, i);
+ offset += plane.length;
}
}
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list