From 24fc79bfb297d24b091e6950f9277edfe9e88c84 Mon Sep 17 00:00:00 2001 From: Underground78 Date: Wed, 10 Aug 2011 21:56:33 +0000 Subject: Update SoundTouch to v1.6.1pre r130 (vanilla except that MMX is disabled for x64 to fix compilation). Patch by XhmikosR. git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@3642 10f7b99b-c216-0410-bff0-8a66a9350fd8 --- docs/Changelog.txt | 1 + src/thirdparty/SoundTouch/include/STTypes.h | 67 +++++++++++------- src/thirdparty/SoundTouch/include/SoundTouch.h | 4 +- src/thirdparty/SoundTouch/source/BPMDetect.cpp | 40 ++++++++++- src/thirdparty/SoundTouch/source/FIRFilter.cpp | 5 +- .../SoundTouch/source/RateTransposer.cpp | 2 +- .../SoundTouch/source/SoundTouch.vcxproj | 15 ++-- src/thirdparty/SoundTouch/source/TDStretch.cpp | 5 +- .../SoundTouch/source/cpu_detect_x86_win.cpp | 16 +++-- src/thirdparty/SoundTouch/source/mmx_optimized.cpp | 4 -- src/thirdparty/SoundTouch/source/sse_optimized.cpp | 82 ---------------------- 11 files changed, 102 insertions(+), 139 deletions(-) diff --git a/docs/Changelog.txt b/docs/Changelog.txt index 69e520bfc..f6e6be5bf 100644 --- a/docs/Changelog.txt +++ b/docs/Changelog.txt @@ -20,6 +20,7 @@ NEW : Ticket #1627, Ope the file's directory from the clip properties CHANGED: Updated Chinese (simplified and traditional), Czech, Dutch, French, German, Japanese, Polish, Russian, Slovakian, Ukrainian translations CHANGED: Updated libogg to v1.3.0 +CHANGED: Updated SoundTouch to v1.6.1pre r130 FIXED : Ticket #311, High dpi awareness FIXED : Ticket #970, "Always load external subtitles" fails if the subtitles filename contains LANG postfix diff --git a/src/thirdparty/SoundTouch/include/STTypes.h b/src/thirdparty/SoundTouch/include/STTypes.h index 98186a552..9c19d65c5 100644 --- a/src/thirdparty/SoundTouch/include/STTypes.h +++ b/src/thirdparty/SoundTouch/include/STTypes.h @@ -60,34 +60,36 @@ typedef unsigned long ulong; namespace soundtouch { + /// Activate these undef's to overrule the possible sampletype + /// setting inherited from some other header file: + //#undef SOUNDTOUCH_INTEGER_SAMPLES + //#undef SOUNDTOUCH_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 + /// has already been done in some other file. + //// + /// Notes: + /// - In Windows environment, choose the sample format with the + /// following defines. + /// - In GNU environment, the floating point samples are used by + /// default, but integer samples can be chosen by giving the + /// following switch to the configure script: + /// ./configure --enable-integer-samples + /// 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. + + // mpc-hc patch: define SOUNDTOUCH_INTEGER_SAMPLES + // the default is SOUNDTOUCH_FLOAT_SAMPLES + #define SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples + //#define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples + + #endif -/// Activate these undef's to overrule the possible sampletype -/// setting inherited from some other header file: -//#undef SOUNDTOUCH_INTEGER_SAMPLES -//#undef SOUNDTOUCH_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 - /// has already been done in some other file. - //// - /// Notes: - /// - In Windows environment, choose the sample format with the - /// following defines. - /// - In GNU environment, the floating point samples are used by - /// default, but integer samples can be chosen by giving the - /// following switch to the configure script: - /// ./configure --enable-integer-samples - /// 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 SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples - #define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples - - #endif - - #ifndef _WIN64 //mpc custom code + #ifndef _WIN64 // MPC-HC custom code: disable MMX for x64 /// 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 @@ -96,6 +98,17 @@ namespace soundtouch #define SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS 1 + /// In GNU environment, allow the user to override this setting by + /// giving the following switch to the configure script: + /// ./configure --disable-x86-optimizations + /// ./configure --enable-x86-optimizations=no + #ifdef SOUNDTOUCH_DISABLE_X86_OPTIMIZATIONS + #undef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS + #endif + #else + /// Always disable optimizations when not using a x86 systems. + #undef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS + #endif // If defined, allows the SIMD-optimized routines to take minor shortcuts diff --git a/src/thirdparty/SoundTouch/include/SoundTouch.h b/src/thirdparty/SoundTouch/include/SoundTouch.h index 203d84fc4..164de19f5 100644 --- a/src/thirdparty/SoundTouch/include/SoundTouch.h +++ b/src/thirdparty/SoundTouch/include/SoundTouch.h @@ -79,10 +79,10 @@ namespace soundtouch { /// Soundtouch library version string -#define SOUNDTOUCH_VERSION "1.5.1pre" +#define SOUNDTOUCH_VERSION "1.6.1pre" /// SoundTouch library version id -#define SOUNDTOUCH_VERSION_ID (10509) +#define SOUNDTOUCH_VERSION_ID (10601) // // Available setting IDs for the 'setSetting' & 'get_setting' functions: diff --git a/src/thirdparty/SoundTouch/source/BPMDetect.cpp b/src/thirdparty/SoundTouch/source/BPMDetect.cpp index 4faa29409..8b3d1c601 100644 --- a/src/thirdparty/SoundTouch/source/BPMDetect.cpp +++ b/src/thirdparty/SoundTouch/source/BPMDetect.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include "FIFOSampleBuffer.h" #include "PeakFinder.h" #include "BPMDetect.h" @@ -74,6 +75,37 @@ const float avgdecay = 0.99986f; const float avgnorm = (1 - avgdecay); +//////////////////////////////////////////////////////////////////////////////// + +// Enable following define to create bpm analysis file: + +// #define _CREATE_BPM_DEBUG_FILE + +#ifdef _CREATE_BPM_DEBUG_FILE + + #define DEBUGFILE_NAME "c:\\temp\\soundtouch-bpm-debug.txt" + + static void _SaveDebugData(const float *data, int minpos, int maxpos, double coeff) + { + FILE *fptr = fopen(DEBUGFILE_NAME, "wt"); + int i; + + if (fptr) + { + printf("\n\nWriting BPM debug data into file " DEBUGFILE_NAME "\n\n"); + for (i = minpos; i < maxpos; i ++) + { + fprintf(fptr, "%d\t%.1lf\t%f\n", i, coeff / (double)i, data[i]); + } + fclose(fptr); + } + } +#else + #define _SaveDebugData(a,b,c,d) +#endif + +//////////////////////////////////////////////////////////////////////////////// + BPMDetect::BPMDetect(int numChannels, int aSampleRate) { @@ -326,8 +358,14 @@ void BPMDetect::inputSamples(const SAMPLETYPE *samples, int numSamples) float BPMDetect::getBpm() { double peakPos; + double coeff; PeakFinder peakFinder; + coeff = 60.0 * ((double)sampleRate / (double)decimateBy); + + // save bpm debug analysis data if debug data enabled + _SaveDebugData(xcorr, windowStart, windowLen, coeff); + // find peak position peakPos = peakFinder.detectPeak(xcorr, windowStart, windowLen); @@ -335,5 +373,5 @@ float BPMDetect::getBpm() if (peakPos < 1e-9) return 0.0; // detection failed. // calculate BPM - return (float)(60.0 * (((double)sampleRate / (double)decimateBy) / peakPos)); + return (float) (coeff / peakPos); } diff --git a/src/thirdparty/SoundTouch/source/FIRFilter.cpp b/src/thirdparty/SoundTouch/source/FIRFilter.cpp index 50c4f62ee..a2745625c 100644 --- a/src/thirdparty/SoundTouch/source/FIRFilter.cpp +++ b/src/thirdparty/SoundTouch/source/FIRFilter.cpp @@ -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,7 +229,6 @@ void * FIRFilter::operator new(size_t /*s*/) FIRFilter * FIRFilter::newInstance() { -#ifndef _WIN64 //mpc custom code uint uExtensions; uExtensions = detectCPUextensions(); @@ -254,8 +253,6 @@ FIRFilter * FIRFilter::newInstance() else #endif // SOUNDTOUCH_ALLOW_SSE -#endif // _WIN64 mpc custom code - { // ISA optimizations not supported, use plain C version return ::new FIRFilter; diff --git a/src/thirdparty/SoundTouch/source/RateTransposer.cpp b/src/thirdparty/SoundTouch/source/RateTransposer.cpp index c288fddb9..2afc18750 100644 --- a/src/thirdparty/SoundTouch/source/RateTransposer.cpp +++ b/src/thirdparty/SoundTouch/source/RateTransposer.cpp @@ -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; diff --git a/src/thirdparty/SoundTouch/source/SoundTouch.vcxproj b/src/thirdparty/SoundTouch/source/SoundTouch.vcxproj index db844b8c3..342ce1b88 100644 --- a/src/thirdparty/SoundTouch/source/SoundTouch.vcxproj +++ b/src/thirdparty/SoundTouch/source/SoundTouch.vcxproj @@ -70,7 +70,7 @@ ..\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;SOUNDTOUCH_INTEGER_SAMPLES;%(PreprocessorDefinitions) + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) NotUsing TurnOffAllWarnings @@ -81,7 +81,7 @@ ..\include;%(AdditionalIncludeDirectories) - _WIN64;NDEBUG;_LIB;SOUNDTOUCH_INTEGER_SAMPLES;%(PreprocessorDefinitions) + _WIN64;NDEBUG;_LIB;%(PreprocessorDefinitions) NotUsing TurnOffAllWarnings @@ -92,7 +92,7 @@ ..\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;SOUNDTOUCH_INTEGER_SAMPLES;%(PreprocessorDefinitions) + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) NotUsing TurnOffAllWarnings @@ -103,7 +103,7 @@ ..\include;%(AdditionalIncludeDirectories) - _WIN64;_DEBUG;_LIB;SOUNDTOUCH_INTEGER_SAMPLES;%(PreprocessorDefinitions) + _WIN64;_DEBUG;_LIB;%(PreprocessorDefinitions) ProgramDatabase NotUsing TurnOffAllWarnings @@ -128,12 +128,7 @@ - - true - true - true - true - + diff --git a/src/thirdparty/SoundTouch/source/TDStretch.cpp b/src/thirdparty/SoundTouch/source/TDStretch.cpp index dd7a43eb5..3ef7798a8 100644 --- a/src/thirdparty/SoundTouch/source/TDStretch.cpp +++ b/src/thirdparty/SoundTouch/source/TDStretch.cpp @@ -728,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!"); @@ -738,7 +738,6 @@ void * TDStretch::operator new(size_t /*s*/) TDStretch * TDStretch::newInstance() { -#ifndef _WIN64 //mpc custom code uint uExtensions; uExtensions = detectCPUextensions(); @@ -764,8 +763,6 @@ TDStretch * TDStretch::newInstance() else #endif // SOUNDTOUCH_ALLOW_SSE -#endif // _WIN64 mpc custom code - { // ISA optimizations not supported, use plain C version return ::new TDStretch; diff --git a/src/thirdparty/SoundTouch/source/cpu_detect_x86_win.cpp b/src/thirdparty/SoundTouch/source/cpu_detect_x86_win.cpp index 98ff02254..44e0520d6 100644 --- a/src/thirdparty/SoundTouch/source/cpu_detect_x86_win.cpp +++ b/src/thirdparty/SoundTouch/source/cpu_detect_x86_win.cpp @@ -42,9 +42,7 @@ #include "cpu_detect.h" -#ifndef WIN32 -#error wrong platform - this source code file is exclusively for Win32 platform -#endif +#include "STTypes.h" ////////////////////////////////////////////////////////////////////////////// // @@ -71,7 +69,9 @@ uint detectCPUextensions(void) if (_dwDisabledISA == 0xffffffff) return 0; - _asm +#ifndef _M_X64 + // 32bit compilation, detect CPU capabilities with inline assembler. + __asm { ; check if 'cpuid' instructions is available by toggling eflags bit 21 ; @@ -125,5 +125,13 @@ uint detectCPUextensions(void) mov res, esi } +#else + + // Visual C++ 64bit compilation doesn't support inline assembler. However, + // all x64 compatible CPUs support MMX & SSE extensions. + res = SUPPORT_MMX | SUPPORT_SSE | SUPPORT_SSE2; + +#endif + return res & ~_dwDisabledISA; } diff --git a/src/thirdparty/SoundTouch/source/mmx_optimized.cpp b/src/thirdparty/SoundTouch/source/mmx_optimized.cpp index 495599c9a..feeab49a6 100644 --- a/src/thirdparty/SoundTouch/source/mmx_optimized.cpp +++ b/src/thirdparty/SoundTouch/source/mmx_optimized.cpp @@ -53,10 +53,6 @@ #ifdef SOUNDTOUCH_ALLOW_MMX // MMX routines available only with integer sample type -#if !(WIN32 || __i386__ || __x86_64__) -#error "wrong platform - this source code file is exclusively for x86 platforms" -#endif - using namespace soundtouch; ////////////////////////////////////////////////////////////////////////////// diff --git a/src/thirdparty/SoundTouch/source/sse_optimized.cpp b/src/thirdparty/SoundTouch/source/sse_optimized.cpp index a1f318b5f..d989ad5aa 100644 --- a/src/thirdparty/SoundTouch/source/sse_optimized.cpp +++ b/src/thirdparty/SoundTouch/source/sse_optimized.cpp @@ -423,88 +423,6 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n dest += 4; } */ - - - /* Similar routine in assembly, again obsoleted due to maintainability - _asm - { - // Very important note: data in 'src' _must_ be aligned to - // 16-byte boundary! - mov edx, count - mov ebx, dword ptr src - mov eax, dword ptr dest - shr edx, 1 - - loop1: - // "outer loop" : during each round 2*2 output samples are calculated - - // give prefetch hints to CPU of what data are to be needed soonish - prefetcht0 [ebx] - prefetcht0 [filterCoeffsLocal] - - mov esi, ebx - mov edi, filterCoeffsLocal - xorps xmm0, xmm0 - xorps xmm1, xmm1 - mov ecx, lengthLocal - - loop2: - // "inner loop" : during each round eight FIR filter taps are evaluated for 2*2 samples - prefetcht0 [esi + 32] // give a prefetch hint to CPU what data are to be needed soonish - prefetcht0 [edi + 32] // give a prefetch hint to CPU what data are to be needed soonish - - movups xmm2, [esi] // possibly unaligned load - movups xmm3, [esi + 8] // possibly unaligned load - mulps xmm2, [edi] - mulps xmm3, [edi] - addps xmm0, xmm2 - addps xmm1, xmm3 - - movups xmm4, [esi + 16] // possibly unaligned load - movups xmm5, [esi + 24] // possibly unaligned load - mulps xmm4, [edi + 16] - mulps xmm5, [edi + 16] - addps xmm0, xmm4 - addps xmm1, xmm5 - - prefetcht0 [esi + 64] // give a prefetch hint to CPU what data are to be needed soonish - prefetcht0 [edi + 64] // give a prefetch hint to CPU what data are to be needed soonish - - movups xmm6, [esi + 32] // possibly unaligned load - movups xmm7, [esi + 40] // possibly unaligned load - mulps xmm6, [edi + 32] - mulps xmm7, [edi + 32] - addps xmm0, xmm6 - addps xmm1, xmm7 - - movups xmm4, [esi + 48] // possibly unaligned load - movups xmm5, [esi + 56] // possibly unaligned load - mulps xmm4, [edi + 48] - mulps xmm5, [edi + 48] - addps xmm0, xmm4 - addps xmm1, xmm5 - - add esi, 64 - add edi, 64 - dec ecx - jnz loop2 - - // Now xmm0 and xmm1 both have a filtered 2-channel sample each, but we still need - // to sum the two hi- and lo-floats of these registers together. - - movhlps xmm2, xmm0 // xmm2 = xmm2_3 xmm2_2 xmm0_3 xmm0_2 - movlhps xmm2, xmm1 // xmm2 = xmm1_1 xmm1_0 xmm0_3 xmm0_2 - shufps xmm0, xmm1, 0xe4 // xmm0 = xmm1_3 xmm1_2 xmm0_1 xmm0_0 - addps xmm0, xmm2 - - movaps [eax], xmm0 - add ebx, 16 - add eax, 16 - - dec edx - jnz loop1 - } - */ } #endif // SOUNDTOUCH_ALLOW_SSE -- cgit v1.2.3