LZ4_resetStreamHC_fast

These functions compress data in successive blocks of any size, using previous blocks as dictionary, to improve compression ratio.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Compression/lz4hc.h

Include

#include "Compression/lz4hc.h"

Source

/Engine/Source/Runtime/Core/Private/Compression/lz4hc.cpp

Syntax

LZ4void LZ4_resetStreamHC_fast
(
    LZ4_streamHC_t * streamHCPtr,
    int compressionLevel
)

Remarks

These functions compress data in successive blocks of any size, using previous blocks as dictionary, to improve compression ratio. One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks. There is an exception for ring buffers, which can be smaller than 64 KB. Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue().

Before starting compression, state must be allocated and properly initialized. LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT.

Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream) or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental). LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once, which is automatically the case when state is created using LZ4_createStreamHC().

After reset, a first "fictional block" can be designated as initial dictionary, using LZ4_loadDictHC() (Optional).

Invoke LZ4_compress_HC_continue() to compress each successive block. The number of blocks is unlimited. Previous input blocks, including initial dictionary when present, must remain accessible and unmodified during compression.

It's allowed to update compression level anytime between blocks, using LZ4_setCompressionLevel() (experimental).

'dst' buffer should be sized to handle worst case scenarios (see LZ4_compressBound(), it ensures compression success). In case of failure, the API does not guarantee recovery, so the state must be reset. To ensure compression success whenever `dst_ buffer size cannot be made >= LZ4_compressBound(), consider using LZ4_compress_HC_continue_destSize().

Whenever previous input blocks can't be preserved unmodified in-place during compression of next blocks, it's possible to copy the last blocks into a more stable memory space, using LZ4_saveDictHC(). Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer' (<= 64 KB)

After completing a streaming compression, it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state, just by resetting it, using LZ4_resetStreamHC_fast().

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss