From df2d8a88aad052fcdccb163bc48698eaf9610a4d Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 14 Sep 2014 19:36:39 +0200 Subject: [PATCH] Changing C-style cast by C++ static_cast --- .../gnuradio_blocks/direct_resampler_conditioner_cc.cc | 9 ++++----- .../gnuradio_blocks/direct_resampler_conditioner_ss.cc | 10 ++++------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc index ef65744c9..a711456e9 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_cc.cc @@ -60,15 +60,14 @@ direct_resampler_conditioner_cc::direct_resampler_conditioner_cc( d_history(1) { // Computes the phase step multiplying the resampling ratio by 2^32 = 4294967296 + const double two_32 = 4294967296.0; if (d_sample_freq_in >= d_sample_freq_out) { - d_phase_step = (unsigned int)floor((double)4294967296.0 - * sample_freq_out / sample_freq_in); + d_phase_step = static_cast(floor(two_32 * sample_freq_out / sample_freq_in)); } else { - d_phase_step = (unsigned int)floor((double)4294967296.0 - * sample_freq_in / sample_freq_out); + d_phase_step = static_cast(floor(two_32 * sample_freq_in / sample_freq_out)); } set_relative_rate(1.0 * sample_freq_out / sample_freq_in); set_output_multiple(1); @@ -87,7 +86,7 @@ direct_resampler_conditioner_cc::~direct_resampler_conditioner_cc() void direct_resampler_conditioner_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) { - int nreqd = std::max((unsigned)1, (int)((double)(noutput_items + 1) + int nreqd = std::max(static_cast(1), static_cast(static_cast(noutput_items + 1) * sample_freq_in() / sample_freq_out()) + history() - 1); unsigned ninputs = ninput_items_required.size(); for (unsigned i = 0; i < ninputs; i++) diff --git a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_ss.cc b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_ss.cc index ec66362c3..96cccd853 100644 --- a/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_ss.cc +++ b/src/algorithms/resampler/gnuradio_blocks/direct_resampler_conditioner_ss.cc @@ -58,17 +58,15 @@ direct_resampler_conditioner_ss::direct_resampler_conditioner_ss( d_sample_freq_in(sample_freq_in), d_sample_freq_out( sample_freq_out), d_phase(0), d_lphase(0), d_history(1) { - + const double two_32 = 4294967296.0; // Computes the phase step multiplying the resampling ratio by 2^32 = 4294967296 if (d_sample_freq_in >= d_sample_freq_out) { - d_phase_step = (unsigned int)floor((double)4294967296.0 - * sample_freq_out / sample_freq_in); + d_phase_step = static_cast(floor(two_32 * sample_freq_out / sample_freq_in)); } else { - d_phase_step = (unsigned int)floor((double)4294967296.0 - * sample_freq_in / sample_freq_out); + d_phase_step = static_cast(floor(two_32 * sample_freq_in / sample_freq_out)); } set_relative_rate(1.0 * sample_freq_out / sample_freq_in); @@ -84,7 +82,7 @@ void direct_resampler_conditioner_ss::forecast(int noutput_items, gr_vector_int &ninput_items_required) { - int nreqd = std::max((unsigned)1, (int)((double)(noutput_items + 1) + int nreqd = std::max(static_cast(1), (int)(static_cast(noutput_items + 1) * sample_freq_in() / sample_freq_out()) + history() - 1); unsigned ninputs = ninput_items_required.size();