From 84f62ff08eec5a485814c77ab4e06967ff470e33 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Sat, 17 Jul 2004 12:26:33 +0000 Subject: [PATCH] Use if present. Patches applied: * erikd@miles--2004/libsndfile--stable--0--patch-3 ChangeLog --- ChangeLog | 17 +++++++++++++++++ configure.ac | 1 + src/sfendian.h | 22 ++++++++++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 90fb6476..fe744b02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2004-07-17 Erik de Castro Lopo + + * src/pcm.c + When converting from unsigned char to float or double, subtract 128 before + converting to float/double rather than after to save a floating point + operation as suggested by Stefan Briesenick. + + * src/(pcm|sfendian|alaw|ulaw|double64|float32).c + Optimize inner loops by changing the loop counting slightly as suggested + by Stefan Briesenick. + + * configure.ac + Detect presence of . + + * src/sfendian.h + Use if present. + 2004-07-02 Erik de Castro Lopo * src/common.h src/*.c diff --git a/configure.ac b/configure.ac index b4a794ff..de90ef53 100644 --- a/configure.ac +++ b/configure.ac @@ -44,6 +44,7 @@ if test "x-$build_os-$host_os-$target_os" = x-mingw32-mingw32-mingw32 ; then AC_HEADER_STDC AC_CHECK_HEADERS(endian.h) +AC_CHECK_HEADERS(byteswap.h) AC_HEADER_SYS_WAIT AC_CHECK_DECLS(S_IRGRP) diff --git a/src/sfendian.h b/src/sfendian.h index fdff5730..59941016 100644 --- a/src/sfendian.h +++ b/src/sfendian.h @@ -16,7 +16,21 @@ ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "config.h" +#include "config.h" + +#if HAVE_BYTESWAP_H + +#include + +#define ENDSWAP_SHORT(x) bswap_16 (x) +#define ENDSWAP_INT(x) bswap_32 (x) + +#else + +#define ENDSWAP_SHORT(x) ((((x)>>8)&0xFF)+(((x)&0xFF)<<8)) +#define ENDSWAP_INT(x) ((((x)>>24)&0xFF)+(((x)>>8)&0xFF00)+(((x)&0xFF00)<<8)+(((x)&0xFF)<<24)) + +#endif /* ** Many file types (ie WAV, AIFF) use sets of four consecutive bytes as a @@ -33,10 +47,6 @@ #error "Target CPU endian-ness unknown. May need to hand edit src/config.h" #endif -/* wo standard endswap macros. */ - -#define ENDSWAP_SHORT(x) ((((x)>>8)&0xFF)+(((x)&0xFF)<<8)) -#define ENDSWAP_INT(x) ((((x)>>24)&0xFF)+(((x)>>8)&0xFF00)+(((x)&0xFF00)<<8)+(((x)&0xFF)<<24)) /* ** Macros to handle reading of data of a specific endian-ness into host endian ** shorts and ints. The single input is an unsigned char* pointer to the start @@ -96,7 +106,7 @@ void endswap_long_copy (long *dest, long *src, int len) ; /* ** Do not edit or modify anything in this comment block. -** The arch-tag line is a file identity tag for the GNU Arch +** The arch-tag line is a file identity tag for the GNU Arch ** revision control system. ** ** arch-tag: f0c5cd54-42d3-4237-90ec-11fe24995de7