ImFusion SDK 4.3
Context Class Reference

#include <ImFusion/Core/Compression.h>

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

Detailed Description

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

This will save execution time and memory.

std::vector<ByteBuffer> inputBuffer = ...
std::vector<ByteBuffer> compressedData;
zstd::Context zstdContext;
for (const auto& bb : inputBuffer)
compressedData.push_back(zstdContext.compress(bb), zstd::CompressionLevel::High);
Specialization of the ByteBufferView class that has ownership of the underlying data.
Definition ByteBuffer.h:169
When (de)compressing many times it is recommended to allocate the context only once and reuse it for ...
Definition Compression.h:70
ByteBuffer compress(const ByteBufferView &inputBuffer, CompressionLevel compressionLevel=CompressionLevel::Average) const
Compress the given input data using the zstd algorithm.

Public Member Functions

ByteBuffer compress (const ByteBufferView &inputBuffer, CompressionLevel compressionLevel=CompressionLevel::Average) const
 Compress the given input data using the zstd algorithm.
 
size_t compressTo (const ByteBufferView &inputBuffer, ByteBufferMutableView outputBuffer, CompressionLevel compressionLevel=CompressionLevel::Average) const
 Compress the given input data to the given buffer using the zstd algorithm.
 
ByteBuffer decompress (const ByteBufferView &inputBuffer) const
 Decompress the given input data using the zstd algorithm.
 
bool decompressTo (const ByteBufferView &inputBuffer, ByteBufferMutableView outputBuffer) const
 Decompress the given data using zstd into an already allocated buffer.
 

Member Function Documentation

◆ compress()

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

Compress the given input data using the zstd algorithm.

Returns an empty buffer on failure.

Parameters
inputBufferInput data to compress
compressionLevelCompression level to choose

◆ compressTo()

size_t compressTo ( const ByteBufferView & inputBuffer,
ByteBufferMutableView outputBuffer,
CompressionLevel compressionLevel = CompressionLevel::Average ) const

Compress the given input data to the given buffer using the zstd algorithm.

This variant will fail if the output buffer is not of sufficient size. Returns The size of the compressed data, or 0 if the output buffer was not of sufficient size.

Parameters
inputBufferInput data to compress
outputBufferOutput buffer to compress into
compressionLevelCompression level to choose

◆ decompress()

ByteBuffer decompress ( const ByteBufferView & inputBuffer) const

Decompress the given input data using the zstd algorithm.

Returns an empty buffer on failure.

Parameters
inputBufferInput data to decompress, must have been created using zstd compression

◆ decompressTo()

bool decompressTo ( const ByteBufferView & inputBuffer,
ByteBufferMutableView outputBuffer ) const

Decompress the given data using zstd into an already allocated buffer.

Parameters
inputBufferInput data to decompress, must have been created using zstd compression
outputBufferOutput buffer to decompress into, must be of sufficient size and already allocated

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close