Revision ff794171

View differences:

libavutil/intreadwrite.h
38 38

  
39 39
#else /* __GNUC__ */
40 40

  
41
#define AV_RN16(a) (*((uint16_t*)(a)))
42
#define AV_RN32(a) (*((uint32_t*)(a)))
43
#define AV_RN64(a) (*((uint64_t*)(a)))
41
#define AV_RN16(a) (*((const uint16_t*)(a)))
42
#define AV_RN32(a) (*((const uint32_t*)(a)))
43
#define AV_RN64(a) (*((const uint64_t*)(a)))
44 44

  
45 45
#define AV_WN16(a, b) *((uint16_t*)(a)) = (b)
46 46
#define AV_WN32(a, b) *((uint32_t*)(a)) = (b)
......
49 49
#endif /* !__GNUC__ */
50 50

  
51 51
/* endian macros */
52
#define AV_RB8(x)     (((uint8_t*)(x))[0])
52
#define AV_RB8(x)     (((const uint8_t*)(x))[0])
53 53
#define AV_WB8(p, d)  do { ((uint8_t*)(p))[0] = (d); } while(0)
54 54

  
55 55
#define AV_RL8(x)     AV_RB8(x)
......
70 70
#  define AV_WL16(p, d) AV_WN16(p, d)
71 71
# endif
72 72
#else /* HAVE_FAST_UNALIGNED */
73
#define AV_RB16(x)  ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
73
#define AV_RB16(x)  ((((const uint8_t*)(x))[0] << 8) | ((const uint8_t*)(x))[1])
74 74
#define AV_WB16(p, d) do { \
75 75
                    ((uint8_t*)(p))[1] = (d); \
76 76
                    ((uint8_t*)(p))[0] = (d)>>8; } while(0)
77 77

  
78
#define AV_RL16(x)  ((((uint8_t*)(x))[1] << 8) | \
79
                      ((uint8_t*)(x))[0])
78
#define AV_RL16(x)  ((((const uint8_t*)(x))[1] << 8) | \
79
                      ((const uint8_t*)(x))[0])
80 80
#define AV_WL16(p, d) do { \
81 81
                    ((uint8_t*)(p))[0] = (d); \
82 82
                    ((uint8_t*)(p))[1] = (d)>>8; } while(0)
83 83
#endif
84 84

  
85
#define AV_RB24(x)  ((((uint8_t*)(x))[0] << 16) | \
86
                     (((uint8_t*)(x))[1] <<  8) | \
87
                      ((uint8_t*)(x))[2])
85
#define AV_RB24(x)  ((((const uint8_t*)(x))[0] << 16) | \
86
                     (((const uint8_t*)(x))[1] <<  8) | \
87
                      ((const uint8_t*)(x))[2])
88 88
#define AV_WB24(p, d) do { \
89 89
                    ((uint8_t*)(p))[2] = (d); \
90 90
                    ((uint8_t*)(p))[1] = (d)>>8; \
91 91
                    ((uint8_t*)(p))[0] = (d)>>16; } while(0)
92 92

  
93
#define AV_RL24(x)  ((((uint8_t*)(x))[2] << 16) | \
94
                     (((uint8_t*)(x))[1] <<  8) | \
95
                      ((uint8_t*)(x))[0])
93
#define AV_RL24(x)  ((((const uint8_t*)(x))[2] << 16) | \
94
                     (((const uint8_t*)(x))[1] <<  8) | \
95
                      ((const uint8_t*)(x))[0])
96 96
#define AV_WL24(p, d) do { \
97 97
                    ((uint8_t*)(p))[0] = (d); \
98 98
                    ((uint8_t*)(p))[1] = (d)>>8; \
......
113 113
#  define AV_WL32(p, d) AV_WN32(p, d)
114 114
# endif
115 115
#else /* HAVE_FAST_UNALIGNED */
116
#define AV_RB32(x)  ((((uint8_t*)(x))[0] << 24) | \
117
                     (((uint8_t*)(x))[1] << 16) | \
118
                     (((uint8_t*)(x))[2] <<  8) | \
119
                      ((uint8_t*)(x))[3])
