From patchwork Tue Jan 26 18:48:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 11026 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 EF22DC0F2B for ; Tue, 26 Jan 2021 18:49:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C1D7D68325; Tue, 26 Jan 2021 19:49:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=posteo.net header.i=@posteo.net header.b="O/UtsOXt"; dkim-atps=neutral Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F0BB6831B for ; Tue, 26 Jan 2021 19:49:13 +0100 (CET) Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 63CE4160065 for ; Tue, 26 Jan 2021 19:49:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1611686952; bh=+00HLx0KNbfNb3pJkp3DsR3jnsaHQiRJZjK7sADvAMI=; h=From:To:Cc:Subject:Date:From; b=O/UtsOXty7ld0Mvi/1tmY/2MxICd90a6q3iJHFjgvjNpzsIMHl1szZ/4T8lMSbZX0 W1R0H60Zmj0hkAfFoBtk5ZBxyQ9ZeWse+IF+U4pj+0f/B4PA221AnwzeMLtYg2qhws H50TaChDwtIfpOi0jFoeewyjoLg+1NhxocpHFBWCmhrdmQn3zka/U//Xi1IkcVNvFF 2dFEPAY0G5Vf9x5xurYcQSXAwxjorIHg8/GCwUg43gRzc7kKnDb3qwfbah2CEuehEn SqoEyaW6EK87fzzyPqCHPhr3KsfIwbJ1UKbPducGTDzXmbQIFq3hdtzahNOxcG1JIa 7sM/DY5F48Dhw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DQG3q4HmWz6tm9; Tue, 26 Jan 2021 19:49:11 +0100 (CET) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 19:48:52 +0100 Message-Id: <20210126184854.46156-4-sebastian.fricke@posteo.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210126184854.46156-1-sebastian.fricke@posteo.net> References: <20210126184854.46156-1-sebastian.fricke@posteo.net> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/5] libcamera: Overload ==/!= operators for BayerFormats 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" Enable to test two Bayer formats for equality by checking if the order of the color channels, the bit depth of the pattern, and the packing scheme match. Additionally, add the reverse operation (!=), which negates the equality test result. Signed-off-by: Sebastian Fricke Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- include/libcamera/internal/bayer_format.h | 6 ++++++ src/libcamera/bayer_format.cpp | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 62814154..5b8c1dc9 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -57,6 +57,12 @@ public: Packing packing; }; +bool operator==(const BayerFormat &lhs, const BayerFormat &rhs); +static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs) +{ + return !(lhs == rhs); +} + } /* namespace libcamera */ #endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */ diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 1acf91d4..d4e7f142 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -215,6 +215,23 @@ std::string BayerFormat::toString() const return result; } +/** + * \brief Compare two BayerFormats for equality + * \return True if order, bitDepth and packing are equal, otherwise false. + */ +bool operator==(const BayerFormat &lhs, const BayerFormat &rhs) +{ + return lhs.order == rhs.order && lhs.bitDepth == rhs.bitDepth && + lhs.packing == rhs.packing; +} + +/** + * \fn bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs) + * \brief Compare two BayerFormats for inequality + * \return True if either order, bitdepth or packing are not equal, otherwise + * false. + */ + /** * \brief Convert a BayerFormat into the corresponding V4L2PixelFormat * \return The V4L2PixelFormat corresponding to this BayerFormat