[Speex-dev] [PATCH 2/3] Use fabsf() instead of fabs() since we have floats, not double
Tristan Matthews
le.businessman at gmail.com
Tue Apr 15 12:45:43 PDT 2014
On Tue, Apr 15, 2014 at 12:33 PM, Peter Meerwald <pmeerw at pmeerw.net> wrote:
> Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
> ---
> libspeexdsp/resample.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/libspeexdsp/resample.c b/libspeexdsp/resample.c
> index e32ca45..a19b997 100644
> --- a/libspeexdsp/resample.c
> +++ b/libspeexdsp/resample.c
> @@ -85,7 +85,7 @@ static void speex_free (void *ptr) {free(ptr);}
> #ifdef FIXED_POINT
> #define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x)))
> #else
> -#define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 :
> floor(.5+(x))))
> +#define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 :
> floorf(.5+(x))))
> #endif
>
> #define IMAX(a,b) ((a) > (b) ? (a) : (b))
> @@ -273,12 +273,12 @@ static spx_word16_t sinc(float cutoff, float x, int
> N, struct FuncDef *window_fu
> {
> /*fprintf (stderr, "%f ", x);*/
> float xx = x * cutoff;
> - if (fabs(x)<1e-6f)
> + if (fabsf(x)<1e-6f)
> return WORD2INT(32768.*cutoff);
> - else if (fabs(x) > .5f*N)
> + else if (fabsf(x) > .5f*N)
> return 0;
> /*FIXME: Can it really be any slower than this? */
> - return WORD2INT(32768.*cutoff*sin(M_PI*xx)/(M_PI*xx) *
> compute_func(fabs(2.*x/N), window_func));
> + return WORD2INT(32768.*cutoff*sin(M_PI*xx)/(M_PI*xx) *
> compute_func(fabsf(2.*x/N), window_func));
> }
> #else
> /* The slow way of computing a sinc for the table. Should improve that
> some day */
> @@ -286,12 +286,12 @@ static spx_word16_t sinc(float cutoff, float x, int
> N, struct FuncDef *window_fu
> {
> /*fprintf (stderr, "%f ", x);*/
> float xx = x * cutoff;
> - if (fabs(x)<1e-6)
> + if (fabsf(x)<1e-6f)
> return cutoff;
> - else if (fabs(x) > .5*N)
> + else if (fabsf(x) > .5f*N)
> return 0;
> /*FIXME: Can it really be any slower than this? */
> - return cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N),
> window_func);
> + return cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabsf(2.*x/N),
> window_func);
> }
> #endif
>
Seems fine, fabsf is supported everywhere fabs is?
Best,
Tristan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/speex-dev/attachments/20140415/14518979/attachment.htm
More information about the Speex-dev
mailing list