From: <man...@us...> - 2013-03-16 20:17:21
|
Revision: 1577 http://sourceforge.net/p/modplug/code/1577 Author: manxorist Date: 2013-03-16 20:17:13 +0000 (Sat, 16 Mar 2013) Log Message: ----------- [Ref] Replace _muldiv and _muldivr with a straight c implementation using 64bit integers and move the new functions into misc_util.h. Rename them to Util::muldiv and Util::muldivr respectively. [Ref] Add a general ENABLE_ASM macro which, when not set, should eventually disable all uses of inline assembler. [Ref] Replace X86_InitMixBuffer() with a simple memset and add alternate C implementations for X86_InitMixBuffer() and X86_Convert32To32() and take further C implementations for X86_StereoFill() and X86_EndChannelOfs() from libmodplug. C implementations are only used when ENABLE_ASM is not set or the compiler is not MSVC. Modified Paths: -------------- trunk/OpenMPT/common/misc_util.h trunk/OpenMPT/common/stdafx.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_med.cpp trunk/OpenMPT/soundlib/Snd_dsp.cpp trunk/OpenMPT/soundlib/Snd_eq.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/misc_util.h =================================================================== --- trunk/OpenMPT/common/misc_util.h 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/common/misc_util.h 2013-03-16 20:17:13 UTC (rev 1577) @@ -370,3 +370,17 @@ } } // namespace Util::sdOs #endif // MODPLUG_TRACKER + +namespace Util { + + inline int32 muldiv(int32 a, int32 b, int32 c) + { + return static_cast<int32>( ( static_cast<int64>(a) * b ) / c ); + } + + inline int32 muldivr(int32 a, int32 b, int32 c) + { + return static_cast<int32>( ( static_cast<int64>(a) * b + ( c / 2 ) ) / c ); + } + +} // namespace Util Modified: trunk/OpenMPT/common/stdafx.h =================================================================== --- trunk/OpenMPT/common/stdafx.h 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/common/stdafx.h 2013-03-16 20:17:13 UTC (rev 1577) @@ -75,6 +75,15 @@ #define WAVE_FORMAT_EXTENSIBLE 0xFFFE #endif // !defined(WAVE_FORMAT_EXTENSIBLE) +// Use inline assembly at all +#define ENABLE_ASM + +// inline assembly requires MSVC compiler +#if defined(ENABLE_ASM) && defined(_MSC_VER) + +// Generate general x86 inline assembly. +#define ENABLE_X86 + // Generate inline assembly using MMX instructions (only used when the CPU supports it). #define ENABLE_MMX @@ -84,6 +93,8 @@ // Generate inline assembly using SSE instructions (only used when the CPU supports it). #define ENABLE_SSE +#endif // ENABLE_ASM + // Enable the built-in equalizer. #define ENABLE_EQ Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -1110,7 +1110,7 @@ if (rVu > 0x10000) rVu = 0x10000; p->dwPos[0] = lVu; p->dwPos[1] = rVu; - DWORD dwVuDecay = _muldiv(dwSamplesRead, 120000, TrackerSettings::Instance().m_dwRate) + 1; + DWORD dwVuDecay = Util::muldiv(dwSamplesRead, 120000, TrackerSettings::Instance().m_dwRate) + 1; if (lVu >= dwVuDecay) gnLVuMeter = (lVu - dwVuDecay) << 11; else gnLVuMeter = 0; if (rVu >= dwVuDecay) gnRVuMeter = (rVu - dwVuDecay) << 11; else gnRVuMeter = 0; } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -349,7 +349,7 @@ return (n >> ((LONG)m_nZoom-1)) - m_nScrollPos; } else { - return _muldiv(n, m_sizeTotal.cx, nLen); + return Util::muldiv(n, m_sizeTotal.cx, nLen); } } return 0; @@ -373,7 +373,7 @@ } else { if (x < 0) x = 0; - if (m_sizeTotal.cx) n = _muldiv(x, nLen, m_sizeTotal.cx); + if (m_sizeTotal.cx) n = Util::muldiv(x, nLen, m_sizeTotal.cx); } if (n < 0) n = 0; if (n > (LONG)nLen) n = nLen; @@ -685,7 +685,7 @@ } else { xmax = cx; - //posincr = _muldiv(len, 0x10000, cx); + //posincr = Util::muldiv(len, 0x10000, cx); posincr = uint64(len) * uint64(0x10000) / uint64(cx); } ::MoveToEx(hdc, 0, ymed, NULL); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -3497,7 +3497,7 @@ DeinterleaveInt16ToFloat(outputs[0], outputs[1], samples); } - m_DataTime += _muldiv(samples, 10000000, m_nSamplesPerSec); + m_DataTime += Util::muldiv(samples, 10000000, m_nSamplesPerSec); } Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -2023,6 +2023,7 @@ DWORD MPPASMCALL X86_Convert32To32(LPVOID lp16, int *pBuffer, DWORD lSampleCount) //------------------------------------------------------------------------------- { +#ifdef ENABLE_X86 DWORD result; _asm { mov ebx, lp16 // ebx = 32-bit buffer @@ -2054,39 +2055,26 @@ mov result, eax } return result; +#else + int32 * p = (int32*)lp16; + for ( DWORD i=0; i<lSampleCount; i++ ) { + int v = pBuffer[i]; + if ( v < MIXING_CLIPMIN ) { + v = MIXING_CLIPMIN; + } else if ( v > MIXING_CLIPMAX ) { + v = MIXING_CLIPMAX; + } + p[i] = v << MIXING_ATTENUATION; + } + return lSampleCount * 4; +#endif } void MPPASMCALL X86_InitMixBuffer(int *pBuffer, UINT nSamples) //------------------------------------------------------------ { - _asm { - mov ecx, nSamples - mov esi, pBuffer - xor eax, eax - mov edx, ecx - shr ecx, 2 - and edx, 3 - jz unroll4x -loop1x: - add esi, 4 - dec edx - mov dword ptr [esi-4], eax - jnz loop1x -unroll4x: - or ecx, ecx - jnz loop4x - jmp done -loop4x: - add esi, 16 - dec ecx - mov dword ptr [esi-16], eax - mov dword ptr [esi-12], eax - mov dword ptr [esi-8], eax - mov dword ptr [esi-4], eax - jnz loop4x -done:; - } + memset(pBuffer, 0, nSamples * sizeof(int)); } @@ -2100,7 +2088,7 @@ { static int gDitherA, gDitherB; - __asm { + _asm { mov esi, pBuffer // esi = pBuffer+i mov eax, nSamples // ebp = i mov ecx, nBits // ecx = number of bits of noise @@ -2201,6 +2189,7 @@ void MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs) //--------------------------------------------------------------------------------------- { +#ifdef ENABLE_X86 _asm { mov edi, pBuffer mov ecx, nSamples @@ -2268,12 +2257,34 @@ mov [esi], eax mov [edi], edx } +#else // c implementation taken from libmodplug + int rofs = *lpROfs; + int lofs = *lpLOfs; + + if ((!rofs) && (!lofs)) + { + X86_InitMixBuffer(pBuffer, nSamples*2); + return; + } + for (UINT i=0; i<nSamples; i++) + { + int x_r = (rofs + (((-rofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + int x_l = (lofs + (((-lofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + rofs -= x_r; + lofs -= x_l; + pBuffer[i*2] = x_r; + pBuffer[i*2+1] = x_l; + } + *lpROfs = rofs; + *lpLOfs = lofs; +#endif } void MPPASMCALL X86_EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples) //---------------------------------------------------------------------------------- { +#ifdef ENABLE_X86 _asm { mov esi, pChannel mov edi, pBuffer @@ -2310,6 +2321,23 @@ mov dword ptr [esi+ModChannel.nROfs], eax mov dword ptr [esi+ModChannel.nLOfs], edx } +#else // c implementation taken from libmodplug + int rofs = pChannel->nROfs; + int lofs = pChannel->nLOfs; + + if ((!rofs) && (!lofs)) return; + for (UINT i=0; i<nSamples; i++) + { + int x_r = (rofs + (((-rofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + int x_l = (lofs + (((-lofs)>>31) & OFSDECAYMASK)) >> OFSDECAYSHIFT; + rofs -= x_r; + lofs -= x_l; + pBuffer[i*2] += x_r; + pBuffer[i*2+1] += x_l; + } + pChannel->nROfs = rofs; + pChannel->nLOfs = lofs; +#endif } @@ -2326,7 +2354,7 @@ //------------------------------------------------------------- { UINT result; - __asm { + _asm { mov esi, pBuffer // esi = pBuffer+i mov ecx, nSamples // ecx = i mov edi, nAGC // edi = AGC (0..256) Modified: trunk/OpenMPT/soundlib/Load_med.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/soundlib/Load_med.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -320,7 +320,7 @@ // Old tempo if (!(pmsh->flags2 & MMD_FLAG2_BPM)) { - param = _muldiv(param, 5*715909, 2*474326); + param = Util::muldiv(param, 5*715909, 2*474326); } // F.0B - F.F0: Set Tempo (assumes LPB=4) if (param > 0x0A) @@ -591,7 +591,7 @@ #endif } else { - deftempo = _muldiv(deftempo, 5*715909, 2*474326); + deftempo = Util::muldiv(deftempo, 5*715909, 2*474326); #ifdef MED_LOG Log("oldtempo: %3d bpm (bpm=%3d)\n", deftempo, BigEndianW(pmsh->deftempo)); #endif Modified: trunk/OpenMPT/soundlib/Snd_dsp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_dsp.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/soundlib/Snd_dsp.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -101,7 +101,7 @@ // sin(x) - sine of x (radians) __inline float sinMPT(float x) { - __asm { + _asm { fld x fsin fstp x Modified: trunk/OpenMPT/soundlib/Snd_eq.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_eq.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/soundlib/Snd_eq.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -376,8 +376,8 @@ } else +#endif // ENABLE_MMX #endif // ENABLE_SSE -#endif // ENABLE_3DNOW #ifdef ENABLE_3DNOW Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -2774,7 +2774,7 @@ if(m_SongFlags[SONG_LINEARSLIDES] && !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))) { int oldPeriod = pChn->nPeriod; - pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideDownTable[param & 0x0F], 65536); + pChn->nPeriod = Util::muldivr(pChn->nPeriod, LinearSlideDownTable[param & 0x0F], 65536); if(oldPeriod == pChn->nPeriod) { pChn->nPeriod--; @@ -2809,7 +2809,7 @@ if (m_SongFlags[SONG_LINEARSLIDES] && !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))) { int oldPeriod = pChn->nPeriod; - pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideUpTable[param & 0x0F], 65536); + pChn->nPeriod = Util::muldivr(pChn->nPeriod, LinearSlideUpTable[param & 0x0F], 65536); if(oldPeriod == pChn->nPeriod) { pChn->nPeriod++; @@ -2844,7 +2844,7 @@ if(m_SongFlags[SONG_LINEARSLIDES] && !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))) { int oldPeriod = pChn->nPeriod; - pChn->nPeriod = _muldivr(pChn->nPeriod, FineLinearSlideDownTable[param & 0x0F], 65536); + pChn->nPeriod = Util::muldivr(pChn->nPeriod, FineLinearSlideDownTable[param & 0x0F], 65536); if(oldPeriod == pChn->nPeriod) { pChn->nPeriod--; @@ -2879,7 +2879,7 @@ if(m_SongFlags[SONG_LINEARSLIDES] && !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))) { int oldPeriod = pChn->nPeriod; - pChn->nPeriod = _muldivr(pChn->nPeriod, FineLinearSlideUpTable[param & 0x0F], 65536); + pChn->nPeriod = Util::muldivr(pChn->nPeriod, FineLinearSlideUpTable[param & 0x0F], 65536); if(oldPeriod == pChn->nPeriod) { pChn->nPeriod++; @@ -2991,7 +2991,7 @@ if (n > 255) n = 255; // Return (a*b+c/2)/c - no divide error // Table is 65536*2(n/192) - delta = _muldivr(pChn->nPeriod, LinearSlideUpTable[n], 65536) - pChn->nPeriod; + delta = Util::muldivr(pChn->nPeriod, LinearSlideUpTable[n], 65536) - pChn->nPeriod; if (delta < 1) delta = 1; } pChn->nPeriod += delta; @@ -3004,7 +3004,7 @@ { UINT n = pChn->nPortamentoSlide >> 2; if (n > 255) n = 255; - delta = _muldivr(pChn->nPeriod, LinearSlideDownTable[n], 65536) - pChn->nPeriod; + delta = Util::muldivr(pChn->nPeriod, LinearSlideDownTable[n], 65536) - pChn->nPeriod; if (delta > -1) delta = -1; } pChn->nPeriod += delta; @@ -3662,13 +3662,13 @@ { // This is "almost" how IT does it - apparently, IT seems to lag one row behind on global volume or channel volume changes. const int swing = (IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING)) ? pChn->nVolSwing : 0; - const int vol = _muldiv((pChn->nVolume + swing) * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 20); + const int vol = Util::muldiv((pChn->nVolume + swing) * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 20); data = (unsigned char)Clamp(vol / 2, 1, 127); //data = (unsigned char)min((pChn->nVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (1 + 6 + 8), 127); } else if(macro[pos] == 'u') // u: volume (calculated) { // Same note as with velocity applies here, but apparently also for instrument / sample volumes? - const int vol = _muldiv(pChn->nCalcVolume * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 26); + const int vol = Util::muldiv(pChn->nCalcVolume * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 26); data = (unsigned char)Clamp(vol / 2, 1, 127); //data = (unsigned char)min((pChn->nCalcVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (7 + 6 + 8), 127); } else if(macro[pos] == 'x') // x: pan set @@ -4205,7 +4205,7 @@ if (n) { if (n > 255) n = 255; - pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideDownTable[n], 65536); + pChn->nPeriod = Util::muldivr(pChn->nPeriod, LinearSlideDownTable[n], 65536); if (pChn->nPeriod == nOldPeriod) pChn->nPeriod = nOldPeriod-1; } } else @@ -4214,7 +4214,7 @@ if (n) { if (n > 255) n = 255; - pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideUpTable[n], 65536); + pChn->nPeriod = Util::muldivr(pChn->nPeriod, LinearSlideUpTable[n], 65536); if (pChn->nPeriod == nOldPeriod) pChn->nPeriod = nOldPeriod+1; } } @@ -4581,7 +4581,7 @@ { if (!nC5Speed) nC5Speed = 8363; //(a*b)/c - return _muldiv(8363, (FreqS3MTable[note % 12] << 5), nC5Speed << (note / 12)); + return Util::muldiv(8363, (FreqS3MTable[note % 12] << 5), nC5Speed << (note / 12)); //8363 * freq[note%12] / nC5Speed * 2^(5-note/12) } } else @@ -4648,10 +4648,10 @@ if(m_SongFlags[SONG_LINEARSLIDES]) { if (!nC5Speed) nC5Speed = 8363; - return _muldiv(nC5Speed, 1712L << 8, (period << 8)+nPeriodFrac); + return Util::muldiv(nC5Speed, 1712L << 8, (period << 8)+nPeriodFrac); } else { - return _muldiv(8363, 1712L << 8, (period << 8)+nPeriodFrac); + return Util::muldiv(8363, 1712L << 8, (period << 8)+nPeriodFrac); } } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-16 20:17:13 UTC (rev 1577) @@ -780,9 +780,6 @@ #define MOD2XMFineTune(k) ((int)( (signed char)((k)<<4) )) #define XM2MODFineTune(k) ((int)( (k>>4)&0x0f )) -int _muldiv(long a, long b, long c); -int _muldivr(long a, long b, long c); - // Read instrument property with 'code' and 'size' from 'file' to instrument 'pIns'. void ReadInstrumentExtensionField(ModInstrument* pIns, const uint32 code, const uint16 size, FileReader &file); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-16 19:45:42 UTC (rev 1576) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-16 20:17:13 UTC (rev 1577) @@ -121,96 +121,7 @@ } -// Return (a*b)/c - no divide error -int _muldiv(long a, long b, long c) -{ - int sign, result; - _asm { - mov eax, a - mov ebx, b - or eax, eax - mov edx, eax - jge aneg - neg eax -aneg: - xor edx, ebx - or ebx, ebx - mov ecx, c - jge bneg - neg ebx -bneg: - xor edx, ecx - or ecx, ecx - mov sign, edx - jge cneg - neg ecx -cneg: - mul ebx - cmp edx, ecx - jae diverr - div ecx - jmp ok -diverr: - mov eax, 0x7fffffff -ok: - mov edx, sign - or edx, edx - jge rneg - neg eax -rneg: - mov result, eax -} - return result; -} - -// Return (a*b+c/2)/c - no divide error -int _muldivr(long a, long b, long c) -{ - int sign, result; - _asm { - mov eax, a - mov ebx, b - or eax, eax - mov edx, eax - jge aneg - neg eax -aneg: - xor edx, ebx - or ebx, ebx - mov ecx, c - jge bneg - neg ebx -bneg: - xor edx, ecx - or ecx, ecx - mov sign, edx - jge cneg - neg ecx -cneg: - mul ebx - mov ebx, ecx - shr ebx, 1 - add eax, ebx - adc edx, 0 - cmp edx, ecx - jae diverr - div ecx - jmp ok -diverr: - mov eax, 0x7fffffff -ok: - mov edx, sign - or edx, edx - jge rneg - neg eax -rneg: - mov result, eax - } - return result; -} - - void CSoundFile::SetMixerSettings(const MixerSettings &mixersettings) //------------------------------------------------------------------- { @@ -265,7 +176,7 @@ BOOL CSoundFile::FadeSong(UINT msec) //---------------------------------- { - samplecount_t nsamples = _muldiv(msec, gdwMixingFreq, 1000); + samplecount_t nsamples = Util::muldiv(msec, gdwMixingFreq, 1000); if (nsamples <= 0) return FALSE; if (nsamples > 0x100000) nsamples = 0x100000; m_nBufferCount = nsamples; @@ -292,7 +203,7 @@ //---------------------------------------- { if(m_SongFlags[SONG_GLOBALFADE]) return FALSE; - m_nGlobalFadeMaxSamples = _muldiv(msec, gdwMixingFreq, 1000); + m_nGlobalFadeMaxSamples = Util::muldiv(msec, gdwMixingFreq, 1000); m_nGlobalFadeSamples = m_nGlobalFadeMaxSamples; m_SongFlags.set(SONG_GLOBALFADE); return TRUE; @@ -1249,11 +1160,11 @@ { l = -l; LimitMax(l, 255); - period = _muldiv(period, LinearSlideUpTable[l], 0x10000); + period = Util::muldiv(period, LinearSlideUpTable[l], 0x10000); } else { LimitMax(l, 255); - period = _muldiv(period, LinearSlideDownTable[l], 0x10000); + period = Util::muldiv(period, LinearSlideDownTable[l], 0x10000); } } //End: Original behavior. } @@ -1641,12 +1552,12 @@ if (l < 0) { l = -l; - vdelta = _muldiv(period, LinearSlideDownTable[l >> 2], 0x10000) - period; - if (l & 0x03) vdelta += _muldiv(period, FineLinearSlideDownTable[l & 0x03], 0x10000) - period; + vdelta = Util::muldiv(period, LinearSlideDownTable[l >> 2], 0x10000) - period; + if (l & 0x03) vdelta += Util::muldiv(period, FineLinearSlideDownTable[l & 0x03], 0x10000) - period; } else { - vdelta = _muldiv(period, LinearSlideUpTable[l >> 2], 0x10000) - period; - if (l & 0x03) vdelta += _muldiv(period, FineLinearSlideUpTable[l & 0x03], 0x10000) - period; + vdelta = Util::muldiv(period, LinearSlideUpTable[l >> 2], 0x10000) - period; + if (l & 0x03) vdelta += Util::muldiv(period, FineLinearSlideUpTable[l & 0x03], 0x10000) - period; } } period += vdelta; @@ -1743,17 +1654,17 @@ int l = abs(vdelta); if(vdelta < 0) { - vdelta = _muldiv(period, LinearSlideDownTable[l >> 2], 0x10000) - period; + vdelta = Util::muldiv(period, LinearSlideDownTable[l >> 2], 0x10000) - period; if (l & 0x03) { - vdelta += _muldiv(period, FineLinearSlideDownTable[l & 0x03], 0x10000) - period; + vdelta += Util::muldiv(period, FineLinearSlideDownTable[l & 0x03], 0x10000) - period; } } else { - vdelta = _muldiv(period, LinearSlideUpTable[l >> 2], 0x10000) - period; + vdelta = Util::muldiv(period, LinearSlideUpTable[l >> 2], 0x10000) - period; if (l & 0x03) { - vdelta += _muldiv(period, FineLinearSlideUpTable[l & 0x03], 0x10000) - period; + vdelta += Util::muldiv(period, FineLinearSlideUpTable[l & 0x03], 0x10000) - period; } } period -= vdelta; @@ -1837,7 +1748,7 @@ df2 = LinearSlideDownTable[n1+1]; } n >>= 2; - period = _muldiv(period, df1 + ((df2 - df1) * (n & 0x3F) >> 6), 256); + period = Util::muldiv(period, df1 + ((df2 - df1) * (n & 0x3F) >> 6), 256); nPeriodFrac = period & 0xFF; period >>= 8; } else @@ -1968,7 +1879,7 @@ if(m_SongFlags[SONG_GLOBALFADE] && m_nGlobalFadeMaxSamples != 0) { - mastervol = _muldiv(mastervol, m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples); + mastervol = Util::muldiv(mastervol, m_nGlobalFadeSamples, m_nGlobalFadeMaxSamples); } if (m_pConfig->getUseGlobalPreAmp()) @@ -2075,7 +1986,7 @@ if (vol) { // IMPORTANT: pChn->nRealVolume is 14 bits !!! - // -> _muldiv( 14+8, 6+6, 18); => RealVolume: 14-bit result (22+12-20) + // -> Util::muldiv( 14+8, 6+6, 18); => RealVolume: 14-bit result (22+12-20) if(pChn->dwFlags[CHN_SYNCMUTE]) { @@ -2084,10 +1995,10 @@ { // Don't let global volume affect level of sample if // Global volume is going to be applied to master output anyway. - pChn->nRealVolume = _muldiv(vol * MAX_GLOBAL_VOLUME, pChn->nGlobalVol * insVol, 1 << 20); + pChn->nRealVolume = Util::muldiv(vol * MAX_GLOBAL_VOLUME, pChn->nGlobalVol * insVol, 1 << 20); } else { - pChn->nRealVolume = _muldiv(vol * m_nGlobalVolume, pChn->nGlobalVol * insVol, 1 << 20); + pChn->nRealVolume = Util::muldiv(vol * m_nGlobalVolume, pChn->nGlobalVol * insVol, 1 << 20); } } @@ -2185,7 +2096,7 @@ // Applying Pitch/Tempo lock. if(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT) && pIns && pIns->wPitchToTempoLock) { - freq = _muldivr(freq, m_nMusicTempo, pIns->wPitchToTempoLock); + freq = Util::muldivr(freq, m_nMusicTempo, pIns->wPitchToTempoLock); } if ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (freq < 256)) @@ -2196,7 +2107,7 @@ pChn->nCalcVolume = 0; } - UINT ninc = _muldiv(freq, 0x10000, gdwMixingFreq); + UINT ninc = Util::muldiv(freq, 0x10000, gdwMixingFreq); if ((ninc >= 0xFFB0) && (ninc <= 0x10090)) ninc = 0x10000; if (m_nFreqFactor != 128) ninc = (ninc * m_nFreqFactor) >> 7; if (ninc > 0xFF0000) ninc = 0xFF0000; @@ -2608,11 +2519,11 @@ { // Ramping required m_lHighResRampingGlobalVolume += step; - *sample = _muldiv(*sample, m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION); + *sample = Util::muldiv(*sample, m_lHighResRampingGlobalVolume, MAX_GLOBAL_VOLUME << VOLUMERAMPPRECISION); m_nSamplesToGlobalVolRampDest--; } else { - *sample = _muldiv(*sample, m_nGlobalVolume, MAX_GLOBAL_VOLUME); + *sample = Util::muldiv(*sample, m_nGlobalVolume, MAX_GLOBAL_VOLUME); m_lHighResRampingGlobalVolume = m_nGlobalVolume << VOLUMERAMPPRECISION; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |