summaryrefslogtreecommitdiffstats
path: root/src/endianmacros.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-02 18:47:03 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-02 18:47:03 +0000
commit13b35a2489e7e1d6341effe6e25b8cb8a0a94a02 (patch)
treed058c8021b02ec17583c3a95dd8a18e27c0e1a4c /src/endianmacros.h
parent961fb4466a9396a11f1a9a6e7d4193409b8949d6 (diff)
add resampler
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@44 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/endianmacros.h')
-rw-r--r--src/endianmacros.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/endianmacros.h b/src/endianmacros.h
new file mode 100644
index 00000000..2394b3e8
--- /dev/null
+++ b/src/endianmacros.h
@@ -0,0 +1,41 @@
+#ifndef fooendianmacroshfoo
+#define fooendianmacroshfoo
+
+#include <inttypes.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define INT16_SWAP(x) ((int16_t)(((int16_t) x >> 8) | ((int16_t) x << 8)))
+#define UINT16_SWAP(x) ((uint16_t)(((uint16_t) x >> 8) | ((uint16_t) x << 8)))
+#define INT32_SWAP(x) ((int32_t)(((int32_t) x >> 24) | ((int32_t) x << 24) | (((int32_t) x & 0xFF00) << 16) | (((int32_t) x) >> 16) & 0xFF00))
+#define UINT32_SWAP(x) ((uint32_t)(((uint32_t) x >> 24) | ((uint32_t) x << 24) | (((uint32_t) x & 0xFF00) << 16) | (((uint32_t) x) >> 16) & 0xFF00))
+
+#ifdef WORDS_BIGENDIAN
+ #define INT16_FROM_LE(x) INT16_SWAP(x)
+ #define INT16_FROM_BE(x) ((int16_t)(x))
+ #define INT16_TO_LE(x) INT16_SWAP(x)
+ #define INT16_TO_BE(x) ((int16_t)(x))
+
+ #define UINT16_FROM_LE(x) UINT16_SWAP(x)
+ #define UINT16_FROM_BE(x) ((uint16_t)(x))
+ #define INT32_FROM_LE(x) INT32_SWAP(x)
+ #define INT32_FROM_BE(x) ((int32_t)(x))
+ #define UINT32_FROM_LE(x) UINT32_SWAP(x)
+ #define UINT32_FROM_BE(x) ((uint32_t)(x))
+#else
+ #define INT16_FROM_LE(x) ((int16_t)(x))
+ #define INT16_FROM_BE(x) INT16_SWAP(x)
+ #define INT16_TO_LE(x) ((int16_t)(x))
+ #define INT16_TO_BE(x) INT16_SWAP(x)
+
+ #define UINT16_FROM_LE(x) ((uint16_t)(x))
+ #define UINT16_FROM_BE(x) UINT16_SWAP(x)
+ #define INT32_FROM_LE(x) ((int32_t)(x))
+ #define INT32_FROM_BE(x) INT32_SWAP(x)
+ #define UINT32_FROM_LE(x) ((uint32_t)(x))
+ #define UINT32_FROM_BE(x) UINT32_SWAP(x)
+#endif
+
+#endif