From patchwork Thu Dec 31 15:53:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Fricke X-Patchwork-Id: 10796 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 687A7C0F1A for ; Thu, 31 Dec 2020 15:54:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 33855615B2; Thu, 31 Dec 2020 16:54:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="osYXTBqp"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 768346031D for ; Thu, 31 Dec 2020 16:54:32 +0100 (CET) Received: by mail-wr1-x42b.google.com with SMTP id i9so20397581wrc.4 for ; Thu, 31 Dec 2020 07:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lPJc7eMqmCuuqQDJUp+L5inJ3xbXv9i5YL4l+Jypyu4=; b=osYXTBqpexYfFDs2+fLXx+YVp0zDKqAGffZAdqFbLpmxA5etMGfzxRj/8c6Cm+qHZq LQJt+oMwPjAr1p4MaWmZG2sNzIMBdGgVD2Yn3xogK8XwW3E7oPUCcwnfx13jU8PkuIaN ZFEG7VCR9XnY3sUlu4YmRyKlrlZ/zBf70CCZc0NwMayfMfa/h79xcXSbvxMCP48O1vcG jNWcvng6q3/YomKlGA8CE5QY7rKNCLlhzUEN20DQNQINMl4vNbsRVT2ouoFf7b/e+9gh f2VIM5ot2+HWyGYw8OaTWHlDBy7ry7adohN2Wsn/8qQYn8JdMKySx19xhAaZ4+mEw0Of 8hbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lPJc7eMqmCuuqQDJUp+L5inJ3xbXv9i5YL4l+Jypyu4=; b=WLM+m4ZlMYYNKkrGF+JZWZTTSQwE15XT0ukGSSHzoKlkJCD4odcJz2/mWwqGHxIZh9 nVwjGmp3toADfD/ah/+0vJ1O3ZVOqZlq0eUBGektnzDNfF2Tq7tg5s/fmdA4L+aqHjZj IbGbW4FmprtQOrV/AJXasOUCsN2Qkzz8azszcv0ev6m+cLVInOkDadOreSWRPmY1m3rm Xp8Lu7b+MtKqTjSbl43v99KAztwAmxLyOxL96ZJA7GKkSDhpD9uxzEZY9992W75fzP1r C3y6z+tV3EyZEKtWpePVmWfeGu8HiznbPLrJ/jOZzilSDWrevX52BejwmSvofKGvBwQX gkiw== X-Gm-Message-State: AOAM530dpqJYZvCFb27Cznr1DT8U2G/6wunji8GXsNSwEcvMYZfp/onc 1Fw97tM1XWEEqxlhZsIwAOYHIWiPxJA= X-Google-Smtp-Source: ABdhPJxCi+/+erB7nTAj3Aq22K32N2/VdV3Sa2F99YfQDQu85+VcpLbeuZZbL/5EcHB7GzFB3iin5A== X-Received: by 2002:a5d:5227:: with SMTP id i7mr66899659wra.68.1609430072259; Thu, 31 Dec 2020 07:54:32 -0800 (PST) Received: from basti-TUXEDO-Book-XA1510.fritz.box (p200300d1ff267500b10aabf0e84cdf75.dip0.t-ipconnect.de. [2003:d1:ff26:7500:b10a:abf0:e84c:df75]) by smtp.gmail.com with ESMTPSA id s63sm14595787wms.18.2020.12.31.07.54.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Dec 2020 07:54:31 -0800 (PST) From: Sebastian Fricke To: libcamera-devel@lists.libcamera.org Date: Thu, 31 Dec 2020 16:53:34 +0100 Message-Id: <20201231155336.7058-3-sebastian.fricke.linux@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201231155336.7058-1-sebastian.fricke.linux@gmail.com> References: <20201231155336.7058-1-sebastian.fricke.linux@gmail.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/4] 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 --- include/libcamera/internal/bayer_format.h | 7 +++++++ src/libcamera/bayer_format.cpp | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 8efe1382..298756e3 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -57,6 +57,13 @@ 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 26065b66..b8635e15 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -160,6 +160,16 @@ 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; +} + /** * \brief Convert a BayerFormat into the corresponding V4L2PixelFormat * \return The V4L2PixelFormat corresponding to this BayerFormat