mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
v4l2: Sum bytesused for all planes when dequeuing buffer
The V4L2 compatibility layer supports the single-planar API only, and thus exposes a single V4L2 buffer plane to applications, regardless of the number of planes in the FrameBuffer. For multi-planar frame buffers, the bytesused value isn't correct as it only takes the first plane into account. Fix it by summing the bytesused values for all FrameBuffer planes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
This commit is contained in:
parent
a339d055cc
commit
a25710428e
1 changed files with 6 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
|||
#include <array>
|
||||
#include <errno.h>
|
||||
#include <linux/videodev2.h>
|
||||
#include <numeric>
|
||||
#include <set>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
@ -211,7 +212,11 @@ void V4L2CameraProxy::updateBuffers()
|
|||
|
||||
switch (fmd.status) {
|
||||
case FrameMetadata::FrameSuccess:
|
||||
buf.bytesused = fmd.planes()[0].bytesused;
|
||||
buf.bytesused = std::accumulate(fmd.planes().begin(),
|
||||
fmd.planes().end(), 0,
|
||||
[](unsigned int total, const auto &plane) {
|
||||
return total + plane.bytesused;
|
||||
});
|
||||
buf.field = V4L2_FIELD_NONE;
|
||||
buf.timestamp.tv_sec = fmd.timestamp / 1000000000;
|
||||
buf.timestamp.tv_usec = fmd.timestamp % 1000000;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue