From b12112d0350994ef13309bf3e7ae171075784140 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Sat, 4 Apr 2026 19:46:50 +0200 Subject: [PATCH] [fix](trx-wefax): discard short images from false auto-start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The variance-based auto-start in Idle state is permissive and fires on any sustained modulated audio — tones, beeps, noise bursts. When that happens mid-transmission, the decoder enters Receiving, the correlation watchdog trips after exactly 31 lines (1 seed + 30 low-correlation), and we end up saving a sliver of garbage to disk and the history. Gate finalize_image() on a 100-line minimum. A real WEFAX chart is hundreds of lines; anything shorter is almost certainly a false auto-start and gets dropped silently (with a debug log). This doesn't change start-tone / phasing-driven captures, only filters out the noise-triggered entries. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Stan Grams --- src/decoders/trx-wefax/src/decoder.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/decoders/trx-wefax/src/decoder.rs b/src/decoders/trx-wefax/src/decoder.rs index e4a92d6..a23f546 100644 --- a/src/decoders/trx-wefax/src/decoder.rs +++ b/src/decoders/trx-wefax/src/decoder.rs @@ -43,6 +43,12 @@ const LINE_CORR_NOISE_THRESHOLD: f32 = 0.2; /// fldigi's line-to-line correlation check for automatic stop. const LINE_CORR_NOISE_LINES: u32 = 30; +/// Minimum image height (lines) to save. Anything shorter is assumed to be a +/// false-positive auto-start (variance detector tripping on tones, noise +/// bursts, or phasing leakage) and discarded silently. A real WEFAX chart is +/// at least several hundred lines long. +const MIN_IMAGE_LINES: u32 = 100; + /// WEFAX decoder output event. #[derive(Debug)] pub enum WefaxEvent { @@ -453,7 +459,18 @@ impl WefaxDecoder { let mut events = Vec::new(); if let Some(ref image) = self.image { - if image.line_count() == 0 { + let lines = image.line_count(); + if lines == 0 { + return events; + } + if lines < MIN_IMAGE_LINES { + debug!( + lines, + min = MIN_IMAGE_LINES, + "WEFAX: discarding short image (likely false auto-start)" + ); + self.image = None; + self.reception_start_ms = None; return events; }