Fixed pointer aligning for mingw64 compilation

This commit is contained in:
oparviai 2012-11-08 18:53:01 +00:00
parent 91305a5806
commit c3f4ff9532
6 changed files with 39 additions and 16 deletions

View File

@ -712,13 +712,23 @@ switch "-bpm" </li>
<p>Kudos for these people who have contributed to development or <p>Kudos for these people who have contributed to development or
submitted bugfixes since SoundTouch v1.3.1: </p> submitted bugfixes since SoundTouch v1.3.1: </p>
<ul> <ul>
<li> Arthur A </li> <li> Arthur A</li>
<li> Richard Ash </li> <li> Richard Ash</li>
<li> Stanislav Brabec </li> <li> Stanislav Brabec</li>
<li> Christian Budde </li> <li> Christian Budde</li>
<li> Brian Cameron </li> <li> Jacek Caban</li>
<li> Jason Champion </li> <li> Brian Cameron</li>
<li> Jason Champion</li>
<li> David Clark</li> <li> David Clark</li>
<li> Patrick Colis</li>
<li> Miquel Colon</li>
<li> Justin Frankel</li>
<li> Jason Garland</li>
<li> Takashi Iwai</li>
<li> Yuval Naveh</li>
<li> Paulo Pizarro</li>
<li> Blaise Potard</li>
<li> RJ Ryan</li>
<li> Patrick Colis </li> <li> Patrick Colis </li>
<li> Miquel Colon </li> <li> Miquel Colon </li>
<li> Sandro Cumerlato</li> <li> Sandro Cumerlato</li>
@ -732,6 +742,8 @@ submitted bugfixes since SoundTouch v1.3.1: </p>
<li> RJ Ryan </li> <li> RJ Ryan </li>
<li> John Sheehy</li> <li> John Sheehy</li>
<li> Tim Shuttleworth</li> <li> Tim Shuttleworth</li>
<li> John Stumpo</li>
<li> Tim Shuttleworth</li>
<li> Katja Vetter</li> <li> Katja Vetter</li>
</ul> </ul>
<p>Moral greetings to all other contributors and users also!</p> <p>Moral greetings to all other contributors and users also!</p>
@ -750,9 +762,8 @@ General Public License for more details.</p>
License along with this library; if not, write to the Free Software License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</p>
<hr><!-- <hr><!--
$Id$ $Id$ -->
-->
<p> <p>
<i>README.html file updated on 29-Sep-2012</i></p> <i>README.html file updated on 8-Nov-2012</i></p>
</body> </body>
</html> </html>

View File

@ -42,6 +42,18 @@
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned long ulong; typedef unsigned long ulong;
// Patch for MinGW: on Win64 long is 32-bit
#ifdef _WIN64
typedef unsigned long long ulongptr;
#else
typedef ulong ulongptr;
#endif
// Helper macro for aligning pointer up to next 16-byte boundary
#define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
#ifdef __GNUC__ #ifdef __GNUC__
// In GCC, include soundtouch_config.h made by config scritps // In GCC, include soundtouch_config.h made by config scritps
#include "soundtouch_config.h" #include "soundtouch_config.h"

View File

@ -177,7 +177,7 @@ void FIFOSampleBuffer::ensureCapacity(uint capacityRequirement)
ST_THROW_RT_ERROR("Couldn't allocate memory!\n"); ST_THROW_RT_ERROR("Couldn't allocate memory!\n");
} }
// Align the buffer to begin at 16byte cache line boundary for optimal performance // Align the buffer to begin at 16byte cache line boundary for optimal performance
temp = (SAMPLETYPE *)(((ulong)tempUnaligned + 15) & (ulong)-16); temp = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(tempUnaligned);
if (samplesInBuffer) if (samplesInBuffer)
{ {
memcpy(temp, ptrBegin(), samplesInBuffer * channels * sizeof(SAMPLETYPE)); memcpy(temp, ptrBegin(), samplesInBuffer * channels * sizeof(SAMPLETYPE));

View File

@ -590,7 +590,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength)
pMidBufferUnaligned = new SAMPLETYPE[overlapLength * 2 + 16 / sizeof(SAMPLETYPE)]; pMidBufferUnaligned = new SAMPLETYPE[overlapLength * 2 + 16 / sizeof(SAMPLETYPE)];
// ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency // ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency
pMidBuffer = (SAMPLETYPE *)((((ulong)pMidBufferUnaligned) + 15) & (ulong)-16); pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned);
clearMidBuffer(); clearMidBuffer();
} }

View File

@ -239,7 +239,7 @@ void FIRFilterMMX::setCoefficients(const short *coeffs, uint newLength, uint uRe
// Ensure that filter coeffs array is aligned to 16-byte boundary // Ensure that filter coeffs array is aligned to 16-byte boundary
delete[] filterCoeffsUnalign; delete[] filterCoeffsUnalign;
filterCoeffsUnalign = new short[2 * newLength + 8]; filterCoeffsUnalign = new short[2 * newLength + 8];
filterCoeffsAlign = (short *)(((ulong)filterCoeffsUnalign + 15) & -16); filterCoeffsAlign = (short *)SOUNDTOUCH_ALIGN_POINTER_16(filterCoeffsUnalign);
// rearrange the filter coefficients for mmx routines // rearrange the filter coefficients for mmx routines
for (i = 0;i < length; i += 4) for (i = 0;i < length; i += 4)

View File

@ -93,7 +93,7 @@ double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2) const
#define _MM_LOAD _mm_load_ps #define _MM_LOAD _mm_load_ps
if (((ulong)pV1) & 15) return -1e50; // skip unaligned locations if (((ulongptr)pV1) & 15) return -1e50; // skip unaligned locations
#else #else
// No cheating allowed, use unaligned load & take the resulting // No cheating allowed, use unaligned load & take the resulting
@ -218,7 +218,7 @@ void FIRFilterSSE::setCoefficients(const float *coeffs, uint newLength, uint uRe
// Ensure that filter coeffs array is aligned to 16-byte boundary // Ensure that filter coeffs array is aligned to 16-byte boundary
delete[] filterCoeffsUnalign; delete[] filterCoeffsUnalign;
filterCoeffsUnalign = new float[2 * newLength + 4]; filterCoeffsUnalign = new float[2 * newLength + 4];
filterCoeffsAlign = (float *)(((unsigned long)filterCoeffsUnalign + 15) & (ulong)-16); filterCoeffsAlign = (float *)SOUNDTOUCH_ALIGN_POINTER_16(filterCoeffsUnalign);
fDivider = (float)resultDivider; fDivider = (float)resultDivider;
@ -246,7 +246,7 @@ uint FIRFilterSSE::evaluateFilterStereo(float *dest, const float *source, uint n
assert(dest != NULL); assert(dest != NULL);
assert((length % 8) == 0); assert((length % 8) == 0);
assert(filterCoeffsAlign != NULL); assert(filterCoeffsAlign != NULL);
assert(((ulong)filterCoeffsAlign) % 16 == 0); assert(((ulongptr)filterCoeffsAlign) % 16 == 0);
// filter is evaluated for two stereo samples with each iteration, thus use of 'j += 2' // filter is evaluated for two stereo samples with each iteration, thus use of 'j += 2'
for (j = 0; j < count; j += 2) for (j = 0; j < count; j += 2)