![]() |
VRS
A file format for sensor data.
|
Decompressor helper class, to decompresses data at a target location. More...
#include <Decompressor.h>
Classes | |
class | Lz4Decompressor |
Decompressor for lz4 data. More... | |
class | ZstdDecompressor |
Decompressor for zstd data. More... | |
Public Member Functions | |
void | setCompressionType (CompressionType compressionType) |
CompressionType | getCompressionType () const |
size_t | getRecommendedInputBufferSize () const |
int | decompress (void *destination, uint32_t destinationSize, uint32_t &outReadSize) |
void * | allocateCompressedDataBuffer (size_t requestSize) |
size_t | getRemainingCompressedDataBufferSize () const |
int | initFrame (FileHandler &file, size_t &outFrameSize, size_t &inOutMaxReadSize) |
int | readFrame (FileHandler &file, void *dst, size_t frameSize, size_t &inOutMaxReadSize) |
void | reset () |
Forget any remaining compressed data, get ready for a new frame. | |
Decompressor helper class, to decompresses data at a target location.
The data to decompress must be in the internal buffer. Use getBuffer(size) to allocate memory for the internal buffer reserving at least size bytes and get a pointer where to write the data, probably reading from disk directly in that internal buffer. Call decompress to decompress a full record to the DataReference location. The whole record will be decompressed & written at the target location without intermediate memory copy.
void * vrs::Decompressor::allocateCompressedDataBuffer | ( | size_t | requestSize | ) |
Get a buffer of a specific size where to write the data to be decoded. The decompressor will assume that the buffer will be filed to the requested size.
requestSize | Size to allocate. |
int vrs::Decompressor::decompress | ( | void * | destination, |
uint32_t | destinationSize, | ||
uint32_t & | outReadSize | ||
) |
Decompress a maximum of destinationSize bytes of data, at the pointed to destination, and return the number of bytes read in outReadSize.
|
inline |
Tell how many bytes we haven't yet decoded from our compressed data buffer.
int vrs::Decompressor::initFrame | ( | FileHandler & | file, |
size_t & | outFrameSize, | ||
size_t & | inOutMaxReadSize | ||
) |
Frame compression APIs, to read compressed frames from a file. 1/ call reset() (if the compressor was used before). 2/ call initFrame to know how large the uncompressed frame is. 3/ allocate enough memory for the whole frame. 4/ read the whole frame in the buffer 5/ if reading more than one successive frames, do not call reset, go straight back to 2/
Start to read a frame, by sniffing the upcoming frame's size.
file | A file open for reading, at the position of the frame. |
frameSize | On success, set to the size in bytes of the upcoming frame. |
maxReadSize | Max number of bytes of compressed frames data. If there are multiple frames, or the size of the compressed frame(s) is unknown, this number maybe the remaining file size. This number is updated as needed, if data is read from the file and placed in an internal decode buffer. |
int vrs::Decompressor::readFrame | ( | FileHandler & | file, |
void * | dst, | ||
size_t | frameSize, | ||
size_t & | inOutMaxReadSize | ||
) |
Read a compressed frame, all at once.
file | A file open for reading, at the position of the frame. |
dst | A pointer to an allocated buffer large enough for the whole frame. |
frameSize | The size of the frame, as returned by initFrame. The buffer must be large enough to read the whole frame at once. |
maxReadSize | Max number of bytes of compressed frames data left. |