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,
92
93 COUNT,
94};
95
96string toString(PixelFormat pixelFormat);
97
99enum class AudioFormat : uint8_t {
100 UNDEFINED = 0,
101 PCM = 1,
102 OPUS = 2,
103 COUNT
104};
105
107string toString(AudioFormat audioFormat);
108
110enum class AudioSampleFormat : uint8_t {
111 UNDEFINED = 0,
112 S8,
113 U8,
114 A_LAW,
115 MU_LAW,
116 S16_LE,
117 U16_LE,
118 S16_BE,
119 U16_BE,
120 S24_LE,
121 U24_LE,
122 S24_BE,
123 U24_BE,
124 S32_LE,
125 U32_LE,
126 S32_BE,
127 U32_BE,
128 F32_LE,
129 F32_BE,
130 F64_LE,
131 F64_BE,
132 COUNT
133};
134
136string toString(AudioSampleFormat audioSampleFormat);
137
138class ContentParser; // to workaround not being able to forward declare istringstream.
139class RecordFormat;
140
143 public:
144 static constexpr uint8_t kQualityUndefined = 255;
145 static constexpr double kInvalidTimestamp = -1E-308; // arbitrary unrealistic value
146
147 ImageContentBlockSpec() = default;
148
150 ImageContentBlockSpec(ImageContentBlockSpec&&) noexcept = default;
152 ImageContentBlockSpec imageSpec,
153 double keyFrameTimestamp,
154 uint32_t keyFrameIndex);
155
158 ImageFormat imageFormat,
159 PixelFormat pixelFormat,
160 uint32_t width = 0,
161 uint32_t height = 0,
162 uint32_t stride = 0,
163 uint32_t stride2 = 0,
164 string codecName = {},
165 uint8_t codecQuality = kQualityUndefined,
166 double keyFrameTimestamp = kInvalidTimestamp,
167 uint32_t keyFrameIndex = 0);
168
170 /* implicit */ ImageContentBlockSpec(
171 ImageFormat imageFormat,
172 uint32_t width = 0,
173 uint32_t height = 0);
174
177 PixelFormat pixelFormat,
178 uint32_t width,
179 uint32_t height,
180 uint32_t stride = 0,
181 uint32_t stride2 = 0
182 );
183
186 ImageFormat imageFormat,
187 string codecName,
188 uint8_t codecQuality = kQualityUndefined,
190 uint32_t width = 0,
191 uint32_t height = 0,
192 uint32_t stride = 0,
193 uint32_t stride2 = 0);
194
197 string codecName,
198 uint8_t codecQuality,
199 PixelFormat pixelFormat,
200 uint32_t width,
201 uint32_t height,
202 uint32_t stride = 0,
203 uint32_t stride2 = 0);
204
206 explicit ImageContentBlockSpec(const string& formatStr);
207
208 ~ImageContentBlockSpec() = default;
209
210 void init(
211 PixelFormat pixelFormat,
212 uint32_t width = 0,
213 uint32_t height = 0,
214 uint32_t stride = 0,
215 uint32_t stride2 = 0,
216 string codecName = {},
217 uint8_t codecQuality = kQualityUndefined,
218 double keyFrameTimestamp = kInvalidTimestamp,
219 uint32_t keyFrameIndex = 0);
220
222 void set(ContentParser& parser);
224 void clear();
225
228
231 string asString() const;
232
235 size_t getBlockSize() const;
236
239 size_t getRawImageSize() const;
240
244
246 bool operator==(const ImageContentBlockSpec& rhs) const;
247 bool operator!=(const ImageContentBlockSpec& rhs) const;
248
251 return imageFormat_;
252 }
253
255 string getImageFormatAsString() const;
256
259 return pixelFormat_;
260 }
262 string getPixelFormatAsString() const;
264 uint32_t getWidth() const {
265 return width_;
266 }
268 uint32_t getHeight() const {
269 return height_;
270 }
272 uint32_t getStride() const;
275 uint32_t getRawStride() const {
276 return stride_;
277 }
278 uint32_t getRawStride2() const {
279 return stride2_;
280 }
282 uint32_t getDefaultStride() const;
284 uint32_t getDefaultStride2() const;
285
287 uint32_t getPlaneCount() const {
288 return getPlaneCount(pixelFormat_);
289 }
290
293 uint32_t getPlaneStride(uint32_t planeIndex) const;
294
297 uint32_t getPlaneHeight(uint32_t planeIndex) const;
298
303 uint8_t getChannelCountPerPixel() const {
304 return getChannelCountPerPixel(pixelFormat_);
305 }
310 size_t getBytesPerPixel() const {
311 return getBytesPerPixel(pixelFormat_);
312 }
313
316 const string& getCodecName() const {
317 return codecName_;
318 }
322 uint8_t getCodecQuality() const {
323 return isQualityValid(codecQuality_) ? codecQuality_ : kQualityUndefined;
324 }
325
327 inline static bool isQualityValid(uint8_t quality) {
328 return quality <= 100;
329 }
330
332 double getKeyFrameTimestamp() const {
333 return keyFrameTimestamp_;
334 }
338 uint32_t getKeyFrameIndex() const {
339 return keyFrameIndex_;
340 }
341
343 static uint8_t getChannelCountPerPixel(PixelFormat pixel);
345 static size_t getBytesPerPixel(PixelFormat pixel);
346
348 static string getPixelFormatAsString(PixelFormat pixelFormat) {
349 return toString(pixelFormat);
350 }
351
353 static uint32_t getPlaneCount(PixelFormat pixelFormat);
354
357 bool sanityCheckStrides() const;
358
359 private:
362 uint32_t width_{0};
363 uint32_t height_{0};
364 uint32_t stride_{0}; // Stride (bytes between lines) for the first pixel plane
365 uint32_t stride2_{0}; // Stride for the other planes (same for all)
366 // for ImageFormat::VIDEO
367 string codecName_;
368 double keyFrameTimestamp_{kInvalidTimestamp};
369 uint32_t keyFrameIndex_{0};
370 uint8_t codecQuality_{kQualityUndefined};
371};
372
375 public:
376 AudioContentBlockSpec() = default;
379 AudioContentBlockSpec(AudioContentBlockSpec&&) noexcept = default;
381 explicit AudioContentBlockSpec(AudioFormat audioFormat, uint8_t channelCount = 0);
383 AudioFormat audioFormat,
384 AudioSampleFormat sampleFormat,
385 uint8_t channelCount = 0,
386 uint8_t sampleFrameStride = 0,
387 uint32_t sampleFrameRate = 0,
388 uint32_t sampleFrameCount = 0,
389 uint8_t stereoPairCount = 0);
390 ~AudioContentBlockSpec() = default;
391
394 explicit AudioContentBlockSpec(const string& formatStr);
395
398 void set(ContentParser& parser);
400 void clear();
401
402 AudioContentBlockSpec& operator=(const AudioContentBlockSpec&) = default;
403 AudioContentBlockSpec& operator=(AudioContentBlockSpec&&) noexcept = default;
404
405 bool operator==(const AudioContentBlockSpec& rhs) const;
406 bool operator!=(const AudioContentBlockSpec& rhs) const {
407 return !operator==(rhs);
408 }
411 string asString() const;
412
414 size_t getBlockSize() const;
415
417 size_t getPcmBlockSize() const;
418
420 bool isCompatibleWith(const AudioContentBlockSpec& rhs) const;
423 return audioFormat_;
424 }
427 return sampleFormat_;
428 }
430 string getSampleFormatAsString() const;
432 bool isLittleEndian() const {
433 return isLittleEndian(sampleFormat_);
434 }
436 bool isIEEEFloat() const {
437 return isIEEEFloat(sampleFormat_);
438 }
440 uint8_t getBitsPerSample() const {
441 return getBitsPerSample(sampleFormat_);
442 }
444 uint8_t getBytesPerSample() const {
445 return (getBitsPerSample(sampleFormat_) + 7) / 8; // round up
446 }
448 uint8_t getSampleFrameStride() const;
450 uint8_t getChannelCount() const {
451 return channelCount_;
452 }
454 uint32_t getSampleRate() const {
455 return sampleFrameRate_;
456 }
458 uint32_t getSampleCount() const {
459 return sampleFrameCount_;
460 }
462 void setSampleCount(uint32_t sampleCount) {
463 sampleFrameCount_ = sampleCount;
464 }
465
466 uint8_t getStereoPairCount() const {
467 return stereoPairCount_;
468 }
469
472 bool isSampleBlockFormatDefined() const;
473
475 static bool isLittleEndian(AudioSampleFormat sampleFormat);
477 static bool isIEEEFloat(AudioSampleFormat sampleFormat);
479 static uint8_t getBitsPerSample(AudioSampleFormat sampleFormat);
481 static uint8_t getBytesPerSample(AudioSampleFormat sampleFormat);
483 static string getSampleFormatAsString(AudioSampleFormat sampleFormat) {
484 return toString(sampleFormat);
485 }
486
487 private:
488 AudioFormat audioFormat_{};
489 AudioSampleFormat sampleFormat_{};
490 uint8_t sampleFrameStride_{};
491 uint8_t channelCount_{};
492 uint32_t sampleFrameRate_{};
493 uint32_t sampleFrameCount_{};
494 uint8_t stereoPairCount_{};
495};
496
510 public:
512 static const size_t kSizeUnknown;
513
515 /* implicit */ ContentBlock(ContentType type = ContentType::EMPTY, size_t size = kSizeUnknown);
516
518 explicit ContentBlock(const string& formatStr);
519
521 /* implicit */ ContentBlock(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0);
522
525 std::string codecName,
526 uint8_t codecQuality,
528 uint32_t width = 0,
529 uint32_t height = 0,
530 uint32_t stride = 0,
531 uint32_t stride2 = 0);
532
535 PixelFormat pixelFormat,
536 uint32_t width,
537 uint32_t height,
538 uint32_t stride = 0,
539 uint32_t stride2 = 0);
540
541 /* implicit */ ContentBlock(const ImageContentBlockSpec& imageSpec, size_t size = kSizeUnknown);
542 /* implicit */ ContentBlock(
543 ImageContentBlockSpec&& imageSpec,
544 size_t size = kSizeUnknown) noexcept;
546 const ContentBlock& imageContentBlock,
547 double keyFrameTimestamp,
548 uint32_t keyFrameIndex);
549
551 /* implicit */ ContentBlock(AudioFormat audioFormat, uint8_t channelCount = 0);
552 /* implicit */ ContentBlock(const AudioContentBlockSpec& audioSpec, size_t size);
553
556 AudioFormat audioFormat,
557 AudioSampleFormat sampleFormat,
558 uint8_t numChannels = 0,
559 uint8_t sampleFrameStride = 0,
560 uint32_t sampleRate = 0,
561 uint32_t sampleCount = 0,
562 uint8_t stereoPairCount = 0);
563
565 ContentBlock(const ContentBlock&) = default;
566 ContentBlock(ContentBlock&&) noexcept = default;
567
569 ContentBlock(const ContentBlock& other, size_t size)
570 : contentType_{other.contentType_}, size_{size} {
571 if (contentType_ == ContentType::IMAGE) {
572 imageSpec_ = other.imageSpec_;
573 } else if (contentType_ == ContentType::AUDIO) {
574 audioSpec_ = other.audioSpec_;
575 } else if (contentType_ == ContentType::CUSTOM) {
576 customContentBlockFormat_ = other.customContentBlockFormat_;
577 }
578 }
579
580 ~ContentBlock() = default;
581
582 ContentBlock& operator=(const ContentBlock& rhs) = default;
583 ContentBlock& operator=(ContentBlock&& rhs) noexcept = default;
584
586 string asString() const;
587
589 size_t getBlockSize() const;
590
593 return contentType_;
594 }
595
599 return customContentBlockFormat_;
600 }
601
602 bool operator==(const ContentBlock& rhs) const;
603
604 bool operator!=(const ContentBlock& rhs) const {
605 return !operator==(rhs);
606 }
607
609 RecordFormat operator+(const ContentBlock&) const;
610
612 const ImageContentBlockSpec& image() const;
614 const AudioContentBlockSpec& audio() const;
615
616 protected:
617 ContentType contentType_ = ContentType::EMPTY;
618 size_t size_ = kSizeUnknown;
619 ImageContentBlockSpec imageSpec_;
620 AudioContentBlockSpec audioSpec_;
621 string customContentBlockFormat_;
622};
623
625 public:
626 explicit CustomContentBlock(const string& customContentBlockFormat, size_t size = kSizeUnknown);
627 explicit CustomContentBlock(size_t size = kSizeUnknown);
628};
629
631using RecordFormatMap = map<pair<Record::Type, uint32_t>, RecordFormat>;
632
642 public:
644 RecordableTypeId typeIdIn,
645 Record::Type recordTypeIn,
646 uint32_t formatVersionIn,
647 size_t blockIndexIn)
648 : typeId(typeIdIn),
649 recordType(recordTypeIn),
650 formatVersion(formatVersionIn),
651 blockIndex(blockIndexIn) {}
652
653 RecordableTypeId getRecordableTypeId() const {
654 return typeId;
655 }
656
657 Record::Type getRecordType() const {
658 return recordType;
659 }
660
661 uint32_t getFormatVersion() const {
662 return formatVersion;
663 }
664
665 size_t getBlockIndex() const {
666 return blockIndex;
667 }
668
669 private:
670 RecordableTypeId typeId;
671 Record::Type recordType;
672 uint32_t formatVersion;
673 size_t blockIndex;
674};
675
686 public:
688 RecordFormat() = default;
690 RecordFormat(const RecordFormat&) = default;
691 /* implicit */ RecordFormat(RecordFormat&&) noexcept = default;
692 ~RecordFormat() = default;
693
694 RecordFormat& operator=(const RecordFormat&) = default;
695 RecordFormat& operator=(RecordFormat&&) noexcept = default;
696
700 explicit RecordFormat(const string& format) {
701 set(format);
702 }
706 explicit RecordFormat(const char* format) {
707 set(format);
708 }
710 /* implicit */ RecordFormat(const ContentBlock& block) {
711 blocks_.emplace_back(block);
712 }
714 /* implicit */ RecordFormat(ContentBlock&& block) noexcept {
715 blocks_.emplace_back(std::move(block));
716 }
718 RecordFormat(const ContentBlock& first, const ContentBlock& second) {
719 blocks_.emplace_back(first);
720 blocks_.emplace_back(second);
721 }
723 RecordFormat(ContentBlock&& first, ContentBlock&& second) noexcept {
724 blocks_.emplace_back(std::move(first));
725 blocks_.emplace_back(std::move(second));
726 }
731 /* implicit */ RecordFormat(ContentType type, size_t size = ContentBlock::kSizeUnknown) {
732 blocks_.emplace_back(type, size);
733 }
734
737 blocks_.emplace_back(block);
738 return *this;
739 }
742 blocks_.emplace_back(std::move(block));
743 return *this;
744 }
745
746 bool operator==(const RecordFormat& rhs) const;
747 bool operator!=(const RecordFormat& rhs) const {
748 return !operator==(rhs);
749 }
750
751 void clear() {
752 blocks_.clear();
753 }
754
757 void set(const string& format);
760 string asString() const;
761
764 size_t getRecordSize() const;
767 size_t getUsedBlocksCount() const;
771 size_t getBlocksOfTypeCount(ContentType type) const;
775 const ContentBlock& getContentBlock(size_t index) const;
779 return getContentBlock(0);
780 }
785 size_t getRemainingBlocksSize(size_t firstBlock) const;
792 size_t getBlockSize(size_t blockIndex, size_t remainingSize) const;
793
794 // Static VRS dedicated helper methods, for RecordFormat & DataLayout purposes.
795
797 static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion);
798 static string getDataLayoutTagName(Record::Type type, uint32_t version, size_t blockIndex);
801 static bool parseRecordFormatTagName(
802 const string& tagName,
803 Record::Type& recordType,
804 uint32_t& formatVersion);
805
808 static bool addRecordFormat(
809 map<string, string>& inOutRecordFormatRegister,
810 Record::Type recordType,
811 uint32_t formatVersion,
812 const RecordFormat& format,
813 const vector<const DataLayout*>& layouts);
814
815 static void getRecordFormats(
816 const map<string, string>& recordFormatRegister,
817 RecordFormatMap& outFormats);
818
819 static unique_ptr<DataLayout> getDataLayout(
820 const map<string, string>& recordFormatRegister,
821 const ContentBlockId& blockId);
822
823 private:
824 vector<ContentBlock> blocks_;
825};
826
827} // namespace vrs
Specification of an audio content block.
Definition RecordFormat.h:374
uint8_t getChannelCount() const
Get the number of audio channels in each sample frame (not in the content block).
Definition RecordFormat.h:450
void setSampleCount(uint32_t sampleCount)
Set the number of audio sample frames in the content block.
Definition RecordFormat.h:462
string asString() const
Definition RecordFormat.cpp:778
uint8_t getBitsPerSample() const
Get the number of bits per audio sample.
Definition RecordFormat.h:440
AudioContentBlockSpec(const AudioContentBlockSpec &)=default
Default copy constructor.
bool isLittleEndian() const
Tell if the audio sample format is little endian.
Definition RecordFormat.h:432
bool isSampleBlockFormatDefined() const
Definition RecordFormat.cpp:831
size_t getPcmBlockSize() const
Assuming PCM, get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:807
uint32_t getSampleCount() const
Get the number of audio sample frames in the content block.
Definition RecordFormat.h:458
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:718
uint8_t getBytesPerSample() const
Get the number of bytes per audio sample.
Definition RecordFormat.h:444
uint8_t getSampleFrameStride() const
Number of bytes used by a group of synchronous audio samples, including padding.
Definition RecordFormat.cpp:925
uint32_t getSampleRate() const
Get the audio frame sample rate.
Definition RecordFormat.h:454
bool isIEEEFloat() const
Tell if the audio sample format is an IEEE float.
Definition RecordFormat.h:436
AudioFormat getAudioFormat() const
Get audio format.
Definition RecordFormat.h:422
AudioSampleFormat getSampleFormat() const
Get audio sample format.
Definition RecordFormat.h:426
size_t getBlockSize() const
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:803
string getSampleFormatAsString() const
Get audio sample format as a string.
Definition RecordFormat.cpp:827
bool isCompatibleWith(const AudioContentBlockSpec &rhs) const
Tell if two audio block have identical audio formats.
Definition RecordFormat.cpp:821
static string getSampleFormatAsString(AudioSampleFormat sampleFormat)
Get an audio sample format as a string.
Definition RecordFormat.h:483
Specification of a VRS record content block.
Definition RecordFormat.h:509
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:1039
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:991
ContentType getContentType() const
Get the ContentType of the block.
Definition RecordFormat.h:592
string getCustomContentBlockFormat() const
Definition RecordFormat.h:598
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:512
Helper to identify a particular content block within a file.
Definition RecordFormat.h:641
RecordFormat string parsing helper class.
Definition RecordFormat.cpp:37
Definition RecordFormat.h:624
Specification of an image content block.
Definition RecordFormat.h:142
ImageContentBlockSpec & operator=(const ImageContentBlockSpec &)=default
Default copy assignment.
void set(ContentParser &parser)
When constructing from a string.
Definition RecordFormat.cpp:383
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:340
uint32_t getDefaultStride2() const
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value)
Definition RecordFormat.cpp:589
uint8_t getCodecQuality() const
Definition RecordFormat.h:322
string getPixelFormatAsString() const
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.cpp:640
uint32_t getKeyFrameIndex() const
Definition RecordFormat.h:338
string asString() const
Definition RecordFormat.cpp:428
size_t getBytesPerPixel() const
Definition RecordFormat.h:310
uint32_t getHeight() const
Get image height, or 0 if unknown/unspecified.
Definition RecordFormat.h:268
string getImageFormatAsString() const
Get Image format as string.
Definition RecordFormat.cpp:644
uint32_t getPlaneHeight(uint32_t planeIndex) const
Definition RecordFormat.cpp:603
uint32_t getStride() const
Get image stride (number of bytes between rows) for the first plane.
Definition RecordFormat.cpp:648
PixelFormat getPixelFormat() const
Get Pixel format.
Definition RecordFormat.h:258
static string getPixelFormatAsString(PixelFormat pixelFormat)
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.h:348
const string & getCodecName() const
Definition RecordFormat.h:316
uint32_t getPlaneStride(uint32_t planeIndex) const
Definition RecordFormat.cpp:579
bool sanityCheckStrides() const
Definition RecordFormat.cpp:566
size_t getRawImageSize() const
Definition RecordFormat.cpp:626
uint32_t getRawStride() const
Definition RecordFormat.h:275
size_t getBlockSize() const
Definition RecordFormat.cpp:622
ImageContentBlockSpec core() const
Return base of format (no codec quality nor key frame info)
Definition RecordFormat.cpp:351
double getKeyFrameTimestamp() const
Get timestamp of the key frame of the group of frames this video frame belongs to.
Definition RecordFormat.h:332
uint32_t getDefaultStride() const
Get default stride for plane 0 when stride isn't specified (minimum stride value)
Definition RecordFormat.cpp:653
static bool isQualityValid(uint8_t quality)
Validate that a quality value is valid.
Definition RecordFormat.h:327
uint8_t getChannelCountPerPixel() const
Definition RecordFormat.h:303
ImageFormat getImageFormat() const
Get image format.
Definition RecordFormat.h:250
uint32_t getPlaneCount() const
Get the number of planes for this pixel format.
Definition RecordFormat.h:287
uint32_t getWidth() const
Get image width, or 0 if unknown/unspecified.
Definition RecordFormat.h:264
Description of the format of a VRS record as a succession of typed blocks of content.
Definition RecordFormat.h:685
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:1216
RecordFormat(const RecordFormat &)=default
Default copy constructor.
RecordFormat(ContentBlock &&first, ContentBlock &&second) noexcept
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:723
static bool parseRecordFormatTagName(const string &tagName, Record::Type &recordType, uint32_t &formatVersion)
Definition RecordFormat.cpp:1263
size_t getBlocksOfTypeCount(ContentType type) const
Definition RecordFormat.cpp:1186
RecordFormat & operator+(ContentBlock &&block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:741
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:706
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:710
RecordFormat(ContentType type, size_t size=ContentBlock::kSizeUnknown)
Definition RecordFormat.h:731
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:714
const ContentBlock & getFirstContentBlock() const
Definition RecordFormat.h:778
RecordFormat(const ContentBlock &first, const ContentBlock &second)
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:718
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:736
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:631
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.
@ 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:110
@ 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:99
@ 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.