[SCM] calf/master: More protections against denormals.
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:40:49 UTC 2013
The following commit has been merged in the master branch:
commit 23f14c9a0d01d2e461ba7e0eaf872880fab0c313
Author: Carl Hetherington <cth at carlh.net>
Date: Sat Jan 7 09:56:36 2012 +0000
More protections against denormals.
Note from KF: I didn't apply the patch to configure.ac, as I'm not sure
if it's safe for systems that don't support SSE (ARM etc.).
diff --git a/src/calf/biquad.h b/src/calf/biquad.h
index 99cf2a4..a6d5a95 100644
--- a/src/calf/biquad.h
+++ b/src/calf/biquad.h
@@ -429,6 +429,11 @@ struct biquad_d2: public biquad_coeffs<Coeff>
/// direct II form with two state variables
inline T process(T in)
{
+ dsp::sanitize_denormal(in);
+ dsp::sanitize(in);
+ dsp::sanitize(w1);
+ dsp::sanitize(w2);
+
T tmp = in - w1 * b1 - w2 * b2;
T out = tmp * a0 + w1 * a1 + w2 * a2;
w2 = w1;
diff --git a/src/calf/primitives.h b/src/calf/primitives.h
index efc820f..cbc7758 100644
--- a/src/calf/primitives.h
+++ b/src/calf/primitives.h
@@ -408,6 +408,16 @@ inline void sanitize(float &value)
}
/**
+ * Force already-denormal float value to zero
+ */
+inline void sanitize_denormal(float& value)
+{
+ if (((*(unsigned int *) &value) & 0x7f800000) == 0) {
+ value = 0;
+ }
+}
+
+/**
* Force "small enough" double value to zero
*/
inline void sanitize(double &value)
diff --git a/src/modules_comp.cpp b/src/modules_comp.cpp
index 0a0d8ab..0ee6842 100644
--- a/src/modules_comp.cpp
+++ b/src/modules_comp.cpp
@@ -1715,7 +1715,9 @@ void gain_reduction_audio_module::process(float &left, float &right, const float
float absample = average ? (fabs(*det_left) + fabs(*det_right)) * 0.5f : std::max(fabs(*det_left), fabs(*det_right));
if(rms) absample *= absample;
-
+
+ dsp::sanitize(linSlope);
+
linSlope += (absample - linSlope) * (absample > linSlope ? attack_coeff : release_coeff);
float gain = 1.f;
if(linSlope > 0.f) {
@@ -1963,7 +1965,9 @@ void expander_audio_module::process(float &left, float &right, const float *det_
bool average = (stereo_link == 0);
float absample = average ? (fabs(*det_left) + fabs(*det_right)) * 0.5f : std::max(fabs(*det_left), fabs(*det_right));
if(rms) absample *= absample;
-
+
+ dsp::sanitize(linSlope);
+
linSlope += (absample - linSlope) * (absample > linSlope ? attack_coeff : release_coeff);
float gain = 1.f;
if(linSlope > 0.f) {
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list