Refuse to accept NaNs in MovingMedian, replacing them with zeros (and a warning) instead. (Must push something, to maintain filter length)

This commit is contained in:
Chris Cannam
2015-02-23 10:56:31 +00:00
parent 5ffec3ea8a
commit 0f4a9e1612

View File

@@ -30,6 +30,8 @@
#include <algorithm> #include <algorithm>
#include <iostream>
namespace RubberBand namespace RubberBand
{ {
@@ -59,6 +61,10 @@ public:
} }
void push(T value) { void push(T value) {
if (value != value) {
std::cerr << "WARNING: MovingMedian: NaN encountered" << std::endl;
value = T();
}
drop(m_frame[0]); drop(m_frame[0]);
v_move(m_frame, m_frame+1, P::m_size-1); v_move(m_frame, m_frame+1, P::m_size-1);
m_frame[P::m_size-1] = value; m_frame[P::m_size-1] = value;