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
55 TV,
56 Full,
57 Unknown
58 };
59
81
101
108 BT709,
109 Gamma22,
110 Gamma28,
111 SMPTE170M,
112 SMPTE240M,
113 Linear,
114 Log,
115 LogSqrt,
117 BT1361,
119 BT2020_10,
120 BT2020_12,
121 SMPTE2084,
122 SMPTE428,
123 ARIB_B67,
124 Unknown
125 };
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}
Pixel format plus colorimetry.
Definition color.hxx:225
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.
Media property value types.
Primaries
Chromaticity primaries.
Definition color.hxx:86
Transfer
Transfer characteristics.
Definition color.hxx:106
Space
YUV / RGB matrix coefficients.
Definition color.hxx:64
@ BT2020CL
BT.2020 constant luminance.
@ Unknown
Unlisted backend value.
@ BT2020NCL
BT.2020 non-constant luminance.
constexpr const char * ToString(ChannelLayout layout) noexcept
Converts a ChannelLayout to a string.
Definition channel_layout.hxx:74
Range
Luma/chroma sample range.
Definition color.hxx:53
@ Unknown
Unlisted backend value.
PixelFormat
Curated pixel formats.
Definition pixel_format.hxx:54
#define STORMBYTE_MULTIMEDIA_PUBLIC
Imported symbol.
Definition visibility.h:47