mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-04-02 16:57:03 +00:00
Adding a new data_type_adapter, from interleaved short to
std::complex<short>
This commit is contained in:
parent
42902c4663
commit
b96ca007f5
@ -18,10 +18,12 @@
|
||||
|
||||
|
||||
set(DATATYPE_ADAPTER_SOURCES
|
||||
byte_to_short.cc
|
||||
ibyte_to_cbyte.cc
|
||||
ibyte_to_complex.cc
|
||||
ishort_to_cshort.cc
|
||||
ishort_to_complex.cc
|
||||
ibyte_to_complex.cc
|
||||
byte_to_short.cc
|
||||
ibyte_to_cbyte.cc )
|
||||
)
|
||||
|
||||
include_directories(
|
||||
$(CMAKE_CURRENT_SOURCE_DIR)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
set(DATA_TYPE_GR_BLOCKS_SOURCES
|
||||
interleaved_byte_to_complex_byte.cc
|
||||
interleaved_short_to_complex_short.cc
|
||||
)
|
||||
|
||||
include_directories(
|
||||
@ -30,4 +31,4 @@ include_directories(
|
||||
file(GLOB DATA_TYPE_GR_BLOCKS_HEADERS "*.h")
|
||||
add_library(data_type_gr_blocks ${DATA_TYPE_GR_BLOCKS_SOURCES} ${DATA_TYPE_GR_BLOCKS_HEADERS})
|
||||
source_group(Headers FILES ${DATA_TYPE_GR_BLOCKS_HEADERS})
|
||||
target_link_libraries(data_type_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES})
|
||||
target_link_libraries(data_type_gr_blocks ${GNURADIO_RUNTIME_LIBRARIES} ${VOLK_LIBRARIES})
|
@ -42,7 +42,7 @@ interleaved_byte_to_complex_byte_sptr make_interleaved_byte_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(int8_t)),
|
||||
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), // lv_8sc_t is a Volk's typedef for std::complex<signed char>
|
||||
2)
|
||||
{
|
||||
@ -55,11 +55,11 @@ int interleaved_byte_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 int8_t *in = (const int8_t *) input_items[0];
|
||||
lv_8sc_t *out = (lv_8sc_t *) output_items[0];
|
||||
// This could be put into a Volk kernel
|
||||
signed char real_part;
|
||||
signed char imag_part;
|
||||
int8_t real_part;
|
||||
int8_t imag_part;
|
||||
for(unsigned int number = 0; number < 2 * noutput_items; number++)
|
||||
{
|
||||
// lv_cmake(r, i) defined at volk/volk_complex.h
|
||||
@ -67,6 +67,5 @@ int interleaved_byte_to_complex_byte::work(int noutput_items,
|
||||
imag_part = *in++;
|
||||
*out++ = lv_cmake(real_part, imag_part);
|
||||
}
|
||||
|
||||
return noutput_items;
|
||||
}
|
||||
|
@ -47,80 +47,80 @@ FirFilter::FirFilter(ConfigurationInterface* configuration, std::string role,
|
||||
size_t item_size;
|
||||
(*this).init();
|
||||
if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("gr_complex") == 0)
|
||||
&& (output_item_type_.compare("gr_complex") == 0))
|
||||
{
|
||||
item_size = sizeof(gr_complex);
|
||||
fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(1, taps_);
|
||||
DLOG(INFO) << "input_filter(" << fir_filter_ccf_->unique_id() << ")";
|
||||
if (dump_)
|
||||
&& (output_item_type_.compare("gr_complex") == 0))
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
|
||||
item_size = sizeof(gr_complex);
|
||||
fir_filter_ccf_ = gr::filter::fir_filter_ccf::make(1, taps_);
|
||||
DLOG(INFO) << "input_filter(" << fir_filter_ccf_->unique_id() << ")";
|
||||
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("cshort") == 0)
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
{
|
||||
item_size = sizeof(lv_16sc_t);
|
||||
cshort_to_float_x2_ = make_cshort_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_short_1_ = gr::blocks::float_to_short::make();
|
||||
float_to_short_2_ = gr::blocks::float_to_short::make();
|
||||
short_x2_to_cshort_ = make_short_x2_to_cshort();
|
||||
if (dump_)
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
{
|
||||
DLOG(INFO) << "Dumping output into file " << dump_filename_;
|
||||
file_sink_ = gr::blocks::file_sink::make(item_size, dump_filename_.c_str());
|
||||
item_size = sizeof(lv_16sc_t);
|
||||
cshort_to_float_x2_ = make_cshort_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_short_1_ = gr::blocks::float_to_short::make();
|
||||
float_to_short_2_ = gr::blocks::float_to_short::make();
|
||||
short_x2_to_cshort_ = make_short_x2_to_cshort();
|
||||
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("gr_complex") == 0))
|
||||
{
|
||||
item_size = sizeof(gr_complex);
|
||||
cbyte_to_float_x2_ = make_complex_byte_to_float_x2();
|
||||
&& (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() << ")";
|
||||
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();
|
||||
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());
|
||||
}
|
||||
}
|
||||
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();
|
||||
&& (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() << ")";
|
||||
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();
|
||||
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();
|
||||
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());
|
||||
}
|
||||
}
|
||||
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) << " Unknown item type conversion";
|
||||
}
|
||||
{
|
||||
LOG(ERROR) << " Unknown item type conversion";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -145,8 +145,8 @@ void FirFilter::connect(gr::top_block_sptr top_block)
|
||||
}
|
||||
}
|
||||
else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0)
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
{
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
{
|
||||
top_block->connect(cshort_to_float_x2_, 0, fir_filter_fff_1_, 0);
|
||||
top_block->connect(cshort_to_float_x2_, 1, fir_filter_fff_2_, 0);
|
||||
top_block->connect(fir_filter_fff_1_, 0, float_to_short_1_, 0);
|
||||
@ -157,9 +157,9 @@ void FirFilter::connect(gr::top_block_sptr top_block)
|
||||
{
|
||||
top_block->connect(short_x2_to_cshort_, 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))
|
||||
&& (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);
|
||||
@ -204,7 +204,7 @@ void FirFilter::disconnect(gr::top_block_sptr top_block)
|
||||
}
|
||||
}
|
||||
else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
|
||||
&& (output_item_type_.compare("gr_complex") == 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);
|
||||
@ -216,8 +216,8 @@ void FirFilter::disconnect(gr::top_block_sptr top_block)
|
||||
}
|
||||
}
|
||||
else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0)
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
{
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
{
|
||||
top_block->disconnect(cshort_to_float_x2_, 0, fir_filter_fff_1_, 0);
|
||||
top_block->disconnect(cshort_to_float_x2_, 1, fir_filter_fff_2_, 0);
|
||||
top_block->disconnect(fir_filter_fff_1_, 0, float_to_short_1_, 0);
|
||||
@ -229,7 +229,7 @@ void FirFilter::disconnect(gr::top_block_sptr top_block)
|
||||
top_block->disconnect(short_x2_to_cshort_, 0, file_sink_, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
|
||||
&& (output_item_type_.compare("cbyte") == 0))
|
||||
{
|
||||
@ -265,7 +265,7 @@ gr::basic_block_sptr FirFilter::get_left_block()
|
||||
return cshort_to_float_x2_;
|
||||
}
|
||||
else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
|
||||
&& (output_item_type_.compare("gr_complex") == 0))
|
||||
&& (output_item_type_.compare("gr_complex") == 0))
|
||||
{
|
||||
return cbyte_to_float_x2_;
|
||||
}
|
||||
@ -291,12 +291,12 @@ gr::basic_block_sptr FirFilter::get_right_block()
|
||||
return fir_filter_ccf_;
|
||||
}
|
||||
else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cshort") == 0)
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
&& (output_item_type_.compare("cshort") == 0))
|
||||
{
|
||||
return short_x2_to_cshort_;
|
||||
}
|
||||
else if ((taps_item_type_.compare("float") == 0) && (input_item_type_.compare("cbyte") == 0)
|
||||
&& (output_item_type_.compare("gr_complex") == 0))
|
||||
&& (output_item_type_.compare("gr_complex") == 0))
|
||||
{
|
||||
return float_to_complex_;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ byte_x2_to_complex_byte_sptr make_byte_x2_to_complex_byte()
|
||||
|
||||
|
||||
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 (2, 2, sizeof(int8_t)), // int8_t, defined in stdint.h and included in volk.h (signed 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);
|
||||
@ -54,12 +54,12 @@ int byte_x2_to_complex_byte::work(int noutput_items,
|
||||
gr_vector_const_void_star &input_items,
|
||||
gr_vector_void_star &output_items)
|
||||
{
|
||||
const char *in0 = (const char *) input_items[0];
|
||||
const char *in1 = (const char *) input_items[1];
|
||||
const int8_t *in0 = (const int8_t *) input_items[0];
|
||||
const int8_t *in1 = (const int8_t *) input_items[1];
|
||||
lv_8sc_t *out = (lv_8sc_t *) output_items[0];
|
||||
// This could be put into a volk kernel
|
||||
signed char real_part;
|
||||
signed char imag_part;
|
||||
int8_t real_part;
|
||||
int8_t imag_part;
|
||||
for(int number = 0; number < noutput_items; number++)
|
||||
{
|
||||
// lv_cmake(r, i) defined at volk/volk_complex.h
|
||||
@ -67,6 +67,5 @@ int byte_x2_to_complex_byte::work(int noutput_items,
|
||||
imag_part = *in1++;
|
||||
*out++ = lv_cmake(real_part, imag_part);
|
||||
}
|
||||
|
||||
return noutput_items;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ complex_byte_to_float_x2::complex_byte_to_float_x2() : sync_block("complex_byte_
|
||||
gr::io_signature::make (1, 1, sizeof(lv_8sc_t)), // lv_8sc_t is a Volk's typedef for std::complex<signed char>
|
||||
gr::io_signature::make (2, 2, sizeof(float)))
|
||||
{
|
||||
const int alignment_multiple = volk_get_alignment() / sizeof(lv_8sc_t);
|
||||
const int alignment_multiple = volk_get_alignment() / sizeof(float);
|
||||
set_alignment(std::max(1, alignment_multiple));
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,11 @@
|
||||
|
||||
#include "signal_conditioner.h"
|
||||
#include "array_signal_conditioner.h"
|
||||
#include "ishort_to_complex.h"
|
||||
#include "ibyte_to_complex.h"
|
||||
#include "byte_to_short.h"
|
||||
#include "ibyte_to_cbyte.h"
|
||||
#include "ibyte_to_complex.h"
|
||||
#include "ishort_to_cshort.h"
|
||||
#include "ishort_to_complex.h"
|
||||
#include "direct_resampler_conditioner.h"
|
||||
#include "fir_filter.h"
|
||||
#include "freq_xlating_fir_filter.h"
|
||||
@ -444,15 +446,9 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
|
||||
#endif
|
||||
|
||||
// DATA TYPE ADAPTER -----------------------------------------------------------
|
||||
else if (implementation.compare("Ishort_To_Complex") == 0)
|
||||
else if (implementation.compare("Byte_To_Short") == 0)
|
||||
{
|
||||
std::unique_ptr<GNSSBlockInterface>block_(new IshortToComplex(configuration.get(), role, in_streams,
|
||||
out_streams, queue));
|
||||
block = std::move(block_);
|
||||
}
|
||||
else if (implementation.compare("Ibyte_To_Complex") == 0)
|
||||
{
|
||||
std::unique_ptr<GNSSBlockInterface>block_(new IbyteToComplex(configuration.get(), role, in_streams,
|
||||
std::unique_ptr<GNSSBlockInterface>block_(new ByteToShort(configuration.get(), role, in_streams,
|
||||
out_streams, queue));
|
||||
block = std::move(block_);
|
||||
}
|
||||
@ -462,6 +458,25 @@ std::unique_ptr<GNSSBlockInterface> GNSSBlockFactory::GetBlock(
|
||||
out_streams, queue));
|
||||
block = std::move(block_);
|
||||
}
|
||||
else if (implementation.compare("Ibyte_To_Complex") == 0)
|
||||
{
|
||||
std::unique_ptr<GNSSBlockInterface>block_(new IbyteToComplex(configuration.get(), role, in_streams,
|
||||
out_streams, queue));
|
||||
block = std::move(block_);
|
||||
}
|
||||
else if (implementation.compare("Ishort_To_Cshort") == 0)
|
||||
{
|
||||
std::unique_ptr<GNSSBlockInterface>block_(new IshortToCshort(configuration.get(), role, in_streams,
|
||||
out_streams, queue));
|
||||
block = std::move(block_);
|
||||
}
|
||||
else if (implementation.compare("Ishort_To_Complex") == 0)
|
||||
{
|
||||
std::unique_ptr<GNSSBlockInterface>block_(new IshortToComplex(configuration.get(), role, in_streams,
|
||||
out_streams, queue));
|
||||
block = std::move(block_);
|
||||
}
|
||||
|
||||
// INPUT FILTER ----------------------------------------------------------------
|
||||
else if (implementation.compare("Fir_Filter") == 0)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user