PolyVox
0.3.0-dev
Open source voxel management library
|
Performs compression of data using Run Length Encoding (RLE). More...
#include <RLECompressor.h>
Public Member Functions | |
RLECompressor () | |
Constructor. | |
~RLECompressor () | |
Destructor. | |
uint32_t | getMaxCompressedSize (uint32_t uUncompressedInputSize) |
Computes a worst-case scenario for how big the output can be for a given input size. | |
uint32_t | compress (void *pSrcData, uint32_t uSrcLength, void *pDstData, uint32_t uDstLength) |
Compresses the data. | |
uint32_t | decompress (void *pSrcData, uint32_t uSrcLength, void *pDstData, uint32_t uDstLength) |
Decompresses the data. | |
Public Member Functions inherited from PolyVox::Compressor | |
Compressor () | |
Constructor. | |
virtual | ~Compressor () |
Destructor. | |
Performs compression of data using Run Length Encoding (RLE).
This compressor is designed for voxel data which contains long runs of the same value. Minecraft-style terrain and other cubic-style terrains are likely to fall under this category, whereas density fields for Marching Cubes terrain will not. Please see the following article if you want more details of how RLE compression works: http://en.wikipedia.org/wiki/Run-length_encoding
Definition at line 18 of file RLECompressor.h.
PolyVox::RLECompressor< ValueType, LengthType >::RLECompressor | ( | ) |
Constructor.
Definition at line 8 of file RLECompressor.inl.
PolyVox::RLECompressor< ValueType, LengthType >::~RLECompressor | ( | ) |
Destructor.
Definition at line 13 of file RLECompressor.inl.
|
virtual |
Compresses the data.
Performs compression of the data pointed to by pSrcData and stores the result in pDstData. The user is responsible for allocating both buffers and for making sure that the destination buffer is large enough to hold the result. If you don't know how big the compressed data will be (and you probably won't know this) then you can call getMaxCompressedSize() to get an upper bound. The actual compressed size is then returned by this function and you can use this to copy your compressed data to a more suitably size buffer.
pSrcData | A pointer to the data to be compressed. |
uSrcLength | The length of the data to be compressed. |
pDstData | A pointer to the memory where the result should be stored. |
uDstLength | The length of the destination buffer (compression will fail if this isn't big enough). |
Implements PolyVox::Compressor.
Definition at line 25 of file RLECompressor.inl.
|
virtual |
Decompresses the data.
Performs decompression of the data pointed to by pSrcData and stores the result in pDstData. The user is responsible for allocating both buffers and for making sure that the destination buffer is large enough to hold the result. This means you need to know how large the resulting data might be, so before you compress the data it may be worth storing this information somewhere. The actual decompressed size is then returned by this function
pSrcData | A pointer to the data to be decompressed. |
uSrcLength | The length of the data to be decompressed. |
pDstData | A pointer to the memory where the result should be stored. |
uDstLength | The length of the destination buffer (decompression will fail if this isn't big enough). |
Implements PolyVox::Compressor.
Definition at line 86 of file RLECompressor.inl.
|
virtual |
Computes a worst-case scenario for how big the output can be for a given input size.
If necessary you can use this as a destination buffer size, though it may be somewhat wasteful. It is not guarenteed that compression actually shrinks the data, so the worst-case value returned by this function may be bigger than the input size.
uUncompressedInputSize | The size of the uncompressed input data |
Implements PolyVox::Compressor.
Definition at line 18 of file RLECompressor.inl.