diff --git a/resources/news.txt b/resources/news.txt index e6f987de2..161b30d70 100644 --- a/resources/news.txt +++ b/resources/news.txt @@ -10,6 +10,7 @@ FIXED: Aliasing when input rate is higher than 2 Msps. IMPROVED: AGC performance. IMPROVED: WFM stereo & OIRT performance. + IMPROVED: I/Q swap performance. IMPROVED: Apply amplitude normalization to FFT window functions. diff --git a/src/dsp/correct_iq_cc.cpp b/src/dsp/correct_iq_cc.cpp index 70eeb0d5d..bf7d13ec2 100644 --- a/src/dsp/correct_iq_cc.cpp +++ b/src/dsp/correct_iq_cc.cpp @@ -93,26 +93,11 @@ iq_swap_cc_sptr make_iq_swap_cc(bool enabled) } iq_swap_cc::iq_swap_cc(bool enabled) - : gr::hier_block2 ("iq_swap_cc", + : gr::sync_block ("iq_swap_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(gr_complex))) { d_enabled = enabled; - d_c2f = gr::blocks::complex_to_float::make(); - d_f2c = gr::blocks::float_to_complex::make(); - - connect(self(), 0, d_c2f, 0); - if (enabled) - { - connect(d_c2f, 0, d_f2c, 1); - connect(d_c2f, 1, d_f2c, 0); - } - else - { - connect(d_c2f, 0, d_f2c, 0); - connect(d_c2f, 1, d_f2c, 1); - } - connect(d_f2c, 0, self(), 0); } iq_swap_cc::~iq_swap_cc() @@ -129,39 +114,28 @@ void iq_swap_cc::set_enabled(bool enabled) qDebug() << "IQ swap:" << enabled; d_enabled = enabled; +} - lock(); - if (d_enabled) - { - disconnect(d_c2f, 0, d_f2c, 0); - disconnect(d_c2f, 1, d_f2c, 1); - connect(d_c2f, 0, d_f2c, 1); - connect(d_c2f, 1, d_f2c, 0); - } - else - { - disconnect(d_c2f, 0, d_f2c, 1); - disconnect(d_c2f, 1, d_f2c, 0); - connect(d_c2f, 0, d_f2c, 0); - connect(d_c2f, 1, d_f2c, 1); - } +int iq_swap_cc::work(int noutput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items) +{ + const float *in = (const float *)input_items[0]; + float *out = (float *)output_items[0]; -/** DEBUG **/ -/** disconnect_all() does not work here **/ -/* - disconnect_all(); - connect(self(), 0, d_c2f, 0); - if (enabled) + if (d_enabled) { - connect(d_c2f, 0, d_f2c, 1); - connect(d_c2f, 1, d_f2c, 0); + for (int i = 0; i < noutput_items; ++i) + { + out[1] = in[0]; + out[0] = in[1]; + in += 2; + out += 2; + } } else { - connect(d_c2f, 0, d_f2c, 0); - connect(d_c2f, 1, d_f2c, 1); + memcpy(out, in, noutput_items * sizeof(gr_complex)); } - connect(d_f2c, 0, self(), 0); -*/ - unlock(); + return noutput_items; } diff --git a/src/dsp/correct_iq_cc.h b/src/dsp/correct_iq_cc.h index 1bb7268a2..230799205 100644 --- a/src/dsp/correct_iq_cc.h +++ b/src/dsp/correct_iq_cc.h @@ -87,7 +87,7 @@ iq_swap_cc_sptr make_iq_swap_cc(bool enabled); /*! \brief Block to swap I and Q channels. * \ingroup DSP */ -class iq_swap_cc : public gr::hier_block2 +class iq_swap_cc : public gr::sync_block { friend iq_swap_cc_sptr make_iq_swap_cc(bool enabled); @@ -97,10 +97,11 @@ class iq_swap_cc : public gr::hier_block2 public: ~iq_swap_cc(); void set_enabled(bool enabled); + int work(int noutput_items, + gr_vector_const_void_star& input_items, + gr_vector_void_star& output_items); private: - gr::blocks::complex_to_float::sptr d_c2f; - gr::blocks::float_to_complex::sptr d_f2c; bool d_enabled; };