From patchwork Tue Jul 18 21:45:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42813 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781517pzb; Tue, 18 Jul 2023 14:46:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlFSRwVzPWRtzFPnm2EmShWVwWldUouIynntsQSXMIvuFqH2Q1TP2cbGZWSrrH6tCqTwa6p/ X-Received: by 2002:a17:906:1cd:b0:98f:8481:24b3 with SMTP id 13-20020a17090601cd00b0098f848124b3mr281927ejj.37.1689716780685; Tue, 18 Jul 2023 14:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716780; cv=none; d=google.com; s=arc-20160816; b=bUVs3BGyqtiiTUCK9HBuJt9OuhtjTMl4beSV7eRI96P7jYAtriV3TMcx2VcttCOEwZ BihXpPIvfzw5gTUq2C+nopGAJLF1pqhzl00G3InZBHNDAzRvBPQGiARa2gXSXnChjHYL e7JkuNPJW1BqTAHtWIQGZJ5JNyk+yQD4kF9CZx8NPvuegtUKtP6+PPWT9lw7WnrXdzyZ c4Fcv8TMdQxz8nGGE9Lq3NoSlnEhcBFMIB5VG3rlqlets5WOocoxKd9RDjOwl9BNEw3l e6oWW4S7a9HJQ1tjkJA8zzlf+iNXj9+bou6kazwqBGLcZSIBKloqoFaRL2bLAPpNP14u lIdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=3ScEtj5MPgx2nViJjMEehBFhbM3VWzbwHtHdKW8ZRMM=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=cXXcPXTR2bddzrO6tBjgjX0VUhtz5oox5S/C6+gOhmC9bJCNCIsAzU7TGwDXwZc26A ef9swobLgPEg2Clgy2MiwAq6K7ge2Eikg1xIK10J3ywhvWJFTklr0lQeiQ5G6xZFnOty VM7CsVEOGPiTGojeAEmwbedtL1nAvVg/ZjA97bCMB3HkJc/bvVoKi5AZacb2kz/4DBdW kVq5kwzUszjZy1V92tQP9Zq3cIdHlUUQFKJNvvkzoNaM8AqbqNSFaHyP0MGn8HcC2XOT TaafjgGTIbwkEmbEkV5hmnAYxRdTp+9Zt4AQWiL7Jz1hzHT0948Wx9Y+oHHrZO9bBCaW nGpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lv19-20020a170906bc9300b009895a6d847fsi1748764ejb.742.2023.07.18.14.46.20; Tue, 18 Jul 2023 14:46:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3FA1668C5A4; Wed, 19 Jul 2023 00:45:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A5E4268C562 for ; Wed, 19 Jul 2023 00:45:47 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id DCB6F20003 for ; Tue, 18 Jul 2023 21:45:46 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:32 +0200 Message-Id: <20230718214542.685375-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230718214542.685375-1-michael@niedermayer.cc> References: <20230718214542.685375-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 04/14] avradio/sdrdemux: snap2station() should look only at the vissible window X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: A7fV+7ip/AYk Otherwise we can skip over areas not leaving time to scan them Signed-off-by: Michael Niedermayer --- 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; ifrequency - current_freq;