Skip to main content

Crate atx_core

Crate atx_core 

Source
Expand description

atx-core — reader/decoder for Apple ATX (AAPL) texture-image containers.

ATX files are Apple “AAPL” texture containers found throughout iOS UI image caches: PosterBoard / runtime snapshots, wallpapers, contact posters, avatars / Animoji. Forensically they are what was on screen.

§Container layout (clean-room from the iLEAPP reference)

The byte-level framing below is reimplemented clean-room from abrignoni/iLEAPP’s leapp_functions/parsers/apple_atx.py (MIT, @JamesHabben, 2026-06-25), the authoritative reverse-engineered reference cited by the source write-up (James Habben, 2026-06-26).

AAPL\r\n\x1a\n      8-byte signature (PNG-style)
[size u32 LE][tag] chunk header (size = payload bytes, NOT incl. the 8-byte header)
  payload[size]
...                repeated to EOF

Chunk tags: HEAD (metadata), FILL, astc/ASTC (raw ASTC payload), LZFS (LZFSE-compressed ASTC).

§Decode pipeline

  • LZFS payload: LZFSE-decompress (lzfse_rust) → a linear ASTC 4x4 stream (padded to the 4x4 block grid) → astc-decode → RGBA8. No macro de-tiling — the compressed stream is already linear.
  • raw astc/ASTC payload: the ASTC blocks are macro-tiled in 32x32 block (128 px) tiles, Morton-ordered within each tile. De-tile to a linear block stream, then astc-decode → RGBA8. The Morton X/Y interpretation is not flagged by the format, so both orientations are decoded and the one with the smaller brightness jump across the 128-px macro-tile seams is kept (the reference’s grid-seam heuristic).

Codecs are REUSED, never reinvented: lzfse_rust (the fleet’s LZFSE) and astc-decode. The new value-add is the AAPL container parse, the HEAD field layout, and the Morton de-tiling.

§Validation status (Doer-Checker) — tier-1

In-crate unit tests cover the container parse and Morton math against the documented byte layout. Beyond that, the end-to-end decode is tier-1 validated on real device textures: 108 real .atx files from a public iPhone 11 / iOS 17.3 full-file-system image decode to RGBA matching the independent iLEAPP reference (a different author and a different ASTC decoder) to within one LSB per channel on every file, across both the LZFSE-compressed and raw macro-tiled paths. See docs/validation.md for the corpus, oracle, and per-path results.

Epistemics: report the pixel format as confirmed vs inferred; never claim a file is the active wallpaper just because of its path. State what the container holds, not what it means.

Modules§

fourcc
The chunk FourCC tags ATX containers carry.

Structs§

Atx
A parsed ATX container: its chunk inventory, optional HEAD metadata, optional texture payload, and any non-fatal parse warnings (truncation, trailing bytes).
ChunkRef
A located chunk within the container, from the framed [size][tag] walk.
DecodedImage
A decoded ATX image (RGBA8).
Head
HEAD metadata, parsed at the byte offsets confirmed from the iLEAPP reference.
Payload
A located texture payload chunk and its inner framing.

Enums§

AtxError
Errors from reading or decoding an ATX container.
FormatConfidence
How confidently the pixel format is known — the source research’s honest distinction (never present an inference as a confirmed fact).

Constants§

MAGIC
Every ATX file begins with this 8-byte signature (AAPL + a PNG-style \r\n\x1a\n guard). Confirmed from the iLEAPP reference (AAPL_MAGIC).

Functions§

astc4x4_confidence
Map a pixel-format discriminator pair to an ASTC-4x4 confidence, per the iLEAPP findings. Returns None for an unrecognized pair — surface the raw pair to the analyst rather than guessing a format.
decode
Decode the texture payload to RGBA8.
is_atx
Whether bytes begins with the full 8-byte ATX AAPL magic.
morton_5bit
Decode an index into a 5-bit Morton (Z-order) (x, y) pair: even bits form x, odd bits form y. Pure function — the de-tiling primitive.
parse
Parse an ATX container: validate the magic (loud on failure), walk the framed chunk list, and parse HEAD + locate the texture payload. Malformed chunks after a valid magic degrade to Atx::warnings.