diff --git a/Readme.md b/Readme.md
index 24f799cb3..47440c434 100644
--- a/Readme.md
+++ b/Readme.md
@@ -22,6 +22,24 @@ These plugins come from the parent code base and are still present in the source
- osmosdr
- v4l-msi
- v4l-rtl
+
+
Gnuradio
+
+The Gnuradio plugin source needs extra packages, including `liblog4cpp-dev libboost-system-dev gnuradio-dev libosmosdr-dev`
+
+If you use your own location for Gnuradio install directory you need to specify library and include locations. Example with `/opt/install/gnuradio-3.7.5.1` with the following defines on `cmake` command line:
+
+`-DGNURADIO_RUNTIME_LIBRARIES=/opt/install/gnuradio-3.7.5.1/lib/libgnuradio-runtime.so -DGNURADIO_RUNTIME_INCLUDE_DIRS=/opt/install/gnuradio-3.7.5.1/include`
+
+osmosdr
+
+If you use your own location for gr.osmocom install directory you need to specify library and include locations. Example with `/opt/install/gr-osmosdr` with the following defines on `cmake` command line:
+
+`-DGNURADIO_OSMOSDR_LIBRARIES=/opt/install/gr-osmosdr/lib/libgnuradio-osmosdr.so -DGNURADIO_OSMOSDR_INCLUDE_DIRS=/opt/install/gr-osmosdr/include`
+
+v4l-*
+
+Use `cmake ../ -DV4L-RTL=ON` to build the Linux kernel driver for RTL-SDR (Experimental). Needs a recent kernel and libv4l2. Will need extra work to support SDRPlay. Needs `cp KERNEL_SOURCE/include/linux/compiler.h /usr/include/linux/` and `cp KERNEL_SOURCE/include/uapi/linux/videodev2.h /usr/include/uapi/linux/` and package `libv4l-dev`.
Supported hardware
@@ -57,22 +75,6 @@ If you use your own location for librtlsdr install directory you need to specify
`librtlsdr-dev` is in the `universe` repo. (utopic 14.10 amd64.)
-Use `cmake ../ -DV4L-RTL=ON` to build the Linux kernel driver for RTL-SDR (Experimental). Needs a recent kernel and libv4l2. Will need extra work to support SDRPlay. Needs `cp KERNEL_SOURCE/include/linux/compiler.h /usr/include/linux/` and `cp KERNEL_SOURCE/include/uapi/linux/videodev2.h /usr/include/uapi/linux/` and package `libv4l-dev`.
-
-The Gnuradio plugin source needs extra packages, including `liblog4cpp-dev libboost-system-dev gnuradio-dev libosmosdr-dev`
-
-For non standard installations of RTL-SDR library, the GNU Radio runtime and gr.osmocom drivers use the following variables in the cmake command line. The paths specified are just examples:
-
- - For GNU Radio runtime:
- - Includes: `-DGNURADIO_RUNTIME_INCLUDE_DIRS=/opt/install/gnuradio-3.7.5.1/include`
- - Library: `-DGNURADIO_RUNTIME_LIBRARIES=/opt/install/gnuradio-3.7.5.1/lib/libgnuradio-runtime.so`
- - For gr.osmocom:
- - Includes: `-DGNURADIO_OSMOSDR_INCLUDE_DIRS=/opt/install/gr-osmosdr/include`
- - Library: `-DGNURADIO_OSMOSDR_LIBRARIES=/opt/install/gr-osmosdr/lib/libgnuradio-osmosdr.so`
- - For RTL-SDR library:
- - Includes: `-DLIBRTLSDR_INCLUDE_DIR=/opt/install/rtlsdr/include`
- - Library: `-DLIBRTLSDR_LIBRARIES=/opt/install/rtlsdr/lib/librtlsdr.so`
-
There is no installation procedure the executable is at the root of the build directory
For Debian
@@ -87,8 +89,6 @@ Assuming Debian Jessie is used:
`mkdir build && cd build && cmake ../ && make`
-Then the same remarks as for Ubuntu apply...
-
Known Issues
- You will need to stop input before changing preset then start again
@@ -147,6 +147,7 @@ Then the same remarks as for Ubuntu apply...
- Message queuing and handling redesign. Still not completely satisfactory
- Objects have their own input and output message queues
- Dedicated message queue to communicate to the GUI for objects coupled with a GUI
+ - Optimizations with Valgrind cachegrind
- Many other little things...
To Do
diff --git a/include-gpl/dsp/bandpass.h b/include-gpl/dsp/bandpass.h
index 844efc365..3e0ffb147 100644
--- a/include-gpl/dsp/bandpass.h
+++ b/include-gpl/dsp/bandpass.h
@@ -76,32 +76,33 @@ public:
Type acc = 0;
int a = m_ptr;
int b = a - 1;
- int i, size;
+ int i, n_taps, size;
m_samples[m_ptr] = sample;
+ size = m_samples.size(); // Valgrind optim (2)
while(b < 0)
{
- b += m_samples.size();
+ b += size;
}
- size = (int) m_taps.size() - 1; // Valgrind optim
+ n_taps = m_taps.size() - 1; // Valgrind optim
- for(i = 0; i < size; i++)
+ for(i = 0; i < n_taps; i++)
{
acc += (m_samples[a] + m_samples[b]) * m_taps[i];
a++;
- while(a >= (int)m_samples.size())
+ while (a >= size)
{
- a -= m_samples.size();
+ a -= size;
}
b--;
while(b < 0)
{
- b += m_samples.size();
+ b += size;
}
}
@@ -109,9 +110,9 @@ public:
m_ptr++;
- while(m_ptr >= (int)m_samples.size())
+ while (m_ptr >= size)
{
- m_ptr -= m_samples.size();
+ m_ptr -= size;
}
return acc;
diff --git a/include-gpl/dsp/decimators.h b/include-gpl/dsp/decimators.h
index 7fdda91fe..048b18c24 100644
--- a/include-gpl/dsp/decimators.h
+++ b/include-gpl/dsp/decimators.h
@@ -58,9 +58,11 @@ void Decimators::decimate1(SampleVector::iterator* it, const T* buf, qint32 l
for (int pos = 0; pos < len; pos += 2) {
xreal = buf[pos+0];
yimag = buf[pos+1];
- Sample s( xreal * 16, yimag * 16 ); // shift by 4 bit positions (signed)
- **it = s;
- (*it)++;
+ (**it).setReal(xreal * 16); // Valgrind optim (2 - comment not repeated)
+ (**it).setImag(yimag * 16);
+ //Sample s( xreal * 16, yimag * 16 ); // shift by 4 bit positions (signed)
+ //**it = s;
+ ++(*it); // Valgrind optim (comment not repeated)
}
}
@@ -68,17 +70,23 @@ template
void Decimators::decimate2_u(SampleVector::iterator* it, const T* buf, qint32 len)
{
qint16 xreal, yimag;
- for (int pos = 0; pos < len - 7; pos += 8) {
+
+ for (int pos = 0; pos < len - 7; pos += 8)
+ {
xreal = buf[pos+0] - buf[pos+3];
yimag = buf[pos+1] + buf[pos+2] - 255;
- Sample s( xreal << 3, yimag << 3 );
- **it = s;
- (*it)++;
+ //Sample s( xreal << 3, yimag << 3 );
+ //**it = s;
+ (**it).setReal(xreal << 3);
+ (**it).setImag(yimag << 3);
+ ++(*it);
xreal = buf[pos+7] - buf[pos+4];
yimag = 255 - buf[pos+5] - buf[pos+6];
- Sample t( xreal << 3, yimag << 3 );
- **it = t;
- (*it)++;
+ //Sample t( xreal << 3, yimag << 3 );
+ //**it = t;
+ (**it).setReal(xreal << 3);
+ (**it).setImag(yimag << 3);
+ ++(*it);
}
}
@@ -86,17 +94,23 @@ template
void Decimators::decimate2(SampleVector::iterator* it, const T* buf, qint32 len)
{
qint16 xreal, yimag;
- for (int pos = 0; pos < len - 7; pos += 8) {
+
+ for (int pos = 0; pos < len - 7; pos += 8)
+ {
xreal = buf[pos+0] - buf[pos+3];
yimag = buf[pos+1] + buf[pos+2];
- Sample s( xreal << 3, yimag << 3 );
- **it = s;
- (*it)++;
+ //Sample s( xreal << 3, yimag << 3 );
+ //**it = s;
+ (**it).setReal(xreal << 3);
+ (**it).setImag(yimag << 3);
+ ++(*it);
xreal = buf[pos+7] - buf[pos+4];
yimag = - buf[pos+5] - buf[pos+6];
- Sample t( xreal << 3, yimag << 3 );
- **it = t;
- (*it)++;
+ //Sample t( xreal << 3, yimag << 3 );
+ //**it = t;
+ (**it).setReal(xreal << 3);
+ (**it).setImag(yimag << 3);
+ ++(*it);
}
}
@@ -104,192 +118,255 @@ template
void Decimators::decimate2_sup(SampleVector::iterator* it, const T* buf, qint32 len)
{
qint16 xreal, yimag;
- for (int pos = 0; pos < len - 7; pos += 8) {
+
+ for (int pos = 0; pos < len - 7; pos += 8)
+ {
xreal = buf[pos+1] - buf[pos+2];
yimag = - buf[pos+0] - buf[pos+3];
- Sample s( xreal << 3, yimag << 3 );
- **it = s;
- (*it)++;
+ //Sample s( xreal << 3, yimag << 3 );
+ //**it = s;
+ (**it).setReal(xreal << 3);
+ (**it).setImag(yimag << 3);
+ ++(*it);
xreal = buf[pos+6] - buf[pos+5];
yimag = buf[pos+4] + buf[pos+7];
- Sample t( xreal << 3, yimag << 3 );
- **it = t;
- (*it)++;
+ //Sample t( xreal << 3, yimag << 3 );
+ //**it = t;
+ (**it).setReal(xreal << 3);
+ (**it).setImag(yimag << 3);
+ ++(*it);
}
}
+/*
+template
+void Decimators::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len)
+{
+ int pos = 0;
+
+ while (pos < len - 3)
+ {
+ Sample s0(buf[pos+0] << 3, buf[pos+1] << 3);
+ pos += 2;
+
+ if (m_decimator2.workDecimateCenter(&s0))
+ {
+ **it = s0;
+ ++(*it);
+ }
+ }
+}*/
+
template
void Decimators::decimate2_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
- for (int pos = 0; pos < len - 3; pos += 4) {
- Sample s1(buf[pos+0] << 3, buf[pos+1] << 3);
- Sample s2(buf[pos+2] << 3, buf[pos+3] << 3);
- m_decimator2.myDecimate(&s1, &s2);
- **it = s2;
- (*it)++;
+ int pos = 0;
+
+ while (pos < len - 3)
+ {
+ qint16 x0 = buf[pos+0] << 3;
+ qint16 y0 = buf[pos+1] << 3;
+ pos += 2;
+
+ if (m_decimator2.workDecimateCenter(&x0, &y0))
+ {
+ (**it).setReal(x0);
+ (**it).setImag(y0);
+ ++(*it);
+ }
}
}
+/*
+template
+void Decimators::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len)
+{
+ int pos = 0;
+
+ while (pos < len)
+ {
+ Sample s0(buf[pos+0] << 4, buf[pos+1] << 4);
+ pos += 2;
+
+ if (m_decimator2.workDecimateCenter(&s0))
+ {
+ Sample s1 = s0;
+
+ if (m_decimator4.workDecimateCenter(&s1))
+ {
+ (**it) = s1;
+ ++(*it);
+ }
+ }
+ }
+}*/
+
template
void Decimators::decimate4_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
- for (int pos = 0; pos < len - 7; pos += 8) {
- Sample s1(buf[pos+0] << 4, buf[pos+1] << 4);
- Sample s2(buf[pos+2] << 4, buf[pos+3] << 4);
- Sample s3(buf[pos+4] << 4, buf[pos+5] << 4);
- Sample s4(buf[pos+6] << 4, buf[pos+7] << 4);
- m_decimator2.myDecimate(&s1, &s2);
- m_decimator2.myDecimate(&s3, &s4);
- m_decimator4.myDecimate(&s2, &s4);
- **it = s4;
- (*it)++;
+ int pos = 0;
+
+ while (pos < len)
+ {
+ qint16 x0 = buf[pos+0] << 3;
+ qint16 y0 = buf[pos+1] << 3;
+ pos += 2;
+
+ if (m_decimator2.workDecimateCenter(&x0, &y0))
+ {
+ qint16 x1 = x0;
+ qint16 y1 = y0;
+
+ if (m_decimator4.workDecimateCenter(&x1, &y1))
+ {
+ (**it).setReal(x0);
+ (**it).setImag(y0);
+ ++(*it);
+ }
+ }
}
}
template
void Decimators::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
- for (int pos = 0; pos < len - 15; pos += 16) {
- Sample s1(buf[pos+0] << 4, buf[pos+1] << 4);
- Sample s2(buf[pos+2] << 4, buf[pos+3] << 4);
- Sample s3(buf[pos+4] << 4, buf[pos+5] << 4);
- Sample s4(buf[pos+6] << 4, buf[pos+7] << 4);
- Sample s5(buf[pos+8] << 4, buf[pos+9] << 4);
- Sample s6(buf[pos+10] << 4, buf[pos+11] << 4);
- Sample s7(buf[pos+12] << 4, buf[pos+13] << 4);
- Sample s8(buf[pos+14] << 4, buf[pos+15] << 4);
- m_decimator2.myDecimate(&s1, &s2);
- m_decimator2.myDecimate(&s3, &s4);
- m_decimator2.myDecimate(&s5, &s6);
- m_decimator2.myDecimate(&s7, &s8);
- m_decimator4.myDecimate(&s2, &s4);
- m_decimator4.myDecimate(&s6, &s8);
- m_decimator8.myDecimate(&s4, &s8);
- **it = s8;
- (*it)++;
+ int pos = 0;
+
+ while (pos < len)
+ {
+ qint16 x0 = buf[pos+0] << 4;
+ qint16 y0 = buf[pos+1] << 4;
+ pos += 2;
+
+ if (m_decimator2.workDecimateCenter(&x0, &y0))
+ {
+ qint16 x1 = x0;
+ qint16 y1 = y0;
+
+ if (m_decimator4.workDecimateCenter(&x1, &y1))
+ {
+ qint16 x2 = x1;
+ qint16 y2 = y1;
+
+ if (m_decimator8.workDecimateCenter(&x2, &y2))
+ {
+ (**it).setReal(x2);
+ (**it).setImag(y2);
+ ++(*it);
+ }
+ }
+ }
}
}
+/*
+template
+void Decimators::decimate8_cen(SampleVector::iterator* it, const T* buf, qint32 len)
+{
+ int pos = 0;
+
+ while (pos < len)
+ {
+ Sample s0(buf[pos+0] << 4, buf[pos+1] << 4);
+ pos += 2;
+
+ if (m_decimator2.workDecimateCenter(&s0))
+ {
+ Sample s1 = s0;
+
+ if (m_decimator4.workDecimateCenter(&s1))
+ {
+ Sample s2 = s1;
+
+ if (m_decimator8.workDecimateCenter(&s2))
+ {
+ (**it) = s2;
+ ++(*it);
+ }
+ }
+ }
+ }
+}*/
+
template
void Decimators::decimate16_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
- for (int pos = 0; pos < len - 31; pos += 32) {
- Sample s1(buf[pos+0] << 4, buf[pos+1] << 4);
- Sample s2(buf[pos+2] << 4, buf[pos+3] << 4);
- Sample s3(buf[pos+4] << 4, buf[pos+5] << 4);
- Sample s4(buf[pos+6] << 4, buf[pos+7] << 4);
- Sample s5(buf[pos+8] << 4, buf[pos+9] << 4);
- Sample s6(buf[pos+10] << 4, buf[pos+11] << 4);
- Sample s7(buf[pos+12] << 4, buf[pos+13] << 4);
- Sample s8(buf[pos+14] << 4, buf[pos+15] << 4);
- Sample s9(buf[pos+16] << 4, buf[pos+17] << 4);
- Sample s10(buf[pos+18] << 4, buf[pos+19] << 4);
- Sample s11(buf[pos+20] << 4, buf[pos+21] << 4);
- Sample s12(buf[pos+22] << 4, buf[pos+23] << 4);
- Sample s13(buf[pos+24] << 4, buf[pos+25] << 4);
- Sample s14(buf[pos+26] << 4, buf[pos+27] << 4);
- Sample s15(buf[pos+28] << 4, buf[pos+29] << 4);
- Sample s16(buf[pos+30] << 4, buf[pos+31] << 4);
+ int pos = 0;
- m_decimator2.myDecimate(&s1, &s2);
- m_decimator2.myDecimate(&s3, &s4);
- m_decimator2.myDecimate(&s5, &s6);
- m_decimator2.myDecimate(&s7, &s8);
- m_decimator2.myDecimate(&s9, &s10);
- m_decimator2.myDecimate(&s11, &s12);
- m_decimator2.myDecimate(&s13, &s14);
- m_decimator2.myDecimate(&s15, &s16);
+ while (pos < len)
+ {
+ qint16 x0 = buf[pos+0] << 4;
+ qint16 y0 = buf[pos+1] << 4;
+ pos += 2;
- m_decimator4.myDecimate(&s2, &s4);
- m_decimator4.myDecimate(&s6, &s8);
- m_decimator4.myDecimate(&s10, &s12);
- m_decimator4.myDecimate(&s14, &s16);
+ if (m_decimator2.workDecimateCenter(&x0, &y0))
+ {
+ qint16 x1 = x0;
+ qint16 y1 = y0;
- m_decimator8.myDecimate(&s4, &s8);
- m_decimator8.myDecimate(&s12, &s16);
+ if (m_decimator4.workDecimateCenter(&x1, &y1))
+ {
+ qint16 x2 = x1;
+ qint16 y2 = y1;
- m_decimator16.myDecimate(&s8, &s16);
+ if (m_decimator8.workDecimateCenter(&x2, &y2))
+ {
+ qint16 x3 = x2;
+ qint16 y3 = y2;
- **it = s16;
- (*it)++;
+ if (m_decimator16.workDecimateCenter(&x3, &y3))
+ {
+ (**it).setReal(x3);
+ (**it).setImag(y3);
+ ++(*it);
+ }
+ }
+ }
+ }
}
}
template
void Decimators::decimate32_cen(SampleVector::iterator* it, const T* buf, qint32 len)
{
- for (int pos = 0; pos < len - 63; pos += 64) {
- Sample s1(buf[pos+0] << 4, buf[pos+1] << 4);
- Sample s2(buf[pos+2] << 4, buf[pos+3] << 4);
- Sample s3(buf[pos+4] << 4, buf[pos+5] << 4);
- Sample s4(buf[pos+6] << 4, buf[pos+7] << 4);
- Sample s5(buf[pos+8] << 4, buf[pos+9] << 4);
- Sample s6(buf[pos+10] << 4, buf[pos+11] << 4);
- Sample s7(buf[pos+12] << 4, buf[pos+13] << 4);
- Sample s8(buf[pos+14] << 4, buf[pos+15] << 4);
- Sample s9(buf[pos+16] << 4, buf[pos+17] << 4);
- Sample s10(buf[pos+18] << 4, buf[pos+19] << 4);
- Sample s11(buf[pos+20] << 4, buf[pos+21] << 4);
- Sample s12(buf[pos+22] << 4, buf[pos+23] << 4);
- Sample s13(buf[pos+24] << 4, buf[pos+25] << 4);
- Sample s14(buf[pos+26] << 4, buf[pos+27] << 4);
- Sample s15(buf[pos+28] << 4, buf[pos+29] << 4);
- Sample s16(buf[pos+30] << 4, buf[pos+31] << 4);
- Sample s17(buf[pos+32] << 4, buf[pos+33] << 4);
- Sample s18(buf[pos+34] << 4, buf[pos+35] << 4);
- Sample s19(buf[pos+36] << 4, buf[pos+37] << 4);
- Sample s20(buf[pos+38] << 4, buf[pos+39] << 4);
- Sample s21(buf[pos+40] << 4, buf[pos+41] << 4);
- Sample s22(buf[pos+42] << 4, buf[pos+43] << 4);
- Sample s23(buf[pos+44] << 4, buf[pos+45] << 4);
- Sample s24(buf[pos+46] << 4, buf[pos+47] << 4);
- Sample s25(buf[pos+48] << 4, buf[pos+49] << 4);
- Sample s26(buf[pos+50] << 4, buf[pos+51] << 4);
- Sample s27(buf[pos+52] << 4, buf[pos+53] << 4);
- Sample s28(buf[pos+54] << 4, buf[pos+55] << 4);
- Sample s29(buf[pos+56] << 4, buf[pos+57] << 4);
- Sample s30(buf[pos+58] << 4, buf[pos+59] << 4);
- Sample s31(buf[pos+60] << 4, buf[pos+61] << 4);
- Sample s32(buf[pos+62] << 4, buf[pos+63] << 4);
+ int pos = 0;
- m_decimator2.myDecimate(&s1, &s2);
- m_decimator2.myDecimate(&s3, &s4);
- m_decimator2.myDecimate(&s5, &s6);
- m_decimator2.myDecimate(&s7, &s8);
- m_decimator2.myDecimate(&s9, &s10);
- m_decimator2.myDecimate(&s11, &s12);
- m_decimator2.myDecimate(&s13, &s14);
- m_decimator2.myDecimate(&s15, &s16);
- m_decimator2.myDecimate(&s17, &s18);
- m_decimator2.myDecimate(&s19, &s20);
- m_decimator2.myDecimate(&s21, &s22);
- m_decimator2.myDecimate(&s23, &s24);
- m_decimator2.myDecimate(&s25, &s26);
- m_decimator2.myDecimate(&s27, &s28);
- m_decimator2.myDecimate(&s29, &s30);
- m_decimator2.myDecimate(&s31, &s32);
+ while (pos < len)
+ {
+ qint16 x0 = buf[pos+0] << 4;
+ qint16 y0 = buf[pos+1] << 4;
+ pos += 2;
- m_decimator4.myDecimate(&s2, &s4);
- m_decimator4.myDecimate(&s6, &s8);
- m_decimator4.myDecimate(&s10, &s12);
- m_decimator4.myDecimate(&s14, &s16);
- m_decimator4.myDecimate(&s18, &s20);
- m_decimator4.myDecimate(&s22, &s24);
- m_decimator4.myDecimate(&s26, &s28);
- m_decimator4.myDecimate(&s30, &s32);
+ if (m_decimator2.workDecimateCenter(&x0, &y0))
+ {
+ qint16 x1 = x0;
+ qint16 y1 = y0;
- m_decimator8.myDecimate(&s4, &s8);
- m_decimator8.myDecimate(&s12, &s16);
- m_decimator8.myDecimate(&s20, &s24);
- m_decimator8.myDecimate(&s28, &s32);
+ if (m_decimator4.workDecimateCenter(&x1, &y1))
+ {
+ qint16 x2 = x1;
+ qint16 y2 = y1;
- m_decimator16.myDecimate(&s8, &s16);
- m_decimator16.myDecimate(&s24, &s32);
+ if (m_decimator8.workDecimateCenter(&x2, &y2))
+ {
+ qint16 x3 = x2;
+ qint16 y3 = y2;
- m_decimator32.myDecimate(&s16, &s32);
+ if (m_decimator16.workDecimateCenter(&x3, &y3))
+ {
+ qint16 x4 = x3;
+ qint16 y4 = y3;
- **it = s32;
- (*it)++;
+ if (m_decimator32.workDecimateCenter(&x4, &y4))
+ {
+ (**it).setReal(x4);
+ (**it).setImag(y4);
+ ++(*it);
+ }
+ }
+ }
+ }
+ }
}
}
@@ -297,12 +374,18 @@ template
void Decimators::decimate4(SampleVector::iterator* it, const T* buf, qint32 len)
{
qint16 xreal, yimag;
- for (int pos = 0; pos < len - 7; pos += 8) {
+
+ for (int pos = 0; pos < len - 7; pos += 8)
+ {
xreal = buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4];
yimag = buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6];
+
+ (**it).setReal(xreal << 2);
+ (**it).setImag(yimag << 2);
+ /*
Sample s( xreal << 2, yimag << 2 ); // was shift 3
- **it = s;
- (*it)++;
+ **it = s;*/
+ ++(*it);
}
}
@@ -316,52 +399,72 @@ void Decimators::decimate4_sup(SampleVector::iterator* it, const T* buf, qint
// x y x y x y x y / x -> 0,-3,-4,7 / y -> 1,2,-5,-6
// [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
qint16 xreal, yimag;
- for (int pos = 0; pos < len - 7; pos += 8) {
+
+ for (int pos = 0; pos < len - 7; pos += 8)
+ {
xreal = buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6];
yimag = - buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7];
//xreal = buf[pos+0] - buf[pos+3] - buf[pos+4] + buf[pos+7];
//yimag = buf[pos+1] + buf[pos+2] - buf[pos+5] - buf[pos+6];
+
+ (**it).setReal(xreal << 2);
+ (**it).setImag(yimag << 2);
+ /*
Sample s( xreal << 2, yimag << 2 ); // was shift 3
- **it = s;
- (*it)++;
+ **it = s;*/
+ ++(*it);
}
}
template
void Decimators::decimate8(SampleVector::iterator* it, const T* buf, qint32 len)
{
- qint16 xreal, yimag;
- for (int pos = 0; pos < len - 15; pos += 8) {
- xreal = buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4];
- yimag = buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6];
- Sample s1( xreal << 2, yimag << 2 ); // was shift 3
- pos += 8;
- xreal = buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4];
- yimag = buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6];
- Sample s2( xreal << 2, yimag << 2 ); // was shift 3
+ qint16 xreal[2], yimag[2];
+ for (int pos = 0; pos < len - 15; pos += 8)
+ {
+ xreal[0] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]) << 2;
+ yimag[0] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]) << 2;
+ //Sample s1( xreal << 2, yimag << 2 ); // was shift 3
+ pos += 8;
+ xreal[1] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]) << 2;
+ yimag[1] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]) << 2;
+ //Sample s2( xreal << 2, yimag << 2 ); // was shift 3
+
+ m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]);
+
+ (**it).setReal(xreal[1]);
+ (**it).setImag(yimag[1]);
+ /*
m_decimator2.myDecimate(&s1, &s2);
- **it = s2;
- (*it)++;
+ **it = s2;*/
+ ++(*it);
}
}
template
void Decimators::decimate8_sup(SampleVector::iterator* it, const T* buf, qint32 len)
{
- qint16 xreal, yimag;
- for (int pos = 0; pos < len - 15; pos += 8) {
- xreal = buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6];
- yimag = - buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7];
- Sample s1( xreal << 2, yimag << 2 ); // was shift 3
- pos += 8;
- xreal = buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6];
- yimag = - buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7];
- Sample s2( xreal << 2, yimag << 2 ); // was shift 3
+ qint16 xreal[2], yimag[2];
+ for (int pos = 0; pos < len - 15; pos += 8)
+ {
+ xreal[0] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]) << 2;
+ yimag[0] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]) << 2;
+ //Sample s1( xreal << 2, yimag << 2 ); // was shift 3
+ pos += 8;
+ xreal[1] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]) << 2;
+ yimag[1] = (- buf[pos+0] - buf[pos+3] + buf[pos+4] + buf[pos+7]) << 2;
+ //Sample s2( xreal << 2, yimag << 2 ); // was shift 3
+
+ m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]);
+
+ (**it).setReal(xreal[1]);
+ (**it).setImag(yimag[1]);
+ /*
m_decimator2.myDecimate(&s1, &s2);
- **it = s2;
- (*it)++;
+ **it = s2;*/
+ ++(*it);
}
}
@@ -372,13 +475,23 @@ void Decimators::decimate16(SampleVector::iterator* it, const T* buf, qint32
// downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
qint16 xreal[4], yimag[4];
- for (int pos = 0; pos < len - 31; ) {
- for (int i = 0; i < 4; i++) {
+ for (int pos = 0; pos < len - 31; )
+ {
+ for (int i = 0; i < 4; i++)
+ {
xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]) << 2; // was shift 4
yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]) << 2; // was shift 4
pos += 8;
}
+ m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]);
+ m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]);
+ m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]);
+
+ (**it).setReal(xreal[3]);
+ (**it).setImag(yimag[3]);
+
+ /* Valgrind optim
Sample s1( xreal[0], yimag[0] );
Sample s2( xreal[1], yimag[1] );
Sample s3( xreal[2], yimag[2] );
@@ -389,8 +502,8 @@ void Decimators::decimate16(SampleVector::iterator* it, const T* buf, qint32
m_decimator4.myDecimate(&s2, &s4);
- **it = s4;
- (*it)++;
+ **it = s4;*/
+ ++(*it);
}
}
@@ -401,13 +514,23 @@ void Decimators::decimate16_sup(SampleVector::iterator* it, const T* buf, qin
// downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7]
qint16 xreal[4], yimag[4];
- for (int pos = 0; pos < len - 31; ) {
- for (int i = 0; i < 4; i++) {
+ for (int pos = 0; pos < len - 31; )
+ {
+ for (int i = 0; i < 4; i++)
+ {
xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]) << 2; // was shift 4
yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]) << 2; // was shift 4
pos += 8;
}
+ m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]);
+ m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]);
+
+ m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]);
+
+ (**it).setReal(xreal[3]);
+ (**it).setImag(yimag[3]);
+ /*
Sample s1( xreal[0], yimag[0] );
Sample s2( xreal[1], yimag[1] );
Sample s3( xreal[2], yimag[2] );
@@ -418,8 +541,8 @@ void Decimators::decimate16_sup(SampleVector::iterator* it, const T* buf, qin
m_decimator4.myDecimate(&s2, &s4);
- **it = s4;
- (*it)++;
+ **it = s4;*/
+ ++(*it);
}
}
@@ -428,13 +551,28 @@ void Decimators::decimate32(SampleVector::iterator* it, const T* buf, qint32
{
qint16 xreal[8], yimag[8];
- for (int pos = 0; pos < len - 63; ) {
- for (int i = 0; i < 8; i++) {
+ for (int pos = 0; pos < len - 63; )
+ {
+ for (int i = 0; i < 8; i++)
+ {
xreal[i] = (buf[pos+0] - buf[pos+3] + buf[pos+7] - buf[pos+4]) << 2;
yimag[i] = (buf[pos+1] - buf[pos+5] + buf[pos+2] - buf[pos+6]) << 2;
pos += 8;
}
+ m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]);
+ m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]);
+ m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[3]);
+ m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]);
+
+ m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]);
+ m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]);
+
+ m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]);
+
+ (**it).setReal(xreal[7]);
+ (**it).setImag(yimag[7]);
+ /*
Sample s1( xreal[0], yimag[0] );
Sample s2( xreal[1], yimag[1] );
Sample s3( xreal[2], yimag[2] );
@@ -454,8 +592,8 @@ void Decimators::decimate32(SampleVector::iterator* it, const T* buf, qint32
m_decimator8.myDecimate(&s4, &s8);
- **it = s8;
- (*it)++;
+ **it = s8;*/
+ ++(*it);
}
}
@@ -464,13 +602,28 @@ void Decimators::decimate32_sup(SampleVector::iterator* it, const T* buf, qin
{
qint16 xreal[8], yimag[8];
- for (int pos = 0; pos < len - 63; ) {
- for (int i = 0; i < 8; i++) {
+ for (int pos = 0; pos < len - 63; )
+ {
+ for (int i = 0; i < 8; i++)
+ {
xreal[i] = (buf[pos+1] - buf[pos+2] - buf[pos+5] + buf[pos+6]) << 2;
yimag[i] = (buf[pos+4] + buf[pos+7] - buf[pos+0] - buf[pos+3]) << 2;
pos += 8;
}
+ m_decimator2.myDecimate(xreal[0], yimag[0], &xreal[1], &yimag[1]);
+ m_decimator2.myDecimate(xreal[2], yimag[2], &xreal[3], &yimag[3]);
+ m_decimator2.myDecimate(xreal[4], yimag[4], &xreal[5], &yimag[3]);
+ m_decimator2.myDecimate(xreal[6], yimag[6], &xreal[7], &yimag[7]);
+
+ m_decimator4.myDecimate(xreal[1], yimag[1], &xreal[3], &yimag[3]);
+ m_decimator4.myDecimate(xreal[5], yimag[5], &xreal[7], &yimag[7]);
+
+ m_decimator8.myDecimate(xreal[3], yimag[3], &xreal[7], &yimag[7]);
+
+ (**it).setReal(xreal[7]);
+ (**it).setImag(yimag[7]);
+ /*
Sample s1( xreal[0], yimag[0] );
Sample s2( xreal[1], yimag[1] );
Sample s3( xreal[2], yimag[2] );
@@ -490,8 +643,8 @@ void Decimators::decimate32_sup(SampleVector::iterator* it, const T* buf, qin
m_decimator8.myDecimate(&s4, &s8);
- **it = s8;
- (*it)++;
+ **it = s8;*/
+ ++(*it);
}
}
diff --git a/include-gpl/dsp/highpass.h b/include-gpl/dsp/highpass.h
index 407cdc1db..de293b4b1 100644
--- a/include-gpl/dsp/highpass.h
+++ b/include-gpl/dsp/highpass.h
@@ -56,27 +56,43 @@ public:
Type acc = 0;
int a = m_ptr;
int b = a - 1;
- int i;
+ int i, n_taps, size;
m_samples[m_ptr] = sample;
+ size = m_samples.size(); // Valgrind optim (2)
while(b < 0)
- b += m_samples.size();
+ {
+ b += size;
+ }
- for(i = 0; i < (int)m_taps.size() - 1; i++) {
+ n_taps = m_taps.size() - 1; // Valgrind optim
+
+ for (i = 0; i < n_taps; i++)
+ {
acc += (m_samples[a] + m_samples[b]) * m_taps[i];
a++;
- while(a >= (int)m_samples.size())
- a -= m_samples.size();
- b--;
- while(b < 0)
- b += m_samples.size();
- }
- acc += m_samples[a] * m_taps[i];
+ while (a >= size)
+ {
+ a -= size;
+ }
+
+ b--;
+
+ while (b < 0)
+ {
+ b += size;
+ }
+ }
+
+ acc += m_samples[a] * m_taps[i];
m_ptr++;
- while(m_ptr >= (int)m_samples.size())
- m_ptr -= m_samples.size();
+
+ while (m_ptr >= size)
+ {
+ m_ptr -= size;
+ }
return acc;
}
diff --git a/include-gpl/dsp/inthalfbandfilter.h b/include-gpl/dsp/inthalfbandfilter.h
index 204d58f2c..e1555d5e5 100644
--- a/include-gpl/dsp/inthalfbandfilter.h
+++ b/include-gpl/dsp/inthalfbandfilter.h
@@ -24,7 +24,8 @@ public:
m_samples[m_ptr][0] = sample->real();
m_samples[m_ptr][1] = sample->imag();
- switch(m_state) {
+ switch(m_state)
+ {
case 0:
// advance write-pointer
m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
@@ -50,10 +51,44 @@ public:
}
}
+ bool workDecimateCenter(qint16 *x, qint16 *y)
+ {
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = *x;
+ m_samples[m_ptr][1] = *y;
+
+ switch(m_state)
+ {
+ case 0:
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+
+ // next state
+ m_state = 1;
+
+ // tell caller we don't have a new sample
+ return false;
+
+ default:
+ // save result
+ doFIR(x, y);
+
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+
+ // next state
+ m_state = 0;
+
+ // tell caller we have a new sample
+ return true;
+ }
+ }
+
// downsample by 2, return edges of spectrum rotated into center
bool workDecimateFullRotate(Sample* sample)
{
- switch(m_state) {
+ switch(m_state)
+ {
case 0:
// insert sample into ring-buffer
m_samples[m_ptr][0] = sample->real();
@@ -90,140 +125,142 @@ public:
// downsample by 2, return lower half of original spectrum
bool workDecimateLowerHalf(Sample* sample)
{
- switch(m_state) {
- case 0:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = -sample->imag();
- m_samples[m_ptr][1] = sample->real();
+ switch(m_state)
+ {
+ case 0:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = -sample->imag();
+ m_samples[m_ptr][1] = sample->real();
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 1;
+ // next state
+ m_state = 1;
- // tell caller we don't have a new sample
- return false;
+ // tell caller we don't have a new sample
+ return false;
- case 1:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = -sample->real();
- m_samples[m_ptr][1] = -sample->imag();
+ case 1:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = -sample->real();
+ m_samples[m_ptr][1] = -sample->imag();
- // save result
- doFIR(sample);
+ // save result
+ doFIR(sample);
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 2;
+ // next state
+ m_state = 2;
- // tell caller we have a new sample
- return true;
+ // tell caller we have a new sample
+ return true;
- case 2:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = sample->imag();
- m_samples[m_ptr][1] = -sample->real();
+ case 2:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = sample->imag();
+ m_samples[m_ptr][1] = -sample->real();
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 3;
+ // next state
+ m_state = 3;
- // tell caller we don't have a new sample
- return false;
+ // tell caller we don't have a new sample
+ return false;
- default:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = sample->real();
- m_samples[m_ptr][1] = sample->imag();
+ default:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = sample->real();
+ m_samples[m_ptr][1] = sample->imag();
- // save result
- doFIR(sample);
+ // save result
+ doFIR(sample);
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 0;
+ // next state
+ m_state = 0;
- // tell caller we have a new sample
- return true;
- }
+ // tell caller we have a new sample
+ return true;
+ }
}
// downsample by 2, return upper half of original spectrum
bool workDecimateUpperHalf(Sample* sample)
{
- switch(m_state) {
- case 0:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = sample->imag();
- m_samples[m_ptr][1] = -sample->real();
+ switch(m_state)
+ {
+ case 0:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = sample->imag();
+ m_samples[m_ptr][1] = -sample->real();
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 1;
+ // next state
+ m_state = 1;
- // tell caller we don't have a new sample
- return false;
+ // tell caller we don't have a new sample
+ return false;
- case 1:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = -sample->real();
- m_samples[m_ptr][1] = -sample->imag();
+ case 1:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = -sample->real();
+ m_samples[m_ptr][1] = -sample->imag();
- // save result
- doFIR(sample);
+ // save result
+ doFIR(sample);
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 2;
+ // next state
+ m_state = 2;
- // tell caller we have a new sample
- return true;
+ // tell caller we have a new sample
+ return true;
- case 2:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = -sample->imag();
- m_samples[m_ptr][1] = sample->real();
+ case 2:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = -sample->imag();
+ m_samples[m_ptr][1] = sample->real();
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 3;
+ // next state
+ m_state = 3;
- // tell caller we don't have a new sample
- return false;
+ // tell caller we don't have a new sample
+ return false;
- default:
- // insert sample into ring-buffer
- m_samples[m_ptr][0] = sample->real();
- m_samples[m_ptr][1] = sample->imag();
+ default:
+ // insert sample into ring-buffer
+ m_samples[m_ptr][0] = sample->real();
+ m_samples[m_ptr][1] = sample->imag();
- // save result
- doFIR(sample);
+ // save result
+ doFIR(sample);
- // advance write-pointer
- m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
+ // advance write-pointer
+ m_ptr = (m_ptr + HB_FILTERORDER) % (HB_FILTERORDER + 1);
- // next state
- m_state = 0;
+ // next state
+ m_state = 0;
- // tell caller we have a new sample
- return true;
- }
+ // tell caller we have a new sample
+ return true;
+ }
}
- void myDecimate(Sample* sample1, Sample* sample2)
+ void myDecimate(const Sample* sample1, Sample* sample2)
{
static const qint16 mod33[38] = { 31,32,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,30,31,32,0,1,2};
@@ -240,8 +277,25 @@ public:
m_ptr = mod33[m_ptr + 2 - 1];
}
+ void myDecimate(qint16 x1, qint16 y1, qint16 *x2, qint16 *y2)
+ {
+ static const qint16 mod33[38] = { 31,32,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,30,31,32,0,1,2};
+
+ m_samples[m_ptr][0] = x1;
+ m_samples[m_ptr][1] = y1;
+ m_ptr = mod33[m_ptr + 2 - 1];
+
+ m_samples[m_ptr][0] = *x2;
+ m_samples[m_ptr][1] = *y2;
+
+ doFIR(x2, y2);
+
+ m_ptr = mod33[m_ptr + 2 - 1];
+ }
+
protected:
- qint16 m_samples[HB_FILTERORDER + 1][2];
+ qint32 m_samples[HB_FILTERORDER + 1][2]; // Valgrind optim (from qint16)
qint16 m_ptr;
int m_state;
@@ -330,6 +384,93 @@ protected:
sample->setReal(iAcc >> HB_SHIFT);
sample->setImag(qAcc >> HB_SHIFT);
}
+
+ void doFIR(qint16 *x, qint16 *y)
+ {
+ // coefficents
+
+ #if HB_FILTERORDER == 64
+ static const qint32 COEFF[16] = {
+ -0.001114417441601693505720538368564120901 * (1 << HB_SHIFT),
+ 0.001268007827185253051302527005361753254 * (1 << HB_SHIFT),
+ -0.001959831378850490895410230152151598304 * (1 << HB_SHIFT),
+ 0.002878308307661380308073439948657323839 * (1 << HB_SHIFT),
+ -0.004071361818258721100571850826099762344 * (1 << HB_SHIFT),
+ 0.005597288494657440618973431867289036745 * (1 << HB_SHIFT),
+ -0.007532345003308904551886371336877346039 * (1 << HB_SHIFT),
+ 0.009980346844667375288961963519795972388 * (1 << HB_SHIFT),
+ -0.013092614174300500062830820979797863401 * (1 << HB_SHIFT),
+ 0.01710934914871829748417297878404497169 * (1 << HB_SHIFT),
+ -0.022443558692997273018576720460259821266 * (1 << HB_SHIFT),
+ 0.029875811511593811098386197500076377764 * (1 << HB_SHIFT),
+ -0.041086352085710403647667021687084343284 * (1 << HB_SHIFT),
+ 0.060465467462665789533104998554335907102 * (1 << HB_SHIFT),
+ -0.104159517495977321788203084906854201108 * (1 << HB_SHIFT),
+ 0.317657589850154464805598308885237202048 * (1 << HB_SHIFT),
+ };
+ #elif HB_FILTERORDER == 48
+ static const qint32 COEFF[12] = {
+ -0.004102576237611492253332112767338912818 * (1 << HB_SHIFT),
+ 0.003950551047979387886410762575906119309 * (1 << HB_SHIFT),
+ -0.005807875789391703583164350277456833282 * (1 << HB_SHIFT),
+ 0.00823497890520805998770814682075069868 * (1 << HB_SHIFT),
+ -0.011372226513199541059195851744334504474 * (1 << HB_SHIFT),
+ 0.015471557140973646315984524335362948477 * (1 << HB_SHIFT),
+ -0.020944996398689276484450516591095947661 * (1 << HB_SHIFT),
+ 0.028568078132034283034279553703527199104 * (1 << HB_SHIFT),
+ -0.040015143905614086738964374490024056286 * (1 << HB_SHIFT),
+ 0.059669519431831075095828964549582451582 * (1 << HB_SHIFT),
+ -0.103669138691865420076609893840213771909 * (1 << HB_SHIFT),
+ 0.317491986549921390015072120149852707982 * (1 << HB_SHIFT)
+ };
+ #elif HB_FILTERORDER == 32
+ static const qint16 mod33[38] = { 31,32,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,
+ 20,21,22,23,24,25,26,27,28,29,30,31,32,0,1,2} ;
+ static const qint32 COEFF[8] = {
+ (qint32)(-0.015956912844043127236437484839370881673 * (1 << HB_SHIFT)),
+ (qint32)( 0.013023031678944928940522274274371739011 * (1 << HB_SHIFT)),
+ (qint32)(-0.01866942273717486777684371190844103694 * (1 << HB_SHIFT)),
+ (qint32)( 0.026550887571157304190005987720724078827 * (1 << HB_SHIFT)),
+ (qint32)(-0.038350314277854319344740474662103224546 * (1 << HB_SHIFT)),
+ (qint32)( 0.058429248652825838128421764849917963147 * (1 << HB_SHIFT)),
+ (qint32)(-0.102889802028955756885153505209018476307 * (1 << HB_SHIFT)),
+ (qint32)( 0.317237706405931241260276465254719369113 * (1 << HB_SHIFT))
+ };
+ #else
+ #error unsupported filter order
+ #endif
+
+
+ // init read-pointer
+ int a = mod33[m_ptr + 2 + 1]; // 0 + 1
+ int b = mod33[m_ptr + 2 - 2]; //-1 - 1
+
+ // go through samples in buffer
+ qint32 iAcc = 0;
+ qint32 qAcc = 0;
+
+ for (int i = 0; i < HB_FILTERORDER / 4; i++)
+ {
+ // do multiply-accumulate
+ //qint32 iTmp = m_samples[a][0] + m_samples[b][0]; // Valgrind optim
+ //qint32 qTmp = m_samples[a][1] + m_samples[b][1]; // Valgrind optim
+ iAcc += (m_samples[a][0] + m_samples[b][0]) * COEFF[i];
+ qAcc += (m_samples[a][1] + m_samples[b][1]) * COEFF[i];
+
+ // update read-pointer
+ a = mod33[a + 2 + 2];
+ b = mod33[b + 2 - 2];
+ }
+
+ a = mod33[a + 2 - 1];
+
+ iAcc += ((qint32)m_samples[a][0] + 1) << (HB_SHIFT - 1);
+ qAcc += ((qint32)m_samples[a][1] + 1) << (HB_SHIFT - 1);
+
+ *x = iAcc >> HB_SHIFT;
+ *y = qAcc >> HB_SHIFT;
+ }
+
};
#endif // INCLUDE_INTHALFBANDFILTER_H
diff --git a/include-gpl/dsp/lowpass.h b/include-gpl/dsp/lowpass.h
index 1d6705b4e..355941210 100644
--- a/include-gpl/dsp/lowpass.h
+++ b/include-gpl/dsp/lowpass.h
@@ -54,42 +54,42 @@ public:
Type acc = 0;
int a = m_ptr;
int b = a - 1;
- int i, size;
+ int i, n_taps, size;
m_samples[m_ptr] = sample;
+ size = m_samples.size(); // Valgrind optim (2)
while (b < 0)
{
- b += m_samples.size();
+ b += size;
}
- size = (int) m_taps.size() - 1; // Valgrind optim
+ n_taps = m_taps.size() - 1; // Valgrind optim
- for (i = 0; i < size; i++)
+ for (i = 0; i < n_taps; i++)
{
acc += (m_samples[a] + m_samples[b]) * m_taps[i];
a++;
- while (a >= (int)m_samples.size())
+ while (a >= size)
{
- a -= m_samples.size();
+ a -= size;
}
b--;
while(b < 0)
{
- b += m_samples.size();
+ b += size;
}
}
acc += m_samples[a] * m_taps[i];
-
m_ptr++;
- while(m_ptr >= (int)m_samples.size())
+ while(m_ptr >= size)
{
- m_ptr -= m_samples.size();
+ m_ptr -= size;
}
return acc;
diff --git a/include/dsp/dsptypes.h b/include/dsp/dsptypes.h
index b6bbf6710..046d91bdb 100644
--- a/include/dsp/dsptypes.h
+++ b/include/dsp/dsptypes.h
@@ -28,21 +28,22 @@ typedef std::complex Complex;
typedef qint16 FixReal;
#pragma pack(push, 1)
-struct Sample {
+struct Sample
+{
Sample() {}
Sample(FixReal real) : m_real(real), m_imag(0) {}
Sample(FixReal real, FixReal imag) : m_real(real), m_imag(imag) {}
Sample(const Sample& other) : m_real(other.m_real), m_imag(other.m_imag) {}
- Sample& operator=(const Sample& other) { m_real = other.m_real; m_imag = other.m_imag; return *this; }
+ inline Sample& operator=(const Sample& other) { m_real = other.m_real; m_imag = other.m_imag; return *this; }
- Sample& operator+=(const Sample& other) { m_real += other.m_real; m_imag += other.m_imag; return *this; }
- Sample& operator-=(const Sample& other) { m_real -= other.m_real; m_imag -= other.m_imag; return *this; }
+ inline Sample& operator+=(const Sample& other) { m_real += other.m_real; m_imag += other.m_imag; return *this; }
+ inline Sample& operator-=(const Sample& other) { m_real -= other.m_real; m_imag -= other.m_imag; return *this; }
- void setReal(FixReal v) { m_real = v; }
- void setImag(FixReal v) { m_imag = v; }
+ inline void setReal(FixReal v) { m_real = v; }
+ inline void setImag(FixReal v) { m_imag = v; }
- FixReal real() const { return m_real; }
- FixReal imag() const { return m_imag; }
+ inline FixReal real() const { return m_real; }
+ inline FixReal imag() const { return m_imag; }
FixReal m_real;
FixReal m_imag;