You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The implementation provides compression behavior similar to the
lzo1x_999_compress function in lzo2 (i.e. higher compression, lower speed).
The implementation is fixed to the default parameters of the original and
provides no facilities for various compression "levels" or an initialization
dictionary.
The decompressor is compatible with data compressed by other LZO1X
implementations.
Usage
#include<lzokay.hpp>
#include<cstring>intcompress_and_decompress(constuint8_t* data, std::size_t length) {
lzokay::EResult error;
/* This variable and 6th parameter of compress() is optional, but may * be reused across multiple compression runs; avoiding repeat * allocation/deallocation of the work memory used by the compressor.*/
lzokay::Dict<> dict;
std::size_t estimated_size = lzokay::compress_worst_size(length);
std::unique_ptr<uint8_t[]> compressed(newuint8_t[estimated_size]);
std::size_t compressed_size;
error = lzokay::compress(data, length, compressed.get(), estimated_size,
compressed_size, dict);
if (error < lzokay::EResult::Success)
return1;
std::unique_ptr<uint8_t[]> decompressed(newuint8_t[length]);
std::size_t decompressed_size;
error = lzokay::decompress(compressed.get(), compressed_size,
decompressed.get(), length, decompressed_size);
if (error < lzokay::EResult::Success)
return1;
if (std::memcmp(data, decompressed.get(), decompressed_size) != 0)
return1;
return0;
}
License
LZ👌 is available under the
MIT License
and has no external dependencies.
About
LZ👌 – MIT licensed C++ implementation of LZO compression/decompression algorithm