PolyVox  0.3.0-dev
Open source voxel management library
Public Member Functions | List of all members
PolyVox::Compressor Class Referenceabstract

Provides an interface for performing compression of data. More...

#include <Compressor.h>

+ Inheritance diagram for PolyVox::Compressor:

Public Member Functions

 Compressor ()
 Constructor.
 
virtual ~Compressor ()
 Destructor.
 
virtual uint32_t getMaxCompressedSize (uint32_t uUncompressedInputSize)=0
 Computes a worst-case scenario for how big the output can be for a given input size.
 
virtual uint32_t compress (void *pSrcData, uint32_t uSrcLength, void *pDstData, uint32_t uDstLength)=0
 Compresses the data.
 
virtual uint32_t decompress (void *pSrcData, uint32_t uSrcLength, void *pDstData, uint32_t uDstLength)=0
 Decompresses the data.
 

Detailed Description

Provides an interface for performing compression of data.

This class provides an interface which can be implemented by derived classes which perform data compression. The main purpose of this is to allow the user to change the compression algorithm which is used by a LargeVolume, based on the kind of voxel data it is storing. Users may also wish to use Compressor subclasses in more general compression-related scenarios but this is not well tested.

If you wish to implement your own compression algorithms for use in PolyVox then you should begin by subclassing this class.

See Also
MinizCompressor, RLECompressor

Definition at line 43 of file Compressor.h.

Constructor & Destructor Documentation

PolyVox::Compressor::Compressor ( )
inline

Constructor.

Definition at line 47 of file Compressor.h.

virtual PolyVox::Compressor::~Compressor ( )
inlinevirtual

Destructor.

Definition at line 49 of file Compressor.h.

Member Function Documentation

virtual uint32_t PolyVox::Compressor::compress ( void *  pSrcData,
uint32_t  uSrcLength,
void *  pDstData,
uint32_t  uDstLength 
)
pure 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.

Implemented in PolyVox::RLECompressor< ValueType, LengthType >, and PolyVox::MinizCompressor.

Referenced by PolyVox::Block< VoxelType >::compress().

virtual uint32_t PolyVox::Compressor::decompress ( void *  pSrcData,
uint32_t  uSrcLength,
void *  pDstData,
uint32_t  uDstLength 
)
pure 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.

Implemented in PolyVox::RLECompressor< ValueType, LengthType >, and PolyVox::MinizCompressor.

Referenced by PolyVox::Block< VoxelType >::uncompress().

virtual uint32_t PolyVox::Compressor::getMaxCompressedSize ( uint32_t  uUncompressedInputSize)
pure 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.

Implemented in PolyVox::RLECompressor< ValueType, LengthType >, and PolyVox::MinizCompressor.

Referenced by PolyVox::Block< VoxelType >::compress().


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