Browse Source

gen_audio_resampler_filter.c: Precalculate loop-invariant bessel(beta).

Minor optimization in offline code.
Ryan C. Gordon 2 years ago
parent
commit
5968f3d828
1 changed files with 2 additions and 1 deletions
  1. 2 1
      build-scripts/gen_audio_resampler_filter.c

+ 2 - 1
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;
     }