Skip to content

Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.

fix(video): every frame a loop path delivers passes a ghost screen read on its own coverage

Soohong Kima381c79f35cd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e88fcd9..357e16a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.
+## Unreleased (v2.43.0)
+
+- **Fix: no loop path delivers a ghost frame unmeasured — `video-cycle-align` takes a clean source frame beside it.** A video model filming a walk held on twos or threes sometimes leaves a frame half drawn between two drawings: a band of part coverage where a leg was and is going. The alignment took such a frame as filmed at its own time, never measured, and a frame RIFE made beside it carried the band and passed — `--between auto` judged a made frame only against its two neighbours (`dark_excess`, `outline_loss`), and a neighbour that is itself the ghost leaves nothing in excess. Now every frame delivered is read on its own coverage (`rife.ghost`: part-covered pixels, alpha 0.1–0.9, in regions at least 5 px thick, over the frame's solid pixels; a ghost over 0.3 %, `interpolation_quality.GHOST_WARN`). The source loop is screened first (`ghost_screen` per loop row and in `cycle_align`: `limit`, `thick_px`, the loop's own `level`, `reads`, and each filmed `ghosts` frame of `cycle.source/`); a loop whose median frame is over the limit is drawn part-covered (a glow, a translucent cape) and is not judged. Under `auto` and `nearest` a time on a filmed ghost takes the frame after it (or before it), a made frame that is a ghost gives way to the nearer source frame (fault `ghost`), and where that nearer frame is the ghost the other frame beside the time is taken; `rife` keeps both, named. Each such cell is listed in `ghost_at` (`at`, `source`, `ghost`, `taken`) with a warning line; a ghost with no clean frame beside it is kept and the line says to film the direction again. A loop already the set's length is screened the same way. Made frames in `smear` carry their `ghost` reading.
+- **The same screen in the other loop paths.** `video-loop` records the screen of the cut it delivers for a walk or run (`ghost_screen` in its report and summary, a `warning:` line per ghost naming `cycle/frame-NNN.png`): a loop delivered as cut, never aligned, shows its ghost. The jump repair rejects a proposal that is a ghost, its rounds' `original` and `proposal` carrying `ghost`. `video-loop-compare` and `video-loop-repair` keep their versioned `rife.smear` measures and do not read it. Not seen by the screen: a made frame that blends two drawings inside one silhouette with its outline whole — no part coverage to read.
+- **`tests/video/test_ghost_screen.py`** draws outlined legs with a band of 0.3 coverage between the feet: the measure reads the band and not a softened edge; the alignment takes the clean frame beside a ghost at a whole time and beside a made frame that carries one, keeps it named under `rife` or with no clean frame beside it, screens a loop already that long and leaves a loop drawn part-covered as before; `video-loop` names the ghost in its cut; the jump repair rejects a ghost proposal; and through the real RIFE, where installed, no resampled cell carries the filmed ghost.
+
## v2.42.0 - A set's directions on one sheet, standing on one ground line; a loop whose strip as cut is missing is refused by name
- **New `sprite-gen video-set-sheet`: the directions of one set on one sheet, standing on one ground line.** Each direction is cut on its own and a strip is the union of its own cycle's bodies, so laid side by side the directions stand at different heights and cell sizes. `video-set-sheet --loop-dir <dir> --view <view> …` (the views as `video-cycle-align` takes them; a strip turned over to face the other way is a direction like any other) writes `<name>.sheet.png` and `<name>.sheet.json`: a row per direction in the compass order S, SW, W, NW, N, NE, E, SE whatever order the loops are given in, a frame a column; one cell that holds every pixel of every cell of every direction, centred on the pivot each strip declares (`anchor`) or else its bottom centre, so every cell's pivot is its bottom centre; one ground line, `baseline_y`, the lowest body pixel (alpha 8 and over, as `video-loop` reads a body) of any cell — a fainter pixel, a soft shadow, is kept in the cell below the line and is no body — (a direction whose strip leaves room under its feet stands that much above it, as cut: `body_bottom_y`); and every row as cut, pixel for pixel — nothing is scaled direction by direction, one size across a set is `video-loop --body-height`'s. `--center <still>` stands a transparent still (the set's base) with its body on the same line at the rows' standing height (the median of their `body_h`, against the still's own as `video-loop` reads one), centred, in `<name>.center.png`. Loops of different lengths, in frames or frame time, are laid all the same, the shorter rows' last cells empty, with `same_length: false` and a warning. The record carries `order`, `columns`, `cell_w`, `cell_h`, `baseline_y`, `anchor`, `same_length`, per row its `code`, `view`, `frames`, `delay_ms`, strip `name`, `input`, `strip_sha256`, `body_h` and `body_bottom_y`, and the centre's `png`, `input`, `sha256`, `standing_h`, `body_h`, `scale` and `box`. A direction given twice, a front or back view with a side, a `--view` count other than the loops', a loop directory without one strip and its sidecar, an opaque centre still and a centre beside rows without `body_h` are refused before anything is written. The loop directories are only read. Every other verb writes what 2.41.0 writes. [docs/video-pipeline.md](docs/video-pipeline.md#7-one-sheet-for-a-set--video-set-sheet).
diff --git a/SKILL.md b/SKILL.md
index 36fe557..d39fe7d 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -142,4 +142,4 @@ Scene creation consumes finished assets and remains optional. Asset metadata own
## Contracts and advanced tools
-[run-contract](docs/run-contract.md) owns numeric requests, run layout, atomic publication and curated exports. [architecture](docs/architecture.md) explains domain ownership. [docs index](docs/README.md) lists every specialized feature and QA procedure. `sprite-gen --help` derives the command map from the package catalog. Never replace an engine stage — extraction, the loop cut, set alignment, loop repair — with a script of your own while presenting the result as a pipeline output. Where a stage's result is wrong, use the engine's own options first (another cut with `video-loop --max-len` or `--cycle fixed`, `video-cycle-align --length`, `--between auto` (the default: a made frame that melted takes the nearer source frame) or `--between nearest`, or `--cycles <loop>=<k>` once you have counted a suspect loop's strides, or `--foot <loop>=left|right` (`video-set --align-foot <item>=…`) once you have looked at the first strike frame of a loop the report lists under `unnamed_feet`), keep the engine's result as the comparison, report the defect against the engine, and name in the delivery each stage done by hand and why. A new clip is for what no stage can reach: the drawing, the motion itself, a clip that holds no whole cycle ([loop-review](docs/loop-review.md)) — and a clip the engine names for one: when the alignment report's `retake` lists a loop (reason `held-drawings`: the cycle cut from its clip shows each drawing for two or three frames, the set's length leaves it at under 13 drawings a second, and frames between its drawings could not be made, so the loop halts there), run the engine verbs first as above, then film that direction again and align the set anew rather than hand-painting the gap; tell the user what the reason was and that a new take usually fixes it ([loop-repair](docs/loop-repair.md) section 4). `video-loop --anchor motion-auto` already cuts a walk two steps long — one cycle — where a staff held above the head closes only there (`cycle.steps`, `strip.json` `steps: 2`; `video-cycle-align` aligns it as the one cycle it is). When its report's `cycle.step_screen` says `suspect` (a slow walk cut one step long), or `video-cycle-align` stops on a loop under `one_step`, count the steps in the loop (how often each foot lands) and cut it again with `video-loop --steps 1` if it is one step (`--steps 2` if it is two); never stretch or double it by hand. When `video-loop` warns that the top of the silhouette jumps into the loop's first frame (a staff or flag held above the head, swinging on its own beat), or that the held part does not close at the wrap below its top, that part does not close at the cut: look at the loop, and try `--cycle fixed` with another cut before filming again; a walk refused for no cycle names in its report's `cycle.candidates` the windows it measured, best first, for a cut you must deliver anyway ([loop-repair](docs/loop-repair.md) section 3, "The seam pop" and "The held side").
+[run-contract](docs/run-contract.md) owns numeric requests, run layout, atomic publication and curated exports. [architecture](docs/architecture.md) explains domain ownership. [docs index](docs/README.md) lists every specialized feature and QA procedure. `sprite-gen --help` derives the command map from the package catalog. Never replace an engine stage — extraction, the loop cut, set alignment, loop repair — with a script of your own while presenting the result as a pipeline output. Where a stage's result is wrong, use the engine's own options first (another cut with `video-loop --max-len` or `--cycle fixed`, `video-cycle-align --length`, `--between auto` (the default: a made frame that melted or carries a ghost takes the nearer source frame, and a filmed ghost frame a clean one beside it) or `--between nearest`, or `--cycles <loop>=<k>` once you have counted a suspect loop's strides, or `--foot <loop>=left|right` (`video-set --align-foot <item>=…`) once you have looked at the first strike frame of a loop the report lists under `unnamed_feet`), keep the engine's result as the comparison, report the defect against the engine, and name in the delivery each stage done by hand and why. A new clip is for what no stage can reach: the drawing, the motion itself, a clip that holds no whole cycle ([loop-review](docs/loop-review.md)) — and a clip the engine names for one: when the alignment report's `retake` lists a loop (reason `held-drawings`: the cycle cut from its clip shows each drawing for two or three frames, the set's length leaves it at under 13 drawings a second, and frames between its drawings could not be made, so the loop halts there), run the engine verbs first as above, then film that direction again and align the set anew rather than hand-painting the gap; tell the user what the reason was and that a new take usually fixes it ([loop-repair](docs/loop-repair.md) section 4). `video-loop --anchor motion-auto` already cuts a walk two steps long — one cycle — where a staff held above the head closes only there (`cycle.steps`, `strip.json` `steps: 2`; `video-cycle-align` aligns it as the one cycle it is). When its report's `cycle.step_screen` says `suspect` (a slow walk cut one step long), or `video-cycle-align` stops on a loop under `one_step`, count the steps in the loop (how often each foot lands) and cut it again with `video-loop --steps 1` if it is one step (`--steps 2` if it is two); never stretch or double it by hand. When `video-loop` warns that the top of the silhouette jumps into the loop's first frame (a staff or flag held above the head, swinging on its own beat), or that the held part does not close at the wrap below its top, that part does not close at the cut: look at the loop, and try `--cycle fixed` with another cut before filming again; a walk refused for no cycle names in its report's `cycle.candidates` the windows it measured, best first, for a cut you must deliver anyway ([loop-repair](docs/loop-repair.md) section 3, "The seam pop" and "The held side").
diff --git a/docs/loop-repair.md b/docs/loop-repair.md
index 42263af..bec7466 100644
--- a/docs/loop-repair.md
+++ b/docs/loop-repair.md
@@ -179,12 +179,14 @@ Blocked targets are skipped while independent candidates remain. Scores are re-r
after adoption; a rejected target is never retried in that run. The circular last/first
adjacency rule and call budget still apply. The shared `interpolation_quality` policy
is the same one used by cycle alignment: `dark_excess > 0.001` or
-`outline_loss > 0.05` rejects a proposal. An empty proposal is also rejected.
+`outline_loss > 0.05` rejects a proposal, and so does a proposal that is a ghost on its own
+coverage (`ghost` over 0.003, read where the loop's ghost screen reads it, section 4). An empty
+proposal is also rejected.
The original middle frame is retained, not a duplicate of either neighbour.
The report's `jump_repair` carries `replaced` (cycle frame indices), `attempts`,
`blocked` targets, and each round's step, target, score, whole/hair parts,
-`original` and `proposal` measurements, `faults`, and `outcome` (`accepted` or
+`original` and `proposal` measurements (with each one's `ghost`), `faults`, and `outcome` (`accepted` or
`rejected`). It also records `score_max_before` / `score_max_after`, why it stopped,
and which interpolator made the proposals. Rejection is not overall quality failure
or success: original drawing changes and normal gait motion can remain.
@@ -543,22 +545,24 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
- **Length**: the median of the set's own lengths (`--length` overrides). The median is the
length that needs the fewest made frames across the set; a loop already that long is not
- touched.
+ resampled — every frame is its own, and only the ghost screen (below) may give one way.
- **Resample, offset 0**: frame k of a loop of L frames resampled to L* is the source at time
k·L/L*, cyclic. A time within 0.03 of a source frame takes that frame as filmed; only a time
between two frames is made, by RIFE at that fraction (section 1). An offset of half a frame,
which would remake every frame, is not offered (section 2).
- **Between two source frames** (`--between`): `auto` (default) makes the frame with RIFE,
measures it (below) and keeps it unless it has a fault, where the nearer source frame is taken
- instead and named; `rife` keeps every made frame and names the faulty ones; `nearest` takes the
- nearer source frame every time, so nothing is made and no RIFE is needed, and the motion keeps
+ instead and named — the other one beside it where the nearer is a filmed ghost (below); `rife`
+ keeps every made frame and names the faulty ones; `nearest` takes the nearer source frame every
+ time (the other where the nearer is a filmed ghost), so nothing is made and no RIFE is needed, and the motion keeps
the filmed frames at up to half a frame off their time (a loop stretched longer shows a frame
twice, which the GIF and WebP hold as one frame of twice the delay). `video-set` passes
`--align-between`. `auto` runs RIFE for every frame between two source frames, as `rife` does,
and needs it installed the same way.
- **Smear and melt, per made frame**: `cycle_align.smear` lists every frame RIFE made, with its
- `method` — `rife` (kept) or `nearest` (the nearer source frame taken instead) — its `faults`,
- and what it has that neither source frame beside it has (`rife.smear`):
+ `method` — `rife` (kept) or `nearest` (a source frame beside it taken instead) — its `faults`,
+ its own ghost reading (`ghost`, below; `null` where the screen does not read the loop), and what
+ it has that neither source frame beside it has (`rife.smear`):
- `dark_excess`: dark pixels (luma under 70/255) inside the body beyond the darker neighbour's
count, as a fraction of its solid pixels — a black smear raises it, a dark part that only
moved (a hat, a watch) does not. Over 0.1 % it is the fault `smear`.
@@ -569,11 +573,14 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
Over 5 % it is the fault `outline`. A step the flow follows keeps its outline; a figure drawn
without outlines loses none against neighbours that have none, and is not judged by it.
- `partial_excess`: part-covered pixels beyond the more ragged neighbour's, as a fraction of
- its solid pixels. Reported, not judged: a melted frame and a clean one read alike on it.
+ its solid pixels. Reported, not judged: a melted frame and a clean one read alike on it, and a
+ frame made beside a filmed ghost carries the ghost without adding to it — the ghost screen
+ reads part coverage on the frame alone.
Every fault is a line in the report's `warnings` (and on stderr, and in `video-set`'s
`warnings`), whichever `--between`: under `auto` it says the nearer source frame was taken
- there; under `rife` that the frame is kept, to look at in `cycle/`. The report counts the
+ there (or the other, the nearer being a filmed ghost); under `rife` that the frame is kept, to
+ look at in `cycle/`. The report counts the
frames kept from RIFE (`made_by_rife`) and those replaced (`replaced`); a loop row lists both
(`made_at`, `nearest_at`).
@@ -585,6 +592,46 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
short step at every fraction and 32 % for the melted frame. The 5 % line is where a frame stops
reading as a little soft at a foot and starts reading as melted; it is a reference, not a
measured optimum, and frames near it are worth a look either way.
+- **The ghost screen, every frame delivered** (`interpolation_quality.ghost_screen`, `rife.ghost`):
+ a video model filming a walk held on twos or threes sometimes leaves a frame half way between two
+ drawings — a band of part coverage where a leg was and is going.
+ Taken at its own time it was delivered as filmed, never measured; a frame RIFE made beside it
+ carried the band, and measured against that neighbour it added nothing. So every frame the
+ alignment delivers is read on its own coverage, not against its neighbours:
+ - `ghost`: part-covered pixels (alpha 0.1–0.9) inside regions at least **5 px** thick
+ (`rife.GHOST_THICK`; an antialiased edge or a keyed strand of hair is a pixel or two wide and
+ erodes away), as a fraction of the frame's solid pixels. Over **0.3 %**
+ (`interpolation_quality.GHOST_WARN`) the frame is a ghost: on a made frame the fault `ghost`.
+ - The screen reads the loop as filmed (`cycle.source/`): `ghost_screen` per loop row and in
+ `cycle_align` — `limit`, `thick_px`, the loop's own `level` (its median frame's reading), `reads`,
+ and `ghosts` (each `frame` of `cycle.source/` over the limit, with its reading). A loop whose
+ level is itself over the limit is drawn part-covered — a glow, a translucent cape — and is not
+ judged (`reads: false`, with `why`): every made frame's `ghost` is `null`, nothing gives way.
+ - A time on a filmed ghost takes the source frame after it, or the one before it where that one
+ is a ghost too, under `auto` and `nearest`; a made frame that is a ghost gives way like any
+ faulty one, to the nearer source frame, or to the other beside its time where the nearer is a
+ filmed ghost. `rife` keeps both, named. Where both frames beside it are ghosts the ghost is
+ kept, named, and the line says to film the direction again. A loop already the set's length
+ is screened the same way.
+ - Each cell where a filmed ghost would have been delivered is listed in `ghost_at` (`at`, the
+ ghost `source` as a frame of `cycle.source/`, its `ghost` reading, and the frame `taken` — the
+ ghost itself where it was kept), with a line in `warnings` ("source frame 5 is a filmed ghost
+ (…), so source frame 6 beside it was taken there"). `cells_from` says the same per cell.
+ - Where 0.3 % sits: set by eye on drawn walks, between the half-drawn frames (and the frames
+ made beside them) that a person sees as ghosts, which read well above it, and the frames seen
+ as clean, which read well under it; a sliver of the same kind, too small to see at a strip's
+ size, reads under it too. On the synthetic legs of `tests/video/test_ghost_screen.py` a keyed
+ edge softened over two or three pixels reads 0.04 % and a band of 0.3 coverage between the
+ feet 2 %. It is a reference, not a measured optimum, and a frame near it is worth a look either way.
+ - What it does not see: a frame RIFE made that blends two drawings inside one silhouette — the
+ near and far boots cross-faded while the outline stays whole — has no part coverage to read
+ and is not a ghost here.
+ - `video-loop` records the same screen of the cut it delivers, for a walk or run
+ (`ghost_screen` in its report, and a `warning:` line per ghost naming `cycle/frame-NNN.png`):
+ a loop delivered as cut — one direction, never aligned — shows its ghost, and the alignment
+ screens `cycle.source/` again and takes a clean frame beside it. The jump repair (section 2)
+ rejects a proposal that is a ghost. `video-loop-compare` and `video-loop-repair` keep their own
+ versioned measures (`rife.smear`, [loop comparison](loop-comparison.md)) and do not read it.
- **What `auto` costs**: a frame replaced shows the nearer source frame, so the motion there
steps as filmed, up to half a frame off its time, and the loop shows fewer distinct drawings a
second than `rife` — but no melted one. A clip drawn on twos has a long step between drawings
@@ -718,7 +765,7 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
rewritten at the loop's own cell rules (`cell_height_cap`, body-height target, anchor), at the
loop's frame rate, so the aligned cycle lasts L*/fps seconds. `strip.json` gains
`cycle_align` (`from`, `to`, `between`, `taken`, `made_by_rife`, `made_at`, `smear` and/or
- `nearest_at`, `drawings`, `retake`, `turned_by`, `turned_on`, `view`, `start_foot`, `start_foot_source`, `strikes`, the seam ratio of the rebuilt
+ `nearest_at`, `ghost_screen`, `ghost_at`, `drawings`, `retake`, `turned_by`, `turned_on`, `view`, `start_foot`, `start_foot_source`, `strikes`, the seam ratio of the rebuilt
cells, `cells_from`, `origin`, and the re-verified GIF/WebP).
- **Where every cell is from**: `cycle_align.cells_from` holds, per cell of the rebuilt strip,
`{"source": i}` — frame i of `cycle.source/`, taken as filmed (a turn, a snap, or the nearer
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index ac9bc79..ab504d2 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -379,8 +379,10 @@ default): one `--loop-dir` per direction of the same walk or run, one `--view` e
order, so that every loop starts as the same own foot lands wherever its view can tell the feet
apart. A frame that falls between two source frames is made by RIFE, and the command fails where one
is needed and RIFE is not installed; `--between nearest` makes none. A frame RIFE made that melted
-(lost its outline where legs crossed too far) is replaced by the nearer source frame and named
-(`--between auto`, the default; [loop repair](loop-repair.md) section 4). A loop whose view cannot
+(lost its outline where legs crossed too far) or carries a ghost (a band of part coverage) is
+replaced by the nearer source frame and named, and a filmed frame left half drawn between two
+drawings gives way to a clean source frame beside it (`--between auto`, the default; [loop
+repair](loop-repair.md) section 4, "The ghost screen"). A loop whose view cannot
tell its feet apart — or tells them apart by too small a margin (`foot_why` `low-margin`) — starts
on its larger strike and is listed under the report's `unnamed_feet` with its two strike frames in
`cycle/`: look at the first, say which own foot lands there, and run the same alignment again with
diff --git a/sprite_gen/video/align.py b/sprite_gen/video/align.py
index ca6325b..d62a618 100644
--- a/sprite_gen/video/align.py
+++ b/sprite_gen/video/align.py
@@ -6,14 +6,18 @@ set measured 16 to 27 frames). A game that turns a character mid-stride wants ev
to be the same number of frames and to start on the same step. So every loop of the set is
resampled to the set's median length L*: frame k of the new loop is the source loop at time
k·L/L* (cyclic, offset 0), so a time that lands on a source frame takes that frame as filmed
-and only the times between two frames are made by RIFE — each kept unless it smeared or lost its
-outline, where the nearer source frame is taken instead (`--between auto`, the default; `rife`
-keeps every made frame and warns, `nearest` makes none). Then each loop is turned to start as a
-heel lands — read off the stride, the lowest row or the body's top line (`foot_strike`), never off
-the frame's top edge, which a long ear owns. docs/loop-repair.md section 4.
+and only the times between two frames are made by RIFE — each kept unless it smeared, lost its
+outline or carries a ghost, where the nearer source frame is taken instead (`--between auto`, the
+default; `rife` keeps every made frame and warns, `nearest` makes none). Every frame delivered,
+filmed or made, passes the ghost screen (`interpolation_quality.ghost_screen`): a filmed frame half
+drawn between two drawings gives way to a clean source frame beside it, named in `ghost_at`. Then
+each loop is turned to start as a heel lands — read off the stride, the lowest row or the body's
+top line (`foot_strike`), never off the frame's top edge, which a long ear owns.
+docs/loop-repair.md section 4.
Every frame between two source frames softens a little, so the length is the median (the one
-that needs the fewest made frames across the set), and a loop already that long is not touched.
+that needs the fewest made frames across the set), and a loop already that long is not resampled
+(its frames still pass the ghost screen).
A loop whose cut holds each drawing for two or three frames (`held_drawings`, sprite_gen/video/
held.py), that the length leaves at under RETAKE_DRAWINGS_MIN drawings a second, with frames
@@ -89,7 +93,7 @@ from sprite_gen.video import legs as legs_mod
from sprite_gen.video import loop as loop_mod
from sprite_gen.video import period as period_mod
from sprite_gen.video import rife as rife_mod
-from sprite_gen.video.interpolation_quality import SMEAR_WARN, OUTLINE_WARN, faults
+from sprite_gen.video.interpolation_quality import SMEAR_WARN, OUTLINE_WARN, faults, ghost_screen
SNAP = 0.03 # a sample time within this of a source frame takes that frame
SOURCE_DIR = loop_mod.CYCLE_SOURCE_DIR # removed by video-loop whenever it cuts the loop again
@@ -190,48 +194,67 @@ def resample(frames: list[Image.Image], length: int, interpolate: rife_mod.Inter
[i, j], "t": t}` for one made between two.
A time between two source frames is made by `interpolate`, with what it added and the outline it
- lost measured (`rife.smear`) and judged (`faults`); `between` auto keeps a made frame with no
- fault and takes the nearer source frame where it has one, rife keeps every made frame, nearest
- makes none and takes the nearer source frame (the motion keeps the filmed frames at up to half a
- frame off their time). Every made frame is listed in `smear` with its `method`: rife (kept) or
- nearest (the nearer source frame taken instead)."""
+ lost measured (`rife.smear`), its own ghost read (`rife.ghost`), and judged (`faults`); `between`
+ auto keeps a made frame with no fault and takes the nearer source frame where it has one, rife
+ keeps every made frame, nearest makes none and takes the nearer source frame (the motion keeps the
+ filmed frames at up to half a frame off their time). Every made frame is listed in `smear` with
+ its `method`: rife (kept) or nearest (a source frame beside it taken instead).
+
+ Every frame delivered passes the ghost screen (`ghost_screen`, the source loop's, recorded as it is):
+ a source frame it names is not taken under auto or nearest — at a time on it, the frame after it is,
+ or the one before it; where it is the nearer frame, the other beside the time is — and rife keeps it.
+ Each such cell is listed in `ghost_at`: `at`, the ghost `source` and its reading, and the frame
+ `taken` (the ghost itself where rife kept it, or where neither frame beside it is clean)."""
count = len(frames)
if length < 2:
raise ValueError(f"cycle length {length} is too short")
if between not in BETWEEN:
raise ValueError(f"between must be one of {', '.join(BETWEEN)}, not {between!r}")
+ screen = ghost_screen(frames)
+ ghosts = {g["frame"]: g["ghost"] for g in screen["ghosts"]}
out: list[Image.Image] = []
made_at: list[int] = []
nearest_at: list[int] = []
smears: list[dict[str, Any]] = []
+ ghost_at: list[dict[str, Any]] = []
+
+ def clean(k: int, first: int, other: int) -> int:
+ """`first` where the screen passes it, else `other` where it passes that (rife takes `first`
+ as it is); each ghost passed over or taken is listed in `ghost_at`."""
+ if first not in ghosts:
+ return first
+ taken_ = first if between == "rife" or other in ghosts else other
+ ghost_at.append({"at": k, "source": first, "ghost": ghosts[first], "taken": taken_})
+ return taken_
+
for k in range(length):
t = k * count / length
i = int(np.floor(t))
frac = t - i
nearer = (i + (frac >= 0.5)) % count
- if frac < SNAP:
- taken: dict[str, Any] = {"source": i % count}
- elif frac > 1 - SNAP:
- taken = {"source": (i + 1) % count}
+ beside = (i + (frac < 0.5)) % count # the other frame beside the time
+ if frac < SNAP or frac > 1 - SNAP: # on a source frame (the nearer); a ghost there gives way to the frame after it, else before
+ after, before = (nearer + 1) % count, (nearer - 1) % count
+ taken: dict[str, Any] = {"source": clean(k, nearer, before if after in ghosts else after)}
elif between == "nearest":
- taken = {"source": nearer}
+ taken = {"source": clean(k, nearer, beside)}
nearest_at.append(k)
else:
if interpolate is None:
raise ValueError(f"frame {k} of {length} falls between source frames and no interpolator is available")
a, b = frames[i % count], frames[(i + 1) % count]
made = interpolate(a, b, frac)
- measure = rife_mod.smear(made, a, b)
+ measure = {**rife_mod.smear(made, a, b), "ghost": rife_mod.ghost(made) if screen["reads"] else None}
wrong = faults(measure)
keep = between == "rife" or not wrong
- taken = {"between": [i % count, (i + 1) % count], "t": round(frac, 4)} if keep else {"source": nearer}
+ taken = {"between": [i % count, (i + 1) % count], "t": round(frac, 4)} if keep else {"source": clean(k, nearer, beside)}
(made_at if keep else nearest_at).append(k)
smears.append({"at": k, "method": "rife" if keep else "nearest", **measure, "faults": wrong})
out.append(made if "between" in taken else frames[taken["source"]])
if cells_from is not None:
cells_from.append(taken)
facts: dict[str, Any] = {"from": count, "to": length, "between": between, "taken": length - len(made_at),
- "made_by_rife": len(made_at), "made_at": made_at}
+ "made_by_rife": len(made_at), "made_at": made_at, "ghost_screen": screen, "ghost_at": ghost_at}
if between != "rife":
facts["nearest_at"] = nearest_at
if between != "nearest":
@@ -662,18 +685,36 @@ def _unnamed_foot(row: dict[str, Any]) -> dict[str, Any]:
"settle": [f"--foot {row['dir']}={s}" for s in handed_mod.SIDES]}
-def _fault_line(name: str, m: dict[str, Any]) -> str:
- """A made frame's faults, in words, and what became of it."""
+def _ghost_words(reading: float) -> str:
+ return f"a part-covered band over {100 * reading:.2f} % of its body, at least {rife_mod.GHOST_THICK} px thick"
+
+
+def _fault_line(name: str, m: dict[str, Any], *, other_side: bool = False) -> str:
+ """A made frame's faults, in words, and what became of it; `other_side` where the nearer source
+ frame is a filmed ghost and the other beside it was taken (`_ghost_line` names both)."""
what = [*([f"has {100 * m['dark_excess']:.2f} % more dark pixels inside the body than either source frame beside it — a smear"]
if "smear" in m["faults"] else []),
*([f"lost its outline on {100 * m['outline_loss']:.2f} % of its edge beyond either source frame beside it — "
- "a melted or ghost limb"] if "outline" in m["faults"] else [])]
+ "a melted or ghost limb"] if "outline" in m["faults"] else []),
+ *([f"carries {_ghost_words(m['ghost'])} — a ghost"] if "ghost" in m["faults"] else [])]
if m["method"] == "nearest":
- return f"{name}: frame {m['at']}: RIFE's frame " + "; ".join(what) + ", so the nearer source frame was taken there (--between auto)"
+ return (f"{name}: frame {m['at']}: RIFE's frame " + "; ".join(what)
+ + (", so the source frame on its other side was taken there, the nearer being a filmed ghost (--between auto)"
+ if other_side else ", so the nearer source frame was taken there (--between auto)"))
return (f"{name}: frame {m['at']} (made by RIFE) " + "; ".join(what)
+ "; see it in cycle/, or align with --between auto (the nearer source frame there) or --between nearest")
+def _ghost_line(name: str, g: dict[str, Any], between: str) -> str:
+ """A cell where a filmed ghost frame would have been delivered, and what was instead."""
+ line = f"{name}: frame {g['at']}: source frame {g['source']} is a filmed ghost ({_ghost_words(g['ghost'])})"
+ if g["taken"] != g["source"]:
+ return line + f", so source frame {g['taken']} beside it was taken there"
+ if between == "rife":
+ return line + "; kept (--between rife) — see it in cycle/, or align with --between auto or nearest (a clean frame beside it there)"
+ return line + ", and so are the frames beside it; kept — film this direction again"
+
+
def align_set(loop_dirs: list[Path], *, length: int | None = None, interpolate: rife_mod.Interpolate | None = None,
report_path: Path | None = None, between: str = DEFAULT_BETWEEN, views: list[str | None] | None = None,
start_foot: str = START_FOOT, multi_cycle: str = "fail", cycles: dict[str, int] | None = None,
@@ -826,6 +867,10 @@ def align_set(loop_dirs: list[Path], *, length: int | None = None, interpolate:
record["nearest_at"] = sorted((k - start) % target for k in facts["nearest_at"])
if "smear" in facts:
record["smear"] = sorted(({**m, "at": (m["at"] - start) % target} for m in facts["smear"]), key=lambda m: m["at"])
+ # the screen's frames and the ghosts passed over as frames of cycle.source/, each cell where it now stands
+ record["ghost_screen"] = {**facts["ghost_screen"], "ghosts": [{**g, "frame": index[g["frame"]]} for g in facts["ghost_screen"]["ghosts"]]}
+ record["ghost_at"] = sorted(({**g, "at": (g["at"] - start) % target, "source": index[g["source"]], "taken": index[g["taken"]]}
+ for g in facts["ghost_at"]), key=lambda g: g["at"])
provenance = [{"source": index[p["source"]]} if "source" in p else {"between": [index[j] for j in p["between"]], "t": p["t"]}
for p in provenance]
aligned.append((out[start:] + out[:start], record, provenance[start:] + provenance[:start]))
@@ -836,10 +881,12 @@ def align_set(loop_dirs: list[Path], *, length: int | None = None, interpolate:
rows.append({"dir": str(d), "name": meta_path.name[: -len(".strip.json")],
**{k: v for k, v in record.items() if k not in ("gif", "webp", "origin")},
"strip": {k: merged[k] for k in ("frames", "w", "h", "body_h", "delay_ms")}})
- warnings = [_fault_line(r["name"], m) for r in rows for m in r.get("smear", []) if m["faults"]]
+ warnings = [_fault_line(r["name"], m, other_side=any(g["at"] == m["at"] and g["taken"] != g["source"] for g in r["ghost_at"]))
+ for r in rows for m in r.get("smear", []) if m["faults"]]
retakes = [{"dir": r["dir"], "name": r["name"], **r["retake"]} for r in rows if r["retake"]]
# A loop to film again is named by its directory where two loops share a strip name (each `walk`).
shared = len({r["name"] for r in rows}) < len(rows)
+ warnings += [_ghost_line(r["dir"] if shared else r["name"], g, between) for r in rows for g in r["ghost_at"]]
warnings = cycle_warnings + [_retake_line(r["dir"] if shared else r["name"], r["retake"]) for r in rows if r["retake"]] + warnings
unnamed = [_unnamed_foot(r) for r in rows if r["start_foot"] is None]
if len(rows) > 1 and views is None and unnamed:
@@ -890,10 +937,12 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:
parser.add_argument("--state", help="the set's motion state (walk, run), for loops cut before video-loop wrote it in the strip metadata: "
"its gait floor is the shortest cycle the screen looks for")
parser.add_argument("--between", choices=BETWEEN, default=DEFAULT_BETWEEN,
- help="a time between two source frames: auto (default) makes that frame with RIFE and keeps it unless it smeared "
- "or lost its outline (a melted limb), where the nearer source frame is taken and named in the warnings; rife "
- "keeps every made frame and warns on those; nearest takes the nearer source frame — nothing made, no RIFE "
- "needed, the motion up to half a frame off its time. Every made frame is measured in the report (`smear`)")
+ help="a time between two source frames: auto (default) makes that frame with RIFE and keeps it unless it smeared, "
+ "lost its outline (a melted limb) or carries a ghost (a part-covered band), where the nearer source frame is "
+ "taken and named in the warnings; rife keeps every made frame and warns on those; nearest takes the nearer "
+ "source frame — nothing made, no RIFE needed, the motion up to half a frame off its time. Every made frame is "
+ "measured in the report (`smear`); under auto and nearest a filmed ghost frame gives way to a clean source "
+ "frame beside it (`ghost_at`)")
def parse_cycles(values: list[str]) -> dict[str, int]:
diff --git a/sprite_gen/video/interpolation_quality.py b/sprite_gen/video/interpolation_quality.py
index cf7fe6e..5c7dd41 100644
--- a/sprite_gen/video/interpolation_quality.py
+++ b/sprite_gen/video/interpolation_quality.py
@@ -1,15 +1,43 @@
# SPDX-License-Identifier: Apache-2.0
-"""The shared acceptance policy for RIFE frames in repair and cycle alignment.
+"""The shared acceptance policy for the frames repair and cycle alignment deliver.
-Measurements live in ``rife.smear``; these are the existing alignment bounds,
-also applied before replacing a filmed middle frame during jump repair.
+Measurements live in ``rife`` (``smear``, ``ghost``); these are the existing alignment bounds,
+also applied before replacing a filmed middle frame during jump repair, and the ghost screen
+every frame a loop path delivers passes, filmed or made (docs/loop-repair.md section 4).
"""
+from PIL import Image
+
+from sprite_gen._deps import np
+from sprite_gen.video import rife
+
SMEAR_WARN = 0.001
OUTLINE_WARN = 0.05
+# A frame whose part-covered regions at least rife.GHOST_THICK pixels thick come to more than this
+# share of its solid pixels is a ghost: set by eye on drawn walks, between the half-drawn frames a video
+# model leaves between two held drawings (and the frames made beside them) and the frames seen as clean
+# (docs/loop-repair.md section 4).
+GHOST_WARN = 0.003
-def faults(measure: dict[str, float]) -> list[str]:
- """Smear inside the body or outline loss beyond both neighbours."""
+def faults(measure: dict[str, float | None]) -> list[str]:
+ """Smear inside the body or outline loss beyond both neighbours, and a ghost on the frame's
+ own coverage where the measure carries its reading (`ghost`; None where the screen does not
+ read the loop, `ghost_screen`)."""
return ([*(["smear"] if measure["dark_excess"] > SMEAR_WARN else []),
- *(["outline"] if measure["outline_loss"] > OUTLINE_WARN else [])])
+ *(["outline"] if measure["outline_loss"] > OUTLINE_WARN else []),
+ *(["ghost"] if (measure.get("ghost") or 0.0) > GHOST_WARN else [])])
+
+
+def ghost_screen(frames: list[Image.Image]) -> dict:
+ """The ghost screen of a loop as filmed: its frames whose `rife.ghost` is over GHOST_WARN
+ (`ghosts`, each `frame` and its reading) and the loop's own level, the median reading. A loop
+ whose level is over it is drawn part-covered — a glow, a translucent cape — and the screen does
+ not read it (`reads` false, with `why`): its ghosts cannot be told from its drawing."""
+ readings = [rife.ghost(f) for f in frames]
+ level = round(float(np.median(readings)), 5) if readings else 0.0
+ record = {"limit": GHOST_WARN, "thick_px": rife.GHOST_THICK, "level": level, "reads": level <= GHOST_WARN}
+ if not record["reads"]:
+ return {**record, "ghosts": [], "why": f"the loop is drawn part-covered: its median frame reads {level:.5f}, over the "
+ f"{GHOST_WARN} that names a ghost"}
+ return {**record, "ghosts": [{"frame": i, "ghost": v} for i, v in enumerate(readings) if v > GHOST_WARN]}
diff --git a/sprite_gen/video/loop.py b/sprite_gen/video/loop.py
index af7cbdd..8d2cf2d 100644
--- a/sprite_gen/video/loop.py
+++ b/sprite_gen/video/loop.py
@@ -53,6 +53,7 @@ from sprite_gen.video import legs as legs_mod
from sprite_gen.video import period as period_mod
from sprite_gen.video import repair as repair_mod
from sprite_gen.video import rife as rife_mod
+from sprite_gen.video.interpolation_quality import ghost_screen
from sprite_gen.video import evidence as evidence_mod
from sprite_gen.video.frames import drop_specks
@@ -1345,6 +1346,14 @@ def run_loop(
raise SystemExit(error)
for line in warnings:
print(f"video-loop: warning: {line} (reference bound; the loop is kept — docs/loop-repair.md)", file=sys.stderr)
+ # The ghost screen of the cut as delivered (docs/loop-repair.md section 4): a loop delivered as cut,
+ # never aligned, carries a filmed ghost as it is, so each is named here; `video-cycle-align` screens
+ # its source again and takes a clean frame beside it.
+ report_base["ghost_screen"] = ghost_screen(frames)
+ for g in report_base["ghost_screen"]["ghosts"]:
+ print(f"video-loop: warning: frame {g['frame']} of the cut (cycle/frame-{g['frame']:03d}.png) carries a part-covered band "
+ f"over {100 * g['ghost']:.2f} % of its body, at least {rife_mod.GHOST_THICK} px thick — a filmed ghost; delivered as cut "
+ "it shows, and video-cycle-align takes a clean frame beside it (docs/loop-repair.md)", file=sys.stderr)
cycle_dir.mkdir(parents=True, exist_ok=True)
for old in cycle_dir.glob("frame-*.png"):
old.unlink()
@@ -1548,6 +1557,8 @@ def run(**kwargs: object) -> int:
summary["cycle"]["coverage"] = payload["cycle"]["coverage"]
if "step_screen" in payload["cycle"]:
summary["cycle"]["step_screen"] = payload["cycle"]["step_screen"]
+ if payload.get("ghost_screen", {}).get("ghosts"):
+ summary["ghost_screen"] = payload["ghost_screen"]
if payload.get("jump_repair", {}).get("replaced"):
summary["jump_repair"] = {k: payload["jump_repair"][k] for k in ("replaced", "score_max_before", "score_max_after")}
summary["strip"] = {k: payload["strip"][k] for k in ("path", "frames", "w", "h", "body_h", "delay_ms")}
diff --git a/sprite_gen/video/repair.py b/sprite_gen/video/repair.py
index e249ce3..4179e50 100644
--- a/sprite_gen/video/repair.py
+++ b/sprite_gen/video/repair.py
@@ -20,8 +20,8 @@ from typing import Any
from PIL import Image
from sprite_gen._deps import np
-from sprite_gen.video.rife import Interpolate, smear
-from sprite_gen.video.interpolation_quality import faults
+from sprite_gen.video.rife import Interpolate, ghost, smear
+from sprite_gen.video.interpolation_quality import faults, ghost_screen
# A step this many times the loop's median step (whole body, or the hair behind it) is a jump.
JUMP_RATIO = 1.4
@@ -81,13 +81,15 @@ def repair_jumps(frames: list[Image.Image], interpolate: Interpolate | None, *,
At most `max_frames` calls, and never next to a frame already made: two made frames side by side
are made from each other and melt the legs. A proposal with a shared interpolation-quality
- fault keeps the original middle frame. Blocked and rejected targets do not end the search
+ fault — a ghost too, on its own coverage, where the loop's ghost screen reads it — keeps the
+ original middle frame. Blocked and rejected targets do not end the search
for independent targets. `interpolate` may be None while no jump is
found; it is asked for only when a frame is to be made (a ValueError says so otherwise).
Scores are re-read after each replacement, on the union box of the original loop."""
out = list(frames)
n = len(out)
box = union_box(frames)
+ reads: bool | None = None # whether the ghost screen reads the loop as filmed, once a frame is made
first = jump_scores(out, facing=facing, box=box)
record: dict[str, Any] = {
"ratio": ratio, "max_frames": max_frames, "facing": facing, "hair_box": list(hair_box(facing)),
@@ -134,13 +136,16 @@ def repair_jumps(frames: list[Image.Image], interpolate: Interpolate | None, *,
if made.mode != "RGBA" or made.size != out[j].size:
raise ValueError("repair interpolator must return an RGBA frame of the original size")
attempted.add(j)
- measure = smear(made, a, b)
+ if reads is None:
+ reads = ghost_screen(frames)["reads"]
+ measure = {**smear(made, a, b), "ghost": ghost(made) if reads else None}
wrong = faults(measure)
if not made.getchannel("A").getbbox():
wrong.append("empty")
record["rounds"].append({"step": [k, (k + 1) % n], "target": j, "score": round(score, 4),
"whole": round(float(scores["whole"][k]), 4), "hair": round(float(scores["hair"][k]), 4),
- "original": smear(out[j], a, b), "proposal": measure, "faults": wrong,
+ "original": {**smear(out[j], a, b), "ghost": ghost(out[j]) if reads else None},
+ "proposal": measure, "faults": wrong,
"outcome": "rejected" if wrong else "accepted", **({"replaced": j} if not wrong else {})})
if not wrong:
out[j] = made
diff --git a/sprite_gen/video/rife.py b/sprite_gen/video/rife.py
index 652683e..164ea70 100644
--- a/sprite_gen/video/rife.py
+++ b/sprite_gen/video/rife.py
@@ -10,7 +10,8 @@ pushed out from inside its outline (`bleed`): a disagreement there reads as the
black a frame premultiplied over black put under it (2.24 and before: a black smear between
crossing legs). Inside the coverage the colour is the frame's own, outline included.
`smear` measures what a made frame has that neither neighbour has, and the outline it lost where
-the flow failed and melted a limb into the fill (docs/loop-repair.md section 4).
+the flow failed and melted a limb into the fill; `ghost` reads a band of part coverage on a frame
+alone, filmed or made (docs/loop-repair.md section 4).
The binary's own CPU path (`-g -1`) returns a wrong frame with rife-v4.6 on both macOS and
Linux (measured 2026-10-03: mean error 39 against 3.3 through Vulkan), so it is never passed;
@@ -55,6 +56,10 @@ PARTIAL_ALPHA = (0.1, 0.9)
# when a dark solid pixel lies within this many pixels of it. A drawn outline sits on the edge, under
# an antialiased pixel or two, whatever the frame's size.
OUTLINE_REACH = 2
+# `ghost`: part-covered pixels count where they make a region at least this many pixels thick. An
+# antialiased edge or a keyed strand of hair is a pixel or two wide and erodes away; the band a video
+# model leaves between two drawings, or a flow carries from it, does not.
+GHOST_THICK = 5
CALL_TIMEOUT_SECONDS = 120
Interpolate = Callable[[Image.Image, Image.Image, float], Image.Image]
@@ -223,6 +228,17 @@ def smear(made: Image.Image, a: Image.Image, b: Image.Image) -> dict[str, float]
"outline_loss": round((um - max(ua, ub)) / max(1, em), 5)}
+def ghost(frame: Image.Image) -> float:
+ """Part-covered pixels (PARTIAL_ALPHA) inside regions at least GHOST_THICK pixels thick, as a
+ fraction of the frame's solid pixels: a ghost band, read on the frame's own coverage and not
+ against its neighbours, so a band a filmed frame carries reads the same in a frame made beside
+ it (docs/loop-repair.md section 4)."""
+ alpha = np.asarray(frame.convert("RGBA").getchannel("A"), dtype=np.float32) / 255.0
+ lo, hi = PARTIAL_ALPHA
+ thick = _mask((alpha > lo) & (alpha < hi), GHOST_THICK, ImageFilter.MinFilter)
+ return round(float(thick.sum()) / max(1, int((alpha >= 0.5).sum())), 5)
+
+
class Rife:
"""A located RIFE as an `Interpolate` callable. Counts the frames it made (`made`)."""
diff --git a/tests/video/test_cycle_align.py b/tests/video/test_cycle_align.py
index 9856a6a..97425ff 100644
--- a/tests/video/test_cycle_align.py
+++ b/tests/video/test_cycle_align.py
@@ -49,8 +49,8 @@ def test_resample_keeps_every_frame_that_lands_on_a_source_frame():
frames = [_walker(2 * math.pi * k / 6) for k in range(6)]
rec = Recorder()
out, facts = align.resample(frames, 12, rec, between="rife")
- assert {k: v for k, v in facts.items() if k != "smear"} == {"from": 6, "to": 12, "between": "rife", "taken": 6, "made_by_rife": 6,
- "made_at": [1, 3, 5, 7, 9, 11]}
+ assert {k: v for k, v in facts.items() if k not in ("smear", "ghost_screen")} == {
+ "from": 6, "to": 12, "between": "rife", "taken": 6, "made_by_rife": 6, "made_at": [1, 3, 5, 7, 9, 11], "ghost_at": []}
assert [m["at"] for m in facts["smear"]] == [1, 3, 5, 7, 9, 11]
assert all(out[2 * k] is frames[k] for k in range(6)) and rec.calls == [0.5] * 6
same, facts = align.resample(frames, 6, None) # already that long: untouched, nothing made
diff --git a/tests/video/test_ghost_screen.py b/tests/video/test_ghost_screen.py
index c077ad7..458ca1b 100644
--- a/tests/video/test_ghost_screen.py
+++ b/tests/video/test_ghost_screen.py
@@ -5,8 +5,8 @@ frame RIFE made beside one — is read on its own coverage, not against the fram
loop path delivers one unmeasured.
The fixtures are synthetic: two outlined legs (tests/video/test_rife.py `_walker`) and, for a
-filmed ghost, a band of 0.3 coverage between the feet, where a video model's transition frame
-carried one in a walk filmed on threes. The interpolators are stand-ins that follow the motion
+filmed ghost, a band of 0.3 coverage between the feet, where a video model's half-drawn frame
+between two held drawings carries one. The interpolators are stand-ins that follow the motion
(a whole, outlined frame); the one real-RIFE case runs where RIFE is installed."""
from __future__ import annotations
diff --git a/tests/video/test_loop_prop_seam_held.py b/tests/video/test_loop_prop_seam_held.py
index 728061a..563fe4e 100644
--- a/tests/video/test_loop_prop_seam_held.py
+++ b/tests/video/test_loop_prop_seam_held.py
@@ -375,6 +375,8 @@ CYCLE_ALIGN_KEYS_2350 = {"between", "cycle_screen", "cycles_given", "drawings",
"start_foot_source", "stride_swing", "strikes", "taken", "to", "turned_by", "turned_on", "view"}
# 2.41.0: where every cell is from, and the cut the first alignment was made from (video-follow --read-on)
CORRESPONDENCE_KEYS_2410 = {"cells_from", "origin"}
+# 2.43.0: the ghost screen of the loop as filmed, and each cell where a filmed ghost gave way or was kept
+GHOST_KEYS_2430 = {"ghost_screen", "ghost_at"}
def test_cycle_align_writes_a_loop_without_a_held_part_as_before(tmp_path):
@@ -398,7 +400,7 @@ def test_cycle_align_writes_a_loop_without_a_held_part_as_before(tmp_path):
for d in dirs:
meta = json.loads((d / "loop.strip.json").read_text())
assert set(meta) == STRIP_KEYS_2350 | SOURCE_KEYS_2390
- assert set(meta["cycle_align"]) == CYCLE_ALIGN_KEYS_2350 | CORRESPONDENCE_KEYS_2410
+ assert set(meta["cycle_align"]) == CYCLE_ALIGN_KEYS_2350 | CORRESPONDENCE_KEYS_2410 | GHOST_KEYS_2430
# The cut's source stays as the cut wrote it: `cycle_align` says the cells were turned after it, so it
# no longer names each cell's frame (docs/loop-comparison.md). The rebuilt strip names its own cells —
# the same frames, turned, under the same crop.
diff --git a/tests/video/test_rife.py b/tests/video/test_rife.py
index a7c7f0b..315b30f 100644
--- a/tests/video/test_rife.py
+++ b/tests/video/test_rife.py
@@ -226,9 +226,10 @@ def test_real_rife_melts_legs_crossing_too_far_and_alignment_takes_the_nearer_fr
out, facts = align.resample(list(far), 4, interpolate) # times 0, 0.5, 1, 1.5: both made at t=0.5
assert facts["between"] == "auto" and facts["made_by_rife"] == 0 and facts["nearest_at"] == [1, 3]
assert out[1] is far[1] and out[3] is far[0]
- assert [(m["method"], m["faults"]) for m in facts["smear"]] == [("nearest", ["outline"])] * 2
+ # the melted legs are left part-covered too: a ghost on its own coverage as well (section 4)
+ assert [(m["method"], m["faults"][0]) for m in facts["smear"]] == [("nearest", "outline")] * 2
kept, facts = align.resample(list(far), 4, interpolate, between="rife")
- assert facts["made_at"] == [1, 3] and all(m["faults"] == ["outline"] and m["method"] == "rife" for m in facts["smear"])
+ assert facts["made_at"] == [1, 3] and all(m["faults"][0] == "outline" and m["method"] == "rife" for m in facts["smear"])
out, facts = align.resample(list(near), 4, interpolate)
assert facts["made_at"] == [1, 3] and facts["nearest_at"] == [] and all(not m["faults"] for m in facts["smear"])
@@ -246,5 +247,5 @@ def test_real_rife_repair_rejects_outline_loss_and_keeps_the_original_middle(mon
interpolate = rife.Rife()
out, facts = repair.repair_jumps(frames, interpolate)
assert interpolate.made == facts["attempts"] == 1
- assert facts["replaced"] == [] and facts["rounds"][0]["faults"] == ["outline"]
+ assert facts["replaced"] == [] and facts["rounds"][0]["faults"][0] == "outline"
assert [f.tobytes() for f in out] == before == [f.tobytes() for f in frames]