mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-01-11 15:29:28 -05:00
FIRAndDecimateBy2Complex: expose decimation_factor, bring work function into class.
This commit is contained in:
parent
cde15e4271
commit
424c0eac3f
@ -197,32 +197,27 @@ buffer_s16_t FIR64AndDecimateBy2Real::execute(
|
||||
return { dst.p, src.count / 2, src.sampling_rate / 2 };
|
||||
}
|
||||
|
||||
size_t fir_and_decimate_by_2_complex_fast(
|
||||
const complex16_t* const src_start,
|
||||
const size_t src_count,
|
||||
complex16_t* const dst_start,
|
||||
complex16_t* const z,
|
||||
const complex16_t* const taps,
|
||||
const size_t taps_count,
|
||||
const size_t decimation_factor
|
||||
buffer_c16_t FIRAndDecimateComplex::execute(
|
||||
buffer_c16_t src,
|
||||
buffer_c16_t dst
|
||||
) {
|
||||
/* int16_t input (sample count "n" must be multiple of decimation_factor)
|
||||
* -> int16_t output, decimated by decimation_factor.
|
||||
* taps are normalized to 1 << 16 == 1.0.
|
||||
*/
|
||||
const auto src_p = src_start;
|
||||
auto dst_p = dst_start;
|
||||
const sample_t* src_p = src.p;
|
||||
sample_t* dst_p = dst.p;
|
||||
|
||||
while(src_p < &src_start[src_count]) {
|
||||
while(src_p < &src.p[src.count]) {
|
||||
/* Put two new samples into delay buffer */
|
||||
auto z_new_p = &z[taps_count - decimation_factor];
|
||||
for(size_t i=0; i<decimation_factor; i++) {
|
||||
auto z_new_p = &samples_[taps_count_ - decimation_factor_];
|
||||
for(size_t i=0; i<decimation_factor_; i++) {
|
||||
*__SIMD32(z_new_p)++ = *__SIMD32(src_p)++;
|
||||
}
|
||||
|
||||
size_t loop_count = taps_count / 8;
|
||||
auto t_p = &taps[0];
|
||||
auto z_p = &z[0];
|
||||
size_t loop_count = taps_count_ / 8;
|
||||
auto t_p = &taps_reversed_[0];
|
||||
auto z_p = &samples_[0];
|
||||
|
||||
int64_t t_real = 0;
|
||||
int64_t t_imag = 0;
|
||||
@ -282,10 +277,10 @@ size_t fir_and_decimate_by_2_complex_fast(
|
||||
|
||||
/* Shift sample buffer left/down by decimation factor. */
|
||||
const size_t unroll_factor = 4;
|
||||
size_t shift_count = (taps_count - 1) / unroll_factor;
|
||||
size_t shift_count = (taps_count_ - decimation_factor_) / unroll_factor;
|
||||
|
||||
auto t = &z[0];
|
||||
auto s = &z[decimation_factor];
|
||||
sample_t* t = &samples_[0];
|
||||
const sample_t* s = &samples_[decimation_factor_];
|
||||
|
||||
while(shift_count > 0) {
|
||||
*__SIMD32(t)++ = *__SIMD32(s)++;
|
||||
@ -295,14 +290,14 @@ size_t fir_and_decimate_by_2_complex_fast(
|
||||
shift_count--;
|
||||
}
|
||||
|
||||
shift_count = (taps_count - 1) % unroll_factor;
|
||||
shift_count = (taps_count_ - decimation_factor_) % unroll_factor;
|
||||
while(shift_count > 0) {
|
||||
*(t++) = *(s++);
|
||||
shift_count--;
|
||||
}
|
||||
}
|
||||
|
||||
return src_count / decimation_factor;
|
||||
return { dst.p, src.count / decimation_factor_, src.sampling_rate / decimation_factor_ };
|
||||
}
|
||||
|
||||
buffer_s16_t DecimateBy2CIC4Real::execute(
|
||||
|
@ -78,17 +78,7 @@ private:
|
||||
const std::array<int16_t, taps_count>& taps;
|
||||
};
|
||||
|
||||
size_t fir_and_decimate_by_2_complex_fast(
|
||||
const complex16_t* const src_start,
|
||||
const size_t src_count,
|
||||
complex16_t* const dst_start,
|
||||
complex16_t* const z,
|
||||
const complex16_t* const taps,
|
||||
const size_t taps_count,
|
||||
const size_t decimation_factor
|
||||
);
|
||||
|
||||
class FIRAndDecimateBy2Complex {
|
||||
class FIRAndDecimateComplex {
|
||||
public:
|
||||
using sample_t = complex16_t;
|
||||
using tap_t = complex16_t;
|
||||
@ -98,18 +88,21 @@ public:
|
||||
/* NOTE! Current code makes an assumption that block of samples to be
|
||||
* processed will be a multiple of the taps_count.
|
||||
*/
|
||||
FIRAndDecimateBy2Complex(
|
||||
const size_t taps_count
|
||||
FIRAndDecimateComplex(
|
||||
const size_t taps_count,
|
||||
const size_t decimation_factor
|
||||
) : samples_ { std::make_unique<samples_t>(taps_count) },
|
||||
taps_reversed_ { std::make_unique<taps_t>(taps_count) },
|
||||
taps_count_ { taps_count }
|
||||
taps_count_ { taps_count },
|
||||
decimation_factor_ { decimation_factor }
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
FIRAndDecimateBy2Complex(
|
||||
const T& taps
|
||||
) : FIRAndDecimateBy2Complex(taps.size())
|
||||
FIRAndDecimateComplex(
|
||||
const T& taps,
|
||||
const size_t decimation_factor
|
||||
) : FIRAndDecimateComplex(taps.size(), decimation_factor)
|
||||
{
|
||||
std::reverse_copy(taps.cbegin(), taps.cend(), &taps_reversed_[0]);
|
||||
}
|
||||
@ -117,18 +110,15 @@ public:
|
||||
buffer_c16_t execute(
|
||||
buffer_c16_t src,
|
||||
buffer_c16_t dst
|
||||
) {
|
||||
const auto dst_count = fir_and_decimate_by_2_complex_fast(src.p, src.count, dst.p, &samples_[0], &taps_reversed_[0], taps_count_, decimation_factor);
|
||||
return { dst.p, dst_count, src.sampling_rate / decimation_factor };
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
private:
|
||||
using samples_t = sample_t[];
|
||||
|
||||
const std::unique_ptr<samples_t> samples_;
|
||||
const std::unique_ptr<taps_t> taps_reversed_;
|
||||
const size_t taps_count_;
|
||||
const size_t decimation_factor { 2 };
|
||||
const size_t decimation_factor_;
|
||||
};
|
||||
|
||||
class DecimateBy2CIC4Real {
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
private:
|
||||
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 };
|
||||
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_031_070_tfilter;
|
||||
dsp::decimate::FIRAndDecimateBy2Complex channel_filter { channel_filter_taps.taps };
|
||||
dsp::decimate::FIRAndDecimateComplex channel_filter { channel_filter_taps.taps, 2 };
|
||||
dsp::demodulate::AM demod;
|
||||
IIRBiquadFilter audio_hpf { audio_hpf_config };
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ private:
|
||||
|
||||
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By16 };
|
||||
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_031_070_tfilter;
|
||||
dsp::decimate::FIRAndDecimateBy2Complex channel_filter { channel_filter_taps.taps };
|
||||
dsp::decimate::FIRAndDecimateComplex channel_filter { channel_filter_taps.taps, 2 };
|
||||
|
||||
dsp::matched_filter::MatchedFilter mf { baseband::ais::rrc_taps_128_decim_4_p, 1 };
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
private:
|
||||
ChannelDecimator decimator { ChannelDecimator::DecimationFactor::By32 };
|
||||
const fir_taps_real<64>& channel_filter_taps = taps_64_lp_042_078_tfilter;
|
||||
dsp::decimate::FIRAndDecimateBy2Complex channel_filter { channel_filter_taps.taps };
|
||||
dsp::decimate::FIRAndDecimateComplex channel_filter { channel_filter_taps.taps, 2 };
|
||||
dsp::demodulate::FM demod { 48000, 7500 };
|
||||
|
||||
IIRBiquadFilter audio_hpf { audio_hpf_config };
|
||||
|
Loading…
Reference in New Issue
Block a user