diff mbox series

[FFmpeg-devel,05/18] avradio/sdrdemux: Do not timeout negative stations

Message ID 20230708212530.109692-5-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,01/18] avradio/sdrdemux: Fix uninitialized access | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch

Commit Message

Michael Niedermayer July 8, 2023, 9:25 p.m. UTC
If we identified that a station is an artifact of the SDR, we dont
want to timeout that to avoid it being redetected as station

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavradio/sdrdemux.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 13cec10505..39eaa0c094 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -347,6 +347,7 @@  static void decay_stations(SDRContext *sdr)
 
     for (int i=0; i<nb_stations; i++) {
         Station *station = station_list[i];
+        int hs;
 
         if (station->frequency - station->bandwidth/2 < sdr->block_center_freq - sdr->bandwidth/2 ||
             station->frequency + station->bandwidth/2 > sdr->block_center_freq + sdr->bandwidth/2)
@@ -355,9 +356,10 @@  static void decay_stations(SDRContext *sdr)
         if (station->timeout)
             station->non_detection_per_mix_frequency[histogram_index(sdr, station->frequency)] ++;
 
+        hs = histogram_score(station);
+
         if (station->in_station_list) {
             int station_timeout = STATION_TIMEOUT;
-            int hs = histogram_score(station);
 
             if (hs == 0) {
                 station_timeout = 5; //give the station a moment to be properly detected and then discard it
@@ -370,7 +372,13 @@  static void decay_stations(SDRContext *sdr)
                     station->in_station_list = 0;
             }
         } else {
-            if (station->timeout++ > CANDIDATE_STATION_TIMEOUT) {
+            int station_timeout = CANDIDATE_STATION_TIMEOUT;
+
+            //We do not want to drop "negative" stations to avoid them being redetected
+            if (hs <= 0)
+                station_timeout = INT_MAX;
+
+            if (station->timeout++ > station_timeout) {
                 struct AVTreeNode *next = NULL;
                 tree_remove(&sdr->station_root, station, station_cmp, &next);
                 av_freep(&next);