FFmpeg
intreadwrite.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVUTIL_INTREADWRITE_H
20 #define AVUTIL_INTREADWRITE_H
21 
22 #include <stdint.h>
23 #include "libavutil/avconfig.h"
24 #include "attributes.h"
25 #include "bswap.h"
26 
27 typedef union {
28  uint64_t u64;
29  uint32_t u32[2];
30  uint16_t u16[4];
31  uint8_t u8 [8];
32  double f64;
33  float f32[2];
34 } av_alias av_alias64;
35 
36 typedef union {
37  uint32_t u32;
38  uint16_t u16[2];
39  uint8_t u8 [4];
40  float f32;
41 } av_alias av_alias32;
42 
43 typedef union {
44  uint16_t u16;
45  uint8_t u8 [2];
46 } av_alias av_alias16;
47 
48 /*
49  * Arch-specific headers can provide any combination of
50  * AV_[RW][BLN](16|24|32|48|64) and AV_(COPY|SWAP|ZERO)(64|128) macros.
51  * Preprocessor symbols must be defined, even if these are implemented
52  * as inline functions.
53  *
54  * R/W means read/write, B/L/N means big/little/native endianness.
55  * The following macros require aligned access, compared to their
56  * unaligned variants: AV_(COPY|SWAP|ZERO)(64|128), AV_[RW]N[8-64]A.
57  * Incorrect usage may range from abysmal performance to crash
58  * depending on the platform.
59  *
60  * The unaligned variants are AV_[RW][BLN][8-64] and AV_COPY*U.
61  */
62 
63 #ifdef HAVE_AV_CONFIG_H
64 
65 #include "config.h"
66 
67 #if ARCH_ARM
68 # include "arm/intreadwrite.h"
69 #elif ARCH_AVR32
70 # include "avr32/intreadwrite.h"
71 #elif ARCH_MIPS
72 # include "mips/intreadwrite.h"
73 #elif ARCH_PPC
74 # include "ppc/intreadwrite.h"
75 #elif ARCH_X86
76 # include "x86/intreadwrite.h"
77 #endif
78 
79 #endif /* HAVE_AV_CONFIG_H */
80 
81 /*
82  * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
83  */
84 
85 #if AV_HAVE_BIGENDIAN
86 
87 # if defined(AV_RN16) && !defined(AV_RB16)
88 # define AV_RB16(p) AV_RN16(p)
89 # elif !defined(AV_RN16) && defined(AV_RB16)
90 # define AV_RN16(p) AV_RB16(p)
91 # endif
92 
93 # if defined(AV_WN16) && !defined(AV_WB16)
94 # define AV_WB16(p, v) AV_WN16(p, v)
95 # elif !defined(AV_WN16) && defined(AV_WB16)
96 # define AV_WN16(p, v) AV_WB16(p, v)
97 # endif
98 
99 # if defined(AV_RN24) && !defined(AV_RB24)
100 # define AV_RB24(p) AV_RN24(p)
101 # elif !defined(AV_RN24) && defined(AV_RB24)
102 # define AV_RN24(p) AV_RB24(p)
103 # endif
104 
105 # if defined(AV_WN24) && !defined(AV_WB24)
106 # define AV_WB24(p, v) AV_WN24(p, v)
107 # elif !defined(AV_WN24) && defined(AV_WB24)
108 # define AV_WN24(p, v) AV_WB24(p, v)
109 # endif
110 
111 # if defined(AV_RN32) && !defined(AV_RB32)
112 # define AV_RB32(p) AV_RN32(p)
113 # elif !defined(AV_RN32) && defined(AV_RB32)
114 # define AV_RN32(p) AV_RB32(p)
115 # endif
116 
117 # if defined(AV_WN32) && !defined(AV_WB32)
118 # define AV_WB32(p, v) AV_WN32(p, v)
119 # elif !defined(AV_WN32) && defined(AV_WB32)
120 # define AV_WN32(p, v) AV_WB32(p, v)
121 # endif
122 
123 # if defined(AV_RN48) && !defined(AV_RB48)
124 # define AV_RB48(p) AV_RN48(p)
125 # elif !defined(AV_RN48) && defined(AV_RB48)
126 # define AV_RN48(p) AV_RB48(p)
127 # endif
128 
129 # if defined(AV_WN48) && !defined(AV_WB48)
130 # define AV_WB48(p, v) AV_WN48(p, v)
131 # elif !defined(AV_WN48) && defined(AV_WB48)
132 # define AV_WN48(p, v) AV_WB48(p, v)
133 # endif
134 
135 # if defined(AV_RN64) && !defined(AV_RB64)
136 # define AV_RB64(p) AV_RN64(p)
137 # elif !defined(AV_RN64) && defined(AV_RB64)
138 # define AV_RN64(p) AV_RB64(p)
139 # endif
140 
141 # if defined(AV_WN64) && !defined(AV_WB64)
142 # define AV_WB64(p, v) AV_WN64(p, v)
143 # elif !defined(AV_WN64) && defined(AV_WB64)
144 # define AV_WN64(p, v) AV_WB64(p, v)
145 # endif
146 
147 #else /* AV_HAVE_BIGENDIAN */
148 
149 # if defined(AV_RN16) && !defined(AV_RL16)
150 # define AV_RL16(p) AV_RN16(p)
151 # elif !defined(AV_RN16) && defined(AV_RL16)
152 # define AV_RN16(p) AV_RL16(p)
153 # endif
154 
155 # if defined(AV_WN16) && !defined(AV_WL16)
156 # define AV_WL16(p, v) AV_WN16(p, v)
157 # elif !defined(AV_WN16) && defined(AV_WL16)
158 # define AV_WN16(p, v) AV_WL16(p, v)
159 # endif
160 
161 # if defined(AV_RN24) && !defined(AV_RL24)
162 # define AV_RL24(p) AV_RN24(p)
163 # elif !defined(AV_RN24) && defined(AV_RL24)
164 # define AV_RN24(p) AV_RL24(p)
165 # endif
166 
167 # if defined(AV_WN24) && !defined(AV_WL24)
168 # define AV_WL24(p, v) AV_WN24(p, v)
169 # elif !defined(AV_WN24) && defined(AV_WL24)
170 # define AV_WN24(p, v) AV_WL24(p, v)
171 # endif
172 
173 # if defined(AV_RN32) && !defined(AV_RL32)
174 # define AV_RL32(p) AV_RN32(p)
175 # elif !defined(AV_RN32) && defined(AV_RL32)
176 # define AV_RN32(p) AV_RL32(p)
177 # endif
178 
179 # if defined(AV_WN32) && !defined(AV_WL32)
180 # define AV_WL32(p, v) AV_WN32(p, v)
181 # elif !defined(AV_WN32) && defined(AV_WL32)
182 # define AV_WN32(p, v) AV_WL32(p, v)
183 # endif
184 
185 # if defined(AV_RN48) && !defined(AV_RL48)
186 # define AV_RL48(p) AV_RN48(p)
187 # elif !defined(AV_RN48) && defined(AV_RL48)
188 # define AV_RN48(p) AV_RL48(p)
189 # endif
190 
191 # if defined(AV_WN48) && !defined(AV_WL48)
192 # define AV_WL48(p, v) AV_WN48(p, v)
193 # elif !defined(AV_WN48) && defined(AV_WL48)
194 # define AV_WN48(p, v) AV_WL48(p, v)
195 # endif
196 
197 # if defined(AV_RN64) && !defined(AV_RL64)
198 # define AV_RL64(p) AV_RN64(p)
199 # elif !defined(AV_RN64) && defined(AV_RL64)
200 # define AV_RN64(p) AV_RL64(p)
201 # endif
202 
203 # if defined(AV_WN64) && !defined(AV_WL64)
204 # define AV_WL64(p, v) AV_WN64(p, v)
205 # elif !defined(AV_WN64) && defined(AV_WL64)
206 # define AV_WN64(p, v) AV_WL64(p, v)
207 # endif
208 
209 #endif /* !AV_HAVE_BIGENDIAN */
210 
211 /*
212  * Define AV_[RW]N helper macros to simplify definitions not provided
213  * by per-arch headers.
214  */
215 
216 #if defined(__GNUC__) || defined(__clang__)
217 
218 union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
219 union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
220 union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
221 
222 # define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
223 # define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
224 
225 #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_X64) || defined(_M_ARM64)) && AV_HAVE_FAST_UNALIGNED
226 
227 # define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
228 # define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
229 
230 #elif AV_HAVE_FAST_UNALIGNED
231 
232 # define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
233 # define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
234 
235 #else
236 
237 #ifndef AV_RB16
238 # define AV_RB16(x) \
239  ((((const uint8_t*)(x))[0] << 8) | \
240  ((const uint8_t*)(x))[1])
241 #endif
242 #ifndef AV_WB16
243 # define AV_WB16(p, val) do { \
244  uint16_t d = (val); \
245  ((uint8_t*)(p))[1] = (d); \
246  ((uint8_t*)(p))[0] = (d)>>8; \
247  } while(0)
248 #endif
249 
250 #ifndef AV_RL16
251 # define AV_RL16(x) \
252  ((((const uint8_t*)(x))[1] << 8) | \
253  ((const uint8_t*)(x))[0])
254 #endif
255 #ifndef AV_WL16
256 # define AV_WL16(p, val) do { \
257  uint16_t d = (val); \
258  ((uint8_t*)(p))[0] = (d); \
259  ((uint8_t*)(p))[1] = (d)>>8; \
260  } while(0)
261 #endif
262 
263 #ifndef AV_RB32
264 # define AV_RB32(x) \
265  (((uint32_t)((const uint8_t*)(x))[0] << 24) | \
266  (((const uint8_t*)(x))[1] << 16) | \
267  (((const uint8_t*)(x))[2] << 8) | \
268  ((const uint8_t*)(x))[3])
269 #endif
270 #ifndef AV_WB32
271 # define AV_WB32(p, val) do { \
272  uint32_t d = (val); \
273  ((uint8_t*)(p))[3] = (d); \
274  ((uint8_t*)(p))[2] = (d)>>8; \
275  ((uint8_t*)(p))[1] = (d)>>16; \
276  ((uint8_t*)(p))[0] = (d)>>24; \
277  } while(0)
278 #endif
279 
280 #ifndef AV_RL32
281 # define AV_RL32(x) \
282  (((uint32_t)((const uint8_t*)(x))[3] << 24) | \
283  (((const uint8_t*)(x))[2] << 16) | \
284  (((const uint8_t*)(x))[1] << 8) | \
285  ((const uint8_t*)(x))[0])
286 #endif
287 #ifndef AV_WL32
288 # define AV_WL32(p, val) do { \
289  uint32_t d = (val); \
290  ((uint8_t*)(p))[0] = (d); \
291  ((uint8_t*)(p))[1] = (d)>>8; \
292  ((uint8_t*)(p))[2] = (d)>>16; \
293  ((uint8_t*)(p))[3] = (d)>>24; \
294  } while(0)
295 #endif
296 
297 #ifndef AV_RB64
298 # define AV_RB64(x) \
299  (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
300  ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
301  ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
302  ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
303  ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
304  ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
305  ((uint64_t)((const uint8_t*)(x))[6] << 8) | \
306  (uint64_t)((const uint8_t*)(x))[7])
307 #endif
308 #ifndef AV_WB64
309 # define AV_WB64(p, val) do { \
310  uint64_t d = (val); \
311  ((uint8_t*)(p))[7] = (d); \
312  ((uint8_t*)(p))[6] = (d)>>8; \
313  ((uint8_t*)(p))[5] = (d)>>16; \
314  ((uint8_t*)(p))[4] = (d)>>24; \
315  ((uint8_t*)(p))[3] = (d)>>32; \
316  ((uint8_t*)(p))[2] = (d)>>40; \
317  ((uint8_t*)(p))[1] = (d)>>48; \
318  ((uint8_t*)(p))[0] = (d)>>56; \
319  } while(0)
320 #endif
321 
322 #ifndef AV_RL64
323 # define AV_RL64(x) \
324  (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
325  ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
326  ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
327  ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
328  ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
329  ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
330  ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
331  (uint64_t)((const uint8_t*)(x))[0])
332 #endif
333 #ifndef AV_WL64
334 # define AV_WL64(p, val) do { \
335  uint64_t d = (val); \
336  ((uint8_t*)(p))[0] = (d); \
337  ((uint8_t*)(p))[1] = (d)>>8; \
338  ((uint8_t*)(p))[2] = (d)>>16; \
339  ((uint8_t*)(p))[3] = (d)>>24; \
340  ((uint8_t*)(p))[4] = (d)>>32; \
341  ((uint8_t*)(p))[5] = (d)>>40; \
342  ((uint8_t*)(p))[6] = (d)>>48; \
343  ((uint8_t*)(p))[7] = (d)>>56; \
344  } while(0)
345 #endif
346 
347 #if AV_HAVE_BIGENDIAN
348 # define AV_RN(s, p) AV_RB##s(p)
349 # define AV_WN(s, p, v) AV_WB##s(p, v)
350 #else
351 # define AV_RN(s, p) AV_RL##s(p)
352 # define AV_WN(s, p, v) AV_WL##s(p, v)
353 #endif
354 
355 #endif /* HAVE_FAST_UNALIGNED */
356 
357 #ifndef AV_RN16
358 # define AV_RN16(p) AV_RN(16, p)
359 #endif
360 
361 #ifndef AV_RN32
362 # define AV_RN32(p) AV_RN(32, p)
363 #endif
364 
365 #ifndef AV_RN64
366 # define AV_RN64(p) AV_RN(64, p)
367 #endif
368 
369 #ifndef AV_WN16
370 # define AV_WN16(p, v) AV_WN(16, p, v)
371 #endif
372 
373 #ifndef AV_WN32
374 # define AV_WN32(p, v) AV_WN(32, p, v)
375 #endif
376 
377 #ifndef AV_WN64
378 # define AV_WN64(p, v) AV_WN(64, p, v)
379 #endif
380 
381 #if AV_HAVE_BIGENDIAN
382 # define AV_RB(s, p) AV_RN##s(p)
383 # define AV_WB(s, p, v) AV_WN##s(p, v)
384 # define AV_RL(s, p) av_bswap##s(AV_RN##s(p))
385 # define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v))
386 #else
387 # define AV_RB(s, p) av_bswap##s(AV_RN##s(p))
388 # define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v))
389 # define AV_RL(s, p) AV_RN##s(p)
390 # define AV_WL(s, p, v) AV_WN##s(p, v)
391 #endif
392 
393 #define AV_RB8(x) (((const uint8_t*)(x))[0])
394 #define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
395 
396 #define AV_RL8(x) AV_RB8(x)
397 #define AV_WL8(p, d) AV_WB8(p, d)
398 
399 #ifndef AV_RB16
400 # define AV_RB16(p) AV_RB(16, p)
401 #endif
402 #ifndef AV_WB16
403 # define AV_WB16(p, v) AV_WB(16, p, v)
404 #endif
405 
406 #ifndef AV_RL16
407 # define AV_RL16(p) AV_RL(16, p)
408 #endif
409 #ifndef AV_WL16
410 # define AV_WL16(p, v) AV_WL(16, p, v)
411 #endif
412 
413 #ifndef AV_RB32
414 # define AV_RB32(p) AV_RB(32, p)
415 #endif
416 #ifndef AV_WB32
417 # define AV_WB32(p, v) AV_WB(32, p, v)
418 #endif
419 
420 #ifndef AV_RL32
421 # define AV_RL32(p) AV_RL(32, p)
422 #endif
423 #ifndef AV_WL32
424 # define AV_WL32(p, v) AV_WL(32, p, v)
425 #endif
426 
427 #ifndef AV_RB64
428 # define AV_RB64(p) AV_RB(64, p)
429 #endif
430 #ifndef AV_WB64
431 # define AV_WB64(p, v) AV_WB(64, p, v)
432 #endif
433 
434 #ifndef AV_RL64
435 # define AV_RL64(p) AV_RL(64, p)
436 #endif
437 #ifndef AV_WL64
438 # define AV_WL64(p, v) AV_WL(64, p, v)
439 #endif
440 
441 #ifndef AV_RB24
442 # define AV_RB24(x) \
443  ((((const uint8_t*)(x))[0] << 16) | \
444  (((const uint8_t*)(x))[1] << 8) | \
445  ((const uint8_t*)(x))[2])
446 #endif
447 #ifndef AV_WB24
448 # define AV_WB24(p, d) do { \
449  ((uint8_t*)(p))[2] = (d); \
450  ((uint8_t*)(p))[1] = (d)>>8; \
451  ((uint8_t*)(p))[0] = (d)>>16; \
452  } while(0)
453 #endif
454 
455 #ifndef AV_RL24
456 # define AV_RL24(x) \
457  ((((const uint8_t*)(x))[2] << 16) | \
458  (((const uint8_t*)(x))[1] << 8) | \
459  ((const uint8_t*)(x))[0])
460 #endif
461 #ifndef AV_WL24
462 # define AV_WL24(p, d) do { \
463  ((uint8_t*)(p))[0] = (d); \
464  ((uint8_t*)(p))[1] = (d)>>8; \
465  ((uint8_t*)(p))[2] = (d)>>16; \
466  } while(0)
467 #endif
468 
469 #ifndef AV_RB48
470 # define AV_RB48(x) \
471  (((uint64_t)((const uint8_t*)(x))[0] << 40) | \
472  ((uint64_t)((const uint8_t*)(x))[1] << 32) | \
473  ((uint64_t)((const uint8_t*)(x))[2] << 24) | \
474  ((uint64_t)((const uint8_t*)(x))[3] << 16) | \
475  ((uint64_t)((const uint8_t*)(x))[4] << 8) | \
476  (uint64_t)((const uint8_t*)(x))[5])
477 #endif
478 #ifndef AV_WB48
479 # define AV_WB48(p, darg) do { \
480  uint64_t d = (darg); \
481  ((uint8_t*)(p))[5] = (d); \
482  ((uint8_t*)(p))[4] = (d)>>8; \
483  ((uint8_t*)(p))[3] = (d)>>16; \
484  ((uint8_t*)(p))[2] = (d)>>24; \
485  ((uint8_t*)(p))[1] = (d)>>32; \
486  ((uint8_t*)(p))[0] = (d)>>40; \
487  } while(0)
488 #endif
489 
490 #ifndef AV_RL48
491 # define AV_RL48(x) \
492  (((uint64_t)((const uint8_t*)(x))[5] << 40) | \
493  ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
494  ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
495  ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
496  ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
497  (uint64_t)((const uint8_t*)(x))[0])
498 #endif
499 #ifndef AV_WL48
500 # define AV_WL48(p, darg) do { \
501  uint64_t d = (darg); \
502  ((uint8_t*)(p))[0] = (d); \
503  ((uint8_t*)(p))[1] = (d)>>8; \
504  ((uint8_t*)(p))[2] = (d)>>16; \
505  ((uint8_t*)(p))[3] = (d)>>24; \
506  ((uint8_t*)(p))[4] = (d)>>32; \
507  ((uint8_t*)(p))[5] = (d)>>40; \
508  } while(0)
509 #endif
510 
511 /*
512  * The AV_[RW]NA macros access naturally aligned data
513  * in a type-safe way.
514  */
515 
516 #define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
517 #define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
518 
519 #ifndef AV_RN16A
520 # define AV_RN16A(p) AV_RNA(16, p)
521 #endif
522 
523 #ifndef AV_RN32A
524 # define AV_RN32A(p) AV_RNA(32, p)
525 #endif
526 
527 #ifndef AV_RN64A
528 # define AV_RN64A(p) AV_RNA(64, p)
529 #endif
530 
531 #ifndef AV_WN16A
532 # define AV_WN16A(p, v) AV_WNA(16, p, v)
533 #endif
534 
535 #ifndef AV_WN32A
536 # define AV_WN32A(p, v) AV_WNA(32, p, v)
537 #endif
538 
539 #ifndef AV_WN64A
540 # define AV_WN64A(p, v) AV_WNA(64, p, v)
541 #endif
542 
543 #if AV_HAVE_BIGENDIAN
544 # define AV_RLA(s, p) av_bswap##s(AV_RN##s##A(p))
545 # define AV_WLA(s, p, v) AV_WN##s##A(p, av_bswap##s(v))
546 #else
547 # define AV_RLA(s, p) AV_RN##s##A(p)
548 # define AV_WLA(s, p, v) AV_WN##s##A(p, v)
549 #endif
550 
551 #ifndef AV_RL64A
552 # define AV_RL64A(p) AV_RLA(64, p)
553 #endif
554 #ifndef AV_WL64A
555 # define AV_WL64A(p, v) AV_WLA(64, p, v)
556 #endif
557 
558 /*
559  * The AV_COPYxxU macros are suitable for copying data to/from unaligned
560  * memory locations.
561  */
562 
563 #define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
564 
565 #ifndef AV_COPY16U
566 # define AV_COPY16U(d, s) AV_COPYU(16, d, s)
567 #endif
568 
569 #ifndef AV_COPY32U
570 # define AV_COPY32U(d, s) AV_COPYU(32, d, s)
571 #endif
572 
573 #ifndef AV_COPY64U
574 # define AV_COPY64U(d, s) AV_COPYU(64, d, s)
575 #endif
576 
577 #ifndef AV_COPY128U
578 # define AV_COPY128U(d, s) \
579  do { \
580  AV_COPY64U(d, s); \
581  AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8); \
582  } while(0)
583 #endif
584 
585 /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
586  * naturally aligned.
587  */
588 
589 #define AV_COPY(n, d, s) \
590  (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
591 
592 #ifndef AV_COPY16
593 # define AV_COPY16(d, s) AV_COPY(16, d, s)
594 #endif
595 
596 #ifndef AV_COPY32
597 # define AV_COPY32(d, s) AV_COPY(32, d, s)
598 #endif
599 
600 #ifndef AV_COPY64
601 # define AV_COPY64(d, s) AV_COPY(64, d, s)
602 #endif
603 
604 #ifndef AV_COPY128
605 # define AV_COPY128(d, s) \
606  do { \
607  AV_COPY64(d, s); \
608  AV_COPY64((char*)(d)+8, (char*)(s)+8); \
609  } while(0)
610 #endif
611 
612 #define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
613 
614 #ifndef AV_SWAP64
615 # define AV_SWAP64(a, b) AV_SWAP(64, a, b)
616 #endif
617 
618 #define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
619 
620 #ifndef AV_ZERO16
621 # define AV_ZERO16(d) AV_ZERO(16, d)
622 #endif
623 
624 #ifndef AV_ZERO32
625 # define AV_ZERO32(d) AV_ZERO(32, d)
626 #endif
627 
628 #ifndef AV_ZERO64
629 # define AV_ZERO64(d) AV_ZERO(64, d)
630 #endif
631 
632 #ifndef AV_ZERO128
633 # define AV_ZERO128(d) \
634  do { \
635  AV_ZERO64(d); \
636  AV_ZERO64((char*)(d)+8); \
637  } while(0)
638 #endif
639 
640 #endif /* AVUTIL_INTREADWRITE_H */
intreadwrite.h
unaligned_64::l
uint64_t l
Definition: intreadwrite.h:218
av_alias::f64
double f64
Definition: intreadwrite.h:32
intreadwrite.h
av_alias
Definition: intreadwrite.h:27
intreadwrite.h
av_alias::u64
uint64_t u64
Definition: intreadwrite.h:28
unaligned_64
Definition: intreadwrite.h:218
intreadwrite.h
unaligned_16::l
uint16_t l
Definition: intreadwrite.h:220
unaligned_32
Definition: intreadwrite.h:219
intreadwrite.h
attributes.h
av_alias
union unaligned_64 av_alias
unaligned_16
Definition: intreadwrite.h:220
bswap.h
unaligned_32::l
uint32_t l
Definition: intreadwrite.h:219