ImFusion SDK 4.3
ImFusion::Compression::zstd Namespace Reference

Compression using Zstandard, a high speed compression algorithm still providing good compression ratios. More...

Detailed Description

Compression using Zstandard, a high speed compression algorithm still providing good compression ratios.

See also
https://facebook.github.io/zstd/

Classes

class  Context
 When (de)compressing many times it is recommended to allocate the context only once and reuse it for each successive operations. More...
 

Enumerations

enum class  CompressionLevel {
  Fastest = 1 , Fast = 5 , Average = 10 , High = 15 ,
  Highest = 20
}
 Selection of available Zstandard compression levels. More...
 

Functions

ByteBuffer compress (const ByteBufferView &data, CompressionLevel compressionLevel=CompressionLevel::Average)
 Convenience function to quickly compress the given data with Zstandard as a one-time action.
 
ByteBuffer decompress (const ByteBufferView &data)
 Convenience function to quickly decompress the given data with Zstandard as a one-time action.
 
size_t getMaxCompressedSize (size_t inputSize)
 Returns the maximum possible (worst-case) size of a compressed buffer, given an input of size inputSize.
 
size_t getDecompressedSize (const ByteBufferView &compressedData)
 Returns the size of the data encoded in a compressed buffer.
 
size_t findActualCompressedSize (const ByteBufferView &compressedData)
 Returns the exact size of a compressed buffer.
 

Enumeration Type Documentation

◆ CompressionLevel

enum class CompressionLevel
strong

Selection of available Zstandard compression levels.

Technically, you can pass any number supported by Zstandard (see http://facebook.github.io/zstd/zstd_manual.html), however exact behavior of compression level is somewhat under-documented so we remain on the conservative side here.

Function Documentation

◆ compress()

ByteBuffer compress ( const ByteBufferView & data,
CompressionLevel compressionLevel = CompressionLevel::Average )

Convenience function to quickly compress the given data with Zstandard as a one-time action.

Use a Context if you have multiple successive operations on different pieces of data.

◆ decompress()

ByteBuffer decompress ( const ByteBufferView & data)

Convenience function to quickly decompress the given data with Zstandard as a one-time action.

Use a Context if you have multiple successive operations on different pieces of data.

◆ getDecompressedSize()

size_t getDecompressedSize ( const ByteBufferView & compressedData)

Returns the size of the data encoded in a compressed buffer.

Returns 0 if compressedData is not a valid compressed buffer.

◆ findActualCompressedSize()

size_t findActualCompressedSize ( const ByteBufferView & compressedData)

Returns the exact size of a compressed buffer.

Returns 0 if compressedData does not contain valid compressed data. The return value (if valid) can be used to pass the correct buffer size to decompress() This is useful if you do not know the exact size of a compressed buffer, for example if multiple buffers are concatenated into one.

Parameters
compressedDataa buffer that starts with (but may be longer than) compressed data
Search Tab / S to search, Esc to close