Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH 09/18] avradio/sdrdemux: The RTLSDR DC artifact is not consistent
Date: Sat,  8 Jul 2023 23:25:21 +0200
Message-ID: <20230708212530.109692-9-michael@niedermayer.cc> (raw)
In-Reply-To: <20230708212530.109692-1-michael@niedermayer.cc>

so we need to check every block, we cannot just check a few and
then subtract the same value

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 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; i<sdr->block_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; i<sdr->block_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".

  parent reply	other threads:[~2023-07-08 21:27 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-08 21:25 [FFmpeg-devel] [PATCH 01/18] avradio/sdrdemux: Fix uninitialized access Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 02/18] avradio/sdrdemux: factor frequency tolerance constants out Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 03/18] avradio/sdr: Add fm multiple parameter Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 04/18] avradio/sdrinradio: Dont automatically select 2.56Mhz on the rtlsdr Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 05/18] avradio/sdrdemux: Do not timeout negative stations Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 06/18] avradio/sdrinradio: Factor print_and_free_list() out Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 07/18] avradio/sdrinradio: Print list of Time Sources Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 08/18] avradio: split out vissualization code Michael Niedermayer
2023-07-08 21:25 ` Michael Niedermayer [this message]
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 10/18] avradio/sdr: eliminate avpriv_* Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 11/18] avradio/vissualize: rotate waterfall Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 12/18] avradio/sdrdemux: Set AVFMTCTX_NOHEADER Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 13/18] avradio/sdrdemux: fix bug adding candidate stations and then crashing Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 14/18] avradio/sdrdemux: fm_probe: dont allow bandwidh=sample rate Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 15/18] doc: add sdr examples Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 16/18] avradio/sdr: rename fft_p2 Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 17/18] avradio/sdrdemux: more correct phase 2 bandwidth of FM demodulation Michael Niedermayer
2023-07-08 21:25 ` [FFmpeg-devel] [PATCH 18/18] avradio/sdrdemux: Fix DC offset issue in AM demodulation Michael Niedermayer
2023-07-09 23:43 ` [FFmpeg-devel] [PATCH 01/18] avradio/sdrdemux: Fix uninitialized access Michael Niedermayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230708212530.109692-9-michael@niedermayer.cc \
    --to=michael@niedermayer.cc \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git