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): a walk's cut is held to its body's own rise and fall before it is cut, whichever way it was chosen, so no step is handed out unnamed as a cycle, no cut is made longer, and no cut of two cycles is aligned in a set as one

Soohong Kimac08cc6ba0e5
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52aee8b..c50b009 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,13 +10,15 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the
- **Removed: the same-picture rule (`local_cycle.same_picture`, `local_cycle.same_picture_count`, `local_cycle.SAME_PICTURE_MAX`, count code `same-picture`, report fields `step_count.search.same_picture` and `step_count.same_picture`).** It kept the search's cut, with no `steps`, where the count said one step; it never cut one cycle where the search had found two. `local_cycle.read_cycles` takes its place.
- **New: walk start-stop retake reporting (`loop.stand_retake`, `crossings.Reading.stands`).** In gap mode, runs where the feet stay together longer than `run_limit` (√2 times the median whole pass run) are recorded in `Reading.stands`. Where a clip shows its steps, contains `stands`, and the cut kept does not count two steps (`verdict` is not `two`) with no two-step cut closing between the standing frames, `loop.stand_retake` emits a `retake` report (`reason: "start-stop"`, `remedy: "retake"`), keeping the cut as cut without refusal under `--unfixed refuse`. Where a part also pops, one `retake` names both (`loop.retakes`): the first reason's record, `reasons: ["part-pop", "start-stop"]`, and each reason's numbers under its own key (`part_pop`, `start_stop`).
- **Changed: `video-set` defaults gait anchoring to `motion-auto` (`batch.anchor_for`).** Without an explicit `--anchor`, `video-set` cuts each walk and run item whose loop is searched (`cycle_for` returns `auto` or `periodic`) with `motion-auto`, and assigns `none` to idle, attack, once-hold, lifetime, and once-return items; explicit `--anchor` options are applied to every item as before. `video-set` passes each item's view to `video-loop`. Any item whose loop names a retake carries `loop.retake`, appears in the set's `warnings`, and appends ` (film again: <reasons>)` to `table.md`.
-- **Changed: cycle alignment leaves out start-stop retake and cycle-unwitnessed loops (`batch.align_gaits`, `video-set --align-cycles auto`).** Takes flagged with `start-stop` retakes loop no two steps, and loops whose crossings were left on steps unwitnessed (`cycle-unwitnessed`) may have two steps that are two cycles and would play at twice their speed if aligned as one cycle; both are excluded from gait cycle alignment, keeping their loops as cut while aligning the remaining directions. Excluded items are recorded under `left_out` (`{item: reasons}`, listing `["start-stop"]`, `["cycle-unwitnessed"]`, or both) with a stderr warning and a set warning; if fewer than two directions remain, alignment is skipped (`applied: false`, `why: "fewer than two directions left to align"`).
+- **Changed: cycle alignment leaves out start-stop retake, cycle-unwitnessed and cycle-four-steps loops (`batch.align_gaits`, `video-set --align-cycles auto`, `local_cycle.four_steps`).** Takes flagged with `start-stop` retakes loop no two steps, loops whose cut nothing witnesses whole cycles (`cycle-unwitnessed`: crossings left on steps unwitnessed, or a cut the cut witness held) may hold half a cycle or two, and the warning says so, and loops whose cut witness says four steps (`cycle-four-steps`) hold two cycles where their strip counts two steps (`steps: 2`, which `video-cycle-align` reads as one cycle) and would play twice as fast if aligned as one cycle; all are excluded from gait cycle alignment, keeping their loops as cut while aligning the remaining directions. Excluded items are recorded under `left_out` (`{item: reasons}`, listing `["start-stop"]`, `["cycle-unwitnessed"]`, `["cycle-four-steps"]`, or `["start-stop", "cycle-unwitnessed"]`) with a stderr warning and a set warning; if fewer than two directions remain, alignment is skipped (`applied: false`, `why: "fewer than two directions left to align"`). A left-out loop whose step screen suspects one step is told in its warning what settles it (`video-loop --steps 1`), as `video-cycle-align` says when it stops on such a loop, and `batch.left_out_why` takes `one_step`.
+- **New: a walk's cut is held to its body's word before it is cut (`loop._witnessed`, `local_cycle.cut_word`, `local_cycle.unwitnessed`, `local_cycle.held_verdict`).** In `video-loop --anchor motion-auto` (`--cycle auto` or `periodic`), after `loop._by_steps` chooses the cut and before frames are cut, `loop._witnessed(cycle, frames=...)` holds the cut s/L to `local_cycle.cut_word(signals, length)`, which reads `local_cycle.bob_word` at length L (read over the feet (`local_cycle.over_feet`, `feet=True`) so a sway of the picture once a cut, which the flow leaves whole at the cut's length, does not hide the body's rise and fall twice the cut) and says `"two steps"` (a cycle), `"four steps"` (two cycles), `"one step"` (once in the cut), or null. On two steps or four steps the cut stands (`cut: [s, L]`, `says`, `bob`), and a cut of four steps (two cycles), its strip still counting two steps, makes `local_cycle.four_steps(cycle)` true, and `video-set` leaves the item out of cycle alignment (`left_out` `["cycle-four-steps"]`); anything else is held exactly as chosen (two clip crossing intervals where counted, else the search's cut), setting `cut_witness.held` to `"unwitnessed"`, warning `cycle-unwitnessed` (`local_cycle.held_verdict(cycle)` via `local_cycle.step_verdict`), and marking `local_cycle.unwitnessed(cycle)` true so `video-set` leaves the item out of cycle alignment (`left_out` `["cycle-unwitnessed"]`), while cuts the step count already held record `held: "step count"`. A reading of `"one step"` is held and never cut again two long because a body rising and falling once in the cut cannot be distinguished between half a cycle of legs drawn alike and a full cycle of a limp or bouncing legless body without reading legs, and the witness never lengthens or shortens a cut; walks whose body rises once a cycle, legless bodies bouncing once in the cut, and walks carried whole with no rise of their own are held and named even where a cut is a whole cycle.
+- **Changed: the body's own rise and fall is read against the lowest opaque row as well (`legs.body_signals` `sole`, `legs.OPAQUE`, `local_cycle.own_beat`).** `legs.body_signals(frames)` now returns `sole` per frame, taking the lowest row with an alpha of `legs.OPAQUE` (255) or the lowest solid row where none is opaque. `local_cycle.own_beat(signals, interval)` reads `sole` with `twice_an_interval` and takes `less_lowest` as the top line's rise and fall less the lowest solid row's or less the lowest opaque row's, whichever leaves less, returning `sole` as rows up and down. This prevents a translucent shadow drawn fixed on the screen under the feet from acting as the lowest solid row and registering picture shake twice an interval as the body's own rise against it, since opaque feet move with the picture.
- CLI: `video-loop --view front|back|side|front_diagonal|back_diagonal` (default none) sets the clip view for cycle detection and foot cue selection.
-- Report fields: `cycle.step_count.cycles` (`{asked, interval, overlap, half, one, two, slack, cue, bob, cycles, unwitnessed, why}`, where `cue` and `bob` are recorded only where the picture passes, `cue: {range, floor, swapped, one, says, why}` only with a view, `one` absent where `says` is `"alike"`, `bob: {swing, rows, floor, twice, half, quarter, edge, body: {beat, lowest, head, less_lowest, less_head, own, share, scale, least, scale_least}, says, why}`, `half`, `quarter`, `edge` and `body` absent under the floors, `body` absent where under 8 frames are left, and `why` absent where it says `"cycles"`, and `unwitnessed` true only where nothing witnessed); the loop's warnings (`jolt.warnings`); `step_count.stands` and `step_count.run_limit`; `loop.retake` (`{reason: "start-stop", reasons, start_stop: {stands, run_limit, crossings, cut, verdict, code, why}, remedy: "retake"}`); the set report's item `loop.retake` (`{reason, reasons, remedy}`) and item `loop["cycle-unwitnessed"]` (`true`), and its state's `cycle_align.<state>.left_out` (`{item: reasons}`).
-- Python callers: new `local_cycle.read_cycles(reading, distances, view=None, cue=None, cue_step=None, signals=None)`, `local_cycle.bob_word(signals, interval)`, `local_cycle.twice_an_interval(values, interval)`, `local_cycle.own_beat(signals, interval)`, `local_cycle.BOB_OWN`, `local_cycle.BOB_SCALE`, `local_cycle.BEAT_FRAMES`, `legs.body_signals(frames)`, `legs.CROWN`, `local_cycle.off_flow(values, interval)`, `local_cycle.cue_word(cue, interval, step=None)`, `local_cycle.BOB_TWICE`, `local_cycle.BOB_FLOOR`, `local_cycle.BOB_ROWS`, `local_cycle.UNWITNESSED`, `local_cycle.CUE_FLOOR`, `legs.TONE`, `local_cycle.repeat_at(distances, span)`, `batch.anchor_for(state, cut, anchor)`, `batch.left_out_why(reasons, stands=False)`, `loop.stand_retake(cycle)`, `loop.retakes(*records)`, `loop.STAND_REASON`; `crossings._alternation` is now public `crossings.correlation_on(values, span)`; `align._feet`, `align._depth_cue`, `align._shade_cue`, and `align.SHADE_BAND` are moved to `legs.feet_halves`, `legs.depth_cue`, `legs.shade_cue`, and `legs.SHADE_BAND` (`align` keeps `_depth_cue` and `_shade_cue` aliases); `crossings.Reading` gains `interval`, `per`, `cycles`, `hides`, and `mark_cycles(said)`.
+- Report fields: `cycle.step_count.cycles` (`{asked, interval, overlap, half, one, two, slack, cue, bob, cycles, unwitnessed, why}`, where `cue` and `bob` are recorded only where the picture passes, `cue: {range, floor, swapped, one, says, why}` only with a view, `one` absent where `says` is `"alike"`, `bob: {swing, rows, floor, twice, half, quarter, edge, body: {beat, lowest, sole, head, less_lowest, less_head, own, share, scale, least, scale_least}, says, why}`, `half`, `quarter`, `edge` and `body` absent under the floors, `body` absent where under 8 frames are left, and `why` absent where it says `"cycles"`, and `unwitnessed` true only where nothing witnessed); the loop's warnings (`jolt.warnings`); `step_count.stands` and `step_count.run_limit`; `loop.retake` (`{reason: "start-stop", reasons, start_stop: {stands, run_limit, crossings, cut, verdict, code, why}, remedy: "retake"}`); the set report's item `loop.retake` (`{reason, reasons, remedy}`) and item `loop["cycle-unwitnessed"]` (`true`), and its state's `cycle_align.<state>.left_out` (`{item: reasons}`); the loop report's `cycle.cut_witness` (`{cut, says, bob, on, why, held}`, `bob` and `on` with `over`, with `on` only for four steps or one step, `why` only where `says` is null, and `held` only where held); the printed summary's `cycle.cut_witness` (`{cut, says, held}`).
+- Python callers: new `local_cycle.read_cycles(reading, distances, view=None, cue=None, cue_step=None, signals=None)`, `local_cycle.bob_word(signals, interval, feet=False)`, `local_cycle.twice_an_interval(values, interval)`, `local_cycle.own_beat(signals, interval)`, `local_cycle.cut_word(signals, length)`, `local_cycle.over_feet(signals, interval)`, `local_cycle.unwitnessed(cycle)`, `local_cycle.four_steps(cycle)`, `local_cycle.held_verdict(cycle)`, `legs.OPAQUE`, `local_cycle.BOB_OWN`, `local_cycle.BOB_SCALE`, `local_cycle.BEAT_FRAMES`, `legs.body_signals(frames)`, `legs.CROWN`, `local_cycle.off_flow(values, interval)`, `local_cycle.cue_word(cue, interval, step=None)`, `local_cycle.BOB_TWICE`, `local_cycle.BOB_FLOOR`, `local_cycle.BOB_ROWS`, `local_cycle.UNWITNESSED`, `local_cycle.FOUR_STEPS`, `local_cycle.CUE_FLOOR`, `legs.TONE`, `local_cycle.repeat_at(distances, span)`, `batch.anchor_for(state, cut, anchor)`, `batch.left_out_why(reasons, stands=False, one_step=False)`, `loop.stand_retake(cycle)`, `loop.retakes(*records)`, `loop.STAND_REASON`; `crossings._alternation` is now public `crossings.correlation_on(values, span)`; `align._feet`, `align._depth_cue`, `align._shade_cue`, and `align.SHADE_BAND` are moved to `legs.feet_halves`, `legs.depth_cue`, `legs.shade_cue`, and `legs.SHADE_BAND` (`align` keeps `_depth_cue` and `_shade_cue` aliases); `crossings.Reading` gains `interval`, `per`, `cycles`, `hides`, and `mark_cycles(said)`.
- **Tests**: `tests/video/test_walk_steps.py` covers these synthetic walker cases (the walkers' bodies rise and fall on legs whose soles stay on the ground unless held still or drawn carried whole):
- a walker seen from behind whose far foot hides behind the near one (feet together over half the interval) across cycles of 20 frames on twos, 24 on threes, and 17.5 and 18.5 on ones: its top line rises and falls twice an interval, cutting one cycle within a frame with `cycles` true, `steps: 2`, and no cue read with no view, its bob's `body.share` at least `0.3`, `body.scale` at least `0.6`, `edge` 0, and its `why` naming the body's own; the same walker with its far leg drawn as the near one (legs alike), with no view and with `--view back_diagonal`, is still cut to one cycle because the view's cue says `"alike"` (which no longer refuses) and the bob witnesses;
- - a front-diagonal walker whose near foot steps out toward the camera and passes the far one apart (feet together under half the interval, cycle 16 and 18): with `--view front_diagonal` cut to one cycle because its foot cue moves over the floor and does not turn over one interval on (`says` null) and its top line rises and falls twice an interval; without a view it is not asked and is cut to two cycles (32, 36 frames);
+ - a front-diagonal walker whose near foot steps out toward the camera and passes the far one apart (feet together under half the interval, cycle 16 and 18): with `--view front_diagonal` cut to one cycle because its foot cue moves over the floor and does not turn over one interval on (`says` null) and its top line rises and falls twice an interval; without a view it is not asked and is cut to two cycles (32, 36 frames); its cut witness says `"four steps"`, its strip says `steps: 2`, and `local_cycle.four_steps` is true;
- the walker seen from behind (17.5 on ones; no view and `--view back_diagonal`) and the front-diagonal walker (16, `--view front_diagonal`) with their bodies held still: the top line does not rise and fall (the line left under `BOB_FLOOR` of the body's height and under `BOB_ROWS` rows), keeping two intervals (two cycles) with `cycles` false, `unwitnessed` true, and the warning naming the cut;
- a side walker whose two steps are one silhouette (46-frame cycle, near and far a tone or four apart), passes brief: not asked with no view or `--view side`, keeping two steps at 46 frames;
- the same 46-frame walker filmed as a front diagonal, its far leg four tones off the near one, `--view front_diagonal`: the picture passes, but the foot cue turns over one interval on (`says: "steps"`), keeping two steps at 46 frames with no warning;
@@ -39,9 +41,21 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the
- the side walker rising and falling on its legs once a step (its crossings its steps), running: both soles lifted up to 1, 2, 3 or 6 px off the ground while the body is high; still or on a picture moved 6 px either way every d/2 (two phases) or every d frames: never witnessed;
- the side walker drawn as a view from behind or a diagonal draws feet, each sole up to 6, 12 or 24 px lower the further back its foot is, the foot moving forward lifted 8 px (the lowest row is the planted foot, sliding down the screen through its step); still, or on a picture moved 3, 6 (four phases) or 12 px either way every d/2 frames, or 6 px every d: never witnessed;
- synthetic start-stop clips with feet together for 15 frames at the head and 14 at the tail alongside passes of 8 and 3 frames flag retakes when the cut is uncertain, omit retakes when counted as two steps, and report no `stands` when feet only pass.
+ - `cut_word` units on a cut 16 frames long with a body 100 rows tall on feet that stay on the ground report "two steps", "four steps" (`on.interval` 8), "one step" (`on.interval` 32), and null as its top line rises and falls 3 rows either way every 8, 4, or 16 frames or is held still.
+ - a unit with the body on a picture moved 3 rows up and down twice an interval of 15 frames and a translucent shadow fixed on the screen as its lowest solid row yields `says` null with "its lowest row rises and falls with it" when read against the lowest opaque row, and reports "cycles" with the lowest opaque row where the lowest solid row is.
+ - the wide legs-alike side walker (46-frame cycle, crossings every 23 frames) over a translucent shadow drawn with it apart under its feet leaves the step count no feet to read so the search cuts 23 frames, held at 23 and named with "one step" when rising and falling on its legs, and held and named with null when carried whole.
+ - the same walker with each sole drawn up to 12 px lower the further back its foot is and the foot moving forward lifted 8 px has the step count count the search's 23 frames as two steps, returning "one step", held and named.
+ - the same walker over a shadow fixed on the screen apart under its feet on a picture shaken 12 px up and down every half step counts two steps by the crossings with a cut of 14 frames or under, held and named.
+ - the same walker on a picture moved 12 px up and down every two thirds of a step has the search cut 16 frames or under, held and named.
+ - the same walker held still on its legs over a shadow fixed on the screen touching its soles on a picture shaken 6 px twice a step reads no feet, cuts 23 frames; its top line over the lowest opaque row (the feet's) holds still, so its witness says null with "does not rise and fall", read over `sole`, and it is held and named (read over the lowest solid row alone, the shadow holding still, the picture's shaking would witness `"two steps"`).
+ - a walk rising and falling on its legs once a step, its feet on the ground, on a picture swaying up and down once a cycle or slower (the wide walker with its legs drawn alike, crossings every 23 frames, a cycle of 46 frames, the picture swaying 12 px either way every 46 frames or 24 px every 69 frames; and the walker whose far foot passes hidden, 20 frames a cycle on twos, the picture swaying 24 px every 40 frames) is cut one cycle, its cut witnessed `"two steps"`, read over `reach` or `sole`, not held, no warning.
+ - a side walker whose legs four tones apart tell its steps apart on a 30-frame cycle, filmed 100 frames, with its body sinking 3 px once a cycle and not at each step (a limp) is cut 30 frames by the search, two steps by the crossings, returning "one step", held and named, and is never cut 60 frames long.
+ - the legless body bouncing every 16 frames leaves the search's cut standing as cut, never cut again two long, and is held and named where the body rises and falls once in it.
- **Tests**: `tests/video/test_gait_guard_anchor_wide.py` and `tests/video/test_cycle_align.py` cover batch anchoring and cycle alignment:
- `batch.anchor_for` assigns `motion-auto` to walk and run loops while assigning `none` to cheer, walk with `--anchor none`, and pinned idle items, propagating loop retakes to item records, warnings, and markdown tables;
- `batch.align_gaits` excludes loops with a `start-stop` retake, a loop with `cycle-unwitnessed`, or a loop with both, names its reasons under `left_out` (`["start-stop"]`, `["cycle-unwitnessed"]`, `["start-stop", "cycle-unwitnessed"]`) and in the stderr warning, aligns remaining directions, and leaves the state unaligned when fewer than two directions remain.
+ - `batch.align_gaits` with three directions, two loops of one cycle (20 and 24 frames) and one loop of two cycles (40 frames) whose strip says `steps: 2` and whose cut witness says four steps: the two-cycle loop is left out under `left_out` (`["cycle-four-steps"]`) and named in the warning, its loop and strip kept as cut (40 frames, `steps: 2`), and the other two are aligned to their median length.
+- **Tests**: `tests/video/test_one_step_cut.py`: a side walker whose cycle (42 frames) the walk window cannot hold is cut one step long (21 frames) by the pixel search, its feet read as unseen, and the step screen names it; before, the test said nothing else speaks (no `steps` and no warning about steps), whereas now there are still no `steps`, the walker is carried whole on its legs, so its cut witness holds the cut (`cut_witness.held` is `"unwitnessed"`, `local_cycle.unwitnessed` is true), and the one warning that speaks of steps is the witness's (`local_cycle.held_verdict`), naming `cycle-unwitnessed`. In a set of two items, the same walker on a 25-frame cycle (front, cut a whole cycle) and the one-step side walk, their rows now carry the marks `run_set` records (`cycle-unwitnessed` from `local_cycle.unwitnessed`, and `step_screen`) instead of rows built without them; both are left out of the alignment (`left_out` `["cycle-unwitnessed"]` each, `why: "fewer than two directions left to align"`), each warning says nothing witnesses its cut whole cycles and it may hold half a cycle or two, only the side walk's warning adds that it may be one step (cut it again with `video-loop --steps 1` if it is), `video-cycle-align` run on the items' loops reads the step screen in the report beside the side walk's loop and stops on it (`one_step`), naming `--steps 1`, and the set table still marks the side walk's cycle `(one step?)`.
## v3.5.0 - Widened square canvas framing for side walk and run stride and trailing parts, measured background matte cutout for flat backgrounds of any colour, and failure when a cutout removes nothing
diff --git a/docs/loop-repair.md b/docs/loop-repair.md
index d7bd173..eed84f5 100644
--- a/docs/loop-repair.md
+++ b/docs/loop-repair.md
@@ -1353,13 +1353,15 @@ frames left counted from the first; it returns the twice-an-interval harmonic as
a rows either way twice an interval reads a in magnitude. Lines read so over the same frames and
interval subtract as they move. None where fewer than `BEAT_FRAMES` (`8`) frames are left. Where none:
`says` null, `why`: "its top line's rise and fall twice an interval is not read against its lowest row
-and head: under 8 frames are left less the flow". `local_cycle.own_beat(signals, interval)` reads three
-lines with `twice_an_interval`: the top line (`top`), the lowest solid row (`reach`) and the head's
-width (`crown`, a log). It returns, in rows up and down (twice the magnitude): `beat` (the top line's),
-`lowest` (the lowest row's), `head` (the head width's, scaled by the body's median height), `less_lowest`
-(the top line's less the lowest row's: the picture moving taken out), `less_head` (that again with the
-head width's, scaled by the body's median height, added: the picture zooming taken out as well), and
-`own`, the smaller of `less_lowest` and `less_head`. None where a line is not read. The floor is the
+and head: under 8 frames are left less the flow". `local_cycle.own_beat(signals, interval)` reads four
+lines with `twice_an_interval`: the top line (`top`), the lowest solid row (`reach`), the lowest opaque
+row (`sole`) and the head's width (`crown`, a log). It returns, in rows up and down (twice the
+magnitude): `beat` (the top line's), `lowest` (the lowest row's), `sole` (the lowest opaque row's),
+`head` (the head width's, scaled by the body's median height), `less_lowest` (the top line's less the
+lowest solid row's or less the lowest opaque row's, whichever leaves less: the picture moving taken out),
+`less_head` (that again with the head width's, scaled by the body's median height, added: the picture
+zooming taken out as well), and `own`, the smaller of `less_lowest` and `less_head`. None where a line
+is not read. The floor is the
larger of `BOB_ROWS` and `BOB_FLOOR` of the body's median height. Where `less_lowest` is under the larger
of `BOB_OWN` (`0.3`) times `beat` and the floor: `says` null, `why`: "its lowest row rises and falls with
it: less the lowest row's, its top line's rise and fall twice an interval is {x} rows of {beat} ({percent};
@@ -1375,7 +1377,11 @@ of the line's rise against it. The picture zoomed in and out widens the head as
much as the body's height grows, so nothing is left once the head's scale is taken out too.
`legs.body_signals(frames)`: per frame `crown`, the log of the mean width (in alpha) of the band from
2 % to 10 % of the clip's median body height below the first solid row (`legs.CROWN` = `(0.02, 0.10)`),
-and `edge`, 1 where the lowest solid row is the frame's last row, else 0. `signals` are the frames'
+`edge`, 1 where the lowest solid row is the frame's last row, else 0, and `sole`, the lowest row with a
+fully opaque pixel (alpha `legs.OPAQUE` = 255), or the lowest solid row where a frame has none, because a
+shadow drawn translucent under the feet is solid to the legs' reading (alpha 128 or more) and, drawn fixed
+on the screen, stays while the picture moves, so a picture shaken twice an interval would otherwise be read
+as the body's own rise against it; the feet are drawn opaque and move with the picture. `signals` are the frames'
`legs.strike_signals` merged with `legs.body_signals`; the body's median height is the median of
`signals["height"]`. Only the step count's witness reads them: `loop.read_steps` merges them into the
signals it passes to `local_cycle.read_cycles`. `legs.strike_signals` is unchanged, so the loop report's
@@ -1496,7 +1502,8 @@ or 12 px either way every d/2 frames, or 6 px every d: never witnessed.
**Choosing the cut.**
- The clip does not show its steps (no feet seen, a legless body, a lean that does not turn over, under
- three crossings): the search's cut, exactly as before. Only `cycle.step_count` is new.
+ three crossings): the search's cut is kept as the search cut it, and then held to the body's word like
+ every other cut (see "The cut's witness" below); `cycle.step_count` and `cycle.cut_witness` are recorded.
- The search's cut is a two within **1.5** frames of phase (`crossings.PHASE_TOLERANCE`): kept, every
image and frame as the search alone cuts it.
- Otherwise the cut is among the cuts that cover two steps — any start, any length the count allows,
@@ -1550,6 +1557,47 @@ screen below then has its word only where the count does not: its pixel suspicio
`pixel_suspect`, `suspect` false. A count given (`--steps`) is the word on the search's cut, and the
crossings are not asked.
+**The cut's witness.** In `video-loop --anchor motion-auto` (a walk or run whose cycle is searched: `--cycle auto`
+or `periodic`), right after the step count (`loop._by_steps`) has chosen the cut and before any frame is cut,
+`loop._witnessed(cycle, frames=...)` holds the chosen cut s/L to the body's word, whichever way it was chosen:
+the pixel search's cut, two steps by the clip's crossings, crossings read or not read; it does not run for a count
+given (`--steps`), a fixed cut, `--anchor none`, or any state that is not a walk or a run (motion-auto refuses
+those). This witness is needed because legs drawn alike loop as well on one step as on two; crossings read off
+feet that slide down the screen through their step (as a view from behind or a diagonal draws a planted foot),
+or off a shadow under the feet on a picture that moves, count half steps or quarter steps; and a shadow under the
+feet can leave the step count no feet to read, handing out the search's one-step cut with nothing named.
+`local_cycle.cut_word(signals, length)` reads `local_cycle.bob_word` (the body's own rise and fall twice an
+interval) over the feet (`local_cycle.over_feet`, `bob_word(..., feet=True)`; taking the top line less the lowest
+solid row, `reach`, or less the lowest opaque row, `sole`, whichever leaves less of the top line's rise and
+fall twice an interval; the flow at the cut's length leaves a sway of the picture once a cut whole, and the feet
+move with the picture, while the step count's reading at the crossing interval keeps the top line on the screen)
+at the cut's length L and says: `"two steps"` where the body rises and falls of its own twice in the
+cut (the cut is a cycle); `"four steps"` where it does so twice in half the cut (two cycles); `"one step"` where
+it does so twice in two cuts, that is once in the cut; null where none of these is read (`why` is the reading's
+own why); returning `{says, bob, on, why}`: `bob` the reading on the cut, `on` the reading at L/2 or 2L that said
+four steps or one step, with its `interval`. Two steps or four steps: the cut stands, and `cycle.cut_witness`
+records `{cut: [s, L], says, bob}`.
+A cut of four steps (two cycles) still has its strip counting two steps (`steps: 2`), which `video-cycle-align`
+reads as one cycle; so `local_cycle.four_steps(cycle)` is true and `video-set` leaves the item out of its state's
+cycle alignment (`left_out` `["cycle-four-steps"]`, `local_cycle.FOUR_STEPS`), its loop as cut. `video-cycle-align`
+run on its own does not read the witness.
+Anything else: the cut is held: kept exactly as it was chosen (two of the clip's crossing intervals where the
+step count counted them, else the search's cut), `cut_witness.held` is `"unwitnessed"`, a warning line names
+`cycle-unwitnessed` (`local_cycle.held_verdict(cycle)`, said through `local_cycle.step_verdict`), and
+`local_cycle.unwitnessed(cycle)` is true, so `video-set` leaves the item out of its state's cycle alignment
+(`left_out` `["cycle-unwitnessed"]`); its warning says nothing witnesses its cut whole cycles, so it may hold
+half a cycle or two, and, where its step screen suspects the cut is one step, adds what settles that
+(`video-loop --steps 1`); a cut the step count had already held (crossings left on steps,
+`step_count.cycles.unwitnessed`) is recorded `{cut, held: "step count"}` and named as before.
+`"one step"` is held, never cut again two of its lengths long: a body that rises and falls once in the cut may be
+one step of a walk whose legs are drawn alike (half its cycle), or a whole cycle of a body that rises and falls
+once a cycle: a limp, or a legless body bouncing as it goes (the walk window already admits a legless body's fast
+bounce); nothing that reads no leg tells the two apart, and cutting again two long would loop two cycles of the
+second. The loop report's `cycle.cut_witness` records `{cut, says, bob, on, why, held}` (`on` only for four steps
+or one step, `why` only where `says` is null, `held` only where held); the printed summary's
+`cycle.cut_witness` records `{cut, says, held}`.
+The loop report's `bob` and `on` record `over`, the row the line was read over (`reach` or `sole`).
+
**What crossings cannot see**: a hold the step range absorbs (a 13-frame step held to 17), a still run of
the feet together inside the clip as long as a pass, and a wobble that reaches the reading's sides at a
step's beat read as steps; a narrow step that opens the feet only just past the reading's threshold reads
@@ -1570,7 +1618,11 @@ part held over the head moves on a beat of its own) has its crossings left on st
with the warning, and `video-set` leaves it out of the cycle alignment (`video-cycle-align` run on its own
reads such a loop's `steps: 2` as one cycle; through `video-set` it is left out); and a walk whose crossings
are its steps, whose legs are drawn alike so its picture repeats a step on, and whose top line rises and
-falls twice a step (a part over the head on a beat twice the step's) would still be read as cycles. Four-legged gaits are read as one foot band (`legs.strike_signals`), as before.
+falls twice a step (a part over the head on a beat twice the step's) would still be read as cycles.
+A walk whose body rises and falls once a cycle (a limp) and a legless body bouncing once in its cut are held
+and named even where the cut is a whole cycle, and a walk carried up and down whole, feet and all, with no
+rise of its own, is held. The witness never lengthens or shortens a cut.
+Four-legged gaits are read as one foot band (`legs.strike_signals`), as before.
### The step gate: every step between drawings, and a fixed cut's count
@@ -1698,6 +1750,9 @@ sprite-gen video-cycle-align --loop-dir set/front-walk/loop --loop-dir set/side-
cut it again with `video-loop … --steps 1` (the arguments are in its report) and align the set
anew; if it is two, `--cycles <loop>=1` aligns it as it is. A loop with no report beside it is not
screened this way.
+ In `video-set`, a walk whose cut its cut witness held is left out of the alignment
+ (`cycle-unwitnessed`) before it is screened, and where its step screen suspects one step, its
+ warning gives the same advice (cut it again with `video-loop --steps 1` if it is one).
- **Two cycles in one loop are stopped, and counted by whoever looks**: one length for the set is
one beat only if every loop holds one cycle. A loop that holds two strides, resampled to the
set's length, walks twice as fast as the rest, arms and legs alike — and pixels cannot tell it
diff --git a/docs/video-pipeline.md b/docs/video-pipeline.md
index f06504a..28f641c 100644
--- a/docs/video-pipeline.md
+++ b/docs/video-pipeline.md
@@ -210,10 +210,13 @@ stops the set before anything is rewritten instead (both are explained in
[loop repair](loop-repair.md) section 4).
`video-set`'s own alignment (`batch.align_gaits`) leaves out a loop named a take to film again for
-`start-stop` or one whose crossings were left on steps unwitnessed (`cycle-unwitnessed`: its two
-steps may be two cycles, and aligned as one cycle it would play at twice its speed): its loop is kept
-as cut, the rest are aligned without it, and the state's record names it under `left_out` with its
-reasons.
+`start-stop`, a loop whose cut nothing witnesses whole cycles (`cycle-unwitnessed`: its crossings
+left on steps unwitnessed, or its cut held by the cut witness), which may hold half a cycle or two,
+or a loop its body rises and falls four times in (`cycle-four-steps`: it holds two cycles where its
+strip counts two steps, and aligned as one cycle it would play twice as fast): its loop is kept as
+cut, the rest are aligned without it, and the state's record names it under `left_out` with its
+reasons. A loop left out whose step screen suspects it is one step is told in its warning what
+settles that (`video-loop --steps 1`), as `video-cycle-align` says when it stops on such a loop.
`video-prompt --json` also gives the duration (the state's own, as `video-set`), whether the clip
ends on the canvas (`last_frame`), the loop cut (`cycle`) and the canvas, clip, frames and loop
diff --git a/sprite_gen/video/batch.py b/sprite_gen/video/batch.py
index da2cf76..79efc1a 100644
--- a/sprite_gen/video/batch.py
+++ b/sprite_gen/video/batch.py
@@ -883,9 +883,14 @@ def run_item(
if "steps" in lp["cycle"]:
# the cut's steps are known: its frame count is two steps — one cycle — not twice its siblings' one
result["loop"]["steps"] = lp["cycle"]["steps"]["count"]
- if ((lp["cycle"].get("step_count") or {}).get("cycles") or {}).get("unwitnessed"):
- # its crossings may mark cycles, and nothing witnesses whether: its two steps may be two cycles
+ if local_cycle.unwitnessed(lp["cycle"]):
+ # its crossings may mark cycles, or its cut be one step, and nothing witnesses whether: it may hold half a
+ # cycle or two
result["loop"][local_cycle.UNWITNESSED] = True
+ if local_cycle.four_steps(lp["cycle"]):
+ # its body rises and falls four times in its cut: two cycles where its strip counts two steps — aligned as one
+ # cycle, it would play twice as fast
+ result["loop"][local_cycle.FOUR_STEPS] = True
if (lp["cycle"].get("step_screen") or {}).get("suspect"):
# the cut may be one step of a cycle twice as long (recorded, not cut again)
result["loop"]["step_screen"] = {k: lp["cycle"]["step_screen"][k] for k in ("lag", "ratio", "depth", "coverage")}
@@ -968,15 +973,22 @@ def _align_view(r: dict[str, Any]) -> str | None:
return r["direction"] + (f"@{r['turned']}" if r["direction"] in handed_mod.LATERAL_VIEWS else "")
-def left_out_why(reasons: list[str], *, stands: bool = False) -> str:
+def left_out_why(reasons: list[str], *, stands: bool = False, one_step: bool = False) -> str:
"""Why `align_gaits` left a loop out of its state's alignment (`reasons`, as `left_out` keeps them), in words: a take
- to film again (its retake reasons, `start-stop` among them; `stands` says why the walk is filmed again), and a loop
- whose crossings may mark cycles with nothing to witness whether (`cycle-unwitnessed`)."""
- retake = [r for r in reasons if r != local_cycle.UNWITNESSED]
+ to film again (its retake reasons, `start-stop` among them; `stands` says why the walk is filmed again), a loop
+ whose cut nothing witnesses whole cycles (`cycle-unwitnessed`: crossings left on steps, or a cut the cut witness
+ held — half a cycle or two, whichever), and a loop cut two cycles long where its strip counts two steps
+ (`cycle-four-steps`). `one_step`, its step screen suspecting it is one step (`step_screen`), adds the count that
+ settles it, as an alignment that stops on such a loop says."""
+ retake = [r for r in reasons if r not in (local_cycle.UNWITNESSED, local_cycle.FOUR_STEPS)]
stood = ": the walk starts or stops in it" if stands and loop_mod.STAND_REASON in retake else ""
- return " and ".join([*([f"a take to film again ({', '.join(retake)}){stood}"] if retake else []),
- *([f"its crossings may mark cycles and nothing witnesses whether ({local_cycle.UNWITNESSED}): its two "
- "steps may be two cycles"] if local_cycle.UNWITNESSED in reasons else [])])
+ why = " and ".join([*([f"a take to film again ({', '.join(retake)}){stood}"] if retake else []),
+ *([f"nothing witnesses its cut whole cycles ({local_cycle.UNWITNESSED}): it may hold half a cycle or two"]
+ if local_cycle.UNWITNESSED in reasons else []),
+ *([f"its body rises and falls four times in its cut ({local_cycle.FOUR_STEPS}): it holds two cycles "
+ "where its strip counts two steps, and aligned as one cycle it would play twice as fast"]
+ if local_cycle.FOUR_STEPS in reasons else [])])
+ return why + ("; its step screen says it may be one step (cut it again with video-loop --steps 1 if it is)" if one_step else "")
def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpolate: Any = None, between: str = align_mod.DEFAULT_BETWEEN,
@@ -989,11 +1001,14 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpo
RIFE is installed (`rife-not-installed`), or a loop may hold two or three cycles and nobody has
counted them (`cycle-suspects`, the loops under `suspects`; `video-cycle-align --cycles`).
A loop whose take is to be filmed again because the walk starts or stops in it (`retake` reason
- `start-stop`, loop.stand_retake) loops no two steps and has no cycle to match, and a loop whose clip's
- crossings may mark cycles with nothing to witness whether (`cycle-unwitnessed`,
- local_cycle.read_cycles) may loop two cycles where it counts two steps: each is left out, its loop
- kept as cut, the rest aligned without it, and its state names it under `left_out`, with its reasons —
- no loop is played at twice its speed, and no count of its cycles is asked for.
+ `start-stop`, loop.stand_retake) loops no two steps and has no cycle to match, a loop whose cut nothing
+ witnesses whole cycles (`cycle-unwitnessed`, local_cycle.unwitnessed: its crossings left on steps, or
+ its cut held by the cut witness) may hold half a cycle or two, and a loop its body rises and falls four
+ times in (`cycle-four-steps`, local_cycle.four_steps) loops two where its strip counts two steps: each
+ is left out, its loop kept as cut, the rest aligned without it, and its state names it under
+ `left_out`, with its reasons — no loop is played at twice its speed, and no count of its cycles is
+ asked for. One left out whose step screen suspects it is one step (`step_screen`) is told in its
+ warning what settles that (`video-loop --steps 1`), as an alignment that stops on it would tell.
`feet` maps an item to the own foot that lands on its loop's first strike (`--align-foot`,
`video-cycle-align --foot`), handed to its state's alignment. A state that names loops whose foot
@@ -1006,11 +1021,14 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpo
return out
by_state: dict[str, list[dict[str, Any]]] = {}
left_out: dict[str, dict[str, list[str]]] = {}
+ # a loop left out whose step screen suspects its cut is one step says what settles it, as the alignment would
+ stepped = {r["item"] for r in results if r.get("ok") and "step_screen" in r["loop"]}
for r in results:
if r.get("ok") and loop_mod.profile_for(r["state"]).gait:
reasons = (r["loop"].get("retake") or {}).get("reasons") or []
why = [*(reasons if loop_mod.STAND_REASON in reasons else []),
- *([local_cycle.UNWITNESSED] if r["loop"].get(local_cycle.UNWITNESSED) else [])]
+ *([local_cycle.UNWITNESSED] if r["loop"].get(local_cycle.UNWITNESSED) else []),
+ *([local_cycle.FOUR_STEPS] if r["loop"].get(local_cycle.FOUR_STEPS) else [])]
if why:
left_out.setdefault(r["state"], {})[r["item"]] = why
continue
@@ -1061,8 +1079,8 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpo
for state, items in left_out.items():
out.setdefault(state, {"ok": True, "applied": False, "why": "fewer than two directions left to align"})["left_out"] = items
for item, reasons in items.items():
- print(f"video-set: warning: {state}: {item} left out of the cycle alignment — {left_out_why(reasons, stands=True)}, "
- "and its loop is kept as cut", file=sys.stderr)
+ print(f"video-set: warning: {state}: {item} left out of the cycle alignment — "
+ f"{left_out_why(reasons, stands=True, one_step=item in stepped)}, and its loop is kept as cut", file=sys.stderr)
# a foot told for an item no alignment took (its state not aligned, or the item failed) is never dropped quietly
for state, told_items in asked.items():
if told_items and not out[state].get("applied"):
@@ -1072,7 +1090,8 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpo
if r is None:
raise SystemExit(f"video-set: --align-foot {item}={foot} names no item of the set")
why = (f"{item} failed" if not r.get("ok") else
- f"{item} was left out of the alignment, {left_out_why(left_out[r['state']][item])}" if item in left_out.get(r["state"], {}) else
+ f"{item} was left out of the alignment, {left_out_why(left_out[r['state']][item], one_step=item in stepped)}"
+ if item in left_out.get(r["state"], {}) else
f"{r['state']} was not aligned (filmed in fewer than two directions)")
out.setdefault(r["state"], {"ok": True, "applied": False, "why": why}).setdefault("feet_unused", {})[item] = foot
for state, a in out.items():
@@ -1228,7 +1247,8 @@ def run_set(
# A take to film again its loop named (`retake`) — never a failure, never silent — and one the alignment left out.
warnings += [f"{r['item']}: film this direction again ({', '.join(r['loop']['retake']['reasons'])}) — {r['dir']}/loop.report.json `retake`"
for r in results if r.get("ok") and r["loop"].get("retake")]
- warnings += [f"cycle-align:{st}: {item} left out — {left_out_why(reasons)}, its loop kept as cut"
+ stepped = {r["item"] for r in results if r.get("ok") and "step_screen" in r["loop"]}
+ warnings += [f"cycle-align:{st}: {item} left out — {left_out_why(reasons, one_step=item in stepped)}, its loop kept as cut"
for st, a in aligned.items() for item, reasons in a.get("left_out", {}).items()]
warnings += [f"cycle-align:{st}: --align-foot {item}={foot} not applied ({a.get('why') or a.get('error') or 'the item failed'})"
for st, a in aligned.items() for item, foot in a.get("feet_unused", {}).items()]
diff --git a/sprite_gen/video/legs.py b/sprite_gen/video/legs.py
index ad5f3c0..35cd421 100644
--- a/sprite_gen/video/legs.py
+++ b/sprite_gen/video/legs.py
@@ -12,9 +12,10 @@ Both read the same per-frame signals (`strike_signals`) and choose between them
- `reach`: the lowest solid row. Seen from the front or back the foot nearer the viewer is drawn
lower, once a step.
- `top`: the body's top line, for a body with no legs to read. It rises and falls once a step
- whichever leg leads, so the step count reads it as the witness that a crossing interval holds
- two steps (`local_cycle.bob_word`) — against the lowest row and the head's width, since the
- picture moving or zoomed with the body moves the line as well.
+ whichever leg leads, so the step count reads it as the witness that a crossing interval, or a
+ cut, holds two steps (`local_cycle.bob_word`, `local_cycle.cut_word`) — against the lowest row,
+ the lowest opaque row and the head's width, since the picture moving or zoomed with the body
+ moves the line as well.
- `gap`: the widest empty run between the foot band's two ends, of the frame's height — two feet
seen apart.
@@ -23,6 +24,10 @@ The step count's witness reads two more (`body_signals`), recorded nowhere else:
- `crown`: the head's width, the log of the mean width (in alpha) of the band CROWN of the clip's
median body height below the first solid row. A picture zoomed in and out widens and narrows
it as it lifts and lowers the top line; a body rising and falling on its legs leaves it.
+- `sole`: the lowest row with a pixel drawn fully opaque (alpha OPAQUE), or the lowest solid row
+ where a frame has none. A shadow is drawn translucent under the feet, solid all the same, and
+ it need not move with them: one drawn on the screen stays while the picture moves, and the
+ lowest solid row is then its, not the feet's. The feet are drawn opaque.
- `edge`: 1 where the lowest solid row is the frame's last row — the feet may run off the
frame, and the lowest row is the frame's, not theirs — else 0.
@@ -50,6 +55,7 @@ from sprite_gen._deps import np
FOOT_BAND = 0.08 # fraction of the frame's own height, measured up from its lowest opaque row
LOW_ALPHA = 128 # the legs are read off solid pixels only
+OPAQUE = 255 # drawn fully opaque: the feet, not a shadow drawn translucent under them
BODY_RUN = 0.5 # the body's top line: the first row at least half as wide as the frame's widest
CROWN = (0.02, 0.10) # the head's top band: from 2 % to 10 % of the body's median height below its first solid row
# A walk seen from the side or a diagonal opens its feet by a good part of its height each step;
@@ -111,15 +117,17 @@ def strike_signals(frames: list[Image.Image]) -> dict[str, list[float]]:
def body_signals(frames: list[Image.Image]) -> dict[str, list[float]]:
"""Per frame, from the solid pixels, what the step count's witness reads besides `strike_signals`:
- `crown` and `edge` (see the module). `crown` reads the same band of every frame, of the clip's
- median body height."""
- edge, firsts, heights, widths = [], [], [], []
+ `crown`, `sole` and `edge` (see the module). `crown` reads the same band of every frame, of the
+ clip's median body height."""
+ edge, sole, firsts, heights, widths = [], [], [], [], []
for f in frames:
alpha = np.asarray(f.getchannel("A"))
rows = np.nonzero((alpha >= LOW_ALPHA).any(axis=1))[0]
if rows.size == 0:
raise ValueError("a loop frame has no solid body")
y0, y1 = int(rows[0]), int(rows[-1])
+ opaque = np.nonzero((alpha >= OPAQUE).any(axis=1))[0]
+ sole.append(float(opaque[-1] if opaque.size else y1))
edge.append(float(y1 == alpha.shape[0] - 1))
firsts.append(y0)
heights.append(y1 - y0 + 1)
@@ -127,7 +135,7 @@ def body_signals(frames: list[Image.Image]) -> dict[str, list[float]]:
median = float(np.median(heights)) if frames else 0.0
a0, a1 = max(1, math.ceil(CROWN[0] * median)), max(2, math.ceil(CROWN[1] * median))
crown = [float(np.log(max(1e-6, w[y0 + a0 : y0 + a1].sum() / (a1 - a0)))) for y0, w in zip(firsts, widths)]
- return {"crown": crown, "edge": edge}
+ return {"crown": crown, "sole": sole, "edge": edge}
def swings(sig: dict[str, list[float]]) -> dict[str, float]:
diff --git a/sprite_gen/video/local_cycle.py b/sprite_gen/video/local_cycle.py
index cebdd7f..a1749e9 100644
--- a/sprite_gen/video/local_cycle.py
+++ b/sprite_gen/video/local_cycle.py
@@ -47,7 +47,9 @@ CUE_FLOOR = 0.5
# BOB_TWICE (correlated BOB_TWICE or over there, -BOB_TWICE or under here); where it holds one it is turned over half an
# interval on, and a flow left over is as it was at both. A line left whose range is under BOB_FLOOR of the body's
# median height, or under BOB_ROWS pixel rows (a line read in whole rows rounds a row up and down as the picture
-# drifts), does not rise and fall, and witnesses nothing.
+# drifts), does not rise and fall, and witnesses nothing. A walk's cut, read whole as it is cut (`cut_word`), is read so
+# on the top line over its feet (`over_feet`): at the cut's length a picture swaying once a cut is left whole, and on
+# the screen it would hide the body's rise and fall twice the cut; the feet move with it.
# The picture moving up and down moves the line as the body does, on any beat — shaken twice an interval it is pixel for
# pixel a body carried up and down whole, feet and all — and the picture zoomed in and out lifts and lowers it too. So the
# line's rise and fall twice an interval (`twice_an_interval`) is read against the body's own lowest row and head
@@ -69,7 +71,15 @@ SIDE_VIEW = 'side' # from the side the legs a step on are one silhouette, as ne
# A loop whose clip one interval on is the same picture, as a walk whose feet meet once a cycle draws it, with nothing
# to witness whether they do (`read_cycles`): its crossings stay on steps, so its two steps may be two cycles. Named on
# its step count (`cycles.unwitnessed`), and `video-set` leaves it out of its state's cycle alignment under this reason.
+# So is a walk's cut that nothing witnesses whole cycles as it is cut, whichever way it was chosen (`cut_word`, loop
+# `_witnessed`; `cut_witness.held`): it may be one step of a walk whose legs are drawn alike, or, the body rising and
+# falling once in it, a whole cycle of a body that does so once a cycle (`unwitnessed`).
UNWITNESSED = 'cycle-unwitnessed'
+# A walk's cut its body rises and falls four times in (`cut_word` says four steps, loop `_witnessed`): two cycles, and it
+# stands. Its strip still counts the two steps the crossings counted (`steps: 2`), which `video-cycle-align` reads as one
+# cycle, a return half way its second step: aligned so, it would play twice as fast as the rest. `video-set` leaves it
+# out of its state's cycle alignment under this reason (`four_steps`).
+FOUR_STEPS = 'cycle-four-steps'
def _around(start, length):
@@ -585,43 +595,65 @@ def twice_an_interval(values, interval):
def own_beat(signals, interval):
"""The body's own rise and fall twice an interval `interval` frames long (`bob_word`), read off `signals`
- (`legs.strike_signals` `top`, `reach` and `height`, `legs.body_signals` `crown`) as `twice_an_interval` reads each:
- the top line's, less the lowest row's (the picture moving taken out), and less that again of the head's width's
- scaled to the body's median height (the picture zooming taken out). Returns, in rows up and down: `beat` (the top
- line's), `lowest`, `head`, `less_lowest`, `less_head`, and `own`, the smaller of the last two. None where a line is
+ (`legs.strike_signals` `top`, `reach` and `height`, `legs.body_signals` `crown` and `sole`) as `twice_an_interval`
+ reads each: the top line's, less the lowest row's (the picture moving taken out) — the lowest solid row's or the
+ lowest opaque row's, whichever leaves less: a shadow drawn translucent under the feet and fixed on the screen is the
+ lowest solid row and does not move with the picture, the feet do — and less that again of the head's width's scaled
+ to the body's median height (the picture zooming taken out). Returns, in rows up and down: `beat` (the top line's),
+ `lowest`, `sole`, `head`, `less_lowest`, `less_head`, and `own`, the smaller of the last two. None where a line is
not read."""
height = float(np.median(signals['height']))
- top, lowest, crown = (twice_an_interval(signals[k], interval) for k in ('top', 'reach', 'crown'))
- if top is None or lowest is None or crown is None:
+ top, lowest, sole, crown = (twice_an_interval(signals[k], interval) for k in ('top', 'reach', 'sole', 'crown'))
+ if top is None or lowest is None or sole is None or crown is None:
return None
- less_lowest = top - lowest
+ less_lowest = min(top - lowest, top - sole, key=abs)
less_head = less_lowest + height*crown
- return {'beat': 2*abs(top), 'lowest': 2*abs(lowest), 'head': 2*height*abs(crown), 'less_lowest': 2*abs(less_lowest),
- 'less_head': 2*abs(less_head), 'own': 2*min(abs(less_lowest), abs(less_head))}
+ return {'beat': 2*abs(top), 'lowest': 2*abs(lowest), 'sole': 2*abs(sole), 'head': 2*height*abs(crown),
+ 'less_lowest': 2*abs(less_lowest), 'less_head': 2*abs(less_head), 'own': 2*min(abs(less_lowest), abs(less_head))}
-def bob_word(signals, interval):
+def over_feet(signals, interval):
+ """The body's top line over its lowest row, per frame, and which row (`reach`, the lowest solid one, or `sole`, the
+ lowest opaque one): whichever leaves less of the top line's rise and fall twice an interval, as `own_beat` takes it
+ (the solid one where that is not read). The picture moving carries the body and its feet alike, on any beat, and
+ the line over the feet holds still for it; the body rising and falling on its legs is left."""
+ top = np.asarray(signals['top'], dtype=float)
+ lines = {k: top - np.asarray(signals[k], dtype=float) for k in ('reach', 'sole')}
+ left = {k: twice_an_interval(line, interval) for k, line in lines.items()}
+ over = 'sole' if None not in left.values() and abs(left['sole']) < abs(left['reach']) else 'reach'
+ return lines[over], over
+
+
+def bob_word(signals, interval, *, feet=False):
"""Whether the body rises and falls twice an interval `interval` frames long (`read_cycles`), read off `signals`
(`legs.strike_signals` with `legs.body_signals`) without telling the legs apart. Its top line (`top`, in pixel rows)
less its flow (`off_flow`) ranges BOB_FLOOR of the body's median `height` or more and BOB_ROWS rows or more, and it
is as it was half an interval on and turned over a quarter on (`crossings.correlation_on`, BOB_TWICE or over there
- and -BOB_TWICE or under here): it rises and falls twice an interval. And that rise and fall is the body's own
- (`own_beat`): what is left of it against the lowest row, and against the head's width as well, is at least BOB_OWN
- of it and over the floor, the head's width taking it down to no less than BOB_SCALE of what is left against the
- lowest row, and no frame's lowest row is its last (`edge`). Then `says` `cycles` — a step each rise, two steps an
- interval; None otherwise, with why. Returns the record: `swing` (the line left's range, of the body's height),
- `rows` (in rows), `floor`, `twice`, `half` and `quarter` (where read), `edge` (frames whose lowest row is their
- last), `body` (`own_beat`, in rows up and down, with `share`, `own` of `beat`, and `scale`, `less_head` of
- `less_lowest`; where read), `says`."""
+ and -BOB_TWICE or under here): it rises and falls twice an interval. With `feet`, the line so read is the top line
+ over the lowest row (`over_feet`), the picture's moving taken out first (`cut_word`: the picture moving once a cut,
+ which `off_flow` leaves whole, would hide the rise and fall twice it). And that rise and fall is the body's own
+ (`own_beat`): what is left of it against the lowest row (solid or opaque, whichever leaves less), and against the
+ head's width as well, is at least BOB_OWN of it and over the floor, the head's width taking it down to no less than
+ BOB_SCALE of what is left against the lowest row, and no frame's lowest row is its last (`edge`). Then `says`
+ `cycles` — a step each rise, two steps an interval; None otherwise, with why. Returns the record: `swing` (the line
+ left's range, of the body's height), `rows` (in rows), `floor`, `twice`, `over` (with `feet`: the row the line is
+ read over), `half` and `quarter` (where read), `edge` (frames whose lowest row is their last), `body` (`own_beat`,
+ in rows up and down, with `share`, `own` of `beat`, and `scale`, `less_head` of `less_lowest`; where read), `says`."""
height = float(np.median(signals['height']))
- values = off_flow(signals['top'], interval)
+ line, what, extent = signals['top'], "its top line", "its top line's range"
+ word = {}
+ if feet:
+ line, over = over_feet(signals, interval)
+ what = f"its top line over its lowest {'opaque' if over == 'sole' else 'solid'} row"
+ extent, word = f"the range of {what}", {'over': over}
+ values = off_flow(line, interval)
rows = float(values.max()-values.min()) if values.size else 0.0
swing = rows/height if height > 0 else 0.0
- word = {'swing': round(swing, 4), 'rows': round(rows, 2), 'floor': BOB_FLOOR, 'twice': BOB_TWICE}
+ word = {'swing': round(swing, 4), 'rows': round(rows, 2), 'floor': BOB_FLOOR, 'twice': BOB_TWICE, **word}
if not values.size:
- return {**word, 'says': None, 'why': "its top line less its flow is not read: the clip is under an interval long"}
+ return {**word, 'says': None, 'why': f"{what} less its flow is not read: the clip is under an interval long"}
if swing < BOB_FLOOR or rows < BOB_ROWS:
- return {**word, 'says': None, 'why': f"its top line's range less its flow ({swing:.2%} of the body's height, {rows:.1f} "
+ return {**word, 'says': None, 'why': f"{extent} less its flow ({swing:.2%} of the body's height, {rows:.1f} "
f"rows) is under {BOB_FLOOR:.1%} or {BOB_ROWS} rows: it does not rise and fall"}
half, quarter = (crossings_mod.correlation_on(values, interval/k) for k in (2, 4))
edge = sum(1 for e in signals['edge'] if e)
@@ -633,7 +665,7 @@ def bob_word(signals, interval):
'scale': round(beat['less_head']/beat['less_lowest'], 3) if beat['less_lowest'] else 0.0,
'least': BOB_OWN, 'scale_least': BOB_SCALE}
if half is None or quarter is None or half < BOB_TWICE or quarter > -BOB_TWICE:
- return {**word, 'says': None, 'why': f"its top line less its flow does not rise and fall twice an interval "
+ return {**word, 'says': None, 'why': f"{what} less its flow does not rise and fall twice an interval "
f"({'not read' if half is None else f'{half:+.2f}'} half an interval on, "
f"{'not read' if quarter is None else f'{quarter:+.2f}'} a quarter on: not at least "
f"{BOB_TWICE:+g} and at most {-BOB_TWICE:+g})"}
@@ -719,6 +751,52 @@ def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None, signa
return said
+def cut_word(signals, length):
+ """The body's word on a walk's cut `length` frames long as it is about to be cut, whichever way it was chosen — the
+ pixel search's, the step count's crossings read or not read (loop `_witnessed`). Legs drawn alike loop as well on
+ one step as on two, and crossings read off feet that slide, or off a shadow under them on a picture that moves, can
+ count half steps: the legs cannot say the cut is a cycle, and the body's own rise and fall, once a step, is read
+ instead (`bob_word`, off `signals`: `legs.strike_signals` with `legs.body_signals`), its top line read over its
+ feet (`feet`): a picture moving once a cut, as a slow sway or drift whose turn is a cycle long does, is left whole
+ by the flow taken out at the cut's length and would hide the rise and fall twice it, and the feet move with it.
+ It `says`:
+
+ - `two steps` where it rises and falls twice the cut (`bob_word` on the cut says cycles): the cut is a cycle;
+ - `four steps` where it does so twice half the cut: the cut is two cycles;
+ - `one step` where it does so twice two cuts — once the cut: the cut is one step of a walk, or a whole cycle of a
+ body that rises and falls once a cycle (a limp, a body with no legs that bounces as it goes); the body cannot
+ tell which, and it witnesses no cycle;
+ - None where none of these is read: nothing witnesses the cut whole cycles (`why`, the reading on the cut).
+
+ Returns {'says', 'bob': the reading on the cut, 'on': the reading that said four steps or one step, with its
+ `interval`, 'why' where None}."""
+ if not signals:
+ return {'says': None, 'why': 'no top line read: a frame has no solid body'}
+ bob = bob_word(signals, length, feet=True)
+ if bob['says'] == 'cycles':
+ return {'says': 'two steps', 'bob': bob}
+ for says, span in (('four steps', length/2), ('one step', 2*length)):
+ word = bob_word(signals, span, feet=True)
+ if word['says'] == 'cycles':
+ return {'says': says, 'bob': bob, 'on': {'interval': round(span, 2), **word}}
+ return {'says': None, 'bob': bob, 'why': bob['why']}
+
+
+def unwitnessed(cycle):
+ """Whether a walk's loop leaves with nothing to witness it whole cycles (UNWITNESSED): its crossings left on steps
+ (`read_cycles`, `step_count.cycles.unwitnessed`), or its cut held (`cut_word`, loop `_witnessed`,
+ `cut_witness.held`). `video-set` leaves it out of its state's cycle alignment."""
+ return bool(((cycle.get('step_count') or {}).get('cycles') or {}).get('unwitnessed')
+ or (cycle.get('cut_witness') or {}).get('held'))
+
+
+def four_steps(cycle):
+ """Whether a walk's loop is cut two cycles long, its body rising and falling four times in it (FOUR_STEPS:
+ `cut_word`, loop `_witnessed`, `cut_witness.says`). It stands; `video-set` leaves it out of its state's cycle
+ alignment, its strip counting two steps."""
+ return (cycle.get('cut_witness') or {}).get('says') == 'four steps'
+
+
def _rank(rows, *, flow_limit, seam_max, in_phase):
"""Two-step cuts, best first, and how many of the first passed the gates: in phase (`in_phase`), its top band calm
at the wrap (`_calm`: a thin part the flow hardly sees, a staff, does not jump), its wrap over its step (`ratio`) at
@@ -864,10 +942,11 @@ def step_verdict(cycle):
"""The step count's warnings, in words: crossings left on steps because nothing witnesses two steps an interval
where the clip one interval on is the same picture (`read_cycles`, `unwitnessed`), a cut taken on two steps whose
seam the pixel search refuses (a part off the legs' beat) or that passed no gate, a search's cut kept where no
- two-step cut closes, and a clip that shows its steps but no cut of two."""
+ two-step cut closes, and a clip that shows its steps but no cut of two — and the body's word where it holds the cut
+ (`held_verdict`), crossings read or not."""
counted = cycle.get('step_count')
if not counted or not counted.get('readable'):
- return []
+ return held_verdict(cycle)
s, L = cycle['start'], cycle['length']
out = []
said = counted.get('cycles') or {}
@@ -899,4 +978,28 @@ def step_verdict(cycle):
elif 'two_cuts' in counted and counted['two_cuts'] == 0:
out.append(f"the clip shows its steps (crossings {counted['crossings']}) but no cut of two: the cut {s}/{L} is "
f"{counted['cut']['verdict']} ({counted['cut']['why']}) — count its steps")
- return out
+ return out + held_verdict(cycle)
+
+
+def held_verdict(cycle):
+ """The body's word on the cut, where it holds it (`cut_witness`, loop `_witnessed`), in words: a cut nothing
+ witnesses whole cycles, or one the body rises and falls once in — one step of a walk, or a whole cycle of a body
+ that does so once a cycle — kept as it was chosen. Each names UNWITNESSED."""
+ said = cycle.get('cut_witness') or {}
+ if said.get('held') != 'unwitnessed':
+ return []
+ s, L = said['cut']
+ counted = cycle.get('step_count') or {}
+ basis = (f"the step count reads no feet ({counted.get('why', 'no reading')})" if not counted.get('readable')
+ else "the clip's crossings cannot say it either: read off feet that slide, or off a shadow under them on a "
+ "picture that moves, they count half steps")
+ if said['says'] is None:
+ return [f"nothing that reads no leg witnesses the cut {s}/{L} whole cycles ({said['why']}): {basis} — where the "
+ f"walk's legs are drawn alike, a step loops as a cycle does, and the loop may be half its cycle "
+ f"({UNWITNESSED})"]
+ on = said['on']
+ return [f"nothing that reads no leg witnesses the cut {s}/{L} whole cycles: the body's top line rises and falls of its "
+ f"own once in it ({on['half']:+.2f} a cut on, {on['quarter']:+.2f} half a cut on) — one step of a walk whose "
+ f"legs are drawn alike, half its cycle, or a whole cycle of a body that rises and falls once a cycle (a limp, "
+ f"a body with no legs that bounces as it goes) — and {basis}. The cut is kept as chosen: cut again two long, "
+ f"it would loop two of such a body's cycles ({UNWITNESSED})"]
diff --git a/sprite_gen/video/loop.py b/sprite_gen/video/loop.py
index ce165e7..bf04888 100644
--- a/sprite_gen/video/loop.py
+++ b/sprite_gen/video/loop.py
@@ -1785,6 +1785,37 @@ def _counted(cycle: dict[str, Any], steps: int, *, window: CutWindow, D: np.ndar
return found
+def _witnessed(cycle: dict[str, Any], *, frames: list[Image.Image]) -> dict[str, Any]:
+ """The cut a walk's search and step count chose (`_by_steps`), held to one word before it is cut whichever way it
+ was chosen — the search's, two steps by the clip's crossings, crossings read or not: the body's
+ (`local_cycle.cut_word`), recorded `cut_witness`. Legs drawn alike loop as well on one step as on two, and
+ crossings read off feet that slide, or off a shadow under them on a picture that moves, count half steps.
+
+ - Its own rise and fall twice the cut, or four times: the cut is a cycle, or two, and stands. Cut two cycles, its
+ strip still counts two steps where the crossings counted them, and `video-set` leaves it out of its state's cycle
+ alignment (local_cycle.FOUR_STEPS, `local_cycle.four_steps`).
+ - Else nothing witnesses the cut handed out whole cycles, and it is held (`held: unwitnessed`): kept — two of the
+ clip's crossing intervals where it counted them, else as the search chose it — and named
+ (local_cycle.UNWITNESSED, `held_verdict`); `video-set` leaves it out of its state's cycle alignment
+ (`local_cycle.unwitnessed`). So is a cut the body rises and falls once in (`says` one step): one step of a walk,
+ or a whole cycle of a body that rises and falls once a cycle — a limp, a body with no legs that bounces as it
+ goes — which nothing that reads no leg tells apart. It is never cut again two long: that would loop two of such
+ a body's cycles.
+
+ A cut whose crossings the step count left on steps, nothing witnessing two steps an interval (`cycles.unwitnessed`),
+ is held so already, and named on its step count (`held: step count`). Only a walk or a run comes here
+ (motion-auto, its cycle searched, no count given)."""
+ first = [cycle["start"], cycle["length"]]
+ if ((cycle.get("step_count") or {}).get("cycles") or {}).get("unwitnessed"):
+ cycle["cut_witness"] = {"cut": first, "held": "step count"}
+ return cycle
+ strike = leg_signals(frames)
+ said = {"cut": first, **local_cycle.cut_word({**strike, **legs_mod.body_signals(frames)} if strike else None,
+ cycle["length"])}
+ cycle["cut_witness"] = said if said["says"] in ("two steps", "four steps") else {**said, "held": "unwitnessed"}
+ return cycle
+
+
def _from_lead_in(record: Any, lead: int) -> Any:
"""A search's record (a cut, or the windows a refusal measured) in the clip's own frame numbers: the
search read the clip after its first `lead` frames, so every `start` and `context_pair_range` it wrote
@@ -2124,6 +2155,7 @@ def _cut_loop(
cycle = _by_steps(cycle, refused, frames=source_frames, analysis=analysis, D=D, trajectory=trajectory,
window=window, searched=searched, detect=detect, seam_max=seam_max, cells=cells,
view=view, facing=facing)
+ cycle = _witnessed(cycle, frames=source_frames)
elif cycle_mode == "once":
source_frames = [Image.open(f).convert("RGBA") for f in files]
cycle = nonloop.select_cut(D, masses, fps=fps, ending=partial(
@@ -2840,6 +2872,9 @@ def run(**kwargs: object) -> int:
if "step_count" in payload["cycle"]:
counted = payload["cycle"]["step_count"]
summary["cycle"]["step_count"] = {k: counted[k] for k in ("mode", "readable", "chosen_by", "cut", "why") if k in counted}
+ if "cut_witness" in payload["cycle"]:
+ summary["cycle"]["cut_witness"] = {k: payload["cycle"]["cut_witness"][k] for k in ("cut", "says", "held")
+ if k in payload["cycle"]["cut_witness"]}
if payload.get("ghost_screen", {}).get("ghosts") or payload.get("ghost_screen", {}).get("reads") is False:
summary["ghost_screen"] = payload["ghost_screen"]
for key in ("ghost_given_way", "ghost_kept"):
diff --git a/tests/video/test_cycle_align.py b/tests/video/test_cycle_align.py
index 90d875e..b4158cb 100644
--- a/tests/video/test_cycle_align.py
+++ b/tests/video/test_cycle_align.py
@@ -211,11 +211,11 @@ def test_the_view_picks_the_signal_so_a_short_legged_walk_starts_on_a_strike(vie
assert strike["foot_why"].startswith("no legs to read"), strike
-def _cut(tmp_path: Path, name: str, length: int) -> Path:
+def _cut(tmp_path: Path, name: str, length: int, cycles: int = 1) -> Path:
keyed = tmp_path / f"{name}-keyed"
keyed.mkdir()
for k in range(length + 6):
- _walker(2 * math.pi * k / length).save(keyed / f"{k:04d}.png")
+ _walker(2 * math.pi * cycles * k / length).save(keyed / f"{k:04d}.png")
out = tmp_path / name
loop_mod.run_loop(keyed, out, fps=24.0, state="walk", min_len=None, max_len=None, n_out=None, seam_max=1000.0,
name="walk", report_path=None, cycle_mode="fixed", start=0, length=length, anchor="none", repair="off")
@@ -344,10 +344,10 @@ def test_video_set_aligns_each_gait_filmed_in_two_or_more_directions(tmp_path):
])
def test_video_set_leaves_a_take_to_film_again_or_an_unwitnessed_count_out_of_the_alignment(tmp_path, capsys, named, reasons):
"""A loop named a take to film again because the walk starts or stops in it (`retake` `start-stop`) loops no two
- steps; a loop whose crossings may mark cycles with nothing to witness whether (`cycle-unwitnessed`,
- `local_cycle.read_cycles`) may loop two cycles where it counts two steps, and aligned it would play at twice its
- speed. Either is left out, its loop as cut, its reasons named, and the rest are aligned without it. Left alone, the
- state is not aligned."""
+ steps; a loop whose cut nothing witnesses whole cycles (`cycle-unwitnessed`, `local_cycle.unwitnessed`: its
+ crossings left on steps, or its cut held by the cut witness) may hold half a cycle or two, and aligned as one it
+ would play at twice its speed or half. Either is left out, its loop as cut, its reasons named in words true of
+ half a cycle and of two, and the rest are aligned without it. Left alone, the state is not aligned."""
from sprite_gen.video import batch
rows = []
@@ -362,12 +362,43 @@ def test_video_set_leaves_a_take_to_film_again_or_an_unwitnessed_count_out_of_th
assert [r["loop"]["n_out"] for r in rows] == [out["walk"]["length"]] * 2 + [19] and "cycle_align" not in rows[2]["loop"]
said = capsys.readouterr().err
assert ("a take to film again (start-stop)" in said) is ("start-stop" in reasons)
- assert (f"nothing witnesses whether ({local_cycle.UNWITNESSED})" in said) is (local_cycle.UNWITNESSED in reasons)
+ held = f"nothing witnesses its cut whole cycles ({local_cycle.UNWITNESSED}): it may hold half a cycle or two"
+ assert (held in said) is (local_cycle.UNWITNESSED in reasons) and "may be one step" not in said
alone = batch.align_gaits(rows[1:], tmp_path, "auto", interpolate=Recorder())
assert alone == {"walk": {"ok": True, "applied": False, "why": "fewer than two directions left to align",
"left_out": {"back-walk": reasons}}}
+def test_video_set_leaves_a_loop_its_body_rises_and_falls_four_times_in_out_of_the_alignment(tmp_path, capsys):
+ """A walk's cut its body rises and falls four times in (`cut_witness.says` four steps, `local_cycle.four_steps`) is
+ two cycles long and stands, and its strip counts the two steps its crossings counted (`steps: 2`), which
+ `video-cycle-align` reads as one cycle, a return half way its second step: aligned so to the set's median length,
+ it would play its two cycles where the rest play one, twice as fast. `video-set` leaves it out, its loop and strip
+ as cut, named (`cycle-four-steps`), and aligns the rest without it."""
+ from sprite_gen.video import batch
+
+ rows = []
+ for direction, length, cycles in (("front", 20, 1), ("side", 24, 1), ("back", 40, 2)):
+ item = tmp_path / f"{direction}-walk"
+ item.mkdir()
+ loop = _cut(item, "loop", length, cycles=cycles)
+ named = {}
+ if cycles == 2:
+ strip = loop / "walk.strip.json"
+ strip.write_text(json.dumps({**json.loads(strip.read_text()), "steps": 2}))
+ named = {"cycle-four-steps": True}
+ rows.append({"item": f"{direction}-walk", "direction": direction, "state": "walk", "dir": str(item), "ok": True,
+ "loop": {"n_out": length, **named}})
+ out = batch.align_gaits(rows, tmp_path, "auto", interpolate=Recorder())
+ assert out["walk"].get("lengths") == [20, 24], f"the loop of two cycles is aligned as one: {out['walk']}"
+ assert out["walk"]["applied"] and out["walk"]["left_out"] == {"back-walk": ["cycle-four-steps"]}
+ assert [r["loop"]["n_out"] for r in rows] == [out["walk"]["length"]] * 2 + [40] and "cycle_align" not in rows[2]["loop"]
+ meta = json.loads((tmp_path / "back-walk" / "loop" / "walk.strip.json").read_text())
+ assert meta["frames"] == 40 and meta["steps"] == 2 and "cycle_align" not in meta
+ assert f"four times in its cut ({local_cycle.FOUR_STEPS})" in capsys.readouterr().err
+
+
def _no_rife(monkeypatch, tmp_path: Path) -> None:
monkeypatch.delenv("SPRITE_GEN_RIFE", raising=False)
# PATH keeps every other tool (img2webp, ffmpeg); only the directories holding a RIFE go
diff --git a/tests/video/test_one_step_cut.py b/tests/video/test_one_step_cut.py
index 0a5ab56..7f23cf1 100644
--- a/tests/video/test_one_step_cut.py
+++ b/tests/video/test_one_step_cut.py
@@ -26,7 +26,7 @@ import pytest
from PIL import Image, ImageDraw
from conftest import feet_unseen
-from sprite_gen.video import align, batch, loop, period
+from sprite_gen.video import align, batch, local_cycle, loop, period
from tests.video.test_video_pipeline import HAS_IMG2WEBP
# Every test here cuts a loop, and a loop is written with img2webp: without it they skip, as the
@@ -111,8 +111,12 @@ def test_a_walk_cut_one_step_long_is_named_by_the_step_screen(slow):
assert screen["lag"] in (CYCLE - 1, CYCLE, CYCLE + 1) and screen["ratio"] <= period.STEP_RATIO_MAX
assert screen["depth"] >= loop.PERIODICITY_MIN and screen["pairs"] == FRAMES - screen["lag"]
assert screen["coverage"] == round((FRAMES - screen["lag"]) / screen["lag"], 4)
- # Nothing is cut on it, and nothing else speaks: no warning, no `steps`.
- assert "steps" not in cycle and not any("step" in line for line in report["jolt"]["warnings"])
+ # Nothing is cut on it, and nothing else claims steps: no `steps`. The one other word is the cut witness's: the walker
+ # is carried whole on its legs, so nothing over its feet rises and falls to witness the cut whole cycles, and the cut
+ # is held as the search chose it, named (`cycle-unwitnessed`); `video-set` leaves it out of its cycle alignment.
+ witness, said = cycle["cut_witness"], [line for line in report["jolt"]["warnings"] if "step" in line]
+ assert "steps" not in cycle and witness["held"] == "unwitnessed" and local_cycle.unwitnessed(cycle), witness
+ assert said == local_cycle.held_verdict(cycle) and said[0].endswith(f"({local_cycle.UNWITNESSED})"), said
def _same_but_the_screen(a: Path, b: Path) -> None:
@@ -253,8 +257,12 @@ def test_cycle_align_stops_on_a_loop_that_may_be_one_step_and_names_the_count_th
@pytest.mark.slow
def test_video_set_names_a_loop_that_may_be_one_step_and_its_table_says_so(slow, tmp_path, capsys):
- """A video-set item keeps the cut's report beside its loop directory (`<item>/loop.report.json`):
- the alignment reads the step screen there, and the set stops on the side walk with what settles it."""
+ """A video-set item keeps the cut's report beside its loop directory (`<item>/loop.report.json`), and its row carries
+ the marks `run_set` records of its cut: the walker is carried whole on its legs, so the cut witness holds both cuts,
+ the front walk's whole cycle and the side walk's step (`cycle-unwitnessed`), and the step screen suspects the
+ side walk's. The set leaves both out of its alignment, named in words true of half a cycle and of two, and tells the
+ side walk what settles the step screen's suspicion (`--steps 1`), as `video-cycle-align` does: run on the items'
+ loops, it reads the step screen in the report beside the side walk's loop and stops on it."""
_, keyed, _ = slow
rows = []
for direction, source in (("front", _keyed(tmp_path / "whole", cycle=25)), ("side", keyed)):
@@ -264,13 +272,22 @@ def test_video_set_names_a_loop_that_may_be_one_step_and_its_table_says_so(slow,
anchor="motion-auto", repair="off")
rows.append({"item": f"{direction}-walk", "direction": direction, "state": "walk", "dir": str(item), "ok": True,
"loop": {"cycle": lp["cycle"]["length"], "period": None, "seam_ratio": 1.0, "n_out": lp["n_out"],
+ **({local_cycle.UNWITNESSED: True} if local_cycle.unwitnessed(lp["cycle"]) else {}),
**({"step_screen": lp["cycle"]["step_screen"]} if lp["cycle"]["step_screen"]["suspect"] else {})}})
out = batch.align_gaits(rows, tmp_path, "auto", interpolate=None, between="nearest")
- walk = out["walk"]
- assert walk["applied"] is False and walk["reason"] == "cycle-suspects"
- assert walk["why"].startswith("side-walk may be one step (cut it again with video-loop --steps 1 if it is)")
- assert walk["suspects"][0]["one_step"]["report"] == str((tmp_path / "side-walk" / "loop.report.json").resolve())
- assert "cycles not aligned" in capsys.readouterr().err
+ assert out["walk"] == {"ok": True, "applied": False, "why": "fewer than two directions left to align",
+ "left_out": {"front-walk": [local_cycle.UNWITNESSED], "side-walk": [local_cycle.UNWITNESSED]}}
+ err = capsys.readouterr().err.splitlines()
+ front, side = (next(line for line in err if f"walk: {d}-walk left out of the cycle alignment — " in line)
+ for d in ("front", "side"))
+ held = f"nothing witnesses its cut whole cycles ({local_cycle.UNWITNESSED}): it may hold half a cycle or two"
+ settle = "may be one step (cut it again with video-loop --steps 1 if it is)"
+ assert held in front and held in side and settle in side and settle not in front, (front, side)
+ with pytest.raises(align.CycleSuspects) as stop:
+ align.align_set([Path(r["dir"]) / "loop" for r in rows], between="nearest")
+ (entry,) = stop.value.suspects
+ assert entry["one_step"]["report"] == str((tmp_path / "side-walk" / "loop.report.json").resolve())
+ assert "may be one step" in str(stop.value) and "--steps 1" in str(stop.value)
table = batch.write_table(rows, tmp_path / "table.md")
assert f"| {rows[1]['loop']['cycle']} (one step?) |" in table and f"| {rows[0]['loop']['cycle']} |" in table
rows[1]["loop"] = {**rows[1]["loop"], "cycle": 42, "steps": 2}
diff --git a/tests/video/test_walk_steps.py b/tests/video/test_walk_steps.py
index d8e81c7..226cfc5 100644
--- a/tests/video/test_walk_steps.py
+++ b/tests/video/test_walk_steps.py
@@ -143,7 +143,7 @@ def _outward(k: float, *, cycle: float, bob: int = 3, whole: bool = False) -> Im
def _alike(k: float, *, cycle: float, phase: float = 0, tone: int = 1, lean: float = 0, leg_tone: int | None = None,
leg_half: int = 5, lift: int = 0, light: tuple[str, int] | None = None, bob: int = 3, whole: bool = False,
- air: int = 0, slide: int = 0) -> Image.Image:
+ air: int = 0, slide: int = 0, limp: int = 0) -> Image.Image:
"""A side walker whose two steps are the same silhouette: the far leg and arm `tone` tones lighter than the near
ones (the far leg `leg_tone`, where given: 0 draws the legs alike), the arms swinging `lean` px further back than
forward — nothing else tells a step from the next. Each leg is drawn `leg_half` px either side of its line: at 10
@@ -152,12 +152,13 @@ def _alike(k: float, *, cycle: float, phase: float = 0, tone: int = 1, lean: flo
(`_lit`). The body rises and falls `bob` px once a step on its legs, the feet on the ground (`whole`: carried with
it). A run lifts both soles up to `air` px off the ground while the body is high; a view from behind or a diagonal
draws each sole up to `slide` px lower the further back its foot is (the planted foot sliding down the screen
- through its step)."""
+ through its step). A limp sinks the body `limp` px either way once a cycle, low on one leg's step, high on the
+ other's."""
ph = 2 * math.pi * (k + phase) / cycle
im = Image.new("RGBA", (300, 220))
d = ImageDraw.Draw(im)
drawn = Image.new("L", im.size)
- x, y = 90, 40 + round(bob * math.cos(2 * ph))
+ x, y = 90, 40 + round(bob * math.cos(2 * ph) + limp * math.cos(ph))
for sign, t in ((1, 0), (-1, tone)):
sw = sign * (16 * math.sin(ph) + lean)
d.rectangle((x + 14 - sw - 4, y + 34, x + 14 - sw + 4, y + 72), fill=(190 + t, 190 + t, 190 + t, 255))
@@ -420,7 +421,9 @@ def test_a_diagonal_walk_whose_near_foot_steps_out_is_cut_one_cycle_from_its_vie
screen once a cycle, and briefly — no pass hides. Given the view, the count asks the picture: the clip one interval
on is the same picture, the legs as they were, the view's foot cue does not turn over there, and the body rises and
falls twice an interval. One cycle, `steps: 2` (the parent engine counted each meeting a step and cut two cycles,
- 32 and 36 frames). Without the view it is not asked, and cuts as before."""
+ 32 and 36 frames). Without the view it is not asked, and cuts as before, two cycles: its body rises and falls four
+ times in the cut, which stands, its strip counting two steps, and `video-set` leaves it out of its cycle alignment
+ (`local_cycle.four_steps`)."""
keyed = _keyed(tmp_path, lambda k: _outward(k, cycle=cycle))
_cut(tmp_path / "view", keyed, "--view", "front_diagonal")
counted = _one_cycle(tmp_path / "view", cycle)
@@ -434,6 +437,8 @@ def test_a_diagonal_walk_whose_near_foot_steps_out_is_cut_one_cycle_from_its_vie
assert counted["cycles"]["bob"]["says"] == "cycles"
plain = _cut(tmp_path / "plain", keyed)
assert "cycles" not in plain["cycle"]["step_count"] and abs(plain["cycle"]["length"] - 2 * cycle) <= 1
+ said = plain["cycle"]["cut_witness"]
+ assert said["says"] == "four steps" and local_cycle.four_steps(plain["cycle"]) and plain["cycle"]["steps"]["count"] == 2
@pytest.mark.slow
@@ -668,12 +673,25 @@ def test_a_walk_the_search_cuts_two_steps_in_phase_is_cut_as_before(tmp_path):
@pytest.mark.slow
def test_a_body_with_no_feet_to_read_is_cut_as_the_search_cuts_it(tmp_path):
+ """A legless body bouncing every 16 frames — a walk the window admits (`walk`'s floor): no feet to read, and the
+ search's cut stands as it cut it, never cut again two long. The body rises and falls once a bounce, once a cycle: a
+ cut of one bounce is the body's whole cycle, and to the body's word it is one step as well — nothing that reads no
+ leg tells them apart, so the cut is held and named, not cut again (two bounces); a cut the body rises and falls
+ twice in stands."""
keyed = _keyed(tmp_path, _blob, frames=64)
report = _cut(tmp_path / "out", keyed)
- counted = report["cycle"]["step_count"]
+ c = report["cycle"]
+ counted = c["step_count"]
assert counted["readable"] is False and counted["chosen_by"] == "search" and counted["why"]
- assert counted["search"]["cut"] == [report["cycle"]["start"], report["cycle"]["length"]]
+ assert counted["search"]["cut"] == [c["start"], c["length"]]
assert "steps" not in report["cycle"] and "steps" not in json.loads((tmp_path / "out" / "loop.strip.json").read_text())
+ said = c["cut_witness"]
+ assert said["cut"] == [c["start"], c["length"]] and said["says"] in ("one step", "two steps")
+ if said["says"] == "one step":
+ _held(report)
+ assert abs(c["length"] - 16) <= 1
+ else:
+ assert "held" not in said and not local_cycle.unwitnessed(c)
@pytest.mark.slow
@@ -723,12 +741,14 @@ def _reading(run: int) -> crossings.Reading:
runs=[(c - run // 2, c + run // 2) for c in middles])
-def _body(top, *, lowest=None, crown=None, edge=None) -> dict:
+def _body(top, *, lowest=None, crown=None, edge=None, sole=None) -> dict:
"""Leg signals (`legs.strike_signals`, `legs.body_signals`) of a body 100 rows tall whose top line is `top` (per
- frame), its lowest row `lowest` (140 throughout: the feet on the ground) and its head `crown` wide (log; 20 px
- throughout), no lowest row on the frame's last row unless `edge` says where."""
+ frame), its lowest row `lowest` (140 throughout: the feet on the ground), its lowest opaque row `sole` (the lowest
+ row's: nothing translucent under the feet) and its head `crown` wide (log; 20 px throughout), no lowest row on the
+ frame's last row unless `edge` says where."""
n = len(top)
- return {"top": [float(v) for v in top], "reach": [140.0] * n if lowest is None else [float(v) for v in lowest],
+ reach = [140.0] * n if lowest is None else [float(v) for v in lowest]
+ return {"top": [float(v) for v in top], "reach": reach, "sole": list(reach) if sole is None else [float(v) for v in sole],
"crown": [math.log(20)] * n if crown is None else [float(v) for v in crown],
"edge": [0.0] * n if edge is None else [float(v) for v in edge], "height": [100.0] * n}
@@ -1104,6 +1124,202 @@ def test_a_walk_whose_planted_foot_slides_down_the_screen_is_never_witnessed_two
assert _word_of(_carried(lambda k: frames[k], _shake(shake, 23)), 23)["says"] is None, (slide, shake)
[email protected]("beat, says", [(8, "two steps"), (4, "four steps"), (16, "one step"), (None, None)])
+def test_a_cut_is_witnessed_by_how_often_the_body_rises_and_falls_in_it(beat, says):
+ """`cut_word` on a cut 16 frames long, the body 100 rows tall on feet that stay on the ground, its top line rising
+ and falling 3 rows either way every `beat` frames: twice the cut is two steps, a cycle; four times, two cycles;
+ once, one step — or a whole cycle of a body that rises and falls once a cycle, which the word cannot tell from it;
+ held still, nothing witnesses the cut whole cycles."""
+ word = local_cycle.cut_word(_bob(beat), 16)
+ assert word["says"] == says
+ if says is None:
+ assert word["bob"]["says"] is None and word["why"] == word["bob"]["why"]
+ elif says != "two steps":
+ assert word["on"]["says"] == "cycles" and word["on"]["interval"] == {"four steps": 8, "one step": 32}[says]
+
+
+def test_a_shadow_on_the_screen_under_the_feet_does_not_hold_a_shaken_picture_still_for_the_witness():
+ """`bob_word` on an interval of 15 frames, the body 100 rows tall on a picture moved 3 rows up and down twice an
+ interval: its top line and its feet move with the picture, but a shadow drawn translucent under the feet and fixed
+ on the screen is its lowest solid row, and holds still. Read against that row alone the picture's moving is the
+ body's own (it witnessed two steps an interval so); against the lowest opaque row, the feet's, nothing is left."""
+ t = np.arange(FRAMES)
+ moved = np.round(3 * np.cos(4 * np.pi * (t - 8) / 15))
+ shadowed = _body(40 + moved, lowest=[150.0] * FRAMES, sole=140 + moved)
+ word = local_cycle.bob_word(shadowed, 15)
+ assert word["says"] is None and "its lowest row rises and falls with it" in word["why"]
+ assert word["body"]["lowest"] == 0 and word["body"]["sole"] == pytest.approx(word["body"]["beat"])
+ assert local_cycle.bob_word({**shadowed, "sole": shadowed["reach"]}, 15)["says"] == "cycles"
+
+
+# A shadow drawn dark and translucent (alpha 200) under the walker's feet, 36 px wide (narrower than the body's widest
+# run, so the top line stays on the body): apart (6..12 px under the soles) or touching (over the soles' last 3 rows).
+SHADOWS = {"apart": (86, GROUND + 6, 122, GROUND + 12), "touch": (86, GROUND - 3, 122, GROUND + 5)}
+
+
+def _shadowed(draw, motion, *, shadow: str, screen: bool, room: int = 60):
+ """`draw`'s walker over a SHADOWS `shadow`, the picture moved `motion(k)` px down in frame k on a canvas `room` px
+ taller either side; the shadow drawn on the screen (`screen`: it stays while the picture moves) or with the walker.
+ The shadow is solid to the legs' reading: the feet are not seen apart over it."""
+ box = SHADOWS[shadow]
+
+ def frame(k: int) -> Image.Image:
+ walker = draw(k)
+ out = Image.new("RGBA", (walker.width, walker.height + 2 * room))
+ if screen:
+ ImageDraw.Draw(out).ellipse((box[0], box[1] + room, box[2], box[3] + room), fill=(40, 40, 40, 200))
+ out.alpha_composite(walker, (0, room + motion(k)))
+ else:
+ layer = Image.new("RGBA", walker.size)
+ ImageDraw.Draw(layer).ellipse(box, fill=(40, 40, 40, 200))
+ layer.alpha_composite(walker)
+ out.paste(layer, (0, room + motion(k)))
+ return out
+ return frame
+
+
+def _not_silent(report: dict, cycle: float) -> None:
+ """The plan's count of a silent half cycle, whichever way the cut was chosen: a loop handed out (passed) shorter
+ than three quarters of the walk's `cycle`, with no warning naming UNWITNESSED and no retake reason. None is."""
+ c = report["cycle"]
+ named = any(local_cycle.UNWITNESSED in w for w in report["jolt"]["warnings"]) or (report.get("retake") or {}).get("reasons")
+ assert report["status"] != "passed" or c["length"] >= 0.75 * cycle or named, (
+ f"the cut {c['start']}/{c['length']} of a walk {cycle} frames a cycle is handed out, nothing named")
+
+
+def _held(report: dict) -> dict:
+ """Nothing that reads no leg witnesses the cut handed out whole cycles — the body's rise and fall not read twice
+ in it, or once (one step, or a whole cycle of a body that rises and falls once a cycle): it is held as chosen
+ (`cut_witness.held`), never cut again, a warning names it (UNWITNESSED), and `video-set` leaves it out of its cycle
+ alignment (`local_cycle.unwitnessed`)."""
+ c = report["cycle"]
+ said = c["cut_witness"]
+ assert report["status"] == "passed" and said["held"] == "unwitnessed" and local_cycle.unwitnessed(c)
+ assert said["cut"] == [c["start"], c["length"]] and said["says"] in (None, "one step") and "cut_again" not in said
+ assert (c.get("steps") or {}).get("by") != "body"
+ assert any(local_cycle.UNWITNESSED in w and f"the cut {c['start']}/{c['length']} whole cycles" in w
+ for w in report["jolt"]["warnings"])
+ return said
+
+
[email protected]("body", ["on-its-legs", "whole"])
+def test_a_walk_whose_feet_a_shadow_hides_from_the_step_count_is_never_cut_one_step_unnamed(tmp_path, body):
+ """The wide walker with its legs drawn alike, its crossings its steps every 23 frames, over a shadow drawn with it
+ apart under its feet: the step count reads no feet, and the search cuts 23 frames — one step, which loops as a cycle
+ does where the legs are drawn alike (the parent engine handed it out so, nothing named). Rising and falling on its
+ legs once a step, the body rises and falls once the cut — one step, or a whole cycle of a body that does so once a
+ cycle; carried up and down whole, feet and all, it does not of its own. Either way nothing that reads no leg says
+ the cut is a cycle: held as cut, named. (Held still on its legs, the loop is refused: its wrap jumps.)"""
+ drawn = {"on-its-legs": {}, "whole": {"whole": True}}[body]
+ report = _cut(tmp_path / "out", _keyed(tmp_path, _shadowed(lambda k: _alike(k, **_STEPS, **drawn), lambda k: 0,
+ shadow="apart", screen=False)))
+ _not_silent(report, 46)
+ counted = report["cycle"]["step_count"]
+ assert counted["readable"] is False and counted["chosen_by"] == "search"
+ said = _held(report)
+ assert said["says"] == {"on-its-legs": "one step", "whole": None}[body]
+ assert said["cut"] == counted["search"]["cut"] and abs(said["cut"][1] - 23) <= 1
+
+
+def test_a_walk_whose_planted_foot_slides_is_never_cut_one_step_unnamed(tmp_path):
+ """The wide walker rising and falling on its legs once a step, its crossings its steps every 23 frames, each sole
+ drawn up to 12 px lower the further back its foot is (as a view from behind or a diagonal draws it) and the foot
+ moving forward lifted 8 px: the step count reads a crossing every half step and counts the search's 23 frames — one
+ step — two (the parent engine handed it out so, nothing named). The body rises and falls once the cut: one step,
+ or a whole cycle of a body that does so once a cycle, and the crossings cannot say which: held as cut, named."""
+ report = _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _alike(k, **_STEPS, lift=8, slide=12)))
+ _not_silent(report, 46)
+ counted = report["cycle"]["step_count"]
+ assert counted["readable"] and counted["chosen_by"] == "search" and counted["cut"]["verdict"] == "two"
+ said = _held(report)
+ assert said["says"] == "one step" and said["cut"] == counted["search"]["cut"] and abs(said["cut"][1] - 23) <= 1
+
+
+def test_a_limping_walk_is_never_cut_two_cycles_long(tmp_path):
+ """A side walker whose legs a tone or a few apart tell its steps apart, 30 frames a cycle, filmed 100 frames (long
+ enough to read its body's rise and fall over twice the cut), whose body sinks on one leg's step and not the
+ other's: it rises and falls once a cycle, as a body with no legs that bounces does. The search cuts it a cycle, two
+ steps by its crossings. To the body's word the cut is one step, and it cannot tell that from one cycle of such a
+ body: the cut stands as it was cut, held, named — never cut again two long, two cycles."""
+ report = _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _alike(k, cycle=30, phase=8, tone=4, lean=1, bob=0, limp=3),
+ frames=100))
+ c = report["cycle"]
+ assert report["status"] == "passed" and abs(c["length"] - 30) <= 1.5
+ assert c["step_count"]["chosen_by"] in ("search", "two steps") and c["steps"] == {"count": 2, "by": "crossings"}
+ said = _held(report)
+ assert said["says"] == "one step" and said["on"]["interval"] == 2 * c["length"]
+
+
+def test_a_walk_over_a_shadow_on_the_screen_on_a_shaken_picture_is_never_cut_a_quarter_cycle_unnamed(tmp_path):
+ """The wide walker rising and falling on its legs once a step (23 frames), over a shadow drawn on the screen apart
+ under its feet, on a picture shaken 12 px up and down every half step: the feet move in and out over the shadow with
+ the picture, and the step count reads a crossing every quarter step and cuts two of them — 12 frames, a quarter of
+ a cycle (the parent engine handed it out so, nothing named). Against the lowest opaque row, the feet's, moving with
+ the picture where the shadow holds still, the body does not rise and fall of its own twice the cut, nor once: held,
+ named."""
+ shaken = _shadowed(lambda k: _alike(k, **_STEPS), _shake((0.5, 12, 0), 23), shadow="apart", screen=True)
+ report = _cut(tmp_path / "out", _keyed(tmp_path, shaken))
+ _not_silent(report, 46)
+ assert report["cycle"]["step_count"]["readable"] and report["cycle"]["step_count"]["chosen_by"] == "two steps"
+ assert _held(report)["cut"][1] <= 14
+
+
+def test_a_walk_on_a_picture_moved_every_two_thirds_of_a_step_is_never_cut_a_third_of_a_cycle_unnamed(tmp_path):
+ """The wide walker rising and falling on its legs once a step (23 frames), on a picture moved 12 px up and down
+ every two thirds of a step (dy = round(12 sin(2 pi k / (2/3 x 23) + pi/2))): the search cuts the picture's own 15
+ frames, a third of a cycle, and the step count keeps it (the parent engine handed it out so, nothing named).
+ Against its feet, moving with the picture, the body does not rise and fall twice the cut, nor once: held, named."""
+ report = _cut(tmp_path / "out", _keyed(tmp_path, _carried(lambda k: _alike(k, **_STEPS), _shake((2 / 3, 12, math.pi / 2), 23))))
+ _not_silent(report, 46)
+ assert report["cycle"]["step_count"]["chosen_by"] == "search" and _held(report)["cut"][1] <= 16
+
+
+def test_a_still_walk_over_a_shadow_on_the_screen_on_a_picture_shaken_twice_a_step_is_never_witnessed(tmp_path):
+ """The wide walker held still on its legs (crossings its steps, 23 frames), over a shadow drawn on the screen
+ touching its soles, on a picture shaken 6 px up and down twice a step: the step count reads no feet, and the search
+ cuts 23 frames — one step. The top line rises and falls twice the cut with the picture, and the lowest solid row is
+ the shadow, holding still: read over it alone, the picture's moving is the body's own and witnesses two steps.
+ Over the lowest opaque row, the feet's, the top line holds still: held, named."""
+ shaken = _shadowed(lambda k: _alike(k, **_STEPS, bob=0), _shake((0.5, 6, math.pi / 2), 23), shadow="touch", screen=True)
+ report = _cut(tmp_path / "out", _keyed(tmp_path, shaken))
+ _not_silent(report, 46)
+ assert report["cycle"]["step_count"]["readable"] is False
+ said = _held(report)
+ bob = said["bob"]
+ assert abs(said["cut"][1] - 23) <= 1 and said["says"] is None
+ assert bob["over"] == "sole" and bob["rows"] < local_cycle.BOB_ROWS and "does not rise and fall" in said["why"]
+ frames = [shaken(k) for k in range(FRAMES)]
+ signals = {**legs.strike_signals(frames), **legs.body_signals(frames)}
+ assert local_cycle.cut_word({**signals, "sole": signals["reach"]}, said["cut"][1])["says"] == "two steps"
+
+
[email protected]("walker, cycle, sway", [("steps", 46, (2, 12, 0)), ("steps", 46, (3, 24, math.pi / 2)),
+ ("behind", 20, (2, 24, 0))])
+def test_a_walk_rising_on_its_legs_on_a_picture_swaying_once_a_cycle_or_slower_is_witnessed_one_cycle(tmp_path, walker, cycle, sway):
+ """A walk rising and falling on its legs once a step, its feet on the ground, on a picture swaying up and down once
+ a cycle or slower — 12 px either way every 46 frames or 24 px every 69 (the wide walker with its legs drawn alike,
+ its crossings its steps every 23 frames), 24 px every 40 (the walker whose far foot passes hidden, 20 frames a cycle
+ on twos): a slow motion of the whole picture, not the walk's. The cut is a cycle. Taken out at the cut's length,
+ the flow leaves the sway whole, and the top line on the screen rises and falls with it once the cut: read so, the
+ body's rise and fall twice the cut is hidden and the cycle held. Over its feet, which move with the picture, the
+ top line rises and falls twice the cut: two steps, witnessed, nothing named."""
+ draw, d = {"steps": (lambda k: _alike(k, **_STEPS), 23), "behind": (lambda k: _behind(k, cycle=20, hold=2), 20)}[walker]
+ report = _cut(tmp_path / "out", _keyed(tmp_path, _carried(draw, _shake(sway, d))))
+ _not_silent(report, cycle)
+ c = report["cycle"]
+ said = c["cut_witness"]
+ assert report["status"] == "passed" and abs(c["length"] - cycle) <= 1.5 and said["cut"] == [c["start"], c["length"]]
+ assert said["says"] == "two steps" and said["bob"]["over"] in ("reach", "sole") and "held" not in said
+ assert not local_cycle.unwitnessed(c) and not any(local_cycle.UNWITNESSED in w for w in report["jolt"]["warnings"])
+
+
@pytest.mark.parametrize("verdict, named", [("uncertain", True), ("two", False)])
def test_a_walk_that_starts_and_stops_in_the_take_is_named_to_film_again(verdict, named):
"""Feet together 15 frames at the head and 14 at the tail, longer than any pass the clip shows whole (8, 3): the