Re: [linux-audio-dev] EVO 0.0.5 released , resampling (interpolation) support added

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

Subject: Re: [linux-audio-dev] EVO 0.0.5 released , resampling (interpolation) support added
From: Karl JH Millar (kmillar_AT_MIT.EDU)
Date: Tue Sep 19 2000 - 22:53:35 EEST


Okay,

I didn't understand what you were doing with the split. I'm with it now.

> one guy on music-dsp suggested
> to first subtract 0.5 from pos
> and then simply "fistl" the value (rounds to the neares integer)
> this would work if the intel FPU (but I believe that this is specified by the
> IEEE floating point standard) won't screw things when the fractional part
> equals 0.5.

This works for positive numbers at least.

> Basically the Intel FPU rounds to the nearest even number that means:
> 1.5 is rounded to 2 and 2.5 is rounded to 2 too.
> 3.5 is rounded to 4 , 4.5 is rounded to 4 too (because 4 is the nearest even)

I think what you're seeing here is that 1.5 is actually 1.5 + something small,
which the FPU correctly rounds to 2. 2.5 is 2.5 - something small, which is
again correctly rounded to 2 as well. Remember that floating point numbers
aren't exact.

> so what I had in mind is the following:
> fistl the pos value so that you get the rounded value
> store it in pos_int
> pos_fract = pos - pos_int
> if(pos_fract >= 1.0) { pos_fract -= 1.0; pos_int++; }
>
> or alternatively:
> pos -= 0.5
> and repeat the procedure above:
> fistl the pos value so that you get the rounded value
> store it in pos_int
> pos_fract = pos - pos_int
> if(pos_fract >= 1.0) { pos_fract -= 1.0; pos_int++; }

You should be able to do the latter without the last line and it should be
fine. On modern processors the latter will be significantly faster. The
subtraction is a few clock cycles (and can be pipelined). The branch in the
first case is not readily predictable, and since branch misprediction penalties
are around 10-20 cycles they will dominate the time the first method takes.

Karl.


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

This archive was generated by hypermail 2b28 : Tue Sep 19 2000 - 23:47:44 EEST