diff --git a/firmware/baseband/dsp_decimate.cpp b/firmware/baseband/dsp_decimate.cpp index 930a2fb3..eb2f6d6e 100644 --- a/firmware/baseband/dsp_decimate.cpp +++ b/firmware/baseband/dsp_decimate.cpp @@ -205,10 +205,15 @@ buffer_c16_t FIRAndDecimateComplex::execute( * -> int16_t output, decimated by decimation_factor. * taps are normalized to 1 << 16 == 1.0. */ - const sample_t* src_p = src.p; + const auto output_sampling_rate = src.sampling_rate / decimation_factor_; + const size_t output_samples = src.count / decimation_factor_; + sample_t* dst_p = dst.p; + const buffer_c16_t result { dst.p, output_samples, output_sampling_rate }; - while(src_p < &src.p[src.count]) { + const sample_t* src_p = src.p; + size_t outer_count = output_samples; + while(outer_count > 0) { /* Put two new samples into delay buffer */ auto z_new_p = &samples_[taps_count_ - decimation_factor_]; for(size_t i=0; i