#include <CompressorZLib.h>
Inherits AZ::IO::Compressor.
|
|
| AZ_CLASS_ALLOCATOR (CompressorZLib, AZ::SystemAllocator) |
| |
| | CompressorZLib (unsigned int decompressionCachePerStream=64 *1024, unsigned int dataBufferSize=128 *1024) |
| |
| AZ::u32 | GetTypeId () const override |
| | Return compressor type id.
|
| |
| bool | ReadHeaderAndData (CompressorStream *stream, AZ::u8 *data, unsigned int dataSize) override |
| | Called when we open a stream to Read for the first time. Data contains the first. dataSize <= m_maxHeaderSize.
|
| |
| bool | WriteHeaderAndData (CompressorStream *stream) override |
| | Called when we are about to start writing to a compressed stream.
|
| |
| SizeType | Read (CompressorStream *stream, SizeType byteSize, SizeType offset, void *buffer) override |
| | Forwarded function from the Device when we from a compressed stream.
|
| |
| SizeType | Write (CompressorStream *stream, SizeType byteSize, const void *data, SizeType offset=SizeType(-1)) override |
| | Forwarded function from the Device when we write to a compressed stream.
|
| |
| bool | WriteSeekPoint (CompressorStream *stream) override |
| | Write a seek point.
|
| |
| bool | StartCompressor (CompressorStream *stream, int compressionLevel, SizeType autoSeekDataSize) override |
| | Set auto seek point even dataSize bytes.
|
| |
| bool | Close (CompressorStream *stream) override |
| | Called just before we close the stream. All compression data will be flushed and finalized. (You can't add data afterwards).
|
| |
|
virtual | ~Compressor () |
| | When we open a stream to check if it's compressed we read the first m_maxHeaderSize bytes.
|
| |
|
|
SizeType | FillFromDecompressCache (CompressorZLibData *zlibData, void *&buffer, SizeType &byteSize, SizeType &offset) |
| | Read as much data as possible and adjust the parameters.
|
| |
|
SizeType | FillCompressedBuffer (CompressorStream *stream) |
| | Read data from stream into the compression buffer.
|
| |
|
void | AcquireDataBuffer () |
| | Acquire data buffer resource (if not created it will be allocated) and increment m_dataBufferUseCount.
|
| |
|
void | ReleaseDataBuffer () |
| | Release data buffer resource, if m_dataBufferUseCount == 0 all memory will be freed.
|
| |
|
|
CompressorStream * | m_lastReadStream |
| | Cached last stream we read data into the m_dataBuffer.
|
| |
|
SizeType | m_lastReadStreamOffset |
| | Offset of the last read (in the m_dataBuffer) in the compressed stream.
|
| |
|
SizeType | m_lastReadStreamSize |
| | Size of the data in m_dataBuffer of the last read.
|
| |
|
unsigned char * | m_compressedDataBuffer |
| | Data buffer used to read/write compressed data.
|
| |
|
unsigned int | m_compressedDataBufferSize |
| | Data buffer size (stored so we can lazy allocate m_dataBuffer as we need).
|
| |
|
unsigned int | m_compressedDataBufferUseCount |
| | Data buffer use count.
|
| |
|
unsigned int | m_decompressionCachePerStream |
| | Cache per stream for each compressed stream stream in bytes.
|
| |
ZLib compressor implementation. Note: As of now the CompressorZLib is the only supported compressor. We can move much of the caching functionality into the base Compressor class to be shared. Please do so when you have an actual need to implement another compressor, don't just copy and paste.
◆ CompressorZLib()
| AZ::IO::CompressorZLib::CompressorZLib |
( |
unsigned int |
decompressionCachePerStream = 64 *1024, |
|
|
unsigned int |
dataBufferSize = 128 *1024 |
|
) |
| |
- Parameters
-
| decompressionCachePerStream | cache of decompressed data stored per stream, the more streams you have open the more memory it will use, You can use 0 size too to save memory, but every read will happen with decompression from the closest seek point. That might be fine if we use stream read cache and it matches the size of the seek points (you will need to make sure of that), otherwise the extra cache can be useful. We can convert this system to use pools of caches, but as of now this should be fine. |
| dataBufferSize | we have one compressor per device, only one stream can read/write at a time and the data buffer is shared for IO operations, the buffer is refCounted and existing only when we read/write compressed streams. |
◆ Close()
Called just before we close the stream. All compression data will be flushed and finalized. (You can't add data afterwards).
Implements AZ::IO::Compressor.
◆ GetTypeId()
| AZ::u32 AZ::IO::CompressorZLib::GetTypeId |
( |
| ) |
const |
|
inlineoverridevirtual |
◆ Read()
| SizeType AZ::IO::CompressorZLib::Read |
( |
CompressorStream * |
stream, |
|
|
SizeType |
byteSize, |
|
|
SizeType |
offset, |
|
|
void * |
buffer |
|
) |
| |
|
overridevirtual |
Forwarded function from the Device when we from a compressed stream.
Implements AZ::IO::Compressor.
◆ ReadHeaderAndData()
Called when we open a stream to Read for the first time. Data contains the first. dataSize <= m_maxHeaderSize.
Implements AZ::IO::Compressor.
◆ StartCompressor()
| bool AZ::IO::CompressorZLib::StartCompressor |
( |
CompressorStream * |
stream, |
|
|
int |
compressionLevel, |
|
|
SizeType |
autoSeekDataSize |
|
) |
| |
|
overridevirtual |
◆ Write()
| SizeType AZ::IO::CompressorZLib::Write |
( |
CompressorStream * |
stream, |
|
|
SizeType |
byteSize, |
|
|
const void * |
data, |
|
|
SizeType |
offset = SizeType(-1) |
|
) |
| |
|
overridevirtual |
Forwarded function from the Device when we write to a compressed stream.
Implements AZ::IO::Compressor.
◆ WriteHeaderAndData()
Called when we are about to start writing to a compressed stream.
Reimplemented from AZ::IO::Compressor.
◆ WriteSeekPoint()
The documentation for this class was generated from the following file:
- Code/Framework/AzCore/AzCore/IO/CompressorZLib.h