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

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] swh plugins and fixing undenormalize
From: Steve Harris (S.W.Harris_AT_ecs.soton.ac.uk)
Date: Thu Jun 24 2004 - 12:17:53 EEST


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


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Thu Jun 24 2004 - 12:11:23 EEST