1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

Deep redesign: Bandpass and lowpass filter Valgrind optimization

This commit is contained in:
f4exb 2015-08-29 18:39:29 +02:00
parent f121ba258b
commit a8efd95db7
2 changed files with 40 additions and 18 deletions

View File

@ -76,26 +76,31 @@ public:
Type acc = 0;
int a = m_ptr;
int b = a - 1;
int i;
int i, size;
m_samples[m_ptr] = sample;
while(b < 0) {
while(b < 0)
{
b += m_samples.size();
}
for(i = 0; i < (int)m_taps.size() - 1; i++)
size = (int) m_taps.size() - 1; // Valgrind optim
for(i = 0; i < size; i++)
{
acc += (m_samples[a] + m_samples[b]) * m_taps[i];
acc += (m_samples[a] + m_samples[b]) * m_taps[i];
a++;
while(a >= (int)m_samples.size()) {
while(a >= (int)m_samples.size())
{
a -= m_samples.size();
}
b--;
while(b < 0) {
while(b < 0)
{
b += m_samples.size();
}
}
@ -104,7 +109,8 @@ public:
m_ptr++;
while(m_ptr >= (int)m_samples.size()) {
while(m_ptr >= (int)m_samples.size())
{
m_ptr -= m_samples.size();
}

View File

@ -54,27 +54,43 @@ public:
Type acc = 0;
int a = m_ptr;
int b = a - 1;
int i;
int i, size;
m_samples[m_ptr] = sample;
while(b < 0)
while (b < 0)
{
b += m_samples.size();
for(i = 0; i < (int)m_taps.size() - 1; 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();
}
size = (int) m_taps.size() - 1; // Valgrind optim
for (i = 0; i < size; 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];
m_ptr++;
while(m_ptr >= (int)m_samples.size())
{
m_ptr -= m_samples.size();
}
return acc;
}