]> git.saurik.com Git - wxWidgets.git/blob - utils/wxMMedia2/lib/converter.def
* ESD works in full duplex (theorically)
[wxWidgets.git] / utils / wxMMedia2 / lib / converter.def
1 #include <stdio.h>
2
3 #define DEFINE_CONV(name, input_type, output_type, convert) \
4 static void Convert_##name##(const char *buf_in, char *buf_out, wxUint32 len) \
5 {\
6 register input_type src; \
7 register const input_type *t_buf_in = (input_type *)buf_in; \
8 register output_type *t_buf_out = (output_type *)buf_out; \
9 \
10 while (len > 0) { \
11 src = *t_buf_in++; \
12 *t_buf_out++ = convert; \
13 len -= sizeof(input_type); \
14 } \
15 }
16
17 DEFINE_CONV(8_8_sign, wxUint8, wxUint8, (src ^ 0x80))
18
19 DEFINE_CONV(8_16, wxUint8, wxUint16, (((wxUint16)src) << 8))
20 DEFINE_CONV(8_16_swap, wxUint8, wxUint16, (src))
21 DEFINE_CONV(8_16_sign, wxUint8, wxUint16, (((wxUint16)(src ^ 0x80)) << 8))
22 DEFINE_CONV(8_16_sign_swap, wxUint8, wxUint16, (src ^ 0x80))
23
24 DEFINE_CONV(16_8, wxUint16, wxUint8, (wxUint8)(src >> 8))
25 DEFINE_CONV(16_8_sign, wxUint16, wxUint8, (wxUint8)((src >> 8) ^ 0x80))
26 DEFINE_CONV(16_swap_8, wxUint16, wxUint8, (wxUint8)(src & 0xff))
27 DEFINE_CONV(16_swap_8_sign, wxUint16, wxUint8, (wxUint8)((src & 0xff) ^ 0x80))
28
29 DEFINE_CONV(16_sign, wxUint16, wxUint16, (src ^ 0x8000))
30 DEFINE_CONV(16_swap, wxUint16, wxUint16, (((src & 0xff) << 8) | ((src >> 8) & 0xff)))
31 DEFINE_CONV(16_swap_16_sign, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x8000))
32 DEFINE_CONV(16_sign_16_swap, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x80))
33 DEFINE_CONV(16_swap_16_sign_swap, wxUint16, wxUint16, (src ^ 0x80))