From dea7e44a76e4e886f2bc60b0e82322a71b1f1f4f Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Wed, 16 Jun 2004 15:22:59 +0000 Subject: [PATCH] -1, TRUE/true, FALSE/false and tabs replacements. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- contrib/include/wx/mmedia/sndbase.h | 4 +- contrib/include/wx/mmedia/sndfile.h | 2 +- contrib/include/wx/mmedia/sndpcm.h | 2 +- contrib/include/wx/mmedia/vidbase.h | 6 +- contrib/samples/mmedia/mmbman.cpp | 30 +- contrib/samples/mmedia/mmboard.cpp | 2 +- contrib/src/mmedia/cdunix.cpp | 2 +- contrib/src/mmedia/cdwin.cpp | 12 +- contrib/src/mmedia/g711.cpp | 308 +++++------ contrib/src/mmedia/g721.cpp | 168 +++--- contrib/src/mmedia/g723_24.cpp | 160 +++--- contrib/src/mmedia/g723_40.cpp | 182 +++--- contrib/src/mmedia/g72x.cpp | 828 ++++++++++++++-------------- contrib/src/mmedia/sndaiff.cpp | 36 +- contrib/src/mmedia/sndbase.cpp | 4 +- contrib/src/mmedia/sndcpcm.cpp | 16 +- contrib/src/mmedia/sndesd.cpp | 46 +- contrib/src/mmedia/sndfile.cpp | 74 +-- contrib/src/mmedia/sndg72x.cpp | 8 +- contrib/src/mmedia/sndmsad.cpp | 14 +- contrib/src/mmedia/sndoss.cpp | 62 +-- contrib/src/mmedia/sndpcm.cpp | 2 +- contrib/src/mmedia/sndulaw.cpp | 8 +- contrib/src/mmedia/sndwav.cpp | 64 +-- contrib/src/mmedia/sndwin.cpp | 84 +-- contrib/src/mmedia/vidbase.cpp | 8 +- contrib/src/mmedia/vidwin.cpp | 44 +- contrib/src/mmedia/vidxanm.cpp | 140 ++--- 28 files changed, 1158 insertions(+), 1158 deletions(-) diff --git a/contrib/include/wx/mmedia/sndbase.h b/contrib/include/wx/mmedia/sndbase.h index eff565ef6e..34fa8aec40 100644 --- a/contrib/include/wx/mmedia/sndbase.h +++ b/contrib/include/wx/mmedia/sndbase.h @@ -125,7 +125,7 @@ class WXDLLIMPEXP_MMEDIA wxSoundStream { // Returns the best size for IO calls virtual wxUint32 GetBestSize() const { return 1024; } - // SetSoundFormat returns TRUE when the format can be handled. + // SetSoundFormat returns true when the format can be handled. virtual bool SetSoundFormat(const wxSoundFormatBase& format); // GetSoundFormat returns the current sound format. @@ -146,7 +146,7 @@ class WXDLLIMPEXP_MMEDIA wxSoundStream { wxUint32 GetLastAccess() const { return m_lastcount; } // This is only useful for device (I think). - virtual bool QueueFilled() const { return TRUE; } + virtual bool QueueFilled() const { return true; } protected: // Current sound format diff --git a/contrib/include/wx/mmedia/sndfile.h b/contrib/include/wx/mmedia/sndfile.h index 62218e81d8..5c5bc18d25 100644 --- a/contrib/include/wx/mmedia/sndfile.h +++ b/contrib/include/wx/mmedia/sndfile.h @@ -98,7 +98,7 @@ public: // You should use this function to test whether this file codec can read // the stream you passed to it. - virtual bool CanRead() { return FALSE; } + virtual bool CanRead() { return false; } protected: wxSoundRouterStream m_codec; diff --git a/contrib/include/wx/mmedia/sndpcm.h b/contrib/include/wx/mmedia/sndpcm.h index ab742f803f..21690ff4ae 100644 --- a/contrib/include/wx/mmedia/sndpcm.h +++ b/contrib/include/wx/mmedia/sndpcm.h @@ -23,7 +23,7 @@ class wxSoundFormatPcm : public wxSoundFormatBase { public: wxSoundFormatPcm(wxUint32 srate = 22500, wxUint8 bps = 8, - wxUint16 channels = 2, bool sign = TRUE, + wxUint16 channels = 2, bool sign = true, int order = wxLITTLE_ENDIAN); ~wxSoundFormatPcm(); diff --git a/contrib/include/wx/mmedia/vidbase.h b/contrib/include/wx/mmedia/vidbase.h index 8d7810f37b..631d2ea10b 100644 --- a/contrib/include/wx/mmedia/vidbase.h +++ b/contrib/include/wx/mmedia/vidbase.h @@ -5,7 +5,7 @@ // Created: 1997 // Updated: 1998 // Copyright: (C) 1997, 1998, Guilhem Lavaux -// CVS: $Id$ +// CVS: $Id$ // License: wxWindows license // ///////////////////////////////////////////////////////////////////////////// /* Real -*- C++ -*- */ @@ -68,7 +68,7 @@ public: // Dtor virtual ~wxVideoBaseDriver(); - // Usual functions ... They all return FALSE in case of errors. + // Usual functions ... They all return false in case of errors. virtual bool Play() = 0; virtual bool Stop() = 0; virtual bool Pause() = 0; @@ -79,7 +79,7 @@ public: virtual bool GetSize(wxSize& size) const = 0; // Test the capability of the driver to handle the specified type - virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) const { return FALSE; } + virtual bool IsCapable(wxVideoType WXUNUSED(v_type)) const { return false; } // Return the video codec name virtual wxString GetMovieCodec() const = 0; diff --git a/contrib/samples/mmedia/mmbman.cpp b/contrib/samples/mmedia/mmbman.cpp index 85728e9ec1..de23245548 100644 --- a/contrib/samples/mmedia/mmbman.cpp +++ b/contrib/samples/mmedia/mmbman.cpp @@ -245,7 +245,7 @@ void MMBoardSoundFile::SetPosition(MMBoardTime btime) bool MMBoardSoundFile::NeedWindow() { - return FALSE; + return false; } void MMBoardSoundFile::SetWindow(wxWindow *WXUNUSED(window)) @@ -310,17 +310,17 @@ wxString MMBoardSoundFile::GetStringInformation() case wxSOUND_PCM: { wxSoundFormatPcm *pcm_format = (wxSoundFormatPcm *)format; - info += wxString::Format(wxT("PCM %s %s\n"), + info += wxString::Format(wxT("PCM %s %s\n"), pcm_format->Signed() ? wxT("signed") : wxT("unsigned"), pcm_format->GetOrder() == wxLITTLE_ENDIAN ? wxT("little endian") : wxT("big endian")); - info += wxString::Format(wxT("Sampling rate: %d\n") - wxT("Bits per sample: %d\n") - wxT("Number of channels: %d\n"), - pcm_format->GetSampleRate(), - pcm_format->GetBPS(), - pcm_format->GetChannels()); - - break; + info += wxString::Format(wxT("Sampling rate: %d\n") + wxT("Bits per sample: %d\n") + wxT("Number of channels: %d\n"), + pcm_format->GetSampleRate(), + pcm_format->GetBPS(), + pcm_format->GetChannels()); + + break; } case wxSOUND_MSADPCM: { wxSoundFormatMSAdpcm *adpcm_format = (wxSoundFormatMSAdpcm *)format; @@ -334,13 +334,13 @@ wxString MMBoardSoundFile::GetStringInformation() } case wxSOUND_ULAW: { wxSoundFormatUlaw *ulaw_format = (wxSoundFormatUlaw *)format; - info += wxT("ULAW\n"); - info += wxString::Format(wxT("Sampling rate: %d\n"), ulaw_format->GetSampleRate()); - break; + info += wxT("ULAW\n"); + info += wxString::Format(wxT("Sampling rate: %d\n"), ulaw_format->GetSampleRate()); + break; } default: info += wxT("Unknown"); - break; + break; } return info; } @@ -375,7 +375,7 @@ MMBoardVideoFile::~MMBoardVideoFile() bool MMBoardVideoFile::NeedWindow() { - return TRUE; + return true; } void MMBoardVideoFile::SetWindow(wxWindow *window) diff --git a/contrib/samples/mmedia/mmboard.cpp b/contrib/samples/mmedia/mmboard.cpp index cb430f5fa8..bdb509f92a 100644 --- a/contrib/samples/mmedia/mmboard.cpp +++ b/contrib/samples/mmedia/mmboard.cpp @@ -284,7 +284,7 @@ MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSi // Initialize main slider m_positionSlider = new wxSlider( m_panel, MMBoard_PositionSlider, 0, 0, 60, - wxDefaultPosition, wxSize(300, -1), + wxDefaultPosition, wxSize(300, wxDefaultSize.y), wxSL_HORIZONTAL | wxSL_AUTOTICKS); m_positionSlider->SetPageSize(60); // 60 secs m_positionSlider->Disable(); diff --git a/contrib/src/mmedia/cdunix.cpp b/contrib/src/mmedia/cdunix.cpp index 05b6dd070b..936eeef4d2 100644 --- a/contrib/src/mmedia/cdunix.cpp +++ b/contrib/src/mmedia/cdunix.cpp @@ -80,7 +80,7 @@ void wxCDAudioLinux::OpenDevice(const wxString& dev_name) struct cdrom_tocentry entry, old_entry; struct cdrom_tochdr diskinf; struct cdrom_msf0 *msf = &entry.cdte_addr.msf, - *old_msf = &old_entry.cdte_addr.msf; + *old_msf = &old_entry.cdte_addr.msf; wxCDtime *the_track; wxCDtime tot_tm; wxUint8 nb_tracks, i; diff --git a/contrib/src/mmedia/cdwin.cpp b/contrib/src/mmedia/cdwin.cpp index 1752cc1810..6458f49fd4 100644 --- a/contrib/src/mmedia/cdwin.cpp +++ b/contrib/src/mmedia/cdwin.cpp @@ -46,7 +46,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxCDAudioWin, wxCDAudio) wxCDAudioWin::wxCDAudioWin(void) - : wxCDAudio(), m_trksize(NULL), m_trkpos(NULL), m_toc(NULL), m_ok(TRUE) + : wxCDAudio(), m_trksize(NULL), m_trkpos(NULL), m_toc(NULL), m_ok(true) { MCI_OPEN_PARMS open_struct; MCI_SET_PARMS set_struct; @@ -56,7 +56,7 @@ wxCDAudioWin::wxCDAudioWin(void) DWORD ret = mciSendCommand((MCIDEVICEID)NULL, MCI_OPEN, MCI_OPEN_TYPE, (DWORD)&open_struct); if (ret) { - m_ok = FALSE; + m_ok = false; return; } m_internal->dev_id = open_struct.wDeviceID; @@ -150,7 +150,7 @@ bool wxCDAudioWin::Play(const wxCDtime& beg_time, const wxCDtime& end_time) MCI_PLAY_PARMS play_struct; if (!m_ok) - return FALSE; + return false; tmsf = MCI_MAKE_TMSF(beg_time.track, beg_time.min, beg_time.sec, 0); @@ -160,13 +160,13 @@ bool wxCDAudioWin::Play(const wxCDtime& beg_time, const wxCDtime& end_time) play_struct.dwTo = tmsf; mciSendCommand(m_internal->dev_id, MCI_PLAY, 0, (DWORD)&play_struct); - return TRUE; + return true; } bool wxCDAudioWin::Pause(void) { if (!m_ok) - return FALSE; + return false; return (mciSendCommand(m_internal->dev_id, MCI_PAUSE, 0, 0) == 0); } @@ -174,7 +174,7 @@ bool wxCDAudioWin::Pause(void) bool wxCDAudioWin::Resume(void) { if (!m_ok) - return FALSE; + return false; return (mciSendCommand(m_internal->dev_id, MCI_RESUME, 0, 0) == 0); } diff --git a/contrib/src/mmedia/g711.cpp b/contrib/src/mmedia/g711.cpp index 42c3abb639..60517b2eb0 100644 --- a/contrib/src/mmedia/g711.cpp +++ b/contrib/src/mmedia/g711.cpp @@ -31,65 +31,65 @@ * * u-law, A-law and linear PCM conversions. */ -#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ -#define QUANT_MASK (0xf) /* Quantization field mask. */ -#define NSEGS (8) /* Number of A-law segments. */ -#define SEG_SHIFT (4) /* Left shift for segment number. */ -#define SEG_MASK (0x70) /* Segment field mask. */ +#define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ +#define QUANT_MASK (0xf) /* Quantization field mask. */ +#define NSEGS (8) /* Number of A-law segments. */ +#define SEG_SHIFT (4) /* Left shift for segment number. */ +#define SEG_MASK (0x70) /* Segment field mask. */ static short seg_end[8] = {0xFF, 0x1FF, 0x3FF, 0x7FF, - 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF}; + 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF}; /* copy from CCITT G.711 specifications */ -unsigned char _u2a[128] = { /* u- to A-law conversions */ - 1, 1, 2, 2, 3, 3, 4, 4, - 5, 5, 6, 6, 7, 7, 8, 8, - 9, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, - 25, 27, 29, 31, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, - 46, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 81, 82, 83, 84, 85, 86, 87, 88, - 89, 90, 91, 92, 93, 94, 95, 96, - 97, 98, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 109, 110, 111, 112, - 113, 114, 115, 116, 117, 118, 119, 120, - 121, 122, 123, 124, 125, 126, 127, 128}; +unsigned char _u2a[128] = { /* u- to A-law conversions */ + 1, 1, 2, 2, 3, 3, 4, 4, + 5, 5, 6, 6, 7, 7, 8, 8, + 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, + 25, 27, 29, 31, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, + 46, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 61, 62, + 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, + 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, + 105, 106, 107, 108, 109, 110, 111, 112, + 113, 114, 115, 116, 117, 118, 119, 120, + 121, 122, 123, 124, 125, 126, 127, 128}; -unsigned char _a2u[128] = { /* A- to u-law conversions */ - 1, 3, 5, 7, 9, 11, 13, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 32, 33, 33, 34, 34, 35, 35, - 36, 37, 38, 39, 40, 41, 42, 43, - 44, 45, 46, 47, 48, 48, 49, 49, - 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64, 64, - 65, 66, 67, 68, 69, 70, 71, 72, - 73, 74, 75, 76, 77, 78, 79, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127}; +unsigned char _a2u[128] = { /* A- to u-law conversions */ + 1, 3, 5, 7, 9, 11, 13, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + 32, 32, 33, 33, 34, 34, 35, 35, + 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 48, 49, 49, + 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 64, + 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 79, + 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, + 104, 105, 106, 107, 108, 109, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 119, + 120, 121, 122, 123, 124, 125, 126, 127}; static int search( - int val, - short *table, - int size) + int val, + short *table, + int size) { - int i; + int i; - for (i = 0; i < size; i++) { - if (val <= *table++) - return (i); - } - return (size); + for (i = 0; i < size; i++) { + if (val <= *table++) + return (i); + } + return (size); } /* @@ -97,50 +97,50 @@ search( * * linear2alaw() accepts an 16-bit integer and encodes it as A-law data. * - * Linear Input Code Compressed Code - * ------------------------ --------------- - * 0000000wxyza 000wxyz - * 0000001wxyza 001wxyz - * 000001wxyzab 010wxyz - * 00001wxyzabc 011wxyz - * 0001wxyzabcd 100wxyz - * 001wxyzabcde 101wxyz - * 01wxyzabcdef 110wxyz - * 1wxyzabcdefg 111wxyz + * Linear Input Code Compressed Code + * ------------------------ --------------- + * 0000000wxyza 000wxyz + * 0000001wxyza 001wxyz + * 000001wxyzab 010wxyz + * 00001wxyzabc 011wxyz + * 0001wxyzabcd 100wxyz + * 001wxyzabcde 101wxyz + * 01wxyzabcdef 110wxyz + * 1wxyzabcdefg 111wxyz * * For further information see John C. Bellamy's Digital Telephony, 1982, * John Wiley & Sons, pps 98-111 and 472-476. */ unsigned char linear2alaw( - int pcm_val) /* 2's complement (16-bit range) */ + int pcm_val) /* 2's complement (16-bit range) */ { - int mask; - int seg; - unsigned char aval; + int mask; + int seg; + unsigned char aval; - if (pcm_val >= 0) { - mask = 0xD5; /* sign (7th) bit = 1 */ - } else { - mask = 0x55; /* sign bit = 0 */ - pcm_val = -pcm_val - 8; - } + if (pcm_val >= 0) { + mask = 0xD5; /* sign (7th) bit = 1 */ + } else { + mask = 0x55; /* sign bit = 0 */ + pcm_val = -pcm_val - 8; + } - /* Convert the scaled magnitude to segment number. */ - seg = search(pcm_val, seg_end, 8); + /* Convert the scaled magnitude to segment number. */ + seg = search(pcm_val, seg_end, 8); - /* Combine the sign, segment, and quantization bits. */ + /* Combine the sign, segment, and quantization bits. */ - if (seg >= 8) /* out of range, return maximum value. */ - return (0x7F ^ mask); - else { - aval = seg << SEG_SHIFT; - if (seg < 2) - aval |= (pcm_val >> 4) & QUANT_MASK; - else - aval |= (pcm_val >> (seg + 3)) & QUANT_MASK; - return (aval ^ mask); - } + if (seg >= 8) /* out of range, return maximum value. */ + return (0x7F ^ mask); + else { + aval = seg << SEG_SHIFT; + if (seg < 2) + aval |= (pcm_val >> 4) & QUANT_MASK; + else + aval |= (pcm_val >> (seg + 3)) & QUANT_MASK; + return (aval ^ mask); + } } /* @@ -149,30 +149,30 @@ linear2alaw( */ int alaw2linear( - unsigned char a_val) + unsigned char a_val) { - int t; - int seg; + int t; + int seg; - a_val ^= 0x55; + a_val ^= 0x55; - t = (a_val & QUANT_MASK) << 4; - seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT; - switch (seg) { - case 0: - t += 8; - break; - case 1: - t += 0x108; - break; - default: - t += 0x108; - t <<= seg - 1; - } - return ((a_val & SIGN_BIT) ? t : -t); + t = (a_val & QUANT_MASK) << 4; + seg = ((unsigned)a_val & SEG_MASK) >> SEG_SHIFT; + switch (seg) { + case 0: + t += 8; + break; + case 1: + t += 0x108; + break; + default: + t += 0x108; + t <<= seg - 1; + } + return ((a_val & SIGN_BIT) ? t : -t); } -#define BIAS (0x84) /* Bias for linear code. */ +#define BIAS (0x84) /* Bias for linear code. */ /* * linear2ulaw() - Convert a linear PCM value to u-law @@ -181,16 +181,16 @@ alaw2linear( * is biased by adding 33 which shifts the encoding range from (0 - 8158) to * (33 - 8191). The result can be seen in the following encoding table: * - * Biased Linear Input Code Compressed Code - * ------------------------ --------------- - * 00000001wxyza 000wxyz - * 0000001wxyzab 001wxyz - * 000001wxyzabc 010wxyz - * 00001wxyzabcd 011wxyz - * 0001wxyzabcde 100wxyz - * 001wxyzabcdef 101wxyz - * 01wxyzabcdefg 110wxyz - * 1wxyzabcdefgh 111wxyz + * Biased Linear Input Code Compressed Code + * ------------------------ --------------- + * 00000001wxyza 000wxyz + * 0000001wxyzab 001wxyz + * 000001wxyzabc 010wxyz + * 00001wxyzabcd 011wxyz + * 0001wxyzabcde 100wxyz + * 001wxyzabcdef 101wxyz + * 01wxyzabcdefg 110wxyz + * 1wxyzabcdefgh 111wxyz * * Each biased linear code has a leading 1 which identifies the segment * number. The value of the segment number is equal to 7 minus the number @@ -205,34 +205,34 @@ alaw2linear( */ unsigned char linear2ulaw( - int pcm_val) /* 2's complement (16-bit range) */ + int pcm_val) /* 2's complement (16-bit range) */ { - int mask; - int seg; - unsigned char uval; + int mask; + int seg; + unsigned char uval; - /* Get the sign and the magnitude of the value. */ - if (pcm_val < 0) { - pcm_val = BIAS - pcm_val; - mask = 0x7F; - } else { - pcm_val += BIAS; - mask = 0xFF; - } + /* Get the sign and the magnitude of the value. */ + if (pcm_val < 0) { + pcm_val = BIAS - pcm_val; + mask = 0x7F; + } else { + pcm_val += BIAS; + mask = 0xFF; + } - /* Convert the scaled magnitude to segment number. */ - seg = search(pcm_val, seg_end, 8); + /* Convert the scaled magnitude to segment number. */ + seg = search(pcm_val, seg_end, 8); - /* - * Combine the sign, segment, quantization bits; - * and complement the code word. - */ - if (seg >= 8) /* out of range, return maximum value. */ - return (0x7F ^ mask); - else { - uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF); - return (uval ^ mask); - } + /* + * Combine the sign, segment, quantization bits; + * and complement the code word. + */ + if (seg >= 8) /* out of range, return maximum value. */ + return (0x7F ^ mask); + else { + uval = (seg << 4) | ((pcm_val >> (seg + 3)) & 0xF); + return (uval ^ mask); + } } @@ -247,39 +247,39 @@ linear2ulaw( */ int ulaw2linear( - unsigned char u_val) + unsigned char u_val) { - int t; + int t; - /* Complement to obtain normal u-law value. */ - u_val = ~u_val; + /* Complement to obtain normal u-law value. */ + u_val = ~u_val; - /* - * Extract and bias the quantization bits. Then - * shift up by the segment number and subtract out the bias. - */ - t = ((u_val & QUANT_MASK) << 3) + BIAS; - t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT; + /* + * Extract and bias the quantization bits. Then + * shift up by the segment number and subtract out the bias. + */ + t = ((u_val & QUANT_MASK) << 3) + BIAS; + t <<= ((unsigned)u_val & SEG_MASK) >> SEG_SHIFT; - return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS)); + return ((u_val & SIGN_BIT) ? (BIAS - t) : (t - BIAS)); } /* A-law to u-law conversion */ unsigned char alaw2ulaw( - unsigned char aval) + unsigned char aval) { - aval &= 0xff; - return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) : - (0x7F ^ _a2u[aval ^ 0x55])); + aval &= 0xff; + return ((aval & 0x80) ? (0xFF ^ _a2u[aval ^ 0xD5]) : + (0x7F ^ _a2u[aval ^ 0x55])); } /* u-law to A-law conversion */ unsigned char ulaw2alaw( - unsigned char uval) + unsigned char uval) { - uval &= 0xff; - return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) : - (0x55 ^ (_u2a[0x7F ^ uval] - 1))); + uval &= 0xff; + return ((uval & 0x80) ? (0xD5 ^ (_u2a[0xFF ^ uval] - 1)) : + (0x55 ^ (_u2a[0x7F ^ uval] - 1))); } diff --git a/contrib/src/mmedia/g721.cpp b/contrib/src/mmedia/g721.cpp index bfc561a7a6..4068c5b85d 100644 --- a/contrib/src/mmedia/g721.cpp +++ b/contrib/src/mmedia/g721.cpp @@ -57,19 +57,19 @@ static short qtab_721[7] = {-124, 80, 178, 246, 300, 349, 400}; * Maps G.721 code word to reconstructed scale factor normalized log * magnitude values. */ -static short _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425, - 425, 373, 323, 273, 213, 135, 4, -2048}; +static short _dqlntab[16] = {-2048, 4, 135, 213, 273, 323, 373, 425, + 425, 373, 323, 273, 213, 135, 4, -2048}; /* Maps G.721 code word to log of scale factor multiplier. */ -static short _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122, - 1122, 355, 198, 112, 64, 41, 18, -12}; +static short _witab[16] = {-12, 18, 41, 64, 112, 198, 355, 1122, + 1122, 355, 198, 112, 64, 41, 18, -12}; /* * Maps G.721 code words to a set of values whose long and short * term averages are computed and then compared to give an indication * how stationary (steady state) the signal is. */ -static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00, - 0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0}; +static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00, + 0xE00, 0x600, 0x200, 0x200, 0x200, 0, 0, 0}; /* * g721_encoder() @@ -79,50 +79,50 @@ static short _fitab[16] = {0, 0, 0, 0x200, 0x200, 0x200, 0x600, 0xE00, */ int g721_encoder( - int sl, - int in_coding, - struct g72x_state *state_ptr) + int sl, + int in_coding, + struct g72x_state *state_ptr) { - short sezi, se, sez; /* ACCUM */ - short d; /* SUBTA */ - short sr; /* ADDB */ - short y; /* MIX */ - short dqsez; /* ADDC */ - short dq, i; - - switch (in_coding) { /* linearize input sample to 14-bit PCM */ - case AUDIO_ENCODING_ALAW: - sl = alaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_ULAW: - sl = ulaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_LINEAR: - sl = ((short)sl) >> 2; /* 14-bit dynamic range */ - break; - default: - return (-1); - } - - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */ - - d = sl - se; /* estimation difference */ - - /* quantize the prediction difference */ - y = step_size(state_ptr); /* quantizer step size */ - i = quantize(d, y, qtab_721, 7); /* i = ADPCM code */ - - dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */ - - sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */ - - dqsez = sr + sez - se; /* pole prediction diff. */ - - update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); - - return (i); + short sezi, se, sez; /* ACCUM */ + short d; /* SUBTA */ + short sr; /* ADDB */ + short y; /* MIX */ + short dqsez; /* ADDC */ + short dq, i; + + switch (in_coding) { /* linearize input sample to 14-bit PCM */ + case AUDIO_ENCODING_ALAW: + sl = alaw2linear(sl) >> 2; + break; + case AUDIO_ENCODING_ULAW: + sl = ulaw2linear(sl) >> 2; + break; + case AUDIO_ENCODING_LINEAR: + sl = ((short)sl) >> 2; /* 14-bit dynamic range */ + break; + default: + return (-1); + } + + sezi = predictor_zero(state_ptr); + sez = sezi >> 1; + se = (sezi + predictor_pole(state_ptr)) >> 1; /* estimated signal */ + + d = sl - se; /* estimation difference */ + + /* quantize the prediction difference */ + y = step_size(state_ptr); /* quantizer step size */ + i = quantize(d, y, qtab_721, 7); /* i = ADPCM code */ + + dq = reconstruct(i & 8, _dqlntab[i], y); /* quantized est diff */ + + sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconst. signal */ + + dqsez = sr + sez - se; /* pole prediction diff. */ + + update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); + + return (i); } /* @@ -136,40 +136,40 @@ g721_encoder( */ int g721_decoder( - int i, - int out_coding, - struct g72x_state *state_ptr) + int i, + int out_coding, + struct g72x_state *state_ptr) { - short sezi, sei, sez, se; /* ACCUM */ - short y; /* MIX */ - short sr; /* ADDB */ - short dq; - short dqsez; - - i &= 0x0f; /* mask to get proper bits */ - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - y = step_size(state_ptr); /* dynamic quantizer step size */ - - dq = reconstruct(i & 0x08, _dqlntab[i], y); /* quantized diff. */ - - sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq; /* reconst. signal */ - - dqsez = sr - se + sez; /* pole prediction diff. */ - - update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); - - switch (out_coding) { - case AUDIO_ENCODING_ALAW: - return (tandem_adjust_alaw(sr, se, y, i, 8, qtab_721)); - case AUDIO_ENCODING_ULAW: - return (tandem_adjust_ulaw(sr, se, y, i, 8, qtab_721)); - case AUDIO_ENCODING_LINEAR: - return (sr << 2); /* sr was 14-bit dynamic range */ - default: - return (-1); - } + short sezi, sei, sez, se; /* ACCUM */ + short y; /* MIX */ + short sr; /* ADDB */ + short dq; + short dqsez; + + i &= 0x0f; /* mask to get proper bits */ + sezi = predictor_zero(state_ptr); + sez = sezi >> 1; + sei = sezi + predictor_pole(state_ptr); + se = sei >> 1; /* se = estimated signal */ + + y = step_size(state_ptr); /* dynamic quantizer step size */ + + dq = reconstruct(i & 0x08, _dqlntab[i], y); /* quantized diff. */ + + sr = (dq < 0) ? (se - (dq & 0x3FFF)) : se + dq; /* reconst. signal */ + + dqsez = sr - se + sez; /* pole prediction diff. */ + + update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr); + + switch (out_coding) { + case AUDIO_ENCODING_ALAW: + return (tandem_adjust_alaw(sr, se, y, i, 8, qtab_721)); + case AUDIO_ENCODING_ULAW: + return (tandem_adjust_ulaw(sr, se, y, i, 8, qtab_721)); + case AUDIO_ENCODING_LINEAR: + return (sr << 2); /* sr was 14-bit dynamic range */ + default: + return (-1); + } } diff --git a/contrib/src/mmedia/g723_24.cpp b/contrib/src/mmedia/g723_24.cpp index f17b1d676a..6e31578df1 100644 --- a/contrib/src/mmedia/g723_24.cpp +++ b/contrib/src/mmedia/g723_24.cpp @@ -44,17 +44,17 @@ * Maps G.723_24 code word to reconstructed scale factor normalized log * magnitude values. */ -static short _dqlntab[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048}; +static short _dqlntab[8] = {-2048, 135, 273, 373, 373, 273, 135, -2048}; /* Maps G.723_24 code word to log of scale factor multiplier. */ -static short _witab[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128}; +static short _witab[8] = {-128, 960, 4384, 18624, 18624, 4384, 960, -128}; /* * Maps G.723_24 code words to a set of values whose long and short * term averages are computed and then compared to give an indication * how stationary (steady state) the signal is. */ -static short _fitab[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0}; +static short _fitab[8] = {0, 0x200, 0x400, 0xE00, 0xE00, 0x400, 0x200, 0}; static short qtab_723_24[3] = {8, 218, 331}; @@ -66,50 +66,50 @@ static short qtab_723_24[3] = {8, 218, 331}; */ int g723_24_encoder( - int sl, - int in_coding, - struct g72x_state *state_ptr) + int sl, + int in_coding, + struct g72x_state *state_ptr) { - short sei, sezi, se, sez; /* ACCUM */ - short d; /* SUBTA */ - short y; /* MIX */ - short sr; /* ADDB */ - short dqsez; /* ADDC */ - short dq, i; - - switch (in_coding) { /* linearize input sample to 14-bit PCM */ - case AUDIO_ENCODING_ALAW: - sl = alaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_ULAW: - sl = ulaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_LINEAR: - sl = ((short)sl) >> 2; /* sl of 14-bit dynamic range */ - break; - default: - return (-1); - } - - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - d = sl - se; /* d = estimation diff. */ - - /* quantize prediction difference d */ - y = step_size(state_ptr); /* quantizer step size */ - i = quantize(d, y, qtab_723_24, 3); /* i = ADPCM code */ - dq = reconstruct(i & 4, _dqlntab[i], y); /* quantized diff. */ - - sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconstructed signal */ - - dqsez = sr + sez - se; /* pole prediction diff. */ - - update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - return (i); + short sei, sezi, se, sez; /* ACCUM */ + short d; /* SUBTA */ + short y; /* MIX */ + short sr; /* ADDB */ + short dqsez; /* ADDC */ + short dq, i; + + switch (in_coding) { /* linearize input sample to 14-bit PCM */ + case AUDIO_ENCODING_ALAW: + sl = alaw2linear(sl) >> 2; + break; + case AUDIO_ENCODING_ULAW: + sl = ulaw2linear(sl) >> 2; + break; + case AUDIO_ENCODING_LINEAR: + sl = ((short)sl) >> 2; /* sl of 14-bit dynamic range */ + break; + default: + return (-1); + } + + sezi = predictor_zero(state_ptr); + sez = sezi >> 1; + sei = sezi + predictor_pole(state_ptr); + se = sei >> 1; /* se = estimated signal */ + + d = sl - se; /* d = estimation diff. */ + + /* quantize prediction difference d */ + y = step_size(state_ptr); /* quantizer step size */ + i = quantize(d, y, qtab_723_24, 3); /* i = ADPCM code */ + dq = reconstruct(i & 4, _dqlntab[i], y); /* quantized diff. */ + + sr = (dq < 0) ? se - (dq & 0x3FFF) : se + dq; /* reconstructed signal */ + + dqsez = sr + sez - se; /* pole prediction diff. */ + + update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); + + return (i); } /* @@ -121,39 +121,39 @@ g723_24_encoder( */ int g723_24_decoder( - int i, - int out_coding, - struct g72x_state *state_ptr) + int i, + int out_coding, + struct g72x_state *state_ptr) { - short sezi, sei, sez, se; /* ACCUM */ - short y; /* MIX */ - short sr; /* ADDB */ - short dq; - short dqsez; - - i &= 0x07; /* mask to get proper bits */ - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - y = step_size(state_ptr); /* adaptive quantizer step size */ - dq = reconstruct(i & 0x04, _dqlntab[i], y); /* unquantize pred diff */ - - sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq); /* reconst. signal */ - - dqsez = sr - se + sez; /* pole prediction diff. */ - - update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - switch (out_coding) { - case AUDIO_ENCODING_ALAW: - return (tandem_adjust_alaw(sr, se, y, i, 4, qtab_723_24)); - case AUDIO_ENCODING_ULAW: - return (tandem_adjust_ulaw(sr, se, y, i, 4, qtab_723_24)); - case AUDIO_ENCODING_LINEAR: - return (sr << 2); /* sr was of 14-bit dynamic range */ - default: - return (-1); - } + short sezi, sei, sez, se; /* ACCUM */ + short y; /* MIX */ + short sr; /* ADDB */ + short dq; + short dqsez; + + i &= 0x07; /* mask to get proper bits */ + sezi = predictor_zero(state_ptr); + sez = sezi >> 1; + sei = sezi + predictor_pole(state_ptr); + se = sei >> 1; /* se = estimated signal */ + + y = step_size(state_ptr); /* adaptive quantizer step size */ + dq = reconstruct(i & 0x04, _dqlntab[i], y); /* unquantize pred diff */ + + sr = (dq < 0) ? (se - (dq & 0x3FFF)) : (se + dq); /* reconst. signal */ + + dqsez = sr - se + sez; /* pole prediction diff. */ + + update(3, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); + + switch (out_coding) { + case AUDIO_ENCODING_ALAW: + return (tandem_adjust_alaw(sr, se, y, i, 4, qtab_723_24)); + case AUDIO_ENCODING_ULAW: + return (tandem_adjust_ulaw(sr, se, y, i, 4, qtab_723_24)); + case AUDIO_ENCODING_LINEAR: + return (sr << 2); /* sr was of 14-bit dynamic range */ + default: + return (-1); + } } diff --git a/contrib/src/mmedia/g723_40.cpp b/contrib/src/mmedia/g723_40.cpp index 9a71969c63..30c5b431d6 100644 --- a/contrib/src/mmedia/g723_40.cpp +++ b/contrib/src/mmedia/g723_40.cpp @@ -52,29 +52,29 @@ * Maps G.723_40 code word to ructeconstructed scale factor normalized log * magnitude values. */ -static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318, - 358, 395, 429, 459, 488, 514, 539, 566, - 566, 539, 514, 488, 459, 429, 395, 358, - 318, 274, 224, 169, 104, 28, -66, -2048}; +static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318, + 358, 395, 429, 459, 488, 514, 539, 566, + 566, 539, 514, 488, 459, 429, 395, 358, + 318, 274, 224, 169, 104, 28, -66, -2048}; /* Maps G.723_40 code word to log of scale factor multiplier. */ -static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200, - 4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272, - 22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512, - 3200, 1856, 1312, 1280, 1248, 768, 448, 448}; +static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200, + 4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272, + 22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512, + 3200, 1856, 1312, 1280, 1248, 768, 448, 448}; /* * Maps G.723_40 code words to a set of values whose long and short * term averages are computed and then compared to give an indication * how stationary (steady state) the signal is. */ -static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200, - 0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00, - 0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200, - 0x200, 0x200, 0x200, 0, 0, 0, 0, 0}; +static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200, + 0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00, + 0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200, + 0x200, 0x200, 0x200, 0, 0, 0, 0, 0}; static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339, - 378, 413, 445, 475, 502, 528, 553}; + 378, 413, 445, 475, 502, 528, 553}; /* * g723_40_encoder() @@ -85,51 +85,51 @@ static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339, */ int g723_40_encoder( - int sl, - int in_coding, - struct g72x_state *state_ptr) + int sl, + int in_coding, + struct g72x_state *state_ptr) { - short sei, sezi, se, sez; /* ACCUM */ - short d; /* SUBTA */ - short y; /* MIX */ - short sr; /* ADDB */ - short dqsez; /* ADDC */ - short dq, i; - - switch (in_coding) { /* linearize input sample to 14-bit PCM */ - case AUDIO_ENCODING_ALAW: - sl = alaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_ULAW: - sl = ulaw2linear(sl) >> 2; - break; - case AUDIO_ENCODING_LINEAR: - sl = ((short) sl) >> 2; /* sl of 14-bit dynamic range */ - break; - default: - return (-1); - } - - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - d = sl - se; /* d = estimation difference */ - - /* quantize prediction difference */ - y = step_size(state_ptr); /* adaptive quantizer step size */ - i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */ - - dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */ - - sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */ - - dqsez = sr + sez - se; /* dqsez = pole prediction diff. */ - - update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - return (i); + short sei, sezi, se, sez; /* ACCUM */ + short d; /* SUBTA */ + short y; /* MIX */ + short sr; /* ADDB */ + short dqsez; /* ADDC */ + short dq, i; + + switch (in_coding) { /* linearize input sample to 14-bit PCM */ + case AUDIO_ENCODING_ALAW: + sl = alaw2linear(sl) >> 2; + break; + case AUDIO_ENCODING_ULAW: + sl = ulaw2linear(sl) >> 2; + break; + case AUDIO_ENCODING_LINEAR: + sl = ((short) sl) >> 2; /* sl of 14-bit dynamic range */ + break; + default: + return (-1); + } + + sezi = predictor_zero(state_ptr); + sez = sezi >> 1; + sei = sezi + predictor_pole(state_ptr); + se = sei >> 1; /* se = estimated signal */ + + d = sl - se; /* d = estimation difference */ + + /* quantize prediction difference */ + y = step_size(state_ptr); /* adaptive quantizer step size */ + i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */ + + dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */ + + sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */ + + dqsez = sr + sez - se; /* dqsez = pole prediction diff. */ + + update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); + + return (i); } /* @@ -141,39 +141,39 @@ g723_40_encoder( */ int g723_40_decoder( - int i, - int out_coding, - struct g72x_state *state_ptr) + int i, + int out_coding, + struct g72x_state *state_ptr) { - short sezi, sei, sez, se; /* ACCUM */ - short y; /* MIX */ - short sr; /* ADDB */ - short dq; - short dqsez; - - i &= 0x1f; /* mask to get proper bits */ - sezi = predictor_zero(state_ptr); - sez = sezi >> 1; - sei = sezi + predictor_pole(state_ptr); - se = sei >> 1; /* se = estimated signal */ - - y = step_size(state_ptr); /* adaptive quantizer step size */ - dq = reconstruct(i & 0x10, _dqlntab[i], y); /* estimation diff. */ - - sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */ - - dqsez = sr - se + sez; /* pole prediction diff. */ - - update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); - - switch (out_coding) { - case AUDIO_ENCODING_ALAW: - return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40)); - case AUDIO_ENCODING_ULAW: - return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40)); - case AUDIO_ENCODING_LINEAR: - return (sr << 2); /* sr was of 14-bit dynamic range */ - default: - return (-1); - } + short sezi, sei, sez, se; /* ACCUM */ + short y; /* MIX */ + short sr; /* ADDB */ + short dq; + short dqsez; + + i &= 0x1f; /* mask to get proper bits */ + sezi = predictor_zero(state_ptr); + sez = sezi >> 1; + sei = sezi + predictor_pole(state_ptr); + se = sei >> 1; /* se = estimated signal */ + + y = step_size(state_ptr); /* adaptive quantizer step size */ + dq = reconstruct(i & 0x10, _dqlntab[i], y); /* estimation diff. */ + + sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */ + + dqsez = sr - se + sez; /* pole prediction diff. */ + + update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr); + + switch (out_coding) { + case AUDIO_ENCODING_ALAW: + return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40)); + case AUDIO_ENCODING_ULAW: + return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40)); + case AUDIO_ENCODING_LINEAR: + return (sr << 2); /* sr was of 14-bit dynamic range */ + default: + return (-1); + } } diff --git a/contrib/src/mmedia/g72x.cpp b/contrib/src/mmedia/g72x.cpp index c6f2a016c2..2202cf8235 100644 --- a/contrib/src/mmedia/g72x.cpp +++ b/contrib/src/mmedia/g72x.cpp @@ -35,7 +35,7 @@ #include "wx/mmedia/internal/g72x.h" static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, - 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000}; + 0x100, 0x200, 0x400, 0x800, 0x1000, 0x2000, 0x4000}; /* * quan() @@ -47,16 +47,16 @@ static short power2[15] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, */ static int quan( - int val, - short *table, - int size) + int val, + short *table, + int size) { - int i; + int i; - for (i = 0; i < size; i++) - if (val < *table++) - break; - return (i); + for (i = 0; i < size; i++) + if (val < *table++) + break; + return (i); } static char quan2_tab[65536]; @@ -65,42 +65,42 @@ static int init_tabs_done = 0; inline char quan2 (unsigned short val) { - return quan2_tab[val]; + return quan2_tab[val]; } inline short base2 (unsigned short val) { - return base2_tab[val]; + return base2_tab[val]; } static void init_quan2_tab (void) { - long i; + long i; - for (i = 0; i < 65536; i++) { - quan2_tab[i] = quan (i, power2, 15); - }; + for (i = 0; i < 65536; i++) { + quan2_tab[i] = quan (i, power2, 15); + }; } static void init_base2_tab (void) { - long i; - short exp; + long i; + short exp; - for (i = 0; i < 65536; i++) { - exp = quan2 (short (i)); - base2_tab[i] = short ((exp << 6) + ((i << 6) >> exp)); - }; + for (i = 0; i < 65536; i++) { + exp = quan2 (short (i)); + base2_tab[i] = short ((exp << 6) + ((i << 6) >> exp)); + }; } static void init_tabs (void) { - if (init_tabs_done) return; + if (init_tabs_done) return; - init_quan2_tab(); - init_base2_tab(); + init_quan2_tab(); + init_base2_tab(); - init_tabs_done = 1; + init_tabs_done = 1; } /* @@ -111,24 +111,24 @@ static void init_tabs (void) */ static int fmult( - int an, - int srn) + int an, + int srn) { - short anmag, anexp, anmant; - short wanexp, wanmant; - short retval; + short anmag, anexp, anmant; + short wanexp, wanmant; + short retval; - anmag = (an > 0) ? an : ((-an) & 0x1FFF); - anexp = quan2(anmag) - 6; - anmant = (anmag == 0) ? 32 : - (anexp >= 0) ? anmag >> anexp : anmag << -anexp; - wanexp = anexp + ((srn >> 6) & 0xF) - 13; + anmag = (an > 0) ? an : ((-an) & 0x1FFF); + anexp = quan2(anmag) - 6; + anmant = (anmag == 0) ? 32 : + (anexp >= 0) ? anmag >> anexp : anmag << -anexp; + wanexp = anexp + ((srn >> 6) & 0xF) - 13; - wanmant = (anmant * (srn & 077) + 0x30) >> 4; - retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) : - (wanmant >> -wanexp); + wanmant = (anmant * (srn & 077) + 0x30) >> 4; + retval = (wanexp >= 0) ? ((wanmant << wanexp) & 0x7FFF) : + (wanmant >> -wanexp); - return (((an ^ srn) < 0) ? -retval : retval); + return (((an ^ srn) < 0) ? -retval : retval); } /* @@ -140,27 +140,27 @@ fmult( */ void g72x_init_state( - struct g72x_state *state_ptr) + struct g72x_state *state_ptr) { - int cnta; - - init_tabs (); - - state_ptr->yl = 34816; - state_ptr->yu = 544; - state_ptr->dms = 0; - state_ptr->dml = 0; - state_ptr->ap = 0; - for (cnta = 0; cnta < 2; cnta++) { - state_ptr->a[cnta] = 0; - state_ptr->pk[cnta] = 0; - state_ptr->sr[cnta] = 32; - } - for (cnta = 0; cnta < 6; cnta++) { - state_ptr->b[cnta] = 0; - state_ptr->dq[cnta] = 32; - } - state_ptr->td = 0; + int cnta; + + init_tabs (); + + state_ptr->yl = 34816; + state_ptr->yu = 544; + state_ptr->dms = 0; + state_ptr->dml = 0; + state_ptr->ap = 0; + for (cnta = 0; cnta < 2; cnta++) { + state_ptr->a[cnta] = 0; + state_ptr->pk[cnta] = 0; + state_ptr->sr[cnta] = 32; + } + for (cnta = 0; cnta < 6; cnta++) { + state_ptr->b[cnta] = 0; + state_ptr->dq[cnta] = 32; + } + state_ptr->td = 0; } /* @@ -171,15 +171,15 @@ g72x_init_state( */ int predictor_zero( - struct g72x_state *state_ptr) + struct g72x_state *state_ptr) { - int i; - int sezi; + int i; + int sezi; - sezi = fmult(state_ptr->b[0] >> 2, state_ptr->dq[0]); - for (i = 1; i < 6; i++) /* ACCUM */ - sezi += fmult(state_ptr->b[i] >> 2, state_ptr->dq[i]); - return (sezi); + sezi = fmult(state_ptr->b[0] >> 2, state_ptr->dq[0]); + for (i = 1; i < 6; i++) /* ACCUM */ + sezi += fmult(state_ptr->b[i] >> 2, state_ptr->dq[i]); + return (sezi); } /* * predictor_pole() @@ -189,10 +189,10 @@ predictor_zero( */ int predictor_pole( - struct g72x_state *state_ptr) + struct g72x_state *state_ptr) { - return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) + - fmult(state_ptr->a[0] >> 2, state_ptr->sr[0])); + return (fmult(state_ptr->a[1] >> 2, state_ptr->sr[1]) + + fmult(state_ptr->a[0] >> 2, state_ptr->sr[0])); } /* * step_size() @@ -202,24 +202,24 @@ predictor_pole( */ int step_size( - struct g72x_state *state_ptr) + struct g72x_state *state_ptr) { - int y; - int dif; - int al; - - if (state_ptr->ap >= 256) - return (state_ptr->yu); - else { - y = state_ptr->yl >> 6; - dif = state_ptr->yu - y; - al = state_ptr->ap >> 2; - if (dif > 0) - y += (dif * al) >> 6; - else if (dif < 0) - y += (dif * al + 0x3F) >> 6; - return (y); - } + int y; + int dif; + int al; + + if (state_ptr->ap >= 256) + return (state_ptr->yu); + else { + y = state_ptr->yl >> 6; + dif = state_ptr->yu - y; + al = state_ptr->ap >> 2; + if (dif > 0) + y += (dif * al) >> 6; + else if (dif < 0) + y += (dif * al + 0x3F) >> 6; + return (y); + } } /* @@ -233,47 +233,47 @@ step_size( */ int quantize( - int d, /* Raw difference signal sample */ - int y, /* Step size multiplier */ - short *table, /* quantization table */ - int size) /* table size of short integers */ + int d, /* Raw difference signal sample */ + int y, /* Step size multiplier */ + short *table, /* quantization table */ + int size) /* table size of short integers */ { - short dqm; /* Magnitude of 'd' */ - short exp; /* Integer part of base 2 log of 'd' */ - short mant; /* Fractional part of base 2 log */ - short dl; /* Log of magnitude of 'd' */ - short dln; /* Step size scale factor normalized log */ - int i; - - /* - * LOG - * - * Compute base 2 log of 'd', and store in 'dl'. - */ - dqm = abs(d); - exp = quan2(dqm >> 1); - mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */ - dl = (exp << 7) + mant; - - /* - * SUBTB - * - * "Divide" by step size multiplier. - */ - dln = dl - (y >> 2); - - /* - * QUAN - * - * Obtain codword i for 'd'. - */ - i = quan(dln, table, size); - if (d < 0) /* take 1's complement of i */ - return ((size << 1) + 1 - i); - else if (i == 0) /* take 1's complement of 0 */ - return ((size << 1) + 1); /* new in 1988 */ - else - return (i); + short dqm; /* Magnitude of 'd' */ + short exp; /* Integer part of base 2 log of 'd' */ + short mant; /* Fractional part of base 2 log */ + short dl; /* Log of magnitude of 'd' */ + short dln; /* Step size scale factor normalized log */ + int i; + + /* + * LOG + * + * Compute base 2 log of 'd', and store in 'dl'. + */ + dqm = abs(d); + exp = quan2(dqm >> 1); + mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */ + dl = (exp << 7) + mant; + + /* + * SUBTB + * + * "Divide" by step size multiplier. + */ + dln = dl - (y >> 2); + + /* + * QUAN + * + * Obtain codword i for 'd'. + */ + i = quan(dln, table, size); + if (d < 0) /* take 1's complement of i */ + return ((size << 1) + 1 - i); + else if (i == 0) /* take 1's complement of 0 */ + return ((size << 1) + 1); /* new in 1988 */ + else + return (i); } /* * reconstruct() @@ -284,25 +284,25 @@ quantize( */ int reconstruct( - int sign, /* 0 for non-negative value */ - int dqln, /* G.72x codeword */ - int y) /* Step size multiplier */ + int sign, /* 0 for non-negative value */ + int dqln, /* G.72x codeword */ + int y) /* Step size multiplier */ { - short dql; /* Log of 'dq' magnitude */ - short dex; /* Integer part of log */ - short dqt; - short dq; /* Reconstructed difference signal sample */ - - dql = dqln + (y >> 2); /* ADDA */ - - if (dql < 0) { - return ((sign) ? -0x8000 : 0); - } else { /* ANTILOG */ - dex = (dql >> 7) & 15; - dqt = 128 + (dql & 127); - dq = (dqt << 7) >> (14 - dex); - return ((sign) ? (dq - 0x8000) : dq); - } + short dql; /* Log of 'dq' magnitude */ + short dex; /* Integer part of log */ + short dqt; + short dq; /* Reconstructed difference signal sample */ + + dql = dqln + (y >> 2); /* ADDA */ + + if (dql < 0) { + return ((sign) ? -0x8000 : 0); + } else { /* ANTILOG */ + dex = (dql >> 7) & 15; + dqt = 128 + (dql & 127); + dq = (dqt << 7) >> (14 - dex); + return ((sign) ? (dq - 0x8000) : dq); + } } @@ -313,189 +313,189 @@ reconstruct( */ void update( - int code_size, /* distinguish 723_40 with others */ - int y, /* quantizer step size */ - int wi, /* scale factor multiplier */ - int fi, /* for long/short term energies */ - int dq, /* quantized prediction difference */ - int sr, /* reconstructed signal */ - int dqsez, /* difference from 2-pole predictor */ - struct g72x_state *state_ptr) /* coder state pointer */ + int code_size, /* distinguish 723_40 with others */ + int y, /* quantizer step size */ + int wi, /* scale factor multiplier */ + int fi, /* for long/short term energies */ + int dq, /* quantized prediction difference */ + int sr, /* reconstructed signal */ + int dqsez, /* difference from 2-pole predictor */ + struct g72x_state *state_ptr) /* coder state pointer */ { - int cnt; - short mag; /* Adaptive predictor, FLOAT A */ - short a2p; /* LIMC */ - short a1ul; /* UPA1 */ - short pks1; /* UPA2 */ - short fa1; - char tr; /* tone/transition detector */ - short ylint, thr2, dqthr; - short ylfrac, thr1; - short pk0; - - pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */ - - mag = dq & 0x7FFF; /* prediction difference magnitude */ - /* TRANS */ - ylint = short (state_ptr->yl >> 15); /* exponent part of yl */ - ylfrac = (state_ptr->yl >> 10) & 0x1F; /* fractional part of yl */ - thr1 = (32 + ylfrac) << ylint; /* threshold */ - thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */ - dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */ - if (state_ptr->td == 0) /* signal supposed voice */ - tr = 0; - else if (mag <= dqthr) /* supposed data, but small mag */ - tr = 0; /* treated as voice */ - else /* signal is data (modem) */ - tr = 1; - - /* - * Quantizer scale factor adaptation. - */ - - /* FUNCTW & FILTD & DELAY */ - /* update non-steady state step size multiplier */ - state_ptr->yu = y + ((wi - y) >> 5); - - /* LIMB */ - if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */ - state_ptr->yu = 544; - else if (state_ptr->yu > 5120) - state_ptr->yu = 5120; - - /* FILTE & DELAY */ - /* update steady state step size multiplier */ - state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6); - - /* - * Adaptive predictor coefficients. - */ - if (tr == 1) { /* reset a's and b's for modem signal */ - state_ptr->a[0] = 0; - state_ptr->a[1] = 0; - state_ptr->b[0] = 0; - state_ptr->b[1] = 0; - state_ptr->b[2] = 0; - state_ptr->b[3] = 0; - state_ptr->b[4] = 0; - state_ptr->b[5] = 0; - - a2p = 0; /* eliminate Compiler Warnings */ - } else { /* update a's and b's */ - pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */ - - /* update predictor pole a[1] */ - a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7); - if (dqsez != 0) { - fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0]; - if (fa1 < -8191) /* a2p = function of fa1 */ - a2p -= 0x100; - else if (fa1 > 8191) - a2p += 0xFF; - else - a2p += fa1 >> 5; - - if (pk0 ^ state_ptr->pk[1]) - /* LIMC */ - if (a2p <= -12160) - a2p = -12288; - else if (a2p >= 12416) - a2p = 12288; - else - a2p -= 0x80; - else if (a2p <= -12416) - a2p = -12288; - else if (a2p >= 12160) - a2p = 12288; - else - a2p += 0x80; - } - - /* TRIGB & DELAY */ - state_ptr->a[1] = a2p; - - /* UPA1 */ - /* update predictor pole a[0] */ - state_ptr->a[0] -= state_ptr->a[0] >> 8; - if (dqsez != 0) - if (pks1 == 0) - state_ptr->a[0] += 192; - else - state_ptr->a[0] -= 192; - - /* LIMD */ - a1ul = 15360 - a2p; - if (state_ptr->a[0] < -a1ul) - state_ptr->a[0] = -a1ul; - else if (state_ptr->a[0] > a1ul) - state_ptr->a[0] = a1ul; - - /* UPB : update predictor zeros b[6] */ - for (cnt = 0; cnt < 6; cnt++) { - if (code_size == 5) /* for 40Kbps G.723 */ - state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9; - else /* for G.721 and 24Kbps G.723 */ - state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8; - if (dq & 0x7FFF) { /* XOR */ - if ((dq ^ state_ptr->dq[cnt]) >= 0) - state_ptr->b[cnt] += 128; - else - state_ptr->b[cnt] -= 128; - } - } - } - - for (cnt = 5; cnt > 0; cnt--) - state_ptr->dq[cnt] = state_ptr->dq[cnt-1]; - /* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */ - if (mag == 0) { - state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20; - } else { - state_ptr->dq[0] = (dq >= 0) ? - base2 (mag) : base2 (mag) - 0x400; - } - - state_ptr->sr[1] = state_ptr->sr[0]; - /* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */ - if (sr == 0) { - state_ptr->sr[0] = 0x20; - } else if (sr > 0) { - state_ptr->sr[0] = base2(sr); - } else if (sr > -32768) { - mag = -sr; - state_ptr->sr[0] = base2(mag) - 0x400; - } else - state_ptr->sr[0] = short (0xFC20); - - /* DELAY A */ - state_ptr->pk[1] = state_ptr->pk[0]; - state_ptr->pk[0] = pk0; - - /* TONE */ - if (tr == 1) /* this sample has been treated as data */ - state_ptr->td = 0; /* next one will be treated as voice */ - else if (a2p < -11776) /* small sample-to-sample correlation */ - state_ptr->td = 1; /* signal may be data */ - else /* signal is voice */ - state_ptr->td = 0; - - /* - * Adaptation speed control. - */ - state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */ - state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */ - - if (tr == 1) - state_ptr->ap = 256; - else if (y < 1536) /* SUBTC */ - state_ptr->ap += (0x200 - state_ptr->ap) >> 4; - else if (state_ptr->td == 1) - state_ptr->ap += (0x200 - state_ptr->ap) >> 4; - else if (abs((state_ptr->dms << 2) - state_ptr->dml) >= - (state_ptr->dml >> 3)) - state_ptr->ap += (0x200 - state_ptr->ap) >> 4; - else - state_ptr->ap += (-state_ptr->ap) >> 4; + int cnt; + short mag; /* Adaptive predictor, FLOAT A */ + short a2p; /* LIMC */ + short a1ul; /* UPA1 */ + short pks1; /* UPA2 */ + short fa1; + char tr; /* tone/transition detector */ + short ylint, thr2, dqthr; + short ylfrac, thr1; + short pk0; + + pk0 = (dqsez < 0) ? 1 : 0; /* needed in updating predictor poles */ + + mag = dq & 0x7FFF; /* prediction difference magnitude */ + /* TRANS */ + ylint = short (state_ptr->yl >> 15); /* exponent part of yl */ + ylfrac = (state_ptr->yl >> 10) & 0x1F; /* fractional part of yl */ + thr1 = (32 + ylfrac) << ylint; /* threshold */ + thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */ + dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */ + if (state_ptr->td == 0) /* signal supposed voice */ + tr = 0; + else if (mag <= dqthr) /* supposed data, but small mag */ + tr = 0; /* treated as voice */ + else /* signal is data (modem) */ + tr = 1; + + /* + * Quantizer scale factor adaptation. + */ + + /* FUNCTW & FILTD & DELAY */ + /* update non-steady state step size multiplier */ + state_ptr->yu = y + ((wi - y) >> 5); + + /* LIMB */ + if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */ + state_ptr->yu = 544; + else if (state_ptr->yu > 5120) + state_ptr->yu = 5120; + + /* FILTE & DELAY */ + /* update steady state step size multiplier */ + state_ptr->yl += state_ptr->yu + ((-state_ptr->yl) >> 6); + + /* + * Adaptive predictor coefficients. + */ + if (tr == 1) { /* reset a's and b's for modem signal */ + state_ptr->a[0] = 0; + state_ptr->a[1] = 0; + state_ptr->b[0] = 0; + state_ptr->b[1] = 0; + state_ptr->b[2] = 0; + state_ptr->b[3] = 0; + state_ptr->b[4] = 0; + state_ptr->b[5] = 0; + + a2p = 0; /* eliminate Compiler Warnings */ + } else { /* update a's and b's */ + pks1 = pk0 ^ state_ptr->pk[0]; /* UPA2 */ + + /* update predictor pole a[1] */ + a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7); + if (dqsez != 0) { + fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0]; + if (fa1 < -8191) /* a2p = function of fa1 */ + a2p -= 0x100; + else if (fa1 > 8191) + a2p += 0xFF; + else + a2p += fa1 >> 5; + + if (pk0 ^ state_ptr->pk[1]) + /* LIMC */ + if (a2p <= -12160) + a2p = -12288; + else if (a2p >= 12416) + a2p = 12288; + else + a2p -= 0x80; + else if (a2p <= -12416) + a2p = -12288; + else if (a2p >= 12160) + a2p = 12288; + else + a2p += 0x80; + } + + /* TRIGB & DELAY */ + state_ptr->a[1] = a2p; + + /* UPA1 */ + /* update predictor pole a[0] */ + state_ptr->a[0] -= state_ptr->a[0] >> 8; + if (dqsez != 0) + if (pks1 == 0) + state_ptr->a[0] += 192; + else + state_ptr->a[0] -= 192; + + /* LIMD */ + a1ul = 15360 - a2p; + if (state_ptr->a[0] < -a1ul) + state_ptr->a[0] = -a1ul; + else if (state_ptr->a[0] > a1ul) + state_ptr->a[0] = a1ul; + + /* UPB : update predictor zeros b[6] */ + for (cnt = 0; cnt < 6; cnt++) { + if (code_size == 5) /* for 40Kbps G.723 */ + state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9; + else /* for G.721 and 24Kbps G.723 */ + state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8; + if (dq & 0x7FFF) { /* XOR */ + if ((dq ^ state_ptr->dq[cnt]) >= 0) + state_ptr->b[cnt] += 128; + else + state_ptr->b[cnt] -= 128; + } + } + } + + for (cnt = 5; cnt > 0; cnt--) + state_ptr->dq[cnt] = state_ptr->dq[cnt-1]; + /* FLOAT A : convert dq[0] to 4-bit exp, 6-bit mantissa f.p. */ + if (mag == 0) { + state_ptr->dq[0] = (dq >= 0) ? 0x20 : 0xFC20; + } else { + state_ptr->dq[0] = (dq >= 0) ? + base2 (mag) : base2 (mag) - 0x400; + } + + state_ptr->sr[1] = state_ptr->sr[0]; + /* FLOAT B : convert sr to 4-bit exp., 6-bit mantissa f.p. */ + if (sr == 0) { + state_ptr->sr[0] = 0x20; + } else if (sr > 0) { + state_ptr->sr[0] = base2(sr); + } else if (sr > -32768) { + mag = -sr; + state_ptr->sr[0] = base2(mag) - 0x400; + } else + state_ptr->sr[0] = short (0xFC20); + + /* DELAY A */ + state_ptr->pk[1] = state_ptr->pk[0]; + state_ptr->pk[0] = pk0; + + /* TONE */ + if (tr == 1) /* this sample has been treated as data */ + state_ptr->td = 0; /* next one will be treated as voice */ + else if (a2p < -11776) /* small sample-to-sample correlation */ + state_ptr->td = 1; /* signal may be data */ + else /* signal is voice */ + state_ptr->td = 0; + + /* + * Adaptation speed control. + */ + state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */ + state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */ + + if (tr == 1) + state_ptr->ap = 256; + else if (y < 1536) /* SUBTC */ + state_ptr->ap += (0x200 - state_ptr->ap) >> 4; + else if (state_ptr->td == 1) + state_ptr->ap += (0x200 - state_ptr->ap) >> 4; + else if (abs((state_ptr->dms << 2) - state_ptr->dml) >= + (state_ptr->dml >> 3)) + state_ptr->ap += (0x200 - state_ptr->ap) >> 4; + else + state_ptr->ap += (-state_ptr->ap) >> 4; } /* @@ -507,103 +507,103 @@ update( * is adjusted by one level of A-law or u-law codes. * * Input: - * sr decoder output linear PCM sample, - * se predictor estimate sample, - * y quantizer step size, - * i decoder input code, - * sign sign bit of code i + * sr decoder output linear PCM sample, + * se predictor estimate sample, + * y quantizer step size, + * i decoder input code, + * sign sign bit of code i * * Return: - * adjusted A-law or u-law compressed sample. + * adjusted A-law or u-law compressed sample. */ int tandem_adjust_alaw( - int sr, /* decoder output linear PCM sample */ - int se, /* predictor estimate sample */ - int y, /* quantizer step size */ - int i, /* decoder input code */ - int sign, - short *qtab) + int sr, /* decoder output linear PCM sample */ + int se, /* predictor estimate sample */ + int y, /* quantizer step size */ + int i, /* decoder input code */ + int sign, + short *qtab) { - unsigned char sp; /* A-law compressed 8-bit code */ - short dx; /* prediction error */ - char id; /* quantized prediction error */ - int sd; /* adjusted A-law decoded sample value */ - int im; /* biased magnitude of i */ - int imx; /* biased magnitude of id */ - - if (sr <= -32768) - sr = -1; - sp = linear2alaw((sr >> 1) << 3); /* short to A-law compression */ - dx = (alaw2linear(sp) >> 2) - se; /* 16-bit prediction error */ - id = quantize(dx, y, qtab, sign - 1); - - if (id == i) { /* no adjustment on sp */ - return (sp); - } else { /* sp adjustment needed */ - /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */ - im = i ^ sign; /* 2's complement to biased unsigned */ - imx = id ^ sign; - - if (imx > im) { /* sp adjusted to next lower value */ - if (sp & 0x80) { - sd = (sp == 0xD5) ? 0x55 : - ((sp ^ 0x55) - 1) ^ 0x55; - } else { - sd = (sp == 0x2A) ? 0x2A : - ((sp ^ 0x55) + 1) ^ 0x55; - } - } else { /* sp adjusted to next higher value */ - if (sp & 0x80) - sd = (sp == 0xAA) ? 0xAA : - ((sp ^ 0x55) + 1) ^ 0x55; - else - sd = (sp == 0x55) ? 0xD5 : - ((sp ^ 0x55) - 1) ^ 0x55; - } - return (sd); - } + unsigned char sp; /* A-law compressed 8-bit code */ + short dx; /* prediction error */ + char id; /* quantized prediction error */ + int sd; /* adjusted A-law decoded sample value */ + int im; /* biased magnitude of i */ + int imx; /* biased magnitude of id */ + + if (sr <= -32768) + sr = -1; + sp = linear2alaw((sr >> 1) << 3); /* short to A-law compression */ + dx = (alaw2linear(sp) >> 2) - se; /* 16-bit prediction error */ + id = quantize(dx, y, qtab, sign - 1); + + if (id == i) { /* no adjustment on sp */ + return (sp); + } else { /* sp adjustment needed */ + /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */ + im = i ^ sign; /* 2's complement to biased unsigned */ + imx = id ^ sign; + + if (imx > im) { /* sp adjusted to next lower value */ + if (sp & 0x80) { + sd = (sp == 0xD5) ? 0x55 : + ((sp ^ 0x55) - 1) ^ 0x55; + } else { + sd = (sp == 0x2A) ? 0x2A : + ((sp ^ 0x55) + 1) ^ 0x55; + } + } else { /* sp adjusted to next higher value */ + if (sp & 0x80) + sd = (sp == 0xAA) ? 0xAA : + ((sp ^ 0x55) + 1) ^ 0x55; + else + sd = (sp == 0x55) ? 0xD5 : + ((sp ^ 0x55) - 1) ^ 0x55; + } + return (sd); + } } int tandem_adjust_ulaw( - int sr, /* decoder output linear PCM sample */ - int se, /* predictor estimate sample */ - int y, /* quantizer step size */ - int i, /* decoder input code */ - int sign, - short *qtab) + int sr, /* decoder output linear PCM sample */ + int se, /* predictor estimate sample */ + int y, /* quantizer step size */ + int i, /* decoder input code */ + int sign, + short *qtab) { - unsigned char sp; /* u-law compressed 8-bit code */ - short dx; /* prediction error */ - char id; /* quantized prediction error */ - int sd; /* adjusted u-law decoded sample value */ - int im; /* biased magnitude of i */ - int imx; /* biased magnitude of id */ - - if (sr <= -32768) - sr = 0; - sp = linear2ulaw(sr << 2); /* short to u-law compression */ - dx = (ulaw2linear(sp) >> 2) - se; /* 16-bit prediction error */ - id = quantize(dx, y, qtab, sign - 1); - if (id == i) { - return (sp); - } else { - /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */ - im = i ^ sign; /* 2's complement to biased unsigned */ - imx = id ^ sign; - if (imx > im) { /* sp adjusted to next lower value */ - if (sp & 0x80) - sd = (sp == 0xFF) ? 0x7E : sp + 1; - else - sd = (sp == 0) ? 0 : sp - 1; - - } else { /* sp adjusted to next higher value */ - if (sp & 0x80) - sd = (sp == 0x80) ? 0x80 : sp - 1; - else - sd = (sp == 0x7F) ? 0xFE : sp + 1; - } - return (sd); - } + unsigned char sp; /* u-law compressed 8-bit code */ + short dx; /* prediction error */ + char id; /* quantized prediction error */ + int sd; /* adjusted u-law decoded sample value */ + int im; /* biased magnitude of i */ + int imx; /* biased magnitude of id */ + + if (sr <= -32768) + sr = 0; + sp = linear2ulaw(sr << 2); /* short to u-law compression */ + dx = (ulaw2linear(sp) >> 2) - se; /* 16-bit prediction error */ + id = quantize(dx, y, qtab, sign - 1); + if (id == i) { + return (sp); + } else { + /* ADPCM codes : 8, 9, ... F, 0, 1, ... , 6, 7 */ + im = i ^ sign; /* 2's complement to biased unsigned */ + imx = id ^ sign; + if (imx > im) { /* sp adjusted to next lower value */ + if (sp & 0x80) + sd = (sp == 0xFF) ? 0x7E : sp + 1; + else + sd = (sp == 0) ? 0 : sp - 1; + + } else { /* sp adjusted to next higher value */ + if (sp & 0x80) + sd = (sp == 0x80) ? 0x80 : sp - 1; + else + sd = (sp == 0x7F) ? 0xFE : sp + 1; + } + return (sd); + } } diff --git a/contrib/src/mmedia/sndaiff.cpp b/contrib/src/mmedia/sndaiff.cpp index 6174200eb2..2d06ccdc11 100644 --- a/contrib/src/mmedia/sndaiff.cpp +++ b/contrib/src/mmedia/sndaiff.cpp @@ -63,25 +63,25 @@ bool wxSoundAiff::CanRead() wxUint32 signature1, signature2, len; if (m_input->Read(&signature1, 4).LastRead() != 4) - return FALSE; + return false; if (wxUINT32_SWAP_ON_BE(signature1) != FORM_SIGNATURE) { m_input->Ungetch(&signature1, 4); - return FALSE; + return false; } m_input->Read(&len, 4); if (m_input->LastRead() != 4) { m_input->Ungetch(&len, m_input->LastRead()); m_input->Ungetch(&signature1, 4); - return FALSE; + return false; } if (m_input->Read(&signature2, 4).LastRead() != 4) { m_input->Ungetch(&signature2, m_input->LastRead()); m_input->Ungetch(&len, 4); m_input->Ungetch(&signature1, 4); - return FALSE; + return false; } m_input->Ungetch(&signature2, 4); @@ -91,12 +91,12 @@ bool wxSoundAiff::CanRead() if ( wxUINT32_SWAP_ON_BE(signature2) != AIFF_SIGNATURE && wxUINT32_SWAP_ON_BE(signature2) != AIFC_SIGNATURE) - return FALSE; + return false; - return TRUE; + return true; } -#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return FALSE; } +#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return false; } bool wxSoundAiff::PrepareToPlay() { @@ -106,11 +106,11 @@ bool wxSoundAiff::PrepareToPlay() if (!m_input) { m_snderror = wxSOUND_INVSTRM; - return FALSE; + return false; } m_snderror = wxSOUND_NOERROR; - data.BigEndianOrdered(TRUE); + data.BigEndianOrdered(true); FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM); FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != FORM_SIGNATURE, wxSOUND_INVSTRM); @@ -127,7 +127,7 @@ bool wxSoundAiff::PrepareToPlay() wxUINT32_SWAP_ON_BE(signature) != AIFC_SIGNATURE, wxSOUND_INVSTRM); // "AIFF" / "AIFC" - end_headers = FALSE; + end_headers = false; while (!end_headers) { FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM); @@ -148,11 +148,11 @@ bool wxSoundAiff::PrepareToPlay() sndformat.SetSampleRate((wxUint32) srate); sndformat.SetBPS(bps); sndformat.SetChannels(channels); - sndformat.Signed(FALSE); + sndformat.Signed(false); sndformat.SetOrder(wxBIG_ENDIAN); if (!SetSoundFormat(sndformat)) - return FALSE; + return false; // We pass all data left m_input->SeekI(len-18, wxFromCurrent); break; @@ -165,7 +165,7 @@ bool wxSoundAiff::PrepareToPlay() m_base_offset = m_input->TellI(); // len-8 bytes of samples FinishPreparation(len - 8); - end_headers = TRUE; + end_headers = true; break; } default: @@ -173,28 +173,28 @@ bool wxSoundAiff::PrepareToPlay() break; } } - return TRUE; + return true; } bool wxSoundAiff::PrepareToRecord(wxUint32 WXUNUSED(time)) { // TODO - return FALSE; + return false; } bool wxSoundAiff::FinishRecording() { // TODO - return FALSE; + return false; } bool wxSoundAiff::RepositionStream(wxUint32 WXUNUSED(position)) { // If the stream is not seekable "TellI() returns wxInvalidOffset" we cannot reposition stream if (m_base_offset == wxInvalidOffset) - return FALSE; + return false; m_input->SeekI(m_base_offset, wxFromStart); - return TRUE; + return true; } wxUint32 wxSoundAiff::GetData(void *buffer, wxUint32 len) diff --git a/contrib/src/mmedia/sndbase.cpp b/contrib/src/mmedia/sndbase.cpp index ed3ea6ecc7..d0c96431da 100644 --- a/contrib/src/mmedia/sndbase.cpp +++ b/contrib/src/mmedia/sndbase.cpp @@ -72,7 +72,7 @@ wxSoundStream::~wxSoundStream() // important function of the wxSoundStream class. It prepares the stream to // receive or send the data in a strict format. Normally, the sound stream // should be ready to accept any format it is asked to manage but in certain -// cases, it really cannot: in that case it returns FALSE. To have more +// cases, it really cannot: in that case it returns false. To have more // details in the functionnalities of SetSoundFormat see // wxSoundRouterStream::SetSoundFormat() // -------------------------------------------------------------------------- @@ -84,7 +84,7 @@ bool wxSoundStream::SetSoundFormat(const wxSoundFormatBase& format) // create a new one by cloning the format passed in parameter m_sndformat = format.Clone(); - return TRUE; + return true; } diff --git a/contrib/src/mmedia/sndcpcm.cpp b/contrib/src/mmedia/sndcpcm.cpp index 3e922ba392..9f887a4804 100644 --- a/contrib/src/mmedia/sndcpcm.cpp +++ b/contrib/src/mmedia/sndcpcm.cpp @@ -279,11 +279,11 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format) if (m_sndio->SetSoundFormat(format)) { m_function_out = NULL; m_function_in = NULL; - return TRUE; + return true; } if (format.GetType() != wxSOUND_PCM) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } if (m_sndformat) delete m_sndformat; @@ -300,11 +300,11 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format) src_rate = pcm_format->GetSampleRate(); dst_rate = pcm_format2->GetSampleRate(); - m_needResampling = TRUE; + m_needResampling = true; if (src_rate < dst_rate) - m_expandSamples = TRUE; + m_expandSamples = true; else - m_expandSamples = FALSE; + m_expandSamples = false; m_pitch = (src_rate << FLOATBITS) / dst_rate; } #endif @@ -327,7 +327,7 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format) break; default: // TODO: Add something here: error, log, ... - return FALSE; + return false; } switch (pcm_format2->GetBPS()) { case 8: @@ -338,7 +338,7 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format) break; default: // TODO: Add something here: error, log, ... - return FALSE; + return false; } if (pcm_format2->Signed() != pcm_format->Signed()) @@ -399,7 +399,7 @@ bool wxSoundStreamPcm::SetSoundFormat(const wxSoundFormatBase& format) wxUnusedVar( SetSoundFormatReturn ); m_sndformat = new_format; - return TRUE; + return true; } wxUint32 wxSoundStreamPcm::GetWriteSize(wxUint32 len) const diff --git a/contrib/src/mmedia/sndesd.cpp b/contrib/src/mmedia/sndesd.cpp index dab5f28897..f7c74b7c07 100644 --- a/contrib/src/mmedia/sndesd.cpp +++ b/contrib/src/mmedia/sndesd.cpp @@ -62,7 +62,7 @@ wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname) wxSoundFormatPcm pcm_default; // First, we make some basic test: is there ESD on this computer ? - m_esd_ok = FALSE; + m_esd_ok = false; if (hostname.IsNull()) m_fd_output = esd_play_stream(ESD_PLAY | ESD_STREAM, 22050, @@ -86,9 +86,9 @@ wxSoundStreamESD::wxSoundStreamESD(const wxString& hostname) // Initialize some variable m_snderror = wxSOUND_NOERROR; - m_esd_stop = TRUE; - m_q_filled = TRUE; - m_esd_ok = TRUE; + m_esd_stop = true; + m_q_filled = true; + m_esd_ok = true; m_fd_output= -1; m_fd_input = -1; #endif // defined HAVE_ESD_H @@ -154,7 +154,7 @@ wxSoundStream& wxSoundStreamESD::Write(const void *buffer, wxUint32 len) else m_snderror = wxSOUND_NOERROR; - m_q_filled = TRUE; + m_q_filled = true; return *this; #endif // defined HAVE_ESD_H @@ -168,18 +168,18 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format) { #ifndef HAVE_ESD_H m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; #else wxSoundFormatPcm *pcm_format; if (format.GetType() != wxSOUND_PCM) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } if (!m_esd_ok) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } if (m_sndformat) @@ -188,7 +188,7 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format) m_sndformat = format.Clone(); if (!m_sndformat) { m_snderror = wxSOUND_MEMERROR; - return FALSE; + return false; } pcm_format = (wxSoundFormatPcm *)m_sndformat; @@ -198,9 +198,9 @@ bool wxSoundStreamESD::SetSoundFormat(const wxSoundFormatBase& format) m_snderror = wxSOUND_NOERROR; if (*pcm_format != format) { m_snderror = wxSOUND_NOEXACT; - return FALSE; + return false; } - return TRUE; + return true; #endif // defined HAVE_ESD_H } @@ -234,7 +234,7 @@ static void _wxSound_OSS_CBack(gpointer data, int source, // -------------------------------------------------------------------------- void wxSoundStreamESD::WakeUpEvt(int evt) { - m_q_filled = FALSE; + m_q_filled = false; OnSoundEvent(evt); } @@ -245,14 +245,14 @@ bool wxSoundStreamESD::StartProduction(int evt) { #ifndef HAVE_ESD_H m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; #else wxSoundFormatPcm *pcm; int flag = 0; if (!m_esd_ok) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } if (!m_esd_stop) @@ -286,10 +286,10 @@ bool wxSoundStreamESD::StartProduction(int evt) } #endif - m_esd_stop = FALSE; - m_q_filled = FALSE; + m_esd_stop = false; + m_q_filled = false; - return TRUE; + return true; #endif // defined HAVE_ESD_H } @@ -300,10 +300,10 @@ bool wxSoundStreamESD::StopProduction() { #ifndef HAVE_ESD_H m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; #else if (m_esd_stop) - return FALSE; + return false; if (m_fd_input != -1) { esd_close(m_fd_input); @@ -320,9 +320,9 @@ bool wxSoundStreamESD::StopProduction() m_fd_input = -1; m_fd_output= -1; - m_esd_stop = TRUE; - m_q_filled = TRUE; - return TRUE; + m_esd_stop = true; + m_q_filled = true; + return true; #endif // defined HAVE_ESD_H } @@ -350,7 +350,7 @@ void wxSoundStreamESD::DetectBest(wxSoundFormatPcm *pcm) best_pcm.SetBPS(8); best_pcm.SetOrder(wxLITTLE_ENDIAN); - best_pcm.Signed(TRUE); + best_pcm.Signed(true); // Finally recopy the new format *pcm = best_pcm; diff --git a/contrib/src/mmedia/sndfile.cpp b/contrib/src/mmedia/sndfile.cpp index 54e333b6c8..1e857741f1 100644 --- a/contrib/src/mmedia/sndfile.cpp +++ b/contrib/src/mmedia/sndfile.cpp @@ -78,7 +78,7 @@ wxSoundStream& wxSoundRouterStream::Write(const void *buffer, wxUint32 len) // sound driver using the specified format. If this fails, it uses personnal // codec converters: for the moment there is a PCM converter (PCM to PCM: // with optional resampling, ...), an ULAW converter (ULAW to PCM), a G72X -// converter (G72X to PCM). If nothing works, it returns FALSE. +// converter (G72X to PCM). If nothing works, it returns false. // -------------------------------------------------------------------------- bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format) { @@ -89,12 +89,12 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format) if (m_sndio->SetSoundFormat(format)) { // We are lucky, it is working. wxSoundStream::SetSoundFormat(m_sndio->GetSoundFormat()); - return TRUE; + return true; } switch(format.GetType()) { case wxSOUND_NOFORMAT: - return FALSE; + return false; case wxSOUND_PCM: m_router = new wxSoundStreamPcm(*m_sndio); m_router->SetSoundFormat(format); @@ -112,11 +112,11 @@ bool wxSoundRouterStream::SetSoundFormat(const wxSoundFormatBase& format) m_router->SetSoundFormat(format); break; default: - return FALSE; + return false; } wxSoundStream::SetSoundFormat(m_router->GetSoundFormat()); - return TRUE; + return true; } // -------------------------------------------------------------------------- @@ -139,19 +139,19 @@ bool wxSoundRouterStream::StartProduction(int evt) { if (!m_router) { if (m_sndio->StartProduction(evt)) - return TRUE; + return true; m_snderror = m_sndio->GetError(); m_lastcount = m_sndio->GetLastAccess(); - return FALSE; + return false; } if (m_router->StartProduction(evt)) - return TRUE; + return true; m_snderror = m_router->GetError(); m_lastcount = m_router->GetLastAccess(); - return FALSE; + return false; } // -------------------------------------------------------------------------- @@ -161,19 +161,19 @@ bool wxSoundRouterStream::StopProduction() { if (!m_router) { if (m_sndio->StopProduction()) - return TRUE; + return true; m_snderror = m_sndio->GetError(); m_lastcount = m_sndio->GetLastAccess(); - return FALSE; + return false; } if (m_router->StopProduction()) - return TRUE; + return true; m_snderror = m_router->GetError(); m_lastcount = m_router->GetLastAccess(); - return FALSE; + return false; } // -------------------------------------------------------------------------- @@ -187,7 +187,7 @@ wxSoundFileStream::wxSoundFileStream(wxInputStream& stream, { m_length = 0; m_bytes_left = 0; - m_prepared = FALSE; + m_prepared = false; } wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream, @@ -197,7 +197,7 @@ wxSoundFileStream::wxSoundFileStream(wxOutputStream& stream, { m_length = 0; m_bytes_left = 0; - m_prepared = FALSE; + m_prepared = false; } wxSoundFileStream::~wxSoundFileStream() @@ -209,51 +209,51 @@ wxSoundFileStream::~wxSoundFileStream() bool wxSoundFileStream::Play() { if (m_state != wxSOUND_FILE_STOPPED) - return FALSE; + return false; if (!m_prepared) if (!PrepareToPlay()) - return FALSE; + return false; m_state = wxSOUND_FILE_PLAYING; if (!StartProduction(wxSOUND_OUTPUT)) - return FALSE; + return false; - return TRUE; + return true; } bool wxSoundFileStream::Record(wxUint32 time) { if (m_state != wxSOUND_FILE_STOPPED) - return FALSE; + return false; if (!PrepareToRecord(time)) - return FALSE; + return false; FinishPreparation(m_sndformat->GetBytesFromTime(time)); m_state = wxSOUND_FILE_RECORDING; if (!StartProduction(wxSOUND_INPUT)) - return FALSE; + return false; - return TRUE; + return true; } bool wxSoundFileStream::Stop() { if (m_state == wxSOUND_FILE_STOPPED) - return FALSE; + return false; if (!StopProduction()) - return FALSE; + return false; - m_prepared = FALSE; + m_prepared = false; if (m_state == wxSOUND_FILE_RECORDING) if (!FinishRecording()) { m_state = wxSOUND_FILE_STOPPED; - return FALSE; + return false; } if (m_input) @@ -263,35 +263,35 @@ bool wxSoundFileStream::Stop() m_output->SeekO(0, wxFromStart); m_state = wxSOUND_FILE_STOPPED; - return TRUE; + return true; } bool wxSoundFileStream::Pause() { if (m_state == wxSOUND_FILE_PAUSED || m_state == wxSOUND_FILE_STOPPED) - return FALSE; + return false; if (!StopProduction()) - return FALSE; + return false; m_oldstate = m_state; m_state = wxSOUND_FILE_PAUSED; - return TRUE; + return true; } bool wxSoundFileStream::Resume() { if (m_state == wxSOUND_FILE_PLAYING || m_state == wxSOUND_FILE_RECORDING || m_state == wxSOUND_FILE_STOPPED) - return FALSE; + return false; if (!StartProduction( (m_oldstate == wxSOUND_FILE_PLAYING) ? wxSOUND_OUTPUT : wxSOUND_INPUT)) - return FALSE; + return false; m_state = m_oldstate; - return TRUE; + return true; } wxSoundStream& wxSoundFileStream::Read(void *buffer, wxUint32 len) @@ -321,9 +321,9 @@ bool wxSoundFileStream::StartProduction(int evt) m_sndio->SetEventHandler(this); if (!m_codec.StartProduction(evt)) - return FALSE; + return false; - return TRUE; + return true; } bool wxSoundFileStream::StopProduction() @@ -334,7 +334,7 @@ bool wxSoundFileStream::StopProduction() void wxSoundFileStream::FinishPreparation(wxUint32 len) { m_bytes_left = m_length = len; - m_prepared = TRUE; + m_prepared = true; } wxString wxSoundFileStream::GetCodecName() const diff --git a/contrib/src/mmedia/sndg72x.cpp b/contrib/src/mmedia/sndg72x.cpp index f9ce3ca810..1f772d2548 100644 --- a/contrib/src/mmedia/sndg72x.cpp +++ b/contrib/src/mmedia/sndg72x.cpp @@ -104,7 +104,7 @@ bool wxSoundFormatG72X::operator !=(const wxSoundFormatBase& frmt2) const wxSoundFormatG72X *g72x = (wxSoundFormatG72X *)&frmt2; if (frmt2.GetType() != wxSOUND_G72X) - return TRUE; + return true; return (g72x->m_srate != m_srate || g72x->m_g72x_type != m_g72x_type); } @@ -196,7 +196,7 @@ bool wxSoundStreamG72X::SetSoundFormat(const wxSoundFormatBase& format) { if (format.GetType() != wxSOUND_G72X) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } wxSoundFormatPcm pcm; @@ -210,7 +210,7 @@ bool wxSoundStreamG72X::SetSoundFormat(const wxSoundFormatBase& format) pcm.SetSampleRate(g72x->GetSampleRate()); pcm.SetBPS(16); pcm.SetChannels(1); // Only mono supported - pcm.Signed(TRUE); + pcm.Signed(true); pcm.SetOrder(wxBYTE_ORDER); // Look for the correct codec to use and set its bit width @@ -235,7 +235,7 @@ bool wxSoundStreamG72X::SetSoundFormat(const wxSoundFormatBase& format) // Let the router finish the work m_router->SetSoundFormat(pcm); - return TRUE; + return true; } #define BYTE_SIZE 8 diff --git a/contrib/src/mmedia/sndmsad.cpp b/contrib/src/mmedia/sndmsad.cpp index 3f627c63ed..d2db32ef08 100644 --- a/contrib/src/mmedia/sndmsad.cpp +++ b/contrib/src/mmedia/sndmsad.cpp @@ -130,7 +130,7 @@ bool wxSoundFormatMSAdpcm::operator !=(const wxSoundFormatBase& frmt2) const const wxSoundFormatMSAdpcm *adpcm = (const wxSoundFormatMSAdpcm *)&frmt2; if (frmt2.GetType() != wxSOUND_MSADPCM) - return TRUE; + return true; return (adpcm->m_srate != m_srate) && (adpcm->m_nchannels != m_nchannels); } @@ -143,8 +143,8 @@ wxSoundStreamMSAdpcm::wxSoundStreamMSAdpcm(wxSoundStream& sndio) { // PCM converter m_router = new wxSoundRouterStream(sndio); - m_got_header = FALSE; - m_stereo = FALSE; + m_got_header = false; + m_stereo = false; } wxSoundStreamMSAdpcm::~wxSoundStreamMSAdpcm() @@ -354,7 +354,7 @@ bool wxSoundStreamMSAdpcm::SetSoundFormat(const wxSoundFormatBase& format) { if (format.GetType() != wxSOUND_MSADPCM) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } wxSoundFormatPcm pcm; @@ -369,13 +369,13 @@ bool wxSoundStreamMSAdpcm::SetSoundFormat(const wxSoundFormatBase& format) if (!ncoefs) { wxLogError(wxT("Number of ADPCM coefficients must be non null")); - return FALSE; + return false; } pcm.SetSampleRate(adpcm->GetSampleRate()); pcm.SetBPS(16); pcm.SetChannels(adpcm->GetChannels()); - pcm.Signed(TRUE); + pcm.Signed(true); pcm.SetOrder(wxBYTE_ORDER); m_stereo = (adpcm->GetChannels() == 2); @@ -384,6 +384,6 @@ bool wxSoundStreamMSAdpcm::SetSoundFormat(const wxSoundFormatBase& format) m_router->SetSoundFormat(pcm); - return TRUE; + return true; } diff --git a/contrib/src/mmedia/sndoss.cpp b/contrib/src/mmedia/sndoss.cpp index 51253c92e0..4070ca0fdc 100644 --- a/contrib/src/mmedia/sndoss.cpp +++ b/contrib/src/mmedia/sndoss.cpp @@ -40,7 +40,7 @@ wxSoundStreamOSS::wxSoundStreamOSS(const wxString& dev_name) m_fd = open(dev_name.mb_str(), O_WRONLY); if (m_fd == -1) { // OSS not found - m_oss_ok = FALSE; + m_oss_ok = false; m_snderror = wxSOUND_INVDEV; return; } @@ -59,9 +59,9 @@ wxSoundStreamOSS::wxSoundStreamOSS(const wxString& dev_name) // Close OSS close(m_fd); - m_oss_ok = TRUE; - m_oss_stop = TRUE; - m_q_filled = TRUE; + m_oss_ok = true; + m_oss_stop = true; + m_q_filled = true; } wxSoundStreamOSS::~wxSoundStreamOSS() @@ -86,7 +86,7 @@ wxSoundStream& wxSoundStreamOSS::Read(void *buffer, wxUint32 len) } m_lastcount = (wxUint32)ret = read(m_fd, buffer, len); - m_q_filled = TRUE; + m_q_filled = true; if (ret < 0) m_snderror = wxSOUND_IOERROR; @@ -107,7 +107,7 @@ wxSoundStream& wxSoundStreamOSS::Write(const void *buffer, wxUint32 len) } ret = write(m_fd, buffer, len); - m_q_filled = TRUE; + m_q_filled = true; if (ret < 0) { m_lastcount = 0; @@ -127,12 +127,12 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format) if (format.GetType() != wxSOUND_PCM) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } if (!m_oss_ok) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } if (m_sndformat) @@ -141,7 +141,7 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format) m_sndformat = format.Clone(); if (!m_sndformat) { m_snderror = wxSOUND_MEMERROR; - return FALSE; + return false; } pcm_format = (wxSoundFormatPcm *)m_sndformat; @@ -150,7 +150,7 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format) m_fd = open(m_devname.mb_str(), O_WRONLY); if (m_fd == -1) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } } @@ -176,10 +176,10 @@ bool wxSoundStreamOSS::SetSoundFormat(const wxSoundFormatBase& format) m_snderror = wxSOUND_NOERROR; if (*pcm_format != format) { m_snderror = wxSOUND_NOEXACT; - return FALSE; + return false; } - return TRUE; + return true; } bool wxSoundStreamOSS::SetupFormat(wxSoundFormatPcm *pcm_format) @@ -217,34 +217,34 @@ bool wxSoundStreamOSS::SetupFormat(wxSoundFormatPcm *pcm_format) switch (tmp) { case AFMT_U8: pcm_format->SetBPS(8); - pcm_format->Signed(FALSE); + pcm_format->Signed(false); break; case AFMT_S8: pcm_format->SetBPS(8); - pcm_format->Signed(TRUE); + pcm_format->Signed(true); break; case AFMT_U16_LE: pcm_format->SetBPS(16); - pcm_format->Signed(FALSE); + pcm_format->Signed(false); pcm_format->SetOrder(wxLITTLE_ENDIAN); break; case AFMT_U16_BE: pcm_format->SetBPS(16); - pcm_format->Signed(FALSE); + pcm_format->Signed(false); pcm_format->SetOrder(wxBIG_ENDIAN); break; case AFMT_S16_LE: pcm_format->SetBPS(16); - pcm_format->Signed(TRUE); + pcm_format->Signed(true); pcm_format->SetOrder(wxLITTLE_ENDIAN); break; case AFMT_S16_BE: pcm_format->SetBPS(16); - pcm_format->Signed(TRUE); + pcm_format->Signed(true); pcm_format->SetOrder(wxBIG_ENDIAN); break; } - return TRUE; + return true; } #ifdef __WXGTK__ @@ -268,7 +268,7 @@ static void _wxSound_OSS_CBack(gpointer data, int source, void wxSoundStreamOSS::WakeUpEvt(int evt) { - m_q_filled = FALSE; + m_q_filled = false; OnSoundEvent(evt); } @@ -282,7 +282,7 @@ bool wxSoundStreamOSS::StartProduction(int evt) old_frmt = m_sndformat->Clone(); if (!old_frmt) { m_snderror = wxSOUND_MEMERROR; - return FALSE; + return false; } if (evt == wxSOUND_OUTPUT) @@ -292,7 +292,7 @@ bool wxSoundStreamOSS::StartProduction(int evt) if (m_fd == -1) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } SetSoundFormat(*old_frmt); @@ -314,25 +314,25 @@ bool wxSoundStreamOSS::StartProduction(int evt) ioctl(m_fd, SNDCTL_DSP_SETTRIGGER, &trig); - m_oss_stop = FALSE; - m_q_filled = FALSE; + m_oss_stop = false; + m_q_filled = false; - return TRUE; + return true; } bool wxSoundStreamOSS::StopProduction() { if (m_oss_stop) - return FALSE; + return false; #ifdef __WXGTK__ gdk_input_remove(m_tag); #endif close(m_fd); - m_oss_stop = TRUE; - m_q_filled = TRUE; - return TRUE; + m_oss_stop = true; + m_q_filled = true; + return true; } bool wxSoundStreamOSS::QueueFilled() const @@ -375,12 +375,12 @@ void wxSoundStreamOSS::DetectBest(wxSoundFormatPcm *pcm) // It supports signed samples if (pcm->Signed() && ((fmt_mask & (AFMT_S16_LE | AFMT_S16_BE | AFMT_S8)) != 0)) - best_pcm.Signed(TRUE); + best_pcm.Signed(true); // It supports unsigned samples if (!pcm->Signed() && ((fmt_mask & (AFMT_U16_LE | AFMT_U16_BE | AFMT_U8)) != 0)) - best_pcm.Signed(FALSE); + best_pcm.Signed(false); // Finally recopy the new format *pcm = best_pcm; diff --git a/contrib/src/mmedia/sndpcm.cpp b/contrib/src/mmedia/sndpcm.cpp index a6a5a70080..d28fa068d3 100644 --- a/contrib/src/mmedia/sndpcm.cpp +++ b/contrib/src/mmedia/sndpcm.cpp @@ -88,7 +88,7 @@ bool wxSoundFormatPcm::operator!=(const wxSoundFormatBase& format) const wxSoundFormatPcm *format2 = (wxSoundFormatPcm *)&format; if (format.GetType() != wxSOUND_PCM) - return TRUE; + return true; return ( (m_srate != format2->m_srate) || (m_bps != format2->m_bps) || diff --git a/contrib/src/mmedia/sndulaw.cpp b/contrib/src/mmedia/sndulaw.cpp index f0ea5cfc66..8898291ad0 100644 --- a/contrib/src/mmedia/sndulaw.cpp +++ b/contrib/src/mmedia/sndulaw.cpp @@ -82,7 +82,7 @@ bool wxSoundFormatUlaw::operator !=(const wxSoundFormatBase& frmt2) const wxSoundFormatUlaw *ulaw = (wxSoundFormatUlaw *)&frmt2; if (frmt2.GetType() != wxSOUND_ULAW) - return TRUE; + return true; return (ulaw->m_srate != m_srate); } @@ -160,7 +160,7 @@ bool wxSoundStreamUlaw::SetSoundFormat(const wxSoundFormatBase& format) { if (format.GetType() != wxSOUND_ULAW) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } // As the codec only support 16 bits, Mono we must use a wxSoundRouter @@ -177,10 +177,10 @@ bool wxSoundStreamUlaw::SetSoundFormat(const wxSoundFormatBase& format) pcm.SetSampleRate(ulaw->GetSampleRate()); pcm.SetBPS(16); pcm.SetChannels(ulaw->GetChannels()); - pcm.Signed(TRUE); + pcm.Signed(true); pcm.SetOrder(wxBYTE_ORDER); m_router->SetSoundFormat(pcm); - return TRUE; + return true; } diff --git a/contrib/src/mmedia/sndwav.cpp b/contrib/src/mmedia/sndwav.cpp index 75f5bf9e59..76fc470954 100644 --- a/contrib/src/mmedia/sndwav.cpp +++ b/contrib/src/mmedia/sndwav.cpp @@ -64,7 +64,7 @@ wxString wxSoundWave::GetCodecName() const return wxString(wxT("wxSoundWave codec")); } -#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return FALSE; } +#define FAIL_WITH(condition, err) if (condition) { m_snderror = err; return false; } bool wxSoundWave::CanRead() { @@ -77,7 +77,7 @@ bool wxSoundWave::CanRead() if (wxUINT32_SWAP_ON_BE(signature1) != RIFF_SIGNATURE) { m_input->Ungetch(&signature1, 4); - return FALSE; + return false; } // Pass the global length @@ -93,9 +93,9 @@ bool wxSoundWave::CanRead() // Test the second signature if (wxUINT32_SWAP_ON_BE(signature2) != WAVE_SIGNATURE) - return FALSE; + return false; - return TRUE; + return true; } bool wxSoundWave::HandleOutputPCM(wxDataInputStream& WXUNUSED(data), wxUint32 len, @@ -108,15 +108,15 @@ bool wxSoundWave::HandleOutputPCM(wxDataInputStream& WXUNUSED(data), wxUint32 le sndformat.SetSampleRate(sample_fq); sndformat.SetBPS(bits_p_spl); sndformat.SetChannels(channels); - sndformat.Signed(TRUE); + sndformat.Signed(true); sndformat.SetOrder(wxLITTLE_ENDIAN); if (!SetSoundFormat(sndformat)) - return FALSE; + return false; m_input->SeekI(len, wxFromCurrent); - return TRUE; + return true; } bool wxSoundWave::HandleOutputMSADPCM(wxDataInputStream& data, wxUint32 len, @@ -150,13 +150,13 @@ bool wxSoundWave::HandleOutputMSADPCM(wxDataInputStream& data, wxUint32 len, delete[] coefs[1]; if (!SetSoundFormat(sndformat)) - return FALSE; + return false; len -= coefs_len*4 + 4; m_input->SeekI(len, wxFromCurrent); - return TRUE; + return true; } bool wxSoundWave::HandleOutputG721(wxDataInputStream& WXUNUSED(data), wxUint32 len, @@ -170,11 +170,11 @@ bool wxSoundWave::HandleOutputG721(wxDataInputStream& WXUNUSED(data), wxUint32 l sndformat.SetG72XType(wxSOUND_G721); if (!SetSoundFormat(sndformat)) - return FALSE; + return false; m_input->SeekI(len, wxFromCurrent); - return TRUE; + return true; } bool wxSoundWave::PrepareToPlay() @@ -184,11 +184,11 @@ bool wxSoundWave::PrepareToPlay() if (!m_input) { m_snderror = wxSOUND_INVSTRM; - return FALSE; + return false; } wxDataInputStream data(*m_input); - data.BigEndianOrdered(FALSE); + data.BigEndianOrdered(false); // Get the first signature FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM); @@ -205,7 +205,7 @@ bool wxSoundWave::PrepareToPlay() FAIL_WITH(wxUINT32_SWAP_ON_BE(signature) != WAVE_SIGNATURE, wxSOUND_INVSTRM); // "WAVE" - end_headers = FALSE; + end_headers = false; // Chunk loop while (!end_headers) { FAIL_WITH(m_input->Read(&signature, 4).LastRead() != 4, wxSOUND_INVSTRM); @@ -228,31 +228,31 @@ bool wxSoundWave::PrepareToPlay() if (!HandleOutputPCM(data, len, channels, sample_fq, byte_p_sec, byte_p_spl, bits_p_spl)) - return FALSE; + return false; break; case 0x02: // MS ADPCM if (!HandleOutputMSADPCM(data, len, channels, sample_fq, byte_p_sec, byte_p_spl, bits_p_spl)) - return FALSE; + return false; break; case 0x40: // G721 if (!HandleOutputG721(data, len, channels, sample_fq, byte_p_sec, byte_p_spl, bits_p_spl)) - return FALSE; + return false; break; default: m_snderror = wxSOUND_NOCODEC; - return FALSE; + return false; } break; } case DATA_SIGNATURE: // "data" m_base_offset = m_input->TellI(); - end_headers = TRUE; + end_headers = true; FinishPreparation(len); break; default: @@ -261,7 +261,7 @@ bool wxSoundWave::PrepareToPlay() break; } } - return TRUE; + return true; } wxSoundFormatBase *wxSoundWave::HandleInputPCM(wxDataOutputStream& data) @@ -282,7 +282,7 @@ wxSoundFormatBase *wxSoundWave::HandleInputPCM(wxDataOutputStream& data) byte_p_sec = pcm->GetBytesFromTime(1); format = 0x01; - pcm->Signed(TRUE); + pcm->Signed(true); pcm->SetOrder(wxLITTLE_ENDIAN); data << format << channels << sample_fq @@ -330,14 +330,14 @@ FAIL_WITH(s->Write(&signature, 4).LastWrite() != 4, wxSOUND_INVSTRM); if (!m_output) { m_snderror = wxSOUND_INVSTRM; - return FALSE; + return false; } wxDataOutputStream data(*m_output); wxDataOutputStream fmt_d_data(fmt_data); - data.BigEndianOrdered(FALSE); - fmt_d_data.BigEndianOrdered(FALSE); + data.BigEndianOrdered(false); + fmt_d_data.BigEndianOrdered(false); WRITE_SIGNATURE(m_output, RIFF_SIGNATURE); @@ -359,14 +359,14 @@ FAIL_WITH(s->Write(&signature, 4).LastWrite() != 4, wxSOUND_INVSTRM); break; default: m_snderror = wxSOUND_NOCODEC; - return FALSE; + return false; } FAIL_WITH(!frmt, wxSOUND_NOCODEC); if (!SetSoundFormat(*frmt)) { delete frmt; - return FALSE; + return false; } delete frmt; @@ -387,28 +387,28 @@ FAIL_WITH(s->Write(&signature, 4).LastWrite() != 4, wxSOUND_INVSTRM); WRITE_SIGNATURE(m_output, DATA_SIGNATURE); data.Write32(m_sndformat->GetBytesFromTime(time)); - return TRUE; + return true; } bool wxSoundWave::FinishRecording() { if (m_output->SeekO(0, wxFromStart) == wxInvalidOffset) // We can't but there is no error. - return TRUE; + return true; if (m_bytes_left == 0) - return TRUE; + return true; // TODO: Update headers when we stop before the specified time (if possible) - return TRUE; + return true; } bool wxSoundWave::RepositionStream(wxUint32 WXUNUSED(position)) { if (m_base_offset == wxInvalidOffset) - return FALSE; + return false; m_input->SeekI(m_base_offset, wxFromStart); - return TRUE; + return true; } wxUint32 wxSoundWave::GetData(void *buffer, wxUint32 len) diff --git a/contrib/src/mmedia/sndwin.cpp b/contrib/src/mmedia/sndwin.cpp index ea2cbe2b69..b058747e4a 100644 --- a/contrib/src/mmedia/sndwin.cpp +++ b/contrib/src/mmedia/sndwin.cpp @@ -80,7 +80,7 @@ wxSoundStreamWin::wxSoundStreamWin() { wxSoundFormatPcm pcm; - m_production_started = FALSE; + m_production_started = false; m_internal = new wxSoundInternal; if (!m_internal) { m_snderror = wxSOUND_MEMERROR; @@ -93,10 +93,10 @@ wxSoundStreamWin::wxSoundStreamWin() CreateSndWindow(); SetSoundFormat(pcm); - m_internal->m_input_enabled = FALSE; - m_internal->m_output_enabled = FALSE; + m_internal->m_input_enabled = false; + m_internal->m_output_enabled = false; - m_waiting_for = FALSE; + m_waiting_for = false; if (!OpenDevice(wxSOUND_OUTPUT)) { m_snderror = wxSOUND_NOERROR; //next call to OpenDevice won't do this @@ -157,7 +157,7 @@ void wxSoundStreamWin::CreateSndWindow() // NB: class name must be kept in sync with wxCanvasClassName in // src/msw/app.cpp! m_internal->m_sndWin = ::CreateWindow(wxT("wxWindowClass"), NULL, 0, - 0, 0, 0, 0, NULL, (HMENU) NULL, + 0, 0, 0, 0, NULL, (HMENU) NULL, wxGetInstance(), NULL); GetLastError(); @@ -199,7 +199,7 @@ bool wxSoundStreamWin::OpenDevice(int mode) if (!m_sndformat) { m_snderror = wxSOUND_INVFRMT; - return FALSE; + return false; } pcm = (wxSoundFormatPcm *)m_sndformat; @@ -225,13 +225,13 @@ bool wxSoundStreamWin::OpenDevice(int mode) if (result != MMSYSERR_NOERROR) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } m_output_frag_out = WXSOUND_MAX_QUEUE-1; m_current_frag_out = 0; - m_internal->m_output_enabled = TRUE; + m_internal->m_output_enabled = true; } // ----------------------------------- // Open the driver for Input operation @@ -246,29 +246,29 @@ bool wxSoundStreamWin::OpenDevice(int mode) if (result != MMSYSERR_NOERROR) { m_snderror = wxSOUND_INVDEV; - return FALSE; + return false; } m_current_frag_in = WXSOUND_MAX_QUEUE-1; m_input_frag_in = 0; - m_internal->m_input_enabled = TRUE; + m_internal->m_input_enabled = true; } if (mode & wxSOUND_OUTPUT) { if (!AllocHeaders(wxSOUND_OUTPUT)) { CloseDevice(); - return FALSE; + return false; } } if (mode & wxSOUND_INPUT) { if (!AllocHeaders(wxSOUND_INPUT)) { CloseDevice(); - return FALSE; + return false; } } - return TRUE; + return true; } // ------------------------------------------------------------------------- @@ -279,13 +279,13 @@ void wxSoundStreamWin::CloseDevice() { if (m_internal->m_output_enabled) { FreeHeaders(wxSOUND_OUTPUT); - m_internal->m_output_enabled = FALSE; + m_internal->m_output_enabled = false; waveOutClose(m_internal->m_devout); } if (m_internal->m_input_enabled) { FreeHeaders(wxSOUND_INPUT); - m_internal->m_input_enabled = FALSE; + m_internal->m_input_enabled = false; waveInClose(m_internal->m_devin); } } @@ -381,8 +381,8 @@ wxSoundInfoHeader *wxSoundStreamWin::AllocHeader(int mode) // AllocHeaders() allocates WXSOUND_MAX_QUEUE (= 128) blocks for an operation // queue. It uses AllocHeader() for each element. // -// Once it has allocated all blocks, it returns TRUE and if an error occured -// it returns FALSE. +// Once it has allocated all blocks, it returns true and if an error occured +// it returns false. // ------------------------------------------------------------------------- bool wxSoundStreamWin::AllocHeaders(int mode) { @@ -400,10 +400,10 @@ bool wxSoundStreamWin::AllocHeaders(int mode) headers[i] = AllocHeader(mode); if (!headers[i]) { FreeHeaders(mode); - return FALSE; + return false; } } - return TRUE; + return true; } // ------------------------------------------------------------------------- @@ -482,11 +482,11 @@ void wxSoundStreamWin::WaitFor(wxSoundInfoHeader *info) // PROBLEM // return; } - m_waiting_for = TRUE; + m_waiting_for = true; // Else, we wait for its termination while (info->m_playing || info->m_recording) wxYield(); - m_waiting_for = FALSE; + m_waiting_for = false; } // ------------------------------------------------------------------------- @@ -508,18 +508,18 @@ bool wxSoundStreamWin::AddToQueue(wxSoundInfoHeader *info) result = waveInAddBuffer(m_internal->m_devin, info->m_header, sizeof(WAVEHDR)); if (result == MMSYSERR_NOERROR) - info->m_recording = TRUE; + info->m_recording = true; else - return FALSE; + return false; } else if (info->m_mode == wxSOUND_OUTPUT) { result = waveOutWrite(m_internal->m_devout, info->m_header, sizeof(WAVEHDR)); if (result == MMSYSERR_NOERROR) - info->m_playing = TRUE; + info->m_playing = true; else - return FALSE; + return false; } - return TRUE; + return true; } // ------------------------------------------------------------------------- @@ -530,8 +530,8 @@ bool wxSoundStreamWin::AddToQueue(wxSoundInfoHeader *info) // ------------------------------------------------------------------------- void wxSoundStreamWin::ClearHeader(wxSoundInfoHeader *info) { - info->m_playing = FALSE; - info->m_recording = FALSE; + info->m_playing = false; + info->m_recording = false; info->m_position = 0; info->m_size = GetBestSize(); } @@ -552,7 +552,7 @@ wxSoundInfoHeader *wxSoundStreamWin::NextFragmentOutput() WaitFor(m_headers_play[m_current_frag_out]); } if (m_current_frag_out == m_output_frag_out) - m_queue_filled = TRUE; + m_queue_filled = true; return m_headers_play[m_current_frag_out]; } @@ -612,7 +612,7 @@ wxSoundInfoHeader *wxSoundStreamWin::NextFragmentInput() // We reached the writer position: the queue is full. if (m_current_frag_in == m_input_frag_in) - m_queue_filled = TRUE; + m_queue_filled = true; return header; } @@ -672,7 +672,7 @@ void wxSoundStreamWin::NotifyDoneBuffer(wxUint32 WXUNUSED(dev_handle), int flag) info = m_headers_play[m_output_frag_out]; // Clear header to tell the system the buffer is free now ClearHeader(info); - m_queue_filled = FALSE; + m_queue_filled = false; if (!m_waiting_for) // Try to requeue a new buffer. OnSoundEvent(wxSOUND_OUTPUT); @@ -681,12 +681,12 @@ void wxSoundStreamWin::NotifyDoneBuffer(wxUint32 WXUNUSED(dev_handle), int flag) return; // Recording completed - m_headers_rec[m_input_frag_in]->m_recording = FALSE; + m_headers_rec[m_input_frag_in]->m_recording = false; // Queue pointer: writer m_input_frag_in = (m_input_frag_in + 1) % WXSOUND_MAX_QUEUE; if (!m_waiting_for) OnSoundEvent(wxSOUND_INPUT); - m_queue_filled = FALSE; + m_queue_filled = false; } } @@ -705,17 +705,17 @@ bool wxSoundStreamWin::SetSoundFormat(const wxSoundFormatBase& base) bool wxSoundStreamWin::StartProduction(int evt) { if (!m_internal) - return FALSE; + return false; if ((m_internal->m_output_enabled && (evt & wxSOUND_OUTPUT)) || (m_internal->m_input_enabled && (evt & wxSOUND_INPUT))) CloseDevice(); if (!OpenDevice(evt)) - return FALSE; + return false; - m_production_started = TRUE; - m_queue_filled = FALSE; + m_production_started = true; + m_queue_filled = false; // Send a dummy event to start. if (evt & wxSOUND_OUTPUT) OnSoundEvent(wxSOUND_OUTPUT); @@ -728,7 +728,7 @@ bool wxSoundStreamWin::StartProduction(int evt) waveInStart(m_internal->m_devin); } - return TRUE; + return true; } // ------------------------------------------------------------------------- @@ -738,13 +738,13 @@ bool wxSoundStreamWin::StopProduction() { if (!m_production_started) { m_snderror = wxSOUND_NOTSTARTED; - return FALSE; + return false; } m_snderror = wxSOUND_NOERROR; - m_production_started = FALSE; + m_production_started = false; CloseDevice(); - return TRUE; + return true; } // ------------------------------------------------------------------------- @@ -771,7 +771,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSoundWinModule, wxModule) bool wxSoundWinModule::OnInit() { wxSoundHandleList = new wxList(wxKEY_INTEGER); - return TRUE; + return true; } void wxSoundWinModule::OnExit() { diff --git a/contrib/src/mmedia/vidbase.cpp b/contrib/src/mmedia/vidbase.cpp index a0fc70cb1e..a62c2a90cb 100644 --- a/contrib/src/mmedia/vidbase.cpp +++ b/contrib/src/mmedia/vidbase.cpp @@ -50,7 +50,7 @@ wxVideoBaseDriver::~wxVideoBaseDriver() bool wxVideoBaseDriver::AttachOutput(wxWindow& output) { m_video_output = &output; - return TRUE; + return true; } void wxVideoBaseDriver::DetachOutput() @@ -62,11 +62,11 @@ void wxVideoBaseDriver::DetachOutput() wxFrame *wxVideoCreateFrame(wxVideoBaseDriver *vid_drv) { - wxFrame *frame = new wxFrame(NULL, -1, _("Video Output"), wxDefaultPosition, wxSize(100, 100)); - wxWindow *vid_out = new wxWindow(frame, -1, wxPoint(0, 0), wxSize(300, 300)); + wxFrame *frame = new wxFrame(NULL, wxID_ANY, _("Video Output"), wxDefaultPosition, wxSize(100, 100)); + wxWindow *vid_out = new wxWindow(frame, wxID_ANY, wxPoint(0, 0), wxSize(300, 300)); frame->Layout(); - frame->Show(TRUE); + frame->Show(true); vid_drv->AttachOutput(*vid_out); vid_drv->Play(); diff --git a/contrib/src/mmedia/vidwin.cpp b/contrib/src/mmedia/vidwin.cpp index d5f1c4741e..ddfe966bf8 100644 --- a/contrib/src/mmedia/vidwin.cpp +++ b/contrib/src/mmedia/vidwin.cpp @@ -49,10 +49,10 @@ wxVideoWindows::wxVideoWindows(wxInputStream& str) : wxVideoBaseDriver(str) { m_internal = new wxVIDWinternal; - m_remove_file = TRUE; + m_remove_file = true; m_filename = wxGetTempFileName(_T("wxvid")); - m_paused = FALSE; - m_stopped = TRUE; + m_paused = false; + m_stopped = true; m_frameRate = 1.0; wxFileOutputStream temp_file(m_filename); @@ -65,10 +65,10 @@ wxVideoWindows::wxVideoWindows(const wxString& filename) : wxVideoBaseDriver(filename) { m_internal = new wxVIDWinternal; - m_remove_file = FALSE; + m_remove_file = false; m_filename = filename; - m_paused = FALSE; - m_stopped = TRUE; + m_paused = false; + m_stopped = true; m_frameRate = 1.0; OpenFile(); } @@ -92,7 +92,7 @@ void wxVideoWindows::OpenFile() openStruct.hWndParent = 0; mciSendCommand(0, MCI_OPEN, - MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT, + MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_OPEN_TYPE|MCI_DGV_OPEN_32BIT, (DWORD)(LPVOID)&openStruct); m_internal->m_dev_id = openStruct.wDeviceID; @@ -122,16 +122,16 @@ void wxVideoWindows::OpenFile() bool wxVideoWindows::Pause() { if (m_paused || m_stopped) - return TRUE; - m_paused = TRUE; + return true; + m_paused = true; return (mciSendCommand(m_internal->m_dev_id, MCI_PAUSE, MCI_WAIT, 0) == 0); } bool wxVideoWindows::Resume() { if (!m_paused || m_stopped) - return TRUE; - m_paused = FALSE; + return true; + m_paused = false; return (mciSendCommand(m_internal->m_dev_id, MCI_RESUME, 0, 0) == 0); } @@ -149,12 +149,12 @@ bool wxVideoWindows::GetSize(wxSize& size) const { size.SetWidth(200); size.SetHeight(200); - return TRUE; + return true; } bool wxVideoWindows::SetSize(wxSize WXUNUSED(size)) { - return TRUE; + return true; } bool wxVideoWindows::IsCapable(wxVideoType v_type) const @@ -167,12 +167,12 @@ bool wxVideoWindows::AttachOutput(wxWindow& output) MCI_DGV_WINDOW_PARMS win_struct; if (!wxVideoBaseDriver::AttachOutput(output)) - return FALSE; + return false; win_struct.hWnd = (HWND)output.GetHWND(); mciSendCommand(m_internal->m_dev_id, MCI_WINDOW, - MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct); - return TRUE; + MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct); + return true; } void wxVideoWindows::DetachOutput() @@ -183,14 +183,14 @@ void wxVideoWindows::DetachOutput() win_struct.hWnd = 0; mciSendCommand(m_internal->m_dev_id, MCI_WINDOW, - MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct); + MCI_DGV_WINDOW_HWND, (DWORD)(LPVOID)&win_struct); } bool wxVideoWindows::Play() { if (!m_stopped) - return FALSE; - m_stopped = FALSE; + return false; + m_stopped = false; return (mciSendCommand(m_internal->m_dev_id, MCI_PLAY, 0, NULL) == 0); } @@ -199,10 +199,10 @@ bool wxVideoWindows::Stop() MCI_SEEK_PARMS seekStruct; if (m_stopped) - return FALSE; - m_stopped = TRUE; + return false; + m_stopped = true; if (::mciSendCommand(m_internal->m_dev_id, MCI_STOP, MCI_WAIT, NULL) != 0) - return FALSE; + return false; seekStruct.dwCallback = 0; seekStruct.dwTo = 0; diff --git a/contrib/src/mmedia/vidxanm.cpp b/contrib/src/mmedia/vidxanm.cpp index e2bb35a3b2..2d767c14b7 100644 --- a/contrib/src/mmedia/vidxanm.cpp +++ b/contrib/src/mmedia/vidxanm.cpp @@ -77,14 +77,14 @@ wxVideoXANIMProcess::wxVideoXANIMProcess(wxVideoXANIM *xanim) void wxVideoXANIMProcess::OnTerminate(int WXUNUSED(pid), int WXUNUSED(status)) { - m_vid_xanim->m_xanim_started = FALSE; + m_vid_xanim->m_xanim_started = false; m_vid_xanim->OnFinished(); } wxVideoXANIMOutput::wxVideoXANIMOutput() - : wxProcess(NULL, -1) + : wxProcess(NULL, wxID_ANY) { - m_terminated = FALSE; + m_terminated = false; Redirect(); } @@ -95,7 +95,7 @@ bool wxVideoXANIMOutput::IsTerminated() const void wxVideoXANIMOutput::OnTerminate(int pid, int status) { - m_terminated = TRUE; + m_terminated = true; } // ------------------------------------------------------------------------- @@ -106,10 +106,10 @@ wxVideoXANIM::wxVideoXANIM() { m_internal = new wxXANIMinternal; m_xanim_detector = new wxVideoXANIMProcess(this); - m_xanim_started = FALSE; - m_paused = FALSE; + m_xanim_started = false; + m_paused = false; m_filename = wxEmptyString; - m_remove_file = FALSE; + m_remove_file = false; } wxVideoXANIM::wxVideoXANIM(wxInputStream& str) @@ -117,13 +117,13 @@ wxVideoXANIM::wxVideoXANIM(wxInputStream& str) { m_internal = new wxXANIMinternal; m_xanim_detector = new wxVideoXANIMProcess(this); - m_xanim_started = FALSE; - m_paused = FALSE; + m_xanim_started = false; + m_paused = false; m_size[0] = 0; m_size[1] = 0; m_filename = wxGetTempFileName(_T("vidxa")); - m_remove_file = TRUE; + m_remove_file = true; wxFileOutputStream fout(m_filename); fout << str; @@ -135,11 +135,11 @@ wxVideoXANIM::wxVideoXANIM(const wxString& filename) { m_internal = new wxXANIMinternal; m_xanim_detector = new wxVideoXANIMProcess(this); - m_xanim_started = FALSE; - m_paused = FALSE; + m_xanim_started = false; + m_paused = false; m_filename = filename; - m_remove_file = FALSE; + m_remove_file = false; m_size[0] = 0; m_size[1] = 0; @@ -163,42 +163,42 @@ wxVideoXANIM::~wxVideoXANIM() bool wxVideoXANIM::Play() { if (!m_paused && m_xanim_started) - return TRUE; + return true; if (!m_video_output) { wxVideoCreateFrame(this); - return TRUE; + return true; } // The movie starts with xanim if (RestartXANIM()) { - m_paused = FALSE; - return TRUE; + m_paused = false; + return true; } - return FALSE; + return false; } bool wxVideoXANIM::Pause() { if (!m_paused && SendCommand(" ")) { - m_paused = TRUE; - return TRUE; + m_paused = true; + return true; } - return FALSE; + return false; } bool wxVideoXANIM::Resume() { if (m_paused && SendCommand(" ")) { - m_paused = FALSE; - return TRUE; + m_paused = false; + return true; } - return FALSE; + return false; } bool wxVideoXANIM::Stop() { if (!m_xanim_started) - return FALSE; + return false; SendCommand("q"); @@ -207,9 +207,9 @@ bool wxVideoXANIM::Stop() wxYield(); } - m_paused = FALSE; + m_paused = false; - return TRUE; + return true; } // ------------------------------------------------------------------------- @@ -218,18 +218,18 @@ bool wxVideoXANIM::Stop() bool wxVideoXANIM::SetSize(wxSize size) { if (!m_video_output) - return FALSE; + return false; m_video_output->SetSize(size.GetWidth(), size.GetHeight()); - return FALSE; + return false; } bool wxVideoXANIM::GetSize(wxSize& size) const { if (m_size[0] == 0) - return FALSE; + return false; size.Set(m_size[0], m_size[1]); - return TRUE; + return true; } // ------------------------------------------------------------------------- @@ -238,11 +238,11 @@ bool wxVideoXANIM::GetSize(wxSize& size) const bool wxVideoXANIM::IsCapable(wxVideoType v_type) const { if (v_type == wxVIDEO_MSAVI || v_type == wxVIDEO_MPEG || - v_type == wxVIDEO_QT || v_type == wxVIDEO_GIF || v_type == wxVIDEO_JMOV || - v_type == wxVIDEO_FLI || v_type == wxVIDEO_IFF || v_type == wxVIDEO_SGI) - return TRUE; + v_type == wxVIDEO_QT || v_type == wxVIDEO_GIF || v_type == wxVIDEO_JMOV || + v_type == wxVIDEO_FLI || v_type == wxVIDEO_IFF || v_type == wxVIDEO_SGI) + return true; else - return FALSE; + return false; } // ------------------------------------------------------------------------- @@ -314,16 +314,16 @@ bool wxVideoXANIM::IsStopped() const bool wxVideoXANIM::AttachOutput(wxWindow& out) { if (!wxVideoBaseDriver::AttachOutput(out)) - return FALSE; + return false; - return TRUE; + return true; } void wxVideoXANIM::DetachOutput() { SendCommand("q"); - m_xanim_started = FALSE; - m_paused = FALSE; + m_xanim_started = false; + m_paused = false; wxVideoBaseDriver::DetachOutput(); } @@ -332,29 +332,29 @@ void wxVideoXANIM::DetachOutput() // Lowlevel XAnim controller bool wxVideoXANIM::SendCommand(const char *command, char **ret, - wxUint32 *size) + wxUint32 *size) { if (!m_xanim_started) if (!RestartXANIM()) - return FALSE; + return false; // Send a command to XAnim through X11 Property XChangeProperty(m_internal->xanim_dpy, m_internal->xanim_window, - m_internal->xanim_atom, - XA_STRING, 8, PropModeReplace, (unsigned char *)command, - strlen(command)); + m_internal->xanim_atom, + XA_STRING, 8, PropModeReplace, (unsigned char *)command, + strlen(command)); XFlush(m_internal->xanim_dpy); if (ret) { int prop_format; - Atom prop_type; - unsigned long extra; - - XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window, - m_internal->xanim_ret, 0, 16, True, AnyPropertyType, - &prop_type, &prop_format, (unsigned long *)size, - &extra, (unsigned char **)ret); + Atom prop_type; + unsigned long extra; + + XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window, + m_internal->xanim_ret, 0, 16, True, AnyPropertyType, + &prop_type, &prop_format, (unsigned long *)size, + &extra, (unsigned char **)ret); } - return TRUE; + return true; } bool wxVideoXANIM::CollectInfo() @@ -366,8 +366,8 @@ bool wxVideoXANIM::CollectInfo() xanimProcess = new wxVideoXANIMOutput; xanim_command = wxT("xanim +v +Zv -Ae "); xanim_command += m_filename; - if (!wxExecute(xanim_command, FALSE, xanimProcess)) - return FALSE; + if (!wxExecute(xanim_command, false, xanimProcess)) + return false; wxInputStream *infoStream = xanimProcess->GetInputStream(); wxString totalOutput; @@ -443,7 +443,7 @@ i = my_long; delete xanimProcess; - return TRUE; + return true; } bool wxVideoXANIM::RestartXANIM() @@ -458,10 +458,10 @@ bool wxVideoXANIM::RestartXANIM() bool xanim_chg_size; if (!m_video_output || m_xanim_started) - return FALSE; + return false; // Check if we can change the size of the window dynamicly - xanim_chg_size = TRUE; + xanim_chg_size = true; // Get current display #ifdef __WXGTK__ m_internal->xanim_dpy = gdk_display; @@ -472,27 +472,27 @@ bool wxVideoXANIM::RestartXANIM() #endif // Get the XANIM atom m_internal->xanim_atom = XInternAtom(m_internal->xanim_dpy, - "XANIM_PROPERTY", False); + "XANIM_PROPERTY", False); // Build the command xanim_command.Printf(wxT("xanim -Zr +Ze +Sr +f +W%d +f +q " - "+Av70 %s %s"), m_internal->xanim_window, - (xanim_chg_size) ? _T("") : _T(""), - WXSTRINGCAST m_filename); + "+Av70 %s %s"), m_internal->xanim_window, + (xanim_chg_size) ? _T("") : _T(""), + WXSTRINGCAST m_filename); // Execute it - if (!wxExecute(xanim_command, FALSE, m_xanim_detector)) - return FALSE; + if (!wxExecute(xanim_command, false, m_xanim_detector)) + return false; // Wait for XAnim to be ready nitems = 0; - m_xanim_started = TRUE; + m_xanim_started = true; while (nitems == 0 && m_xanim_started) { ret = XGetWindowProperty(m_internal->xanim_dpy, m_internal->xanim_window, - m_internal->xanim_atom, - 0, 4, False, AnyPropertyType, &prop_type, - &prop_format, &nitems, &extra, - (unsigned char **)&prop); + m_internal->xanim_atom, + 0, 4, False, AnyPropertyType, &prop_type, + &prop_format, &nitems, &extra, + (unsigned char **)&prop); wxYield(); } @@ -507,7 +507,7 @@ bool wxVideoXANIM::RestartXANIM() // Very useful ! Actually it "should" sends a SETSIZE event to XAnim // FIXME: This event is not sent !! - m_paused = FALSE; + m_paused = false; - return TRUE; + return true; } -- 2.45.2