changeset 12486:e02a261e4c92

using bswap.h for endianness conversion
author reimar
date Tue, 18 May 2004 19:13:15 +0000
parents d6885dbe1017
children deec5d737a61
files libaf/af_format.c
diffstat 1 files changed, 3 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_format.c	Tue May 18 17:51:25 2004 +0000
+++ b/libaf/af_format.c	Tue May 18 19:13:15 2004 +0000
@@ -11,6 +11,7 @@
 #include <limits.h>
 
 #include "af.h"
+#include "../bswap.h"
 
 // Integer to float conversion through lrintf()
 #ifdef HAVE_LRINTF
@@ -379,10 +380,8 @@
   register int i;
   switch(bps){
     case(2):{
-      register uint16_t s;
       for(i=0;i<len;i++){
-	s=((uint16_t*)in)[i];
-	((uint16_t*)out)[i]=(uint16_t)(((s&0x00FF)<<8) | (s&0xFF00)>>8);
+	((uint16_t*)out)[i]=bswap_16(((uint16_t*)in)[i]);
       }
       break;
     }
@@ -398,13 +397,8 @@
       break;
     }
     case(4):{
-      register uint32_t s;
       for(i=0;i<len;i++){
-	s=((uint32_t*)in)[i];
-	((uint32_t*)out)[i]=(uint32_t)(((s&0x000000FF)<<24) | 
-				       ((s&0x0000FF00)<<8)  |
-				       ((s&0x00FF0000)>>8)  |
-				       ((s&0xFF000000)>>24));
+	((uint32_t*)out)[i]=bswap_32(((uint32_t*)in)[i]);
       }
       break;
     }