media/libsoundtouch/src/STTypes.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial