Skip to main content

Module codec

Module codec 

Source
Expand description

MNF5 (v0.5 format): atlas codec, zlib container.

Structs§

Atlas
Atlas: previously decoded patches, ranked lookup by signature.
DecodeLimits
Configurable decoder resource ceilings (review fix 3). Defaults are the format-derived maxima; callers decoding untrusted input can tighten any of them independently.
DecodeResult
Decoded image: dims + RGB8 pixels.
Dims
Image dimensions in pixels.
GeomStats
Encode statistics (per-tile choices/savings; feeds vis maps).
Sig
Tile signature: RGB means used for nearest-neighbor ranking.
Tile
A tile: raw RGB data plus its (possibly partial) edge dims.

Enums§

Mode
Per-tile record kinds: literal or reference (v0.5 mode grammar).

Constants§

ATLAS_CAPACITY
Atlas cap: max distinct previously-decoded patches tracked.
HEADER_SIZE
Magic + header size (bytes): MNF5 + 5×u32 LE.
NUM_TRANSFORMS
D8 geometric transforms considered (identity + rotation/reflection).
RANK_CANDIDATES
Best-N references evaluated per tile after signature ranking.
TILE_SIZE
Tile edge in pixels (both axes).

Functions§

apply_transform
Pixel bytes after D8 transform t (deterministic integer perm).
build_header
Build the 24-byte MNF5 header.
compress_payload
zlib-compress the assembled record stream (level 9).
decode
Decode an MNF5 file (header + zlib payload) back to RGB8 pixels.
decode_with_limits
Decode MNF5 with configurable ceilings.
div_ceil
Ceiling division.
encode_mnf5
One-call MNF5 encode (the CLI’s pipeline exposed as API): split, encode the tile stream, compress, and assemble header + payload.
encode_stats
Encode + utilization counters (v0.6 exit metric: reference utilization).
encode_tiles
Encode a tile stream (row-major, tile_dims shapes) with optional atlas matching. Raw bytes per tile: mode, optional idx, optional transform, body; mode 2 (geometric atlas, v0.6) writes both index (u32 LE) and transform id (u8) after the mode byte. use_geom extends matching to the D8 group; with use_atlas only, exact prior-patch references (v0.5 behavior) are used.
split_tiles
Split an RGB8 pixel buffer into row-major Tiles (public: CLI uses the same tiling as encoder/decoder/tests — one definition of truth).
tile_dims
(w,h) of tile t, respecting partial edge tiles.
tile_grid
(tiles_per_row, tile_rows) for the row-major tile scan.
tile_proxy_cost
Cost proxy for one tile’s contribution to the compressed stream. ponytail: per-tile zlib call is O(128) small compressions per tile — fine at benchmark scale; if profiling shows it hot, cache or use a rolling window.
tile_sig
Compute a tile’s signature for atlas ranking.
transform_dims
Dims of a tile after D8 transform t (swapped for rotations).
transform_is_valid_for
Which transforms keep the tile shape (a reference must reproduce tw x th): all 8 on square patches, only the identity/hflip/vflip/rot180 subgroup on non-square partial tiles.