summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/BlockPartitioner.h8
-rw-r--r--src/Buffer.h8
-rw-r--r--src/CicEqualizer.h8
-rw-r--r--src/ConvEncoder.cpp8
-rw-r--r--src/ConvEncoder.h19
-rw-r--r--src/DabModulator.cpp18
-rw-r--r--src/DabModulator.h7
-rw-r--r--src/DifferentialModulator.h8
-rw-r--r--src/EtiReader.cpp8
-rw-r--r--src/EtiReader.h6
-rw-r--r--src/FIRFilter.h2
-rw-r--r--src/FicSource.cpp62
-rw-r--r--src/FicSource.h35
-rw-r--r--src/Flowgraph.cpp129
-rw-r--r--src/Flowgraph.h37
-rw-r--r--src/FormatConverter.h6
-rw-r--r--src/FrameMultiplexer.h6
-rw-r--r--src/FrequencyInterleaver.h6
-rw-r--r--src/GainControl.cpp2
-rw-r--r--src/GainControl.h6
-rw-r--r--src/GuardIntervalInserter.h8
-rw-r--r--src/InputMemory.cpp7
-rw-r--r--src/InputMemory.h9
-rw-r--r--src/ModCodec.cpp87
-rw-r--r--src/ModCodec.h52
-rw-r--r--src/ModInput.cpp72
-rw-r--r--src/ModInput.h53
-rw-r--r--src/ModMux.cpp68
-rw-r--r--src/ModMux.h54
-rw-r--r--src/ModOutput.cpp72
-rw-r--r--src/ModOutput.h53
-rw-r--r--src/ModPlugin.cpp50
-rw-r--r--src/ModPlugin.h51
-rw-r--r--src/NullSymbol.cpp19
-rw-r--r--src/NullSymbol.h23
-rw-r--r--src/OfdmGenerator.h6
-rw-r--r--src/OutputFile.cpp9
-rw-r--r--src/OutputFile.h14
-rw-r--r--src/OutputMemory.cpp9
-rw-r--r--src/OutputMemory.h11
-rw-r--r--src/OutputUHD.cpp2
-rw-r--r--src/OutputUHD.h9
-rw-r--r--src/OutputZeroMQ.cpp8
-rw-r--r--src/OutputZeroMQ.h11
-rw-r--r--src/PhaseReference.cpp12
-rw-r--r--src/PhaseReference.h17
-rw-r--r--src/PrbsGenerator.cpp47
-rw-r--r--src/PrbsGenerator.h27
-rw-r--r--src/PuncturingEncoder.cpp56
-rw-r--r--src/PuncturingEncoder.h37
-rw-r--r--src/PuncturingRule.cpp20
-rw-r--r--src/PuncturingRule.h20
-rw-r--r--src/QpskSymbolMapper.h6
-rw-r--r--src/Resampler.h6
-rw-r--r--src/SignalMultiplexer.h8
-rw-r--r--src/SubchannelSource.cpp638
-rw-r--r--src/SubchannelSource.h36
-rw-r--r--src/TII.h6
-rw-r--r--src/TimeInterleaver.h6
59 files changed, 789 insertions, 1299 deletions
diff --git a/src/BlockPartitioner.h b/src/BlockPartitioner.h
index 70f5a76..90cffa3 100644
--- a/src/BlockPartitioner.h
+++ b/src/BlockPartitioner.h
@@ -19,15 +19,15 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef BLOCK_PARTITIONER_H
-#define BLOCK_PARTITIONER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModMux.h"
+#include "ModPlugin.h"
+#include <vector>
#include <sys/types.h>
@@ -54,5 +54,3 @@ protected:
size_t d_outputFramecount;
};
-
-#endif // BLOCK_PARTITIONER_H
diff --git a/src/Buffer.h b/src/Buffer.h
index 4bb157b..c4c73ce 100644
--- a/src/Buffer.h
+++ b/src/Buffer.h
@@ -20,14 +20,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef BUFFER_H
-#define BUFFER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <unistd.h>
+#include <memory>
/* Buffer is a container for a byte array, that is memcpy'ed
* on assignment and by the copy-constructor.
@@ -48,6 +48,8 @@ class Buffer {
void *data;
public:
+ using sptr = std::shared_ptr<Buffer>;
+
Buffer(const Buffer& copy);
Buffer(size_t len = 0, const void *data = NULL);
~Buffer();
@@ -71,5 +73,3 @@ class Buffer {
void *getData() const { return data; }
};
-#endif // BUFFER_H
-
diff --git a/src/CicEqualizer.h b/src/CicEqualizer.h
index f8b6edf..792da02 100644
--- a/src/CicEqualizer.h
+++ b/src/CicEqualizer.h
@@ -19,15 +19,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef CIC_EQUALIZER_H
-#define CIC_EQUALIZER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <vector>
#include <sys/types.h>
@@ -57,6 +56,3 @@ protected:
std::vector<float> myFilter;
};
-
-#endif //CIC_EQUALIZER_H
-
diff --git a/src/ConvEncoder.cpp b/src/ConvEncoder.cpp
index 0aaec7f..74de34f 100644
--- a/src/ConvEncoder.cpp
+++ b/src/ConvEncoder.cpp
@@ -52,14 +52,6 @@ ConvEncoder::ConvEncoder(size_t framesize) :
d_framesize(framesize)
{
PDEBUG("ConvEncoder::ConvEncoder(%zu)\n", framesize);
-
-}
-
-
-ConvEncoder::~ConvEncoder()
-{
- PDEBUG("ConvEncoder::~ConvEncoder()\n");
-
}
diff --git a/src/ConvEncoder.h b/src/ConvEncoder.h
index 7912fde..4360bfd 100644
--- a/src/ConvEncoder.h
+++ b/src/ConvEncoder.h
@@ -19,32 +19,23 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef CONV_ENCODER_H
-#define CONV_ENCODER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-
-#include "ModCodec.h"
-
+#include "ModPlugin.h"
#include <sys/types.h>
-
class ConvEncoder : public ModCodec
{
-private:
- size_t d_framesize;
-
-protected:
-
public:
ConvEncoder(size_t framesize);
- virtual ~ConvEncoder();
int process(Buffer* const dataIn, Buffer* dataOut);
const char* name() { return "ConvEncoder"; }
-};
+private:
+ size_t d_framesize;
+};
-#endif // CONV_ENCODER_H
diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp
index c96a763..f63ecd7 100644
--- a/src/DabModulator.cpp
+++ b/src/DabModulator.cpp
@@ -74,8 +74,8 @@ DabModulator::DabModulator(
myFilterTapsFilename(filterTapsFilename),
myTiiConfig(tiiConfig)
{
- PDEBUG("DabModulator::DabModulator(%u, %u, %u, %u) @ %p\n",
- outputRate, clockRate, dabMode, gainMode, this);
+ PDEBUG("DabModulator::DabModulator(%u, %u, %u, %zu) @ %p\n",
+ outputRate, clockRate, dabMode, (size_t)gainMode, this);
if (myDabMode == 0) {
setMode(2);
@@ -252,11 +252,11 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut)
// Configuring puncturing encoder
auto ficPunc = make_shared<PuncturingEncoder>();
- for (const auto *rule : fic->get_rules()) {
+ for (const auto &rule : fic->get_rules()) {
PDEBUG(" Adding rule:\n");
- PDEBUG(" Length: %zu\n", rule->length());
- PDEBUG(" Pattern: 0x%x\n", rule->pattern());
- ficPunc->append_rule(*rule);
+ PDEBUG(" Length: %zu\n", rule.length());
+ PDEBUG(" Pattern: 0x%x\n", rule.pattern());
+ ficPunc->append_rule(rule);
}
PDEBUG(" Adding tail\n");
ficPunc->append_tail_rule(PuncturingRule(3, 0xcccccc));
@@ -312,9 +312,9 @@ int DabModulator::process(Buffer* const dataIn, Buffer* dataOut)
for (const auto& rule : subchannel->get_rules()) {
PDEBUG(" Adding rule:\n");
- PDEBUG(" Length: %zu\n", rule->length());
- PDEBUG(" Pattern: 0x%x\n", rule->pattern());
- subchPunc->append_rule(*rule);
+ PDEBUG(" Length: %zu\n", rule.length());
+ PDEBUG(" Pattern: 0x%x\n", rule.pattern());
+ subchPunc->append_rule(rule);
}
PDEBUG(" Adding tail\n");
subchPunc->append_tail_rule(PuncturingRule(3, 0xcccccc));
diff --git a/src/DabModulator.h b/src/DabModulator.h
index 41fa42d..77c0457 100644
--- a/src/DabModulator.h
+++ b/src/DabModulator.h
@@ -25,8 +25,7 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef DAB_MODULATOR_H
-#define DAB_MODULATOR_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -36,7 +35,7 @@
#include <string>
#include <memory>
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include "EtiReader.h"
#include "Flowgraph.h"
#include "GainControl.h"
@@ -90,5 +89,3 @@ protected:
size_t myFicSizeIn;
};
-#endif // DAB_MODULATOR_H
-
diff --git a/src/DifferentialModulator.h b/src/DifferentialModulator.h
index 05eeed2..b26ea8b 100644
--- a/src/DifferentialModulator.h
+++ b/src/DifferentialModulator.h
@@ -19,15 +19,15 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _DIFFERENTIAL_MODULATOR_H
-#define _DIFFERENTIAL_MODULATOR_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModMux.h"
+#include "ModPlugin.h"
+#include <vector>
#include <sys/types.h>
@@ -48,5 +48,3 @@ protected:
size_t d_carriers;
};
-
-#endif //_DIFFERENTIAL_MODULATOR_H
diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp
index 1511015..e841f03 100644
--- a/src/EtiReader.cpp
+++ b/src/EtiReader.cpp
@@ -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) 2014, 2015
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -205,7 +205,7 @@ int EtiReader::process(const Buffer* dataIn)
}
PDEBUG("Writting 128 bytes of FIC channel data\n");
Buffer fic = Buffer(128, in);
- myFicSource->process(&fic, NULL);
+ myFicSource->loadFicData(fic);
input_size -= 128;
framesize -= 128;
in += 128;
@@ -215,7 +215,7 @@ int EtiReader::process(const Buffer* dataIn)
}
PDEBUG("Writting 96 bytes of FIC channel data\n");
Buffer fic = Buffer(96, in);
- myFicSource->process(&fic, NULL);
+ myFicSource->loadFicData(fic);
input_size -= 96;
framesize -= 96;
in += 96;
@@ -227,7 +227,7 @@ int EtiReader::process(const Buffer* dataIn)
unsigned size = mySources[i]->framesize();
PDEBUG("Writting %i bytes of subchannel data\n", size);
Buffer subch = Buffer(size, in);
- mySources[i]->process(&subch, NULL);
+ mySources[i]->loadSubchannelData(subch);
input_size -= size;
framesize -= size;
in += size;
diff --git a/src/EtiReader.h b/src/EtiReader.h
index a8399d2..cfc03af 100644
--- a/src/EtiReader.h
+++ b/src/EtiReader.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) 2014, 2015
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -24,8 +24,7 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef ETI_READER_H
-#define ETI_READER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -88,5 +87,4 @@ private:
};
-#endif // ETI_READER_H
diff --git a/src/FIRFilter.h b/src/FIRFilter.h
index ceac4cd..209d79d 100644
--- a/src/FIRFilter.h
+++ b/src/FIRFilter.h
@@ -31,7 +31,7 @@
#include <boost/thread.hpp>
#include "RemoteControl.h"
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include "PcDebug.h"
#include "ThreadsafeQueue.h"
diff --git a/src/FicSource.cpp b/src/FicSource.cpp
index 64bd1a7..85614f6 100644
--- a/src/FicSource.cpp
+++ b/src/FicSource.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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -28,7 +33,7 @@
#include <string.h>
-const std::vector<PuncturingRule*>& FicSource::get_rules()
+const std::vector<PuncturingRule>& FicSource::get_rules()
{
return d_puncturing_rules;
}
@@ -47,67 +52,42 @@ FicSource::FicSource(eti_FC &fc) :
d_buffer.setLength(0);
return;
}
-
+
if (fc.MID == 3) {
d_framesize = 32 * 4;
- d_puncturing_rules.push_back(new PuncturingRule(29 * 16, 0xeeeeeeee));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, 0xeeeeeeec));
+ d_puncturing_rules.emplace_back(29 * 16, 0xeeeeeeee);
+ d_puncturing_rules.emplace_back(3 * 16, 0xeeeeeeec);
} else {
d_framesize = 24 * 4;
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, 0xeeeeeeee));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, 0xeeeeeeec));
+ d_puncturing_rules.emplace_back(21 * 16, 0xeeeeeeee);
+ d_puncturing_rules.emplace_back(3 * 16, 0xeeeeeeec);
}
d_buffer.setLength(d_framesize);
}
-
-FicSource::~FicSource()
-{
- PDEBUG("FicSource::~FicSource()\n");
- for (size_t i = 0; i < d_puncturing_rules.size(); ++i) {
-// PDEBUG(" Deleting rules @ %p\n", d_puncturing_rules[i]);
- delete d_puncturing_rules[i];
- }
-}
-
-
size_t FicSource::getFramesize()
{
return d_framesize;
}
-
-int FicSource::process(Buffer* inputData, Buffer* outputData)
+void FicSource::loadFicData(const Buffer& fic)
{
- PDEBUG("FicSource::process"
- "(inputData: %p, outputData: %p)\n",
- inputData, outputData);
-
- if ((inputData != NULL) && inputData->getLength()) {
- PDEBUG(" Input, storing data\n");
- if (inputData->getLength() != d_framesize) {
- PDEBUG("ERROR: FicSource::process.inputSize != d_framesize\n");
- exit(-1);
- }
- d_buffer = *inputData;
- return inputData->getLength();
- }
- PDEBUG(" Output, retriving data\n");
-
- return read(outputData);
+ d_buffer = fic;
}
-
-int FicSource::read(Buffer* outputData)
+int FicSource::process(Buffer* outputData)
{
- PDEBUG("FicSource::read(outputData: %p, outputSize: %zu)\n",
+ PDEBUG("FicSource::process (outputData: %p, outputSize: %zu)\n",
outputData, outputData->getLength());
if (d_buffer.getLength() != d_framesize) {
- PDEBUG("ERROR: FicSource::read.outputSize != d_framesize\n");
- exit(-1);
+ throw std::runtime_error(
+ "ERROR: FicSource::process.outputSize != d_framesize: " +
+ std::to_string(d_buffer.getLength()) + " != " +
+ std::to_string(d_framesize));
}
*outputData = d_buffer;
-
+
return outputData->getLength();
}
+
diff --git a/src/FicSource.h b/src/FicSource.h
index 307908c..cb1d3a8 100644
--- a/src/FicSource.h
+++ b/src/FicSource.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -19,43 +24,33 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FIC_SOURCE_H
-#define FIC_SOURCE_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-
#include "PuncturingRule.h"
#include "Eti.h"
-#include "ModInput.h"
-
+#include "ModPlugin.h"
#include <vector>
#include <sys/types.h>
-
class FicSource : public ModInput
{
-protected:
- size_t d_framesize;
- Buffer d_buffer;
- std::vector<PuncturingRule*> d_puncturing_rules;
-
public:
FicSource(eti_FC &fc);
- FicSource(const FicSource&);
- FicSource& operator=(const FicSource&);
- virtual ~FicSource();
size_t getFramesize();
- const std::vector<PuncturingRule*>& get_rules();
-
- int process(Buffer* inputData, Buffer* outputData);
+ const std::vector<PuncturingRule>& get_rules();
+
+ void loadFicData(const Buffer& fic);
+ int process(Buffer* outputData);
const char* name() { return "FicSource"; }
- int read(Buffer* outputData);
+private:
+ size_t d_framesize;
+ Buffer d_buffer;
+ std::vector<PuncturingRule> d_puncturing_rules;
};
-
-#endif // FIC_SOURCE_H
diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp
index c199945..0eb1c60 100644
--- a/src/Flowgraph.cpp
+++ b/src/Flowgraph.cpp
@@ -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) 2015
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -27,6 +27,7 @@
#include "Flowgraph.h"
#include "PcDebug.h"
#include <memory>
+#include <algorithm>
#if HAVE_DECL__MM_MALLOC
# include <mm_malloc.h>
@@ -36,17 +37,12 @@
#include <sys/types.h>
#include <stdexcept>
#include <assert.h>
-#if defined(_WIN32) and !defined(__MINGW32__)
-//#include <sys/timeb.h>
-//#include <sys/types.h>
-#else
#include <sys/time.h>
-#endif
using namespace std;
-typedef std::vector<shared_ptr<Node> >::iterator NodeIterator;
-typedef std::vector<shared_ptr<Edge> >::iterator EdgeIterator;
+using NodeIterator = std::vector<shared_ptr<Node> >::iterator;
+using EdgeIterator = std::vector<shared_ptr<Edge> >::iterator;
Node::Node(shared_ptr<ModPlugin> plugin) :
@@ -55,10 +51,8 @@ Node::Node(shared_ptr<ModPlugin> plugin) :
{
PDEBUG("Node::Node(plugin(%s): %p) @ %p\n",
plugin->name(), plugin.get(), this);
-
}
-
Node::~Node()
{
PDEBUG("Node::~Node() @ %p\n", this);
@@ -67,6 +61,55 @@ Node::~Node()
assert(myOutputBuffers.size() == 0);
}
+void Node::addOutputBuffer(Buffer::sptr& buffer)
+{
+ myOutputBuffers.push_back(buffer);
+#if DEBUG
+ std::string fname = string(myPlugin->name()) +
+ "-" + to_string(myDebugFiles.size()) +
+ "-" + to_string((size_t)(void*)myPlugin.get()) +
+ ".dat";
+ FILE* fd = fopen(fname.c_str(), "wb");
+ assert(fd != nullptr);
+ myDebugFiles.push_back(fd);
+#endif
+}
+
+void Node::removeOutputBuffer(Buffer::sptr& buffer)
+{
+ auto it = std::find(
+ myOutputBuffers.begin(),
+ myOutputBuffers.end(),
+ buffer);
+ if (it != myOutputBuffers.end()) {
+#if DEBUG
+ size_t pos = std::distance(myOutputBuffers.begin(),
+ it);
+
+ auto fd_it = std::next(myDebugFiles.begin(), pos);
+
+ fclose(*fd_it);
+ myDebugFiles.erase(fd_it);
+#endif
+ myOutputBuffers.erase(it);
+ }
+}
+
+void Node::addInputBuffer(Buffer::sptr& buffer)
+{
+ myInputBuffers.push_back(buffer);
+}
+
+void Node::removeInputBuffer(Buffer::sptr& buffer)
+{
+ auto it = std::find(
+ myInputBuffers.begin(),
+ myInputBuffers.end(),
+ buffer);
+ if (it != myInputBuffers.end()) {
+ myInputBuffers.erase(it);
+ }
+}
Edge::Edge(shared_ptr<Node>& srcNode, shared_ptr<Node>& dstNode) :
mySrcNode(srcNode),
@@ -78,8 +121,8 @@ Edge::Edge(shared_ptr<Node>& srcNode, shared_ptr<Node>& dstNode) :
this);
myBuffer = make_shared<Buffer>();
- srcNode->myOutputBuffers.push_back(myBuffer);
- dstNode->myInputBuffers.push_back(myBuffer);
+ srcNode->addOutputBuffer(myBuffer);
+ dstNode->addInputBuffer(myBuffer);
}
@@ -87,52 +130,52 @@ Edge::~Edge()
{
PDEBUG("Edge::~Edge() @ %p\n", this);
- std::vector<shared_ptr<Buffer> >::iterator buffer;
- if (myBuffer != NULL) {
- for (buffer = mySrcNode->myOutputBuffers.begin();
- buffer != mySrcNode->myOutputBuffers.end();
- ++buffer) {
- if (*buffer == myBuffer) {
- mySrcNode->myOutputBuffers.erase(buffer);
- break;
- }
- }
-
- for (buffer = myDstNode->myInputBuffers.begin();
- buffer != myDstNode->myInputBuffers.end();
- ++buffer) {
- if (*buffer == myBuffer) {
- myDstNode->myInputBuffers.erase(buffer);
- break;
- }
- }
+ if (myBuffer) {
+ mySrcNode->removeOutputBuffer(myBuffer);
+ myDstNode->removeInputBuffer(myBuffer);
}
}
int Node::process()
{
- PDEBUG("Edge::process()\n");
+ PDEBUG("Node::process()\n");
PDEBUG(" Plugin name: %s (%p)\n", myPlugin->name(), myPlugin.get());
- // the plugin process() still wants vector<Buffer*>
+ // the plugin process() wants vector<Buffer*>
// arguments.
std::vector<Buffer*> inBuffers;
- std::vector<shared_ptr<Buffer> >::iterator buffer;
- for (buffer = myInputBuffers.begin();
- buffer != myInputBuffers.end();
- ++buffer) {
- inBuffers.push_back(buffer->get());
+ for (auto& buffer : myInputBuffers) {
+ assert(buffer.get() != nullptr);
+ inBuffers.push_back(buffer.get());
}
std::vector<Buffer*> outBuffers;
- for (buffer = myOutputBuffers.begin();
- buffer != myOutputBuffers.end();
- ++buffer) {
- outBuffers.push_back(buffer->get());
+ for (auto& buffer : myOutputBuffers) {
+ assert(buffer.get() != nullptr);
+ outBuffers.push_back(buffer.get());
}
- return myPlugin->process(inBuffers, outBuffers);
+ int ret = myPlugin->process(inBuffers, outBuffers);
+#if DEBUG
+ assert(myDebugFiles.size() == myOutputBuffers.size());
+
+ auto buf = myOutputBuffers.begin();
+ auto fd_it = myDebugFiles.begin();
+
+ for (size_t i = 0; i < myDebugFiles.size(); i++) {
+ if (*buf) {
+ Buffer& b = *buf->get();
+ FILE* fd = *fd_it;
+
+ fwrite(b.getData(), b.getLength(), 1, fd);
+ }
+
+ ++buf;
+ ++fd_it;
+ }
+#endif
+ return ret;
}
diff --git a/src/Flowgraph.h b/src/Flowgraph.h
index 9c6c2d8..ebb7314 100644
--- a/src/Flowgraph.h
+++ b/src/Flowgraph.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) 2015
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -24,8 +24,7 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FLOWGRAPH_H
-#define FLOWGRAPH_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -37,28 +36,38 @@
#include <memory>
#include <sys/types.h>
#include <vector>
-
+#include <list>
+#include <cstdio>
class Node
{
public:
Node(std::shared_ptr<ModPlugin> plugin);
~Node();
- Node(const Node&);
- Node& operator=(const Node&);
+ Node(const Node&) = delete;
+ Node& operator=(const Node&) = delete;
std::shared_ptr<ModPlugin> plugin() { return myPlugin; }
- std::vector<std::shared_ptr<Buffer> > myInputBuffers;
- std::vector<std::shared_ptr<Buffer> > myOutputBuffers;
-
int process();
time_t processTime() { return myProcessTime; }
void addProcessTime(time_t processTime) {
myProcessTime += processTime;
}
+ void addOutputBuffer(Buffer::sptr& buffer);
+ void removeOutputBuffer(Buffer::sptr& buffer);
+
+ void addInputBuffer(Buffer::sptr& buffer);
+ void removeInputBuffer(Buffer::sptr& buffer);
+
protected:
+ std::list<Buffer::sptr> myInputBuffers;
+ std::list<Buffer::sptr> myOutputBuffers;
+#if DEBUG
+ std::list<FILE*> myDebugFiles;
+#endif
+
std::shared_ptr<ModPlugin> myPlugin;
time_t myProcessTime;
};
@@ -69,8 +78,8 @@ class Edge
public:
Edge(std::shared_ptr<Node>& src, std::shared_ptr<Node>& dst);
~Edge();
- Edge(const Edge&);
- Edge& operator=(const Edge&);
+ Edge(const Edge&) = delete;
+ Edge& operator=(const Edge&) = delete;
protected:
std::shared_ptr<Node> mySrcNode;
@@ -84,8 +93,8 @@ class Flowgraph
public:
Flowgraph();
virtual ~Flowgraph();
- Flowgraph(const Flowgraph&);
- Flowgraph& operator=(const Flowgraph&);
+ Flowgraph(const Flowgraph&) = delete;
+ Flowgraph& operator=(const Flowgraph&) = delete;
void connect(std::shared_ptr<ModPlugin> input,
std::shared_ptr<ModPlugin> output);
@@ -98,5 +107,3 @@ protected:
};
-#endif // FLOWGRAPH_H
-
diff --git a/src/FormatConverter.h b/src/FormatConverter.h
index 0243685..86ce347 100644
--- a/src/FormatConverter.h
+++ b/src/FormatConverter.h
@@ -26,15 +26,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FORMAT_CONVERTER_H
-#define FORMAT_CONVERTER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "porting.h"
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <complex>
#include <stdint.h>
@@ -49,5 +48,4 @@ class FormatConverter : public ModCodec
const char* name();
};
-#endif // FORMAT_CONVERTER_H
diff --git a/src/FrameMultiplexer.h b/src/FrameMultiplexer.h
index b32a0d7..b1dd971 100644
--- a/src/FrameMultiplexer.h
+++ b/src/FrameMultiplexer.h
@@ -19,15 +19,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FRAME_MULTIPLEXER_H
-#define FRAME_MULTIPLEXER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModMux.h"
+#include "ModPlugin.h"
#include "SubchannelSource.h"
#include <memory>
@@ -52,5 +51,4 @@ protected:
const std::vector<std::shared_ptr<SubchannelSource> >* mySubchannels;
};
-#endif // FRAME_MULTIPLEXER_H
diff --git a/src/FrequencyInterleaver.h b/src/FrequencyInterleaver.h
index 0e4a287..7c0fb22 100644
--- a/src/FrequencyInterleaver.h
+++ b/src/FrequencyInterleaver.h
@@ -19,15 +19,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef FREQUENCY_INTERLEAVER_H
-#define FREQUENCY_INTERLEAVER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <sys/types.h>
@@ -50,4 +49,3 @@ protected:
size_t* d_indexes;
};
-#endif // FREQUENCY_INTERLEAVER_H
diff --git a/src/GainControl.cpp b/src/GainControl.cpp
index ec3e90f..4a05be1 100644
--- a/src/GainControl.cpp
+++ b/src/GainControl.cpp
@@ -58,7 +58,7 @@ GainControl::GainControl(size_t framesize,
m_digGain(digGain),
m_normalise(normalise)
{
- PDEBUG("GainControl::GainControl(%zu, %u) @ %p\n", framesize, mode, this);
+ PDEBUG("GainControl::GainControl(%zu, %zu) @ %p\n", framesize, (size_t)mode, this);
/* register the parameters that can be remote controlled */
RC_ADD_PARAMETER(digital, "Digital Gain");
diff --git a/src/GainControl.h b/src/GainControl.h
index 603875b..a8f8233 100644
--- a/src/GainControl.h
+++ b/src/GainControl.h
@@ -25,14 +25,13 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GAIN_CONTROL_H
-#define GAIN_CONTROL_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include "RemoteControl.h"
#include <sys/types.h>
@@ -87,5 +86,4 @@ class GainControl : public ModCodec, public RemoteControllable
#endif
};
-#endif // GAIN_CONTROL_H
diff --git a/src/GuardIntervalInserter.h b/src/GuardIntervalInserter.h
index ffa8f5e..70a8fcd 100644
--- a/src/GuardIntervalInserter.h
+++ b/src/GuardIntervalInserter.h
@@ -19,16 +19,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUARD_INTERVAL_INSERTER_H
-#define GUARD_INTERVAL_INSERTER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
-
+#include "ModPlugin.h"
#include <sys/types.h>
@@ -53,5 +51,3 @@ protected:
bool myHasNull;
};
-
-#endif // GUARD_INTERVAL_INSERTER_H
diff --git a/src/InputMemory.cpp b/src/InputMemory.cpp
index e27e967..c15c2b8 100644
--- a/src/InputMemory.cpp
+++ b/src/InputMemory.cpp
@@ -48,11 +48,10 @@ void InputMemory::setInput(Buffer* dataIn)
}
-int InputMemory::process(Buffer* dataIn, Buffer* dataOut)
+int InputMemory::process(Buffer* dataOut)
{
- PDEBUG("InputMemory::process"
- "(dataIn: %p, dataOut: %p)\n",
- dataIn, dataOut);
+ PDEBUG("InputMemory::process (dataOut: %p)\n",
+ dataOut);
*dataOut = *myDataIn;
diff --git a/src/InputMemory.h b/src/InputMemory.h
index 6d794a1..e5a6512 100644
--- a/src/InputMemory.h
+++ b/src/InputMemory.h
@@ -19,15 +19,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef INPUT_MEMORY_H
-#define INPUT_MEMORY_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModInput.h"
+#include "ModPlugin.h"
class InputMemory : public ModInput
@@ -35,7 +34,7 @@ class InputMemory : public ModInput
public:
InputMemory(Buffer* dataIn);
virtual ~InputMemory();
- virtual int process(Buffer* dataIn, Buffer* dataOut);
+ virtual int process(Buffer* dataOut);
const char* name() { return "InputMemory"; }
void setInput(Buffer* dataIn);
@@ -44,5 +43,3 @@ protected:
Buffer *myDataIn;
};
-
-#endif // INPUT_MEMORY_H
diff --git a/src/ModCodec.cpp b/src/ModCodec.cpp
deleted file mode 100644
index 9e7cf72..0000000
--- a/src/ModCodec.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ModCodec.h"
-
-#include <assert.h>
-
-
-#ifdef DEBUG
-size_t ModCodec::myCount = 0;
-#endif
-
-
-ModCodec::ModCodec() :
- ModPlugin()
-{
-#ifdef DEBUG
- myOutputFile = NULL;
-#endif
-}
-
-
-ModCodec::~ModCodec()
-{
-#ifdef DEBUG
- if (myOutputFile != NULL) {
- fclose(myOutputFile);
- }
-#endif
-}
-
-
-int ModCodec::process(std::vector<Buffer*> dataIn,
- std::vector<Buffer*> dataOut)
-{
- assert(dataIn.size() <= 1);
- assert(dataOut.size() <= 1);
-
- if (dataIn.size() == 0) {
-#ifdef DEBUG
- int ret = process(NULL, dataOut[0]);
- if (myOutputFile == NULL) {
- char filename[128];
- sprintf(filename, "output.cod.%.2zu.%s", myCount, name());
- myOutputFile = fopen(filename, "w");
- ++myCount;
- }
- fwrite(dataOut[0]->getData(), dataOut[0]->getLength(), 1, myOutputFile);
- return ret;
-#else
- return process(NULL, dataOut[0]);
-#endif
- }
-#ifdef DEBUG
- int ret = process(dataIn[0], dataOut[0]);
- if (ret) {
- if (myOutputFile == NULL) {
- char filename[128];
- sprintf(filename, "output.cod.%.2zu.%s", myCount, name());
- myOutputFile = fopen(filename, "w");
- ++myCount;
- }
- fwrite(dataOut[0]->getData(), dataOut[0]->getLength(), 1, myOutputFile);
- }
- return ret;
-#else
- return process(dataIn[0], dataOut[0]);
-#endif
-}
diff --git a/src/ModCodec.h b/src/ModCodec.h
deleted file mode 100644
index 465af46..0000000
--- a/src/ModCodec.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-
-#include "ModPlugin.h"
-
-#include <sys/types.h>
-#include <vector>
-
-
-class ModCodec : public ModPlugin
-{
-public:
- ModCodec();
- virtual ~ModCodec();
-
- virtual int process(std::vector<Buffer*> dataIn,
- std::vector<Buffer*> dataOut);
- virtual int process(Buffer* const dataIn, Buffer* dataOut) = 0;
-
-protected:
-#ifdef DEBUG
- FILE* myOutputFile;
- static size_t myCount;
-#endif
-};
-
-
diff --git a/src/ModInput.cpp b/src/ModInput.cpp
deleted file mode 100644
index 392b2ae..0000000
--- a/src/ModInput.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ModInput.h"
-
-#include <assert.h>
-
-
-#ifdef DEBUG
-size_t ModInput::myCount = 0;
-#endif
-
-
-ModInput::ModInput() :
- ModPlugin()
-{
-#ifdef DEBUG
- myOutputFile = NULL;
-#endif
-}
-
-
-ModInput::~ModInput()
-{
-#ifdef DEBUG
- if (myOutputFile != NULL) {
- fclose(myOutputFile);
- }
-#endif
-}
-
-
-int ModInput::process(std::vector<Buffer*> dataIn,
- std::vector<Buffer*> dataOut)
-{
- assert(dataIn.size() == 0);
- assert(dataOut.size() == 1);
-
-#ifdef DEBUG
- int ret = process(NULL, dataOut[0]);
- if (myOutputFile == NULL) {
- char filename[256];
- sprintf(filename, "output.in.%.2zu.%s", myCount, name());
- myOutputFile = fopen(filename, "w");
- ++myCount;
- assert(myOutputFile != NULL);
- }
- fprintf(stderr, "Writting %zu bytes @ %p from %s\n", dataOut[0]->getLength(), dataOut[0], name());
- fwrite(dataOut[0]->getData(), dataOut[0]->getLength(), 1, myOutputFile);
- return ret;
-#else
- return process(NULL, dataOut[0]);
-#endif
-}
diff --git a/src/ModInput.h b/src/ModInput.h
deleted file mode 100644
index 2f1619c..0000000
--- a/src/ModInput.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MOD_INPUT_H
-#define MOD_INPUT_H
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-
-#include "ModPlugin.h"
-
-#include <sys/types.h>
-
-
-class ModInput : public ModPlugin
-{
-public:
- ModInput();
- virtual ~ModInput();
-
- virtual int process(std::vector<Buffer*> dataIn,
- std::vector<Buffer*> dataOut);
- virtual int process(Buffer* dataIn, Buffer* dataOut) = 0;
-
-protected:
-#ifdef DEBUG
- FILE* myOutputFile;
- static size_t myCount;
-#endif
-};
-
-
-#endif // MOD_INPUT_H
diff --git a/src/ModMux.cpp b/src/ModMux.cpp
deleted file mode 100644
index 2ab9b43..0000000
--- a/src/ModMux.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ModMux.h"
-
-#include <assert.h>
-
-
-#ifdef DEBUG
-size_t ModMux::myCount = 0;
-#endif
-
-
-ModMux::ModMux() :
- ModPlugin()
-{
-#ifdef DEBUG
- myOutputFile = NULL;
-#endif
-}
-
-
-ModMux::~ModMux()
-{
-#ifdef DEBUG
- if (myOutputFile != NULL) {
- fclose(myOutputFile);
- }
-#endif
-}
-
-
-int ModMux::process(std::vector<Buffer*> dataIn, std::vector<Buffer*> dataOut)
-{
- assert(dataOut.size() == 1);
-
-#ifdef DEBUG
- int ret = process(dataIn, dataOut[0]);
- if (myOutputFile == NULL) {
- char filename[128];
- sprintf(filename, "output.mux.%.2zu.%s", myCount, name());
- myOutputFile = fopen(filename, "w");
- ++myCount;
- }
- fwrite(dataOut[0]->getData(), dataOut[0]->getLength(), 1, myOutputFile);
- return ret;
-#else
- return process(dataIn, dataOut[0]);
-#endif
-}
diff --git a/src/ModMux.h b/src/ModMux.h
deleted file mode 100644
index 45f2ce2..0000000
--- a/src/ModMux.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MOD_MUX_H
-#define MOD_MUX_H
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-
-#include "ModPlugin.h"
-
-#include <sys/types.h>
-#include <vector>
-
-
-class ModMux : public ModPlugin
-{
-public:
- ModMux();
- virtual ~ModMux();
-
- virtual int process(std::vector<Buffer*> dataIn,
- std::vector<Buffer*> dataOut);
- virtual int process(std::vector<Buffer*> dataIn, Buffer* dataOut) = 0;
-
-protected:
-#ifdef DEBUG
- FILE* myOutputFile;
- static size_t myCount;
-#endif
-};
-
-
-#endif // MOD_MUX_H
diff --git a/src/ModOutput.cpp b/src/ModOutput.cpp
deleted file mode 100644
index 12818c7..0000000
--- a/src/ModOutput.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ModOutput.h"
-
-#include <assert.h>
-
-
-#ifdef DEBUG
-size_t ModOutput::myCount = 0;
-#endif
-
-
-ModOutput::ModOutput() :
- ModPlugin()
-{
-#ifdef DEBUG
- myOutputFile = NULL;
-#endif
-}
-
-
-ModOutput::~ModOutput()
-{
-#ifdef DEBUG
- if (myOutputFile != NULL) {
- fclose(myOutputFile);
- }
-#endif
-}
-
-
-int ModOutput::process(std::vector<Buffer*> dataIn,
- std::vector<Buffer*> dataOut)
-{
- assert(dataIn.size() == 1);
- assert(dataOut.size() == 0);
-
-#ifdef DEBUG
- int ret = process(dataIn[0], NULL);
- if (myOutputFile == NULL) {
- char filename[256];
- sprintf(filename, "output.out.%.2zu.%s", myCount, name());
- myOutputFile = fopen(filename, "w");
- ++myCount;
- assert(myOutputFile != NULL);
- }
- fprintf(stderr, "Writting %zu bytes @ %p from %s\n", dataIn[0]->getLength(), dataIn[0], name());
- fwrite(dataIn[0]->getData(), dataIn[0]->getLength(), 1, myOutputFile);
- return ret;
-#else
- return process(dataIn[0], NULL);
-#endif
-}
diff --git a/src/ModOutput.h b/src/ModOutput.h
deleted file mode 100644
index 5e370e8..0000000
--- a/src/ModOutput.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
- the Queen in Right of Canada (Communications Research Center Canada)
- */
-/*
- This file is part of ODR-DabMod.
-
- ODR-DabMod is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as
- published by the Free Software Foundation, either version 3 of the
- License, or (at your option) any later version.
-
- ODR-DabMod is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MOD_OUTPUT_H
-#define MOD_OUTPUT_H
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-
-#include "ModPlugin.h"
-
-#include <sys/types.h>
-
-
-class ModOutput : public ModPlugin
-{
-public:
- ModOutput();
- virtual ~ModOutput();
-
- virtual int process(std::vector<Buffer*> dataIn,
- std::vector<Buffer*> dataOut);
- virtual int process(Buffer* dataIn, Buffer* dataOut) = 0;
-
-protected:
-#ifdef DEBUG
- FILE* myOutputFile;
- static size_t myCount;
-#endif
-};
-
-
-#endif // MOD_OUTPUT_H
diff --git a/src/ModPlugin.cpp b/src/ModPlugin.cpp
index 1f94770..775b284 100644
--- a/src/ModPlugin.cpp
+++ b/src/ModPlugin.cpp
@@ -1,6 +1,11 @@
/*
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
+
+ Copyright (C) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -20,4 +25,49 @@
*/
#include "ModPlugin.h"
+#include "PcDebug.h"
+#include <stdexcept>
+#include <string>
+
+#define MODASSERT(cond) \
+ if (not (cond)) { \
+ throw std::runtime_error("Assertion failure: " #cond " for " + \
+ std::string(name())); \
+ }
+
+int ModInput::process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut)
+{
+ MODASSERT(dataIn.empty());
+ MODASSERT(dataOut.size() == 1);
+ return process(dataOut[0]);
+}
+
+int ModCodec::process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut)
+{
+ MODASSERT(dataIn.size() == 1);
+ MODASSERT(dataOut.size() == 1);
+ return process(dataIn[0], dataOut[0]);
+}
+
+int ModMux::process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut)
+{
+ MODASSERT(not dataIn.empty());
+ MODASSERT(dataOut.size() == 1);
+ return process(dataIn, dataOut[0]);
+}
+
+int ModOutput::process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut)
+{
+ MODASSERT(dataIn.size() == 1);
+ MODASSERT(dataOut.empty());
+ return process(dataIn[0]);
+}
diff --git a/src/ModPlugin.h b/src/ModPlugin.h
index 215951a..bdc3843 100644
--- a/src/ModPlugin.h
+++ b/src/ModPlugin.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -30,16 +35,52 @@
#include <sys/types.h>
#include <vector>
-#ifdef DEBUG
-# include <stdio.h>
-#endif
-
class ModPlugin
{
public:
- virtual int process(std::vector<Buffer*> dataIn,
+ virtual int process(
+ std::vector<Buffer*> dataIn,
std::vector<Buffer*> dataOut) = 0;
virtual const char* name() = 0;
};
+/* Inputs are sources, the output buffers without reading any */
+class ModInput : public ModPlugin
+{
+public:
+ virtual int process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut);
+ virtual int process(Buffer* dataOut) = 0;
+};
+
+/* Codecs are 1-input 1-output flowgraph plugins */
+class ModCodec : public ModPlugin
+{
+public:
+ virtual int process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut);
+ virtual int process(Buffer* const dataIn, Buffer* dataOut) = 0;
+};
+
+/* Muxes are N-input 1-output flowgraph plugins */
+class ModMux : public ModPlugin
+{
+public:
+ virtual int process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut);
+ virtual int process(std::vector<Buffer*> dataIn, Buffer* dataOut) = 0;
+};
+
+/* Outputs do not create any output buffers */
+class ModOutput : public ModPlugin
+{
+public:
+ virtual int process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut);
+ virtual int process(Buffer* dataIn) = 0;
+};
diff --git a/src/NullSymbol.cpp b/src/NullSymbol.cpp
index f2c600e..015e564 100644
--- a/src/NullSymbol.cpp
+++ b/src/NullSymbol.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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -29,31 +34,27 @@
typedef std::complex<float> complexf;
-
NullSymbol::NullSymbol(size_t nbCarriers) :
- ModCodec(),
+ ModInput(),
myNbCarriers(nbCarriers)
{
PDEBUG("NullSymbol::NullSymbol(%zu) @ %p\n", nbCarriers, this);
-
}
NullSymbol::~NullSymbol()
{
PDEBUG("NullSymbol::~NullSymbol() @ %p\n", this);
-
}
-int NullSymbol::process(Buffer* const dataIn, Buffer* dataOut)
+int NullSymbol::process(Buffer* dataOut)
{
- PDEBUG("NullSymbol::process"
- "(dataIn: %p, dataOut: %p)\n",
- dataIn, dataOut);
-
+ PDEBUG("NullSymbol::process(dataOut: %p)\n", dataOut);
+
dataOut->setLength(myNbCarriers * 2 * sizeof(float));
bzero(dataOut->getData(), dataOut->getLength());
return dataOut->getLength();
}
+
diff --git a/src/NullSymbol.h b/src/NullSymbol.h
index e8372f0..8840449 100644
--- a/src/NullSymbol.h
+++ b/src/NullSymbol.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -19,32 +24,30 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NULL_SYMBOL_H
-#define NULL_SYMBOL_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "porting.h"
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <sys/types.h>
#include <stdint.h>
-class NullSymbol : public ModCodec
+class NullSymbol : public ModInput
{
-protected:
- size_t myNbCarriers;
-
public:
NullSymbol(size_t nbCarriers);
virtual ~NullSymbol();
- int process(Buffer* const dataIn, Buffer* dataOut);
+ int process(Buffer* dataOut);
const char* name() { return "NullSymbol"; }
-};
+private:
+ size_t myNbCarriers;
+
+};
-#endif // NULL_SYMBOL_H
diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h
index 061ad91..a8c3c19 100644
--- a/src/OfdmGenerator.h
+++ b/src/OfdmGenerator.h
@@ -24,15 +24,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef OFDM_GENERATOR_H
-#define OFDM_GENERATOR_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "porting.h"
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include "fftw3.h"
@@ -67,5 +66,4 @@ protected:
unsigned myZeroSize;
};
-#endif // OFDM_GENERATOR_H
diff --git a/src/OutputFile.cpp b/src/OutputFile.cpp
index d1a7a4c..23d5523 100644
--- a/src/OutputFile.cpp
+++ b/src/OutputFile.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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -53,9 +58,9 @@ OutputFile::~OutputFile()
}
-int OutputFile::process(Buffer* dataIn, Buffer* dataOut)
+int OutputFile::process(Buffer* dataIn)
{
- PDEBUG("OutputFile::process(%p, %p)\n", dataIn, dataOut);
+ PDEBUG("OutputFile::process(%p)\n", dataIn);
assert(dataIn != NULL);
if (fwrite(dataIn->getData(), dataIn->getLength(), 1, myFile) == 0) {
diff --git a/src/OutputFile.h b/src/OutputFile.h
index 8b37f91..7121ef3 100644
--- a/src/OutputFile.h
+++ b/src/OutputFile.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -19,15 +24,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef OUTPUT_FILE_H
-#define OUTPUT_FILE_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModOutput.h"
+#include "ModPlugin.h"
#include <string>
#include <stdio.h>
@@ -40,7 +44,7 @@ public:
OutputFile(std::string filename);
virtual ~OutputFile();
- virtual int process(Buffer* dataIn, Buffer* dataOut);
+ virtual int process(Buffer* dataIn);
const char* name() { return "OutputFile"; }
protected:
@@ -48,5 +52,3 @@ protected:
FILE* myFile;
};
-
-#endif // OUTPUT_FILE_H
diff --git a/src/OutputMemory.cpp b/src/OutputMemory.cpp
index 6e81cba..6e2fd49 100644
--- a/src/OutputMemory.cpp
+++ b/src/OutputMemory.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2014
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -71,11 +71,10 @@ void OutputMemory::setOutput(Buffer* dataOut)
}
-int OutputMemory::process(Buffer* dataIn, Buffer* dataOut)
+int OutputMemory::process(Buffer* dataIn)
{
- PDEBUG("OutputMemory::process"
- "(dataIn: %p, dataOut: %p)\n",
- dataIn, dataOut);
+ PDEBUG("OutputMemory::process(dataIn: %p)\n",
+ dataIn);
*myDataOut = *dataIn;
diff --git a/src/OutputMemory.h b/src/OutputMemory.h
index 56cbc01..715cb2d 100644
--- a/src/OutputMemory.h
+++ b/src/OutputMemory.h
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2014
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -24,8 +24,7 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef OUTPUT_MEMORY_H
-#define OUTPUT_MEMORY_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -44,7 +43,7 @@
#endif
-#include "ModOutput.h"
+#include "ModPlugin.h"
class OutputMemory : public ModOutput
@@ -52,7 +51,7 @@ class OutputMemory : public ModOutput
public:
OutputMemory(Buffer* dataOut);
virtual ~OutputMemory();
- virtual int process(Buffer* dataIn, Buffer* dataOut);
+ virtual int process(Buffer* dataIn);
const char* name() { return "OutputMemory"; }
void setOutput(Buffer* dataOut);
@@ -68,5 +67,3 @@ protected:
#endif
};
-#endif // OUTPUT_MEMORY_H
-
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index d5caa15..55a24b2 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -304,7 +304,7 @@ void OutputUHD::SetDelayBuffer(unsigned int dabMode)
myDelayBuf.resize(myTFDurationMs * myConf.sampleRate / 1000);
}
-int OutputUHD::process(Buffer* dataIn, Buffer* dataOut)
+int OutputUHD::process(Buffer* dataIn)
{
uwd.muting = myConf.muting;
diff --git a/src/OutputUHD.h b/src/OutputUHD.h
index 8ef4037..9987c79 100644
--- a/src/OutputUHD.h
+++ b/src/OutputUHD.h
@@ -33,8 +33,7 @@ DESCRIPTION:
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef OUTPUT_UHD_H
-#define OUTPUT_UHD_H
+#pragma once
#define FAKE_UHD 0
@@ -54,7 +53,7 @@ DESCRIPTION:
#include <string>
#include "Log.h"
-#include "ModOutput.h"
+#include "ModPlugin.h"
#include "EtiReader.h"
#include "TimestampDecoder.h"
#include "RemoteControl.h"
@@ -222,7 +221,7 @@ class OutputUHD: public ModOutput, public RemoteControllable {
OutputUHD(OutputUHDConfig& config);
~OutputUHD();
- int process(Buffer* dataIn, Buffer* dataOut);
+ int process(Buffer* dataIn);
const char* name() { return "OutputUHD"; }
@@ -287,5 +286,3 @@ class OutputUHD: public ModOutput, public RemoteControllable {
#endif // HAVE_OUTPUT_UHD
-#endif // OUTPUT_UHD_H
-
diff --git a/src/OutputZeroMQ.cpp b/src/OutputZeroMQ.cpp
index 1148a42..93fe3c0 100644
--- a/src/OutputZeroMQ.cpp
+++ b/src/OutputZeroMQ.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2014
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -64,11 +64,11 @@ OutputZeroMQ::~OutputZeroMQ()
PDEBUG("OutputZeroMQ::~OutputZeroMQ() @ %p\n", this);
}
-int OutputZeroMQ::process(Buffer* dataIn, Buffer* dataOut)
+int OutputZeroMQ::process(Buffer* dataIn)
{
PDEBUG("OutputZeroMQ::process"
- "(dataIn: %p, dataOut: %p)\n",
- dataIn, dataOut);
+ "(dataIn: %p)\n",
+ dataIn);
if (m_type == ZMQ_REP) {
// A ZMQ_REP socket requires a request first
diff --git a/src/OutputZeroMQ.h b/src/OutputZeroMQ.h
index 85f85a7..3107225 100644
--- a/src/OutputZeroMQ.h
+++ b/src/OutputZeroMQ.h
@@ -2,7 +2,7 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2014
+ Copyright (C) 2016
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -24,8 +24,7 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef OUTPUT_ZEROMQ_H
-#define OUTPUT_ZEROMQ_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -33,7 +32,7 @@
#if defined(HAVE_ZEROMQ)
-#include "ModOutput.h"
+#include "ModPlugin.h"
#include "zmq.hpp"
class OutputZeroMQ : public ModOutput
@@ -41,7 +40,7 @@ class OutputZeroMQ : public ModOutput
public:
OutputZeroMQ(std::string endpoint, int type, Buffer* dataOut = NULL);
virtual ~OutputZeroMQ();
- virtual int process(Buffer* dataIn, Buffer* dataOut);
+ virtual int process(Buffer* dataIn);
const char* name() { return m_name.c_str(); }
protected:
@@ -57,5 +56,3 @@ class OutputZeroMQ : public ModOutput
#endif // HAVE_ZEROMQ
-#endif // OUTPUT_ZEROMQ_H
-
diff --git a/src/PhaseReference.cpp b/src/PhaseReference.cpp
index 2fbd32d..c73c6e2 100644
--- a/src/PhaseReference.cpp
+++ b/src/PhaseReference.cpp
@@ -55,7 +55,7 @@ const uint8_t PhaseReference::d_h[4][32] = {
PhaseReference::PhaseReference(unsigned int dabmode) :
- ModCodec(),
+ ModInput(),
d_dabmode(dabmode)
{
PDEBUG("PhaseReference::PhaseReference(%u) @ %p\n", dabmode, this);
@@ -165,15 +165,9 @@ void PhaseReference::fillData()
}
-int PhaseReference::process(Buffer* const dataIn, Buffer* dataOut)
+int PhaseReference::process(Buffer* dataOut)
{
- PDEBUG("PhaseReference::process(dataIn: %p, dataOut: %p)\n",
- dataIn, dataOut);
-
- if ((dataIn != NULL) && (dataIn->getLength() != 0)) {
- throw std::runtime_error(
- "PhaseReference::process input size not valid!");
- }
+ PDEBUG("PhaseReference::process(dataOut: %p)\n", dataOut);
dataOut->setData(&d_dataIn[0], d_carriers * sizeof(complexf));
diff --git a/src/PhaseReference.h b/src/PhaseReference.h
index 12ac9c4..f7a5cdc 100644
--- a/src/PhaseReference.h
+++ b/src/PhaseReference.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -19,21 +24,20 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PHASE_REFERENCE_H
-#define PHASE_REFERENCE_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <sys/types.h>
#include <complex>
#include <vector>
-class PhaseReference : public ModCodec
+class PhaseReference : public ModInput
{
public:
PhaseReference(unsigned int dabmode);
@@ -41,8 +45,7 @@ public:
PhaseReference(const PhaseReference&);
PhaseReference& operator=(const PhaseReference&);
-
- int process(Buffer* const dataIn, Buffer* dataOut);
+ int process(Buffer* dataOut);
const char* name() { return "PhaseReference"; }
protected:
@@ -55,5 +58,3 @@ protected:
void fillData();
};
-#endif // PHASE_REFERENCE_H
-
diff --git a/src/PrbsGenerator.cpp b/src/PrbsGenerator.cpp
index baec9b7..69d6af4 100644
--- a/src/PrbsGenerator.cpp
+++ b/src/PrbsGenerator.cpp
@@ -29,7 +29,7 @@
PrbsGenerator::PrbsGenerator(size_t framesize, uint32_t polynomial,
uint32_t accum, size_t init) :
- ModCodec(),
+ ModPlugin(),
d_framesize(framesize),
d_polynomial(polynomial),
d_accum(accum),
@@ -122,17 +122,28 @@ uint32_t PrbsGenerator::update_prbs()
}
-int PrbsGenerator::process(Buffer* const dataIn, Buffer* dataOut)
+int PrbsGenerator::process(
+ std::vector<Buffer*> dataIn,
+ std::vector<Buffer*> dataOut)
{
- PDEBUG("PrbsGenerator::process(dataIn: %p, dataOut: %p)\n",
- dataIn, dataOut);
- dataOut->setLength(d_framesize);
- unsigned char* out = reinterpret_cast<unsigned char*>(dataOut->getData());
-
+ PDEBUG("PrbsGenerator::process(dataIn: %zu, dataOut: %zu)\n",
+ dataIn.size(), dataOut.size());
+ if (dataIn.size() > 1) {
+ throw std::runtime_error("Invalid dataIn size for PrbsGenerator " +
+ std::to_string(dataIn.size()));
+ }
+ if (dataOut.size() != 1) {
+ throw std::runtime_error("Invalid dataOut size for PrbsGenerator " +
+ std::to_string(dataOut.size()));
+ }
+ dataOut[0]->setLength(d_framesize);
+ unsigned char* out = reinterpret_cast<unsigned char*>(dataOut[0]->getData());
+
// Initialization
if (d_accum_init) {
d_accum = d_accum_init;
- } else {
+ }
+ else {
d_accum = 0;
while (d_accum < d_polynomial) {
d_accum <<= 1;
@@ -147,28 +158,30 @@ int PrbsGenerator::process(Buffer* const dataIn, Buffer* dataOut)
}
for (; i < d_framesize; ++i) {
- // Writting data
d_accum = update_prbs();
if ((d_accum_init == 0xa9) && (i % 188 == 0)) { // DVB energy dispersal
out[i] = 0;
- } else {
+ }
+ else {
out[i] = (unsigned char)(d_accum & 0xff);
}
//PDEBUG("accum: 0x%x\n", d_accum);
}
- if ((dataIn != NULL) && dataIn->getLength()) {
+ if (not dataIn.empty()) {
PDEBUG(" mixing input\n");
- const unsigned char* in = reinterpret_cast<const unsigned char*>(dataIn->getData());
- if (dataIn->getLength() != dataOut->getLength()) {
- PDEBUG("%zu != %zu\n", dataIn->getLength(), dataOut->getLength());
+ const unsigned char* in =
+ reinterpret_cast<const unsigned char*>(dataIn[0]->getData());
+
+ if (dataIn[0]->getLength() != dataOut[0]->getLength()) {
+ PDEBUG("%zu != %zu\n", dataIn[0]->getLength(), dataOut[0]->getLength());
throw std::runtime_error("PrbsGenerator::process "
"input size is not equal to output size!\n");
}
- for (size_t i = 0; i < dataOut->getLength(); ++i) {
+ for (size_t i = 0; i < dataOut[0]->getLength(); ++i) {
out[i] ^= in[i];
}
}
-
- return dataOut->getLength();
+
+ return dataOut[0]->getLength();
}
diff --git a/src/PrbsGenerator.h b/src/PrbsGenerator.h
index 0603df7..b86bc70 100644
--- a/src/PrbsGenerator.h
+++ b/src/PrbsGenerator.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -19,30 +24,28 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PRBS_GENERATOR_H
-#define PRBS_GENERATOR_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-
-#include "ModCodec.h"
-
+#include "ModPlugin.h"
#include <sys/types.h>
#include <stdint.h>
-
-class PrbsGenerator : public ModCodec
+/* The PrbsGenerator can work as a ModInput generating a Prbs
+ * sequence from the given parameters only, or as a ModCodec
+ * XORing incoming data with the PRBS
+ */
+class PrbsGenerator : public ModPlugin
{
private:
-
-protected:
uint32_t parity_check(uint32_t prbs_accum);
void gen_prbs_table();
uint32_t update_prbs();
void gen_weight_table();
-
+
size_t d_framesize;
// table of matrix products used to update a 32-bit PRBS generator
uint32_t d_prbs_table [4][256];
@@ -63,9 +66,7 @@ public:
size_t init = 0);
virtual ~PrbsGenerator();
- int process(Buffer* const dataIn, Buffer* dataOut);
+ int process(std::vector<Buffer*> dataIn, std::vector<Buffer*> dataOut);
const char* name() { return "PrbsGenerator"; }
};
-
-#endif // PRBS_GENERATOR_H
diff --git a/src/PuncturingEncoder.cpp b/src/PuncturingEncoder.cpp
index 66fd0e0..a212a93 100644
--- a/src/PuncturingEncoder.cpp
+++ b/src/PuncturingEncoder.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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -32,47 +37,29 @@ PuncturingEncoder::PuncturingEncoder() :
ModCodec(),
d_in_block_size(0),
d_out_block_size(0),
- d_tail_rule(NULL)
+ d_tail_rule()
{
PDEBUG("PuncturingEncoder() @ %p\n", this);
}
-
-PuncturingEncoder::~PuncturingEncoder()
-{
- PDEBUG("PuncturingEncoder::~PuncturingEncoder() @ %p\n", this);
- for (unsigned i = 0; i < d_rules.size(); ++i) {
- PDEBUG(" Deleting rules @ %p\n", d_rules[i]);
- delete d_rules[i];
- }
- if (d_tail_rule != NULL) {
- PDEBUG(" Deleting rules @ %p\n", d_tail_rule);
- delete d_tail_rule;
- }
-}
-
void PuncturingEncoder::adjust_item_size()
{
PDEBUG("PuncturingEncoder::adjust_item_size()\n");
int in_size = 0;
int out_size = 0;
int length = 0;
- std::vector<PuncturingRule*>::iterator ptr;
-
- for (ptr = d_rules.begin(); ptr != d_rules.end(); ++ptr) {
- for (length = (*ptr)->length(); length > 0; length -= 4) {
- out_size += (*ptr)->bit_size();
+
+ for (const auto& rule : d_rules) {
+ for (length = rule.length(); length > 0; length -= 4) {
+ out_size += rule.bit_size();
in_size += 4;
-// PDEBUG("- in: %i, out: %i\n", in_size, out_size);
}
-// PDEBUG("- in: %i, out: %i\n", in_size, (out_size + 7) / 8);
}
- if (d_tail_rule != NULL) {
-// PDEBUG("- computing tail rule\n");
+
+ if (d_tail_rule) {
in_size += d_tail_rule->length();
out_size += d_tail_rule->bit_size();
-// PDEBUG("- in: %i, out: %i\n", in_size, out_size);
}
d_in_block_size = in_size;
@@ -86,7 +73,7 @@ void PuncturingEncoder::adjust_item_size()
void PuncturingEncoder::append_rule(const PuncturingRule& rule)
{
PDEBUG("append_rule(rule(%zu, 0x%x))\n", rule.length(), rule.pattern());
- d_rules.push_back(new PuncturingRule(rule));
+ d_rules.push_back(rule);
adjust_item_size();
}
@@ -95,7 +82,7 @@ void PuncturingEncoder::append_rule(const PuncturingRule& rule)
void PuncturingEncoder::append_tail_rule(const PuncturingRule& rule)
{
PDEBUG("append_tail_rule(rule(%zu, 0x%x))\n", rule.length(), rule.pattern());
- d_tail_rule = new PuncturingRule(rule);
+ d_tail_rule = rule;
adjust_item_size();
}
@@ -113,14 +100,14 @@ int PuncturingEncoder::process(Buffer* const dataIn, Buffer* dataOut)
unsigned char data;
uint32_t mask;
uint32_t pattern;
- std::vector<PuncturingRule*>::iterator ptr = d_rules.begin();
+ auto rule_it = d_rules.begin();
PDEBUG(" in block size: %zu\n", d_in_block_size);
PDEBUG(" out block size: %zu\n", d_out_block_size);
dataOut->setLength(d_out_block_size);
const unsigned char* in = reinterpret_cast<const unsigned char*>(dataIn->getData());
unsigned char* out = reinterpret_cast<unsigned char*>(dataOut->getData());
-
+
if (dataIn->getLength() != d_in_block_size) {
throw std::runtime_error("PuncturingEncoder::process wrong input size");
}
@@ -129,9 +116,9 @@ int PuncturingEncoder::process(Buffer* const dataIn, Buffer* dataOut)
d_in_block_size -= d_tail_rule->length();
}
while (in_count < d_in_block_size) {
- for (length = (*ptr)->length(); length > 0; length -= 4) {
+ for (length = rule_it->length(); length > 0; length -= 4) {
mask = 0x80000000;
- pattern = (*ptr)->pattern();
+ pattern = rule_it->pattern();
for (int i = 0; i < 4; ++i) {
data = in[in_count++];
for (int j = 0; j < 8; ++j) {
@@ -148,8 +135,8 @@ int PuncturingEncoder::process(Buffer* const dataIn, Buffer* dataOut)
}
}
}
- if (++ptr == d_rules.end()) {
- ptr = d_rules.begin();
+ if (++rule_it == d_rules.end()) {
+ rule_it = d_rules.begin();
}
}
if (d_tail_rule) {
@@ -183,11 +170,12 @@ int PuncturingEncoder::process(Buffer* const dataIn, Buffer* dataOut)
for (size_t i = d_out_block_size; i < dataOut->getLength(); ++i) {
out[out_count++] = 0;
}
+
assert(out_count == dataOut->getLength());
if (out_count != dataOut->getLength()) {
throw std::runtime_error("PuncturingEncoder::process output size "
"does not correspond!");
}
-
+
return d_out_block_size;
}
diff --git a/src/PuncturingEncoder.h b/src/PuncturingEncoder.h
index 17dc21f..19be53e 100644
--- a/src/PuncturingEncoder.h
+++ b/src/PuncturingEncoder.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -19,8 +24,7 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PUNCTURING_ENCODER_H
-#define PUNCTURING_ENCODER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -28,36 +32,31 @@
#include "PuncturingRule.h"
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <vector>
#include <sys/types.h>
-
+#include <boost/optional.hpp>
class PuncturingEncoder : public ModCodec
{
-private:
- size_t d_in_block_size;
- size_t d_out_block_size;
- std::vector<PuncturingRule*> d_rules;
- PuncturingRule* d_tail_rule;
-
-protected:
- void adjust_item_size();
-
public:
PuncturingEncoder();
- virtual ~PuncturingEncoder();
- PuncturingEncoder(const PuncturingEncoder&);
- PuncturingEncoder& operator=(const PuncturingEncoder&);
-
+
void append_rule(const PuncturingRule& rule);
void append_tail_rule(const PuncturingRule& rule);
int process(Buffer* const dataIn, Buffer* dataOut);
const char* name() { return "PuncturingEncoder"; }
size_t getInputSize() { return d_in_block_size; }
size_t getOutputSize() { return d_out_block_size; }
-};
+private:
+ size_t d_in_block_size;
+ size_t d_out_block_size;
+ std::vector<PuncturingRule> d_rules;
+ boost::optional<PuncturingRule> d_tail_rule;
+
+ void adjust_item_size();
+
+};
-#endif // PUNCTURING_ENCODER_H
diff --git a/src/PuncturingRule.cpp b/src/PuncturingRule.cpp
index 77668aa..ee5bfa0 100644
--- a/src/PuncturingRule.cpp
+++ b/src/PuncturingRule.cpp
@@ -19,42 +19,24 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef HAVE_CONFIG_H
-//#include "config.h"
-#endif
-
#include "PcDebug.h"
#include "PuncturingRule.h"
#include <stdio.h>
-#include <stdexcept>
-
PuncturingRule::PuncturingRule(
const size_t length,
const uint32_t pattern) :
d_length(length),
d_pattern(pattern)
-{
- PDEBUG("PuncturingRule::PuncturingRule(%zu, 0x%x) @ %p\n",
- length, pattern, this);
-}
-
-
-PuncturingRule::~PuncturingRule()
-{
- PDEBUG("PuncturingRule::~PuncturingRule() @ %p\n", this);
-}
-
+{ }
size_t PuncturingRule::bit_size() const
{
-// fprintf(stderr, "Calling bit_size()");
size_t bits = 0;
for (uint32_t mask = 0x80000000; mask != 0; mask >>= 1) {
if (d_pattern & mask) {
++bits;
}
}
-// fprintf(stderr, " -> return %i\n", bits);
return bits;
}
diff --git a/src/PuncturingRule.h b/src/PuncturingRule.h
index d600b95..c91acf1 100644
--- a/src/PuncturingRule.h
+++ b/src/PuncturingRule.h
@@ -19,38 +19,28 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef PUNCTURING_RULE_H
-#define PUNCTURING_RULE_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-
#include <sys/types.h>
#include <stdint.h>
-
class PuncturingRule
{
-private:
- size_t d_length;
- uint32_t d_pattern;
-
-protected:
-
public:
PuncturingRule(
const size_t length,
const uint32_t pattern);
- virtual ~PuncturingRule();
-// PuncturingRule(const PuncturingRule& rule);
- PuncturingRule& operator=(const PuncturingRule&);
size_t length() const { return d_length; }
size_t bit_size() const;
const uint32_t pattern() const { return d_pattern; }
-};
+private:
+ size_t d_length;
+ uint32_t d_pattern;
+};
-#endif // PUNCTURING_RULE_H
diff --git a/src/QpskSymbolMapper.h b/src/QpskSymbolMapper.h
index ddba719..98f2e60 100644
--- a/src/QpskSymbolMapper.h
+++ b/src/QpskSymbolMapper.h
@@ -19,15 +19,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef QPSK_SYMBOL_MAPPER_H
-#define QPSK_SYMBOL_MAPPER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <sys/types.h>
@@ -48,4 +47,3 @@ protected:
size_t d_carriers;
};
-#endif // QPSK_SYMBOL_MAPPER_H
diff --git a/src/Resampler.h b/src/Resampler.h
index f8388ee..d9d9d89 100644
--- a/src/Resampler.h
+++ b/src/Resampler.h
@@ -24,15 +24,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef RESAMPLER_H
-#define RESAMPLER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "porting.h"
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <sys/types.h>
#include <fftw3.h>
@@ -73,5 +72,4 @@ protected:
float myFactor;
};
-#endif // RESAMPLER_H
diff --git a/src/SignalMultiplexer.h b/src/SignalMultiplexer.h
index 79b9640..5186a8d 100644
--- a/src/SignalMultiplexer.h
+++ b/src/SignalMultiplexer.h
@@ -19,15 +19,15 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SIGNAL_MULTIPLEXER_H
-#define SIGNAL_MULTIPLEXER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModMux.h"
+#include "ModPlugin.h"
+#include <vector>
#include <sys/types.h>
@@ -49,5 +49,3 @@ protected:
size_t d_frameSize;
};
-
-#endif // SIGNAL_MULTIPLEXER_H
diff --git a/src/SubchannelSource.cpp b/src/SubchannelSource.cpp
index 14d6399..f4b6b55 100644
--- a/src/SubchannelSource.cpp
+++ b/src/SubchannelSource.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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -54,7 +59,7 @@
#define P24 0xffffffff
-const std::vector<PuncturingRule*>& SubchannelSource::get_rules()
+const std::vector<PuncturingRule>& SubchannelSource::get_rules()
{
return d_puncturing_rules;
}
@@ -67,42 +72,38 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
d_protection(stc.TPL)
{
PDEBUG("SubchannelSource::SubchannelSource(...) @ %p\n", this);
-// PDEBUG(" Start address: %i\n", d_start_address);
-// PDEBUG(" Framesize: %i\n", d_framesize);
-// PDEBUG(" Protection: %i\n", d_protection);
+ PDEBUG(" Start address: %zu\n", d_start_address);
+ PDEBUG(" Framesize: %zu\n", d_framesize);
+ PDEBUG(" Protection: %zu\n", d_protection);
if (protectionForm()) {
if (protectionOption() == 0) {
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(
- ((6 * bitrate() / 8) - 3) * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(
- 3 * 16, P23));
+ d_puncturing_rules.emplace_back(
+ ((6 * bitrate() / 8) - 3) * 16, P24);
+ d_puncturing_rules.emplace_back(3 * 16, P23);
break;
case 2:
if (bitrate() == 8) {
- d_puncturing_rules.push_back(new PuncturingRule(
- 5 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(
- 1 * 16, P12));
+ d_puncturing_rules.emplace_back(5 * 16, P13);
+ d_puncturing_rules.emplace_back(1 * 16, P12);
} else {
- d_puncturing_rules.push_back(new PuncturingRule(
- ((2 * bitrate() / 8) - 3) * 16, P14));
- d_puncturing_rules.push_back(new PuncturingRule(
- ((4 * bitrate() / 8) + 3) * 16, P13));
+ d_puncturing_rules.emplace_back(
+ ((2 * bitrate() / 8) - 3) * 16, P14);
+ d_puncturing_rules.emplace_back(
+ ((4 * bitrate() / 8) + 3) * 16, P13);
}
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(
- ((6 * bitrate() / 8) - 3) * 16, P8));
- d_puncturing_rules.push_back(new PuncturingRule(
- 3 * 16, P7));
+ d_puncturing_rules.emplace_back(
+ ((6 * bitrate() / 8) - 3) * 16, P8);
+ d_puncturing_rules.emplace_back(3 * 16, P7);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(
- ((4 * bitrate() / 8) - 3) * 16, P3));
- d_puncturing_rules.push_back(new PuncturingRule(
- ((2 * bitrate() / 8) + 3) * 16, P2));
+ d_puncturing_rules.emplace_back(
+ ((4 * bitrate() / 8) - 3) * 16, P3);
+ d_puncturing_rules.emplace_back(
+ ((2 * bitrate() / 8) + 3) * 16, P2);
break;
default:
fprintf(stderr,
@@ -115,28 +116,28 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
} else if (protectionOption() == 1) {
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(
- ((24 * bitrate() / 32) - 3) * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(
- 3 * 16, P9));
+ d_puncturing_rules.emplace_back(
+ ((24 * bitrate() / 32) - 3) * 16, P10);
+ d_puncturing_rules.emplace_back(
+ 3 * 16, P9);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(
- ((24 * bitrate() / 32) - 3) * 16, P6));
- d_puncturing_rules.push_back(new PuncturingRule(
- 3 * 16, P5));
+ d_puncturing_rules.emplace_back(
+ ((24 * bitrate() / 32) - 3) * 16, P6);
+ d_puncturing_rules.emplace_back(
+ 3 * 16, P5);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(
- ((24 * bitrate() / 32) - 3) * 16, P4));
- d_puncturing_rules.push_back(new PuncturingRule(
- 3 * 16, P3));
+ d_puncturing_rules.emplace_back(
+ ((24 * bitrate() / 32) - 3) * 16, P4);
+ d_puncturing_rules.emplace_back(
+ 3 * 16, P3);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(
- ((24 * bitrate() / 32) - 3) * 16, P2));
- d_puncturing_rules.push_back(new PuncturingRule(
- 3 * 16, P1));
+ d_puncturing_rules.emplace_back(
+ ((24 * bitrate() / 32) - 3) * 16, P2);
+ d_puncturing_rules.emplace_back(
+ 3 * 16, P1);
break;
default:
fprintf(stderr,
@@ -160,32 +161,32 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 32:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(5 * 16, P17));
- d_puncturing_rules.push_back(new PuncturingRule(13 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P17));
+ d_puncturing_rules.emplace_back(3 * 16, P24);
+ d_puncturing_rules.emplace_back(5 * 16, P17);
+ d_puncturing_rules.emplace_back(13 * 16, P12);
+ d_puncturing_rules.emplace_back(3 * 16, P17);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P22));
- d_puncturing_rules.push_back(new PuncturingRule(4 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(14 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P13));
+ d_puncturing_rules.emplace_back(3 * 16, P22);
+ d_puncturing_rules.emplace_back(4 * 16, P13);
+ d_puncturing_rules.emplace_back(14 * 16, P8 );
+ d_puncturing_rules.emplace_back(3 * 16, P13);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P15));
- d_puncturing_rules.push_back(new PuncturingRule(4 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(14 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P8 ));
+ d_puncturing_rules.emplace_back(3 * 16, P15);
+ d_puncturing_rules.emplace_back(4 * 16, P9 );
+ d_puncturing_rules.emplace_back(14 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P8 );
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P11));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(18 * 16, P5 ));
+ d_puncturing_rules.emplace_back(3 * 16, P11);
+ d_puncturing_rules.emplace_back(3 * 16, P6 );
+ d_puncturing_rules.emplace_back(18 * 16, P5 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(4 * 16, P3 ));
- d_puncturing_rules.push_back(new PuncturingRule(17 * 16, P2 ));
+ d_puncturing_rules.emplace_back(3 * 16, P5 );
+ d_puncturing_rules.emplace_back(4 * 16, P3 );
+ d_puncturing_rules.emplace_back(17 * 16, P2 );
break;
default:
error = true;
@@ -194,34 +195,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 48:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(5 * 16, P18));
- d_puncturing_rules.push_back(new PuncturingRule(25 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P18));
+ d_puncturing_rules.emplace_back(3 * 16, P24);
+ d_puncturing_rules.emplace_back(5 * 16, P18);
+ d_puncturing_rules.emplace_back(25 * 16, P13);
+ d_puncturing_rules.emplace_back(3 * 16, P18);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(4 * 16, P14));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P15));
+ d_puncturing_rules.emplace_back(3 * 16, P24);
+ d_puncturing_rules.emplace_back(4 * 16, P14);
+ d_puncturing_rules.emplace_back(26 * 16, P8 );
+ d_puncturing_rules.emplace_back(3 * 16, P15);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P15));
- d_puncturing_rules.push_back(new PuncturingRule(4 * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9 ));
+ d_puncturing_rules.emplace_back(3 * 16, P15);
+ d_puncturing_rules.emplace_back(4 * 16, P10);
+ d_puncturing_rules.emplace_back(26 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P9 );
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(4 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P6 ));
+ d_puncturing_rules.emplace_back(3 * 16, P9 );
+ d_puncturing_rules.emplace_back(4 * 16, P6 );
+ d_puncturing_rules.emplace_back(26 * 16, P4 );
+ d_puncturing_rules.emplace_back(3 * 16, P6 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(4 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P3 ));
+ d_puncturing_rules.emplace_back(4 * 16, P5 );
+ d_puncturing_rules.emplace_back(3 * 16, P4 );
+ d_puncturing_rules.emplace_back(26 * 16, P2 );
+ d_puncturing_rules.emplace_back(3 * 16, P3 );
break;
default:
error = true;
@@ -230,28 +231,28 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 56:
switch (protectionLevel()) {
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P23));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(23 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P13));
+ d_puncturing_rules.emplace_back(6 * 16, P23);
+ d_puncturing_rules.emplace_back(10 * 16, P13);
+ d_puncturing_rules.emplace_back(23 * 16, P8 );
+ d_puncturing_rules.emplace_back(3 * 16, P13);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(12 * 16, P7 ));
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9 ));
+ d_puncturing_rules.emplace_back(6 * 16, P16);
+ d_puncturing_rules.emplace_back(12 * 16, P7 );
+ d_puncturing_rules.emplace_back(21 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P9 );
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(23 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P5 ));
+ d_puncturing_rules.emplace_back(6 * 16, P9 );
+ d_puncturing_rules.emplace_back(10 * 16, P6 );
+ d_puncturing_rules.emplace_back(23 * 16, P4 );
+ d_puncturing_rules.emplace_back(3 * 16, P5 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(23 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P3 ));
+ d_puncturing_rules.emplace_back(6 * 16, P5 );
+ d_puncturing_rules.emplace_back(10 * 16, P4 );
+ d_puncturing_rules.emplace_back(23 * 16, P2 );
+ d_puncturing_rules.emplace_back(3 * 16, P3 );
break;
default:
error = true;
@@ -260,33 +261,33 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 64:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P18));
- d_puncturing_rules.push_back(new PuncturingRule(28 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P18));
+ d_puncturing_rules.emplace_back(6 * 16, P24);
+ d_puncturing_rules.emplace_back(11 * 16, P18);
+ d_puncturing_rules.emplace_back(28 * 16, P12);
+ d_puncturing_rules.emplace_back(3 * 16, P18);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P23));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(29 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P13));
+ d_puncturing_rules.emplace_back(6 * 16, P23);
+ d_puncturing_rules.emplace_back(10 * 16, P13);
+ d_puncturing_rules.emplace_back(29 * 16, P8 );
+ d_puncturing_rules.emplace_back(3 * 16, P13);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(12 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(27 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9 ));
+ d_puncturing_rules.emplace_back(6 * 16, P16);
+ d_puncturing_rules.emplace_back(12 * 16, P8 );
+ d_puncturing_rules.emplace_back(27 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P9 );
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P11));
- d_puncturing_rules.push_back(new PuncturingRule(9 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(33 * 16, P5 ));
+ d_puncturing_rules.emplace_back(6 * 16, P11);
+ d_puncturing_rules.emplace_back(9 * 16, P6 );
+ d_puncturing_rules.emplace_back(33 * 16, P5 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(9 * 16, P3 ));
- d_puncturing_rules.push_back(new PuncturingRule(31 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(2 * 16, P3 ));
+ d_puncturing_rules.emplace_back(6 * 16, P5 );
+ d_puncturing_rules.emplace_back(9 * 16, P3 );
+ d_puncturing_rules.emplace_back(31 * 16, P2 );
+ d_puncturing_rules.emplace_back(2 * 16, P3 );
break;
default:
error = true;
@@ -295,34 +296,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 80:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P17));
- d_puncturing_rules.push_back(new PuncturingRule(41 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P18));
+ d_puncturing_rules.emplace_back(6 * 16, P24);
+ d_puncturing_rules.emplace_back(10 * 16, P17);
+ d_puncturing_rules.emplace_back(41 * 16, P12);
+ d_puncturing_rules.emplace_back(3 * 16, P18);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P23));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(41 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P13));
+ d_puncturing_rules.emplace_back(6 * 16, P23);
+ d_puncturing_rules.emplace_back(10 * 16, P13);
+ d_puncturing_rules.emplace_back(41 * 16, P8 );
+ d_puncturing_rules.emplace_back(3 * 16, P13);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(40 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P7 ));
+ d_puncturing_rules.emplace_back(6 * 16, P16);
+ d_puncturing_rules.emplace_back(11 * 16, P8 );
+ d_puncturing_rules.emplace_back(40 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P7 );
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P11));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(41 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P6 ));
+ d_puncturing_rules.emplace_back(6 * 16, P11);
+ d_puncturing_rules.emplace_back(10 * 16, P6 );
+ d_puncturing_rules.emplace_back(41 * 16, P5 );
+ d_puncturing_rules.emplace_back(3 * 16, P6 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P3 ));
- d_puncturing_rules.push_back(new PuncturingRule(41 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P3 ));
+ d_puncturing_rules.emplace_back(6 * 16, P6 );
+ d_puncturing_rules.emplace_back(10 * 16, P3 );
+ d_puncturing_rules.emplace_back(41 * 16, P2 );
+ d_puncturing_rules.emplace_back(3 * 16, P3 );
break;
default:
error = true;
@@ -331,34 +332,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 96:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(13 * 16, P18));
- d_puncturing_rules.push_back(new PuncturingRule(50 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P19));
+ d_puncturing_rules.emplace_back(6 * 16, P24);
+ d_puncturing_rules.emplace_back(13 * 16, P18);
+ d_puncturing_rules.emplace_back(50 * 16, P13);
+ d_puncturing_rules.emplace_back(3 * 16, P19);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P22));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(53 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P12));
+ d_puncturing_rules.emplace_back(6 * 16, P22);
+ d_puncturing_rules.emplace_back(10 * 16, P12);
+ d_puncturing_rules.emplace_back(53 * 16, P9 );
+ d_puncturing_rules.emplace_back(3 * 16, P12);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(6 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(12 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(51 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P10));
+ d_puncturing_rules.emplace_back(6 * 16, P16);
+ d_puncturing_rules.emplace_back(12 * 16, P9 );
+ d_puncturing_rules.emplace_back(51 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P10);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(7 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(10 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(52 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P6 ));
+ d_puncturing_rules.emplace_back(7 * 16, P9 );
+ d_puncturing_rules.emplace_back(10 * 16, P6 );
+ d_puncturing_rules.emplace_back(52 * 16, P4 );
+ d_puncturing_rules.emplace_back(3 * 16, P6 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(7 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(9 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(53 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P4 ));
+ d_puncturing_rules.emplace_back(7 * 16, P5 );
+ d_puncturing_rules.emplace_back(9 * 16, P4 );
+ d_puncturing_rules.emplace_back(53 * 16, P2 );
+ d_puncturing_rules.emplace_back(3 * 16, P4 );
break;
default:
error = true;
@@ -367,28 +368,28 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 112:
switch (protectionLevel()) {
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P23));
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(49 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P14));
+ d_puncturing_rules.emplace_back(11 * 16, P23);
+ d_puncturing_rules.emplace_back(21 * 16, P12);
+ d_puncturing_rules.emplace_back(49 * 16, P9 );
+ d_puncturing_rules.emplace_back(3 * 16, P14);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(23 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(47 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9 ));
+ d_puncturing_rules.emplace_back(11 * 16, P16);
+ d_puncturing_rules.emplace_back(23 * 16, P8 );
+ d_puncturing_rules.emplace_back(47 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P9 );
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(49 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P8 ));
+ d_puncturing_rules.emplace_back(11 * 16, P9 );
+ d_puncturing_rules.emplace_back(21 * 16, P6 );
+ d_puncturing_rules.emplace_back(49 * 16, P4 );
+ d_puncturing_rules.emplace_back(3 * 16, P8 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(14 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(17 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(50 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P5 ));
+ d_puncturing_rules.emplace_back(14 * 16, P5 );
+ d_puncturing_rules.emplace_back(17 * 16, P4 );
+ d_puncturing_rules.emplace_back(50 * 16, P2 );
+ d_puncturing_rules.emplace_back(3 * 16, P5 );
break;
default:
error = true;
@@ -397,34 +398,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 128:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(20 * 16, P17));
- d_puncturing_rules.push_back(new PuncturingRule(62 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P19));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(20 * 16, P17);
+ d_puncturing_rules.emplace_back(62 * 16, P13);
+ d_puncturing_rules.emplace_back(3 * 16, P19);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P22));
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(61 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P14));
+ d_puncturing_rules.emplace_back(11 * 16, P22);
+ d_puncturing_rules.emplace_back(21 * 16, P12);
+ d_puncturing_rules.emplace_back(61 * 16, P9 );
+ d_puncturing_rules.emplace_back(3 * 16, P14);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(22 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(60 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P10));
+ d_puncturing_rules.emplace_back(11 * 16, P16);
+ d_puncturing_rules.emplace_back(22 * 16, P9 );
+ d_puncturing_rules.emplace_back(60 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P10);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P11));
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(61 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P7 ));
+ d_puncturing_rules.emplace_back(11 * 16, P11);
+ d_puncturing_rules.emplace_back(21 * 16, P6 );
+ d_puncturing_rules.emplace_back(61 * 16, P5 );
+ d_puncturing_rules.emplace_back(3 * 16, P7 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(12 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(19 * 16, P3 ));
- d_puncturing_rules.push_back(new PuncturingRule(62 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P4 ));
+ d_puncturing_rules.emplace_back(12 * 16, P5 );
+ d_puncturing_rules.emplace_back(19 * 16, P3 );
+ d_puncturing_rules.emplace_back(62 * 16, P2 );
+ d_puncturing_rules.emplace_back(3 * 16, P4 );
break;
default:
error = true;
@@ -433,34 +434,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 160:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(22 * 16, P18));
- d_puncturing_rules.push_back(new PuncturingRule(84 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P19));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(22 * 16, P18);
+ d_puncturing_rules.emplace_back(84 * 16, P12);
+ d_puncturing_rules.emplace_back(3 * 16, P19);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P22));
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, P11));
- d_puncturing_rules.push_back(new PuncturingRule(85 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P13));
+ d_puncturing_rules.emplace_back(11 * 16, P22);
+ d_puncturing_rules.emplace_back(21 * 16, P11);
+ d_puncturing_rules.emplace_back(85 * 16, P9 );
+ d_puncturing_rules.emplace_back(3 * 16, P13);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(24 * 16, P8 ));
- d_puncturing_rules.push_back(new PuncturingRule(82 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P11));
+ d_puncturing_rules.emplace_back(11 * 16, P16);
+ d_puncturing_rules.emplace_back(24 * 16, P8 );
+ d_puncturing_rules.emplace_back(82 * 16, P6 );
+ d_puncturing_rules.emplace_back(3 * 16, P11);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P11));
- d_puncturing_rules.push_back(new PuncturingRule(23 * 16, P6 ));
- d_puncturing_rules.push_back(new PuncturingRule(83 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9 ));
+ d_puncturing_rules.emplace_back(11 * 16, P11);
+ d_puncturing_rules.emplace_back(23 * 16, P6 );
+ d_puncturing_rules.emplace_back(83 * 16, P5 );
+ d_puncturing_rules.emplace_back(3 * 16, P9 );
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P5 ));
- d_puncturing_rules.push_back(new PuncturingRule(19 * 16, P4 ));
- d_puncturing_rules.push_back(new PuncturingRule(87 * 16, P2 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P4 ));
+ d_puncturing_rules.emplace_back(11 * 16, P5 );
+ d_puncturing_rules.emplace_back(19 * 16, P4 );
+ d_puncturing_rules.emplace_back(87 * 16, P2 );
+ d_puncturing_rules.emplace_back(3 * 16, P4 );
break;
default:
error = true;
@@ -469,34 +470,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 192:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(21 * 16, P20));
- d_puncturing_rules.push_back(new PuncturingRule(109 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P24));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(21 * 16, P20);
+ d_puncturing_rules.emplace_back(109 * 16, P13);
+ d_puncturing_rules.emplace_back(3 * 16, P24);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P22));
- d_puncturing_rules.push_back(new PuncturingRule(20 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(110 * 16, P9));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P13));
+ d_puncturing_rules.emplace_back(11 * 16, P22);
+ d_puncturing_rules.emplace_back(20 * 16, P13);
+ d_puncturing_rules.emplace_back(110 * 16, P9);
+ d_puncturing_rules.emplace_back(3 * 16, P13);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(24 * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(106 * 16, P6));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P11));
+ d_puncturing_rules.emplace_back(11 * 16, P16);
+ d_puncturing_rules.emplace_back(24 * 16, P10);
+ d_puncturing_rules.emplace_back(106 * 16, P6);
+ d_puncturing_rules.emplace_back(3 * 16, P11);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(22 * 16, P6));
- d_puncturing_rules.push_back(new PuncturingRule(108 * 16, P4));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9));
+ d_puncturing_rules.emplace_back(11 * 16, P10);
+ d_puncturing_rules.emplace_back(22 * 16, P6);
+ d_puncturing_rules.emplace_back(108 * 16, P4);
+ d_puncturing_rules.emplace_back(3 * 16, P9);
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P6));
- d_puncturing_rules.push_back(new PuncturingRule(20 * 16, P4));
- d_puncturing_rules.push_back(new PuncturingRule(110 * 16, P2));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P5));
+ d_puncturing_rules.emplace_back(11 * 16, P6);
+ d_puncturing_rules.emplace_back(20 * 16, P4);
+ d_puncturing_rules.emplace_back(110 * 16, P2);
+ d_puncturing_rules.emplace_back(3 * 16, P5);
break;
default:
error = true;
@@ -505,34 +506,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 224:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(24 * 16, P20));
- d_puncturing_rules.push_back(new PuncturingRule(130 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P20));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(24 * 16, P20);
+ d_puncturing_rules.emplace_back(130 * 16, P12);
+ d_puncturing_rules.emplace_back(3 * 16, P20);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(22 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(132 * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P15));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(22 * 16, P16);
+ d_puncturing_rules.emplace_back(132 * 16, P10);
+ d_puncturing_rules.emplace_back(3 * 16, P15);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(20 * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(134 * 16, P7));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P9));
+ d_puncturing_rules.emplace_back(11 * 16, P16);
+ d_puncturing_rules.emplace_back(20 * 16, P10);
+ d_puncturing_rules.emplace_back(134 * 16, P7);
+ d_puncturing_rules.emplace_back(3 * 16, P9);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(12 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P8));
- d_puncturing_rules.push_back(new PuncturingRule(127 * 16, P4));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P11));
+ d_puncturing_rules.emplace_back(12 * 16, P12);
+ d_puncturing_rules.emplace_back(26 * 16, P8);
+ d_puncturing_rules.emplace_back(127 * 16, P4);
+ d_puncturing_rules.emplace_back(3 * 16, P11);
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(12 * 16, P8));
- d_puncturing_rules.push_back(new PuncturingRule(22 * 16, P6));
- d_puncturing_rules.push_back(new PuncturingRule(131 * 16, P2));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P6));
+ d_puncturing_rules.emplace_back(12 * 16, P8);
+ d_puncturing_rules.emplace_back(22 * 16, P6);
+ d_puncturing_rules.emplace_back(131 * 16, P2);
+ d_puncturing_rules.emplace_back(3 * 16, P6);
break;
default:
error = true;
@@ -541,34 +542,34 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 256:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P19));
- d_puncturing_rules.push_back(new PuncturingRule(152 * 16, P14));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P18));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(26 * 16, P19);
+ d_puncturing_rules.emplace_back(152 * 16, P14);
+ d_puncturing_rules.emplace_back(3 * 16, P18);
break;
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(22 * 16, P14));
- d_puncturing_rules.push_back(new PuncturingRule(156 * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P13));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(22 * 16, P14);
+ d_puncturing_rules.emplace_back(156 * 16, P10);
+ d_puncturing_rules.emplace_back(3 * 16, P13);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(27 * 16, P10));
- d_puncturing_rules.push_back(new PuncturingRule(151 * 16, P7));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P10));
+ d_puncturing_rules.emplace_back(11 * 16, P16);
+ d_puncturing_rules.emplace_back(27 * 16, P10);
+ d_puncturing_rules.emplace_back(151 * 16, P7);
+ d_puncturing_rules.emplace_back(3 * 16, P10);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P12));
- d_puncturing_rules.push_back(new PuncturingRule(24 * 16, P9));
- d_puncturing_rules.push_back(new PuncturingRule(154 * 16, P5));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P10));
+ d_puncturing_rules.emplace_back(11 * 16, P12);
+ d_puncturing_rules.emplace_back(24 * 16, P9);
+ d_puncturing_rules.emplace_back(154 * 16, P5);
+ d_puncturing_rules.emplace_back(3 * 16, P10);
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P6));
- d_puncturing_rules.push_back(new PuncturingRule(24 * 16, P5));
- d_puncturing_rules.push_back(new PuncturingRule(154 * 16, P2));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P5));
+ d_puncturing_rules.emplace_back(11 * 16, P6);
+ d_puncturing_rules.emplace_back(24 * 16, P5);
+ d_puncturing_rules.emplace_back(154 * 16, P2);
+ d_puncturing_rules.emplace_back(3 * 16, P5);
break;
default:
error = true;
@@ -577,22 +578,22 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 320:
switch (protectionLevel()) {
case 2:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P17));
- d_puncturing_rules.push_back(new PuncturingRule(200 * 16, P9 ));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P17));
+ d_puncturing_rules.emplace_back(11 * 16, P24);
+ d_puncturing_rules.emplace_back(26 * 16, P17);
+ d_puncturing_rules.emplace_back(200 * 16, P9 );
+ d_puncturing_rules.emplace_back(3 * 16, P17);
break;
case 4:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P13));
- d_puncturing_rules.push_back(new PuncturingRule(25 * 16, P9));
- d_puncturing_rules.push_back(new PuncturingRule(201 * 16, P5));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P10));
+ d_puncturing_rules.emplace_back(11 * 16, P13);
+ d_puncturing_rules.emplace_back(25 * 16, P9);
+ d_puncturing_rules.emplace_back(201 * 16, P5);
+ d_puncturing_rules.emplace_back(3 * 16, P10);
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P8));
- d_puncturing_rules.push_back(new PuncturingRule(26 * 16, P5));
- d_puncturing_rules.push_back(new PuncturingRule(200 * 16, P2));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P6));
+ d_puncturing_rules.emplace_back(11 * 16, P8);
+ d_puncturing_rules.emplace_back(26 * 16, P5);
+ d_puncturing_rules.emplace_back(200 * 16, P2);
+ d_puncturing_rules.emplace_back(3 * 16, P6);
break;
default:
error = true;
@@ -601,22 +602,22 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
case 384:
switch (protectionLevel()) {
case 1:
- d_puncturing_rules.push_back(new PuncturingRule(12 * 16, P24));
- d_puncturing_rules.push_back(new PuncturingRule(28 * 16, P20));
- d_puncturing_rules.push_back(new PuncturingRule(245 * 16, P14));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P23));
+ d_puncturing_rules.emplace_back(12 * 16, P24);
+ d_puncturing_rules.emplace_back(28 * 16, P20);
+ d_puncturing_rules.emplace_back(245 * 16, P14);
+ d_puncturing_rules.emplace_back(3 * 16, P23);
break;
case 3:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P16));
- d_puncturing_rules.push_back(new PuncturingRule(24 * 16, P9));
- d_puncturing_rules.push_back(new PuncturingRule(250 * 16, P7));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P10));
+ d_puncturing_rules.emplace_back(11 * 16, P16);
+ d_puncturing_rules.emplace_back(24 * 16, P9);
+ d_puncturing_rules.emplace_back(250 * 16, P7);
+ d_puncturing_rules.emplace_back(3 * 16, P10);
break;
case 5:
- d_puncturing_rules.push_back(new PuncturingRule(11 * 16, P8));
- d_puncturing_rules.push_back(new PuncturingRule(27 * 16, P6));
- d_puncturing_rules.push_back(new PuncturingRule(247 * 16, P2));
- d_puncturing_rules.push_back(new PuncturingRule(3 * 16, P7));
+ d_puncturing_rules.emplace_back(11 * 16, P8);
+ d_puncturing_rules.emplace_back(27 * 16, P6);
+ d_puncturing_rules.emplace_back(247 * 16, P2);
+ d_puncturing_rules.emplace_back(3 * 16, P7);
break;
default:
error = true;
@@ -634,23 +635,11 @@ SubchannelSource::SubchannelSource(eti_STC &stc) :
}
}
-
-SubchannelSource::~SubchannelSource()
-{
- PDEBUG("SubchannelSource::~SubchannelSource() @ %p\n", this);
- for (unsigned i = 0; i < d_puncturing_rules.size(); ++i) {
-// PDEBUG(" Deleting rules @ %p\n", d_puncturing_rules[i]);
- delete d_puncturing_rules[i];
- }
-}
-
-
size_t SubchannelSource::startAddress()
{
return d_start_address;
}
-
size_t SubchannelSource::framesize()
{
return d_framesize;
@@ -1018,8 +1007,8 @@ size_t SubchannelSource::bitrate()
{
return d_framesize / 3;
}
-
-
+
+
size_t SubchannelSource::protection()
{
return d_protection;
@@ -1049,38 +1038,23 @@ size_t SubchannelSource::protectionOption()
return 0;
}
-
-int SubchannelSource::process(Buffer* inputData, Buffer* outputData)
+void SubchannelSource::loadSubchannelData(const Buffer& data)
{
- PDEBUG("SubchannelSource::process"
- "(inputData: %p, outputData: %p)\n",
- inputData, outputData);
-
- if (inputData != NULL && inputData->getLength()) {
- PDEBUG(" Input, storing data\n");
- if (inputData->getLength() != d_framesize) {
- PDEBUG("ERROR: Subchannel::process.inputSize != d_framesize\n");
- exit(-1);
- }
- d_buffer = *inputData;
- return inputData->getLength();
- }
- PDEBUG(" Output, retriving data\n");
-
- return read(outputData);
+ d_buffer = data;
}
-
-int SubchannelSource::read(Buffer* outputData)
+int SubchannelSource::process(Buffer* outputData)
{
- PDEBUG("SubchannelSource::read(outputData: %p, outputSize: %zu)\n",
+ PDEBUG("SubchannelSource::process(outputData: %p, outputSize: %zu)\n",
outputData, outputData->getLength());
-
+
if (d_buffer.getLength() != d_framesize) {
- PDEBUG("ERROR: Subchannel::read.outputSize != d_framesize\n");
- exit(-1);
+ throw std::runtime_error(
+ "ERROR: Subchannel::process: d_buffer != d_framesize: " +
+ std::to_string(d_buffer.getLength()) + " != " +
+ std::to_string(d_framesize));
}
*outputData = d_buffer;
-
+
return outputData->getLength();
}
diff --git a/src/SubchannelSource.h b/src/SubchannelSource.h
index e1db026..f2f261b 100644
--- a/src/SubchannelSource.h
+++ b/src/SubchannelSource.h
@@ -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) 2016
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -19,8 +24,7 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SUBCHANNEL_SOURCE_H
-#define SUBCHANNEL_SOURCE_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
@@ -29,25 +33,15 @@
#include "PuncturingRule.h"
#include "Eti.h"
-#include "ModInput.h"
+#include "ModPlugin.h"
#include <vector>
class SubchannelSource : public ModInput
{
-protected:
- size_t d_start_address;
- size_t d_framesize;
- size_t d_protection;
- Buffer d_buffer;
- std::vector<PuncturingRule*> d_puncturing_rules;
-
public:
SubchannelSource(eti_STC &stc);
- SubchannelSource(const SubchannelSource&);
- SubchannelSource& operator=(const SubchannelSource&);
- virtual ~SubchannelSource();
size_t startAddress();
size_t framesize();
@@ -57,12 +51,18 @@ public:
size_t protectionForm();
size_t protectionLevel();
size_t protectionOption();
- const std::vector<PuncturingRule*>& get_rules();
-
- int process(Buffer* inputData, Buffer* outputData);
+ const std::vector<PuncturingRule>& get_rules();
+
+ void loadSubchannelData(const Buffer& data);
+ int process(Buffer* outputData);
const char* name() { return "SubchannelSource"; }
- int read(Buffer* outputData);
+
+private:
+ size_t d_start_address;
+ size_t d_framesize;
+ size_t d_protection;
+ Buffer d_buffer;
+ std::vector<PuncturingRule> d_puncturing_rules;
};
-#endif // SUBCHANNEL_SOURCE_H
diff --git a/src/TII.h b/src/TII.h
index 45388ce..b088147 100644
--- a/src/TII.h
+++ b/src/TII.h
@@ -26,14 +26,13 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef TII_H
-#define TII_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include "RemoteControl.h"
#include <boost/thread.hpp>
@@ -107,5 +106,4 @@ class TII : public ModCodec, public RemoteControllable
TII& operator=(const TII&);
};
-#endif // TII_H
diff --git a/src/TimeInterleaver.h b/src/TimeInterleaver.h
index 31ec006..c131d24 100644
--- a/src/TimeInterleaver.h
+++ b/src/TimeInterleaver.h
@@ -19,15 +19,14 @@
along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef TIME_INTERLEAVER_H
-#define TIME_INTERLEAVER_H
+#pragma once
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "ModCodec.h"
+#include "ModPlugin.h"
#include <vector>
#include <deque>
@@ -52,4 +51,3 @@ public:
};
-#endif // TIME_INTERLEAVER_H