Message ID | 20200727162143.31317-2-kgupta@es.iitr.ac.in |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Kaaira, On 27/07/2020 17:21, Kaaira Gupta wrote: > Add a function which returns PixelFormatInfo, given format name as > a string. > > Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> > --- > include/libcamera/internal/formats.h | 1 + > src/libcamera/formats.cpp | 16 ++++++++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h > index 0bb1510..b8e4749 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 11774b0..5f14281 100644 > --- a/src/libcamera/formats.cpp > +++ b/src/libcamera/formats.cpp > @@ -663,6 +663,22 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) > return info->second; > } > > +/** > + * \brief Retrieve information about a pixel format > + * \param[in] name The name of pixel format > + * \return The PixelFormatInfo describing the \a name if known, or an > + * invalid PixelFormatInfo otherwise I might have said here: "return The PixelFormatInfo describing the PixelFormat matching the \a name if known, or an invalid PixelFormatInfo otherwise" Just to clarify that we are describing the PixelFormat, not the 'name'. But if you're happy with that, it could be updated while applying, so no need for further revisions. Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > + */ > +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 >
diff --git a/include/libcamera/internal/formats.h b/include/libcamera/internal/formats.h index 0bb1510..b8e4749 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 11774b0..5f14281 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -663,6 +663,22 @@ const PixelFormatInfo &PixelFormatInfo::info(const V4L2PixelFormat &format) return info->second; } +/** + * \brief Retrieve information about a pixel format + * \param[in] name The name of pixel format + * \return The PixelFormatInfo describing 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
Add a function which returns PixelFormatInfo, given format name as a string. Signed-off-by: Kaaira Gupta <kgupta@es.iitr.ac.in> --- include/libcamera/internal/formats.h | 1 + src/libcamera/formats.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)