1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-30 17:03:15 +00:00

Add more extensive use of cstdint typenames

This commit is contained in:
Carles Fernandez 2018-08-14 01:32:06 +02:00
parent 200648be50
commit b64850d285
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
8 changed files with 73 additions and 70 deletions

View File

@ -39,7 +39,7 @@
using google::LogMessage; using google::LogMessage;
notch_sptr make_notch_filter(float pfa, float p_c_factor, notch_sptr make_notch_filter(float pfa, float p_c_factor,
int length_, int n_segments_est, int n_segments_reset) int32_t length_, int32_t n_segments_est, int32_t n_segments_reset)
{ {
return notch_sptr(new Notch(pfa, p_c_factor, length_, n_segments_est, n_segments_reset)); return notch_sptr(new Notch(pfa, p_c_factor, length_, n_segments_est, n_segments_reset));
} }
@ -47,31 +47,31 @@ notch_sptr make_notch_filter(float pfa, float p_c_factor,
Notch::Notch(float pfa, Notch::Notch(float pfa,
float p_c_factor, float p_c_factor,
int length_, int32_t length_,
int n_segments_est, int32_t n_segments_est,
int n_segments_reset) : gr::block("Notch", int32_t n_segments_reset) : gr::block("Notch",
gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex))) gr::io_signature::make(1, 1, sizeof(gr_complex)))
{ {
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple)); set_alignment(std::max(1, alignment_multiple));
set_history(2); set_history(2);
this->pfa = pfa; this->pfa = pfa;
noise_pow_est = 0.0; noise_pow_est = 0.0;
this->p_c_factor = gr_complex(p_c_factor, 0); this->p_c_factor = gr_complex(p_c_factor, 0.0);
this->length_ = length_; //Set the number of samples per segment this->length_ = length_; // Set the number of samples per segment
filter_state_ = false; //Initial state of the filter filter_state_ = false; // Initial state of the filter
n_deg_fred = 2 * length_; //Number of dregrees of freedom n_deg_fred = 2 * length_; // Number of dregrees of freedom
n_segments = 0; n_segments = 0;
this->n_segments_est = n_segments_est; // Set the number of segments for noise power estimation this->n_segments_est = n_segments_est; // Set the number of segments for noise power estimation
this->n_segments_reset = n_segments_reset; // Set the period (in segments) when the noise power is estimated this->n_segments_reset = n_segments_reset; // Set the period (in segments) when the noise power is estimated
z_0 = gr_complex(0, 0); z_0 = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred); boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
c_samples = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); c_samples = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment()));
angle_ = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment())); angle_ = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment())); power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
last_out = gr_complex(0, 0); last_out = gr_complex(0.0, 0.0);
d_fft = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(length_, true)); d_fft = std::unique_ptr<gr::fft::fft_complex>(new gr::fft::fft_complex(length_, true));
} }
@ -86,7 +86,7 @@ Notch::~Notch()
void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
{ {
for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++)
{ {
ninput_items_required[aux] = length_; ninput_items_required[aux] = length_;
} }
@ -96,7 +96,7 @@ void Notch::forecast(int noutput_items __attribute__((unused)), gr_vector_int &n
int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{ {
int index_out = 0; int32_t index_out = 0;
float sig2dB = 0.0; float sig2dB = 0.0;
float sig2lin = 0.0; float sig2lin = 0.0;
lv_32fc_t dot_prod_; lv_32fc_t dot_prod_;
@ -127,7 +127,7 @@ int Notch::general_work(int noutput_items, gr_vector_int &ninput_items __attribu
} }
volk_32fc_x2_multiply_conjugate_32fc(c_samples, in, (in - 1), length_); volk_32fc_x2_multiply_conjugate_32fc(c_samples, in, (in - 1), length_);
volk_32fc_s32f_atan2_32f(angle_, c_samples, static_cast<float>(1.0), length_); volk_32fc_s32f_atan2_32f(angle_, c_samples, static_cast<float>(1.0), length_);
for (int aux = 0; aux < length_; aux++) for (int32_t aux = 0; aux < length_; aux++)
{ {
z_0 = std::exp(gr_complex(0, 1) * (*(angle_ + aux))); z_0 = std::exp(gr_complex(0, 1) * (*(angle_ + aux)));
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out; *(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;

View File

@ -34,6 +34,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <gnuradio/fft/fft.h> #include <gnuradio/fft/fft.h>
#include <cstdint>
#include <memory> #include <memory>
class Notch; class Notch;
@ -41,7 +42,7 @@ class Notch;
typedef boost::shared_ptr<Notch> notch_sptr; typedef boost::shared_ptr<Notch> notch_sptr;
notch_sptr make_notch_filter(float pfa, float p_c_factor, notch_sptr make_notch_filter(float pfa, float p_c_factor,
int length_, int n_segments_est, int n_segments_reset); int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
/*! /*!
* \brief This class implements a real-time software-defined multi state notch filter * \brief This class implements a real-time software-defined multi state notch filter
@ -53,11 +54,11 @@ private:
float pfa; float pfa;
float noise_pow_est; float noise_pow_est;
float thres_; float thres_;
int length_; int32_t length_;
int n_deg_fred; int32_t n_deg_fred;
unsigned int n_segments; uint32_t n_segments;
unsigned int n_segments_est; uint32_t n_segments_est;
unsigned int n_segments_reset; uint32_t n_segments_reset;
bool filter_state_; bool filter_state_;
gr_complex last_out; gr_complex last_out;
gr_complex z_0; gr_complex z_0;
@ -68,7 +69,7 @@ private:
std::unique_ptr<gr::fft::fft_complex> d_fft; std::unique_ptr<gr::fft::fft_complex> d_fft;
public: public:
Notch(float pfa, float p_c_factor, int length_, int n_segments_est, int n_segments_reset); Notch(float pfa, float p_c_factor, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
~Notch(); ~Notch();

View File

@ -38,7 +38,7 @@
using google::LogMessage; using google::LogMessage;
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff) notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff)
{ {
return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff)); return notch_lite_sptr(new NotchLite(p_c_factor, pfa, length_, n_segments_est, n_segments_reset, n_segments_coeff));
} }
@ -46,17 +46,17 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_,
NotchLite::NotchLite(float p_c_factor, NotchLite::NotchLite(float p_c_factor,
float pfa, float pfa,
int length_, int32_t length_,
int n_segments_est, int32_t n_segments_est,
int n_segments_reset, int32_t n_segments_reset,
int n_segments_coeff) : gr::block("NotchLite", int32_t n_segments_coeff) : gr::block("NotchLite",
gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex))) gr::io_signature::make(1, 1, sizeof(gr_complex)))
{ {
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple)); set_alignment(std::max(1, alignment_multiple));
set_history(2); set_history(2);
this->p_c_factor = gr_complex(p_c_factor, 0); this->p_c_factor = gr_complex(p_c_factor, 0.0);
this->n_segments_est = n_segments_est; this->n_segments_est = n_segments_est;
this->n_segments_reset = n_segments_reset; this->n_segments_reset = n_segments_reset;
this->n_segments_coeff_reset = n_segments_coeff; this->n_segments_coeff_reset = n_segments_coeff;
@ -68,12 +68,12 @@ NotchLite::NotchLite(float p_c_factor,
n_deg_fred = 2 * length_; n_deg_fred = 2 * length_;
noise_pow_est = 0.0; noise_pow_est = 0.0;
filter_state_ = false; filter_state_ = false;
z_0 = gr_complex(0, 0); z_0 = gr_complex(0.0, 0.0);
last_out = gr_complex(0, 0); last_out = gr_complex(0.0, 0.0);
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred); boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
c_samples1 = gr_complex(0, 0); c_samples1 = gr_complex(0.0, 0.0);
c_samples2 = gr_complex(0, 0); c_samples2 = gr_complex(0.0, 0.0);
angle1 = 0.0; angle1 = 0.0;
angle2 = 0.0; angle2 = 0.0;
power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment())); power_spect = static_cast<float *>(volk_malloc(length_ * sizeof(float), volk_get_alignment()));
@ -89,7 +89,7 @@ NotchLite::~NotchLite()
void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
{ {
for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++)
{ {
ninput_items_required[aux] = length_; ninput_items_required[aux] = length_;
} }
@ -99,7 +99,7 @@ void NotchLite::forecast(int noutput_items __attribute__((unused)), gr_vector_in
int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)), int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{ {
int index_out = 0; int32_t index_out = 0;
float sig2dB = 0.0; float sig2dB = 0.0;
float sig2lin = 0.0; float sig2lin = 0.0;
lv_32fc_t dot_prod_; lv_32fc_t dot_prod_;
@ -138,7 +138,7 @@ int NotchLite::general_work(int noutput_items, gr_vector_int &ninput_items __att
float angle_ = (angle1 + angle2) / 2.0; float angle_ = (angle1 + angle2) / 2.0;
z_0 = std::exp(gr_complex(0, 1) * angle_); z_0 = std::exp(gr_complex(0, 1) * angle_);
} }
for (int aux = 0; aux < length_; aux++) for (int32_t aux = 0; aux < length_; aux++)
{ {
*(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out; *(out + aux) = *(in + aux) - z_0 * (*(in + aux - 1)) + p_c_factor * z_0 * last_out;
last_out = *(out + aux); last_out = *(out + aux);

View File

@ -34,13 +34,14 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <gnuradio/fft/fft.h> #include <gnuradio/fft/fft.h>
#include <cstdint>
#include <memory> #include <memory>
class NotchLite; class NotchLite;
typedef boost::shared_ptr<NotchLite> notch_lite_sptr; typedef boost::shared_ptr<NotchLite> notch_lite_sptr;
notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff); notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
/*! /*!
* \brief This class implements a real-time software-defined multi state notch filter light version * \brief This class implements a real-time software-defined multi state notch filter light version
@ -49,13 +50,13 @@ notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_,
class NotchLite : public gr::block class NotchLite : public gr::block
{ {
private: private:
int length_; int32_t length_;
int n_segments; int32_t n_segments;
int n_segments_est; int32_t n_segments_est;
int n_segments_reset; int32_t n_segments_reset;
int n_segments_coeff_reset; int32_t n_segments_coeff_reset;
int n_segments_coeff; int32_t n_segments_coeff;
int n_deg_fred; int32_t n_deg_fred;
float pfa; float pfa;
float thres_; float thres_;
float noise_pow_est; float noise_pow_est;
@ -71,7 +72,7 @@ private:
std::unique_ptr<gr::fft::fft_complex> d_fft; std::unique_ptr<gr::fft::fft_complex> d_fft;
public: public:
NotchLite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff); NotchLite(float p_c_factor, float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff);
~NotchLite(); ~NotchLite();

View File

@ -37,21 +37,21 @@
using google::LogMessage; using google::LogMessage;
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_,
int n_segments_est, int n_segments_reset) int32_t n_segments_est, int32_t n_segments_reset)
{ {
return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset)); return pulse_blanking_cc_sptr(new pulse_blanking_cc(pfa, length_, n_segments_est, n_segments_reset));
} }
pulse_blanking_cc::pulse_blanking_cc(float pfa, pulse_blanking_cc::pulse_blanking_cc(float pfa,
int length_, int32_t length_,
int n_segments_est, int32_t n_segments_est,
int n_segments_reset) : gr::block("pulse_blanking_cc", int32_t n_segments_reset) : gr::block("pulse_blanking_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex))) gr::io_signature::make(1, 1, sizeof(gr_complex)))
{ {
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex); const int32_t alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple)); set_alignment(std::max(1, alignment_multiple));
this->pfa = pfa; this->pfa = pfa;
this->length_ = length_; this->length_ = length_;
@ -64,9 +64,9 @@ pulse_blanking_cc::pulse_blanking_cc(float pfa,
boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred); boost::math::chi_squared_distribution<float> my_dist_(n_deg_fred);
thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa)); thres_ = boost::math::quantile(boost::math::complement(my_dist_, pfa));
zeros_ = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment())); zeros_ = static_cast<gr_complex *>(volk_malloc(length_ * sizeof(gr_complex), volk_get_alignment()));
for (int aux = 0; aux < length_; aux++) for (int32_t aux = 0; aux < length_; aux++)
{ {
zeros_[aux] = gr_complex(0, 0); zeros_[aux] = gr_complex(0.0, 0.0);
} }
} }
@ -79,7 +79,7 @@ pulse_blanking_cc::~pulse_blanking_cc()
void pulse_blanking_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required) void pulse_blanking_cc::forecast(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items_required)
{ {
for (unsigned int aux = 0; aux < ninput_items_required.size(); aux++) for (uint32_t aux = 0; aux < ninput_items_required.size(); aux++)
{ {
ninput_items_required[aux] = length_; ninput_items_required[aux] = length_;
} }
@ -93,7 +93,7 @@ int pulse_blanking_cc::general_work(int noutput_items, gr_vector_int &ninput_ite
gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]); gr_complex *out = reinterpret_cast<gr_complex *>(output_items[0]);
float *magnitude = static_cast<float *>(volk_malloc(noutput_items * sizeof(float), volk_get_alignment())); float *magnitude = static_cast<float *>(volk_malloc(noutput_items * sizeof(float), volk_get_alignment()));
volk_32fc_magnitude_squared_32f(magnitude, in, noutput_items); volk_32fc_magnitude_squared_32f(magnitude, in, noutput_items);
int sample_index = 0; int32_t sample_index = 0;
float segment_energy; float segment_energy;
while ((sample_index + length_) < noutput_items) while ((sample_index + length_) < noutput_items)
{ {

View File

@ -33,22 +33,23 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <gnuradio/block.h> #include <gnuradio/block.h>
#include <cstdint>
class pulse_blanking_cc; class pulse_blanking_cc;
typedef boost::shared_ptr<pulse_blanking_cc> pulse_blanking_cc_sptr; typedef boost::shared_ptr<pulse_blanking_cc> pulse_blanking_cc_sptr;
pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset); pulse_blanking_cc_sptr make_pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
class pulse_blanking_cc : public gr::block class pulse_blanking_cc : public gr::block
{ {
private: private:
int length_; int32_t length_;
int n_segments; int32_t n_segments;
int n_segments_est; int32_t n_segments_est;
int n_segments_reset; int32_t n_segments_reset;
int n_deg_fred; int32_t n_deg_fred;
bool last_filtered; bool last_filtered;
float noise_power_estimation; float noise_power_estimation;
float thres_; float thres_;
@ -56,7 +57,7 @@ private:
gr_complex *zeros_; gr_complex *zeros_;
public: public:
pulse_blanking_cc(float pfa, int length_, int n_segments_est, int n_segments_reset); pulse_blanking_cc(float pfa, int32_t length_, int32_t n_segments_est, int32_t n_segments_reset);
~pulse_blanking_cc(); ~pulse_blanking_cc();

View File

@ -268,7 +268,7 @@ uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset<GALILE
{ {
for (int32_t j = 0; j < parameter[i].second; j++) for (int32_t j = 0; j < parameter[i].second; j++)
{ {
value <<= 1; //shift left value <<= 1; // shift left
if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1) if (bits[GALILEO_DATA_JK_BITS - parameter[i].first - j] == 1)
{ {
value += 1; // insert the bit value += 1; // insert the bit
@ -287,7 +287,7 @@ uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset<GALILEO
{ {
for (int32_t j = 0; j < parameter[i].second; j++) for (int32_t j = 0; j < parameter[i].second; j++)
{ {
value <<= 1; //shift left value <<= 1; // shift left
if (bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j] == 1) if (bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j] == 1)
{ {
value += 1; // insert the bit value += 1; // insert the bit

View File

@ -632,7 +632,7 @@ Gps_Iono Gps_Navigation_Message::get_iono()
iono.d_beta2 = d_beta2; iono.d_beta2 = d_beta2;
iono.d_beta3 = d_beta3; iono.d_beta3 = d_beta3;
iono.valid = flag_iono_valid; iono.valid = flag_iono_valid;
//WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue // WARNING: We clear flag_utc_model_valid in order to not re-send the same information to the ionospheric parameters queue
flag_iono_valid = false; flag_iono_valid = false;
return iono; return iono;
} }