comparison bitstream.h @ 3302:cb356bfc7e22 libavcodec

add unaligned16() and unaligned64()
author mru
date Thu, 11 May 2006 23:17:23 +0000
parents b9a0ca749833
children ff5bed27d7ca
comparison
equal deleted inserted replaced
3301:89af006ac42d 3302:cb356bfc7e22
139 #define UNALIGNED_STORES_ARE_BAD 139 #define UNALIGNED_STORES_ARE_BAD
140 #endif 140 #endif
141 141
142 /* used to avoid missaligned exceptions on some archs (alpha, ...) */ 142 /* used to avoid missaligned exceptions on some archs (alpha, ...) */
143 #if defined(ARCH_X86) || defined(ARCH_X86_64) 143 #if defined(ARCH_X86) || defined(ARCH_X86_64)
144 # define unaligned16(a) (*(const uint16_t*)(a))
144 # define unaligned32(a) (*(const uint32_t*)(a)) 145 # define unaligned32(a) (*(const uint32_t*)(a))
146 # define unaligned64(a) (*(const uint64_t*)(a))
145 #else 147 #else
146 # ifdef __GNUC__ 148 # ifdef __GNUC__
147 static inline uint32_t unaligned32(const void *v) { 149 # define unaligned(x) \
148 struct Unaligned { 150 static inline uint##x##_t unaligned##x(const void *v) { \
149 uint32_t i; 151 struct Unaligned { \
150 } __attribute__((packed)); 152 uint##x##_t i; \
151 153 } __attribute__((packed)); \
152 return ((const struct Unaligned *) v)->i; 154 \
155 return ((const struct Unaligned *) v)->i; \
153 } 156 }
154 # elif defined(__DECC) 157 # elif defined(__DECC)
155 static inline uint32_t unaligned32(const void *v) { 158 # define unaligned(x) \
156 return *(const __unaligned uint32_t *) v; 159 static inline uint##x##_t unaligned##x##(const void *v) { \
160 return *(const __unaligned uint##x##_t *) v; \
157 } 161 }
158 # else 162 # else
159 static inline uint32_t unaligned32(const void *v) { 163 # define unaligned(x) \
160 return *(const uint32_t *) v; 164 static inline uint##x##_t unaligned##x##(const void *v) { \
165 return *(const uint##x##_t *) v; \
161 } 166 }
162 # endif 167 # endif
168 unaligned(16)
169 unaligned(32)
170 unaligned(64)
171 #undef unaligned
163 #endif //!ARCH_X86 172 #endif //!ARCH_X86
164 173
165 #ifndef ALT_BITSTREAM_WRITER 174 #ifndef ALT_BITSTREAM_WRITER
166 static inline void put_bits(PutBitContext *s, int n, unsigned int value) 175 static inline void put_bits(PutBitContext *s, int n, unsigned int value)
167 { 176 {