From patchwork Tue Jul 18 21:45:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42810 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781306pzb; Tue, 18 Jul 2023 14:45:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlESI5s/WTIAoL42+2FhOEsNY5l0ZpRNcg248i6GB2h2rPWnnkCuxnB1A5jKFSAd5FJ9WnPl X-Received: by 2002:a5d:49c7:0:b0:317:18f9:c5bd with SMTP id t7-20020a5d49c7000000b0031718f9c5bdmr186621wrs.3.1689716755022; Tue, 18 Jul 2023 14:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716755; cv=none; d=google.com; s=arc-20160816; b=Z6qtCVNzxZAXA2XefAFCtjXXrr1Mm8QXv8v8N0SOrlukPK3cpQC1Zs39PQt3ci/3RB MnKxZufoDKzjsTbEPPkFicCNqmIBKXfUQuWiZ/cK6g+AMwakxHE8D5bFmDZy9NMtTOxT qKBzWpYCsQxbA3q4lnP4EROEVAtxmhZwxz80bURPtJKm/6d/vmnTuVZoUDRlQMpkO34o Xl2cs2Xi4V5BuRaDsHwlpP5aF/eOwYgxv9JS3/+yPLRRsD6G8D6CqfMHLwvxdCC1uRPH PxBGKim9mgN1P1ubX3HSSfnmAEeWLi90uh96dKs6LBIXbdfjl2KWWZ1Vc/9ncil8cWNB m0Dg== 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:message-id:date:to:from :delivered-to; bh=IX0PYUDZ1zTPiyHAJQ7S+TO2XrPy2kFbnBosT9KUal0=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=y3u9BdJhNLF05kBucgZxy4NDUNYIo4fz0fkJl8mKAUbBYc5Fh4XZGWZWRH6qe3wTlo ZiDdOSgDP+Nwqda+1QwDsQScPUqXTNJ/2NF7XbLEqUoBeW+R6YUy9GwkhS7KulDtUHbo mAyK7HeTsUrn3jFV9OTe6ZOf9bseUHt2LP3ipx8IyRzvq1XgVeXfj92C/LrYsK3snD+n p93sk1fvp3LKmWzlvd7A2PXie6s98/t7ZD/j9YcxOsRr1O+X5uBw0i15/JwiThYWukTF S0n0EBoqviIKOh2XmE+W50rcXWSRAEqloGxj0gtRYs/Gl1WRqRU3CC/LiHiV0xLzgbY9 7DZQ== 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 j2-20020a17090686c200b00992acfbcee1si1741184ejy.851.2023.07.18.14.45.54; Tue, 18 Jul 2023 14:45:54 -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 3F97468C554; Wed, 19 Jul 2023 00:45:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3362568C19B for ; Wed, 19 Jul 2023 00:45:44 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9553E240005 for ; Tue, 18 Jul 2023 21:45:43 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:29 +0200 Message-Id: <20230718214542.685375-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 01/14] avradio/sdrdemux: Add Mittelwelle / Mediumwave / Mediumfrequency band 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: ny1II0/Rdw3W Signed-off-by: Michael Niedermayer --- libavradio/sdrdemux.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index 1b3061a406..318b5465da 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -1134,6 +1134,7 @@ static int demodulate_fm(SDRContext *sdr, Station *station, AVStream *st, AVPack BandDescriptor band_descs[] = { + {"Mediumwave band" , "MW", 520000, 1600000}, {"Shortwave band" , "SW", 6000000, 18000000}, {"FM broadcast band", "FM", 88000000, 108000000}, }; From patchwork Tue Jul 18 21:45:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42811 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781363pzb; Tue, 18 Jul 2023 14:46:04 -0700 (PDT) X-Google-Smtp-Source: APBJJlFWvQG5aj/1a9iTrWDDGA7TFM+gGWXD9JDc8enJHUDBe3AkH+A344hwcAbCkGMYbU6/4urC X-Received: by 2002:a05:6402:181a:b0:51d:9b4d:66bd with SMTP id g26-20020a056402181a00b0051d9b4d66bdmr941105edy.9.1689716763797; Tue, 18 Jul 2023 14:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716763; cv=none; d=google.com; s=arc-20160816; b=EBcm7qKzkHOiRw7cNkNkbYnN7uU9JSdzqXcUAzFGie2Io9lNutAgPunRBs6FnBWCoB CiyPBpiknbgClEXJsQzWR51bfDS8C6HlK/Tt487+jrc9L0foxk+t+Mbxbd8e5XxfI64A /HPoyxZwiRzeYi2J8uVoOMfwMlbu9FT4ufSOllEhgns7X8v5GX5cvK9cYBoKm4qTz1pS yElemmJhVTPS/OpJFQgWza+pU0FZwAFiMKq1gOSIGPWbOacyCtemwRbiq3RmJ+Uy6m/j ijcS9UlQT1G05KVJ90tysorSgefDJTx09g/zTXsxshZ59jupTC2stMtmSzPCt1cuyM7V qgBg== 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=Ktz3W0rHYiXQ3i4N0ywRYQSmJaMdVWedx9UlS23I+js=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=emzUH5um3osmF4h1NT/6zM85Lv3OE/1fq482AofRMNfBq3rEn3sTjz7vzh5VBbwEAn SLrwkE0J7yDyieGUGdWqp3563sVDJQozvdKYDtpldc/EfFlnpcZXHUiKuXWVZMeibvtt J4QPLZmIYNyimrf9R/cxfa6shjH8TnFXPk+QdAFNCCLtzfZKEoxxT7ck4opOzks5vHrB Ygf0mpjCn5iBrpp/4mBMXE01AcNYlkBuqBLAnJMVdAnWyLiKGQ7jaJF8p2to+yDhLo7c r0E4iMnZRDuxTblonjT7p9cwcCqlPwosQbvxFGJl/Lj0vtbAK+GiMkOSjuczaXKlzInR mwCw== 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 l7-20020aa7c307000000b0051e0e397ae5si1776189edq.215.2023.07.18.14.46.03; Tue, 18 Jul 2023 14:46:03 -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 5750B68C574; Wed, 19 Jul 2023 00:45:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8CF3568C206 for ; Wed, 19 Jul 2023 00:45:45 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id C18861C0002 for ; Tue, 18 Jul 2023 21:45:44 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:30 +0200 Message-Id: <20230718214542.685375-2-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 02/14] avradio/sdrdemux: Fix corner case in snap2band 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: PqrLRrfhRFPZ Signed-off-by: Michael Niedermayer --- 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)) From patchwork Tue Jul 18 21:45:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42812 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781429pzb; Tue, 18 Jul 2023 14:46:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6c2ypM6MsmwdvmoEFNNrbMA6GVxs6ltkrz0dv7IgWJ4BCEtqJ94atcYLAW4vw+fx2gQCZ X-Received: by 2002:aa7:d444:0:b0:51d:9195:400f with SMTP id q4-20020aa7d444000000b0051d9195400fmr911336edr.17.1689716772567; Tue, 18 Jul 2023 14:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716772; cv=none; d=google.com; s=arc-20160816; b=m6VHZXrGy6OGdiwznw0riXmrQf0VRyzR6Yi30FH7Xa4EvVNR1jjnOI5cNZiCFukZdl ChQP2Sy3ziiALLJ0o7TGxjsDQMc6F2qjqSeUQ2spH+7tWrn6cx9ZDLCmB+51yqYK9Z8A 2i9eHuqGsSz0ke72/ZOtff9m2a/yxjPd56inTnTYcTNFlsRyx0r65yENnJwAyvPPnVOY z3m6176+xR7/BKhOTAx2ZoeAmR86Aopl7+XY4j64dj9jhxqKjB0kHXIGBFmhfAP5atAK I8MWt+yhGUT6RvXhYZ5ZNEyA5ibKF0M8c5MBdb+K+Vo1HcOwZu8y8b/8GUImqAVJ5prM kUGQ== 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=OwajR5YgaNQqt/IEhFkCbXsn5NgX+84lftCb76EXkYo=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=XMLVnNgURfpVQ3TQykgEtqSCDZeMyBfxEQaBACLlI76VRzFc+BVateeSQ5HvOVHu06 nv/7C4oheUfN7ayw/nGSVFstOWJ55dUlBmjd7SbL5cJ9ltlzYn7HYMKOmCfbumlH3pWW Xhimy0yqhWSdLnFOgJbIeJXLcYM/qy9xmbs2g4H5bmnvw5vgx31mQi62HVUb1k4w37hm QRVfosENZCynOs6+LHtpnagiAapyMaij0pm4nc599bg8LiV8ptdVXD6yjtmrCmKtq8EH YdOaBm4paFdh795crwRa2RE5tWv144lkT1xdSmIn4tDA0CtZhZW22FIQ+L7+TefczzpI /BsQ== 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 g8-20020aa7c588000000b0051da08decbdsi1893349edq.636.2023.07.18.14.46.12; Tue, 18 Jul 2023 14:46:12 -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 424F068C586; Wed, 19 Jul 2023 00:45:54 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8703068C557 for ; Wed, 19 Jul 2023 00:45:46 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id DE3AE1BF204 for ; Tue, 18 Jul 2023 21:45:45 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:31 +0200 Message-Id: <20230718214542.685375-3-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 03/14] avradio/sdrdemux: Fix seeking to stations at the edge of the range 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: suZwEYTEe+0v Signed-off-by: Michael Niedermayer --- 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); 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; From patchwork Tue Jul 18 21:45:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42814 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781590pzb; Tue, 18 Jul 2023 14:46:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlF5ZxHWzZrzKys6YXzVNC6SkIborf7j+x/7gvVN654j9+s/WkJJM2u2COm9ynf2OpzKEoD0 X-Received: by 2002:a17:906:4546:b0:992:d013:1131 with SMTP id s6-20020a170906454600b00992d0131131mr800754ejq.52.1689716789629; Tue, 18 Jul 2023 14:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716789; cv=none; d=google.com; s=arc-20160816; b=MNgk3kmYsD3rAbVyBSSh2nZwgpXiPyzkAnUM4Q/4sa4K0XASrguARZ9IZyTMV2/PRt kCUrOfmHLVNt9Bueyy2cbKT/luENNxk9+AFDwCXfPl5zmF5x1CaIy+mi4lsIs7qqY3nu L1nIJTzniV+PCyhKmva+gfB3O0vdMOgJDJqFAFl2KaLkeFMjkrXtbs9uU4DP0iSH+ml7 4chRi/2Eqerz8UttL7iC0YezPJTIY5iKu3Lf9F2qRIkJ624Z/nTrtBI8XK4iBADAH/1p i5CC+4LgV/5C1k51DWuAzlP3PIUw+bDYCImVbz6tbPqpb1ZM9v2N6VboYsMl7+lIB1zk CGyw== 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=IDrG8LXuwRSZAAZHQmoFyW2cgbxk4zN1pvkPNa77p34=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=fcJ+VOMjTwtgbhPBPDFX5iKILrYUGJph6KTomrN9XztZ6V8r9Q+IepHadQJgSlWDz+ V0nGZsaWEiQSCdPFc+QHEyzdFGyWdpOu2r/f7fDZVVMoZsxAbE2aZjwKjq97DGW+R1cl h6lGmiyam/UhNKD5PQRqgTJOs4OS4uItefXobIpJPa6XQKjxTEvricuYhx0yt6Db+5sZ hwxVolDhUstINpLnvqXkuOje16LOxgjNuKUBl7DCE0krroPpO4FVmPyoEyZFKhd0igIz MR38k9sMvhl9gfGAchUBjf6uG02L1V3X1T1BBbPFYxtW+hDdew1E74NGglKldauqGhQv oP1w== 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 dx14-20020a170906a84e00b0099331b3e6f2si1697784ejb.663.2023.07.18.14.46.29; Tue, 18 Jul 2023 14:46:29 -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 522E068C5AA; Wed, 19 Jul 2023 00:45:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AB8EF68C4BE for ; Wed, 19 Jul 2023 00:45:48 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id E5567E0002 for ; Tue, 18 Jul 2023 21:45:47 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:33 +0200 Message-Id: <20230718214542.685375-5-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 05/14] avradio/sdr: snap2station() documentation 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: hBRPP0z6P063 Signed-off-by: Michael Niedermayer --- 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]; From patchwork Tue Jul 18 21:45:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42809 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781639pzb; Tue, 18 Jul 2023 14:46:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlFZRBpMTFv5krPsCmUlJwTqst84SUvOWEOczk9rCkIM8qfT7fDf+YHZeI+cExRZyPCu3f1y X-Received: by 2002:a17:906:c:b0:994:1956:2331 with SMTP id 12-20020a170906000c00b0099419562331mr763245eja.13.1689716797919; Tue, 18 Jul 2023 14:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716797; cv=none; d=google.com; s=arc-20160816; b=fDrLfQeJ4DKGGTmjX+G/5wtv3I/de2c/Vr8dLh+CPAWd0MffYx0/mDFwTKYFnN2Vj1 Skpt5ZkkJABNwqM98VsauTQZ5RHfA0BmlyfEciEnOzE4NOsJ2i8IdYh0hQaR3z4vqd/o BHcIDIjaYUtKYiU3LFJumRcOgWqcgUpxU6CXzErrPk0vE7h4KPM9pKLOtYgum56pmaL0 RRPsq1yegbLcfwIrIKrLm6jzvzVbYZouktW9RzVw1PM4Qr4EYKODWXSsz7q+bxfGQ0FJ iHXBwKHyurHvZ1Ocj0RgZqOhdlZBRWSsXAIkqNpIz6Ink7oyWcxD09pX7GCrigtJNFux BNXg== 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=WgLYQEZtYYJHs3R4Y5SdqeOtfMPYwGZSpoUPcVrYgR0=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=tvLvt1Nds1JQSALeeppvEJYrAASF5ITA/VOaQMd91UCOLQD339SGQbL7S7nmPpwgpv PwB0xigUJYi+vKPj0cuSFSwBSVsHtCPXKeErcHIYBeiK1Lk7U4ReA8S7kRxMBYwsh7XM hcwcBZz+RPgNho15HYjLoovyFD+kxKU0qB4wfOvY9gCfhUt+kSbKL6Jz+GBbBamDVXqj mHP6JwlwifHM+SXSow6XpTnurLmyw75XZBEattPcrEgocihw9okSzjWN0xwEkvymGuTP /V32aB7ZgBAKSVN7uwJ/4iL1sCxvuToek2Z1CqjSafxQh3feTSZkRcVBQzHgPyXSS7DH Oa+w== 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 j22-20020a170906831600b00982c9660263si1765088ejx.803.2023.07.18.14.46.37; Tue, 18 Jul 2023 14:46:37 -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 4056068C5BB; Wed, 19 Jul 2023 00:45:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE83868C58E for ; Wed, 19 Jul 2023 00:45:49 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4806740005 for ; Tue, 18 Jul 2023 21:45:48 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:34 +0200 Message-Id: <20230718214542.685375-6-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 06/14] avradio/sdrdemux: do not hack bandwidth value in random places 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: oIBf3fypODGx 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 --- 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); From patchwork Tue Jul 18 21:45:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42815 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781686pzb; Tue, 18 Jul 2023 14:46:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZYb2HCNJujV9x9YbjsmWVzZ7milqGGlAsk94MfiLnPrmtp8F44NwA1Pw5S5pvs/W1wvI/ X-Received: by 2002:aa7:da8b:0:b0:521:8a13:644e with SMTP id q11-20020aa7da8b000000b005218a13644emr750864eds.13.1689716805748; Tue, 18 Jul 2023 14:46:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716805; cv=none; d=google.com; s=arc-20160816; b=aVFnouwZXFc4rfuQuSiXXyrpcwmN8DyB6RBMb6DxShWYMWyR7/IW2kIT7VmnGuJULD pnM2HzmigZVmIUN3NxuVHPMtsAHUU6p2oYuz47+iSqhE0o6Vynw0Fs49iJ1JeWJrgqgs qkoAOzfngAeZ4fq2mtQSyTys2EH3Yik3C3+LUYg0WQDNwa1nUHKyAfgMIuOZF6TMVe6d ItQN2amF0yoFb/GMDG0feAEQogNVEXcPOk0fk6H/kq1Zzk9ohNdQaDLTLleFNslCcjGp 6lMyvaXvSUczLwv0zehQR7LobxRT6+1Z054nArqSiOLud2Ufy0kIKYRPNItsqcW1NRLq iolA== 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=A0bog90DaDBb3UwTvM3ycv2atiN429jkpIdJw5dbzDs=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=R9jEOK2Hww9dGQYhRCvSgJrBy8WvUeCZvbFoozX27q/BYmipHsHcwA4i5aDwvKeuZB /GKbzdQ7gzDlkmjl2dCw3rVwEy6ht9EQPlAnoGhpaNWawq7r/ThsOJm3UZ8fhrk4ziSk YxzAmy3rFPVzv0TZ1QXV5vkUYE2T6Gk6H131DHGmO9UVBa5cCwzA8ydraAe9OEAd66Gk wNdcHh+K4psBChfLqrViurAAfDnDL50R1hOCK6aj+cjHv0IUaBYZvSEcscZcyYiGkqQm X09eilcKvt9wtUIO1R6CN7FAjVuEVzgyiDuRTMB33CyVn6Olw8IqfATAkNqWk9qxkn/R NEEQ== 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 n14-20020a05640206ce00b0051e576a4c7asi1866344edy.260.2023.07.18.14.46.45; Tue, 18 Jul 2023 14:46:45 -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 46CA568C5D5; Wed, 19 Jul 2023 00:46:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E7C6D68C36B for ; Wed, 19 Jul 2023 00:46:02 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9DD7EC0002 for ; Tue, 18 Jul 2023 21:45:50 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:35 +0200 Message-Id: <20230718214542.685375-7-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 07/14] avradio/sdrdemux: snap2station consider more distant stations 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: RAmYClyvP8C6 Signed-off-by: Michael Niedermayer --- 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 X-Patchwork-Id: 42816 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781741pzb; Tue, 18 Jul 2023 14:46:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlGeA5WUAQBtGADYh68CF+8sipdyMNIti3wB20hJgeOTZThZs4jv60dGT6ORMvxpl+7KMzTj X-Received: by 2002:a17:906:2219:b0:993:f611:7c95 with SMTP id s25-20020a170906221900b00993f6117c95mr713063ejs.39.1689716813650; Tue, 18 Jul 2023 14:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716813; cv=none; d=google.com; s=arc-20160816; b=RHKRHR0H1DNkZqpwd+1UsqZnl2ObtqdIJMKRNtpiu8JgXKWytCmcZwsxH186s9qg56 h1qsFwcvTIdnWU047e4Wry6LmAZ3uGxsqOwJAOe8QB3LASvpGhC1kfRCxquxQ6fv6kOp mvDfe8QKqZjXBdlzgkQ2NSnDp+wkSSnl8y3fOeT2M9F8AV5PChlXZxEEf/xG8kXYZalF U1SHA10LH5u3oCVWZL/HElFTx8Cnm6ASGB1ndYVwZqqRhGK/rn++5scyh8gvVNjf6s/Q afOxjYu2nqaZHxsusDp2jRPonGR+qxvo4xJ3f7jxiAE5W6w97/RS7FXR1fzior9HMFHF ePcw== 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=Hko2LCc40LjDJzxyL6y3VwuLgSkOIcVqluclNFHNRCU=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=WrQkUe/zjkFn5LMtOtWB1R2whXCcjHGKxZS2zivZU3oaAMkfwB2zoW/MW8FyP69zoV pmHcTww5q7A/YZpFtzzC7TRgPXy74Qc/45MemcQfKVP3qMbqju23LJqz+AW7KXNAmVTE F1wswWXnQ3TipGauQMlkTZF6IMNX/3CMf+OaJUF4YW7X6F2kDn3XEvlp2EVIamkrZ8bv uJVWG2LFttHqreaiABnli1nL5UMXB/sBu5kV01qNRNObw5PUB4XDjzBjo1lySvzEi5qx uBytDrIbn7ovbWucjU7aqGu0cNE+aDmcj7J+QbT7M5ZyheqogkMx2TsbTRQ4oE/O/0gt Y1Pw== 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 k20-20020a1709061c1400b0099364d9f0e7si1615116ejg.543.2023.07.18.14.46.53; Tue, 18 Jul 2023 14:46:53 -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 4AF5E68C5F2; Wed, 19 Jul 2023 00:46:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9147E68C36B for ; Wed, 19 Jul 2023 00:46:03 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id BD5E860003 for ; Tue, 18 Jul 2023 21:46:02 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:36 +0200 Message-Id: <20230718214542.685375-8-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 08/14] tests: Add avradio/sdrdemux tests 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: 41Y902NfVVRE Signed-off-by: Michael Niedermayer --- 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 From patchwork Tue Jul 18 21:45:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42817 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781798pzb; Tue, 18 Jul 2023 14:47:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlHdUxQQm4tJpLpCc6Bqhb7gvWsTz2KJzTfYjmRCNYsJgbUR6Ug2at7F9BOHMMUmGuLUmXfU X-Received: by 2002:a17:906:73d2:b0:982:8c28:c50d with SMTP id n18-20020a17090673d200b009828c28c50dmr911780ejl.58.1689716821566; Tue, 18 Jul 2023 14:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716821; cv=none; d=google.com; s=arc-20160816; b=kiIcqCVvfbjD0xPnBdLwM3z2qKSQ6jpPrOJID+biruBYm7aGvWcow0RvTR1L1erNon gC5/XOBaKecfJ0dqxywBWwUT9ocd+NGfFxFqTcjtiKcTB+ofO569XPqAT1eqGIb4zxH1 YHprXH1PpLtgXO8OMLvxTh2ZPMwBwOEyTqtNH7V3eDJFxpSOURRvX3XAS2QPBBnTQ9hq LuoenGq4jl5QykUdD1l0h98+NndYfldOAwzTC/gjfoA605qk0V8EEL7DYKE3I7WpPmgt MQ4lpn8dVFXIyEVxPkfihvSn+4oNFr5WUL6keFMGr7B2u1f0fr9QLluRX1Sc33qdJHvu 0XGw== 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=Bw3drLbNA4WcHZ4CgC4iW8k2mT21AfNxLmDWmDXn4MY=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=j1g0UjeBwbBNuUtEpkHPXFdyxMFpGX9MS3ViC5CECqbIQedTAS9tg0k+IXYQoiwWpy MngaWf2bj3tCsYwxy+EddryplXD4IjDYGkLGe1PcMmXZGG4zBBLSS0OZ/cnIKusqwqIF ntdcPA7C2Eh3B+7o+Pt0plmCqRC/+0YpsqD4sZf45hhjBp9Atd1KR4ue8ZUfuF+CkJbN gUuEqGT4UN8LRf88snBMDIsQbNjRJ9fGfMM2FdTFTDS3Z+HVPOOSEZrYDFMFeQA9Jx96 VzojqnjT2eLluyjSPVz6IE7/eRajq7W/zPq8xEaas4yX9O/py7R5TF34GFl6eDTs4t4o C0/Q== 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 pj25-20020a170906d79900b0098e42bef73asi1810491ejb.98.2023.07.18.14.47.01; Tue, 18 Jul 2023 14:47:01 -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 4516968C5F1; Wed, 19 Jul 2023 00:46:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3FD5A68C5D3 for ; Wed, 19 Jul 2023 00:46:04 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 96A6940006 for ; Tue, 18 Jul 2023 21:46:03 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:37 +0200 Message-Id: <20230718214542.685375-9-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 09/14] avradio/sdr: Remove code setting frequency from variable being 0 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: UVeXpBRIq2Ew wanted_freq is 0 at this point Signed-off-by: Michael Niedermayer --- 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); From patchwork Tue Jul 18 21:45:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42818 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781859pzb; Tue, 18 Jul 2023 14:47:10 -0700 (PDT) X-Google-Smtp-Source: APBJJlFL6FGDEyAbKFweokENS1a1AzgXJIoN73mOg7A2upXvOvmoKlVj3uaSqhMu2F3yrzySmXy2 X-Received: by 2002:a05:6402:345:b0:51e:d76:25b2 with SMTP id r5-20020a056402034500b0051e0d7625b2mr877728edw.29.1689716829689; Tue, 18 Jul 2023 14:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716829; cv=none; d=google.com; s=arc-20160816; b=NGum3jcRtSWKrFhORljvwfFyyKfJR4FaCqItZlATiGtRll59Xzy7Z8wj4HHr04Wh9m +1CKndSC260pdXQTNJT/VSurXIukIzBx4WtcbSAtBf/dM48uv0Sk9ZCaQIKR4QVeucNO vSxDURTAW4p2V4FOZHot7Uairez6ocKxd8QGJv9jEQwZGEXZcPzWJpAVzX1dJ9P4ntqO s6XDNf1cpJ3nd6FwQxN6Q4J6ZgdhRASpSUdUtqWle9Z3F6FLEirLUqR/CHgXau1jyBJU ZKg/cWqEJ9334ktiNn4oZ+FyL3ICawUSfAxKU0ZZonMP3S/zTb6+ObB4ce31zJrobSTa r7dg== 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=hD5dQHIafo/fb4Zst0dd2tnu8P9u+RP83dNHZqioHes=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=tXDTjpTd8GepYPNi54IT6Pvv5mm5w1mSJ7k27dzVC1xEs+CKsQpPkkDHs72dKlrHiN VSq3qY1fdynUoqprdrLnocu3TVVRFiA1laK7DIQ0mKHA4sTC5MLYuXIHCjiWb4ulL2xj X0lPaRoKhoZc4mLut0UYf4jYMmS08CijSgsA+d005h2T/qFdExmd3G1b1ZwJ/9JjqfK9 jWLlpHbRPJXbiJYYfax14wKbAGIgegqKsqbRu62H9BGej1Z8UAfz86O797yOnW2ANZ6/ GDUxL0EhVXpQ6JaF4ZbkVrBhLYpGFRT7U6R0EQxUJi6EvgNGx8uFZcxrxl4TIJK21nRw 6lkw== 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 c2-20020aa7c742000000b0051e22dd4640si1967699eds.471.2023.07.18.14.47.09; Tue, 18 Jul 2023 14:47:09 -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 3CA7868C36B; Wed, 19 Jul 2023 00:46:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0BFDD68C5AE for ; Wed, 19 Jul 2023 00:46:04 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 65668E0002 for ; Tue, 18 Jul 2023 21:46:04 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:38 +0200 Message-Id: <20230718214542.685375-10-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 10/14] avradio/sdrdemux: no need to set wanted_freq from sdrfile_initial_setup() 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: VdHCafOXEYGq Signed-off-by: Michael Niedermayer --- 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); From patchwork Tue Jul 18 21:45:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42819 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781911pzb; Tue, 18 Jul 2023 14:47:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHZ/EHXygliDtekQ+Vm1glktOZn/BbBtpECetdGNfWKneAtqMipjUUe2ZWuQpQO0W3bH6AE X-Received: by 2002:a05:6512:282b:b0:4f9:607a:6508 with SMTP id cf43-20020a056512282b00b004f9607a6508mr547126lfb.50.1689716837551; Tue, 18 Jul 2023 14:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716837; cv=none; d=google.com; s=arc-20160816; b=Z/4OiuUE9XsRBIfKRwwa5ig8GWWibM4E1txuT9hW+uOZWDKGBwfvT5dFPtWr3aV1Cu mSFQgAv516WQioa1CsxAhImK/giT6yebKOfua2qBtdAF5XwLDtQ7GIXd6hR3vupaYgBt wrCTqJfajItuEd+OmaUVwa04v7rLkZLz9/zHVfJNpwbu0NIYAv1v/eqDz9kCeQwFBrf8 L4vTFL0DvbwCaPm0JDxBNw6oHIgapWUNLcYJnwTrU90ggHqk5bobaoDRKk8fobwkaWUJ E09FGKEJLtwnOv9ObTPlGwImET3Y3LKXpTVzJ72NammmpeN0dIraR33L2wrHEUqqvT73 1M8w== 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=BawymE77p4ghfw4f8mGueMo0uDsYBUXV4sxlhrOYt8o=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=bCFpHNzOZd/KnHF81SrslGyQxh9xjtREmWgrjF5ARjD2dRY6ftgub3RRnBmjxeBHYc PB+z2ykkDzaQYbe02FR+gXtnHqK28mIdAGz/fDss/RpKnufFsCiVe1MUIalFNE6VEoY2 lWODszi87nUARdpQst4GyccM8BnV8vchD6Ouy15yLq5hbpjxI5RYmxgk4EwNpCpZbcYe yJo5X09DVfXkzQxe7iN1yfgknbUYZevZmio6wLeCcAAH+L0cEw0zEyKAoxtT/brDbtxL b6YOsP4P1GN3YnUqgCwe63BBOoKRl8gDIRseisVIRJ4iKE4/1FGsRouaYkcCuVAmDgt9 kNgw== 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 k21-20020a05640212d500b0051e05151467si1768755edx.224.2023.07.18.14.47.17; Tue, 18 Jul 2023 14:47:17 -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 1E8FB68C5F6; Wed, 19 Jul 2023 00:46:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1E0C68C5DB for ; Wed, 19 Jul 2023 00:46:05 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 337B240007 for ; Tue, 18 Jul 2023 21:46:05 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:39 +0200 Message-Id: <20230718214542.685375-11-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 11/14] avradio/sdr: More atomics, less Mutexes 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: ej1jRrdWKTYp Maybe this is cleaner Signed-off-by: Michael Niedermayer --- 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"}, From patchwork Tue Jul 18 21:45:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42820 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp781980pzb; Tue, 18 Jul 2023 14:47:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlE7mRTijxhwu7qg6Z7jYQBWE8Vo3BPnx/X3scQ0Zk41DeZ5DAh4Sh78qcDYh3OrY1WbC99f X-Received: by 2002:aa7:df8e:0:b0:51e:1c18:dd99 with SMTP id b14-20020aa7df8e000000b0051e1c18dd99mr905535edy.38.1689716845729; Tue, 18 Jul 2023 14:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716845; cv=none; d=google.com; s=arc-20160816; b=j6f6MYbx87hF1R3d1xeB++9RkVeOag5CKW1SudWnhvoyiJmefVopDhT1O+WUQsL+Ou AJrSBuEgBAxpiwOxuIPRRNnNos0rBP7TdBzbkwJ7020I+hBPlYxA7QxNf4TBv8LJjDeK 1poytMezawXAy2+2jqY4YVgVRHmVjPTZowVc3OTYPuf/mI79mflTsYQr7pEPkdA8hJMk w9K8Zerpn3RXh4O41zM86rg7lsEvIk16f99l1CrTapfXKwi92dNUbwAj7p1IrwmhIXP6 6S+mfc4c+pxr3m2DYBhqoUvQ3QVF9EXAy53NEOlEkFKG2OJXwdG/WxQmTDR81UC6MqpB 8iAA== 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=AoGQr1SInALjicNElko/6rjpvOhVW/o+6EXwLxJVydk=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=yU49VQ+BFPMXqLlKw3LEVBPxsz0W5g9sOMnWi32CWD47IQMFJjUWsSQKxi/xbx7wjK VFU1l7brMMihMneovR/IWuT5EgkzZ2t4o8bFE0SvGJvRC55rUNbibDNkkmykDMHEYyYo /KQhOq/09dbl/Rz8GPLYtB78x0YSCYdHREJq46lzLArZ8STQT6yvYrN9gpjEryLaFSUW 8S2B1KERlmXJrkHD6EIZ+Ty/i7fKPTkF11qqyezqeMfx8CkZNhwlXPpB1ZYJEMEhJyGb d5F/1sM20AFhqVuFTc1h1XVWC1GhGugYqqCJsEpa+u1qa1EI1zJ+8ppV/rPwqsaRx+WB gP+Q== 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 o1-20020aa7d3c1000000b0051dd3e8fc91si1987858edr.67.2023.07.18.14.47.25; Tue, 18 Jul 2023 14:47:25 -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 1F78E68C588; Wed, 19 Jul 2023 00:46:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9DE6C68C238 for ; Wed, 19 Jul 2023 00:46:17 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 148F81C0002 for ; Tue, 18 Jul 2023 21:46:05 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:40 +0200 Message-Id: <20230718214542.685375-12-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 12/14] avradio/sdrdemux: + vs. - bug 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: 01Yu6VAGpWyX Signed-off-by: Michael Niedermayer --- 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) { From patchwork Tue Jul 18 21:45:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42808 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp782036pzb; Tue, 18 Jul 2023 14:47:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlGRTuc5U5daULDUgYUt6zz2E0h9eD+k8Rr7g8PzRaOCXMmZl8NWLOSEvhhW/c+j4qd0gx9Y X-Received: by 2002:a17:906:8b:b0:982:79fa:4532 with SMTP id 11-20020a170906008b00b0098279fa4532mr861200ejc.53.1689716853708; Tue, 18 Jul 2023 14:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716853; cv=none; d=google.com; s=arc-20160816; b=gdXcTan/6qZYUHWezTz09j+IGYdzgrnXlKViE3R1v4nUtZc5lWI1Yt+SO/Mc4hRv57 duw7HL/lDBKmrBBaFrHt3ealMYoi58Op9/xGT4ZoyNFCF39w9oPDuU/rhGVlqZr16meo U84VfKoWUXSPLCPUVdGpDTpoll/bDOD9+BI9HwRt7mIsuw8t9fuHC6wlMhrPaLPBB4uf Sy1gMmDS/RT56jz5IpTqehda2VVvHHSft9nireHwcCfKcDJUBQEN1vQV6APzu/mRG/XC 60uVJt+H7C/p0E1wIfOd348lldpiBNRfzlWTymzH8lIrRwSQpYLVA1mUpqjxBukDfdY2 VIig== 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=UNeERvKyhisTU8e+D78YTVd82N4zVbxdN6gGFvZZ3ws=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=gUMwjPp8uhvUqdpWfb1Kso6VO0TuXPbAXn3biAWXz5h8z9C1PyP4hzGwN8I1Gl3JAi vYl5re20VRJSNCnDzRghA0ZjRnWgkwdaCj+NblQBgOv9wu1fIOUx0B1lIApuPmpF+KOp IaEb4N7gvvZCaGmUU/smgFpPfw7gZOT3j10urmF6DJPwLo5AHFLhz75q5OVM4tfLmTrv hvE8jCyJcrLRpUzY9xrfZKeVfeDvuTWFMF1yg9Yb23IZ/WJr0lkg4Mv6L/ISxt/G2Asp OsLxBlJVTdWoAf43rkp9sEn/kPGF9ZKA+2Td8+HF2n5RhAXiNLOFdfxNkSJkaJEoHU/0 xPbQ== 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 a20-20020a1709062b1400b0098e1c7a62casi1723442ejg.334.2023.07.18.14.47.33; Tue, 18 Jul 2023 14:47:33 -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 465DB68C64B; Wed, 19 Jul 2023 00:46:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B3CF68C562 for ; Wed, 19 Jul 2023 00:46:18 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id E436D60002 for ; Tue, 18 Jul 2023 21:46:17 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:41 +0200 Message-Id: <20230718214542.685375-13-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 13/14] avradio/sdrdemux: snap2band doesnt change anything so use const 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: 4XG2n7YJGsJb Signed-off-by: Michael Niedermayer --- 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; From patchwork Tue Jul 18 21:45:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42821 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:b813:b0:130:ccc6:6c4b with SMTP id fi19csp782094pzb; Tue, 18 Jul 2023 14:47:41 -0700 (PDT) X-Google-Smtp-Source: APBJJlEM0WsSHU9JQ74iMNBbqLVCFGt3OY2IuW55KojWvPPmwVUG8DxT7JBEbGovEk6fORGLNsqd X-Received: by 2002:a2e:9798:0:b0:2b6:a344:29cf with SMTP id y24-20020a2e9798000000b002b6a34429cfmr411903lji.17.1689716861430; Tue, 18 Jul 2023 14:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689716861; cv=none; d=google.com; s=arc-20160816; b=ZIBZnUYk/aQBc9XqP5KEnvN+ajG/leWgFLCW4fv0MKcGdLDm2y/kewSOMVfrqsKmiF IDVbh4yDTEZvzMlVgZbChECgb4We52Z0Rf6XTsQS85QC6wdVExN1rfI0fu0VgSFvZ3U/ e9IVu4n8DhoOXMT4SLqc8kxRFBqMClxzyXDsbZWRD60yge6azTSj7sqBaRqS9H4aBoRB CdpTVdrgoxtnMAxN84INcUexspNkmh4W8hHqGeutzfRbt8IVikTAn9DEFcN5Z4+5uRpJ Ox1pbwz8AShnLsWoAC43NJ2ydpw/nxUBd2PmZYE6h7S5772E1wCXCFg9kEHE3fnwtlIO uyUw== 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=otGe4Ry3B5OvlVe7LdfEp8Qvzhx6zNo7WUjgPaWvPZQ=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=Iau2ZRAkFYf5SkFu4X82sPhLYVTS8fik9yrB/XiaL8C/8dItL1++w8FY4YyOBBAjtH uYc03wI99zJHBUT13HZ8GeB4OpoDx99a00KQjIkZlLlHvVmiBAyZZOFDw/z20UnMyJb2 sp3H8QGxX4GnML29UjvQi4dp8ErzCEMmDPaQS49ZDmc48Oxvbp5AJC/iUe5ilzKxqJrc x45Tgf4V73VBlERT/UqShCN51hGl2dQfKgeNDeHNWIgACi/fpW1lgctfH6d8ZpyEL9xL 7IRd/J7UFhAQj7nLBvVWPTDxfG8UkBNzQUPKFXD/F8y+fAkdOScRbwkZ28QSJvdWa0l+ uDqg== 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 z5-20020a1709064e0500b009893fe84e74si1853363eju.484.2023.07.18.14.47.41; Tue, 18 Jul 2023 14:47:41 -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 4F93068C613; Wed, 19 Jul 2023 00:46:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5CEF568C62F for ; Wed, 19 Jul 2023 00:46:19 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id C5EAA240007 for ; Tue, 18 Jul 2023 21:46:18 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 18 Jul 2023 23:45:42 +0200 Message-Id: <20230718214542.685375-14-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 14/14] avradio/sdrdemux: Fix wraparound with seeking 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: kHaF2MGzrj3x 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 --- 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); }