Repository navigation
core: image diff, RGBA8 pixels to the rects that differ - #667
Merged
Merged
Conversation
core.diff.Image walks two images a row at a time (identical rows cost one vectorized compare), compares differing rows per 32x32 (or 16x16) tile segment, merges changed tiles into rects and shrinks each to its exact changed pixels, with an optional per-channel tolerance and a max_rects coalesce. core.diff.TileGrid keeps 8 bytes per tile to diff a past step. std-only; bench-diff measures the DIFF_PLAN section 3 budget. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RYmfUKnG4kP4sBA4jTt5CX
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RYmfUKnG4kP4sBA4jTt5CX
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RYmfUKnG4kP4sBA4jTt5CX
…change, bench) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RYmfUKnG4kP4sBA4jTt5CX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of fizzyedit/plans
plans/DIFF_PLAN.mdstep 3 (2.4, 3). Independent of step 1 (text):core/diff.zigis the namespace and only namesImage/TileGrid; step 1 adds its files beside them.What
core.diff.Image: stride-aware RGBA8 diff. Identical rows cost one 64-byte-vector compare (firstDiff); differing rows are compared per 32x32 (or 16x16) tile segment from the first differing byte. Changed tiles merge into rects (runs along a row, joined to an identical run above), each shrunk to its exact changed pixels (exact, default) with a pixel count. Optional per-channeltolerance,max_rectscoalescing into a bounding box,size_changedfor different sizes (overlap diffed). Shared storage and identical buffers return early. Reusable state: no allocation after the first diff of a size.core.diff.TileGrid: 8 bytes per tile (63 KB for 4K), keepable per step;diffcompares two grids into tile rects.bench-diff+ unit tests (including a property test that the rects cover every differing pixel and the pixel count is exact), rootfizzy-diff-tests.Bench (
zig build bench-diff -Doptimize=ReleaseFast, Linux cloud box)std.mem.indexOfDiff/eqlwere ~4-6x slower than the vector loop here, hencefirstDiff. Tile size default (32 vs 16) andtolerancestay open questions in the plan.SDK / UI
No SDK or plugin boundary change, no UI.
Generated by Claude Code