1
0
mirror of https://github.com/RPCS3/soundtouch.git synced 2024-11-08 12:02:28 +01:00

use more specifically named global #defines

This commit is contained in:
oparviai 2011-02-13 19:13:57 +00:00
parent f3da7ef4ed
commit d002b52f2a
13 changed files with 773 additions and 864 deletions

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ dnl this program; if not, write to the Free Software Foundation, Inc., 59 Temple
dnl Place - Suite 330, Boston, MA 02111-1307, USA
# Process this file with autoconf to produce a configure script.
AC_INIT(SoundTouch, 1.5.0, [http://www.surina.net/soundtouch])
AC_INIT(SoundTouch, 1.6.0, [http://www.surina.net/soundtouch])
AC_CONFIG_AUX_DIR(config)
AM_CONFIG_HEADER([include/soundtouch_config.h])
AM_INIT_AUTOMAKE
@ -80,10 +80,10 @@ AC_ARG_ENABLE(integer-samples,
if test "x$enable_integer_samples" = "xyes"; then
echo "****** Integer sample type enabled ******"
AC_DEFINE(INTEGER_SAMPLES,1,[Use Integer as Sample type])
AC_DEFINE(SOUNDTOUCH_INTEGER_SAMPLES,1,[Use Integer as Sample type])
else
echo "****** Float sample type enabled ******"
AC_DEFINE(FLOAT_SAMPLES,1,[Use Float as Sample type])
AC_DEFINE(SOUNDTOUCH_FLOAT_SAMPLES,1,[Use Float as Sample type])
fi

View File

@ -63,10 +63,10 @@ namespace soundtouch
/// Activate these undef's to overrule the possible sampletype
/// setting inherited from some other header file:
//#undef INTEGER_SAMPLES
//#undef FLOAT_SAMPLES
//#undef SOUNDTOUCH_INTEGER_SAMPLES
//#undef SOUNDTOUCH_FLOAT_SAMPLES
#if !(INTEGER_SAMPLES || FLOAT_SAMPLES)
#if !(SOUNDTOUCH_INTEGER_SAMPLES || SOUNDTOUCH_FLOAT_SAMPLES)
/// Choose either 32bit floating point or 16bit integer sampletype
/// by choosing one of the following defines, unless this selection
@ -82,8 +82,8 @@ namespace soundtouch
/// However, if you still prefer to select the sample format here
/// also in GNU environment, then please #undef the INTEGER_SAMPLE
/// and FLOAT_SAMPLE defines first as in comments above.
//#define INTEGER_SAMPLES 1 //< 16bit integer samples
#define FLOAT_SAMPLES 1 //< 32bit float samples
//#define SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples
#define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples
#endif
@ -94,30 +94,30 @@ namespace soundtouch
/// routines compiled for whatever reason, you may disable these optimizations
/// to make the library compile.
#define ALLOW_X86_OPTIMIZATIONS 1
#define SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS 1
#endif
// If defined, allows the SIMD-optimized routines to take minor shortcuts
// for improved performance. Undefine to require faithfully similar SIMD
// calculations as in normal C implementation.
#define ALLOW_NONEXACT_SIMD_OPTIMIZATION 1
#define SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION 1
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
// 16bit integer sample type
typedef short SAMPLETYPE;
// data type for sample accumulation: Use 32bit integer to prevent overflows
typedef long LONG_SAMPLETYPE;
#ifdef FLOAT_SAMPLES
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
// check that only one sample type is defined
#error "conflicting sample types defined"
#endif // FLOAT_SAMPLES
#endif // SOUNDTOUCH_FLOAT_SAMPLES
#ifdef ALLOW_X86_OPTIMIZATIONS
#ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
// Allow MMX optimizations
#define ALLOW_MMX 1
#define SOUNDTOUCH_ALLOW_MMX 1
#endif
#else
@ -127,12 +127,12 @@ namespace soundtouch
// data type for sample accumulation: Use double to utilize full precision.
typedef double LONG_SAMPLETYPE;
#ifdef ALLOW_X86_OPTIMIZATIONS
#ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
// Allow SSE optimizations
#define ALLOW_SSE 1
#define SOUNDTOUCH_ALLOW_SSE 1
#endif
#endif // INTEGER_SAMPLES
#endif // SOUNDTOUCH_INTEGER_SAMPLES
};
@ -140,6 +140,6 @@ namespace soundtouch
// parameter setting crosses from value <1 to >=1 or vice versa during processing.
// Default is off as such crossover is untypical case and involves a slight sound
// quality compromise.
//#define PREVENT_CLICK_AT_RATE_CROSSOVER 1
//#define SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER 1
#endif

View File

@ -146,10 +146,10 @@ static void setup(SoundTouch *pSoundTouch, const WavInFile *inFile, const RunPar
// print processing information
if (params->outFileName)
{
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
fprintf(stderr, "Uses 16bit integer sample type in processing.\n\n");
#else
#ifndef FLOAT_SAMPLES
#ifndef SOUNDTOUCH_FLOAT_SAMPLES
#error "Sampletype not defined"
#endif
fprintf(stderr, "Uses 32bit floating point sample type in processing.\n\n");

View File

@ -88,7 +88,7 @@ BPMDetect::BPMDetect(int numChannels, int aSampleRate)
// Initialize RMS volume accumulator to RMS level of 3000 (out of 32768) that's
// a typical RMS signal level value for song data. This value is then adapted
// to the actual level during processing.
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
// integer samples
RMSVolumeAccu = (3000 * 3000) / avgnorm;
#else
@ -169,7 +169,7 @@ int BPMDetect::decimate(SAMPLETYPE *dest, const SAMPLETYPE *src, int numsamples)
out = (LONG_SAMPLETYPE)(decimateSum / (decimateBy * channels));
decimateSum = 0;
decimateCount = 0;
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
// check ranges for sure (shouldn't actually be necessary)
if (out > 32767)
{
@ -179,7 +179,7 @@ int BPMDetect::decimate(SAMPLETYPE *dest, const SAMPLETYPE *src, int numsamples)
{
out = -32768;
}
#endif // INTEGER_SAMPLES
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[outcount] = (SAMPLETYPE)out;
outcount ++;
}
@ -268,10 +268,10 @@ void BPMDetect::calcEnvelope(SAMPLETYPE *samples, int numsamples)
envelopeAccu += val;
out = (LONG_SAMPLETYPE)(envelopeAccu * norm);
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
// cut peaks (shouldn't be necessary though)
if (out > 32767) out = 32767;
#endif // INTEGER_SAMPLES
#endif // SOUNDTOUCH_INTEGER_SAMPLES
samples[i] = (SAMPLETYPE)out;
}

View File

@ -75,7 +75,7 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
{
uint i, j, end;
LONG_SAMPLETYPE suml, sumr;
#ifdef FLOAT_SAMPLES
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
// when using floating point samples, use a scaler instead of a divider
// because division is much slower operation than multiplying.
double dScaler = 1.0 / (double)resultDivider;
@ -108,7 +108,7 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
ptr[2 * i + 7] * filterCoeffs[i + 3];
}
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
suml >>= resultDivFactor;
sumr >>= resultDivFactor;
// saturate to 16 bit integer limits
@ -118,7 +118,7 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
#else
suml *= dScaler;
sumr *= dScaler;
#endif // INTEGER_SAMPLES
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[j] = (SAMPLETYPE)suml;
dest[j + 1] = (SAMPLETYPE)sumr;
}
@ -133,7 +133,7 @@ uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint
{
uint i, j, end;
LONG_SAMPLETYPE sum;
#ifdef FLOAT_SAMPLES
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
// when using floating point samples, use a scaler instead of a divider
// because division is much slower operation than multiplying.
double dScaler = 1.0 / (double)resultDivider;
@ -154,13 +154,13 @@ uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint
src[i + 2] * filterCoeffs[i + 2] +
src[i + 3] * filterCoeffs[i + 3];
}
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
sum >>= resultDivFactor;
// saturate to 16 bit integer limits
sum = (sum < -32768) ? -32768 : (sum > 32767) ? 32767 : sum;
#else
sum *= dScaler;
#endif // INTEGER_SAMPLES
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[j] = (SAMPLETYPE)sum;
src ++;
}
@ -235,23 +235,23 @@ FIRFilter * FIRFilter::newInstance()
// Check if MMX/SSE instruction set extensions supported by CPU
#ifdef ALLOW_MMX
#ifdef SOUNDTOUCH_ALLOW_MMX
// MMX routines available only with integer sample types
if (uExtensions & SUPPORT_MMX)
{
return ::new FIRFilterMMX;
}
else
#endif // ALLOW_MMX
#endif // SOUNDTOUCH_ALLOW_MMX
#ifdef ALLOW_SSE
#ifdef SOUNDTOUCH_ALLOW_SSE
if (uExtensions & SUPPORT_SSE)
{
// SSE support
return ::new FIRFilterSSE;
}
else
#endif // ALLOW_SSE
#endif // SOUNDTOUCH_ALLOW_SSE
{
// ISA optimizations not supported, use plain C version

View File

@ -102,7 +102,7 @@ public:
// Optional subclasses that implement CPU-specific optimizations:
#ifdef ALLOW_MMX
#ifdef SOUNDTOUCH_ALLOW_MMX
/// Class that implements MMX optimized functions exclusive for 16bit integer samples type.
class FIRFilterMMX : public FIRFilter
@ -119,10 +119,10 @@ public:
virtual void setCoefficients(const short *coeffs, uint newLength, uint uResultDivFactor);
};
#endif // ALLOW_MMX
#endif // SOUNDTOUCH_ALLOW_MMX
#ifdef ALLOW_SSE
#ifdef SOUNDTOUCH_ALLOW_SSE
/// Class that implements SSE optimized functions exclusive for floating point samples type.
class FIRFilterSSE : public FIRFilter
{
@ -138,7 +138,7 @@ public:
virtual void setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor);
};
#endif // ALLOW_SSE
#endif // SOUNDTOUCH_ALLOW_SSE
}

View File

@ -115,7 +115,7 @@ void * RateTransposer::operator new(size_t s)
RateTransposer *RateTransposer::newInstance()
{
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
return ::new RateTransposerInteger;
#else
return ::new RateTransposerFloat;

View File

@ -243,7 +243,7 @@ void SoundTouch::calcEffectiveRateAndTempo()
if (!TEST_FLOAT_EQUAL(rate,oldRate)) pRateTransposer->setRate(rate);
if (!TEST_FLOAT_EQUAL(tempo, oldTempo)) pTDStretch->setTempo(tempo);
#ifndef PREVENT_CLICK_AT_RATE_CROSSOVER
#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
if (rate <= 1.0f)
{
if (output != pTDStretch)
@ -317,7 +317,7 @@ void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
pTDStretch->putSamples(samples, nSamples);
}
*/
#ifndef PREVENT_CLICK_AT_RATE_CROSSOVER
#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
else if (rate <= 1.0f)
{
// transpose the rate down, output the transposed sound to tempo changer buffer

View File

@ -744,24 +744,24 @@ TDStretch * TDStretch::newInstance()
// Check if MMX/SSE instruction set extensions supported by CPU
#ifdef ALLOW_MMX
#ifdef SOUNDTOUCH_ALLOW_MMX
// MMX routines available only with integer sample types
if (uExtensions & SUPPORT_MMX)
{
return ::new TDStretchMMX;
}
else
#endif // ALLOW_MMX
#endif // SOUNDTOUCH_ALLOW_MMX
#ifdef ALLOW_SSE
#ifdef SOUNDTOUCH_ALLOW_SSE
if (uExtensions & SUPPORT_SSE)
{
// SSE support
return ::new TDStretchSSE;
}
else
#endif // ALLOW_SSE
#endif // SOUNDTOUCH_ALLOW_SSE
{
// ISA optimizations not supported, use plain C version
@ -776,7 +776,7 @@ TDStretch * TDStretch::newInstance()
//
//////////////////////////////////////////////////////////////////////////////
#ifdef INTEGER_SAMPLES
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
// Slopes the amplitude of the 'midBuffer' samples so that cross correlation
// is faster to calculate
@ -905,14 +905,14 @@ long TDStretch::calcCrossCorrStereo(const short *mixingPos, const short *compare
return (long)((double)corr * SHRT_MAX / sqrt((double)norm));
}
#endif // INTEGER_SAMPLES
#endif // SOUNDTOUCH_INTEGER_SAMPLES
//////////////////////////////////////////////////////////////////////////////
//
// Floating point arithmetics specific algorithm implementations.
//
#ifdef FLOAT_SAMPLES
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
// Slopes the amplitude of the 'midBuffer' samples so that cross correlation
@ -1023,4 +1023,4 @@ double TDStretch::calcCrossCorrStereo(const float *mixingPos, const float *compa
return corr / sqrt(norm);
}
#endif // FLOAT_SAMPLES
#endif // SOUNDTOUCH_FLOAT_SAMPLES

View File

@ -251,7 +251,7 @@ public:
// Implementation-specific class declarations:
#ifdef ALLOW_MMX
#ifdef SOUNDTOUCH_ALLOW_MMX
/// Class that implements MMX optimized routines for 16bit integer samples type.
class TDStretchMMX : public TDStretch
{
@ -260,10 +260,10 @@ public:
virtual void overlapStereo(short *output, const short *input) const;
virtual void clearCrossCorrState();
};
#endif /// ALLOW_MMX
#endif /// SOUNDTOUCH_ALLOW_MMX
#ifdef ALLOW_SSE
#ifdef SOUNDTOUCH_ALLOW_SSE
/// Class that implements SSE optimized routines for floating point samples type.
class TDStretchSSE : public TDStretch
{
@ -271,7 +271,7 @@ public:
double calcCrossCorrStereo(const float *mixingPos, const float *compare) const;
};
#endif /// ALLOW_SSE
#endif /// SOUNDTOUCH_ALLOW_SSE
}
#endif /// TDStretch_H

View File

@ -50,7 +50,7 @@
#include "STTypes.h"
#ifdef ALLOW_MMX
#ifdef SOUNDTOUCH_ALLOW_MMX
// MMX routines available only with integer sample type
#if !(WIN32 || __i386__ || __x86_64__)
@ -317,4 +317,4 @@ uint FIRFilterMMX::evaluateFilterStereo(short *dest, const short *src, uint numS
return (numSamples & 0xfffffffe) - length;
}
#endif // ALLOW_MMX
#endif // SOUNDTOUCH_ALLOW_MMX

View File

@ -56,7 +56,7 @@
using namespace soundtouch;
#ifdef ALLOW_SSE
#ifdef SOUNDTOUCH_ALLOW_SSE
// SSE routines available only with float sample type
@ -84,10 +84,10 @@ double TDStretchSSE::calcCrossCorrStereo(const float *pV1, const float *pV2) con
// This can mean up to ~ 10-fold difference (incl. part of which is
// due to skipping every second round for stereo sound though).
//
// Compile-time define ALLOW_NONEXACT_SIMD_OPTIMIZATION is provided
// Compile-time define SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION is provided
// for choosing if this little cheating is allowed.
#ifdef ALLOW_NONEXACT_SIMD_OPTIMIZATION
#ifdef SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION
// Little cheating allowed, return valid correlation only for
// aligned locations, meaning every second round for stereo sound.
@ -507,4 +507,4 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n
*/
}
#endif // ALLOW_SSE
#endif // SOUNDTOUCH_ALLOW_SSE