libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
hdrdynamic2094_40.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <cstdint>
14#include <promeki/buffer.h>
15#include <promeki/error.h>
16#include <promeki/json.h>
17#include <promeki/list.h>
18#include <promeki/namespace.h>
19#include <promeki/result.h>
20#include <promeki/string.h>
21
22PROMEKI_NAMESPACE_BEGIN
23
24class DataStream;
25
135class HdrDynamic2094_40 {
136 public:
137 PROMEKI_DATATYPE(HdrDynamic2094_40, DataTypeHdrDynamic2094_40, 1)
138
139
140 static constexpr uint8_t MaxWindows = 3;
141
143 static constexpr uint8_t MaxDistributionPercentiles = 15;
144
146 static constexpr uint8_t MaxBezierCurveAnchors = 15;
147
149 static constexpr uint8_t InfoFrameType = 0x81;
150
152 static constexpr uint8_t InfoFrameVersion = 1;
153
161 static constexpr uint32_t HdrPlusOui = 0x90848B;
162
171 struct Window {
172 uint16_t upperLeftCornerX = 0;
173 uint16_t upperLeftCornerY = 0;
174 uint16_t lowerRightCornerX = 0;
175 uint16_t lowerRightCornerY = 0;
176 uint16_t centerOfEllipseX = 0;
177 uint16_t centerOfEllipseY = 0;
178 uint8_t rotationAngle = 0;
179 uint16_t semimajorAxisInternalEllipse = 0;
180 uint16_t semimajorAxisExternalEllipse = 0;
181 uint16_t semiminorAxisExternalEllipse = 0;
182 bool overlapProcessOption = false;
183
184 bool operator==(const Window &o) const;
185 bool operator!=(const Window &o) const { return !(*this == o); }
186 };
187
199 struct ActualPeakLuminance {
200 uint8_t numRows = 0;
201 uint8_t numCols = 0;
202 List<uint8_t> values;
203
205 bool isPresent() const { return numRows > 0 && numCols > 0; }
206
207 bool operator==(const ActualPeakLuminance &o) const;
208 bool operator!=(const ActualPeakLuminance &o) const { return !(*this == o); }
209 };
210
215 struct DistributionMaxRgb {
216 uint8_t percentage = 0;
217 uint32_t percentile = 0;
218
219 bool operator==(const DistributionMaxRgb &o) const {
220 return percentage == o.percentage && percentile == o.percentile;
221 }
222 bool operator!=(const DistributionMaxRgb &o) const { return !(*this == o); }
223 };
224
233 struct ToneMapping {
234 uint16_t kneePointX = 0;
235 uint16_t kneePointY = 0;
236 List<uint16_t> bezierCurveAnchors;
237
238 bool operator==(const ToneMapping &o) const;
239 bool operator!=(const ToneMapping &o) const { return !(*this == o); }
240 };
241
250 struct WindowProcessing {
251 uint32_t maxScl[3] = {0, 0, 0};
252 uint32_t averageMaxRgb = 0;
253 List<DistributionMaxRgb> distribution;
254 uint16_t fractionBrightPixels = 0;
255
256 bool hasToneMapping = false;
257 ToneMapping toneMapping;
258
259 bool hasColorSaturationMapping = false;
260 uint8_t colorSaturationWeight = 0;
261
262 bool operator==(const WindowProcessing &o) const;
263 bool operator!=(const WindowProcessing &o) const { return !(*this == o); }
264 };
265
267 HdrDynamic2094_40();
268
269 // -- Top-level field accessors -----------------------------
270
272 uint8_t applicationVersion() const { return _applicationVersion; }
274 void setApplicationVersion(uint8_t v) { _applicationVersion = v; }
275
279 uint8_t numWindows() const { return _numWindows; }
280
288 void setNumWindows(uint8_t n);
289
297 const List<Window> &extraWindows() const { return _extraWindows; }
299 List<Window> &extraWindows() { return _extraWindows; }
300
306 uint32_t targetedSystemDisplayMaximumLuminance() const {
307 return _targetedSystemDisplayMaximumLuminance;
308 }
310 void setTargetedSystemDisplayMaximumLuminance(uint32_t v) {
311 _targetedSystemDisplayMaximumLuminance = v & 0x07FFFFFFu;
312 }
313
315 const ActualPeakLuminance &targetedSystemDisplayActualPeakLuminance() const {
316 return _targetedSystemDisplayActualPeakLuminance;
317 }
319 ActualPeakLuminance &targetedSystemDisplayActualPeakLuminance() {
320 return _targetedSystemDisplayActualPeakLuminance;
321 }
322
324 const List<WindowProcessing> &windowProcessing() const { return _windowProcessing; }
326 List<WindowProcessing> &windowProcessing() { return _windowProcessing; }
327
329 const ActualPeakLuminance &masteringDisplayActualPeakLuminance() const {
330 return _masteringDisplayActualPeakLuminance;
331 }
333 ActualPeakLuminance &masteringDisplayActualPeakLuminance() {
334 return _masteringDisplayActualPeakLuminance;
335 }
336
337 // -- Wire round-trip ---------------------------------------
338
350 Buffer toBuffer() const;
351
366 static Result<HdrDynamic2094_40> fromBuffer(const void *data, size_t size);
367
369 static Result<HdrDynamic2094_40> fromBuffer(const Buffer &buf);
370
371 // -- Inspection / debugging --------------------------------
372
383 JsonObject toJson() const;
384
386 bool operator==(const HdrDynamic2094_40 &o) const;
388 bool operator!=(const HdrDynamic2094_40 &o) const { return !(*this == o); }
389
391 String toString() const;
392
401 Error writeToStream(DataStream &s) const;
402
407 template <uint32_t V> static Result<HdrDynamic2094_40> readFromStream(DataStream &s);
408
409 private:
410 uint8_t _applicationVersion = 0;
411 uint8_t _numWindows = 1;
412 List<Window> _extraWindows;
413 uint32_t _targetedSystemDisplayMaximumLuminance = 0;
414 ActualPeakLuminance _targetedSystemDisplayActualPeakLuminance;
415 List<WindowProcessing> _windowProcessing;
416 ActualPeakLuminance _masteringDisplayActualPeakLuminance;
417};
418
419PROMEKI_NAMESPACE_END
420
421#endif // PROMEKI_ENABLE_PROAV