From patchwork Tue Nov 26 23:35:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 2351 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C315861C62 for ; Wed, 27 Nov 2019 00:39:27 +0100 (CET) X-Halon-ID: fb3c3f54-10a5-11ea-a0b9-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac5865.dip0.t-ipconnect.de [84.172.88.101]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id fb3c3f54-10a5-11ea-a0b9-005056917f90; Wed, 27 Nov 2019 00:39:26 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 27 Nov 2019 00:35:53 +0100 Message-Id: <20191126233620.1695316-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191126233620.1695316-1-niklas.soderlund@ragnatech.se> References: <20191126233620.1695316-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 03/30] libcamera: buffer: Add BufferInfo container for buffer metadata information X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Nov 2019 23:39:28 -0000 For FrameBuffers the metadata information gathered when a buffer is captured will not be stored directly in the buffer object but in its own container. Add the BufferInfo class to hold this information. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- include/libcamera/buffer.h | 30 +++++++++++++ src/libcamera/buffer.cpp | 92 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 80602124f24be4a0..7302b9f32ce8c50d 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -16,6 +16,36 @@ namespace libcamera { class Request; class Stream; +class BufferInfo +{ +public: + enum Status { + BufferSuccess, + BufferError, + BufferCancelled, + }; + + struct Plane { + unsigned int bytesused; + }; + + BufferInfo(); + + void update(Status status, unsigned int sequence, uint64_t timestamp, + const std::vector &planes); + + Status status() const { return status_; } + unsigned int sequence() const { return sequence_; } + uint64_t timestamp() const { return timestamp_; } + const std::vector &planes() const { return planes_; } + +private: + Status status_; + unsigned int sequence_; + uint64_t timestamp_; + std::vector planes_; +}; + class Plane final { public: diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index 960eeb8f7d193ddd..4acff216cafba484 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -23,6 +23,98 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Buffer) +/** + * \class BufferInfo + * \brief Dynamic buffer metadata + * + * The BufferInfo class references a buffers dynamic metadata related to the + * frame contained in the buffer. + */ + +/** + * \enum BufferInfo::Status + * Buffer completion status + * \var BufferInfo::BufferSuccess + * The buffer has completed with success and contains valid data. All its other + * metadata (such as bytesused(), timestamp() or sequence() number) are valid. + * \var BufferInfo::BufferError + * The buffer has completed with an error and doesn't contain valid data. Its + * other metadata are valid. + * \var BufferInfo::BufferCancelled + * The buffer has been cancelled due to capture stop. Its other metadata are + * invalid and shall not be used. + */ + +/** + * \struct BufferInfo::Plane + * \brief Plane specific buffer information + */ + +/** + * \var BufferInfo::Plane::bytesused + * \brief Retrieve the number of bytes occupied by the data in the plane + * \return Number of bytes occupied in the plane + */ + +BufferInfo::BufferInfo() + : status_(BufferError), sequence_(0), timestamp_(0) +{ +} + +/** + * \brief Uptade the buffer information + * \param[in] status New buffer status + * \param[in] sequence New buffer sequence + * \param[in] timestamp New buffer timestamp + * \param[in] planes New buffer plane meta data + * + * Update the stored buffer meta data information. + */ +void BufferInfo::update(Status status, unsigned int sequence, + uint64_t timestamp, const std::vector &planes) +{ + status_ = status; + sequence_ = sequence; + timestamp_ = timestamp; + planes_ = planes; +} + +/** + * \fn BufferInfo::status() + * \brief Retrieve the buffer status + * + * The buffer status reports whether the buffer has completed successfully + * (BufferSuccess) or if an error occurred (BufferError). + * + * \return The buffer status + */ + +/** + * \fn BufferInfo::sequence() + * \brief Retrieve the buffer sequence number + * + * The sequence number is a monotonically increasing number assigned to the + * buffer processed by the stream. Gaps in the sequence numbers indicate + * dropped frames. + * + * \return Sequence number of the buffer + */ + +/** + * \fn BufferInfo::timestamp() + * \brief Retrieve the time when the buffer was processed + * + * The timestamp is expressed as a number of nanoseconds since the epoch. + * + * \return Timestamp when the buffer was processed + */ + +/** + * \fn BufferInfo::planes() + * \brief Retrieve the plane(s) information for the buffer + * \return A array holding all plane information for the buffer + */ + /** * \class Plane * \brief A memory region to store a single plane of a frame