VRS
A file format for sensor data.
Loading...
Searching...
No Matches
RecordFormat.h
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <map>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "Record.h"
25
26namespace vrs {
27
28using std::map;
29using std::pair;
30using std::string;
31using std::unique_ptr;
32using std::vector;
33
35enum class ContentType : uint8_t {
36 CUSTOM = 0,
37 EMPTY,
39 IMAGE,
40 AUDIO,
41 COUNT
42};
43
44string toString(ContentType contentType);
45
49enum class ImageFormat : uint8_t {
50 UNDEFINED = 0,
51 RAW,
52 JPG,
53 PNG,
54 VIDEO,
55 JXL,
57 COUNT
58};
59
60string toString(ImageFormat imageFormat);
61
63enum class PixelFormat : uint8_t {
64 UNDEFINED = 0,
65
66 GREY8 = 1,
67 BGR8,
68 DEPTH32F,
69 RGB8,
72 RGBA8,
73 RGB10,
74 RGB12,
75 GREY10,
76 GREY12,
77 GREY16,
78 RGB32F,
79 SCALAR64F,
80 YUY2,
83 RGBA32F,
85 RAW10,
91
92 COUNT,
93};
94
95string toString(PixelFormat pixelFormat);
96
98enum class AudioFormat : uint8_t {
99 UNDEFINED = 0,
100 PCM = 1,
101 OPUS = 2,
102 COUNT
103};
104
106string toString(AudioFormat audioFormat);
107
109enum class AudioSampleFormat : uint8_t {
110 UNDEFINED = 0,
111 S8,
112 U8,
113 A_LAW,
114 MU_LAW,
115 S16_LE,
116 U16_LE,
117 S16_BE,
118 U16_BE,
119 S24_LE,
120 U24_LE,
121 S24_BE,
122 U24_BE,
123 S32_LE,
124 U32_LE,
125 S32_BE,
126 U32_BE,
127 F32_LE,
128 F32_BE,
129 F64_LE,
130 F64_BE,
131 COUNT
132};
133
135string toString(AudioSampleFormat audioSampleFormat);
136
137class ContentParser; // to workaround not being able to forward declare istringstream.
138class RecordFormat;
139
142 public:
143 static constexpr uint8_t kQualityUndefined = 255;
144 static constexpr double kInvalidTimestamp = -1E-308; // arbitrary unrealistic value
145
146 ImageContentBlockSpec() = default;
147
149 ImageContentBlockSpec(ImageContentBlockSpec&&) noexcept = default;
151 const ImageContentBlockSpec& imageSpec,
152 double keyFrameTimestamp,
153 uint32_t keyFrameIndex);
154
157 ImageFormat imageFormat,
158 PixelFormat pixelFormat,
159 uint32_t width = 0,
160 uint32_t height = 0,
161 uint32_t stride = 0,
162 uint32_t stride2 = 0,
163 string codecName = {},
164 uint8_t codecQuality = kQualityUndefined,
165 double keyFrameTimestamp = kInvalidTimestamp,
166 uint32_t keyFrameIndex = 0);
167
169 /* implicit */ ImageContentBlockSpec(
170 ImageFormat imageFormat,
171 uint32_t width = 0,
172 uint32_t height = 0);
173
176 PixelFormat pixelFormat,
177 uint32_t width,
178 uint32_t height,
179 uint32_t stride = 0,
180 uint32_t stride2 = 0
181 );
182
185 ImageFormat imageFormat,
186 string codecName,
187 uint8_t codecQuality = kQualityUndefined,
189 uint32_t width = 0,
190 uint32_t height = 0,
191 uint32_t stride = 0,
192 uint32_t stride2 = 0);
193
196 string codecName,
197 uint8_t codecQuality,
198 PixelFormat pixelFormat,
199 uint32_t width,
200 uint32_t height,
201 uint32_t stride = 0,
202 uint32_t stride2 = 0);
203
205 explicit ImageContentBlockSpec(const string& formatStr);
206
207 ~ImageContentBlockSpec() = default;
208
209 void init(
210 PixelFormat pixelFormat,
211 uint32_t width = 0,
212 uint32_t height = 0,
213 uint32_t stride = 0,
214 uint32_t stride2 = 0,
215 string codecName = {},
216 uint8_t codecQuality = kQualityUndefined,
217 double keyFrameTimestamp = kInvalidTimestamp,
218 uint32_t keyFrameIndex = 0);
219
221 void set(ContentParser& parser);
223 void clear();
224
227
230 string asString() const;
231
234 size_t getBlockSize() const;
235
238 size_t getRawImageSize() const;
239
243
245 bool operator==(const ImageContentBlockSpec& rhs) const;
246 bool operator!=(const ImageContentBlockSpec& rhs) const;
247
250 return imageFormat_;
251 }
252
254 string getImageFormatAsString() const;
255
258 return pixelFormat_;
259 }
261 string getPixelFormatAsString() const;
263 uint32_t getWidth() const {
264 return width_;
265 }
267 uint32_t getHeight() const {
268 return height_;
269 }
271 uint32_t getStride() const;
274 uint32_t getRawStride() const {
275 return stride_;
276 }
277 uint32_t getRawStride2() const {
278 return stride2_;
279 }
281 uint32_t getDefaultStride() const;
283 uint32_t getDefaultStride2() const;
284
286 uint32_t getPlaneCount() const {
287 return getPlaneCount(pixelFormat_);
288 }
289
292 uint32_t getPlaneStride(uint32_t planeIndex) const;
293
296 uint32_t getPlaneHeight(uint32_t planeIndex) const;
297
302 uint8_t getChannelCountPerPixel() const {
303 return getChannelCountPerPixel(pixelFormat_);
304 }
309 size_t getBytesPerPixel() const {
310 return getBytesPerPixel(pixelFormat_);
311 }
312
315 const string& getCodecName() const {
316 return codecName_;
317 }
321 uint8_t getCodecQuality() const {
322 return isQualityValid(codecQuality_) ? codecQuality_ : kQualityUndefined;
323 }
324
326 inline static bool isQualityValid(uint8_t quality) {
327 return quality <= 100;
328 }
329
331 double getKeyFrameTimestamp() const {
332 return keyFrameTimestamp_;
333 }
337 uint32_t getKeyFrameIndex() const {
338 return keyFrameIndex_;
339 }
340
342 static uint8_t getChannelCountPerPixel(PixelFormat pixel);
344 static size_t getBytesPerPixel(PixelFormat pixel);
345
347 static string getPixelFormatAsString(PixelFormat pixelFormat) {
348 return toString(pixelFormat);
349 }
350
352 static uint32_t getPlaneCount(PixelFormat pixelFormat);
353
356 bool sanityCheckStrides() const;
357
358 private:
361 uint32_t width_{0};
362 uint32_t height_{0};
363 uint32_t stride_{0}; // Stride (bytes between lines) for the first pixel plane
364 uint32_t stride2_{0}; // Stride for the other planes (same for all)
365 // for ImageFormat::VIDEO
366 string codecName_;
367 double keyFrameTimestamp_{kInvalidTimestamp};
368 uint32_t keyFrameIndex_{0};
369 uint8_t codecQuality_{kQualityUndefined};
370};
371
374 public:
375 AudioContentBlockSpec() = default;
378 AudioContentBlockSpec(AudioContentBlockSpec&&) noexcept = default;
380 explicit AudioContentBlockSpec(AudioFormat audioFormat, uint8_t channelCount = 0);
382 AudioFormat audioFormat,
383 AudioSampleFormat sampleFormat,
384 uint8_t channelCount = 0,
385 uint8_t sampleFrameStride = 0,
386 uint32_t sampleFrameRate = 0,
387 uint32_t sampleFrameCount = 0,
388 uint8_t stereoPairCount = 0);
389 ~AudioContentBlockSpec() = default;
390
393 explicit AudioContentBlockSpec(const string& formatStr);
394
397 void set(ContentParser& parser);
399 void clear();
400
401 AudioContentBlockSpec& operator=(const AudioContentBlockSpec&) = default;
402 AudioContentBlockSpec& operator=(AudioContentBlockSpec&&) noexcept = default;
403
404 bool operator==(const AudioContentBlockSpec& rhs) const;
405 bool operator!=(const AudioContentBlockSpec& rhs) const {
406 return !operator==(rhs);
407 }
410 string asString() const;
411
413 size_t getBlockSize() const;
414
416 size_t getPcmBlockSize() const;
417
419 bool isCompatibleWith(const AudioContentBlockSpec& rhs) const;
422 return audioFormat_;
423 }
426 return sampleFormat_;
427 }
429 string getSampleFormatAsString() const;
431 bool isLittleEndian() const {
432 return isLittleEndian(sampleFormat_);
433 }
435 bool isIEEEFloat() const {
436 return isIEEEFloat(sampleFormat_);
437 }
439 uint8_t getBitsPerSample() const {
440 return getBitsPerSample(sampleFormat_);
441 }
443 uint8_t getBytesPerSample() const {
444 return (getBitsPerSample(sampleFormat_) + 7) / 8; // round up
445 }
447 uint8_t getSampleFrameStride() const;
449 uint8_t getChannelCount() const {
450 return channelCount_;
451 }
453 uint32_t getSampleRate() const {
454 return sampleFrameRate_;
455 }
457 uint32_t getSampleCount() const {
458 return sampleFrameCount_;
459 }
461 void setSampleCount(uint32_t sampleCount) {
462 sampleFrameCount_ = sampleCount;
463 }
464
465 uint8_t getStereoPairCount() const {
466 return stereoPairCount_;
467 }
468
471 bool isSampleBlockFormatDefined() const;
472
474 static bool isLittleEndian(AudioSampleFormat sampleFormat);
476 static bool isIEEEFloat(AudioSampleFormat sampleFormat);
478 static uint8_t getBitsPerSample(AudioSampleFormat sampleFormat);
480 static uint8_t getBytesPerSample(AudioSampleFormat sampleFormat);
482 static string getSampleFormatAsString(AudioSampleFormat sampleFormat) {
483 return toString(sampleFormat);
484 }
485
486 private:
487 AudioFormat audioFormat_{};
488 AudioSampleFormat sampleFormat_{};
489 uint8_t sampleFrameStride_{};
490 uint8_t channelCount_{};
491 uint32_t sampleFrameRate_{};
492 uint32_t sampleFrameCount_{};
493 uint8_t stereoPairCount_{};
494};
495
509 public:
511 static const size_t kSizeUnknown;
512
514 /* implicit */ ContentBlock(ContentType type = ContentType::EMPTY, size_t size = kSizeUnknown);
515
517 explicit ContentBlock(const string& formatStr);
518
520 /* implicit */ ContentBlock(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0);
521
524 std::string codecName,
525 uint8_t codecQuality,
527 uint32_t width = 0,
528 uint32_t height = 0,
529 uint32_t stride = 0,
530 uint32_t stride2 = 0);
531
534 PixelFormat pixelFormat,
535 uint32_t width,
536 uint32_t height,
537 uint32_t stride = 0,
538 uint32_t stride2 = 0);
539
540 /* implicit */ ContentBlock(const ImageContentBlockSpec& imageSpec, size_t size = kSizeUnknown);
541 /* implicit */ ContentBlock(
542 ImageContentBlockSpec&& imageSpec,
543 size_t size = kSizeUnknown) noexcept;
545 const ContentBlock& imageContentBlock,
546 double keyFrameTimestamp,
547 uint32_t keyFrameIndex);
548
550 /* implicit */ ContentBlock(AudioFormat audioFormat, uint8_t channelCount = 0);
551 /* implicit */ ContentBlock(const AudioContentBlockSpec& audioSpec, size_t size);
552
555 AudioFormat audioFormat,
556 AudioSampleFormat sampleFormat,
557 uint8_t numChannels = 0,
558 uint8_t sampleFrameStride = 0,
559 uint32_t sampleRate = 0,
560 uint32_t sampleCount = 0,
561 uint8_t stereoPairCount = 0);
562
564 ContentBlock(const ContentBlock&) = default;
565 ContentBlock(ContentBlock&&) noexcept = default;
566
568 ContentBlock(const ContentBlock& other, size_t size)
569 : contentType_{other.contentType_}, size_{size} {
570 if (contentType_ == ContentType::IMAGE) {
571 imageSpec_ = other.imageSpec_;
572 } else if (contentType_ == ContentType::AUDIO) {
573 audioSpec_ = other.audioSpec_;
574 } else if (contentType_ == ContentType::CUSTOM) {
575 customContentBlockFormat_ = other.customContentBlockFormat_;
576 }
577 }
578
579 ~ContentBlock() = default;
580
581 ContentBlock& operator=(const ContentBlock& rhs) = default;
582 ContentBlock& operator=(ContentBlock&& rhs) noexcept = default;
583
585 string asString() const;
586
588 size_t getBlockSize() const;
589
592 return contentType_;
593 }
594
598 return customContentBlockFormat_;
599 }
600
601 bool operator==(const ContentBlock& rhs) const;
602
603 bool operator!=(const ContentBlock& rhs) const {
604 return !operator==(rhs);
605 }
606
608 RecordFormat operator+(const ContentBlock&) const;
609
611 const ImageContentBlockSpec& image() const;
613 const AudioContentBlockSpec& audio() const;
614
615 protected:
616 ContentType contentType_ = ContentType::EMPTY;
617 size_t size_ = kSizeUnknown;
618 ImageContentBlockSpec imageSpec_;
619 AudioContentBlockSpec audioSpec_;
620 string customContentBlockFormat_;
621};
622
624 public:
625 explicit CustomContentBlock(const string& customContentBlockFormat, size_t size = kSizeUnknown);
626 explicit CustomContentBlock(size_t size = kSizeUnknown);
627};
628
630using RecordFormatMap = map<pair<Record::Type, uint32_t>, RecordFormat>;
631
641 public:
643 RecordableTypeId typeId,
644 Record::Type recordType,
645 uint32_t formatVersion,
646 size_t blockIndex)
647 : typeId(typeId),
648 recordType(recordType),
649 formatVersion(formatVersion),
650 blockIndex(blockIndex) {}
651
652 RecordableTypeId getRecordableTypeId() const {
653 return typeId;
654 }
655
656 Record::Type getRecordType() const {
657 return recordType;
658 }
659
660 uint32_t getFormatVersion() const {
661 return formatVersion;
662 }
663
664 size_t getBlockIndex() const {
665 return blockIndex;
666 }
667
668 private:
669 RecordableTypeId typeId;
670 Record::Type recordType;
671 uint32_t formatVersion;
672 size_t blockIndex;
673};
674
685 public:
687 RecordFormat() = default;
689 RecordFormat(const RecordFormat&) = default;
690 /* implicit */ RecordFormat(RecordFormat&&) noexcept = default;
691 ~RecordFormat() = default;
692
693 RecordFormat& operator=(const RecordFormat&) = default;
694 RecordFormat& operator=(RecordFormat&&) noexcept = default;
695
699 explicit RecordFormat(const string& format) {
700 set(format);
701 }
705 explicit RecordFormat(const char* format) {
706 set(format);
707 }
709 /* implicit */ RecordFormat(const ContentBlock& block) {
710 blocks_.emplace_back(block);
711 }
713 /* implicit */ RecordFormat(ContentBlock&& block) noexcept {
714 blocks_.emplace_back(std::move(block));
715 }
717 RecordFormat(const ContentBlock& first, const ContentBlock& second) {
718 blocks_.emplace_back(first);
719 blocks_.emplace_back(second);
720 }
722 RecordFormat(ContentBlock&& first, ContentBlock&& second) noexcept {
723 blocks_.emplace_back(std::move(first));
724 blocks_.emplace_back(std::move(second));
725 }
730 /* implicit */ RecordFormat(ContentType type, size_t size = ContentBlock::kSizeUnknown) {
731 blocks_.emplace_back(type, size);
732 }
733
736 blocks_.emplace_back(block);
737 return *this;
738 }
741 blocks_.emplace_back(std::move(block));
742 return *this;
743 }
744
745 bool operator==(const RecordFormat& rhs) const;
746 bool operator!=(const RecordFormat& rhs) const {
747 return !operator==(rhs);
748 }
749
750 void clear() {
751 blocks_.clear();
752 }
753
756 void set(const string& format);
759 string asString() const;
760
763 size_t getRecordSize() const;
766 size_t getUsedBlocksCount() const;
770 size_t getBlocksOfTypeCount(ContentType type) const;
774 const ContentBlock& getContentBlock(size_t index) const;
778 return getContentBlock(0);
779 }
784 size_t getRemainingBlocksSize(size_t firstBlock) const;
791 size_t getBlockSize(size_t blockIndex, size_t remainingSize) const;
792
793 // Static VRS dedicated helper methods, for RecordFormat & DataLayout purposes.
794
796 static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion);
797 static string getDataLayoutTagName(Record::Type type, uint32_t version, size_t blockIndex);
800 static bool parseRecordFormatTagName(
801 const string& tagName,
802 Record::Type& recordType,
803 uint32_t& formatVersion);
804
807 static bool addRecordFormat(
808 map<string, string>& inOutRecordFormatRegister,
809 Record::Type recordType,
810 uint32_t formatVersion,
811 const RecordFormat& format,
812 const vector<const DataLayout*>& layouts);
813
814 static void getRecordFormats(
815 const map<string, string>& recordFormatRegister,
816 RecordFormatMap& outFormats);
817
818 static unique_ptr<DataLayout> getDataLayout(
819 const map<string, string>& recordFormatRegister,
820 const ContentBlockId& blockId);
821
822 private:
823 vector<ContentBlock> blocks_;
824};
825
826} // namespace vrs
Specification of an audio content block.
Definition RecordFormat.h:373
uint8_t getChannelCount() const
Get the number of audio channels in each sample frame (not in the content block).
Definition RecordFormat.h:449
void setSampleCount(uint32_t sampleCount)
Set the number of audio sample frames in the content block.
Definition RecordFormat.h:461
string asString() const
Definition RecordFormat.cpp:777
uint8_t getBitsPerSample() const
Get the number of bits per audio sample.
Definition RecordFormat.h:439
AudioContentBlockSpec(const AudioContentBlockSpec &)=default
Default copy constructor.
bool isLittleEndian() const
Tell if the audio sample format is little endian.
Definition RecordFormat.h:431
bool isSampleBlockFormatDefined() const
Definition RecordFormat.cpp:830
size_t getPcmBlockSize() const
Assuming PCM, get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:806
uint32_t getSampleCount() const
Get the number of audio sample frames in the content block.
Definition RecordFormat.h:457
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:717
uint8_t getBytesPerSample() const
Get the number of bytes per audio sample.
Definition RecordFormat.h:443
uint8_t getSampleFrameStride() const
Number of bytes used by a group of synchronous audio samples, including padding.
Definition RecordFormat.cpp:924
uint32_t getSampleRate() const
Get the audio frame sample rate.
Definition RecordFormat.h:453
bool isIEEEFloat() const
Tell if the audio sample format is an IEEE float.
Definition RecordFormat.h:435
AudioFormat getAudioFormat() const
Get audio format.
Definition RecordFormat.h:421
AudioSampleFormat getSampleFormat() const
Get audio sample format.
Definition RecordFormat.h:425
size_t getBlockSize() const
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:802
string getSampleFormatAsString() const
Get audio sample format as a string.
Definition RecordFormat.cpp:826
bool isCompatibleWith(const AudioContentBlockSpec &rhs) const
Tell if two audio block have identical audio formats.
Definition RecordFormat.cpp:820
static string getSampleFormatAsString(AudioSampleFormat sampleFormat)
Get an audio sample format as a string.
Definition RecordFormat.h:482
Specification of a VRS record content block.
Definition RecordFormat.h:508
size_t getBlockSize() const
Get the content block size, if available or calculable.
Definition RecordFormat.cpp:1069
ContentBlock(const ContentBlock &)=default
Default copy constructor.
string asString() const
Conversion to string, to store on disk & reconstruct later using constructor.
Definition RecordFormat.cpp:1038
const ImageContentBlockSpec & image() const
Get the image content spec. Requires the content block to be of type ContentType::IMAGE.
Definition RecordFormat.cpp:1111
ContentBlock(ContentType type=ContentType::EMPTY, size_t size=kSizeUnknown)
Very generic block description.
Definition RecordFormat.cpp:990
ContentType getContentType() const
Get the ContentType of the block.
Definition RecordFormat.h:591
string getCustomContentBlockFormat() const
Definition RecordFormat.h:597
const AudioContentBlockSpec & audio() const
Get the audio content spec. Requires the content block to be of type ContentType::AUDIO.
Definition RecordFormat.cpp:1116
RecordFormat operator+(const ContentBlock &) const
Assembly operator, to construct a RecordFormat for ContentBlock parts.
Definition RecordFormat.cpp:1107
ContentBlock(std::string codecName, uint8_t codecQuality, PixelFormat pixelFormat=PixelFormat::UNDEFINED, uint32_t width=0, uint32_t height=0, uint32_t stride=0, uint32_t stride2=0)
Image formats with custom codec encoding.
static const size_t kSizeUnknown
Special value used to represent an unknown block size.
Definition RecordFormat.h:511
Helper to identify a particular content block within a file.
Definition RecordFormat.h:640
RecordFormat string parsing helper class.
Definition RecordFormat.cpp:37
Definition RecordFormat.h:623
Specification of an image content block.
Definition RecordFormat.h:141
ImageContentBlockSpec & operator=(const ImageContentBlockSpec &)=default
Default copy assignment.
void set(ContentParser &parser)
When constructing from a string.
Definition RecordFormat.cpp:380
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:337
uint32_t getDefaultStride2() const
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value)
Definition RecordFormat.cpp:584
uint8_t getCodecQuality() const
Definition RecordFormat.h:321
string getPixelFormatAsString() const
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.cpp:639
uint32_t getKeyFrameIndex() const
Definition RecordFormat.h:337
string asString() const
Definition RecordFormat.cpp:425
size_t getBytesPerPixel() const
Definition RecordFormat.h:309
uint32_t getHeight() const
Get image height, or 0 if unknown/unspecified.
Definition RecordFormat.h:267
string getImageFormatAsString() const
Get Image format as string.
Definition RecordFormat.cpp:643
uint32_t getPlaneHeight(uint32_t planeIndex) const
Definition RecordFormat.cpp:601
uint32_t getStride() const
Get image stride (number of bytes between rows) for the first plane.
Definition RecordFormat.cpp:647
PixelFormat getPixelFormat() const
Get Pixel format.
Definition RecordFormat.h:257
static string getPixelFormatAsString(PixelFormat pixelFormat)
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.h:347
const string & getCodecName() const
Definition RecordFormat.h:315
uint32_t getPlaneStride(uint32_t planeIndex) const
Definition RecordFormat.cpp:574
bool sanityCheckStrides() const
Definition RecordFormat.cpp:561
size_t getRawImageSize() const
Definition RecordFormat.cpp:625
uint32_t getRawStride() const
Definition RecordFormat.h:274
size_t getBlockSize() const
Definition RecordFormat.cpp:621
ImageContentBlockSpec core() const
Return base of format (no codec quality nor key frame info)
Definition RecordFormat.cpp:348
double getKeyFrameTimestamp() const
Get timestamp of the key frame of the group of frames this video frame belongs to.
Definition RecordFormat.h:331
uint32_t getDefaultStride() const
Get default stride for plane 0 when stride isn't specified (minimum stride value)
Definition RecordFormat.cpp:652
static bool isQualityValid(uint8_t quality)
Validate that a quality value is valid.
Definition RecordFormat.h:326
uint8_t getChannelCountPerPixel() const
Definition RecordFormat.h:302
ImageFormat getImageFormat() const
Get image format.
Definition RecordFormat.h:249
uint32_t getPlaneCount() const
Get the number of planes for this pixel format.
Definition RecordFormat.h:286
uint32_t getWidth() const
Get image width, or 0 if unknown/unspecified.
Definition RecordFormat.h:263
Description of the format of a VRS record as a succession of typed blocks of content.
Definition RecordFormat.h:684
size_t getRemainingBlocksSize(size_t firstBlock) const
Definition RecordFormat.cpp:1164
static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion)
Names of the VRS stream tags used for RecordFormat descriptions.
Definition RecordFormat.cpp:1221
RecordFormat(const RecordFormat &)=default
Default copy constructor.
RecordFormat(ContentBlock &&first, ContentBlock &&second) noexcept
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:722
static bool parseRecordFormatTagName(const string &tagName, Record::Type &recordType, uint32_t &formatVersion)
Definition RecordFormat.cpp:1268
size_t getBlocksOfTypeCount(ContentType type) const
Definition RecordFormat.cpp:1186
RecordFormat & operator+(ContentBlock &&block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:740
static bool addRecordFormat(map< string, string > &inOutRecordFormatRegister, Record::Type recordType, uint32_t formatVersion, const RecordFormat &format, const vector< const DataLayout * > &layouts)
Definition RecordFormat.cpp:1290
RecordFormat(const char *format)
Definition RecordFormat.h:705
size_t getBlockSize(size_t blockIndex, size_t remainingSize) const
Definition RecordFormat.cpp:1204
RecordFormat(const ContentBlock &block)
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:709
RecordFormat(ContentType type, size_t size=ContentBlock::kSizeUnknown)
Definition RecordFormat.h:730
size_t getUsedBlocksCount() const
Definition RecordFormat.cpp:1176
RecordFormat()=default
Empty record format definition.
RecordFormat(ContentBlock &&block) noexcept
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:713
const ContentBlock & getFirstContentBlock() const
Definition RecordFormat.h:777
RecordFormat(const ContentBlock &first, const ContentBlock &second)
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:717
void set(const string &format)
Definition RecordFormat.cpp:1141
size_t getRecordSize() const
Definition RecordFormat.cpp:1160
const ContentBlock & getContentBlock(size_t index) const
Definition RecordFormat.cpp:1196
string asString() const
Definition RecordFormat.cpp:1149
RecordFormat & operator+(const ContentBlock &block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:735
Type
Definition Record.h:88
Definition Compressor.cpp:113
map< pair< Record::Type, uint32_t >, RecordFormat > RecordFormatMap
Map a pair of record type/format version to a record format, for a particular stream.
Definition RecordFormat.h:630
PixelFormat
Pixel format type, then the image format is ImageFormat::RAW.
Definition RecordFormat.h:63
@ GREY12
uses 16 bit little-endian values. 4 most significant bits are unused and set to 0.
@ UNDEFINED
Unknown/unrecognized.
@ GREY10
uses 16 bit little-endian values. 6 most significant bits are unused and set to 0.
@ RGB8
3 uint8_t values, red + green + blue.
@ DEPTH32F
1 32 bit float value, representing a depth.
@ YUV_420_NV21
Y plane + half width/half height chroma plane with weaved V and U values.
@ RAW10
https://developer.android.com/reference/android/graphics/ImageFormat#RAW10
@ RAW10_BAYER_RGGB
10 bit per pixel, RGGB bayer pattern.
@ YUV_I420_PLANAR
same as YUV_I420_SPLIT, but more conventional name.
@ YUV_I420_SPLIT
3 uint8_t values, 4:2:0. The 3 planes are stored separately.
@ RGBA32F
1 32 bit float value.
@ BAYER8_RGGB
8 bit per pixel, RGGB bayer pattern.
@ RAW10_BAYER_BGGR
10 bit per pixel, BGGR bayer pattern.
@ RGB10
uses 16 bit little-endian values. 6 most significant bits are unused and set to 0.
@ RGBA8
4 uint8_t values, red + blue + green + alpha.
@ GREY8
1 uint8_t.
@ YUY2
4 uint8_t values, 4:2:2, single plane.
@ YUV_420_NV12
Y plane + half width/half height chroma plane with weaved U and V values.
@ RGB12
uses 16 bit little-endian values. 4 most significant bits are unused and set to 0.
@ RGB32F
1 32 bit float value.
@ GREY10PACKED
10 bit per pixel, packed in successive little-endian bits, in 40 bits blocks.
@ SCALAR64F
1 64 bit float value, representing high precision image data.
@ BGR8
3 uint8_t values, blue + green + red.
@ GREY16
uses 16 bit little-endian values.
AudioSampleFormat
Audio sample format, when the audio type is AudioFormat::PCM.
Definition RecordFormat.h:109
@ U32_LE
LPCM, unsigned, 32 bit little endian.
@ F64_BE
LPCM, 64 bit float big endian.
@ U16_BE
LPCM, unsigned, 16 bit big endian.
@ U32_BE
LPCM, unsigned, 32 bit big endian.
@ F64_LE
LPCM, 64 bit float little endian.
@ S32_BE
LPCM, signed, 32 bit big endian.
@ U8
LPCM, unsigned, 8 bit.
@ S16_BE
LPCM, signed, 16 bit big endian.
@ F32_LE
LPCM, 32 bit float little endian.
@ S24_LE
LPCM, signed, 24 bit little endian.
@ S16_LE
LPCM, signed, 16 bit little endian.
@ U24_BE
LPCM, unsigned, 24 bit big endian.
@ S24_BE
LPCM, signed, 24 bit big endian.
@ S8
LPCM, signed, 8 bit.
@ MU_LAW
mu-law PCM, 8 bit.
@ U24_LE
LPCM, unsigned, 24 bit little endian.
@ U16_LE
LPCM, unsigned, 16 bit little endian.
@ F32_BE
LPCM, 32 bit float big endian.
@ A_LAW
a-law PCM, 8 bit.
@ S32_LE
LPCM, signed, 32 bit little endian.
ImageFormat
Definition RecordFormat.h:49
@ UNDEFINED
Unknown/unspecified.
@ CUSTOM_CODEC
Images encoded with a custom or experimental codec.
@ PNG
PNG data.
@ RAW
Raw pixel data.
@ JPG
JPEG data.
@ JXL
JPEG-XL data.
@ VIDEO
Video codec encoded images.
AudioFormat
Audio format type.
Definition RecordFormat.h:98
@ PCM
Raw PCM audio data.
@ OPUS
Audio data compressed using Opus. https://opus-codec.org/.
RecordableTypeId
VRS stream type or class identifier enum.
Definition StreamId.h:49
ContentType
Type of a record's block.
Definition RecordFormat.h:35
@ IMAGE
Image block.
@ DATA_LAYOUT
DataLayout block.
@ CUSTOM
Custom format, or unknown/unspecified data format.
@ EMPTY
No data (internal).
@ AUDIO
Audio block.