Commit 5968f3d828aaf28a28763fce794020fc8239a35a

Ryan C. Gordon 2022-05-26T10:44:01

gen_audio_resampler_filter.c: Precalculate loop-invariant bessel(beta). Minor optimization in offline code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/build-scripts/gen_audio_resampler_filter.c b/build-scripts/gen_audio_resampler_filter.c
index 4a343fb..99d7795 100644
--- a/build-scripts/gen_audio_resampler_filter.c
+++ b/build-scripts/gen_audio_resampler_filter.c
@@ -74,11 +74,12 @@ kaiser_and_sinc(float *table, float *diffs, const int tablelen, const double bet
 {
     const int lenm1 = tablelen - 1;
     const int lenm1div2 = lenm1 / 2;
+    const double bessel_beta = bessel(beta);
     int i;
 
     table[0] = 1.0f;
     for (i = 1; i < tablelen; i++) {
-        const double kaiser = bessel(beta * sqrt(1.0 - pow(((i - lenm1) / 2.0) / lenm1div2, 2.0))) / bessel(beta);
+        const double kaiser = bessel(beta * sqrt(1.0 - pow(((i - lenm1) / 2.0) / lenm1div2, 2.0))) / bessel_beta;
         table[tablelen - i] = (float) kaiser;
     }