Class CodecService
Provides codec agnostic helper functions for compression/decompression
Inheritance
System.Object
CodecService
Namespace: Unity.Tiny.Codec
Syntax
public static class CodecService
Methods
Compress(Codec, Byte*, Int32, out Byte*, Allocator)
Compresses the passed in src
data into newly allocated dst
buffer. Users must free dst
manually after calling Compress
Declaration
public static int Compress(Codec codec, in byte *src, int srcSize, out byte *dst, Allocator allocator = null)
Parameters
Type | Name | Description |
---|---|---|
Codec | codec | |
System.Byte* | src | |
System.Int32 | srcSize | |
System.Byte* | dst | |
Allocator | allocator |
Returns
Type | Description |
---|---|
System.Int32 |
CompressUpperBound(Codec, Int32)
Return the maximum size that a codec may output in a "worst case" scenario when compressing data
Declaration
public static int CompressUpperBound(Codec codec, int size)
Parameters
Type | Name | Description |
---|---|---|
Codec | codec | |
System.Int32 | size |
Returns
Type | Description |
---|---|
System.Int32 |
Decompress(Codec, Byte*, Int32, Byte*, Int32)
Decompresses data in src
buffer and returns true with the decompressed data stored in the passed in, previously allocated decompressedData
buffer.
Users thus should know ahead of time how large a decompressedData
buffer to use before calling this function. Not
passing a large enough buffer will result in this function failing and returning false.
Declaration
public static bool Decompress(Codec codec, in byte *compressedData, int compressedSize, byte *decompressedData, int decompressedSize)
Parameters
Type | Name | Description |
---|---|---|
Codec | codec | |
System.Byte* | compressedData | |
System.Int32 | compressedSize | |
System.Byte* | decompressedData | |
System.Int32 | decompressedSize |
Returns
Type | Description |
---|---|
System.Boolean |