StormByte C++ Library: Multimedia module 0.0.9999
StormByte-Multimedia is a StormByte library module for parsing configuration files
Loading...
Searching...
No Matches
color.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Multimedia.
5 *
6 * StormByte-Multimedia original source is dual-licensed:
7 *
8 * 1. GNU Lesser General Public License v3.0 (or later)
9 * You may redistribute and/or modify this file under the terms of the
10 * GNU Lesser General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * 2. Commercial license
15 * Alternatively, this file may be used under the terms of a commercial
16 * license agreement with the copyright holder
17 * (David C. Manuelda <StormByte@gmail.com>).
18 *
19 * Both licenses apply only to original StormByte-Multimedia source in this
20 * file. Third-party components — including FFmpeg and embedded trained data —
21 * remain under their own licenses and are not covered by the commercial grant.
22 *
23 * Neither license grants any patent rights. Any patent licenses required
24 * to use this software or third-party components must be obtained separately
25 * from the patent holders.
26 *
27 * StormByte-Multimedia is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 *
32 * You should have received a copy of the GNU Lesser General Public License
33 * version 3 along with StormByte-Multimedia. If not, see
34 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
35 *
36 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
37 */
38
39#pragma once
40
43
59
81
101
126
132 constexpr const char* ToString(Range range) noexcept {
133 switch (range) {
134 case Range::Unspecified: return "Unspecified";
135 case Range::TV: return "TV";
136 case Range::Full: return "Full";
137 case Range::Unknown: return "Unknown";
138 default: return "Invalid";
139 }
140 }
141
147 constexpr const char* ToString(Space space) noexcept {
148 switch (space) {
149 case Space::Unspecified: return "Unspecified";
150 case Space::RGB: return "RGB";
151 case Space::BT709: return "BT709";
152 case Space::FCC: return "FCC";
153 case Space::BT470BG: return "BT470BG";
154 case Space::SMPTE170M: return "SMPTE170M";
155 case Space::SMPTE240M: return "SMPTE240M";
156 case Space::YCgCo: return "YCgCo";
157 case Space::BT2020NCL: return "BT2020NCL";
158 case Space::BT2020CL: return "BT2020CL";
159 case Space::SMPTE2085: return "SMPTE2085";
160 case Space::ChromaDerivedNCL: return "ChromaDerivedNCL";
161 case Space::ChromaDerivedCL: return "ChromaDerivedCL";
162 case Space::ICtCp: return "ICtCp";
163 case Space::Unknown: return "Unknown";
164 default: return "Invalid";
165 }
166 }
167
173 constexpr const char* ToString(Primaries primaries) noexcept {
174 switch (primaries) {
175 case Primaries::Unspecified: return "Unspecified";
176 case Primaries::BT709: return "BT709";
177 case Primaries::BT470M: return "BT470M";
178 case Primaries::BT470BG: return "BT470BG";
179 case Primaries::SMPTE170M: return "SMPTE170M";
180 case Primaries::SMPTE240M: return "SMPTE240M";
181 case Primaries::Film: return "Film";
182 case Primaries::BT2020: return "BT2020";
183 case Primaries::SMPTE428: return "SMPTE428";
184 case Primaries::SMPTE431: return "SMPTE431";
185 case Primaries::SMPTE432: return "SMPTE432";
186 case Primaries::EBU3213: return "EBU3213";
187 case Primaries::Unknown: return "Unknown";
188 default: return "Invalid";
189 }
190 }
191
197 constexpr const char* ToString(Transfer transfer) noexcept {
198 switch (transfer) {
199 case Transfer::Unspecified: return "Unspecified";
200 case Transfer::BT709: return "BT709";
201 case Transfer::Gamma22: return "Gamma22";
202 case Transfer::Gamma28: return "Gamma28";
203 case Transfer::SMPTE170M: return "SMPTE170M";
204 case Transfer::SMPTE240M: return "SMPTE240M";
205 case Transfer::Linear: return "Linear";
206 case Transfer::Log: return "Log";
207 case Transfer::LogSqrt: return "LogSqrt";
208 case Transfer::IEC61966_2_4: return "IEC61966_2_4";
209 case Transfer::BT1361: return "BT1361";
210 case Transfer::IEC61966_2_1: return "IEC61966_2_1";
211 case Transfer::BT2020_10: return "BT2020_10";
212 case Transfer::BT2020_12: return "BT2020_12";
213 case Transfer::SMPTE2084: return "SMPTE2084";
214 case Transfer::SMPTE428: return "SMPTE428";
215 case Transfer::ARIB_B67: return "ARIB_B67";
216 case Transfer::Unknown: return "Unknown";
217 default: return "Invalid";
218 }
219 }
220
226 public:
235 Color(PixelFormat format, Range range, Space space, Primaries primaries, Transfer transfer) noexcept;
236
240 Color(const Color&) = default;
241
245 Color(Color&&) noexcept = default;
246
250 ~Color() noexcept = default;
251
256 Color& operator=(const Color&) = default;
257
262 Color& operator=(Color&&) noexcept = default;
263
268 PixelFormat PixelFormat() const noexcept;
269
274 Range Range() const noexcept;
275
280 Space Space() const noexcept;
281
286 Primaries Primaries() const noexcept;
287
292 Transfer Transfer() const noexcept;
293
298 bool IsHDR10() const noexcept;
299
304 bool IsHLG() const noexcept;
305
306 private:
307 enum PixelFormat m_format;
308 enum Range m_range;
309 enum Space m_space;
310 enum Primaries m_primaries;
311 enum Transfer m_transfer;
312 };
313}
Primaries Primaries() const noexcept
Chromaticity primaries.
bool IsHLG() const noexcept
HLG colorimetry (10-bit+, BT.2020, ARIB B67).
bool IsHDR10() const noexcept
HDR10 colorimetry (10-bit+, BT.2020, PQ).
PixelFormat PixelFormat() const noexcept
Pixel format.
Color(const Color &)=default
Copy constructor.
Color(Color &&) noexcept=default
Move constructor.
Color(PixelFormat format, Range range, Space space, Primaries primaries, Transfer transfer) noexcept
Full color description.
Range Range() const noexcept
Sample range.
Space Space() const noexcept
Matrix coefficients.
Transfer Transfer() const noexcept
Transfer characteristics.
Media property value types.
Primaries
Chromaticity primaries.
Definition color.hxx:86
@ BT709
BT.709.
Definition color.hxx:88
@ BT470M
BT.470 M.
Definition color.hxx:89
@ SMPTE170M
SMPTE 170M.
Definition color.hxx:91
@ SMPTE431
SMPTE 431 (DCI-P3).
Definition color.hxx:96
@ SMPTE240M
SMPTE 240M.
Definition color.hxx:92
@ Unspecified
Not signaled.
Definition color.hxx:87
@ Unknown
Unlisted backend value.
Definition color.hxx:99
@ EBU3213
EBU 3213.
Definition color.hxx:98
@ BT470BG
BT.470 BG.
Definition color.hxx:90
@ Film
Film.
Definition color.hxx:93
@ BT2020
BT.2020.
Definition color.hxx:94
@ SMPTE432
SMPTE 432 (Display P3).
Definition color.hxx:97
@ SMPTE428
SMPTE 428.
Definition color.hxx:95
Transfer
Transfer characteristics.
Definition color.hxx:106
@ BT709
BT.709.
Definition color.hxx:108
@ SMPTE170M
SMPTE 170M.
Definition color.hxx:111
@ Linear
Linear.
Definition color.hxx:113
@ SMPTE240M
SMPTE 240M.
Definition color.hxx:112
@ BT2020_12
BT.2020 12-bit.
Definition color.hxx:120
@ Gamma22
Gamma 2.2.
Definition color.hxx:109
@ BT2020_10
BT.2020 10-bit.
Definition color.hxx:119
@ Unspecified
Not signaled.
Definition color.hxx:107
@ LogSqrt
Log sqrt.
Definition color.hxx:115
@ BT1361
BT.1361.
Definition color.hxx:117
@ Unknown
Unlisted backend value.
Definition color.hxx:124
@ Gamma28
Gamma 2.8.
Definition color.hxx:110
@ IEC61966_2_4
IEC 61966-2-4.
Definition color.hxx:116
@ ARIB_B67
HLG.
Definition color.hxx:123
@ SMPTE2084
PQ.
Definition color.hxx:121
@ IEC61966_2_1
IEC 61966-2-1 (sRGB).
Definition color.hxx:118
@ Log
Log.
Definition color.hxx:114
@ SMPTE428
SMPTE 428.
Definition color.hxx:122
Space
YUV / RGB matrix coefficients.
Definition color.hxx:64
@ BT709
BT.709.
Definition color.hxx:67
@ ChromaDerivedCL
Chroma-derived CL.
Definition color.hxx:77
@ SMPTE170M
SMPTE 170M.
Definition color.hxx:70
@ YCgCo
YCgCo.
Definition color.hxx:72
@ ChromaDerivedNCL
Chroma-derived NCL.
Definition color.hxx:76
@ SMPTE240M
SMPTE 240M.
Definition color.hxx:71
@ BT2020CL
BT.2020 constant luminance.
Definition color.hxx:74
@ ICtCp
ICtCp.
Definition color.hxx:78
@ Unspecified
Not signaled.
Definition color.hxx:65
@ Unknown
Unlisted backend value.
Definition color.hxx:79
@ RGB
RGB.
Definition color.hxx:66
@ FCC
FCC.
Definition color.hxx:68
@ BT470BG
BT.470 BG.
Definition color.hxx:69
@ SMPTE2085
SMPTE 2085.
Definition color.hxx:75
@ BT2020NCL
BT.2020 non-constant luminance.
Definition color.hxx:73
constexpr const char * ToString(ChannelLayout layout) noexcept
Converts a ChannelLayout to a string.
Definition channel_layout.hxx:74
@ Unknown
Unlisted or missing.
Definition channel_layout.hxx:53
Range
Luma/chroma sample range.
Definition color.hxx:53
@ TV
Limited / MPEG.
Definition color.hxx:55
@ Unspecified
Not signaled.
Definition color.hxx:54
@ Unknown
Unlisted backend value.
Definition color.hxx:57
@ Full
Full / JPEG.
Definition color.hxx:56
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47