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 D272F461B1 for ; Sat, 8 Jul 2023 21:28:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 51A1E68C60D; Sun, 9 Jul 2023 00:25:57 +0300 (EEST) 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 2FBD868C5A0 for ; Sun, 9 Jul 2023 00:25:49 +0300 (EEST) X-GND-Sasl: michael@niedermayer.cc Received: by mail.gandi.net (Postfix) with ESMTPSA id 87EE7C0002 for ; Sat, 8 Jul 2023 21:25:48 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 8 Jul 2023 23:25:30 +0200 Message-Id: <20230708212530.109692-18-michael@niedermayer.cc> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230708212530.109692-1-michael@niedermayer.cc> References: <20230708212530.109692-1-michael@niedermayer.cc> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/18] avradio/sdrdemux: Fix DC offset issue in AM demodulation 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: Signed-off-by: Michael Niedermayer --- libavradio/sdrdemux.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index d73cbc0a06..7cc71b2cfb 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -740,7 +740,8 @@ static int demodulate_am(SDRContext *sdr, int stream_index, AVPacket *pkt) AVComplexFloat mm; double s2 = 0; double dcw = 0; - float amp, amp2; + float amp, stamp, wamp; + for(i = 0; i<2*sst->block_size; i++) { double tmp; AVComplexFloat v = sst->iblock[i]; @@ -755,17 +756,17 @@ static int demodulate_am(SDRContext *sdr, int stream_index, AVPacket *pkt) dcw += sst->window[i] * sst->window[i]; } - amp = dcw / (dc1.re*dc1.re + dc1.im*dc1.im); - amp2= dcw / s2; - amp = FFMIN(amp, amp2 * 0.1); + stamp = dcw / (dc1.re*dc1.re + dc1.im*dc1.im); + amp = FFMIN(stamp, dcw / s2 * 0.1); if (sst->am_amplitude) amp = 0.9*sst->am_amplitude + 0.1*amp; sst->am_amplitude = amp; + wamp = amp/stamp; mm = (AVComplexFloat){dc1.re * amp, -dc1.im * amp}; for(i = 0; i<2*sst->block_size; i++) { AVComplexFloat v = sst->iblock[i]; - sst->iblock[i].re = v.re*mm.re - v.im*mm.im - sst->window[i]; + sst->iblock[i].re = v.re*mm.re - v.im*mm.im - sst->window[i] * wamp; sst->iblock[i].im = v.re*mm.im + v.im*mm.re; } -- 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".