Merge pull request #1206 from willcode/fix/iq-swap-hog

iq_swap_cc: implement directly instead of as a hier block
This commit is contained in:
Clayton Smith 2023-04-13 00:28:45 -04:00 committed by GitHub
commit 660ee91cd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 47 deletions

View File

@ -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.

View File

@ -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;
}
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];
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);
for (int i = 0; i < noutput_items; ++i)
{
out[1] = in[0];
out[0] = in[1];
in += 2;
out += 2;
}
}
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);
memcpy(out, in, noutput_items * sizeof(gr_complex));
}
/** DEBUG **/
/** disconnect_all() does not work here **/
/*
disconnect_all();
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);
*/
unlock();
return noutput_items;
}

View File

@ -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 @@ protected:
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;
};