From e876da1b38221d8020d81b72926d2dee5c2bdc55 Mon Sep 17 00:00:00 2001 From: Jamie Bullock Date: Fri, 15 Feb 2008 12:43:13 +0000 Subject: - Fixed bugs in xtract_flatness(), or at least added necessary documentation and error checking to avoid problems - Added xtract_is_denormal() helper function and XTRACT_DENORMAL_FOUND return code - Replaced all instances of log, sqrt, exp etc. with respective floating point counterparts (logf etc.) - Added check for architecture endianness to configure script - Bug fix to PD example, now no longer crashes if no arguments are given - Minor documentation updates --- src/helper.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/helper.c') diff --git a/src/helper.c b/src/helper.c index 60b3af7..e9e79e5 100644 --- a/src/helper.c +++ b/src/helper.c @@ -21,8 +21,18 @@ /* helper.c: helper functions. */ +#include + +#include + #include "xtract/libxtract.h" +#ifdef WORDS_BIGENDIAN +#define INDEX 0 +#else +#define INDEX 1 +#endif + int xtract_windowed(const float *data, const int N, const void *argv, float *result){ int n; @@ -45,8 +55,7 @@ int xtract_features_from_subframes(const float *data, const int N, const int fea float *result1, *result2; - int n, i, - rv; + int n, rv; n = N >> 1; @@ -63,3 +72,12 @@ int xtract_features_from_subframes(const float *data, const int N, const int fea return rv; } + +inline int xtract_is_denormal(double const d){ + if(sizeof(d) != 2 * sizeof(int)) + fprintf(stderr, "libxtract: Error: xtract_is_denormal() detects inconsistent wordlength for type 'double'\n"); + + int l = ((int *)&d)[INDEX]; + return (l&0x7ff00000) == 0 && d!=0; //Check for 0 may not be necessary +} + -- cgit v1.2.3