From c440c828bc071effb76e60968c9d4a4a74c134df Mon Sep 17 00:00:00 2001 From: Sebastian Fricke Date: Tue, 26 Jan 2021 19:48:52 +0100 Subject: libcamera: bayer_format: Overload ==/!= operators for BayerFormats 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 Signed-off-by: Laurent Pinchart --- src/libcamera/bayer_format.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/libcamera/bayer_format.cpp') diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 1acf91d4..ae730d94 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, or false otherwise + */ +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, or false + * otherwise + */ + /** * \brief Convert a BayerFormat into the corresponding V4L2PixelFormat * \return The V4L2PixelFormat corresponding to this BayerFormat -- cgit v1.2.1