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 - 20:27:05 EEST


I'm not an x86 assembly expert, but this one is pretty simple. I believe that
the way to do fp->int conversion quickly is this:

inline int double_to_int(double f) {
#ifdef __i386__
  int i;
  asm("fistpl %0" : "=m"(i) : "st"(f) );
  return i;
#else
  return (int)f;
#endif
}

inline double int_to_double(int i) {
#ifdef __i386__
  double f;
  asm("fildl %1" : "=st"(f) : "m"(i));
  return f;
#else
  return (double)i;
#endif
}

To get the routines for single-precision, just replace double with float. The
asm is the same. This should be very fast (comparable a single multiply,
although the timings vary from processor to processor).

This method makes more sense than a "portable" C only method, as for most
processors you'd expect the direct method to be optimal.

>I'll try both custom FP asm (rounding and then check if
>the fractional part is >1.0 and in that case decrement it by
>1.0 and increase the int part by 1),

Do you really want to truncate rather than round? While the C standard
specifies truncation, most audio needs would probably be better served by
rounding anyway. Is it a portability/consistency concern?

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 - 21:18:32 EEST