* Updated README

* Recoded converters (in a cleaner way)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5980 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Guilhem Lavaux 2000-02-12 12:11:23 +00:00
parent 9bb3479c68
commit ef366f3523
7 changed files with 123 additions and 178 deletions

View File

@ -0,0 +1,39 @@
--------------------------------------------------------------------------
| wxMultimedia (c) 1998, 1999, 2000 Guilhem Lavaux
| wxWindows license
--------------------------------------------------------------------------
This is the wxMultimedia package. It intends to be a portable way to access
some multimedia component on variable system. For the moment, I implemented
sound, video and CD access.
Sound features:
* low level/OSS style access to the sound card. You can open/setup the
parameters of the sound card then write/read directly to/from it.
* mid level codecs: compressors and sound codec are supported. For the
moment there is a support for G711/G721/G723 and MULAW formats (as well
PCM).
* high level format: WAV file format is supported in read/write and AIFF
format in read only
Sound bugs:
* it seems there are still some bugs in the recording code on Windows
on Cygwin B20.1 (to be verified)
* wave files created with wxSoundWave have some problem with Windows Media
Player (not windows recorder)
Video features:
* high level video file playing: on Unix you can play (through xanim) video
files directly into your application
* MPEG video file to be supported through SMPEG as soon as I have some free
time
Video bugs:
* Recode windows port
CD features:
* standard access to the CDAUDIO interface
CD bugs:

View File

@ -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--;
src = *t_buf_in++; \
*t_buf_out++ = convert; \
len--; \
} \
}
#if SWAP_BYTES==0
DEFINE_CONV(8_8_sign, wxUint8, wxUint8, (src ^ 0x80))
#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;
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))
#else
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 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
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))

View File

@ -2,7 +2,7 @@
// Name: sndbase.cpp
// Purpose:
// Date: 08/11/1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
// CVSID: $Id$
// --------------------------------------------------------------------------
#ifdef __GNUG__

View File

