2015-02-03 15:14:42 +00:00
|
|
|
/*!
|
|
|
|
* \file short_x2_to_cshort.cc
|
|
|
|
* \brief Adapts two short streams into a std::complex<short> stream
|
|
|
|
* \author Carles Fernandez Prades, cfernandez(at)cttc.es
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2015-02-03 15:14:42 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2015-02-03 15:14:42 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2015-02-03 15:14:42 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2015-02-03 15:14:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "short_x2_to_cshort.h"
|
|
|
|
#include <gnuradio/io_signature.h>
|
2019-03-05 11:33:54 +00:00
|
|
|
#include <volk_gnsssdr/volk_gnsssdr.h>
|
|
|
|
#include <algorithm> // for max
|
|
|
|
#include <complex> // for complex
|
2015-02-03 15:14:42 +00:00
|
|
|
|
|
|
|
short_x2_to_cshort_sptr make_short_x2_to_cshort()
|
|
|
|
{
|
|
|
|
return short_x2_to_cshort_sptr(new short_x2_to_cshort());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
short_x2_to_cshort::short_x2_to_cshort() : sync_block("short_x2_to_cshort",
|
2018-12-08 17:49:31 +00:00
|
|
|
gr::io_signature::make(2, 2, sizeof(int16_t)),
|
|
|
|
gr::io_signature::make(1, 1, sizeof(lv_16sc_t)))
|
2015-02-03 15:14:42 +00:00
|
|
|
{
|
2020-07-10 20:06:29 +00:00
|
|
|
const auto alignment_multiple = static_cast<int>(volk_gnsssdr_get_alignment() / sizeof(lv_16sc_t));
|
2015-02-03 15:14:42 +00:00
|
|
|
set_alignment(std::max(1, alignment_multiple));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int short_x2_to_cshort::work(int noutput_items,
|
2018-03-03 01:03:39 +00:00
|
|
|
gr_vector_const_void_star &input_items,
|
|
|
|
gr_vector_void_star &output_items)
|
2015-02-03 15:14:42 +00:00
|
|
|
{
|
2018-12-08 17:49:31 +00:00
|
|
|
const auto *in0 = reinterpret_cast<const int16_t *>(input_items[0]);
|
|
|
|
const auto *in1 = reinterpret_cast<const int16_t *>(input_items[1]);
|
2018-12-03 15:25:11 +00:00
|
|
|
auto *out = reinterpret_cast<lv_16sc_t *>(output_items[0]);
|
2015-02-03 15:14:42 +00:00
|
|
|
// This could be put into a volk kernel
|
2018-12-08 17:49:31 +00:00
|
|
|
int16_t real_part;
|
|
|
|
int16_t imag_part;
|
2018-03-03 01:03:39 +00:00
|
|
|
for (int number = 0; number < noutput_items; number++)
|
2015-02-03 15:14:42 +00:00
|
|
|
{
|
|
|
|
real_part = *in0++;
|
|
|
|
imag_part = *in1++;
|
|
|
|
*out++ = lv_cmake(real_part, imag_part);
|
|
|
|
}
|
|
|
|
|
|
|
|
return noutput_items;
|
|
|
|
}
|