[linux-audio-dev] swh plugins and fixing undenormalize

Steve Harris S.W.Harris at ecs.soton.ac.uk
Thu Jun 24 09:17:53 UTC 2004


On Thu, Jun 24, 2004 at 05:31:30 +1000, Erik de Castro Lopo wrote:
> Since the problem is denormalised numbers, has anybody thought of
> adding a small DC offset (1e-15) or alternating the addition/subraction
> of a small value?

Yes. I use it in some places.

The problem with addition is that denormals tend to bite in feedback
loops, where DC offsets are a bit of a pain.

You can do

y += delta
y -= delta

but youre at the mercy of the optimiser.
 
> If I had a spare couple of hours I'd benchmark it myself. 

There is some stuff online about it.

A C99 safe version of the obove macro (with a bit of extension, to catch
"P4 denormals") is:

typedef union {
        float f;
        int32_t i;
} ls_pcast32;

static inline float flush_to_zero(float f)
{
        ls_pcast32 v;

        v.f = f;

        // original: return (v.i & 0x7f800000) == 0 ? 0.0f : f;
        // version from Tim Blechmann:
        return (v.i & 0x7f800000) < 0x08000000 ? 0.0f : f;
}

- Steve



More information about the Linux-audio-dev mailing list