libcamera: v4l2_videodevice: Use utils::enumerate()

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

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
This commit is contained in:
Laurent Pinchart
2021-09-01 21:00:24 +03:00
parent c64f7eb5c0
commit 0f4d81c2bf

View File

@@ -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;
}
}