From patchwork Tue Aug 4 21:47:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9195 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 22113BD87A for ; Tue, 4 Aug 2020 21:47:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 66ACB60567; Tue, 4 Aug 2020 23:47:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fOrQ3usn"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4940C60548 for ; Tue, 4 Aug 2020 23:47:17 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8867056E; Tue, 4 Aug 2020 23:47:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1596577636; bh=xOBkeVTzlN+Qtprad+1Xq3vpczkJ7mQZ5vHIrUpNAHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fOrQ3usnJ4GNSbdix7AX+NUd19V4uBSly/8s/glnJ1tEJZjdchMOLc5u+JvaRKIR6 5nmhuzQUdhOxVN7jTIsO+9k1KRpbmnRlaD19BqsNU+Ip5OmEi3yoUH33AOS14BsEjZ CSz3ZBoNt5KwND+NJwFwwocWneyJRiPnDxs61l10= From: Kieran Bingham To: libcamera devel Date: Tue, 4 Aug 2020 22:47:00 +0100 Message-Id: <20200804214711.177645-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200804214711.177645-1-kieran.bingham@ideasonboard.com> References: <20200804214711.177645-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 02/13] libcamera: formats: add numPlanes helper 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 --- v3: - Rename $SUBJECT :D v2: - Rename to numPlanes - Simplify fucntion doc. --- include/libcamera/internal/formats.h | 2 ++ src/libcamera/formats.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index b8e474916378..51a8a6b8b0ae 100644 --- a/include/libcamera/internal/formats.h +++ b/include/libcamera/internal/formats.h @@ -46,6 +46,8 @@ public: unsigned int frameSize(const Size &size, const std::array &strides) const; + unsigned int numPlanes() const; + /* \todo Add support for non-contiguous memory planes */ const char *name; PixelFormat format; diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index a51e96810aed..ebaae9be3d75 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 */