From a1b9f4aa1b202effcc3d200aaeea1c1882913954 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Tue, 23 Feb 2016 15:04:20 -0800 Subject: [PATCH] Simplify, generalize, share int16_t taps copy function. Also prevents compiler loop unrolling in non-critical code, for code size improvement. --- firmware/baseband/dsp_decimate.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/firmware/baseband/dsp_decimate.cpp b/firmware/baseband/dsp_decimate.cpp index 642437490..93dbc6025 100644 --- a/firmware/baseband/dsp_decimate.cpp +++ b/firmware/baseband/dsp_decimate.cpp @@ -177,6 +177,20 @@ static inline uint32_t scale_round_and_pack( return __PKHBT(saturated_real, saturated_imag, 16); } +template +static void taps_copy( + const Tap* const source, + Tap* const target, + const size_t count, + const bool shift_up +) { + const uint32_t negate_pattern = shift_up ? 0b1110 : 0b0100; + for(size_t i=0; i> (i & 3)) & 1; + target[i] = negate ? -source[i] : source[i]; + } +} + // FIRC8xR16x24FS4Decim4 ////////////////////////////////////////////////// void FIRC8xR16x24FS4Decim4::configure( @@ -184,13 +198,7 @@ void FIRC8xR16x24FS4Decim4::configure( const int32_t scale, const Shift shift ) { - const int negate_factor = (shift == Shift::Up) ? -1 : 1; - for(size_t i=0; i