From 2bba7d602744ccd6dab26940661f0fdfbf231af8 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 25 Dec 2016 21:34:03 +0100 Subject: Refactor flowgraph and puncturing rules --- src/BlockPartitioner.h | 8 +- src/Buffer.h | 8 +- src/CicEqualizer.h | 8 +- src/ConvEncoder.cpp | 8 - src/ConvEncoder.h | 19 +- src/DabModulator.cpp | 18 +- src/DabModulator.h | 7 +- src/DifferentialModulator.h | 8 +- src/EtiReader.cpp | 8 +- src/EtiReader.h | 6 +- src/FIRFilter.h | 2 +- src/FicSource.cpp | 62 ++--- src/FicSource.h | 35 ++- src/Flowgraph.cpp | 129 ++++++--- src/Flowgraph.h | 37 +-- src/FormatConverter.h | 6 +- src/FrameMultiplexer.h | 6 +- src/FrequencyInterleaver.h | 6 +- src/GainControl.cpp | 2 +- src/GainControl.h | 6 +- src/GuardIntervalInserter.h | 8 +- src/InputMemory.cpp | 7 +- src/InputMemory.h | 9 +- src/ModCodec.cpp | 87 ------ src/ModCodec.h | 52 ---- src/ModInput.cpp | 72 ----- src/ModInput.h | 53 ---- src/ModMux.cpp | 68 ----- src/ModMux.h | 54 ---- src/ModOutput.cpp | 72 ----- src/ModOutput.h | 53 ---- src/ModPlugin.cpp | 50 ++++ src/ModPlugin.h | 51 +++- src/NullSymbol.cpp | 19 +- src/NullSymbol.h | 23 +- src/OfdmGenerator.h | 6 +- src/OutputFile.cpp | 9 +- src/OutputFile.h | 14 +- src/OutputMemory.cpp | 9 +- src/OutputMemory.h | 11 +- src/OutputUHD.cpp | 2 +- src/OutputUHD.h | 9 +- src/OutputZeroMQ.cpp | 8 +- src/OutputZeroMQ.h | 11 +- src/PhaseReference.cpp | 12 +- src/PhaseReference.h | 17 +- src/PrbsGenerator.cpp | 47 ++-- src/PrbsGenerator.h | 27 +- src/PuncturingEncoder.cpp | 56 ++-- src/PuncturingEncoder.h | 37 ++- src/PuncturingRule.cpp | 20 +- src/PuncturingRule.h | 20 +- src/QpskSymbolMapper.h | 6 +- src/Resampler.h | 6 +- src/SignalMultiplexer.h | 8 +- src/SubchannelSource.cpp | 638 +++++++++++++++++++++----------------------- src/SubchannelSource.h | 36 +-- src/TII.h | 6 +- src/TimeInterleaver.h | 6 +- 59 files changed, 789 insertions(+), 1299 deletions(-) delete mode 100644 src/ModCodec.cpp delete mode 100644 src/ModCodec.h delete mode 100644 src/ModInput.cpp delete mode 100644 src/ModInput.h delete mode 100644 src/ModMux.cpp delete mode 100644 src/ModMux.h delete mode 100644 src/ModOutput.cpp delete mode 100644 src/ModOutput.h (limited to 'src') 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 . */ -#ifndef BLOCK_PARTITIONER_H -#define BLOCK_PARTITIONER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModMux.h" +#include "ModPlugin.h" +#include #include @@ -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 . */ -#ifndef BUFFER_H -#define BUFFER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif #include +#include /* 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(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 . */ -#ifndef CIC_EQUALIZER_H -#define CIC_EQUALIZER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" +#include "ModPlugin.h" #include #include @@ -57,6 +56,3 @@ protected: std::vector 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 . */ -#ifndef CONV_ENCODER_H -#define CONV_ENCODER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif - -#include "ModCodec.h" - +#include "ModPlugin.h" #include - 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(); - 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 . */ -#ifndef DAB_MODULATOR_H -#define DAB_MODULATOR_H +#pragma once #ifdef HAVE_CONFIG_H # include "config.h" @@ -36,7 +35,7 @@ #include #include -#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 . */ -#ifndef _DIFFERENTIAL_MODULATOR_H -#define _DIFFERENTIAL_MODULATOR_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModMux.h" +#include "ModPlugin.h" +#include #include @@ -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 . */ -#ifndef ETI_READER_H -#define ETI_READER_H +#pragma once #ifdef HAVE_CONFIG_H # include @@ -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 #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 -const std::vector& FicSource::get_rules() +const std::vector& 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 . */ -#ifndef FIC_SOURCE_H -#define FIC_SOURCE_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif - #include "PuncturingRule.h" #include "Eti.h" -#include "ModInput.h" - +#include "ModPlugin.h" #include #include - class FicSource : public ModInput { -protected: - size_t d_framesize; - Buffer d_buffer; - std::vector d_puncturing_rules; - public: FicSource(eti_FC &fc); - FicSource(const FicSource&); - FicSource& operator=(const FicSource&); - virtual ~FicSource(); size_t getFramesize(); - const std::vector& get_rules(); - - int process(Buffer* inputData, Buffer* outputData); + const std::vector& 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 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 +#include #if HAVE_DECL__MM_MALLOC # include @@ -36,17 +37,12 @@ #include #include #include -#if defined(_WIN32) and !defined(__MINGW32__) -//#include -//#include -#else #include -#endif using namespace std; -typedef std::vector >::iterator NodeIterator; -typedef std::vector >::iterator EdgeIterator; +using NodeIterator = std::vector >::iterator; +using EdgeIterator = std::vector >::iterator; Node::Node(shared_ptr plugin) : @@ -55,10 +51,8 @@ Node::Node(shared_ptr 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& srcNode, shared_ptr& dstNode) : mySrcNode(srcNode), @@ -78,8 +121,8 @@ Edge::Edge(shared_ptr& srcNode, shared_ptr& dstNode) : this); myBuffer = make_shared(); - 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 >::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 + // the plugin process() wants vector // arguments. std::vector inBuffers; - std::vector >::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 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 . */ -#ifndef FLOWGRAPH_H -#define FLOWGRAPH_H +#pragma once #ifdef HAVE_CONFIG_H # include @@ -37,28 +36,38 @@ #include #include #include - +#include +#include class Node { public: Node(std::shared_ptr plugin); ~Node(); - Node(const Node&); - Node& operator=(const Node&); + Node(const Node&) = delete; + Node& operator=(const Node&) = delete; std::shared_ptr plugin() { return myPlugin; } - std::vector > myInputBuffers; - std::vector > 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 myInputBuffers; + std::list myOutputBuffers; +#if DEBUG + std::list myDebugFiles; +#endif + std::shared_ptr myPlugin; time_t myProcessTime; }; @@ -69,8 +78,8 @@ class Edge public: Edge(std::shared_ptr& src, std::shared_ptr& dst); ~Edge(); - Edge(const Edge&); - Edge& operator=(const Edge&); + Edge(const Edge&) = delete; + Edge& operator=(const Edge&) = delete; protected: std::shared_ptr 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 input, std::shared_ptr 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 . */ -#ifndef FORMAT_CONVERTER_H -#define FORMAT_CONVERTER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif #include "porting.h" -#include "ModCodec.h" +#include "ModPlugin.h" #include #include @@ -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 . */ -#ifndef FRAME_MULTIPLEXER_H -#define FRAME_MULTIPLEXER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModMux.h" +#include "ModPlugin.h" #include "SubchannelSource.h" #include @@ -52,5 +51,4 @@ protected: const std::vector >* 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 . */ -#ifndef FREQUENCY_INTERLEAVER_H -#define FREQUENCY_INTERLEAVER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" +#include "ModPlugin.h" #include @@ -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 . */ -#ifndef GAIN_CONTROL_H -#define GAIN_CONTROL_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" +#include "ModPlugin.h" #include "RemoteControl.h" #include @@ -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 . */ -#ifndef GUARD_INTERVAL_INSERTER_H -#define GUARD_INTERVAL_INSERTER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" - +#include "ModPlugin.h" #include @@ -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 . */ -#ifndef INPUT_MEMORY_H -#define INPUT_MEMORY_H +#pragma once #ifdef HAVE_CONFIG_H # include #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 . - */ - -#include "ModCodec.h" - -#include - - -#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 dataIn, - std::vector 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 . - */ - -#pragma once - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "ModPlugin.h" - -#include -#include - - -class ModCodec : public ModPlugin -{ -public: - ModCodec(); - virtual ~ModCodec(); - - virtual int process(std::vector dataIn, - std::vector 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 . - */ - -#include "ModInput.h" - -#include - - -#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 dataIn, - std::vector 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 . - */ - -#ifndef MOD_INPUT_H -#define MOD_INPUT_H - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "ModPlugin.h" - -#include - - -class ModInput : public ModPlugin -{ -public: - ModInput(); - virtual ~ModInput(); - - virtual int process(std::vector dataIn, - std::vector 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 . - */ - -#include "ModMux.h" - -#include - - -#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 dataIn, std::vector 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 . - */ - -#ifndef MOD_MUX_H -#define MOD_MUX_H - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "ModPlugin.h" - -#include -#include - - -class ModMux : public ModPlugin -{ -public: - ModMux(); - virtual ~ModMux(); - - virtual int process(std::vector dataIn, - std::vector dataOut); - virtual int process(std::vector 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 . - */ - -#include "ModOutput.h" - -#include - - -#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 dataIn, - std::vector 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 . - */ - -#ifndef MOD_OUTPUT_H -#define MOD_OUTPUT_H - -#ifdef HAVE_CONFIG_H -# include -#endif - - -#include "ModPlugin.h" - -#include - - -class ModOutput : public ModPlugin -{ -public: - ModOutput(); - virtual ~ModOutput(); - - virtual int process(std::vector dataIn, - std::vector 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 +#include + +#define MODASSERT(cond) \ + if (not (cond)) { \ + throw std::runtime_error("Assertion failure: " #cond " for " + \ + std::string(name())); \ + } + +int ModInput::process( + std::vector dataIn, + std::vector dataOut) +{ + MODASSERT(dataIn.empty()); + MODASSERT(dataOut.size() == 1); + return process(dataOut[0]); +} + +int ModCodec::process( + std::vector dataIn, + std::vector dataOut) +{ + MODASSERT(dataIn.size() == 1); + MODASSERT(dataOut.size() == 1); + return process(dataIn[0], dataOut[0]); +} + +int ModMux::process( + std::vector dataIn, + std::vector dataOut) +{ + MODASSERT(not dataIn.empty()); + MODASSERT(dataOut.size() == 1); + return process(dataIn, dataOut[0]); +} + +int ModOutput::process( + std::vector dataIn, + std::vector 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 #include -#ifdef DEBUG -# include -#endif - class ModPlugin { public: - virtual int process(std::vector dataIn, + virtual int process( + std::vector dataIn, std::vector 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 dataIn, + std::vector 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 dataIn, + std::vector 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 dataIn, + std::vector dataOut); + virtual int process(std::vector dataIn, Buffer* dataOut) = 0; +}; + +/* Outputs do not create any output buffers */ +class ModOutput : public ModPlugin +{ +public: + virtual int process( + std::vector dataIn, + std::vector 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 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 . */ -#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 #include -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 . */ -#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 . */ -#ifndef OUTPUT_FILE_H -#define OUTPUT_FILE_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModOutput.h" +#include "ModPlugin.h" #include #include @@ -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 . */ -#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 . */ -#ifndef OUTPUT_UHD_H -#define OUTPUT_UHD_H +#pragma once #define FAKE_UHD 0 @@ -54,7 +53,7 @@ DESCRIPTION: #include #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 . */ -#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 . */ -#ifndef PHASE_REFERENCE_H -#define PHASE_REFERENCE_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" +#include "ModPlugin.h" #include #include #include -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 dataIn, + std::vector dataOut) { - PDEBUG("PrbsGenerator::process(dataIn: %p, dataOut: %p)\n", - dataIn, dataOut); - dataOut->setLength(d_framesize); - unsigned char* out = reinterpret_cast(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(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(dataIn->getData()); - if (dataIn->getLength() != dataOut->getLength()) { - PDEBUG("%zu != %zu\n", dataIn->getLength(), dataOut->getLength()); + const unsigned char* in = + reinterpret_cast(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 . */ -#ifndef PRBS_GENERATOR_H -#define PRBS_GENERATOR_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif - -#include "ModCodec.h" - +#include "ModPlugin.h" #include #include - -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 dataIn, std::vector 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::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::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(dataIn->getData()); unsigned char* out = reinterpret_cast(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 . */ -#ifndef PUNCTURING_ENCODER_H -#define PUNCTURING_ENCODER_H +#pragma once #ifdef HAVE_CONFIG_H # include @@ -28,36 +32,31 @@ #include "PuncturingRule.h" -#include "ModCodec.h" +#include "ModPlugin.h" #include #include - +#include class PuncturingEncoder : public ModCodec { -private: - size_t d_in_block_size; - size_t d_out_block_size; - std::vector 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 d_rules; + boost::optional 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 . */ -#ifdef HAVE_CONFIG_H -//#include "config.h" -#endif - #include "PcDebug.h" #include "PuncturingRule.h" #include -#include - 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 . */ -#ifndef PUNCTURING_RULE_H -#define PUNCTURING_RULE_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif - #include #include - 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 . */ -#ifndef QPSK_SYMBOL_MAPPER_H -#define QPSK_SYMBOL_MAPPER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" +#include "ModPlugin.h" #include @@ -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 . */ -#ifndef RESAMPLER_H -#define RESAMPLER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif #include "porting.h" -#include "ModCodec.h" +#include "ModPlugin.h" #include #include @@ -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 . */ -#ifndef SIGNAL_MULTIPLEXER_H -#define SIGNAL_MULTIPLEXER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModMux.h" +#include "ModPlugin.h" +#include #include @@ -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& SubchannelSource::get_rules() +const std::vector& 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 . */ -#ifndef SUBCHANNEL_SOURCE_H -#define SUBCHANNEL_SOURCE_H +#pragma once #ifdef HAVE_CONFIG_H # include @@ -29,25 +33,15 @@ #include "PuncturingRule.h" #include "Eti.h" -#include "ModInput.h" +#include "ModPlugin.h" #include class SubchannelSource : public ModInput { -protected: - size_t d_start_address; - size_t d_framesize; - size_t d_protection; - Buffer d_buffer; - std::vector 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& get_rules(); - - int process(Buffer* inputData, Buffer* outputData); + const std::vector& 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 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 . */ -#ifndef TII_H -#define TII_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" +#include "ModPlugin.h" #include "RemoteControl.h" #include @@ -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 . */ -#ifndef TIME_INTERLEAVER_H -#define TIME_INTERLEAVER_H +#pragma once #ifdef HAVE_CONFIG_H # include #endif -#include "ModCodec.h" +#include "ModPlugin.h" #include #include @@ -52,4 +51,3 @@ public: }; -#endif // TIME_INTERLEAVER_H -- cgit v1.2.3