mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-28 17:19:31 +01:00
Animate often keeps a library image or sound only as its own data file
(bin/*.dat in zip/XFL packages; the same bytes are the Media <n> /
M <n> <stamp> streams of legacy Flash 8-CS4 .fla files). These were
reported as "stored in Animate's own format" and left out.
New L0 crate anicraft-flamedia (miniz_oxide and craft-audio, both
already in the tree) decodes them, with bounded memory and no panics:
* bitmaps: 26-byte header (kind 03, format 05 = A,R,G,B, row bytes,
width, height, frame in twips, has-alpha, compressed), then u16-length
chunks ending in u16 0 that join into one zlib stream inflating to
exactly row bytes x height; premultiplied ARGB becomes straight RGBA8.
Other pixel formats, uncompressed and JPEG-backed variants are
refused with a clear reason, not guessed at. Edges capped at 8192,
inflate capped at the size the header promises.
* sounds: raw s16le PCM, interleaved; rate and channels from the XFL
item's format ("44kHz 16bit Stereo") or the legacy CMediaSound format
byte; checked against sampleCount and wrapped losslessly as WAV.
The XFL importer now brings these bitmaps and sounds in (raw PCM only
when the data is exactly sampleCount frames long, so an MP3 kept as it
came, or a payload without a sampleCount, is not misread as PCM).
Unobserved variants are named in the report with why.
Tests: synthetic payloads built from the grammar (every truncation,
every damaged byte, oversize and zlib-bomb refusal, premultiplied
conversion, chunking, padded rows, format parsing, WAV wrapping), an
import test, and an env-gated differential test against the corpus
twins (ANICRAFT_FLA_CORPUS): every twin's 88x31 badge decodes to the
same pixels, and the movie template's four sounds come across with
their 12376/7072/901680/21216 frames.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>