q3huff

Python 3 C API wrapper for Huffman code found in ioquake3.


License
GPL-3.0-only
Install
pip install q3huff==0.4.0

Documentation

python-q3huff Build Status

This is a python module for encoding and decoding data using huffman compression as found in the ioquake3 source.

Requirements

For Windows, python3.5 or greater required.
For Linux and MacOS, python3.4 or greater required.

Installing the latest release:

$ pip install q3huff

Installing from source:

Make sure you have python-dev setup. For Windows, this means you need Visual Studio 2015.

$ pip install .

Module Documentation

q3huff.compress( bytes ) → bytes

Compresses bytes and returns result

q3huff.decompress( bytes ) → bytes

Decompresses bytes and returns result

q3huff.Reader( bytes ) → reader

Reader objects are for reading primitive types from a bytes object that may or may not be huffman compressed, depending on the value of reader.oob.

reader.reset( bytes ) → None

reader.read_bits( num_bits ) → integer

reader.read_char() → integer

reader.read_byte() → integer

reader.lookahead_byte() → integer

reader.read_data( num_bytes ) → bytes

reader.read_short() → integer

reader.read_long() → integer

reader.read_float() → float

reader.read_string() → string

reader.read_bigstring() → string

reader.read_string_line() → string

reader.read_angle() → float

reader.read_angle16() → float

reader.read_delta( old_value, num_bits ) → integer

reader.read_delta_float( old_value ) → float

reader.read_delta_key( key, old_value, num_bits ) → integer

reader.read_delta_key_float( key, old_value ) → float

reader.oob

(R/W) Boolean flag that determines if input should be huffman compressed or not.

q3huff.Writer() → writer

Writer objects are for writing primitive types to a buffer that may or may or may not be huffman compressed, depending on the value of writer.oob. The buffer can be read using writer.data.

writer.reset()

writer.write_bits( integer, num_bits )

writer.write_char( integer )

writer.write_byte( integer )

writer.write_data( bytes )

writer.write_short( integer )

writer.write_long( integer )

writer.write_float( float )

writer.write_string( string )

writer.write_bigstring( string )

writer.write_angle( float )

writer.write_angle16( float )

writer.write_delta( old_value, new_value, num_bits )

writer.write_delta_float( old_value, new_value )

writer.write_delta_key( key, old_value, new_value, num_bits )

writer.write_delta_key_float( key, old_value, new_value )

writer.data

(R) Output buffer.

writer.oob

(R/W) Boolean flag that determines if output should be huffman compressed or not.

writer.overflow

(R) Boolean flag that indicates if the output buffer has overflowed