[{"id":14800,"web_url":"https://patchwork.libcamera.org/comment/14800/","msgid":"<YBCfsXn53BFJCC3M@pendragon.ideasonboard.com>","date":"2021-01-26T23:03:13","subject":"Re: [libcamera-devel] [PATCH v3 3/5] libcamera: Overload ==/!=\n\toperators for BayerFormats","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Sebastian,\n\nThank you for the patch.\n\nOn Tue, Jan 26, 2021 at 07:48:52PM +0100, Sebastian Fricke wrote:\n> Enable to test two Bayer formats for equality by checking if the order\n> of the color channels, the bit depth of the pattern, and the packing\n> scheme match. Additionally, add the reverse operation (!=), which negates\n> the equality test result.\n> \n> Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  include/libcamera/internal/bayer_format.h |  6 ++++++\n>  src/libcamera/bayer_format.cpp            | 17 +++++++++++++++++\n>  2 files changed, 23 insertions(+)\n> \n> diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\n> index 62814154..5b8c1dc9 100644\n> --- a/include/libcamera/internal/bayer_format.h\n> +++ b/include/libcamera/internal/bayer_format.h\n> @@ -57,6 +57,12 @@ public:\n>  \tPacking packing;\n>  };\n>  \n> +bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);\n> +static inline bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)\n> +{\n> +\treturn !(lhs == rhs);\n> +}\n> +\n>  } /* namespace libcamera */\n>  \n>  #endif /* __LIBCAMERA_INTERNAL_BAYER_FORMAT_H__ */\n> diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp\n> index 1acf91d4..d4e7f142 100644\n> --- a/src/libcamera/bayer_format.cpp\n> +++ b/src/libcamera/bayer_format.cpp\n> @@ -215,6 +215,23 @@ std::string BayerFormat::toString() const\n>  \treturn result;\n>  }\n>  \n> +/**\n> + * \\brief Compare two BayerFormats for equality\n> + * \\return True if order, bitDepth and packing are equal, otherwise false.\n\ns/\\.$//\n\nSame below. I'll update when applying the patches.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> + */\n> +bool operator==(const BayerFormat &lhs, const BayerFormat &rhs)\n> +{\n> +\treturn lhs.order == rhs.order && lhs.bitDepth == rhs.bitDepth &&\n> +\t       lhs.packing == rhs.packing;\n> +}\n> +\n> +/**\n> + * \\fn bool operator!=(const BayerFormat &lhs, const BayerFormat &rhs)\n> + * \\brief Compare two BayerFormats for inequality\n> + * \\return True if either order, bitdepth or packing are not equal, otherwise\n> + * false.\n> + */\n> +\n>  /**\n>   * \\brief Convert a BayerFormat into the corresponding V4L2PixelFormat\n>   * \\return The V4L2PixelFormat corresponding to this BayerFormat","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0D4AAC0F2B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jan 2021 23:03:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8EBE168332;\n\tWed, 27 Jan 2021 00:03:35 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A1A1F682D2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jan 2021 00:03:33 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1036F2C1;\n\tWed, 27 Jan 2021 00:03:33 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VzYxhXih\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1611702213;\n\tbh=ObP8Cy99QpnCpGT92r8WxpmT/nxHcXrLiBSHimMF4tU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VzYxhXihAtrvtKK0fFRN298EhEZYTT+a57IIAIP/BVjDcsZ2DEA4+X6tbPbDhcYrQ\n\tz2CLPpqNdYvWaOdGEEzdgvxmizbkjmLbV9C0K7TH7Kx5/TUArRNodeX7nPt+R+nbil\n\tEX//MWT5M4eWgE+0TdFvPbc07DYS+Z+LxY90h1uo=","Date":"Wed, 27 Jan 2021 01:03:13 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Sebastian Fricke <sebastian.fricke@posteo.net>","Message-ID":"<YBCfsXn53BFJCC3M@pendragon.ideasonboard.com>","References":"<20210126184854.46156-1-sebastian.fricke@posteo.net>\n\t<20210126184854.46156-4-sebastian.fricke@posteo.net>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210126184854.46156-4-sebastian.fricke@posteo.net>","Subject":"Re: [libcamera-devel] [PATCH v3 3/5] libcamera: Overload ==/!=\n\toperators for BayerFormats","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]