mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-28 17:19:31 +01:00
fix(fla): read each stream by its own entry; tests and ADR say what they check
These come from CodeRabbit's first review, where they sat in the review body rather than in threads. Container and dump: - `Compound::read_entry` reads the entry itself, and a stream path's first entry is indexed. A damaged file that lists one path twice now dumps each entry's own bytes beside its own size, and lookups no longer scan the directory. - `fla-dump --stream` reads only that stream (`dump_only`), so another stream's damage can't fail it. A stream the file doesn't have is said. Tests: - The FAT-loop test needs the file to open, and needs the stream's loop refused. - The test writer marks its FAT sectors FATSECT, as [MS-CFB] 2.3 says. - The corpus tests compare the scene count. - A twin member that is listed but can't be read fails the test instead of shrinking what is compared. - The stage test covers every pinned pair. - Text runs compare the full character position. - The one tolerated text-bounds difference is pinned to the value seen. - The own-media test fails on any twin that doesn't import, and on any corpus folder it can't list. It knows the two downloads that are zips of documents. ADR 0120: - the Stage 1 scope reads as history; - the openspec path is gone; - the shape check names what it compares (edges and style indices); - the text check says 372 records pair and 371 match field for field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
87ed789114
commit
3144fed2c6
9 files changed
+149
-55
No files matched your search
@@ -311,10 +311,9 @@ pub fn run(argv: &[String]) -> Result<String, String> {
|
||||
if !anicraft_fla::is_legacy(&data) {
|
||||
return Err(format!("{p}: not a legacy Flash document (its first bytes are not the compound binary signature)"));
|
||||
}
|
||||
let streams = anicraft_fla::dump(&data).map_err(|e| format!("{p}: {e}"))?;
|
||||
let wanted = a.flag("stream");
|
||||
// With --stream, only that stream is read: another one's damage can't fail it.
|
||||
let streams = anicraft_fla::dump_only(&data, a.flag("stream")).map_err(|e| format!("{p}: {e}"))?;
|
||||
let list: Vec<Value> = streams.iter()
|
||||
.filter(|s| wanted.is_none_or(|w| s.path == w))
|
||||
.map(|s| {
|
||||
let mut v = json!({
|
||||
"stream": s.path,
|
||||
|
||||
+19
-2
@@ -85,6 +85,8 @@ pub struct Compound<'a> {
|
||||
len: u64,
|
||||
/// Directory entries with paths, root first, then the tree in walk order.
|
||||
entries: Vec<Entry>,
|
||||
/// Each stream path's first entry in `entries` (a damaged file may list a path twice).
|
||||
streams: HashMap<String, usize>,
|
||||
}
|
||||
|
||||
impl<'a> Compound<'a> {
|
||||
@@ -133,7 +135,13 @@ impl<'a> Compound<'a> {
|
||||
let size = if kind == Kind::Stream { e.size } else { 0 };
|
||||
entries.push(Entry { path, kind, size, start: e.start, id });
|
||||
}
|
||||
Ok(Compound { file, len: data.len() as u64, entries })
|
||||
let mut streams = HashMap::new();
|
||||
for (i, e) in entries.iter().enumerate() {
|
||||
if e.kind == Kind::Stream {
|
||||
streams.entry(e.path.clone()).or_insert(i);
|
||||
}
|
||||
}
|
||||
Ok(Compound { file, len: data.len() as u64, entries, streams })
|
||||
}
|
||||
|
||||
/// Every entry, root first, then the tree in walk order.
|
||||
@@ -143,7 +151,16 @@ impl<'a> Compound<'a> {
|
||||
|
||||
/// Reads a stream by its full path. Storages have nothing to read.
|
||||
pub fn stream(&self, path: &str) -> Result<Vec<u8>, Error> {
|
||||
let entry = self.entries.iter().find(|e| e.kind == Kind::Stream && e.path == path).ok_or_else(|| Error::NotFound(path.to_string()))?;
|
||||
let entry = self.streams.get(path).and_then(|&i| self.entries.get(i)).ok_or_else(|| Error::NotFound(path.to_string()))?;
|
||||
self.read_entry(entry)
|
||||
}
|
||||
|
||||
/// Reads the stream one of [`Compound::entries`] is: its own bytes, even when another
|
||||
/// entry of a damaged file has the same path.
|
||||
pub fn read_entry(&self, entry: &Entry) -> Result<Vec<u8>, Error> {
|
||||
if entry.kind != Kind::Stream {
|
||||
return Err(Error::NotFound(entry.path.clone()));
|
||||
}
|
||||
// Refused before anything is reserved for it: no stream holds more than the file does.
|
||||
if entry.size > MAX_STREAM || entry.size > self.len {
|
||||
return Err(Error::StreamTooLarge);
|
||||
|
||||
+14
-2
@@ -64,16 +64,23 @@ pub struct StreamDump {
|
||||
|
||||
/// Dumps a legacy document's streams for triage and reverse-engineering.
|
||||
pub fn dump(data: &[u8]) -> Result<Vec<StreamDump>, cfb::Error> {
|
||||
dump_only(data, None)
|
||||
}
|
||||
|
||||
/// [`dump`], of only the streams at path `only` when it is given: the others aren't read, so
|
||||
/// a damaged one can't fail the dump or spend the tag budget. A path no stream has is
|
||||
/// [`cfb::Error::NotFound`].
|
||||
pub fn dump_only(data: &[u8], only: Option<&str>) -> Result<Vec<StreamDump>, cfb::Error> {
|
||||
let file = cfb::Compound::new(data)?;
|
||||
let mut out = Vec::new();
|
||||
// One tag budget for the whole file: several directory entries may share one chain, so a
|
||||
// budget per stream would let a small file hold millions of tags.
|
||||
let mut tags_left = records::MAX_TAGS;
|
||||
for entry in file.entries() {
|
||||
if entry.kind != cfb::Kind::Stream {
|
||||
if entry.kind != cfb::Kind::Stream || only.is_some_and(|p| p != entry.path) {
|
||||
continue;
|
||||
}
|
||||
let bytes = file.stream(&entry.path)?;
|
||||
let bytes = file.read_entry(entry)?;
|
||||
let scan = records::scan_tags_max(&bytes, tags_left);
|
||||
tags_left = tags_left.saturating_sub(scan.tags.len());
|
||||
out.push(StreamDump {
|
||||
@@ -84,5 +91,10 @@ pub fn dump(data: &[u8]) -> Result<Vec<StreamDump>, cfb::Error> {
|
||||
tags_complete: scan.complete,
|
||||
});
|
||||
}
|
||||
if let Some(p) = only
|
||||
&& out.is_empty()
|
||||
{
|
||||
return Err(cfb::Error::NotFound(p.to_string()));
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
+15
-13
@@ -126,14 +126,17 @@ pub(crate) fn write(streams: &[(&str, Vec<u8>)]) -> Vec<u8> {
|
||||
out.extend_from_slice(&mf_padded);
|
||||
pos += mf_padded.len();
|
||||
|
||||
// The FAT: the FAT's own chain first, then the big streams, the directory, the mini
|
||||
// stream and the mini FAT; everything else free.
|
||||
// The FAT: the big streams, the directory, the mini stream and the mini FAT chained, the
|
||||
// FAT's own sectors marked FATSECT ([MS-CFB] 2.3); everything else free.
|
||||
let fat_start = (pos / SECTOR - 1) as u32;
|
||||
let fat_entries_needed = pos / SECTOR + 1;
|
||||
let fat_sectors = fat_entries_needed.div_ceil(SECTOR / 4);
|
||||
// Enough FAT sectors to hold an entry for every sector, their own included.
|
||||
let mut fat_sectors = 1;
|
||||
while fat_start as usize + fat_sectors > fat_sectors * SECTOR / 4 {
|
||||
fat_sectors += 1;
|
||||
}
|
||||
let mut fat = vec![FREESECT; fat_sectors * SECTOR / 4];
|
||||
for (i, entry) in fat.iter_mut().enumerate().take(fat_sectors) {
|
||||
*entry = if i + 1 < fat_sectors { fat_start + i as u32 + 1 } else { ENDOFCHAIN };
|
||||
for i in 0..fat_sectors {
|
||||
fat[fat_start as usize + i] = FATSECT;
|
||||
}
|
||||
let chain = |fat: &mut Vec<u32>, first: u32, count: usize| {
|
||||
for i in 0..count {
|
||||
@@ -229,20 +232,19 @@ fn a_fat_chain_that_loops_is_refused() {
|
||||
for w in 0..(f.len() - fat_at) / 4 {
|
||||
let at = fat_at + w * 4;
|
||||
let v = u32::from_le_bytes(f[at..at + 4].try_into().unwrap());
|
||||
if v != ENDOFCHAIN && v != FREESECT && v != FATSECT_MARKER && v > 0 && v < (f.len() / 512) as u32 {
|
||||
if v != ENDOFCHAIN && v != FREESECT && v != FATSECT && v > 0 && v < (f.len() / 512) as u32 {
|
||||
set_u32(&mut f, at, w as u32);
|
||||
}
|
||||
}
|
||||
// Opening validates the header, directory and mini-FAT chains; the stream's own
|
||||
// chain is walked when the stream is read.
|
||||
if let Ok(file) = Compound::new(&f) {
|
||||
assert!(matches!(file.stream("Contents"), Err(Error::Damaged(_))), "the looping stream chain must be refused");
|
||||
}
|
||||
// Only the stream's own chain loops, so the file opens; the loop is refused when the
|
||||
// stream is read.
|
||||
let file = Compound::new(&f).expect("only the stream's chain loops");
|
||||
assert!(matches!(file.stream("Contents"), Err(Error::Damaged(why)) if why.contains("loop")), "the looping stream chain must be refused");
|
||||
}
|
||||
|
||||
const ENDOFCHAIN: u32 = 0xFFFF_FFFE;
|
||||
const FREESECT: u32 = 0xFFFF_FFFF;
|
||||
const FATSECT_MARKER: u32 = 0xFFFF_FFFC;
|
||||
const FATSECT: u32 = 0xFFFF_FFFD;
|
||||
|
||||
#[test]
|
||||
fn a_header_that_lies_about_its_structure_is_refused() {
|
||||
|
||||
@@ -413,3 +413,29 @@ fn many_edges_through_one_vertex_rebuild_the_same() {
|
||||
assert_eq!(got.len(), 3, "two fills and a stroke");
|
||||
assert_eq!(got, oracle_shapes(&rec));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_dumped_stream_is_its_own_entry_even_when_a_damaged_file_repeats_a_path() {
|
||||
// Two entries with one path: each dumps its own size and its own bytes.
|
||||
let mut f = write(&[("Contents", vec![1; 8]), ("Contentz", vec![2; 100])]);
|
||||
let second = entry_record(&f, "Contentz");
|
||||
f[second + 14] = b's'; // "Contentz" → "Contents" (UTF-16, the 8th unit)
|
||||
let dumped = crate::dump(&f).expect("dumps");
|
||||
let sizes: Vec<u64> = dumped.iter().map(|s| s.size).collect();
|
||||
assert!(sizes.contains(&8) && sizes.contains(&100), "{sizes:?}");
|
||||
for s in &dumped {
|
||||
let want = if s.size == 8 { "01 01 01 01 01 01 01 01" } else { "02 02 02 02 02 02 02 02" };
|
||||
assert_eq!(s.head, want, "the {}-byte entry shows its own bytes", s.size);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dump_of_one_stream_reads_only_that_stream() {
|
||||
let mut f = write(&[("Contents", b"hello".to_vec()), ("Other", vec![7; 5000])]);
|
||||
let other = entry_record(&f, "Other");
|
||||
f[other + 120..other + 128].copy_from_slice(&0x7FFF_FFFFu64.to_le_bytes()); // past the file
|
||||
assert!(crate::dump(&f).is_err(), "the damaged stream fails a whole dump");
|
||||
let one = crate::dump_only(&f, Some("Contents")).expect("but not one of another stream");
|
||||
assert_eq!(one.iter().map(|s| s.path.as_str()).collect::<Vec<_>>(), ["Contents"]);
|
||||
assert!(matches!(crate::dump_only(&f, Some("Nowhere")), Err(Error::NotFound(_))), "a stream it doesn't have is said");
|
||||
}
|
||||
+20
-12
@@ -164,7 +164,8 @@ fn twin_library(path: &std::path::Path) -> std::collections::HashMap<String, Vec
|
||||
let p = entry.expect("entry").path();
|
||||
if p.is_dir() {
|
||||
dirs.push(p);
|
||||
} else if let Ok(xml) = std::fs::read_to_string(&p) {
|
||||
} else if p.extension().is_some_and(|e| e == "xml") {
|
||||
let xml = std::fs::read_to_string(&p).unwrap_or_else(|e| panic!("{}: {e}", p.display()));
|
||||
add(&p.to_string_lossy().replace('\\', "/"), xml);
|
||||
}
|
||||
}
|
||||
@@ -174,9 +175,9 @@ fn twin_library(path: &std::path::Path) -> std::collections::HashMap<String, Vec
|
||||
let archive = craft_xfl::Archive::open(&bytes).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let names: Vec<String> = archive.names().filter(|n| n.starts_with("LIBRARY/") && n.ends_with(".xml")).map(str::to_string).collect();
|
||||
for name in names {
|
||||
if let Ok(Some(xml)) = archive.read(&name) {
|
||||
add(&name, String::from_utf8_lossy(&xml).into_owned());
|
||||
}
|
||||
let xml = archive.read(&name).unwrap_or_else(|e| panic!("{}: {name}: {e}", path.display()));
|
||||
let xml = xml.unwrap_or_else(|| panic!("{}: {name} is listed but has no data", path.display()));
|
||||
add(&name, String::from_utf8_lossy(&xml).into_owned());
|
||||
}
|
||||
}
|
||||
out
|
||||
@@ -316,14 +317,20 @@ fn the_corpus_decodes_curved_shapes_edge_for_edge_like_the_twins() {
|
||||
eprintln!("{matched} decoded shapes match their twins edge for edge ({curved} with curves)");
|
||||
}
|
||||
|
||||
/// The XML of a twin's member: from its zip package, or its extracted folder.
|
||||
/// The XML of a twin's member: from its zip package, or its extracted folder. `None` only
|
||||
/// when the twin has no such member; a member it lists that can't be read fails the test, so
|
||||
/// a reader that loses members can't shrink what is compared.
|
||||
fn twin_member(path: &std::path::Path, member: &str) -> Option<Vec<u8>> {
|
||||
if path.is_dir() {
|
||||
return std::fs::read(path.join(member)).ok();
|
||||
let p = path.join(member);
|
||||
if !p.exists() {
|
||||
return None;
|
||||
}
|
||||
return Some(std::fs::read(&p).unwrap_or_else(|e| panic!("{}: {e}", p.display())));
|
||||
}
|
||||
let bytes = std::fs::read(path).ok()?;
|
||||
let archive = craft_xfl::Archive::open(&bytes).ok()?;
|
||||
archive.read(member).ok().flatten()
|
||||
let bytes = std::fs::read(path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let archive = craft_xfl::Archive::open(&bytes).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
archive.read(member).unwrap_or_else(|e| panic!("{}: {member}: {e}", path.display()))
|
||||
}
|
||||
|
||||
fn twin_members(path: &std::path::Path) -> Vec<String> {
|
||||
@@ -331,8 +338,8 @@ fn twin_members(path: &std::path::Path) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
let mut dirs = vec![path.to_path_buf()];
|
||||
while let Some(dir) = dirs.pop() {
|
||||
for entry in std::fs::read_dir(&dir).expect("twin lists").flatten() {
|
||||
let p = entry.path();
|
||||
for entry in std::fs::read_dir(&dir).unwrap_or_else(|e| panic!("{}: {e}", dir.display())) {
|
||||
let p = entry.unwrap_or_else(|e| panic!("{}: {e}", dir.display())).path();
|
||||
if p.is_dir() {
|
||||
dirs.push(p);
|
||||
} else if let Ok(rel) = p.strip_prefix(path) {
|
||||
@@ -515,6 +522,7 @@ fn the_corpus_timelines_match_the_twins_keyframe_for_keyframe() {
|
||||
let dom = twin_member(&twin_path, "DOMDocument.xml").expect("DOMDocument.xml");
|
||||
let dom = craft_xfl::document::Document::parse(&dom).expect("twin parses");
|
||||
let scenes: Vec<&craft_xml::El> = dom.root().descendants().filter(|e| local(&e.name) == "DOMTimeline").collect();
|
||||
assert_eq!(doc.scenes.len(), scenes.len(), "{legacy}: scene count");
|
||||
for (scene, tl) in doc.scenes.iter().zip(scenes) {
|
||||
compare(&format!("{legacy}:{}", scene.name), &legacy_timeline(&doc, &scene.timeline), &twin_timeline(tl), &mut t);
|
||||
}
|
||||
@@ -587,7 +595,7 @@ fn the_corpus_stage_matches_the_twins() {
|
||||
}
|
||||
checked += 1;
|
||||
}
|
||||
assert!(checked >= 6);
|
||||
assert_eq!(checked, TWINS.len(), "every pair the manifest pins is compared");
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -32,8 +32,18 @@ const TWINS: &[(&str, &str)] = &[
|
||||
];
|
||||
|
||||
/// The one known difference: Animate recomputed this text's bounds on resave, one twip
|
||||
/// narrower on each side (the legacy value is authoritative).
|
||||
const TOLERATED: &[(&str, &str, usize, &str)] = &[("mademoiselle-legacy.fla", "P 2 1609991139", 3619, "left"), ("mademoiselle-legacy.fla", "P 2 1609991139", 3619, "width")];
|
||||
/// narrower on each side (the legacy value is authoritative). Each entry pins the difference
|
||||
/// seen (legacy minus twin, in px), so any other value of that field still fails.
|
||||
const TOLERATED: &[(&str, &str, usize, &str, f64)] = &[("mademoiselle-legacy.fla", "P 2 1609991139", 3619, "left", -0.05), ("mademoiselle-legacy.fla", "P 2 1609991139", 3619, "width", 0.1)];
|
||||
|
||||
/// A bounds field's difference, legacy minus twin (only `left` and `width` are tolerated).
|
||||
fn bounds_delta(t: &TextRecord, w: &Twin, field: &str) -> Option<f64> {
|
||||
match field {
|
||||
"left" => Some(t.left() as f64 - num(w.attrs.get("left"), 0.0)),
|
||||
"width" => Some(t.width() as f64 - num(w.attrs.get("width"), 0.0)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// A twin text element: where it was, its kind, attributes, matrix and runs.
|
||||
struct Twin {
|
||||
@@ -181,7 +191,11 @@ fn compare(t: &TextRecord, w: &Twin) -> Vec<(&'static str, bool)> {
|
||||
("run fillColor", fill == g("fillColor").unwrap_or("#000000").to_ascii_uppercase()),
|
||||
("run alpha", (s.rgba[3] as f64 / 255.0 - num(ra.get("alpha"), 1.0)).abs() < 0.003),
|
||||
("run autoKern", s.auto_kern == (g("autoKern") != Some("false"))),
|
||||
("run characterPosition", (s.shift == anicraft_doc::BaselineShift::Superscript) == (g("characterPosition") == Some("superscript"))),
|
||||
("run characterPosition", s.shift == match g("characterPosition") {
|
||||
Some("superscript") => anicraft_doc::BaselineShift::Superscript,
|
||||
Some("subscript") => anicraft_doc::BaselineShift::Subscript,
|
||||
_ => anicraft_doc::BaselineShift::Normal,
|
||||
}),
|
||||
("run alignment", align == g("alignment")),
|
||||
// Animate leaves lineSpacing out at its default, 2 px (stored as 40 twips).
|
||||
("run lineSpacing", near(s.line_spacing as f64, num(ra.get("lineSpacing"), 2.0))),
|
||||
@@ -249,7 +263,9 @@ fn every_corpus_text_record_decodes_like_its_twin() {
|
||||
paired += 1;
|
||||
let mut all = true;
|
||||
for (name, ok) in compare(t, &twins[pick]) {
|
||||
let tolerated = TOLERATED.iter().any(|(f, s, h, c)| f == legacy && *s == entry.path && *h == t.head && *c == name);
|
||||
let tolerated = TOLERATED.iter().any(|(f, s, h, c, d)| {
|
||||
f == legacy && *s == entry.path && *h == t.head && *c == name && bounds_delta(t, &twins[pick], name).is_some_and(|got| (got - d).abs() < 1e-4)
|
||||
});
|
||||
let e = checks.entry(name).or_default();
|
||||
e.1 += 1;
|
||||
if ok || tolerated {
|
||||
|
||||
@@ -13,23 +13,32 @@ fn corpus() -> Option<PathBuf> {
|
||||
std::env::var_os("ANICRAFT_FLA_CORPUS").map(PathBuf::from)
|
||||
}
|
||||
|
||||
/// Lists a folder of the corpus; one that can't be listed fails the test, so a corpus read
|
||||
/// short can't pass by comparing less.
|
||||
fn list(dir: &Path) -> Vec<PathBuf> {
|
||||
let entries = std::fs::read_dir(dir).unwrap_or_else(|e| panic!("{}: {e}", dir.display()));
|
||||
entries.map(|e| e.unwrap_or_else(|e| panic!("{}: {e}", dir.display())).path()).collect()
|
||||
}
|
||||
|
||||
/// The corpus's modern twins: `*-animate.fla`, and the `.fla`/`.xfl` files in `*-animate/`.
|
||||
/// A `*-animate.fla` whose `*-animate/` folder holds `.fla` files is the download those were
|
||||
/// unpacked from (a zip of documents, not a document), so it isn't one; Mademoiselle's is a
|
||||
/// zipped XFL folder, a document, and counts beside its unpacked copy.
|
||||
fn twins(dir: &Path) -> Vec<PathBuf> {
|
||||
let mut out = Vec::new();
|
||||
let Ok(entries) = std::fs::read_dir(dir) else { return out };
|
||||
for path in entries.flatten().map(|e| e.path()) {
|
||||
for path in list(dir) {
|
||||
let name = path.file_name().and_then(|n| n.to_str()).unwrap_or_default().to_string();
|
||||
if !name.contains("-animate") {
|
||||
continue;
|
||||
}
|
||||
if path.is_dir() {
|
||||
for inner in std::fs::read_dir(&path).into_iter().flatten().flatten().map(|e| e.path()) {
|
||||
if inner.extension().is_some_and(|e| e == "fla" || e == "xfl") {
|
||||
out.push(inner);
|
||||
}
|
||||
}
|
||||
out.extend(list(&path).into_iter().filter(|inner| inner.extension().is_some_and(|e| e == "fla" || e == "xfl")));
|
||||
} else if path.extension().is_some_and(|e| e == "fla") {
|
||||
out.push(path);
|
||||
let unpacked = path.with_extension("");
|
||||
let bundle = unpacked.is_dir() && list(&unpacked).iter().any(|p| p.extension().is_some_and(|e| e == "fla"));
|
||||
if !bundle {
|
||||
out.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
out.sort();
|
||||
@@ -42,8 +51,7 @@ fn every_twins_badge_decodes_from_animates_own_bitmap_data() {
|
||||
let mut badges = Vec::new();
|
||||
let mut opened = Vec::new();
|
||||
for path in twins(&dir) {
|
||||
// One zip in the corpus has a damaged central directory; its XFL folder copy is checked.
|
||||
let Ok((doc, report)) = anicraft_xfl::import_path(&path) else { continue };
|
||||
let (doc, report) = anicraft_xfl::import_path(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
opened.push(path.display().to_string());
|
||||
let summary = report.summary();
|
||||
assert!(!summary.contains("Animate's own format"), "{}: {summary}", path.display());
|
||||
@@ -62,7 +70,9 @@ fn every_twins_badge_decodes_from_animates_own_bitmap_data() {
|
||||
assert_eq!(px.rgba[mid + 3], 255, "{}: the middle is opaque", path.display());
|
||||
badges.push(px.rgba.clone());
|
||||
}
|
||||
assert!(opened.len() >= 8, "expected the corpus's twins to open, got {opened:?}");
|
||||
// The manifest's 9 pairs: 6 Animate `.fla` files, the Mademoiselle XFL folder and its zip,
|
||||
// and the RoboKit and Storyboard downloads' 3 `.fla` files.
|
||||
assert!(opened.len() >= 10, "expected every twin the manifest pins, got {opened:?}");
|
||||
assert!(badges.windows(2).all(|w| w[0] == w[1]), "every twin's badge decodes to the same pixels");
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ Files saved by Flash 8 through CS4 — the bulk of the historical Flash authorin
|
||||
are OLE2 **compound binary files** (Microsoft `[MS-CFB]`), unlike the zip packages Flash
|
||||
CS5 and Animate write. The hardened zip reader (ADR 0054) refuses them with the sentence
|
||||
"this .fla was saved by Flash CS4 or earlier…", which was honest, and
|
||||
`docs/requirements.md` listed binary FLA as a P1 stretch goal. This ADR covers reading
|
||||
the container and its record streams; decoding the records into the document model is
|
||||
follow-on work tracked in `openspec/changes/add-legacy-fla-import/`.
|
||||
`docs/requirements.md` listed binary FLA as a P1 stretch goal. This ADR began with
|
||||
reading the container and its record streams (Stage 1); decoding the records into the
|
||||
document model came after it, and the Decision and Consequences below record both.
|
||||
|
||||
## Decision
|
||||
|
||||
@@ -33,7 +33,8 @@ follow-on work tracked in `openspec/changes/add-legacy-fla-import/`.
|
||||
(structure), `CPicShape`, `CPicSymbol`, `CPicText`, `CPicSprite`, `CPicButton`,
|
||||
`CPicMorphShape` (+ `CMorphSegment`/`CMorphCurve`/`CMorphHintItem`), `CPicBitmap`,
|
||||
`CMediaBits`, `CMediaSound`, `CQTAudioSettings`, `CDocumentPage`, `CColorDef`,
|
||||
`CObList`. Payloads (geometry, fills, transforms, text) stay to be decoded.
|
||||
`CObList`. At Stage 1 the payloads (geometry, fills, transforms, text) were still to be
|
||||
decoded; their layouts follow under Consequences.
|
||||
|
||||
3. **Reverse-engineer differentially.** EDAP Tools ships the same sample rigs in both
|
||||
eras ("for Flash 8–CS6" legacy OLE2, "for Animate" modern zip FLA). Decoding is built
|
||||
@@ -79,8 +80,8 @@ follow-on work tracked in `openspec/changes/add-legacy-fla-import/`.
|
||||
(i16 in 1/256 twip, i32 in 1/256 twip, i16 in 1/2 twip), all relative to the pen; style
|
||||
changes carry stroke/left-fill/right-fill indices as u8 or u16. A record with a control
|
||||
point is a quadratic curve. Verified differentially: every shape body the decoder finds
|
||||
in the corpus (3197, 2201 of them curved) matches its twin's XFL edges, styles and
|
||||
matrix. (An earlier reading took the edge unit for half-pixels; it is half-twips — the
|
||||
in the corpus (3197, 2201 of them curved) matches its twin's XFL edges and their fill and
|
||||
stroke style indices (the record's matrix and the styles' contents aren't compared). (An earlier reading took the edge unit for half-pixels; it is half-twips — the
|
||||
"UFO mask" fixture is 10.9 × 11.2 px.) Fill regions are rebuilt per style as the XFL
|
||||
importer does. Bitmap fills and stroke kinds (dashed, dotted, hairline) are not yet
|
||||
located.
|
||||
@@ -176,10 +177,13 @@ follow-on work tracked in `openspec/changes/add-legacy-fla-import/`.
|
||||
1628/1628 layers their keyframes (index and duration), 6993/6993 keyframes their tween
|
||||
kind, 4457/4457 instances their library item, matrix, loop mode, first frame and instance
|
||||
name (18 buttons, 3 named); 335/335 non-empty texts sit on the twins' keyframes with their
|
||||
kind, characters and position (and 372/372 text records match field for field); 9/9 bitmap
|
||||
kind, characters and position (372/372 text records pair with their twin's, and 371 match
|
||||
field for field: one differs by a twip in its left edge and width, a difference the test
|
||||
pins); 9/9 bitmap
|
||||
instances and bitmap items (name, folder, size), 5/5 frame sounds (sound, sync, repeats,
|
||||
envelope) and 4/4 sound items (folder, rate, channels, length); 39/39 library folders and
|
||||
328/328 symbols at their twins' library paths and types; the stage matches on all pairs.
|
||||
328/328 symbols at their twins' library paths and types; the stage size, frame rate and
|
||||
colour match on every pair.
|
||||
Rendered frames of the movie template and the character rigs match their twins' apart
|
||||
from dotted strokes, text antialiasing on a few pixels, and the shape tweens whose hints
|
||||
the twins' XFL path drops.
|
||||
|
||||
Reference in new issue
Block a user