summaryrefslogtreecommitdiff
path: root/noncore/multimedia/camera/jpegtoavi/byteswap.h
blob: 17ab6cc3ba7b11884d58aaf4cdbe1ae789885572 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef _BYTESWAP_H_
#define _BYTESWAP_H_

#include <endian.h>
#include <sys/types.h>

#ifndef BYTE_ORDER
# error "Aiee: BYTE_ORDER not defined\n";
#endif

#define SWAP2(x) (((x>>8) & 0x00ff) |\
                  ((x<<8) & 0xff00))

#define SWAP4(x) (((x>>24) & 0x000000ff) |\
                  ((x>>8)  & 0x0000ff00) |\
                  ((x<<8)  & 0x00ff0000) |\
                  ((x<<24) & 0xff000000))

#if BYTE_ORDER==BIG_ENDIAN
# define LILEND2(a) SWAP2((a))
# define LILEND4(a) SWAP4((a))
# define BIGEND2(a) (a)
# define BIGEND4(a) (a)
#else
# define LILEND2(a) (a)
# define LILEND4(a) (a)
# define BIGEND2(a) SWAP2((a))
# define BIGEND4(a) SWAP4((a))
#endif

#endif