summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/internal/formats.h1
-rw-r--r--src/libcamera/formats.cpp16
2 files changed, 17 insertions, 0 deletions
diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h
index 0bb15104..b8e47491 100644
--- a/include/libcamera/internal/formats.h
+++ b/include/libcamera/internal/formats.h
@@ -38,6 +38,7 @@ public:
static const PixelFormatInfo &info(const PixelFormat &format);
static const PixelFormatInfo &info(const V4L2PixelFormat &format);
+ static const PixelFormatInfo &info(const std::string &name);
unsigned int stride(unsigned int width, unsigned int plane,
unsigned int align = 1) const;
diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp
index cd63c15c..a51e9681 100644
--- a/src/libcamera/formats.cpp
+++ b/src/libcamera/formats.cpp
@@ -704,6 +704,22 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format)
}
/**
+ * \brief Retrieve information about a pixel format
+ * \param[in] name The name of pixel format
+ * \return The PixelFormatInfo describing the PixelFormat matching the
+ * \a name if known, or an invalid PixelFormatInfo otherwise
+ */
+const PixelFormatInfo &PixelFormatInfo::info(const std::string &name)
+{
+ for (const auto &info : pixelFormatInfo) {
+ if (info.second.name == name)
+ return info.second;
+ }
+
+ return pixelFormatInfoInvalid;
+}
+
+/**
* \brief Compute the stride
* \param[in] width The width of the line, in pixels
* \param[in] plane The index of the plane whose stride is to be computed