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