4 /* It's need for ffmpeg. Else where will be defined ARCH_X86?*/
14 inline static unsigned short ByteSwap16(unsigned short x)
16 __asm("xchgb %b0,%h0" :
21 #define bswap_16(x) ByteSwap16(x)
23 inline static unsigned int ByteSwap32(unsigned int x)
29 __asm("xchgb %b0,%h0\n"
37 #define bswap_32(x) ByteSwap32(x)
39 inline static unsigned long long int ByteSwap64(unsigned long long int x)
41 register union { __extension__ unsigned long long int __ll;
42 unsigned long int __l[2]; } __x;
44 "=r"(__x.__l[0]),"=r"(__x.__l[1]):
45 "0"(bswap_32((unsigned long)x)),"1"(bswap_32((unsigned long)(x>>32))));
48 #define bswap_64(x) ByteSwap64(x)
52 #define bswap_16(x) (((x) & 0x00ff) << 8 | ((x) & 0xff00) >> 8)
55 // code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc.
57 ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
58 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
62 ({ union { __extension__ unsigned long long int __ll; \
63 unsigned long int __l[2]; } __w, __r; \
65 __r.__l[0] = bswap_32 (__w.__l[1]); \
66 __r.__l[1] = bswap_32 (__w.__l[0]); \
68 #endif /* !ARCH_X86 */
70 #endif /* !HAVE_BYTESWAP_H */
72 // be2me ... BigEndian to MachineEndian
73 // le2me ... LittleEndian to MachineEndian
75 #ifdef WORDS_BIGENDIAN
76 #define be2me_16(x) (x)
77 #define be2me_32(x) (x)
78 #define be2me_64(x) (x)
79 #define le2me_16(x) bswap_16(x)
80 #define le2me_32(x) bswap_32(x)
81 #define le2me_64(x) bswap_64(x)
83 #define be2me_16(x) bswap_16(x)
84 #define be2me_32(x) bswap_32(x)
85 #define be2me_64(x) bswap_64(x)
86 #define le2me_16(x) (x)
87 #define le2me_32(x) (x)
88 #define le2me_64(x) (x)