From 38ca814e9723562da7b3a63f89662f801ca45614 Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Thu, 23 Jul 2020 11:19:38 +0100 Subject: libcamera: formats: add numPlanes helper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Determine the number of planes used by a format by counting the number of PixelFormatPlaneInfo entries with a valid entry. Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/libcamera/formats.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/libcamera/formats.cpp') diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index a51e9681..ebaae9be 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -821,4 +821,22 @@ PixelFormatInfo::frameSize(const Size &size, return sum; } +/** + * \brief Retrieve the number of planes represented by the format + * \return The number of planes used by the format + */ +unsigned int PixelFormatInfo::numPlanes() const +{ + unsigned int count = 0; + + for (const PixelFormatPlaneInfo &p : planes) { + if (p.bytesPerGroup == 0) + break; + + count++; + } + + return count; +} + } /* namespace libcamera */ -- cgit v1.2.1