[hamradio-commits] [gnss-sdr] 06/44: adding a fir_filter for std::complex<signed char> (aka cbyte). It converts the data type to floats, filters, and converts back to cbyte.
Carles Fernandez
carles_fernandez-guest at moszumanska.debian.org
Sun Feb 15 15:32:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
carles_fernandez-guest pushed a commit to branch next
in repository gnss-sdr.
commit b9e7d8a446a9a9c86142fc8b4416faa05fcb02ba
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date: Tue Feb 3 00:58:21 2015 +0100
adding a fir_filter for std::complex<signed char> (aka cbyte). It
converts the data type to floats, filters, and converts back to cbyte.
---
.../data_type_adapter/adapters/ibyte_to_cbyte.h | 4 +-
.../interleaved_byte_to_complex_byte.cc | 8 +-
.../input_filter/adapters/CMakeLists.txt | 1 +
src/algorithms/input_filter/adapters/fir_filter.cc | 161 ++++++++++++++++++++-
src/algorithms/input_filter/adapters/fir_filter.h | 13 +-
.../input_filter/gnuradio_blocks/CMakeLists.txt | 5 +-
.../gnuradio_blocks/byte_x2_to_complex_byte.cc} | 32 ++--
.../gnuradio_blocks/byte_x2_to_complex_byte.h | 61 ++++++++
.../gnuradio_blocks/complex_byte_to_float_x2.cc} | 33 ++---
.../gnuradio_blocks/complex_byte_to_float_x2.h | 61 ++++++++
src/core/receiver/CMakeLists.txt | 1 +
src/core/receiver/gnss_block_factory.cc | 7 +
src/tests/CMakeLists.txt | 1 +
13 files changed, 338 insertions(+), 50 deletions(-)
diff --git a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h
index f326b60..366df10 100644
--- a/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h
+++ b/src/algorithms/data_type_adapter/adapters/ibyte_to_cbyte.h
@@ -29,8 +29,8 @@
* -------------------------------------------------------------------------
*/
-#ifndef GNSS_SDR_IBYTE_TO_COMPLEX_H_
-#define GNSS_SDR_IBYTE_TO_COMPLEX_H_
+#ifndef GNSS_SDR_IBYTE_TO_CBYTE_H_
+#define GNSS_SDR_IBYTE_TO_CBYTE_H_
#include <string>
#include <gnuradio/blocks/file_sink.h>
diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
index 8851788..3ce882f 100644
--- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
+++ b/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
@@ -58,12 +58,14 @@ int interleaved_byte_to_complex_byte::work(int noutput_items,
const signed char *in = (const signed char *) input_items[0];
lv_8sc_t *out = (lv_8sc_t *) output_items[0];
// This could be put into a Volk kernel
- unsigned int sample_index = 0;
+ signed char real_part;
+ signed char imag_part;
for(unsigned int number = 0; number < 2 * noutput_items; number++)
{
// lv_cmake(r, i) defined at volk/volk_complex.h
- *out++ = lv_cmake(in[sample_index], in[sample_index + 1]);
- sample_index = sample_index + 2;
+ real_part = *in++;
+ imag_part = *in++;
+ *out++ = lv_cmake(real_part, imag_part);
}
return noutput_items;
diff --git a/src/algorithms/input_filter/adapters/CMakeLists.txt b/src/algorithms/input_filter/adapters/CMakeLists.txt
index e0742c2..23c59e4 100644
--- a/src/algorithms/input_filter/adapters/CMakeLists.txt
+++ b/src/algorithms/input_filter/adapters/CMakeLists.txt
@@ -30,6 +30,7 @@ include_directories(
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
+ ${VOLK_INCLUDE_DIRS}
)
file(GLOB INPUT_FILTER_ADAPTER_HEADERS "*.h")
diff --git a/src/algorithms/input_filter/adapters/fir_filter.cc b/src/algorithms/input_filter/adapters/fir_filter.cc
index 3236956..8b0a22c 100644
--- a/src/algorithms/input_filter/adapters/fir_filter.cc
+++ b/src/algorithms/input_filter/adapters/fir_filter.cc
@@ -32,6 +32,7 @@
#include <boost/lexical_cast.hpp>
#include <gnuradio/filter/pm_remez.h>
#include <glog/logging.h>
+#include <volk/volk.h>
#include "configuration_interface.h"
using google::LogMessage;
@@ -56,9 +57,50 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role,
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
}
}
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ item_size = sizeof(gr_complex);
+ cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
+
+ fir_filter_fff_1_ = gr::filter::fir_filter_fff::make(1, taps_);
+ fir_filter_fff_2_ = gr::filter::fir_filter_fff::make(1, taps_);
+ DLOG(INFO) << "I input_filter(" << fir_filter_fff_1_->unique_id() << ")";
+ DLOG(INFO) << "Q input_filter(" << fir_filter_fff_2_->unique_id() << ")";
+
+ float_to_complex_ = gr::blocks::float_to_complex::make();
+
+ if (dump_)
+ {
+ DLOG(INFO) << "Dumping output into file " << dump_filename_;
+ file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
+ }
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("cbyte") == 0))
+ {
+ item_size = sizeof(lv_8sc_t);
+ cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
+
+ fir_filter_fff_1_ = gr::filter::fir_filter_fff::make(1, taps_);
+ fir_filter_fff_2_ = gr::filter::fir_filter_fff::make(1, taps_);
+ DLOG(INFO) << "I input_filter(" << fir_filter_fff_1_->unique_id() << ")";
+ DLOG(INFO) << "Q input_filter(" << fir_filter_fff_2_->unique_id() << ")";
+
+ float_to_char_1_ = gr::blocks::float_to_char::make();
+ float_to_char_2_ = gr::blocks::float_to_char::make();
+
+ char_x2_cbyte_ = make_byte_x2_to_complex_byte();
+
+ if (dump_)
+ {
+ DLOG(INFO) << "Dumping output into file " << dump_filename_;
+ file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
+ }
+ }
else
{
- LOG(ERROR) << taps_item_type_ << " unknown input filter item type";
+ LOG(ERROR) << " Unknown item type conversion";
}
}
@@ -71,13 +113,48 @@ FirFilter::~FirFilter()
void FirFilter::connect(gr::top_block_sptr top_block)
{
- if (dump_)
+ if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
{
- top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
+ if (dump_)
+ {
+ top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
+ }
+ else
+ {
+ DLOG(INFO) << "Nothing to connect internally";
+ }
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ top_block->connect(cbyte_to_float_x2_, 0, fir_filter_fff_1_, 0);
+ top_block->connect(cbyte_to_float_x2_, 1, fir_filter_fff_2_, 0);
+ top_block->connect(fir_filter_fff_1_, 0, float_to_complex_, 0);
+ top_block->connect(fir_filter_fff_2_, 0, float_to_complex_, 1);
+ if (dump_)
+ {
+ top_block->connect(float_to_complex_, 0, file_sink_, 0);
+ }
+
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("cbyte") == 0))
+ {
+ top_block->connect(cbyte_to_float_x2_, 0, fir_filter_fff_1_, 0);
+ top_block->connect(cbyte_to_float_x2_, 1, fir_filter_fff_2_, 0);
+ top_block->connect(fir_filter_fff_1_, 0, float_to_char_1_, 0);
+ top_block->connect(fir_filter_fff_2_, 0, float_to_char_2_, 0);
+ top_block->connect(float_to_char_1_, 0, char_x2_cbyte_, 0);
+ top_block->connect(float_to_char_2_, 0, char_x2_cbyte_, 1);
+ if (dump_)
+ {
+ top_block->connect(char_x2_cbyte_, 0, file_sink_, 0);
+ }
}
else
{
- DLOG(INFO) << "Nothing to connect internally";
+ LOG(ERROR) << " Unknown item type conversion";
}
}
@@ -85,9 +162,39 @@ void FirFilter::connect(gr::top_block_sptr top_block)
void FirFilter::disconnect(gr::top_block_sptr top_block)
{
- if (dump_)
+ if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ if (dump_)
+ {
+ top_block->disconnect(fir_filter_ccf_, 0, file_sink_, 0);
+ }
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ top_block->disconnect(fir_filter_fff_2_, 0, float_to_complex_, 1);
+ top_block->disconnect(fir_filter_fff_1_, 0, float_to_complex_, 0);
+ top_block->disconnect(cbyte_to_float_x2_, 1, fir_filter_fff_2_, 0);
+ top_block->disconnect(cbyte_to_float_x2_, 0, fir_filter_fff_1_, 0);
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("cbyte") == 0))
+ {
+ top_block->disconnect(float_to_char_2_, 0, char_x2_cbyte_, 1);
+ top_block->disconnect(float_to_char_1_, 0, char_x2_cbyte_, 0);
+ top_block->disconnect(fir_filter_fff_2_, 0, float_to_char_2_, 0);
+ top_block->disconnect(fir_filter_fff_1_, 0, float_to_char_1_, 0);
+ top_block->disconnect(cbyte_to_float_x2_, 0, fir_filter_fff_1_, 0);
+ top_block->disconnect(cbyte_to_float_x2_, 1, fir_filter_fff_2_, 0);
+ if (dump_)
+ {
+ top_block->disconnect(char_x2_cbyte_, 0, file_sink_, 0);
+ }
+ }
+ else
{
- top_block->connect(fir_filter_ccf_, 0, file_sink_, 0);
+ LOG(ERROR) << " unknown input filter item type";
}
}
@@ -95,14 +202,52 @@ void FirFilter::disconnect(gr::top_block_sptr top_block)
gr::basic_block_sptr FirFilter::get_left_block()
{
- return fir_filter_ccf_;
+ if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ return fir_filter_ccf_;
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ return cbyte_to_float_x2_;
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("cbyte") == 0))
+ {
+ return cbyte_to_float_x2_;
+ }
+ else
+ {
+ return nullptr;
+ LOG(ERROR) << " unknown input filter item type";
+ }
}
gr::basic_block_sptr FirFilter::get_right_block()
{
- return fir_filter_ccf_;
+ if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ return fir_filter_ccf_;
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("gr_complex") == 0))
+ {
+ return float_to_complex_;
+ }
+ else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
+ && (output_item_type_.compare("cbyte") == 0))
+ {
+ return char_x2_cbyte_;
+ }
+ else
+ {
+ return nullptr;
+ LOG(ERROR) << " unknown input filter item type";
+ }
}
diff --git a/src/algorithms/input_filter/adapters/fir_filter.h b/src/algorithms/input_filter/adapters/fir_filter.h
index e8a8821..cd549e8 100644
--- a/src/algorithms/input_filter/adapters/fir_filter.h
+++ b/src/algorithms/input_filter/adapters/fir_filter.h
@@ -38,11 +38,15 @@
#include <vector>
#include <gnuradio/gr_complex.h>
#include <gnuradio/blocks/file_sink.h>
+#include <gnuradio/blocks/float_to_char.h>
+#include <gnuradio/blocks/float_to_complex.h>
#include <gnuradio/filter/fir_filter_ccf.h>
+#include <gnuradio/filter/fir_filter_fff.h>
#include <gnuradio/msg_queue.h>
#include "gnss_synchro.h"
#include "gnss_block_interface.h"
-
+#include "complex_byte_to_float_x2.h"
+#include "byte_x2_to_complex_byte.h"
class ConfigurationInterface;
@@ -100,6 +104,13 @@ private:
boost::shared_ptr<gr::msg_queue> queue_;
gr::blocks::file_sink::sptr file_sink_;
void init();
+ complex_byte_to_float_x2_sptr cbyte_to_float_x2_;
+ gr::filter::fir_filter_fff::sptr fir_filter_fff_1_;
+ gr::filter::fir_filter_fff::sptr fir_filter_fff_2_;
+ gr::blocks::float_to_char::sptr float_to_char_1_;
+ gr::blocks::float_to_char::sptr float_to_char_2_;
+ byte_x2_to_complex_byte_sptr char_x2_cbyte_;
+ gr::blocks::float_to_complex::sptr float_to_complex_;
};
#endif
diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt
index 932504b..3da599a 100644
--- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt
+++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt
@@ -19,6 +19,8 @@
set(INPUT_FILTER_GR_BLOCKS_SOURCES
beamformer.cc
+ complex_byte_to_float_x2.cc
+ byte_x2_to_complex_byte.cc
)
include_directories(
@@ -26,9 +28,10 @@ include_directories(
${GLOG_INCLUDE_DIRS}
${GFlags_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
+ ${VOLK_INCLUDE_DIRS}
)
file(GLOB INPUT_FILTER_GR_BLOCKS_HEADERS "*.h")
add_library(input_filter_gr_blocks ${INPUT_FILTER_GR_BLOCKS_SOURCES} ${INPUT_FILTER_GR_BLOCKS_HEADERS})
source_group(Headers FILES ${INPUT_FILTER_GR_BLOCKS_HEADERS})
-target_link_libraries(input_filter_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES})
\ No newline at end of file
+target_link_libraries(input_filter_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES})
\ No newline at end of file
diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc b/src/algorithms/input_filter/gnuradio_blocks/byte_x2_to_complex_byte.cc
similarity index 63%
copy from src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
copy to src/algorithms/input_filter/gnuradio_blocks/byte_x2_to_complex_byte.cc
index 8851788..11b3b44 100644
--- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
+++ b/src/algorithms/input_filter/gnuradio_blocks/byte_x2_to_complex_byte.cc
@@ -1,6 +1,6 @@
/*!
- * \file interleaved_byte_to_complex_byte.cc
- * \brief Adapts an 8-bits interleaved sample stream into a 16-bits complex stream
+ * \file byte_x2_to_complex_byte.cc
+ * \brief * \brief Adapts two signed char streams into a std::complex<signed char> stream
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
@@ -29,41 +29,43 @@
*/
-#include "interleaved_byte_to_complex_byte.h"
+#include "byte_x2_to_complex_byte.h"
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
-interleaved_byte_to_complex_byte_sptr make_interleaved_byte_to_complex_byte()
+byte_x2_to_complex_byte_sptr make_byte_x2_to_complex_byte()
{
- return interleaved_byte_to_complex_byte_sptr(new interleaved_byte_to_complex_byte());
+ return byte_x2_to_complex_byte_sptr(new byte_x2_to_complex_byte());
}
-interleaved_byte_to_complex_byte::interleaved_byte_to_complex_byte() : sync_decimator("interleaved_byte_to_complex_byte",
- gr::io_signature::make (1, 1, sizeof(char)),
- gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), // lv_8sc_t is a Volk's typedef for std::complex<signed char>
- 2)
+byte_x2_to_complex_byte::byte_x2_to_complex_byte() : sync_block("byte_x2_to_complex_byte",
+ gr::io_signature::make (2, 2, sizeof(char)),
+ gr::io_signature::make (1, 1, sizeof(lv_8sc_t))) // lv_8sc_t is a Volk's typedef for std::complex<signed char>
{
const int alignment_multiple = volk_get_alignment() / sizeof(lv_8sc_t);
set_alignment(std::max(1, alignment_multiple));
}
-int interleaved_byte_to_complex_byte::work(int noutput_items,
+int byte_x2_to_complex_byte::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const signed char *in = (const signed char *) input_items[0];
+ const char *in0 = (const char *) input_items[0];
+ const char *in1 = (const char *) input_items[1];
lv_8sc_t *out = (lv_8sc_t *) output_items[0];
- // This could be put into a Volk kernel
- unsigned int sample_index = 0;
+ // This could be put into a volk kernel
+ signed char real_part;
+ signed char imag_part;
for(unsigned int number = 0; number < 2 * noutput_items; number++)
{
// lv_cmake(r, i) defined at volk/volk_complex.h
- *out++ = lv_cmake(in[sample_index], in[sample_index + 1]);
- sample_index = sample_index + 2;
+ real_part = *in0++;
+ imag_part = *in1++;
+ *out++ = lv_cmake(real_part, imag_part);
}
return noutput_items;
diff --git a/src/algorithms/input_filter/gnuradio_blocks/byte_x2_to_complex_byte.h b/src/algorithms/input_filter/gnuradio_blocks/byte_x2_to_complex_byte.h
new file mode 100644
index 0000000..e730c69
--- /dev/null
+++ b/src/algorithms/input_filter/gnuradio_blocks/byte_x2_to_complex_byte.h
@@ -0,0 +1,61 @@
+/*!
+ * \file byte_x2_to_complex_byte.h
+ * \brief Adapts two signed char streams into a std::complex<signed char> stream
+ * \author Carles Fernandez Prades, cfernandez(at)cttc.es
+ *
+ * -------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ * Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * GNSS-SDR 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.
+ *
+ * GNSS-SDR 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 GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+#ifndef GNSS_SDR_BYTE_X2_TO_COMPLEX_BYTE_H_
+#define GNSS_SDR_BYTE_X2_TO_COMPLEX_BYTE_H_
+
+
+#include <string>
+#include <boost/shared_ptr.hpp>
+#include <gnuradio/sync_block.h>
+
+class byte_x2_to_complex_byte;
+
+typedef boost::shared_ptr<byte_x2_to_complex_byte> byte_x2_to_complex_byte_sptr;
+
+byte_x2_to_complex_byte_sptr make_byte_x2_to_complex_byte();
+
+/*!
+ * \brief This class adapts two signed char streams
+ * into a std::complex<signed char> stream
+ */
+class byte_x2_to_complex_byte : public gr::sync_block
+{
+private:
+ friend byte_x2_to_complex_byte_sptr make_byte_x2_to_complex_byte();
+public:
+ byte_x2_to_complex_byte();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc b/src/algorithms/input_filter/gnuradio_blocks/complex_byte_to_float_x2.cc
similarity index 58%
copy from src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
copy to src/algorithms/input_filter/gnuradio_blocks/complex_byte_to_float_x2.cc
index 8851788..88315ce 100644
--- a/src/algorithms/data_type_adapter/gnuradio_blocks/interleaved_byte_to_complex_byte.cc
+++ b/src/algorithms/input_filter/gnuradio_blocks/complex_byte_to_float_x2.cc
@@ -1,6 +1,6 @@
/*!
- * \file interleaved_byte_to_complex_byte.cc
- * \brief Adapts an 8-bits interleaved sample stream into a 16-bits complex stream
+ * \file complex_byte_to_float_x2.cc
+ * \brief Adapts a std::complex<signed char> stream into two 16-bits (short) streams
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
*
* -------------------------------------------------------------------------
@@ -29,42 +29,35 @@
*/
-#include "interleaved_byte_to_complex_byte.h"
+#include "complex_byte_to_float_x2.h"
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
-interleaved_byte_to_complex_byte_sptr make_interleaved_byte_to_complex_byte()
+complex_byte_to_float_x2_sptr make_complex_byte_to_float_x2()
{
- return interleaved_byte_to_complex_byte_sptr(new interleaved_byte_to_complex_byte());
+ return complex_byte_to_float_x2_sptr(new complex_byte_to_float_x2());
}
-interleaved_byte_to_complex_byte::interleaved_byte_to_complex_byte() : sync_decimator("interleaved_byte_to_complex_byte",
- gr::io_signature::make (1, 1, sizeof(char)),
+complex_byte_to_float_x2::complex_byte_to_float_x2() : sync_block("complex_byte_to_float_x2",
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), // lv_8sc_t is a Volk's typedef for std::complex<signed char>
- 2)
+ gr::io_signature::make (2, 2, sizeof(float)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(lv_8sc_t);
set_alignment(std::max(1, alignment_multiple));
}
-int interleaved_byte_to_complex_byte::work(int noutput_items,
+int complex_byte_to_float_x2::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
- const signed char *in = (const signed char *) input_items[0];
- lv_8sc_t *out = (lv_8sc_t *) output_items[0];
- // This could be put into a Volk kernel
- unsigned int sample_index = 0;
- for(unsigned int number = 0; number < 2 * noutput_items; number++)
- {
- // lv_cmake(r, i) defined at volk/volk_complex.h
- *out++ = lv_cmake(in[sample_index], in[sample_index + 1]);
- sample_index = sample_index + 2;
- }
-
+ const lv_8sc_t *in = (const lv_8sc_t *) input_items[0];
+ float *out0 = (float*) output_items[0];
+ float *out1 = (float*) output_items[1];
+ const float scalar = 1;
+ volk_8ic_s32f_deinterleave_32f_x2(out0, out1, in, scalar, noutput_items);
return noutput_items;
}
diff --git a/src/algorithms/input_filter/gnuradio_blocks/complex_byte_to_float_x2.h b/src/algorithms/input_filter/gnuradio_blocks/complex_byte_to_float_x2.h
new file mode 100644
index 0000000..6842930
--- /dev/null
+++ b/src/algorithms/input_filter/gnuradio_blocks/complex_byte_to_float_x2.h
@@ -0,0 +1,61 @@
+/*!
+ * \file complex_byte_to_float_x2.h
+ * \brief Adapts a std::complex<signed char> stream into two 16-bits (short) streams
+ * \author Carles Fernandez Prades, cfernandez(at)cttc.es
+ *
+ * -------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ * Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * GNSS-SDR 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.
+ *
+ * GNSS-SDR 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 GNSS-SDR. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * -------------------------------------------------------------------------
+ */
+
+#ifndef GNSS_SDR_COMPLEX_BYTE_TO_FLOAT_X2_H_
+#define GNSS_SDR_COMPLEX_BYTE_TO_FLOAT_X2_H_
+
+
+#include <string>
+#include <boost/shared_ptr.hpp>
+#include <gnuradio/sync_block.h>
+
+class complex_byte_to_float_x2;
+
+typedef boost::shared_ptr<complex_byte_to_float_x2> complex_byte_to_float_x2_sptr;
+
+complex_byte_to_float_x2_sptr make_complex_byte_to_float_x2();
+
+/*!
+ * \brief This class adapts a std::complex<signed char> stream
+ * into two 16-bits (short) streams
+ */
+class complex_byte_to_float_x2 : public gr::sync_block
+{
+private:
+ friend complex_byte_to_float_x2_sptr make_complex_byte_to_float_x2();
+public:
+ complex_byte_to_float_x2();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif
diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt
index e499eaf..51cd6cc 100644
--- a/src/core/receiver/CMakeLists.txt
+++ b/src/core/receiver/CMakeLists.txt
@@ -41,6 +41,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/algorithms/channel/libs
${CMAKE_SOURCE_DIR}/src/algorithms/conditioner/adapters
${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/adapters
+ ${CMAKE_SOURCE_DIR}/src/algorithms/data_type_adapter/gnuradio_blocks
${CMAKE_SOURCE_DIR}/src/algorithms/resampler/adapters
${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/adapters
${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/gnuradio_blocks
diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc
index d837d64..df77fca 100644
--- a/src/core/receiver/gnss_block_factory.cc
+++ b/src/core/receiver/gnss_block_factory.cc
@@ -54,6 +54,7 @@
#include "array_signal_conditioner.h"
#include "ishort_to_complex.h"
#include "ibyte_to_complex.h"
+#include "ibyte_to_cbyte.h"
#include "direct_resampler_conditioner.h"
#include "fir_filter.h"
#include "freq_xlating_fir_filter.h"
@@ -455,6 +456,12 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
out_streams, queue));
block = std::move(block_);
}
+ else if (implementation.compare("Ibyte_To_Cbyte") == 0)
+ {
+ std::unique_ptr<GNSSBlockInterface>block_(new IbyteToCbyte(configuration.get(), role, in_streams,
+ out_streams, queue));
+ block = std::move(block_);
+ }
// INPUT FILTER ----------------------------------------------------------------
else if (implementation.compare("Fir_Filter") == 0)
{
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 649dd0a..4bf0c89 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -138,6 +138,7 @@ include_directories(
${CMAKE_SOURCE_DIR}/src/algorithms/signal_generator/adapters
${CMAKE_SOURCE_DIR}/src/algorithms/signal_generator/gnuradio_blocks
${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/adapters
+ ${CMAKE_SOURCE_DIR}/src/algorithms/input_filter/gnuradio_blocks
${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/adapters
${CMAKE_SOURCE_DIR}/src/algorithms/acquisition/gnuradio_blocks
${CMAKE_SOURCE_DIR}/src/algorithms/output_filter/adapters
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git
More information about the pkg-hamradio-commits
mailing list