mirror of
https://github.com/azahar-emu/soundtouch
synced 2025-11-07 07:30:02 +01:00
Eliminated alloca() call that caused compatibility woes
This commit is contained in:
parent
bfc89b45a9
commit
126d1ac41d
@ -61,12 +61,15 @@ FIRFilter::FIRFilter()
|
|||||||
length = 0;
|
length = 0;
|
||||||
lengthDiv8 = 0;
|
lengthDiv8 = 0;
|
||||||
filterCoeffs = NULL;
|
filterCoeffs = NULL;
|
||||||
|
sum = NULL;
|
||||||
|
sumsize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FIRFilter::~FIRFilter()
|
FIRFilter::~FIRFilter()
|
||||||
{
|
{
|
||||||
delete[] filterCoeffs;
|
delete[] filterCoeffs;
|
||||||
|
delete[] sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Usual C-version of the filter routine for stereo sound
|
// Usual C-version of the filter routine for stereo sound
|
||||||
@ -167,10 +170,18 @@ uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const
|
uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels)
|
||||||
{
|
{
|
||||||
uint i, j, end, c;
|
uint i, j, end, c;
|
||||||
LONG_SAMPLETYPE *sum=(LONG_SAMPLETYPE*)alloca(numChannels*sizeof(*sum));
|
|
||||||
|
if (sumsize < numChannels)
|
||||||
|
{
|
||||||
|
// allocate large enough array for keeping sums
|
||||||
|
sumsize = numChannels;
|
||||||
|
delete[] sum;
|
||||||
|
sum = new LONG_SAMPLETYPE[numChannels];
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
// when using floating point samples, use a scaler instead of a divider
|
// when using floating point samples, use a scaler instead of a divider
|
||||||
// because division is much slower operation than multiplying.
|
// because division is much slower operation than multiplying.
|
||||||
@ -253,7 +264,7 @@ uint FIRFilter::getLength() const
|
|||||||
//
|
//
|
||||||
// Note : The amount of outputted samples is by value of 'filter_length'
|
// Note : The amount of outputted samples is by value of 'filter_length'
|
||||||
// smaller than the amount of input samples.
|
// smaller than the amount of input samples.
|
||||||
uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const
|
uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels)
|
||||||
{
|
{
|
||||||
assert(length > 0);
|
assert(length > 0);
|
||||||
assert(lengthDiv8 * 8 == length);
|
assert(lengthDiv8 * 8 == length);
|
||||||
|
|||||||
@ -65,13 +65,17 @@ protected:
|
|||||||
// Memory for filter coefficients
|
// Memory for filter coefficients
|
||||||
SAMPLETYPE *filterCoeffs;
|
SAMPLETYPE *filterCoeffs;
|
||||||
|
|
||||||
|
// Memory for keeping temporary sums in multichannel processing
|
||||||
|
LONG_SAMPLETYPE *sum;
|
||||||
|
uint sumsize;
|
||||||
|
|
||||||
virtual uint evaluateFilterStereo(SAMPLETYPE *dest,
|
virtual uint evaluateFilterStereo(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples) const;
|
uint numSamples) const;
|
||||||
virtual uint evaluateFilterMono(SAMPLETYPE *dest,
|
virtual uint evaluateFilterMono(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples) const;
|
uint numSamples) const;
|
||||||
virtual uint evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const;
|
virtual uint evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FIRFilter();
|
FIRFilter();
|
||||||
@ -91,7 +95,7 @@ public:
|
|||||||
uint evaluate(SAMPLETYPE *dest,
|
uint evaluate(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples,
|
uint numSamples,
|
||||||
uint numChannels) const;
|
uint numChannels);
|
||||||
|
|
||||||
uint getLength() const;
|
uint getLength() const;
|
||||||
|
|
||||||
|
|||||||
@ -348,8 +348,8 @@ void SoundTouch::flush()
|
|||||||
int i;
|
int i;
|
||||||
int nUnprocessed;
|
int nUnprocessed;
|
||||||
int nOut;
|
int nOut;
|
||||||
SAMPLETYPE *buff=(SAMPLETYPE*)alloca(64*channels*sizeof(SAMPLETYPE));
|
SAMPLETYPE *buff = new SAMPLETYPE[64 * channels];
|
||||||
|
|
||||||
// check how many samples still await processing, and scale
|
// check how many samples still await processing, and scale
|
||||||
// that by tempo & rate to get expected output sample count
|
// that by tempo & rate to get expected output sample count
|
||||||
nUnprocessed = numUnprocessedSamples();
|
nUnprocessed = numUnprocessedSamples();
|
||||||
@ -378,6 +378,8 @@ void SoundTouch::flush()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete[] buff;
|
||||||
|
|
||||||
// Clear working buffers
|
// Clear working buffers
|
||||||
pRateTransposer->clear();
|
pRateTransposer->clear();
|
||||||
pTDStretch->clearInput();
|
pTDStretch->clearInput();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user