shithub: dumb

Download patch

ref: e65a86fc81352fbd667269f22878365606e2cf2c
parent: 1fe80f166e57778b1500bb035ec9ff8d95819006
author: Chris Moeller <kode54@gmail.com>
date: Mon May 6 13:08:39 EDT 2013

Removed unnecessary optimization function

--- a/dumb/src/helpers/lanczos_resampler.c
+++ b/dumb/src/helpers/lanczos_resampler.c
@@ -13,12 +13,6 @@
 
 enum { lanczos_buffer_size = LANCZOS_WIDTH * 4 };
 
-int my_abs(int in)
-{
-	int const mask = in >> sizeof(int) * CHAR_BIT - 1;
-	return (in + mask) ^ mask;
-}
-
 int fEqual(const double b, const double a)
 {
 	return fabs(a - b) < 1.0e-6;
@@ -34,7 +28,7 @@
 	unsigned i;
 	double dx = (double)(LANCZOS_WIDTH) / LANCZOS_SAMPLES, x = 0.0;
 	for (i = 0; i < LANCZOS_SAMPLES + 1; ++i, x += dx)
-		lanczos_lut[i] = my_abs(x) < LANCZOS_WIDTH ? sinc(x) * sinc(x / LANCZOS_WIDTH) : 0.0;
+		lanczos_lut[i] = abs(x) < LANCZOS_WIDTH ? sinc(x) * sinc(x / LANCZOS_WIDTH) : 0.0;
 }
 
 typedef struct lanczos_resampler
@@ -164,7 +158,7 @@
 			for (; i >= -LANCZOS_WIDTH + 1; --i)
 			{
 				int pos = i * step;
-				kernel_sum += kernel[i + LANCZOS_WIDTH - 1] = lanczos_lut[my_abs(phase_adj - pos)];
+				kernel_sum += kernel[i + LANCZOS_WIDTH - 1] = lanczos_lut[abs(phase_adj - pos)];
 			}
 			for (sample = 0, i = 0; i < LANCZOS_WIDTH * 2; ++i)
 				sample += in[i] * kernel[i];