Commit Graph
3 Commits
Author SHA1 Message Date
Isaac ConnorandClaude Opus 5.5 bfbe4115e7 test: select the SIMD delta helpers whichever test ran first
The Delta tests set config.cpu_extensions before the first Image is built,
but Image::Initialise() latches the helpers on first use, so when another
test built an Image first they ran the scalar helpers and missed the SIMD
paths they exist to cover. Run Initialise() again in each test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 16:15:24 -05:00
Isaac ConnorandClaude Opus 5.5 f3216bb9f6 fix: size Image::Delta blocks for the NEON delta helpers
The NEON delta helpers consume 64 gray8 pixels or 16 rgb32 pixels per
iteration, not the 16 and 4 of the SSE2 and unrolled C ones that Delta split
each row by. A row whose bulk was a multiple of 16 but not 64 (gray8), or of 4
but not 16 (rgb32), wrapped the NEON loop counter past zero and ran off the end
of memory, so zmc crashed on ARM with motion detection at widths such as 1366.
On macOS arm64 the Delta tests die with SIGBUS when they are the first to
initialise Image, which made the macOS CI job fail depending on test order.

Split rows into 64- and 16-pixel blocks, which every variant divides, and leave
the rest to the scalar tail. Add an rgb32 case whose bulk runs one NEON block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 15:36:58 -05:00
Isaac ConnorandClaude Opus 4.8 bb7204449b fix: handle a non-block-aligned row width in Image::Delta
The delta8_* helpers consume whole blocks per iteration (16 pixels for
the gray8 unrolled/SSE2/NEON variants, 4 pixels for the rgb32 ones). The
SSE2 and NEON variants require the pixel count to be an exact multiple of
that block: a shorter count wraps the loop counter past zero and runs off
the end of memory, and the unrolled C variants overrun by up to a block.

Since PR #4788 made Delta stride-aware it drives those helpers row by row
with the row width as the count. update_function_pointers() only falls
back to the scalar helpers when total pixels % 4 is non-zero, which does
not imply each row width is block-aligned. A monitor whose width is not a
multiple of 16 (e.g. 1366) therefore reaches sse2_delta8_gray8 with a
count of 1366 and zmc dies with SIGSEGV in that loop.

Run the block-aligned bulk of each row through the fast/SIMD helper and
finish the remaining tail pixels with the matching one-pixel-at-a-time
scalar helper.

tests/zm_image_delta.cpp exercises gray8 (widths 17 and 1366) and rgb32
(width 6) at counts that select the SIMD path; each reproduces the crash
on the unfixed code and verifies the per-pixel result on the fix.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-11 21:53:49 -05:00