Message ID | 20220712055609.14910-1-umang.jain@ideasonboard.com |
---|---|
State | Rejected |
Headers | show |
Series |
|
Related | show |
Hi Umang, Thank you for the patch. On Tue, Jul 12, 2022 at 11:26:09AM +0530, Umang Jain via libcamera-devel wrote: > Provide a convenience helper to check is the given colorspace > belongs to a set of standard colorspace or not. > > Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> > --- > include/libcamera/color_space.h | 1 + > src/libcamera/color_space.cpp | 31 +++++++++++++++++++++++++++++++ > 2 files changed, 32 insertions(+) > > diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h > index 086c56c1..43786d2a 100644 > --- a/include/libcamera/color_space.h > +++ b/include/libcamera/color_space.h > @@ -59,6 +59,7 @@ public: > > std::string toString() const; > static std::string toString(const std::optional<ColorSpace> &colorSpace); > + bool isStandardColorSpace(); > }; > > bool operator==(const ColorSpace &lhs, const ColorSpace &rhs); > diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp > index 895e5c8e..004346f5 100644 > --- a/src/libcamera/color_space.cpp > +++ b/src/libcamera/color_space.cpp > @@ -212,6 +212,37 @@ std::string ColorSpace::toString(const std::optional<ColorSpace> &colorSpace) > return colorSpace->toString(); > } > > +/** > + * brief Checks whether the colorspace is a standard colorspace or not > + * > + * This is convenience helper to check whether the given colorspace is > + * a standard colorspace or not. > + * > + * \return True if it is a standard colorspace, false otherwise > + */ > +bool ColorSpace::isStandardColorSpace() > +{ > + bool isStdColorSpace = false; > + > + static const std::vector<ColorSpace> stdColorSpaces = { > + ColorSpace::Raw, > + ColorSpace::Jpeg, > + ColorSpace::Srgb, > + ColorSpace::Smpte170m, > + ColorSpace::Rec709, > + ColorSpace::Rec2020 > + }; > + > + auto it = std::find_if(stdColorSpaces.begin(), stdColorSpaces.end(), > + [this](const auto &item) { > + return *this == item; > + }); > + if (it != stdColorSpaces.end()) > + isStdColorSpace = true; > + > + return isStdColorSpace; return it != stdColorSpaces.end(); The implementation otherwise looks fine, but I'm not sure where we would use this :-) > +} > + > /** > * \var ColorSpace::primaries > * \brief The color primaries of this color space
diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h index 086c56c1..43786d2a 100644 --- a/include/libcamera/color_space.h +++ b/include/libcamera/color_space.h @@ -59,6 +59,7 @@ public: std::string toString() const; static std::string toString(const std::optional<ColorSpace> &colorSpace); + bool isStandardColorSpace(); }; bool operator==(const ColorSpace &lhs, const ColorSpace &rhs); diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp index 895e5c8e..004346f5 100644 --- a/src/libcamera/color_space.cpp +++ b/src/libcamera/color_space.cpp @@ -212,6 +212,37 @@ std::string ColorSpace::toString(const std::optional<ColorSpace> &colorSpace) return colorSpace->toString(); } +/** + * brief Checks whether the colorspace is a standard colorspace or not + * + * This is convenience helper to check whether the given colorspace is + * a standard colorspace or not. + * + * \return True if it is a standard colorspace, false otherwise + */ +bool ColorSpace::isStandardColorSpace() +{ + bool isStdColorSpace = false; + + static const std::vector<ColorSpace> stdColorSpaces = { + ColorSpace::Raw, + ColorSpace::Jpeg, + ColorSpace::Srgb, + ColorSpace::Smpte170m, + ColorSpace::Rec709, + ColorSpace::Rec2020 + }; + + auto it = std::find_if(stdColorSpaces.begin(), stdColorSpaces.end(), + [this](const auto &item) { + return *this == item; + }); + if (it != stdColorSpaces.end()) + isStdColorSpace = true; + + return isStdColorSpace; +} + /** * \var ColorSpace::primaries * \brief The color primaries of this color space
Provide a convenience helper to check is the given colorspace belongs to a set of standard colorspace or not. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> --- include/libcamera/color_space.h | 1 + src/libcamera/color_space.cpp | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)