My Project
Functions
Compression

Functions

int wc_Compress (byte *out, word32 outSz, const byte *in, word32 inSz, word32 flags)
 This function compresses the given input data using Huffman coding and stores the output in out. Note that the output buffer should still be larger than the input buffer because there exists a certain input for which there will be no compression possible, which will still require a lookup table. It is recommended that one allocate srcSz + 0.1% + 12 for the output buffer. More...
 
int wc_DeCompress (byte *out, word32 outSz, const byte *in, word32 inSz)
 This function decompresses the given compressed data using Huffman coding and stores the output in out. More...
 

Detailed Description

Function Documentation

◆ wc_Compress()

int wc_Compress ( byte *  out,
word32  outSz,
const byte *  in,
word32  inSz,
word32  flags 
)

This function compresses the given input data using Huffman coding and stores the output in out. Note that the output buffer should still be larger than the input buffer because there exists a certain input for which there will be no compression possible, which will still require a lookup table. It is recommended that one allocate srcSz + 0.1% + 12 for the output buffer.

Returns
On successfully compressing the input data, returns the number of bytes stored in the output buffer
COMPRESS_INIT_E Returned if there is an error initializing the stream for compression
COMPRESS_E Returned if an error occurs during compression
Parameters
outpointer to the output buffer in which to store the compressed data
outSzsize available in the output buffer for storage
inpointer to the buffer containing the message to compress
inSzsize of the input message to compress
flagsflags to control how compression operates. Use 0 for normal decompression

Example

byte message[] = { // initialize text to compress };
byte compressed[(sizeof(message) + sizeof(message) * .001 + 12 )];
// Recommends at least srcSz + .1% + 12
if( wc_Compress(compressed, sizeof(compressed), message, sizeof(message),
0) != 0){
// error compressing data
}
See also
wc_DeCompress

◆ wc_DeCompress()

int wc_DeCompress ( byte *  out,
word32  outSz,
const byte *  in,
word32  inSz 
)

This function decompresses the given compressed data using Huffman coding and stores the output in out.

Returns
Success On successfully decompressing the input data, returns the number of bytes stored in the output buffer
COMPRESS_INIT_E: Returned if there is an error initializing the stream for compression
COMPRESS_E: Returned if an error occurs during compression
Parameters
outpointer to the output buffer in which to store the decompressed data
outSzsize available in the output buffer for storage
inpointer to the buffer containing the message to decompress
inSzsize of the input message to decompress

Example

byte compressed[] = { // initialize compressed message };
byte decompressed[MAX_MESSAGE_SIZE];
if( wc_DeCompress(decompressed, sizeof(decompressed),
compressed, sizeof(compressed)) != 0 ) {
// error decompressing data
}
See also
wc_Compress
wc_DeCompress
int wc_DeCompress(byte *out, word32 outSz, const byte *in, word32 inSz)
This function decompresses the given compressed data using Huffman coding and stores the output in ou...
wc_Compress
int wc_Compress(byte *out, word32 outSz, const byte *in, word32 inSz, word32 flags)
This function compresses the given input data using Huffman coding and stores the output in out....