Rollback of changes to resampler

This commit is contained in:
Ryzerth 2021-04-18 01:15:57 +02:00
parent cf4cfb50fc
commit ba25eee09a

View File

@ -83,14 +83,14 @@ namespace dsp {
void updateWindow(dsp::filter_window::generic_window* window) { void updateWindow(dsp::filter_window::generic_window* window) {
std::lock_guard<std::mutex> lck(generic_block<PolyphaseResampler<T>>::ctrlMtx); std::lock_guard<std::mutex> lck(generic_block<PolyphaseResampler<T>>::ctrlMtx);
//generic_block<PolyphaseResampler<T>>::tempStop(); generic_block<PolyphaseResampler<T>>::tempStop();
_window = window; _window = window;
volk_free(taps); volk_free(taps);
tapCount = window->getTapCount(); tapCount = window->getTapCount();
taps = (float*)volk_malloc(tapCount * sizeof(float), volk_get_alignment()); taps = (float*)volk_malloc(tapCount * sizeof(float), volk_get_alignment());
window->createTaps(taps, tapCount, _interp); window->createTaps(taps, tapCount, _interp);
buildTapPhases(); buildTapPhases();
//generic_block<PolyphaseResampler<T>>::tempStart(); generic_block<PolyphaseResampler<T>>::tempStart();
} }
int calcOutSize(int in) { int calcOutSize(int in) {
@ -103,35 +103,30 @@ namespace dsp {
return -1; return -1;
} }
{ int outCount = calcOutSize(count);
std::lock_guard<std::mutex> lck(generic_block<PolyphaseResampler<T>>::ctrlMtx); memcpy(&buffer[tapsPerPhase], _in->readBuf, count * sizeof(T));
int outCount = calcOutSize(count); _in->flush();
memcpy(&buffer[tapsPerPhase], _in->readBuf, count * sizeof(T));
_in->flush();
// Write to output // Write to output
int outIndex = 0; int outIndex = 0;
int _interp_m_1 = _interp - 1; int _interp_m_1 = _interp - 1;
if constexpr (std::is_same_v<T, float>) { if constexpr (std::is_same_v<T, float>) {
for (int i = 0; outIndex < outCount; i += _decim) { for (int i = 0; outIndex < outCount; i += _decim) {
int phase = i % _interp; int phase = i % _interp;
volk_32f_x2_dot_prod_32f(&out.writeBuf[outIndex], &buffer[i / _interp], tapPhases[phase], tapsPerPhase); volk_32f_x2_dot_prod_32f(&out.writeBuf[outIndex], &buffer[i / _interp], tapPhases[phase], tapsPerPhase);
outIndex++; outIndex++;
}
} }
if constexpr (std::is_same_v<T, complex_t> || std::is_same_v<T, stereo_t>) {
for (int i = 0; outIndex < outCount; i += _decim) {
int phase = i % _interp;
volk_32fc_32f_dot_prod_32fc((lv_32fc_t*)&out.writeBuf[outIndex], (lv_32fc_t*)&buffer[(i / _interp)], tapPhases[phase], tapsPerPhase);
outIndex++;
}
}
if (!out.swap(outCount)) {
return -1;
}
memmove(buffer, &buffer[count], tapsPerPhase * sizeof(T));
} }
if constexpr (std::is_same_v<T, complex_t> || std::is_same_v<T, stereo_t>) {
for (int i = 0; outIndex < outCount; i += _decim) {
int phase = i % _interp;
volk_32fc_32f_dot_prod_32fc((lv_32fc_t*)&out.writeBuf[outIndex], (lv_32fc_t*)&buffer[(i / _interp)], tapPhases[phase], tapsPerPhase);
outIndex++;
}
}
if (!out.swap(outCount)) { return -1; }
memmove(buffer, &buffer[count], tapsPerPhase * sizeof(T));
return count; return count;
} }