ptwm.codecs
ptwm.codecs
Plane-level entropy coders.
ptwm.codecs
python/ptwm/codecs/__init__.py:1module ptwm.codecsPlane-level entropy coders.
ptwm.codecs.Codec
python/ptwm/codecs/__init__.py:26class Codec(Protocol):Plane-level entropy coder.
ptwm.codecs.Codec.decode
python/ptwm/codecs/__init__.py:36def decode(self, blob: bytes | memoryview, original_len: int) -> bytesDecode ``blob`` back to the original bytes.
ptwm.codecs.Codec.encode
python/ptwm/codecs/__init__.py:32def encode(self, data: bytes | memoryview) -> bytesEncode ``data`` into a codec-specific blob.
ptwm.codecs.Codec.name
python/ptwm/codecs/__init__.py:30name: strptwm.codecs.CodecId
python/ptwm/codecs/__init__.py:169class CodecId(IntEnum):Numeric codec identifiers — wire identifiers, never reassign.
ptwm.codecs.CodecId.ArithmeticO0
python/ptwm/codecs/__init__.py:186ArithmeticO0 = 18ptwm.codecs.CodecId.ArithmeticO0Adaptive
python/ptwm/codecs/__init__.py:187ArithmeticO0Adaptive = 19ptwm.codecs.CodecId.ArithmeticO1
python/ptwm/codecs/__init__.py:188ArithmeticO1 = 20ptwm.codecs.CodecId.ContextMixingLite
python/ptwm/codecs/__init__.py:189ContextMixingLite = 21ptwm.codecs.CodecId.Fpc
python/ptwm/codecs/__init__.py:182Fpc = 6ptwm.codecs.CodecId.HuffLlm5Bit
python/ptwm/codecs/__init__.py:190HuffLlm5Bit = 22ptwm.codecs.CodecId.Huffman
python/ptwm/codecs/__init__.py:178Huffman = 1ptwm.codecs.CodecId.Identity
python/ptwm/codecs/__init__.py:177Identity = 0ptwm.codecs.CodecId.NeuralPredictor
python/ptwm/codecs/__init__.py:192NeuralPredictor = 24ptwm.codecs.CodecId.Order1Arithmetic
python/ptwm/codecs/__init__.py:191Order1Arithmetic = 23ptwm.codecs.CodecId.Order1ScaleAC
python/ptwm/codecs/__init__.py:185Order1ScaleAC = 17ptwm.codecs.CodecId.PerGroupCodebook
python/ptwm/codecs/__init__.py:184PerGroupCodebook = 16ptwm.codecs.CodecId.Rans
python/ptwm/codecs/__init__.py:179Rans = 3ptwm.codecs.CodecId.Tans
python/ptwm/codecs/__init__.py:183Tans = 7ptwm.codecs.CodecId.Zstd
python/ptwm/codecs/__init__.py:180Zstd = 4ptwm.codecs.CodecId.ZstdDict
python/ptwm/codecs/__init__.py:181ZstdDict = 5ptwm.codecs.decode_planes
python/ptwm/codecs/__init__.py:153def decode_planes(blobs: Sequence[bytes | memoryview], original_lens: Sequence[int], codec: Codec | str) -> list[bytes]Decode each blob with ``codec``, using the matching ``original_lens[i]``.
ptwm.codecs.encode_planes
python/ptwm/codecs/__init__.py:144def encode_planes(planes: Sequence[Plane | bytes | memoryview], codec: Codec | str) -> list[bytes]Encode each plane with ``codec``. Returns one blob per plane.
ptwm.codecs.get_codec
python/ptwm/codecs/__init__.py:129def get_codec(name: str) -> CodecLook up a codec by short name.
ptwm.codecs.HuffmanCodec
python/ptwm/codecs/__init__.py:62class HuffmanCodec:Canonical-Huffman entropy coder (4-stream interleaved).
ptwm.codecs.HuffmanCodec.__init__
python/ptwm/codecs/__init__.py:1def __init__(self, name: str = 'huffman') -> Noneptwm.codecs.HuffmanCodec.decode
python/ptwm/codecs/__init__.py:72def decode(self, blob: bytes | memoryview, original_len: int) -> bytesDecode a Huffman blob produced by :meth:`encode`.
ptwm.codecs.HuffmanCodec.encode
python/ptwm/codecs/__init__.py:68def encode(self, data: bytes | memoryview) -> bytesHuffman-encode ``data``; falls back to tagged-raw if not beneficial.
ptwm.codecs.HuffmanCodec.name
python/ptwm/codecs/__init__.py:66name: str = 'huffman'ptwm.codecs.IdentityCodec
python/ptwm/codecs/__init__.py:47class IdentityCodec:Passthrough codec: ``encode`` and ``decode`` return their input.
ptwm.codecs.IdentityCodec.__init__
python/ptwm/codecs/__init__.py:1def __init__(self, name: str = 'identity') -> Noneptwm.codecs.IdentityCodec.decode
python/ptwm/codecs/__init__.py:57def decode(self, blob: bytes | memoryview, original_len: int) -> bytesReturn ``blob`` unchanged after a length check.
ptwm.codecs.IdentityCodec.encode
python/ptwm/codecs/__init__.py:53def encode(self, data: bytes | memoryview) -> bytesReturn ``data`` unchanged.
ptwm.codecs.IdentityCodec.name
python/ptwm/codecs/__init__.py:51name: str = 'identity'ptwm.codecs.RansCodec
python/ptwm/codecs/__init__.py:77class RansCodec:Range-asymmetric-numeral-systems entropy coder.
ptwm.codecs.RansCodec.__init__
python/ptwm/codecs/__init__.py:1def __init__(self, name: str = 'rans') -> Noneptwm.codecs.RansCodec.decode
python/ptwm/codecs/__init__.py:87def decode(self, blob: bytes | memoryview, original_len: int) -> bytesDecode an rANS blob produced by :meth:`encode`.
ptwm.codecs.RansCodec.encode
python/ptwm/codecs/__init__.py:83def encode(self, data: bytes | memoryview) -> bytesrANS-encode ``data``; falls back to tagged-raw if not beneficial.
ptwm.codecs.RansCodec.name
python/ptwm/codecs/__init__.py:81name: str = 'rans'ptwm.codecs.ZstdCodec
python/ptwm/codecs/__init__.py:92class ZstdCodec:ZSTD entropy coder. ``level`` is the standard 1-22 compression level.
ptwm.codecs.ZstdCodec.__init__
python/ptwm/codecs/__init__.py:1def __init__(self, level: int = 3) -> Noneptwm.codecs.ZstdCodec.decode
python/ptwm/codecs/__init__.py:107def decode(self, blob: bytes | memoryview, original_len: int) -> bytesDecode a ZSTD blob and verify its length matches ``original_len``.
ptwm.codecs.ZstdCodec.encode
python/ptwm/codecs/__init__.py:103def encode(self, data: bytes | memoryview) -> bytesZSTD-encode ``data`` at ``self.level``.
ptwm.codecs.ZstdCodec.level
python/ptwm/codecs/__init__.py:96level: int = 3ptwm.codecs.ZstdCodec.name
python/ptwm/codecs/__init__.py:99name: strShort codec name suffixed by level (e.g. ``zstd-3``).