PolyVox  0.3.0-dev
Open source voxel management library
Classes | Public Member Functions | List of all members
PolyVox::RLECompressor< ValueType, LengthType > Class Template Reference

Performs compression of data using Run Length Encoding (RLE). More...

#include <RLECompressor.h>

+ Inheritance diagram for PolyVox::RLECompressor< ValueType, LengthType >:
+ Collaboration diagram for PolyVox::RLECompressor< ValueType, LengthType >:

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.
 

Detailed Description

template<typename ValueType, typename LengthType>
class PolyVox::RLECompressor< ValueType, LengthType >

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

See Also
MinizCompressor

Definition at line 18 of file RLECompressor.h.

Constructor & Destructor Documentation

template<typename ValueType , typename LengthType >
PolyVox::RLECompressor< ValueType, LengthType >::RLECompressor ( )

Constructor.

Definition at line 8 of file RLECompressor.inl.

template<typename ValueType , typename LengthType >
PolyVox::RLECompressor< ValueType, LengthType >::~RLECompressor ( )

Destructor.

Definition at line 13 of file RLECompressor.inl.

Member Function Documentation

template<typename ValueType , typename LengthType >
uint32_t PolyVox::RLECompressor< ValueType, LengthType >::compress ( void *  pSrcData,
uint32_t  uSrcLength,
void *  pDstData,
uint32_t  uDstLength 
)
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.

Parameters
pSrcDataA pointer to the data to be compressed.
uSrcLengthThe length of the data to be compressed.
pDstDataA pointer to the memory where the result should be stored.
uDstLengthThe length of the destination buffer (compression will fail if this isn't big enough).
Returns
The size of the resulting compressed data.

Implements PolyVox::Compressor.

Definition at line 25 of file RLECompressor.inl.

template<typename ValueType , typename LengthType >
uint32_t PolyVox::RLECompressor< ValueType, LengthType >::decompress ( void *  pSrcData,
uint32_t  uSrcLength,
void *  pDstData,
uint32_t  uDstLength 
)
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

Parameters
pSrcDataA pointer to the data to be decompressed.
uSrcLengthThe length of the data to be decompressed.
pDstDataA pointer to the memory where the result should be stored.
uDstLengthThe length of the destination buffer (decompression will fail if this isn't big enough).
Returns
The size of the resulting uncompressed data.

Implements PolyVox::Compressor.

Definition at line 86 of file RLECompressor.inl.

template<typename ValueType , typename LengthType >
uint32_t PolyVox::RLECompressor< ValueType, LengthType >::getMaxCompressedSize ( uint32_t  uUncompressedInputSize)
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.

Parameters
uUncompressedInputSizeThe size of the uncompressed input data
Returns
The largest possible size of the compressed output data.

Implements PolyVox::Compressor.

Definition at line 18 of file RLECompressor.inl.


The documentation for this class was generated from the following files: