Very slight speed improvement in FIR filters.
This commit is contained in:
parent
cecf407d00
commit
47525ef796
25
Filter.cc
25
Filter.cc
|
@ -109,22 +109,27 @@ void LowPassFilterFirIQ::process(const IQSampleVector& samples_in,
|
|||
if (n == 0)
|
||||
return;
|
||||
|
||||
// NOTE: We use m_coeff the wrong way around because it is slightly
|
||||
// faster to scan forward through the array. The result is still correct
|
||||
// because the coefficients are symmetric.
|
||||
|
||||
// The first few samples need data from m_state.
|
||||
unsigned int i = 0;
|
||||
for (; i < n && i < order; i++) {
|
||||
IQSample y(0);
|
||||
for (unsigned int j = 0; j <= i; j++)
|
||||
y += samples_in[i-j] * m_coeff[j];
|
||||
for (unsigned int j = i + 1; j <= order; j++)
|
||||
y += m_state[order + i - j] * m_coeff[j];
|
||||
IQSample y = 0;
|
||||
for (unsigned int j = 0; j < order - i; j++)
|
||||
y += m_state[i+j] * m_coeff[j];
|
||||
for (unsigned int j = order - i; j <= order; j++)
|
||||
y += samples_in[i-order+j] * m_coeff[j];
|
||||
samples_out[i] = y;
|
||||
}
|
||||
|
||||
// Remaining samples only need data from samples_in.
|
||||
for (; i < n; i++) {
|
||||
IQSample y(0);
|
||||
IQSample y = 0;
|
||||
IQSampleVector::const_iterator inp = samples_in.begin() + i - order;
|
||||
for (unsigned int j = 0; j <= order; j++)
|
||||
y += samples_in[i-j] * m_coeff[j];
|
||||
y += inp[j] * m_coeff[j];
|
||||
samples_out[i] = y;
|
||||
}
|
||||
|
||||
|
@ -182,17 +187,17 @@ void DownsampleFilter::process(const SampleVector& samples_in,
|
|||
unsigned int i = 0;
|
||||
for (; p < n && p < order; p += pstep, i++) {
|
||||
Sample y = 0;
|
||||
for (unsigned int j = 0; j <= p; j++)
|
||||
for (unsigned int j = 1; j <= p; j++)
|
||||
y += samples_in[p-j] * m_coeff[j];
|
||||
for (unsigned int j = p + 1; j <= order; j++)
|
||||
y += m_state[order + p - j] * m_coeff[j];
|
||||
y += m_state[order+p-j] * m_coeff[j];
|
||||
samples_out[i] = y;
|
||||
}
|
||||
|
||||
// Remaining samples only need data from samples_in.
|
||||
for (; p < n; p += pstep, i++) {
|
||||
Sample y = 0;
|
||||
for (unsigned int j = 0; j <= order; j++)
|
||||
for (unsigned int j = 1; j <= order; j++)
|
||||
y += samples_in[p-j] * m_coeff[j];
|
||||
samples_out[i] = y;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue