mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-17 09:07:41 +02:00
Merge: Fix assertion violations in wave clip cache code.
This commit is contained in:
commit
836b3c6d6b
@ -467,11 +467,14 @@ bool WaveClip::GetWaveDisplay(float *min, float *max, float *rms,int* bl,
|
|||||||
mWaveCacheMutex.Lock();
|
mWaveCacheMutex.Lock();
|
||||||
|
|
||||||
|
|
||||||
if (mWaveCache &&
|
const bool match =
|
||||||
|
mWaveCache &&
|
||||||
mWaveCache->dirty == mDirty &&
|
mWaveCache->dirty == mDirty &&
|
||||||
|
mWaveCache->pps == pixelsPerSecond;
|
||||||
|
|
||||||
|
if (match &&
|
||||||
mWaveCache->start == t0 &&
|
mWaveCache->start == t0 &&
|
||||||
mWaveCache->len >= numPixels &&
|
mWaveCache->len >= numPixels) {
|
||||||
mWaveCache->pps == pixelsPerSecond) {
|
|
||||||
|
|
||||||
//check for invalid regions, and make the bottom if an else if.
|
//check for invalid regions, and make the bottom if an else if.
|
||||||
//invalid regions are kept in a sorted array.
|
//invalid regions are kept in a sorted array.
|
||||||
@ -534,7 +537,8 @@ bool WaveClip::GetWaveDisplay(float *min, float *max, float *rms,int* bl,
|
|||||||
sampleCount denom = 0;
|
sampleCount denom = 0;
|
||||||
int oldX0 = 0, oldXLast = 0;
|
int oldX0 = 0, oldXLast = 0;
|
||||||
double error = 0.0;
|
double error = 0.0;
|
||||||
if (oldCache->len > 0) {
|
if (match &&
|
||||||
|
oldCache->len > 0) {
|
||||||
oldWhere0 = oldCache->where[1] - samplesPerPixel;
|
oldWhere0 = oldCache->where[1] - samplesPerPixel;
|
||||||
const sampleCount oldWhereLast(floor(0.5 +
|
const sampleCount oldWhereLast(floor(0.5 +
|
||||||
oldWhere0 + oldCache->len * samplesPerPixel
|
oldWhere0 + oldCache->len * samplesPerPixel
|
||||||
@ -574,9 +578,8 @@ bool WaveClip::GetWaveDisplay(float *min, float *max, float *rms,int* bl,
|
|||||||
// Optimization: if the old cache is good and overlaps
|
// Optimization: if the old cache is good and overlaps
|
||||||
// with the current one, re-use as much of the cache as
|
// with the current one, re-use as much of the cache as
|
||||||
// possible
|
// possible
|
||||||
if (denom > 0 &&
|
if (match &&
|
||||||
oldCache->dirty == mDirty &&
|
denom > 0 &&
|
||||||
oldCache->pps == pixelsPerSecond &&
|
|
||||||
oldX0 < oldCache->len &&
|
oldX0 < oldCache->len &&
|
||||||
oldXLast > oldCache->start) {
|
oldXLast > oldCache->start) {
|
||||||
|
|
||||||
@ -791,7 +794,9 @@ bool WaveClip::GetSpectrogram(float *freq, sampleCount *where,
|
|||||||
}
|
}
|
||||||
#endif // EXPERIMENTAL_USE_REALFFTF
|
#endif // EXPERIMENTAL_USE_REALFFTF
|
||||||
|
|
||||||
if (mSpecCache &&
|
const bool match =
|
||||||
|
mSpecCache &&
|
||||||
|
mSpecCache->dirty == mDirty &&
|
||||||
mSpecCache->minFreqOld == minFreq &&
|
mSpecCache->minFreqOld == minFreq &&
|
||||||
mSpecCache->maxFreqOld == maxFreq &&
|
mSpecCache->maxFreqOld == maxFreq &&
|
||||||
mSpecCache->rangeOld == range &&
|
mSpecCache->rangeOld == range &&
|
||||||
@ -802,11 +807,12 @@ bool WaveClip::GetSpectrogram(float *freq, sampleCount *where,
|
|||||||
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
|
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
|
||||||
mSpecCache->fftSkipPointsOld == fftSkipPoints &&
|
mSpecCache->fftSkipPointsOld == fftSkipPoints &&
|
||||||
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
|
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
|
||||||
mSpecCache->dirty == mDirty &&
|
|
||||||
mSpecCache->start == t0 &&
|
|
||||||
mSpecCache->ac == autocorrelation &&
|
mSpecCache->ac == autocorrelation &&
|
||||||
mSpecCache->len >= numPixels &&
|
mSpecCache->pps == pixelsPerSecond;
|
||||||
mSpecCache->pps == pixelsPerSecond) {
|
|
||||||
|
if (match &&
|
||||||
|
mSpecCache->start == t0 &&
|
||||||
|
mSpecCache->len >= numPixels) {
|
||||||
memcpy(freq, mSpecCache->freq, numPixels*half*sizeof(float));
|
memcpy(freq, mSpecCache->freq, numPixels*half*sizeof(float));
|
||||||
memcpy(where, mSpecCache->where, (numPixels+1)*sizeof(sampleCount));
|
memcpy(where, mSpecCache->where, (numPixels+1)*sizeof(sampleCount));
|
||||||
return false; //hit cache completely
|
return false; //hit cache completely
|
||||||
@ -828,7 +834,8 @@ bool WaveClip::GetSpectrogram(float *freq, sampleCount *where,
|
|||||||
int oldX0 = 0, oldXLast = 0;
|
int oldX0 = 0, oldXLast = 0;
|
||||||
double error = 0.0;
|
double error = 0.0;
|
||||||
|
|
||||||
if (oldCache->len > 0) {
|
if (match &&
|
||||||
|
oldCache->len > 0) {
|
||||||
oldWhere0 = oldCache->where[1] - samplesPerPixel;
|
oldWhere0 = oldCache->where[1] - samplesPerPixel;
|
||||||
const sampleCount oldWhereLast(floor(0.5 +
|
const sampleCount oldWhereLast(floor(0.5 +
|
||||||
oldWhere0 + oldCache->len * samplesPerPixel
|
oldWhere0 + oldCache->len * samplesPerPixel
|
||||||
@ -865,20 +872,8 @@ bool WaveClip::GetSpectrogram(float *freq, sampleCount *where,
|
|||||||
// Optimization: if the old cache is good and overlaps
|
// Optimization: if the old cache is good and overlaps
|
||||||
// with the current one, re-use as much of the cache as
|
// with the current one, re-use as much of the cache as
|
||||||
// possible
|
// possible
|
||||||
if (denom > 0 &&
|
if (match &&
|
||||||
oldCache->dirty == mDirty &&
|
denom > 0 &&
|
||||||
oldCache->minFreqOld == minFreq &&
|
|
||||||
oldCache->maxFreqOld == maxFreq &&
|
|
||||||
oldCache->rangeOld == range &&
|
|
||||||
oldCache->gainOld == gain &&
|
|
||||||
oldCache->windowTypeOld == windowType &&
|
|
||||||
oldCache->windowSizeOld == windowSize &&
|
|
||||||
oldCache->frequencyGainOld == frequencygain &&
|
|
||||||
#ifdef EXPERIMENTAL_FFT_SKIP_POINTS
|
|
||||||
oldCache->fftSkipPointsOld == fftSkipPoints &&
|
|
||||||
#endif //EXPERIMENTAL_FFT_SKIP_POINTS
|
|
||||||
oldCache->pps == pixelsPerSecond &&
|
|
||||||
oldCache->ac == autocorrelation &&
|
|
||||||
oldX0 < oldCache->len &&
|
oldX0 < oldCache->len &&
|
||||||
oldXLast > oldCache->start) {
|
oldXLast > oldCache->start) {
|
||||||
for (sampleCount x = 0; x < mSpecCache->len; x++) {
|
for (sampleCount x = 0; x < mSpecCache->len; x++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user