Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 4cbd4dd17959f7858303f53c529c3183aa5bab92
parent 29c4146ff3a287fe93d0a667d1fa5beccf764728
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Mon, 26 Oct 2026 22:48:36 -0400

report-to-video: the fact-check stamps' seconds on the cut's frames, so a moved stamp keys as it did

A stamp's seconds are stored to the millisecond, so in a cut moved by m
frames the same stamp sat up to a millisecond off -- a step of the cue grid
one time in four, and every frame of its slam and tally roll a new key. On
whole frames it lands where it did but once in thirty; its look moves by at
most half a frame.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/report-to-video/chrome-deck.mjs | 4++--
Mumtool/report-to-video/chrome-deck.test.mjs | 7++++---
Mumtool/report-to-video/chrome-stamp.mjs | 6+++---
Mumtool/report-to-video/claim-knobs.test.mjs | 2+-
Mumtool/report-to-video/deck.mjs | 16++++++++++++++++
Mumtool/report-to-video/factcheck.test.mjs | 22++++++++++++----------
6 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/umtool/report-to-video/chrome-deck.mjs b/umtool/report-to-video/chrome-deck.mjs @@ -38,7 +38,7 @@ import { fileURLToPath } from "node:url"; import { - claimsLayout, cueTime, cueTimeAfter, deckChoreography, deckLayout, deckMarkers, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, resolveDeck, + claimsLayout, cueTime, cueTimeAfter, stampsOnFrames, deckChoreography, deckLayout, deckMarkers, MARKER_LABEL_SIZE, MARKER_ROW, pageDuration, pipSegments, pipXs, resolveDeck, } from "./deck.mjs"; import { claimsCues, claimsMarkup } from "./chrome-claims.mjs"; import { resolveFactcheck, tallyCues, tallyFinals, tallyKey, tallyLabelOf, tallyOf, tallyPopIns, VERDICT_SHAPES } from "./factcheck.mjs"; @@ -269,7 +269,7 @@ export function deckCues(schedule, render) { // then pops in; it keeps its place in the row (the deck is laid for every // cell), so nothing else moves when it does. if (tally) { - const t = tallyCues(schedule.factcheck.stamps, tally, { popIn: tallyPopIns(render, tally) }); + const t = tallyCues(stampsOnFrames(schedule.factcheck.stamps, fps), tally, { popIn: tallyPopIns(render, tally) }); for (const [k, v] of Object.entries(t.init)) put(k, v); for (const e of t.events) add(e.k, e.at, e.dur, e.to, e.ease, e.why); } diff --git a/umtool/report-to-video/chrome-deck.test.mjs b/umtool/report-to-video/chrome-deck.test.mjs @@ -362,9 +362,10 @@ test("the fact-check tally is in the panel, so it slides with it; a cut without // The count steps as the stamp lands, and the page carries that cue. const { cues } = deckCues(stamped, RENDER); const step = cues.find((c) => c.k === "ty.CORROBORATED.n1"); - // (On the sub-frame cue grid, deck.mjs cueTime.) - assert.equal(step.at, cueTime(18.78, 30)); - assert.ok(dataOf(html).cues.some((c) => c.k === "ty.CORROBORATED.n1" && c.at === cueTime(18.78, 30))); + // (A stamp on the cut's frames, deck.mjs stampsOnFrames; cues on the sub-frame grid, cueTime.) + const landed = cueTime(Math.round(18.78 * 30) / 30, 30); + assert.equal(step.at, landed); + assert.ok(dataOf(html).cues.some((c) => c.k === "ty.CORROBORATED.n1" && c.at === landed)); // The title's column gives the tally its room. const narrowed = deckLayout(RENDER, { tally: ["CORROBORATED"] }); assert.ok(html.includes(`max-width: ${narrowed.text.width}px`)); diff --git a/umtool/report-to-video/chrome-stamp.mjs b/umtool/report-to-video/chrome-stamp.mjs @@ -11,7 +11,7 @@ // The timeline is cues, computed here, each stating its from -- a render is a // seek per frame, from parallel workers, in any order (chrome-deck.mjs says // why at length). The times are factcheck.mjs `stampSchedule`'s, untouched. -import { cueTime, cueTimeAfter, pageDuration, stampGeometry } from "./deck.mjs"; +import { cueTime, cueTimeAfter, pageDuration, stampGeometry, stampsOnFrames } from "./deck.mjs"; import { mix, rgba } from "./chrome-deck.mjs"; import { drawnStamps, resolveFactcheck, STAMP_MOTION } from "./factcheck.mjs"; @@ -47,14 +47,14 @@ export const STAMP_POSE = Object.freeze({ rest: -6, from: -14, scale: 1.7, leave */ export function stampCues(schedule, render = null) { // A claim's `stamp: false` counts in the tally and is not drawn here. - const stamps = drawnStamps(schedule.factcheck?.stamps); + const fps = Number(schedule.fps ?? render?.fps ?? 30); + const stamps = stampsOnFrames(drawnStamps(schedule.factcheck?.stamps), fps); const motion = render ? resolveFactcheck(render).stamp.motion ?? "slam" : "slam"; const P = STAMP_POSE; const m = STAMP_MOTION; const init = {}; const ev = []; // Cue times on the sub-frame grid (deck.mjs cueTime), durations to 4 places. - const fps = Number(schedule.fps ?? render?.fps ?? 30); const add = (k, at, dur, to, ease, why) => ev.push({ k, at: cueTime(at, fps), dur: r4(Math.max(INSTANT, dur)), to, ease, why }); stamps.forEach((s, j) => { const why = `stamp ${s.claim}`; diff --git a/umtool/report-to-video/claim-knobs.test.mjs b/umtool/report-to-video/claim-knobs.test.mjs @@ -168,7 +168,7 @@ test("stamp:false: counted in the tally, not drawn; a cut whose every claim is h assert.equal(drawnStamps(sched.factcheck.stamps).length, 1); const { cues } = stampCues(sched); assert.ok(cues.every((c) => /st0|fl0/.test(c.k))); - assert.ok(cues.some((c) => c.at === cueTime(9.72, 30) && c.k === "st0"), "the drawn one is stamp 0"); + assert.ok(cues.some((c) => c.at === cueTime(Math.round(9.72 * 30) / 30, 30) && c.k === "st0"), "the drawn one is stamp 0"); assert.equal(tallySteps(sched.factcheck.stamps).at(-1).count, 2); assert.equal(stampsDrawn(sched, RENDER), true); const none = { ...sched, factcheck: { stamps: [ST("a", "PARTLY", 5, { stamp: false })] } }; diff --git a/umtool/report-to-video/deck.mjs b/umtool/report-to-video/deck.mjs @@ -3088,6 +3088,22 @@ export const cueTime = (v, fps) => Math.round(v * fps * CUE_GRID) / (fps * CUE_G /** A cue time on the grid, never before `v` (a clamp to when an element is free). */ export const cueTimeAfter = (v, fps) => Math.ceil(v * fps * CUE_GRID - 1e-6) / (fps * CUE_GRID); +/** + * The fact-check stamps with their seconds on the cut's frames. A stamp's + * seconds are its segment's start plus where in the clip its claim falls, + * stored to the millisecond -- so the same stamp in a cut moved by m frames + * is m frames plus up to a millisecond later, which on the sub-frame grid + * (cueTime) lands a step off one time in four. On whole frames, it lands on + * the same frame of its clip but once in thirty, and a stamp's look is + * unchanged to within half a frame. + */ +export const stampsOnFrames = (stamps, fps) => (stamps ?? []).map((s) => ({ + ...s, + ...(Number.isFinite(s.at) ? { at: Math.round(s.at * fps) / fps } : {}), + ...(Number.isFinite(s.landed) ? { landed: Math.round(s.landed * fps) / fps } : {}), + ...(Array.isArray(s.out) ? { out: s.out.map((v) => Math.round(v * fps) / fps) } : {}), +})); + /** Frames a render of `total` seconds at `fps` produces. */ export const frameCount = (total, fps) => Math.round(total * fps); diff --git a/umtool/report-to-video/factcheck.test.mjs b/umtool/report-to-video/factcheck.test.mjs @@ -287,20 +287,20 @@ test("tally.showAt first: a cell is hidden until its first stamp lands, pops in // Its one appearance: the pop, at the second its first stamp lands, and nothing hides it again. const own = cues.filter((c) => c.k === k); assert.equal(own.length, 1, `${k}: ${JSON.stringify(own)}`); - assert.equal(own[0].at, cueTime(firstLanding(v), 30)); + assert.equal(own[0].at, cueTime(Math.round(firstLanding(v) * 30) / 30, 30)); assert.deepEqual(own[0].from, { autoAlpha: 0, scale: TALLY_POP.from }); assert.deepEqual(own[0].to, { autoAlpha: 1, scale: 1 }); assert.equal(own[0].dur, TALLY_POP.seconds); assert.equal(own[0].ease, TALLY_POP.ease); // It arrives reading its first count, and the flash fires with it. const n1 = cues.filter((c) => c.k === `${k}.n1`); - assert.equal(n1[0].at, cueTime(firstLanding(v), 30)); + assert.equal(n1[0].at, cueTime(Math.round(firstLanding(v) * 30) / 30, 30)); assert.deepEqual(n1[0].to, { yPercent: 0, autoAlpha: 1 }); - assert.ok(cues.some((c) => c.k === `${k}.flash` && c.at === cueTime(firstLanding(v), 30) && c.to.opacity === 1)); + assert.ok(cues.some((c) => c.k === `${k}.flash` && c.at === cueTime(Math.round(firstLanding(v) * 30) / 30, 30) && c.to.opacity === 1)); assert.ok(!cues.some((c) => c.k === `${k}.n0`), "the 0 is never rolled"); } // PARTLY's second step rolls as ever: 1 out, 2 in, at its landing. - const second = cueTime(stamps.filter((x) => x.verdict === "PARTLY").map((x) => x.landed).sort((a, b) => a - b)[1], 30); + const second = cueTime(Math.round(stamps.filter((x) => x.verdict === "PARTLY").map((x) => x.landed).sort((a, b) => a - b)[1] * 30) / 30, 30); assert.ok(cues.some((c) => c.k === "ty.PARTLY.n1" && c.at === second && c.to.autoAlpha === 0)); assert.ok(cues.some((c) => c.k === "ty.PARTLY.n2" && c.at === second && c.to.autoAlpha === 1)); // Every cue still states the from the one before it left. @@ -342,15 +342,17 @@ test("stampCues: each stamp slams in to land at its `landed`, flashes, and leave assert.deepEqual(init.st0, { autoAlpha: 0, scale: STAMP_POSE.scale, rotation: STAMP_POSE.from }); const of = (k) => cues.filter((c) => c.k === k); const [slam, leave] = of("st0"); - near(slam.at, 16, "slam starts"); - near(slam.at + slam.dur, 16.28, "lands"); + // A stamp's seconds are on the cut's frames (deck.mjs stampsOnFrames): within half a frame. + const nearF = (a, b, msg) => assert.ok(Math.abs(a - b) <= 1 / 60 + 1e-6, `${msg}: ${a} != ${b}`); + nearF(slam.at, 16, "slam starts"); + nearF(slam.at + slam.dur, 16.28, "lands"); assert.deepEqual(slam.to, { autoAlpha: 1, scale: 1, rotation: STAMP_POSE.rest }); - near(leave.at, 19, "leaves"); - near(leave.dur, 0.5, "over the dissolve"); + nearF(leave.at, 19, "leaves"); + nearF(leave.dur, 0.5, "over the dissolve"); assert.deepEqual(leave.from, { autoAlpha: 1, scale: 1 }); - near(of("fl0")[0].at, 16.28, "flash at landing"); + nearF(of("fl0")[0].at, 16.28, "flash at landing"); // Cue times sit on the sub-frame grid (deck.mjs cueTime): within half a step. - assert.ok(Math.abs(of("fl0")[1].at - (16.28 + STAMP_MOTION.flashUp)) <= 1 / 480 + 1e-9, "flash down"); + nearF(of("fl0")[1].at, 16.28 + STAMP_MOTION.flashUp, "flash down"); assert.equal(cues.filter((c) => c.k.startsWith("st")).length, 6); });