]> git.sesse.net Git - c64tapwav/commitdiff
Store only the right-hand side of the Lanczos table, saving a branch.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Mar 2015 15:19:57 +0000 (16:19 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Mar 2015 15:19:57 +0000 (16:19 +0100)
interpolate.cpp
interpolate.h

index cd250c151851619bb0fd128e5120dbc18e049ec1..78b2dae1e43e59cdb8923d90e6fd9a8e5645f0dd 100644 (file)
@@ -1,11 +1,11 @@
 #include "interpolate.h"
 
 #include "interpolate.h"
 
-double lanczos_table[(LANCZOS_RADIUS * 2) * LANCZOS_RESOLUTION];
+double lanczos_table[LANCZOS_RADIUS * LANCZOS_RESOLUTION];
 
 void make_lanczos_weight_table()
 {
 
 void make_lanczos_weight_table()
 {
-       for (int i = 0; i < (LANCZOS_RADIUS * 2) * LANCZOS_RESOLUTION; ++i) {
-               float x = double(i) / LANCZOS_RESOLUTION - LANCZOS_RADIUS;
+       for (int i = 0; i < LANCZOS_RADIUS * LANCZOS_RESOLUTION; ++i) {
+               float x = double(i) / LANCZOS_RESOLUTION;
                lanczos_table[i] = lanczos_weight(x);
        }
 }
                lanczos_table[i] = lanczos_weight(x);
        }
 }
index 55bc61cc3ca146147e0ba31b68c303e8b387493f..f9aeb110060a0501b1e79255fa0edbab2a156ecb 100644 (file)
@@ -26,13 +26,13 @@ inline double lanczos_weight(double x)
        return sinc(M_PI * x) * sinc(M_PI * x / LANCZOS_RADIUS);
 }
 
        return sinc(M_PI * x) * sinc(M_PI * x / LANCZOS_RADIUS);
 }
 
-extern double lanczos_table[(LANCZOS_RADIUS * 2) * LANCZOS_RESOLUTION];
+extern double lanczos_table[LANCZOS_RADIUS * LANCZOS_RESOLUTION];
 void make_lanczos_weight_table();
 
 inline double lanczos_weight_table(double x)
 {
 void make_lanczos_weight_table();
 
 inline double lanczos_weight_table(double x)
 {
-       int table_id = lrintf((x + LANCZOS_RADIUS) * LANCZOS_RESOLUTION);
-       if (table_id < 0 || table_id >= (LANCZOS_RADIUS * 2) * LANCZOS_RESOLUTION) {
+       int table_id = lrintf(fabs(x) * LANCZOS_RESOLUTION);
+       if (table_id >= LANCZOS_RADIUS * LANCZOS_RESOLUTION) {
                return 0.0;
        }
        return lanczos_table[table_id];
                return 0.0;
        }
        return lanczos_table[table_id];