Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2011-05-03 18:00:27 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2011-05-03 18:00:27 +0400
commita283669d90fd4766dffe734be5a5998b7e57c52d (patch)
treec06d02db50103d89fbaa7837f0d8c2fc59f829cd /src/filters/renderer/MpcAudioRenderer/SoundTouch
parenta10493b2eedbed40b0ca028d7b512dabca84556a (diff)
legacy branch: merge r2857-r3069 from trunk
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/branches/legacy@3070 10f7b99b-c216-0410-bff0-8a66a9350fd8
Diffstat (limited to 'src/filters/renderer/MpcAudioRenderer/SoundTouch')
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/BPMDetect.h17
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSampleBuffer.h4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSamplePipe.h4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/STTypes.h44
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/SoundTouch.h33
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp349
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.cpp4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.h4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/BPMDetect.cpp61
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIFOSampleBuffer.cpp4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp41
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.h31
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.cpp6
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.h4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp16
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.h4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/SoundTouch.cpp16
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp53
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.h34
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect.h4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp4
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp10
-rw-r--r--src/filters/renderer/MpcAudioRenderer/SoundTouch/source/sse_optimized.cpp14
23 files changed, 217 insertions, 544 deletions
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/BPMDetect.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/BPMDetect.h
index 4def43f1e..ff1d3c44f 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/BPMDetect.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/BPMDetect.h
@@ -26,10 +26,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: BPMDetect.h 63 2009-02-21 16:00:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -78,10 +78,19 @@ protected:
float *xcorr;
/// Amplitude envelope sliding average approximation level accumulator
- float envelopeAccu;
+ double envelopeAccu;
/// RMS volume sliding average approximation level accumulator
- float RMSVolumeAccu;
+ double RMSVolumeAccu;
+
+ /// Level below which to cut off signals
+ double cutCoeff;
+
+ /// Accumulator for accounting what proportion of samples exceed cutCoeff level
+ double aboveCutAccu;
+
+ /// Accumulator for total samples to calculate proportion of samples that exceed cutCoeff level
+ double totalAccu;
/// Sample average counter.
int decimateCount;
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSampleBuffer.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSampleBuffer.h
index 76cbf9514..e69918ac2 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSampleBuffer.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSampleBuffer.h
@@ -15,10 +15,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: FIFOSampleBuffer.h 63 2009-02-21 16:00:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSamplePipe.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSamplePipe.h
index b5fc3b779..ad982cbba 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSamplePipe.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/FIFOSamplePipe.h
@@ -17,10 +17,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-04-13 16:18:48 +0300 (Mon, 13 Apr 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: FIFOSamplePipe.h 69 2009-04-13 13:18:48Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/STTypes.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/STTypes.h
index cad502ffa..98186a552 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/STTypes.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/STTypes.h
@@ -8,10 +8,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-05-17 14:30:57 +0300 (Sun, 17 May 2009) $
+// Last changed : $Date$
// File revision : $Revision: 3 $
//
-// $Id: STTypes.h 70 2009-05-17 11:30:57Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -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,42 +82,42 @@ 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
- #ifndef _WIN64
+ #ifndef _WIN64 //mpc custom code
/// Define this to allow X86-specific assembler/intrinsic optimizations.
/// Notice that library contains also usual C++ versions of each of these
/// these routines, so if you're having difficulties getting the optimized
/// 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,16 +127,12 @@ namespace soundtouch
// data type for sample accumulation: Use double to utilize full precision.
typedef double LONG_SAMPLETYPE;
- #ifdef ALLOW_X86_OPTIMIZATIONS
- // Allow 3DNow! and SSE optimizations
- #if WIN32
- #define ALLOW_3DNOW 1
- #endif
-
- #define ALLOW_SSE 1
+ #ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
+ // Allow SSE optimizations
+ #define SOUNDTOUCH_ALLOW_SSE 1
#endif
- #endif // INTEGER_SAMPLES
+ #endif // SOUNDTOUCH_INTEGER_SAMPLES
};
@@ -144,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
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/SoundTouch.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/SoundTouch.h
index 0e042d3c0..203d84fc4 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/SoundTouch.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/Include/SoundTouch.h
@@ -41,10 +41,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-12-28 22:10:14 +0200 (Mon, 28 Dec 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: SoundTouch.h 78 2009-12-28 20:10:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -79,10 +79,10 @@ namespace soundtouch
{
/// Soundtouch library version string
-#define SOUNDTOUCH_VERSION "1.5.0"
+#define SOUNDTOUCH_VERSION "1.5.1pre"
/// SoundTouch library version id
-#define SOUNDTOUCH_VERSION_ID (10500)
+#define SOUNDTOUCH_VERSION_ID (10509)
//
// Available setting IDs for the 'setSetting' & 'get_setting' functions:
@@ -116,6 +116,31 @@ namespace soundtouch
#define SETTING_OVERLAP_MS 5
+/// Call "getSetting" with this ID to query nominal average processing sequence
+/// size in samples. This value tells approcimate value how many input samples
+/// SoundTouch needs to gather before it does DSP processing run for the sample batch.
+///
+/// Notices:
+/// - This is read-only parameter, i.e. setSetting ignores this parameter
+/// - Returned value is approximate average value, exact processing batch
+/// size may wary from time to time
+/// - This parameter value is not constant but may change depending on
+/// tempo/pitch/rate/samplerate settings.
+#define SETTING_NOMINAL_INPUT_SEQUENCE 6
+
+
+/// Call "getSetting" with this ID to query nominal average processing output
+/// size in samples. This value tells approcimate value how many output samples
+/// SoundTouch outputs once it does DSP processing run for a batch of input samples.
+///
+/// Notices:
+/// - This is read-only parameter, i.e. setSetting ignores this parameter
+/// - Returned value is approximate average value, exact processing batch
+/// size may wary from time to time
+/// - This parameter value is not constant but may change depending on
+/// tempo/pitch/rate/samplerate settings.
+#define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
+
class SoundTouch : public FIFOProcessor
{
private:
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp
deleted file mode 100644
index f0a9d7ecc..000000000
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/3dnow_win.cpp
+++ /dev/null
@@ -1,349 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-///
-/// Win32 version of the AMD 3DNow! optimized routines for AMD K6-2/Athlon
-/// processors. All 3DNow! optimized functions have been gathered into this
-/// single source code file, regardless to their class or original source code
-/// file, in order to ease porting the library to other compiler and processor
-/// platforms.
-///
-/// By the way; the performance gain depends heavily on the CPU generation: On
-/// K6-2 these routines provided speed-up of even 2.4 times, while on Athlon the
-/// difference to the original routines stayed at unremarkable 8%! Such a small
-/// improvement on Athlon is due to 3DNow can perform only two operations in
-/// parallel, and obviously also the Athlon FPU is doing a very good job with
-/// the standard C floating point routines! Here these routines are anyway,
-/// although it might not be worth the effort to convert these to GCC platform,
-/// for Athlon CPU at least. The situation is different regarding the SSE
-/// optimizations though, thanks to the four parallel operations of SSE that
-/// already make a difference.
-///
-/// This file is to be compiled in Windows platform with Microsoft Visual C++
-/// Compiler. Please see '3dnow_gcc.cpp' for the gcc compiler version for all
-/// GNU platforms (if file supplied).
-///
-/// NOTICE: If using Visual Studio 6.0, you'll need to install the "Visual C++
-/// 6.0 processor pack" update to support 3DNow! instruction set. The update is
-/// available for download at Microsoft Developers Network, see here:
-/// http://msdn.microsoft.com/en-us/vstudio/aa718349.aspx
-///
-/// If the above URL is expired or removed, go to "http://msdn.microsoft.com" and
-/// perform a search with keywords "processor pack".
-///
-/// Author : Copyright (c) Olli Parviainen
-/// Author e-mail : oparviai 'at' iki.fi
-/// SoundTouch WWW: http://www.surina.net/soundtouch
-///
-////////////////////////////////////////////////////////////////////////////////
-//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
-// File revision : $Revision: 4 $
-//
-// $Id: 3dnow_win.cpp 63 2009-02-21 16:00:14Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
-// License :
-//
-// SoundTouch audio processing library
-// Copyright (c) Olli Parviainen
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-////////////////////////////////////////////////////////////////////////////////
-
-#include "cpu_detect.h"
-#include "STTypes.h"
-
-#ifndef WIN32
-#error "wrong platform - this source code file is exclusively for Win32 platform"
-#endif
-
-using namespace soundtouch;
-
-#ifdef ALLOW_3DNOW
-// 3DNow! routines available only with float sample type
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// implementation of 3DNow! optimized functions of class 'TDStretch3DNow'
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include "TDStretch.h"
-
-
-// Calculates cross correlation of two buffers
-double TDStretch3DNow::calcCrossCorrStereo(const float *pV1, const float *pV2) const
-{
- int overlapLengthLocal = overlapLength;
- float corr = 0;
-
- // Calculates the cross-correlation value between 'pV1' and 'pV2' vectors
- /*
- c-pseudocode:
-
- corr = 0;
- for (i = 0; i < overlapLength / 4; i ++)
- {
- corr += pV1[0] * pV2[0];
- pV1[1] * pV2[1];
- pV1[2] * pV2[2];
- pV1[3] * pV2[3];
- pV1[4] * pV2[4];
- pV1[5] * pV2[5];
- pV1[6] * pV2[6];
- pV1[7] * pV2[7];
-
- pV1 += 8;
- pV2 += 8;
- }
- */
-
- _asm
- {
- // give prefetch hints to CPU of what data are to be needed soonish.
- // give more aggressive hints on pV1 as that changes more between different calls
- // while pV2 stays the same.
- prefetch [pV1]
- prefetch [pV2]
- prefetch [pV1 + 32]
-
- mov eax, dword ptr pV2
- mov ebx, dword ptr pV1
-
- pxor mm0, mm0
-
- mov ecx, overlapLengthLocal
- shr ecx, 2 // div by four
-
- loop1:
- movq mm1, [eax]
- prefetch [eax + 32] // give a prefetch hint to CPU what data are to be needed soonish
- pfmul mm1, [ebx]
- prefetch [ebx + 64] // give a prefetch hint to CPU what data are to be needed soonish
-
- movq mm2, [eax + 8]
- pfadd mm0, mm1
- pfmul mm2, [ebx + 8]
-
- movq mm3, [eax + 16]
- pfadd mm0, mm2
- pfmul mm3, [ebx + 16]
-
- movq mm4, [eax + 24]
- pfadd mm0, mm3
- pfmul mm4, [ebx + 24]
-
- add eax, 32
- pfadd mm0, mm4
- add ebx, 32
-
- dec ecx
- jnz loop1
-
- // add halfs of mm0 together and return the result.
- // note: mm1 is used as a dummy parameter only, we actually don't care about it's value
- pfacc mm0, mm1
- movd corr, mm0
- femms
- }
-
- return corr;
-}
-
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-//
-// implementation of 3DNow! optimized functions of class 'FIRFilter'
-//
-//////////////////////////////////////////////////////////////////////////////
-
-#include "FIRFilter.h"
-
-FIRFilter3DNow::FIRFilter3DNow() : FIRFilter()
-{
- filterCoeffsUnalign = NULL;
- filterCoeffsAlign = NULL;
-}
-
-
-FIRFilter3DNow::~FIRFilter3DNow()
-{
- delete[] filterCoeffsUnalign;
- filterCoeffsUnalign = NULL;
- filterCoeffsAlign = NULL;
-}
-
-
-// (overloaded) Calculates filter coefficients for 3DNow! routine
-void FIRFilter3DNow::setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor)
-{
- uint i;
- float fDivider;
-
- FIRFilter::setCoefficients(coeffs, newLength, uResultDivFactor);
-
- // Scale the filter coefficients so that it won't be necessary to scale the filtering result
- // also rearrange coefficients suitably for 3DNow!
- // Ensure that filter coeffs array is aligned to 16-byte boundary
- delete[] filterCoeffsUnalign;
- filterCoeffsUnalign = new float[2 * newLength + 4];
- filterCoeffsAlign = (float *)(((uint)filterCoeffsUnalign + 15) & (uint)-16);
-
- fDivider = (float)resultDivider;
-
- // rearrange the filter coefficients for mmx routines
- for (i = 0; i < newLength; i ++)
- {
- filterCoeffsAlign[2 * i + 0] =
- filterCoeffsAlign[2 * i + 1] = coeffs[i + 0] / fDivider;
- }
-}
-
-
-// 3DNow!-optimized version of the filter routine for stereo sound
-uint FIRFilter3DNow::evaluateFilterStereo(float *dest, const float *src, uint numSamples) const
-{
- float *filterCoeffsLocal = filterCoeffsAlign;
- uint count = (numSamples - length) & (uint)-2;
- uint lengthLocal = length / 4;
-
- assert(length != 0);
- assert(count % 2 == 0);
-
- /* original code:
-
- double suml1, suml2;
- double sumr1, sumr2;
- uint i, j;
-
- for (j = 0; j < count; j += 2)
- {
- const float *ptr;
-
- suml1 = sumr1 = 0.0;
- suml2 = sumr2 = 0.0;
- ptr = src;
- filterCoeffsLocal = filterCoeffs;
- for (i = 0; i < lengthLocal; i ++)
- {
- // unroll loop for efficiency.
-
- suml1 += ptr[0] * filterCoeffsLocal[0] +
- ptr[2] * filterCoeffsLocal[2] +
- ptr[4] * filterCoeffsLocal[4] +
- ptr[6] * filterCoeffsLocal[6];
-
- sumr1 += ptr[1] * filterCoeffsLocal[1] +
- ptr[3] * filterCoeffsLocal[3] +
- ptr[5] * filterCoeffsLocal[5] +
- ptr[7] * filterCoeffsLocal[7];
-
- suml2 += ptr[8] * filterCoeffsLocal[0] +
- ptr[10] * filterCoeffsLocal[2] +
- ptr[12] * filterCoeffsLocal[4] +
- ptr[14] * filterCoeffsLocal[6];
-
- sumr2 += ptr[9] * filterCoeffsLocal[1] +
- ptr[11] * filterCoeffsLocal[3] +
- ptr[13] * filterCoeffsLocal[5] +
- ptr[15] * filterCoeffsLocal[7];
-
- ptr += 16;
- filterCoeffsLocal += 8;
- }
- dest[0] = (float)suml1;
- dest[1] = (float)sumr1;
- dest[2] = (float)suml2;
- dest[3] = (float)sumr2;
-
- src += 4;
- dest += 4;
- }
-
- */
- _asm
- {
- mov eax, dword ptr dest
- mov ebx, dword ptr src
- mov edx, count
- shr edx, 1
-
- loop1:
- // "outer loop" : during each round 2*2 output samples are calculated
- prefetch [ebx] // give a prefetch hint to CPU what data are to be needed soonish
- prefetch [filterCoeffsLocal] // give a prefetch hint to CPU what data are to be needed soonish
-
- mov esi, ebx
- mov edi, filterCoeffsLocal
- pxor mm0, mm0
- pxor mm1, mm1
- mov ecx, lengthLocal
-
- loop2:
- // "inner loop" : during each round four FIR filter taps are evaluated for 2*2 output samples
- movq mm2, [edi]
- movq mm3, mm2
- prefetch [edi + 32] // give a prefetch hint to CPU what data are to be needed soonish
- pfmul mm2, [esi]
- prefetch [esi + 32] // give a prefetch hint to CPU what data are to be needed soonish
- pfmul mm3, [esi + 8]
-
- movq mm4, [edi + 8]
- movq mm5, mm4
- pfadd mm0, mm2
- pfmul mm4, [esi + 8]
- pfadd mm1, mm3
- pfmul mm5, [esi + 16]
-
- movq mm2, [edi + 16]
- movq mm6, mm2
- pfadd mm0, mm4
- pfmul mm2, [esi + 16]
- pfadd mm1, mm5
- pfmul mm6, [esi + 24]
-
- movq mm3, [edi + 24]
- movq mm7, mm3
- pfadd mm0, mm2
- pfmul mm3, [esi + 24]
- pfadd mm1, mm6
- pfmul mm7, [esi + 32]
- add esi, 32
- pfadd mm0, mm3
- add edi, 32
- pfadd mm1, mm7
-
- dec ecx
- jnz loop2
-
- movq [eax], mm0
- add ebx, 16
- movq [eax + 8], mm1
- add eax, 16
-
- dec edx
- jnz loop1
-
- femms
- }
-
- return count;
-}
-
-
-#endif // ALLOW_3DNOW
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.cpp
index 96abda49c..191b97b13 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.cpp
@@ -12,10 +12,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-01-11 13:34:24 +0200 (Sun, 11 Jan 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: AAFilter.cpp 45 2009-01-11 11:34:24Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.h
index d5c8ce4ca..0ab97dde1 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/AAFilter.h
@@ -13,10 +13,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: AAFilter.h 11 2008-02-10 16:26:55Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/BPMDetect.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/BPMDetect.cpp
index 405f514bf..4faa29409 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/BPMDetect.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/BPMDetect.cpp
@@ -26,10 +26,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: BPMDetect.cpp 63 2009-02-21 16:00:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -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
@@ -96,6 +96,10 @@ BPMDetect::BPMDetect(int numChannels, int aSampleRate)
RMSVolumeAccu = (0.092f * 0.092f) / avgnorm;
#endif
+ cutCoeff = 1.75;
+ aboveCutAccu = 0;
+ totalAccu = 0;
+
// choose decimation factor so that result is approx. 500 Hz
decimateBy = sampleRate / 500;
assert(decimateBy > 0);
@@ -165,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)
{
@@ -175,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 ++;
}
@@ -215,16 +219,15 @@ void BPMDetect::updateXCorr(int process_samples)
}
-
// Calculates envelope of the sample data
void BPMDetect::calcEnvelope(SAMPLETYPE *samples, int numsamples)
{
- const float decay = 0.7f; // decay constant for smoothing the envelope
- const float norm = (1 - decay);
+ const static double decay = 0.7f; // decay constant for smoothing the envelope
+ const static double norm = (1 - decay);
int i;
LONG_SAMPLETYPE out;
- float val;
+ double val;
for (i = 0; i < numsamples; i ++)
{
@@ -233,22 +236,50 @@ void BPMDetect::calcEnvelope(SAMPLETYPE *samples, int numsamples)
val = (float)fabs((float)samples[i]);
RMSVolumeAccu += val * val;
- // cut amplitudes that are below 2 times average RMS volume
+ // cut amplitudes that are below cutoff ~2 times RMS volume
// (we're interested in peak values, not the silent moments)
- val -= 2 * (float)sqrt(RMSVolumeAccu * avgnorm);
- val = (val > 0) ? val : 0;
+ val -= cutCoeff * sqrt(RMSVolumeAccu * avgnorm);
+ if (val > 0)
+ {
+ aboveCutAccu += 1.0; // sample above threshold
+ }
+ else
+ {
+ val = 0;
+ }
+
+ totalAccu += 1.0;
+
+ // maintain sliding statistic what proportion of 'val' samples is
+ // above cutoff threshold
+ aboveCutAccu *= 0.99931; // 2 sec time constant
+ totalAccu *= 0.99931;
+
+ if (totalAccu > 500)
+ {
+ // after initial settling, auto-adjust cutoff level so that ~8% of
+ // values are above the threshold
+ double d = (aboveCutAccu / totalAccu) - 0.08;
+ cutCoeff += 0.001 * d;
+ }
// smooth amplitude envelope
envelopeAccu *= decay;
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;
}
+
+ // check that cutoff doesn't get too small - it can be just silent sequence!
+ if (cutCoeff < 1.5)
+ {
+ cutCoeff = 1.5;
+ }
}
@@ -301,7 +332,7 @@ float BPMDetect::getBpm()
peakPos = peakFinder.detectPeak(xcorr, windowStart, windowLen);
assert(decimateBy != 0);
- if (peakPos < 1e-6) return 0.0; // detection failed.
+ if (peakPos < 1e-9) return 0.0; // detection failed.
// calculate BPM
return (float)(60.0 * (((double)sampleRate / (double)decimateBy) / peakPos));
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIFOSampleBuffer.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIFOSampleBuffer.cpp
index 01f64b083..8393f7b0d 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIFOSampleBuffer.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIFOSampleBuffer.cpp
@@ -15,10 +15,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-27 19:24:42 +0200 (Fri, 27 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: FIFOSampleBuffer.cpp 68 2009-02-27 17:24:42Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp
index f17d997ed..161d68516 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.cpp
@@ -11,10 +11,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-25 19:13:51 +0200 (Wed, 25 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: FIRFilter.cpp 67 2009-02-25 17:13:51Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -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 ++;
}
@@ -219,7 +219,7 @@ uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSample
// Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX-capable CPU available or not.
-void * FIRFilter::operator new(size_t /*s*/)
+void * FIRFilter::operator new(size_t s)
{
// Notice! don't use "new FIRFilter" directly, use "newInstance" to create a new instance instead!
throw std::runtime_error("Error in FIRFilter::new: Don't use 'new FIRFilter', use 'newInstance' member instead!");
@@ -229,41 +229,32 @@ void * FIRFilter::operator new(size_t /*s*/)
FIRFilter * FIRFilter::newInstance()
{
-#ifndef _WIN64
+#ifndef _WIN64 //mpc custom code
uint uExtensions;
uExtensions = detectCPUextensions();
- // Check if MMX/SSE/3DNow! instruction set extensions supported by CPU
+ // 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
-#ifdef ALLOW_3DNOW
- if (uExtensions & SUPPORT_3DNOW)
- {
- // 3DNow! support
- return ::new FIRFilter3DNow;
- }
- else
-#endif // ALLOW_3DNOW
-
-#endif // _WIN64
+#endif // _WIN64 mpc custom code
{
// ISA optimizations not supported, use plain C version
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.h
index 5713f7bb2..fcee72ac1 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/FIRFilter.h
@@ -11,10 +11,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: FIRFilter.h 63 2009-02-21 16:00:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -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,29 +119,10 @@ public:
virtual void setCoefficients(const short *coeffs, uint newLength, uint uResultDivFactor);
};
-#endif // ALLOW_MMX
+#endif // SOUNDTOUCH_ALLOW_MMX
-#ifdef ALLOW_3DNOW
-
- /// Class that implements 3DNow! optimized functions exclusive for floating point samples type.
- class FIRFilter3DNow : public FIRFilter
- {
- protected:
- float *filterCoeffsUnalign;
- float *filterCoeffsAlign;
-
- virtual uint evaluateFilterStereo(float *dest, const float *src, uint numSamples) const;
- public:
- FIRFilter3DNow();
- ~FIRFilter3DNow();
- virtual void setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor);
- };
-
-#endif // ALLOW_3DNOW
-
-
-#ifdef ALLOW_SSE
+#ifdef SOUNDTOUCH_ALLOW_SSE
/// Class that implements SSE optimized functions exclusive for floating point samples type.
class FIRFilterSSE : public FIRFilter
{
@@ -157,7 +138,7 @@ public:
virtual void setCoefficients(const float *coeffs, uint newLength, uint uResultDivFactor);
};
-#endif // ALLOW_SSE
+#endif // SOUNDTOUCH_ALLOW_SSE
}
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.cpp
index 03f60bfa9..9ad601cd9 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.cpp
@@ -11,10 +11,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: PeakFinder.cpp 63 2009-02-21 16:00:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -164,7 +164,7 @@ double PeakFinder::getPeakCenter(const float *data, int peakpos) const
groundLevel = max(data[gp1], data[gp2]);
peakLevel = data[peakpos];
- if (groundLevel < 1e-6) return 0; // ground level too small => detection failed
+ if (groundLevel < 1e-9) return 0; // ground level too small => detection failed
if ((peakLevel / groundLevel) < 1.3) return 0; // peak less than 30% of the ground level => no good peak detected
// calculate 70%-level of the peak
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.h
index e3640cc6d..a72b24f28 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/PeakFinder.h
@@ -9,10 +9,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: PeakFinder.h 63 2009-02-21 16:00:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp
index 49d71ab9d..2afc18750 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.cpp
@@ -10,10 +10,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-10-31 16:37:24 +0200 (Sat, 31 Oct 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: RateTransposer.cpp 74 2009-10-31 14:37:24Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -106,7 +106,7 @@ public:
// Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX/SSE/etc-capable CPU available or not.
-void * RateTransposer::operator new(size_t /*s*/)
+void * RateTransposer::operator new(size_t s)
{
throw runtime_error("Error in RateTransoser::new: don't use \"new TDStretch\" directly, use \"newInstance\" to create a new instance instead!");
return NULL;
@@ -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;
@@ -417,7 +417,7 @@ uint RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *sr
// now always (iSlopeCount > SCALE)
iSlopeCount -= SCALE;
- while (TRUE)
+ while (1)
{
while (iSlopeCount > SCALE)
{
@@ -467,7 +467,7 @@ uint RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *
// now always (iSlopeCount > SCALE)
iSlopeCount -= SCALE;
- while (TRUE)
+ while (1)
{
while (iSlopeCount > SCALE)
{
@@ -554,7 +554,7 @@ uint RateTransposerFloat::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src,
if (nSamples > 1)
{
- while (TRUE)
+ while (1)
{
while (fSlopeCount > 1.0f)
{
@@ -600,7 +600,7 @@ uint RateTransposerFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *sr
if (nSamples > 1)
{
- while (TRUE)
+ while (1)
{
while (fSlopeCount > 1.0f)
{
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.h
index f035af2c0..9cd1c6f06 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/RateTransposer.h
@@ -14,10 +14,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: RateTransposer.h 63 2009-02-21 16:00:14Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/SoundTouch.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/SoundTouch.cpp
index aa7ac0284..6f7b9a894 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/SoundTouch.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/SoundTouch.cpp
@@ -41,10 +41,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-05-19 07:57:30 +0300 (Tue, 19 May 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: SoundTouch.cpp 73 2009-05-19 04:57:30Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -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
@@ -448,7 +448,13 @@ int SoundTouch::getSetting(int settingId) const
pTDStretch->getParameters(NULL, NULL, NULL, &temp);
return temp;
- default :
+ case SETTING_NOMINAL_INPUT_SEQUENCE :
+ return pTDStretch->getInputSampleReq();
+
+ case SETTING_NOMINAL_OUTPUT_SEQUENCE :
+ return pTDStretch->getOutputBatchSize();
+
+ default :
return 0;
}
}
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp
index 6dea5f516..97109aa70 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.cpp
@@ -13,10 +13,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-12-28 21:27:04 +0200 (Mon, 28 Dec 2009) $
+// Last changed : $Date$
// File revision : $Revision: 1.12 $
//
-// $Id: TDStretch.cpp 77 2009-12-28 19:27:04Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -646,7 +646,6 @@ void TDStretch::processSamples()
// Process samples as long as there are enough samples in 'inputBuffer'
// to form a processing frame.
-// while ((int)inputBuffer.numSamples() >= sampleReq - (outDebt / 4))
while ((int)inputBuffer.numSamples() >= sampleReq)
{
// If tempo differs from the normal ('SCALE'), scan for the best overlapping
@@ -661,16 +660,8 @@ void TDStretch::processSamples()
outputBuffer.putSamples((uint)overlapLength);
// ... then copy sequence samples from 'inputBuffer' to output:
- temp = (seekLength / 2 - offset);
-
- // compensate cumulated output length diff vs. ideal output
-// temp -= outDebt / 4;
-
- // update ideal vs. true output difference
-// outDebt += temp;
// length of sequence
-// temp += (seekWindowLength - 2 * overlapLength);
temp = (seekWindowLength - 2 * overlapLength);
// crosscheck that we don't have buffer overflow...
@@ -737,7 +728,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength)
// Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX/SSE/etc-capable CPU available or not.
-void * TDStretch::operator new(size_t /*s*/)
+void * TDStretch::operator new(size_t s)
{
// Notice! don't use "new TDStretch" directly, use "newInstance" to create a new instance instead!
throw std::runtime_error("Error in TDStretch::new: Don't use 'new TDStretch' directly, use 'newInstance' member instead!");
@@ -747,43 +738,33 @@ void * TDStretch::operator new(size_t /*s*/)
TDStretch * TDStretch::newInstance()
{
-#ifndef _WIN64
- uint uExtensions;
+#ifndef _WIN64 //mpc custom code
+ uint uExtensions;
uExtensions = detectCPUextensions();
- // Check if MMX/SSE/3DNow! instruction set extensions supported by CPU
+ // 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
-
-
-#ifdef ALLOW_3DNOW
- if (uExtensions & SUPPORT_3DNOW)
- {
- // 3DNow! support
- return ::new TDStretch3DNow;
- }
- else
-#endif // ALLOW_3DNOW
+#endif // SOUNDTOUCH_ALLOW_SSE
-#endif // _WIN64
+#endif // _WIN64 mpc custom code
{
// ISA optimizations not supported, use plain C version
@@ -798,7 +779,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
@@ -849,8 +830,8 @@ void TDStretch::overlapStereo(short *poutput, const short *input) const
{
temp = (short)(overlapLength - i);
cnt2 = 2 * i;
- poutput[cnt2] = (short)((input[cnt2] * i + pMidBuffer[cnt2] * temp ) / overlapLength);
- poutput[cnt2 + 1] = (short)((input[cnt2 + 1] * i + pMidBuffer[cnt2 + 1] * temp ) / overlapLength);
+ poutput[cnt2] = (input[cnt2] * i + pMidBuffer[cnt2] * temp ) / overlapLength;
+ poutput[cnt2 + 1] = (input[cnt2 + 1] * i + pMidBuffer[cnt2 + 1] * temp ) / overlapLength;
}
}
@@ -927,14 +908,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
@@ -1045,4 +1026,4 @@ double TDStretch::calcCrossCorrStereo(const float *mixingPos, const float *compa
return corr / sqrt(norm);
}
-#endif // FLOAT_SAMPLES
+#endif // SOUNDTOUCH_FLOAT_SAMPLES
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.h
index 00d1f3e31..c236aa4e7 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/TDStretch.h
@@ -13,10 +13,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-05-17 14:35:13 +0300 (Sun, 17 May 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: TDStretch.h 71 2009-05-17 11:35:13Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -233,13 +233,25 @@ public:
uint numSamples ///< Number of samples in 'samples' so that one sample
///< contains both channels if stereo
);
+
+ /// return nominal input sample requirement for triggering a processing batch
+ int getInputSampleReq() const
+ {
+ return (int)(nominalSkip + 0.5);
+ }
+
+ /// return nominal output sample amount when running a processing batch
+ int getOutputBatchSize() const
+ {
+ return seekWindowLength - overlapLength;
+ }
};
// 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
{
@@ -248,20 +260,10 @@ public:
virtual void overlapStereo(short *output, const short *input) const;
virtual void clearCrossCorrState();
};
-#endif /// ALLOW_MMX
-
-
-#ifdef ALLOW_3DNOW
- /// Class that implements 3DNow! optimized routines for floating point samples type.
- class TDStretch3DNow : public TDStretch
- {
- protected:
- double calcCrossCorrStereo(const float *mixingPos, const float *compare) const;
- };
-#endif /// ALLOW_3DNOW
+#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
{
@@ -269,7 +271,7 @@ public:
double calcCrossCorrStereo(const float *mixingPos, const float *compare) const;
};
-#endif /// ALLOW_SSE
+#endif /// SOUNDTOUCH_ALLOW_SSE
}
#endif /// TDStretch_H
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect.h b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect.h
index 025781dae..900eb3ce0 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect.h
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect.h
@@ -12,10 +12,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: cpu_detect.h 11 2008-02-10 16:26:55Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
index c6c542467..98ff02254 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/cpu_detect_x86_win.cpp
@@ -12,10 +12,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-02-13 18:22:48 +0200 (Fri, 13 Feb 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: cpu_detect_x86_win.cpp 62 2009-02-13 16:22:48Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp
index 2740617a0..495599c9a 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/mmx_optimized.cpp
@@ -20,10 +20,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-10-31 16:53:23 +0200 (Sat, 31 Oct 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: mmx_optimized.cpp 75 2009-10-31 14:53:23Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -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__)
@@ -162,7 +162,7 @@ void TDStretchMMX::overlapStereo(short *output, const short *input) const
// mix1 = mixer values for 2nd stereo sample
// adder = adder for updating mixer values after each round
- mix1 = _mm_set_pi16(0, (short)overlapLength, 0, (short)overlapLength);
+ mix1 = _mm_set_pi16(0, overlapLength, 0, overlapLength);
adder = _mm_set_pi16(1, -1, 1, -1);
mix2 = _mm_add_pi16(mix1, adder);
adder = _mm_add_pi16(adder, adder);
@@ -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
diff --git a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/sse_optimized.cpp b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/sse_optimized.cpp
index 7659be682..a1f318b5f 100644
--- a/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/sse_optimized.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/SoundTouch/source/sse_optimized.cpp
@@ -23,10 +23,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2009-12-28 22:32:57 +0200 (Mon, 28 Dec 2009) $
+// Last changed : $Date$
// File revision : $Revision: 4 $
//
-// $Id: sse_optimized.cpp 80 2009-12-28 20:32:57Z oparviai $
+// $Id$
//
////////////////////////////////////////////////////////////////////////////////
//
@@ -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.
@@ -281,7 +281,7 @@ void FIRFilterSSE::setCoefficients(const float *coeffs, uint newLength, uint uRe
FIRFilter::setCoefficients(coeffs, newLength, uResultDivFactor);
// Scale the filter coefficients so that it won't be necessary to scale the filtering result
- // also rearrange coefficients suitably for 3DNow!
+ // also rearrange coefficients suitably for SSE
// Ensure that filter coeffs array is aligned to 16-byte boundary
delete[] filterCoeffsUnalign;
filterCoeffsUnalign = new float[2 * newLength + 4];
@@ -507,4 +507,4 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n
*/
}
-#endif // ALLOW_SSE
+#endif // SOUNDTOUCH_ALLOW_SSE