summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-03-15 18:22:46 +0100
committerNiklas Söderlund <niklas.soderlund@ragnatech.se>2020-03-18 18:02:40 +0100
commit8c0bbcd3d3751a716eb8bf03e703aa6fdbe1bd3f (patch)
tree579d0822f08b07770329800b07a219aad6723803 /include
parent4bc262ecaa736b956cf8878d8f3459c9caf7c37e (diff)
libcamera: PixelFormat: Turn into a class
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 <niklas.soderlund@ragnatech.se> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/pixelformats.h25
1 files changed, 24 insertions, 1 deletions
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 <set>
#include <stdint.h>
+#include <string>
#include <linux/drm_fourcc.h>
namespace libcamera {
-using PixelFormat = uint32_t;
+class PixelFormat
+{
+public:
+ PixelFormat();
+ PixelFormat(uint32_t fourcc, const std::set<uint64_t> &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<uint64_t> &modifiers() const { return modifiers_; }
+
+ std::string toString() const;
+
+private:
+ uint32_t fourcc_;
+ std::set<uint64_t> modifiers_;
+};
} /* namespace libcamera */