Skip to content

Commit

Permalink
Fix an Lanczos Index edge Case (#4469)
Browse files Browse the repository at this point in the history
Closes #4465
  • Loading branch information
baconpaul authored May 3, 2021
1 parent a5388b4 commit 32f6d8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/common/dsp/LanczosResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
#include "LanczosResampler.h"

float LanczosResampler::lanczosTable alignas(
16)[LanczosResampler::tableObs][LanczosResampler::filterWidth];
16)[LanczosResampler::tableObs + 1][LanczosResampler::filterWidth];
float LanczosResampler::lanczosTableDX alignas(
16)[LanczosResampler::tableObs][LanczosResampler::filterWidth];
16)[LanczosResampler::tableObs + 1][LanczosResampler::filterWidth];

bool LanczosResampler::tablesInitialized = false;

Expand Down
11 changes: 8 additions & 3 deletions src/common/dsp/LanczosResampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ struct LanczosResampler
static constexpr double dx = 1.0 / (tableObs);

// Fixme: Make this static and shared
static float lanczosTable alignas(16)[tableObs][filterWidth], lanczosTableDX
alignas(16)[tableObs][filterWidth];
static float lanczosTable alignas(16)[tableObs + 1][filterWidth], lanczosTableDX
alignas(16)[tableObs + 1][filterWidth];
static bool tablesInitialized;

// This is a stereo resampler
Expand All @@ -65,7 +65,7 @@ struct LanczosResampler
memset(input, 0, 2 * BUFFER_SZ * sizeof(float));
if (!tablesInitialized)
{
for (int t = 0; t < tableObs; ++t)
for (int t = 0; t < tableObs + 1; ++t)
{
double x0 = dx * t;
for (int i = 0; i < filterWidth; ++i)
Expand All @@ -82,6 +82,11 @@ struct LanczosResampler
lanczosTable[(t + 1) & (tableObs - 1)][i] - lanczosTable[t][i];
}
}
for (int i = 0; i < filterWidth; ++i)
{
// Wrap at the end - deriv is the same
lanczosTableDX[tableObs][i] = lanczosTable[0][i];
}
tablesInitialized = true;
}
}
Expand Down

0 comments on commit 32f6d8a

Please sign in to comment.