]>
Commit | Line | Data |
---|---|---|
ef366f35 GL |
1 | #define DEFINE_CONV(name, input_type, output_type, convert) \ |
2 | static void Convert_##name##(const char *buf_in, char *buf_out, wxUint32 len) \ | |
526ddb13 | 3 | {\ |
ef366f35 GL |
4 | register input_type src; \ |
5 | register const input_type *t_buf_in = (input_type *)buf_in; \ | |
6 | register output_type *t_buf_out = (output_type *)buf_out; \ | |
526ddb13 GL |
7 | \ |
8 | while (len > 0) { \ | |
ef366f35 GL |
9 | src = *t_buf_in++; \ |
10 | *t_buf_out++ = convert; \ | |
11 | len--; \ | |
12 | } \ | |
13 | } | |
14 | ||
15 | DEFINE_CONV(8_8_sign, wxUint8, wxUint8, (src ^ 0x80)) | |
16 | ||
17 | DEFINE_CONV(8_16, wxUint8, wxUint16, (((wxUint16)src) << 8)) | |
18 | DEFINE_CONV(8_16_swap, wxUint8, wxUint16, (src)) | |
19 | DEFINE_CONV(8_16_sign, wxUint8, wxUint16, (((wxUint16)(src ^ 0x80)) << 8)) | |
20 | DEFINE_CONV(8_16_sign_swap, wxUint8, wxUint16, (src ^ 0x80)) | |
21 | ||
22 | DEFINE_CONV(16_8, wxUint16, wxUint8, (wxUint8)(src >> 8)) | |
23 | DEFINE_CONV(16_8_sign, wxUint16, wxUint8, (wxUint8)((src >> 8) ^ 0x80)) | |
24 | DEFINE_CONV(16_swap_8, wxUint16, wxUint8, (wxUint8)(src & 0xff)) | |
25 | DEFINE_CONV(16_swap_8_sign, wxUint16, wxUint8, (wxUint8)((src & 0xff) ^ 0x80)) | |
26 | ||
27 | DEFINE_CONV(16_sign, wxUint16, wxUint16, (src ^ 0x8000)) | |
28 | DEFINE_CONV(16_swap, wxUint16, wxUint16, (((src & 0xff) << 8) | ((src >> 8) & 0xff))) | |
29 | DEFINE_CONV(16_swap_16_sign, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x8000)) | |
30 | DEFINE_CONV(16_sign_16_swap, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x80)) | |
31 | DEFINE_CONV(16_swap_16_sign_swap, wxUint16, wxUint16, (src ^ 0x80)) |