From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH 06/12] avradio/sdr: Warnings cleanup Date: Tue, 11 Jul 2023 23:19:04 +0200 Message-ID: <20230711211910.1257355-6-michael@niedermayer.cc> (raw) In-Reply-To: <20230711211910.1257355-1-michael@niedermayer.cc> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- libavradio/sdr.h | 1 + libavradio/sdrdemux.c | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libavradio/sdr.h b/libavradio/sdr.h index f966a16e2e..834b1f40b4 100644 --- a/libavradio/sdr.h +++ b/libavradio/sdr.h @@ -152,6 +152,7 @@ typedef struct SDRContext { int64_t last_pts; int64_t pts; int block_size; + double block_time; int kbd_alpha; AVComplexFloat *windowed_block; int64_t block_center_freq; ///< center frequency the current block contains diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index 93e48c2cdf..8b8c126380 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -177,14 +177,15 @@ static int create_station(SDRContext *sdr, Station *candidate_station) { double freq = candidate_station->frequency; int64_t bandwidth = candidate_station->bandwidth; float score = candidate_station->score; - void *tmp; - int i; + int i, nb_stations; Station *best_station = NULL; float drift = bandwidth/3.0; double best_distance = drift; int conflict = INT_MAX; int nb_candidate_conflict = 0; int nb_candidate_match = 0; + Station *station_list[1000]; + if (candidate_station->in_station_list) return 0; @@ -193,8 +194,7 @@ static int create_station(SDRContext *sdr, Station *candidate_station) { if (ff_sdr_histogram_score(candidate_station) <= 0) return 0; - Station *station_list[1000]; - 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)); + nb_stations = ff_sdr_find_stations(sdr, sdr->block_center_freq, sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list)); for (i=0; i<nb_stations; i++) { Station *s = station_list[i]; double delta = fabs(s->frequency - freq); @@ -286,11 +286,12 @@ static int create_station(SDRContext *sdr, Station *candidate_station) { static void create_stations(SDRContext *sdr) { Station *station_list[1000]; + int nb_stations; if (!sdr->block_center_freq) return; - 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)); + nb_stations = ff_sdr_find_stations(sdr, sdr->block_center_freq, sdr->sdr_sample_rate*0.5, station_list, FF_ARRAY_ELEMS(station_list)); for(int i = 0; i<nb_stations; i++) { create_station(sdr, station_list[i]); @@ -392,7 +393,6 @@ static int create_candidate_station(SDRContext *sdr, enum Modulation modulation, } if (!nb_stations) { - double block_time = sdr->block_size / (double)sdr->sdr_sample_rate; station = av_mallocz(sizeof(*station)); if (!station) return AVERROR(ENOMEM); @@ -400,7 +400,7 @@ static int create_candidate_station(SDRContext *sdr, enum Modulation modulation, if (!sdr->rds_ring_size) - sdr->rds_ring_size = ceil((2*105 / 1187.5 + 2.0*block_time) * sdr->fm_block_size_p2 / block_time); + sdr->rds_ring_size = ceil((2*105 / 1187.5 + 2.0*sdr->block_time) * sdr->fm_block_size_p2 / sdr->block_time); station->rds_ring = av_mallocz(sizeof(*station->rds_ring ) * sdr->rds_ring_size); @@ -901,7 +901,7 @@ static int probe_fm(SDRContext *sdr) float rmax = max_in_range(sdr, i-half_bw_i/4, i+half_bw_i/4); int lowcount = countbelow(sdr, i-half_bw_i/4, i+half_bw_i/4, rmax / 100); - double peak_i; + double peak_i, f, f2; if (lowcount / (half_bw_i*0.5) > 0.99) continue; @@ -912,8 +912,8 @@ static int probe_fm(SDRContext *sdr) if (peak_i < 0) continue; av_assert0(fabs(peak_i-i) < 2); - double f = peak_i * 0.5 * sdr->sdr_sample_rate / sdr->block_size + sdr->block_center_freq - sdr->sdr_sample_rate/2; - double f2 = center * 0.5 * sdr->sdr_sample_rate / sdr->block_size + sdr->block_center_freq - sdr->sdr_sample_rate/2; + f = peak_i * 0.5 * sdr->sdr_sample_rate / sdr->block_size + sdr->block_center_freq - sdr->sdr_sample_rate/2; + f2 = center * 0.5 * sdr->sdr_sample_rate / sdr->block_size + sdr->block_center_freq - sdr->sdr_sample_rate/2; if (fabs(f2 - f) > 1000) continue; @@ -1115,7 +1115,6 @@ static int setup_stream(SDRContext *sdr, int stream_index, Station *station) AVFormatContext *s = sdr->avfmt; AVStream *st = s->streams[stream_index]; SDRStream *sst = st->priv_data; - double block_time = sdr->block_size / (double)sdr->sdr_sample_rate; int ret; //For now we expect each station to be only demodulated once, nothing should break though if its done more often @@ -1133,7 +1132,7 @@ static int setup_stream(SDRContext *sdr, int stream_index, Station *station) if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { free_stream(sdr, stream_index); - for (sst->block_size = 4; 2ll *sst->station->bandwidth * block_time > sst->block_size; sst->block_size <<= 1) + for (sst->block_size = 4; 2ll *sst->station->bandwidth * sdr->block_time > sst->block_size; sst->block_size <<= 1) ; sst->block_size = FFMIN(sdr->block_size, sst->block_size); @@ -1491,10 +1490,10 @@ int ff_sdr_common_init(AVFormatContext *s) } av_log(s, AV_LOG_INFO, "Block size %d\n", sdr->block_size); - double block_time = sdr->block_size / (double)sdr->sdr_sample_rate; + sdr->block_time = sdr->block_size / (double)sdr->sdr_sample_rate; sdr->fm_bandwidth_p2 = 18 * 1000; if (!sdr->fm_block_size_p2) - for (sdr->fm_block_size_p2 = 4; 2ll *sdr->fm_bandwidth_p2 * block_time > sdr->fm_block_size_p2; sdr->fm_block_size_p2 <<= 1) + for (sdr->fm_block_size_p2 = 4; 2ll *sdr->fm_bandwidth_p2 * sdr->block_time > sdr->fm_block_size_p2; sdr->fm_block_size_p2 <<= 1) ; sdr->windowed_block = av_malloc(sizeof(*sdr->windowed_block) * 2 * sdr->block_size); @@ -1836,9 +1835,9 @@ process_next_block: return ret; } } else { - av_assert0(sdr->mode == AllStationMode); Station *station_list[1000]; 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)); + av_assert0(sdr->mode == AllStationMode); for(int i = 0; i<nb_stations; i++) { Station *station = station_list[i]; if (!station->stream && station->in_station_list) { -- 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".
next prev parent reply other threads:[~2023-07-11 21:20 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-07-11 21:18 [FFmpeg-devel] [PATCH 01/12] avradio/sdrdemux: Fix use of uninitialized memory Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 02/12] avradio/rds: Implement burst error decoder Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 03/12] avradio/rds: Keep track of program_id Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 04/12] avradio/sdr: Move rds_ring to Station Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 05/12] avradio/rds: move phase 2 window to main context Michael Niedermayer 2023-07-11 21:19 ` Michael Niedermayer [this message] 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 07/12] avradio/rds: warnings cleanup Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 08/12] avradio/sdr: Move IFFT and block size to main context Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 09/12] avradio/sdr: Move per stream arraies " Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 10/12] avradio/sdr: Move tx contexts out of stream so its not duplicated Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 11/12] avradio/sdr: Pass AVStream instead of int to demodulate Michael Niedermayer 2023-07-11 21:19 ` [FFmpeg-devel] [PATCH 12/12] avradio/sdr: Process RDS of all stations not just the current one Michael Niedermayer 2023-07-12 23:26 ` [FFmpeg-devel] [PATCH 01/12] avradio/sdrdemux: Fix use of uninitialized memory Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230711211910.1257355-6-michael@niedermayer.cc \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git