RangeCompression

Description

static class Tinman.Terrain.Codec.RangeCompression

A range coder for compression.

Encoding a buffer entirely filled with 0 will always take up 8 bytes. A buffer entirely filled with other values will always take up 16 bytes.

The maximum input buffer size for compression is 256 megabytes for a single call to CompressSize resp. Compress. To compress more data, split it into chunks and call the compression method sequentially for each chunk.

Public / Methods

Compress


public static method Compress → (2)

input in : ByteBuffer

[not-null]
The input buffer.

output in : ByteBuffer

[not-null]
The output buffer.

returns → int32

The number of bytes that have been written to output in. In case a buffer overflow has occurred, the number of required output buffer bytes n is returned as: -1-n.

Compresses the given input bytes and writes the compressed output bytes to the given buffer.

Compress​Chunk


public static method CompressChunk → (3)

input in : ByteBuffer

[not-null]
The input buffer.

output in : ByteBuffer

[not-null]
The output buffer.

result in : int32

The return value of the preceding call to CompressChunk or 0 if this is the first call.

returns → int32

The number of bytes that have been written to output in. In case a buffer overflow has occurred, the number of required output buffer bytes n is returned as: -1-n.

Helper method for compressing multiple data chunks in a row, while keeping track of output buffer overflow situations.

Compress​Size


public static method CompressSize → (1)

input in : ByteBuffer

[not-null]
The input bytes.

returns → int32

The number of compressed output bytes.

Compresses the given bytes and returns the length of the compressed data.

Decompress


public static method Decompress → (2)

input in : ByteBuffer

[not-null]
The input buffer.

output in : ByteBuffer

[not-null]
The output buffer.

returns → int32

The number of bytes that have been written to output in. In case a buffer overflow has occurred, the number of required output buffer bytes n is returned as: -1-n.

Decompresses the given bytes.

IOException

If the binary input in is malformed.

Decompress​Size


public static method DecompressSize → (1)

input in : ByteBuffer

[not-null]
The compressed data buffer.

returns → int32

Size of decompressed data.

Returns the size of the decompressed data.