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 <vrs/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,
94
95 COUNT,
96};
97
98string toString(PixelFormat pixelFormat);
99
101enum class AudioFormat : uint8_t {
102 UNDEFINED = 0,
103 PCM = 1,
104 OPUS = 2,
105 COUNT
106};
107
109string toString(AudioFormat audioFormat);
110
112enum class AudioSampleFormat : uint8_t {
113 UNDEFINED = 0,
114 S8,
115 U8,
116 A_LAW,
117 MU_LAW,
118 S16_LE,
119 U16_LE,
120 S16_BE,
121 U16_BE,
122 S24_LE,
123 U24_LE,
124 S24_BE,
125 U24_BE,
126 S32_LE,
127 U32_LE,
128 S32_BE,
129 U32_BE,
130 F32_LE,
131 F32_BE,
132 F64_LE,
133 F64_BE,
134 COUNT
135};
136
138string toString(AudioSampleFormat audioSampleFormat);
139
140class ContentParser; // to workaround not being able to forward declare istringstream.
141class RecordFormat;
142
145 public:
146 static constexpr uint8_t kQualityUndefined = 255;
147 static constexpr double kInvalidTimestamp = -1E-308; // arbitrary unrealistic value
148
149 ImageContentBlockSpec() = default;
150
152 ImageContentBlockSpec(ImageContentBlockSpec&&) noexcept = default;
154 ImageContentBlockSpec imageSpec,
155 double keyFrameTimestamp,
156 uint32_t keyFrameIndex);
157
160 ImageFormat imageFormat,
161 PixelFormat pixelFormat,
162 uint32_t width = 0,
163 uint32_t height = 0,
164 uint32_t stride = 0,
165 uint32_t stride2 = 0,
166 string codecName = {},
167 uint8_t codecQuality = kQualityUndefined,
168 double keyFrameTimestamp = kInvalidTimestamp,
169 uint32_t keyFrameIndex = 0);
170
172 /* implicit */ ImageContentBlockSpec(
173 ImageFormat imageFormat,
174 uint32_t width = 0,
175 uint32_t height = 0);
176
179 PixelFormat pixelFormat,
180 uint32_t width,
181 uint32_t height,
182 uint32_t stride = 0,
183 uint32_t stride2 = 0
184 );
185
188 ImageFormat imageFormat,
189 string codecName,
190 uint8_t codecQuality = kQualityUndefined,
192 uint32_t width = 0,
193 uint32_t height = 0,
194 uint32_t stride = 0,
195 uint32_t stride2 = 0);
196
199 string codecName,
200 uint8_t codecQuality,
201 PixelFormat pixelFormat,
202 uint32_t width,
203 uint32_t height,
204 uint32_t stride = 0,
205 uint32_t stride2 = 0);
206
208 explicit ImageContentBlockSpec(const string& formatStr);
209
210 ~ImageContentBlockSpec() = default;
211
212 void init(
213 PixelFormat pixelFormat,
214 uint32_t width = 0,
215 uint32_t height = 0,
216 uint32_t stride = 0,
217 uint32_t stride2 = 0,
218 string codecName = {},
219 uint8_t codecQuality = kQualityUndefined,
220 double keyFrameTimestamp = kInvalidTimestamp,
221 uint32_t keyFrameIndex = 0);
222
224 void set(ContentParser& parser);
226 void clear();
227
230
233 string asString() const;
234
237 size_t getBlockSize() const;
238
241 size_t getRawImageSize() const;
242
246
248 bool operator==(const ImageContentBlockSpec& rhs) const;
249 bool operator!=(const ImageContentBlockSpec& rhs) const;
250
253 return imageFormat_;
254 }
255
257 string getImageFormatAsString() const;
258
261 return pixelFormat_;
262 }
264 string getPixelFormatAsString() const;
266 uint32_t getWidth() const {
267 return width_;
268 }
270 uint32_t getHeight() const {
271 return height_;
272 }
274 uint32_t getStride() const;
277 uint32_t getRawStride() const {
278 return stride_;
279 }
280 uint32_t getRawStride2() const {
281 return stride2_;
282 }
284 uint32_t getDefaultStride() const;
286 uint32_t getDefaultStride2() const;
287
289 uint32_t getPlaneCount() const {
290 return getPlaneCount(pixelFormat_);
291 }
292
295 uint32_t getPlaneStride(uint32_t planeIndex) const;
296
299 uint32_t getPlaneHeight(uint32_t planeIndex) const;
300
305 uint8_t getChannelCountPerPixel() const {
306 return getChannelCountPerPixel(pixelFormat_);
307 }
312 size_t getBytesPerPixel() const {
313 return getBytesPerPixel(pixelFormat_);
314 }
315
318 const string& getCodecName() const {
319 return codecName_;
320 }
324 uint8_t getCodecQuality() const {
325 return isQualityValid(codecQuality_) ? codecQuality_ : kQualityUndefined;
326 }
327
329 inline static bool isQualityValid(uint8_t quality) {
330 return quality <= 100;
331 }
332
334 double getKeyFrameTimestamp() const {
335 return keyFrameTimestamp_;
336 }
340 uint32_t getKeyFrameIndex() const {
341 return keyFrameIndex_;
342 }
343
345 static uint8_t getChannelCountPerPixel(PixelFormat pixel);
347 static size_t getBytesPerPixel(PixelFormat pixel);
348
350 static string getPixelFormatAsString(PixelFormat pixelFormat) {
351 return toString(pixelFormat);
352 }
353
355 static uint32_t getPlaneCount(PixelFormat pixelFormat);
356
359 bool sanityCheckStrides() const;
360
361 private:
364 uint32_t width_{0};
365 uint32_t height_{0};
366 uint32_t stride_{0}; // Stride (bytes between lines) for the first pixel plane
367 uint32_t stride2_{0}; // Stride for the other planes (same for all)
368 // for ImageFormat::VIDEO
369 string codecName_;
370 double keyFrameTimestamp_{kInvalidTimestamp};
371 uint32_t keyFrameIndex_{0};
372 uint8_t codecQuality_{kQualityUndefined};
373};
374
377 public:
378 AudioContentBlockSpec() = default;
381 AudioContentBlockSpec(AudioContentBlockSpec&&) noexcept = default;
383 explicit AudioContentBlockSpec(AudioFormat audioFormat, uint8_t channelCount = 0);
385 AudioFormat audioFormat,
386 AudioSampleFormat sampleFormat,
387 uint8_t channelCount = 0,
388 uint8_t sampleFrameStride = 0,
389 uint32_t sampleFrameRate = 0,
390 uint32_t sampleFrameCount = 0,
391 uint8_t stereoPairCount = 0);
392 ~AudioContentBlockSpec() = default;
393
396 explicit AudioContentBlockSpec(const string& formatStr);
397
400 void set(ContentParser& parser);
402 void clear();
403
404 AudioContentBlockSpec& operator=(const AudioContentBlockSpec&) = default;
405 AudioContentBlockSpec& operator=(AudioContentBlockSpec&&) noexcept = default;
406
407 bool operator==(const AudioContentBlockSpec& rhs) const;
408 bool operator!=(const AudioContentBlockSpec& rhs) const {
409 return !operator==(rhs);
410 }
413 string asString() const;
414
416 size_t getBlockSize() const;
417
419 size_t getPcmBlockSize() const;
420
422 bool isCompatibleWith(const AudioContentBlockSpec& rhs) const;
425 return audioFormat_;
426 }
429 return sampleFormat_;
430 }
432 string getSampleFormatAsString() const;
434 bool isLittleEndian() const {
435 return isLittleEndian(sampleFormat_);
436 }
438 bool isIEEEFloat() const {
439 return isIEEEFloat(sampleFormat_);
440 }
442 uint8_t getBitsPerSample() const {
443 return getBitsPerSample(sampleFormat_);
444 }
446 uint8_t getBytesPerSample() const {
447 return (getBitsPerSample(sampleFormat_) + 7) / 8; // round up
448 }
450 uint8_t getSampleFrameStride() const;
452 uint8_t getChannelCount() const {
453 return channelCount_;
454 }
456 uint32_t getSampleRate() const {
457 return sampleFrameRate_;
458 }
460 uint32_t getSampleCount() const {
461 return sampleFrameCount_;
462 }
464 void setSampleCount(uint32_t sampleCount) {
465 sampleFrameCount_ = sampleCount;
466 }
467
468 uint8_t getStereoPairCount() const {
469 return stereoPairCount_;
470 }
471
474 bool isSampleBlockFormatDefined() const;
475
477 static bool isLittleEndian(AudioSampleFormat sampleFormat);
479 static bool isIEEEFloat(AudioSampleFormat sampleFormat);
481 static uint8_t getBitsPerSample(AudioSampleFormat sampleFormat);
483 static uint8_t getBytesPerSample(AudioSampleFormat sampleFormat);
485 static string getSampleFormatAsString(AudioSampleFormat sampleFormat) {
486 return toString(sampleFormat);
487 }
488
489 private:
490 AudioFormat audioFormat_{};
491 AudioSampleFormat sampleFormat_{};
492 uint8_t sampleFrameStride_{};
493 uint8_t channelCount_{};
494 uint32_t sampleFrameRate_{};
495 uint32_t sampleFrameCount_{};
496 uint8_t stereoPairCount_{};
497};
498
512 public:
514 static const size_t kSizeUnknown;
515
517 /* implicit */ ContentBlock(ContentType type = ContentType::EMPTY, size_t size = kSizeUnknown);
518
520 explicit ContentBlock(const string& formatStr);
521
523 /* implicit */ ContentBlock(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0);
524
527 std::string codecName,
528 uint8_t codecQuality,
530 uint32_t width = 0,
531 uint32_t height = 0,
532 uint32_t stride = 0,
533 uint32_t stride2 = 0);
534
537 PixelFormat pixelFormat,
538 uint32_t width,
539 uint32_t height,
540 uint32_t stride = 0,
541 uint32_t stride2 = 0);
542
543 /* implicit */ ContentBlock(const ImageContentBlockSpec& imageSpec, size_t size = kSizeUnknown);
544 /* implicit */ ContentBlock(
545 ImageContentBlockSpec&& imageSpec,
546 size_t size = kSizeUnknown) noexcept;
548 const ContentBlock& imageContentBlock,
549 double keyFrameTimestamp,
550 uint32_t keyFrameIndex);
551
553 /* implicit */ ContentBlock(AudioFormat audioFormat, uint8_t channelCount = 0);
554 /* implicit */ ContentBlock(const AudioContentBlockSpec& audioSpec, size_t size);
555
558 AudioFormat audioFormat,
559 AudioSampleFormat sampleFormat,
560 uint8_t numChannels = 0,
561 uint8_t sampleFrameStride = 0,
562 uint32_t sampleRate = 0,
563 uint32_t sampleCount = 0,
564 uint8_t stereoPairCount = 0);
565
567 ContentBlock(const ContentBlock&) = default;
568 ContentBlock(ContentBlock&&) noexcept = default;
569
571 ContentBlock(const ContentBlock& other, size_t size)
572 : contentType_{other.contentType_}, size_{size} {
573 if (contentType_ == ContentType::IMAGE) {
574 imageSpec_ = other.imageSpec_;
575 } else if (contentType_ == ContentType::AUDIO) {
576 audioSpec_ = other.audioSpec_;
577 } else if (contentType_ == ContentType::CUSTOM) {
578 customContentBlockFormat_ = other.customContentBlockFormat_;
579 }
580 }
581
582 ~ContentBlock() = default;
583
584 ContentBlock& operator=(const ContentBlock& rhs) = default;
585 ContentBlock& operator=(ContentBlock&& rhs) noexcept = default;
586
588 string asString() const;
589
591 size_t getBlockSize() const;
592
595 return contentType_;
596 }
597
601 return customContentBlockFormat_;
602 }
603
604 bool operator==(const ContentBlock& rhs) const;
605
606 bool operator!=(const ContentBlock& rhs) const {
607 return !operator==(rhs);
608 }
609
611 RecordFormat operator+(const ContentBlock&) const;
612
614 const ImageContentBlockSpec& image() const;
616 const AudioContentBlockSpec& audio() const;
617
618 protected:
619 ContentType contentType_ = ContentType::EMPTY;
620 size_t size_ = kSizeUnknown;
621 ImageContentBlockSpec imageSpec_;
622 AudioContentBlockSpec audioSpec_;
623 string customContentBlockFormat_;
624};
625
627 public:
628 explicit CustomContentBlock(const string& customContentBlockFormat, size_t size = kSizeUnknown);
629 explicit CustomContentBlock(size_t size = kSizeUnknown);
630};
631
633using RecordFormatMap = map<pair<Record::Type, uint32_t>, RecordFormat>;
634
644 public:
646 RecordableTypeId typeIdIn,
647 Record::Type recordTypeIn,
648 uint32_t formatVersionIn,
649 size_t blockIndexIn)
650 : typeId(typeIdIn),
651 recordType(recordTypeIn),
652 formatVersion(formatVersionIn),
653 blockIndex(blockIndexIn) {}
654
655 RecordableTypeId getRecordableTypeId() const {
656 return typeId;
657 }
658
659 Record::Type getRecordType() const {
660 return recordType;
661 }
662
663 uint32_t getFormatVersion() const {
664 return formatVersion;
665 }
666
667 size_t getBlockIndex() const {
668 return blockIndex;
669 }
670
671 private:
672 RecordableTypeId typeId;
673 Record::Type recordType;
674 uint32_t formatVersion;
675 size_t blockIndex;
676};
677
688 public:
690 RecordFormat() = default;
692 RecordFormat(const RecordFormat&) = default;
693 /* implicit */ RecordFormat(RecordFormat&&) noexcept = default;
694 ~RecordFormat() = default;
695
696 RecordFormat& operator=(const RecordFormat&) = default;
697 RecordFormat& operator=(RecordFormat&&) noexcept = default;
698
702 explicit RecordFormat(const string& format) {
703 set(format);
704 }
708 explicit RecordFormat(const char* format) {
709 set(format);
710 }
712 /* implicit */ RecordFormat(const ContentBlock& block) {
713 blocks_.emplace_back(block);
714 }
716 /* implicit */ RecordFormat(ContentBlock&& block) noexcept {
717 blocks_.emplace_back(std::move(block));
718 }
720 RecordFormat(const ContentBlock& first, const ContentBlock& second) {
721 blocks_.emplace_back(first);
722 blocks_.emplace_back(second);
723 }
725 RecordFormat(ContentBlock&& first, ContentBlock&& second) noexcept {
726 blocks_.emplace_back(std::move(first));
727 blocks_.emplace_back(std::move(second));
728 }
733 /* implicit */ RecordFormat(ContentType type, size_t size = ContentBlock::kSizeUnknown) {
734 blocks_.emplace_back(type, size);
735 }
736
739 blocks_.emplace_back(block);
740 return *this;
741 }
744 blocks_.emplace_back(std::move(block));
745 return *this;
746 }
747
748 bool operator==(const RecordFormat& rhs) const;
749 bool operator!=(const RecordFormat& rhs) const {
750 return !operator==(rhs);
751 }
752
753 void clear() {
754 blocks_.clear();
755 }
756
759 void set(const string& format);
762 string asString() const;
763
766 size_t getRecordSize() const;
769 size_t getUsedBlocksCount() const;
773 size_t getBlocksOfTypeCount(ContentType type) const;
777 const ContentBlock& getContentBlock(size_t index) const;
781 return getContentBlock(0);
782 }
787 size_t getRemainingBlocksSize(size_t firstBlock) const;
794 size_t getBlockSize(size_t blockIndex, size_t remainingSize) const;
795
796 // Static VRS dedicated helper methods, for RecordFormat & DataLayout purposes.
797
799 static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion);
800 static string getDataLayoutTagName(Record::Type type, uint32_t version, size_t blockIndex);
803 static bool parseRecordFormatTagName(
804 const string& tagName,
805 Record::Type& recordType,
806 uint32_t& formatVersion);
807
810 static bool addRecordFormat(
811 map<string, string>& inOutRecordFormatRegister,
812 Record::Type recordType,
813 uint32_t formatVersion,
814 const RecordFormat& format,
815 const vector<const DataLayout*>& layouts);
816
817 static void getRecordFormats(
818 const map<string, string>& recordFormatRegister,
819 RecordFormatMap& outFormats);
820
821 static unique_ptr<DataLayout> getDataLayout(
822 const map<string, string>& recordFormatRegister,
823 const ContentBlockId& blockId);
824
825 private:
826 vector<ContentBlock> blocks_;
827};
828
829} // namespace vrs
Specification of an audio content block.
Definition RecordFormat.h:376
uint8_t getChannelCount() const
Get the number of audio channels in each sample frame (not in the content block).
Definition RecordFormat.h:452
void setSampleCount(uint32_t sampleCount)
Set the number of audio sample frames in the content block.
Definition RecordFormat.h:464
string asString() const
Definition RecordFormat.cpp:787
uint8_t getBitsPerSample() const
Get the number of bits per audio sample.
Definition RecordFormat.h:442
AudioContentBlockSpec(const AudioContentBlockSpec &)=default
Default copy constructor.
bool isLittleEndian() const
Tell if the audio sample format is little endian.
Definition RecordFormat.h:434
bool isSampleBlockFormatDefined() const
Definition RecordFormat.cpp:840
size_t getPcmBlockSize() const
Assuming PCM, get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:816
uint32_t getSampleCount() const
Get the number of audio sample frames in the content block.
Definition RecordFormat.h:460
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:727
uint8_t getBytesPerSample() const
Get the number of bytes per audio sample.
Definition RecordFormat.h:446
uint8_t getSampleFrameStride() const
Number of bytes used by a group of synchronous audio samples, including padding.
Definition RecordFormat.cpp:934
uint32_t getSampleRate() const
Get the audio frame sample rate.
Definition RecordFormat.h:456
bool isIEEEFloat() const
Tell if the audio sample format is an IEEE float.
Definition RecordFormat.h:438
AudioFormat getAudioFormat() const
Get audio format.
Definition RecordFormat.h:424
AudioSampleFormat getSampleFormat() const
Get audio sample format.
Definition RecordFormat.h:428
size_t getBlockSize() const
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:812
string getSampleFormatAsString() const
Get audio sample format as a string.
Definition RecordFormat.cpp:836
bool isCompatibleWith(const AudioContentBlockSpec &rhs) const
Tell if two audio block have identical audio formats.
Definition RecordFormat.cpp:830
static string getSampleFormatAsString(AudioSampleFormat sampleFormat)
Get an audio sample format as a string.
Definition RecordFormat.h:485
Specification of a VRS record content block.
Definition RecordFormat.h:511
size_t getBlockSize() const
Get the content block size, if available or calculable.
Definition RecordFormat.cpp:1078
ContentBlock(const ContentBlock &)=default
Default copy constructor.
string asString() const
Conversion to string, to store on disk & reconstruct later using constructor.
Definition RecordFormat.cpp:1048
const ImageContentBlockSpec & image() const
Get the image content spec. Requires the content block to be of type ContentType::IMAGE.
Definition RecordFormat.cpp:1120
ContentBlock(ContentType type=ContentType::EMPTY, size_t size=kSizeUnknown)
Very generic block description.
Definition RecordFormat.cpp:1000
ContentType getContentType() const
Get the ContentType of the block.
Definition RecordFormat.h:594
string getCustomContentBlockFormat() const
Definition RecordFormat.h:600
const AudioContentBlockSpec & audio() const
Get the audio content spec. Requires the content block to be of type ContentType::AUDIO.
Definition RecordFormat.cpp:1125
RecordFormat operator+(const ContentBlock &) const
Assembly operator, to construct a RecordFormat for ContentBlock parts.
Definition RecordFormat.cpp:1116
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:514
Helper to identify a particular content block within a file.
Definition RecordFormat.h:643
RecordFormat string parsing helper class.
Definition RecordFormat.cpp:37
Definition RecordFormat.h:626
Specification of an image content block.
Definition RecordFormat.h:144
ImageContentBlockSpec & operator=(const ImageContentBlockSpec &)=default
Default copy assignment.
void set(ContentParser &parser)
When constructing from a string.
Definition RecordFormat.cpp:388
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:345
uint32_t getDefaultStride2() const
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value)
Definition RecordFormat.cpp:598
uint8_t getCodecQuality() const
Definition RecordFormat.h:324
string getPixelFormatAsString() const
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.cpp:649
uint32_t getKeyFrameIndex() const
Definition RecordFormat.h:340
string asString() const
Definition RecordFormat.cpp:433
size_t getBytesPerPixel() const
Definition RecordFormat.h:312
uint32_t getHeight() const
Get image height, or 0 if unknown/unspecified.
Definition RecordFormat.h:270
string getImageFormatAsString() const
Get Image format as string.
Definition RecordFormat.cpp:653
uint32_t getPlaneHeight(uint32_t planeIndex) const
Definition RecordFormat.cpp:612
uint32_t getStride() const
Get image stride (number of bytes between rows) for the first plane.
Definition RecordFormat.cpp:657
PixelFormat getPixelFormat() const
Get Pixel format.
Definition RecordFormat.h:260
static string getPixelFormatAsString(PixelFormat pixelFormat)
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.h:350
const string & getCodecName() const
Definition RecordFormat.h:318
uint32_t getPlaneStride(uint32_t planeIndex) const
Definition RecordFormat.cpp:588
bool sanityCheckStrides() const
Definition RecordFormat.cpp:575
size_t getRawImageSize() const
Definition RecordFormat.cpp:635
uint32_t getRawStride() const
Definition RecordFormat.h:277
size_t getBlockSize() const
Definition RecordFormat.cpp:631
ImageContentBlockSpec core() const
Return base of format (no codec quality nor key frame info)
Definition RecordFormat.cpp:356
double getKeyFrameTimestamp() const
Get timestamp of the key frame of the group of frames this video frame belongs to.
Definition RecordFormat.h:334
uint32_t getDefaultStride() const
Get default stride for plane 0 when stride isn't specified (minimum stride value)
Definition RecordFormat.cpp:662
static bool isQualityValid(uint8_t quality)
Validate that a quality value is valid.
Definition RecordFormat.h:329
uint8_t getChannelCountPerPixel() const
Definition RecordFormat.h:305
ImageFormat getImageFormat() const
Get image format.
Definition RecordFormat.h:252
uint32_t getPlaneCount() const
Get the number of planes for this pixel format.
Definition RecordFormat.h:289
uint32_t getWidth() const
Get image width, or 0 if unknown/unspecified.
Definition RecordFormat.h:266
Description of the format of a VRS record as a succession of typed blocks of content.
Definition RecordFormat.h:687
size_t getRemainingBlocksSize(size_t firstBlock) const
Definition RecordFormat.cpp:1173
static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion)
Names of the VRS stream tags used for RecordFormat descriptions.
Definition RecordFormat.cpp:1225
RecordFormat(const RecordFormat &)=default
Default copy constructor.
RecordFormat(ContentBlock &&first, ContentBlock &&second) noexcept
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:725
static bool parseRecordFormatTagName(const string &tagName, Record::Type &recordType, uint32_t &formatVersion)
Definition RecordFormat.cpp:1272
size_t getBlocksOfTypeCount(ContentType type) const
Definition RecordFormat.cpp:1195
RecordFormat & operator+(ContentBlock &&block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:743
static bool addRecordFormat(map< string, string > &inOutRecordFormatRegister, Record::Type recordType, uint32_t formatVersion, const RecordFormat &format, const vector< const DataLayout * > &layouts)
Definition RecordFormat.cpp:1293
RecordFormat(const char *format)
Definition RecordFormat.h:708
size_t getBlockSize(size_t blockIndex, size_t remainingSize) const
Definition RecordFormat.cpp:1213
RecordFormat(const ContentBlock &block)
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:712
RecordFormat(ContentType type, size_t size=ContentBlock::kSizeUnknown)
Definition RecordFormat.h:733
size_t getUsedBlocksCount() const
Definition RecordFormat.cpp:1185
RecordFormat()=default
Empty record format definition.
RecordFormat(ContentBlock &&block) noexcept
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:716
const ContentBlock & getFirstContentBlock() const
Definition RecordFormat.h:780
RecordFormat(const ContentBlock &first, const ContentBlock &second)
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:720
void set(const string &format)
Definition RecordFormat.cpp:1150
size_t getRecordSize() const
Definition RecordFormat.cpp:1169
const ContentBlock & getContentBlock(size_t index) const
Definition RecordFormat.cpp:1205
string asString() const
Definition RecordFormat.cpp:1158
RecordFormat & operator+(const ContentBlock &block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:738
Type
Definition Record.h:90
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:633
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.
@ BAYER8_GBRG
8 bit per pixel, GBRG bayer pattern.
@ RGB10
uses 16 bit little-endian values. 6 most significant bits are unused and set to 0.
@ BAYER10_GBRG
10 bit per pixel, GBRG bayer pattern.
@ 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.
@ BAYER8_BGGR
8 bit per pixel, BGGR bayer pattern.
@ 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:112
@ 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:101
@ 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:51
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.