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:
Smittix
2026-02-07 14:55:22 +00:00
parent bb4ccc6355
commit 1ee64efc81
2 changed files with 15 additions and 3 deletions

View File

@@ -487,9 +487,14 @@ class SSTVDecoder:
sync_energy = goertzel_mag(samples, 1200.0, SAMPLE_RATE)
noise_floor = max(rms * 0.5, 0.001)
if leader_energy > noise_floor * 5:
# Require the tone to both exceed the noise floor AND
# dominate the other tone by 2x to avoid false positives
# from broadband noise.
if (leader_energy > noise_floor * 5
and leader_energy > sync_energy * 2):
sstv_tone = 'leader'
elif sync_energy > noise_floor * 5:
elif (sync_energy > noise_floor * 5
and sync_energy > leader_energy * 2):
sstv_tone = 'sync'
elif signal_level > 10:
sstv_tone = 'noise'