From: <man...@us...> - 2013-06-07 21:55:52
|
Revision: 2316 http://sourceforge.net/p/modplug/code/2316 Author: manxorist Date: 2013-06-07 21:55:44 +0000 (Fri, 07 Jun 2013) Log Message: ----------- [Ref] Move MixReverbBuffer into CReverb. [Ref] Simplify CReverb interface and do ReverbSend flag tracking in the new MixReverbBuffer getter function GetReverbSendBuffer(). [Ref] This removes a performance optimization in cases where all channels with have reverb flag set are also plugin or rear channels. In this case, processing reverb is not strictly needed (because reverb is not processed for plugin or rear channels). This case is really rare. Remove this optimization to gain better code readability. Modified Paths: -------------- trunk/OpenMPT/sounddsp/Reverb.cpp trunk/OpenMPT/sounddsp/Reverb.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/sounddsp/Reverb.cpp =================================================================== --- trunk/OpenMPT/sounddsp/Reverb.cpp 2013-06-07 20:34:46 UTC (rev 2315) +++ trunk/OpenMPT/sounddsp/Reverb.cpp 2013-06-07 21:55:44 UTC (rev 2316) @@ -35,12 +35,18 @@ { // Shared reverb state - gnReverbSamples = 0; - gnReverbDecaySamples = 0; - gnReverbSend = 0; + +#ifndef NO_REVERB + MemsetZero(MixReverbBuffer); +#endif gnRvbROfsVol = 0; gnRvbLOfsVol = 0; + gnReverbSend = 0; + + gnReverbSamples = 0; + gnReverbDecaySamples = 0; + // Internal reverb state g_bLastInPresent = 0; g_bLastOutPresent = 0; @@ -247,6 +253,8 @@ void CReverb::Shutdown() //---------------------- { + gnReverbSend = 0; + gnRvbLOfsVol = 0; gnRvbROfsVol = 0; @@ -396,42 +404,33 @@ } -void CReverb::ProcessPrepare(int *MixReverbBuffer, UINT nSamples) -//--------------------------------------------------------------- +int *CReverb::GetReverbSendBuffer(UINT nSamples) +//---------------------------------------------- { - gnReverbSend = 0; // no data sent yet - if(!gnReverbSamples) - { - // reverb had decayed completely, we will probably not process reverb, so no need to clear buffer - return; - } - StereoFill(MixReverbBuffer, nSamples, &gnRvbROfsVol, &gnRvbLOfsVol); -} - - -void CReverb::ProcessWillSend(int *MixReverbBuffer, UINT nSamples) -//---------------------------------------------------------------- -{ - if(!gnReverbSend && !gnReverbSamples) - { - // reverb had decayed completely before, and we did not clear the buffer yet, do it now because we get new data + if(!gnReverbSend) + { // and we did not clear the buffer yet, do it now because we will get new data StereoFill(MixReverbBuffer, nSamples, &gnRvbROfsVol, &gnRvbLOfsVol); } gnReverbSend = 1; // we will have to process reverb + return MixReverbBuffer; } // Reverb -void CReverb::Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples) -//----------------------------------------------------------------------------- +void CReverb::Process(int *MixSoundBuffer, UINT nSamples) +//------------------------------------------------------- { - UINT nIn, nOut; - + if(!(GetProcSupport() & PROCSUPPORT_MMX)) return; if((!gnReverbSend) && (!gnReverbSamples)) { // no data is sent to reverb and reverb decayed completely return; } - if (!(GetProcSupport() & PROCSUPPORT_MMX)) return; + if(!gnReverbSend) + { // no input data in MixReverbBuffer, so the buffer got not cleared in GetReverbSendBuffer(), do it now for decay + StereoFill(MixReverbBuffer, nSamples, &gnRvbROfsVol, &gnRvbLOfsVol); + } + + UINT nIn, nOut; // Dynamically adjust reverb master gains LONG lMasterGain; lMasterGain = ((g_RefDelay.lMasterGain * m_Settings.m_nReverbDepth) >> 4); @@ -494,6 +493,7 @@ Shutdown(); gnReverbSamples = 0; } + gnReverbSend = 0; // no input data in MixReverbBuffer } Modified: trunk/OpenMPT/sounddsp/Reverb.h =================================================================== --- trunk/OpenMPT/sounddsp/Reverb.h 2013-06-07 20:34:46 UTC (rev 2315) +++ trunk/OpenMPT/sounddsp/Reverb.h 2013-06-07 21:55:44 UTC (rev 2316) @@ -126,6 +126,9 @@ CReverbSettings m_Settings; // Shared reverb state +private: + int MixReverbBuffer[MIXBUFFERSIZE * 2]; +public: LONG gnRvbROfsVol; LONG gnRvbLOfsVol; @@ -157,15 +160,11 @@ public: void Initialize(BOOL bReset, DWORD MixingFreq); - // call once before calling Process - void ProcessPrepare(int *MixReverbBuffer, UINT nSamples); - - // call after ProcessPrepare and before you are putting data into MixReverbBuffer, // can be called multiple times or never (if no data is sent to reverb) - void ProcessWillSend(int *MixReverbBuffer, UINT nSamples); + int *GetReverbSendBuffer(UINT nSamples); - // call once after all data has been sent - void Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples); + // call once after all data has been sent. + void Process(int *MixSoundBuffer, UINT nSamples); // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] bool SetReverbParameters(UINT nDepth, UINT nType); Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-07 20:34:46 UTC (rev 2315) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-07 21:55:44 UTC (rev 2316) @@ -1485,10 +1485,15 @@ pbuffer = MixSoundBuffer; #ifndef NO_REVERB #ifdef ENABLE_MMX - if((m_MixerSettings.DSPMask & SNDDSP_REVERB) && (GetProcSupport() & PROCSUPPORT_MMX) && !pChannel->dwFlags[CHN_NOREVERB]) - pbuffer = MixReverbBuffer; - if(pChannel->dwFlags[CHN_REVERB] && (GetProcSupport() & PROCSUPPORT_MMX)) - pbuffer = MixReverbBuffer; + if(GetProcSupport() & PROCSUPPORT_MMX) + { + if(((m_MixerSettings.DSPMask & SNDDSP_REVERB) && !pChannel->dwFlags[CHN_NOREVERB]) || pChannel->dwFlags[CHN_REVERB]) + { + pbuffer = m_Reverb.GetReverbSendBuffer(count); + pOfsR = &m_Reverb.gnRvbROfsVol; + pOfsL = &m_Reverb.gnRvbLOfsVol; + } + } #endif #endif if(pChannel->dwFlags[CHN_SURROUND] && m_MixerSettings.gnChannels > 2) @@ -1512,15 +1517,6 @@ } } } -#ifndef NO_REVERB - if (pbuffer == MixReverbBuffer) - { - // notify reverb that there will be data in the reverb buffer to be processed - m_Reverb.ProcessWillSend(MixReverbBuffer, count); - pOfsR = &m_Reverb.gnRvbROfsVol; - pOfsL = &m_Reverb.gnRvbLOfsVol; - } -#endif nchused++; //////////////////////////////////////////////////// SampleLooping: Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-06-07 20:34:46 UTC (rev 2315) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-06-07 21:55:44 UTC (rev 2316) @@ -511,9 +511,6 @@ { MemsetZero(MixSoundBuffer); MemsetZero(MixRearBuffer); -#ifndef NO_REVERB - MemsetZero(MixReverbBuffer); -#endif MemsetZero(MixFloatBuffer); gnDryLOfsVol = 0; gnDryROfsVol = 0; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-06-07 20:34:46 UTC (rev 2315) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-06-07 21:55:44 UTC (rev 2316) @@ -288,9 +288,6 @@ // Front Mix Buffer (Also room for interleaved rear mix) int MixSoundBuffer[MIXBUFFERSIZE * 4]; int MixRearBuffer[MIXBUFFERSIZE * 2]; -#ifndef NO_REVERB - int MixReverbBuffer[MIXBUFFERSIZE * 2]; -#endif float MixFloatBuffer[MIXBUFFERSIZE * 2]; LONG gnDryLOfsVol; LONG gnDryROfsVol; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-07 20:34:46 UTC (rev 2315) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-07 21:55:44 UTC (rev 2316) @@ -290,9 +290,6 @@ // Resetting sound buffer StereoFill(MixSoundBuffer, lCount, &gnDryROfsVol, &gnDryLOfsVol); -#ifndef NO_REVERB - m_Reverb.ProcessPrepare(MixReverbBuffer, lCount); -#endif // NO_REVERB if (m_MixerSettings.gnChannels >= 2) { @@ -300,7 +297,7 @@ CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); + m_Reverb.Process(MixSoundBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -315,7 +312,7 @@ CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); + m_Reverb.Process(MixSoundBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |