summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Mortensen <mortensenit@users.noreply.github.com>2015-01-05 16:36:52 +0100
committerKenneth Mortensen <mortensenit@users.noreply.github.com>2015-01-05 16:36:52 +0100
commit191817b42ad86a250bbff02895e9646f51531672 (patch)
tree521d6b1a9a30a657d84c80ca9660c24c4db8ee86 /src
parentfcc439f1387887110ccbf0e9e6a6d116eba315ac (diff)
parent94c1f63b6fd07d74f3325274dd19fd6beaf53965 (diff)
downloaddabmod-191817b42ad86a250bbff02895e9646f51531672.tar.gz
dabmod-191817b42ad86a250bbff02895e9646f51531672.tar.bz2
dabmod-191817b42ad86a250bbff02895e9646f51531672.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src')
-rw-r--r--src/DabMod.cpp95
-rw-r--r--src/GainControl.cpp10
-rw-r--r--src/Makefile.am126
-rw-r--r--src/OfdmGenerator.cpp85
-rw-r--r--src/OfdmGenerator.h20
-rw-r--r--src/OutputUHD.cpp4
-rw-r--r--src/OutputUHD.h5
-rw-r--r--src/OutputZeroMQ.cpp67
-rw-r--r--src/OutputZeroMQ.h60
-rw-r--r--src/Resampler.cpp102
-rw-r--r--src/Resampler.h22
-rw-r--r--src/kiss_fftsimd.h8
12 files changed, 472 insertions, 132 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index 67ad12d..91c0b9d 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -38,6 +38,7 @@
#if defined(HAVE_OUTPUT_UHD)
# include "OutputUHD.h"
#endif
+#include "OutputZeroMQ.h"
#include "InputReader.h"
#include "PcDebug.h"
#include "TimestampDecoder.h"
@@ -91,11 +92,11 @@ void printUsage(char* progName, FILE* out = stderr)
#endif
__DATE__, __TIME__);
fprintf(out, "Usage with configuration file:\n");
- fprintf(out, "\t%s -C config_file.ini\n\n", progName);
+ fprintf(out, "\t%s [-C] config_file.ini\n\n", progName);
fprintf(out, "Usage with command line options:\n");
fprintf(out, "\t%s"
- " [input]"
+ " input"
" (-f filename | -u uhddevice -F frequency) "
" [-G txgain]"
" [-o offset]"
@@ -137,8 +138,13 @@ void printVersion(FILE *out = stderr)
{
fprintf(out, "Welcome to %s %s, compiled at %s, %s\n\n",
PACKAGE, VERSION, __DATE__, __TIME__);
- fprintf(out, "ODR-DabMod is copyright (C) Her Majesty the Queen in Right of Canada,\n"
- " 2009, 2010, 2011, 2012 Communications Research Centre (CRC).\n"
+ fprintf(out,
+ " ODR-DabMod is copyright (C) Her Majesty the Queen in Right of Canada,\n"
+ " 2009, 2010, 2011, 2012 Communications Research Centre (CRC),\n"
+ " and\n"
+ " Copyright (C) 2014 Matthias P. Braendli, matthias.braendli@mpb.li\n"
+ "\n"
+ " http://opendigitalradio.org\n"
"\n"
" This program is available free of charge and is licensed to you on a\n"
" non-exclusive basis; you may not redistribute it.\n"
@@ -151,8 +157,10 @@ void printVersion(FILE *out = stderr)
" In no event shall CRC be LIABLE for any LOSS, DAMAGE or COST that may be\n"
" incurred in connection with the use of this software.\n"
"\n"
+#if USE_KISS_FFT
"ODR-DabMod makes use of the following open source packages:\n"
" Kiss FFT v1.2.9 (Revised BSD) - http://kissfft.sourceforge.net/\n"
+#endif
);
}
@@ -166,6 +174,7 @@ int main(int argc, char* argv[])
std::string inputTransport = "file";
std::string outputName;
+ int useZeroMQOutput = 0;
int useFileOutput = 0;
int useUHDOutput = 0;
@@ -257,7 +266,7 @@ int main(int argc, char* argv[])
break;
case 'G':
#if defined(HAVE_OUTPUT_UHD)
- outputuhd_conf.txgain = (int)strtol(optarg, NULL, 10);
+ outputuhd_conf.txgain = strtod(optarg, NULL);
#endif
break;
case 'l':
@@ -330,11 +339,47 @@ int main(int argc, char* argv[])
#endif
<< std::endl;
+ std::cerr << "Using FFT library " <<
+#if defined(USE_FFTW)
+ "FFTW" <<
+#endif
+#if defined(USE_KISS_FFT)
+ "Kiss FFT" <<
+#endif
+#if defined(USE_SIMD)
+ " (with fft_simd)" <<
+#endif
+ "\n";
+
+ std::cerr << "Compiled with features: " <<
+#if defined(HAVE_INPUT_ZEROMQ)
+ "input_zeromq " <<
+#endif
+#if defined(HAVE_OUTPUT_UHD)
+ "output_uhd " <<
+#endif
+#if defined(HAVE_OUTPUT_ZEROMQ)
+ "output_zeromq " <<
+#endif
+ "\n";
+
if (use_configuration_file && use_configuration_cmdline) {
fprintf(stderr, "Warning: configuration file and command line parameters are defined:\n\t"
"Command line parameters override settings in the configuration file !\n");
}
+ // No argument given ? You can't be serious ! Show usage.
+ if (argc == 1) {
+ printUsage(argv[0]);
+ goto END_MAIN;
+ }
+
+ // If only one argument is given, interpret as configuration file name
+ if (argc == 2) {
+ use_configuration_file = true;
+ configuration_file = argv[1];
+ }
+
if (use_configuration_file) {
// First read parameters from the file
using boost::property_tree::ptree;
@@ -399,7 +444,7 @@ int main(int argc, char* argv[])
clockRate = pt.get("modulator.dac_clk_rate", (size_t)0);
digitalgain = pt.get("modulator.digital_gain", digitalgain);
outputRate = pt.get("modulator.rate", outputRate);
-
+
// FIR Filter parameters:
if (pt.get("firfilter.enabled", 0) == 1) {
try {
@@ -451,7 +496,7 @@ int main(int argc, char* argv[])
"setting type in [uhd] device is deprecated !\n";
}
- outputuhd_conf.txgain = pt.get("uhdoutput.txgain", 0);
+ outputuhd_conf.txgain = pt.get("uhdoutput.txgain", 0.0);
outputuhd_conf.frequency = pt.get<double>("uhdoutput.frequency", 0);
std::string chan = pt.get<std::string>("uhdoutput.channel", "");
@@ -531,6 +576,12 @@ int main(int argc, char* argv[])
useUHDOutput = 1;
}
#endif
+#if defined(HAVE_OUTPUT_ZEROMQ)
+ else if (output_selected == "zmq") {
+ outputName = pt.get<std::string>("zmqoutput.listen");
+ useZeroMQOutput = 1;
+ }
+#endif
else {
std::cerr << "Error: Invalid output defined.\n";
goto END_MAIN;
@@ -563,6 +614,7 @@ int main(int argc, char* argv[])
outputuhd_conf.muteNoTimestamps = (pt.get("delaymanagement.mutenotimestamps", 0) == 1);
#endif
}
+
if (!rc) {
logger.level(warn) << "No Remote-Control started";
rc = new RemoteControllerDummy();
@@ -584,7 +636,7 @@ int main(int argc, char* argv[])
}
// Setting ETI input filename
- if (inputName == "") {
+ if (use_configuration_cmdline && inputName == "") {
if (optind < argc) {
inputName = argv[optind++];
@@ -600,7 +652,7 @@ int main(int argc, char* argv[])
}
// Checking unused arguments
- if (optind != argc) {
+ if (use_configuration_cmdline && optind != argc) {
fprintf(stderr, "Invalid arguments:");
while (optind != argc) {
fprintf(stderr, " %s", argv[optind++]);
@@ -612,7 +664,7 @@ int main(int argc, char* argv[])
goto END_MAIN;
}
- if (!useFileOutput && !useUHDOutput) {
+ if (!useFileOutput && !useUHDOutput && !useZeroMQOutput) {
logger.level(error) << "Output not specified";
fprintf(stderr, "Must specify output !");
goto END_MAIN;
@@ -623,8 +675,12 @@ int main(int argc, char* argv[])
fprintf(stderr, " Type: %s\n", inputTransport.c_str());
fprintf(stderr, " Source: %s\n", inputName.c_str());
fprintf(stderr, "Output\n");
+
+ if (useFileOutput) {
+ fprintf(stderr, " Name: %s\n", outputName.c_str());
+ }
#if defined(HAVE_OUTPUT_UHD)
- if (useUHDOutput) {
+ else if (useUHDOutput) {
fprintf(stderr, " UHD\n"
" Device: %s\n"
" Type: %s\n"
@@ -633,12 +689,13 @@ int main(int argc, char* argv[])
outputuhd_conf.usrpType.c_str(),
outputuhd_conf.masterClockRate);
}
- else if (useFileOutput) {
-#else
- if (useFileOutput) {
#endif
- fprintf(stderr, " Name: %s\n", outputName.c_str());
+ else if (useZeroMQOutput) {
+ fprintf(stderr, " ZeroMQ\n"
+ " Listening on: %s\n",
+ outputName.c_str());
}
+
fprintf(stderr, " Sampling rate: ");
if (outputRate > 1000) {
if (outputRate > 1000000) {
@@ -713,6 +770,14 @@ int main(int argc, char* argv[])
}
}
#endif
+#if defined(HAVE_OUTPUT_ZEROMQ)
+ else if (useZeroMQOutput) {
+ /* We normalise the same way as for the UHD output */
+ normalise = 1.0f/50000.0f;
+
+ output = new OutputZeroMQ(outputName);
+ }
+#endif
flowgraph = new Flowgraph();
data.setLength(6144);
diff --git a/src/GainControl.cpp b/src/GainControl.cpp
index a34dcf2..03d8aa6 100644
--- a/src/GainControl.cpp
+++ b/src/GainControl.cpp
@@ -27,12 +27,20 @@
#include "GainControl.h"
#include "PcDebug.h"
-#include "kiss_fftsimd.h"
#include <stdio.h>
#include <stdexcept>
#include <string>
+#ifdef __SSE__
+# include <xmmintrin.h>
+union __u128 {
+ __m128 m;
+ float f[4];
+};
+#endif
+
+
using namespace std;
diff --git a/src/Makefile.am b/src/Makefile.am
index f6102e9..922ce52 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,95 +22,105 @@ else
GITVERSION_FLAGS =
endif
-if HAVE_INPUT_ZEROMQ_TEST
-ZMQ_LIBS =-lzmq
-else
-ZMQ_LIBS =
-endif
-
-if HAVE_OUTPUT_UHD_TEST
-UHD_SOURCES =OutputUHD.cpp OutputUHD.h
-else
-UHD_SOURCES =
-endif
-
if HAVE_SSE
SIMD_CFLAGS = -msse -msse2
else
SIMD_CFLAGS =
endif
+bin_PROGRAMS = odr-dabmod
+
+if USE_KISS_FFT
FFT_DIR=$(top_builddir)/lib/kiss_fft129
FFT_INC=-I$(FFT_DIR) -I$(FFT_DIR)/tools
-FFT_SRC=$(FFT_DIR)/kiss_fft.c $(FFT_DIR)/kiss_fft.h $(FFT_DIR)/tools/kiss_fftr.c $(FFT_DIR)/tools/kiss_fftr.h kiss_fftsimd.c kiss_fftsimd.h
+FFT_SRC=$(FFT_DIR)/kiss_fft.c \
+ $(FFT_DIR)/kiss_fft.h \
+ $(FFT_DIR)/tools/kiss_fftr.c \
+ $(FFT_DIR)/tools/kiss_fftr.h \
+ kiss_fftsimd.c \
+ kiss_fftsimd.h
FFT_FLG=-ffast-math
.PHONY: kiss_fft129 reed-solomon-4.0
-bin_PROGRAMS = odr-dabmod
+DabModulator.cpp: $(FFT_DIR)
-DabModulator.cpp: $(FFT_DIR)
+BUILT_SOURCES: $(FFT_DIR)
-BUILT_SOURCES: $(FFT_DIR)
+FFT_LDADD=
$(FFT_DIR):
if [ ! -e $(FFT_DIR) ]; then \
tar xzf $(top_srcdir)/lib/kiss_fft129.tar.gz -C $(top_builddir)/lib; \
fi
-odr_dabmod_CPPFLAGS = -Wall $(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS)
-odr_dabmod_LDADD = $(ZMQ_LIBS)
+else
+FFT_LDADD=
+FFT_DIR=
+FFT_INC=
+FFT_SRC=
+FFT_FLG=
+endif
+
+odr_dabmod_CPPFLAGS = -Wall \
+ $(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS)
+odr_dabmod_LDADD = $(FFT_LDADD)
odr_dabmod_SOURCES = DabMod.cpp \
- PcDebug.h \
- porting.c porting.h \
- DabModulator.cpp DabModulator.h \
- Buffer.cpp Buffer.h \
- ModCodec.cpp ModCodec.h \
- ModPlugin.cpp ModPlugin.h \
- ModFormat.cpp ModFormat.h \
- EtiReader.cpp EtiReader.h \
- Eti.cpp Eti.h \
- FicSource.cpp FicSource.h \
+ PcDebug.h \
+ porting.c porting.h \
+ DabModulator.cpp DabModulator.h \
+ Buffer.cpp Buffer.h \
+ ModCodec.cpp ModCodec.h \
+ ModPlugin.cpp ModPlugin.h \
+ ModFormat.cpp ModFormat.h \
+ EtiReader.cpp EtiReader.h \
+ Eti.cpp Eti.h \
+ FicSource.cpp FicSource.h \
FIRFilter.cpp FIRFilter.h \
- ModInput.cpp ModInput.h \
- PuncturingRule.cpp PuncturingRule.h \
- PuncturingEncoder.cpp PuncturingEncoder.h \
- SubchannelSource.cpp SubchannelSource.h \
- Flowgraph.cpp Flowgraph.h \
- GainControl.cpp GainControl.h \
- OutputMemory.cpp OutputMemory.h \
+ ModInput.cpp ModInput.h \
+ PuncturingRule.cpp PuncturingRule.h \
+ PuncturingEncoder.cpp PuncturingEncoder.h \
+ SubchannelSource.cpp SubchannelSource.h \
+ Flowgraph.cpp Flowgraph.h \
+ GainControl.cpp GainControl.h \
+ OutputMemory.cpp OutputMemory.h \
+ OutputZeroMQ.cpp OutputZeroMQ.h \
TimestampDecoder.h TimestampDecoder.cpp \
- $(UHD_SOURCES) \
- ModOutput.cpp ModOutput.h \
- InputMemory.cpp InputMemory.h \
+ OutputUHD.cpp OutputUHD.h \
+ ModOutput.cpp ModOutput.h \
+ InputMemory.cpp InputMemory.h \
InputFileReader.cpp InputZeroMQReader.cpp InputReader.h \
- OutputFile.cpp OutputFile.h \
- FrameMultiplexer.cpp FrameMultiplexer.h \
- ModMux.cpp ModMux.h \
- PrbsGenerator.cpp PrbsGenerator.h \
- BlockPartitioner.cpp BlockPartitioner.h \
- QpskSymbolMapper.cpp QpskSymbolMapper.h \
- FrequencyInterleaver.cpp FrequencyInterleaver.h \
- PhaseReference.cpp PhaseReference.h \
- DifferentialModulator.cpp DifferentialModulator.h \
- NullSymbol.cpp NullSymbol.h \
- SignalMultiplexer.cpp SignalMultiplexer.h \
- CicEqualizer.cpp CicEqualizer.h \
- OfdmGenerator.cpp OfdmGenerator.h \
- GuardIntervalInserter.cpp GuardIntervalInserter.h \
- Resampler.cpp Resampler.h \
- ConvEncoder.cpp ConvEncoder.h \
- TimeInterleaver.cpp TimeInterleaver.h \
+ OutputFile.cpp OutputFile.h \
+ FrameMultiplexer.cpp FrameMultiplexer.h \
+ ModMux.cpp ModMux.h \
+ PrbsGenerator.cpp PrbsGenerator.h \
+ BlockPartitioner.cpp BlockPartitioner.h \
+ QpskSymbolMapper.cpp QpskSymbolMapper.h \
+ FrequencyInterleaver.cpp FrequencyInterleaver.h \
+ PhaseReference.cpp PhaseReference.h \
+ DifferentialModulator.cpp DifferentialModulator.h \
+ NullSymbol.cpp NullSymbol.h \
+ SignalMultiplexer.cpp SignalMultiplexer.h \
+ CicEqualizer.cpp CicEqualizer.h \
+ OfdmGenerator.cpp OfdmGenerator.h \
+ GuardIntervalInserter.cpp GuardIntervalInserter.h \
+ Resampler.cpp Resampler.h \
+ ConvEncoder.cpp ConvEncoder.h \
+ TimeInterleaver.cpp TimeInterleaver.h \
ThreadsafeQueue.h \
Log.cpp Log.h \
RemoteControl.cpp RemoteControl.h \
zmq.hpp
-nodist_odr_dabmod_SOURCES =$(FFT_SRC)
+nodist_odr_dabmod_SOURCES = $(FFT_SRC)
-dist_bin_SCRIPTS =crc-dwap.py
+dist_bin_SCRIPTS = crc-dwap.py
-EXTRA_DIST =kiss_fftsimd.c kiss_fftsimd.h
+if USE_KISS_FFT
+EXTRA_DIST = kiss_fftsimd.c kiss_fftsimd.h
clean-local:
rm -rf $(FFT_DIR)
+
+endif
+
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp
index c7e8ebf..7044249 100644
--- a/src/OfdmGenerator.cpp
+++ b/src/OfdmGenerator.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) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -21,9 +26,15 @@
#include "OfdmGenerator.h"
#include "PcDebug.h"
-#include "kiss_fftsimd.h"
+#if USE_FFTW
+# include "fftw3.h"
+# define FFT_TYPE fftwf_complex
+#else
+# include "kiss_fftsimd.h"
+#endif
#include <stdio.h>
+#include <string.h>
#include <stdexcept>
#include <assert.h>
#include <complex>
@@ -37,7 +48,11 @@ OfdmGenerator::OfdmGenerator(size_t nbSymbols,
ModCodec(ModFormat(nbSymbols * nbCarriers * sizeof(FFT_TYPE)),
ModFormat(nbSymbols * spacing * sizeof(FFT_TYPE))),
myFftPlan(NULL),
+#if USE_FFTW
+ myFftIn(NULL), myFftOut(NULL),
+#else
myFftBuffer(NULL),
+#endif
myNbSymbols(nbSymbols),
myNbCarriers(nbCarriers),
mySpacing(spacing)
@@ -57,7 +72,8 @@ OfdmGenerator::OfdmGenerator(size_t nbSymbols,
myNegDst = spacing - (nbCarriers / 2);
myNegSrc = (nbCarriers + 1) / 2;
myNegSize = nbCarriers / 2;
- } else {
+ }
+ else {
myPosDst = (nbCarriers & 1 ? 0 : 1);
myPosSrc = nbCarriers / 2;
myPosSize = (nbCarriers + 1) / 2;
@@ -77,8 +93,25 @@ OfdmGenerator::OfdmGenerator(size_t nbSymbols,
PDEBUG(" myZeroDst: %u\n", myZeroDst);
PDEBUG(" myZeroSize: %u\n", myZeroSize);
+#if USE_FFTW
+ const int N = mySpacing; // The size of the FFT
+ myFftIn = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * N);
+ myFftOut = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * N);
+ myFftPlan = fftwf_plan_dft_1d(N,
+ myFftIn, myFftOut,
+ FFTW_BACKWARD, FFTW_MEASURE);
+
+ if (sizeof(complexf) != sizeof(FFT_TYPE)) {
+ printf("sizeof(complexf) %zu\n", sizeof(complexf));
+ printf("sizeof(FFT_TYPE) %zu\n", sizeof(FFT_TYPE));
+ throw std::runtime_error(
+ "OfdmGenerator::process complexf size is not FFT_TYPE size!");
+ }
+#else
myFftPlan = kiss_fft_alloc(mySpacing, 1, NULL, NULL);
myFftBuffer = (FFT_TYPE*)memalign(16, mySpacing * sizeof(FFT_TYPE));
+#endif
+
}
@@ -86,16 +119,32 @@ OfdmGenerator::~OfdmGenerator()
{
PDEBUG("OfdmGenerator::~OfdmGenerator() @ %p\n", this);
+#if USE_FFTW
+ if (myFftIn) {
+ fftwf_free(myFftIn);
+ }
+
+ if (myFftOut) {
+ fftwf_free(myFftOut);
+ }
+
+ if (myFftPlan) {
+ fftwf_destroy_plan(myFftPlan);
+ }
+
+#else
if (myFftPlan != NULL) {
kiss_fft_free(myFftPlan);
}
+
if (myFftBuffer != NULL) {
free(myFftBuffer);
}
+
kiss_fft_cleanup();
+#endif
}
-
int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
{
PDEBUG("OfdmGenerator::process(dataIn: %p, dataOut: %p)\n",
@@ -105,6 +154,7 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
FFT_TYPE* in = reinterpret_cast<FFT_TYPE*>(dataIn->getData());
FFT_TYPE* out = reinterpret_cast<FFT_TYPE*>(dataOut->getData());
+
size_t sizeIn = dataIn->getLength() / sizeof(complexf);
size_t sizeOut = dataOut->getLength() / sizeof(complexf);
@@ -125,7 +175,27 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
"OfdmGenerator::process output size not valid!");
}
-#ifdef USE_SIMD
+#if USE_FFTW
+ // No SIMD/no-SIMD distinction, it's too early to optimize anything
+ for (size_t i = 0; i < myNbSymbols; ++i) {
+ myFftIn[0][0] = 0;
+ myFftIn[0][1] = 0;
+
+ bzero(&myFftIn[myZeroDst], myZeroSize * sizeof(FFT_TYPE));
+ memcpy(&myFftIn[myPosDst], &in[myPosSrc],
+ myPosSize * sizeof(FFT_TYPE));
+ memcpy(&myFftIn[myNegDst], &in[myNegSrc],
+ myNegSize * sizeof(FFT_TYPE));
+
+ fftwf_execute(myFftPlan);
+
+ memcpy(out, myFftOut, mySpacing * sizeof(FFT_TYPE));
+
+ in += myNbCarriers;
+ out += mySpacing;
+ }
+#else
+# ifdef USE_SIMD
for (size_t i = 0, j = 0; i < sizeIn; ) {
// Pack 4 fft operations
typedef struct {
@@ -154,7 +224,8 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
dataBuffer[myNegDst + l].i[k] = cplxIn[i + myNegSrc + l].imag();
}
i += myNbCarriers;
- } else {
+ }
+ else {
for (size_t l = 0; l < myNbCarriers; ++l) {
dataBuffer[l].r[k] = 0.0f;
dataBuffer[l].i[k] = 0.0f;
@@ -174,7 +245,7 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
}
}
}
-#else
+# else
for (size_t i = 0; i < myNbSymbols; ++i) {
FFT_REAL(myFftBuffer[0]) = 0;
FFT_IMAG(myFftBuffer[0]) = 0;
@@ -189,7 +260,9 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
in += myNbCarriers;
out += mySpacing;
}
+# endif
#endif
return sizeOut;
}
+
diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h
index 5be2d03..ec9f14a 100644
--- a/src/OfdmGenerator.h
+++ b/src/OfdmGenerator.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) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -28,10 +33,14 @@
#include "porting.h"
#include "ModCodec.h"
-#include "kiss_fftsimd.h"
+#if USE_FFTW
+# include "fftw3.h"
+#else
+# include "kiss_fftsimd.h"
+# include <kiss_fft.h>
+#endif
-#include <kiss_fft.h>
#include <sys/types.h>
@@ -48,8 +57,13 @@ public:
const char* name() { return "OfdmGenerator"; }
protected:
+#if USE_FFTW
+ fftwf_plan myFftPlan;
+ fftwf_complex *myFftIn, *myFftOut;
+#else
FFT_PLAN myFftPlan;
FFT_TYPE *myFftBuffer;
+#endif
size_t myNbSymbols;
size_t myNbCarriers;
size_t mySpacing;
@@ -63,5 +77,5 @@ protected:
unsigned myZeroSize;
};
-
#endif // OFDM_GENERATOR_H
+
diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp
index 3d8eea6..8063e75 100644
--- a/src/OutputUHD.cpp
+++ b/src/OutputUHD.cpp
@@ -25,6 +25,9 @@
*/
#include "OutputUHD.h"
+
+#ifdef HAVE_OUTPUT_UHD
+
#include "PcDebug.h"
#include "Log.h"
#include "RemoteControl.h"
@@ -652,3 +655,4 @@ const string OutputUHD::get_parameter(const string& parameter) const
return ss.str();
}
+#endif // HAVE_OUTPUT_UHD
diff --git a/src/OutputUHD.h b/src/OutputUHD.h
index 3a047bf..a2ffb7d 100644
--- a/src/OutputUHD.h
+++ b/src/OutputUHD.h
@@ -42,6 +42,8 @@ DESCRIPTION:
# include <config.h>
#endif
+#ifdef HAVE_OUTPUT_UHD
+
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
@@ -166,7 +168,7 @@ struct OutputUHDConfig {
long masterClockRate;
unsigned sampleRate;
double frequency;
- int txgain;
+ double txgain;
bool enableSync;
bool muteNoTimestamps;
@@ -230,6 +232,7 @@ class OutputUHD: public ModOutput, public RemoteControllable {
size_t lastLen;
};
+#endif // HAVE_OUTPUT_UHD
#endif // OUTPUT_UHD_H
diff --git a/src/OutputZeroMQ.cpp b/src/OutputZeroMQ.cpp
new file mode 100644
index 0000000..0e759dd
--- /dev/null
+++ b/src/OutputZeroMQ.cpp
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
+ Right of Canada (Communications Research Center Canada)
+
+ Copyright (C) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
+ */
+/*
+ This file is part of ODR-DabMod.
+
+ ODR-DabMod is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ ODR-DabMod is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "OutputZeroMQ.h"
+#include "PcDebug.h"
+#include <stdexcept>
+#include <string.h>
+#include <sstream>
+
+#if defined(HAVE_OUTPUT_ZEROMQ)
+
+OutputZeroMQ::OutputZeroMQ(std::string endpoint, Buffer* dataOut)
+ : ModOutput(ModFormat(1), ModFormat(0)),
+ m_zmq_context(1),
+ m_zmq_pub_sock(m_zmq_context, ZMQ_PUB),
+ m_endpoint(endpoint)
+{
+ PDEBUG("OutputZeroMQ::OutputZeroMQ(%p) @ %p\n", dataOut, this);
+
+ std::stringstream ss;
+ ss << "OutputZeroMQ(" << m_endpoint << ")";
+ m_name = ss.str();
+
+ m_zmq_pub_sock.bind(m_endpoint.c_str());
+}
+
+OutputZeroMQ::~OutputZeroMQ()
+{
+ PDEBUG("OutputZeroMQ::~OutputZeroMQ() @ %p\n", this);
+}
+
+int OutputZeroMQ::process(Buffer* dataIn, Buffer* dataOut)
+{
+ PDEBUG("OutputZeroMQ::process"
+ "(dataIn: %p, dataOut: %p)\n",
+ dataIn, dataOut);
+
+ m_zmq_pub_sock.send(dataIn->getData(), dataIn->getLength());
+
+ return dataIn->getLength();
+}
+
+#endif // HAVE_OUTPUT_ZEROMQ_H
+
diff --git a/src/OutputZeroMQ.h b/src/OutputZeroMQ.h
new file mode 100644
index 0000000..1c48fe7
--- /dev/null
+++ b/src/OutputZeroMQ.h
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
+ Right of Canada (Communications Research Center Canada)
+
+ Copyright (C) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
+ */
+/*
+ This file is part of ODR-DabMod.
+
+ ODR-DabMod is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ ODR-DabMod is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with ODR-DabMod. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef OUTPUT_ZEROMQ_H
+#define OUTPUT_ZEROMQ_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if defined(HAVE_OUTPUT_ZEROMQ)
+
+#include "ModOutput.h"
+#include "zmq.hpp"
+
+class OutputZeroMQ : public ModOutput
+{
+ public:
+ OutputZeroMQ(std::string endpoint, Buffer* dataOut = NULL);
+ virtual ~OutputZeroMQ();
+ virtual int process(Buffer* dataIn, Buffer* dataOut);
+ const char* name() { return m_name.c_str(); }
+
+ protected:
+ zmq::context_t m_zmq_context; // handle for the zmq context
+ zmq::socket_t m_zmq_pub_sock; // handle for the zmq publisher socket
+
+ std::string m_endpoint; // On which port to listen: e.g.
+ // tcp://*:58300
+
+ std::string m_name;
+};
+
+#endif // HAVE_OUTPUT_ZEROMQ_H
+
+#endif // OUTPUT_ZEROMQ_H
+
diff --git a/src/Resampler.cpp b/src/Resampler.cpp
index 334be99..cda4ff4 100644
--- a/src/Resampler.cpp
+++ b/src/Resampler.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) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -22,17 +27,16 @@
#include "Resampler.h"
#include "PcDebug.h"
-
-#if HAVE_DECL__MM_MALLOC
-# include <mm_malloc.h>
-#else
-# define memalign(a, b) malloc(b)
-#endif
+#include <malloc.h>
#include <sys/types.h>
#include <string.h>
#include <stdexcept>
#include <assert.h>
+#if USE_FFTW
+# define FFT_REAL(x) x[0]
+# define FFT_IMAG(x) x[1]
+#endif
unsigned gcd(unsigned a, unsigned b)
{
@@ -59,6 +63,9 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) :
{
PDEBUG("Resampler::Resampler(%zu, %zu) @ %p\n", inputRate, outputRate, this);
+#if USE_FFTW
+ fprintf(stderr, "This software uses the FFTW library.\n\n");
+#else
fprintf(stderr, "This software uses KISS FFT.\n\n");
fprintf(stderr, "Copyright (c) 2003-2004 Mark Borgerding\n"
"\n"
@@ -92,6 +99,7 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) :
"OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY "
"OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE "
"POSSIBILITY OF SUCH DAMAGE.\n");
+#endif
size_t divisor = gcd(inputRate, outputRate);
L = outputRate / divisor;
@@ -119,6 +127,22 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) :
PDEBUG("Window[%zu] = %f\n", i, myWindow[i]);
}
+#if USE_FFTW
+ myFftIn = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn);
+ myFront = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn);
+ myFftPlan1 = fftwf_plan_dft_1d(myFftSizeIn,
+ myFftIn, myFront,
+ FFTW_FORWARD, FFTW_MEASURE);
+
+ myBack = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut);
+ myFftOut = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut);
+ myFftPlan2 = fftwf_plan_dft_1d(myFftSizeOut,
+ myBack, myFftOut,
+ FFTW_BACKWARD, FFTW_MEASURE);
+
+ myBufferIn = (complexf*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn / 2);
+ myBufferOut = (complexf*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut / 2);
+#else
myFftIn = (FFT_TYPE*)memalign(16, myFftSizeIn * sizeof(FFT_TYPE));
myFftOut = (FFT_TYPE*)memalign(16, myFftSizeOut * sizeof(FFT_TYPE));
myBufferIn = (complexf*)memalign(16, myFftSizeIn / 2 * sizeof(FFT_TYPE));
@@ -127,6 +151,7 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) :
myBack = (FFT_TYPE*)memalign(16, myFftSizeOut * sizeof(FFT_TYPE));
myFftPlan1 = kiss_fft_alloc(myFftSizeIn, 0, NULL, NULL);
myFftPlan2 = kiss_fft_alloc(myFftSizeOut, 1, NULL, NULL);
+#endif
memset(myBufferIn, 0, myFftSizeIn / 2 * sizeof(FFT_TYPE));
memset(myBufferOut, 0, myFftSizeOut / 2 * sizeof(FFT_TYPE));
@@ -137,34 +162,30 @@ Resampler::~Resampler()
{
PDEBUG("Resampler::~Resampler() @ %p\n", this);
- if (myFftPlan1 != NULL) {
- free(myFftPlan1);
- }
- if (myFftPlan2 != NULL) {
- free(myFftPlan2);
- }
- if (myFftIn != NULL) {
- free(myFftIn);
- }
- if (myFftOut != NULL) {
- free(myFftOut);
- }
- if (myBufferIn != NULL) {
- free(myBufferIn);
- }
- if (myBufferOut != NULL) {
- free(myBufferOut);
- }
- if (myFront != NULL) {
- free(myFront);
- }
- if (myBack != NULL) {
- free(myBack);
- }
- if (myWindow != NULL) {
- free(myWindow);
- }
+#if USE_FFTW
+ if (myFftPlan1 != NULL) { fftwf_free(myFftPlan1); }
+ if (myFftPlan2 != NULL) { fftwf_free(myFftPlan2); }
+ if (myFftIn != NULL) { fftwf_free(myFftIn); }
+ if (myFftOut != NULL) { fftwf_free(myFftOut); }
+ if (myBufferIn != NULL) { fftwf_free(myBufferIn); }
+ if (myBufferOut != NULL) { fftwf_free(myBufferOut); }
+ if (myFront != NULL) { fftwf_free(myFront); }
+ if (myBack != NULL) { fftwf_free(myBack); }
+ if (myWindow != NULL) { fftwf_free(myWindow); }
+ fftwf_destroy_plan(myFftPlan1);
+ fftwf_destroy_plan(myFftPlan2);
+#else
+ if (myFftPlan1 != NULL) { free(myFftPlan1); }
+ if (myFftPlan2 != NULL) { free(myFftPlan2); }
+ if (myFftIn != NULL) { free(myFftIn); }
+ if (myFftOut != NULL) { free(myFftOut); }
+ if (myBufferIn != NULL) { free(myBufferIn); }
+ if (myBufferOut != NULL) { free(myBufferOut); }
+ if (myFront != NULL) { free(myFront); }
+ if (myBack != NULL) { free(myBack); }
+ if (myWindow != NULL) { free(myWindow); }
kiss_fft_cleanup();
+#endif
}
@@ -179,7 +200,7 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut)
FFT_TYPE* out = reinterpret_cast<FFT_TYPE*>(dataOut->getData());
size_t sizeIn = dataIn->getLength() / sizeof(complexf);
-#ifdef USE_SIMD
+#if defined(USE_SIMD) && !USE_FFTW
size_t sizeOut = dataOut->getLength() / sizeof(complexf);
typedef struct {
@@ -263,7 +284,9 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut)
j += myFftSizeOut / 2;
}
}
-#else
+#endif
+
+#if USE_FFTW || (!defined(USE_SIMD))
for (size_t i = 0, j = 0; i < sizeIn; i += myFftSizeIn / 2, j += myFftSizeOut / 2) {
memcpy(myFftIn, myBufferIn, myFftSizeIn / 2 * sizeof(FFT_TYPE));
memcpy(myFftIn + (myFftSizeIn / 2), in + i, myFftSizeIn / 2 * sizeof(FFT_TYPE));
@@ -273,7 +296,11 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut)
FFT_IMAG(myFftIn[k]) *= myWindow[k];
}
+#if USE_FFTW
+ fftwf_execute(myFftPlan1);
+#else
kiss_fft(myFftPlan1, myFftIn, myFront);
+#endif
if (myFftSizeOut > myFftSizeIn) {
memset(myBack, 0, myFftSizeOut * sizeof(FFT_TYPE));
@@ -304,7 +331,11 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut)
FFT_IMAG(myBack[k]) *= myFactor;
}
+#if USE_FFTW
+ fftwf_execute(myFftPlan2);
+#else
kiss_fft(myFftPlan2, myBack, myFftOut);
+#endif
for (size_t k = 0; k < myFftSizeOut / 2; ++k) {
FFT_REAL(out[j + k]) = myBufferOut[k].real() + FFT_REAL(myFftOut[k]);
@@ -316,3 +347,4 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut)
return 1;
}
+
diff --git a/src/Resampler.h b/src/Resampler.h
index a19b14e..392d0a6 100644
--- a/src/Resampler.h
+++ b/src/Resampler.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) 2014
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -28,12 +33,19 @@
#include "porting.h"
#include "ModCodec.h"
-#include "kiss_fftsimd.h"
+#if USE_FFTW
+# include <sys/types.h>
+# include <fftw3.h>
+# define FFT_TYPE fftwf_complex
+# define FFT_PLAN fftwf_plan
-#include <sys/types.h>
-#include <kiss_fft.h>
-#include <tools/kiss_fftr.h>
+#else
+# include "kiss_fftsimd.h"
+# include <sys/types.h>
+# include <kiss_fft.h>
+# include <tools/kiss_fftr.h>
+#endif
#include <complex>
typedef std::complex<float> complexf;
@@ -68,5 +80,5 @@ protected:
float myFactor;
};
-
#endif // RESAMPLER_H
+
diff --git a/src/kiss_fftsimd.h b/src/kiss_fftsimd.h
index 6d38dc7..90ee435 100644
--- a/src/kiss_fftsimd.h
+++ b/src/kiss_fftsimd.h
@@ -36,14 +36,6 @@
#define FFT_IMAG(a) (a).i
-#ifdef __SSE__
-#include <xmmintrin.h>
-union __u128 {
- __m128 m;
- float f[4];
-};
-#endif
-
#ifdef USE_SIMD