mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
The previous sync search used search_margin = line_samples/10 (~306 samples for Scottie2), reaching deep into B channel pixel data behind pos and well past the expected sync end ahead of pos. When _find_sync returned a position in the late portion of that wide region, pos + R_channel_samples exceeded the buffer length. The buffer-too-short guard in _decode_line then returned early without consuming data or advancing the line counter, causing the stall guard in feed() to permanently break the decode loop. Fix: use a 50-sample backward margin (covers >130 ppm SDR drift) and a forward margin capped to whatever the current buffer can safely support for the R channel. A final candidate-position check before committing pos ensures no overflow is possible. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>