Skip to content

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

Merge branch 'aldegad/polyfit-tie-determinism' — the size hold and the gait fallback scale the same frames on every machine (gait_fallback._trend is decided exactly; loop.drift_reference and motion_anchor._register measured and left: neither flips on macOS, Linux or under noise)

Soohong Kim28a4fe44e459
diff --cc CHANGELOG.md
index 7108eaa,b0323e1..1064f10
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -4,11 -4,10 +4,13 @@@ All notable public changes to `sprite-g
## Unreleased
+- **Output change: `video-follow --on-fold lower` gives each region a gain of its own.** One gain for the strip, set by the region with the smallest radius, let the smallest ellipse decide for every part: a small one (an ear) lowered a large one (a chest) to its own gain, and where that gain went under 1 refused the whole strip, so the chest did not move either. Now a region that folds at `--gain` takes the largest gain that does not fold it (in steps of 0.01), a region that does not fold keeps `--gain`, and one that would have to go under 1, the mass as measured, is **held**: it does not move, and stderr names it by its `--region` (`video-follow: --region <cx,cy,rx,ry> folds at --gain <g>, under 1 (the mass as measured): it is held, and does not move`); a region lowered while another keeps its gain is named the same way (`video-follow: --gain 2.5 folds --region <cx,cy,rx,ry> (a move of <px> px); lowered to --gain <g> for it`). The strip is refused only when every region is held, and that message names the largest region (`… folds a region of radius <r> px over itself (the largest of <n> regions: every one folds), and --on-fold lower would have to go under --gain 1 …`); with one region it reads as before. Where regions of different gains overlap, the larger move wins (`follow.move_regions` takes groups of regions, each with its own offset), and the move there is nowhere steeper than either region's own. In the record each `fold.regions` entry gains `gain` (0 when held) and `held`, the strip's `gain` is the largest any region moved by (`dx_px`, `dy_px` and `reach_px` are that gain's), `fold.ratio` is the nearest any region came to folding and `fold.lowered` says whether any region was lowered or held; the printed summary gains `region_gains`. A strip whose regions all take one gain — one region, regions that fold alike, or none that folds — is written as before, strip, GIF, WebP and record byte for byte. `--on-fold refuse`, the default, is unchanged. [docs/video-pipeline.md](docs/video-pipeline.md#6-follow-through--video-follow).
+- **`tests/video/test_follow.py`** moves a chest with a region on the head too small to move at gain 1: before this the strip was refused, now the head region is held and the strip is the chest's alone, byte for byte (and at `--gain 0.9` the chest still moves at 0.9). A head region that folds at 1.75 beside a chest that does not fold takes 1.75 while the chest keeps 2.5, each region's pixels those of the region moved alone at its gain; a small region inside a larger one folds nowhere; a strip whose every region is held is refused untouched; two regions that fold alike are written with the one-gain record and the strip their gain asked for gives; the command names the region it lowered and the one it held.
+
- - **Fix: `video-loop --anchor motion-auto` reads the same motion from the same pixels on every machine.** A patch of its region search that sits on a flat fill matches equally at several offsets; the FFTs that score them round differently between numpy builds (about 1e-14), and that rounding chose the offset. From the same frames a synthetic walk was tracked differently on Linux than on macOS, its distance matrix differed in most entries, and `tests/video/test_loop_prop_seam_held.py` failed on CI only (first choice popping 2.4 there, 11.7 on macOS). Now costs within 1e-9 of the lowest are one match (`auto_motion.MATCH_TIE`) and the offset nearest the centre the search was put on is taken; regions whose qualities tie on that grain are ranked by their box; and the drift lines that move the analysis frames are least-squares lines with exactly rounded sums (`auto_motion._line`), not `np.polyfit`, whose LAPACK solve rounded differently and tipped bilinear samples of those frames. The tracked offsets, the analysis frames and the distance matrix are now bit-identical on macOS arm64 and Linux x86-64; only the last digits of reported costs and scores differ. Footage whose patches never tie is cut as before: the same regions, offsets and cut, its analysis translations moved only in their last bits (about 1e-14), which can tip a bilinear sample and move a score in its sixth decimal. Drawn, flat-filled frames, where ties are the rule, are tracked — and may be cut — otherwise than v2.36.0 tracked them on any one machine.
+ - **Fix: `video-loop --anchor motion-auto` reads the same motion from the same pixels on every machine.** A patch of its region search that sits on a flat fill matches equally at several offsets; the FFTs that score them round differently between numpy builds (about 1e-14), and that rounding chose the offset. From the same frames a synthetic walk was tracked differently on Linux than on macOS, its distance matrix differed in most entries, and `tests/video/test_loop_prop_seam_held.py` failed on CI only (first choice popping 2.4 there, 11.7 on macOS). Now costs within 1e-9 of the lowest are one match (`auto_motion.MATCH_TIE`) and the offset nearest the centre the search was put on is taken; regions whose qualities tie on that grain are ranked by their box; and the drift lines that move the analysis frames are least-squares lines with exactly rounded sums (`auto_motion._line`, now `sprite_gen.util.lsq.line`), not `np.polyfit`, whose LAPACK solve rounded differently and tipped bilinear samples of those frames. The tracked offsets, the analysis frames and the distance matrix are now bit-identical on macOS arm64 and Linux x86-64; only the last digits of reported costs and scores differ. Footage whose patches never tie is cut as before: the same regions, offsets and cut, its analysis translations moved only in their last bits (about 1e-14), which can tip a bilinear sample and move a score in its sixth decimal. Drawn, flat-filled frames, where ties are the rule, are tracked — and may be cut — otherwise than v2.36.0 tracked them on any one machine.
- **`tests/video/test_auto_motion.py`** perturbs every FFT correlation by up to 1e-12 of its largest value, seed by seed: the tied offset taken on the flat torso, the regions found and every tracked offset are the same under all of them (under v2.36.0 eight seeds took six offsets, 14 px apart, and four seeds found four different region pairs), and the drift line is `np.polyfit`'s to 1e-12 and bit-identical in any order of its points. `test_a_held_part_that_swings_with_the_step_is_cut_one_step_long` draws its pennant on a 53-frame beat (phase 0.75): its first choice pops 12.6, no other candidate's top over 8.5, the cut taken closes below the hand at 0.0; on v2.35.0 with this fix it fails where v2.35.0 reads nothing below the top.
+ - **Fix: the size hold and the gait fallback of `video-loop --anchor motion-auto` scale the same frames on every machine.** Both scale every frame back about a foot point read off a fitted line, and size the room the frames need from it. The line was `np.polyfit`'s, whose LAPACK solve rounds differently between builds (Accelerate on macOS, OpenBLAS on Linux; on the 10-05 synthetic grid their lines lay a few 1e-13 px apart). Feet that stand on the frame's bottom edge in every frame sit exactly where that rounding decides: on a synthetic walker growing 3 %, `np.polyfit` on Linux put them 4 units in the last place past the edge, and with its coefficients moved by up to 1e-12 of themselves, four seeds in eight gave the frames 2 px of room below and four none — another frame size, and so other frames for the cut search. The lines are now least-squares lines with exactly rounded sums (`sprite_gen.util.lsq`, the line `auto_motion` already drew its analysis drift with, moved there): feet on the edge read exactly the edge, and the foot point, the room and every held pixel are the same under any rounding. A clip the hold leaves as filmed and the fallback does not scale is cut as before.
+ - **`tests/video/test_gait_fallback.py`** holds a synthetic walker whose feet stand on the frame's bottom edge with `np.polyfit`'s coefficients moved by up to 1e-12 of themselves, seed by seed: the foot point, the room and every held pixel are the same under all of them (under v2.36.0 eight seeds gave eight foot points and two paddings); a walker that neither moves nor grows reads its box's foot point and height to the bit. `tests/test_lsq.py` checks the line against `np.polyfit` and in any order of its points (moved from `test_auto_motion.py`).
## v2.36.0 - A slow walk cut one step long is named, and cut again on a count; a staff that closes only on two steps is cut as one cycle