116
#define AV_RB32(x)  ((((const uint8_t*)(x))[0] << 24) | \
117
                     (((const uint8_t*)(x))[1] << 16) | \
118
                     (((const uint8_t*)(x))[2] <<  8) | \
119
                      ((const uint8_t*)(x))[3])
120 120
#define AV_WB32(p, d) do { \
121 121
                    ((uint8_t*)(p))[3] = (d); \
122 122
                    ((uint8_t*)(p))[2] = (d)>>8; \
123 123
                    ((uint8_t*)(p))[1] = (d)>>16; \
124 124
                    ((uint8_t*)(p))[0] = (d)>>24; } while(0)
125 125

  
126
#define AV_RL32(x) ((((uint8_t*)(x))[3] << 24) | \
127
                    (((uint8_t*)(x))[2] << 16) | \
128
                    (((uint8_t*)(x))[1] <<  8) | \
129
                     ((uint8_t*)(x))[0])
126
#define AV_RL32(x) ((((const uint8_t*)(x))[3] << 24) | \
127
                    (((const uint8_t*)(x))[2] << 16) | \
128
                    (((const uint8_t*)(x))[1] <<  8) | \
129
                     ((const uint8_t*)(x))[0])
130 130
#define AV_WL32(p, d) do { \
131 131
                    ((uint8_t*)(p))[0] = (d); \
132 132
                    ((uint8_t*)(p))[1] = (d)>>8; \
......
149 149
#  define AV_WL64(p, d) AV_WN64(p, d)
150 150
# endif
151 151
#else /* HAVE_FAST_UNALIGNED */
152
#define AV_RB64(x)  (((uint64_t)((uint8_t*)(x))[0] << 56) | \
153
                     ((uint64_t)((uint8_t*)(x))[1] << 48) | \
154
                     ((uint64_t)((uint8_t*)(x))[2] << 40) | \
155
                     ((uint64_t)((uint8_t*)(x))[3] << 32) | \
156
                     ((uint64_t)((uint8_t*)(x))[4] << 24) | \
157
                     ((uint64_t)((uint8_t*)(x))[5] << 16) | \
158
                     ((uint64_t)((uint8_t*)(x))[6] <<  8) | \
159
                      (uint64_t)((uint8_t*)(x))[7])
152
#define AV_RB64(x)  (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
153
                     ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
154
                     ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
155
                     ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
156
                     ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
157
                     ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
158
                     ((uint64_t)((const uint8_t*)(x))[6] <<  8) | \
159
                      (uint64_t)((const uint8_t*)(x))[7])
160 160
#define AV_WB64(p, d) do { \
161 161
                    ((uint8_t*)(p))[7] = (d);     \
162 162
                    ((uint8_t*)(p))[6] = (d)>>8;  \
......
167 167
                    ((uint8_t*)(p))[1] = (d)>>48; \
168 168
                    ((uint8_t*)(p))[0] = (d)>>56; } while(0)
169 169

  
170
#define AV_RL64(x)  (((uint64_t)((uint8_t*)(x))[7] << 56) | \
171
                     ((uint64_t)((uint8_t*)(x))[6] << 48) | \
172
                     ((uint64_t)((uint8_t*)(x))[5] << 40) | \
173
                     ((uint64_t)((uint8_t*)(x))[4] << 32) | \
174
                     ((uint64_t)((uint8_t*)(x))[3] << 24) | \
175
                     ((uint64_t)((uint8_t*)(x))[2] << 16) | \
176
                     ((uint64_t)((uint8_t*)(x))[1] <<  8) | \
177
                      (uint64_t)((uint8_t*)(x))[0])
170
#define AV_RL64(x)  (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
171
                     ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
172
                     ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
173
                     ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
174
                     ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
175
                     ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
176
                     ((uint64_t)((const uint8_t*)(x))[1] <<  8) | \
177
                      (uint64_t)((const uint8_t*)(x))[0])
178 178
#define AV_WL64(p, d) do { \
179 179
                    ((uint8_t*)(p))[0] = (d);     \
180 180
                    ((uint8_t*)(p))[1] = (d)>>8;  \

Also available in: Unified diff