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_TOMI
76 # include "tomi/intreadwrite.h"
77 #elif ARCH_X86
78 # include "x86/intreadwrite.h"
79 #endif
80 
81 #endif /* HAVE_AV_CONFIG_H */
82 
83 /*
84  * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
85  */
86 
87 #if AV_HAVE_BIGENDIAN
88 
89 # if defined(AV_RN16) && !defined(AV_RB16)
90 # define AV_RB16(p) AV_RN16(p)
91 # elif !defined(AV_RN16) && defined(AV_RB16)
92 # define AV_RN16(p) AV_RB16(p)
93 # endif
94 
95 # if defined(AV_WN16) && !defined(AV_WB16)
96 # define AV_WB16(p, v) AV_WN16(p, v)
97 # elif !defined(AV_WN16) && defined(AV_WB16)
98 # define AV_WN16(p, v) AV_WB16(p, v)
99 # endif
100 
101 # if defined(AV_RN24) && !defined(AV_RB24)
102 # define AV_RB24(p) AV_RN24(p)
103 # elif !defined(AV_RN24) && defined(AV_RB24)
104 # define AV_RN24(p) AV_RB24(p)
105 # endif
106 
107 # if defined(AV_WN24) && !defined(AV_WB24)
108 # define AV_WB24(p, v) AV_WN24(p, v)
109 # elif !defined(AV_WN24) && defined(AV_WB24)
110 # define AV_WN24(p, v) AV_WB24(p, v)
111 # endif
112 
113 # if defined(AV_RN32) && !defined(AV_RB32)
114 # define AV_RB32(p) AV_RN32(p)
115 # elif !defined(AV_RN32) && defined(AV_RB32)
116 # define AV_RN32(p) AV_RB32(p)
117 # endif
118 
119 # if defined(AV_WN32) && !defined(AV_WB32)
120 # define AV_WB32(p, v) AV_WN32(p, v)
121 # elif !defined(AV_WN32) && defined(AV_WB32)
122 # define AV_WN32(p, v) AV_WB32(p, v)
123 # endif
124 
125 # if defined(AV_RN48) && !defined(AV_RB48)
126 # define AV_RB48(p) AV_RN48(p)
127 # elif !defined(AV_RN48) && defined(AV_RB48)
128 # define AV_RN48(p) AV_RB48(p)
129 # endif
130 
131 # if defined(AV_WN48) && !defined(AV_WB48)
132 # define AV_WB48(p, v) AV_WN48(p, v)
133 # elif !defined(AV_WN48) && defined(AV_WB48)
134 # define AV_WN48(p, v) AV_WB48(p, v)
135 # endif
136 
137 # if defined(AV_RN64) && !defined(AV_RB64)
138 # define AV_RB64(p) AV_RN64(p)
139 # elif !defined(AV_RN64) && defined(AV_RB64)
140 # define AV_RN64(p) AV_RB64(p)
141 # endif
142 
143 # if defined(AV_WN64) && !defined(AV_WB64)
144 # define AV_WB64(p, v) AV_WN64(p, v)
145 # elif !defined(AV_WN64) && defined(AV_WB64)
146 # define AV_WN64(p, v) AV_WB64(p, v)
147 # endif
148 
149 #else /* AV_HAVE_BIGENDIAN */
150 
151 # if defined(AV_RN16) && !defined(AV_RL16)
152 # define AV_RL16(p) AV_RN16(p)
153 # elif !defined(AV_RN16) && defined(AV_RL16)
154 # define AV_RN16(p) AV_RL16(p)
155 # endif
156 
157 # if defined(AV_WN16) && !defined(AV_WL16)
158 # define AV_WL16(p, v) AV_WN16(p, v)
159 # elif !defined(AV_WN16) && defined(AV_WL16)
160 # define AV_WN16(p, v) AV_WL16(p, v)
161 # endif
162 
163 # if defined(AV_RN24) && !defined(AV_RL24)
164 # define AV_RL24(p) AV_RN24(p)
165 # elif !defined(AV_RN24) && defined(AV_RL24)
166 # define AV_RN24(p) AV_RL24(p)
167 # endif
168 
169 # if defined(AV_WN24) && !defined(AV_WL24)
170 # define AV_WL24(p, v) AV_WN24(p, v)
171 # elif !defined(AV_WN24) && defined(AV_WL24)
172 # define AV_WN24(p, v) AV_WL24(p, v)
173 # endif
174 
175 # if defined(AV_RN32) && !defined(AV_RL32)
176 # define AV_RL32(p) AV_RN32(p)
177 # elif !defined(AV_RN32) && defined(AV_RL32)
178 # define AV_RN32(p) AV_RL32(p)
179 # endif
180 
181 # if defined(AV_WN32) && !defined(AV_WL32)
182 # define AV_WL32(p, v) AV_WN32(p, v)
183 # elif !defined(AV_WN32) && defined(AV_WL32)
184 # define AV_WN32(p, v) AV_WL32(p, v)
185 # endif
186 
187 # if defined(AV_RN48) && !defined(AV_RL48)
188 # define AV_RL48(p) AV_RN48(p)
189 # elif !defined(AV_RN48) && defined(AV_RL48)
190 # define AV_RN48(p) AV_RL48(p)
191 # endif
192 
193 # if defined(AV_WN48) && !defined(AV_WL48)
194 # define AV_WL48(p, v) AV_WN48(p, v)
195 # elif !defined(AV_WN48) && defined(AV_WL48)
196 # define AV_WN48(p, v) AV_WL48(p, v)
197 # endif
198 
199 # if defined(AV_RN64) && !defined(AV_RL64)
200 # define AV_RL64(p) AV_RN64(p)
201 # elif !defined(AV_RN64) && defined(AV_RL64)
202 # define AV_RN64(p) AV_RL64(p)
203 # endif
204 
205 # if defined(AV_WN64) && !defined(AV_WL64)
206 # define AV_WL64(p, v) AV_WN64(p, v)
207 # elif !defined(AV_WN64) && defined(AV_WL64)
208 # define AV_WN64(p, v) AV_WL64(p, v)
209 # endif
210 
211 #endif /* !AV_HAVE_BIGENDIAN */
212 
213 /*
214  * Define AV_[RW]N helper macros to simplify definitions not provided
215  * by per-arch headers.
216  */
217 
218 #if defined(__GNUC__)
219 
220 union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias;
221 union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias;
222 union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
223 
224 # define AV_RN(s, p) (((const union unaligned_##s *) (p))->l)
225 # define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v))
226 
227 #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_X64) || defined(_M_ARM64)) && AV_HAVE_FAST_UNALIGNED
228 
229 # define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
230 # define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
231 
232 #elif AV_HAVE_FAST_UNALIGNED
233 
234 # define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)
235 # define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))
236 
237 #else
238 
239 #ifndef AV_RB16
240 # define AV_RB16(x) \
241  ((((const uint8_t*)(x))[0] << 8) | \
242  ((const uint8_t*)(x))[1])
243 #endif
244 #ifndef AV_WB16
245 # define AV_WB16(p, val) do { \
246  uint16_t d = (val); \
247  ((uint8_t*)(p))[1] = (d); \
248  ((uint8_t*)(p))[0] = (d)>>8; \
249  } while(0)
250 #endif
251 
252 #ifndef AV_RL16
253 # define AV_RL16(x) \
254  ((((const uint8_t*)(x))[1] << 8) | \
255  ((const uint8_t*)(x))[0])
256 #endif
257 #ifndef AV_WL16
258 # define AV_WL16(p, val) do { \
259  uint16_t d = (val); \
260  ((uint8_t*)(p))[0] = (d); \
261  ((uint8_t*)(p))[1] = (d)>>8; \
262  } while(0)
263 #endif
264 
265 #ifndef AV_RB32
266 # define AV_RB32(x) \
267  (((uint32_t)((const uint8_t*)(x))[0] << 24) | \
268  (((const uint8_t*)(x))[1] << 16) | \
269  (((const uint8_t*)(x))[2] << 8) | \
270  ((const uint8_t*)(x))[3])
271 #endif
272 #ifndef AV_WB32
273 # define AV_WB32(p, val) do { \
274  uint32_t d = (val); \
275  ((uint8_t*)(p))[3] = (d); \
276  ((uint8_t*)(p))[2] = (d)>>8; \
277  ((uint8_t*)(p))[1] = (d)>>16; \
278  ((uint8_t*)(p))[0] = (d)>>24; \
279  } while(0)
280 #endif
281 
282 #ifndef AV_RL32
283 # define AV_RL32(x) \
284  (((uint32_t)((const uint8_t*)(x))[3] << 24) | \
285  (((const uint8_t*)(x))[2] << 16) | \
286  (((const uint8_t*)(x))[1] << 8) | \
287  ((const uint8_t*)(x))[0])
288 #endif
289 #ifndef AV_WL32
290 # define AV_WL32(p, val) do { \
291  uint32_t d = (val); \
292  ((uint8_t*)(p))[0] = (d); \
293  ((uint8_t*)(p))[1] = (d)>>8; \
294  ((uint8_t*)(p))[2] = (d)>>16; \
295  ((uint8_t*)(p))[3] = (d)>>24; \
296  } while(0)
297 #endif
298 
299 #ifndef AV_RB64
300 # define AV_RB64(x) \
301  (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
302  ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
303  ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
304  ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
305  ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
306  ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
307  ((uint64_t)((const uint8_t*)(x))[6] << 8) | \
308  (uint64_t)((const uint8_t*)(x))[7])
309 #endif
310 #ifndef AV_WB64
311 # define AV_WB64(p, val) do { \
312  uint64_t d = (val); \
313  ((uint8_t*)(p))[7] = (d); \
314  ((uint8_t*)(p))[6] = (d)>>8; \
315  ((uint8_t*)(p))[5] = (d)>>16; \
316  ((uint8_t*)(p))[4] = (d)>>24; \
317  ((uint8_t*)(p))[3] = (d)>>32; \
318  ((uint8_t*)(p))[2] = (d)>>40; \
319  ((uint8_t*)(p))[1] = (d)>>48; \
320  ((uint8_t*)(p))[0] = (d)>>56; \
321  } while(0)
322 #endif
323 
324 #ifndef AV_RL64
325 # define AV_RL64(x) \
326  (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
327  ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
328  ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
329  ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
330  ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
331  ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
332  ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
333  (uint64_t)((const uint8_t*)(x))[0])
334 #endif
335 #ifndef AV_WL64
336 # define AV_WL64(p, val) do { \
337  uint64_t d = (val); \
338  ((uint8_t*)(p))[0] = (d); \
339  ((uint8_t*)(p))[1] = (d)>>8; \
340  ((uint8_t*)(p))[2] = (d)>>16; \
341  ((uint8_t*)(p))[3] = (d)>>24; \
342  ((uint8_t*)(p))[4] = (d)>>32; \
343  ((uint8_t*)(p))[5] = (d)>>40; \
344  ((uint8_t*)(p))[6] = (d)>>48; \
345  ((uint8_t*)(p))[7] = (d)>>56; \
346  } while(0)
347 #endif
348 
349 #if AV_HAVE_BIGENDIAN
350 # define AV_RN(s, p) AV_RB##s(p)
351 # define AV_WN(s, p, v) AV_WB##s(p, v)
352 #else
353 # define AV_RN(s, p) AV_RL##s(p)
354 # define AV_WN(s, p, v) AV_WL##s(p, v)
355 #endif
356 
357 #endif /* HAVE_FAST_UNALIGNED */
358 
359 #ifndef AV_RN16
360 # define AV_RN16(p) AV_RN(16, p)
361 #endif
362 
363 #ifndef AV_RN32
364 # define AV_RN32(p) AV_RN(32, p)
365 #endif
366 
367 #ifndef AV_RN64
368 # define AV_RN64(p) AV_RN(64, p)
369 #endif
370 
371 #ifndef AV_WN16
372 # define AV_WN16(p, v) AV_WN(16, p, v)
373 #endif
374 
375 #ifndef AV_WN32
376 # define AV_WN32(p, v) AV_WN(32, p, v)
377 #endif
378 
379 #ifndef AV_WN64
380 # define AV_WN64(p, v) AV_WN(64, p, v)
381 #endif
382 
383 #if AV_HAVE_BIGENDIAN
384 # define AV_RB(s, p) AV_RN##s(p)
385 # define AV_WB(s, p, v) AV_WN##s(p, v)
386 # define AV_RL(s, p) av_bswap##s(AV_RN##s(p))
387 # define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v))
388 #else
389 # define AV_RB(s, p) av_bswap##s(AV_RN##s(p))
390 # define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v))
391 # define AV_RL(s, p) AV_RN##s(p)
392 # define AV_WL(s, p, v) AV_WN##s(p, v)
393 #endif
394 
395 #define AV_RB8(x) (((const uint8_t*)(x))[0])
396 #define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
397 
398 #define AV_RL8(x) AV_RB8(x)
399 #define AV_WL8(p, d) AV_WB8(p, d)
400 
401 #ifndef AV_RB16
402 # define AV_RB16(p) AV_RB(16, p)
403 #endif
404 #ifndef AV_WB16
405 # define AV_WB16(p, v) AV_WB(16, p, v)
406 #endif
407 
408 #ifndef AV_RL16
409 # define AV_RL16(p) AV_RL(16, p)
410 #endif
411 #ifndef AV_WL16
412 # define AV_WL16(p, v) AV_WL(16, p, v)
413 #endif
414 
415 #ifndef AV_RB32
416 # define AV_RB32(p) AV_RB(32, p)
417 #endif
418 #ifndef AV_WB32
419 # define AV_WB32(p, v) AV_WB(32, p, v)
420 #endif
421 
422 #ifndef AV_RL32
423 # define AV_RL32(p) AV_RL(32, p)
424 #endif
425 #ifndef AV_WL32
426 # define AV_WL32(p, v) AV_WL(32, p, v)
427 #endif
428 
429 #ifndef AV_RB64
430 # define AV_RB64(p) AV_RB(64, p)
431 #endif
432 #ifndef AV_WB64
433 # define AV_WB64(p, v) AV_WB(64, p, v)
434 #endif
435 
436 #ifndef AV_RL64
437 # define AV_RL64(p) AV_RL(64, p)
438 #endif
439 #ifndef AV_WL64
440 # define AV_WL64(p, v) AV_WL(64, p, v)
441 #endif
442 
443 #ifndef AV_RB24
444 # define AV_RB24(x) \
445  ((((const uint8_t*)(x))[0] << 16) | \
446  (((const uint8_t*)(x))[1] << 8) | \
447  ((const uint8_t*)(x))[2])
448 #endif
449 #ifndef AV_WB24
450 # define AV_WB24(p, d) do { \
451  ((uint8_t*)(p))[2] = (d); \
452  ((uint8_t*)(p))[1] = (d)>>8; \
453  ((uint8_t*)(p))[0] = (d)>>16; \
454  } while(0)
455 #endif
456 
457 #ifndef AV_RL24
458 # define AV_RL24(x) \
459  ((((const uint8_t*)(x))[2] << 16) | \
460  (((const uint8_t*)(x))[1] << 8) | \
461  ((const uint8_t*)(x))[0])
462 #endif
463 #ifndef AV_WL24
464 # define AV_WL24(p, d) do { \
465  ((uint8_t*)(p))[0] = (d); \
466  ((uint8_t*)(p))[1] = (d)>>8; \
467  ((uint8_t*)(p))[2] = (d)>>16; \
468  } while(0)
469 #endif
470 
471 #ifndef AV_RB48
472 # define AV_RB48(x) \
473  (((uint64_t)((const uint8_t*)(x))[0] << 40) | \
474  ((uint64_t)((const uint8_t*)(x))[1] << 32) | \
475  ((uint64_t)((const uint8_t*)(x))[2] << 24) | \
476  ((uint64_t)((const uint8_t*)(x))[3] << 16) | \
477  ((uint64_t)((const uint8_t*)(x))[4] << 8) | \
478  (uint64_t)((const uint8_t*)(x))[5])
479 #endif
480 #ifndef AV_WB48
481 # define AV_WB48(p, darg) do { \
482  uint64_t d = (darg); \
483  ((uint8_t*)(p))[5] = (d); \
484  ((uint8_t*)(p))[4] = (d)>>8; \
485  ((uint8_t*)(p))[3] = (d)>>16; \
486  ((uint8_t*)(p))[2] = (d)>>24; \
487  ((uint8_t*)(p))[1] = (d)>>32; \
488  ((uint8_t*)(p))[0] = (d)>>40; \
489  } while(0)
490 #endif
491 
492 #ifndef AV_RL48
493 # define AV_RL48(x) \
494  (((uint64_t)((const uint8_t*)(x))[5] << 40) | \
495  ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
496  ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
497  ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
498  ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
499  (uint64_t)((const uint8_t*)(x))[0])
500 #endif
501 #ifndef AV_WL48
502 # define AV_WL48(p, darg) do { \
503  uint64_t d = (darg); \
504  ((uint8_t*)(p))[0] = (d); \
505  ((uint8_t*)(p))[1] = (d)>>8; \
506  ((uint8_t*)(p))[2] = (d)>>16; \
507  ((uint8_t*)(p))[3] = (d)>>24; \
508  ((uint8_t*)(p))[4] = (d)>>32; \
509  ((uint8_t*)(p))[5] = (d)>>40; \
510  } while(0)
511 #endif
512 
513 /*
514  * The AV_[RW]NA macros access naturally aligned data
515  * in a type-safe way.
516  */
517 
518 #define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
519 #define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
520 
521 #ifndef AV_RN16A
522 # define AV_RN16A(p) AV_RNA(16, p)
523 #endif
524 
525 #ifndef AV_RN32A
526 # define AV_RN32A(p) AV_RNA(32, p)
527 #endif
528 
529 #ifndef AV_RN64A
530 # define AV_RN64A(p) AV_RNA(64, p)
531 #endif
532 
533 #ifndef AV_WN16A
534 # define AV_WN16A(p, v) AV_WNA(16, p, v)
535 #endif
536 
537 #ifndef AV_WN32A
538 # define AV_WN32A(p, v) AV_WNA(32, p, v)
539 #endif
540 
541 #ifndef AV_WN64A
542 # define AV_WN64A(p, v) AV_WNA(64, p, v)
543 #endif
544 
545 #if AV_HAVE_BIGENDIAN
546 # define AV_RLA(s, p) av_bswap##s(AV_RN##s##A(p))
547 # define AV_WLA(s, p, v) AV_WN##s##A(p, av_bswap##s(v))
548 #else
549 # define AV_RLA(s, p) AV_RN##s##A(p)
550 # define AV_WLA(s, p, v) AV_WN##s##A(p, v)
551 #endif
552 
553 #ifndef AV_RL64A
554 # define AV_RL64A(p) AV_RLA(64, p)
555 #endif
556 #ifndef AV_WL64A
557 # define AV_WL64A(p, v) AV_WLA(64, p, v)
558 #endif
559 
560 /*
561  * The AV_COPYxxU macros are suitable for copying data to/from unaligned
562  * memory locations.
563  */
564 
565 #define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
566 
567 #ifndef AV_COPY16U
568 # define AV_COPY16U(d, s) AV_COPYU(16, d, s)
569 #endif
570 
571 #ifndef AV_COPY32U
572 # define AV_COPY32U(d, s) AV_COPYU(32, d, s)
573 #endif
574 
575 #ifndef AV_COPY64U
576 # define AV_COPY64U(d, s) AV_COPYU(64, d, s)
577 #endif
578 
579 #ifndef AV_COPY128U
580 # define AV_COPY128U(d, s) \
581  do { \
582  AV_COPY64U(d, s); \
583  AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8); \
584  } while(0)
585 #endif
586 
587 /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
588  * naturally aligned. They may be implemented using MMX,
589  * so emms_c() must be called before using any float code
590  * afterwards.
591  */
592 
593 #define AV_COPY(n, d, s) \
594  (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
595 
596 #ifndef AV_COPY16
597 # define AV_COPY16(d, s) AV_COPY(16, d, s)
598 #endif
599 
600 #ifndef AV_COPY32
601 # define AV_COPY32(d, s) AV_COPY(32, d, s)
602 #endif
603 
604 #ifndef AV_COPY64
605 # define AV_COPY64(d, s) AV_COPY(64, d, s)
606 #endif
607 
608 #ifndef AV_COPY128
609 # define AV_COPY128(d, s) \
610  do { \
611  AV_COPY64(d, s); \
612  AV_COPY64((char*)(d)+8, (char*)(s)+8); \
613  } while(0)
614 #endif
615 
616 #define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
617 
618 #ifndef AV_SWAP64
619 # define AV_SWAP64(a, b) AV_SWAP(64, a, b)
620 #endif
621 
622 #define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
623 
624 #ifndef AV_ZERO16
625 # define AV_ZERO16(d) AV_ZERO(16, d)
626 #endif
627 
628 #ifndef AV_ZERO32
629 # define AV_ZERO32(d) AV_ZERO(32, d)
630 #endif
631 
632 #ifndef AV_ZERO64
633 # define AV_ZERO64(d) AV_ZERO(64, d)
634 #endif
635 
636 #ifndef AV_ZERO128
637 # define AV_ZERO128(d) \
638  do { \
639  AV_ZERO64(d); \
640  AV_ZERO64((char*)(d)+8); \
641  } while(0)
642 #endif
643 
644 #endif /* AVUTIL_INTREADWRITE_H */
intreadwrite.h
unaligned_64::l
uint64_t l
Definition: intreadwrite.h:220
intreadwrite.h
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:220
intreadwrite.h
unaligned_16::l
uint16_t l
Definition: intreadwrite.h:222
unaligned_32
Definition: intreadwrite.h:221
intreadwrite.h
attributes.h
av_alias
union unaligned_64 av_alias
uint8_t
uint8_t
Definition: audio_convert.c:194
unaligned_16
Definition: intreadwrite.h:222
bswap.h
unaligned_32::l
uint32_t l
Definition: intreadwrite.h:221