Turnstone Operating System
Loading...
Searching...
No Matches
zpack.64.c File Reference

LZ77 compression algorithm implementation with simple encoding. More...

#include <zpack.h>
#include <utils.h>

Classes

struct  zpack_match_t
 match structure More...
 
struct  zpack_hashtable_t
 hashtable structure More...
 

Macros

#define ZPACK_MAX_MATCH   (0x3f + 0x40 + 4)
 
#define ZPACK_MIN_MATCH   (4)
 
#define ZPACK_WINDOW_SIZE   16383
 
#define ZPACK_HASHTABLE_SIZE   15
 
#define ZPACK_HASHTABLE_MUL   2654435761U
 
#define ZPACK_HASHTABLE_PREV_SIZE   16384
 
#define ZPACK_NO_POS   (-1)
 

Typedefs

typedef struct zpack_match_t zpack_match_t
 match structure
 
typedef struct zpack_hashtable_t zpack_hashtable_t
 hashtable structure
 

Functions

 MODULE ("turnstone.lib")
 
static uint32_t zpack_hash4 (uint32_t data)
 hash function More...
 
static void zpack_hash_insert (int64_t pos, uint32_t h, zpack_hashtable_t *ht)
 insert position to hashtable More...
 
static zpack_match_t zpack_find_bestmatch (buffer_t *in, int64_t in_len, int64_t in_p, zpack_hashtable_t *ht)
 find best match More...
 
int8_t zpack_pack (buffer_t *in, buffer_t *out)
 packs data at input buffer to output buffer with z77 algorithm More...
 
int8_t zpack_unpack (buffer_t *in, buffer_t *out)
 unpacks data at input buffer to output buffer with z77 algorithm More...
 

Detailed Description

LZ77 compression algorithm implementation with simple encoding.

This work is licensed under TURNSTONE OS Public License. Please read and understand latest version of Licence.

Macro Definition Documentation

◆ ZPACK_HASHTABLE_MUL

#define ZPACK_HASHTABLE_MUL   2654435761U

hash4 multiplier

◆ ZPACK_HASHTABLE_PREV_SIZE

#define ZPACK_HASHTABLE_PREV_SIZE   16384

hashtable previous size, backward item count

◆ ZPACK_HASHTABLE_SIZE

#define ZPACK_HASHTABLE_SIZE   15

hashtable size 2^15

◆ ZPACK_MAX_MATCH

#define ZPACK_MAX_MATCH   (0x3f + 0x40 + 4)

maximum match length

◆ ZPACK_MIN_MATCH

#define ZPACK_MIN_MATCH   (4)

minimum match length

◆ ZPACK_NO_POS

#define ZPACK_NO_POS   (-1)

no position

◆ ZPACK_WINDOW_SIZE

#define ZPACK_WINDOW_SIZE   16383

window size

Function Documentation

◆ MODULE()

MODULE ( "turnstone.lib"  )

module name

◆ zpack_find_bestmatch()

static zpack_match_t zpack_find_bestmatch ( buffer_t in,
int64_t  in_len,
int64_t  in_p,
zpack_hashtable_t ht 
)
static

find best match

Parameters
[in]ininput buffer
[in]in_leninput buffer length
[in]in_pinput buffer position
[in]hthashtable
Returns
best match

◆ zpack_hash4()

static uint32_t zpack_hash4 ( uint32_t  data)
inlinestatic

hash function

Parameters
[in]datadata to hash
Returns
hash value

◆ zpack_hash_insert()

static void zpack_hash_insert ( int64_t  pos,
uint32_t  h,
zpack_hashtable_t ht 
)
inlinestatic

insert position to hashtable

Parameters
[in]posposition
[in]hhash value
[in]hthashtable

◆ zpack_pack()

int8_t zpack_pack ( buffer_t in,
buffer_t out 
)

packs data at input buffer to output buffer with z77 algorithm

Parameters
[in]ininput buffer
[in]outoutput buffer
Returns
size of output buffer

◆ zpack_unpack()

int8_t zpack_unpack ( buffer_t in,
buffer_t out 
)

unpacks data at input buffer to output buffer with z77 algorithm

Parameters
[in]ininput buffer
[in]outoutput buffer
Returns
size of output buffer