UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FCompression Struct Reference

#include <Compression.h>

Static Public Member Functions

static CORE_API uint32 GetCompressorVersion (FName FormatName)
 
static CORE_API bool CompressMemoryBound (FName InFormatName, int64 &OutBufferSizeRequired, int64 InUncompressedSizeBytes, uintptr_t InCompressionData=0)
 
static CORE_API int32 CompressMemoryBound (FName FormatName, int32 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static CORE_API bool GetMaximumCompressedSize (FName InFormatName, int64 &OutMaxCompressedSize, int64 InUncompressedSizeBytes, uintptr_t InCompressionData=0)
 
static CORE_API int32 GetMaximumCompressedSize (FName FormatName, int32 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static CORE_API bool CompressMemory (FName FormatName, void *CompressedBuffer, int64 &CompressedSize, const void *UncompressedBuffer, int64 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, uintptr_t CompressionData=0)
 
static CORE_API bool CompressMemory (FName FormatName, void *CompressedBuffer, int32 &CompressedSize, const void *UncompressedBuffer, int32 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static CORE_API bool CompressMemoryIfWorthDecompressing (FName FormatName, bool &bOutWasCompressed, int64 MinBytesSaved, int32 MinPercentSaved, void *CompressedBuffer, int64 &CompressedSize, const void *UncompressedBuffer, int64 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, uintptr_t CompressionData=0)
 
static CORE_API bool CompressMemoryIfWorthDecompressing (FName FormatName, int32 MinBytesSaved, int32 MinPercentSaved, void *CompressedBuffer, int32 &CompressedSize, const void *UncompressedBuffer, int32 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static CORE_API bool UncompressMemory (FName FormatName, void *UncompressedBuffer, int64 UncompressedSize, const void *CompressedBuffer, int64 CompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, uintptr_t CompressionData=0)
 
static CORE_API bool UncompressMemoryStream (FName FormatName, void *UncompressedBuffer, int64 UncompressedSize, IMemoryReadStream *Stream, int64 StreamOffset, int64 CompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, uintptr_t CompressionData=0)
 
static CORE_API FString GetCompressorDDCSuffix (FName FormatName)
 
static CORE_API bool IsFormatValid (FName FormatName)
 
static CORE_API bool VerifyCompressionFlagsValid (int32 InCompressionFlags)
 
static CORE_API FName GetCompressionFormatFromDeprecatedFlags (ECompressionFlags DeprecatedFlags)
 

Static Public Attributes

static CORE_API TAtomic< uint64CompressorTimeCycles
 
static CORE_API TAtomic< uint64CompressorSrcBytes
 
static CORE_API TAtomic< uint64CompressorDstBytes
 

Member Function Documentation

◆ CompressMemory() [1/2]

bool FCompression::CompressMemory ( FName  FormatName,
void CompressedBuffer,
int32 CompressedSize,
const void UncompressedBuffer,
int32  UncompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
int32  CompressionData = 0 
)
static

◆ CompressMemory() [2/2]

bool FCompression::CompressMemory ( FName  FormatName,
void CompressedBuffer,
int64 CompressedSize,
const void UncompressedBuffer,
int64  UncompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
uintptr_t  CompressionData = 0 
)
static

Thread-safe abstract compression routine. Compresses memory from uncompressed buffer and writes it to compressed buffer. Updates CompressedSize with size of compressed data. Compression controlled by the passed in flags. CompressMemory is expected to return true and write valid data even if it expanded bytes. Always check CompressedSize >= UncompressedSize and fall back to uncompressed, or use CompressMemoryIfWorthDecompressing

Parameters
FormatNameName of the compression format
CompressedBufferBuffer compressed data is going to be written to
CompressedSize[in/out] Size of CompressedBuffer, at exit will be size of compressed data
UncompressedBufferBuffer containing uncompressed data
UncompressedSizeSize of uncompressed data in bytes
FlagsFlags to control what method to use and optionally control memory vs speed
CompressionDataAdditional compression parameter - see comments a top of FCompression struct.
Returns
true if compression succeeds, false if it fails because CompressedBuffer was too small or other reasons

◆ CompressMemoryBound() [1/2]

int32 FCompression::CompressMemoryBound ( FName  FormatName,
int32  UncompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
int32  CompressionData = 0 
)
static

◆ CompressMemoryBound() [2/2]

bool FCompression::CompressMemoryBound ( FName  InFormatName,
int64 OutBufferSizeRequired,
int64  InUncompressedSizeBytes,
uintptr_t  InCompressionData = 0 
)
static

Thread-safe abstract compression routine to query buffer requirements for a compression operation. This is the minimize size to allocate the buffer for CompressMemory (encoding). Use GetMaximumCompressedSize at decode to know how large a compressed buffer may be.

Despite the name, this has nothing to do with how much memory will be allocated during compression.

Parameters
FormatNameName of the compression format
UncompressedSizeSize of uncompressed data in bytes
CompressionDataAdditional compression parameter - see comments a top of FCompression struct.
OutBufferSizeRequiredThe maximum possible bytes needed for compression of a data buffer of the given size.
Returns
false if the bounds couldn't be determined - e.g. the format is unknown or the size isn't supported by the format.

◆ CompressMemoryIfWorthDecompressing() [1/2]

bool FCompression::CompressMemoryIfWorthDecompressing ( FName  FormatName,
bool bOutWasCompressed,
int64  MinBytesSaved,
int32  MinPercentSaved,
void CompressedBuffer,
int64 CompressedSize,
const void UncompressedBuffer,
int64  UncompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
uintptr_t  CompressionData = 0 
)
static

Same as CompressMemory but evaluates if the compression gain is worth the runtime decode time.

Parameters
FormatNameName of the compression format
bOutWasCompressed[out] Whether the compression was worth it. The data is still compressed.
MinBytesSavedMinimum amount of bytes which should be saved when performing compression, otherwise false is returned
MinPercentSavedMinimum percentage of the buffer which should be saved when performing compression, otherwise false is returned
CompressedBufferBuffer compressed data is going to be written to
CompressedSize[in/out] Size of CompressedBuffer, at exit will be size of compressed data
UncompressedBufferBuffer containing uncompressed data
UncompressedSizeSize of uncompressed data in bytes
FlagsFlags to control what method to use and optionally control memory vs speed
CompressionDataAdditional compression parameter - see comments a top of FCompression struct.
Returns
true if compression succeeds, false if it fails because CompressedBuffer was too small or other reasons

◆ CompressMemoryIfWorthDecompressing() [2/2]

bool FCompression::CompressMemoryIfWorthDecompressing ( FName  FormatName,
int32  MinBytesSaved,
int32  MinPercentSaved,
void CompressedBuffer,
int32 CompressedSize,
const void UncompressedBuffer,
int32  UncompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
int32  CompressionData = 0 
)
static

◆ GetCompressionFormatFromDeprecatedFlags()

FName FCompression::GetCompressionFormatFromDeprecatedFlags ( ECompressionFlags  DeprecatedFlags)
static

◆ GetCompressorDDCSuffix()

FString FCompression::GetCompressorDDCSuffix ( FName  FormatName)
static

Returns a string which can be used to identify if a format has become out of date

Parameters
FormatNamename of the format to retrieve the DDC suffix for
Returns
unique DDC key string which will be different when the format is changed / updated

◆ GetCompressorVersion()

uint32 FCompression::GetCompressorVersion ( FName  FormatName)
static

Returns a version number for a specified format

Parameters
FormatNameCompressor format name (eg NAME_Zlib)
Returns
An interpretation of an internal version number for a specific format (different formats will have different layouts) this should change if a version is updated

◆ GetMaximumCompressedSize() [1/2]

int32 FCompression::GetMaximumCompressedSize ( FName  FormatName,
int32  UncompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
int32  CompressionData = 0 
)
static

◆ GetMaximumCompressedSize() [2/2]

bool FCompression::GetMaximumCompressedSize ( FName  InFormatName,
int64 OutMaxCompressedSize,
int64  InUncompressedSizeBytes,
uintptr_t  InCompressionData = 0 
)
static

Thread-safe abstract compression routine to query maximum compressed size that could be made. This is used for making buffers that could hold any compressed buffer that started uncompressed with the given size. It's distinct from the buffer needed to compress! If you are calling CompressMemory then you need to pass a buffer sized based on CompressMemoryBound!

CompressMemoryBound is strictly greater equal GetMaximumCompressedSize.

Parameters
FormatNameName of the compression format
OutMaxCompressedSizeThe maximum possible size of valid compressed data made by this format
InUncompressedSizeBytesSize of uncompressed data in bytes
CompressionDataAdditional compression parameter - see comments a top of FCompression struct.
Returns
success

◆ IsFormatValid()

bool FCompression::IsFormatValid ( FName  FormatName)
static

Checks to see if a format will be usable, so that a fallback can be used

Parameters
FormatNameThe name of the format to test

◆ UncompressMemory()

bool FCompression::UncompressMemory ( FName  FormatName,
void UncompressedBuffer,
int64  UncompressedSize,
const void CompressedBuffer,
int64  CompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
uintptr_t  CompressionData = 0 
)
static

Thread-safe abstract decompression routine. Uncompresses memory from compressed buffer and writes it to uncompressed buffer. UncompressedSize is expected to be the exact size of the data after decompression.

Parameters
FormatNameName of the compression format
UncompressedBufferBuffer containing uncompressed data
UncompressedSizeSize of uncompressed data in bytes
CompressedBufferBuffer compressed data is going to be read from
CompressedSizeSize of CompressedBuffer data in bytes
FlagsFlags to control what method to use to decompress
CompressionDataAdditional decompression parameter (specifies BitWindow value for ZLIB compression format)
Returns
true if compression succeeds, false if it fails because CompressedBuffer was too small or other reasons

◆ UncompressMemoryStream()

bool FCompression::UncompressMemoryStream ( FName  FormatName,
void UncompressedBuffer,
int64  UncompressedSize,
IMemoryReadStream Stream,
int64  StreamOffset,
int64  CompressedSize,
ECompressionFlags  Flags = COMPRESS_NoFlags,
uintptr_t  CompressionData = 0 
)
static

Wraps UncompressMemory to provide access with a IMemoryReadStream interface, attempting to avoid copying in to a contiguous buffer doe decompression if the format supports it. If not, a CompressedSize temp buffer will be allocated.

◆ VerifyCompressionFlagsValid()

bool FCompression::VerifyCompressionFlagsValid ( int32  InCompressionFlags)
static

Verifies if the passed in value represents valid compression flags

Parameters
InCompressionFlagsValue to test

Member Data Documentation

◆ CompressorDstBytes

TAtomic< uint64 > FCompression::CompressorDstBytes
static

Number of bytes after compression.

Nubmer of bytes after compression.

◆ CompressorSrcBytes

TAtomic< uint64 > FCompression::CompressorSrcBytes
static

Number of bytes before compression.

◆ CompressorTimeCycles

TAtomic< uint64 > FCompression::CompressorTimeCycles
static

CompressionData is per-compressor data passed through this API and is interpreted by the codecs. For builtins: NAME_Zlib BitWindow NAME_LZ4 Unused NAME_Gzip Unused NAME_Oodle Unused Time spent compressing data in cycles.

Time spent compressing data in cycles.


The documentation for this struct was generated from the following files: