Diffstat (limited to 'noncore/multimedia/camera/jpegtoavi/byteswap.h') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/jpegtoavi/byteswap.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/noncore/multimedia/camera/jpegtoavi/byteswap.h b/noncore/multimedia/camera/jpegtoavi/byteswap.h new file mode 100644 index 0000000..17ab6cc --- a/dev/null +++ b/noncore/multimedia/camera/jpegtoavi/byteswap.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef _BYTESWAP_H_ | ||
2 | #define _BYTESWAP_H_ | ||
3 | |||
4 | #include <endian.h> | ||
5 | #include <sys/types.h> | ||
6 | |||
7 | #ifndef BYTE_ORDER | ||
8 | # error "Aiee: BYTE_ORDER not defined\n"; | ||
9 | #endif | ||
10 | |||
11 | #define SWAP2(x) (((x>>8) & 0x00ff) |\ | ||
12 | ((x<<8) & 0xff00)) | ||
13 | |||
14 | #define SWAP4(x) (((x>>24) & 0x000000ff) |\ | ||
15 | ((x>>8) & 0x0000ff00) |\ | ||
16 | ((x<<8) & 0x00ff0000) |\ | ||
17 | ((x<<24) & 0xff000000)) | ||
18 | |||
19 | #if BYTE_ORDER==BIG_ENDIAN | ||
20 | # define LILEND2(a) SWAP2((a)) | ||
21 | # define LILEND4(a) SWAP4((a)) | ||
22 | # define BIGEND2(a) (a) | ||
23 | # define BIGEND4(a) (a) | ||
24 | #else | ||
25 | # define LILEND2(a) (a) | ||
26 | # define LILEND4(a) (a) | ||
27 | # define BIGEND2(a) SWAP2((a)) | ||
28 | # define BIGEND4(a) SWAP4((a)) | ||
29 | #endif | ||
30 | |||
31 | #endif | ||