mirror of
https://github.com/smittix/intercept.git
synced 2026-04-27 08:10:00 -07:00
Fix PD120 SSTV decode hang and false leader tone detection
Fix infinite CPU spin in PD120 decoding caused by a 1-sample rounding mismatch between line_samples (24407) and the sum of sub-component samples (24408). The feed() while loop would re-enter _decode_line() endlessly when the buffer was too short by 1 sample. Added a stall guard that breaks the loop when no progress is made. Fix false "leader tone detected" in the signal monitor by requiring the detected tone to dominate the other tone by 2x, matching the approach already used by the VIS detector. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -138,9 +138,16 @@ class SSTVImageDecoder:
|
||||
|
||||
self._buffer = np.concatenate([self._buffer, samples])
|
||||
|
||||
# Process complete lines
|
||||
# Process complete lines.
|
||||
# Guard against stalls: if _decode_line() cannot consume data
|
||||
# (e.g. sub-component samples exceed line_samples due to rounding),
|
||||
# break out and wait for more audio.
|
||||
while not self._complete and len(self._buffer) >= self._line_samples:
|
||||
prev_line = self._current_line
|
||||
prev_len = len(self._buffer)
|
||||
self._decode_line()
|
||||
if self._current_line == prev_line and len(self._buffer) == prev_len:
|
||||
break # No progress — need more data
|
||||
|
||||
# Prevent unbounded buffer growth - keep at most 2 lines worth
|
||||
max_buffer = self._line_samples * 2
|
||||
|
||||
Reference in New Issue
Block a user