[{"id":14515,"web_url":"https://patchwork.libcamera.org/comment/14515/","msgid":"<X/uh1ZIC9g0Lbwwy@pendragon.ideasonboard.com>","date":"2021-01-11T00:54:45","subject":"Re: [libcamera-devel] [PATCH v2 2/4] 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 Thu, Dec 31, 2020 at 04:53:34PM +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.linux@gmail.com>\n> ---\n>  include/libcamera/internal/bayer_format.h |  7 +++++++\n>  src/libcamera/bayer_format.cpp            | 10 ++++++++++\n>  2 files changed, 17 insertions(+)\n> \n> diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h\n> index 8efe1382..298756e3 100644\n> --- a/include/libcamera/internal/bayer_format.h\n> +++ b/include/libcamera/internal/bayer_format.h\n> @@ -57,6 +57,13 @@ public:\n>  \tPacking packing;\n>  };\n>  \n> +bool operator==(const BayerFormat &lhs, const BayerFormat &rhs);\n> +static inline bool operator!=(const BayerFormat &lhs,\n> +\t\t\t      const BayerFormat &rhs)\n\nThis holds on a single line.\n\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 26065b66..b8635e15 100644\n> --- a/src/libcamera/bayer_format.cpp\n> +++ b/src/libcamera/bayer_format.cpp\n> @@ -160,6 +160,16 @@ 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> + */\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\nYou should also document operator!=().\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 79C37BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 11 Jan 2021 00:55:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 437A068090;\n\tMon, 11 Jan 2021 01:55:01 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B84860317\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Jan 2021 01:55:00 +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 AD0FAEC;\n\tMon, 11 Jan 2021 01:54:59 +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=\"TT8on+FR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1610326499;\n\tbh=EZpKuJjrDBp7jAOf1CovwFIR0hJrQcwMrmp8mDJl3nY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TT8on+FRY7VB7pkFFWGmDc0pLMmOp9H19prrXg7Bl5fwqeVwNlGV5wT3EmGm9oq4/\n\tdv/GU1+FaTEwhmO510wGgzD1do8+K25U9IByk2OZoxKmra0nFhv6y8Rh41ZeiiKuOH\n\tiGlyQIObDxrUVdFYOfKtHAP+qh9XVyb/4oVOL0tM=","Date":"Mon, 11 Jan 2021 02:54:45 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Sebastian Fricke <sebastian.fricke.linux@gmail.com>","Message-ID":"<X/uh1ZIC9g0Lbwwy@pendragon.ideasonboard.com>","References":"<20201231155336.7058-1-sebastian.fricke.linux@gmail.com>\n\t<20201231155336.7058-3-sebastian.fricke.linux@gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201231155336.7058-3-sebastian.fricke.linux@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/4] 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>"}}]