jak-project/third-party/lzokay
Tyler Wilding e74bd3b32b
ci: Add an automated release process (#1262)
* ci: bring over some of my code to enable the process

* ci: cleanup builds a bit and add release stuff

* ci: fix paths and such after debugging

* ci: fix flowchart

* cmake: easily toggle between building everything dyn or statically linked

* ci: build release artifacts statically linked

* ci: fix some issues after testing once again, linux binaries are still too big
2022-03-29 22:47:08 -04:00
..
lzokay-c third-party/licensing: Switch miniLZO usage to LZOkay (#232) 2021-02-06 09:54:23 -05:00
CMakeLists.txt ci: Add an automated release process (#1262) 2022-03-29 22:47:08 -04:00
Config.cmake.in third-party/licensing: Switch miniLZO usage to LZOkay (#232) 2021-02-06 09:54:23 -05:00
LICENSE third-party/licensing: Switch miniLZO usage to LZOkay (#232) 2021-02-06 09:54:23 -05:00
lzokay.cpp [decomp] finish actor-link-h and a few more (#592) 2021-06-14 20:46:54 -04:00
lzokay.hpp third-party/licensing: Switch miniLZO usage to LZOkay (#232) 2021-02-06 09:54:23 -05:00
README.md third-party/licensing: Switch miniLZO usage to LZOkay (#232) 2021-02-06 09:54:23 -05:00
test.cpp third-party/licensing: Switch miniLZO usage to LZOkay (#232) 2021-02-06 09:54:23 -05:00

LZ👌

A minimal, C++14 implementation of the LZO compression format.

Objective

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>

int compress_and_decompress(const uint8_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(new uint8_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)
    return 1;

  std::unique_ptr<uint8_t[]> decompressed(new uint8_t[length]);
  std::size_t decompressed_size;
  error = lzokay::decompress(compressed.get(), compressed_size,
                             decompressed.get(), length, decompressed_size);
  if (error < lzokay::EResult::Success)
    return 1;

  if (std::memcmp(data, decompressed.get(), decompressed_size) != 0)
    return 1;

  return 0;
}

License

LZ👌 is available under the MIT License and has no external dependencies.