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,
90
91 COUNT,
92};
93
94string toString(PixelFormat pixelFormat);
95
97enum class AudioFormat : uint8_t {
98 UNDEFINED = 0,
99 PCM = 1,
100 OPUS = 2,
101 COUNT
102};
103
105string toString(AudioFormat audioFormat);
106
108enum class AudioSampleFormat : uint8_t {
109 UNDEFINED = 0,
110 S8,
111 U8,
112 A_LAW,
113 MU_LAW,
114 S16_LE,
115 U16_LE,
116 S16_BE,
117 U16_BE,
118 S24_LE,
119 U24_LE,
120 S24_BE,
121 U24_BE,
122 S32_LE,
123 U32_LE,
124 S32_BE,
125 U32_BE,
126 F32_LE,
127 F32_BE,
128 F64_LE,
129 F64_BE,
130 COUNT
131};
132
134string toString(AudioSampleFormat audioSampleFormat);
135
136class ContentParser; // to workaround not being able to forward declare istringstream.
137class RecordFormat;
138
141 public:
142 static constexpr uint8_t kQualityUndefined = 255;
143 static constexpr double kInvalidTimestamp = -1E-308; // arbitrary unrealistic value
144
145 ImageContentBlockSpec() = default;
146
148 ImageContentBlockSpec(ImageContentBlockSpec&&) noexcept = default;
150 const ImageContentBlockSpec& imageSpec,
151 double keyFrameTimestamp,
152 uint32_t keyFrameIndex);
153
156 ImageFormat imageFormat,
157 PixelFormat pixelFormat,
158 uint32_t width = 0,
159 uint32_t height = 0,
160 uint32_t stride = 0,
161 uint32_t stride2 = 0,
162 string codecName = {},
163 uint8_t codecQuality = kQualityUndefined,
164 double keyFrameTimestamp = kInvalidTimestamp,
165 uint32_t keyFrameIndex = 0);
166
168 ImageContentBlockSpec(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0);
169
172 PixelFormat pixelFormat,
173 uint32_t width,
174 uint32_t height,
175 uint32_t stride = 0,
176 uint32_t stride2 = 0
177 );
178
181 ImageFormat imageFormat,
182 string codecName,
183 uint8_t codecQuality = kQualityUndefined,
185 uint32_t width = 0,
186 uint32_t height = 0,
187 uint32_t stride = 0,
188 uint32_t stride2 = 0);
189
192 string codecName,
193 uint8_t codecQuality,
194 PixelFormat pixelFormat,
195 uint32_t width,
196 uint32_t height,
197 uint32_t stride = 0,
198 uint32_t stride2 = 0);
199
201 explicit ImageContentBlockSpec(const string& formatStr);
202
203 ~ImageContentBlockSpec() = default;
204
205 void init(
206 PixelFormat pixelFormat,
207 uint32_t width = 0,
208 uint32_t height = 0,
209 uint32_t stride = 0,
210 uint32_t stride2 = 0,
211 string codecName = {},
212 uint8_t codecQuality = kQualityUndefined,
213 double keyFrameTimestamp = kInvalidTimestamp,
214 uint32_t keyFrameIndex = 0);
215
217 void set(ContentParser& parser);
219 void clear();
220
223
226 string asString() const;
227
230 size_t getBlockSize() const;
231
234 size_t getRawImageSize() const;
235
239
241 bool operator==(const ImageContentBlockSpec& rhs) const;
242 bool operator!=(const ImageContentBlockSpec& rhs) const;
243
246 return imageFormat_;
247 }
248
250 string getImageFormatAsString() const;
251
254 return pixelFormat_;
255 }
257 string getPixelFormatAsString() const;
259 uint32_t getWidth() const {
260 return width_;
261 }
263 uint32_t getHeight() const {
264 return height_;
265 }
267 uint32_t getStride() const;
270 uint32_t getRawStride() const {
271 return stride_;
272 }
273 uint32_t getRawStride2() const {
274 return stride2_;
275 }
277 uint32_t getDefaultStride() const;
279 uint32_t getDefaultStride2() const;
280
282 uint32_t getPlaneCount() const {
283 return getPlaneCount(pixelFormat_);
284 }
285
288 uint32_t getPlaneStride(uint32_t planeIndex) const;
289
292 uint32_t getPlaneHeight(uint32_t planeIndex) const;
293
298 uint8_t getChannelCountPerPixel() const {
299 return getChannelCountPerPixel(pixelFormat_);
300 }
305 size_t getBytesPerPixel() const {
306 return getBytesPerPixel(pixelFormat_);
307 }
308
311 const string& getCodecName() const {
312 return codecName_;
313 }
317 uint8_t getCodecQuality() const {
318 return isQualityValid(codecQuality_) ? codecQuality_ : kQualityUndefined;
319 }
320
322 inline static bool isQualityValid(uint8_t quality) {
323 return quality <= 100;
324 }
325
327 double getKeyFrameTimestamp() const {
328 return keyFrameTimestamp_;
329 }
333 uint32_t getKeyFrameIndex() const {
334 return keyFrameIndex_;
335 }
336
338 static uint8_t getChannelCountPerPixel(PixelFormat pixel);
340 static size_t getBytesPerPixel(PixelFormat pixel);
341
343 static string getPixelFormatAsString(PixelFormat pixelFormat) {
344 return toString(pixelFormat);
345 }
346
348 static uint32_t getPlaneCount(PixelFormat pixelFormat);
349
352 bool sanityCheckStrides() const;
353
354 private:
357 uint32_t width_{0};
358 uint32_t height_{0};
359 uint32_t stride_{0}; // Stride (bytes between lines) for the first pixel plane
360 uint32_t stride2_{0}; // Stride for the other planes (same for all)
361 // for ImageFormat::VIDEO
362 string codecName_;
363 double keyFrameTimestamp_{kInvalidTimestamp};
364 uint32_t keyFrameIndex_{0};
365 uint8_t codecQuality_{kQualityUndefined};
366};
367
370 public:
371 AudioContentBlockSpec() = default;
374 AudioContentBlockSpec(AudioContentBlockSpec&&) noexcept = default;
376 explicit AudioContentBlockSpec(AudioFormat audioFormat, uint8_t channelCount = 0);
378 AudioFormat audioFormat,
379 AudioSampleFormat sampleFormat,
380 uint8_t channelCount = 0,
381 uint8_t sampleFrameStride = 0,
382 uint32_t sampleFrameRate = 0,
383 uint32_t sampleFrameCount = 0,
384 uint8_t stereoPairCount = 0);
385 ~AudioContentBlockSpec() = default;
386
389 explicit AudioContentBlockSpec(const string& formatStr);
390
393 void set(ContentParser& parser);
395 void clear();
396
397 AudioContentBlockSpec& operator=(const AudioContentBlockSpec&) = default;
398 AudioContentBlockSpec& operator=(AudioContentBlockSpec&&) noexcept = default;
399
400 bool operator==(const AudioContentBlockSpec& rhs) const;
401 bool operator!=(const AudioContentBlockSpec& rhs) const {
402 return !operator==(rhs);
403 }
406 string asString() const;
407
409 size_t getBlockSize() const;
410
412 size_t getPcmBlockSize() const;
413
415 bool isCompatibleWith(const AudioContentBlockSpec& rhs) const;
418 return audioFormat_;
419 }
422 return sampleFormat_;
423 }
425 string getSampleFormatAsString() const;
427 bool isLittleEndian() const {
428 return isLittleEndian(sampleFormat_);
429 }
431 bool isIEEEFloat() const {
432 return isIEEEFloat(sampleFormat_);
433 }
435 uint8_t getBitsPerSample() const {
436 return getBitsPerSample(sampleFormat_);
437 }
439 uint8_t getBytesPerSample() const {
440 return (getBitsPerSample(sampleFormat_) + 7) / 8; // round up
441 }
443 uint8_t getSampleFrameStride() const;
445 uint8_t getChannelCount() const {
446 return channelCount_;
447 }
449 uint32_t getSampleRate() const {
450 return sampleFrameRate_;
451 }
453 uint32_t getSampleCount() const {
454 return sampleFrameCount_;
455 }
457 void setSampleCount(uint32_t sampleCount) {
458 sampleFrameCount_ = sampleCount;
459 }
460
461 uint8_t getStereoPairCount() const {
462 return stereoPairCount_;
463 }
464
467 bool isSampleBlockFormatDefined() const;
468
470 static bool isLittleEndian(AudioSampleFormat sampleFormat);
472 static bool isIEEEFloat(AudioSampleFormat sampleFormat);
474 static uint8_t getBitsPerSample(AudioSampleFormat sampleFormat);
476 static uint8_t getBytesPerSample(AudioSampleFormat sampleFormat);
478 static string getSampleFormatAsString(AudioSampleFormat sampleFormat) {
479 return toString(sampleFormat);
480 }
481
482 private:
483 AudioFormat audioFormat_{};
484 AudioSampleFormat sampleFormat_{};
485 uint8_t sampleFrameStride_{};
486 uint8_t channelCount_{};
487 uint32_t sampleFrameRate_{};
488 uint32_t sampleFrameCount_{};
489 uint8_t stereoPairCount_{};
490};
491
505 public:
507 static const size_t kSizeUnknown;
508
511
513 explicit ContentBlock(const string& formatStr);
514
516 ContentBlock(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0);
517
520 std::string codecName,
521 uint8_t codecQuality,
523 uint32_t width = 0,
524 uint32_t height = 0,
525 uint32_t stride = 0,
526 uint32_t stride2 = 0);
527
530 PixelFormat pixelFormat,
531 uint32_t width,
532 uint32_t height,
533 uint32_t stride = 0,
534 uint32_t stride2 = 0);
535
536 ContentBlock(const ImageContentBlockSpec& imageSpec, size_t size = kSizeUnknown);
537 ContentBlock(ImageContentBlockSpec&& imageSpec, size_t size = kSizeUnknown) noexcept;
539 const ContentBlock& imageContentBlock,
540 double keyFrameTimestamp,
541 uint32_t keyFrameIndex);
542
544 ContentBlock(AudioFormat audioFormat, uint8_t channelCount = 0);
545 ContentBlock(const AudioContentBlockSpec& audioSpec, size_t size);
546
549 AudioFormat audioFormat,
550 AudioSampleFormat sampleFormat,
551 uint8_t numChannels = 0,
552 uint8_t sampleFrameStride = 0,
553 uint32_t sampleRate = 0,
554 uint32_t sampleCount = 0,
555 uint8_t stereoPairCount = 0);
556
558 ContentBlock(const ContentBlock&) = default;
559 ContentBlock(ContentBlock&&) noexcept = default;
560
562 ContentBlock(const ContentBlock& other, size_t size)
563 : contentType_{other.contentType_}, size_{size} {
564 if (contentType_ == ContentType::IMAGE) {
565 imageSpec_ = other.imageSpec_;
566 } else if (contentType_ == ContentType::AUDIO) {
567 audioSpec_ = other.audioSpec_;
568 } else if (contentType_ == ContentType::CUSTOM) {
569 customContentBlockFormat_ = other.customContentBlockFormat_;
570 }
571 }
572
573 ~ContentBlock() = default;
574
575 ContentBlock& operator=(const ContentBlock& rhs) = default;
576 ContentBlock& operator=(ContentBlock&& rhs) noexcept = default;
577
579 string asString() const;
580
582 size_t getBlockSize() const;
583
586 return contentType_;
587 }
588
592 return customContentBlockFormat_;
593 }
594
595 bool operator==(const ContentBlock& rhs) const;
596
597 bool operator!=(const ContentBlock& rhs) const {
598 return !operator==(rhs);
599 }
600
602 RecordFormat operator+(const ContentBlock&) const;
603
605 const ImageContentBlockSpec& image() const;
607 const AudioContentBlockSpec& audio() const;
608
609 protected:
610 ContentType contentType_ = ContentType::EMPTY;
611 size_t size_ = kSizeUnknown;
612 ImageContentBlockSpec imageSpec_;
613 AudioContentBlockSpec audioSpec_;
614 string customContentBlockFormat_;
615};
616
618 public:
619 explicit CustomContentBlock(const string& customContentBlockFormat, size_t size = kSizeUnknown);
620 explicit CustomContentBlock(size_t size = kSizeUnknown);
621};
622
624using RecordFormatMap = map<pair<Record::Type, uint32_t>, RecordFormat>;
625
635 public:
637 RecordableTypeId typeId,
638 Record::Type recordType,
639 uint32_t formatVersion,
640 size_t blockIndex)
641 : typeId(typeId),
642 recordType(recordType),
643 formatVersion(formatVersion),
644 blockIndex(blockIndex) {}
645
646 RecordableTypeId getRecordableTypeId() const {
647 return typeId;
648 }
649
650 Record::Type getRecordType() const {
651 return recordType;
652 }
653
654 uint32_t getFormatVersion() const {
655 return formatVersion;
656 }
657
658 size_t getBlockIndex() const {
659 return blockIndex;
660 }
661
662 private:
663 RecordableTypeId typeId;
664 Record::Type recordType;
665 uint32_t formatVersion;
666 size_t blockIndex;
667};
668
679 public:
681 RecordFormat() = default;
683 RecordFormat(const RecordFormat&) = default;
684 RecordFormat(RecordFormat&&) noexcept = default;
685 ~RecordFormat() = default;
686
687 RecordFormat& operator=(const RecordFormat&) = default;
688 RecordFormat& operator=(RecordFormat&&) noexcept = default;
689
693 RecordFormat(const string& format) {
694 set(format);
695 }
699 RecordFormat(const char* format) {
700 set(format);
701 }
704 blocks_.emplace_back(block);
705 }
707 RecordFormat(ContentBlock&& block) noexcept {
708 blocks_.emplace_back(std::move(block));
709 }
711 RecordFormat(const ContentBlock& first, const ContentBlock& second) {
712 blocks_.emplace_back(first);
713 blocks_.emplace_back(second);
714 }
716 RecordFormat(ContentBlock&& first, ContentBlock&& second) noexcept {
717 blocks_.emplace_back(std::move(first));
718 blocks_.emplace_back(std::move(second));
719 }
725 blocks_.emplace_back(type, size);
726 }
727
730 blocks_.emplace_back(block);
731 return *this;
732 }
735 blocks_.emplace_back(std::move(block));
736 return *this;
737 }
738
739 bool operator==(const RecordFormat& rhs) const;
740 bool operator!=(const RecordFormat& rhs) const {
741 return !operator==(rhs);
742 }
743
744 void clear() {
745 blocks_.clear();
746 }
747
750 void set(const string& format);
753 string asString() const;
754
757 size_t getRecordSize() const;
760 size_t getUsedBlocksCount() const;
764 size_t getBlocksOfTypeCount(ContentType type) const;
768 const ContentBlock& getContentBlock(size_t index) const;
772 return getContentBlock(0);
773 }
778 size_t getRemainingBlocksSize(size_t firstBlock) const;
785 size_t getBlockSize(size_t blockIndex, size_t remainingSize) const;
786
787 // Static VRS dedicated helper methods, for RecordFormat & DataLayout purposes.
788
790 static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion);
791 static string getDataLayoutTagName(Record::Type type, uint32_t version, size_t blockIndex);
794 static bool parseRecordFormatTagName(
795 const string& tagName,
796 Record::Type& recordType,
797 uint32_t& formatVersion);
798
801 static bool addRecordFormat(
802 map<string, string>& inOutRecordFormatRegister,
803 Record::Type recordType,
804 uint32_t formatVersion,
805 const RecordFormat& format,
806 const vector<const DataLayout*>& layouts);
807
808 static void getRecordFormats(
809 const map<string, string>& recordFormatRegister,
810 RecordFormatMap& outFormats);
811
812 static unique_ptr<DataLayout> getDataLayout(
813 const map<string, string>& recordFormatRegister,
814 const ContentBlockId& blockId);
815
816 private:
817 vector<ContentBlock> blocks_;
818};
819
820} // namespace vrs
Specification of an audio content block.
Definition RecordFormat.h:369
uint8_t getChannelCount() const
Get the number of audio channels in each sample frame (not in the content block).
Definition RecordFormat.h:445
void setSampleCount(uint32_t sampleCount)
Set the number of audio sample frames in the content block.
Definition RecordFormat.h:457
string asString() const
Definition RecordFormat.cpp:771
uint8_t getBitsPerSample() const
Get the number of bits per audio sample.
Definition RecordFormat.h:435
AudioContentBlockSpec(const AudioContentBlockSpec &)=default
Default copy constructor.
bool isLittleEndian() const
Tell if the audio sample format is little endian.
Definition RecordFormat.h:427
bool isSampleBlockFormatDefined() const
Definition RecordFormat.cpp:824
size_t getPcmBlockSize() const
Assuming PCM, get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:800
uint32_t getSampleCount() const
Get the number of audio sample frames in the content block.
Definition RecordFormat.h:453
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:711
uint8_t getBytesPerSample() const
Get the number of bytes per audio sample.
Definition RecordFormat.h:439
uint8_t getSampleFrameStride() const
Number of bytes used by a group of synchronous audio samples, including padding.
Definition RecordFormat.cpp:918
uint32_t getSampleRate() const
Get the audio frame sample rate.
Definition RecordFormat.h:449
bool isIEEEFloat() const
Tell if the audio sample format is an IEEE float.
Definition RecordFormat.h:431
AudioFormat getAudioFormat() const
Get audio format.
Definition RecordFormat.h:417
AudioSampleFormat getSampleFormat() const
Get audio sample format.
Definition RecordFormat.h:421
size_t getBlockSize() const
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:796
string getSampleFormatAsString() const
Get audio sample format as a string.
Definition RecordFormat.cpp:820
bool isCompatibleWith(const AudioContentBlockSpec &rhs) const
Tell if two audio block have identical audio formats.
Definition RecordFormat.cpp:814
static string getSampleFormatAsString(AudioSampleFormat sampleFormat)
Get an audio sample format as a string.
Definition RecordFormat.h:478
Specification of a VRS record content block.
Definition RecordFormat.h:504
size_t getBlockSize() const
Get the content block size, if available or calculable.
Definition RecordFormat.cpp:1063
ContentBlock(const ContentBlock &)=default
Default copy constructor.
string asString() const
Conversion to string, to store on disk & reconstruct later using constructor.
Definition RecordFormat.cpp:1032
const ImageContentBlockSpec & image() const
Get the image content spec. Requires the content block to be of type ContentType::IMAGE.
Definition RecordFormat.cpp:1105
ContentBlock(ContentType type=ContentType::EMPTY, size_t size=kSizeUnknown)
Very generic block description.
Definition RecordFormat.cpp:984
ContentType getContentType() const
Get the ContentType of the block.
Definition RecordFormat.h:585
string getCustomContentBlockFormat() const
Definition RecordFormat.h:591
const AudioContentBlockSpec & audio() const
Get the audio content spec. Requires the content block to be of type ContentType::AUDIO.
Definition RecordFormat.cpp:1110
RecordFormat operator+(const ContentBlock &) const
Assembly operator, to construct a RecordFormat for ContentBlock parts.
Definition RecordFormat.cpp:1101
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:507
Helper to identify a particular content block within a file.
Definition RecordFormat.h:634
RecordFormat string parsing helper class.
Definition RecordFormat.cpp:37
Definition RecordFormat.h:617
Specification of an image content block.
Definition RecordFormat.h:140
ImageContentBlockSpec & operator=(const ImageContentBlockSpec &)=default
Default copy assignment.
void set(ContentParser &parser)
When constructing from a string.
Definition RecordFormat.cpp:377
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:334
uint32_t getDefaultStride2() const
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value)
Definition RecordFormat.cpp:579
uint8_t getCodecQuality() const
Definition RecordFormat.h:317
string getPixelFormatAsString() const
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.cpp:634
uint32_t getKeyFrameIndex() const
Definition RecordFormat.h:333
string asString() const
Definition RecordFormat.cpp:422
size_t getBytesPerPixel() const
Definition RecordFormat.h:305
uint32_t getHeight() const
Get image height, or 0 if unknown/unspecified.
Definition RecordFormat.h:263
string getImageFormatAsString() const
Get Image format as string.
Definition RecordFormat.cpp:638
uint32_t getPlaneHeight(uint32_t planeIndex) const
Definition RecordFormat.cpp:596
uint32_t getStride() const
Get image stride (number of bytes between rows) for the first plane.
Definition RecordFormat.cpp:642
PixelFormat getPixelFormat() const
Get Pixel format.
Definition RecordFormat.h:253
static string getPixelFormatAsString(PixelFormat pixelFormat)
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.h:343
const string & getCodecName() const
Definition RecordFormat.h:311
uint32_t getPlaneStride(uint32_t planeIndex) const
Definition RecordFormat.cpp:569
bool sanityCheckStrides() const
Definition RecordFormat.cpp:556
size_t getRawImageSize() const
Definition RecordFormat.cpp:620
uint32_t getRawStride() const
Definition RecordFormat.h:270
size_t getBlockSize() const
Definition RecordFormat.cpp:616
ImageContentBlockSpec core() const
Return base of format (no codec quality nor key frame info)
Definition RecordFormat.cpp:345
double getKeyFrameTimestamp() const
Get timestamp of the key frame of the group of frames this video frame belongs to.
Definition RecordFormat.h:327
uint32_t getDefaultStride() const
Get default stride for plane 0 when stride isn't specified (minimum stride value)
Definition RecordFormat.cpp:647
static bool isQualityValid(uint8_t quality)
Validate that a quality value is valid.
Definition RecordFormat.h:322
uint8_t getChannelCountPerPixel() const
Definition RecordFormat.h:298
ImageFormat getImageFormat() const
Get image format.
Definition RecordFormat.h:245
uint32_t getPlaneCount() const
Get the number of planes for this pixel format.
Definition RecordFormat.h:282
uint32_t getWidth() const
Get image width, or 0 if unknown/unspecified.
Definition RecordFormat.h:259
Description of the format of a VRS record as a succession of typed blocks of content.
Definition RecordFormat.h:678
size_t getRemainingBlocksSize(size_t firstBlock) const
Definition RecordFormat.cpp:1158
static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion)
Names of the VRS stream tags used for RecordFormat descriptions.
Definition RecordFormat.cpp:1215
RecordFormat(const RecordFormat &)=default
Default copy constructor.
RecordFormat(ContentBlock &&first, ContentBlock &&second) noexcept
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:716
static bool parseRecordFormatTagName(const string &tagName, Record::Type &recordType, uint32_t &formatVersion)
Definition RecordFormat.cpp:1262
size_t getBlocksOfTypeCount(ContentType type) const
Definition RecordFormat.cpp:1180
RecordFormat & operator+(ContentBlock &&block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:734
static bool addRecordFormat(map< string, string > &inOutRecordFormatRegister, Record::Type recordType, uint32_t formatVersion, const RecordFormat &format, const vector< const DataLayout * > &layouts)
Definition RecordFormat.cpp:1284
RecordFormat(const char *format)
Definition RecordFormat.h:699
size_t getBlockSize(size_t blockIndex, size_t remainingSize) const
Definition RecordFormat.cpp:1198
RecordFormat(const ContentBlock &block)
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:703
RecordFormat(ContentType type, size_t size=ContentBlock::kSizeUnknown)
Definition RecordFormat.h:724
size_t getUsedBlocksCount() const
Definition RecordFormat.cpp:1170
RecordFormat()=default
Empty record format definition.
RecordFormat(ContentBlock &&block) noexcept
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:707
const ContentBlock & getFirstContentBlock() const
Definition RecordFormat.h:771
RecordFormat(const ContentBlock &first, const ContentBlock &second)
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:711
void set(const string &format)
Definition RecordFormat.cpp:1135
size_t getRecordSize() const
Definition RecordFormat.cpp:1154
const ContentBlock & getContentBlock(size_t index) const
Definition RecordFormat.cpp:1190
string asString() const
Definition RecordFormat.cpp:1143
RecordFormat & operator+(const ContentBlock &block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:729
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:624
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.
@ 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:108
@ 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:97
@ 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.