From d66f54ca157b5226398f54e1bb04554fc38715f7 Mon Sep 17 00:00:00 2001 From: Yudhistira Erlandinata Date: Wed, 16 Oct 2024 13:17:28 +0000 Subject: libcamera: reserve frame sequence reported from the hardware Originally libcamera resets the sequence to 0 on streamOn. However, However, there are occasions when the user needs the original hardware sequence to query processing information of the particular frame. The patch reserves the hwSequence in the FrameMetadata. Signed-off-by: Yudhistira Erlandinata Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- include/libcamera/framebuffer.h | 1 + src/libcamera/framebuffer.cpp | 9 +++++++++ src/libcamera/v4l2_videodevice.cpp | 1 + 3 files changed, 11 insertions(+) diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index ff839243..fccfaa82 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -34,6 +34,7 @@ struct FrameMetadata { Status status; unsigned int sequence; + unsigned int hwSequence; uint64_t timestamp; Span planes() { return planes_; } diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp index 826848f7..d9d6294b 100644 --- a/src/libcamera/framebuffer.cpp +++ b/src/libcamera/framebuffer.cpp @@ -86,6 +86,15 @@ LOG_DEFINE_CATEGORY(Buffer) * Gaps in the sequence numbers indicate dropped frames. */ +/** + * \var FrameMetadata::hwSequence + * \brief The real hardware Frame sequence number + * + * \a FrameMetadata::sequence auto-corrects the initial value to zero on frame + * start. This value keeps the original hardware sequence to allow users to + * query processing information of particular frames. + */ + /** * \var FrameMetadata::timestamp * \brief Time when the frame was captured diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 14eba056..9bc677ed 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1862,6 +1862,7 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() ? FrameMetadata::FrameError : FrameMetadata::FrameSuccess; metadata.sequence = buf.sequence; + metadata.hwSequence = buf.sequence; metadata.timestamp = buf.timestamp.tv_sec * 1000000000ULL + buf.timestamp.tv_usec * 1000ULL; -- cgit v1.2.1