mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2024-12-17 14:29:59 +00:00
Add autodocs to public functions in compressor and decompressor
This commit is contained in:
parent
cd7517fb65
commit
8b992bb33a
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,10 +1,2 @@
|
|||||||
bin
|
|
||||||
vault
|
|
||||||
packed_lzsa
|
|
||||||
packed_lz4
|
|
||||||
packed_lizard
|
|
||||||
packed_lz5
|
|
||||||
packed_zx7
|
|
||||||
packed_rnc
|
|
||||||
obj
|
obj
|
||||||
lzsa
|
lzsa
|
||||||
|
11
src/expand.c
11
src/expand.c
@ -152,6 +152,17 @@ static inline FORCE_INLINE int lzsa_expand_match_slow(const unsigned char **ppIn
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decompress one data block
|
||||||
|
*
|
||||||
|
* @param pInBlock pointer to compressed data
|
||||||
|
* @param nInBlockSize size of compressed data, in bytes
|
||||||
|
* @param pOutData pointer to output decompression buffer (previously decompressed bytes + room for decompressing this block)
|
||||||
|
* @param nOutDataOffset starting index of where to store decompressed bytes in output buffer (and size of previously decompressed bytes)
|
||||||
|
* @param nBlockMaxSize total size of output decompression buffer, in bytes
|
||||||
|
*
|
||||||
|
* @return size of decompressed data in bytes, or -1 for error
|
||||||
|
*/
|
||||||
int lzsa_expand_block(const unsigned char *pInBlock, int nBlockSize, unsigned char *pOutData, int nOutDataOffset, int nBlockMaxSize) {
|
int lzsa_expand_block(const unsigned char *pInBlock, int nBlockSize, unsigned char *pOutData, int nOutDataOffset, int nBlockMaxSize) {
|
||||||
const unsigned char *pInBlockEnd = pInBlock + nBlockSize;
|
const unsigned char *pInBlockEnd = pInBlock + nBlockSize;
|
||||||
const unsigned char *pInBlockFastEnd = pInBlock + nBlockSize - 16;
|
const unsigned char *pInBlockFastEnd = pInBlock + nBlockSize - 16;
|
||||||
|
11
src/expand.h
11
src/expand.h
@ -23,6 +23,17 @@
|
|||||||
#ifndef _EXPAND_H
|
#ifndef _EXPAND_H
|
||||||
#define _EXPAND_H
|
#define _EXPAND_H
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decompress one data block
|
||||||
|
*
|
||||||
|
* @param pInBlock pointer to compressed data
|
||||||
|
* @param nInBlockSize size of compressed data, in bytes
|
||||||
|
* @param pOutData pointer to output decompression buffer (previously decompressed bytes + room for decompressing this block)
|
||||||
|
* @param nOutDataOffset starting index of where to store decompressed bytes in output buffer (and size of previously decompressed bytes)
|
||||||
|
* @param nBlockMaxSize total size of output decompression buffer, in bytes
|
||||||
|
*
|
||||||
|
* @return size of decompressed data in bytes, or -1 for error
|
||||||
|
*/
|
||||||
int lzsa_expand_block(const unsigned char *pInBlock, int nBlockSize, unsigned char *pOutData, int nOutDataOffset, int nBlockMaxSize);
|
int lzsa_expand_block(const unsigned char *pInBlock, int nBlockSize, unsigned char *pOutData, int nOutDataOffset, int nBlockMaxSize);
|
||||||
|
|
||||||
#endif /* _EXPAND_H */
|
#endif /* _EXPAND_H */
|
||||||
|
39
src/shrink.c
39
src/shrink.c
@ -44,20 +44,34 @@
|
|||||||
|
|
||||||
#define LEAVE_ALONE_MATCH_SIZE 600
|
#define LEAVE_ALONE_MATCH_SIZE 600
|
||||||
|
|
||||||
int lzsa_compressor_init(lsza_compressor *pCompressor, const int nMaxDataSize) {
|
/** One match */
|
||||||
pCompressor->intervals = (int *)malloc(nMaxDataSize * sizeof(int));
|
typedef struct _lzsa_match {
|
||||||
|
unsigned short length;
|
||||||
|
unsigned short offset;
|
||||||
|
} lzsa_match;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize compression context
|
||||||
|
*
|
||||||
|
* @param pCompressor compression context to initialize
|
||||||
|
* @param nMaxWindowSize maximum size of input data window (previously compressed bytes + bytes to compress)
|
||||||
|
*
|
||||||
|
* @return 0 for success, non-zero for failure
|
||||||
|
*/
|
||||||
|
int lzsa_compressor_init(lsza_compressor *pCompressor, const int nMaxWindowSize) {
|
||||||
|
pCompressor->intervals = (int *)malloc(nMaxWindowSize * sizeof(int));
|
||||||
pCompressor->pos_data = NULL;
|
pCompressor->pos_data = NULL;
|
||||||
pCompressor->open_intervals = NULL;
|
pCompressor->open_intervals = NULL;
|
||||||
pCompressor->match = NULL;
|
pCompressor->match = NULL;
|
||||||
|
|
||||||
if (pCompressor->intervals) {
|
if (pCompressor->intervals) {
|
||||||
pCompressor->pos_data = (int *)malloc(nMaxDataSize * sizeof(int));
|
pCompressor->pos_data = (int *)malloc(nMaxWindowSize * sizeof(int));
|
||||||
|
|
||||||
if (pCompressor->pos_data) {
|
if (pCompressor->pos_data) {
|
||||||
pCompressor->open_intervals = (int *)malloc((LCP_MAX + 1) * sizeof(int));
|
pCompressor->open_intervals = (int *)malloc((LCP_MAX + 1) * sizeof(int));
|
||||||
|
|
||||||
if (pCompressor->open_intervals) {
|
if (pCompressor->open_intervals) {
|
||||||
pCompressor->match = (lzsa_match *)malloc(nMaxDataSize * NMATCHES_PER_OFFSET * sizeof(lzsa_match));
|
pCompressor->match = (lzsa_match *)malloc(nMaxWindowSize * NMATCHES_PER_OFFSET * sizeof(lzsa_match));
|
||||||
|
|
||||||
if (pCompressor->match)
|
if (pCompressor->match)
|
||||||
return 0;
|
return 0;
|
||||||
@ -77,6 +91,11 @@ int lzsa_compressor_init(lsza_compressor *pCompressor, const int nMaxDataSize) {
|
|||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up compression context and free up any associated resources
|
||||||
|
*
|
||||||
|
* @param pCompressor compression context to clean up
|
||||||
|
*/
|
||||||
void lzsa_compressor_destroy(lsza_compressor *pCompressor) {
|
void lzsa_compressor_destroy(lsza_compressor *pCompressor) {
|
||||||
if (pCompressor->match) {
|
if (pCompressor->match) {
|
||||||
free(pCompressor->match);
|
free(pCompressor->match);
|
||||||
@ -531,6 +550,18 @@ static int lzsa_write_block(lsza_compressor *pCompressor, const unsigned char *p
|
|||||||
return nOutOffset;
|
return nOutOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compress one block of data
|
||||||
|
*
|
||||||
|
* @param pCompressor compression context
|
||||||
|
* @param pInWindow pointer to input data window (previously compressed bytes + bytes to compress)
|
||||||
|
* @param nPreviousBlockSize number of previously compressed bytes (or 0 for none)
|
||||||
|
* @param nInDataSize number of input bytes to compress
|
||||||
|
* @param pOutData pointer to output buffer
|
||||||
|
* @param nMaxOutDataSize maximum size of output buffer, in bytes
|
||||||
|
*
|
||||||
|
* @return size of compressed data in output buffer, or -1 if the data is uncompressible
|
||||||
|
*/
|
||||||
int lzsa_shrink_block(lsza_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize) {
|
int lzsa_shrink_block(lsza_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize) {
|
||||||
lzsa_build_suffix_array(pCompressor, pInWindow, nPreviousBlockSize + nInDataSize);
|
lzsa_build_suffix_array(pCompressor, pInWindow, nPreviousBlockSize + nInDataSize);
|
||||||
if (nPreviousBlockSize) {
|
if (nPreviousBlockSize) {
|
||||||
|
36
src/shrink.h
36
src/shrink.h
@ -23,11 +23,10 @@
|
|||||||
#ifndef _SHRINK_H
|
#ifndef _SHRINK_H
|
||||||
#define _SHRINK_H
|
#define _SHRINK_H
|
||||||
|
|
||||||
typedef struct {
|
/* Forward declarations */
|
||||||
unsigned short length;
|
typedef struct _lzsa_match lzsa_match;
|
||||||
unsigned short offset;
|
|
||||||
} lzsa_match;
|
|
||||||
|
|
||||||
|
/** Compression context */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int *intervals;
|
int *intervals;
|
||||||
int *pos_data;
|
int *pos_data;
|
||||||
@ -35,8 +34,35 @@ typedef struct {
|
|||||||
lzsa_match *match;
|
lzsa_match *match;
|
||||||
} lsza_compressor;
|
} lsza_compressor;
|
||||||
|
|
||||||
int lzsa_compressor_init(lsza_compressor *pCompressor, const int nMaxDataSize);
|
/**
|
||||||
|
* Initialize compression context
|
||||||
|
*
|
||||||
|
* @param pCompressor compression context to initialize
|
||||||
|
* @param nMaxWindowSize maximum size of input data window (previously compressed bytes + bytes to compress)
|
||||||
|
*
|
||||||
|
* @return 0 for success, non-zero for failure
|
||||||
|
*/
|
||||||
|
int lzsa_compressor_init(lsza_compressor *pCompressor, const int nMaxWindowSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean up compression context and free up any associated resources
|
||||||
|
*
|
||||||
|
* @param pCompressor compression context to clean up
|
||||||
|
*/
|
||||||
void lzsa_compressor_destroy(lsza_compressor *pCompressor);
|
void lzsa_compressor_destroy(lsza_compressor *pCompressor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compress one block of data
|
||||||
|
*
|
||||||
|
* @param pCompressor compression context
|
||||||
|
* @param pInWindow pointer to input data window (previously compressed bytes + bytes to compress)
|
||||||
|
* @param nPreviousBlockSize number of previously compressed bytes (or 0 for none)
|
||||||
|
* @param nInDataSize number of input bytes to compress
|
||||||
|
* @param pOutData pointer to output buffer
|
||||||
|
* @param nMaxOutDataSize maximum size of output buffer, in bytes
|
||||||
|
*
|
||||||
|
* @return size of compressed data in output buffer, or -1 if the data is uncompressible
|
||||||
|
*/
|
||||||
int lzsa_shrink_block(lsza_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize);
|
int lzsa_shrink_block(lsza_compressor *pCompressor, const unsigned char *pInWindow, const int nPreviousBlockSize, const int nInDataSize, unsigned char *pOutData, const int nMaxOutDataSize);
|
||||||
|
|
||||||
#endif /* _SHRINK_H */
|
#endif /* _SHRINK_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user