cmcqueen / lzs-compression Goto Github PK
View Code? Open in Web Editor NEWCompression using LZS-style algorithm, derived from LZ77-style
License: MIT License
Compression using LZS-style algorithm, derived from LZ77-style
License: MIT License
This test compresses and decompresses text by using incremental versions of the functions.
static void compress_decompress_incremental()
{
const char* in_buffer = "Return a string containing a printable representation of an object. "
"For many types, this function makes an attempt to return a string that would yield an "
"object with the same value when passed to eval(), otherwise the representation is a "
"string enclosed in angle brackets that contains the name of the type of the object "
"together with additional information often including the name and address of the object.";
uint8_t out_buffer[1024];
LzsCompressParameters_t compress_params;
lzs_compress_init(&compress_params);
compress_params.inPtr = (const uint8_t*)in_buffer;
compress_params.inLength = strlen(in_buffer);
compress_params.outPtr = out_buffer;
compress_params.outLength = sizeof(out_buffer);
size_t out_size = lzs_compress_incremental(&compress_params, true);
char dec_buffer[1024];
LzsDecompressParameters_t decompress_params;
lzs_decompress_init(&decompress_params);
decompress_params.inPtr = out_buffer;
decompress_params.inLength = out_size;
decompress_params.outPtr = (uint8_t*)dec_buffer;
decompress_params.outLength = sizeof(dec_buffer);
size_t dec_size = lzs_decompress_incremental(&decompress_params);
//dec_buffer[dec_size] = 0;
printf("Decompressed data \n%s\n", dec_buffer);
}
Unfortunately after decompression, the last 3 words (of the object.
) are missing.
Store a hash table of two-byte pairs for each entry in the history table. That allows faster searches through history: when searching for a match, hash the first two bytes that are being searched, then look up the hash value in the table.
This uses more memory to store the hash table (e.g. ~4 kB), but gives a significant speed benefit.
Add thorough unit tests.
Hi Craig,
Can you please add an appropriate license to your library? This will let others like me know whether or not we can use your library in our code.
May I add that a permissive license would be much appreciated!
Thanks!
Hi Craig,
I noticed that the library exposes APIs for "incremental" compression but does not actually implement them.
It would be great if it was implemented.
Thanks!
==18859==ERROR: AddressSanitizer: stack-buffer-overflow on address 0xffce2ae6 at pc 0x0817261a bp 0xffcdf7a8 sp 0xffcdf79c
READ of size 1 at 0xffce2ae6 thread T0
#0 0x8172619 in lzs_compress /builds/Application/dependencies/lzs/src/liblzs/lzs-compression.c:390:45
The offending line appears to be
I'm suspecting the overflow is due to inPtr + 1
when inPtr
is already at the last element of the input array.
For the C code, add an autotools build process. It should build a library, compress and decompress utilities, and unit tests. It should run the unit tests via make check
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.