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 58DDC461D3 for ; Sat, 8 Jul 2023 21:27:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A610768C59F; Sun, 9 Jul 2023 00:25:51 +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 C51E668C572 for ; Sun, 9 Jul 2023 00:25:40 +0300 (EEST) X-GND-Sasl: michael@niedermayer.cc Received: by mail.gandi.net (Postfix) with ESMTPSA id 345D620007 for ; Sat, 8 Jul 2023 21:25:40 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 8 Jul 2023 23:25:21 +0200 Message-Id: <20230708212530.109692-9-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 09/18] avradio/sdrdemux: The RTLSDR DC artifact is not consistent 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: so we need to check every block, we cannot just check a few and then subtract the same value Signed-off-by: Michael Niedermayer --- libavradio/sdr.h | 1 - libavradio/sdrdemux.c | 23 +++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/libavradio/sdr.h b/libavradio/sdr.h index 95ff903293..13237707b3 100644 --- a/libavradio/sdr.h +++ b/libavradio/sdr.h @@ -202,7 +202,6 @@ typedef struct SDRContext { int missing_streams; int rtlsdr_fixes; - float rtlsdr_dc_offset; } SDRContext; typedef struct ModulationDescriptor { diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c index 392fece4e9..6682768461 100644 --- a/libavradio/sdrdemux.c +++ b/libavradio/sdrdemux.c @@ -1705,21 +1705,20 @@ process_next_block: const int8_t *halfblock0 = fifo_element[0].halfblock; const int8_t *halfblock1 = fifo_element[1].halfblock; if (sdr->rtlsdr_fixes>0) { - if (!sdr->rtlsdr_dc_offset || !sdr->block_center_freq) { - int sum = 0; - for (i = 0; i<2*sdr->block_size; i++) - sum += halfblock0[i] - + halfblock1[i]; - sdr->rtlsdr_dc_offset = -sum / (4.0*sdr->block_size); - av_log(s, AV_LOG_DEBUG, "Compensating DC offset %f (this should be around -0.6)\n", sdr->rtlsdr_dc_offset); - } + int sum = 0; + float offset; + for (i = 0; i<2*sdr->block_size; i++) + sum += halfblock0[i] + + halfblock1[i]; + offset = -sum / (4.0*sdr->block_size); + av_log(s, AV_LOG_DEBUG, "Compensating DC offset %f (this should be around -0.6)\n", offset); for (i = 0; iblock_size; i++) { - sdr->windowed_block[i].re = (halfblock0[2*i+0] + sdr->rtlsdr_dc_offset) * sdr->window[i]; - sdr->windowed_block[i].im = (halfblock0[2*i+1] + sdr->rtlsdr_dc_offset) * sdr->window[i]; + sdr->windowed_block[i].re = (halfblock0[2*i+0] + offset) * sdr->window[i]; + sdr->windowed_block[i].im = (halfblock0[2*i+1] + offset) * sdr->window[i]; } for (i = sdr->block_size; i<2*sdr->block_size; i++) { - sdr->windowed_block[i].re = (halfblock1[2*(i - sdr->block_size)+0] + sdr->rtlsdr_dc_offset) * sdr->window[i]; - sdr->windowed_block[i].im = (halfblock1[2*(i - sdr->block_size)+1] + sdr->rtlsdr_dc_offset) * sdr->window[i]; + sdr->windowed_block[i].re = (halfblock1[2*(i - sdr->block_size)+0] + offset) * sdr->window[i]; + sdr->windowed_block[i].im = (halfblock1[2*(i - sdr->block_size)+1] + offset) * sdr->window[i]; } } else { for (i = 0; iblock_size; i++) { -- 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".