media/libsoundtouch/src/STTypes.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:380616e3a76d
1 ////////////////////////////////////////////////////////////////////////////////
2 ///
3 /// Common type definitions for SoundTouch audio processing library.
4 ///
5 /// Author : Copyright (c) Olli Parviainen
6 /// Author e-mail : oparviai 'at' iki.fi
7 /// SoundTouch WWW: http://www.surina.net/soundtouch
8 ///
9 ////////////////////////////////////////////////////////////////////////////////
10 //
11 // Last changed : $Date: 2014-04-06 10:57:21 -0500 (Sun, 06 Apr 2014) $
12 // File revision : $Revision: 3 $
13 //
14 // $Id: STTypes.h 195 2014-04-06 15:57:21Z oparviai $
15 //
16 ////////////////////////////////////////////////////////////////////////////////
17 //
18 // License :
19 //
20 // SoundTouch audio processing library
21 // Copyright (c) Olli Parviainen
22 //
23 // This library is free software; you can redistribute it and/or
24 // modify it under the terms of the GNU Lesser General Public
25 // License as published by the Free Software Foundation; either
26 // version 2.1 of the License, or (at your option) any later version.
27 //
28 // This library is distributed in the hope that it will be useful,
29 // but WITHOUT ANY WARRANTY; without even the implied warranty of
30 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 // Lesser General Public License for more details.
32 //
33 // You should have received a copy of the GNU Lesser General Public
34 // License along with this library; if not, write to the Free Software
35 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 //
37 ////////////////////////////////////////////////////////////////////////////////
38
39 #ifndef STTypes_H
40 #define STTypes_H
41
42 typedef unsigned int uint;
43 typedef unsigned long ulong;
44
45 // Patch for MinGW: on Win64 long is 32-bit
46 #ifdef _WIN64
47 typedef unsigned long long ulongptr;
48 #else
49 typedef ulong ulongptr;
50 #endif
51
52
53 // Helper macro for aligning pointer up to next 16-byte boundary
54 #define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
55
56
57 #include "soundtouch_config.h"
58
59 #ifdef WIN32
60 #ifdef BUILDING_SOUNDTOUCH
61 #define EXPORT __declspec(dllexport)
62 #else
63 #define EXPORT __declspec(dllimport)
64 #endif
65 #else
66 #define EXPORT
67 #endif
68
69 namespace soundtouch
70 {
71 /// Activate these undef's to overrule the possible sampletype
72 /// setting inherited from some other header file:
73 //#undef SOUNDTOUCH_INTEGER_SAMPLES
74 //#undef SOUNDTOUCH_FLOAT_SAMPLES
75
76 /// If following flag is defined, always uses multichannel processing
77 /// routines also for mono and stero sound. This is for routine testing
78 /// purposes; output should be same with either routines, yet disabling
79 /// the dedicated mono/stereo processing routines will result in slower
80 /// runtime performance so recommendation is to keep this off.
81 // #define USE_MULTICH_ALWAYS
82
83 #if (defined(__SOFTFP__))
84 // For Android compilation: Force use of Integer samples in case that
85 // compilation uses soft-floating point emulation - soft-fp is way too slow
86 #undef SOUNDTOUCH_FLOAT_SAMPLES
87 #define SOUNDTOUCH_INTEGER_SAMPLES 1
88 #endif
89
90 #if !(SOUNDTOUCH_INTEGER_SAMPLES || SOUNDTOUCH_FLOAT_SAMPLES)
91
92 /// Choose either 32bit floating point or 16bit integer sampletype
93 /// by choosing one of the following defines, unless this selection
94 /// has already been done in some other file.
95 ////
96 /// Notes:
97 /// - In Windows environment, choose the sample format with the
98 /// following defines.
99 /// - In GNU environment, the floating point samples are used by
100 /// default, but integer samples can be chosen by giving the
101 /// following switch to the configure script:
102 /// ./configure --enable-integer-samples
103 /// However, if you still prefer to select the sample format here
104 /// also in GNU environment, then please #undef the INTEGER_SAMPLE
105 /// and FLOAT_SAMPLE defines first as in comments above.
106 //#define SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples
107 #define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples
108
109 #endif
110
111 #if (_M_IX86 || __i386__ || __x86_64__ || _M_X64)
112 /// Define this to allow X86-specific assembler/intrinsic optimizations.
113 /// Notice that library contains also usual C++ versions of each of these
114 /// these routines, so if you're having difficulties getting the optimized
115 /// routines compiled for whatever reason, you may disable these optimizations
116 /// to make the library compile.
117
118 #define SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS 1
119
120 /// In GNU environment, allow the user to override this setting by
121 /// giving the following switch to the configure script:
122 /// ./configure --disable-x86-optimizations
123 /// ./configure --enable-x86-optimizations=no
124 #ifdef SOUNDTOUCH_DISABLE_X86_OPTIMIZATIONS
125 #undef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
126 #endif
127 #else
128 /// Always disable optimizations when not using a x86 systems.
129 #undef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
130
131 #endif
132
133 // If defined, allows the SIMD-optimized routines to take minor shortcuts
134 // for improved performance. Undefine to require faithfully similar SIMD
135 // calculations as in normal C implementation.
136 #define SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION 1
137
138
139 #ifdef SOUNDTOUCH_INTEGER_SAMPLES
140 // 16bit integer sample type
141 typedef short SAMPLETYPE;
142 // data type for sample accumulation: Use 32bit integer to prevent overflows
143 typedef long LONG_SAMPLETYPE;
144
145 #ifdef SOUNDTOUCH_FLOAT_SAMPLES
146 // check that only one sample type is defined
147 #error "conflicting sample types defined"
148 #endif // SOUNDTOUCH_FLOAT_SAMPLES
149
150 #ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
151 // Allow MMX optimizations
152 #define SOUNDTOUCH_ALLOW_MMX 1
153 #endif
154
155 #else
156
157 // floating point samples
158 typedef float SAMPLETYPE;
159 // data type for sample accumulation: Use double to utilize full precision.
160 typedef double LONG_SAMPLETYPE;
161
162 #ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
163 // Allow SSE optimizations
164 #define SOUNDTOUCH_ALLOW_SSE 1
165 #endif
166
167 #endif // SOUNDTOUCH_INTEGER_SAMPLES
168
169 };
170
171 // define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
172 #define ST_NO_EXCEPTION_HANDLING 1
173 #ifdef ST_NO_EXCEPTION_HANDLING
174 // Exceptions disabled. Throw asserts instead if enabled.
175 #include <assert.h>
176 #define ST_THROW_RT_ERROR(x) {assert((const char *)x);}
177 #else
178 // use c++ standard exceptions
179 #include <stdexcept>
180 #define ST_THROW_RT_ERROR(x) {throw std::runtime_error(x);}
181 #endif
182
183 // When this #define is active, eliminates a clicking sound when the "rate" or "pitch"
184 // parameter setting crosses from value <1 to >=1 or vice versa during processing.
185 // Default is off as such crossover is untypical case and involves a slight sound
186 // quality compromise.
187 //#define SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER 1
188
189 #endif

mercurial