@@ -47,6 +47,7 @@ public:
}
static const BayerFormat &fromMbusCode(unsigned int mbusCode);
+ unsigned int toMbusCode() const;
bool isValid() const { return bitDepth != 0; }
std::string toString() const;
@@ -226,6 +226,17 @@ const BayerFormat &BayerFormat::fromMbusCode(unsigned int mbusCode)
return it->second;
}
+/**
+ * \brief Retrieve the media bus code corresponding this this BayerFormat
+ * \return The corresponding media bus code, or zero if none was found
+ */
+unsigned int BayerFormat::toMbusCode() const
+{
+ auto it = std::find_if(mbusCodeToBayer.begin(), mbusCodeToBayer.end(),
+ [this](const auto &i) { return i.second == *this; });
+ return it != mbusCodeToBayer.end() ? it->first : 0;
+}
+
/**
* \fn BayerFormat::isValid()
* \brief Return whether a BayerFormat is valid