shithub: dumb

Download patch

ref: ad75b32881b5ad9f87a60545058fdbd3bdb885c5
parent: 238f23c94bf91290bcf4bcfaf3e322551b313f8c
author: dmitrykos <[email protected]>
date: Thu Dec 14 15:41:15 EST 2017

Allow NEON resampler for WinRT (when ARM is targeted).
Disallow SSE resampler for X86 if SSE mode is not enabled by the compiler.
Fixed symbol conflict with system log2() (BlackBerry 10, PlayBook platforms were affected).

--- a/dumb/src/helpers/resampler.c
+++ b/dumb/src/helpers/resampler.c
@@ -2,7 +2,9 @@
 #include <string.h>
 #define _USE_MATH_DEFINES
 #include <math.h>
-#if (defined(_M_IX86) || defined(__i386__) || defined(_M_X64) || defined(__amd64__))
+#if (defined(_M_IX86) && (_M_IX86_FP != 0)) ||\
+    (defined(__i386__) && defined(__SSE__)) ||\
+     defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__)
 #include <xmmintrin.h>
 #define RESAMPLER_SSE
 #endif
@@ -11,7 +13,7 @@
 #if TARGET_CPU_ARM || TARGET_CPU_ARM64
 #define RESAMPLER_NEON
 #endif
-#elif (defined(__arm__) && defined(__ARM_NEON__))
+#elif (defined(__arm__) && defined(__ARM_NEON__)) || defined(_M_ARM)
 #define RESAMPLER_NEON
 #endif
 #ifdef RESAMPLER_NEON
--- a/dumb/src/it/itrender.c
+++ b/dumb/src/it/itrender.c
@@ -4091,17 +4091,17 @@
 	playing->sample_vibrato_time += playing->sample->vibrato_speed;
 }
 
-#if (defined(_MSC_VER) && _MSC_VER < 1800) || defined(__ANDROID__)
-static float log2(float x) {return (float)log(x)/(float)log(2.0f);}
-#endif
-
 static int delta_to_note(float delta, int base)
 {
+#define DUMB_LOG2(x) ((float)log((x))/(float)log(2.0f))
+
 	float note;
-	note = log2(delta * 65536.f / (float)base)*12.0f+60.5f;
+	note = DUMB_LOG2(delta * 65536.f / (float)base)*12.0f+60.5f;
 	if (note > 119) note = 119;
 	else if (note < 0) note = 0;
 	return (int)note;
+
+#undef DUMB_LOG2
 }
 
 // Period table for Protracker octaves 0-5: