diff options
author | John Glover <glover.john@gmail.com> | 2010-12-09 22:19:17 +0000 |
---|---|---|
committer | John Glover <glover.john@gmail.com> | 2010-12-09 22:19:17 +0000 |
commit | 5ca314e5ccf3dfb98fdea9d37646baca66d75ec3 (patch) | |
tree | 40de39619d48a3cca458254d081d97222dac6dd7 /sms/analysis.c | |
parent | b27a8f7182edb2f9e15fd60e78d54fb9fd0c5472 (diff) | |
download | simpl-5ca314e5ccf3dfb98fdea9d37646baca66d75ec3.tar.gz simpl-5ca314e5ccf3dfb98fdea9d37646baca66d75ec3.tar.bz2 simpl-5ca314e5ccf3dfb98fdea9d37646baca66d75ec3.zip |
Fixed bug in SMS peak detection - find_peaks was leaking memory wen saving peaks, and a pointer assignment in find_peaks could lead to a double free in freeAnalysis/freeSpectralPeaks.
Diffstat (limited to 'sms/analysis.c')
-rw-r--r-- | sms/analysis.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sms/analysis.c b/sms/analysis.c index 90bec7f..ec4e0fe 100644 --- a/sms/analysis.c +++ b/sms/analysis.c @@ -156,11 +156,6 @@ int sms_findPeaks(int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalPara /* initialize the current frame */ sms_initFrame(iCurrentFrame, pAnalParams, pAnalParams->windowSize); - if(sms_errorCheck()) - { - printf("Error in init frame: %s \n", sms_errorString()); - return 0; - } if(pAnalParams->ppFrames[iCurrentFrame]->iStatus == SMS_FRAME_READY) { @@ -196,14 +191,17 @@ int sms_findPeaks(int sizeWaveform, sfloat *pWaveform, SMS_AnalParams *pAnalPara /* save peaks */ pSpectralPeaks->nPeaksFound = pAnalParams->ppFrames[iCurrentFrame]->nPeaks; pSpectralPeaks->nPeaks = pAnalParams->maxPeaks; - pSpectralPeaks->pSpectralPeaks = pAnalParams->ppFrames[iCurrentFrame]->pSpectralPeaks; - /* convert peak amps to linear */ for(i = 0; i < pSpectralPeaks->nPeaks; i++) { if(i < pSpectralPeaks->nPeaksFound) { - pSpectralPeaks->pSpectralPeaks[i].fMag = pow(10.0, 0.05*(pSpectralPeaks->pSpectralPeaks[i].fMag)); + pSpectralPeaks->pSpectralPeaks[i].fMag = + pow(10.0, 0.05*(pAnalParams->ppFrames[iCurrentFrame]->pSpectralPeaks[i].fMag)); + pSpectralPeaks->pSpectralPeaks[i].fFreq = + pAnalParams->ppFrames[iCurrentFrame]->pSpectralPeaks[i].fFreq; + pSpectralPeaks->pSpectralPeaks[i].fPhase = + pAnalParams->ppFrames[iCurrentFrame]->pSpectralPeaks[i].fPhase; } else { |