00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #define SWP0312 {help = data[i] ; cdp[i*4] = ch[3] ; cdp[i*4+1] = ch[2] ; cdp[i*4+2] = ch[1] ; cdp[i*4+3] = ch[0] ;}
00021 #define SWP12 {help = data[i] ; cdp[i*4] = ch[0] ; cdp[i*4+1] = ch[2] ; cdp[i*4+2] = ch[1] ; cdp[i*4+3] = ch[3] ;}
00022 #define SWP04 { help = data[i]; cdp[i*4] = ch[3] ; cdp[i*4+1] = ch[1] ; cdp[i*4+2] = ch[2] ; cdp[i*4+3] = ch[0] ;}
00023 #define SWP_SHORT {help = data[i] ; cdp[i*4] = ch[1] ; cdp[i*4+1] = ch[0] ; cdp[i*4+2] = ch[3] ; cdp[i*4+3] = ch[2] ;}
00024
00025 namespace OLDEVP {
00026
00027 int swap_raw(int data_byte_ordering,int* data, int size)
00028 {
00029 if(data_byte_ordering == 0x04030201) return(0) ;
00030 char* cdp = (char*) data ;
00031 int help ;
00032 char* ch = (char*)&help ;
00033 int i ;
00034 if(data_byte_ordering == 0x01020304) { for(i = 0 ; i < size ;i++) SWP0312 return(1) ; }
00035 if(data_byte_ordering == 0x04020301) { for(i = 0 ; i < size ;i++)SWP12 return(2) ; }
00036 if(data_byte_ordering == 0x01030204) { for(i = 0 ; i < size ;i++)SWP04 return(3) ; }
00037 return(-1) ;
00038 };
00039
00040 int swap_short(int data_byte_ordering,int* data, int size)
00041 {
00042 if(data_byte_ordering == 0x04030201) return(0) ;
00043 char* cdp = (char*) data ;
00044 int help ;
00045 char* ch = (char*)&help ;
00046 int i ;
00047 if(data_byte_ordering == 0x01020304) { for(i = 0 ; i < size ;i++) SWP_SHORT return(1) ; }
00048 if(data_byte_ordering == 0x04020301) { return -1; }
00049 if(data_byte_ordering == 0x01030204) { return -1; }
00050 return(-1) ;
00051 }
00052 }
00053 #undef SWP0312
00054 #undef SWP12
00055 #undef SWP04
00056 #undef SWP_SHORT
00057
00058