Use <byteswap.h> if present.

Patches applied:

 * erikd@miles--2004/libsndfile--stable--0--patch-3
   ChangeLog
This commit is contained in:
Erik de Castro Lopo 2004-07-17 12:26:33 +00:00
parent 709d860427
commit 84f62ff08e
3 changed files with 34 additions and 6 deletions

View File

@ -1,3 +1,20 @@
2004-07-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* 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 <byteswap.h>.
* src/sfendian.h
Use <byteswap.h> if present.
2004-07-02 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/common.h src/*.c

View File

@ -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)

View File

@ -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 <byteswap.h>
#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