20 #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] ;}
21 #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] ;}
22 #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] ;}
23 #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] ;}
27 int swap_raw(
int data_byte_ordering,
int*
data,
int size)
29 if(data_byte_ordering == 0x04030201)
return(0) ;
30 char* cdp = (
char*) data ;
32 char* ch = (
char*)&help ;
34 if(data_byte_ordering == 0x01020304) {
for(i = 0 ; i < size ;i++) SWP0312
return(1) ; }
35 if(data_byte_ordering == 0x04020301) {
for(i = 0 ; i < size ;i++)SWP12
return(2) ; }
36 if(data_byte_ordering == 0x01030204) {
for(i = 0 ; i < size ;i++)SWP04
return(3) ; }
40 int swap_short(
int data_byte_ordering,
int* data,
int size)
42 if(data_byte_ordering == 0x04030201)
return(0) ;
43 char* cdp = (
char*) data ;
45 char* ch = (
char*)&help ;
47 if(data_byte_ordering == 0x01020304) {
for(i = 0 ; i < size ;i++) SWP_SHORT
return(1) ; }
48 if(data_byte_ordering == 0x04020301) {
return -1; }
49 if(data_byte_ordering == 0x01030204) {
return -1; }