diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-26 10:56:37 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-01-26 10:56:37 +0100 |
commit | e6fb51ebaec9a28dfffe47d0947226d9dd3b1fbf (patch) | |
tree | 18df7eabe464c83a8952552849bde9f6287ec555 | |
parent | ecc9f35493ebdff9e98bf58a47328a8c2e7fac3e (diff) | |
download | dabmod-e6fb51ebaec9a28dfffe47d0947226d9dd3b1fbf.tar.gz dabmod-e6fb51ebaec9a28dfffe47d0947226d9dd3b1fbf.tar.bz2 dabmod-e6fb51ebaec9a28dfffe47d0947226d9dd3b1fbf.zip |
PhaseReference cosmetics
-rw-r--r-- | src/PhaseReference.cpp | 76 | ||||
-rw-r--r-- | src/PhaseReference.h | 36 |
2 files changed, 51 insertions, 61 deletions
diff --git a/src/PhaseReference.cpp b/src/PhaseReference.cpp index c73c6e2..568e15e 100644 --- a/src/PhaseReference.cpp +++ b/src/PhaseReference.cpp @@ -1,6 +1,11 @@ /* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) + + Copyright (C) 2018 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -22,12 +27,9 @@ #include "PhaseReference.h" #include "PcDebug.h" -#include <stdio.h> #include <stdexcept> -#include <complex> -#include <string.h> -typedef std::complex<float> complexf; +using complexf = std::complex<float>; /* ETSI EN 300 401 Table 43 (Clause 14.3.2) * Contains h_{i,k} values @@ -52,8 +54,6 @@ const uint8_t PhaseReference::d_h[4][32] = { * Tables 44 to 47 describe the frequency interleaving done in * FrequencyInterleaver. */ - - PhaseReference::PhaseReference(unsigned int dabmode) : ModInput(), d_dabmode(dabmode) @@ -61,39 +61,33 @@ PhaseReference::PhaseReference(unsigned int dabmode) : PDEBUG("PhaseReference::PhaseReference(%u) @ %p\n", dabmode, this); switch (d_dabmode) { - case 1: - d_carriers = 1536; - d_num = 2048; - break; - case 2: - d_carriers = 384; - d_num = 512; - break; - case 3: - d_carriers = 192; - d_num = 256; - break; - case 4: - d_dabmode = 0; - case 0: - d_carriers = 768; - d_num = 1024; - break; - default: - throw std::runtime_error( - "PhaseReference::PhaseReference DAB mode not valid!"); + case 1: + d_carriers = 1536; + d_num = 2048; + break; + case 2: + d_carriers = 384; + d_num = 512; + break; + case 3: + d_carriers = 192; + d_num = 256; + break; + case 4: + d_dabmode = 0; + case 0: + d_carriers = 768; + d_num = 1024; + break; + default: + throw std::runtime_error( + "PhaseReference::PhaseReference DAB mode not valid!"); } d_dataIn.resize(d_carriers); fillData(); } -PhaseReference::~PhaseReference() -{ - PDEBUG("PhaseReference::~PhaseReference() @ %p\n", this); -} - - complexf convert(uint8_t data) { const complexf value[] = { complexf(1, 0), @@ -107,10 +101,6 @@ complexf convert(uint8_t data) { void PhaseReference::fillData() { - size_t index; - size_t offset; - size_t k; - const int table[][48][2] = { { // Mode 0/4 // Positive part @@ -156,10 +146,14 @@ void PhaseReference::fillData() "PhaseReference::fillData d_dataIn has incorrect size!"); } - for (index = 0, offset = 0; index < d_dataIn.size(); ++offset) { - for (k = 0; k < 32; ++k) { - d_dataIn[index++] = convert(d_h[table[d_dabmode][offset][0]][k] - + table[d_dabmode][offset][1]); + for (size_t index = 0, + offset = 0; + index < d_dataIn.size(); + ++offset) { + for (size_t k = 0; k < 32; ++k) { + d_dataIn[index++] = convert( + d_h[ table[d_dabmode][offset][0] ][k] + + table[d_dabmode][offset][1] ); } } } diff --git a/src/PhaseReference.h b/src/PhaseReference.h index f7a5cdc..6ecdc4e 100644 --- a/src/PhaseReference.h +++ b/src/PhaseReference.h @@ -2,7 +2,7 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyright (C) 2016 + Copyright (C) 2018 Matthias P. Braendli, matthias.braendli@mpb.li http://opendigitalradio.org @@ -32,29 +32,25 @@ #include "ModPlugin.h" -#include <sys/types.h> +#include <cstddef> #include <complex> #include <vector> - class PhaseReference : public ModInput { -public: - PhaseReference(unsigned int dabmode); - virtual ~PhaseReference(); - PhaseReference(const PhaseReference&); - PhaseReference& operator=(const PhaseReference&); - - int process(Buffer* dataOut); - const char* name() { return "PhaseReference"; } - -protected: - unsigned int d_dabmode; - size_t d_carriers; - size_t d_num; - const static unsigned char d_h[4][32]; - std::vector<std::complex<float> > d_dataIn; - - void fillData(); + public: + PhaseReference(unsigned int dabmode); + + int process(Buffer* dataOut) override; + const char* name() override { return "PhaseReference"; } + + protected: + unsigned int d_dabmode; + size_t d_carriers; + size_t d_num; + const static uint8_t d_h[4][32]; + std::vector<std::complex<float> > d_dataIn; + + void fillData(); }; |