aboutsummaryrefslogtreecommitdiffstats
path: root/core/bsinc_tables.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2021-02-23 18:48:02 -0800
committerChris Robinson <[email protected]>2021-02-23 18:48:02 -0800
commit5647aa4042ec64667cd2ba384e30769daa606ab4 (patch)
tree82e42a8a9bc8248d1126a8f4ef1aa8c53cf8b023 /core/bsinc_tables.cpp
parent25d25f9a8004ede46349f80225e13feff6a0748c (diff)
Adjust the bsinc filter table packing
Now each scale's filter and phase delta are interleaved for each phase index, followed by the scale and scale+phase delta for each phase index. This ensures no holes in the filter coefficients for the fast bsinc resampler for a given run, while keeping the scale deltas in the same vicinity for the non-fast bsinc resampler.
Diffstat (limited to 'core/bsinc_tables.cpp')
-rw-r--r--core/bsinc_tables.cpp52
1 files changed, 20 insertions, 32 deletions
diff --git a/core/bsinc_tables.cpp b/core/bsinc_tables.cpp
index 315e1448..334822f5 100644
--- a/core/bsinc_tables.cpp
+++ b/core/bsinc_tables.cpp
@@ -189,16 +189,16 @@ struct BSincFilterArray {
}
size_t idx{0};
- for(size_t si{0};si < BSincScaleCount-1;++si)
+ for(size_t si{0};si < BSincScaleCount;++si)
{
const size_t m{((hdr.a[si]*2) + 3) & ~3u};
const size_t o{(BSincPointsMax-m) / 2};
+ /* Write out each phase index's filter and phase delta for this
+ * quality scale.
+ */
for(size_t pi{0};pi < BSincPhaseCount;++pi)
{
- /* Write out the filter. Also calculate and write out the phase
- * and scale deltas.
- */
for(size_t i{0};i < m;++i)
mTable[idx++] = static_cast<float>(filter[si][pi][o+i]);
@@ -210,11 +210,22 @@ struct BSincFilterArray {
const double phDelta{filter[si][pi+1][o+i] - filter[si][pi][o+i]};
mTable[idx++] = static_cast<float>(phDelta);
}
-
+ }
+ /* Calculate and write out each phase index's filter quality scale
+ * deltas. The last scale index doesn't have any scale or scale-
+ * phase deltas.
+ */
+ if(si == BSincScaleCount-1)
+ {
+ for(size_t i{0};i < BSincPhaseCount*m*2;++i)
+ mTable[idx++] = 0.0f;
+ }
+ else for(size_t pi{0};pi < BSincPhaseCount;++pi)
+ {
/* Linear interpolation between scales is also simplified.
*
- * Given a difference in points between scales, the destination
- * points will be 0, thus: x = a + f (-a)
+ * Given a difference in the number of points between scales,
+ * the destination points will be 0, thus: x = a + f (-a)
*/
for(size_t i{0};i < m;++i)
{
@@ -223,8 +234,8 @@ struct BSincFilterArray {
}
/* This last simplification is done to complete the bilinear
- * equation for the combination of phase and scale.
- */
+ * equation for the combination of phase and scale.
+ */
for(size_t i{0};i < m;++i)
{
const double spDelta{(filter[si+1][pi+1][o+i] - filter[si+1][pi][o+i]) -
@@ -233,29 +244,6 @@ struct BSincFilterArray {
}
}
}
- {
- /* The last scale index doesn't have any scale or scale-phase
- * deltas.
- */
- constexpr size_t si{BSincScaleCount-1};
- const size_t m{((hdr.a[si]*2) + 3) & ~3u};
- const size_t o{(BSincPointsMax-m) / 2};
-
- for(size_t pi{0};pi < BSincPhaseCount;++pi)
- {
- for(size_t i{0};i < m;++i)
- mTable[idx++] = static_cast<float>(filter[si][pi][o+i]);
- for(size_t i{0};i < m;++i)
- {
- const double phDelta{filter[si][pi+1][o+i] - filter[si][pi][o+i]};
- mTable[idx++] = static_cast<float>(phDelta);
- }
- for(size_t i{0};i < m;++i)
- mTable[idx++] = 0.0f;
- for(size_t i{0};i < m;++i)
- mTable[idx++] = 0.0f;
- }
- }
assert(idx == hdr.total_size);
}
};