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 <mich...@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-requ...@ffmpeg.org with subject "unsubscribe".