From 5968f3d828aaf28a28763fce794020fc8239a35a Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 26 May 2022 10:44:01 -0400
Subject: [PATCH] gen_audio_resampler_filter.c: Precalculate loop-invariant
bessel(beta).
Minor optimization in offline code.
---
build-scripts/gen_audio_resampler_filter.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/build-scripts/gen_audio_resampler_filter.c b/build-scripts/gen_audio_resampler_filter.c
index 4a343fb639c..99d77957ebb 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;
}