mirror of
https://github.com/gqrx-sdr/gqrx.git
synced 2024-09-21 10:47:10 +00:00
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:
commit
660ee91cd8
@ -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.
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user