mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-13 16:15:48 +01:00
Andrew Hallendorff's multithreaded Equalization effect.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -13,18 +13,21 @@ Intrinsics (SSE/AVX) and Threaded Equalization
|
||||
#ifndef __AUDACITY_EFFECT_EQUALIZATION48X__
|
||||
#define __AUDACITY_EFFECT_EQUALIZATION48X__
|
||||
|
||||
#ifdef __AVX_ENABLED
|
||||
#define __MAXBUFFERCOUNT 8
|
||||
#else
|
||||
#define __MAXBUFFERCOUNT 4
|
||||
#endif
|
||||
|
||||
// bitwise function selection
|
||||
// options are
|
||||
// options are
|
||||
#define MATH_FUNCTION_ORIGINAL 0 // 0 original path
|
||||
#define MATH_FUNCTION_BITREVERSE_TABLE 1 // 1 SSE BitReverse Table
|
||||
#define MATH_FUNCTION_SIN_COS_TABLE 2 // 2 SSE SinCos Table
|
||||
// 3 SSE with SinCos and BitReverse buffer
|
||||
#define MATH_FUNCTION_SSE 4 // 4 SSE no SinCos and no BitReverse buffer
|
||||
#define MATH_FUNCTION_THREADED 8 // 8 SSE threaded no SinCos and no BitReverse buffer
|
||||
// 9 SSE threaded BitReverse Table
|
||||
// 10 SSE threaded SinCos Table
|
||||
// 11 SSE threaded with SinCos and BitReverse buffer
|
||||
//#define MATH_FUNCTION_AVX 16
|
||||
#define MATH_FUNCTION_THREADED 4 // 4 SSE threaded no SinCos and no BitReverse buffer
|
||||
#define MATH_FUNCTION_SSE 8 // 8 SSE no SinCos and no BitReverse buffer
|
||||
#define MATH_FUNCTION_AVX 16
|
||||
#define MATH_FUNCTION_SEGMENTED_CODE 32
|
||||
|
||||
// added by Andrew Hallendorff intrinsics processing
|
||||
enum EQBufferStatus
|
||||
@@ -35,16 +38,16 @@ enum EQBufferStatus
|
||||
BufferDone
|
||||
};
|
||||
|
||||
|
||||
class BufferInfo {
|
||||
public:
|
||||
BufferInfo() { mBufferLength=0; mBufferStatus=BufferEmpty; };
|
||||
float* mBufferSouce[4];
|
||||
float* mBufferDest[4];
|
||||
BufferInfo() { mBufferLength=0; mBufferStatus=BufferEmpty; mContiguousBufferSize=0; };
|
||||
float* mBufferSouce[__MAXBUFFERCOUNT];
|
||||
float* mBufferDest[__MAXBUFFERCOUNT];
|
||||
int mBufferLength;
|
||||
sampleCount mFftWindowSize;
|
||||
sampleCount mFftFilterSize;
|
||||
float* mScratchBuffer;
|
||||
int mContiguousBufferSize;
|
||||
EQBufferStatus mBufferStatus;
|
||||
};
|
||||
|
||||
@@ -64,20 +67,22 @@ typedef struct {
|
||||
int FMA4;
|
||||
} MathCaps;
|
||||
|
||||
|
||||
class EffectEqualization;
|
||||
|
||||
class EffectEqualization48x;
|
||||
|
||||
static int EQWorkerCounter=0;
|
||||
|
||||
class EQWorker : public wxThread {
|
||||
public:
|
||||
EQWorker():wxThread(wxTHREAD_JOINABLE) {
|
||||
EQWorker():wxThread(wxTHREAD_JOINABLE) {
|
||||
mBufferInfoList=NULL;
|
||||
mBufferInfoCount=0;
|
||||
mMutex=NULL;
|
||||
mEffectEqualization48x=NULL;
|
||||
mExitLoop=false;
|
||||
mThreadID=EQWorkerCounter++;
|
||||
mProcessingType=4;
|
||||
}
|
||||
void SetData( BufferInfo* bufferInfoList, int bufferInfoCount, wxMutex *mutex, EffectEqualization48x *effectEqualization48x) {
|
||||
mBufferInfoList=bufferInfoList;
|
||||
@@ -94,6 +99,7 @@ public:
|
||||
wxMutex *mMutex;
|
||||
EffectEqualization48x *mEffectEqualization48x;
|
||||
bool mExitLoop;
|
||||
int mProcessingType;
|
||||
};
|
||||
|
||||
class EffectEqualization48x {
|
||||
@@ -112,22 +118,37 @@ public:
|
||||
bool Process(EffectEqualization* effectEqualization);
|
||||
bool Benchmark(EffectEqualization* effectEqualization);
|
||||
private:
|
||||
bool RunFunctionSelect(int flags, int count, WaveTrack * t, sampleCount start, sampleCount len);
|
||||
bool TrackCompare();
|
||||
bool DeltaTrack(WaveTrack * t, WaveTrack * t2, sampleCount start, sampleCount len);
|
||||
bool AllocateBuffersWorkers(bool threaded);
|
||||
bool AllocateBuffersWorkers(int nThreads);
|
||||
bool FreeBuffersWorkers();
|
||||
|
||||
bool ProcessTail(WaveTrack * t, WaveTrack * output, sampleCount start, sampleCount len);
|
||||
|
||||
bool ProcessBuffer(fft_type *sourceBuffer, fft_type *destBuffer, sampleCount bufferLength);
|
||||
bool ProcessBuffer1x(BufferInfo *bufferInfo);
|
||||
bool ProcessOne1x(int count, WaveTrack * t, sampleCount start, sampleCount len);
|
||||
void Filter1x(sampleCount len, float *buffer, float *scratchBuffer);
|
||||
|
||||
bool ProcessBuffer4x(BufferInfo *bufferInfo);
|
||||
bool ProcessOne4x(int count, WaveTrack * t, sampleCount start, sampleCount len);
|
||||
bool ProcessOne4xThreaded(int count, WaveTrack * t, sampleCount start, sampleCount len);
|
||||
bool ProcessTail(WaveTrack * t, WaveTrack * output, sampleCount start, sampleCount len);
|
||||
bool ProcessOne1x4xThreaded(int count, WaveTrack * t, sampleCount start, sampleCount len, int processingType=4);
|
||||
void Filter4x(sampleCount len, float *buffer, float *scratchBuffer);
|
||||
|
||||
#ifdef __AVX_ENABLED
|
||||
bool ProcessBuffer8x(BufferInfo *bufferInfo);
|
||||
bool ProcessOne8x(int count, WaveTrack * t, sampleCount start, sampleCount len);
|
||||
bool ProcessOne8xThreaded(int count, WaveTrack * t, sampleCount start, sampleCount len);
|
||||
void Filter8x(sampleCount len, float *buffer, float *scratchBuffer);
|
||||
#endif
|
||||
|
||||
EffectEqualization* mEffectEqualization;
|
||||
int mThreadCount;
|
||||
sampleCount mFilterSize;
|
||||
sampleCount mBlockSize;
|
||||
sampleCount mWindowSize;
|
||||
int mBufferCount;
|
||||
int mWorkerDataCount;
|
||||
int mBlocksPerBuffer;
|
||||
int mScratchBufferSize;
|
||||
@@ -139,6 +160,7 @@ private:
|
||||
bool mThreaded;
|
||||
bool mBenching;
|
||||
friend EQWorker;
|
||||
friend EffectEqualization;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user