libcamera  v0.0.0
Supporting cameras in Linux since 2019
color_space.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 /*
3  * Copyright (C) 2021, Raspberry Pi (Trading) Limited
4  *
5  * color_space.h - color space definitions
6  */
7 
8 #pragma once
9 
10 #include <optional>
11 #include <string>
12 
13 namespace libcamera {
14 
16 {
17 public:
18  enum class Primaries {
19  Raw,
20  Smpte170m,
21  Rec709,
22  Rec2020,
23  };
24 
25  enum class TransferFunction {
26  Linear,
27  Srgb,
28  Rec709,
29  };
30 
31  enum class YcbcrEncoding {
32  None,
33  Rec601,
34  Rec709,
35  Rec2020,
36  };
37 
38  enum class Range {
39  Full,
40  Limited,
41  };
42 
45  {
46  }
47 
48  static const ColorSpace Raw;
49  static const ColorSpace Jpeg;
50  static const ColorSpace Srgb;
51  static const ColorSpace Smpte170m;
52  static const ColorSpace Rec709;
53  static const ColorSpace Rec2020;
54 
59 
60  std::string toString() const;
61  static std::string toString(const std::optional<ColorSpace> &colorSpace);
62 };
63 
64 bool operator==(const ColorSpace &lhs, const ColorSpace &rhs);
65 static inline bool operator!=(const ColorSpace &lhs, const ColorSpace &rhs)
66 {
67  return !(lhs == rhs);
68 }
69 
70 } /* namespace libcamera */
Class to describe a color space.
Definition: color_space.h:16
Primaries
The color primaries for this color space.
Definition: color_space.h:18
Range range
The pixel range used with by color space.
Definition: color_space.h:58
TransferFunction
The transfer function used for this color space.
Definition: color_space.h:25
YcbcrEncoding ycbcrEncoding
The Y'CbCr encoding used by this color space.
Definition: color_space.h:57
static const ColorSpace Rec2020
A constant representing the Rec.2020 color space.
Definition: color_space.h:53
YcbcrEncoding
The Y'CbCr encoding.
Definition: color_space.h:31
static const ColorSpace Rec709
A constant representing the Rec.709 color space.
Definition: color_space.h:52
static const ColorSpace Jpeg
A constant representing the JPEG color space used for encoding JPEG images.
Definition: color_space.h:49
constexpr ColorSpace(Primaries p, TransferFunction t, YcbcrEncoding e, Range r)
Construct a ColorSpace from explicit values.
Definition: color_space.h:43
static const ColorSpace Smpte170m
A constant representing the SMPTE170M color space.
Definition: color_space.h:51
TransferFunction transferFunction
The transfer function used by this color space.
Definition: color_space.h:56
Primaries primaries
The color primaries of this color space.
Definition: color_space.h:55
static const ColorSpace Raw
A constant representing a raw color space (from a sensor)
Definition: color_space.h:48
Range
The range (sometimes "quantisation") for this color space.
Definition: color_space.h:38
static const ColorSpace Srgb
A constant representing the sRGB color space.
Definition: color_space.h:50
std::string toString() const
Assemble and return a readable string representation of the ColorSpace.
Definition: color_space.cpp:131
Top-level libcamera namespace.
Definition: backtrace.h:17
@ Raw
Definition: stream.h:65
bool operator==(const ColorSpace &lhs, const ColorSpace &rhs)
Compare color spaces for equality.
Definition: color_space.cpp:303