Dynamically allocate the temporary bsinc filter table

This commit is contained in:
Chris Robinson
2020-04-06 17:11:21 -07:00
parent 7a324231a3
commit 2fcc3f3887
+7 -2
View File
@@ -5,6 +5,7 @@
#include <cassert>
#include <cmath>
#include <limits>
#include <memory>
#include <stdexcept>
#include "math_defs.h"
@@ -210,10 +211,14 @@ struct Array {
T data[N];
};
/* FIXME: This should be constexpr, but the temporary filter table is apparently too big
* (~200K) for some systems. This requires using heap space, which is not
* allowed in a constexpr function.
*/
template<size_t total_size>
constexpr auto GenerateBSincCoeffs(const BSincHeader &hdr)
auto GenerateBSincCoeffs(const BSincHeader &hdr)
{
double filter[BSincScaleCount][BSincPhaseCount+1][BSincPointsMax]{};
auto filter = std::make_unique<double[][BSincPhaseCount+1][BSincPointsMax]>(BSincScaleCount);
/* Calculate the Kaiser-windowed Sinc filter coefficients for each scale
* and phase index.