From 86b068be620748146059dd3e3f2808da199af175 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 3 Nov 2015 17:02:46 -0800 Subject: [PATCH] Early calculation to reduce pressure on registers. --- firmware/baseband/dsp_decimate.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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