From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 446AA46BD0 for ; Tue, 4 Jul 2023 22:23:29 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3BDDE68C654; Wed, 5 Jul 2023 01:23:13 +0300 (EEST) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --- 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] && -- 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".