@@ -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);
@@ -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);
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(-)