* [FFmpeg-devel] [PATCH 02/14] avradio/sdrdemux: Fix corner case in snap2band
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 03/14] avradio/sdrdemux: Fix seeking to stations at the edge of the range Michael Niedermayer
` (12 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 318b5465da..6b1553b130 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1368,6 +1368,8 @@ static int64_t snap2band(SDRContext *sdr, int64_t wanted_freq, int64_t delta) {
min_center_freq += sdr->bandwidth / 2;
max_center_freq -= sdr->bandwidth / 2;
}
+ min_center_freq = av_clip64(min_center_freq, sdr->min_center_freq, sdr->max_center_freq);
+ max_center_freq = av_clip64(max_center_freq, sdr->min_center_freq, sdr->max_center_freq);
// Is the band in the direction we want to seek to ?
if (FFSIGN(min_center_freq - wanted_freq) == FFSIGN(max_center_freq - wanted_freq))
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 03/14] avradio/sdrdemux: Fix seeking to stations at the edge of the range
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 02/14] avradio/sdrdemux: Fix corner case in snap2band Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 04/14] avradio/sdrdemux: snap2station() should look only at the vissible window Michael Niedermayer
` (11 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 6b1553b130..ca0a9c5cf9 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1322,6 +1322,7 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
av_assert0(!best_station || best_station != sst->station);
if (best_station) {
+ int64_t wanted_freq = av_clip64(lrint(best_station->frequency + 213*1000), sdr->min_center_freq, sdr->max_center_freq); // We target a bit off teh exact frequency to avoid artifacts
int ret = setup_stream(sdr, sdr->single_ch_audio_st_index, best_station);
if (ret < 0) {
av_log(avfmt, AV_LOG_DEBUG, "setup_stream failed\n");
@@ -1331,7 +1332,7 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
pthread_mutex_lock(&sdr->mutex);
*seek_direction =
sdr->seek_direction = 0;
- sdr->wanted_freq = lrint(best_station->frequency + 213*1000); // We target a bit off teh exact frequency to avoid artifacts
+ sdr->wanted_freq = wanted_freq;
//200*1000 had artifacts
av_log(avfmt, AV_LOG_DEBUG, "request f = %"PRId64"\n", sdr->wanted_freq);
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 04/14] avradio/sdrdemux: snap2station() should look only at the vissible window
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 02/14] avradio/sdrdemux: Fix corner case in snap2band Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 03/14] avradio/sdrdemux: Fix seeking to stations at the edge of the range Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 05/14] avradio/sdr: snap2station() documentation Michael Niedermayer
` (10 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Otherwise we can skip over areas not leaving time to scan them
Signed-off-by: Michael Niedermayer <michael@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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 05/14] avradio/sdr: snap2station() documentation
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (2 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 04/14] avradio/sdrdemux: snap2station() should look only at the vissible window Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 06/14] avradio/sdrdemux: do not hack bandwidth value in random places Michael Niedermayer
` (9 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index f189c85a0d..07b43dec1c 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1287,6 +1287,16 @@ static int sdrfile_read_callback(SDRContext *sdr, FIFOElement *fifo_element, int
return ret;
}
+/**
+ * switch to the closest station in view and the provided seek_direction.
+ *
+ * This function is scanning friendly, it will not consider stations not in
+ * view and rather wait for a future invocation when they are in view
+ *
+ * when a station is found, this will move to it and stop scanning if needed
+ *
+ * @return 1 if a station is found, 0 if not, or a negative error code on error
+ */
static int snap2station(SDRContext *sdr, int *seek_direction) {
AVFormatContext *avfmt = sdr->avfmt;
AVStream *st = avfmt->streams[sdr->single_ch_audio_st_index];
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 06/14] avradio/sdrdemux: do not hack bandwidth value in random places
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (3 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 05/14] avradio/sdr: snap2station() documentation Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 07/14] avradio/sdrdemux: snap2station consider more distant stations Michael Niedermayer
` (8 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Instead do a basic check for totally invalid values during setup
and warn the user for things that are still suspicious
Bounding the value in the middle of the code would lead to
growing complexity to consider that.
Instead the code assumes now the value is correct after setup
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 5 ++++-
libavradio/sdrinradio.c | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 07b43dec1c..c284f7d8d8 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -863,7 +863,7 @@ static int probe_fm(SDRContext *sdr)
int half_bw_i = 200*1000 * (int64_t)sdr->block_size / sdr->sdr_sample_rate;
int floor_bw_i = 10*1000 * (int64_t)sdr->block_size / sdr->sdr_sample_rate;
float last_score[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
- int border_i = (sdr->sdr_sample_rate - FFMIN(sdr->bandwidth, sdr->sdr_sample_rate*7/8)) * sdr->block_size / sdr->sdr_sample_rate;
+ int border_i = (sdr->sdr_sample_rate - sdr->bandwidth) * sdr->block_size / sdr->sdr_sample_rate;
if (2*half_bw_i > 2*sdr->block_size)
return 0;
@@ -1516,6 +1516,9 @@ int ff_sdr_common_init(AVFormatContext *s)
sdr->avfmt = s;
s->ctx_flags |= AVFMTCTX_NOHEADER;
+ if (sdr->bandwidth > sdr->sdr_sample_rate * 7 / 8)
+ av_log(s, AV_LOG_WARNING, "Bandwidth looks suspicious\n");
+
if (sdr->width>1 && sdr->height>1) {
/* video stream */
st = avformat_new_stream(s, NULL);
diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index f824a1d190..d569842a9c 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -379,7 +379,7 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
sdr->bandwidth = SoapySDRDevice_getBandwidth(soapy, SOAPY_SDR_RX, 0);
// rtlsdr doesnt return a valid value
- if (!sdr->bandwidth)
+ if (!sdr->bandwidth || sdr->bandwidth >= sdr->sdr_sample_rate)
sdr->bandwidth = sdr->sdr_sample_rate * 4 / 5;
av_log(s, AV_LOG_INFO, "bandwidth %"PRId64"\n", sdr->bandwidth);
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 07/14] avradio/sdrdemux: snap2station consider more distant stations
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (4 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 06/14] avradio/sdrdemux: do not hack bandwidth value in random places Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 08/14] tests: Add avradio/sdrdemux tests Michael Niedermayer
` (7 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index c284f7d8d8..b22d3fed13 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1321,7 +1321,10 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
} 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));
+ //We accept up to a a bandwidth steps minus a bit more than a typical FM channel distance. That ensures we will not have unscanned
+ //areas between the currently vissible and the vissible with the new station
+ //alternatively we could use half sdr->sample_rate or half sdr->bandwidth to be more conservative
+ nb_stations = ff_sdr_find_stations(sdr, current_view, sdr->bandwidth - 250*1000, station_list, FF_ARRAY_ELEMS(station_list));
for(int i = 0; i<nb_stations; i++) {
Station *station = station_list[i];
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 08/14] tests: Add avradio/sdrdemux tests
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (5 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 07/14] avradio/sdrdemux: snap2station consider more distant stations Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-21 18:42 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 09/14] avradio/sdr: Remove code setting frequency from variable being 0 Michael Niedermayer
` (6 subsequent siblings)
13 siblings, 1 reply; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
tests/Makefile | 1 +
tests/fate/sdr.mak | 11 +++++++++
tests/ref/fate/sdr-am | 55 +++++++++++++++++++++++++++++++++++++++++++
tests/ref/fate/sdr-fm | 25 ++++++++++++++++++++
4 files changed, 92 insertions(+)
create mode 100644 tests/fate/sdr.mak
create mode 100644 tests/ref/fate/sdr-am
create mode 100644 tests/ref/fate/sdr-fm
diff --git a/tests/Makefile b/tests/Makefile
index e09f30a0fc..d8a1abd04e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -230,6 +230,7 @@ include $(SRC_PATH)/tests/fate/qt.mak
include $(SRC_PATH)/tests/fate/qtrle.mak
include $(SRC_PATH)/tests/fate/real.mak
include $(SRC_PATH)/tests/fate/screen.mak
+include $(SRC_PATH)/tests/fate/sdr.mak
include $(SRC_PATH)/tests/fate/segafilm.mak
include $(SRC_PATH)/tests/fate/segment.mak
include $(SRC_PATH)/tests/fate/source.mak
diff --git a/tests/fate/sdr.mak b/tests/fate/sdr.mak
new file mode 100644
index 0000000000..a4d9fbba47
--- /dev/null
+++ b/tests/fate/sdr.mak
@@ -0,0 +1,11 @@
+FATE_SDR = fate-sdr-am \
+ fate-sdr-fm \
+
+FATE_SAMPLES_FFMPEG += $(FATE_SDR)
+
+fate-sdr-am: CMD = framecrc -mode all_mode -video_size 400x200 -i $(TARGET_SAMPLES)/sdr/am.sdr -map 0 -filter:a aresample
+fate-sdr-fm: CMD = framecrc -mode all_mode -video_size 400x200 -i $(TARGET_SAMPLES)/sdr/fm.sdr -map 0 -filter:a aresample
+
+FATE_FFMPEG += $(FATE_SDR_FFMPEG-yes)
+
+fate-sdr: $(FATE_SDR) $(FATE_SDR_FFMPEG-yes)
diff --git a/tests/ref/fate/sdr-am b/tests/ref/fate/sdr-am
new file mode 100644
index 0000000000..17f9c25714
--- /dev/null
+++ b/tests/ref/fate/sdr-am
@@ -0,0 +1,55 @@
+#tb 0: 12/125
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 400x200
+#sar 0: 0/1
+#tb 1: 1/16000
+#media_type 1: audio
+#codec_id 1: pcm_s16le
+#sample_rate 1: 16000
+#channel_layout_name 1: stereo
+#tb 2: 1/16000
+#media_type 2: audio
+#codec_id 2: pcm_s16le
+#sample_rate 2: 16000
+#channel_layout_name 2: stereo
+#tb 3: 1/16000
+#media_type 3: audio
+#codec_id 3: pcm_s16le
+#sample_rate 3: 16000
+#channel_layout_name 3: stereo
+#tb 4: 1/16000
+#media_type 4: audio
+#codec_id 4: pcm_s16le
+#sample_rate 4: 16000
+#channel_layout_name 4: stereo
+#tb 5: 1/16000
+#media_type 5: audio
+#codec_id 5: pcm_s16le
+#sample_rate 5: 16000
+#channel_layout_name 5: stereo
+#tb 6: 1/16000
+#media_type 6: audio
+#codec_id 6: pcm_s16le
+#sample_rate 6: 16000
+#channel_layout_name 6: stereo
+0, 0, 0, 1, 320000, 0x816a0964
+0, 1, 1, 1, 320000, 0x140ce2da
+1, 2048, 2048, 1024, 4096, 0x41e3b1dc
+2, 2048, 2048, 1024, 4096, 0x13fff8c1
+3, 2048, 2048, 1024, 4096, 0x71517ac5
+4, 2048, 2048, 1024, 4096, 0x4e5d8739
+5, 2048, 2048, 1024, 4096, 0x4fa3f554
+1, 3072, 3072, 1024, 4096, 0x0c81096b
+2, 3072, 3072, 1024, 4096, 0x1b3c0be0
+3, 3072, 3072, 1024, 4096, 0x483afe54
+4, 3072, 3072, 1024, 4096, 0x76b2f3d0
+5, 3072, 3072, 1024, 4096, 0xd98708c7
+6, 3072, 3072, 1024, 4096, 0x997fd85b
+1, 4096, 4096, 1024, 4096, 0xb1b6e47e
+2, 4096, 4096, 1024, 4096, 0x803a0df9
+3, 4096, 4096, 1024, 4096, 0xfa14198a
+4, 4096, 4096, 1024, 4096, 0xddd40288
+5, 4096, 4096, 1024, 4096, 0x96cd01e5
+6, 4096, 4096, 1024, 4096, 0xf38ce9c6
+0, 3, 3, 1, 320000, 0x73e13a75
diff --git a/tests/ref/fate/sdr-fm b/tests/ref/fate/sdr-fm
new file mode 100644
index 0000000000..e5113f4a08
--- /dev/null
+++ b/tests/ref/fate/sdr-fm
@@ -0,0 +1,25 @@
+#tb 0: 12/187
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 400x200
+#sar 0: 0/1
+#tb 1: 1/64000
+#media_type 1: audio
+#codec_id 1: pcm_s16le
+#sample_rate 1: 64000
+#channel_layout_name 1: stereo
+#tb 2: 1/64000
+#media_type 2: audio
+#codec_id 2: pcm_s16le
+#sample_rate 2: 64000
+#channel_layout_name 2: stereo
+0, 0, 0, 1, 320000, 0xf553af75
+0, 1, 1, 1, 320000, 0xeabc15b3
+1, 8196, 8196, 4096, 16384, 0xc7836d34
+2, 8196, 8196, 4096, 16384, 0xec685101
+1, 12292, 12292, 4096, 16384, 0x8962131e
+2, 12292, 12292, 4096, 16384, 0x5c61360b
+0, 3, 3, 1, 320000, 0x1b178638
+1, 16388, 16388, 4096, 16384, 0xfcb8d5ce
+2, 16388, 16388, 4096, 16384, 0xc9ceb9d6
+0, 4, 4, 1, 320000, 0x49dd90cc
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH 08/14] tests: Add avradio/sdrdemux tests
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 08/14] tests: Add avradio/sdrdemux tests Michael Niedermayer
@ 2023-07-21 18:42 ` Michael Niedermayer
2023-07-21 23:51 ` Michael Niedermayer
0 siblings, 1 reply; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-21 18:42 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 1849 bytes --]
On Tue, Jul 18, 2023 at 11:45:36PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> tests/Makefile | 1 +
> tests/fate/sdr.mak | 11 +++++++++
> tests/ref/fate/sdr-am | 55 +++++++++++++++++++++++++++++++++++++++++++
> tests/ref/fate/sdr-fm | 25 ++++++++++++++++++++
> 4 files changed, 92 insertions(+)
> create mode 100644 tests/fate/sdr.mak
> create mode 100644 tests/ref/fate/sdr-am
> create mode 100644 tests/ref/fate/sdr-fm
>
> diff --git a/tests/Makefile b/tests/Makefile
> index e09f30a0fc..d8a1abd04e 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -230,6 +230,7 @@ include $(SRC_PATH)/tests/fate/qt.mak
> include $(SRC_PATH)/tests/fate/qtrle.mak
> include $(SRC_PATH)/tests/fate/real.mak
> include $(SRC_PATH)/tests/fate/screen.mak
> +include $(SRC_PATH)/tests/fate/sdr.mak
> include $(SRC_PATH)/tests/fate/segafilm.mak
> include $(SRC_PATH)/tests/fate/segment.mak
> include $(SRC_PATH)/tests/fate/source.mak
> diff --git a/tests/fate/sdr.mak b/tests/fate/sdr.mak
> new file mode 100644
> index 0000000000..a4d9fbba47
> --- /dev/null
> +++ b/tests/fate/sdr.mak
> @@ -0,0 +1,11 @@
> +FATE_SDR = fate-sdr-am \
> + fate-sdr-fm \
> +
> +FATE_SAMPLES_FFMPEG += $(FATE_SDR)
> +
> +fate-sdr-am: CMD = framecrc -mode all_mode -video_size 400x200 -i $(TARGET_SAMPLES)/sdr/am.sdr -map 0 -filter:a aresample
> +fate-sdr-fm: CMD = framecrc -mode all_mode -video_size 400x200 -i $(TARGET_SAMPLES)/sdr/fm.sdr -map 0 -filter:a aresample
I will change this to pcm_u8 as there are rounding differences between machiens
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH 08/14] tests: Add avradio/sdrdemux tests
2023-07-21 18:42 ` Michael Niedermayer
@ 2023-07-21 23:51 ` Michael Niedermayer
0 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-21 23:51 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2018 bytes --]
On Fri, Jul 21, 2023 at 08:42:59PM +0200, Michael Niedermayer wrote:
> On Tue, Jul 18, 2023 at 11:45:36PM +0200, Michael Niedermayer wrote:
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > tests/Makefile | 1 +
> > tests/fate/sdr.mak | 11 +++++++++
> > tests/ref/fate/sdr-am | 55 +++++++++++++++++++++++++++++++++++++++++++
> > tests/ref/fate/sdr-fm | 25 ++++++++++++++++++++
> > 4 files changed, 92 insertions(+)
> > create mode 100644 tests/fate/sdr.mak
> > create mode 100644 tests/ref/fate/sdr-am
> > create mode 100644 tests/ref/fate/sdr-fm
> >
> > diff --git a/tests/Makefile b/tests/Makefile
> > index e09f30a0fc..d8a1abd04e 100644
> > --- a/tests/Makefile
> > +++ b/tests/Makefile
> > @@ -230,6 +230,7 @@ include $(SRC_PATH)/tests/fate/qt.mak
> > include $(SRC_PATH)/tests/fate/qtrle.mak
> > include $(SRC_PATH)/tests/fate/real.mak
> > include $(SRC_PATH)/tests/fate/screen.mak
> > +include $(SRC_PATH)/tests/fate/sdr.mak
> > include $(SRC_PATH)/tests/fate/segafilm.mak
> > include $(SRC_PATH)/tests/fate/segment.mak
> > include $(SRC_PATH)/tests/fate/source.mak
> > diff --git a/tests/fate/sdr.mak b/tests/fate/sdr.mak
> > new file mode 100644
> > index 0000000000..a4d9fbba47
> > --- /dev/null
> > +++ b/tests/fate/sdr.mak
> > @@ -0,0 +1,11 @@
> > +FATE_SDR = fate-sdr-am \
> > + fate-sdr-fm \
> > +
> > +FATE_SAMPLES_FFMPEG += $(FATE_SDR)
> > +
> > +fate-sdr-am: CMD = framecrc -mode all_mode -video_size 400x200 -i $(TARGET_SAMPLES)/sdr/am.sdr -map 0 -filter:a aresample
> > +fate-sdr-fm: CMD = framecrc -mode all_mode -video_size 400x200 -i $(TARGET_SAMPLES)/sdr/fm.sdr -map 0 -filter:a aresample
>
> I will change this to pcm_u8 as there are rounding differences between machiens
With u8 it seems to pass on all machienes i tried
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are best at talking, realize last or never when they are wrong.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 09/14] avradio/sdr: Remove code setting frequency from variable being 0
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (6 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 08/14] tests: Add avradio/sdrdemux tests Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 10/14] avradio/sdrdemux: no need to set wanted_freq from sdrfile_initial_setup() Michael Niedermayer
` (5 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
wanted_freq is 0 at this point
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 4 ----
libavradio/sdrinradio.c | 3 ---
2 files changed, 7 deletions(-)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index b22d3fed13..b5e9b9ad04 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1729,10 +1729,6 @@ static int sdrfile_initial_setup(AVFormatContext *s)
//After reading the first packet header we return to the begin so the packet can be read whole
avio_seek(s->pb, 0, SEEK_SET);
- ret = ff_sdr_set_freq(sdr, sdr->wanted_freq);
- if (ret < 0)
- return ret;
-
sdr->read_callback = sdrfile_read_callback;
return ff_sdr_common_init(s);
diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index d569842a9c..d12b0b73fe 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -326,9 +326,6 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
av_log(s, AV_LOG_ERROR, "setSampleRate fail: %s\n", SoapySDRDevice_lastError());
return AVERROR_EXTERNAL;
}
- ret = ff_sdr_set_freq(sdr, sdr->wanted_freq);
- if (ret < 0)
- return ret;
//List the available custom options for this specific driver to the user
arg_info = SoapySDRDevice_getSettingInfo(soapy, &length);
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 10/14] avradio/sdrdemux: no need to set wanted_freq from sdrfile_initial_setup()
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (7 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 09/14] avradio/sdr: Remove code setting frequency from variable being 0 Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 11/14] avradio/sdr: More atomics, less Mutexes Michael Niedermayer
` (4 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index b5e9b9ad04..d5ea2d85b4 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1714,7 +1714,7 @@ static int sdrfile_initial_setup(AVFormatContext *s)
avio_skip(s->pb, 3); //BE
sdr->sdr_sample_rate = avio_rb32(s->pb);
avio_rb32(s->pb); //block_size
- sdr->wanted_freq = av_int2double(avio_rb64(s->pb));
+ av_int2double(avio_rb64(s->pb));
sdr->pts = avio_rb64(s->pb);
if (version > AV_RB24("000")) {
sdr->bandwidth = avio_rb32(s->pb);
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 11/14] avradio/sdr: More atomics, less Mutexes
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (8 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 10/14] avradio/sdrdemux: no need to set wanted_freq from sdrfile_initial_setup() Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 12/14] avradio/sdrdemux: + vs. - bug Michael Niedermayer
` (3 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Maybe this is cleaner
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdr.h | 5 +++--
libavradio/sdrdemux.c | 38 +++++++++++++++++++++++---------------
2 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 27ec1db4f3..3f76aec2a6 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -172,6 +172,7 @@ typedef struct SDRContext {
AVComplexFloat *windowed_block;
int64_t block_center_freq; ///< center frequency the current block contains
int64_t station_freq;
+ int64_t user_wanted_freq;
int sample_size;
double sample_scale;
@@ -218,8 +219,8 @@ typedef struct SDRContext {
AVFifo *empty_block_fifo;
AVFifo *full_block_fifo;
atomic_int close_requested;
- int64_t wanted_freq; ///< center frequency we want the hw to provide next
- int seek_direction; ///< if a seek is requested this is -1 or 1 otherwise 0
+ atomic_int_least64_t wanted_freq; ///< center frequency we want the hw to provide next, only written to by main thread
+ atomic_int seek_direction; ///< if a seek is requested this is -1 or 1 otherwise 0, only written to by main thread
int skip_probe;
/**
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index d5ea2d85b4..a9ddf93733 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1351,14 +1351,12 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
return ret;
}
- pthread_mutex_lock(&sdr->mutex);
- *seek_direction =
- sdr->seek_direction = 0;
- sdr->wanted_freq = wanted_freq;
+ *seek_direction = 0;
+ atomic_store(&sdr->seek_direction, 0);
+ atomic_store(&sdr->wanted_freq, wanted_freq);
//200*1000 had artifacts
- av_log(avfmt, AV_LOG_DEBUG, "request f = %"PRId64"\n", sdr->wanted_freq);
- pthread_mutex_unlock(&sdr->mutex);
+ av_log(avfmt, AV_LOG_DEBUG, "request f = %"PRId64"\n", atomic_load(&sdr->wanted_freq));
return 1;
}
@@ -1426,6 +1424,8 @@ static void *soapy_needs_bigger_buffers_worker(SDRContext *sdr)
{
AVFormatContext *avfmt = sdr->avfmt;
unsigned block_counter = 0;
+ int64_t local_wanted_freq = 0;
+ int64_t last_wanted_freq = 0;
sdr->remaining_file_block_size = 0;
@@ -1436,6 +1436,8 @@ static void *soapy_needs_bigger_buffers_worker(SDRContext *sdr)
int remaining, ret;
int empty_blocks, full_blocks;
float wanted_gain = atomic_load(&sdr->wanted_gain) / 65536.0;
+ int64_t wanted_freq = atomic_load(&sdr->wanted_freq);
+ int seek_direction = atomic_load(&sdr->seek_direction);
//i wish av_fifo was thread safe
pthread_mutex_lock(&sdr->mutex);
@@ -1457,16 +1459,22 @@ static void *soapy_needs_bigger_buffers_worker(SDRContext *sdr)
block_counter ++;
pthread_mutex_lock(&sdr->mutex);
+ // Has the main thread changed the wanted frequency ? if so lets reset our loop to it
+ if (wanted_freq != last_wanted_freq) {
+ local_wanted_freq =
+ last_wanted_freq = wanted_freq;
+ }
+
// we try to get 2 clean blocks after windowing, to improve chances scanning doesnt miss too much
// First block after parameter change is not reliable, we do not assign it any frequency
// 2 blocks are needed with windowing to get a clean FFT output
// Thus > 3 is the minimum for the next frequency update if we want to do something reliable with the data
- if (sdr->seek_direction && block_counter > 5) {
- sdr->wanted_freq = snap2band(sdr, sdr->wanted_freq, sdr->seek_direction*sdr->bandwidth*0.5);
+ if (seek_direction && block_counter > 5) {
+ local_wanted_freq = snap2band(sdr, local_wanted_freq, seek_direction*sdr->bandwidth*0.5);
}
- if (fabs(sdr->wanted_freq - sdr->freq) > 1500) {
+ if (fabs(local_wanted_freq - sdr->freq) > 1500) {
//We could use a seperate MUTEX for the FIFO and for soapy
- ff_sdr_set_freq(sdr, sdr->wanted_freq);
+ ff_sdr_set_freq(sdr, local_wanted_freq);
//This shouldnt really cause any problem if we just continue on error except that we continue returning data with the previous target frequency range
//And theres not much else we can do, an error message was already printed by ff_sdr_set_freq() in that case
block_counter = 0; // we just changed the frequency, do not trust the next blocks content
@@ -1662,6 +1670,8 @@ int ff_sdr_common_init(AVFormatContext *s)
av_fifo_auto_grow_limit(sdr-> full_block_fifo, sdr->sdr_sample_rate / sdr->block_size);
atomic_init(&sdr->close_requested, 0);
+ atomic_init(&sdr->seek_direction, 0);
+ atomic_init(&sdr->wanted_freq, sdr->user_wanted_freq);
atomic_init(&sdr->wanted_gain, lrint((sdr->min_gain + sdr->max_gain) * 65536 / 2));
ret = pthread_mutex_init(&sdr->mutex, NULL);
if (ret) {
@@ -1810,8 +1820,8 @@ process_next_block:
ret = av_fifo_peek(sdr->full_block_fifo, &fifo_element, 2, 0);
if (ret >= 0)
av_fifo_drain2(sdr->full_block_fifo, 1);
- seek_direction = sdr->seek_direction; //This doesnt need a mutex here at all but tools might complain
pthread_mutex_unlock(&sdr->mutex);
+ seek_direction = atomic_load(&sdr->seek_direction);
if (ret < 0) {
av_log(s, AV_LOG_DEBUG, "EAGAIN on not enough data\n");
@@ -2094,9 +2104,7 @@ int ff_sdr_read_seek(AVFormatContext *s, int stream_index,
return ret;
//snap2station found no station lets command the thread to seek
if (!ret) {
- pthread_mutex_lock(&sdr->mutex);
- sdr->seek_direction = dir;
- pthread_mutex_unlock(&sdr->mutex);
+ atomic_store(&sdr->seek_direction, dir);
flush_fifo(sdr, sdr->full_block_fifo);
}
@@ -2207,7 +2215,7 @@ const AVOption ff_sdr_options[] = {
{ "rtlsdr_fixes" , "workaround rtlsdr issues", OFFSET(rtlsdr_fixes), AV_OPT_TYPE_INT , {.i64 = -1}, -1, 1, DEC},
{ "sdrplay_fixes" , "workaround sdrplay issues", OFFSET(sdrplay_fixes), AV_OPT_TYPE_INT , {.i64 = -1}, -1, 1, DEC},
{ "sdr_sr" , "sdr sample rate" , OFFSET(sdr_sample_rate ), AV_OPT_TYPE_INT , {.i64 = 0}, 0, INT_MAX, DEC},
- { "sdr_freq", "sdr frequency" , OFFSET(wanted_freq), AV_OPT_TYPE_INT64 , {.i64 = 9000000}, 0, INT64_MAX, DEC},
+ { "sdr_freq", "sdr frequency" , OFFSET(user_wanted_freq), AV_OPT_TYPE_INT64 , {.i64 = 9000000}, 0, INT64_MAX, DEC},
{ "gain" , "sdr overall gain", OFFSET(sdr_gain), AV_OPT_TYPE_INT , {.i64 = GAIN_SDR_AGC}, -3, INT_MAX, DEC, "gain"},
{ "sdr_agc", "SDR AGC (if supported)", 0, AV_OPT_TYPE_CONST, {.i64 = GAIN_SDR_AGC}, 0, 0, DEC, "gain"},
{ "sw_agc", "Software AGC", 0, AV_OPT_TYPE_CONST, {.i64 = GAIN_SW_AGC}, 0, 0, DEC, "gain"},
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 12/14] avradio/sdrdemux: + vs. - bug
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (9 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 11/14] avradio/sdr: More atomics, less Mutexes Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 13/14] avradio/sdrdemux: snap2band doesnt change anything so use const Michael Niedermayer
` (2 subsequent siblings)
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index a9ddf93733..ded9b8e26a 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1571,7 +1571,7 @@ int ff_sdr_common_init(AVFormatContext *s)
}
sdr->min_center_freq = sdr->min_freq + sdr->sdr_sample_rate / 2;
- sdr->max_center_freq = sdr->max_freq + sdr->sdr_sample_rate / 2;
+ sdr->max_center_freq = sdr->max_freq - sdr->sdr_sample_rate / 2;
if(!sdr->block_size) {
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 13/14] avradio/sdrdemux: snap2band doesnt change anything so use const
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (10 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 12/14] avradio/sdrdemux: + vs. - bug Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 14/14] avradio/sdrdemux: Fix wraparound with seeking Michael Niedermayer
2023-07-22 13:30 ` [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdrdemux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index ded9b8e26a..65b5e6df8d 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1367,7 +1367,7 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
* move frequency in the delta direction within a band
* This can be called from the thread so it must only access runtime constants from sdr->
*/
-static int64_t snap2band(SDRContext *sdr, int64_t wanted_freq, int64_t delta) {
+static int64_t snap2band(const SDRContext *sdr, int64_t wanted_freq, int64_t delta) {
int64_t best_distance = INT64_MAX;
int64_t best_frequency = wanted_freq;
int64_t wrap_frequency = delta > 0 ? 0 : INT64_MAX;
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* [FFmpeg-devel] [PATCH 14/14] avradio/sdrdemux: Fix wraparound with seeking
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (11 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 13/14] avradio/sdrdemux: snap2band doesnt change anything so use const Michael Niedermayer
@ 2023-07-18 21:45 ` Michael Niedermayer
2023-07-22 13:30 ` [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-18 21:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
This implementation is clean and requires no communication between the
threads. It requires a few more lines than i would like though
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavradio/sdr.h | 1 +
libavradio/sdrdemux.c | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 3f76aec2a6..c651ba0d99 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -171,6 +171,7 @@ typedef struct SDRContext {
int kbd_alpha;
AVComplexFloat *windowed_block;
int64_t block_center_freq; ///< center frequency the current block contains
+ int wraparound;
int64_t station_freq;
int64_t user_wanted_freq;
int sample_size;
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 65b5e6df8d..8967ff1ea9 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1307,7 +1307,9 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
Station *station_list[MAX_STATIONS];
int nb_stations;
- if (sst->station) {
+ if (sdr->wraparound) {
+ current_freq = (*seek_direction) > 0 ? 0 : INT64_MAX;
+ } else if (sst->station) {
current_freq = sst->station->frequency;
} else if (sdr->station_freq) {
current_freq = sdr->station_freq;
@@ -1354,6 +1356,7 @@ static int snap2station(SDRContext *sdr, int *seek_direction) {
*seek_direction = 0;
atomic_store(&sdr->seek_direction, 0);
atomic_store(&sdr->wanted_freq, wanted_freq);
+ sdr->wraparound = 0;
//200*1000 had artifacts
av_log(avfmt, AV_LOG_DEBUG, "request f = %"PRId64"\n", atomic_load(&sdr->wanted_freq));
@@ -2021,6 +2024,13 @@ process_next_block:
ret = snap2station(sdr, &seek_direction);
if (ret < 0)
return ret;
+ if (seek_direction && !ret) {
+ int wrapdir = sdr->wraparound == 0 ? seek_direction : -seek_direction;
+ int64_t end_freq = snap2band(sdr, wrapdir > 0 ? 0 : INT64_MAX, wrapdir);
+ if (fabs(end_freq - sdr->block_center_freq) < 1500)
+ sdr->wraparound++;
+
+ }
}
} else {
av_assert0(sdr->mode == AllStationMode);
@@ -2104,6 +2114,7 @@ int ff_sdr_read_seek(AVFormatContext *s, int stream_index,
return ret;
//snap2station found no station lets command the thread to seek
if (!ret) {
+ sdr->wraparound = 0;
atomic_store(&sdr->seek_direction, dir);
flush_fifo(sdr, sdr->full_block_fifo);
}
--
2.31.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band
2023-07-18 21:45 [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band Michael Niedermayer
` (12 preceding siblings ...)
2023-07-18 21:45 ` [FFmpeg-devel] [PATCH 14/14] avradio/sdrdemux: Fix wraparound with seeking Michael Niedermayer
@ 2023-07-22 13:30 ` Michael Niedermayer
13 siblings, 0 replies; 17+ messages in thread
From: Michael Niedermayer @ 2023-07-22 13:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 488 bytes --]
On Tue, Jul 18, 2023 at 11:45:29PM +0200, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavradio/sdrdemux.c | 1 +
> 1 file changed, 1 insertion(+)
will apply patchset (with fate test fixed as described)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 17+ messages in thread