summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Fricke <sebastian.fricke@posteo.net>2021-01-26 19:48:52 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-02-04 21:00:38 +0200
commitc440c828bc071effb76e60968c9d4a4a74c134df (patch)
treedc1cd84c3e2c0fe82189d06961d253806ad626a1
parent11a946bc22212abd9eef467633e8ab359df57299 (diff)
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 <sebastian.fricke@posteo.net> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--include/libcamera/internal/bayer_format.h6
-rw-r--r--src/libcamera/bayer_format.cpp17
2 files changed, 23 insertions, 0 deletions
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..ae730d94 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -216,6 +216,23 @@ std::string BayerFormat::toString() const
}
/**
+ * \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
*/