summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Plowman <david.plowman@raspberrypi.com>2021-12-10 14:44:17 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-12-13 11:29:01 +0200
commitddb5e9d37e05ec85da26aaf8be0442a5ca34280b (patch)
treed774911133f9aaf8038fbf7d9a7f2aba96f929ba /include
parent015fa7f718156f59d233b48653211d08f5567760 (diff)
libcamera: Add ColorSpace class
This class represents a color space by defining its color primaries, the transfer (gamma) function it uses, the YCbCr encoding and whether the output is full or limited range. Signed-off-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/color_space.h70
-rw-r--r--include/libcamera/meson.build1
2 files changed, 71 insertions, 0 deletions
diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h
new file mode 100644
index 00000000..086c56c1
--- /dev/null
+++ b/include/libcamera/color_space.h
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2021, Raspberry Pi (Trading) Limited
+ *
+ * color_space.h - color space definitions
+ */
+
+#pragma once
+
+#include <optional>
+#include <string>
+
+namespace libcamera {
+
+class ColorSpace
+{
+public:
+ enum class Primaries {
+ Raw,
+ Smpte170m,
+ Rec709,
+ Rec2020,
+ };
+
+ enum class TransferFunction {
+ Linear,
+ Srgb,
+ Rec709,
+ };
+
+ enum class YcbcrEncoding {
+ None,
+ Rec601,
+ Rec709,
+ Rec2020,
+ };
+
+ enum class Range {
+ Full,
+ Limited,
+ };
+
+ constexpr ColorSpace(Primaries p, TransferFunction t, YcbcrEncoding e, Range r)
+ : primaries(p), transferFunction(t), ycbcrEncoding(e), range(r)
+ {
+ }
+
+ static const ColorSpace Raw;
+ static const ColorSpace Jpeg;
+ static const ColorSpace Srgb;
+ static const ColorSpace Smpte170m;
+ static const ColorSpace Rec709;
+ static const ColorSpace Rec2020;
+
+ Primaries primaries;
+ TransferFunction transferFunction;
+ YcbcrEncoding ycbcrEncoding;
+ Range range;
+
+ std::string toString() const;
+ static std::string toString(const std::optional<ColorSpace> &colorSpace);
+};
+
+bool operator==(const ColorSpace &lhs, const ColorSpace &rhs);
+static inline bool operator!=(const ColorSpace &lhs, const ColorSpace &rhs)
+{
+ return !(lhs == rhs);
+}
+
+} /* namespace libcamera */
diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index 8c2cae00..408b7acf 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -5,6 +5,7 @@ libcamera_include_dir = 'libcamera' / 'libcamera'
libcamera_public_headers = files([
'camera.h',
'camera_manager.h',
+ 'color_space.h',
'controls.h',
'fence.h',
'framebuffer.h',