Skip to content

Commit

Permalink
Sync FST code to GtkWave SVN r1066
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Jul 26, 2014
1 parent 77bc9da commit a51a9a1
Show file tree
Hide file tree
Showing 6 changed files with 4,906 additions and 4,369 deletions.
18 changes: 9 additions & 9 deletions thirdparty/fastlz.c
@@ -1,4 +1,4 @@
/*
/*
FastLZ - lightning-fast lossless compression library
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
Expand Down Expand Up @@ -53,7 +53,7 @@
#define FASTLZ_INLINE inline
#elif defined(__BORLANDC__) || defined(_MSC_VER) || defined(__LCC__)
#define FASTLZ_INLINE __inline
#else
#else
#define FASTLZ_INLINE
#endif

Expand Down Expand Up @@ -87,7 +87,7 @@ int fastlz_decompress(const void* input, int length, void* output, int maxout);
#define MAX_DISTANCE 8192

#if !defined(FASTLZ_STRICT_ALIGN)
#define FASTLZ_READU16(p) *((const flzuint16*)(p))
#define FASTLZ_READU16(p) *((const flzuint16*)(p))
#else
#define FASTLZ_READU16(p) ((p)[0] | (p)[1]<<8)
#endif
Expand Down Expand Up @@ -233,7 +233,7 @@ static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void*
*hslot = anchor;

/* is this a match? check the first 3 bytes */
if(distance==0 ||
if(distance==0 ||
#if FASTLZ_LEVEL==1
(distance >= MAX_DISTANCE) ||
#else
Expand All @@ -246,11 +246,11 @@ static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void*
/* far, needs at least 5-byte match */
if(distance >= MAX_DISTANCE)
{
if(*ip++ != *ref++ || *ip++!= *ref++)
if(*ip++ != *ref++ || *ip++!= *ref++)
goto literal;
len += 2;
}

match:
#endif

Expand Down Expand Up @@ -346,7 +346,7 @@ static FASTLZ_INLINE int FASTLZ_COMPRESSOR(const void* input, int length, void*
while(len > MAX_LEN-2)
{
*op++ = (7 << 5) + (distance >> 8);
*op++ = MAX_LEN - 2 - 7 -2;
*op++ = MAX_LEN - 2 - 7 -2;
*op++ = (distance & 255);
len -= MAX_LEN-2;
}
Expand Down Expand Up @@ -457,7 +457,7 @@ static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void
ref = op - ofs - MAX_DISTANCE;
}
#endif

#ifdef FASTLZ_SAFE
if (FASTLZ_UNEXPECT_CONDITIONAL(op + len + 3 > op_limit))
return 0;
Expand Down Expand Up @@ -530,7 +530,7 @@ static FASTLZ_INLINE int FASTLZ_DECOMPRESSOR(const void* input, int length, void
return 0;
#endif

*op++ = *ip++;
*op++ = *ip++;
for(--ctrl; ctrl; ctrl--)
*op++ = *ip++;

Expand Down
26 changes: 13 additions & 13 deletions thirdparty/fastlz.h
@@ -1,4 +1,4 @@
/*
/*
FastLZ - lightning-fast lossless compression library
Copyright (C) 2007 Ariya Hidayat (ariya@kde.org)
Expand Down Expand Up @@ -47,11 +47,11 @@ extern "C" {
#endif

/**
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer
The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than
Expand All @@ -63,9 +63,9 @@ extern "C" {
int fastlz_compress(const void* input, int length, void* output);

/**
Decompress a block of compressed data and returns the size of the
decompressed block. If error occurs, e.g. the compressed data is
corrupted or the output buffer is not large enough, then 0 (zero)
Decompress a block of compressed data and returns the size of the
decompressed block. If error occurs, e.g. the compressed data is
corrupted or the output buffer is not large enough, then 0 (zero)
will be returned instead.
The input buffer and the output buffer can not overlap.
Expand All @@ -74,29 +74,29 @@ int fastlz_compress(const void* input, int length, void* output);
more than what is specified in maxout.
*/

int fastlz_decompress(const void* input, int length, void* output, int maxout);
int fastlz_decompress(const void* input, int length, void* output, int maxout);

/**
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
Compress a block of data in the input buffer and returns the size of
compressed block. The size of input buffer is specified by length. The
minimum input buffer size is 16.
The output buffer must be at least 5% larger than the input buffer
The output buffer must be at least 5% larger than the input buffer
and can not be smaller than 66 bytes.
If the input is not compressible, the return value might be larger than
length (input buffer size).
The input buffer and the output buffer can not overlap.
Compression level can be specified in parameter level. At the moment,
Compression level can be specified in parameter level. At the moment,
only level 1 and level 2 are supported.
Level 1 is the fastest compression and generally useful for short data.
Level 2 is slightly slower but it gives better compression ratio.
Note that the compressed data, regardless of the level, can always be
decompressed using the function fastlz_decompress above.
*/
*/

int fastlz_compress_level(int level, const void* input, int length, void* output);

Expand Down

0 comments on commit a51a9a1

Please sign in to comment.