summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2022-11-22 11:30:48 +0000
committerJacopo Mondi <jacopo@jmondi.org>2022-12-01 11:26:44 +0100
commitd2f9c1f0c344f884a8a4296ee77fc0c47655df7a (patch)
treefd330040c3334eaa9013de27cbd906affff28bf8 /src
parentb35f04b3c19487de903b67340fcfb801557295d3 (diff)
libcamera: bayer_format: Add toMbusCode method
This makes it easier to perform transformations on Bayer type mbus codes by converting them to a BayerFormat, doing the transform, and then converting them back again. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/bayer_format.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp
index f27cc166..fdbc4af1 100644
--- a/src/libcamera/bayer_format.cpp
+++ b/src/libcamera/bayer_format.cpp
@@ -227,6 +227,17 @@ const BayerFormat &BayerFormat::fromMbusCode(unsigned int mbusCode)
}
/**
+ * \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
*/