summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-05 15:13:19 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-05 15:13:19 +0100
commit05d2210e4336dc98966683b6e725c65e729b7216 (patch)
tree9fa1ced79cc79cacd3b360d3a9beb09effc93257
parentaf8fb6c3210f3c3923cdfe8660687f8a330dd6b2 (diff)
downloaddabmod-05d2210e4336dc98966683b6e725c65e729b7216.tar.gz
dabmod-05d2210e4336dc98966683b6e725c65e729b7216.tar.bz2
dabmod-05d2210e4336dc98966683b6e725c65e729b7216.zip
Review TII phase definition
-rw-r--r--src/TII.cpp38
-rw-r--r--src/TII.h23
2 files changed, 38 insertions, 23 deletions
diff --git a/src/TII.cpp b/src/TII.cpp
index 8ec4c35..09a4920 100644
--- a/src/TII.cpp
+++ b/src/TII.cpp
@@ -153,8 +153,8 @@ TII::TII(unsigned int dabmode, const tii_config_t& tii_config) :
throw TIIError("TII::TII comb not valid!");
}
- m_enabled_carriers.clear();
- m_enabled_carriers.resize(m_carriers);
+ m_Acp.clear();
+ m_Acp.resize(m_carriers);
prepare_pattern();
}
@@ -199,11 +199,27 @@ int TII::process(Buffer* dataIn, Buffer* dataOut)
* This is because we only enable 32 out of 1536 carriers, not because
* every carrier is lower power.
*/
- for (size_t i = 0; i < m_enabled_carriers.size(); i++) {
- // See header file for an explanation of the old variant
- if (m_enabled_carriers[i]) {
- out[i] = (m_conf.old_variant ? in[i+1] : in[i]);
- out[i+1] = in[i+1];
+ for (size_t i = 0; i < m_Acp.size(); i++) {
+ /* See header file for an explanation of the old variant.
+ *
+ * A_{c,p}(k) and A_{c,p}(k-1) are never both simultaneously true,
+ * so instead of doing the sum inside z_{m,0,k}, we could do
+ *
+ * if (m_Acp[i]) out[i] = in[i];
+ * if (m_Acp[i-1]) out[i] = in[i-1]
+ *
+ * (Considering only the new variant)
+ *
+ * To avoid messing with indices, we substitute j = i-1
+ *
+ * if (m_Acp[i]) out[i] = in[i];
+ * if (m_Acp[j]) out[j+1] = in[j]
+ *
+ * and fuse the two conditionals together:
+ */
+ if (m_Acp[i]) {
+ out[i] = in[i];
+ out[i+1] = (m_conf.old_variant ? in[i+1] : in[i]);
}
}
}
@@ -217,11 +233,11 @@ int TII::process(Buffer* dataIn, Buffer* dataOut)
void TII::enable_carrier(int k) {
int ix = m_carriers/2 + k;
- if (ix < 0 or ix+1 >= (ssize_t)m_enabled_carriers.size()) {
+ if (ix < 0 or ix+1 >= (ssize_t)m_Acp.size()) {
throw TIIError("TII::enable_carrier invalid k!");
}
- m_enabled_carriers[ix] = true;
+ m_Acp[ix] = true;
}
void TII::prepare_pattern() {
@@ -230,8 +246,8 @@ void TII::prepare_pattern() {
std::lock_guard<std::mutex> lock(m_enabled_carriers_mutex);
// Clear previous pattern
- for (size_t i = 0; i < m_enabled_carriers.size(); i++) {
- m_enabled_carriers[i] = false;
+ for (size_t i = 0; i < m_Acp.size(); i++) {
+ m_Acp[i] = false;
}
// This could be written more efficiently, but since it is
diff --git a/src/TII.h b/src/TII.h
index 9a34288..2ad4004 100644
--- a/src/TII.h
+++ b/src/TII.h
@@ -43,11 +43,9 @@
struct tii_config_t
{
- tii_config_t() : enable(false), comb(0), pattern(0), old_variant(false) {}
-
- bool enable;
- int comb;
- int pattern;
+ bool enable = false;
+ int comb = 0;
+ int pattern = 0;
/* EN 300 401 clause 14.8 describes how to generate the TII signal, and
* defines z_{m,0,k}:
@@ -69,7 +67,7 @@ struct tii_config_t
* The option 'old_variant' allows the user to choose between this
* old incorrect implementation and the new conforming one.
*/
- bool old_variant;
+ bool old_variant = false;
};
class TIIError : public std::runtime_error {
@@ -96,11 +94,11 @@ class TII : public ModCodec, public RemoteControllable
const std::string& parameter) const;
protected:
- // Fill m_enabled_carriers with the correct carriers for the pattern/comb
+ // Fill m_Acp with the correct carriers for the pattern/comb
// combination
void prepare_pattern(void);
- // prerequisites: calling thread must hold m_enabled_carriers mutex
+ // prerequisites: calling thread must hold m_Acp mutex
void enable_carrier(int k);
// Configuration settings
@@ -116,12 +114,13 @@ class TII : public ModCodec, public RemoteControllable
std::string m_name;
- // m_enabled_carriers is read by modulator thread, and written
+ // m_Acp is read by modulator thread, and written
// to by RC thread.
mutable std::mutex m_enabled_carriers_mutex;
- // m_enabled_carriers is true only for the first carrier in the
- // active pair
- std::vector<bool> m_enabled_carriers;
+ // m_Acp corresponds to the A_{c,p}(k) function from the spec, except
+ // that the leftmost carrier is at index 0, and not at -m_carriers/2 like
+ // in the spec.
+ std::vector<bool> m_Acp;
};