From patchwork Mon Aug 3 16:18:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9142 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 54473BD86F for ; Mon, 3 Aug 2020 16:18:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B953619F4; Mon, 3 Aug 2020 18:18:24 +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="WOikV1ul"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8BB07605A9 for ; Mon, 3 Aug 2020 18:18:22 +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 EC8F69CE; Mon, 3 Aug 2020 18:18:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1596471502; bh=J6UIdvHGBPmQweKl+qZmHGZG1DflYGit3djkhFdbAgU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WOikV1ulzJUPvHUuqchB0CeB/RIQyPMAd9R4mlJEr/aqn1/4R+A/O8EW1aK5zO1kt bllqL7zthhAfLgicXvUdIRxSB6U9nbcjkp5sLglKcVcghixHfSg7tFMk/CI+G81kWl U/Pst3nzV58Nwx80hHoY4NQwcl56buxbFvLP7iEQ= From: Kieran Bingham To: libcamera devel Date: Mon, 3 Aug 2020 17:18:06 +0100 Message-Id: <20200803161816.107113-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200803161816.107113-1-kieran.bingham@ideasonboard.com> References: <20200803161816.107113-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 02/12] libcamera: formats: add planeCount 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 PxielFormatPlaneInfo entries with a valid entry. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- 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 */