libWiiPy.archive.lz77 Module

libWiiPy.archive.lz77 Module#

Description#

The libWiiPy.archive.lz77 module provides support for handling LZ77 compression, which is a compression format used across the Wii and other Nintendo consoles.

Module Contents#

libWiiPy.archive.lz77.compress_lz77(data: bytes, compression_level: int = 1) bytes#

Compresses data using the Wii’s LZ77 compression algorithm and returns the compressed result. Supports two different levels of compression, one based around a “greedy” LZ compression algorithm and the other based around an optimized LZ compression algorithm. The greedy compressor, level 1, will produce a larger compressed file but will run noticeably faster than the optimized compressor, which is level 2, especially for larger data.

Parameters:
  • data (bytes) – The data to compress.

  • compression_level (int) – The compression level to use, either 1 and 2. Default value is 1.

Returns:

The LZ77-compressed data.

Return type:

bytes

libWiiPy.archive.lz77.decompress_lz77(lz77_data: bytes) bytes#

Decompresses LZ77-compressed data and returns the decompressed result. Supports data both with and without the magic number ‘LZ77’ (which may not be present if the data is embedded in something else).

Parameters:

lz77_data (bytes) – The LZ77-compressed data to decompress.

Returns:

The decompressed data.

Return type:

bytes