@ -2,7 +2,7 @@
// Name: sndcpcm.cpp
// Purpose:
// Date: 08/11/1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
// CVSID: $Id$
// --------------------------------------------------------------------------
#ifdef __GNUG__
@ -26,72 +26,49 @@ wxSoundStreamPcm::~wxSoundStreamPcm()
}
#define SWAP_BYTES 0
#include "converter.def"
#undef SWAP_BYTES
#define SWAP_BYTES 1
#include "converter.def"
#undef SWAP_BYTES
wxSoundStreamPcm::ConverterType s_convert_out_16_to_8[] = {
Convert_16to8_16_no,
Convert_16to8_U2S_16_no,
wxSoundStreamPcm::ConverterType s_converters[] = {
NULL,
Convert_8_8_sign, /* 8 -> 8 sign */
NULL,
NULL,
Convert_16to8_U2S_16_yes,
Convert_16to8_16_yes
NULL,
NULL,
Convert_8_16, /* 8 -> 16 */
Convert_8_16_sign, /* 8 -> 16 sign */
Convert_8_16_swap, /* 8 -> 16 swapped */
Convert_8_16_sign_swap, /* 8 -> 16 sign swapped */
NULL,
NULL,
Convert_16_8, /* 16 -> 8 */
Convert_16_8_sign, /* 16 -> 8 sign */
Convert_16_swap_8, /* 16 swapped -> 8 */
Convert_16_swap_8_sign, /* 16 swapped -> 8 sign */
NULL,
NULL,
NULL, /* 16 -> 16 */
Convert_16_sign, /* 16 -> 16 sign */
Convert_16_swap, /* 16 swapped -> 16 */
Convert_16_swap_16_sign, /* 16 swapped -> 16 sign */
Convert_16_sign_16_swap, /* 16 sign -> 16 swapped */
Convert_16_swap_16_sign_swap /* 16 swapped -> 16 sign swapped */
};
wxSoundStreamPcm::ConverterType s_convert_out_16[] = {
NULL,
Convert_U2S_16_no,
Convert_U2S_SWAP_16_no,
Convert_U2S_SWAP_16_yes,
Convert_U2S_16_yes,
Convert_SWAP_16_no
};
#define CONVERT_BPS 0
#define CONVERT_SIGN 1
#define CONVERT_SWAP 2
#define CONVERT_SIGN_SWAP 3
#define CONVERT_SWAP_SIGN 4
#define CONVERT_SWAP_SIGN_SWAP 5
wxSoundStreamPcm::ConverterType s_convert_out_8[] = {
NULL,
Convert_U2S_8,
Convert_U2S_8,
Convert_U2S_8,
Convert_U2S_8,
NULL
/*,
Convert_U2S_S2M_8,
Convert_U2S_S2M_8,
Convert_U2S_S2M_8,
Convert_U2S_S2M_8,
Convert_S2M_8 */
};
wxSoundStreamPcm::ConverterType s_convert_in_8_to_16[] = {
Convert_8to16_8,
Convert_8to16_U2S_8,
Convert_8to16_U2S_SWAP_8,
NULL,
NULL,
Convert_8to16_SWAP_8
};
wxSoundStreamPcm::ConverterType *s_convert_in_16 = s_convert_out_16;
wxSoundStreamPcm::ConverterType *s_convert_in_8 = s_convert_out_8;
#define CONVERTER 0
#define CONVERTER_SIGN 1
#define CONVERTER_SIGN_SWAP 2
#define CONVERTER_SWAP_SIGN_SWAP 3
#define CONVERTER_SWAP_SIGN 4
#define CONVERTER_SWAP 5
#define CONVERTER_SIGN_STEREO_MONO 6
#define CONVERTER_SIGN_SWAP_STEREO_MONO 7
#define CONVERTER_SWAP_SIGN_SWAP_STEREO_MONO 8
#define CONVERTER_SWAP_SIGN_STEREO_MONO 9
#define CONVERTER_SWAP_STEREO_MONO 10
#define CONVERTER_STEREO_MONO 11
#define CONVERT_BASE_8_8 0
#define CONVERT_BASE_8_16 6
#define CONVERT_BASE_16_8 12
#define CONVERT_BASE_16_16 18
//
// TODO: Read() and Write() aren't really safe. If you give it a buffer which
@ -178,14 +155,19 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
m_16_to_8 = FALSE;
if (pcm_format->GetBPS() != pcm_format2->GetBPS()) {
m_16_to_8 = TRUE;
current_table_out = s_convert_out_16_to_8;
current_table_in = s_convert_in_8_to_16;
if (pcm_format2->GetBPS() == 8) {
current_table_out = &s_converters[CONVERT_BASE_16_8];
current_table_in = &s_converters[CONVERT_BASE_8_16];
} else {
current_table_out = &s_converters[CONVERT_BASE_8_16];
current_table_in = &s_converters[CONVERT_BASE_16_8];
}
} else if (pcm_format->GetBPS() == 16) {
current_table_out = s_convert_out_16;
current_table_in = s_convert_in_16;
current_table_out = &s_converters[CONVERT_BASE_16_16];
current_table_in = &s_converters[CONVERT_BASE_16_16];
} else {
current_table_out = s_convert_out_8;
current_table_in = s_convert_in_8;
current_table_out = &s_converters[CONVERT_BASE_8_8];
current_table_in = &s_converters[CONVERT_BASE_8_8];
}
change_sign = (pcm_format2->Signed() != pcm_format->Signed());
@ -199,22 +181,25 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format)
if (pcm_format->GetOrder() == OTHER_ORDER &&
pcm_format2->GetOrder() == OTHER_ORDER && change_sign)
index = CONVERTER_SWAP_SIGN_SWAP;
index = CONVERT_SWAP_SIGN_SWAP;
else if (pcm_format->GetOrder() == OTHER_ORDER &&
pcm_format2->GetOrder() == MY_ORDER && change_sign)
index = CONVERTER_SWAP_SIGN;
index = CONVERT_SWAP_SIGN;
else if (pcm_format->GetOrder() == MY_ORDER &&
pcm_format->GetOrder() == OTHER_ORDER && change_sign)
index = CONVERTER_SIGN_SWAP;
index = CONVERT_SIGN_SWAP;
else if (change_sign)
index = CONVERT_SIGN;
else if (!change_sign &&
pcm_format->GetOrder() != pcm_format2->GetOrder())
index = CONVERTER_SWAP;
index = CONVERT_SWAP;
else
index = CONVERTER;
index = CONVERT_BPS;
m_function_out = current_table_out[index];
m_function_in = current_table_in[index];

View File

@ -2,7 +2,7 @@
// Name: sndoss.cpp
// Purpose:
// Date: 08/11/1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
// CVSID: $Id$
// --------------------------------------------------------------------------
#ifdef __GNUG__

View File

@ -2,7 +2,7 @@
// Name: sndwin.cpp
// Purpose:
// Date: 08/11/1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999
// Author: Guilhem Lavaux <lavaux@easynet.fr> (C) 1999, 2000
// CVSID: $Id$
// --------------------------------------------------------------------------
#include <wx/wxprec.h>

View File

@ -4,7 +4,7 @@
// Author: Guilhem Lavaux
// Created: February 1998
// Updated:
// Copyright: (C) 1998, Guilhem Lavaux
// Copyright: (C) 1998, 1999, 2000 Guilhem Lavaux
// License: wxWindows license
////////////////////////////////////////////////////////////////////////////////