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,
93
94 COUNT,
95};
96
97string toString(PixelFormat pixelFormat);
98
100enum class AudioFormat : uint8_t {
101 UNDEFINED = 0,
102 PCM = 1,
103 OPUS = 2,
104 COUNT
105};
106
108string toString(AudioFormat audioFormat);
109
111enum class AudioSampleFormat : uint8_t {
112 UNDEFINED = 0,
113 S8,
114 U8,
115 A_LAW,
116 MU_LAW,
117 S16_LE,
118 U16_LE,
119 S16_BE,
120 U16_BE,
121 S24_LE,
122 U24_LE,
123 S24_BE,
124 U24_BE,
125 S32_LE,
126 U32_LE,
127 S32_BE,
128 U32_BE,
129 F32_LE,
130 F32_BE,
131 F64_LE,
132 F64_BE,
133 COUNT
134};
135
137string toString(AudioSampleFormat audioSampleFormat);
138
139class ContentParser; // to workaround not being able to forward declare istringstream.
140class RecordFormat;
141
144 public:
145 static constexpr uint8_t kQualityUndefined = 255;
146 static constexpr double kInvalidTimestamp = -1E-308; // arbitrary unrealistic value
147
148 ImageContentBlockSpec() = default;
149
151 ImageContentBlockSpec(ImageContentBlockSpec&&) noexcept = default;
153 ImageContentBlockSpec imageSpec,
154 double keyFrameTimestamp,
155 uint32_t keyFrameIndex);
156
159 ImageFormat imageFormat,
160 PixelFormat pixelFormat,
161 uint32_t width = 0,
162 uint32_t height = 0,
163 uint32_t stride = 0,
164 uint32_t stride2 = 0,
165 string codecName = {},
166 uint8_t codecQuality = kQualityUndefined,
167 double keyFrameTimestamp = kInvalidTimestamp,
168 uint32_t keyFrameIndex = 0);
169
171 /* implicit */ ImageContentBlockSpec(
172 ImageFormat imageFormat,
173 uint32_t width = 0,
174 uint32_t height = 0);
175
178 PixelFormat pixelFormat,
179 uint32_t width,
180 uint32_t height,
181 uint32_t stride = 0,
182 uint32_t stride2 = 0
183 );
184
187 ImageFormat imageFormat,
188 string codecName,
189 uint8_t codecQuality = kQualityUndefined,
191 uint32_t width = 0,
192 uint32_t height = 0,
193 uint32_t stride = 0,
194 uint32_t stride2 = 0);
195
198 string codecName,
199 uint8_t codecQuality,
200 PixelFormat pixelFormat,
201 uint32_t width,
202 uint32_t height,
203 uint32_t stride = 0,
204 uint32_t stride2 = 0);
205
207 explicit ImageContentBlockSpec(const string& formatStr);
208
209 ~ImageContentBlockSpec() = default;
210
211 void init(
212 PixelFormat pixelFormat,
213 uint32_t width = 0,
214 uint32_t height = 0,
215 uint32_t stride = 0,
216 uint32_t stride2 = 0,
217 string codecName = {},
218 uint8_t codecQuality = kQualityUndefined,
219 double keyFrameTimestamp = kInvalidTimestamp,
220 uint32_t keyFrameIndex = 0);
221
223 void set(ContentParser& parser);
225 void clear();
226
229
232 string asString() const;
233
236 size_t getBlockSize() const;
237
240 size_t getRawImageSize() const;
241
245
247 bool operator==(const ImageContentBlockSpec& rhs) const;
248 bool operator!=(const ImageContentBlockSpec& rhs) const;
249
252 return imageFormat_;
253 }
254
256 string getImageFormatAsString() const;
257
260 return pixelFormat_;
261 }
263 string getPixelFormatAsString() const;
265 uint32_t getWidth() const {
266 return width_;
267 }
269 uint32_t getHeight() const {
270 return height_;
271 }
273 uint32_t getStride() const;
276 uint32_t getRawStride() const {
277 return stride_;
278 }
279 uint32_t getRawStride2() const {
280 return stride2_;
281 }
283 uint32_t getDefaultStride() const;
285 uint32_t getDefaultStride2() const;
286
288 uint32_t getPlaneCount() const {
289 return getPlaneCount(pixelFormat_);
290 }
291
294 uint32_t getPlaneStride(uint32_t planeIndex) const;
295
298 uint32_t getPlaneHeight(uint32_t planeIndex) const;
299
304 uint8_t getChannelCountPerPixel() const {
305 return getChannelCountPerPixel(pixelFormat_);
306 }
311 size_t getBytesPerPixel() const {
312 return getBytesPerPixel(pixelFormat_);
313 }
314
317 const string& getCodecName() const {
318 return codecName_;
319 }
323 uint8_t getCodecQuality() const {
324 return isQualityValid(codecQuality_) ? codecQuality_ : kQualityUndefined;
325 }
326
328 inline static bool isQualityValid(uint8_t quality) {
329 return quality <= 100;
330 }
331
333 double getKeyFrameTimestamp() const {
334 return keyFrameTimestamp_;
335 }
339 uint32_t getKeyFrameIndex() const {
340 return keyFrameIndex_;
341 }
342
344 static uint8_t getChannelCountPerPixel(PixelFormat pixel);
346 static size_t getBytesPerPixel(PixelFormat pixel);
347
349 static string getPixelFormatAsString(PixelFormat pixelFormat) {
350 return toString(pixelFormat);
351 }
352
354 static uint32_t getPlaneCount(PixelFormat pixelFormat);
355
358 bool sanityCheckStrides() const;
359
360 private:
363 uint32_t width_{0};
364 uint32_t height_{0};
365 uint32_t stride_{0}; // Stride (bytes between lines) for the first pixel plane
366 uint32_t stride2_{0}; // Stride for the other planes (same for all)
367 // for ImageFormat::VIDEO
368 string codecName_;
369 double keyFrameTimestamp_{kInvalidTimestamp};
370 uint32_t keyFrameIndex_{0};
371 uint8_t codecQuality_{kQualityUndefined};
372};
373
376 public:
377 AudioContentBlockSpec() = default;
380 AudioContentBlockSpec(AudioContentBlockSpec&&) noexcept = default;
382 explicit AudioContentBlockSpec(AudioFormat audioFormat, uint8_t channelCount = 0);
384 AudioFormat audioFormat,
385 AudioSampleFormat sampleFormat,
386 uint8_t channelCount = 0,
387 uint8_t sampleFrameStride = 0,
388 uint32_t sampleFrameRate = 0,
389 uint32_t sampleFrameCount = 0,
390 uint8_t stereoPairCount = 0);
391 ~AudioContentBlockSpec() = default;
392
395 explicit AudioContentBlockSpec(const string& formatStr);
396
399 void set(ContentParser& parser);
401 void clear();
402
403 AudioContentBlockSpec& operator=(const AudioContentBlockSpec&) = default;
404 AudioContentBlockSpec& operator=(AudioContentBlockSpec&&) noexcept = default;
405
406 bool operator==(const AudioContentBlockSpec& rhs) const;
407 bool operator!=(const AudioContentBlockSpec& rhs) const {
408 return !operator==(rhs);
409 }
412 string asString() const;
413
415 size_t getBlockSize() const;
416
418 size_t getPcmBlockSize() const;
419
421 bool isCompatibleWith(const AudioContentBlockSpec& rhs) const;
424 return audioFormat_;
425 }
428 return sampleFormat_;
429 }
431 string getSampleFormatAsString() const;
433 bool isLittleEndian() const {
434 return isLittleEndian(sampleFormat_);
435 }
437 bool isIEEEFloat() const {
438 return isIEEEFloat(sampleFormat_);
439 }
441 uint8_t getBitsPerSample() const {
442 return getBitsPerSample(sampleFormat_);
443 }
445 uint8_t getBytesPerSample() const {
446 return (getBitsPerSample(sampleFormat_) + 7) / 8; // round up
447 }
449 uint8_t getSampleFrameStride() const;
451 uint8_t getChannelCount() const {
452 return channelCount_;
453 }
455 uint32_t getSampleRate() const {
456 return sampleFrameRate_;
457 }
459 uint32_t getSampleCount() const {
460 return sampleFrameCount_;
461 }
463 void setSampleCount(uint32_t sampleCount) {
464 sampleFrameCount_ = sampleCount;
465 }
466
467 uint8_t getStereoPairCount() const {
468 return stereoPairCount_;
469 }
470
473 bool isSampleBlockFormatDefined() const;
474
476 static bool isLittleEndian(AudioSampleFormat sampleFormat);
478 static bool isIEEEFloat(AudioSampleFormat sampleFormat);
480 static uint8_t getBitsPerSample(AudioSampleFormat sampleFormat);
482 static uint8_t getBytesPerSample(AudioSampleFormat sampleFormat);
484 static string getSampleFormatAsString(AudioSampleFormat sampleFormat) {
485 return toString(sampleFormat);
486 }
487
488 private:
489 AudioFormat audioFormat_{};
490 AudioSampleFormat sampleFormat_{};
491 uint8_t sampleFrameStride_{};
492 uint8_t channelCount_{};
493 uint32_t sampleFrameRate_{};
494 uint32_t sampleFrameCount_{};
495 uint8_t stereoPairCount_{};
496};
497
511 public:
513 static const size_t kSizeUnknown;
514
516 /* implicit */ ContentBlock(ContentType type = ContentType::EMPTY, size_t size = kSizeUnknown);
517
519 explicit ContentBlock(const string& formatStr);
520
522 /* implicit */ ContentBlock(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0);
523
526 std::string codecName,
527 uint8_t codecQuality,
529 uint32_t width = 0,
530 uint32_t height = 0,
531 uint32_t stride = 0,
532 uint32_t stride2 = 0);
533
536 PixelFormat pixelFormat,
537 uint32_t width,
538 uint32_t height,
539 uint32_t stride = 0,
540 uint32_t stride2 = 0);
541
542 /* implicit */ ContentBlock(const ImageContentBlockSpec& imageSpec, size_t size = kSizeUnknown);
543 /* implicit */ ContentBlock(
544 ImageContentBlockSpec&& imageSpec,
545 size_t size = kSizeUnknown) noexcept;
547 const ContentBlock& imageContentBlock,
548 double keyFrameTimestamp,
549 uint32_t keyFrameIndex);
550
552 /* implicit */ ContentBlock(AudioFormat audioFormat, uint8_t channelCount = 0);
553 /* implicit */ ContentBlock(const AudioContentBlockSpec& audioSpec, size_t size);
554
557 AudioFormat audioFormat,
558 AudioSampleFormat sampleFormat,
559 uint8_t numChannels = 0,
560 uint8_t sampleFrameStride = 0,
561 uint32_t sampleRate = 0,
562 uint32_t sampleCount = 0,
563 uint8_t stereoPairCount = 0);
564
566 ContentBlock(const ContentBlock&) = default;
567 ContentBlock(ContentBlock&&) noexcept = default;
568
570 ContentBlock(const ContentBlock& other, size_t size)
571 : contentType_{other.contentType_}, size_{size} {
572 if (contentType_ == ContentType::IMAGE) {
573 imageSpec_ = other.imageSpec_;
574 } else if (contentType_ == ContentType::AUDIO) {
575 audioSpec_ = other.audioSpec_;
576 } else if (contentType_ == ContentType::CUSTOM) {
577 customContentBlockFormat_ = other.customContentBlockFormat_;
578 }
579 }
580
581 ~ContentBlock() = default;
582
583 ContentBlock& operator=(const ContentBlock& rhs) = default;
584 ContentBlock& operator=(ContentBlock&& rhs) noexcept = default;
585
587 string asString() const;
588
590 size_t getBlockSize() const;
591
594 return contentType_;
595 }
596
600 return customContentBlockFormat_;
601 }
602
603 bool operator==(const ContentBlock& rhs) const;
604
605 bool operator!=(const ContentBlock& rhs) const {
606 return !operator==(rhs);
607 }
608
610 RecordFormat operator+(const ContentBlock&) const;
611
613 const ImageContentBlockSpec& image() const;
615 const AudioContentBlockSpec& audio() const;
616
617 protected:
618 ContentType contentType_ = ContentType::EMPTY;
619 size_t size_ = kSizeUnknown;
620 ImageContentBlockSpec imageSpec_;
621 AudioContentBlockSpec audioSpec_;
622 string customContentBlockFormat_;
623};
624
626 public:
627 explicit CustomContentBlock(const string& customContentBlockFormat, size_t size = kSizeUnknown);
628 explicit CustomContentBlock(size_t size = kSizeUnknown);
629};
630
632using RecordFormatMap = map<pair<Record::Type, uint32_t>, RecordFormat>;
633
643 public:
645 RecordableTypeId typeIdIn,
646 Record::Type recordTypeIn,
647 uint32_t formatVersionIn,
648 size_t blockIndexIn)
649 : typeId(typeIdIn),
650 recordType(recordTypeIn),
651 formatVersion(formatVersionIn),
652 blockIndex(blockIndexIn) {}
653
654 RecordableTypeId getRecordableTypeId() const {
655 return typeId;
656 }
657
658 Record::Type getRecordType() const {
659 return recordType;
660 }
661
662 uint32_t getFormatVersion() const {
663 return formatVersion;
664 }
665
666 size_t getBlockIndex() const {
667 return blockIndex;
668 }
669
670 private:
671 RecordableTypeId typeId;
672 Record::Type recordType;
673 uint32_t formatVersion;
674 size_t blockIndex;
675};
676
687 public:
689 RecordFormat() = default;
691 RecordFormat(const RecordFormat&) = default;
692 /* implicit */ RecordFormat(RecordFormat&&) noexcept = default;
693 ~RecordFormat() = default;
694
695 RecordFormat& operator=(const RecordFormat&) = default;
696 RecordFormat& operator=(RecordFormat&&) noexcept = default;
697
701 explicit RecordFormat(const string& format) {
702 set(format);
703 }
707 explicit RecordFormat(const char* format) {
708 set(format);
709 }
711 /* implicit */ RecordFormat(const ContentBlock& block) {
712 blocks_.emplace_back(block);
713 }
715 /* implicit */ RecordFormat(ContentBlock&& block) noexcept {
716 blocks_.emplace_back(std::move(block));
717 }
719 RecordFormat(const ContentBlock& first, const ContentBlock& second) {
720 blocks_.emplace_back(first);
721 blocks_.emplace_back(second);
722 }
724 RecordFormat(ContentBlock&& first, ContentBlock&& second) noexcept {
725 blocks_.emplace_back(std::move(first));
726 blocks_.emplace_back(std::move(second));
727 }
732 /* implicit */ RecordFormat(ContentType type, size_t size = ContentBlock::kSizeUnknown) {
733 blocks_.emplace_back(type, size);
734 }
735
738 blocks_.emplace_back(block);
739 return *this;
740 }
743 blocks_.emplace_back(std::move(block));
744 return *this;
745 }
746
747 bool operator==(const RecordFormat& rhs) const;
748 bool operator!=(const RecordFormat& rhs) const {
749 return !operator==(rhs);
750 }
751
752 void clear() {
753 blocks_.clear();
754 }
755
758 void set(const string& format);
761 string asString() const;
762
765 size_t getRecordSize() const;
768 size_t getUsedBlocksCount() const;
772 size_t getBlocksOfTypeCount(ContentType type) const;
776 const ContentBlock& getContentBlock(size_t index) const;
780 return getContentBlock(0);
781 }
786 size_t getRemainingBlocksSize(size_t firstBlock) const;
793 size_t getBlockSize(size_t blockIndex, size_t remainingSize) const;
794
795 // Static VRS dedicated helper methods, for RecordFormat & DataLayout purposes.
796
798 static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion);
799 static string getDataLayoutTagName(Record::Type type, uint32_t version, size_t blockIndex);
802 static bool parseRecordFormatTagName(
803 const string& tagName,
804 Record::Type& recordType,
805 uint32_t& formatVersion);
806
809 static bool addRecordFormat(
810 map<string, string>& inOutRecordFormatRegister,
811 Record::Type recordType,
812 uint32_t formatVersion,
813 const RecordFormat& format,
814 const vector<const DataLayout*>& layouts);
815
816 static void getRecordFormats(
817 const map<string, string>& recordFormatRegister,
818 RecordFormatMap& outFormats);
819
820 static unique_ptr<DataLayout> getDataLayout(
821 const map<string, string>& recordFormatRegister,
822 const ContentBlockId& blockId);
823
824 private:
825 vector<ContentBlock> blocks_;
826};
827
828} // namespace vrs
Specification of an audio content block.
Definition RecordFormat.h:375
uint8_t getChannelCount() const
Get the number of audio channels in each sample frame (not in the content block).
Definition RecordFormat.h:451
void setSampleCount(uint32_t sampleCount)
Set the number of audio sample frames in the content block.
Definition RecordFormat.h:463
string asString() const
Definition RecordFormat.cpp:784
uint8_t getBitsPerSample() const
Get the number of bits per audio sample.
Definition RecordFormat.h:441
AudioContentBlockSpec(const AudioContentBlockSpec &)=default
Default copy constructor.
bool isLittleEndian() const
Tell if the audio sample format is little endian.
Definition RecordFormat.h:433
bool isSampleBlockFormatDefined() const
Definition RecordFormat.cpp:837
size_t getPcmBlockSize() const
Assuming PCM, get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:813
uint32_t getSampleCount() const
Get the number of audio sample frames in the content block.
Definition RecordFormat.h:459
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:724
uint8_t getBytesPerSample() const
Get the number of bytes per audio sample.
Definition RecordFormat.h:445
uint8_t getSampleFrameStride() const
Number of bytes used by a group of synchronous audio samples, including padding.
Definition RecordFormat.cpp:931
uint32_t getSampleRate() const
Get the audio frame sample rate.
Definition RecordFormat.h:455
bool isIEEEFloat() const
Tell if the audio sample format is an IEEE float.
Definition RecordFormat.h:437
AudioFormat getAudioFormat() const
Get audio format.
Definition RecordFormat.h:423
AudioSampleFormat getSampleFormat() const
Get audio sample format.
Definition RecordFormat.h:427
size_t getBlockSize() const
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:809
string getSampleFormatAsString() const
Get audio sample format as a string.
Definition RecordFormat.cpp:833
bool isCompatibleWith(const AudioContentBlockSpec &rhs) const
Tell if two audio block have identical audio formats.
Definition RecordFormat.cpp:827
static string getSampleFormatAsString(AudioSampleFormat sampleFormat)
Get an audio sample format as a string.
Definition RecordFormat.h:484
Specification of a VRS record content block.
Definition RecordFormat.h:510
size_t getBlockSize() const
Get the content block size, if available or calculable.
Definition RecordFormat.cpp:1075
ContentBlock(const ContentBlock &)=default
Default copy constructor.
string asString() const
Conversion to string, to store on disk & reconstruct later using constructor.
Definition RecordFormat.cpp:1045
const ImageContentBlockSpec & image() const
Get the image content spec. Requires the content block to be of type ContentType::IMAGE.
Definition RecordFormat.cpp:1117
ContentBlock(ContentType type=ContentType::EMPTY, size_t size=kSizeUnknown)
Very generic block description.
Definition RecordFormat.cpp:997
ContentType getContentType() const
Get the ContentType of the block.
Definition RecordFormat.h:593
string getCustomContentBlockFormat() const
Definition RecordFormat.h:599
const AudioContentBlockSpec & audio() const
Get the audio content spec. Requires the content block to be of type ContentType::AUDIO.
Definition RecordFormat.cpp:1122
RecordFormat operator+(const ContentBlock &) const
Assembly operator, to construct a RecordFormat for ContentBlock parts.
Definition RecordFormat.cpp:1113
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:513
Helper to identify a particular content block within a file.
Definition RecordFormat.h:642
RecordFormat string parsing helper class.
Definition RecordFormat.cpp:37
Definition RecordFormat.h:625
Specification of an image content block.
Definition RecordFormat.h:143
ImageContentBlockSpec & operator=(const ImageContentBlockSpec &)=default
Default copy assignment.
void set(ContentParser &parser)
When constructing from a string.
Definition RecordFormat.cpp:387
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:344
uint32_t getDefaultStride2() const
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value)
Definition RecordFormat.cpp:595
uint8_t getCodecQuality() const
Definition RecordFormat.h:323
string getPixelFormatAsString() const
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.cpp:646
uint32_t getKeyFrameIndex() const
Definition RecordFormat.h:339
string asString() const
Definition RecordFormat.cpp:432
size_t getBytesPerPixel() const
Definition RecordFormat.h:311
uint32_t getHeight() const
Get image height, or 0 if unknown/unspecified.
Definition RecordFormat.h:269
string getImageFormatAsString() const
Get Image format as string.
Definition RecordFormat.cpp:650
uint32_t getPlaneHeight(uint32_t planeIndex) const
Definition RecordFormat.cpp:609
uint32_t getStride() const
Get image stride (number of bytes between rows) for the first plane.
Definition RecordFormat.cpp:654
PixelFormat getPixelFormat() const
Get Pixel format.
Definition RecordFormat.h:259
static string getPixelFormatAsString(PixelFormat pixelFormat)
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.h:349
const string & getCodecName() const
Definition RecordFormat.h:317
uint32_t getPlaneStride(uint32_t planeIndex) const
Definition RecordFormat.cpp:585
bool sanityCheckStrides() const
Definition RecordFormat.cpp:572
size_t getRawImageSize() const
Definition RecordFormat.cpp:632
uint32_t getRawStride() const
Definition RecordFormat.h:276
size_t getBlockSize() const
Definition RecordFormat.cpp:628
ImageContentBlockSpec core() const
Return base of format (no codec quality nor key frame info)
Definition RecordFormat.cpp:355
double getKeyFrameTimestamp() const
Get timestamp of the key frame of the group of frames this video frame belongs to.
Definition RecordFormat.h:333
uint32_t getDefaultStride() const
Get default stride for plane 0 when stride isn't specified (minimum stride value)
Definition RecordFormat.cpp:659
static bool isQualityValid(uint8_t quality)
Validate that a quality value is valid.
Definition RecordFormat.h:328
uint8_t getChannelCountPerPixel() const
Definition RecordFormat.h:304
ImageFormat getImageFormat() const
Get image format.
Definition RecordFormat.h:251
uint32_t getPlaneCount() const
Get the number of planes for this pixel format.
Definition RecordFormat.h:288
uint32_t getWidth() const
Get image width, or 0 if unknown/unspecified.
Definition RecordFormat.h:265
Description of the format of a VRS record as a succession of typed blocks of content.
Definition RecordFormat.h:686
size_t getRemainingBlocksSize(size_t firstBlock) const
Definition RecordFormat.cpp:1170
static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion)
Names of the VRS stream tags used for RecordFormat descriptions.
Definition RecordFormat.cpp:1222
RecordFormat(const RecordFormat &)=default
Default copy constructor.
RecordFormat(ContentBlock &&first, ContentBlock &&second) noexcept
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:724
static bool parseRecordFormatTagName(const string &tagName, Record::Type &recordType, uint32_t &formatVersion)
Definition RecordFormat.cpp:1269
size_t getBlocksOfTypeCount(ContentType type) const
Definition RecordFormat.cpp:1192
RecordFormat & operator+(ContentBlock &&block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:742
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:707
size_t getBlockSize(size_t blockIndex, size_t remainingSize) const
Definition RecordFormat.cpp:1210
RecordFormat(const ContentBlock &block)
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:711
RecordFormat(ContentType type, size_t size=ContentBlock::kSizeUnknown)
Definition RecordFormat.h:732
size_t getUsedBlocksCount() const
Definition RecordFormat.cpp:1182
RecordFormat()=default
Empty record format definition.
RecordFormat(ContentBlock &&block) noexcept
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:715
const ContentBlock & getFirstContentBlock() const
Definition RecordFormat.h:779
RecordFormat(const ContentBlock &first, const ContentBlock &second)
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:719
void set(const string &format)
Definition RecordFormat.cpp:1147
size_t getRecordSize() const
Definition RecordFormat.cpp:1166
const ContentBlock & getContentBlock(size_t index) const
Definition RecordFormat.cpp:1202
string asString() const
Definition RecordFormat.cpp:1155
RecordFormat & operator+(const ContentBlock &block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:737
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:632
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.
@ 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:111
@ 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:100
@ 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.