| 886 | } |
| 887 | |
| 888 | bool EffectEqualization48x::ProcessOne1x4xThreaded(int count, WaveTrack * t, |
| 889 | sampleCount start, sampleCount len, int processingType) |
| 890 | { |
| 891 | int subBufferSize=mBufferCount==8?(mSubBufferSize>>1):mSubBufferSize; // half the buffers if avx is active |
| 892 | |
| 893 | sampleCount blockCount=len/mBlockSize; |
| 894 | |
| 895 | if(blockCount<16) // it's not worth 4x processing do a regular process |
| 896 | return ProcessOne4x(count, t, start, len); |
| 897 | if(mThreadCount<=0 || blockCount<256) // don't do it without cores or big data |
| 898 | return ProcessOne4x(count, t, start, len); |
| 899 | |
| 900 | for(int i=0;i<mThreadCount;i++) |
| 901 | mEQWorkers[i].mProcessingType=processingType; |
| 902 | |
| 903 | auto output = t->EmptyCopy(); |
| 904 | t->ConvertToSampleFormat( floatSample ); |
| 905 | |
| 906 | auto trackBlockSize = t->GetMaxBlockSize(); |
| 907 | mEffectEqualization->TrackProgress(count, 0.0); |
| 908 | auto bigRuns = len/(subBufferSize-mBlockSize); |
| 909 | int trackBlocksPerBig=subBufferSize/trackBlockSize; |
| 910 | int trackLeftovers=subBufferSize-trackBlocksPerBig*trackBlockSize; |
| 911 | size_t singleProcessLength = |
| 912 | ((mFilterSize>>1)*bigRuns + len%(bigRuns*(subBufferSize-mBlockSize))) |
| 913 | .as_size_t(); |
| 914 | auto currentSample=start; |
| 915 | |
| 916 | int bigBlocksRead=mWorkerDataCount, bigBlocksWritten=0; |
| 917 | |
| 918 | // fill the first workerDataCount buffers we checked above and there is at least this data |
| 919 | auto maxPreFill = bigRuns < mWorkerDataCount ? bigRuns : mWorkerDataCount; |
| 920 | for(int i=0;i<maxPreFill;i++) |
| 921 | { |
| 922 | // fill the buffer |
| 923 | for(int j=0;j<trackBlocksPerBig;j++) { |
| 924 | t->Get((samplePtr)&mBufferInfo[i].mBufferSouce[0][j*trackBlockSize], floatSample, currentSample, trackBlockSize); |
| 925 | currentSample+=trackBlockSize; |
| 926 | } |
| 927 | if(trackLeftovers) { |
| 928 | t->Get((samplePtr)&mBufferInfo[i].mBufferSouce[0][trackBlocksPerBig*trackBlockSize], floatSample, currentSample, trackLeftovers); |
| 929 | currentSample+=trackLeftovers; |
| 930 | } |
| 931 | currentSample-=mBlockSize+(mFilterSize>>1); |
| 932 | mBufferInfo[i].mBufferStatus=BufferReady; // free for grabbin |
| 933 | } |
| 934 | int currentIndex=0; |
| 935 | bool bBreakLoop = false; |
| 936 | while(bigBlocksWritten<bigRuns && !bBreakLoop) { |
| 937 | bBreakLoop=mEffectEqualization->TrackProgress(count, (double)(bigBlocksWritten)/bigRuns.as_double()); |
| 938 | if( bBreakLoop ) |
| 939 | break; |
| 940 | wxMutexLocker locker( mDataMutex ); // Get in line for data |
| 941 | // process as many blocks as we can |
| 942 | while((mBufferInfo[currentIndex].mBufferStatus==BufferDone) && (bigBlocksWritten<bigRuns)) { // data is ours |
| 943 | output->Append((samplePtr)&mBufferInfo[currentIndex].mBufferDest[0][(bigBlocksWritten?mBlockSize:0)+(mFilterSize>>1)], floatSample, subBufferSize-((bigBlocksWritten?mBlockSize:0)+(mFilterSize>>1))); |
| 944 | bigBlocksWritten++; |
| 945 | if(bigBlocksRead<bigRuns) { |
nothing calls this directly
no test coverage detected