Mercurial > libavutil.hg
comparison intreadwrite.h @ 371:30e766822b5a libavutil
* renaming (ST|LD)(16|32|64) -> AV_(R|W)N(16|32|64)
author | romansh |
---|---|
date | Thu, 09 Aug 2007 17:01:15 +0000 |
parents | c2034e89e9a2 |
children | d0f3bb6e367e |
comparison
equal
deleted
inserted
replaced
370:de3dc287f939 | 371:30e766822b5a |
---|---|
26 | 26 |
27 struct unaligned_64 { uint64_t l; } __attribute__((packed)); | 27 struct unaligned_64 { uint64_t l; } __attribute__((packed)); |
28 struct unaligned_32 { uint32_t l; } __attribute__((packed)); | 28 struct unaligned_32 { uint32_t l; } __attribute__((packed)); |
29 struct unaligned_16 { uint16_t l; } __attribute__((packed)); | 29 struct unaligned_16 { uint16_t l; } __attribute__((packed)); |
30 | 30 |
31 #define LD16(a) (((const struct unaligned_16 *) (a))->l) | 31 #define AV_RN16(a) (((const struct unaligned_16 *) (a))->l) |
32 #define LD32(a) (((const struct unaligned_32 *) (a))->l) | 32 #define AV_RN32(a) (((const struct unaligned_32 *) (a))->l) |
33 #define LD64(a) (((const struct unaligned_64 *) (a))->l) | 33 #define AV_RN64(a) (((const struct unaligned_64 *) (a))->l) |
34 | 34 |
35 #define ST16(a, b) (((struct unaligned_16 *) (a))->l) = (b) | 35 #define AV_WN16(a, b) (((struct unaligned_16 *) (a))->l) = (b) |
36 #define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b) | 36 #define AV_WN32(a, b) (((struct unaligned_32 *) (a))->l) = (b) |
37 #define ST64(a, b) (((struct unaligned_64 *) (a))->l) = (b) | 37 #define AV_WN64(a, b) (((struct unaligned_64 *) (a))->l) = (b) |
38 | 38 |
39 #else /* __GNUC__ */ | 39 #else /* __GNUC__ */ |
40 | 40 |
41 #define LD16(a) (*((uint16_t*)(a))) | 41 #define AV_RN16(a) (*((uint16_t*)(a))) |
42 #define LD32(a) (*((uint32_t*)(a))) | 42 #define AV_RN32(a) (*((uint32_t*)(a))) |
43 #define LD64(a) (*((uint64_t*)(a))) | 43 #define AV_RN64(a) (*((uint64_t*)(a))) |
44 | 44 |
45 #define ST16(a, b) *((uint16_t*)(a)) = (b) | 45 #define AV_WN16(a, b) *((uint16_t*)(a)) = (b) |
46 #define ST32(a, b) *((uint32_t*)(a)) = (b) | 46 #define AV_WN32(a, b) *((uint32_t*)(a)) = (b) |
47 #define ST64(a, b) *((uint64_t*)(a)) = (b) | 47 #define AV_WN64(a, b) *((uint64_t*)(a)) = (b) |
48 | 48 |
49 #endif /* !__GNUC__ */ | 49 #endif /* !__GNUC__ */ |
50 | 50 |
51 /* endian macros */ | 51 /* endian macros */ |
52 #define AV_RB8(x) (((uint8_t*)(x))[0]) | 52 #define AV_RB8(x) (((uint8_t*)(x))[0]) |
55 #define AV_RL8(x) AV_RB8(x) | 55 #define AV_RL8(x) AV_RB8(x) |
56 #define AV_WL8(p, d) AV_WB8(p, d) | 56 #define AV_WL8(p, d) AV_WB8(p, d) |
57 | 57 |
58 #ifdef HAVE_FAST_UNALIGNED | 58 #ifdef HAVE_FAST_UNALIGNED |
59 # ifdef WORDS_BIGENDIAN | 59 # ifdef WORDS_BIGENDIAN |
60 # define AV_RB16(x) LD16(x) | 60 # define AV_RB16(x) AV_RN16(x) |
61 # define AV_WB16(p, d) ST16(p, d) | 61 # define AV_WB16(p, d) AV_WN16(p, d) |
62 | 62 |
63 # define AV_RL16(x) bswap_16(LD16(x)) | 63 # define AV_RL16(x) bswap_16(AV_RN16(x)) |
64 # define AV_WL16(p, d) ST16(p, bswap_16(d)) | 64 # define AV_WL16(p, d) AV_WN16(p, bswap_16(d)) |
65 # else /* WORDS_BIGENDIAN */ | 65 # else /* WORDS_BIGENDIAN */ |
66 # define AV_RB16(x) bswap_16(LD16(x)) | 66 # define AV_RB16(x) bswap_16(AV_RN16(x)) |
67 # define AV_WB16(p, d) ST16(p, bswap_16(d)) | 67 # define AV_WB16(p, d) AV_WN16(p, bswap_16(d)) |
68 | 68 |
69 # define AV_RL16(x) LD16(x) | 69 # define AV_RL16(x) AV_RN16(x) |
70 # define AV_WL16(p, d) ST16(p, d) | 70 # define AV_WL16(p, d) AV_WN16(p, d) |
71 # endif | 71 # endif |
72 #else /* HAVE_FAST_UNALIGNED */ | 72 #else /* HAVE_FAST_UNALIGNED */ |
73 #define AV_RB16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) | 73 #define AV_RB16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) |
74 #define AV_WB16(p, d) do { \ | 74 #define AV_WB16(p, d) do { \ |
75 ((uint8_t*)(p))[1] = (d); \ | 75 ((uint8_t*)(p))[1] = (d); \ |
98 ((uint8_t*)(p))[1] = (d)>>8; \ | 98 ((uint8_t*)(p))[1] = (d)>>8; \ |
99 ((uint8_t*)(p))[2] = (d)>>16; } while(0) | 99 ((uint8_t*)(p))[2] = (d)>>16; } while(0) |
100 | 100 |
101 #ifdef HAVE_FAST_UNALIGNED | 101 #ifdef HAVE_FAST_UNALIGNED |
102 # ifdef WORDS_BIGENDIAN | 102 # ifdef WORDS_BIGENDIAN |
103 # define AV_RB32(x) LD32(x) | 103 # define AV_RB32(x) AV_RN32(x) |
104 # define AV_WB32(p, d) ST32(p, d) | 104 # define AV_WB32(p, d) AV_WN32(p, d) |
105 | 105 |
106 # define AV_RL32(x) bswap_32(LD32(x)) | 106 # define AV_RL32(x) bswap_32(AV_RN32(x)) |
107 # define AV_WL32(p, d) ST32(p, bswap_32(d)) | 107 # define AV_WL32(p, d) AV_WN32(p, bswap_32(d)) |
108 # else /* WORDS_BIGENDIAN */ | 108 # else /* WORDS_BIGENDIAN */ |
109 # define AV_RB32(x) bswap_32(LD32(x)) | 109 # define AV_RB32(x) bswap_32(AV_RN32(x)) |
110 # define AV_WB32(p, d) ST32(p, bswap_32(d)) | 110 # define AV_WB32(p, d) AV_WN32(p, bswap_32(d)) |
111 | 111 |
112 # define AV_RL32(x) LD32(x) | 112 # define AV_RL32(x) AV_RN32(x) |
113 # define AV_WL32(p, d) ST32(p, d) | 113 # define AV_WL32(p, d) AV_WN32(p, d) |
114 # endif | 114 # endif |
115 #else /* HAVE_FAST_UNALIGNED */ | 115 #else /* HAVE_FAST_UNALIGNED */ |
116 #define AV_RB32(x) ((((uint8_t*)(x))[0] << 24) | \ | 116 #define AV_RB32(x) ((((uint8_t*)(x))[0] << 24) | \ |
117 (((uint8_t*)(x))[1] << 16) | \ | 117 (((uint8_t*)(x))[1] << 16) | \ |
118 (((uint8_t*)(x))[2] << 8) | \ | 118 (((uint8_t*)(x))[2] << 8) | \ |
134 ((uint8_t*)(p))[3] = (d)>>24; } while(0) | 134 ((uint8_t*)(p))[3] = (d)>>24; } while(0) |
135 #endif | 135 #endif |
136 | 136 |
137 #ifdef HAVE_FAST_UNALIGNED | 137 #ifdef HAVE_FAST_UNALIGNED |
138 # ifdef WORDS_BIGENDIAN | 138 # ifdef WORDS_BIGENDIAN |
139 # define AV_RB64(x) LD64(x) | 139 # define AV_RB64(x) AV_RN64(x) |
140 # define AV_WB64(p, d) ST64(p, d) | 140 # define AV_WB64(p, d) AV_WN64(p, d) |
141 | 141 |
142 # define AV_RL64(x) bswap_64(LD64(x)) | 142 # define AV_RL64(x) bswap_64(AV_RN64(x)) |
143 # define AV_WL64(p, d) ST64(p, bswap_64(d)) | 143 # define AV_WL64(p, d) AV_WN64(p, bswap_64(d)) |
144 # else /* WORDS_BIGENDIAN */ | 144 # else /* WORDS_BIGENDIAN */ |
145 # define AV_RB64(x) bswap_64(LD64(x)) | 145 # define AV_RB64(x) bswap_64(AV_RN64(x)) |
146 # define AV_WB64(p, d) ST64(p, bswap_64(d)) | 146 # define AV_WB64(p, d) AV_WN64(p, bswap_64(d)) |
147 | 147 |
148 # define AV_RL64(x) LD64(x) | 148 # define AV_RL64(x) AV_RN64(x) |
149 # define AV_WL64(p, d) ST64(p, d) | 149 # define AV_WL64(p, d) AV_WN64(p, d) |
150 # endif | 150 # endif |
151 #else /* HAVE_FAST_UNALIGNED */ | 151 #else /* HAVE_FAST_UNALIGNED */ |
152 #define AV_RB64(x) (((uint64_t)((uint8_t*)(x))[0] << 56) | \ | 152 #define AV_RB64(x) (((uint64_t)((uint8_t*)(x))[0] << 56) | \ |
153 ((uint64_t)((uint8_t*)(x))[1] << 48) | \ | 153 ((uint64_t)((uint8_t*)(x))[1] << 48) | \ |
154 ((uint64_t)((uint8_t*)(x))[2] << 40) | \ | 154 ((uint64_t)((uint8_t*)(x))[2] << 40) | \ |