X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0662cd3286d6da0be81ef063633fec13c5cf741b..5bee458a0f61063fc142a50012261d8ac2c32e5a:/utils/wxMMedia2/lib/converter.def diff --git a/utils/wxMMedia2/lib/converter.def b/utils/wxMMedia2/lib/converter.def index b5279cc03f..21157955f9 100644 --- a/utils/wxMMedia2/lib/converter.def +++ b/utils/wxMMedia2/lib/converter.def @@ -1,110 +1,31 @@ -#define DEFINE_CONV_8(name) \ -static void Convert_##name##_8(const char *buf_in, char *buf_out, wxUint32 len) \ +#define DEFINE_CONV(name, input_type, output_type, convert) \ +static void Convert_##name##(const char *buf_in, char *buf_out, wxUint32 len) \ {\ - wxUint16 val; \ + register input_type src; \ + register const input_type *t_buf_in = (input_type *)buf_in; \ + register output_type *t_buf_out = (output_type *)buf_out; \ \ while (len > 0) { \ - val = *buf_in++; \ - len--; - -#if SWAP_BYTES==0 - -#define DEFINE_CONV_16(name) \ -static void Convert_##name##_16_no(const char *buf_in, char *buf_out, wxUint32 len) \ -{\ - wxUint16 val; \ -\ - while (len > 0) { \ - val = *(wxUint16 *)(buf_in); \ - buf_in += 2; \ - len -= 2; - -#else - -#define DEFINE_CONV_16(name) \ -static void Convert_##name##_16_yes(const char *buf_in, char *buf_out, wxUint32 len) \ -{\ - wxUint16 val; \ -\ - while (len > 0) { \ - val = *(wxUint16 *)(buf_in); \ - val = wxUINT16_SWAP_ALWAYS(val); \ - buf_in += 2; \ - len -= 2; - -#endif - -#define END_CONV } } - -#define PUT16 *((wxUint16 *)buf_out) = val, buf_out += 2; -#define PUT16_SWAP *((wxUint16 *)buf_out) = wxUINT16_SWAP_ALWAYS(val), buf_out += 2; -#define PUT8 *buf_out++ = val; -#define CHANGE16_SIGN val ^= 0x8000; -#define CHANGE8_SIGN val ^= 0x80; -#define REDUCE16_TO_8 val /= 256; -#define AUGMENT8_TO_16 val *= 256; - -DEFINE_CONV_16(16to8) -REDUCE16_TO_8 -PUT8 -END_CONV - -DEFINE_CONV_16(16to8_U2S) -CHANGE16_SIGN -REDUCE16_TO_8 -PUT8 -END_CONV - -DEFINE_CONV_16(U2S) -CHANGE16_SIGN -PUT16 -END_CONV - -DEFINE_CONV_16(U2S_SWAP) -CHANGE16_SIGN -PUT16_SWAP -END_CONV - -#if SWAP_BYTES == 0 - -DEFINE_CONV_16(SWAP) -PUT16_SWAP -END_CONV - -DEFINE_CONV_8(U2S) -CHANGE8_SIGN -PUT8 -END_CONV - -DEFINE_CONV_8(8to16) -AUGMENT8_TO_16 -PUT16 -END_CONV - -DEFINE_CONV_8(8to16_SWAP) -AUGMENT8_TO_16 -PUT16_SWAP -END_CONV - -DEFINE_CONV_8(8to16_U2S) -CHANGE8_SIGN -AUGMENT8_TO_16 -PUT16 -END_CONV - -DEFINE_CONV_8(8to16_U2S_SWAP) -CHANGE8_SIGN -AUGMENT8_TO_16 -PUT16_SWAP -END_CONV - -#endif - -#undef DEFINE_CONV_16 -#undef DEFINE_CONV_8 -#undef END_CONV -#undef CHANGE16_SIGN -#undef CHANGE8_SIGN -#undef PUT16_SWAP -#undef PUT16 -#undef PUT8 + src = *t_buf_in++; \ + *t_buf_out++ = convert; \ + len--; \ + } \ +} + +DEFINE_CONV(8_8_sign, wxUint8, wxUint8, (src ^ 0x80)) + +DEFINE_CONV(8_16, wxUint8, wxUint16, (((wxUint16)src) << 8)) +DEFINE_CONV(8_16_swap, wxUint8, wxUint16, (src)) +DEFINE_CONV(8_16_sign, wxUint8, wxUint16, (((wxUint16)(src ^ 0x80)) << 8)) +DEFINE_CONV(8_16_sign_swap, wxUint8, wxUint16, (src ^ 0x80)) + +DEFINE_CONV(16_8, wxUint16, wxUint8, (wxUint8)(src >> 8)) +DEFINE_CONV(16_8_sign, wxUint16, wxUint8, (wxUint8)((src >> 8) ^ 0x80)) +DEFINE_CONV(16_swap_8, wxUint16, wxUint8, (wxUint8)(src & 0xff)) +DEFINE_CONV(16_swap_8_sign, wxUint16, wxUint8, (wxUint8)((src & 0xff) ^ 0x80)) + +DEFINE_CONV(16_sign, wxUint16, wxUint16, (src ^ 0x8000)) +DEFINE_CONV(16_swap, wxUint16, wxUint16, (((src & 0xff) << 8) | ((src >> 8) & 0xff))) +DEFINE_CONV(16_swap_16_sign, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x8000)) +DEFINE_CONV(16_sign_16_swap, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x80)) +DEFINE_CONV(16_swap_16_sign_swap, wxUint16, wxUint16, (src ^ 0x80))