From patchwork Tue Jul 4 22:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42439 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1e:b0:12b:9ae3:586d with SMTP id c30csp5378228pzh; Tue, 4 Jul 2023 15:23:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlFfmJ4qCK1mWO+HFrmbmqi2TioATfnJKb8M0u0iM2ed7H0GlOGib1VkSj5McpYojY9B3vzN X-Received: by 2002:a05:6512:2145:b0:4fb:9fa7:dcda with SMTP id s5-20020a056512214500b004fb9fa7dcdamr8922324lfr.26.1688509411558; Tue, 04 Jul 2023 15:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688509411; cv=none; d=google.com; s=arc-20160816; b=D9xqTH8vFmNY5HisadDa3maOd5qXDF5MZMH1rV5cA36sqCy4I0uXsq7XydB9HQQxhg 0QLavcoHr8ClEfO0xuSxJ43VVripVQwNfVxT/CynfNo5pqSMxko5BJvBWl+R/2eWCvnI YMxziIpOhwgay8TVc57pByyU7DbSKqWlXEQ4VfIgFdXTHV4Xx/yHsoVZTJ3QlgZY743b QUqyRZ6CzQdeHorSXMCRx5stplhKmVMlcR1D0/K2LmbqaNEPFPEVj9ObYSJfkZ/YldBH OtR50rbJaoOnTjE1RhH1hNwwoprEAJJxdfBCMJEZKvYsfAGbXfUiW7FZpS2SybWyeqNO MwhQ== 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=zsZzNNJZsDcAbCYCOepbLstU8SsCf5Cp64QRxm4XRU4=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=FVX/KMSDfFh4FyEl7Hhz092EbSmQI0w1mvxmzXqIdx1VHFG3LhejE20Lmg2KhN5jbn oEcRCD5zLThAihbpGuePKjdsATrG6+GrA2O7ogy6JIoKKe9R7u8pZmYyaX0lDI/VaXki YyFCVQmNdsDs2XFvAzTknT1u11MvBNvw2QAhYVhzZG1ZP9NnNBh91N1yknToGgnA5qrY ZHBkiigFdx3e5wM5X4L//shCh5Pjcu/Jcg2ZvBu5pr/frCEbdJQsiTkkA4yA+YyrJm6I t3y1niMuBT1+vDfaJsSyq9sdCMdWzsNMrrW+uPmguAdAOM6FAcy4GVBacBt/hUErWF8y Kv/g== 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 v1-20020a056402184100b0051bf4a5dc6dsi4873174edy.34.2023.07.04.15.23.31; Tue, 04 Jul 2023 15:23:31 -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 6BF0768C656; Wed, 5 Jul 2023 01:23:13 +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 E0FD368C646 for ; Wed, 5 Jul 2023 01:23:06 +0300 (EEST) X-GND-Sasl: michael@niedermayer.cc Received: by mail.gandi.net (Postfix) with ESMTPSA id 2548C20003 for ; Tue, 4 Jul 2023 22:23:05 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 5 Jul 2023 00:22:59 +0200 Message-Id: <20230704222302.1129450-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230704222302.1129450-1-michael@niedermayer.cc> References: <20230704222302.1129450-1-michael@niedermayer.cc> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] avradio/sdrdemux: Skip probing in the area outside the bandwidth 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: R7DaLCOm6inD --- libavradio/sdrdemux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index 39e2e54ee7..90f6805c3b 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -394,6 +394,7 @@ static int probe_am(SDRContext *sdr) int i; int bandwidth_f = 6000; int half_bw_i = bandwidth_f * (int64_t)sdr->block_size / sdr->sdr_sample_rate; + int border_i = (sdr->sdr_sample_rate - sdr->bandwidth) * sdr->block_size / sdr->sdr_sample_rate; double avg = 0; if (2*half_bw_i > 2*sdr->block_size) @@ -408,6 +409,10 @@ static int probe_am(SDRContext *sdr) avg += sdr->len2block[i + half_bw_i]; score = half_bw_i * mid / (avg - mid); avg -= sdr->len2block[i - half_bw_i]; + + if (i < border_i || i > 2*sdr->block_size - border_i) + continue; + //TODO also check for symmetry in the spectrum if (mid > 0 && score > AM_THRESHOLD && sdr->len2block[i - 1] < mid && sdr->len2block[i + 1] <= mid && @@ -703,6 +708,7 @@ static int probe_fm(SDRContext *sdr) int half_bw_i = bandwidth_f * (int64_t)sdr->block_size / sdr->sdr_sample_rate; double avg[2] = {0}, tri = 0; float last_score[3] = {FLT_MAX, FLT_MAX, FLT_MAX}; + 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; @@ -726,6 +732,8 @@ static int probe_fm(SDRContext *sdr) last_score[2] = last_score[1]; last_score[1] = last_score[0]; last_score[0] = tri / (b * half_bw_i); + if (i < border_i || i > 2*sdr->block_size - border_i) + continue; if (last_score[1] >= last_score[0] && last_score[1] > last_score[2] &&