Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FCompression Struct Reference

#include <Compression.h>

+ Collaboration diagram for FCompression:

Static Public Member Functions

static uint32 GetCompressorVersion (FName FormatName)
 
static int32 CompressMemoryBound (FName FormatName, int32 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static int32 GetMaximumCompressedSize (FName FormatName, int32 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static bool CompressMemory (FName FormatName, void *CompressedBuffer, int32 &CompressedSize, const void *UncompressedBuffer, int32 UncompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static 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 bool UncompressMemory (FName FormatName, void *UncompressedBuffer, int32 UncompressedSize, const void *CompressedBuffer, int32 CompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static bool UncompressMemoryStream (FName FormatName, void *UncompressedBuffer, int32 UncompressedSize, IMemoryReadStream *Stream, int64 StreamOffset, int32 CompressedSize, ECompressionFlags Flags=COMPRESS_NoFlags, int32 CompressionData=0)
 
static FString GetCompressorDDCSuffix (FName FormatName)
 
static bool IsFormatValid (FName FormatName)
 
static bool VerifyCompressionFlagsValid (int32 InCompressionFlags)
 
static FName GetCompressionFormatFromDeprecatedFlags (ECompressionFlags DeprecatedFlags)
 

Static Public Attributes

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

Static Private Member Functions

static struct ICompressionFormatGetCompressionFormat (FName Method, bool bErrorOnFailure=true)
 

Static Private Attributes

static TMap< FName, struct ICompressionFormat * > CompressionFormats
 
static FCriticalSection CompressionFormatsCriticalSection
 

Detailed Description

Definition at line 28 of file Compression.h.

Member Function Documentation

◆ CompressMemory()

static bool FCompression::CompressMemory ( FName FormatName,
void * CompressedBuffer,
int32 & CompressedSize,
const void * UncompressedBuffer,
int32 UncompressedSize,
ECompressionFlags Flags = COMPRESS_NoFlags,
int32 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 (specifies BitWindow value for ZLIB compression format)
Returns
true if compression succeeds, false if it fails because CompressedBuffer was too small or other reasons

◆ CompressMemoryBound()

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

Thread-safe abstract compression routine to query memory 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.

Parameters
FormatNameName of the compression format
UncompressedSizeSize of uncompressed data in bytes
FlagsFlags to control what method to use and optionally control memory vs speed
CompressionDataAdditional compression parameter (specifies BitWindow value for ZLIB compression format)
Returns
The maximum possible bytes needed for compression of data buffer of size UncompressedSize

◆ CompressMemoryIfWorthDecompressing()

static 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

Same as CompressMemory but evaluates if the compression gain is worth the runtime decode time returns false if the size saving is not worth it (also if CompressedSize >= UncompressedSize) if false is returned, send the data uncompressed instead

Parameters
FormatNameName of the compression format
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 (specifies BitWindow value for ZLIB compression format)
Returns
true if compression succeeds, false if it fails because CompressedBuffer was too small or other reasons

◆ GetCompressionFormat()

static struct ICompressionFormat * FCompression::GetCompressionFormat ( FName Method,
bool bErrorOnFailure = true )
staticprivate

Find a compression format module by name, returning nullptr if no module found

◆ GetCompressionFormatFromDeprecatedFlags()

static FName FCompression::GetCompressionFormatFromDeprecatedFlags ( ECompressionFlags DeprecatedFlags)
static

◆ GetCompressorDDCSuffix()

static 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()

static 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()

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

Thread-safe abstract compression routine to query maximum compressed size that could be made. CompressMemoryBound is strictly greater equal GetMaximumCompressedSize.

Parameters
FormatNameName of the compression format
UncompressedSizeSize of uncompressed data in bytes
FlagsFlags to control what method to use and optionally control memory vs speed
CompressionDataAdditional compression parameter (specifies BitWindow value for ZLIB compression format)
Returns
The maximum possible size of valid compressed data made by this format

◆ IsFormatValid()

static 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()

static bool FCompression::UncompressMemory ( FName FormatName,
void * UncompressedBuffer,
int32 UncompressedSize,
const void * CompressedBuffer,
int32 CompressedSize,
ECompressionFlags Flags = COMPRESS_NoFlags,
int32 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()

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

◆ VerifyCompressionFlagsValid()

static bool FCompression::VerifyCompressionFlagsValid ( int32 InCompressionFlags)
static

Verifies if the passed in value represents valid compression flags

Parameters
InCompressionFlagsValue to test

Member Data Documentation

◆ CompressionFormats

TMap<FName, struct ICompressionFormat*> FCompression::CompressionFormats
staticprivate

Mapping of Compression FNames to their compressor objects

Definition at line 153 of file Compression.h.

◆ CompressionFormatsCriticalSection

FCriticalSection FCompression::CompressionFormatsCriticalSection
staticprivate

Definition at line 154 of file Compression.h.

◆ CompressorDstBytes

TAtomic<uint64> FCompression::CompressorDstBytes
static

Number of bytes after compression.

Definition at line 35 of file Compression.h.

◆ CompressorSrcBytes

TAtomic<uint64> FCompression::CompressorSrcBytes
static

Number of bytes before compression.

Definition at line 33 of file Compression.h.

◆ CompressorTimeCycles

TAtomic<uint64> FCompression::CompressorTimeCycles
static

Time spent compressing data in cycles.

Definition at line 31 of file Compression.h.


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