propack

propack.cli

propack.lz

LZ77 match finding for RNC ProPack compression.

Works directly on the input data array. Match offsets are distances back from the current position (1 = previous byte).

scan_block

def scan_block(data,
               offset,
               size,
               block_size=PACK_BLOCK_SIZE,
               max_matches=MAX_MATCHES,
               max_offset=0xFFFF,
               raw_freq=None,
               pos_freq=None,
               len_freq=None)

Scan data for LZ77 matches, return match records.

Each record is (data_length, match_count_minus2, match_offset_minus1).

If freq lists are provided, frequency counts are accumulated for Huffman table building (method 1).

Returns list of tuples and the number of bytes consumed.

propack.header

propack.bitreader

BitReader Objects

class BitReader()

Reads bits from a byte buffer, used by both method 1 and method 2.

read_bits_m1

def read_bits_m1(count: int) -> int

Read bits in method 1 style (LSB first, 16-bit token, lookahead).

read_bits_m2

def read_bits_m2(count: int) -> int

Read bits in method 2 style (MSB first, 8-bit token).

propack.unpack

unpack

def unpack(data: bytes | bytearray, key: int = 0) -> bytes

Decompress RNC ProPack compressed data.

Arguments:

Returns:

decompressed data as bytes

Raises:

propack.crc

propack.pack

RNC ProPack compression.

pack

def pack(data: bytes | bytearray, method: int = 1, key: int = 0) -> bytes

Compress data using RNC ProPack.

Arguments:

Returns:

compressed data with RNC header as bytes

Raises:

propack.bits

Shared bit manipulation utilities.

ror16

def ror16(key)

Rotate right 16-bit value by 1.

inverse_bits

def inverse_bits(value, count)

Reverse the bit order of value over count bits.

propack.constants

propack.bitwriter

BitWriterM2 Objects

class BitWriterM2()

Write bits MSB-first into 8-bit tokens, with interleaved byte queue.

flush_pending

def flush_pending()

Flush pending bytes directly if no bits are buffered.

BitWriterM1 Objects

class BitWriterM1()

Write bits LSB-first into 16-bit tokens, with interleaved byte queue.