tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

STTypes.h (7222B)


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