FreeCalypso > hg > freecalypso-reveng
diff fluid-mnf/lz.h @ 311:9cecc930d78f
fluid-mnf: original source from TI,
defenestrated line endings and rearranged directory structure,
but no *.[ch] source file content changes yet
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 29 Feb 2020 05:36:07 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fluid-mnf/lz.h Sat Feb 29 05:36:07 2020 +0000 @@ -0,0 +1,59 @@ +/****************************************************************************** + * FLUID (Flash Loader Utility Independent of Device) + * + * Simple LZ77 compressor (c) Texas Instruments, Jesper Pedersem TI-DK + * + * $Id: lz.h 1.4 Thu, 31 Oct 2002 13:12:27 +0100 tsj $ + * + ******************************************************************************/ + +#ifndef _LZ_H_ +#define _LZ_H_ 1 + +// Algorithmn efficiency constants + +// Don't compress unless we have a > THRESHOLD match +#define THRESHOLD 2 + +// Number of bits to use for position, when storing a match +#define POS_BITS 12 +#define POS_MASK 0x0FFF + +// Number of bits to use for length, when storing a match +#define LEN_BITS 4 +#define LEN_MASK 0xF000 + +// Size and size-mask of sliding window +#define WINDOW_SIZE (1 << POS_BITS) +#define WINDOW_MASK (WINDOW_SIZE - 1) + +// Maximum match length +#define MAX_MATCH ((1 << LEN_BITS) + THRESHOLD) + +// This structure is only being used by lzdecode/decompress(). +struct lz_s { + uint8 window[WINDOW_SIZE]; // Sliding window buffer + int16 window_pos; // Current window position + + // Static variables for get_bits() + uint32 bitbuf; // buffer for remaining bits + uint8 bitbuf_size; // number of bits in buffer + + // Global input/output buffer pointers and sizes + uint8 *buffer_in; + uint32 buffer_in_size; + uint32 total_in_size; + uint8 *buffer_out; + uint32 buffer_out_size; + uint32 total_out_size; +}; + + +void compress_init(void); +int compress(char *outbuf, char *inbuf, int size); + +void decompress_init(struct lz_s *plz); +int decompress(struct lz_s *plz, + unsigned char *outbuf, unsigned char *inbuf, int size); + +#endif