142 static constexpr uint8_t kQualityUndefined = 255;
143 static constexpr double kInvalidTimestamp = -1E-308;
151 double keyFrameTimestamp,
152 uint32_t keyFrameIndex);
161 uint32_t stride2 = 0,
162 string codecName = {},
163 uint8_t codecQuality = kQualityUndefined,
164 double keyFrameTimestamp = kInvalidTimestamp,
165 uint32_t keyFrameIndex = 0);
183 uint8_t codecQuality = kQualityUndefined,
188 uint32_t stride2 = 0);
193 uint8_t codecQuality,
198 uint32_t stride2 = 0);
210 uint32_t stride2 = 0,
211 string codecName = {},
212 uint8_t codecQuality = kQualityUndefined,
213 double keyFrameTimestamp = kInvalidTimestamp,
214 uint32_t keyFrameIndex = 0);
273 uint32_t getRawStride2()
const {
318 return isQualityValid(codecQuality_) ? codecQuality_ : kQualityUndefined;
323 return quality <= 100;
328 return keyFrameTimestamp_;
334 return keyFrameIndex_;
344 return toString(pixelFormat);
360 uint32_t stride2_{0};
363 double keyFrameTimestamp_{kInvalidTimestamp};
364 uint32_t keyFrameIndex_{0};
365 uint8_t codecQuality_{kQualityUndefined};
380 uint8_t channelCount = 0,
381 uint8_t sampleFrameStride = 0,
382 uint32_t sampleFrameRate = 0,
383 uint32_t sampleFrameCount = 0,
384 uint8_t stereoPairCount = 0);
402 return !operator==(rhs);
422 return sampleFormat_;
446 return channelCount_;
450 return sampleFrameRate_;
454 return sampleFrameCount_;
458 sampleFrameCount_ = sampleCount;
461 uint8_t getStereoPairCount()
const {
462 return stereoPairCount_;
479 return toString(sampleFormat);
485 uint8_t sampleFrameStride_{};
486 uint8_t channelCount_{};
487 uint32_t sampleFrameRate_{};
488 uint32_t sampleFrameCount_{};
489 uint8_t stereoPairCount_{};
520 std::string codecName,
521 uint8_t codecQuality,
526 uint32_t stride2 = 0);
534 uint32_t stride2 = 0);
540 double keyFrameTimestamp,
541 uint32_t keyFrameIndex);
551 uint8_t numChannels = 0,
552 uint8_t sampleFrameStride = 0,
553 uint32_t sampleRate = 0,
554 uint32_t sampleCount = 0,
555 uint8_t stereoPairCount = 0);
563 : contentType_{other.contentType_}, size_{size} {
565 imageSpec_ = other.imageSpec_;
567 audioSpec_ = other.audioSpec_;
569 customContentBlockFormat_ = other.customContentBlockFormat_;
573 ~ContentBlock() =
default;
575 ContentBlock& operator=(
const ContentBlock& rhs) =
default;
576 ContentBlock& operator=(ContentBlock&& rhs)
noexcept =
default;
592 return customContentBlockFormat_;
598 return !operator==(rhs);
602 RecordFormat
operator+(
const ContentBlock&)
const;
605 const ImageContentBlockSpec&
image()
const;
607 const AudioContentBlockSpec&
audio()
const;
612 ImageContentBlockSpec imageSpec_;
613 AudioContentBlockSpec audioSpec_;
614 string customContentBlockFormat_;
639 uint32_t formatVersion,
642 recordType(recordType),
643 formatVersion(formatVersion),
644 blockIndex(blockIndex) {}
654 uint32_t getFormatVersion()
const {
655 return formatVersion;
658 size_t getBlockIndex()
const {
665 uint32_t formatVersion;
704 blocks_.emplace_back(block);
708 blocks_.emplace_back(std::move(block));
712 blocks_.emplace_back(first);
713 blocks_.emplace_back(second);
717 blocks_.emplace_back(std::move(first));
718 blocks_.emplace_back(std::move(second));
725 blocks_.emplace_back(type, size);
730 blocks_.emplace_back(block);
735 blocks_.emplace_back(std::move(block));
741 return !operator==(rhs);
750 void set(
const string& format);
785 size_t getBlockSize(
size_t blockIndex,
size_t remainingSize)
const;
791 static string getDataLayoutTagName(
Record::Type type, uint32_t version,
size_t blockIndex);
795 const string& tagName,
797 uint32_t& formatVersion);
802 map<string, string>& inOutRecordFormatRegister,
804 uint32_t formatVersion,
806 const vector<const DataLayout*>& layouts);
808 static void getRecordFormats(
809 const map<string, string>& recordFormatRegister,
812 static unique_ptr<DataLayout> getDataLayout(
813 const map<string, string>& recordFormatRegister,
817 vector<ContentBlock> blocks_;
Specification of an audio content block.
Definition RecordFormat.h:369
uint8_t getChannelCount() const
Get the number of audio channels in each sample frame (not in the content block).
Definition RecordFormat.h:445
void setSampleCount(uint32_t sampleCount)
Set the number of audio sample frames in the content block.
Definition RecordFormat.h:457
string asString() const
Definition RecordFormat.cpp:771
uint8_t getBitsPerSample() const
Get the number of bits per audio sample.
Definition RecordFormat.h:435
AudioContentBlockSpec(const AudioContentBlockSpec &)=default
Default copy constructor.
bool isLittleEndian() const
Tell if the audio sample format is little endian.
Definition RecordFormat.h:427
bool isSampleBlockFormatDefined() const
Definition RecordFormat.cpp:824
size_t getPcmBlockSize() const
Assuming PCM, get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:800
uint32_t getSampleCount() const
Get the number of audio sample frames in the content block.
Definition RecordFormat.h:453
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:711
uint8_t getBytesPerSample() const
Get the number of bytes per audio sample.
Definition RecordFormat.h:439
uint8_t getSampleFrameStride() const
Number of bytes used by a group of synchronous audio samples, including padding.
Definition RecordFormat.cpp:918
uint32_t getSampleRate() const
Get the audio frame sample rate.
Definition RecordFormat.h:449
bool isIEEEFloat() const
Tell if the audio sample format is an IEEE float.
Definition RecordFormat.h:431
AudioFormat getAudioFormat() const
Get audio format.
Definition RecordFormat.h:417
AudioSampleFormat getSampleFormat() const
Get audio sample format.
Definition RecordFormat.h:421
size_t getBlockSize() const
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown.
Definition RecordFormat.cpp:796
string getSampleFormatAsString() const
Get audio sample format as a string.
Definition RecordFormat.cpp:820
bool isCompatibleWith(const AudioContentBlockSpec &rhs) const
Tell if two audio block have identical audio formats.
Definition RecordFormat.cpp:814
static string getSampleFormatAsString(AudioSampleFormat sampleFormat)
Get an audio sample format as a string.
Definition RecordFormat.h:478
Specification of a VRS record content block.
Definition RecordFormat.h:504
size_t getBlockSize() const
Get the content block size, if available or calculable.
Definition RecordFormat.cpp:1063
ContentBlock(const ContentBlock &)=default
Default copy constructor.
string asString() const
Conversion to string, to store on disk & reconstruct later using constructor.
Definition RecordFormat.cpp:1032
const ImageContentBlockSpec & image() const
Get the image content spec. Requires the content block to be of type ContentType::IMAGE.
Definition RecordFormat.cpp:1105
ContentBlock(ContentType type=ContentType::EMPTY, size_t size=kSizeUnknown)
Very generic block description.
Definition RecordFormat.cpp:984
ContentType getContentType() const
Get the ContentType of the block.
Definition RecordFormat.h:585
string getCustomContentBlockFormat() const
Definition RecordFormat.h:591
const AudioContentBlockSpec & audio() const
Get the audio content spec. Requires the content block to be of type ContentType::AUDIO.
Definition RecordFormat.cpp:1110
RecordFormat operator+(const ContentBlock &) const
Assembly operator, to construct a RecordFormat for ContentBlock parts.
Definition RecordFormat.cpp:1101
ContentBlock(std::string codecName, uint8_t codecQuality, PixelFormat pixelFormat=PixelFormat::UNDEFINED, uint32_t width=0, uint32_t height=0, uint32_t stride=0, uint32_t stride2=0)
Image formats with custom codec encoding.
static const size_t kSizeUnknown
Special value used to represent an unknown block size.
Definition RecordFormat.h:507
Helper to identify a particular content block within a file.
Definition RecordFormat.h:634
RecordFormat string parsing helper class.
Definition RecordFormat.cpp:37
Definition RecordFormat.h:617
Specification of an image content block.
Definition RecordFormat.h:140
ImageContentBlockSpec & operator=(const ImageContentBlockSpec &)=default
Default copy assignment.
void set(ContentParser &parser)
When constructing from a string.
Definition RecordFormat.cpp:377
void clear()
Clear/reset object to default values.
Definition RecordFormat.cpp:334
uint32_t getDefaultStride2() const
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value)
Definition RecordFormat.cpp:579
uint8_t getCodecQuality() const
Definition RecordFormat.h:317
string getPixelFormatAsString() const
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.cpp:634
uint32_t getKeyFrameIndex() const
Definition RecordFormat.h:333
string asString() const
Definition RecordFormat.cpp:422
size_t getBytesPerPixel() const
Definition RecordFormat.h:305
uint32_t getHeight() const
Get image height, or 0 if unknown/unspecified.
Definition RecordFormat.h:263
string getImageFormatAsString() const
Get Image format as string.
Definition RecordFormat.cpp:638
uint32_t getPlaneHeight(uint32_t planeIndex) const
Definition RecordFormat.cpp:596
uint32_t getStride() const
Get image stride (number of bytes between rows) for the first plane.
Definition RecordFormat.cpp:642
PixelFormat getPixelFormat() const
Get Pixel format.
Definition RecordFormat.h:253
static string getPixelFormatAsString(PixelFormat pixelFormat)
Get pixel format presented as a readable string, from which it can be reconstructed.
Definition RecordFormat.h:343
const string & getCodecName() const
Definition RecordFormat.h:311
uint32_t getPlaneStride(uint32_t planeIndex) const
Definition RecordFormat.cpp:569
bool sanityCheckStrides() const
Definition RecordFormat.cpp:556
size_t getRawImageSize() const
Definition RecordFormat.cpp:620
uint32_t getRawStride() const
Definition RecordFormat.h:270
size_t getBlockSize() const
Definition RecordFormat.cpp:616
ImageContentBlockSpec core() const
Return base of format (no codec quality nor key frame info)
Definition RecordFormat.cpp:345
double getKeyFrameTimestamp() const
Get timestamp of the key frame of the group of frames this video frame belongs to.
Definition RecordFormat.h:327
uint32_t getDefaultStride() const
Get default stride for plane 0 when stride isn't specified (minimum stride value)
Definition RecordFormat.cpp:647
static bool isQualityValid(uint8_t quality)
Validate that a quality value is valid.
Definition RecordFormat.h:322
uint8_t getChannelCountPerPixel() const
Definition RecordFormat.h:298
ImageFormat getImageFormat() const
Get image format.
Definition RecordFormat.h:245
uint32_t getPlaneCount() const
Get the number of planes for this pixel format.
Definition RecordFormat.h:282
uint32_t getWidth() const
Get image width, or 0 if unknown/unspecified.
Definition RecordFormat.h:259
Type
Definition Record.h:88
Definition Compressor.cpp:113
map< pair< Record::Type, uint32_t >, RecordFormat > RecordFormatMap
Map a pair of record type/format version to a record format, for a particular stream.
Definition RecordFormat.h:624
PixelFormat
Pixel format type, then the image format is ImageFormat::RAW.
Definition RecordFormat.h:63
@ GREY12
uses 16 bit little-endian values. 4 most significant bits are unused and set to 0.
@ UNDEFINED
Unknown/unrecognized.
@ GREY10
uses 16 bit little-endian values. 6 most significant bits are unused and set to 0.
@ RGB8
3 uint8_t values, red + green + blue.
@ DEPTH32F
1 32 bit float value, representing a depth.
@ YUV_420_NV21
Y plane + half width/half height chroma plane with weaved V and U values.
@ RAW10
https://developer.android.com/reference/android/graphics/ImageFormat#RAW10
@ RAW10_BAYER_RGGB
10 bit per pixel, RGGB bayer pattern.
@ YUV_I420_PLANAR
same as YUV_I420_SPLIT, but more conventional name.
@ YUV_I420_SPLIT
3 uint8_t values, 4:2:0. The 3 planes are stored separately.
@ RGBA32F
1 32 bit float value.
@ BAYER8_RGGB
8 bit per pixel, RGGB bayer pattern.
@ RAW10_BAYER_BGGR
10 bit per pixel, BGGR bayer pattern.
@ RGB10
uses 16 bit little-endian values. 6 most significant bits are unused and set to 0.
@ RGBA8
4 uint8_t values, red + blue + green + alpha.
@ YUY2
4 uint8_t values, 4:2:2, single plane.
@ YUV_420_NV12
Y plane + half width/half height chroma plane with weaved U and V values.
@ RGB12
uses 16 bit little-endian values. 4 most significant bits are unused and set to 0.
@ RGB32F
1 32 bit float value.
@ SCALAR64F
1 64 bit float value, representing high precision image data.
@ BGR8
3 uint8_t values, blue + green + red.
@ GREY16
uses 16 bit little-endian values.
AudioSampleFormat
Audio sample format, when the audio type is AudioFormat::PCM.
Definition RecordFormat.h:108
@ U32_LE
LPCM, unsigned, 32 bit little endian.
@ F64_BE
LPCM, 64 bit float big endian.
@ U16_BE
LPCM, unsigned, 16 bit big endian.
@ U32_BE
LPCM, unsigned, 32 bit big endian.
@ F64_LE
LPCM, 64 bit float little endian.
@ S32_BE
LPCM, signed, 32 bit big endian.
@ U8
LPCM, unsigned, 8 bit.
@ S16_BE
LPCM, signed, 16 bit big endian.
@ F32_LE
LPCM, 32 bit float little endian.
@ S24_LE
LPCM, signed, 24 bit little endian.
@ S16_LE
LPCM, signed, 16 bit little endian.
@ U24_BE
LPCM, unsigned, 24 bit big endian.
@ S24_BE
LPCM, signed, 24 bit big endian.
@ 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.
@ 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.
@ VIDEO
Video codec encoded images.
AudioFormat
Audio format type.
Definition RecordFormat.h:97
@ 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
@ DATA_LAYOUT
DataLayout block.
@ CUSTOM
Custom format, or unknown/unspecified data format.
@ EMPTY
No data (internal).