From 8c0bbcd3d3751a716eb8bf03e703aa6fdbe1bd3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Sun, 15 Mar 2020 18:22:46 +0100 Subject: libcamera: PixelFormat: Turn into a class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a class to represent a pixel format. This is done to add support for modifiers for the formats. So far no modifiers are added by any pipeline handler, all plumbing to deal with them is however in place. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- include/libcamera/pixelformats.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/libcamera/pixelformats.h b/include/libcamera/pixelformats.h index 544363af..eb40e55a 100644 --- a/include/libcamera/pixelformats.h +++ b/include/libcamera/pixelformats.h @@ -7,13 +7,36 @@ #ifndef __LIBCAMERA_PIXEL_FORMATS_H__ #define __LIBCAMERA_PIXEL_FORMATS_H__ +#include #include +#include #include namespace libcamera { -using PixelFormat = uint32_t; +class PixelFormat +{ +public: + PixelFormat(); + PixelFormat(uint32_t fourcc, const std::set &modifiers = {}); + + bool operator==(const PixelFormat &other) const; + bool operator!=(const PixelFormat &other) const { return !(*this == other); } + bool operator<(const PixelFormat &other) const; + + bool isValid() const { return fourcc_ != 0; } + + operator uint32_t() const { return fourcc_; } + uint32_t fourcc() const { return fourcc_; } + const std::set &modifiers() const { return modifiers_; } + + std::string toString() const; + +private: + uint32_t fourcc_; + std::set modifiers_; +}; } /* namespace libcamera */ -- cgit v1.2.1