so we need to check every block, we cannot just check a few and then subtract the same value
Signed-off-by: Michael Niedermayer <mich...@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-requ...@ffmpeg.org with subject "unsubscribe".