[libcamera-devel] [PATCH v2 4/6] libcamera: formats: Add ImageFormats::contain()
Jacopo Mondi
jacopo at jmondi.org
Tue Jun 9 01:28:42 CEST 2020
Add a method to check if a format is part of the formats enumeration.
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
include/libcamera/internal/formats.h | 1 +
src/libcamera/formats.cpp | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
index cb840014cbd7..914fdde27d0c 100644
--- a/include/libcamera/internal/formats.h
+++ b/include/libcamera/internal/formats.h
@@ -33,6 +33,7 @@ public:
int addFormat(T format, const std::vector<SizeRange> &sizes);
bool isEmpty() const;
+ bool contains(T format) const;
std::vector<T> formats() const;
const std::vector<SizeRange> &sizes(T format) const;
const std::map<T, std::vector<SizeRange>> &data() const;
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index fe50b9aaa1f2..9f46f82c9059 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -99,6 +99,17 @@ bool ImageFormats<T>::isEmpty() const
return data_.empty();
}
+/**
+ * \brief Check if the formats enumeration contains \a format
+ * \param[in] format The format
+ * \return True if the enumeration contains such format, false otherwise
+ */
+template<typename T>
+bool ImageFormats<T>::contains(T format) const
+{
+ return data_.find(format) == data_.end();
+}
+
/**
* \brief Retrieve a list of all supported image formats
* \return List of pixel formats or media bus codes
--
2.27.0
More information about the libcamera-devel
mailing list