]> git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia2/lib/converter.def
dc8074b06e3b343e836e564733ebf38851e398d5
[wxWidgets.git] / utils / wxMMedia2 / lib / converter.def
1 #define DEFINE_CONV_8(name) \
2 static void Convert_##name##_8(const char *buf_in, char *buf_out, size_t len) \
3 {\
4 wxUint16 val; \
5 \
6 while (len > 0) { \
7 val = *buf_in++; \
8 len--;
9
10 #if SWAP_BYTES==0
11
12 #define DEFINE_CONV_16(name) \
13 static void Convert_##name##_16_no(const char *buf_in, char *buf_out, size_t len) \
14 {\
15 wxUint16 val; \
16 \
17 while (len > 0) { \
18 val = *(wxUint16 *)(buf_in); \
19 buf_in += 2; \
20 len -= 2;
21
22 #else
23
24 #define DEFINE_CONV_16(name) \
25 static void Convert_##name##_16_yes(const char *buf_in, char *buf_out, size_t len) \
26 {\
27 wxUint16 val; \
28 \
29 while (len > 0) { \
30 val = *(wxUint16 *)(buf_in); \
31 val = wxUINT16_SWAP_ALWAYS(val); \
32 buf_in += 2; \
33 len -= 2;
34
35 #endif
36
37 #define END_CONV } }
38
39 #define PUT16 *((wxUint16 *)buf_out) = val, buf_out += 2;
40 #define PUT16_SWAP *((wxUint16 *)buf_out) = wxUINT16_SWAP_ALWAYS(val), buf_out += 2;
41 #define PUT8 *buf_out++ = val;
42 #define CHANGE16_SIGN val ^= 0x8000;
43 #define CHANGE8_SIGN val ^= 0x80;
44 #define REDUCE16_TO_8 val /= 256;
45 #define AUGMENT8_TO_16 val *= 256;
46
47 DEFINE_CONV_16(16to8)
48 REDUCE16_TO_8
49 PUT8
50 END_CONV
51
52 DEFINE_CONV_16(16to8_U2S)
53 CHANGE16_SIGN
54 REDUCE16_TO_8
55 PUT8
56 END_CONV
57
58 DEFINE_CONV_16(U2S)
59 CHANGE16_SIGN
60 PUT16
61 END_CONV
62
63 DEFINE_CONV_16(U2S_SWAP)
64 CHANGE16_SIGN
65 PUT16_SWAP
66 END_CONV
67
68 #if SWAP_BYTES == 0
69
70 DEFINE_CONV_16(SWAP)
71 PUT16_SWAP
72 END_CONV
73
74 DEFINE_CONV_8(U2S)
75 CHANGE8_SIGN
76 PUT8
77 END_CONV
78
79 DEFINE_CONV_8(8to16)
80 AUGMENT8_TO_16
81 PUT16
82 END_CONV
83
84 DEFINE_CONV_8(8to16_SWAP)
85 AUGMENT8_TO_16
86 PUT16_SWAP
87 END_CONV
88
89 DEFINE_CONV_8(8to16_U2S)
90 CHANGE8_SIGN
91 AUGMENT8_TO_16
92 PUT16
93 END_CONV
94
95 DEFINE_CONV_8(8to16_U2S_SWAP)
96 CHANGE8_SIGN
97 AUGMENT8_TO_16
98 PUT16_SWAP
99 END_CONV
100
101 #endif
102
103 #undef DEFINE_CONV_16
104 #undef DEFINE_CONV_8
105 #undef END_CONV
106 #undef CHANGE16_SIGN
107 #undef CHANGE8_SIGN
108 #undef PUT16_SWAP
109 #undef PUT16
110 #undef PUT8