![]() |
VRS
A file format for sensor data.
|
Specification of an image content block. More...
#include <RecordFormat.h>
Public Member Functions | |
ImageContentBlockSpec (const ImageContentBlockSpec &)=default | |
ImageContentBlockSpec (const ImageContentBlockSpec &imageSpec, double keyFrameTimestamp, uint32_t keyFrameIndex) | |
ImageContentBlockSpec (ImageFormat imageFormat, PixelFormat pixelFormat, uint32_t width=0, uint32_t height=0, uint32_t stride=0, uint32_t stride2=0, string codecName={}, uint8_t codecQuality=kQualityUndefined, double keyFrameTimestamp=kInvalidTimestamp, uint32_t keyFrameIndex=0) | |
Specify-everything constructor. | |
ImageContentBlockSpec (ImageFormat imageFormat, uint32_t width=0, uint32_t height=0) | |
Image formats with encoding (png, jpeg, etc). | |
ImageContentBlockSpec (PixelFormat pixelFormat, uint32_t width, uint32_t height, uint32_t stride=0, uint32_t stride2=0) | |
Raw pixels image formats. | |
ImageContentBlockSpec (ImageFormat imageFormat, string codecName, uint8_t codecQuality=kQualityUndefined, PixelFormat pixelFormat=PixelFormat::UNDEFINED, uint32_t width=0, uint32_t height=0, uint32_t stride=0, uint32_t stride2=0) | |
Custom codec or video image with codec name. | |
ImageContentBlockSpec (string codecName, uint8_t codecQuality, PixelFormat pixelFormat, uint32_t width, uint32_t height, uint32_t stride=0, uint32_t stride2=0) | |
Video image with codec. | |
ImageContentBlockSpec (const string &formatStr) | |
Constructor used for factory construction. | |
void | set (ContentParser &parser) |
When constructing from a string. | |
void | clear () |
Clear/reset object to default values. | |
ImageContentBlockSpec | core () const |
Return base of format (no codec quality nor key frame info) | |
string | asString () const |
size_t | getBlockSize () const |
size_t | getRawImageSize () const |
ImageContentBlockSpec & | operator= (const ImageContentBlockSpec &)=default |
Default copy assignment. | |
bool | operator== (const ImageContentBlockSpec &rhs) const |
Compare two image block spec strictly, field by field. | |
bool | operator!= (const ImageContentBlockSpec &rhs) const |
ImageFormat | getImageFormat () const |
Get image format. | |
string | getImageFormatAsString () const |
Get Image format as string. | |
PixelFormat | getPixelFormat () const |
Get Pixel format. | |
string | getPixelFormatAsString () const |
Get pixel format presented as a readable string, from which it can be reconstructed. | |
uint32_t | getWidth () const |
Get image width, or 0 if unknown/unspecified. | |
uint32_t | getHeight () const |
Get image height, or 0 if unknown/unspecified. | |
uint32_t | getStride () const |
Get image stride (number of bytes between rows) for the first plane. | |
uint32_t | getRawStride () const |
uint32_t | getRawStride2 () const |
uint32_t | getDefaultStride () const |
Get default stride for plane 0 when stride isn't specified (minimum stride value) | |
uint32_t | getDefaultStride2 () const |
Get default stride for planes N > 0, when stride2 isn't specified (minimum stride2 value) | |
uint32_t | getPlaneCount () const |
Get the number of planes for this pixel format. | |
uint32_t | getPlaneStride (uint32_t planeIndex) const |
uint32_t | getPlaneHeight (uint32_t planeIndex) const |
uint8_t | getChannelCountPerPixel () const |
size_t | getBytesPerPixel () const |
const string & | getCodecName () const |
uint8_t | getCodecQuality () const |
double | getKeyFrameTimestamp () const |
Get timestamp of the key frame of the group of frames this video frame belongs to. | |
uint32_t | getKeyFrameIndex () const |
bool | sanityCheckStrides () const |
Static Public Member Functions | |
static bool | isQualityValid (uint8_t quality) |
Validate that a quality value is valid. | |
static uint8_t | getChannelCountPerPixel (PixelFormat pixel) |
Get the number channels of a pixel. See getChannelCountPerPixel() | |
static size_t | getBytesPerPixel (PixelFormat pixel) |
Get the size of a pixel, in bytes. See getBytesPerPixel() | |
static string | getPixelFormatAsString (PixelFormat pixelFormat) |
Get pixel format presented as a readable string, from which it can be reconstructed. | |
static uint32_t | getPlaneCount (PixelFormat pixelFormat) |
Get the number of planes for this pixel format. | |
Static Public Attributes | |
static constexpr uint8_t | kQualityUndefined = 255 |
static constexpr double | kInvalidTimestamp = -1E-308 |
Specification of an image content block.
vrs::ImageContentBlockSpec::ImageContentBlockSpec | ( | PixelFormat | pixelFormat, |
uint32_t | width, | ||
uint32_t | height, | ||
uint32_t | stride = 0 , |
||
uint32_t | stride2 = 0 |
||
) |
Raw pixels image formats.
stride | number of bytes between lines, if not width * sizeof(pixelFormat) |
stride2 | stride for planes after the first plane |
string vrs::ImageContentBlockSpec::asString | ( | ) | const |
Convert to string, to store on disk & reconstruct later using factory constructor.
size_t vrs::ImageContentBlockSpec::getBlockSize | ( | ) | const |
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown. For RAW images, that's the combined size of all the planes, though there is usually only 1.
|
inline |
Get the size of a pixel format, in bytes. Compliant pixel formats use a fixed number of bytes per pixel, and pixels follow each other without overlap. Some bits might be unused, such as when using two bytes to store 10 bits. Pixel formats that don't work that way will return ContentBlock::kSizeUnknown
|
inline |
Get the number of channels of this format. Every pixel format has a channel count, but it does not tell how the pixel data is arranged in the image buffer (might not be contiguous). In other words, this should not be used to make assumptions on memory layout in any way. A value of 1 means the image is grayscale, or some form of 1 dimensional value, such as depth.
|
inline |
Get name of the video codec used to encode the image, if any. Only used for ImageFormat::VIDEO
|
inline |
Get codec quality setting used to encode the image, if any. 0 means codec-default, 100 means lossless Only used for ImageFormat::VIDEO
|
inline |
Get index of the frame in the group of frames this video frame belongs to. Key frames and only key frames (i-frames) have have an index of 0. The first p-frame after an i-frame has a key frame index of 1, and so on.
uint32_t vrs::ImageContentBlockSpec::getPlaneHeight | ( | uint32_t | planeIndex | ) | const |
Get the number of lines in a specific plane. Returns 0 if plane index is invalid.
uint32_t vrs::ImageContentBlockSpec::getPlaneStride | ( | uint32_t | planeIndex | ) | const |
Get the number of bytes of each line for a specific plane. Returns 0 if plane index is invalid.
size_t vrs::ImageContentBlockSpec::getRawImageSize | ( | ) | const |
Get the number of bytes for this content block, or ContentBlock::kSizeUnknown. Use pixel format, dimensions and stride, and compute the size as if the image format is RAW.
|
inline |
Get the raw stride parameter. Return 0 if no stride value was explicitly provided.
bool vrs::ImageContentBlockSpec::sanityCheckStrides | ( | ) | const |
Verify that stride and stride2 values are reasonable.