[Asterisk-Dev] MP3 library vs. endian.h

Rafal Boni rafal at pobox.com
Wed Jun 11 17:09:09 MST 2003


[...sent once with the wrong From address; apologies to the moderator if
 they see the other message and are confused...]

Folks:
	The way the MP3 library is built, it always defaults to LE mode;
	this is because endian.h defines the LITTLE_ENDIAN macro even on
	BE systems (it's not supposed to be used to guess endianness by
	itself).

	The attached patch gets rid of the hokey machine-detection stuff
	that never worked and instead uses BYTE_ORDER (I wanted to use 
	__BYTE_ORDER or _BYTE_ORDER, but my Linux and NetBSD boxes could
	not agree about which was the right one :-/) to determine if we're
	a BE or LE system.

	This makes the MP3 codec load on my NetBSD/sparc64 (and I'd guess
	all other BE systems as well); I still haven't tested it, though.

	I still see SIGFPE's from the ILBC and LPC10 codes, but the issue
	there doesn't seem to be as clear-cut.

--rafal

Index: codecs/mp3/include/L3.h
===================================================================
RCS file: /usr/cvsroot/asterisk/codecs/mp3/include/L3.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 L3.h
--- codecs/mp3/include/L3.h	12 Feb 2003 13:59:14 -0000	1.1.1.1
+++ codecs/mp3/include/L3.h	11 Jun 2003 22:44:18 -0000
@@ -36,27 +36,10 @@
 #define GLOBAL_GAIN_SCALE (4*15)
 /* #define GLOBAL_GAIN_SCALE 0 */
 
-
-#ifdef _M_IX86
-#define LITTLE_ENDIAN 1
-#endif
-
-#ifdef _M_ALPHA
-#define LITTLE_ENDIAN 1
-#endif
-
-#ifdef sparc
-#define LITTLE_ENDIAN 0
-#endif
-
-#ifndef LITTLE_ENDIAN
-#error Layer III LITTLE_ENDIAN must be defined 0 or 1
-#endif
-
 /*-----------------------------------------------------------*/
 /*---- huffman lookup tables ---*/
 /* endian dependent !!! */
-#if LITTLE_ENDIAN
+#if BYTE_ORDER == LITTLE_ENDIAN
 typedef union
 {
    int ptr;



More information about the asterisk-dev mailing list