[libcamera-devel] [PATCH v2 15/27] libcamera: v4l2_videodevice: Use utils::enumerate()

Laurent Pinchart laurent.pinchart at ideasonboard.com
Mon Sep 6 04:00:48 CEST 2021


Replace a manual counter with the utils::enumerate() utility function.

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh at chromium.org>
---
 src/libcamera/v4l2_videodevice.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 0a7fbdb7e011..59aa53c7c27e 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -1356,7 +1356,7 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
 		const FileDescriptor &fd = planes[0].fd;
 		size_t offset = 0;
 
-		for (size_t i = 0; i < planes.size(); ++i) {
+		for (auto [i, plane] : utils::enumerate(planes)) {
 			/*
 			 * The stride is reported by V4L2 for the first plane
 			 * only. Compute the stride of the other planes by
@@ -1368,11 +1368,11 @@ std::unique_ptr<FrameBuffer> V4L2VideoDevice::createBuffer(unsigned int index)
 					    * formatInfo_->planes[i].bytesPerGroup
 					    / formatInfo_->planes[0].bytesPerGroup;
 
-			planes[i].fd = fd;
-			planes[i].offset = offset;
-			planes[i].length = formatInfo_->planeSize(format_.size.height,
-								  i, stride);
-			offset += planes[i].length;
+			plane.fd = fd;
+			plane.offset = offset;
+			plane.length = formatInfo_->planeSize(format_.size.height,
+							      i, stride);
+			offset += plane.length;
 		}
 	}
 
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list