Mercurial > libavutil.hg
annotate intreadwrite.h @ 232:9845a508ffbd libavutil
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
author | alex |
---|---|
date | Fri, 19 Jan 2007 22:26:10 +0000 |
parents | 33b71496b63b |
children | ee010796c631 |
rev | line source |
---|---|
152
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
1 #ifndef INTREADWRITE_H |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
2 #define INTREADWRITE_H |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
3 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
4 #ifdef __GNUC__ |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
5 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
6 struct unaligned_64 { uint64_t l; } __attribute__((packed)); |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
7 struct unaligned_32 { uint32_t l; } __attribute__((packed)); |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
8 struct unaligned_16 { uint16_t l; } __attribute__((packed)); |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
9 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
10 #define LD16(a) (((const struct unaligned_16 *) (a))->l) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
11 #define LD32(a) (((const struct unaligned_32 *) (a))->l) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
12 #define LD64(a) (((const struct unaligned_64 *) (a))->l) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
13 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
14 #define ST16(a, b) (((struct unaligned_16 *) (a))->l) = (b) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
15 #define ST32(a, b) (((struct unaligned_32 *) (a))->l) = (b) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
16 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
17 #else /* __GNUC__ */ |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
18 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
19 #define LD16(a) (*((uint16_t*)(a))) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
20 #define LD32(a) (*((uint32_t*)(a))) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
21 #define LD64(a) (*((uint64_t*)(a))) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
22 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
23 #define ST16(a, b) *((uint16_t*)(a)) = (b) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
24 #define ST32(a, b) *((uint32_t*)(a)) = (b) |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
25 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
26 #endif /* !__GNUC__ */ |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
27 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
28 /* endian macros */ |
232
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
29 #define AV_RB8(x) (((uint8_t*)(x))[0]) |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
30 #define AV_WB8(p, i, d) { ((uint8_t*)(p))[(i)] = (d); } |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
31 |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
32 #define AV_RB16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
33 #define AV_WB16(p, i, d) { \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
34 ((uint8_t*)(p))[(i)+1] = (d); \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
35 ((uint8_t*)(p))[(i)] = (d)>>8; } |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
36 |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
37 #define AV_RB32(x) ((((uint8_t*)(x))[0] << 24) | \ |
152
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
38 (((uint8_t*)(x))[1] << 16) | \ |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
39 (((uint8_t*)(x))[2] << 8) | \ |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
40 ((uint8_t*)(x))[3]) |
232
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
41 #define AV_WB32(p, i, d) { \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
42 ((uint8_t*)(p))[(i)+3] = (d); \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
43 ((uint8_t*)(p))[(i)+2] = (d)>>8; \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
44 ((uint8_t*)(p))[(i)+1] = (d)>>16; \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
45 ((uint8_t*)(p))[(i)] = (d)>>24; } |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
46 |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
47 #define AV_RL8(x) AV_RB8(x) |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
48 #define AV_WL8(p, i, d) AV_WB8(p, i, d) |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
49 |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
50 #define AV_RL16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0]) |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
51 #define AV_WL16(p, i, d) { \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
52 ((uint8_t*)(p))[(i)] = (d); \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
53 ((uint8_t*)(p))[(i)+1] = (d)>>8; } |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
54 |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
55 #define AV_RL32(x) ((((uint8_t*)(x))[3] << 24) | \ |
152
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
56 (((uint8_t*)(x))[2] << 16) | \ |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
57 (((uint8_t*)(x))[1] << 8) | \ |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
58 ((uint8_t*)(x))[0]) |
232
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
59 #define AV_WL32(p, i, d) { \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
60 ((uint8_t*)(p))[(i)] = (d); \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
61 ((uint8_t*)(p))[(i)+1] = (d)>>8; \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
62 ((uint8_t*)(p))[(i)+2] = (d)>>16; \ |
9845a508ffbd
add AV_WB/WL for lswriting, similar to AV_RB/RL (also increment version)
alex
parents:
231
diff
changeset
|
63 ((uint8_t*)(p))[(i)+3] = (d)>>24; } |
152
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
64 |
5b211d03227b
Move BE_*/LE_*/ST*/LD* macros to a common place. Some further
reimar
parents:
diff
changeset
|
65 #endif /* INTREADWRITE_H */ |