libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
st2110video.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
13#include <cstddef>
14#include <cstdint>
15#include <promeki/config.h>
16#if PROMEKI_ENABLE_PROAV
17#include <promeki/pixelformat.h>
18#endif
20#include <promeki/enums_video.h>
21#include <promeki/framerate.h>
22#include <promeki/map.h>
23#include <promeki/namespace.h>
24#include <promeki/pixelaspect.h>
25#include <promeki/string.h>
26
27PROMEKI_NAMESPACE_BEGIN
28
94class St2110Video {
95 public:
110 struct Pgroup {
111 size_t octets = 0;
112 size_t pixels = 0;
113 size_t samples = 0;
114 };
115
121 static constexpr size_t MaxSamplesPerPgroup = 12;
122
135 static Pgroup pgroup(const St2110Sampling &sampling, const St2110Depth &depth);
136
142 static bool isSupported(const St2110Sampling &sampling, const St2110Depth &depth);
143
152 static int bitsPerSample(const St2110Depth &depth);
153
159 static bool isFloatDepth(const St2110Depth &depth);
160
185 static size_t packSamplesBE(uint8_t *dst, size_t dstCap,
186 const uint16_t *samples, size_t nSamples,
187 int depthBits);
188
199 static size_t unpackSamplesBE(const uint8_t *src, size_t srcSize,
200 uint16_t *samples, size_t nSamples,
201 int depthBits);
202
226 static size_t packRow(const St2110Sampling &sampling, const St2110Depth &depth,
227 size_t nPixels, const uint16_t *samples,
228 uint8_t *dst, size_t dstCap);
229
240 static size_t unpackRow(const St2110Sampling &sampling, const St2110Depth &depth,
241 size_t nPixels, const uint8_t *src, size_t srcSize,
242 uint16_t *samples);
243
252 static size_t rowOctets(const St2110Sampling &sampling, const St2110Depth &depth,
253 size_t nPixels);
254
262 static size_t rowSamples(const St2110Sampling &sampling, const St2110Depth &depth,
263 size_t nPixels);
264
265 // -----------------------------------------------------
266 // Wire-form ↔ project-form conversion for the §7 SDP
267 // fmtp parameter values. The wire form is what the
268 // standard's tables spell (e.g. @c YCbCr-4:2:2,
269 // @c ST2065-1, @c BT2100LINPQ, @c 2110GPM,
270 // @c FULLPROTECT); the project form uses CamelCase
271 // identifiers per the [[feedback-enum-naming-camelcase]]
272 // convention (e.g. @c YCbCr422, @c St2065_1,
273 // @c Bt2100LinPq, @c Gpm, @c FullProtect). These
274 // helpers are the single mapping point — the SDP
275 // builder / parser only ever calls into here.
276 // -----------------------------------------------------
277
279 static String samplingWire(const St2110Sampling &sampling);
281 static String depthWire(const St2110Depth &depth);
283 static String colorimetryWire(const St2110Colorimetry &c);
285 static String tcsWire(const St2110Tcs &t);
287 static String rangeWire(const St2110Range &r);
289 static String packingModeWire(const St2110PackingMode &p);
290
293 static St2110Sampling samplingFromWire(const String &s);
294 static St2110Depth depthFromWire(const String &s);
295 static St2110Colorimetry colorimetryFromWire(const String &s);
296 static St2110Tcs tcsFromWire(const String &s);
297 static St2110Range rangeFromWire(const String &s);
298 static St2110PackingMode packingModeFromWire(const String &s);
299
313 static String ssnFor(const St2110Colorimetry &colorimetry, const St2110Tcs &tcs);
314
324 struct Fmtp {
325 // §7.2 Required Media Type Parameters.
326 St2110Sampling sampling;
327 St2110Depth depth;
328 uint32_t width = 0;
329 uint32_t height = 0;
330 FrameRate exactFrameRate;
331 St2110Colorimetry colorimetry;
332 St2110PackingMode pm{St2110PackingMode::Gpm};
333
334 // §7.3 Media Type Parameters with default values.
335 bool interlace = false;
336 bool segmented = false;
337 St2110Tcs tcs{St2110Tcs::Sdr};
338 St2110Range range{St2110Range::Narrow};
339 uint32_t maxUdp = 0;
340 PixelAspect par;
341 String ssnOverride;
342 };
343
356 static String frameRateToWire(const FrameRate &fr);
357
377 static String toFmtp(const Fmtp &fmtp);
378
406 static Fmtp fromFmtp(const Map<String, String> &params);
407
427 static VideoScanMode fmtpScanMode(const Fmtp &fmtp);
428
441 static void setFmtpScanMode(Fmtp &fmtp, VideoScanMode mode);
442
443#if PROMEKI_ENABLE_PROAV
456 struct PixelFormatBridge {
457 St2110Sampling sampling;
458 St2110Depth depth;
459 St2110Colorimetry colorimetry;
460 St2110Tcs tcs{St2110Tcs::Sdr};
461 St2110Range range{St2110Range::Narrow};
462 };
463
466 static PixelFormatBridge bridgeForPixelFormat(const PixelFormat &pd);
467
498 static PixelFormat wirePixelFormatFor(const St2110Sampling &sampling,
499 const St2110Depth &depth,
500 const St2110Colorimetry &colorimetry,
501 const St2110Range &range);
502#endif // PROMEKI_ENABLE_PROAV
503};
504
505PROMEKI_NAMESPACE_END
506
507#endif // PROMEKI_ENABLE_NETWORK