Skip to content

Commit

Permalink
real fft/ifft optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalsong committed Aug 31, 2024
1 parent 6059531 commit 792a572
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lib/subband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ChannelizerImpl : protected DFTFilterBank
: DFTFilterBank(num_bands, decim_factor, num_taps, false)
, flt_{std::move(filter)}
, fview_{MatView(*flt_, num_taps, num_bands)}
, ifft_{num_bands} {
, fft_{num_bands} {
}

[[nodiscard]] arr_cmplx process(const arr_real& x) {
Expand Down Expand Up @@ -187,14 +187,14 @@ class ChannelizerImpl : protected DFTFilterBank
}
}

//TODO: use fft? pout is real
return ifft_(pout) * nbands_;
//TODO: flip `pout` and remove conj
return conj(fft_(pout));
}

private:
std::shared_ptr<const arr_real> flt_;
MatView fview_;
IfftPlan ifft_;
FftPlanR fft_;
};

//--------------------------------------------------------------------------------------------------------------
Expand All @@ -206,15 +206,14 @@ class ChannelSynthesizerImpl : private DFTFilterBank
: DFTFilterBank(num_bands, decim_factor, num_taps, true)
, flt_{std::move(filter)}
, fview_{MatView(*flt_, num_taps, num_bands)}
, fft_{num_bands} {
//nothing to do
, ifft_{num_bands} {
}

arr_real process(const dsplib::arr_cmplx& x) {
DSPLIB_ASSERT(x.size() == nbands_, "input vector size error");

//TODO: use ifft?
buf_.push(real(fft_(x)));
const auto xx = ifft_(x * nbands_);
buf_.push(xx, true);

// calculate outputs of polyphase filters
// TODO: alternative impl for ntaps > nbands
Expand Down Expand Up @@ -244,7 +243,7 @@ class ChannelSynthesizerImpl : private DFTFilterBank
private:
std::shared_ptr<const arr_real> flt_;
MatView fview_;
FftPlan fft_;
IfftPlanR ifft_;
};

//--------------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 792a572

Please sign in to comment.