changeset 7719:41e8d0916c60

Fix for audio filters on big endian cpus. It's working now on Solaris SPARC & x86
author jkeil
date Sat, 12 Oct 2002 20:02:01 +0000
parents 05ded2e1327a
children c6aa14b47d03
files libaf/af_format.c libaf/af_resample.c libao2/afmt.h
diffstat 3 files changed, 25 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_format.c	Sat Oct 12 16:40:56 2002 +0000
+++ b/libaf/af_format.c	Sat Oct 12 20:02:01 2002 +0000
@@ -28,6 +28,12 @@
 #define LE 		(1<<2) // Little Endian
 #define END_MASK	(1<<2)
 
+#if WORDS_BIGENDIAN	       // native endian of cpu
+#define	NE	BE
+#else
+#define	NE	LE
+#endif
+
 // Signed
 #define US		(0<<3) // Un Signed
 #define SI		(1<<3) // SIgned
@@ -128,8 +134,8 @@
 
   la = l->audio;
 
-  // Change to little endian
-  if((cf&END_MASK)!=LE){
+  // Change to cpu native endian
+  if((cf&END_MASK)!=NE){
     switch(cf&NBITS_MASK){
     case(B16):{
       register uint16_t s;
@@ -150,6 +156,7 @@
     break;
     }
   }
+
   // Change signed/unsigned
   if((cf&SIGN_MASK) != (lf&SIGN_MASK)){
     switch((cf&NBITS_MASK)){
@@ -234,8 +241,9 @@
       break;      
     }
   }
-  // Switch to the correct endainess (again the problem with sun?)
-  if((lf&END_MASK)!=LE){
+
+  // Switch from cpu native endian to the correct endianess 
+  if((lf&END_MASK)!=NE){
     switch(lf&NBITS_MASK){
     case(B16):{
       register uint16_t s;
--- a/libaf/af_resample.c	Sat Oct 12 16:40:56 2002 +0000
+++ b/libaf/af_resample.c	Sat Oct 12 20:02:01 2002 +0000
@@ -212,11 +212,11 @@
 
     // Set parameters
     af->data->nch    = n->nch;
-    af->data->format = AFMT_S16_LE;
+    af->data->format = AFMT_S16_NE;
     af->data->bps    = 2;
     if(af->data->format != n->format || af->data->bps != n->bps)
       rv = AF_FALSE;
-    n->format = AFMT_S16_LE;
+    n->format = AFMT_S16_NE;
     n->bps = 2;
 
     // Calculate up and down sampling factors
--- a/libao2/afmt.h	Sat Oct 12 16:40:56 2002 +0000
+++ b/libao2/afmt.h	Sat Oct 12 20:02:01 2002 +0000
@@ -36,3 +36,14 @@
 # define AFMT_S32_BE              0x00002000
 #endif
 
+
+/* native endian formats */
+#ifndef	AFMT_S16_NE
+# if WORDS_BIGENDIAN
+#  define AFMT_S16_NE	AFMT_S16_BE
+#  define AFMT_S32_NE	AFMT_S32_BE
+# else
+#  define AFMT_S16_NE	AFMT_S16_LE
+#  define AFMT_S32_NE	AFMT_S32_LE
+# endif
+#endif