[vlc-devel] commit: Fixed undenormalise for 64 bits. (Laurent Aimar )
git version control
git at videolan.org
Sun Jul 20 00:52:00 CEST 2008
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Jul 19 22:39:48 2008 +0200| [8400d104d4236612af4b31ea1852383dcfe31c7f]
Fixed undenormalise for 64 bits.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8400d104d4236612af4b31ea1852383dcfe31c7f
---
modules/audio_filter/spatializer/allpass.hpp | 3 +--
modules/audio_filter/spatializer/comb.hpp | 8 +++-----
modules/audio_filter/spatializer/denormals.h | 12 ++++++++++--
3 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/modules/audio_filter/spatializer/allpass.hpp b/modules/audio_filter/spatializer/allpass.hpp
index f907667..5a5a85f 100644
--- a/modules/audio_filter/spatializer/allpass.hpp
+++ b/modules/audio_filter/spatializer/allpass.hpp
@@ -32,8 +32,7 @@ inline float allpass::process(float input)
float output;
float bufout;
- bufout = buffer[bufidx];
- undenormalise(bufout);
+ bufout = undenormalise( buffer[bufidx] );
output = -input + bufout;
buffer[bufidx] = input + (bufout*feedback);
diff --git a/modules/audio_filter/spatializer/comb.hpp b/modules/audio_filter/spatializer/comb.hpp
index 2da83db..8d35e90 100644
--- a/modules/audio_filter/spatializer/comb.hpp
+++ b/modules/audio_filter/spatializer/comb.hpp
@@ -37,13 +37,11 @@ inline float comb::process(float input)
{
float output;
- output = buffer[bufidx];
- undenormalise(output);
+ output = undenormalise( buffer[bufidx] );
- filterstore = (output*damp2) + (filterstore*damp1);
- undenormalise(filterstore);
+ filterstore = undenormalise( output*damp2 + filterstore*damp1 );
- buffer[bufidx] = input + (filterstore*feedback);
+ buffer[bufidx] = input + filterstore*feedback;
if(++bufidx>=bufsize) bufidx = 0;
diff --git a/modules/audio_filter/spatializer/denormals.h b/modules/audio_filter/spatializer/denormals.h
index f871412..bab45c6 100644
--- a/modules/audio_filter/spatializer/denormals.h
+++ b/modules/audio_filter/spatializer/denormals.h
@@ -8,8 +8,16 @@
#ifndef _denormals_
#define _denormals_
-#define undenormalise(sample) if(((*(unsigned int*)&sample)&0x7f800000)==0) sample=0.0f
+#include <stdint.h>
+
+static inline float undenormalise( float f )
+{
+ union { float f; uint32_t u; } data;
+ data.f = f;
+ if( (data.u & 0x7f800000) == 0 )
+ return 0.0;
+ return f;
+}
#endif//_denormals_
-//ends
More information about the vlc-devel
mailing list