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 @@ +#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 |