changeset 3302:cb356bfc7e22 libavcodec

add unaligned16() and unaligned64()
author mru
date Thu, 11 May 2006 23:17:23 +0000
parents 89af006ac42d
children 68721b62a528
files bitstream.h
diffstat 1 files changed, 19 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/bitstream.h	Thu May 11 00:28:30 2006 +0000
+++ b/bitstream.h	Thu May 11 23:17:23 2006 +0000
@@ -141,25 +141,34 @@
 
 /* used to avoid missaligned exceptions on some archs (alpha, ...) */
 #if defined(ARCH_X86) || defined(ARCH_X86_64)
+#    define unaligned16(a) (*(const uint16_t*)(a))
 #    define unaligned32(a) (*(const uint32_t*)(a))
+#    define unaligned64(a) (*(const uint64_t*)(a))
 #else
 #    ifdef __GNUC__
-static inline uint32_t unaligned32(const void *v) {
-    struct Unaligned {
-        uint32_t i;
-    } __attribute__((packed));
-
-    return ((const struct Unaligned *) v)->i;
+#    define unaligned(x)                                \
+static inline uint##x##_t unaligned##x(const void *v) { \
+    struct Unaligned {                                  \
+        uint##x##_t i;                                  \
+    } __attribute__((packed));                          \
+                                                        \
+    return ((const struct Unaligned *) v)->i;           \
 }
 #    elif defined(__DECC)
-static inline uint32_t unaligned32(const void *v) {
-    return *(const __unaligned uint32_t *) v;
+#    define unaligned(x)                                        \
+static inline uint##x##_t unaligned##x##(const void *v) {       \
+    return *(const __unaligned uint##x##_t *) v;                \
 }
 #    else
-static inline uint32_t unaligned32(const void *v) {
-    return *(const uint32_t *) v;
+#    define unaligned(x)                                        \
+static inline uint##x##_t unaligned##x##(const void *v) {       \
+    return *(const uint##x##_t *) v;                            \
 }
 #    endif
+unaligned(16)
+unaligned(32)
+unaligned(64)
+#undef unaligned
 #endif //!ARCH_X86
 
 #ifndef ALT_BITSTREAM_WRITER