[FFmpeg-devel] [PATCH 04/14] avradio/sdrdemux: snap2station() should look only at the vissible window

Michael Niedermayer michael at niedermayer.cc
Wed Jul 19 00:45:32 EEST 2023


Otherwise we can skip over areas not leaving time to scan them

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavradio/sdrdemux.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index ca0a9c5cf9..f189c85a0d 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1291,11 +1291,11 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
     AVFormatContext *avfmt = sdr->avfmt;
     AVStream *st = avfmt->streams[sdr->single_ch_audio_st_index];
     SDRStream *sst = st->priv_data;
-    double current_freq;
+    double current_freq, current_view;
     double best_distance = INT64_MAX;
     Station *best_station = NULL;
     Station *station_list[MAX_STATIONS];
-    int nb_stations = ff_sdr_find_stations(sdr, sdr->block_center_freq, sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list));
+    int nb_stations;
 
     if (sst->station) {
         current_freq = sst->station->frequency;
@@ -1304,6 +1304,15 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
     } else
         current_freq = sdr->block_center_freq;
 
+    if (sdr->block_center_freq) {
+        current_view = sdr->block_center_freq;
+    } else if (sst->station) {
+        current_view = sst->station->frequency;
+    } else
+        current_view = sdr->station_freq;
+
+    nb_stations = ff_sdr_find_stations(sdr, current_view, sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list));
+
     for(int i = 0; i<nb_stations; i++) {
         Station *station = station_list[i];
         double distance = station->frequency - current_freq;
-- 
2.31.1



More information about the ffmpeg-devel mailing list