StormByte-Multimedia 3.3.2
C++26 multimedia processing module of the StormByte suite
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 * A written StormByte commercial agreement may license this original source
24 * on terms other than the LGPL, including specific use, distribution or
25 * linking arrangements such as static linking, as stated in that agreement.
26 * It does not grant rights to dependencies or waive their license conditions.
27 * Enabling WITH_GPL or WITH_NONFREE may include components with separate
28 * obligations for modification, linking (static or dynamic), redistribution
29 * or works that incorporate them. The person modifying, linking, packaging or
30 * distributing the resulting work is responsible for determining and meeting
31 * all applicable requirements, including any needed patent permissions.
32 * A StormByte commercial agreement does not provide those rights for GPL or
33 * nonfree components.
34 *
35 * Neither license grants any patent rights. Any patent licenses required
36 * to use this software or third-party components must be obtained separately
37 * from the patent holders.
38 *
39 * StormByte-Multimedia is distributed in the hope that it will be useful,
40 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 * GNU Lesser General Public License for more details.
43 *
44 * You should have received a copy of the GNU Lesser General Public License
45 * version 3 along with StormByte-Multimedia. If not, see
46 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
47 *
48 * SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-StormByte-Commercial
49 */
50
51#pragma once
52
55#include <StormByte/type_traits/safe.hxx>
56
61namespace StormByte {
66 namespace Multimedia {
71 namespace Property {
82
105
125
150
156 constexpr const char* ToString(Range range) noexcept {
157 switch (range) {
158 case Range::Unspecified: return "Unspecified";
159 case Range::TV: return "TV";
160 case Range::Full: return "Full";
161 case Range::Unknown: return "Unknown";
162 default: return "Invalid";
163 }
164 }
165
171 constexpr const char* ToString(Space space) noexcept {
172 switch (space) {
173 case Space::Unspecified: return "Unspecified";
174 case Space::RGB: return "RGB";
175 case Space::BT709: return "BT709";
176 case Space::FCC: return "FCC";
177 case Space::BT470BG: return "BT470BG";
178 case Space::SMPTE170M: return "SMPTE170M";
179 case Space::SMPTE240M: return "SMPTE240M";
180 case Space::YCgCo: return "YCgCo";
181 case Space::BT2020NCL: return "BT2020NCL";
182 case Space::BT2020CL: return "BT2020CL";
183 case Space::SMPTE2085: return "SMPTE2085";
184 case Space::ChromaDerivedNCL: return "ChromaDerivedNCL";
185 case Space::ChromaDerivedCL: return "ChromaDerivedCL";
186 case Space::ICtCp: return "ICtCp";
187 case Space::Unknown: return "Unknown";
188 case Space::IPTC2: return "IPT-C2";
189 default: return "Invalid";
190 }
191 }
192
198 constexpr const char* ToString(Primaries primaries) noexcept {
199 switch (primaries) {
200 case Primaries::Unspecified: return "Unspecified";
201 case Primaries::BT709: return "BT709";
202 case Primaries::BT470M: return "BT470M";
203 case Primaries::BT470BG: return "BT470BG";
204 case Primaries::SMPTE170M: return "SMPTE170M";
205 case Primaries::SMPTE240M: return "SMPTE240M";
206 case Primaries::Film: return "Film";
207 case Primaries::BT2020: return "BT2020";
208 case Primaries::SMPTE428: return "SMPTE428";
209 case Primaries::SMPTE431: return "SMPTE431";
210 case Primaries::SMPTE432: return "SMPTE432";
211 case Primaries::EBU3213: return "EBU3213";
212 case Primaries::Unknown: return "Unknown";
213 default: return "Invalid";
214 }
215 }
216
222 constexpr const char* ToString(Transfer transfer) noexcept {
223 switch (transfer) {
224 case Transfer::Unspecified: return "Unspecified";
225 case Transfer::BT709: return "BT709";
226 case Transfer::Gamma22: return "Gamma22";
227 case Transfer::Gamma28: return "Gamma28";
228 case Transfer::SMPTE170M: return "SMPTE170M";
229 case Transfer::SMPTE240M: return "SMPTE240M";
230 case Transfer::Linear: return "Linear";
231 case Transfer::Log: return "Log";
232 case Transfer::LogSqrt: return "LogSqrt";
233 case Transfer::IEC61966_2_4: return "IEC61966_2_4";
234 case Transfer::BT1361: return "BT1361";
235 case Transfer::IEC61966_2_1: return "IEC61966_2_1";
236 case Transfer::BT2020_10: return "BT2020_10";
237 case Transfer::BT2020_12: return "BT2020_12";
238 case Transfer::SMPTE2084: return "SMPTE2084";
239 case Transfer::SMPTE428: return "SMPTE428";
240 case Transfer::ARIB_B67: return "ARIB_B67";
241 case Transfer::Unknown: return "Unknown";
242 default: return "Invalid";
243 }
244 }
245
251 public:
255 Color() noexcept = default;
256
265 Color(PixelFormat format, Range range, Space space, Primaries primaries, Transfer transfer) noexcept;
266
272 Color(const Color&) = default;
273
279 Color(Color&&) noexcept = default;
280
284 ~Color() noexcept = default;
285
292 Color& operator=(const Color&) = default;
293
300 Color& operator=(Color&&) noexcept = default;
301
306 enum PixelFormat PixelFormat() const noexcept;
307
312 enum Range Range() const noexcept;
313
318 enum Space Space() const noexcept;
319
324 enum Primaries Primaries() const noexcept;
325
330 enum Transfer Transfer() const noexcept;
331
336 bool IsHDR10() const noexcept;
337
342 bool IsHLG() const noexcept;
343
344 private:
345 enum PixelFormat m_format = PixelFormat::Unknown;
346 enum Range m_range = Range::Unspecified;
347 enum Space m_space = Space::Unspecified;
348 enum Primaries m_primaries = Primaries::Unspecified;
349 enum Transfer m_transfer = Transfer::Unspecified;
350 };
351 }
352 }
353}
354
STORMBYTE_DECLARE_MAYBE_SAFE(StormByte::Buffer::Bridge)
bool IsHLG() const noexcept
HLG colorimetry (10-bit+, BT.2020, ARIB B67).
bool IsHDR10() const noexcept
HDR10 colorimetry (10-bit+, BT.2020, PQ).
enum Space Space() const noexcept
Matrix coefficients.
Color() noexcept=default
Constructs unknown pixel format and unspecified colorimetry.
enum PixelFormat PixelFormat() const noexcept
Pixel format.
enum Range Range() const noexcept
Sample range.
enum Transfer Transfer() const noexcept
Transfer characteristics.
enum Primaries Primaries() const noexcept
Chromaticity primaries.
Multimedia module of the StormByte suite.
Media property value types.
Media property value types.
Primaries
Chromaticity primaries.
Definition color.hxx:110
@ BT709
BT.709.
Definition color.hxx:112
@ BT470M
BT.470 M.
Definition color.hxx:113
@ SMPTE170M
SMPTE 170M.
Definition color.hxx:115
@ SMPTE431
SMPTE 431 (DCI-P3).
Definition color.hxx:120
@ SMPTE240M
SMPTE 240M.
Definition color.hxx:116
@ Unspecified
Not signaled.
Definition color.hxx:111
@ Unknown
Unlisted backend value.
Definition color.hxx:123
@ EBU3213
EBU 3213.
Definition color.hxx:122
@ BT470BG
BT.470 BG.
Definition color.hxx:114
@ Film
Film.
Definition color.hxx:117
@ BT2020
BT.2020.
Definition color.hxx:118
@ SMPTE432
SMPTE 432 (Display P3).
Definition color.hxx:121
@ SMPTE428
SMPTE 428.
Definition color.hxx:119
Transfer
Transfer characteristics.
Definition color.hxx:130
@ BT709
BT.709.
Definition color.hxx:132
@ SMPTE170M
SMPTE 170M.
Definition color.hxx:135
@ Linear
Linear.
Definition color.hxx:137
@ SMPTE240M
SMPTE 240M.
Definition color.hxx:136
@ BT2020_12
BT.2020 12-bit.
Definition color.hxx:144
@ Gamma22
Gamma 2.2.
Definition color.hxx:133
@ BT2020_10
BT.2020 10-bit.
Definition color.hxx:143
@ Unspecified
Not signaled.
Definition color.hxx:131
@ LogSqrt
Log sqrt.
Definition color.hxx:139
@ BT1361
BT.1361.
Definition color.hxx:141
@ Unknown
Unlisted backend value.
Definition color.hxx:148
@ Gamma28
Gamma 2.8.
Definition color.hxx:134
@ IEC61966_2_4
IEC 61966-2-4.
Definition color.hxx:140
@ ARIB_B67
HLG.
Definition color.hxx:147
@ SMPTE2084
PQ.
Definition color.hxx:145
@ IEC61966_2_1
IEC 61966-2-1 (sRGB).
Definition color.hxx:142
@ Log
Log.
Definition color.hxx:138
@ SMPTE428
SMPTE 428.
Definition color.hxx:146
Space
YUV / RGB matrix coefficients.
Definition color.hxx:87
@ BT709
BT.709.
Definition color.hxx:90
@ ChromaDerivedCL
Chroma-derived CL.
Definition color.hxx:100
@ SMPTE170M
SMPTE 170M.
Definition color.hxx:93
@ YCgCo
YCgCo.
Definition color.hxx:95
@ IPTC2
IPT-PQ-C2 (SMPTE ST 2128).
Definition color.hxx:103
@ ChromaDerivedNCL
Chroma-derived NCL.
Definition color.hxx:99
@ SMPTE240M
SMPTE 240M.
Definition color.hxx:94
@ BT2020CL
BT.2020 constant luminance.
Definition color.hxx:97
@ ICtCp
ICtCp.
Definition color.hxx:101
@ Unspecified
Not signaled.
Definition color.hxx:88
@ Unknown
Unlisted backend value.
Definition color.hxx:102
@ RGB
RGB.
Definition color.hxx:89
@ FCC
FCC.
Definition color.hxx:91
@ BT470BG
BT.470 BG.
Definition color.hxx:92
@ SMPTE2085
SMPTE 2085.
Definition color.hxx:98
@ BT2020NCL
BT.2020 non-constant luminance.
Definition color.hxx:96
constexpr const char * ToString(ChannelLayout layout) noexcept
Converts a ChannelLayout to a string.
Definition channel_layout.hxx:96
@ Unknown
Unlisted or missing.
Definition channel_layout.hxx:75
Range
Luma/chroma sample range.
Definition color.hxx:76
@ TV
Limited / MPEG.
Definition color.hxx:78
@ Unspecified
Not signaled.
Definition color.hxx:77
@ Unknown
Unlisted backend value.
Definition color.hxx:80
@ Full
Full / JPEG.
Definition color.hxx:79
Multimedia module of the StormByte suite.
Root namespace of the StormByte C++ suite.
#define STORMBYTE_MULTIMEDIA_PUBLIC
Definition visibility.h:61