Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__H264__App
view libavutil/intreadwrite.h @ 9:ea1ba68cf0ed
update to match api changes + add sscc produced source
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 05 Jun 2013 14:43:26 +0200 |
| parents | |
| children |
line source
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 */
19 #ifndef AVUTIL_INTREADWRITE_H
20 #define AVUTIL_INTREADWRITE_H
22 #include <stdint.h>
23 #include "config.h"
24 #include "bswap.h"
25 #include "common.h"
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 } __attribute__((__may_alias__)) av_alias64;
36 typedef union {
37 uint32_t u32;
38 uint16_t u16[2];
39 uint8_t u8 [4];
40 float f32;
41 } __attribute__((__may_alias__)) av_alias32;
43 typedef union {
44 uint16_t u16;
45 uint8_t u8 [2];
46 } __attribute__((__may_alias__)) av_alias16 ;
48 /*
49 * Arch-specific headers can provide any combination of
50 * AV_[RW][BLN](16|24|32|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 */
55 #if ARCH_ARM
56 # include "arm/intreadwrite.h"
57 #elif ARCH_PPC
58 # include "ppc/intreadwrite.h"
59 #elif ARCH_X86
60 # include "x86/intreadwrite.h"
61 #endif
63 /*
64 * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers.
65 */
67 #if HAVE_BIGENDIAN
69 # if defined(AV_RN16) && !defined(AV_RB16)
70 # define AV_RB16(p) AV_RN16(p)
71 # elif !defined(AV_RN16) && defined(AV_RB16)
72 # define AV_RN16(p) AV_RB16(p)
73 # endif
75 # if defined(AV_WN16) && !defined(AV_WB16)
76 # define AV_WB16(p, v) AV_WN16(p, v)
77 # elif !defined(AV_WN16) && defined(AV_WB16)
78 # define AV_WN16(p, v) AV_WB16(p, v)
79 # endif
81 # if defined(AV_RN24) && !defined(AV_RB24)
82 # define AV_RB24(p) AV_RN24(p)
83 # elif !defined(AV_RN24) && defined(AV_RB24)
84 # define AV_RN24(p) AV_RB24(p)
85 # endif
87 # if defined(AV_WN24) && !defined(AV_WB24)
88 # define AV_WB24(p, v) AV_WN24(p, v)
89 # elif !defined(AV_WN24) && defined(AV_WB24)
90 # define AV_WN24(p, v) AV_WB24(p, v)
91 # endif
93 # if defined(AV_RN32) && !defined(AV_RB32)
94 # define AV_RB32(p) AV_RN32(p)
95 # elif !defined(AV_RN32) && defined(AV_RB32)
96 # define AV_RN32(p) AV_RB32(p)
97 # endif
99 # if defined(AV_WN32) && !defined(AV_WB32)
100 # define AV_WB32(p, v) AV_WN32(p, v)
101 # elif !defined(AV_WN32) && defined(AV_WB32)
102 # define AV_WN32(p, v) AV_WB32(p, v)
103 # endif
105 # if defined(AV_RN64) && !defined(AV_RB64)
106 # define AV_RB64(p) AV_RN64(p)
107 # elif !defined(AV_RN64) && defined(AV_RB64)
108 # define AV_RN64(p) AV_RB64(p)
109 # endif
111 # if defined(AV_WN64) && !defined(AV_WB64)
112 # define AV_WB64(p, v) AV_WN64(p, v)
113 # elif !defined(AV_WN64) && defined(AV_WB64)
114 # define AV_WN64(p, v) AV_WB64(p, v)
115 # endif
117 #else /* HAVE_BIGENDIAN */
119 # if defined(AV_RN16) && !defined(AV_RL16)
120 # define AV_RL16(p) AV_RN16(p)
121 # elif !defined(AV_RN16) && defined(AV_RL16)
122 # define AV_RN16(p) AV_RL16(p)
123 # endif
125 # if defined(AV_WN16) && !defined(AV_WL16)
126 # define AV_WL16(p, v) AV_WN16(p, v)
127 # elif !defined(AV_WN16) && defined(AV_WL16)
128 # define AV_WN16(p, v) AV_WL16(p, v)
129 # endif
131 # if defined(AV_RN24) && !defined(AV_RL24)
132 # define AV_RL24(p) AV_RN24(p)
133 # elif !defined(AV_RN24) && defined(AV_RL24)
134 # define AV_RN24(p) AV_RL24(p)
135 # endif
137 # if defined(AV_WN24) && !defined(AV_WL24)
138 # define AV_WL24(p, v) AV_WN24(p, v)
139 # elif !defined(AV_WN24) && defined(AV_WL24)
140 # define AV_WN24(p, v) AV_WL24(p, v)
141 # endif
143 # if defined(AV_RN32) && !defined(AV_RL32)
144 # define AV_RL32(p) AV_RN32(p)
145 # elif !defined(AV_RN32) && defined(AV_RL32)
146 # define AV_RN32(p) AV_RL32(p)
147 # endif
149 # if defined(AV_WN32) && !defined(AV_WL32)
150 # define AV_WL32(p, v) AV_WN32(p, v)
151 # elif !defined(AV_WN32) && defined(AV_WL32)
152 # define AV_WN32(p, v) AV_WL32(p, v)
153 # endif
155 # if defined(AV_RN64) && !defined(AV_RL64)
156 # define AV_RL64(p) AV_RN64(p)
157 # elif !defined(AV_RN64) && defined(AV_RL64)
158 # define AV_RN64(p) AV_RL64(p)
159 # endif
161 # if defined(AV_WN64) && !defined(AV_WL64)
162 # define AV_WL64(p, v) AV_WN64(p, v)
163 # elif !defined(AV_WN64) && defined(AV_WL64)
164 # define AV_WN64(p, v) AV_WL64(p, v)
165 # endif
167 #endif /* !HAVE_BIGENDIAN */
169 /*
170 * Define AV_[RW]N helper macros to simplify definitions not provided
171 * by per-arch headers.
172 */
176 #if defined(__DECC)
178 # define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p)))
179 # define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v))
181 #else
183 #ifndef AV_RB16
184 # define AV_RB16(x) \
185 ((((const uint8_t*)(x))[0] << 8) | \
186 ((const uint8_t*)(x))[1])
187 #endif
188 #ifndef AV_WB16
189 # define AV_WB16(p, d) do { \
190 ((uint8_t*)(p))[1] = (d); \
191 ((uint8_t*)(p))[0] = (d)>>8; \
192 } while(0)
193 #endif
195 #ifndef AV_RL16
196 # define AV_RL16(x) \
197 ((((const uint8_t*)(x))[1] << 8) | \
198 ((const uint8_t*)(x))[0])
199 #endif
200 #ifndef AV_WL16
201 # define AV_WL16(p, d) do { \
202 ((uint8_t*)(p))[0] = (d); \
203 ((uint8_t*)(p))[1] = (d)>>8; \
204 } while(0)
205 #endif
207 #ifndef AV_RB32
208 # define AV_RB32(x) \
209 ((((const uint8_t*)(x))[0] << 24) | \
210 (((const uint8_t*)(x))[1] << 16) | \
211 (((const uint8_t*)(x))[2] << 8) | \
212 ((const uint8_t*)(x))[3])
213 #endif
214 #ifndef AV_WB32
215 # define AV_WB32(p, d) do { \
216 ((uint8_t*)(p))[3] = (d); \
217 ((uint8_t*)(p))[2] = (d)>>8; \
218 ((uint8_t*)(p))[1] = (d)>>16; \
219 ((uint8_t*)(p))[0] = (d)>>24; \
220 } while(0)
221 #endif
223 #ifndef AV_RL32
224 # define AV_RL32(x) \
225 ((((const uint8_t*)(x))[3] << 24) | \
226 (((const uint8_t*)(x))[2] << 16) | \
227 (((const uint8_t*)(x))[1] << 8) | \
228 ((const uint8_t*)(x))[0])
229 #endif
230 #ifndef AV_WL32
231 # define AV_WL32(p, d) do { \
232 ((uint8_t*)(p))[0] = (d); \
233 ((uint8_t*)(p))[1] = (d)>>8; \
234 ((uint8_t*)(p))[2] = (d)>>16; \
235 ((uint8_t*)(p))[3] = (d)>>24; \
236 } while(0)
237 #endif
239 #ifndef AV_RB64
240 # define AV_RB64(x) \
241 (((uint64_t)((const uint8_t*)(x))[0] << 56) | \
242 ((uint64_t)((const uint8_t*)(x))[1] << 48) | \
243 ((uint64_t)((const uint8_t*)(x))[2] << 40) | \
244 ((uint64_t)((const uint8_t*)(x))[3] << 32) | \
245 ((uint64_t)((const uint8_t*)(x))[4] << 24) | \
246 ((uint64_t)((const uint8_t*)(x))[5] << 16) | \
247 ((uint64_t)((const uint8_t*)(x))[6] << 8) | \
248 (uint64_t)((const uint8_t*)(x))[7])
249 #endif
250 #ifndef AV_WB64
251 # define AV_WB64(p, d) do { \
252 ((uint8_t*)(p))[7] = (d); \
253 ((uint8_t*)(p))[6] = (d)>>8; \
254 ((uint8_t*)(p))[5] = (d)>>16; \
255 ((uint8_t*)(p))[4] = (d)>>24; \
256 ((uint8_t*)(p))[3] = (d)>>32; \
257 ((uint8_t*)(p))[2] = (d)>>40; \
258 ((uint8_t*)(p))[1] = (d)>>48; \
259 ((uint8_t*)(p))[0] = (d)>>56; \
260 } while(0)
261 #endif
263 #ifndef AV_RL64
264 # define AV_RL64(x) \
265 (((uint64_t)((const uint8_t*)(x))[7] << 56) | \
266 ((uint64_t)((const uint8_t*)(x))[6] << 48) | \
267 ((uint64_t)((const uint8_t*)(x))[5] << 40) | \
268 ((uint64_t)((const uint8_t*)(x))[4] << 32) | \
269 ((uint64_t)((const uint8_t*)(x))[3] << 24) | \
270 ((uint64_t)((const uint8_t*)(x))[2] << 16) | \
271 ((uint64_t)((const uint8_t*)(x))[1] << 8) | \
272 (uint64_t)((const uint8_t*)(x))[0])
273 #endif
274 #ifndef AV_WL64
275 # define AV_WL64(p, d) do { \
276 ((uint8_t*)(p))[0] = (d); \
277 ((uint8_t*)(p))[1] = (d)>>8; \
278 ((uint8_t*)(p))[2] = (d)>>16; \
279 ((uint8_t*)(p))[3] = (d)>>24; \
280 ((uint8_t*)(p))[4] = (d)>>32; \
281 ((uint8_t*)(p))[5] = (d)>>40; \
282 ((uint8_t*)(p))[6] = (d)>>48; \
283 ((uint8_t*)(p))[7] = (d)>>56; \
284 } while(0)
285 #endif
287 #if HAVE_BIGENDIAN
288 # define AV_RN(s, p) AV_RB##s(p)
289 # define AV_WN(s, p, v) AV_WB##s(p, v)
290 #else
291 # define AV_RN(s, p) AV_RL##s(p)
292 # define AV_WN(s, p, v) AV_WL##s(p, v)
293 #endif
295 #endif /* HAVE_FAST_UNALIGNED */
297 #ifndef AV_RN16
298 # define AV_RN16(p) AV_RN(16, p)
299 #endif
301 #ifndef AV_RN32
302 # define AV_RN32(p) AV_RN(32, p)
303 #endif
305 #ifndef AV_RN64
306 # define AV_RN64(p) AV_RN(64, p)
307 #endif
309 #ifndef AV_WN16
310 # define AV_WN16(p, v) AV_WN(16, p, v)
311 #endif
313 #ifndef AV_WN32
314 # define AV_WN32(p, v) AV_WN(32, p, v)
315 #endif
317 #ifndef AV_WN64
318 # define AV_WN64(p, v) AV_WN(64, p, v)
319 #endif
321 #if HAVE_BIGENDIAN
322 # define AV_RB(s, p) AV_RN##s(p)
323 # define AV_WB(s, p, v) AV_WN##s(p, v)
324 # define AV_RL(s, p) bswap_##s(AV_RN##s(p))
325 # define AV_WL(s, p, v) AV_WN##s(p, bswap_##s(v))
326 #else
327 # define AV_RB(s, p) bswap_##s(AV_RN##s(p))
328 # define AV_WB(s, p, v) AV_WN##s(p, bswap_##s(v))
329 # define AV_RL(s, p) AV_RN##s(p)
330 # define AV_WL(s, p, v) AV_WN##s(p, v)
331 #endif
333 #define AV_RB8(x) (((const uint8_t*)(x))[0])
334 #define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)
336 #define AV_RL8(x) AV_RB8(x)
337 #define AV_WL8(p, d) AV_WB8(p, d)
339 #ifndef AV_RB16
340 # define AV_RB16(p) AV_RB(16, p)
341 #endif
342 #ifndef AV_WB16
343 # define AV_WB16(p, v) AV_WB(16, p, v)
344 #endif
346 #ifndef AV_RL16
347 # define AV_RL16(p) AV_RL(16, p)
348 #endif
349 #ifndef AV_WL16
350 # define AV_WL16(p, v) AV_WL(16, p, v)
351 #endif
353 #ifndef AV_RB32
354 # define AV_RB32(p) AV_RB(32, p)
355 #endif
356 #ifndef AV_WB32
357 # define AV_WB32(p, v) AV_WB(32, p, v)
358 #endif
360 #ifndef AV_RL32
361 # define AV_RL32(p) AV_RL(32, p)
362 #endif
363 #ifndef AV_WL32
364 # define AV_WL32(p, v) AV_WL(32, p, v)
365 #endif
367 #ifndef AV_RB64
368 # define AV_RB64(p) AV_RB(64, p)
369 #endif
370 #ifndef AV_WB64
371 # define AV_WB64(p, v) AV_WB(64, p, v)
372 #endif
374 #ifndef AV_RL64
375 # define AV_RL64(p) AV_RL(64, p)
376 #endif
377 #ifndef AV_WL64
378 # define AV_WL64(p, v) AV_WL(64, p, v)
379 #endif
381 #ifndef AV_RB24
382 # define AV_RB24(x) \
383 ((((const uint8_t*)(x))[0] << 16) | \
384 (((const uint8_t*)(x))[1] << 8) | \
385 ((const uint8_t*)(x))[2])
386 #endif
387 #ifndef AV_WB24
388 # define AV_WB24(p, d) do { \
389 ((uint8_t*)(p))[2] = (d); \
390 ((uint8_t*)(p))[1] = (d)>>8; \
391 ((uint8_t*)(p))[0] = (d)>>16; \
392 } while(0)
393 #endif
395 #ifndef AV_RL24
396 # define AV_RL24(x) \
397 ((((const uint8_t*)(x))[2] << 16) | \
398 (((const uint8_t*)(x))[1] << 8) | \
399 ((const uint8_t*)(x))[0])
400 #endif
401 #ifndef AV_WL24
402 # define AV_WL24(p, d) do { \
403 ((uint8_t*)(p))[0] = (d); \
404 ((uint8_t*)(p))[1] = (d)>>8; \
405 ((uint8_t*)(p))[2] = (d)>>16; \
406 } while(0)
407 #endif
409 /*
410 * The AV_[RW]NA macros access naturally aligned data
411 * in a type-safe way.
412 */
414 #define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s)
415 #define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v))
417 #ifndef AV_RN16A
418 # define AV_RN16A(p) AV_RNA(16, p)
419 #endif
421 #ifndef AV_RN32A
422 # define AV_RN32A(p) AV_RNA(32, p)
423 #endif
425 #ifndef AV_RN64A
426 # define AV_RN64A(p) AV_RNA(64, p)
427 #endif
429 #ifndef AV_WN16A
430 # define AV_WN16A(p, v) AV_WNA(16, p, v)
431 #endif
433 #ifndef AV_WN32A
434 # define AV_WN32A(p, v) AV_WNA(32, p, v)
435 #endif
437 #ifndef AV_WN64A
438 # define AV_WN64A(p, v) AV_WNA(64, p, v)
439 #endif
441 /* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
442 * naturally aligned. They may be implemented using MMX,
443 * so emms_c() must be called before using any float code
444 * afterwards.
445 */
447 #define AV_COPY(n, d, s) \
448 (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n)
450 #ifndef AV_COPY16
451 # define AV_COPY16(d, s) AV_COPY(16, d, s)
452 #endif
454 #ifndef AV_COPY32
455 # define AV_COPY32(d, s) AV_COPY(32, d, s)
456 #endif
458 #ifndef AV_COPY64
459 # define AV_COPY64(d, s) AV_COPY(64, d, s)
460 #endif
462 #ifndef AV_COPY128
463 # define AV_COPY128(d, s) \
464 do { \
465 AV_COPY64(d, s); \
466 AV_COPY64((char*)(d)+8, (char*)(s)+8); \
467 } while(0)
468 #endif
470 #define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b))
472 #ifndef AV_SWAP64
473 # define AV_SWAP64(a, b) AV_SWAP(64, a, b)
474 #endif
476 #define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0)
478 #ifndef AV_ZERO16
479 # define AV_ZERO16(d) AV_ZERO(16, d)
480 #endif
482 #ifndef AV_ZERO32
483 # define AV_ZERO32(d) AV_ZERO(32, d)
484 #endif
486 #ifndef AV_ZERO64
487 # define AV_ZERO64(d) AV_ZERO(64, d)
488 #endif
490 #ifndef AV_ZERO128
491 # define AV_ZERO128(d) \
492 do { \
493 AV_ZERO64(d); \
494 AV_ZERO64((char*)(d)+8); \
495 } while(0)
496 #endif
498 #endif /* AVUTIL_INTREADWRITE_H */
