#include <Compression.h>
Public Types | |
enum | FlushType { FT_NO_FLUSH = 0 , FT_PARTIAL_FLUSH , FT_SYNC_FLUSH , FT_FULL_FLUSH , FT_FINISH , FT_BLOCK , FT_TREES } |
typedef AZ::u16 | Header |
Typedef for the 2 byte zlib header. | |
Public Member Functions | |
ZLib (IAllocator *workMemAllocator=0) | |
void | StartCompressor (unsigned int compressionLevel=9) |
bool | IsCompressorStarted () const |
void | StopCompressor () |
void | ResetCompressor () |
void | StartDecompressor (Header *hdr=NULL) |
Must be called before we can decompress. Hdr is optional hdr structure that is stored at the begin of the stream and should be passed to the ResetDecompresor. | |
bool | IsDecompressorStarted () const |
void | StopDecompressor () |
void | ResetDecompressor (Header *header=NULL) |
If you will use seek/sync points we require that you pass the header since the reset will reset all states and you can't really continue (unless from the start). | |
unsigned int | GetMinCompressedBufferSize (unsigned int sourceDataSize) |
Return compressed buffer minimal size for the given source size. compressedDataSize in compress must be at least that size, otherwise compression will fail. | |
unsigned int | Compress (const void *data, unsigned int &dataSize, void *compressedData, unsigned int compressedDataSize, FlushType flushType=FT_NO_FLUSH) |
unsigned int | Decompress (const void *compressedData, unsigned int compressedDataSize, void *data, unsigned int &dataSize, FlushType flushType=FT_NO_FLUSH) |
The most well known and used compression algorithm. It gives the best compression ratios even on level 1, the speed and memory usage can be an issue. If you want detailed control over the compressed stream, include "AzCore/compression/zlib/zlib.h" and do it yourself!
unsigned int AZ::ZLib::Compress | ( | const void * | data, |
unsigned int & | dataSize, | ||
void * | compressedData, | ||
unsigned int | compressedDataSize, | ||
FlushType | flushType = FT_NO_FLUSH |
||
) |
Compressed data from the data buffer into compressedData buffer. If compressedData is NOT big enough the left over size will be returned in "dataSize". If dataSize is 0 all data has been compressed.
void AZ::ZLib::StartCompressor | ( | unsigned int | compressionLevel = 9 | ) |
Must be called before we can compress. Compression level can vary from [0 - no compression to 9 - best compression]. Default is 9. Compression level results from a test input stream of ~26MB comprised of a mix of string and binary data: Level Compressed Size Time(ms) 1 ~1.9MB 55ms 2 ~1.8MB 53ms 3 ~1.7MB 45ms 4 ~1.7MB 230ms 5 ~1.6MB 225ms 6 ~1.5MB 325ms 7 ~1.5MB 387ms 8 ~1.4MB 827ms 9 ~1.4MB 858ms