Skip to content

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

test(loop): a pixel's jitter of a walk that barely moves is not a jump, a frame moved two pixels is (red); the walk going away keeps its whole-row feet

Soohong Kim55c343878a5d
diff --git a/tests/video/test_gait_fallback.py b/tests/video/test_gait_fallback.py
index 393e395..777c83c 100644
--- a/tests/video/test_gait_fallback.py
+++ b/tests/video/test_gait_fallback.py
@@ -239,14 +239,10 @@ def test_a_settle_does_not_hide_a_walk_that_grows(tmp_path):
assert np.ptp(heights[:, 3]-heights[:, 1]) <= 6
-def walking_away(k, frames=73, sub_pixel=False):
+def walking_away(k, frames=73):
"""A walker going away from the camera: 15 % smaller by the end and its feet 20 px higher in the
- frame (the ground recedes toward the horizon), its crown 10 px under the top at the start. By
- whole crop rows the feet rise a pixel every three or four frames; `sub_pixel` raises them evenly."""
+ frame (the ground recedes toward the horizon), its crown 10 px under the top at the start."""
image = walker(k, grow=-0.15, frames=frames)
- if sub_pixel:
- return image.convert('RGBa').transform(image.size, Image.Transform.AFFINE, (1, 0, 0, 0, 1, 40 + 20*k/(frames-1)),
- resample=Image.Resampling.BICUBIC).convert('RGBA')
rows = 40 + round(20*k/(frames-1))
out = Image.new('RGBA', image.size)
out.alpha_composite(image.crop((0, rows, image.width, image.height)), (0, 0))
@@ -284,9 +280,7 @@ def test_no_room_is_added_when_nothing_reaches_out():
def test_the_held_loop_of_a_shrinking_walk_keeps_its_crown(tmp_path):
- # The feet rise evenly: by whole rows they jump a pixel every few frames, which on a walk this
- # slow is a step the step gate reads 2.7 times the loop's mean and refuses.
- frames = [walking_away(k, sub_pixel=True) for k in range(73)]
+ frames = [walking_away(k) for k in range(73)]
code, report, output = run(tmp_path, frames)
assert code == 0
assert report['size_hold']['applied'] is True and report['size_hold']['padding_ltrb'][1] > 0
diff --git a/tests/video/test_loop_silent_pass.py b/tests/video/test_loop_silent_pass.py
index 25ba738..be808f8 100644
--- a/tests/video/test_loop_silent_pass.py
+++ b/tests/video/test_loop_silent_pass.py
@@ -3,7 +3,8 @@
- The step gate: every step of a walk's or run's loop as it plays, read between its drawings (`loop.drawing_steps`), the
largest over their mean at most STEP_RATIO_MAX — a frame that jumps inside the loop, where the seam ratio at the wrap
- does not see it, fails the loop. A loop held on twos or threes is read a drawing a step, not a frame a step.
+ does not see it, fails the loop. A loop held on twos or threes is read a drawing a step, not a frame a step. A largest
+ step under STEP_NOISE_MAX is a pixel's jitter of a loop that barely moves, not a jump, however it reads over the mean.
- A frame the jump repair took off the flow and could not make again (its group refused) and that stays off the flow is
`jump_repair.unfixed`, said in a warning line; `--unfixed refuse` fails such a loop.
- A fixed cut the clip's own crossings count an odd number of steps fails (`loop.fixed_count`), but where the clip a cut on
@@ -27,6 +28,7 @@ from PIL import Image, ImageDraw
from sprite_gen.video import local_cycle, repair
from sprite_gen.video import loop as loop_mod
+from tests.video import test_gait_fallback as gait
from tests.video import test_loop_overlap as overlap
from tests.video import test_loop_repair as ponytail
from tests.video.test_body_anchor_gate import PERIOD, _keyed, _moved, _refused, _walk
@@ -87,6 +89,29 @@ def test_a_walk_held_on_threes_is_read_between_its_drawings(tmp_path: Path):
assert float(steps.max()) / mean > loop_mod.STEP_RATIO_MAX # read a frame a step, the hold would fail it
+def test_a_pixels_jitter_of_a_walk_that_barely_moves_is_under_the_noise_floor(tmp_path: Path):
+ """The gait fallback's walk going away from the camera, its feet rising a whole crop row every three or four frames:
+ on a walk that barely moves, the step with a row in it is over 2.5 times the loop's mean step, and a pixel's jitter
+ under the noise floor. The loop passes, the reading said in `step_gate`."""
+ code, report, _ = gait.run(tmp_path, [gait.walking_away(k) for k in range(73)])
+ assert code == 0 and report["status"] == "passed"
+ gate = report["step_gate"]
+ assert gate["largest_ratio"] > loop_mod.STEP_RATIO_MAX and gate["largest_step"] <= loop_mod.STEP_NOISE_MAX
+ assert gate["under_noise"] is True and gate["noise_max"] == loop_mod.STEP_NOISE_MAX and "kept" not in gate
+
+
+def test_a_frame_moved_two_pixels_is_a_jump_over_the_noise_floor(tmp_path: Path):
+ """The side walk standing in place, frame JUMP of the cut moved 2 px and back (6 px as the walk is cut 400 px tall):
+ its step is over the noise floor, and the loop fails on it."""
+ frames = _walk(drift=0.0)
+ frames[JUMP] = _moved(frames[JUMP], 2)
+ message, report = _refused(tmp_path, _keyed(tmp_path, "walk", frames), "cut")
+ assert message.startswith("video-loop: loop step ratio ") and report["seam_refusal"]["reading"] == "steps"
+ gate = report["step_gate"]
+ assert gate["largest_ratio"] > loop_mod.STEP_RATIO_MAX and gate["largest_step"] > loop_mod.STEP_NOISE_MAX
+ assert "under_noise" not in gate
+
+
def _smeared(a: Image.Image, b: Image.Image, t: float) -> Image.Image:
"""A stand-in RIFE whose every frame carries a black smear across the body: a fault, so each group is refused."""
out = b.copy()