mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 10:05:46 -05:00
FT8 support: removed stats stuff that are never used
This commit is contained in:
parent
494f3bf055
commit
e23db7e65c
68
ft8/fft.cpp
68
ft8/fft.cpp
@ -37,7 +37,7 @@ FFTEngine *FFTEngine::GetInstance()
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
FFTEngine::Plan *FFTEngine::get_plan(int n, const char *why)
|
||||
FFTEngine::Plan *FFTEngine::get_plan(int n)
|
||||
{
|
||||
// cache fftw plans in the parent process,
|
||||
// so they will already be there for fork()ed children.
|
||||
@ -49,7 +49,6 @@ FFTEngine::Plan *FFTEngine::get_plan(int n, const char *why)
|
||||
if (m_plans[i]->n_ == n && m_plans[i]->type_ == M_FFTW_TYPE)
|
||||
{
|
||||
Plan *p = m_plans[i];
|
||||
p->uses_ += 1;
|
||||
m_plansmu.unlock();
|
||||
return p;
|
||||
}
|
||||
@ -67,8 +66,6 @@ FFTEngine::Plan *FFTEngine::get_plan(int n, const char *why)
|
||||
Plan *p = new Plan;
|
||||
|
||||
p->n_ = n;
|
||||
p->uses_ = 1;
|
||||
p->why_ = why;
|
||||
p->r_ = (float *)fftwf_malloc(n * sizeof(float));
|
||||
// assert(p->r_);
|
||||
p->c_ = (fftwf_complex *)fftwf_malloc(((n / 2) + 1) * sizeof(fftwf_complex));
|
||||
@ -118,7 +115,6 @@ std::vector<std::complex<float>> FFTEngine::one_fft(
|
||||
const std::vector<float> &samples,
|
||||
int i0,
|
||||
int block,
|
||||
const char *why,
|
||||
FFTEngine::Plan *p
|
||||
)
|
||||
{
|
||||
@ -128,15 +124,10 @@ std::vector<std::complex<float>> FFTEngine::one_fft(
|
||||
int nsamples = samples.size();
|
||||
int nbins = (block / 2) + 1;
|
||||
|
||||
if (p)
|
||||
{
|
||||
// assert(p->n_ == block);
|
||||
p->uses_ += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = get_plan(block, why);
|
||||
if (!p) {
|
||||
p = get_plan(block);
|
||||
}
|
||||
|
||||
fftwf_plan m_plan = p->fwd_;
|
||||
|
||||
// assert((int)samples.size() - i0 >= block);
|
||||
@ -188,7 +179,7 @@ std::vector<std::complex<float>> FFTEngine::one_fft(
|
||||
// do a full set of FFTs, one per symbol-time.
|
||||
// bins[time][frequency]
|
||||
//
|
||||
FFTEngine::ffts_t FFTEngine::ffts(const std::vector<float> &samples, int i0, int block, const char *why)
|
||||
FFTEngine::ffts_t FFTEngine::ffts(const std::vector<float> &samples, int i0, int block)
|
||||
{
|
||||
// assert(i0 >= 0);
|
||||
// assert(block > 1 && (block % 2) == 0);
|
||||
@ -197,12 +188,12 @@ FFTEngine::ffts_t FFTEngine::ffts(const std::vector<float> &samples, int i0, int
|
||||
int nbins = (block / 2) + 1;
|
||||
int nblocks = (nsamples - i0) / block;
|
||||
ffts_t bins(nblocks);
|
||||
for (int si = 0; si < nblocks; si++)
|
||||
{
|
||||
|
||||
for (int si = 0; si < nblocks; si++) {
|
||||
bins[si].resize(nbins);
|
||||
}
|
||||
|
||||
Plan *p = get_plan(block, why);
|
||||
Plan *p = get_plan(block);
|
||||
fftwf_plan m_plan = p->fwd_;
|
||||
|
||||
// allocate our own b/c using p->m_in and p->m_out isn't thread-safe.
|
||||
@ -254,8 +245,7 @@ FFTEngine::ffts_t FFTEngine::ffts(const std::vector<float> &samples, int i0, int
|
||||
std::vector<std::complex<float>> FFTEngine::one_fft_c(
|
||||
const std::vector<float> &samples,
|
||||
int i0,
|
||||
int block,
|
||||
const char *why
|
||||
int block
|
||||
)
|
||||
{
|
||||
// assert(i0 >= 0);
|
||||
@ -263,7 +253,7 @@ std::vector<std::complex<float>> FFTEngine::one_fft_c(
|
||||
|
||||
int nsamples = samples.size();
|
||||
|
||||
Plan *p = get_plan(block, why);
|
||||
Plan *p = get_plan(block);
|
||||
fftwf_plan m_plan = p->cfwd_;
|
||||
|
||||
fftwf_complex *m_in = (fftwf_complex *)fftwf_malloc(block * sizeof(fftwf_complex));
|
||||
@ -286,8 +276,8 @@ std::vector<std::complex<float>> FFTEngine::one_fft_c(
|
||||
fftwf_execute_dft(m_plan, m_in, m_out);
|
||||
|
||||
std::vector<std::complex<float>> out(block);
|
||||
|
||||
float norm = 1.0 / sqrt(block);
|
||||
|
||||
for (int bi = 0; bi < block; bi++)
|
||||
{
|
||||
float re = m_out[bi][0];
|
||||
@ -306,8 +296,7 @@ std::vector<std::complex<float>> FFTEngine::one_fft_c(
|
||||
std::vector<std::complex<float>> FFTEngine::one_fft_cc(
|
||||
const std::vector<std::complex<float>> &samples,
|
||||
int i0,
|
||||
int block,
|
||||
const char *why
|
||||
int block
|
||||
)
|
||||
{
|
||||
// assert(i0 >= 0);
|
||||
@ -315,7 +304,7 @@ std::vector<std::complex<float>> FFTEngine::one_fft_cc(
|
||||
|
||||
int nsamples = samples.size();
|
||||
|
||||
Plan *p = get_plan(block, why);
|
||||
Plan *p = get_plan(block);
|
||||
fftwf_plan m_plan = p->cfwd_;
|
||||
|
||||
fftwf_complex *m_in = (fftwf_complex *)fftwf_malloc(block * sizeof(fftwf_complex));
|
||||
@ -357,13 +346,12 @@ std::vector<std::complex<float>> FFTEngine::one_fft_cc(
|
||||
}
|
||||
|
||||
std::vector<std::complex<float>> FFTEngine::one_ifft_cc(
|
||||
const std::vector<std::complex<float>> &bins,
|
||||
const char *why
|
||||
const std::vector<std::complex<float>> &bins
|
||||
)
|
||||
{
|
||||
int block = bins.size();
|
||||
|
||||
Plan *p = get_plan(block, why);
|
||||
Plan *p = get_plan(block);
|
||||
fftwf_plan m_plan = p->crev_;
|
||||
|
||||
fftwf_complex *m_in = (fftwf_complex *)fftwf_malloc(block * sizeof(fftwf_complex));
|
||||
@ -397,12 +385,12 @@ std::vector<std::complex<float>> FFTEngine::one_ifft_cc(
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<float> FFTEngine::one_ifft(const std::vector<std::complex<float>> &bins, const char *why)
|
||||
std::vector<float> FFTEngine::one_ifft(const std::vector<std::complex<float>> &bins)
|
||||
{
|
||||
int nbins = bins.size();
|
||||
int block = (nbins - 1) * 2;
|
||||
|
||||
Plan *p = get_plan(block, why);
|
||||
Plan *p = get_plan(block);
|
||||
fftwf_plan m_plan = p->rev_;
|
||||
|
||||
fftwf_complex *m_in = (fftwf_complex *)fftwf_malloc(sizeof(fftwf_complex) * ((p->n_ / 2) + 1));
|
||||
@ -437,11 +425,11 @@ std::vector<float> FFTEngine::one_ifft(const std::vector<std::complex<float>> &b
|
||||
//
|
||||
// the return value is x + iy, where y is the hilbert transform of x.
|
||||
//
|
||||
std::vector<std::complex<float>> FFTEngine::analytic(const std::vector<float> &x, const char *why)
|
||||
std::vector<std::complex<float>> FFTEngine::analytic(const std::vector<float> &x)
|
||||
{
|
||||
ulong n = x.size();
|
||||
|
||||
std::vector<std::complex<float>> y = one_fft_c(x, 0, n, why);
|
||||
std::vector<std::complex<float>> y = one_fft_c(x, 0, n);
|
||||
// assert(y.size() == n);
|
||||
|
||||
// leave y[0] alone.
|
||||
@ -463,7 +451,7 @@ std::vector<std::complex<float>> FFTEngine::analytic(const std::vector<float> &x
|
||||
y[i] = 0;
|
||||
}
|
||||
|
||||
std::vector<std::complex<float>> z = one_ifft_cc(y, why);
|
||||
std::vector<std::complex<float>> z = one_ifft_cc(y);
|
||||
|
||||
return z;
|
||||
}
|
||||
@ -482,7 +470,7 @@ std::vector<std::complex<float>> FFTEngine::analytic(const std::vector<float> &x
|
||||
std::vector<float> FFTEngine::hilbert_shift(const std::vector<float> &x, float hz0, float hz1, int rate)
|
||||
{
|
||||
// y = scipy.signal.hilbert(x)
|
||||
std::vector<std::complex<float>> y = analytic(x, "hilbert_shift");
|
||||
std::vector<std::complex<float>> y = analytic(x);
|
||||
// assert(y.size() == x.size());
|
||||
|
||||
float dt = 1.0 / rate;
|
||||
@ -501,18 +489,4 @@ std::vector<float> FFTEngine::hilbert_shift(const std::vector<float> &x, float h
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FFTEngine::fft_stats()
|
||||
{
|
||||
for (int i = 0; i < m_nplans; i++)
|
||||
{
|
||||
Plan *p = m_plans[i];
|
||||
qDebug("FT8::FFTEngine::fft_stats: %-13s %6d %9d %6.3fn",
|
||||
p->why_,
|
||||
p->n_,
|
||||
p->uses_,
|
||||
0.0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace FT8
|
||||
|
21
ft8/fft.h
21
ft8/fft.h
@ -58,25 +58,21 @@ public:
|
||||
fftwf_complex *cc2_; // n
|
||||
fftwf_plan cfwd_; // forward plan
|
||||
fftwf_plan crev_; // reverse plan
|
||||
|
||||
// how much CPU time spent in FFTs that use this plan.
|
||||
const char *why_;
|
||||
int uses_;
|
||||
}; // Plan
|
||||
|
||||
FFTEngine(FFTEngine& other) = delete;
|
||||
void operator=(const FFTEngine &) = delete;
|
||||
static FFTEngine *GetInstance();
|
||||
|
||||
Plan *get_plan(int n, const char *why);
|
||||
Plan *get_plan(int n);
|
||||
|
||||
std::vector<std::complex<float>> one_fft(const std::vector<float> &samples, int i0, int block, const char *why, Plan *p);
|
||||
std::vector<float> one_ifft(const std::vector<std::complex<float>> &bins, const char *why);
|
||||
std::vector<std::complex<float>> one_fft(const std::vector<float> &samples, int i0, int block, Plan *p);
|
||||
std::vector<float> one_ifft(const std::vector<std::complex<float>> &bins);
|
||||
typedef std::vector<std::vector<std::complex<float>>> ffts_t;
|
||||
ffts_t ffts(const std::vector<float> &samples, int i0, int block, const char *why);
|
||||
std::vector<std::complex<float>> one_fft_c(const std::vector<float> &samples, int i0, int block, const char *why);
|
||||
std::vector<std::complex<float>> one_fft_cc(const std::vector<std::complex<float>> &samples, int i0, int block, const char *why);
|
||||
std::vector<std::complex<float>> one_ifft_cc(const std::vector<std::complex<float>> &bins, const char *why);
|
||||
ffts_t ffts(const std::vector<float> &samples, int i0, int block);
|
||||
std::vector<std::complex<float>> one_fft_c(const std::vector<float> &samples, int i0, int block);
|
||||
std::vector<std::complex<float>> one_fft_cc(const std::vector<std::complex<float>> &samples, int i0, int block);
|
||||
std::vector<std::complex<float>> one_ifft_cc(const std::vector<std::complex<float>> &bins);
|
||||
std::vector<float> hilbert_shift(const std::vector<float> &x, float hz0, float hz1, int rate);
|
||||
|
||||
protected:
|
||||
@ -86,8 +82,7 @@ protected:
|
||||
static FFTEngine *m_instance;
|
||||
|
||||
private:
|
||||
std::vector<std::complex<float>> analytic(const std::vector<float> &x, const char *why);
|
||||
void fft_stats();
|
||||
std::vector<std::complex<float>> analytic(const std::vector<float> &x);
|
||||
QMutex m_plansmu;
|
||||
QMutex m_plansmu2;
|
||||
Plan *m_plans[1000];
|
||||
|
30
ft8/ft8.cpp
30
ft8/ft8.cpp
@ -585,8 +585,7 @@ std::vector<float> FT8::reduce_rate(
|
||||
}
|
||||
|
||||
int alen = a.size();
|
||||
std::vector<std::complex<float>> bins1 = fftEngine_->one_fft(
|
||||
a, 0, alen, "reduce_rate1", 0);
|
||||
std::vector<std::complex<float>> bins1 = fftEngine_->one_fft(a, 0, alen, 0);
|
||||
int nbins1 = bins1.size();
|
||||
float bin_hz = arate / (float)alen;
|
||||
|
||||
@ -636,8 +635,7 @@ std::vector<float> FT8::reduce_rate(
|
||||
}
|
||||
|
||||
// use ifft to reduce the rate.
|
||||
std::vector<float> vvv = fftEngine_->one_ifft(bbins, "reduce_rate2");
|
||||
|
||||
std::vector<float> vvv = fftEngine_->one_ifft(bbins);
|
||||
delta_hz = delta * bin_hz;
|
||||
|
||||
return vvv;
|
||||
@ -646,7 +644,7 @@ std::vector<float> FT8::reduce_rate(
|
||||
void FT8::go(int npasses)
|
||||
{
|
||||
// cache to avoid cost of fftw planner mutex.
|
||||
plan32_ = fftEngine_->get_plan(32, "cache32");
|
||||
plan32_ = fftEngine_->get_plan(32);
|
||||
|
||||
if (0)
|
||||
{
|
||||
@ -838,7 +836,7 @@ void FT8::go(int npasses)
|
||||
// just do this once, re-use for every fractional fft_shift
|
||||
// and down_v7_f() to 200 sps.
|
||||
std::vector<std::complex<float>> bins = fftEngine_->one_fft(
|
||||
samples_, 0, samples_.size(), "go1", 0);
|
||||
samples_, 0, samples_.size(), 0);
|
||||
|
||||
for (int hz_frac_i = 0; hz_frac_i < params.coarse_hz_n; hz_frac_i++)
|
||||
{
|
||||
@ -857,7 +855,7 @@ void FT8::go(int npasses)
|
||||
for (int off_frac_i = 0; off_frac_i < params.coarse_off_n; off_frac_i++)
|
||||
{
|
||||
int off_frac = off_frac_i * (block / params.coarse_off_n);
|
||||
FFTEngine::ffts_t bins = fftEngine_->ffts(samples1, off_frac, block, "go2");
|
||||
FFTEngine::ffts_t bins = fftEngine_->ffts(samples1, off_frac, block);
|
||||
std::vector<Strength> oo = coarse(bins, si0, si1);
|
||||
for (int i = 0; i < (int)oo.size(); i++)
|
||||
{
|
||||
@ -933,7 +931,7 @@ float FT8::one_strength(const std::vector<float> &samples200, float hz, int off)
|
||||
int start = starts[which];
|
||||
for (int si = 0; si < 7; si++)
|
||||
{
|
||||
auto fft = fftEngine_->one_fft(samples200, off + (si + start) * 32, 32, "one_strength", plan32_);
|
||||
auto fft = fftEngine_->one_fft(samples200, off + (si + start) * 32, 32, plan32_);
|
||||
for (int bi = 0; bi < 8; bi++)
|
||||
{
|
||||
float x = std::abs(fft[bin0 + bi]);
|
||||
@ -1010,7 +1008,7 @@ float FT8::one_strength_known(
|
||||
|
||||
for (int si = 0; si < 79; si += params.known_sparse)
|
||||
{
|
||||
auto fft = fftEngine_->one_fft(samples, off + si * block, block, "one_strength_known", 0);
|
||||
auto fft = fftEngine_->one_fft(samples, off + si * block, block, 0);
|
||||
|
||||
if (params.known_strength_how == 7)
|
||||
{
|
||||
@ -1233,7 +1231,7 @@ void FT8::search_both_known(
|
||||
int best_off = 0;
|
||||
float best_strength = 0;
|
||||
|
||||
std::vector<std::complex<float>> bins = fftEngine_->one_fft(samples, 0, samples.size(), "stfk", 0);
|
||||
std::vector<std::complex<float>> bins = fftEngine_->one_fft(samples, 0, samples.size(), 0);
|
||||
|
||||
float hz_start, hz_inc, hz_end;
|
||||
if (params.third_hz_n > 1)
|
||||
@ -1297,7 +1295,7 @@ std::vector<float> FT8::fft_shift(
|
||||
}
|
||||
else
|
||||
{
|
||||
bins = fftEngine_->one_fft(samples, off, len, "fft_shift", 0);
|
||||
bins = fftEngine_->one_fft(samples, off, len, 0);
|
||||
hack_bins_ = bins;
|
||||
hack_size_ = samples.size();
|
||||
hack_off_ = off;
|
||||
@ -1338,7 +1336,7 @@ std::vector<float> FT8::fft_shift_f(
|
||||
bins1[i] = 0;
|
||||
}
|
||||
}
|
||||
std::vector<float> out = fftEngine_->one_ifft(bins1, "fft_shift");
|
||||
std::vector<float> out = fftEngine_->one_ifft(bins1);
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -1366,7 +1364,7 @@ std::vector<float> FT8::shift200(
|
||||
FFTEngine::ffts_t FT8::extract(const std::vector<float> &samples200, float, int off)
|
||||
{
|
||||
|
||||
FFTEngine::ffts_t bins3 = fftEngine_->ffts(samples200, off, 32, "extract");
|
||||
FFTEngine::ffts_t bins3 = fftEngine_->ffts(samples200, off, 32);
|
||||
FFTEngine::ffts_t m79(79);
|
||||
|
||||
for (int si = 0; si < 79; si++)
|
||||
@ -2615,7 +2613,7 @@ std::vector<std::complex<float>> FT8::fbandpass(
|
||||
std::vector<float> FT8::down_v7(const std::vector<float> &samples, float hz)
|
||||
{
|
||||
int len = samples.size();
|
||||
std::vector<std::complex<float>> bins = fftEngine_->one_fft(samples, 0, len, "down_v7a", 0);
|
||||
std::vector<std::complex<float>> bins = fftEngine_->one_fft(samples, 0, len, 0);
|
||||
|
||||
return down_v7_f(bins, len, hz);
|
||||
}
|
||||
@ -2660,7 +2658,7 @@ std::vector<float> FT8::down_v7_f(const std::vector<std::complex<float>> &bins,
|
||||
std::vector<std::complex<float>> bbins(blen / 2 + 1);
|
||||
for (int i = 0; i < (int)bbins.size(); i++)
|
||||
bbins[i] = bins1[i];
|
||||
std::vector<float> out = fftEngine_->one_ifft(bbins, "down_v7b");
|
||||
std::vector<float> out = fftEngine_->one_ifft(bbins);
|
||||
|
||||
return out;
|
||||
}
|
||||
@ -3164,7 +3162,7 @@ void FT8::subtract(
|
||||
float diff1 = (bin0 * bin_hz) - hz1;
|
||||
std::vector<float> moved = fftEngine_->hilbert_shift(nsamples_, diff0, diff1, rate_);
|
||||
|
||||
FFTEngine::ffts_t bins = fftEngine_->ffts(moved, off0, block, "subtract");
|
||||
FFTEngine::ffts_t bins = fftEngine_->ffts(moved, off0, block);
|
||||
|
||||
if (bin0 + 8 > (int)bins[0].size())
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user