From patchwork Sun Jan 12 01:01:47 2020 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: 2589 Return-Path: Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DC94A606E6 for ; Sun, 12 Jan 2020 02:03:03 +0100 (CET) X-Halon-ID: 46c8ceb6-34d7-11ea-b6d8-005056917f90 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p54ac5d7b.dip0.t-ipconnect.de [84.172.93.123]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA id 46c8ceb6-34d7-11ea-b6d8-005056917f90; Sun, 12 Jan 2020 02:03:00 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sun, 12 Jan 2020 02:01:47 +0100 Message-Id: <20200112010212.2609025-8-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200112010212.2609025-1-niklas.soderlund@ragnatech.se> References: <20200112010212.2609025-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 07/32] libcamera: buffer: Add FrameMetadata container for 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: Sun, 12 Jan 2020 01:03:04 -0000 With the introduction of FrameBuffer objects, the metadata information related to captured frames will not be stored directly in the frame buffer object. Add a new FrameMetadata class to hold this information. Signed-off-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- * Changes since v3 - Update comment for FrameMetadata::FrameCancelled * Changes since v2 - Clarify documentation for values in enum FrameMetadata::Status members. - Improved documentation. - Added todo to improve FrameMetadata::timestamp descripton. * Changes since v1: - Rename BufferInfo to FrameMetadata - Rename prefix for BufferInfo::Status s/Buffer/Frame/ - Make FrameMetadata a struct with public data members instead of a class with accessors methods. - Dropped FrameMetadata::update() - Documentation updates --- include/libcamera/buffer.h | 17 +++++++++ src/libcamera/buffer.cpp | 73 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 80602124f24be4a0..0b95e41a2dd205b2 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -16,6 +16,23 @@ namespace libcamera { class Request; class Stream; +struct FrameMetadata { + enum Status { + FrameSuccess, + FrameError, + FrameCancelled, + }; + + struct Plane { + unsigned int bytesused; + }; + + 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 5305e3c391da6a69..360eb26cb4ca4906 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -23,6 +23,79 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Buffer) +/** + * \struct FrameMetadata + * \brief Metadata related to a captured frame + * + * The FrameMetadata structure stores all metadata related to a captured frame, + * as stored in a FrameBuffer, such as capture status, timestamp and bytesused. + */ + +/** + * \enum FrameMetadata::Status + * \brief Define the frame completion status + * \var FrameMetadata::FrameSuccess + * The frame has been captured with success and contains valid data. All fields + * of the FrameMetadata structure are valid. + * \var FrameMetadata::FrameError + * An error occurred during capture of the frame. The frame data may be partly + * or fully invalid. The sequence and timestamp fields of the FrameMetadata + * structure is valid, the other fields may be invalid. + * \var FrameMetadata::FrameCancelled + * Capture stopped before the frame completed. The frame data is not valid. All + * fields of the FrameMetadata structure but the status field are invalid. + */ + +/** + * \struct FrameMetadata::Plane + * \brief Per-plane frame metadata + * + * Frames are stored in memory in one or multiple planes. The + * FrameMetadata::Plane structure stores per-plane metadata. + */ + +/** + * \var FrameMetadata::Plane::bytesused + * \brief Number of bytes occupied by the data in the plane, including line + * padding + * + * This value may vary per frame for compressed formats. For uncompressed + * formats it will be constant for all frames, but may be smaller than the + * FrameBuffer size. + */ + +/** + * \var FrameMetadata::status + * \brief Status of the frame + * + * The validity of other fields of the FrameMetadata structure depends on the + * status value. + */ + +/** + * \var FrameMetadata::sequence + * \brief Frame sequence number + * + * The sequence number is a monotonically increasing number assigned to the + * frames captured by the stream. The value is increased by one for each frame. + * Gaps in the sequence numbers indicate dropped frames. + */ + +/** + * \var FrameMetadata::timestamp + * \brief Time when the frame was captured + * + * The timestamp is expressed as a number of nanoseconds relative to the system + * clock since an unspecified time point. + * + * \todo Be more precise on what timestamps refer to. + */ + +/** + * \var FrameMetadata::planes + * \brief Array of per-plane metadata + */ + /** * \class Plane * \brief A memory region to store a single plane of a frame