From bbabae237be4cadb52010bd8dbe0a19bd69ed783 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Wed, 5 Feb 2014 23:53:23 -0800 Subject: [PATCH] disable denormals in eq plugins --- crap_eq.h | 2 ++ crap_eq_const.h | 2 ++ crap_tube.h | 17 +---------------- crap_util.h | 12 ++++++++++++ crap_util_def.h | 8 ++++++++ 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/crap_eq.h b/crap_eq.h index 02d57ee..afe0a46 100644 --- a/crap_eq.h +++ b/crap_eq.h @@ -32,6 +32,7 @@ process(personal *data, float *out_L, float *out_R, unsigned long count) { + disable_denormals(); for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); @@ -44,6 +45,7 @@ process_double(personal *data, double *out_L, double *out_R, unsigned long count) { + disable_denormals(); for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); diff --git a/crap_eq_const.h b/crap_eq_const.h index 30e35a0..4b18a5a 100644 --- a/crap_eq_const.h +++ b/crap_eq_const.h @@ -28,6 +28,7 @@ process(personal *data, float *out_L, float *out_R, unsigned long count) { + disable_denormals(); for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); @@ -40,6 +41,7 @@ process_double(personal *data, double *out_L, double *out_R, unsigned long count) { + disable_denormals(); for (unsigned long pos = 0; pos < count; pos++) { out_L[pos] = process_one(data->filters[0], in_L[pos]); out_R[pos] = process_one(data->filters[1], in_R[pos]); diff --git a/crap_tube.h b/crap_tube.h index 67ae99e..6f030f7 100644 --- a/crap_tube.h +++ b/crap_tube.h @@ -1,13 +1,6 @@ #include -#ifdef __SSE2__ -#include -#ifndef __SSE2_MATH__ -#warning SSE2 enabled but not forced, beware denormals -#endif -#else -#warning built without SSE2, denormals will be painful -#endif +#include "crap_util.h" #define ID 0x50F7BA11 #define LABEL "crap_tube" @@ -24,14 +17,6 @@ typedef struct { double history_R[HIST_SIZE]; } personal; -static void -disable_denormals() -{ - #if __SSE2__ - _mm_setcsr(_mm_getcsr() | 0x8040); - #endif -} - static double distort(double x) { diff --git a/crap_util.h b/crap_util.h index 74db44f..037b976 100644 --- a/crap_util.h +++ b/crap_util.h @@ -1,5 +1,17 @@ #include "math.h" +#ifdef __SSE2__ +#include +#ifndef __SSE2_MATH__ +#warning SSE2 enabled but not forced, beware denormals +#endif +#else +#warning built without SSE2, denormals will be painful +#endif + +static void +disable_denormals(); + #define LIMIT(v,l,u) ((v)<(l)?(l):((v)>(u)?(u):(v))) #define DB2LIN(x) ((x) > -90 ? pow(10, (x) * 0.05) : 0) diff --git a/crap_util_def.h b/crap_util_def.h index c7c5454..3d84f32 100644 --- a/crap_util_def.h +++ b/crap_util_def.h @@ -2,6 +2,14 @@ #include #include +static void +disable_denormals() +{ + #if __SSE2__ + _mm_setcsr(_mm_getcsr() | 0x8040); + #endif +} + /* via http://www.rgba.org/articles/sfrand/sfrand.htm */ static unsigned int mirand = 1;