liblzg  1.0.8
 All Data Structures Files Functions Variables Typedefs Macros
Data Structures | Macros | Typedefs | Functions
lzg.h File Reference

Go to the source code of this file.

Data Structures

struct  lzg_encoder_config_t
 LZG compression configuration parameters. More...
 

Macros

#define LZG_VERSION   "1.0.8"
 LZG library version string.
 
#define LZG_VERNUM   0x01000008
 LZG library version number (strictly incremental)
 
#define LZG_VER_MAJOR   1
 LZG library major version.
 
#define LZG_VER_MINOR   0
 LZG library minor version.
 
#define LZG_VER_REVISION   8
 LZG library revision.
 
#define LZG_FALSE   0
 Boolean FALSE (see lzg_bool_t)
 
#define LZG_TRUE   1
 Boolean TRUE (see lzg_bool_t)
 
#define LZG_LEVEL_1   1
 Lowest/fastest compression level.
 
#define LZG_LEVEL_2   2
 Compression level 2.
 
#define LZG_LEVEL_3   3
 Compression level 3.
 
#define LZG_LEVEL_4   4
 Compression level 4.
 
#define LZG_LEVEL_5   5
 Medium compression level.
 
#define LZG_LEVEL_6   6
 Compression level 6.
 
#define LZG_LEVEL_7   7
 Compression level 7.
 
#define LZG_LEVEL_8   8
 Compression level 8.
 
#define LZG_LEVEL_9   9
 Best/slowest compression level.
 
#define LZG_LEVEL_DEFAULT   LZG_LEVEL_5
 Default compression level.
 

Typedefs

typedef int lzg_bool_t
 Boolean (LZG_TRUE/LZG_FALSE)
 
typedef int lzg_int32_t
 Signed 32-bit integer.
 
typedef unsigned int lzg_uint32_t
 Unsigned 32-bit integer.
 
typedef void(* LZGPROGRESSFUN )(lzg_int32_t progress, void *userdata)
 

Functions

lzg_uint32_t LZG_MaxEncodedSize (lzg_uint32_t insize)
 
void LZG_InitEncoderConfig (lzg_encoder_config_t *config)
 
lzg_uint32_t LZG_Encode (const unsigned char *in, lzg_uint32_t insize, unsigned char *out, lzg_uint32_t outsize, lzg_encoder_config_t *config)
 
lzg_uint32_t LZG_DecodedSize (const unsigned char *in, lzg_uint32_t insize)
 
lzg_uint32_t LZG_Decode (const unsigned char *in, lzg_uint32_t insize, unsigned char *out, lzg_uint32_t outsize)
 
lzg_uint32_t LZG_Version (void)
 
const char * LZG_VersionString (void)
 

Typedef Documentation

typedef void(* LZGPROGRESSFUN)(lzg_int32_t progress, void *userdata)

Progress callback function.

Parameters
[in]progressThe current progress (0-100).
[in]userdataUser supplied data pointer.

Function Documentation

lzg_uint32_t LZG_Decode ( const unsigned char *  in,
lzg_uint32_t  insize,
unsigned char *  out,
lzg_uint32_t  outsize 
)

Decode LZG coded data.

Parameters
[in]inInput (compressed) buffer.
[in]insizeSize of the input buffer (number of bytes).
[out]outOutput (uncompressed) buffer.
[in]outsizeSize of the output buffer (number of bytes).
Returns
The size of the decoded data, or zero if the function failed (e.g. if the end of the output buffer was reached before the entire input buffer was decoded).
lzg_uint32_t LZG_DecodedSize ( const unsigned char *  in,
lzg_uint32_t  insize 
)

Determine the size of the decoded data for a given LZG coded buffer.

Parameters
[in]inInput (compressed) buffer.
[in]insizeSize of the input buffer (number of bytes). This does not have to be the size of the entire compressed data, but it has to be at least 7 bytes (the first few bytes of the header, including the decompression size).
Returns
The size of the decoded data, or zero if the function failed (e.g. if the magic header ID could not be found).
lzg_uint32_t LZG_Encode ( const unsigned char *  in,
lzg_uint32_t  insize,
unsigned char *  out,
lzg_uint32_t  outsize,
lzg_encoder_config_t config 
)

Encode uncompressed data using the LZG coder (i.e. compress the data).

Parameters
[in]inInput (uncompressed) buffer.
[in]insizeSize of the input buffer (number of bytes).
[out]outOutput (compressed) buffer.
[in]outsizeSize of the output buffer (number of bytes).
[in]configCompression configuration (if set to NULL, default encoder configuration parameters are used).
Returns
The size of the encoded data, or zero if the function failed (e.g. if the end of the output buffer was reached before the entire input buffer was encoded).
Note
For the slow method (config->fast = 0), the memory requirement during compression is 136 KB (LZG_LEVEL_1) to 2 MB (LZG_LEVEL_9). For the fast method (config->fast = 1), the memory requirement is 64 MB (LZG_LEVEL_1) to 66 MB (LZG_LEVEL_9). Also note that these figures are doubled on 64-bit systems.
void LZG_InitEncoderConfig ( lzg_encoder_config_t config)

Initialize an encoder configuration object.

Parameters
[out]configConfiguration object.
lzg_uint32_t LZG_MaxEncodedSize ( lzg_uint32_t  insize)

Determine the maximum size of the encoded data for a given uncompressed buffer.

Parameters
[in]insizeSize of the uncompressed buffer (number of bytes).
Returns
Worst case (maximum) size of the encoded data.
lzg_uint32_t LZG_Version ( void  )

Get the version of the LZG library.

Returns
The version of the LZG library, on the same format as LZG_VERNUM.
const char* LZG_VersionString ( void  )

Get the version string of the LZG library.

Returns
The version of the LZG library, on the same format as LZG_VERSION.