diff mbox series

[FFmpeg-devel,4/6] avradio/sdrdemux: adjust frequency precission in probing depending on modulation

Message ID 20230704222302.1129450-4-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/6] avradio/sdrdemux: end on EOF dont wraparound | 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 4, 2023, 10:23 p.m. UTC
for AM we can find the frequency very precissely, for FM currently not so
much

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

Patch

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 90f6805c3b..92b1e2b170 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -166,9 +166,10 @@  static int create_station(SDRContext *sdr, Station *candidate_station) {
         return best_station_index;
     }
     for (i=0; i<sdr->nb_candidate_stations; i++) {
+        int freq_precission = modulation == AM ? 5 : 50;
         double delta = fabs(sdr->candidate_station[i]->frequency - freq);
         // Station already added, or we have 2 rather close stations
-        if (modulation == sdr->candidate_station[i]->modulation && delta < 10 && sdr->candidate_station[i] != candidate_station) {
+        if (modulation == sdr->candidate_station[i]->modulation && delta < freq_precission && sdr->candidate_station[i] != candidate_station) {
             nb_candidate_match++;
         }
         if (modulation != sdr->candidate_station[i]->modulation && delta < (bandwidth + sdr->candidate_station[i]->bandwidth)/2.1)