aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-08-21 18:56:25 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-09-28 13:36:48 +0200
commit63ae20781af39e9cb6673e910e99e28f86c6adb0 (patch)
treecc4594c0bb887d0d4746c86516b7d7d485fb775b /src
parent571d57c591b23d212934f0bb969c33d15c729982 (diff)
downloaddabmod-63ae20781af39e9cb6673e910e99e28f86c6adb0.tar.gz
dabmod-63ae20781af39e9cb6673e910e99e28f86c6adb0.tar.bz2
dabmod-63ae20781af39e9cb6673e910e99e28f86c6adb0.zip
Normalise the CFR FFT
Diffstat (limited to 'src')
-rw-r--r--src/OfdmGenerator.cpp12
-rw-r--r--src/OfdmGenerator.h6
2 files changed, 13 insertions, 5 deletions
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp
index 41c1c85..8d1a560 100644
--- a/src/OfdmGenerator.cpp
+++ b/src/OfdmGenerator.cpp
@@ -173,6 +173,10 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
myNumClip = 0;
myNumErrorClip = 0;
+ // It is not guaranteed that fftw keeps the FFT input vector intact.
+ // That's why we copy it to the reference.
+ std::vector<complexf> reference;
+
for (size_t i = 0; i < myNbSymbols; ++i) {
myFftIn[0][0] = 0;
myFftIn[0][1] = 0;
@@ -183,7 +187,6 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
memcpy(&myFftIn[myNegDst], &in[myNegSrc],
myNegSize * sizeof(FFT_TYPE));
- std::vector<complexf> reference;
if (myCfr) {
reference.resize(mySpacing);
memcpy(reference.data(), myFftIn, mySpacing * sizeof(FFT_TYPE));
@@ -240,8 +243,13 @@ void OfdmGenerator::cfr_one_iteration(complexf *symbol, const complexf *referenc
const float err_clip_squared = myCfrErrorClip * myCfrErrorClip;
for (size_t i = 0; i < mySpacing; i++) {
+ // FFTW computes an unnormalised trasform, i.e. a FFT-IFFT pair
+ // or vice-versa give back the original vector scaled by a factor
+ // FFT-size. Because we're comparing our constellation point
+ // (calculated with IFFT-clip-FFT) against reference (input to
+ // the IFFT), we need to divide by our FFT size.
const complexf constellation_point =
- reinterpret_cast<complexf*>(myCfrPostFft)[i];
+ reinterpret_cast<complexf*>(myCfrPostFft)[i] / (float)mySpacing;
complexf error = reference[i] - constellation_point;
diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h
index a41d583..ad39f5b 100644
--- a/src/OfdmGenerator.h
+++ b/src/OfdmGenerator.h
@@ -72,9 +72,9 @@ class OfdmGenerator : public ModCodec, public RemoteControllable
fftwf_plan myFftPlan;
fftwf_complex *myFftIn, *myFftOut;
- size_t myNbSymbols;
- size_t myNbCarriers;
- size_t mySpacing;
+ const size_t myNbSymbols;
+ const size_t myNbCarriers;
+ const size_t mySpacing;
unsigned myPosSrc;
unsigned myPosDst;
unsigned myPosSize;