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
47enum class ImageFormat : uint8_t {
48 UNDEFINED = 0,
49 RAW,
50 JPG,
51 PNG,
52 VIDEO,
53 JXL,
54 COUNT
55};
56
57string toString(ImageFormat imageFormat);
58
60enum class PixelFormat : uint8_t {
61 UNDEFINED = 0,
62
63 GREY8 = 1,
64 BGR8,
65 DEPTH32F,
66 RGB8,
69 RGBA8,
70 RGB10,
71 RGB12,
72 GREY10,
73 GREY12,
74 GREY16,
75 RGB32F,
76 SCALAR64F,
77 YUY2,
80 RGBA32F,
82 RAW10,
87
88 COUNT,
89};
90
91string toString(PixelFormat pixelFormat);
92
94enum class AudioFormat : uint8_t {
95 UNDEFINED = 0,
96 PCM = 1,
97 OPUS = 2,
98 COUNT
99};
100
102string toString(AudioFormat audioFormat);
103
105enum class AudioSampleFormat : uint8_t {
106 UNDEFINED = 0,
107 S8,
108 U8,
109 A_LAW,
110 MU_LAW,
111 S16_LE,
112 U16_LE,
113 S16_BE,
114 U16_BE,
115 S24_LE,
116 U24_LE,
117 S24_BE,
118 U24_BE,
119 S32_LE,
120 U32_LE,
121 S32_BE,
122 U32_BE,
123 F32_LE,
124 F32_BE,
125 F64_LE,
126 F64_BE,
127 COUNT
128};
129
131string toString(AudioSampleFormat audioSampleFormat);
132
133class ContentParser; // to workaround not being able to forward declare istringstream.
134class RecordFormat;
135
138 public:
139 static constexpr uint8_t kQualityUndefined = 255;
140 static constexpr double kInvalidTimestamp = -1E-308; // arbitrary unrealistic value
141
142 ImageContentBlockSpec() = default;
143
146 const ImageContentBlockSpec& imageSpec,
147 double keyFrameTimestamp,
148 uint32_t keyFrameIndex);
149
152 ImageFormat imageFormat,
153 PixelFormat pixelFormat,
154 uint32_t width = 0,
155 uint32_t height = 0,
156 uint32_t stride = 0,
157 uint32_t stride2 = 0,
158 string codecName = {},
159 uint8_t codecQuality = kQualityUndefined,
160 double keyFrameTimestamp = kInvalidTimestamp,
161 uint32_t keyFrameIndex = 0);
162
164 ImageContentBlockSpec(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0); // NOLINT
165
168 PixelFormat pixelFormat,
169 uint32_t width,
170 uint32_t height,
171 uint32_t stride = 0,
172 uint32_t stride2 = 0
173 );
174
177 string codecName,
178 uint8_t codecQuality,
179 PixelFormat pixelFormat,
180 uint32_t width,
181 uint32_t height,
182 uint32_t stride = 0,
183 uint32_t stride2 = 0);
184
186 explicit ImageContentBlockSpec(const string& formatStr);
187
189 void set(ContentParser& parser);
191 void clear();
192
195
198 string asString() const;
199
202 size_t getBlockSize() const;
203
206 size_t getRawImageSize() const;
207
210
212 bool operator==(const ImageContentBlockSpec& rhs) const;
213 bool operator!=(const ImageContentBlockSpec& rhs) const;
214
217 return imageFormat_;
218 }
219
221 string getImageFormatAsString() const;
222
225 return pixelFormat_;
226 }
228 string getPixelFormatAsString() const;
230 uint32_t getWidth() const {
231 return width_;
232 }
234 uint32_t getHeight() const {
235 return height_;
236 }
238 uint32_t getStride() const;
241 uint32_t getRawStride() const {
242 return stride_;
243 }
244 uint32_t getRawStride2() const {
245 return stride2_;
246 }
248 uint32_t getDefaultStride() const;
250 uint32_t getDefaultStride2() const;
251
253 uint32_t getPlaneCount() const {
254 return getPlaneCount(pixelFormat_);
255 }
256
259 uint32_t getPlaneStride(uint32_t planeIndex) const;
260
263 uint32_t getPlaneHeight(uint32_t planeIndex) const;
264
269 uint8_t getChannelCountPerPixel() const {
270 return getChannelCountPerPixel(pixelFormat_);
271 }
276 size_t getBytesPerPixel() const {
277 return getBytesPerPixel(pixelFormat_);
278 }
279
282 const string& getCodecName() const {
283 return codecName_;
284 }
288 uint8_t getCodecQuality() const {
289 return isQualityValid(codecQuality_) ? codecQuality_ : kQualityUndefined;
290 }
291
293 inline static bool isQualityValid(uint8_t quality) {
294 return quality <= 100;
295 }
296
298 double getKeyFrameTimestamp() const {
299 return keyFrameTimestamp_;
300 }
304 uint32_t getKeyFrameIndex() const {
305 return keyFrameIndex_;
306 }
307
309 static uint8_t getChannelCountPerPixel(PixelFormat pixel);
311 static size_t getBytesPerPixel(PixelFormat pixel);
312
314 static string getPixelFormatAsString(PixelFormat pixelFormat) {
315 return toString(pixelFormat);
316 }
317
319 static uint32_t getPlaneCount(PixelFormat pixelFormat);
320
323 bool sanityCheckStrides() const;
324
325 private:
328 uint32_t width_{0};
329 uint32_t height_{0};
330 uint32_t stride_{0}; // Stride (bytes between lines) for the first pixel plane
331 uint32_t stride2_{0}; // Stride for the other planes (same for all)
332 // for ImageFormat::VIDEO
333 string codecName_;
334 double keyFrameTimestamp_{kInvalidTimestamp};
335 uint32_t keyFrameIndex_{0};
336 uint8_t codecQuality_{kQualityUndefined};
337};
338
341 public:
342 AudioContentBlockSpec() = default;
346 explicit AudioContentBlockSpec(AudioFormat audioFormat, uint8_t channelCount = 0);
348 AudioFormat audioFormat,
349 AudioSampleFormat sampleFormat,
350 uint8_t channelCount = 0,
351 uint8_t sampleFrameStride = 0,
352 uint32_t sampleFrameRate = 0,
353 uint32_t sampleFrameCount = 0,
354 uint8_t stereoPairCount = 0);
355
358 explicit AudioContentBlockSpec(const string& formatStr);
359
362 void set(ContentParser& parser);
364 void clear();
365
368 string asString() const;
369
371 size_t getBlockSize() const;
372
374 size_t getPcmBlockSize() const;
375
378
380 bool operator==(const AudioContentBlockSpec& rhs) const;
381 bool operator!=(const AudioContentBlockSpec& rhs) const {
382 return !operator==(rhs);
383 }
385 bool isCompatibleWith(const AudioContentBlockSpec& rhs) const;
388 return audioFormat_;
389 }
392 return sampleFormat_;
393 }
395 string getSampleFormatAsString() const;
397 bool isLittleEndian() const {
398 return isLittleEndian(sampleFormat_);
399 }
401 bool isIEEEFloat() const {
402 return isIEEEFloat(sampleFormat_);
403 }
405 uint8_t getBitsPerSample() const {
406 return getBitsPerSample(sampleFormat_);
407 }
409 uint8_t getBytesPerSample() const {
410 return (getBitsPerSample(sampleFormat_) + 7) / 8; // round up
411 }
413 uint8_t getSampleFrameStride() const;
415 uint8_t getChannelCount() const {
416 return channelCount_;
417 }
419 uint32_t getSampleRate() const {
420 return sampleFrameRate_;
421 }
423 uint32_t getSampleCount() const {
424 return sampleFrameCount_;
425 }
427 void setSampleCount(uint32_t sampleCount) {
428 sampleFrameCount_ = sampleCount;
429 }
430
431 uint8_t getStereoPairCount() const {
432 return stereoPairCount_;
433 }
434
437 bool isSampleBlockFormatDefined() const;
438
440 static bool isLittleEndian(AudioSampleFormat sampleFormat);
442 static bool isIEEEFloat(AudioSampleFormat sampleFormat);
444 static uint8_t getBitsPerSample(AudioSampleFormat sampleFormat);
446 static uint8_t getBytesPerSample(AudioSampleFormat sampleFormat);
448 static string getSampleFormatAsString(AudioSampleFormat sampleFormat) {
449 return toString(sampleFormat);
450 }
451
452 private:
453 AudioFormat audioFormat_{};
454 AudioSampleFormat sampleFormat_{};
455 uint8_t sampleFrameStride_{};
456 uint8_t channelCount_{};
457 uint32_t sampleFrameRate_{};
458 uint32_t sampleFrameCount_{};
459 uint8_t stereoPairCount_{};
460};
461
475 public:
477 static const size_t kSizeUnknown;
478
480 ContentBlock(ContentType type = ContentType::EMPTY, size_t size = kSizeUnknown); // NOLINT
481
483 explicit ContentBlock(const string& formatStr);
484
486 ContentBlock(ImageFormat imageFormat, uint32_t width = 0, uint32_t height = 0); // NOLINT
487
490 const std::string& codecName,
491 uint8_t codecQuality,
493 uint32_t width = 0,
494 uint32_t height = 0,
495 uint32_t stride = 0,
496 uint32_t stride2 = 0);
497
500 PixelFormat pixelFormat,
501 uint32_t width,
502 uint32_t height,
503 uint32_t stride = 0,
504 uint32_t stride2 = 0);
505
506 ContentBlock(const ImageContentBlockSpec& imageSpec, size_t size = kSizeUnknown); // NOLINT
508 const ContentBlock& imageContentBlock,
509 double keyFrameTimestamp,
510 uint32_t keyFrameIndex);
511
513 ContentBlock(AudioFormat audioFormat, uint8_t channelCount = 0); // NOLINT
514 ContentBlock(const AudioContentBlockSpec& audioSpec, size_t size);
515
518 AudioFormat audioFormat,
519 AudioSampleFormat sampleFormat,
520 uint8_t numChannels = 0,
521 uint8_t sampleFrameStride = 0,
522 uint32_t sampleRate = 0,
523 uint32_t sampleCount = 0,
524 uint8_t stereoPairCount = 0);
525
527 ContentBlock(const ContentBlock&) = default;
528
530 ContentBlock(const ContentBlock& other, size_t size)
531 : contentType_{other.contentType_}, size_{size} {
532 if (contentType_ == ContentType::IMAGE) {
533 imageSpec_ = other.imageSpec_;
534 } else if (contentType_ == ContentType::AUDIO) {
535 audioSpec_ = other.audioSpec_;
536 } else if (contentType_ == ContentType::CUSTOM) {
537 customContentBlockFormat_ = other.customContentBlockFormat_;
538 }
539 }
540
542 ContentBlock& operator=(const ContentBlock& rhs) = default;
543
545 string asString() const;
546
548 size_t getBlockSize() const;
549
552 return contentType_;
553 }
554
558 return customContentBlockFormat_;
559 }
560
561 bool operator==(const ContentBlock& rhs) const;
562
563 bool operator!=(const ContentBlock& rhs) const {
564 return !operator==(rhs);
565 }
566
568 RecordFormat operator+(const ContentBlock&) const;
569
571 const ImageContentBlockSpec& image() const;
573 const AudioContentBlockSpec& audio() const;
574
575 protected:
576 ContentType contentType_ = ContentType::EMPTY;
577 size_t size_ = kSizeUnknown;
578 ImageContentBlockSpec imageSpec_;
579 AudioContentBlockSpec audioSpec_;
580 string customContentBlockFormat_;
581};
582
584 public:
585 explicit CustomContentBlock(const string& customContentBlockFormat, size_t size = kSizeUnknown);
586 explicit CustomContentBlock(size_t size = kSizeUnknown);
587};
588
590using RecordFormatMap = map<pair<Record::Type, uint32_t>, RecordFormat>;
591
601 public:
603 RecordableTypeId typeId,
604 Record::Type recordType,
605 uint32_t formatVersion,
606 size_t blockIndex)
607 : typeId(typeId),
608 recordType(recordType),
609 formatVersion(formatVersion),
610 blockIndex(blockIndex) {}
611
612 RecordableTypeId getRecordableTypeId() const {
613 return typeId;
614 }
615
616 Record::Type getRecordType() const {
617 return recordType;
618 }
619
620 uint32_t getFormatVersion() const {
621 return formatVersion;
622 }
623
624 size_t getBlockIndex() const {
625 return blockIndex;
626 }
627
628 private:
629 RecordableTypeId typeId;
630 Record::Type recordType;
631 uint32_t formatVersion;
632 size_t blockIndex;
633};
634
645 public:
647 RecordFormat() = default;
649 RecordFormat(const RecordFormat&) = default; // NOLINT
650
654 RecordFormat(const string& format) { // NOLINT
655 set(format);
656 }
660 RecordFormat(const char* format) { // NOLINT
661 set(format);
662 }
664 RecordFormat(const ContentBlock& block) { // NOLINT
665 blocks_.emplace_back(block);
666 }
668 RecordFormat(ContentBlock&& block) { // NOLINT
669 blocks_.emplace_back(block);
670 }
672 RecordFormat(const ContentBlock& first, const ContentBlock& second) {
673 blocks_.emplace_back(first);
674 blocks_.emplace_back(second);
675 }
677 RecordFormat(const ContentBlock&& first, const ContentBlock&& second) {
678 blocks_.emplace_back(first);
679 blocks_.emplace_back(second);
680 }
685 RecordFormat(ContentType type, size_t size = ContentBlock::kSizeUnknown) { // NOLINT
686 blocks_.emplace_back(type, size);
687 }
688
691 blocks_.emplace_back(block);
692 return *this;
693 }
696 blocks_.emplace_back(block);
697 return *this;
698 }
699
702 bool operator==(const RecordFormat& rhs) const;
703 bool operator!=(const RecordFormat& rhs) const {
704 return !operator==(rhs);
705 }
706
707 void clear() {
708 blocks_.clear();
709 }
710
713 void set(const string& format);
716 string asString() const;
717
720 size_t getRecordSize() const;
723 size_t getUsedBlocksCount() const;
727 size_t getBlocksOfTypeCount(ContentType type) const;
731 const ContentBlock& getContentBlock(size_t index) const;
735 return getContentBlock(0);
736 }
741 size_t getRemainingBlocksSize(size_t firstBlock) const;
748 size_t getBlockSize(size_t blockIndex, size_t remainingSize) const;
749
750 // Static VRS dedicated helper methods, for RecordFormat & DataLayout purposes.
751
753 static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion);
754 static string getDataLayoutTagName(Record::Type type, uint32_t version, size_t blockIndex);
757 static bool parseRecordFormatTagName(
758 const string& tagName,
759 Record::Type& recordType,
760 uint32_t& formatVersion);
761
764 static bool addRecordFormat(
765 map<string, string>& inOutRecordFormatRegister,
766 Record::Type recordType,
767 uint32_t formatVersion,
768 const RecordFormat& format,
769 const vector<const DataLayout*>& layouts);
770
771 static void getRecordFormats(
772 const map<string, string>& recordFormatRegister,
773 RecordFormatMap& outFormats);
774
775 static unique_ptr<DataLayout> getDataLayout(
776 const map<string, string>& recordFormatRegister,
777 const ContentBlockId& blockId);
778
779 private:
780 vector<ContentBlock> blocks_;
781};
782
783} // namespace vrs
Specification of an audio content block.
Definition RecordFormat.h:340
uint8_t getChannelCount() const
Get the number of audio channels in each sample frame (not in the content block).
Definition RecordFormat.h:415
void setSampleCount(uint32_t sampleCount)
Set the number of audio sample frames in the content block.
Definition RecordFormat.h:427
string asString() const
Definition RecordFormat.cpp:797
void set(ContentParser &parser)
Definition RecordFormat.cpp:746
uint8_t getBitsPerSample() const
Get the number of bits per audio sample.
Definition RecordFormat.h:405
AudioContentBlockSpec(const AudioContentBlockSpec &)=default
Default copy constructor.
bool operator==(const AudioContentBlockSpec &rhs) const
Compare two audio block spec.
Definition RecordFormat.cpp:834
bool isLittleEndian() const
Tell if the audio sample format is little endian.
Definition RecordFormat.h:397
bool isSampleBlockFormatDefined() const
Definition RecordFormat.cpp:850
size_t getPcmBlockSize() const
Assuming PCM, get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:826
uint32_t getSampleCount() const
Get the number of audio sample frames in the content block.
Definition RecordFormat.h:423
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:737
uint8_t getBytesPerSample() const
Get the number of bytes per audio sample.
Definition RecordFormat.h:409
uint8_t getSampleFrameStride() const
Number of bytes used by a group of synchronous audio samples, including padding.
Definition RecordFormat.cpp:944
uint32_t getSampleRate() const
Get the audio frame sample rate.
Definition RecordFormat.h:419
bool isIEEEFloat() const
Tell if the audio sample format is an IEEE float.
Definition RecordFormat.h:401
AudioFormat getAudioFormat() const
Get audio format.
Definition RecordFormat.h:387
AudioSampleFormat getSampleFormat() const
Get audio sample format.
Definition RecordFormat.h:391
AudioContentBlockSpec & operator=(const AudioContentBlockSpec &)=default
Default copy assignment.
size_t getBlockSize() const
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:822
string getSampleFormatAsString() const
Get audio sample format as a string.
Definition RecordFormat.cpp:846
bool isCompatibleWith(const AudioContentBlockSpec &rhs) const
Tell if two audio block have identical audio formats.
Definition RecordFormat.cpp:840
static string getSampleFormatAsString(AudioSampleFormat sampleFormat)
Get an audio sample format as a string.
Definition RecordFormat.h:448
Specification of a VRS record content block.
Definition RecordFormat.h:474
ContentBlock(const ContentBlock &other, size_t size)
Copy constructor, except for the size.
Definition RecordFormat.h:530
size_t getBlockSize() const
Get the content block size, if available or calculable.
Definition RecordFormat.cpp:1087
ContentBlock(const ContentBlock &)=default
Default copy constructor.
string asString() const
Conversion to string, to store on disk & reconstruct later using constructor.
Definition RecordFormat.cpp:1056
const ImageContentBlockSpec & image() const
Get the image content spec. Requires the content block to be of type ContentType::IMAGE.
Definition RecordFormat.cpp:1129
ContentType getContentType() const
Get the ContentType of the block.
Definition RecordFormat.h:551
string getCustomContentBlockFormat() const
Definition RecordFormat.h:557
const AudioContentBlockSpec & audio() const
Get the audio content spec. Requires the content block to be of type ContentType::AUDIO.
Definition RecordFormat.cpp:1134
ContentBlock(const 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.
RecordFormat operator+(const ContentBlock &) const
Assembly operator, to construct a RecordFormat for ContentBlock parts.
Definition RecordFormat.cpp:1125
ContentBlock & operator=(const ContentBlock &rhs)=default
Default copy assignment.
static const size_t kSizeUnknown
Special value used to represent an unknown block size.
Definition RecordFormat.h:477
Helper to identify a particular content block within a file.
Definition RecordFormat.h:600
RecordFormat string parsing helper class.
Definition RecordFormat.cpp:37
Definition RecordFormat.h:583
Specification of an image content block.
Definition RecordFormat.h:137
ImageContentBlockSpec & operator=(const ImageContentBlockSpec &)=default
Default copy assignment.
void set(ContentParser &parser)
When constructing from a string.
Definition RecordFormat.cpp:404
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:361
uint32_t getDefaultStride2() const
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value)
Definition RecordFormat.cpp:605
uint8_t getCodecQuality() const
Definition RecordFormat.h:288
string getPixelFormatAsString() const
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.cpp:660
uint32_t getKeyFrameIndex() const
Definition RecordFormat.h:304
string asString() const
Definition RecordFormat.cpp:449
size_t getBytesPerPixel() const
Definition RecordFormat.h:276
uint32_t getHeight() const
Get image height, or 0 if unknown/unspecified.
Definition RecordFormat.h:234
string getImageFormatAsString() const
Get Image format as string.
Definition RecordFormat.cpp:664
uint32_t getPlaneHeight(uint32_t planeIndex) const
Definition RecordFormat.cpp:622
uint32_t getStride() const
Get image stride (number of bytes between rows) for the first plane.
Definition RecordFormat.cpp:668
PixelFormat getPixelFormat() const
Get Pixel format.
Definition RecordFormat.h:224
static string getPixelFormatAsString(PixelFormat pixelFormat)
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.h:314
const string & getCodecName() const
Definition RecordFormat.h:282
uint32_t getPlaneStride(uint32_t planeIndex) const
Definition RecordFormat.cpp:595
bool sanityCheckStrides() const
Definition RecordFormat.cpp:582
size_t getRawImageSize() const
Definition RecordFormat.cpp:646
uint32_t getRawStride() const
Definition RecordFormat.h:241
size_t getBlockSize() const
Definition RecordFormat.cpp:642
ImageContentBlockSpec core() const
Return base of format (no codec quality nor key frame info)
Definition RecordFormat.cpp:372
double getKeyFrameTimestamp() const
Get timestamp of the key frame of the group of frames this video frame belongs to.
Definition RecordFormat.h:298
uint32_t getDefaultStride() const
Get default stride for plane 0 when stride isn't specified (minimum stride value)
Definition RecordFormat.cpp:673
static bool isQualityValid(uint8_t quality)
Validate that a quality value is valid.
Definition RecordFormat.h:293
uint8_t getChannelCountPerPixel() const
Definition RecordFormat.h:269
ImageFormat getImageFormat() const
Get image format.
Definition RecordFormat.h:216
uint32_t getPlaneCount() const
Get the number of planes for this pixel format.
Definition RecordFormat.h:253
bool operator==(const ImageContentBlockSpec &rhs) const
Compare two image block spec strictly, field by field.
Definition RecordFormat.cpp:383
uint32_t getWidth() const
Get image width, or 0 if unknown/unspecified.
Definition RecordFormat.h:230
Description of the format of a VRS record as a succession of typed blocks of content.
Definition RecordFormat.h:644
size_t getRemainingBlocksSize(size_t firstBlock) const
Definition RecordFormat.cpp:1182
static string getRecordFormatTagName(Record::Type recordType, uint32_t formatVersion)
Names of the VRS stream tags used for RecordFormat descriptions.
Definition RecordFormat.cpp:1239
RecordFormat(const RecordFormat &)=default
Default copy constructor.
static bool parseRecordFormatTagName(const string &tagName, Record::Type &recordType, uint32_t &formatVersion)
Definition RecordFormat.cpp:1286
size_t getBlocksOfTypeCount(ContentType type) const
Definition RecordFormat.cpp:1204
RecordFormat & operator+(ContentBlock &&block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:695
static bool addRecordFormat(map< string, string > &inOutRecordFormatRegister, Record::Type recordType, uint32_t formatVersion, const RecordFormat &format, const vector< const DataLayout * > &layouts)
Definition RecordFormat.cpp:1308
RecordFormat(const char *format)
Definition RecordFormat.h:660
RecordFormat(const ContentBlock &&first, const ContentBlock &&second)
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:677
size_t getBlockSize(size_t blockIndex, size_t remainingSize) const
Definition RecordFormat.cpp:1222
RecordFormat(ContentBlock &&block)
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:668
RecordFormat(const ContentBlock &block)
Build a RecordFormat from a single ContentBlock.
Definition RecordFormat.h:664
RecordFormat & operator=(const RecordFormat &)=default
Default copy assignment.
RecordFormat(ContentType type, size_t size=ContentBlock::kSizeUnknown)
Definition RecordFormat.h:685
size_t getUsedBlocksCount() const
Definition RecordFormat.cpp:1194
RecordFormat()=default
Empty record format definition.
const ContentBlock & getFirstContentBlock() const
Definition RecordFormat.h:734
RecordFormat(const ContentBlock &first, const ContentBlock &second)
Build a RecordFormat from two ContentBlock definitions.
Definition RecordFormat.h:672
void set(const string &format)
Definition RecordFormat.cpp:1159
RecordFormat(const string &format)
Definition RecordFormat.h:654
size_t getRecordSize() const
Definition RecordFormat.cpp:1178
const ContentBlock & getContentBlock(size_t index) const
Definition RecordFormat.cpp:1214
string asString() const
Definition RecordFormat.cpp:1167
RecordFormat & operator+(const ContentBlock &block)
Append a ContentBlock to this RecordFormat.
Definition RecordFormat.h:690
Type
Definition Record.h:88
Definition AsyncDiskFileChunk.hpp:49
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:590
PixelFormat
Pixel format type, then the image format is ImageFormat::RAW.
Definition RecordFormat.h:60
@ 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:105
@ 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
Image format type.
Definition RecordFormat.h:47
@ UNDEFINED
Unknown/unspecified.
@ PNG
PNG data.
@ RAW
Raw pixel data.
@ JPG
JPEG data.
@ JXL
JPEG-XL data.
@ VIDEO
Video codec encoded frame.
AudioFormat
Audio format type.
Definition RecordFormat.h:94
@ 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.